aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2800usb.c
diff options
context:
space:
mode:
authorGertjan van Wingerde <gwingerde@gmail.com>2010-05-08 17:40:22 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-05-10 14:56:48 -0400
commit2de64dd22d0390688b853788dcadee3c0ad9e518 (patch)
treeb0a6197647817f13a49dfab29899653377027a40 /drivers/net/wireless/rt2x00/rt2800usb.c
parent59679b91d1d33ebe90b72ffded9a57dba788fa6b (diff)
rt2x00: Factor out RXWI processing to common rt2800 code.
RXWI processing is exactly the same for rt2800pci and rt2800usb, so make it common code. Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com> Acked-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2800usb.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c74
1 files changed, 23 insertions, 51 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index b39b858e0cf1..db371193b507 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -507,53 +507,45 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry,
507{ 507{
508 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); 508 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
509 __le32 *rxi = (__le32 *)entry->skb->data; 509 __le32 *rxi = (__le32 *)entry->skb->data;
510 __le32 *rxwi;
511 __le32 *rxd; 510 __le32 *rxd;
512 u32 rxi0; 511 u32 word;
513 u32 rxwi0;
514 u32 rxwi1;
515 u32 rxwi2;
516 u32 rxwi3;
517 u32 rxd0;
518 int rx_pkt_len; 512 int rx_pkt_len;
519 513
520 /* 514 /*
515 * Copy descriptor to the skbdesc->desc buffer, making it safe from
516 * moving of frame data in rt2x00usb.
517 */
518 memcpy(skbdesc->desc, rxi, skbdesc->desc_len);
519
520 /*
521 * RX frame format is : 521 * RX frame format is :
522 * | RXINFO | RXWI | header | L2 pad | payload | pad | RXD | USB pad | 522 * | RXINFO | RXWI | header | L2 pad | payload | pad | RXD | USB pad |
523 * |<------------ rx_pkt_len -------------->| 523 * |<------------ rx_pkt_len -------------->|
524 */ 524 */
525 rt2x00_desc_read(rxi, 0, &rxi0); 525 rt2x00_desc_read(rxi, 0, &word);
526 rx_pkt_len = rt2x00_get_field32(rxi0, RXINFO_W0_USB_DMA_RX_PKT_LEN); 526 rx_pkt_len = rt2x00_get_field32(word, RXINFO_W0_USB_DMA_RX_PKT_LEN);
527
528 rxwi = (__le32 *)(entry->skb->data + RXINFO_DESC_SIZE);
529 527
530 /* 528 /*
531 * FIXME : we need to check for rx_pkt_len validity 529 * Remove the RXINFO structure from the sbk.
532 */ 530 */
533 rxd = (__le32 *)(entry->skb->data + RXINFO_DESC_SIZE + rx_pkt_len); 531 skb_pull(entry->skb, RXINFO_DESC_SIZE);
534 532
535 /* 533 /*
536 * Copy descriptor to the skbdesc->desc buffer, making it safe from 534 * FIXME: we need to check for rx_pkt_len validity
537 * moving of frame data in rt2x00usb.
538 */ 535 */
539 memcpy(skbdesc->desc, rxi, skbdesc->desc_len); 536 rxd = (__le32 *)(entry->skb->data + rx_pkt_len);
540 537
541 /* 538 /*
542 * It is now safe to read the descriptor on all architectures. 539 * It is now safe to read the descriptor on all architectures.
543 */ 540 */
544 rt2x00_desc_read(rxwi, 0, &rxwi0); 541 rt2x00_desc_read(rxd, 0, &word);
545 rt2x00_desc_read(rxwi, 1, &rxwi1);
546 rt2x00_desc_read(rxwi, 2, &rxwi2);
547 rt2x00_desc_read(rxwi, 3, &rxwi3);
548 rt2x00_desc_read(rxd, 0, &rxd0);
549 542
550 if (rt2x00_get_field32(rxd0, RXD_W0_CRC_ERROR)) 543 if (rt2x00_get_field32(word, RXD_W0_CRC_ERROR))
551 rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; 544 rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
552 545
553 rxdesc->cipher = rt2x00_get_field32(rxwi0, RXWI_W0_UDF); 546 rxdesc->cipher_status = rt2x00_get_field32(word, RXD_W0_CIPHER_ERROR);
554 rxdesc->cipher_status = rt2x00_get_field32(rxd0, RXD_W0_CIPHER_ERROR);
555 547
556 if (rt2x00_get_field32(rxd0, RXD_W0_DECRYPTED)) { 548 if (rt2x00_get_field32(word, RXD_W0_DECRYPTED)) {
557 /* 549 /*
558 * Hardware has stripped IV/EIV data from 802.11 frame during 550 * Hardware has stripped IV/EIV data from 802.11 frame during
559 * decryption. Unfortunately the descriptor doesn't contain 551 * decryption. Unfortunately the descriptor doesn't contain
@@ -568,41 +560,21 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry,
568 rxdesc->flags |= RX_FLAG_MMIC_ERROR; 560 rxdesc->flags |= RX_FLAG_MMIC_ERROR;
569 } 561 }
570 562
571 if (rt2x00_get_field32(rxd0, RXD_W0_MY_BSS)) 563 if (rt2x00_get_field32(word, RXD_W0_MY_BSS))
572 rxdesc->dev_flags |= RXDONE_MY_BSS; 564 rxdesc->dev_flags |= RXDONE_MY_BSS;
573 565
574 if (rt2x00_get_field32(rxd0, RXD_W0_L2PAD)) 566 if (rt2x00_get_field32(word, RXD_W0_L2PAD))
575 rxdesc->dev_flags |= RXDONE_L2PAD; 567 rxdesc->dev_flags |= RXDONE_L2PAD;
576 568
577 if (rt2x00_get_field32(rxwi1, RXWI_W1_SHORT_GI))
578 rxdesc->flags |= RX_FLAG_SHORT_GI;
579
580 if (rt2x00_get_field32(rxwi1, RXWI_W1_BW))
581 rxdesc->flags |= RX_FLAG_40MHZ;
582
583 /* 569 /*
584 * Detect RX rate, always use MCS as signal type. 570 * Remove RXD descriptor from end of buffer.
585 */ 571 */
586 rxdesc->dev_flags |= RXDONE_SIGNAL_MCS; 572 skb_trim(entry->skb, rx_pkt_len);
587 rxdesc->rate_mode = rt2x00_get_field32(rxwi1, RXWI_W1_PHYMODE);
588 rxdesc->signal = rt2x00_get_field32(rxwi1, RXWI_W1_MCS);
589
590 /*
591 * Mask of 0x8 bit to remove the short preamble flag.
592 */
593 if (rxdesc->rate_mode == RATE_MODE_CCK)
594 rxdesc->signal &= ~0x8;
595
596 rxdesc->rssi =
597 (rt2x00_get_field32(rxwi2, RXWI_W2_RSSI0) +
598 rt2x00_get_field32(rxwi2, RXWI_W2_RSSI1)) / 2;
599
600 rxdesc->size = rt2x00_get_field32(rxwi0, RXWI_W0_MPDU_TOTAL_BYTE_COUNT);
601 573
602 /* 574 /*
603 * Remove RXWI descriptor from start of buffer. 575 * Process the RXWI structure.
604 */ 576 */
605 skb_pull(entry->skb, skbdesc->desc_len); 577 rt2800_process_rxwi(entry->skb, rxdesc);
606} 578}
607 579
608/* 580/*