Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1 | /* |
Ivo van Doorn | 7e613e1 | 2010-08-06 20:45:38 +0200 | [diff] [blame] | 2 | Copyright (C) 2010 Willow Garage <http://www.willowgarage.com> |
| 3 | Copyright (C) 2004 - 2010 Ivo van Doorn <IvDoorn@gmail.com> |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 4 | <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 Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 27 | #include <linux/kernel.h> |
| 28 | #include <linux/module.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 29 | #include <linux/slab.h> |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 30 | |
| 31 | #include "rt2x00.h" |
| 32 | #include "rt2x00lib.h" |
| 33 | |
| 34 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 35 | * Radio control handlers. |
| 36 | */ |
| 37 | int 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 Doorn | 4b9631a | 2009-07-11 18:00:19 +0200 | [diff] [blame] | 45 | if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 46 | return 0; |
| 47 | |
| 48 | /* |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 49 | * Initialize all data queues. |
Ivo van Doorn | 837e7f2 | 2008-01-06 23:41:45 +0100 | [diff] [blame] | 50 | */ |
Ivo van Doorn | 798b7ad | 2008-11-08 15:25:33 +0100 | [diff] [blame] | 51 | rt2x00queue_init_queues(rt2x00dev); |
Ivo van Doorn | 837e7f2 | 2008-01-06 23:41:45 +0100 | [diff] [blame] | 52 | |
| 53 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 54 | * Enable radio. |
| 55 | */ |
Ivo van Doorn | a2e1d52 | 2008-03-31 15:53:44 +0200 | [diff] [blame] | 56 | status = |
| 57 | rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_ON); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 58 | if (status) |
| 59 | return status; |
| 60 | |
Ivo van Doorn | 2b08da3 | 2008-06-03 18:58:56 +0200 | [diff] [blame] | 61 | rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_IRQ_ON); |
| 62 | |
Ivo van Doorn | a2e1d52 | 2008-03-31 15:53:44 +0200 | [diff] [blame] | 63 | rt2x00leds_led_radio(rt2x00dev, true); |
Ivo van Doorn | 61c2b68 | 2008-04-21 19:01:09 +0200 | [diff] [blame] | 64 | rt2x00led_led_activity(rt2x00dev, true); |
Ivo van Doorn | a2e1d52 | 2008-03-31 15:53:44 +0200 | [diff] [blame] | 65 | |
Ivo van Doorn | 0262ab0 | 2008-08-29 21:04:26 +0200 | [diff] [blame] | 66 | set_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 67 | |
| 68 | /* |
| 69 | * Enable RX. |
| 70 | */ |
Ivo van Doorn | 5cbf830 | 2007-10-06 14:16:09 +0200 | [diff] [blame] | 71 | rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 72 | |
| 73 | /* |
Ivo van Doorn | c965c74 | 2010-07-11 12:25:46 +0200 | [diff] [blame] | 74 | * Start watchdog monitoring. |
| 75 | */ |
| 76 | rt2x00link_start_watchdog(rt2x00dev); |
| 77 | |
| 78 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 79 | * Start the TX queues. |
| 80 | */ |
Johannes Berg | 36d6825 | 2008-05-15 12:55:26 +0200 | [diff] [blame] | 81 | ieee80211_wake_queues(rt2x00dev->hw); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 82 | |
| 83 | return 0; |
| 84 | } |
| 85 | |
| 86 | void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev) |
| 87 | { |
Ivo van Doorn | 0262ab0 | 2008-08-29 21:04:26 +0200 | [diff] [blame] | 88 | if (!test_and_clear_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 89 | return; |
| 90 | |
| 91 | /* |
Ivo van Doorn | a2c9b65 | 2009-01-28 00:32:33 +0100 | [diff] [blame] | 92 | * Stop the TX queues in mac80211. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 93 | */ |
| 94 | ieee80211_stop_queues(rt2x00dev->hw); |
Ivo van Doorn | a2c9b65 | 2009-01-28 00:32:33 +0100 | [diff] [blame] | 95 | rt2x00queue_stop_queues(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 96 | |
| 97 | /* |
Ivo van Doorn | c965c74 | 2010-07-11 12:25:46 +0200 | [diff] [blame] | 98 | * Stop watchdog monitoring. |
| 99 | */ |
| 100 | rt2x00link_stop_watchdog(rt2x00dev); |
| 101 | |
| 102 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 103 | * Disable RX. |
| 104 | */ |
Ivo van Doorn | 5cbf830 | 2007-10-06 14:16:09 +0200 | [diff] [blame] | 105 | rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 106 | |
| 107 | /* |
| 108 | * Disable radio. |
| 109 | */ |
| 110 | rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_OFF); |
Ivo van Doorn | 2b08da3 | 2008-06-03 18:58:56 +0200 | [diff] [blame] | 111 | rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_IRQ_OFF); |
Ivo van Doorn | 61c2b68 | 2008-04-21 19:01:09 +0200 | [diff] [blame] | 112 | rt2x00led_led_activity(rt2x00dev, false); |
Ivo van Doorn | a2e1d52 | 2008-03-31 15:53:44 +0200 | [diff] [blame] | 113 | rt2x00leds_led_radio(rt2x00dev, false); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 114 | } |
| 115 | |
Ivo van Doorn | 5cbf830 | 2007-10-06 14:16:09 +0200 | [diff] [blame] | 116 | 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] | 117 | { |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 118 | /* |
| 119 | * When we are disabling the RX, we should also stop the link tuner. |
| 120 | */ |
Ivo van Doorn | 5cbf830 | 2007-10-06 14:16:09 +0200 | [diff] [blame] | 121 | if (state == STATE_RADIO_RX_OFF) |
Ivo van Doorn | 84e3196 | 2008-12-20 10:53:29 +0100 | [diff] [blame] | 122 | rt2x00link_stop_tuner(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 123 | |
| 124 | rt2x00dev->ops->lib->set_device_state(rt2x00dev, state); |
| 125 | |
| 126 | /* |
| 127 | * When we are enabling the RX, we should also start the link tuner. |
| 128 | */ |
Ivo van Doorn | 84e3196 | 2008-12-20 10:53:29 +0100 | [diff] [blame] | 129 | if (state == STATE_RADIO_RX_ON) |
| 130 | rt2x00link_start_tuner(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 133 | static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac, |
| 134 | struct ieee80211_vif *vif) |
Ivo van Doorn | 5c58ee5 | 2007-10-06 13:34:52 +0200 | [diff] [blame] | 135 | { |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 136 | struct rt2x00_dev *rt2x00dev = data; |
| 137 | struct rt2x00_intf *intf = vif_to_intf(vif); |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 138 | int delayed_flags; |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 139 | |
| 140 | /* |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 141 | * Copy all data we need during this action under the protection |
| 142 | * of a spinlock. Otherwise race conditions might occur which results |
| 143 | * into an invalid configuration. |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 144 | */ |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 145 | spin_lock(&intf->lock); |
| 146 | |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 147 | delayed_flags = intf->delayed_flags; |
| 148 | intf->delayed_flags = 0; |
| 149 | |
| 150 | spin_unlock(&intf->lock); |
| 151 | |
Ivo van Doorn | 980dfcb | 2008-06-25 21:27:00 +0200 | [diff] [blame] | 152 | /* |
| 153 | * It is possible the radio was disabled while the work had been |
| 154 | * scheduled. If that happens we should return here immediately, |
| 155 | * note that in the spinlock protected area above the delayed_flags |
| 156 | * have been cleared correctly. |
| 157 | */ |
Ivo van Doorn | 0262ab0 | 2008-08-29 21:04:26 +0200 | [diff] [blame] | 158 | if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) |
Ivo van Doorn | 980dfcb | 2008-06-25 21:27:00 +0200 | [diff] [blame] | 159 | return; |
| 160 | |
Ivo van Doorn | bd88a78 | 2008-07-09 15:12:44 +0200 | [diff] [blame] | 161 | if (delayed_flags & DELAYED_UPDATE_BEACON) |
Ivo van Doorn | a2c9b65 | 2009-01-28 00:32:33 +0100 | [diff] [blame] | 162 | rt2x00queue_update_beacon(rt2x00dev, vif, true); |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | static void rt2x00lib_intf_scheduled(struct work_struct *work) |
| 166 | { |
| 167 | struct rt2x00_dev *rt2x00dev = |
| 168 | container_of(work, struct rt2x00_dev, intf_work); |
| 169 | |
| 170 | /* |
| 171 | * Iterate over each interface and perform the |
| 172 | * requested configurations. |
| 173 | */ |
| 174 | ieee80211_iterate_active_interfaces(rt2x00dev->hw, |
| 175 | rt2x00lib_intf_scheduled_iter, |
| 176 | rt2x00dev); |
Ivo van Doorn | 5c58ee5 | 2007-10-06 13:34:52 +0200 | [diff] [blame] | 177 | } |
| 178 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 179 | /* |
| 180 | * Interrupt context handlers. |
| 181 | */ |
Helmut Schaa | 07896fe | 2010-07-11 12:27:58 +0200 | [diff] [blame] | 182 | static void rt2x00lib_bc_buffer_iter(void *data, u8 *mac, |
| 183 | struct ieee80211_vif *vif) |
| 184 | { |
| 185 | struct rt2x00_dev *rt2x00dev = data; |
| 186 | struct sk_buff *skb; |
| 187 | |
| 188 | /* |
| 189 | * Only AP mode interfaces do broad- and multicast buffering |
| 190 | */ |
| 191 | if (vif->type != NL80211_IFTYPE_AP) |
| 192 | return; |
| 193 | |
| 194 | /* |
| 195 | * Send out buffered broad- and multicast frames |
| 196 | */ |
| 197 | skb = ieee80211_get_buffered_bc(rt2x00dev->hw, vif); |
| 198 | while (skb) { |
| 199 | rt2x00mac_tx(rt2x00dev->hw, skb); |
| 200 | skb = ieee80211_get_buffered_bc(rt2x00dev->hw, vif); |
| 201 | } |
| 202 | } |
| 203 | |
Helmut Schaa | 9f926fb | 2010-07-11 12:28:23 +0200 | [diff] [blame] | 204 | static void rt2x00lib_beaconupdate_iter(void *data, u8 *mac, |
| 205 | struct ieee80211_vif *vif) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 206 | { |
Helmut Schaa | 4dee32f | 2010-07-11 12:27:26 +0200 | [diff] [blame] | 207 | struct rt2x00_dev *rt2x00dev = data; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 208 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 209 | if (vif->type != NL80211_IFTYPE_AP && |
Andrey Yurovsky | a07dbea | 2008-12-20 10:55:34 +0100 | [diff] [blame] | 210 | vif->type != NL80211_IFTYPE_ADHOC && |
Ivo van Doorn | ce292a6 | 2008-12-20 10:57:02 +0100 | [diff] [blame] | 211 | vif->type != NL80211_IFTYPE_MESH_POINT && |
| 212 | vif->type != NL80211_IFTYPE_WDS) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 213 | return; |
| 214 | |
Helmut Schaa | 4dee32f | 2010-07-11 12:27:26 +0200 | [diff] [blame] | 215 | rt2x00queue_update_beacon(rt2x00dev, vif, true); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev) |
| 219 | { |
Ivo van Doorn | 0262ab0 | 2008-08-29 21:04:26 +0200 | [diff] [blame] | 220 | if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 221 | return; |
| 222 | |
Helmut Schaa | 07896fe | 2010-07-11 12:27:58 +0200 | [diff] [blame] | 223 | /* send buffered bc/mc frames out for every bssid */ |
Helmut Schaa | 4dee32f | 2010-07-11 12:27:26 +0200 | [diff] [blame] | 224 | ieee80211_iterate_active_interfaces(rt2x00dev->hw, |
Helmut Schaa | 07896fe | 2010-07-11 12:27:58 +0200 | [diff] [blame] | 225 | rt2x00lib_bc_buffer_iter, |
| 226 | rt2x00dev); |
Helmut Schaa | 9f926fb | 2010-07-11 12:28:23 +0200 | [diff] [blame] | 227 | /* |
| 228 | * Devices with pre tbtt interrupt don't need to update the beacon |
| 229 | * here as they will fetch the next beacon directly prior to |
| 230 | * transmission. |
| 231 | */ |
| 232 | if (test_bit(DRIVER_SUPPORT_PRE_TBTT_INTERRUPT, &rt2x00dev->flags)) |
| 233 | return; |
Helmut Schaa | 07896fe | 2010-07-11 12:27:58 +0200 | [diff] [blame] | 234 | |
| 235 | /* fetch next beacon */ |
| 236 | ieee80211_iterate_active_interfaces(rt2x00dev->hw, |
Helmut Schaa | 9f926fb | 2010-07-11 12:28:23 +0200 | [diff] [blame] | 237 | rt2x00lib_beaconupdate_iter, |
Helmut Schaa | 07896fe | 2010-07-11 12:27:58 +0200 | [diff] [blame] | 238 | rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 239 | } |
| 240 | EXPORT_SYMBOL_GPL(rt2x00lib_beacondone); |
| 241 | |
Helmut Schaa | 9f926fb | 2010-07-11 12:28:23 +0200 | [diff] [blame] | 242 | void rt2x00lib_pretbtt(struct rt2x00_dev *rt2x00dev) |
| 243 | { |
| 244 | if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) |
| 245 | return; |
| 246 | |
| 247 | /* fetch next beacon */ |
| 248 | ieee80211_iterate_active_interfaces(rt2x00dev->hw, |
| 249 | rt2x00lib_beaconupdate_iter, |
| 250 | rt2x00dev); |
| 251 | } |
| 252 | EXPORT_SYMBOL_GPL(rt2x00lib_pretbtt); |
| 253 | |
Ivo van Doorn | 652a9dd | 2010-08-30 21:15:19 +0200 | [diff] [blame] | 254 | void rt2x00lib_dmadone(struct queue_entry *entry) |
| 255 | { |
| 256 | rt2x00queue_index_inc(entry->queue, Q_INDEX_DMA_DONE); |
| 257 | } |
| 258 | EXPORT_SYMBOL_GPL(rt2x00lib_dmadone); |
| 259 | |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 260 | void rt2x00lib_txdone(struct queue_entry *entry, |
| 261 | struct txdone_entry_desc *txdesc) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 262 | { |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 263 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 264 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 265 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); |
Ivo van Doorn | d74f5ba | 2008-06-16 19:56:54 +0200 | [diff] [blame] | 266 | enum data_queue_qid qid = skb_get_queue_mapping(entry->skb); |
Ivo van Doorn | 9f16617 | 2009-04-26 16:08:50 +0200 | [diff] [blame] | 267 | unsigned int header_length = ieee80211_get_hdrlen_from_skb(entry->skb); |
Benoit PAPILLAULT | 92ed48e | 2009-08-17 18:56:10 +0200 | [diff] [blame] | 268 | u8 rate_idx, rate_flags, retry_rates; |
Johannes Berg | 7351c6b | 2009-11-19 01:08:30 +0100 | [diff] [blame] | 269 | u8 skbdesc_flags = skbdesc->flags; |
Benoit PAPILLAULT | 92ed48e | 2009-08-17 18:56:10 +0200 | [diff] [blame] | 270 | unsigned int i; |
Ivo van Doorn | 2e27cff | 2009-08-29 19:10:14 +0200 | [diff] [blame] | 271 | bool success; |
Ivo van Doorn | d74f5ba | 2008-06-16 19:56:54 +0200 | [diff] [blame] | 272 | |
| 273 | /* |
Gertjan van Wingerde | e513a0b | 2010-06-29 21:41:40 +0200 | [diff] [blame] | 274 | * Unmap the skb. |
| 275 | */ |
| 276 | rt2x00queue_unmap_skb(rt2x00dev, entry->skb); |
| 277 | |
| 278 | /* |
| 279 | * Remove the extra tx headroom from the skb. |
| 280 | */ |
| 281 | skb_pull(entry->skb, rt2x00dev->ops->extra_tx_headroom); |
| 282 | |
| 283 | /* |
| 284 | * Signal that the TX descriptor is no longer in the skb. |
| 285 | */ |
| 286 | skbdesc->flags &= ~SKBDESC_DESC_IN_SKB; |
| 287 | |
| 288 | /* |
Ivo van Doorn | 9f16617 | 2009-04-26 16:08:50 +0200 | [diff] [blame] | 289 | * Remove L2 padding which was added during |
| 290 | */ |
| 291 | if (test_bit(DRIVER_REQUIRE_L2PAD, &rt2x00dev->flags)) |
Ivo van Doorn | daee6c0 | 2009-08-29 20:30:45 +0200 | [diff] [blame] | 292 | rt2x00queue_remove_l2pad(entry->skb, header_length); |
Ivo van Doorn | 9f16617 | 2009-04-26 16:08:50 +0200 | [diff] [blame] | 293 | |
| 294 | /* |
Ivo van Doorn | 2bb057d | 2008-08-04 16:37:44 +0200 | [diff] [blame] | 295 | * If the IV/EIV data was stripped from the frame before it was |
| 296 | * passed to the hardware, we should now reinsert it again because |
Walter Goldens | 77c2061 | 2010-05-18 04:44:54 -0700 | [diff] [blame] | 297 | * mac80211 will expect the same data to be present it the |
Ivo van Doorn | 2bb057d | 2008-08-04 16:37:44 +0200 | [diff] [blame] | 298 | * frame as it was passed to us. |
| 299 | */ |
| 300 | if (test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags)) |
Ivo van Doorn | 9f16617 | 2009-04-26 16:08:50 +0200 | [diff] [blame] | 301 | rt2x00crypto_tx_insert_iv(entry->skb, header_length); |
Ivo van Doorn | 2bb057d | 2008-08-04 16:37:44 +0200 | [diff] [blame] | 302 | |
| 303 | /* |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 304 | * Send frame to debugfs immediately, after this call is completed |
| 305 | * we are going to overwrite the skb->cb array. |
| 306 | */ |
| 307 | rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_TXDONE, entry->skb); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 308 | |
| 309 | /* |
Ivo van Doorn | 2e27cff | 2009-08-29 19:10:14 +0200 | [diff] [blame] | 310 | * Determine if the frame has been successfully transmitted. |
| 311 | */ |
| 312 | success = |
| 313 | test_bit(TXDONE_SUCCESS, &txdesc->flags) || |
Helmut Schaa | fd6dcb8 | 2010-06-14 22:09:09 +0200 | [diff] [blame] | 314 | test_bit(TXDONE_UNKNOWN, &txdesc->flags); |
Ivo van Doorn | 2e27cff | 2009-08-29 19:10:14 +0200 | [diff] [blame] | 315 | |
| 316 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 317 | * Update TX statistics. |
| 318 | */ |
Ivo van Doorn | 2e27cff | 2009-08-29 19:10:14 +0200 | [diff] [blame] | 319 | rt2x00dev->link.qual.tx_success += success; |
| 320 | rt2x00dev->link.qual.tx_failed += !success; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 321 | |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 322 | rate_idx = skbdesc->tx_rate_idx; |
| 323 | rate_flags = skbdesc->tx_rate_flags; |
Benoit PAPILLAULT | 92ed48e | 2009-08-17 18:56:10 +0200 | [diff] [blame] | 324 | retry_rates = test_bit(TXDONE_FALLBACK, &txdesc->flags) ? |
| 325 | (txdesc->retry + 1) : 1; |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 326 | |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 327 | /* |
| 328 | * Initialize TX status |
| 329 | */ |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 330 | memset(&tx_info->status, 0, sizeof(tx_info->status)); |
| 331 | tx_info->status.ack_signal = 0; |
Benoit PAPILLAULT | 92ed48e | 2009-08-17 18:56:10 +0200 | [diff] [blame] | 332 | |
| 333 | /* |
| 334 | * Frame was send with retries, hardware tried |
| 335 | * different rates to send out the frame, at each |
Helmut Schaa | 3d2bc10 | 2010-06-14 22:12:26 +0200 | [diff] [blame] | 336 | * retry it lowered the rate 1 step except when the |
| 337 | * lowest rate was used. |
Benoit PAPILLAULT | 92ed48e | 2009-08-17 18:56:10 +0200 | [diff] [blame] | 338 | */ |
| 339 | for (i = 0; i < retry_rates && i < IEEE80211_TX_MAX_RATES; i++) { |
| 340 | tx_info->status.rates[i].idx = rate_idx - i; |
| 341 | tx_info->status.rates[i].flags = rate_flags; |
Helmut Schaa | 3d2bc10 | 2010-06-14 22:12:26 +0200 | [diff] [blame] | 342 | |
| 343 | if (rate_idx - i == 0) { |
| 344 | /* |
| 345 | * The lowest rate (index 0) was used until the |
| 346 | * number of max retries was reached. |
| 347 | */ |
| 348 | tx_info->status.rates[i].count = retry_rates - i; |
| 349 | i++; |
| 350 | break; |
| 351 | } |
Benoit PAPILLAULT | 92ed48e | 2009-08-17 18:56:10 +0200 | [diff] [blame] | 352 | tx_info->status.rates[i].count = 1; |
| 353 | } |
Ivo van Doorn | 2e27cff | 2009-08-29 19:10:14 +0200 | [diff] [blame] | 354 | if (i < (IEEE80211_TX_MAX_RATES - 1)) |
Benoit PAPILLAULT | 92ed48e | 2009-08-17 18:56:10 +0200 | [diff] [blame] | 355 | tx_info->status.rates[i].idx = -1; /* terminate */ |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 356 | |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 357 | if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK)) { |
Ivo van Doorn | 2e27cff | 2009-08-29 19:10:14 +0200 | [diff] [blame] | 358 | if (success) |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 359 | tx_info->flags |= IEEE80211_TX_STAT_ACK; |
Ivo van Doorn | 2e27cff | 2009-08-29 19:10:14 +0200 | [diff] [blame] | 360 | else |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 361 | rt2x00dev->low_level_stats.dot11ACKFailureCount++; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 362 | } |
| 363 | |
Helmut Schaa | 1df9080 | 2010-06-29 21:38:12 +0200 | [diff] [blame] | 364 | /* |
| 365 | * Every single frame has it's own tx status, hence report |
| 366 | * every frame as ampdu of size 1. |
| 367 | * |
| 368 | * TODO: if we can find out how many frames were aggregated |
| 369 | * by the hw we could provide the real ampdu_len to mac80211 |
| 370 | * which would allow the rc algorithm to better decide on |
| 371 | * which rates are suitable. |
| 372 | */ |
| 373 | if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { |
| 374 | tx_info->flags |= IEEE80211_TX_STAT_AMPDU; |
| 375 | tx_info->status.ampdu_len = 1; |
| 376 | tx_info->status.ampdu_ack_len = success ? 1 : 0; |
| 377 | } |
| 378 | |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 379 | if (rate_flags & IEEE80211_TX_RC_USE_RTS_CTS) { |
Ivo van Doorn | 2e27cff | 2009-08-29 19:10:14 +0200 | [diff] [blame] | 380 | if (success) |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 381 | rt2x00dev->low_level_stats.dot11RTSSuccessCount++; |
Ivo van Doorn | 2e27cff | 2009-08-29 19:10:14 +0200 | [diff] [blame] | 382 | else |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 383 | rt2x00dev->low_level_stats.dot11RTSFailureCount++; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | /* |
Johannes Berg | 7351c6b | 2009-11-19 01:08:30 +0100 | [diff] [blame] | 387 | * Only send the status report to mac80211 when it's a frame |
| 388 | * that originated in mac80211. If this was a extra frame coming |
| 389 | * through a mac80211 library call (RTS/CTS) then we should not |
| 390 | * send the status report back. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 391 | */ |
Johannes Berg | 7351c6b | 2009-11-19 01:08:30 +0100 | [diff] [blame] | 392 | if (!(skbdesc_flags & SKBDESC_NOT_MAC80211)) |
Ivo van Doorn | 7e613e1 | 2010-08-06 20:45:38 +0200 | [diff] [blame] | 393 | ieee80211_tx_status(rt2x00dev->hw, entry->skb); |
Ivo van Doorn | baf26a7 | 2008-02-17 17:32:08 +0100 | [diff] [blame] | 394 | else |
Helmut Schaa | 78e256c | 2010-07-11 12:26:48 +0200 | [diff] [blame] | 395 | dev_kfree_skb_any(entry->skb); |
Ivo van Doorn | d74f5ba | 2008-06-16 19:56:54 +0200 | [diff] [blame] | 396 | |
| 397 | /* |
| 398 | * Make this entry available for reuse. |
| 399 | */ |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 400 | entry->skb = NULL; |
Ivo van Doorn | d74f5ba | 2008-06-16 19:56:54 +0200 | [diff] [blame] | 401 | entry->flags = 0; |
| 402 | |
Ivo van Doorn | 798b7ad | 2008-11-08 15:25:33 +0100 | [diff] [blame] | 403 | rt2x00dev->ops->lib->clear_entry(entry); |
Ivo van Doorn | d74f5ba | 2008-06-16 19:56:54 +0200 | [diff] [blame] | 404 | |
Ivo van Doorn | d74f5ba | 2008-06-16 19:56:54 +0200 | [diff] [blame] | 405 | rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE); |
| 406 | |
| 407 | /* |
| 408 | * If the data queue was below the threshold before the txdone |
| 409 | * handler we must make sure the packet queue in the mac80211 stack |
| 410 | * is reenabled when the txdone handler has finished. |
| 411 | */ |
| 412 | if (!rt2x00queue_threshold(entry->queue)) |
| 413 | ieee80211_wake_queue(rt2x00dev->hw, qid); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 414 | } |
| 415 | EXPORT_SYMBOL_GPL(rt2x00lib_txdone); |
| 416 | |
Ivo van Doorn | 3392bec | 2010-08-06 20:46:53 +0200 | [diff] [blame] | 417 | void rt2x00lib_txdone_noinfo(struct queue_entry *entry, u32 status) |
| 418 | { |
| 419 | struct txdone_entry_desc txdesc; |
| 420 | |
| 421 | txdesc.flags = 0; |
| 422 | __set_bit(status, &txdesc.flags); |
| 423 | txdesc.retry = 0; |
| 424 | |
| 425 | rt2x00lib_txdone(entry, &txdesc); |
| 426 | } |
| 427 | EXPORT_SYMBOL_GPL(rt2x00lib_txdone_noinfo); |
| 428 | |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 429 | static int rt2x00lib_rxdone_read_signal(struct rt2x00_dev *rt2x00dev, |
| 430 | struct rxdone_entry_desc *rxdesc) |
| 431 | { |
| 432 | struct ieee80211_supported_band *sband; |
| 433 | const struct rt2x00_rate *rate; |
| 434 | unsigned int i; |
| 435 | int signal; |
| 436 | int type; |
| 437 | |
| 438 | /* |
| 439 | * For non-HT rates the MCS value needs to contain the |
| 440 | * actually used rate modulation (CCK or OFDM). |
| 441 | */ |
| 442 | if (rxdesc->dev_flags & RXDONE_SIGNAL_MCS) |
| 443 | signal = RATE_MCS(rxdesc->rate_mode, rxdesc->signal); |
| 444 | else |
| 445 | signal = rxdesc->signal; |
| 446 | |
| 447 | type = (rxdesc->dev_flags & RXDONE_SIGNAL_MASK); |
| 448 | |
| 449 | sband = &rt2x00dev->bands[rt2x00dev->curr_band]; |
| 450 | for (i = 0; i < sband->n_bitrates; i++) { |
| 451 | rate = rt2x00_get_rate(sband->bitrates[i].hw_value); |
| 452 | |
| 453 | if (((type == RXDONE_SIGNAL_PLCP) && |
| 454 | (rate->plcp == signal)) || |
| 455 | ((type == RXDONE_SIGNAL_BITRATE) && |
| 456 | (rate->bitrate == signal)) || |
| 457 | ((type == RXDONE_SIGNAL_MCS) && |
| 458 | (rate->mcs == signal))) { |
| 459 | return i; |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | WARNING(rt2x00dev, "Frame received with unrecognized signal, " |
| 464 | "signal=0x%.4x, type=%d.\n", signal, type); |
| 465 | return 0; |
| 466 | } |
| 467 | |
Gertjan van Wingerde | c4da004 | 2008-06-16 19:56:31 +0200 | [diff] [blame] | 468 | void rt2x00lib_rxdone(struct rt2x00_dev *rt2x00dev, |
| 469 | struct queue_entry *entry) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 470 | { |
Gertjan van Wingerde | c4da004 | 2008-06-16 19:56:31 +0200 | [diff] [blame] | 471 | struct rxdone_entry_desc rxdesc; |
| 472 | struct sk_buff *skb; |
Ivo van Doorn | e5ef5ba | 2010-08-06 20:49:27 +0200 | [diff] [blame] | 473 | struct ieee80211_rx_status *rx_status; |
Ivo van Doorn | 2bb057d | 2008-08-04 16:37:44 +0200 | [diff] [blame] | 474 | unsigned int header_length; |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 475 | int rate_idx; |
Ivo van Doorn | 7e613e1 | 2010-08-06 20:45:38 +0200 | [diff] [blame] | 476 | |
| 477 | if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags)) |
| 478 | goto submit_entry; |
| 479 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 480 | /* |
Gertjan van Wingerde | c4da004 | 2008-06-16 19:56:31 +0200 | [diff] [blame] | 481 | * Allocate a new sk_buffer. If no new buffer available, drop the |
| 482 | * received frame and reuse the existing buffer. |
| 483 | */ |
| 484 | skb = rt2x00queue_alloc_rxskb(rt2x00dev, entry); |
| 485 | if (!skb) |
| 486 | return; |
| 487 | |
| 488 | /* |
| 489 | * Unmap the skb. |
| 490 | */ |
| 491 | rt2x00queue_unmap_skb(rt2x00dev, entry->skb); |
| 492 | |
| 493 | /* |
| 494 | * Extract the RXD details. |
| 495 | */ |
| 496 | memset(&rxdesc, 0, sizeof(rxdesc)); |
| 497 | rt2x00dev->ops->lib->fill_rxdone(entry, &rxdesc); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 498 | |
| 499 | /* |
Gertjan van Wingerde | 239c249 | 2008-06-06 22:54:12 +0200 | [diff] [blame] | 500 | * The data behind the ieee80211 header must be |
Gertjan van Wingerde | a9f853d | 2008-06-07 16:57:09 +0200 | [diff] [blame] | 501 | * aligned on a 4 byte boundary. |
Gertjan van Wingerde | 239c249 | 2008-06-06 22:54:12 +0200 | [diff] [blame] | 502 | */ |
Ivo van Doorn | 2bb057d | 2008-08-04 16:37:44 +0200 | [diff] [blame] | 503 | header_length = ieee80211_get_hdrlen_from_skb(entry->skb); |
Gertjan van Wingerde | 239c249 | 2008-06-06 22:54:12 +0200 | [diff] [blame] | 504 | |
Ivo van Doorn | 2bb057d | 2008-08-04 16:37:44 +0200 | [diff] [blame] | 505 | /* |
| 506 | * Hardware might have stripped the IV/EIV/ICV data, |
| 507 | * in that case it is possible that the data was |
Daniel Mack | 3ad2f3fb | 2010-02-03 08:01:28 +0800 | [diff] [blame] | 508 | * provided separately (through hardware descriptor) |
Ivo van Doorn | 2bb057d | 2008-08-04 16:37:44 +0200 | [diff] [blame] | 509 | * in which case we should reinsert the data into the frame. |
| 510 | */ |
Ivo van Doorn | 74415ed | 2008-12-02 22:50:33 +0100 | [diff] [blame] | 511 | if ((rxdesc.dev_flags & RXDONE_CRYPTO_IV) && |
Ivo van Doorn | 9f16617 | 2009-04-26 16:08:50 +0200 | [diff] [blame] | 512 | (rxdesc.flags & RX_FLAG_IV_STRIPPED)) |
Ivo van Doorn | daee6c0 | 2009-08-29 20:30:45 +0200 | [diff] [blame] | 513 | rt2x00crypto_rx_insert_iv(entry->skb, header_length, |
Ivo van Doorn | 9f16617 | 2009-04-26 16:08:50 +0200 | [diff] [blame] | 514 | &rxdesc); |
Gertjan van Wingerde | b734083 | 2009-12-04 23:47:04 +0100 | [diff] [blame] | 515 | else if (header_length && |
| 516 | (rxdesc.size > header_length) && |
| 517 | (rxdesc.dev_flags & RXDONE_L2PAD)) |
Ivo van Doorn | daee6c0 | 2009-08-29 20:30:45 +0200 | [diff] [blame] | 518 | rt2x00queue_remove_l2pad(entry->skb, header_length); |
Ivo van Doorn | 9f16617 | 2009-04-26 16:08:50 +0200 | [diff] [blame] | 519 | else |
Ivo van Doorn | daee6c0 | 2009-08-29 20:30:45 +0200 | [diff] [blame] | 520 | rt2x00queue_align_payload(entry->skb, header_length); |
Gertjan van Wingerde | 239c249 | 2008-06-06 22:54:12 +0200 | [diff] [blame] | 521 | |
Alban Browaeys | 1398d45 | 2009-12-04 23:47:00 +0100 | [diff] [blame] | 522 | /* Trim buffer to correct size */ |
| 523 | skb_trim(entry->skb, rxdesc.size); |
| 524 | |
Gertjan van Wingerde | 239c249 | 2008-06-06 22:54:12 +0200 | [diff] [blame] | 525 | /* |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 526 | * Check if the frame was received using HT. In that case, |
| 527 | * the rate is the MCS index and should be passed to mac80211 |
| 528 | * directly. Otherwise we need to translate the signal to |
| 529 | * the correct bitrate index. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 530 | */ |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 531 | if (rxdesc.rate_mode == RATE_MODE_CCK || |
| 532 | rxdesc.rate_mode == RATE_MODE_OFDM) { |
| 533 | rate_idx = rt2x00lib_rxdone_read_signal(rt2x00dev, &rxdesc); |
| 534 | } else { |
| 535 | rxdesc.flags |= RX_FLAG_HT; |
| 536 | rate_idx = rxdesc.signal; |
Ivo van Doorn | 866a050 | 2008-03-25 14:12:45 +0100 | [diff] [blame] | 537 | } |
| 538 | |
Mattias Nissler | 61af43c | 2007-11-27 21:50:26 +0100 | [diff] [blame] | 539 | /* |
Ivo van Doorn | 84e3196 | 2008-12-20 10:53:29 +0100 | [diff] [blame] | 540 | * Update extra components |
Mattias Nissler | 61af43c | 2007-11-27 21:50:26 +0100 | [diff] [blame] | 541 | */ |
Ivo van Doorn | 84e3196 | 2008-12-20 10:53:29 +0100 | [diff] [blame] | 542 | rt2x00link_update_stats(rt2x00dev, entry->skb, &rxdesc); |
| 543 | rt2x00debug_update_crypto(rt2x00dev, &rxdesc); |
Ivo van Doorn | e5ef5ba | 2010-08-06 20:49:27 +0200 | [diff] [blame] | 544 | rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_RXDONE, entry->skb); |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 545 | |
Ivo van Doorn | e5ef5ba | 2010-08-06 20:49:27 +0200 | [diff] [blame] | 546 | /* |
| 547 | * Initialize RX status information, and send frame |
| 548 | * to mac80211. |
| 549 | */ |
| 550 | rx_status = IEEE80211_SKB_RXCB(entry->skb); |
Ivo van Doorn | ae73e58 | 2008-07-04 16:14:59 +0200 | [diff] [blame] | 551 | rx_status->mactime = rxdesc.timestamp; |
Ivo van Doorn | e5ef5ba | 2010-08-06 20:49:27 +0200 | [diff] [blame] | 552 | rx_status->band = rt2x00dev->curr_band; |
| 553 | rx_status->freq = rt2x00dev->curr_freq; |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 554 | rx_status->rate_idx = rate_idx; |
Gertjan van Wingerde | c4da004 | 2008-06-16 19:56:31 +0200 | [diff] [blame] | 555 | rx_status->signal = rxdesc.rssi; |
| 556 | rx_status->flag = rxdesc.flags; |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 557 | rx_status->antenna = rt2x00dev->link.ant.active.rx; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 558 | |
Ivo van Doorn | 7e613e1 | 2010-08-06 20:45:38 +0200 | [diff] [blame] | 559 | ieee80211_rx_ni(rt2x00dev->hw, entry->skb); |
Gertjan van Wingerde | c4da004 | 2008-06-16 19:56:31 +0200 | [diff] [blame] | 560 | |
| 561 | /* |
| 562 | * Replace the skb with the freshly allocated one. |
| 563 | */ |
| 564 | entry->skb = skb; |
Ivo van Doorn | d74f5ba | 2008-06-16 19:56:54 +0200 | [diff] [blame] | 565 | |
Ivo van Doorn | 7e613e1 | 2010-08-06 20:45:38 +0200 | [diff] [blame] | 566 | submit_entry: |
Ivo van Doorn | 798b7ad | 2008-11-08 15:25:33 +0100 | [diff] [blame] | 567 | rt2x00dev->ops->lib->clear_entry(entry); |
Ivo van Doorn | d74f5ba | 2008-06-16 19:56:54 +0200 | [diff] [blame] | 568 | rt2x00queue_index_inc(entry->queue, Q_INDEX); |
Ivo van Doorn | 7e613e1 | 2010-08-06 20:45:38 +0200 | [diff] [blame] | 569 | rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 570 | } |
| 571 | EXPORT_SYMBOL_GPL(rt2x00lib_rxdone); |
| 572 | |
| 573 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 574 | * Driver initialization handlers. |
| 575 | */ |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 576 | const struct rt2x00_rate rt2x00_supported_rates[12] = { |
| 577 | { |
Ivo van Doorn | 3d8606a | 2008-11-02 00:36:40 +0100 | [diff] [blame] | 578 | .flags = DEV_RATE_CCK, |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 579 | .bitrate = 10, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 580 | .ratemask = BIT(0), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 581 | .plcp = 0x00, |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 582 | .mcs = RATE_MCS(RATE_MODE_CCK, 0), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 583 | }, |
| 584 | { |
Ivo van Doorn | 3d8606a | 2008-11-02 00:36:40 +0100 | [diff] [blame] | 585 | .flags = DEV_RATE_CCK | DEV_RATE_SHORT_PREAMBLE, |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 586 | .bitrate = 20, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 587 | .ratemask = BIT(1), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 588 | .plcp = 0x01, |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 589 | .mcs = RATE_MCS(RATE_MODE_CCK, 1), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 590 | }, |
| 591 | { |
Ivo van Doorn | 3d8606a | 2008-11-02 00:36:40 +0100 | [diff] [blame] | 592 | .flags = DEV_RATE_CCK | DEV_RATE_SHORT_PREAMBLE, |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 593 | .bitrate = 55, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 594 | .ratemask = BIT(2), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 595 | .plcp = 0x02, |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 596 | .mcs = RATE_MCS(RATE_MODE_CCK, 2), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 597 | }, |
| 598 | { |
Ivo van Doorn | 3d8606a | 2008-11-02 00:36:40 +0100 | [diff] [blame] | 599 | .flags = DEV_RATE_CCK | DEV_RATE_SHORT_PREAMBLE, |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 600 | .bitrate = 110, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 601 | .ratemask = BIT(3), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 602 | .plcp = 0x03, |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 603 | .mcs = RATE_MCS(RATE_MODE_CCK, 3), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 604 | }, |
| 605 | { |
Ivo van Doorn | 3d8606a | 2008-11-02 00:36:40 +0100 | [diff] [blame] | 606 | .flags = DEV_RATE_OFDM, |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 607 | .bitrate = 60, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 608 | .ratemask = BIT(4), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 609 | .plcp = 0x0b, |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 610 | .mcs = RATE_MCS(RATE_MODE_OFDM, 0), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 611 | }, |
| 612 | { |
| 613 | .flags = DEV_RATE_OFDM, |
| 614 | .bitrate = 90, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 615 | .ratemask = BIT(5), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 616 | .plcp = 0x0f, |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 617 | .mcs = RATE_MCS(RATE_MODE_OFDM, 1), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 618 | }, |
| 619 | { |
Ivo van Doorn | 3d8606a | 2008-11-02 00:36:40 +0100 | [diff] [blame] | 620 | .flags = DEV_RATE_OFDM, |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 621 | .bitrate = 120, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 622 | .ratemask = BIT(6), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 623 | .plcp = 0x0a, |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 624 | .mcs = RATE_MCS(RATE_MODE_OFDM, 2), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 625 | }, |
| 626 | { |
| 627 | .flags = DEV_RATE_OFDM, |
| 628 | .bitrate = 180, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 629 | .ratemask = BIT(7), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 630 | .plcp = 0x0e, |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 631 | .mcs = RATE_MCS(RATE_MODE_OFDM, 3), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 632 | }, |
| 633 | { |
Ivo van Doorn | 3d8606a | 2008-11-02 00:36:40 +0100 | [diff] [blame] | 634 | .flags = DEV_RATE_OFDM, |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 635 | .bitrate = 240, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 636 | .ratemask = BIT(8), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 637 | .plcp = 0x09, |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 638 | .mcs = RATE_MCS(RATE_MODE_OFDM, 4), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 639 | }, |
| 640 | { |
| 641 | .flags = DEV_RATE_OFDM, |
| 642 | .bitrate = 360, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 643 | .ratemask = BIT(9), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 644 | .plcp = 0x0d, |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 645 | .mcs = RATE_MCS(RATE_MODE_OFDM, 5), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 646 | }, |
| 647 | { |
| 648 | .flags = DEV_RATE_OFDM, |
| 649 | .bitrate = 480, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 650 | .ratemask = BIT(10), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 651 | .plcp = 0x08, |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 652 | .mcs = RATE_MCS(RATE_MODE_OFDM, 6), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 653 | }, |
| 654 | { |
| 655 | .flags = DEV_RATE_OFDM, |
| 656 | .bitrate = 540, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 657 | .ratemask = BIT(11), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 658 | .plcp = 0x0c, |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 659 | .mcs = RATE_MCS(RATE_MODE_OFDM, 7), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 660 | }, |
| 661 | }; |
| 662 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 663 | static void rt2x00lib_channel(struct ieee80211_channel *entry, |
| 664 | const int channel, const int tx_power, |
| 665 | const int value) |
| 666 | { |
Ivo van Doorn | f2a3c7f | 2008-02-03 15:52:45 +0100 | [diff] [blame] | 667 | entry->center_freq = ieee80211_channel_to_frequency(channel); |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 668 | entry->hw_value = value; |
| 669 | entry->max_power = tx_power; |
| 670 | entry->max_antenna_gain = 0xff; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 671 | } |
| 672 | |
| 673 | static void rt2x00lib_rate(struct ieee80211_rate *entry, |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 674 | const u16 index, const struct rt2x00_rate *rate) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 675 | { |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 676 | entry->flags = 0; |
| 677 | entry->bitrate = rate->bitrate; |
Ivo van Doorn | 3ea9646 | 2009-01-04 17:33:25 +0100 | [diff] [blame] | 678 | entry->hw_value =index; |
| 679 | entry->hw_value_short = index; |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 680 | |
Ivo van Doorn | 3ea9646 | 2009-01-04 17:33:25 +0100 | [diff] [blame] | 681 | if (rate->flags & DEV_RATE_SHORT_PREAMBLE) |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 682 | entry->flags |= IEEE80211_RATE_SHORT_PREAMBLE; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 683 | } |
| 684 | |
| 685 | static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev, |
| 686 | struct hw_mode_spec *spec) |
| 687 | { |
| 688 | struct ieee80211_hw *hw = rt2x00dev->hw; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 689 | struct ieee80211_channel *channels; |
| 690 | struct ieee80211_rate *rates; |
Ivo van Doorn | 31562e8 | 2008-02-17 17:35:05 +0100 | [diff] [blame] | 691 | unsigned int num_rates; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 692 | unsigned int i; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 693 | |
Ivo van Doorn | 31562e8 | 2008-02-17 17:35:05 +0100 | [diff] [blame] | 694 | num_rates = 0; |
| 695 | if (spec->supported_rates & SUPPORT_RATE_CCK) |
| 696 | num_rates += 4; |
| 697 | if (spec->supported_rates & SUPPORT_RATE_OFDM) |
| 698 | num_rates += 8; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 699 | |
| 700 | channels = kzalloc(sizeof(*channels) * spec->num_channels, GFP_KERNEL); |
| 701 | if (!channels) |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 702 | return -ENOMEM; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 703 | |
Ivo van Doorn | 31562e8 | 2008-02-17 17:35:05 +0100 | [diff] [blame] | 704 | rates = kzalloc(sizeof(*rates) * num_rates, GFP_KERNEL); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 705 | if (!rates) |
| 706 | goto exit_free_channels; |
| 707 | |
| 708 | /* |
| 709 | * Initialize Rate list. |
| 710 | */ |
Ivo van Doorn | 31562e8 | 2008-02-17 17:35:05 +0100 | [diff] [blame] | 711 | for (i = 0; i < num_rates; i++) |
Ivo van Doorn | 8f5fa7f | 2008-02-03 15:54:34 +0100 | [diff] [blame] | 712 | rt2x00lib_rate(&rates[i], i, rt2x00_get_rate(i)); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 713 | |
| 714 | /* |
| 715 | * Initialize Channel list. |
| 716 | */ |
| 717 | for (i = 0; i < spec->num_channels; i++) { |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 718 | rt2x00lib_channel(&channels[i], |
Ivo van Doorn | 8c5e7a5 | 2008-08-04 16:38:47 +0200 | [diff] [blame] | 719 | spec->channels[i].channel, |
Ivo van Doorn | 8d1331b | 2010-08-23 19:56:07 +0200 | [diff] [blame] | 720 | spec->channels_info[i].max_power, i); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 721 | } |
| 722 | |
| 723 | /* |
Ivo van Doorn | 31562e8 | 2008-02-17 17:35:05 +0100 | [diff] [blame] | 724 | * Intitialize 802.11b, 802.11g |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 725 | * Rates: CCK, OFDM. |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 726 | * Channels: 2.4 GHz |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 727 | */ |
Gertjan van Wingerde | 47ac268 | 2008-02-17 17:35:55 +0100 | [diff] [blame] | 728 | if (spec->supported_bands & SUPPORT_BAND_2GHZ) { |
Ivo van Doorn | 31562e8 | 2008-02-17 17:35:05 +0100 | [diff] [blame] | 729 | rt2x00dev->bands[IEEE80211_BAND_2GHZ].n_channels = 14; |
| 730 | rt2x00dev->bands[IEEE80211_BAND_2GHZ].n_bitrates = num_rates; |
| 731 | rt2x00dev->bands[IEEE80211_BAND_2GHZ].channels = channels; |
| 732 | rt2x00dev->bands[IEEE80211_BAND_2GHZ].bitrates = rates; |
| 733 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = |
| 734 | &rt2x00dev->bands[IEEE80211_BAND_2GHZ]; |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 735 | memcpy(&rt2x00dev->bands[IEEE80211_BAND_2GHZ].ht_cap, |
| 736 | &spec->ht, sizeof(spec->ht)); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 737 | } |
| 738 | |
| 739 | /* |
| 740 | * Intitialize 802.11a |
| 741 | * Rates: OFDM. |
| 742 | * Channels: OFDM, UNII, HiperLAN2. |
| 743 | */ |
Gertjan van Wingerde | 47ac268 | 2008-02-17 17:35:55 +0100 | [diff] [blame] | 744 | if (spec->supported_bands & SUPPORT_BAND_5GHZ) { |
Ivo van Doorn | 31562e8 | 2008-02-17 17:35:05 +0100 | [diff] [blame] | 745 | rt2x00dev->bands[IEEE80211_BAND_5GHZ].n_channels = |
| 746 | spec->num_channels - 14; |
| 747 | rt2x00dev->bands[IEEE80211_BAND_5GHZ].n_bitrates = |
| 748 | num_rates - 4; |
| 749 | rt2x00dev->bands[IEEE80211_BAND_5GHZ].channels = &channels[14]; |
| 750 | rt2x00dev->bands[IEEE80211_BAND_5GHZ].bitrates = &rates[4]; |
| 751 | hw->wiphy->bands[IEEE80211_BAND_5GHZ] = |
| 752 | &rt2x00dev->bands[IEEE80211_BAND_5GHZ]; |
Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 753 | memcpy(&rt2x00dev->bands[IEEE80211_BAND_5GHZ].ht_cap, |
| 754 | &spec->ht, sizeof(spec->ht)); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 755 | } |
| 756 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 757 | return 0; |
| 758 | |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 759 | exit_free_channels: |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 760 | kfree(channels); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 761 | ERROR(rt2x00dev, "Allocation ieee80211 modes failed.\n"); |
| 762 | return -ENOMEM; |
| 763 | } |
| 764 | |
| 765 | static void rt2x00lib_remove_hw(struct rt2x00_dev *rt2x00dev) |
| 766 | { |
Ivo van Doorn | 0262ab0 | 2008-08-29 21:04:26 +0200 | [diff] [blame] | 767 | if (test_bit(DEVICE_STATE_REGISTERED_HW, &rt2x00dev->flags)) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 768 | ieee80211_unregister_hw(rt2x00dev->hw); |
| 769 | |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 770 | if (likely(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ])) { |
| 771 | kfree(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->channels); |
| 772 | kfree(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->bitrates); |
| 773 | rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = NULL; |
| 774 | rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 775 | } |
Ivo van Doorn | 8c5e7a5 | 2008-08-04 16:38:47 +0200 | [diff] [blame] | 776 | |
| 777 | kfree(rt2x00dev->spec.channels_info); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 778 | } |
| 779 | |
| 780 | static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev) |
| 781 | { |
| 782 | struct hw_mode_spec *spec = &rt2x00dev->spec; |
| 783 | int status; |
| 784 | |
Ivo van Doorn | 0262ab0 | 2008-08-29 21:04:26 +0200 | [diff] [blame] | 785 | if (test_bit(DEVICE_STATE_REGISTERED_HW, &rt2x00dev->flags)) |
| 786 | return 0; |
| 787 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 788 | /* |
| 789 | * Initialize HW modes. |
| 790 | */ |
| 791 | status = rt2x00lib_probe_hw_modes(rt2x00dev, spec); |
| 792 | if (status) |
| 793 | return status; |
| 794 | |
| 795 | /* |
Gertjan van Wingerde | 61448f8 | 2008-05-10 13:43:33 +0200 | [diff] [blame] | 796 | * Initialize HW fields. |
| 797 | */ |
| 798 | rt2x00dev->hw->queues = rt2x00dev->ops->tx_queues; |
| 799 | |
| 800 | /* |
Gertjan van Wingerde | e6218cc | 2009-11-23 22:44:52 +0100 | [diff] [blame] | 801 | * Initialize extra TX headroom required. |
| 802 | */ |
Gertjan van Wingerde | 7a4a77b | 2009-12-30 11:36:30 +0100 | [diff] [blame] | 803 | rt2x00dev->hw->extra_tx_headroom = |
| 804 | max_t(unsigned int, IEEE80211_TX_STATUS_HEADROOM, |
| 805 | rt2x00dev->ops->extra_tx_headroom); |
| 806 | |
| 807 | /* |
| 808 | * Take TX headroom required for alignment into account. |
| 809 | */ |
| 810 | if (test_bit(DRIVER_REQUIRE_L2PAD, &rt2x00dev->flags)) |
| 811 | rt2x00dev->hw->extra_tx_headroom += RT2X00_L2PAD_SIZE; |
| 812 | else if (test_bit(DRIVER_REQUIRE_DMA, &rt2x00dev->flags)) |
| 813 | rt2x00dev->hw->extra_tx_headroom += RT2X00_ALIGN_SIZE; |
Gertjan van Wingerde | e6218cc | 2009-11-23 22:44:52 +0100 | [diff] [blame] | 814 | |
| 815 | /* |
Helmut Schaa | 96c3da7 | 2010-10-02 11:27:35 +0200 | [diff] [blame^] | 816 | * Allocate tx status FIFO for driver use. |
| 817 | */ |
| 818 | if (test_bit(DRIVER_REQUIRE_TXSTATUS_FIFO, &rt2x00dev->flags) && |
| 819 | rt2x00dev->ops->lib->txstatus_tasklet) { |
| 820 | /* |
| 821 | * Allocate txstatus fifo and tasklet, we use a size of 512 |
| 822 | * for the kfifo which is big enough to store 512/4=128 tx |
| 823 | * status reports. In the worst case (tx status for all tx |
| 824 | * queues gets reported before we've got a chance to handle |
| 825 | * them) 24*4=384 tx status reports need to be cached. |
| 826 | */ |
| 827 | status = kfifo_alloc(&rt2x00dev->txstatus_fifo, 512, |
| 828 | GFP_KERNEL); |
| 829 | if (status) |
| 830 | return status; |
| 831 | |
| 832 | /* tasklet for processing the tx status reports. */ |
| 833 | tasklet_init(&rt2x00dev->txstatus_tasklet, |
| 834 | rt2x00dev->ops->lib->txstatus_tasklet, |
| 835 | (unsigned long)rt2x00dev); |
| 836 | |
| 837 | } |
| 838 | |
| 839 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 840 | * Register HW. |
| 841 | */ |
| 842 | status = ieee80211_register_hw(rt2x00dev->hw); |
Herton Ronaldo Krzesinski | f05faa3 | 2009-04-10 18:05:14 -0300 | [diff] [blame] | 843 | if (status) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 844 | return status; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 845 | |
Ivo van Doorn | 0262ab0 | 2008-08-29 21:04:26 +0200 | [diff] [blame] | 846 | set_bit(DEVICE_STATE_REGISTERED_HW, &rt2x00dev->flags); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 847 | |
| 848 | return 0; |
| 849 | } |
| 850 | |
| 851 | /* |
| 852 | * Initialization/uninitialization handlers. |
| 853 | */ |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 854 | static void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 855 | { |
Ivo van Doorn | 0262ab0 | 2008-08-29 21:04:26 +0200 | [diff] [blame] | 856 | if (!test_and_clear_bit(DEVICE_STATE_INITIALIZED, &rt2x00dev->flags)) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 857 | return; |
| 858 | |
| 859 | /* |
Ivo van Doorn | 1682fe6 | 2008-03-13 15:38:03 +0100 | [diff] [blame] | 860 | * Unregister extra components. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 861 | */ |
| 862 | rt2x00rfkill_unregister(rt2x00dev); |
| 863 | |
| 864 | /* |
| 865 | * Allow the HW to uninitialize. |
| 866 | */ |
| 867 | rt2x00dev->ops->lib->uninitialize(rt2x00dev); |
| 868 | |
| 869 | /* |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 870 | * Free allocated queue entries. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 871 | */ |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 872 | rt2x00queue_uninitialize(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 873 | } |
| 874 | |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 875 | static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 876 | { |
| 877 | int status; |
| 878 | |
Ivo van Doorn | 0262ab0 | 2008-08-29 21:04:26 +0200 | [diff] [blame] | 879 | if (test_bit(DEVICE_STATE_INITIALIZED, &rt2x00dev->flags)) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 880 | return 0; |
| 881 | |
| 882 | /* |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 883 | * Allocate all queue entries. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 884 | */ |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 885 | status = rt2x00queue_initialize(rt2x00dev); |
| 886 | if (status) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 887 | return status; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 888 | |
| 889 | /* |
| 890 | * Initialize the device. |
| 891 | */ |
| 892 | status = rt2x00dev->ops->lib->initialize(rt2x00dev); |
Ivo van Doorn | ed49998 | 2008-05-05 17:23:47 +0200 | [diff] [blame] | 893 | if (status) { |
| 894 | rt2x00queue_uninitialize(rt2x00dev); |
| 895 | return status; |
| 896 | } |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 897 | |
Ivo van Doorn | 0262ab0 | 2008-08-29 21:04:26 +0200 | [diff] [blame] | 898 | set_bit(DEVICE_STATE_INITIALIZED, &rt2x00dev->flags); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 899 | |
| 900 | /* |
Ivo van Doorn | 1682fe6 | 2008-03-13 15:38:03 +0100 | [diff] [blame] | 901 | * Register the extra components. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 902 | */ |
Ivo van Doorn | 1682fe6 | 2008-03-13 15:38:03 +0100 | [diff] [blame] | 903 | rt2x00rfkill_register(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 904 | |
| 905 | return 0; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 906 | } |
| 907 | |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 908 | int rt2x00lib_start(struct rt2x00_dev *rt2x00dev) |
| 909 | { |
| 910 | int retval; |
| 911 | |
Ivo van Doorn | 0262ab0 | 2008-08-29 21:04:26 +0200 | [diff] [blame] | 912 | if (test_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags)) |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 913 | return 0; |
| 914 | |
| 915 | /* |
| 916 | * If this is the first interface which is added, |
| 917 | * we should load the firmware now. |
| 918 | */ |
Ivo van Doorn | 9404ef3 | 2008-02-03 15:48:38 +0100 | [diff] [blame] | 919 | retval = rt2x00lib_load_firmware(rt2x00dev); |
| 920 | if (retval) |
| 921 | return retval; |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 922 | |
| 923 | /* |
| 924 | * Initialize the device. |
| 925 | */ |
| 926 | retval = rt2x00lib_initialize(rt2x00dev); |
| 927 | if (retval) |
| 928 | return retval; |
| 929 | |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 930 | rt2x00dev->intf_ap_count = 0; |
| 931 | rt2x00dev->intf_sta_count = 0; |
| 932 | rt2x00dev->intf_associated = 0; |
| 933 | |
Ivo van Doorn | bdfa500 | 2009-08-08 23:53:04 +0200 | [diff] [blame] | 934 | /* Enable the radio */ |
| 935 | retval = rt2x00lib_enable_radio(rt2x00dev); |
| 936 | if (retval) { |
| 937 | rt2x00queue_uninitialize(rt2x00dev); |
| 938 | return retval; |
| 939 | } |
| 940 | |
Ivo van Doorn | 0262ab0 | 2008-08-29 21:04:26 +0200 | [diff] [blame] | 941 | set_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags); |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 942 | |
| 943 | return 0; |
| 944 | } |
| 945 | |
| 946 | void rt2x00lib_stop(struct rt2x00_dev *rt2x00dev) |
| 947 | { |
Ivo van Doorn | 0262ab0 | 2008-08-29 21:04:26 +0200 | [diff] [blame] | 948 | if (!test_and_clear_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags)) |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 949 | return; |
| 950 | |
| 951 | /* |
| 952 | * Perhaps we can add something smarter here, |
| 953 | * but for now just disabling the radio should do. |
| 954 | */ |
| 955 | rt2x00lib_disable_radio(rt2x00dev); |
| 956 | |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 957 | rt2x00dev->intf_ap_count = 0; |
| 958 | rt2x00dev->intf_sta_count = 0; |
| 959 | rt2x00dev->intf_associated = 0; |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 960 | } |
| 961 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 962 | /* |
| 963 | * driver allocation handlers. |
| 964 | */ |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 965 | int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev) |
| 966 | { |
| 967 | int retval = -ENOMEM; |
| 968 | |
Ivo van Doorn | 8ff48a8 | 2008-11-09 23:40:46 +0100 | [diff] [blame] | 969 | mutex_init(&rt2x00dev->csr_mutex); |
| 970 | |
Sean Cross | 66f84d6 | 2009-11-05 20:22:03 +0100 | [diff] [blame] | 971 | set_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags); |
| 972 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 973 | /* |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 974 | * Make room for rt2x00_intf inside the per-interface |
| 975 | * structure ieee80211_vif. |
| 976 | */ |
| 977 | rt2x00dev->hw->vif_data_size = sizeof(struct rt2x00_intf); |
| 978 | |
Ivo van Doorn | 3514a44 | 2008-10-29 17:18:46 +0100 | [diff] [blame] | 979 | /* |
| 980 | * Determine which operating modes are supported, all modes |
| 981 | * which require beaconing, depend on the availability of |
| 982 | * beacon entries. |
| 983 | */ |
| 984 | rt2x00dev->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); |
| 985 | if (rt2x00dev->ops->bcn->entry_num > 0) |
| 986 | rt2x00dev->hw->wiphy->interface_modes |= |
| 987 | BIT(NL80211_IFTYPE_ADHOC) | |
Andrey Yurovsky | a07dbea | 2008-12-20 10:55:34 +0100 | [diff] [blame] | 988 | BIT(NL80211_IFTYPE_AP) | |
Ivo van Doorn | ce292a6 | 2008-12-20 10:57:02 +0100 | [diff] [blame] | 989 | BIT(NL80211_IFTYPE_MESH_POINT) | |
| 990 | BIT(NL80211_IFTYPE_WDS); |
Luis R. Rodriguez | f59ac04 | 2008-08-29 16:26:43 -0700 | [diff] [blame] | 991 | |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 992 | /* |
Stephen Boyd | 9acd56d | 2010-07-16 09:50:10 -0700 | [diff] [blame] | 993 | * Initialize configuration work. |
| 994 | */ |
| 995 | INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled); |
| 996 | |
| 997 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 998 | * Let the driver probe the device to detect the capabilities. |
| 999 | */ |
| 1000 | retval = rt2x00dev->ops->lib->probe_hw(rt2x00dev); |
| 1001 | if (retval) { |
| 1002 | ERROR(rt2x00dev, "Failed to allocate device.\n"); |
| 1003 | goto exit; |
| 1004 | } |
| 1005 | |
| 1006 | /* |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 1007 | * Allocate queue array. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1008 | */ |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 1009 | retval = rt2x00queue_allocate(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1010 | if (retval) |
| 1011 | goto exit; |
| 1012 | |
| 1013 | /* |
| 1014 | * Initialize ieee80211 structure. |
| 1015 | */ |
| 1016 | retval = rt2x00lib_probe_hw(rt2x00dev); |
| 1017 | if (retval) { |
| 1018 | ERROR(rt2x00dev, "Failed to initialize hw.\n"); |
| 1019 | goto exit; |
| 1020 | } |
| 1021 | |
| 1022 | /* |
Ivo van Doorn | 1682fe6 | 2008-03-13 15:38:03 +0100 | [diff] [blame] | 1023 | * Register extra components. |
Ivo van Doorn | a9450b7 | 2008-02-03 15:53:40 +0100 | [diff] [blame] | 1024 | */ |
Ivo van Doorn | 84e3196 | 2008-12-20 10:53:29 +0100 | [diff] [blame] | 1025 | rt2x00link_register(rt2x00dev); |
Ivo van Doorn | a9450b7 | 2008-02-03 15:53:40 +0100 | [diff] [blame] | 1026 | rt2x00leds_register(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1027 | rt2x00debug_register(rt2x00dev); |
| 1028 | |
| 1029 | return 0; |
| 1030 | |
| 1031 | exit: |
| 1032 | rt2x00lib_remove_dev(rt2x00dev); |
| 1033 | |
| 1034 | return retval; |
| 1035 | } |
| 1036 | EXPORT_SYMBOL_GPL(rt2x00lib_probe_dev); |
| 1037 | |
| 1038 | void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev) |
| 1039 | { |
Ivo van Doorn | 0262ab0 | 2008-08-29 21:04:26 +0200 | [diff] [blame] | 1040 | clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags); |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame] | 1041 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1042 | /* |
| 1043 | * Disable radio. |
| 1044 | */ |
| 1045 | rt2x00lib_disable_radio(rt2x00dev); |
| 1046 | |
| 1047 | /* |
Pavel Roskin | d8cc892 | 2009-08-02 14:30:15 -0400 | [diff] [blame] | 1048 | * Stop all work. |
| 1049 | */ |
Pavel Roskin | d8cc892 | 2009-08-02 14:30:15 -0400 | [diff] [blame] | 1050 | cancel_work_sync(&rt2x00dev->intf_work); |
Ivo van Doorn | 7e613e1 | 2010-08-06 20:45:38 +0200 | [diff] [blame] | 1051 | cancel_work_sync(&rt2x00dev->rxdone_work); |
| 1052 | cancel_work_sync(&rt2x00dev->txdone_work); |
Pavel Roskin | d8cc892 | 2009-08-02 14:30:15 -0400 | [diff] [blame] | 1053 | |
| 1054 | /* |
Helmut Schaa | 96c3da7 | 2010-10-02 11:27:35 +0200 | [diff] [blame^] | 1055 | * Free the tx status fifo. |
| 1056 | */ |
| 1057 | kfifo_free(&rt2x00dev->txstatus_fifo); |
| 1058 | |
| 1059 | /* |
| 1060 | * Kill the tx status tasklet. |
| 1061 | */ |
| 1062 | tasklet_kill(&rt2x00dev->txstatus_tasklet); |
| 1063 | |
| 1064 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1065 | * Uninitialize device. |
| 1066 | */ |
| 1067 | rt2x00lib_uninitialize(rt2x00dev); |
| 1068 | |
| 1069 | /* |
Ivo van Doorn | 1682fe6 | 2008-03-13 15:38:03 +0100 | [diff] [blame] | 1070 | * Free extra components |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1071 | */ |
| 1072 | rt2x00debug_deregister(rt2x00dev); |
Ivo van Doorn | a9450b7 | 2008-02-03 15:53:40 +0100 | [diff] [blame] | 1073 | rt2x00leds_unregister(rt2x00dev); |
| 1074 | |
| 1075 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1076 | * Free ieee80211_hw memory. |
| 1077 | */ |
| 1078 | rt2x00lib_remove_hw(rt2x00dev); |
| 1079 | |
| 1080 | /* |
| 1081 | * Free firmware image. |
| 1082 | */ |
| 1083 | rt2x00lib_free_firmware(rt2x00dev); |
| 1084 | |
| 1085 | /* |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 1086 | * Free queue structures. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1087 | */ |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 1088 | rt2x00queue_free(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1089 | } |
| 1090 | EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev); |
| 1091 | |
| 1092 | /* |
| 1093 | * Device state handlers |
| 1094 | */ |
| 1095 | #ifdef CONFIG_PM |
| 1096 | int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state) |
| 1097 | { |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1098 | NOTICE(rt2x00dev, "Going to sleep.\n"); |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame] | 1099 | |
| 1100 | /* |
Ivo van Doorn | 0712612 | 2009-01-23 17:04:05 +0100 | [diff] [blame] | 1101 | * Prevent mac80211 from accessing driver while suspended. |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame] | 1102 | */ |
Ivo van Doorn | 0712612 | 2009-01-23 17:04:05 +0100 | [diff] [blame] | 1103 | if (!test_and_clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags)) |
| 1104 | return 0; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1105 | |
| 1106 | /* |
Ivo van Doorn | 0712612 | 2009-01-23 17:04:05 +0100 | [diff] [blame] | 1107 | * Cleanup as much as possible. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1108 | */ |
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 | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1115 | rt2x00debug_deregister(rt2x00dev); |
| 1116 | |
| 1117 | /* |
Ivo van Doorn | 9896322 | 2008-03-27 17:15:24 +0100 | [diff] [blame] | 1118 | * Set device mode to sleep for power management, |
| 1119 | * on some hardware this call seems to consistently fail. |
| 1120 | * From the specifications it is hard to tell why it fails, |
| 1121 | * and if this is a "bad thing". |
| 1122 | * Overall it is safe to just ignore the failure and |
| 1123 | * continue suspending. The only downside is that the |
| 1124 | * device will not be in optimal power save mode, but with |
| 1125 | * the radio and the other components already disabled the |
| 1126 | * device is as good as disabled. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1127 | */ |
Ivo van Doorn | 0712612 | 2009-01-23 17:04:05 +0100 | [diff] [blame] | 1128 | if (rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_SLEEP)) |
Ivo van Doorn | 9896322 | 2008-03-27 17:15:24 +0100 | [diff] [blame] | 1129 | WARNING(rt2x00dev, "Device failed to enter sleep state, " |
| 1130 | "continue suspending.\n"); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1131 | |
| 1132 | return 0; |
| 1133 | } |
| 1134 | EXPORT_SYMBOL_GPL(rt2x00lib_suspend); |
| 1135 | |
| 1136 | int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev) |
| 1137 | { |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1138 | NOTICE(rt2x00dev, "Waking up.\n"); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1139 | |
| 1140 | /* |
Ivo van Doorn | 1682fe6 | 2008-03-13 15:38:03 +0100 | [diff] [blame] | 1141 | * Restore/enable extra components. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1142 | */ |
| 1143 | rt2x00debug_register(rt2x00dev); |
Ivo van Doorn | a9450b7 | 2008-02-03 15:53:40 +0100 | [diff] [blame] | 1144 | rt2x00leds_resume(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1145 | |
| 1146 | /* |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 1147 | * We are ready again to receive requests from mac80211. |
| 1148 | */ |
Ivo van Doorn | 0262ab0 | 2008-08-29 21:04:26 +0200 | [diff] [blame] | 1149 | set_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags); |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 1150 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1151 | return 0; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1152 | } |
| 1153 | EXPORT_SYMBOL_GPL(rt2x00lib_resume); |
| 1154 | #endif /* CONFIG_PM */ |
| 1155 | |
| 1156 | /* |
| 1157 | * rt2x00lib module information. |
| 1158 | */ |
| 1159 | MODULE_AUTHOR(DRV_PROJECT); |
| 1160 | MODULE_VERSION(DRV_VERSION); |
| 1161 | MODULE_DESCRIPTION("rt2x00 library"); |
| 1162 | MODULE_LICENSE("GPL"); |