blob: fa74acdd271ff399a9cb8438ea8aadcce370536b [file] [log] [blame]
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001/*
Ivo van Doorn7e613e12010-08-06 20:45:38 +02002 Copyright (C) 2010 Willow Garage <http://www.willowgarage.com>
3 Copyright (C) 2004 - 2010 Ivo van Doorn <IvDoorn@gmail.com>
Ivo van Doorn95ea3622007-09-25 17:57:13 -07004 <http://rt2x00.serialmonkey.com>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the
18 Free Software Foundation, Inc.,
19 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22/*
23 Module: rt2x00lib
24 Abstract: rt2x00 generic device routines.
25 */
26
Ivo van Doorn95ea3622007-09-25 17:57:13 -070027#include <linux/kernel.h>
28#include <linux/module.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090029#include <linux/slab.h>
Ivo van Doorn95ea3622007-09-25 17:57:13 -070030
31#include "rt2x00.h"
32#include "rt2x00lib.h"
33
34/*
Ivo van Doorn95ea3622007-09-25 17:57:13 -070035 * Radio control handlers.
36 */
37int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev)
38{
39 int status;
40
41 /*
42 * Don't enable the radio twice.
43 * And check if the hardware button has been disabled.
44 */
Ivo van Doorn4b9631a2009-07-11 18:00:19 +020045 if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
Ivo van Doorn95ea3622007-09-25 17:57:13 -070046 return 0;
47
48 /*
Ivo van Doorn181d6902008-02-05 16:42:23 -050049 * Initialize all data queues.
Ivo van Doorn837e7f22008-01-06 23:41:45 +010050 */
Ivo van Doorn798b7ad2008-11-08 15:25:33 +010051 rt2x00queue_init_queues(rt2x00dev);
Ivo van Doorn837e7f22008-01-06 23:41:45 +010052
53 /*
Ivo van Doorn95ea3622007-09-25 17:57:13 -070054 * Enable radio.
55 */
Ivo van Doorna2e1d522008-03-31 15:53:44 +020056 status =
57 rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_ON);
Ivo van Doorn95ea3622007-09-25 17:57:13 -070058 if (status)
59 return status;
60
Ivo van Doorn2b08da32008-06-03 18:58:56 +020061 rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_IRQ_ON);
62
Ivo van Doorna2e1d522008-03-31 15:53:44 +020063 rt2x00leds_led_radio(rt2x00dev, true);
Ivo van Doorn61c2b682008-04-21 19:01:09 +020064 rt2x00led_led_activity(rt2x00dev, true);
Ivo van Doorna2e1d522008-03-31 15:53:44 +020065
Ivo van Doorn0262ab02008-08-29 21:04:26 +020066 set_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags);
Ivo van Doorn95ea3622007-09-25 17:57:13 -070067
68 /*
Ivo van Doorn0b7fde52010-12-13 12:35:17 +010069 * Enable queues.
Ivo van Doorn95ea3622007-09-25 17:57:13 -070070 */
Ivo van Doorn0b7fde52010-12-13 12:35:17 +010071 rt2x00queue_start_queues(rt2x00dev);
Ivo van Doornea175ee2010-11-06 15:48:43 +010072 rt2x00link_start_tuner(rt2x00dev);
Ivo van Doorn95ea3622007-09-25 17:57:13 -070073
74 /*
Ivo van Doornc965c742010-07-11 12:25:46 +020075 * Start watchdog monitoring.
76 */
77 rt2x00link_start_watchdog(rt2x00dev);
78
Ivo van Doorn95ea3622007-09-25 17:57:13 -070079 return 0;
80}
81
82void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev)
83{
Ivo van Doorn0262ab02008-08-29 21:04:26 +020084 if (!test_and_clear_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
Ivo van Doorn95ea3622007-09-25 17:57:13 -070085 return;
86
87 /*
Ivo van Doornc965c742010-07-11 12:25:46 +020088 * Stop watchdog monitoring.
89 */
90 rt2x00link_stop_watchdog(rt2x00dev);
91
92 /*
Ivo van Doorn0b7fde52010-12-13 12:35:17 +010093 * Stop all queues
Ivo van Doorn95ea3622007-09-25 17:57:13 -070094 */
Ivo van Doornea175ee2010-11-06 15:48:43 +010095 rt2x00link_stop_tuner(rt2x00dev);
Ivo van Doorn0b7fde52010-12-13 12:35:17 +010096 rt2x00queue_stop_queues(rt2x00dev);
Ivo van Doorn5be65602010-12-13 12:35:40 +010097 rt2x00queue_flush_queues(rt2x00dev, true);
Ivo van Doorn95ea3622007-09-25 17:57:13 -070098
99 /*
100 * Disable radio.
101 */
102 rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_OFF);
Ivo van Doorn2b08da32008-06-03 18:58:56 +0200103 rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_IRQ_OFF);
Ivo van Doorn61c2b682008-04-21 19:01:09 +0200104 rt2x00led_led_activity(rt2x00dev, false);
Ivo van Doorna2e1d522008-03-31 15:53:44 +0200105 rt2x00leds_led_radio(rt2x00dev, false);
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700106}
107
Ivo van Doorn6bb40dd2008-02-03 15:49:59 +0100108static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac,
109 struct ieee80211_vif *vif)
Ivo van Doorn5c58ee52007-10-06 13:34:52 +0200110{
Ivo van Doorn6bb40dd2008-02-03 15:49:59 +0100111 struct rt2x00_dev *rt2x00dev = data;
112 struct rt2x00_intf *intf = vif_to_intf(vif);
Ivo van Doorn6bb40dd2008-02-03 15:49:59 +0100113 int delayed_flags;
Johannes Berg471b3ef2007-12-28 14:32:58 +0100114
115 /*
Ivo van Doorn6bb40dd2008-02-03 15:49:59 +0100116 * Copy all data we need during this action under the protection
117 * of a spinlock. Otherwise race conditions might occur which results
118 * into an invalid configuration.
Johannes Berg471b3ef2007-12-28 14:32:58 +0100119 */
Ivo van Doorn6bb40dd2008-02-03 15:49:59 +0100120 spin_lock(&intf->lock);
121
Ivo van Doorn6bb40dd2008-02-03 15:49:59 +0100122 delayed_flags = intf->delayed_flags;
123 intf->delayed_flags = 0;
124
125 spin_unlock(&intf->lock);
126
Ivo van Doorn980dfcb2008-06-25 21:27:00 +0200127 /*
128 * It is possible the radio was disabled while the work had been
129 * scheduled. If that happens we should return here immediately,
130 * note that in the spinlock protected area above the delayed_flags
131 * have been cleared correctly.
132 */
Ivo van Doorn0262ab02008-08-29 21:04:26 +0200133 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
Ivo van Doorn980dfcb2008-06-25 21:27:00 +0200134 return;
135
Ivo van Doornbd88a782008-07-09 15:12:44 +0200136 if (delayed_flags & DELAYED_UPDATE_BEACON)
Ivo van Doorna2c9b652009-01-28 00:32:33 +0100137 rt2x00queue_update_beacon(rt2x00dev, vif, true);
Ivo van Doorn6bb40dd2008-02-03 15:49:59 +0100138}
139
140static void rt2x00lib_intf_scheduled(struct work_struct *work)
141{
142 struct rt2x00_dev *rt2x00dev =
143 container_of(work, struct rt2x00_dev, intf_work);
144
145 /*
146 * Iterate over each interface and perform the
147 * requested configurations.
148 */
149 ieee80211_iterate_active_interfaces(rt2x00dev->hw,
150 rt2x00lib_intf_scheduled_iter,
151 rt2x00dev);
Ivo van Doorn5c58ee52007-10-06 13:34:52 +0200152}
153
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700154/*
155 * Interrupt context handlers.
156 */
Helmut Schaa07896fe2010-07-11 12:27:58 +0200157static void rt2x00lib_bc_buffer_iter(void *data, u8 *mac,
158 struct ieee80211_vif *vif)
159{
160 struct rt2x00_dev *rt2x00dev = data;
161 struct sk_buff *skb;
162
163 /*
164 * Only AP mode interfaces do broad- and multicast buffering
165 */
166 if (vif->type != NL80211_IFTYPE_AP)
167 return;
168
169 /*
170 * Send out buffered broad- and multicast frames
171 */
172 skb = ieee80211_get_buffered_bc(rt2x00dev->hw, vif);
173 while (skb) {
174 rt2x00mac_tx(rt2x00dev->hw, skb);
175 skb = ieee80211_get_buffered_bc(rt2x00dev->hw, vif);
176 }
177}
178
Helmut Schaa9f926fb2010-07-11 12:28:23 +0200179static void rt2x00lib_beaconupdate_iter(void *data, u8 *mac,
180 struct ieee80211_vif *vif)
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700181{
Helmut Schaa4dee32f2010-07-11 12:27:26 +0200182 struct rt2x00_dev *rt2x00dev = data;
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700183
Johannes Berg05c914f2008-09-11 00:01:58 +0200184 if (vif->type != NL80211_IFTYPE_AP &&
Andrey Yurovskya07dbea2008-12-20 10:55:34 +0100185 vif->type != NL80211_IFTYPE_ADHOC &&
Ivo van Doornce292a62008-12-20 10:57:02 +0100186 vif->type != NL80211_IFTYPE_MESH_POINT &&
187 vif->type != NL80211_IFTYPE_WDS)
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700188 return;
189
Helmut Schaa4dee32f2010-07-11 12:27:26 +0200190 rt2x00queue_update_beacon(rt2x00dev, vif, true);
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700191}
192
193void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev)
194{
Ivo van Doorn0262ab02008-08-29 21:04:26 +0200195 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700196 return;
197
Helmut Schaa07896fe2010-07-11 12:27:58 +0200198 /* send buffered bc/mc frames out for every bssid */
Helmut Schaa4dee32f2010-07-11 12:27:26 +0200199 ieee80211_iterate_active_interfaces(rt2x00dev->hw,
Helmut Schaa07896fe2010-07-11 12:27:58 +0200200 rt2x00lib_bc_buffer_iter,
201 rt2x00dev);
Helmut Schaa9f926fb2010-07-11 12:28:23 +0200202 /*
203 * Devices with pre tbtt interrupt don't need to update the beacon
204 * here as they will fetch the next beacon directly prior to
205 * transmission.
206 */
207 if (test_bit(DRIVER_SUPPORT_PRE_TBTT_INTERRUPT, &rt2x00dev->flags))
208 return;
Helmut Schaa07896fe2010-07-11 12:27:58 +0200209
210 /* fetch next beacon */
211 ieee80211_iterate_active_interfaces(rt2x00dev->hw,
Helmut Schaa9f926fb2010-07-11 12:28:23 +0200212 rt2x00lib_beaconupdate_iter,
Helmut Schaa07896fe2010-07-11 12:27:58 +0200213 rt2x00dev);
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700214}
215EXPORT_SYMBOL_GPL(rt2x00lib_beacondone);
216
Helmut Schaa9f926fb2010-07-11 12:28:23 +0200217void rt2x00lib_pretbtt(struct rt2x00_dev *rt2x00dev)
218{
219 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
220 return;
221
222 /* fetch next beacon */
223 ieee80211_iterate_active_interfaces(rt2x00dev->hw,
224 rt2x00lib_beaconupdate_iter,
225 rt2x00dev);
226}
227EXPORT_SYMBOL_GPL(rt2x00lib_pretbtt);
228
Ivo van Doorn64e7d722010-12-13 12:36:00 +0100229void rt2x00lib_dmastart(struct queue_entry *entry)
230{
231 set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags);
232 rt2x00queue_index_inc(entry->queue, Q_INDEX);
233}
234EXPORT_SYMBOL_GPL(rt2x00lib_dmastart);
235
Ivo van Doorn652a9dd2010-08-30 21:15:19 +0200236void rt2x00lib_dmadone(struct queue_entry *entry)
237{
Ivo van Doorndba5dc12010-12-13 12:36:18 +0100238 set_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags);
Ivo van Doorna13c8f32010-10-11 15:39:48 +0200239 clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags);
Ivo van Doorn652a9dd2010-08-30 21:15:19 +0200240 rt2x00queue_index_inc(entry->queue, Q_INDEX_DMA_DONE);
241}
242EXPORT_SYMBOL_GPL(rt2x00lib_dmadone);
243
Ivo van Doorn181d6902008-02-05 16:42:23 -0500244void rt2x00lib_txdone(struct queue_entry *entry,
245 struct txdone_entry_desc *txdesc)
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700246{
Ivo van Doorn181d6902008-02-05 16:42:23 -0500247 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
Johannes Berge039fa42008-05-15 12:55:29 +0200248 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb);
Johannes Berge6a98542008-10-21 12:40:02 +0200249 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
RA-Jay Hungf8eaec62010-11-13 19:12:54 +0100250 unsigned int header_length, i;
Benoit PAPILLAULT92ed48e2009-08-17 18:56:10 +0200251 u8 rate_idx, rate_flags, retry_rates;
Johannes Berg7351c6b2009-11-19 01:08:30 +0100252 u8 skbdesc_flags = skbdesc->flags;
Ivo van Doorn2e27cff2009-08-29 19:10:14 +0200253 bool success;
Ivo van Doornd74f5ba2008-06-16 19:56:54 +0200254
255 /*
Gertjan van Wingerdee513a0b2010-06-29 21:41:40 +0200256 * Unmap the skb.
257 */
Ivo van Doornfa695602010-10-11 15:37:25 +0200258 rt2x00queue_unmap_skb(entry);
Gertjan van Wingerdee513a0b2010-06-29 21:41:40 +0200259
260 /*
261 * Remove the extra tx headroom from the skb.
262 */
263 skb_pull(entry->skb, rt2x00dev->ops->extra_tx_headroom);
264
265 /*
266 * Signal that the TX descriptor is no longer in the skb.
267 */
268 skbdesc->flags &= ~SKBDESC_DESC_IN_SKB;
269
270 /*
RA-Jay Hungf8eaec62010-11-13 19:12:54 +0100271 * Determine the length of 802.11 header.
272 */
273 header_length = ieee80211_get_hdrlen_from_skb(entry->skb);
274
275 /*
Ivo van Doorn9f166172009-04-26 16:08:50 +0200276 * Remove L2 padding which was added during
277 */
278 if (test_bit(DRIVER_REQUIRE_L2PAD, &rt2x00dev->flags))
Ivo van Doorndaee6c02009-08-29 20:30:45 +0200279 rt2x00queue_remove_l2pad(entry->skb, header_length);
Ivo van Doorn9f166172009-04-26 16:08:50 +0200280
281 /*
Ivo van Doorn2bb057d2008-08-04 16:37:44 +0200282 * If the IV/EIV data was stripped from the frame before it was
283 * passed to the hardware, we should now reinsert it again because
Walter Goldens77c20612010-05-18 04:44:54 -0700284 * mac80211 will expect the same data to be present it the
Ivo van Doorn2bb057d2008-08-04 16:37:44 +0200285 * frame as it was passed to us.
286 */
287 if (test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags))
Ivo van Doorn9f166172009-04-26 16:08:50 +0200288 rt2x00crypto_tx_insert_iv(entry->skb, header_length);
Ivo van Doorn2bb057d2008-08-04 16:37:44 +0200289
290 /*
Johannes Berge039fa42008-05-15 12:55:29 +0200291 * Send frame to debugfs immediately, after this call is completed
292 * we are going to overwrite the skb->cb array.
293 */
294 rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_TXDONE, entry->skb);
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700295
296 /*
Ivo van Doorn2e27cff2009-08-29 19:10:14 +0200297 * Determine if the frame has been successfully transmitted.
298 */
299 success =
300 test_bit(TXDONE_SUCCESS, &txdesc->flags) ||
Helmut Schaafd6dcb82010-06-14 22:09:09 +0200301 test_bit(TXDONE_UNKNOWN, &txdesc->flags);
Ivo van Doorn2e27cff2009-08-29 19:10:14 +0200302
303 /*
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700304 * Update TX statistics.
305 */
Ivo van Doorn2e27cff2009-08-29 19:10:14 +0200306 rt2x00dev->link.qual.tx_success += success;
307 rt2x00dev->link.qual.tx_failed += !success;
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700308
Johannes Berge6a98542008-10-21 12:40:02 +0200309 rate_idx = skbdesc->tx_rate_idx;
310 rate_flags = skbdesc->tx_rate_flags;
Benoit PAPILLAULT92ed48e2009-08-17 18:56:10 +0200311 retry_rates = test_bit(TXDONE_FALLBACK, &txdesc->flags) ?
312 (txdesc->retry + 1) : 1;
Johannes Berge6a98542008-10-21 12:40:02 +0200313
Ivo van Doorn181d6902008-02-05 16:42:23 -0500314 /*
315 * Initialize TX status
316 */
Johannes Berge039fa42008-05-15 12:55:29 +0200317 memset(&tx_info->status, 0, sizeof(tx_info->status));
318 tx_info->status.ack_signal = 0;
Benoit PAPILLAULT92ed48e2009-08-17 18:56:10 +0200319
320 /*
321 * Frame was send with retries, hardware tried
322 * different rates to send out the frame, at each
Helmut Schaa3d2bc102010-06-14 22:12:26 +0200323 * retry it lowered the rate 1 step except when the
324 * lowest rate was used.
Benoit PAPILLAULT92ed48e2009-08-17 18:56:10 +0200325 */
326 for (i = 0; i < retry_rates && i < IEEE80211_TX_MAX_RATES; i++) {
327 tx_info->status.rates[i].idx = rate_idx - i;
328 tx_info->status.rates[i].flags = rate_flags;
Helmut Schaa3d2bc102010-06-14 22:12:26 +0200329
330 if (rate_idx - i == 0) {
331 /*
332 * The lowest rate (index 0) was used until the
333 * number of max retries was reached.
334 */
335 tx_info->status.rates[i].count = retry_rates - i;
336 i++;
337 break;
338 }
Benoit PAPILLAULT92ed48e2009-08-17 18:56:10 +0200339 tx_info->status.rates[i].count = 1;
340 }
Ivo van Doorn2e27cff2009-08-29 19:10:14 +0200341 if (i < (IEEE80211_TX_MAX_RATES - 1))
Benoit PAPILLAULT92ed48e2009-08-17 18:56:10 +0200342 tx_info->status.rates[i].idx = -1; /* terminate */
Ivo van Doorn181d6902008-02-05 16:42:23 -0500343
Johannes Berge039fa42008-05-15 12:55:29 +0200344 if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK)) {
Ivo van Doorn2e27cff2009-08-29 19:10:14 +0200345 if (success)
Johannes Berge039fa42008-05-15 12:55:29 +0200346 tx_info->flags |= IEEE80211_TX_STAT_ACK;
Ivo van Doorn2e27cff2009-08-29 19:10:14 +0200347 else
Ivo van Doorn181d6902008-02-05 16:42:23 -0500348 rt2x00dev->low_level_stats.dot11ACKFailureCount++;
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700349 }
350
Helmut Schaa1df90802010-06-29 21:38:12 +0200351 /*
352 * Every single frame has it's own tx status, hence report
353 * every frame as ampdu of size 1.
354 *
355 * TODO: if we can find out how many frames were aggregated
356 * by the hw we could provide the real ampdu_len to mac80211
357 * which would allow the rc algorithm to better decide on
358 * which rates are suitable.
359 */
360 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
361 tx_info->flags |= IEEE80211_TX_STAT_AMPDU;
362 tx_info->status.ampdu_len = 1;
363 tx_info->status.ampdu_ack_len = success ? 1 : 0;
364 }
365
Johannes Berge6a98542008-10-21 12:40:02 +0200366 if (rate_flags & IEEE80211_TX_RC_USE_RTS_CTS) {
Ivo van Doorn2e27cff2009-08-29 19:10:14 +0200367 if (success)
Ivo van Doorn181d6902008-02-05 16:42:23 -0500368 rt2x00dev->low_level_stats.dot11RTSSuccessCount++;
Ivo van Doorn2e27cff2009-08-29 19:10:14 +0200369 else
Ivo van Doorn181d6902008-02-05 16:42:23 -0500370 rt2x00dev->low_level_stats.dot11RTSFailureCount++;
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700371 }
372
373 /*
Johannes Berg7351c6b2009-11-19 01:08:30 +0100374 * Only send the status report to mac80211 when it's a frame
375 * that originated in mac80211. If this was a extra frame coming
376 * through a mac80211 library call (RTS/CTS) then we should not
377 * send the status report back.
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700378 */
Johannes Stezenbach20ed3162010-11-30 16:49:23 +0100379 if (!(skbdesc_flags & SKBDESC_NOT_MAC80211)) {
380 if (test_bit(DRIVER_REQUIRE_TASKLET_CONTEXT, &rt2x00dev->flags))
381 ieee80211_tx_status(rt2x00dev->hw, entry->skb);
382 else
383 ieee80211_tx_status_ni(rt2x00dev->hw, entry->skb);
384 } else
Helmut Schaa78e256c2010-07-11 12:26:48 +0200385 dev_kfree_skb_any(entry->skb);
Ivo van Doornd74f5ba2008-06-16 19:56:54 +0200386
387 /*
388 * Make this entry available for reuse.
389 */
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700390 entry->skb = NULL;
Ivo van Doornd74f5ba2008-06-16 19:56:54 +0200391 entry->flags = 0;
392
Ivo van Doorn798b7ad2008-11-08 15:25:33 +0100393 rt2x00dev->ops->lib->clear_entry(entry);
Ivo van Doornd74f5ba2008-06-16 19:56:54 +0200394
Ivo van Doornd74f5ba2008-06-16 19:56:54 +0200395 rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE);
396
397 /*
398 * If the data queue was below the threshold before the txdone
399 * handler we must make sure the packet queue in the mac80211 stack
400 * is reenabled when the txdone handler has finished.
401 */
402 if (!rt2x00queue_threshold(entry->queue))
Ivo van Doorn0b7fde52010-12-13 12:35:17 +0100403 rt2x00queue_unpause_queue(entry->queue);
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700404}
405EXPORT_SYMBOL_GPL(rt2x00lib_txdone);
406
Ivo van Doorn3392bec2010-08-06 20:46:53 +0200407void rt2x00lib_txdone_noinfo(struct queue_entry *entry, u32 status)
408{
409 struct txdone_entry_desc txdesc;
410
411 txdesc.flags = 0;
412 __set_bit(status, &txdesc.flags);
413 txdesc.retry = 0;
414
415 rt2x00lib_txdone(entry, &txdesc);
416}
417EXPORT_SYMBOL_GPL(rt2x00lib_txdone_noinfo);
418
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200419static int rt2x00lib_rxdone_read_signal(struct rt2x00_dev *rt2x00dev,
420 struct rxdone_entry_desc *rxdesc)
421{
422 struct ieee80211_supported_band *sband;
423 const struct rt2x00_rate *rate;
424 unsigned int i;
Ivo van Doorn3590eea2010-10-11 15:38:07 +0200425 int signal = rxdesc->signal;
426 int type = (rxdesc->dev_flags & RXDONE_SIGNAL_MASK);
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200427
Ivo van Doorn3590eea2010-10-11 15:38:07 +0200428 switch (rxdesc->rate_mode) {
429 case RATE_MODE_CCK:
430 case RATE_MODE_OFDM:
431 /*
432 * For non-HT rates the MCS value needs to contain the
433 * actually used rate modulation (CCK or OFDM).
434 */
435 if (rxdesc->dev_flags & RXDONE_SIGNAL_MCS)
436 signal = RATE_MCS(rxdesc->rate_mode, signal);
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200437
Ivo van Doorn3590eea2010-10-11 15:38:07 +0200438 sband = &rt2x00dev->bands[rt2x00dev->curr_band];
439 for (i = 0; i < sband->n_bitrates; i++) {
440 rate = rt2x00_get_rate(sband->bitrates[i].hw_value);
441 if (((type == RXDONE_SIGNAL_PLCP) &&
442 (rate->plcp == signal)) ||
443 ((type == RXDONE_SIGNAL_BITRATE) &&
444 (rate->bitrate == signal)) ||
445 ((type == RXDONE_SIGNAL_MCS) &&
446 (rate->mcs == signal))) {
447 return i;
448 }
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200449 }
Ivo van Doorn3590eea2010-10-11 15:38:07 +0200450 break;
451 case RATE_MODE_HT_MIX:
452 case RATE_MODE_HT_GREENFIELD:
453 if (signal >= 0 && signal <= 76)
454 return signal;
455 break;
456 default:
457 break;
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200458 }
459
460 WARNING(rt2x00dev, "Frame received with unrecognized signal, "
Ivo van Doorn3590eea2010-10-11 15:38:07 +0200461 "mode=0x%.4x, signal=0x%.4x, type=%d.\n",
462 rxdesc->rate_mode, signal, type);
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200463 return 0;
464}
465
Ivo van Doornfa695602010-10-11 15:37:25 +0200466void rt2x00lib_rxdone(struct queue_entry *entry)
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700467{
Ivo van Doornfa695602010-10-11 15:37:25 +0200468 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
Gertjan van Wingerdec4da0042008-06-16 19:56:31 +0200469 struct rxdone_entry_desc rxdesc;
470 struct sk_buff *skb;
Ivo van Doorne5ef5ba2010-08-06 20:49:27 +0200471 struct ieee80211_rx_status *rx_status;
Ivo van Doorn2bb057d2008-08-04 16:37:44 +0200472 unsigned int header_length;
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200473 int rate_idx;
Ivo van Doorn7e613e12010-08-06 20:45:38 +0200474
Ivo van Doorn070192d2010-11-04 20:41:05 +0100475 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) ||
476 !test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
477 goto submit_entry;
478
Ivo van Doorn7e613e12010-08-06 20:45:38 +0200479 if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags))
480 goto submit_entry;
481
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700482 /*
Gertjan van Wingerdec4da0042008-06-16 19:56:31 +0200483 * Allocate a new sk_buffer. If no new buffer available, drop the
484 * received frame and reuse the existing buffer.
485 */
Ivo van Doornfa695602010-10-11 15:37:25 +0200486 skb = rt2x00queue_alloc_rxskb(entry);
Gertjan van Wingerdec4da0042008-06-16 19:56:31 +0200487 if (!skb)
Ivo van Doorn1550c8e2010-10-11 15:38:26 +0200488 goto submit_entry;
Gertjan van Wingerdec4da0042008-06-16 19:56:31 +0200489
490 /*
491 * Unmap the skb.
492 */
Ivo van Doornfa695602010-10-11 15:37:25 +0200493 rt2x00queue_unmap_skb(entry);
Gertjan van Wingerdec4da0042008-06-16 19:56:31 +0200494
495 /*
496 * Extract the RXD details.
497 */
498 memset(&rxdesc, 0, sizeof(rxdesc));
499 rt2x00dev->ops->lib->fill_rxdone(entry, &rxdesc);
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700500
501 /*
Gertjan van Wingerde239c2492008-06-06 22:54:12 +0200502 * The data behind the ieee80211 header must be
Gertjan van Wingerdea9f853d2008-06-07 16:57:09 +0200503 * aligned on a 4 byte boundary.
Gertjan van Wingerde239c2492008-06-06 22:54:12 +0200504 */
Ivo van Doorn2bb057d2008-08-04 16:37:44 +0200505 header_length = ieee80211_get_hdrlen_from_skb(entry->skb);
Gertjan van Wingerde239c2492008-06-06 22:54:12 +0200506
Ivo van Doorn2bb057d2008-08-04 16:37:44 +0200507 /*
508 * Hardware might have stripped the IV/EIV/ICV data,
509 * in that case it is possible that the data was
Daniel Mack3ad2f3fb2010-02-03 08:01:28 +0800510 * provided separately (through hardware descriptor)
Ivo van Doorn2bb057d2008-08-04 16:37:44 +0200511 * in which case we should reinsert the data into the frame.
512 */
Ivo van Doorn74415ed2008-12-02 22:50:33 +0100513 if ((rxdesc.dev_flags & RXDONE_CRYPTO_IV) &&
Ivo van Doorn9f166172009-04-26 16:08:50 +0200514 (rxdesc.flags & RX_FLAG_IV_STRIPPED))
Ivo van Doorndaee6c02009-08-29 20:30:45 +0200515 rt2x00crypto_rx_insert_iv(entry->skb, header_length,
Ivo van Doorn9f166172009-04-26 16:08:50 +0200516 &rxdesc);
Gertjan van Wingerdeb7340832009-12-04 23:47:04 +0100517 else if (header_length &&
518 (rxdesc.size > header_length) &&
519 (rxdesc.dev_flags & RXDONE_L2PAD))
Ivo van Doorndaee6c02009-08-29 20:30:45 +0200520 rt2x00queue_remove_l2pad(entry->skb, header_length);
Ivo van Doorn9f166172009-04-26 16:08:50 +0200521 else
Ivo van Doorndaee6c02009-08-29 20:30:45 +0200522 rt2x00queue_align_payload(entry->skb, header_length);
Gertjan van Wingerde239c2492008-06-06 22:54:12 +0200523
Alban Browaeys1398d452009-12-04 23:47:00 +0100524 /* Trim buffer to correct size */
525 skb_trim(entry->skb, rxdesc.size);
526
Gertjan van Wingerde239c2492008-06-06 22:54:12 +0200527 /*
Ivo van Doorn3590eea2010-10-11 15:38:07 +0200528 * Translate the signal to the correct bitrate index.
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700529 */
Ivo van Doorn3590eea2010-10-11 15:38:07 +0200530 rate_idx = rt2x00lib_rxdone_read_signal(rt2x00dev, &rxdesc);
531 if (rxdesc.rate_mode == RATE_MODE_HT_MIX ||
532 rxdesc.rate_mode == RATE_MODE_HT_GREENFIELD)
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200533 rxdesc.flags |= RX_FLAG_HT;
Ivo van Doorn866a0502008-03-25 14:12:45 +0100534
Mattias Nissler61af43c2007-11-27 21:50:26 +0100535 /*
Ivo van Doorn84e31962008-12-20 10:53:29 +0100536 * Update extra components
Mattias Nissler61af43c2007-11-27 21:50:26 +0100537 */
Ivo van Doorn84e31962008-12-20 10:53:29 +0100538 rt2x00link_update_stats(rt2x00dev, entry->skb, &rxdesc);
539 rt2x00debug_update_crypto(rt2x00dev, &rxdesc);
Ivo van Doorne5ef5ba2010-08-06 20:49:27 +0200540 rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_RXDONE, entry->skb);
Ivo van Doorn69f81a22007-10-13 16:26:36 +0200541
Ivo van Doorne5ef5ba2010-08-06 20:49:27 +0200542 /*
543 * Initialize RX status information, and send frame
544 * to mac80211.
545 */
546 rx_status = IEEE80211_SKB_RXCB(entry->skb);
Ivo van Doornae73e582008-07-04 16:14:59 +0200547 rx_status->mactime = rxdesc.timestamp;
Ivo van Doorne5ef5ba2010-08-06 20:49:27 +0200548 rx_status->band = rt2x00dev->curr_band;
549 rx_status->freq = rt2x00dev->curr_freq;
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200550 rx_status->rate_idx = rate_idx;
Gertjan van Wingerdec4da0042008-06-16 19:56:31 +0200551 rx_status->signal = rxdesc.rssi;
552 rx_status->flag = rxdesc.flags;
Ivo van Doorn69f81a22007-10-13 16:26:36 +0200553 rx_status->antenna = rt2x00dev->link.ant.active.rx;
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700554
Ivo van Doorn7e613e12010-08-06 20:45:38 +0200555 ieee80211_rx_ni(rt2x00dev->hw, entry->skb);
Gertjan van Wingerdec4da0042008-06-16 19:56:31 +0200556
557 /*
558 * Replace the skb with the freshly allocated one.
559 */
560 entry->skb = skb;
Ivo van Doornd74f5ba2008-06-16 19:56:54 +0200561
Ivo van Doorn7e613e12010-08-06 20:45:38 +0200562submit_entry:
Ivo van Doorn070192d2010-11-04 20:41:05 +0100563 entry->flags = 0;
Ivo van Doorn7e613e12010-08-06 20:45:38 +0200564 rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE);
Ivo van Doorn070192d2010-11-04 20:41:05 +0100565 if (test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) &&
Ivo van Doorn64e7d722010-12-13 12:36:00 +0100566 test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
Ivo van Doorn070192d2010-11-04 20:41:05 +0100567 rt2x00dev->ops->lib->clear_entry(entry);
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700568}
569EXPORT_SYMBOL_GPL(rt2x00lib_rxdone);
570
571/*
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700572 * Driver initialization handlers.
573 */
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100574const struct rt2x00_rate rt2x00_supported_rates[12] = {
575 {
Ivo van Doorn3d8606a2008-11-02 00:36:40 +0100576 .flags = DEV_RATE_CCK,
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100577 .bitrate = 10,
Ivo van Doornaa776722008-03-09 22:48:08 +0100578 .ratemask = BIT(0),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100579 .plcp = 0x00,
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200580 .mcs = RATE_MCS(RATE_MODE_CCK, 0),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100581 },
582 {
Ivo van Doorn3d8606a2008-11-02 00:36:40 +0100583 .flags = DEV_RATE_CCK | DEV_RATE_SHORT_PREAMBLE,
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100584 .bitrate = 20,
Ivo van Doornaa776722008-03-09 22:48:08 +0100585 .ratemask = BIT(1),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100586 .plcp = 0x01,
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200587 .mcs = RATE_MCS(RATE_MODE_CCK, 1),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100588 },
589 {
Ivo van Doorn3d8606a2008-11-02 00:36:40 +0100590 .flags = DEV_RATE_CCK | DEV_RATE_SHORT_PREAMBLE,
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100591 .bitrate = 55,
Ivo van Doornaa776722008-03-09 22:48:08 +0100592 .ratemask = BIT(2),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100593 .plcp = 0x02,
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200594 .mcs = RATE_MCS(RATE_MODE_CCK, 2),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100595 },
596 {
Ivo van Doorn3d8606a2008-11-02 00:36:40 +0100597 .flags = DEV_RATE_CCK | DEV_RATE_SHORT_PREAMBLE,
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100598 .bitrate = 110,
Ivo van Doornaa776722008-03-09 22:48:08 +0100599 .ratemask = BIT(3),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100600 .plcp = 0x03,
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200601 .mcs = RATE_MCS(RATE_MODE_CCK, 3),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100602 },
603 {
Ivo van Doorn3d8606a2008-11-02 00:36:40 +0100604 .flags = DEV_RATE_OFDM,
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100605 .bitrate = 60,
Ivo van Doornaa776722008-03-09 22:48:08 +0100606 .ratemask = BIT(4),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100607 .plcp = 0x0b,
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200608 .mcs = RATE_MCS(RATE_MODE_OFDM, 0),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100609 },
610 {
611 .flags = DEV_RATE_OFDM,
612 .bitrate = 90,
Ivo van Doornaa776722008-03-09 22:48:08 +0100613 .ratemask = BIT(5),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100614 .plcp = 0x0f,
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200615 .mcs = RATE_MCS(RATE_MODE_OFDM, 1),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100616 },
617 {
Ivo van Doorn3d8606a2008-11-02 00:36:40 +0100618 .flags = DEV_RATE_OFDM,
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100619 .bitrate = 120,
Ivo van Doornaa776722008-03-09 22:48:08 +0100620 .ratemask = BIT(6),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100621 .plcp = 0x0a,
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200622 .mcs = RATE_MCS(RATE_MODE_OFDM, 2),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100623 },
624 {
625 .flags = DEV_RATE_OFDM,
626 .bitrate = 180,
Ivo van Doornaa776722008-03-09 22:48:08 +0100627 .ratemask = BIT(7),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100628 .plcp = 0x0e,
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200629 .mcs = RATE_MCS(RATE_MODE_OFDM, 3),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100630 },
631 {
Ivo van Doorn3d8606a2008-11-02 00:36:40 +0100632 .flags = DEV_RATE_OFDM,
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100633 .bitrate = 240,
Ivo van Doornaa776722008-03-09 22:48:08 +0100634 .ratemask = BIT(8),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100635 .plcp = 0x09,
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200636 .mcs = RATE_MCS(RATE_MODE_OFDM, 4),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100637 },
638 {
639 .flags = DEV_RATE_OFDM,
640 .bitrate = 360,
Ivo van Doornaa776722008-03-09 22:48:08 +0100641 .ratemask = BIT(9),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100642 .plcp = 0x0d,
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200643 .mcs = RATE_MCS(RATE_MODE_OFDM, 5),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100644 },
645 {
646 .flags = DEV_RATE_OFDM,
647 .bitrate = 480,
Ivo van Doornaa776722008-03-09 22:48:08 +0100648 .ratemask = BIT(10),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100649 .plcp = 0x08,
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200650 .mcs = RATE_MCS(RATE_MODE_OFDM, 6),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100651 },
652 {
653 .flags = DEV_RATE_OFDM,
654 .bitrate = 540,
Ivo van Doornaa776722008-03-09 22:48:08 +0100655 .ratemask = BIT(11),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100656 .plcp = 0x0c,
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200657 .mcs = RATE_MCS(RATE_MODE_OFDM, 7),
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100658 },
659};
660
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700661static void rt2x00lib_channel(struct ieee80211_channel *entry,
662 const int channel, const int tx_power,
663 const int value)
664{
Ivo van Doornf2a3c7f2008-02-03 15:52:45 +0100665 entry->center_freq = ieee80211_channel_to_frequency(channel);
Johannes Berg8318d782008-01-24 19:38:38 +0100666 entry->hw_value = value;
667 entry->max_power = tx_power;
668 entry->max_antenna_gain = 0xff;
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700669}
670
671static void rt2x00lib_rate(struct ieee80211_rate *entry,
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100672 const u16 index, const struct rt2x00_rate *rate)
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700673{
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100674 entry->flags = 0;
675 entry->bitrate = rate->bitrate;
Mark Einonc2361ba2010-11-06 15:46:36 +0100676 entry->hw_value = index;
Ivo van Doorn3ea96462009-01-04 17:33:25 +0100677 entry->hw_value_short = index;
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100678
Ivo van Doorn3ea96462009-01-04 17:33:25 +0100679 if (rate->flags & DEV_RATE_SHORT_PREAMBLE)
Ivo van Doorn70e2fed2008-02-03 15:50:40 +0100680 entry->flags |= IEEE80211_RATE_SHORT_PREAMBLE;
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700681}
682
683static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
684 struct hw_mode_spec *spec)
685{
686 struct ieee80211_hw *hw = rt2x00dev->hw;
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700687 struct ieee80211_channel *channels;
688 struct ieee80211_rate *rates;
Ivo van Doorn31562e82008-02-17 17:35:05 +0100689 unsigned int num_rates;
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700690 unsigned int i;
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700691
Ivo van Doorn31562e82008-02-17 17:35:05 +0100692 num_rates = 0;
693 if (spec->supported_rates & SUPPORT_RATE_CCK)
694 num_rates += 4;
695 if (spec->supported_rates & SUPPORT_RATE_OFDM)
696 num_rates += 8;
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700697
698 channels = kzalloc(sizeof(*channels) * spec->num_channels, GFP_KERNEL);
699 if (!channels)
Johannes Berg8318d782008-01-24 19:38:38 +0100700 return -ENOMEM;
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700701
Ivo van Doorn31562e82008-02-17 17:35:05 +0100702 rates = kzalloc(sizeof(*rates) * num_rates, GFP_KERNEL);
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700703 if (!rates)
704 goto exit_free_channels;
705
706 /*
707 * Initialize Rate list.
708 */
Ivo van Doorn31562e82008-02-17 17:35:05 +0100709 for (i = 0; i < num_rates; i++)
Ivo van Doorn8f5fa7f2008-02-03 15:54:34 +0100710 rt2x00lib_rate(&rates[i], i, rt2x00_get_rate(i));
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700711
712 /*
713 * Initialize Channel list.
714 */
715 for (i = 0; i < spec->num_channels; i++) {
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700716 rt2x00lib_channel(&channels[i],
Ivo van Doorn8c5e7a52008-08-04 16:38:47 +0200717 spec->channels[i].channel,
Ivo van Doorn8d1331b2010-08-23 19:56:07 +0200718 spec->channels_info[i].max_power, i);
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700719 }
720
721 /*
Ivo van Doorn31562e82008-02-17 17:35:05 +0100722 * Intitialize 802.11b, 802.11g
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700723 * Rates: CCK, OFDM.
Johannes Berg8318d782008-01-24 19:38:38 +0100724 * Channels: 2.4 GHz
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700725 */
Gertjan van Wingerde47ac2682008-02-17 17:35:55 +0100726 if (spec->supported_bands & SUPPORT_BAND_2GHZ) {
Ivo van Doorn31562e82008-02-17 17:35:05 +0100727 rt2x00dev->bands[IEEE80211_BAND_2GHZ].n_channels = 14;
728 rt2x00dev->bands[IEEE80211_BAND_2GHZ].n_bitrates = num_rates;
729 rt2x00dev->bands[IEEE80211_BAND_2GHZ].channels = channels;
730 rt2x00dev->bands[IEEE80211_BAND_2GHZ].bitrates = rates;
731 hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
732 &rt2x00dev->bands[IEEE80211_BAND_2GHZ];
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200733 memcpy(&rt2x00dev->bands[IEEE80211_BAND_2GHZ].ht_cap,
734 &spec->ht, sizeof(spec->ht));
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700735 }
736
737 /*
738 * Intitialize 802.11a
739 * Rates: OFDM.
740 * Channels: OFDM, UNII, HiperLAN2.
741 */
Gertjan van Wingerde47ac2682008-02-17 17:35:55 +0100742 if (spec->supported_bands & SUPPORT_BAND_5GHZ) {
Ivo van Doorn31562e82008-02-17 17:35:05 +0100743 rt2x00dev->bands[IEEE80211_BAND_5GHZ].n_channels =
744 spec->num_channels - 14;
745 rt2x00dev->bands[IEEE80211_BAND_5GHZ].n_bitrates =
746 num_rates - 4;
747 rt2x00dev->bands[IEEE80211_BAND_5GHZ].channels = &channels[14];
748 rt2x00dev->bands[IEEE80211_BAND_5GHZ].bitrates = &rates[4];
749 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
750 &rt2x00dev->bands[IEEE80211_BAND_5GHZ];
Ivo van Doorn35f00cf2009-04-26 16:09:32 +0200751 memcpy(&rt2x00dev->bands[IEEE80211_BAND_5GHZ].ht_cap,
752 &spec->ht, sizeof(spec->ht));
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700753 }
754
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700755 return 0;
756
Johannes Berg8318d782008-01-24 19:38:38 +0100757 exit_free_channels:
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700758 kfree(channels);
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700759 ERROR(rt2x00dev, "Allocation ieee80211 modes failed.\n");
760 return -ENOMEM;
761}
762
763static void rt2x00lib_remove_hw(struct rt2x00_dev *rt2x00dev)
764{
Ivo van Doorn0262ab02008-08-29 21:04:26 +0200765 if (test_bit(DEVICE_STATE_REGISTERED_HW, &rt2x00dev->flags))
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700766 ieee80211_unregister_hw(rt2x00dev->hw);
767
Johannes Berg8318d782008-01-24 19:38:38 +0100768 if (likely(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ])) {
769 kfree(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->channels);
770 kfree(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->bitrates);
771 rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = NULL;
772 rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL;
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700773 }
Ivo van Doorn8c5e7a52008-08-04 16:38:47 +0200774
775 kfree(rt2x00dev->spec.channels_info);
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700776}
777
778static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev)
779{
780 struct hw_mode_spec *spec = &rt2x00dev->spec;
781 int status;
782
Ivo van Doorn0262ab02008-08-29 21:04:26 +0200783 if (test_bit(DEVICE_STATE_REGISTERED_HW, &rt2x00dev->flags))
784 return 0;
785
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700786 /*
787 * Initialize HW modes.
788 */
789 status = rt2x00lib_probe_hw_modes(rt2x00dev, spec);
790 if (status)
791 return status;
792
793 /*
Gertjan van Wingerde61448f82008-05-10 13:43:33 +0200794 * Initialize HW fields.
795 */
796 rt2x00dev->hw->queues = rt2x00dev->ops->tx_queues;
797
798 /*
Gertjan van Wingerdee6218cc2009-11-23 22:44:52 +0100799 * Initialize extra TX headroom required.
800 */
Gertjan van Wingerde7a4a77b2009-12-30 11:36:30 +0100801 rt2x00dev->hw->extra_tx_headroom =
802 max_t(unsigned int, IEEE80211_TX_STATUS_HEADROOM,
803 rt2x00dev->ops->extra_tx_headroom);
804
805 /*
806 * Take TX headroom required for alignment into account.
807 */
808 if (test_bit(DRIVER_REQUIRE_L2PAD, &rt2x00dev->flags))
809 rt2x00dev->hw->extra_tx_headroom += RT2X00_L2PAD_SIZE;
810 else if (test_bit(DRIVER_REQUIRE_DMA, &rt2x00dev->flags))
811 rt2x00dev->hw->extra_tx_headroom += RT2X00_ALIGN_SIZE;
Gertjan van Wingerdee6218cc2009-11-23 22:44:52 +0100812
813 /*
Helmut Schaa96c3da72010-10-02 11:27:35 +0200814 * Allocate tx status FIFO for driver use.
815 */
816 if (test_bit(DRIVER_REQUIRE_TXSTATUS_FIFO, &rt2x00dev->flags) &&
817 rt2x00dev->ops->lib->txstatus_tasklet) {
818 /*
819 * Allocate txstatus fifo and tasklet, we use a size of 512
820 * for the kfifo which is big enough to store 512/4=128 tx
821 * status reports. In the worst case (tx status for all tx
822 * queues gets reported before we've got a chance to handle
823 * them) 24*4=384 tx status reports need to be cached.
824 */
825 status = kfifo_alloc(&rt2x00dev->txstatus_fifo, 512,
826 GFP_KERNEL);
827 if (status)
828 return status;
829
830 /* tasklet for processing the tx status reports. */
831 tasklet_init(&rt2x00dev->txstatus_tasklet,
832 rt2x00dev->ops->lib->txstatus_tasklet,
833 (unsigned long)rt2x00dev);
834
835 }
836
837 /*
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700838 * Register HW.
839 */
840 status = ieee80211_register_hw(rt2x00dev->hw);
Herton Ronaldo Krzesinskif05faa32009-04-10 18:05:14 -0300841 if (status)
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700842 return status;
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700843
Ivo van Doorn0262ab02008-08-29 21:04:26 +0200844 set_bit(DEVICE_STATE_REGISTERED_HW, &rt2x00dev->flags);
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700845
846 return 0;
847}
848
849/*
850 * Initialization/uninitialization handlers.
851 */
Ivo van Doorne37ea212008-01-06 23:40:07 +0100852static void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev)
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700853{
Ivo van Doorn0262ab02008-08-29 21:04:26 +0200854 if (!test_and_clear_bit(DEVICE_STATE_INITIALIZED, &rt2x00dev->flags))
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700855 return;
856
857 /*
Ivo van Doorn1682fe62008-03-13 15:38:03 +0100858 * Unregister extra components.
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700859 */
860 rt2x00rfkill_unregister(rt2x00dev);
861
862 /*
863 * Allow the HW to uninitialize.
864 */
865 rt2x00dev->ops->lib->uninitialize(rt2x00dev);
866
867 /*
Ivo van Doorn181d6902008-02-05 16:42:23 -0500868 * Free allocated queue entries.
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700869 */
Ivo van Doorn181d6902008-02-05 16:42:23 -0500870 rt2x00queue_uninitialize(rt2x00dev);
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700871}
872
Ivo van Doorne37ea212008-01-06 23:40:07 +0100873static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev)
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700874{
875 int status;
876
Ivo van Doorn0262ab02008-08-29 21:04:26 +0200877 if (test_bit(DEVICE_STATE_INITIALIZED, &rt2x00dev->flags))
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700878 return 0;
879
880 /*
Ivo van Doorn181d6902008-02-05 16:42:23 -0500881 * Allocate all queue entries.
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700882 */
Ivo van Doorn181d6902008-02-05 16:42:23 -0500883 status = rt2x00queue_initialize(rt2x00dev);
884 if (status)
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700885 return status;
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700886
887 /*
888 * Initialize the device.
889 */
890 status = rt2x00dev->ops->lib->initialize(rt2x00dev);
Ivo van Doorned499982008-05-05 17:23:47 +0200891 if (status) {
892 rt2x00queue_uninitialize(rt2x00dev);
893 return status;
894 }
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700895
Ivo van Doorn0262ab02008-08-29 21:04:26 +0200896 set_bit(DEVICE_STATE_INITIALIZED, &rt2x00dev->flags);
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700897
898 /*
Ivo van Doorn1682fe62008-03-13 15:38:03 +0100899 * Register the extra components.
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700900 */
Ivo van Doorn1682fe62008-03-13 15:38:03 +0100901 rt2x00rfkill_register(rt2x00dev);
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700902
903 return 0;
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700904}
905
Ivo van Doorne37ea212008-01-06 23:40:07 +0100906int rt2x00lib_start(struct rt2x00_dev *rt2x00dev)
907{
908 int retval;
909
Ivo van Doorn0262ab02008-08-29 21:04:26 +0200910 if (test_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags))
Ivo van Doorne37ea212008-01-06 23:40:07 +0100911 return 0;
912
913 /*
914 * If this is the first interface which is added,
915 * we should load the firmware now.
916 */
Ivo van Doorn9404ef32008-02-03 15:48:38 +0100917 retval = rt2x00lib_load_firmware(rt2x00dev);
918 if (retval)
919 return retval;
Ivo van Doorne37ea212008-01-06 23:40:07 +0100920
921 /*
922 * Initialize the device.
923 */
924 retval = rt2x00lib_initialize(rt2x00dev);
925 if (retval)
926 return retval;
927
Ivo van Doorn6bb40dd2008-02-03 15:49:59 +0100928 rt2x00dev->intf_ap_count = 0;
929 rt2x00dev->intf_sta_count = 0;
930 rt2x00dev->intf_associated = 0;
931
Ivo van Doornbdfa5002009-08-08 23:53:04 +0200932 /* Enable the radio */
933 retval = rt2x00lib_enable_radio(rt2x00dev);
Helmut Schaa1f0280c2010-10-02 11:34:05 +0200934 if (retval)
Ivo van Doornbdfa5002009-08-08 23:53:04 +0200935 return retval;
Ivo van Doornbdfa5002009-08-08 23:53:04 +0200936
Ivo van Doorn0262ab02008-08-29 21:04:26 +0200937 set_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags);
Ivo van Doorne37ea212008-01-06 23:40:07 +0100938
939 return 0;
940}
941
942void rt2x00lib_stop(struct rt2x00_dev *rt2x00dev)
943{
Ivo van Doorn0262ab02008-08-29 21:04:26 +0200944 if (!test_and_clear_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags))
Ivo van Doorne37ea212008-01-06 23:40:07 +0100945 return;
946
947 /*
948 * Perhaps we can add something smarter here,
949 * but for now just disabling the radio should do.
950 */
951 rt2x00lib_disable_radio(rt2x00dev);
952
Ivo van Doorn6bb40dd2008-02-03 15:49:59 +0100953 rt2x00dev->intf_ap_count = 0;
954 rt2x00dev->intf_sta_count = 0;
955 rt2x00dev->intf_associated = 0;
Ivo van Doorne37ea212008-01-06 23:40:07 +0100956}
957
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700958/*
959 * driver allocation handlers.
960 */
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700961int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
962{
963 int retval = -ENOMEM;
964
Ivo van Doorn8ff48a82008-11-09 23:40:46 +0100965 mutex_init(&rt2x00dev->csr_mutex);
966
Sean Cross66f84d62009-11-05 20:22:03 +0100967 set_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
968
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700969 /*
Ivo van Doorn6bb40dd2008-02-03 15:49:59 +0100970 * Make room for rt2x00_intf inside the per-interface
971 * structure ieee80211_vif.
972 */
973 rt2x00dev->hw->vif_data_size = sizeof(struct rt2x00_intf);
974
Ivo van Doorn3514a442008-10-29 17:18:46 +0100975 /*
976 * Determine which operating modes are supported, all modes
977 * which require beaconing, depend on the availability of
978 * beacon entries.
979 */
980 rt2x00dev->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
981 if (rt2x00dev->ops->bcn->entry_num > 0)
982 rt2x00dev->hw->wiphy->interface_modes |=
983 BIT(NL80211_IFTYPE_ADHOC) |
Andrey Yurovskya07dbea2008-12-20 10:55:34 +0100984 BIT(NL80211_IFTYPE_AP) |
Ivo van Doornce292a62008-12-20 10:57:02 +0100985 BIT(NL80211_IFTYPE_MESH_POINT) |
986 BIT(NL80211_IFTYPE_WDS);
Luis R. Rodriguezf59ac042008-08-29 16:26:43 -0700987
Ivo van Doorn6bb40dd2008-02-03 15:49:59 +0100988 /*
Stephen Boyd9acd56d2010-07-16 09:50:10 -0700989 * Initialize configuration work.
990 */
991 INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled);
992
993 /*
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700994 * Let the driver probe the device to detect the capabilities.
995 */
996 retval = rt2x00dev->ops->lib->probe_hw(rt2x00dev);
997 if (retval) {
998 ERROR(rt2x00dev, "Failed to allocate device.\n");
999 goto exit;
1000 }
1001
1002 /*
Ivo van Doorn181d6902008-02-05 16:42:23 -05001003 * Allocate queue array.
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001004 */
Ivo van Doorn181d6902008-02-05 16:42:23 -05001005 retval = rt2x00queue_allocate(rt2x00dev);
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001006 if (retval)
1007 goto exit;
1008
1009 /*
1010 * Initialize ieee80211 structure.
1011 */
1012 retval = rt2x00lib_probe_hw(rt2x00dev);
1013 if (retval) {
1014 ERROR(rt2x00dev, "Failed to initialize hw.\n");
1015 goto exit;
1016 }
1017
1018 /*
Ivo van Doorn1682fe62008-03-13 15:38:03 +01001019 * Register extra components.
Ivo van Doorna9450b72008-02-03 15:53:40 +01001020 */
Ivo van Doorn84e31962008-12-20 10:53:29 +01001021 rt2x00link_register(rt2x00dev);
Ivo van Doorna9450b72008-02-03 15:53:40 +01001022 rt2x00leds_register(rt2x00dev);
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001023 rt2x00debug_register(rt2x00dev);
1024
1025 return 0;
1026
1027exit:
1028 rt2x00lib_remove_dev(rt2x00dev);
1029
1030 return retval;
1031}
1032EXPORT_SYMBOL_GPL(rt2x00lib_probe_dev);
1033
1034void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
1035{
Ivo van Doorn0262ab02008-08-29 21:04:26 +02001036 clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
Ivo van Doorn066cb632007-09-25 20:55:39 +02001037
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001038 /*
1039 * Disable radio.
1040 */
1041 rt2x00lib_disable_radio(rt2x00dev);
1042
1043 /*
Pavel Roskind8cc8922009-08-02 14:30:15 -04001044 * Stop all work.
1045 */
Pavel Roskind8cc8922009-08-02 14:30:15 -04001046 cancel_work_sync(&rt2x00dev->intf_work);
Ivo van Doorn7e613e12010-08-06 20:45:38 +02001047 cancel_work_sync(&rt2x00dev->rxdone_work);
1048 cancel_work_sync(&rt2x00dev->txdone_work);
Pavel Roskind8cc8922009-08-02 14:30:15 -04001049
1050 /*
Helmut Schaa96c3da72010-10-02 11:27:35 +02001051 * Free the tx status fifo.
1052 */
1053 kfifo_free(&rt2x00dev->txstatus_fifo);
1054
1055 /*
1056 * Kill the tx status tasklet.
1057 */
1058 tasklet_kill(&rt2x00dev->txstatus_tasklet);
1059
1060 /*
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001061 * Uninitialize device.
1062 */
1063 rt2x00lib_uninitialize(rt2x00dev);
1064
1065 /*
Ivo van Doorn1682fe62008-03-13 15:38:03 +01001066 * Free extra components
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001067 */
1068 rt2x00debug_deregister(rt2x00dev);
Ivo van Doorna9450b72008-02-03 15:53:40 +01001069 rt2x00leds_unregister(rt2x00dev);
1070
1071 /*
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001072 * Free ieee80211_hw memory.
1073 */
1074 rt2x00lib_remove_hw(rt2x00dev);
1075
1076 /*
1077 * Free firmware image.
1078 */
1079 rt2x00lib_free_firmware(rt2x00dev);
1080
1081 /*
Ivo van Doorn181d6902008-02-05 16:42:23 -05001082 * Free queue structures.
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001083 */
Ivo van Doorn181d6902008-02-05 16:42:23 -05001084 rt2x00queue_free(rt2x00dev);
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001085}
1086EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev);
1087
1088/*
1089 * Device state handlers
1090 */
1091#ifdef CONFIG_PM
1092int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state)
1093{
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001094 NOTICE(rt2x00dev, "Going to sleep.\n");
Ivo van Doorn066cb632007-09-25 20:55:39 +02001095
1096 /*
Ivo van Doorn07126122009-01-23 17:04:05 +01001097 * Prevent mac80211 from accessing driver while suspended.
Ivo van Doorn066cb632007-09-25 20:55:39 +02001098 */
Ivo van Doorn07126122009-01-23 17:04:05 +01001099 if (!test_and_clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
1100 return 0;
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001101
1102 /*
Ivo van Doorn07126122009-01-23 17:04:05 +01001103 * Cleanup as much as possible.
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001104 */
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001105 rt2x00lib_uninitialize(rt2x00dev);
Ivo van Doorn1682fe62008-03-13 15:38:03 +01001106
1107 /*
1108 * Suspend/disable extra components.
1109 */
Ivo van Doorna9450b72008-02-03 15:53:40 +01001110 rt2x00leds_suspend(rt2x00dev);
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001111 rt2x00debug_deregister(rt2x00dev);
1112
1113 /*
Ivo van Doorn98963222008-03-27 17:15:24 +01001114 * Set device mode to sleep for power management,
1115 * on some hardware this call seems to consistently fail.
1116 * From the specifications it is hard to tell why it fails,
1117 * and if this is a "bad thing".
1118 * Overall it is safe to just ignore the failure and
1119 * continue suspending. The only downside is that the
1120 * device will not be in optimal power save mode, but with
1121 * the radio and the other components already disabled the
1122 * device is as good as disabled.
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001123 */
Ivo van Doorn07126122009-01-23 17:04:05 +01001124 if (rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_SLEEP))
Ivo van Doorn98963222008-03-27 17:15:24 +01001125 WARNING(rt2x00dev, "Device failed to enter sleep state, "
1126 "continue suspending.\n");
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001127
1128 return 0;
1129}
1130EXPORT_SYMBOL_GPL(rt2x00lib_suspend);
1131
1132int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
1133{
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001134 NOTICE(rt2x00dev, "Waking up.\n");
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001135
1136 /*
Ivo van Doorn1682fe62008-03-13 15:38:03 +01001137 * Restore/enable extra components.
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001138 */
1139 rt2x00debug_register(rt2x00dev);
Ivo van Doorna9450b72008-02-03 15:53:40 +01001140 rt2x00leds_resume(rt2x00dev);
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001141
1142 /*
Ivo van Doorne37ea212008-01-06 23:40:07 +01001143 * We are ready again to receive requests from mac80211.
1144 */
Ivo van Doorn0262ab02008-08-29 21:04:26 +02001145 set_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
Ivo van Doorne37ea212008-01-06 23:40:07 +01001146
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001147 return 0;
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001148}
1149EXPORT_SYMBOL_GPL(rt2x00lib_resume);
1150#endif /* CONFIG_PM */
1151
1152/*
1153 * rt2x00lib module information.
1154 */
1155MODULE_AUTHOR(DRV_PROJECT);
1156MODULE_VERSION(DRV_VERSION);
1157MODULE_DESCRIPTION("rt2x00 library");
1158MODULE_LICENSE("GPL");