diff options
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00usb.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00usb.c | 103 |
1 files changed, 21 insertions, 82 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c index 3080969ae5b3..83862e7f7aec 100644 --- a/drivers/net/wireless/rt2x00/rt2x00usb.c +++ b/drivers/net/wireless/rt2x00/rt2x00usb.c | |||
@@ -40,7 +40,7 @@ int rt2x00usb_vendor_request(struct rt2x00_dev *rt2x00dev, | |||
40 | void *buffer, const u16 buffer_length, | 40 | void *buffer, const u16 buffer_length, |
41 | const int timeout) | 41 | const int timeout) |
42 | { | 42 | { |
43 | struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev); | 43 | struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev); |
44 | int status; | 44 | int status; |
45 | unsigned int i; | 45 | unsigned int i; |
46 | unsigned int pipe = | 46 | unsigned int pipe = |
@@ -130,10 +130,9 @@ static void rt2x00usb_interrupt_txdone(struct urb *urb) | |||
130 | struct queue_entry *entry = (struct queue_entry *)urb->context; | 130 | struct queue_entry *entry = (struct queue_entry *)urb->context; |
131 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; | 131 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; |
132 | struct txdone_entry_desc txdesc; | 132 | struct txdone_entry_desc txdesc; |
133 | enum data_queue_qid qid = skb_get_queue_mapping(entry->skb); | ||
134 | 133 | ||
135 | if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) || | 134 | if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) || |
136 | !__test_and_clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) | 135 | !test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) |
137 | return; | 136 | return; |
138 | 137 | ||
139 | /* | 138 | /* |
@@ -157,26 +156,12 @@ static void rt2x00usb_interrupt_txdone(struct urb *urb) | |||
157 | txdesc.retry = 0; | 156 | txdesc.retry = 0; |
158 | 157 | ||
159 | rt2x00lib_txdone(entry, &txdesc); | 158 | rt2x00lib_txdone(entry, &txdesc); |
160 | |||
161 | /* | ||
162 | * Make this entry available for reuse. | ||
163 | */ | ||
164 | entry->flags = 0; | ||
165 | rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE); | ||
166 | |||
167 | /* | ||
168 | * If the data queue was below the threshold before the txdone | ||
169 | * handler we must make sure the packet queue in the mac80211 stack | ||
170 | * is reenabled when the txdone handler has finished. | ||
171 | */ | ||
172 | if (!rt2x00queue_threshold(entry->queue)) | ||
173 | ieee80211_wake_queue(rt2x00dev->hw, qid); | ||
174 | } | 159 | } |
175 | 160 | ||
176 | int rt2x00usb_write_tx_data(struct queue_entry *entry) | 161 | int rt2x00usb_write_tx_data(struct queue_entry *entry) |
177 | { | 162 | { |
178 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; | 163 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; |
179 | struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev); | 164 | struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev); |
180 | struct queue_entry_priv_usb *entry_priv = entry->priv_data; | 165 | struct queue_entry_priv_usb *entry_priv = entry->priv_data; |
181 | struct skb_frame_desc *skbdesc; | 166 | struct skb_frame_desc *skbdesc; |
182 | u32 length; | 167 | u32 length; |
@@ -191,10 +176,8 @@ int rt2x00usb_write_tx_data(struct queue_entry *entry) | |||
191 | * Fill in skb descriptor | 176 | * Fill in skb descriptor |
192 | */ | 177 | */ |
193 | skbdesc = get_skb_frame_desc(entry->skb); | 178 | skbdesc = get_skb_frame_desc(entry->skb); |
194 | memset(skbdesc, 0, sizeof(*skbdesc)); | ||
195 | skbdesc->desc = entry->skb->data; | 179 | skbdesc->desc = entry->skb->data; |
196 | skbdesc->desc_len = entry->queue->desc_size; | 180 | skbdesc->desc_len = entry->queue->desc_size; |
197 | skbdesc->entry = entry; | ||
198 | 181 | ||
199 | /* | 182 | /* |
200 | * USB devices cannot blindly pass the skb->len as the | 183 | * USB devices cannot blindly pass the skb->len as the |
@@ -264,13 +247,11 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb) | |||
264 | { | 247 | { |
265 | struct queue_entry *entry = (struct queue_entry *)urb->context; | 248 | struct queue_entry *entry = (struct queue_entry *)urb->context; |
266 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; | 249 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; |
267 | struct sk_buff *skb; | 250 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); |
268 | struct skb_frame_desc *skbdesc; | ||
269 | struct rxdone_entry_desc rxdesc; | ||
270 | u8 rxd[32]; | 251 | u8 rxd[32]; |
271 | 252 | ||
272 | if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) || | 253 | if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) || |
273 | !test_and_clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) | 254 | !test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) |
274 | return; | 255 | return; |
275 | 256 | ||
276 | /* | 257 | /* |
@@ -278,50 +259,22 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb) | |||
278 | * to be actually valid, or if the urb is signaling | 259 | * to be actually valid, or if the urb is signaling |
279 | * a problem. | 260 | * a problem. |
280 | */ | 261 | */ |
281 | if (urb->actual_length < entry->queue->desc_size || urb->status) | 262 | if (urb->actual_length < entry->queue->desc_size || urb->status) { |
282 | goto skip_entry; | 263 | __set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags); |
264 | usb_submit_urb(urb, GFP_ATOMIC); | ||
265 | return; | ||
266 | } | ||
283 | 267 | ||
284 | /* | 268 | /* |
285 | * Fill in skb descriptor | 269 | * Fill in desc fields of the skb descriptor |
286 | */ | 270 | */ |
287 | skbdesc = get_skb_frame_desc(entry->skb); | ||
288 | memset(skbdesc, 0, sizeof(*skbdesc)); | ||
289 | skbdesc->entry = entry; | ||
290 | skbdesc->desc = rxd; | 271 | skbdesc->desc = rxd; |
291 | skbdesc->desc_len = entry->queue->desc_size; | 272 | skbdesc->desc_len = entry->queue->desc_size; |
292 | 273 | ||
293 | memset(&rxdesc, 0, sizeof(rxdesc)); | ||
294 | rt2x00dev->ops->lib->fill_rxdone(entry, &rxdesc); | ||
295 | |||
296 | /* | ||
297 | * Allocate a new sk buffer to replace the current one. | ||
298 | * If allocation fails, we should drop the current frame | ||
299 | * so we can recycle the existing sk buffer for the new frame. | ||
300 | */ | ||
301 | skb = rt2x00queue_alloc_rxskb(entry->queue); | ||
302 | if (!skb) | ||
303 | goto skip_entry; | ||
304 | |||
305 | /* | 274 | /* |
306 | * Send the frame to rt2x00lib for further processing. | 275 | * Send the frame to rt2x00lib for further processing. |
307 | */ | 276 | */ |
308 | rt2x00lib_rxdone(entry, &rxdesc); | 277 | rt2x00lib_rxdone(rt2x00dev, entry); |
309 | |||
310 | /* | ||
311 | * Replace current entry's skb with the newly allocated one, | ||
312 | * and reinitialize the urb. | ||
313 | */ | ||
314 | entry->skb = skb; | ||
315 | urb->transfer_buffer = entry->skb->data; | ||
316 | urb->transfer_buffer_length = entry->skb->len; | ||
317 | |||
318 | skip_entry: | ||
319 | if (test_bit(DEVICE_ENABLED_RADIO, &entry->queue->rt2x00dev->flags)) { | ||
320 | __set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags); | ||
321 | usb_submit_urb(urb, GFP_ATOMIC); | ||
322 | } | ||
323 | |||
324 | rt2x00queue_index_inc(entry->queue, Q_INDEX); | ||
325 | } | 278 | } |
326 | 279 | ||
327 | /* | 280 | /* |
@@ -331,6 +284,7 @@ void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev) | |||
331 | { | 284 | { |
332 | struct queue_entry_priv_usb *entry_priv; | 285 | struct queue_entry_priv_usb *entry_priv; |
333 | struct queue_entry_priv_usb_bcn *bcn_priv; | 286 | struct queue_entry_priv_usb_bcn *bcn_priv; |
287 | struct data_queue *queue; | ||
334 | unsigned int i; | 288 | unsigned int i; |
335 | 289 | ||
336 | rt2x00usb_vendor_request_sw(rt2x00dev, USB_RX_CONTROL, 0, 0, | 290 | rt2x00usb_vendor_request_sw(rt2x00dev, USB_RX_CONTROL, 0, 0, |
@@ -339,9 +293,11 @@ void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev) | |||
339 | /* | 293 | /* |
340 | * Cancel all queues. | 294 | * Cancel all queues. |
341 | */ | 295 | */ |
342 | for (i = 0; i < rt2x00dev->rx->limit; i++) { | 296 | queue_for_each(rt2x00dev, queue) { |
343 | entry_priv = rt2x00dev->rx->entries[i].priv_data; | 297 | for (i = 0; i < queue->limit; i++) { |
344 | usb_kill_urb(entry_priv->urb); | 298 | entry_priv = queue->entries[i].priv_data; |
299 | usb_kill_urb(entry_priv->urb); | ||
300 | } | ||
345 | } | 301 | } |
346 | 302 | ||
347 | /* | 303 | /* |
@@ -364,7 +320,7 @@ EXPORT_SYMBOL_GPL(rt2x00usb_disable_radio); | |||
364 | void rt2x00usb_init_rxentry(struct rt2x00_dev *rt2x00dev, | 320 | void rt2x00usb_init_rxentry(struct rt2x00_dev *rt2x00dev, |
365 | struct queue_entry *entry) | 321 | struct queue_entry *entry) |
366 | { | 322 | { |
367 | struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev); | 323 | struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev); |
368 | struct queue_entry_priv_usb *entry_priv = entry->priv_data; | 324 | struct queue_entry_priv_usb *entry_priv = entry->priv_data; |
369 | 325 | ||
370 | usb_fill_bulk_urb(entry_priv->urb, usb_dev, | 326 | usb_fill_bulk_urb(entry_priv->urb, usb_dev, |
@@ -431,8 +387,6 @@ static void rt2x00usb_free_urb(struct rt2x00_dev *rt2x00dev, | |||
431 | entry_priv = queue->entries[i].priv_data; | 387 | entry_priv = queue->entries[i].priv_data; |
432 | usb_kill_urb(entry_priv->urb); | 388 | usb_kill_urb(entry_priv->urb); |
433 | usb_free_urb(entry_priv->urb); | 389 | usb_free_urb(entry_priv->urb); |
434 | if (queue->entries[i].skb) | ||
435 | kfree_skb(queue->entries[i].skb); | ||
436 | } | 390 | } |
437 | 391 | ||
438 | /* | 392 | /* |
@@ -454,10 +408,7 @@ static void rt2x00usb_free_urb(struct rt2x00_dev *rt2x00dev, | |||
454 | int rt2x00usb_initialize(struct rt2x00_dev *rt2x00dev) | 408 | int rt2x00usb_initialize(struct rt2x00_dev *rt2x00dev) |
455 | { | 409 | { |
456 | struct data_queue *queue; | 410 | struct data_queue *queue; |
457 | struct sk_buff *skb; | 411 | int status; |
458 | unsigned int entry_size; | ||
459 | unsigned int i; | ||
460 | int uninitialized_var(status); | ||
461 | 412 | ||
462 | /* | 413 | /* |
463 | * Allocate DMA | 414 | * Allocate DMA |
@@ -468,18 +419,6 @@ int rt2x00usb_initialize(struct rt2x00_dev *rt2x00dev) | |||
468 | goto exit; | 419 | goto exit; |
469 | } | 420 | } |
470 | 421 | ||
471 | /* | ||
472 | * For the RX queue, skb's should be allocated. | ||
473 | */ | ||
474 | entry_size = rt2x00dev->rx->data_size + rt2x00dev->rx->desc_size; | ||
475 | for (i = 0; i < rt2x00dev->rx->limit; i++) { | ||
476 | skb = rt2x00queue_alloc_rxskb(rt2x00dev->rx); | ||
477 | if (!skb) | ||
478 | goto exit; | ||
479 | |||
480 | rt2x00dev->rx->entries[i].skb = skb; | ||
481 | } | ||
482 | |||
483 | return 0; | 422 | return 0; |
484 | 423 | ||
485 | exit: | 424 | exit: |
@@ -558,7 +497,7 @@ int rt2x00usb_probe(struct usb_interface *usb_intf, | |||
558 | usb_set_intfdata(usb_intf, hw); | 497 | usb_set_intfdata(usb_intf, hw); |
559 | 498 | ||
560 | rt2x00dev = hw->priv; | 499 | rt2x00dev = hw->priv; |
561 | rt2x00dev->dev = usb_intf; | 500 | rt2x00dev->dev = &usb_intf->dev; |
562 | rt2x00dev->ops = ops; | 501 | rt2x00dev->ops = ops; |
563 | rt2x00dev->hw = hw; | 502 | rt2x00dev->hw = hw; |
564 | mutex_init(&rt2x00dev->usb_cache_mutex); | 503 | mutex_init(&rt2x00dev->usb_cache_mutex); |