aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2800usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2800usb.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c71
1 files changed, 32 insertions, 39 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index ab95346cf6a..82755cf8b73 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -92,7 +92,7 @@ static bool rt2800usb_check_crc(const u8 *data, const size_t len)
92static int rt2800usb_check_firmware(struct rt2x00_dev *rt2x00dev, 92static int rt2800usb_check_firmware(struct rt2x00_dev *rt2x00dev,
93 const u8 *data, const size_t len) 93 const u8 *data, const size_t len)
94{ 94{
95 u16 chipset = (rt2x00_rev(&rt2x00dev->chip) >> 16) & 0xffff; 95 u16 chipset = (rt2x00_rev(rt2x00dev) >> 16) & 0xffff;
96 size_t offset = 0; 96 size_t offset = 0;
97 97
98 /* 98 /*
@@ -138,7 +138,7 @@ static int rt2800usb_load_firmware(struct rt2x00_dev *rt2x00dev,
138 u32 reg; 138 u32 reg;
139 u32 offset; 139 u32 offset;
140 u32 length; 140 u32 length;
141 u16 chipset = (rt2x00_rev(&rt2x00dev->chip) >> 16) & 0xffff; 141 u16 chipset = (rt2x00_rev(rt2x00dev) >> 16) & 0xffff;
142 142
143 /* 143 /*
144 * Check which section of the firmware we need. 144 * Check which section of the firmware we need.
@@ -248,24 +248,6 @@ static void rt2800usb_toggle_rx(struct rt2x00_dev *rt2x00dev,
248 rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg); 248 rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
249} 249}
250 250
251static int rt2800usb_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev)
252{
253 unsigned int i;
254 u32 reg;
255
256 for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
257 rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, &reg);
258 if (!rt2x00_get_field32(reg, WPDMA_GLO_CFG_TX_DMA_BUSY) &&
259 !rt2x00_get_field32(reg, WPDMA_GLO_CFG_RX_DMA_BUSY))
260 return 0;
261
262 msleep(1);
263 }
264
265 ERROR(rt2x00dev, "WPDMA TX/RX busy, aborting.\n");
266 return -EACCES;
267}
268
269static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev) 251static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev)
270{ 252{
271 u32 reg; 253 u32 reg;
@@ -274,7 +256,7 @@ static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev)
274 /* 256 /*
275 * Initialize all registers. 257 * Initialize all registers.
276 */ 258 */
277 if (unlikely(rt2800usb_wait_wpdma_ready(rt2x00dev) || 259 if (unlikely(rt2800_wait_wpdma_ready(rt2x00dev) ||
278 rt2800_init_registers(rt2x00dev) || 260 rt2800_init_registers(rt2x00dev) ||
279 rt2800_init_bbp(rt2x00dev) || 261 rt2800_init_bbp(rt2x00dev) ||
280 rt2800_init_rfcsr(rt2x00dev))) 262 rt2800_init_rfcsr(rt2x00dev)))
@@ -295,9 +277,7 @@ static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev)
295 277
296 rt2800_register_read(rt2x00dev, USB_DMA_CFG, &reg); 278 rt2800_register_read(rt2x00dev, USB_DMA_CFG, &reg);
297 rt2x00_set_field32(&reg, USB_DMA_CFG_PHY_CLEAR, 0); 279 rt2x00_set_field32(&reg, USB_DMA_CFG_PHY_CLEAR, 0);
298 /* Don't use bulk in aggregation when working with USB 1.1 */ 280 rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_AGG_EN, 0);
299 rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_AGG_EN,
300 (rt2x00dev->rx->usb_maxpacket == 512));
301 rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_AGG_TIMEOUT, 128); 281 rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_AGG_TIMEOUT, 128);
302 /* 282 /*
303 * Total room for RX frames in kilobytes, PBF might still exceed 283 * Total room for RX frames in kilobytes, PBF might still exceed
@@ -346,7 +326,7 @@ static void rt2800usb_disable_radio(struct rt2x00_dev *rt2x00dev)
346 rt2800_register_write(rt2x00dev, TX_PIN_CFG, 0); 326 rt2800_register_write(rt2x00dev, TX_PIN_CFG, 0);
347 327
348 /* Wait for DMA, ignore error */ 328 /* Wait for DMA, ignore error */
349 rt2800usb_wait_wpdma_ready(rt2x00dev); 329 rt2800_wait_wpdma_ready(rt2x00dev);
350 330
351 rt2x00usb_disable_radio(rt2x00dev); 331 rt2x00usb_disable_radio(rt2x00dev);
352} 332}
@@ -573,41 +553,57 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry,
573{ 553{
574 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 554 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
575 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); 555 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
576 __le32 *rxd = (__le32 *)entry->skb->data; 556 __le32 *rxi = (__le32 *)entry->skb->data;
577 __le32 *rxwi; 557 __le32 *rxwi;
578 u32 rxd0; 558 __le32 *rxd;
559 u32 rxi0;
579 u32 rxwi0; 560 u32 rxwi0;
580 u32 rxwi1; 561 u32 rxwi1;
581 u32 rxwi2; 562 u32 rxwi2;
582 u32 rxwi3; 563 u32 rxwi3;
564 u32 rxd0;
565 int rx_pkt_len;
566
567 /*
568 * RX frame format is :
569 * | RXINFO | RXWI | header | L2 pad | payload | pad | RXD | USB pad |
570 * |<------------ rx_pkt_len -------------->|
571 */
572 rt2x00_desc_read(rxi, 0, &rxi0);
573 rx_pkt_len = rt2x00_get_field32(rxi0, RXINFO_W0_USB_DMA_RX_PKT_LEN);
574
575 rxwi = (__le32 *)(entry->skb->data + RXINFO_DESC_SIZE);
576
577 /*
578 * FIXME : we need to check for rx_pkt_len validity
579 */
580 rxd = (__le32 *)(entry->skb->data + RXINFO_DESC_SIZE + rx_pkt_len);
583 581
584 /* 582 /*
585 * Copy descriptor to the skbdesc->desc buffer, making it safe from 583 * Copy descriptor to the skbdesc->desc buffer, making it safe from
586 * moving of frame data in rt2x00usb. 584 * moving of frame data in rt2x00usb.
587 */ 585 */
588 memcpy(skbdesc->desc, rxd, skbdesc->desc_len); 586 memcpy(skbdesc->desc, rxi, skbdesc->desc_len);
589 rxd = (__le32 *)skbdesc->desc;
590 rxwi = &rxd[RXINFO_DESC_SIZE / sizeof(__le32)];
591 587
592 /* 588 /*
593 * It is now safe to read the descriptor on all architectures. 589 * It is now safe to read the descriptor on all architectures.
594 */ 590 */
595 rt2x00_desc_read(rxd, 0, &rxd0);
596 rt2x00_desc_read(rxwi, 0, &rxwi0); 591 rt2x00_desc_read(rxwi, 0, &rxwi0);
597 rt2x00_desc_read(rxwi, 1, &rxwi1); 592 rt2x00_desc_read(rxwi, 1, &rxwi1);
598 rt2x00_desc_read(rxwi, 2, &rxwi2); 593 rt2x00_desc_read(rxwi, 2, &rxwi2);
599 rt2x00_desc_read(rxwi, 3, &rxwi3); 594 rt2x00_desc_read(rxwi, 3, &rxwi3);
595 rt2x00_desc_read(rxd, 0, &rxd0);
600 596
601 if (rt2x00_get_field32(rxd0, RXINFO_W0_CRC_ERROR)) 597 if (rt2x00_get_field32(rxd0, RXD_W0_CRC_ERROR))
602 rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; 598 rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
603 599
604 if (test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags)) { 600 if (test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags)) {
605 rxdesc->cipher = rt2x00_get_field32(rxwi0, RXWI_W0_UDF); 601 rxdesc->cipher = rt2x00_get_field32(rxwi0, RXWI_W0_UDF);
606 rxdesc->cipher_status = 602 rxdesc->cipher_status =
607 rt2x00_get_field32(rxd0, RXINFO_W0_CIPHER_ERROR); 603 rt2x00_get_field32(rxd0, RXD_W0_CIPHER_ERROR);
608 } 604 }
609 605
610 if (rt2x00_get_field32(rxd0, RXINFO_W0_DECRYPTED)) { 606 if (rt2x00_get_field32(rxd0, RXD_W0_DECRYPTED)) {
611 /* 607 /*
612 * Hardware has stripped IV/EIV data from 802.11 frame during 608 * Hardware has stripped IV/EIV data from 802.11 frame during
613 * decryption. Unfortunately the descriptor doesn't contain 609 * decryption. Unfortunately the descriptor doesn't contain
@@ -622,13 +618,11 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry,
622 rxdesc->flags |= RX_FLAG_MMIC_ERROR; 618 rxdesc->flags |= RX_FLAG_MMIC_ERROR;
623 } 619 }
624 620
625 if (rt2x00_get_field32(rxd0, RXINFO_W0_MY_BSS)) 621 if (rt2x00_get_field32(rxd0, RXD_W0_MY_BSS))
626 rxdesc->dev_flags |= RXDONE_MY_BSS; 622 rxdesc->dev_flags |= RXDONE_MY_BSS;
627 623
628 if (rt2x00_get_field32(rxd0, RXINFO_W0_L2PAD)) { 624 if (rt2x00_get_field32(rxd0, RXD_W0_L2PAD))
629 rxdesc->dev_flags |= RXDONE_L2PAD; 625 rxdesc->dev_flags |= RXDONE_L2PAD;
630 skbdesc->flags |= SKBDESC_L2_PADDED;
631 }
632 626
633 if (rt2x00_get_field32(rxwi1, RXWI_W1_SHORT_GI)) 627 if (rt2x00_get_field32(rxwi1, RXWI_W1_SHORT_GI))
634 rxdesc->flags |= RX_FLAG_SHORT_GI; 628 rxdesc->flags |= RX_FLAG_SHORT_GI;
@@ -663,7 +657,6 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry,
663 * Remove RXWI descriptor from start of buffer. 657 * Remove RXWI descriptor from start of buffer.
664 */ 658 */
665 skb_pull(entry->skb, skbdesc->desc_len); 659 skb_pull(entry->skb, skbdesc->desc_len);
666 skb_trim(entry->skb, rxdesc->size);
667} 660}
668 661
669/* 662/*