aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2800pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2800pci.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.c318
1 files changed, 128 insertions, 190 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index 91cce2d0f6db..b2f23272c3aa 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -60,6 +60,12 @@ static void rt2800pci_mcu_status(struct rt2x00_dev *rt2x00dev, const u8 token)
60 unsigned int i; 60 unsigned int i;
61 u32 reg; 61 u32 reg;
62 62
63 /*
64 * SOC devices don't support MCU requests.
65 */
66 if (rt2x00_is_soc(rt2x00dev))
67 return;
68
63 for (i = 0; i < 200; i++) { 69 for (i = 0; i < 200; i++) {
64 rt2800_register_read(rt2x00dev, H2M_MAILBOX_CID, &reg); 70 rt2800_register_read(rt2x00dev, H2M_MAILBOX_CID, &reg);
65 71
@@ -341,19 +347,6 @@ static int rt2800pci_init_queues(struct rt2x00_dev *rt2x00dev)
341 struct queue_entry_priv_pci *entry_priv; 347 struct queue_entry_priv_pci *entry_priv;
342 u32 reg; 348 u32 reg;
343 349
344 rt2800_register_read(rt2x00dev, WPDMA_RST_IDX, &reg);
345 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX0, 1);
346 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX1, 1);
347 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX2, 1);
348 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX3, 1);
349 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX4, 1);
350 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX5, 1);
351 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DRX_IDX0, 1);
352 rt2800_register_write(rt2x00dev, WPDMA_RST_IDX, reg);
353
354 rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00000e1f);
355 rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00000e00);
356
357 /* 350 /*
358 * Initialize registers. 351 * Initialize registers.
359 */ 352 */
@@ -620,64 +613,31 @@ static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev,
620/* 613/*
621 * TX descriptor initialization 614 * TX descriptor initialization
622 */ 615 */
616static int rt2800pci_write_tx_data(struct queue_entry* entry,
617 struct txentry_desc *txdesc)
618{
619 int ret;
620
621 ret = rt2x00pci_write_tx_data(entry, txdesc);
622 if (ret)
623 return ret;
624
625 rt2800_write_txwi(entry->skb, txdesc);
626
627 return 0;
628}
629
630
623static void rt2800pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, 631static void rt2800pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
624 struct sk_buff *skb, 632 struct sk_buff *skb,
625 struct txentry_desc *txdesc) 633 struct txentry_desc *txdesc)
626{ 634{
627 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); 635 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
628 __le32 *txd = skbdesc->desc; 636 struct queue_entry_priv_pci *entry_priv = skbdesc->entry->priv_data;
629 __le32 *txwi = (__le32 *)(skb->data - rt2x00dev->ops->extra_tx_headroom); 637 __le32 *txd = entry_priv->desc;
630 u32 word; 638 u32 word;
631 639
632 /* 640 /*
633 * Initialize TX Info descriptor
634 */
635 rt2x00_desc_read(txwi, 0, &word);
636 rt2x00_set_field32(&word, TXWI_W0_FRAG,
637 test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
638 rt2x00_set_field32(&word, TXWI_W0_MIMO_PS, 0);
639 rt2x00_set_field32(&word, TXWI_W0_CF_ACK, 0);
640 rt2x00_set_field32(&word, TXWI_W0_TS,
641 test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags));
642 rt2x00_set_field32(&word, TXWI_W0_AMPDU,
643 test_bit(ENTRY_TXD_HT_AMPDU, &txdesc->flags));
644 rt2x00_set_field32(&word, TXWI_W0_MPDU_DENSITY, txdesc->mpdu_density);
645 rt2x00_set_field32(&word, TXWI_W0_TX_OP, txdesc->ifs);
646 rt2x00_set_field32(&word, TXWI_W0_MCS, txdesc->mcs);
647 rt2x00_set_field32(&word, TXWI_W0_BW,
648 test_bit(ENTRY_TXD_HT_BW_40, &txdesc->flags));
649 rt2x00_set_field32(&word, TXWI_W0_SHORT_GI,
650 test_bit(ENTRY_TXD_HT_SHORT_GI, &txdesc->flags));
651 rt2x00_set_field32(&word, TXWI_W0_STBC, txdesc->stbc);
652 rt2x00_set_field32(&word, TXWI_W0_PHYMODE, txdesc->rate_mode);
653 rt2x00_desc_write(txwi, 0, word);
654
655 rt2x00_desc_read(txwi, 1, &word);
656 rt2x00_set_field32(&word, TXWI_W1_ACK,
657 test_bit(ENTRY_TXD_ACK, &txdesc->flags));
658 rt2x00_set_field32(&word, TXWI_W1_NSEQ,
659 test_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags));
660 rt2x00_set_field32(&word, TXWI_W1_BW_WIN_SIZE, txdesc->ba_size);
661 rt2x00_set_field32(&word, TXWI_W1_WIRELESS_CLI_ID,
662 test_bit(ENTRY_TXD_ENCRYPT, &txdesc->flags) ?
663 txdesc->key_idx : 0xff);
664 rt2x00_set_field32(&word, TXWI_W1_MPDU_TOTAL_BYTE_COUNT,
665 skb->len - txdesc->l2pad);
666 rt2x00_set_field32(&word, TXWI_W1_PACKETID,
667 skbdesc->entry->queue->qid + 1);
668 rt2x00_desc_write(txwi, 1, word);
669
670 /*
671 * Always write 0 to IV/EIV fields, hardware will insert the IV
672 * from the IVEIV register when TXD_W3_WIV is set to 0.
673 * When TXD_W3_WIV is set to 1 it will use the IV data
674 * from the descriptor. The TXWI_W1_WIRELESS_CLI_ID indicates which
675 * crypto entry in the registers should be used to encrypt the frame.
676 */
677 _rt2x00_desc_write(txwi, 2, 0 /* skbdesc->iv[0] */);
678 _rt2x00_desc_write(txwi, 3, 0 /* skbdesc->iv[1] */);
679
680 /*
681 * The buffers pointed by SD_PTR0/SD_LEN0 and SD_PTR1/SD_LEN1 641 * The buffers pointed by SD_PTR0/SD_LEN0 and SD_PTR1/SD_LEN1
682 * must contains a TXWI structure + 802.11 header + padding + 802.11 642 * must contains a TXWI structure + 802.11 header + padding + 802.11
683 * data. We choose to have SD_PTR0/SD_LEN0 only contains TXWI and 643 * data. We choose to have SD_PTR0/SD_LEN0 only contains TXWI and
@@ -698,15 +658,14 @@ static void rt2800pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
698 !test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags)); 658 !test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
699 rt2x00_set_field32(&word, TXD_W1_BURST, 659 rt2x00_set_field32(&word, TXD_W1_BURST,
700 test_bit(ENTRY_TXD_BURST, &txdesc->flags)); 660 test_bit(ENTRY_TXD_BURST, &txdesc->flags));
701 rt2x00_set_field32(&word, TXD_W1_SD_LEN0, 661 rt2x00_set_field32(&word, TXD_W1_SD_LEN0, TXWI_DESC_SIZE);
702 rt2x00dev->ops->extra_tx_headroom);
703 rt2x00_set_field32(&word, TXD_W1_LAST_SEC0, 0); 662 rt2x00_set_field32(&word, TXD_W1_LAST_SEC0, 0);
704 rt2x00_set_field32(&word, TXD_W1_DMA_DONE, 0); 663 rt2x00_set_field32(&word, TXD_W1_DMA_DONE, 0);
705 rt2x00_desc_write(txd, 1, word); 664 rt2x00_desc_write(txd, 1, word);
706 665
707 rt2x00_desc_read(txd, 2, &word); 666 rt2x00_desc_read(txd, 2, &word);
708 rt2x00_set_field32(&word, TXD_W2_SD_PTR1, 667 rt2x00_set_field32(&word, TXD_W2_SD_PTR1,
709 skbdesc->skb_dma + rt2x00dev->ops->extra_tx_headroom); 668 skbdesc->skb_dma + TXWI_DESC_SIZE);
710 rt2x00_desc_write(txd, 2, word); 669 rt2x00_desc_write(txd, 2, word);
711 670
712 rt2x00_desc_read(txd, 3, &word); 671 rt2x00_desc_read(txd, 3, &word);
@@ -714,15 +673,21 @@ static void rt2800pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
714 !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags)); 673 !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags));
715 rt2x00_set_field32(&word, TXD_W3_QSEL, 2); 674 rt2x00_set_field32(&word, TXD_W3_QSEL, 2);
716 rt2x00_desc_write(txd, 3, word); 675 rt2x00_desc_write(txd, 3, word);
676
677 /*
678 * Register descriptor details in skb frame descriptor.
679 */
680 skbdesc->desc = txd;
681 skbdesc->desc_len = TXD_DESC_SIZE;
717} 682}
718 683
719/* 684/*
720 * TX data initialization 685 * TX data initialization
721 */ 686 */
722static void rt2800pci_write_beacon(struct queue_entry *entry) 687static void rt2800pci_write_beacon(struct queue_entry *entry,
688 struct txentry_desc *txdesc)
723{ 689{
724 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 690 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
725 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
726 unsigned int beacon_base; 691 unsigned int beacon_base;
727 u32 reg; 692 u32 reg;
728 693
@@ -735,15 +700,25 @@ static void rt2800pci_write_beacon(struct queue_entry *entry)
735 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg); 700 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg);
736 701
737 /* 702 /*
738 * Write entire beacon with descriptor to register. 703 * Add the TXWI for the beacon to the skb.
704 */
705 rt2800_write_txwi(entry->skb, txdesc);
706 skb_push(entry->skb, TXWI_DESC_SIZE);
707
708 /*
709 * Write entire beacon with TXWI to register.
739 */ 710 */
740 beacon_base = HW_BEACON_OFFSET(entry->entry_idx); 711 beacon_base = HW_BEACON_OFFSET(entry->entry_idx);
741 rt2800_register_multiwrite(rt2x00dev, 712 rt2800_register_multiwrite(rt2x00dev, beacon_base,
742 beacon_base, 713 entry->skb->data, entry->skb->len);
743 skbdesc->desc, skbdesc->desc_len); 714
744 rt2800_register_multiwrite(rt2x00dev, 715 /*
745 beacon_base + skbdesc->desc_len, 716 * Enable beaconing again.
746 entry->skb->data, entry->skb->len); 717 */
718 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 1);
719 rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 1);
720 rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 1);
721 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg);
747 722
748 /* 723 /*
749 * Clean up beacon skb. 724 * Clean up beacon skb.
@@ -757,18 +732,6 @@ static void rt2800pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
757{ 732{
758 struct data_queue *queue; 733 struct data_queue *queue;
759 unsigned int idx, qidx = 0; 734 unsigned int idx, qidx = 0;
760 u32 reg;
761
762 if (queue_idx == QID_BEACON) {
763 rt2800_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
764 if (!rt2x00_get_field32(reg, BCN_TIME_CFG_BEACON_GEN)) {
765 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 1);
766 rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 1);
767 rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 1);
768 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg);
769 }
770 return;
771 }
772 735
773 if (queue_idx > QID_HCCA && queue_idx != QID_MGMT) 736 if (queue_idx > QID_HCCA && queue_idx != QID_MGMT)
774 return; 737 return;
@@ -811,34 +774,21 @@ static void rt2800pci_fill_rxdone(struct queue_entry *entry,
811 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 774 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
812 struct queue_entry_priv_pci *entry_priv = entry->priv_data; 775 struct queue_entry_priv_pci *entry_priv = entry->priv_data;
813 __le32 *rxd = entry_priv->desc; 776 __le32 *rxd = entry_priv->desc;
814 __le32 *rxwi = (__le32 *)entry->skb->data; 777 u32 word;
815 u32 rxd3; 778
816 u32 rxwi0; 779 rt2x00_desc_read(rxd, 3, &word);
817 u32 rxwi1; 780
818 u32 rxwi2; 781 if (rt2x00_get_field32(word, RXD_W3_CRC_ERROR))
819 u32 rxwi3;
820
821 rt2x00_desc_read(rxd, 3, &rxd3);
822 rt2x00_desc_read(rxwi, 0, &rxwi0);
823 rt2x00_desc_read(rxwi, 1, &rxwi1);
824 rt2x00_desc_read(rxwi, 2, &rxwi2);
825 rt2x00_desc_read(rxwi, 3, &rxwi3);
826
827 if (rt2x00_get_field32(rxd3, RXD_W3_CRC_ERROR))
828 rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; 782 rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
829 783
830 if (test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags)) { 784 /*
831 /* 785 * Unfortunately we don't know the cipher type used during
832 * Unfortunately we don't know the cipher type used during 786 * decryption. This prevents us from correct providing
833 * decryption. This prevents us from correct providing 787 * correct statistics through debugfs.
834 * correct statistics through debugfs. 788 */
835 */ 789 rxdesc->cipher_status = rt2x00_get_field32(word, RXD_W3_CIPHER_ERROR);
836 rxdesc->cipher = rt2x00_get_field32(rxwi0, RXWI_W0_UDF);
837 rxdesc->cipher_status =
838 rt2x00_get_field32(rxd3, RXD_W3_CIPHER_ERROR);
839 }
840 790
841 if (rt2x00_get_field32(rxd3, RXD_W3_DECRYPTED)) { 791 if (rt2x00_get_field32(word, RXD_W3_DECRYPTED)) {
842 /* 792 /*
843 * Hardware has stripped IV/EIV data from 802.11 frame during 793 * Hardware has stripped IV/EIV data from 802.11 frame during
844 * decryption. Unfortunately the descriptor doesn't contain 794 * decryption. Unfortunately the descriptor doesn't contain
@@ -853,51 +803,22 @@ static void rt2800pci_fill_rxdone(struct queue_entry *entry,
853 rxdesc->flags |= RX_FLAG_MMIC_ERROR; 803 rxdesc->flags |= RX_FLAG_MMIC_ERROR;
854 } 804 }
855 805
856 if (rt2x00_get_field32(rxd3, RXD_W3_MY_BSS)) 806 if (rt2x00_get_field32(word, RXD_W3_MY_BSS))
857 rxdesc->dev_flags |= RXDONE_MY_BSS; 807 rxdesc->dev_flags |= RXDONE_MY_BSS;
858 808
859 if (rt2x00_get_field32(rxd3, RXD_W3_L2PAD)) 809 if (rt2x00_get_field32(word, RXD_W3_L2PAD))
860 rxdesc->dev_flags |= RXDONE_L2PAD; 810 rxdesc->dev_flags |= RXDONE_L2PAD;
861 811
862 if (rt2x00_get_field32(rxwi1, RXWI_W1_SHORT_GI))
863 rxdesc->flags |= RX_FLAG_SHORT_GI;
864
865 if (rt2x00_get_field32(rxwi1, RXWI_W1_BW))
866 rxdesc->flags |= RX_FLAG_40MHZ;
867
868 /* 812 /*
869 * Detect RX rate, always use MCS as signal type. 813 * Process the RXWI structure that is at the start of the buffer.
870 */ 814 */
871 rxdesc->dev_flags |= RXDONE_SIGNAL_MCS; 815 rt2800_process_rxwi(entry->skb, rxdesc);
872 rxdesc->rate_mode = rt2x00_get_field32(rxwi1, RXWI_W1_PHYMODE);
873 rxdesc->signal = rt2x00_get_field32(rxwi1, RXWI_W1_MCS);
874
875 /*
876 * Mask of 0x8 bit to remove the short preamble flag.
877 */
878 if (rxdesc->rate_mode == RATE_MODE_CCK)
879 rxdesc->signal &= ~0x8;
880
881 rxdesc->rssi =
882 (rt2x00_get_field32(rxwi2, RXWI_W2_RSSI0) +
883 rt2x00_get_field32(rxwi2, RXWI_W2_RSSI1)) / 2;
884
885 rxdesc->noise =
886 (rt2x00_get_field32(rxwi3, RXWI_W3_SNR0) +
887 rt2x00_get_field32(rxwi3, RXWI_W3_SNR1)) / 2;
888
889 rxdesc->size = rt2x00_get_field32(rxwi0, RXWI_W0_MPDU_TOTAL_BYTE_COUNT);
890 816
891 /* 817 /*
892 * Set RX IDX in register to inform hardware that we have handled 818 * Set RX IDX in register to inform hardware that we have handled
893 * this entry and it is available for reuse again. 819 * this entry and it is available for reuse again.
894 */ 820 */
895 rt2800_register_write(rt2x00dev, RX_CRX_IDX, entry->entry_idx); 821 rt2800_register_write(rt2x00dev, RX_CRX_IDX, entry->entry_idx);
896
897 /*
898 * Remove TXWI descriptor from start of buffer.
899 */
900 skb_pull(entry->skb, RXWI_DESC_SIZE);
901} 822}
902 823
903/* 824/*
@@ -907,14 +828,12 @@ static void rt2800pci_txdone(struct rt2x00_dev *rt2x00dev)
907{ 828{
908 struct data_queue *queue; 829 struct data_queue *queue;
909 struct queue_entry *entry; 830 struct queue_entry *entry;
910 struct queue_entry *entry_done; 831 __le32 *txwi;
911 struct queue_entry_priv_pci *entry_priv;
912 struct txdone_entry_desc txdesc; 832 struct txdone_entry_desc txdesc;
913 u32 word; 833 u32 word;
914 u32 reg; 834 u32 reg;
915 u32 old_reg; 835 u32 old_reg;
916 unsigned int type; 836 int wcid, ack, pid, tx_wcid, tx_ack, tx_pid;
917 unsigned int index;
918 u16 mcs, real_mcs; 837 u16 mcs, real_mcs;
919 838
920 /* 839 /*
@@ -936,76 +855,89 @@ static void rt2800pci_txdone(struct rt2x00_dev *rt2x00dev)
936 break; 855 break;
937 old_reg = reg; 856 old_reg = reg;
938 857
858 wcid = rt2x00_get_field32(reg, TX_STA_FIFO_WCID);
859 ack = rt2x00_get_field32(reg, TX_STA_FIFO_TX_ACK_REQUIRED);
860 pid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_TYPE);
861
939 /* 862 /*
940 * Skip this entry when it contains an invalid 863 * Skip this entry when it contains an invalid
941 * queue identication number. 864 * queue identication number.
942 */ 865 */
943 type = rt2x00_get_field32(reg, TX_STA_FIFO_PID_TYPE) - 1; 866 if (pid <= 0 || pid > QID_RX)
944 if (type >= QID_RX)
945 continue; 867 continue;
946 868
947 queue = rt2x00queue_get_queue(rt2x00dev, type); 869 queue = rt2x00queue_get_queue(rt2x00dev, pid - 1);
948 if (unlikely(!queue)) 870 if (unlikely(!queue))
949 continue; 871 continue;
950 872
951 /* 873 /*
952 * Skip this entry when it contains an invalid 874 * Inside each queue, we process each entry in a chronological
953 * index number. 875 * order. We first check that the queue is not empty.
954 */ 876 */
955 index = rt2x00_get_field32(reg, TX_STA_FIFO_WCID) - 1; 877 if (rt2x00queue_empty(queue))
956 if (unlikely(index >= queue->limit))
957 continue; 878 continue;
879 entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
958 880
959 entry = &queue->entries[index]; 881 /* Check if we got a match by looking at WCID/ACK/PID
960 entry_priv = entry->priv_data; 882 * fields */
961 rt2x00_desc_read((__le32 *)entry->skb->data, 0, &word); 883 txwi = (__le32 *)(entry->skb->data -
884 rt2x00dev->ops->extra_tx_headroom);
962 885
963 entry_done = rt2x00queue_get_entry(queue, Q_INDEX_DONE); 886 rt2x00_desc_read(txwi, 1, &word);
964 while (entry != entry_done) { 887 tx_wcid = rt2x00_get_field32(word, TXWI_W1_WIRELESS_CLI_ID);
965 /* 888 tx_ack = rt2x00_get_field32(word, TXWI_W1_ACK);
966 * Catch up. 889 tx_pid = rt2x00_get_field32(word, TXWI_W1_PACKETID);
967 * Just report any entries we missed as failed.
968 */
969 WARNING(rt2x00dev,
970 "TX status report missed for entry %d\n",
971 entry_done->entry_idx);
972 890
973 txdesc.flags = 0; 891 if ((wcid != tx_wcid) || (ack != tx_ack) || (pid != tx_pid))
974 __set_bit(TXDONE_UNKNOWN, &txdesc.flags); 892 WARNING(rt2x00dev, "invalid TX_STA_FIFO content\n");
975 txdesc.retry = 0;
976
977 rt2x00lib_txdone(entry_done, &txdesc);
978 entry_done = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
979 }
980 893
981 /* 894 /*
982 * Obtain the status about this packet. 895 * Obtain the status about this packet.
983 */ 896 */
984 txdesc.flags = 0; 897 txdesc.flags = 0;
985 if (rt2x00_get_field32(reg, TX_STA_FIFO_TX_SUCCESS)) 898 rt2x00_desc_read(txwi, 0, &word);
986 __set_bit(TXDONE_SUCCESS, &txdesc.flags); 899 mcs = rt2x00_get_field32(word, TXWI_W0_MCS);
987 else 900 real_mcs = rt2x00_get_field32(reg, TX_STA_FIFO_MCS);
988 __set_bit(TXDONE_FAILURE, &txdesc.flags);
989 901
990 /* 902 /*
991 * Ralink has a retry mechanism using a global fallback 903 * Ralink has a retry mechanism using a global fallback
992 * table. We setup this fallback table to try immediate 904 * table. We setup this fallback table to try the immediate
993 * lower rate for all rates. In the TX_STA_FIFO, 905 * lower rate for all rates. In the TX_STA_FIFO, the MCS field
994 * the MCS field contains the MCS used for the successfull 906 * always contains the MCS used for the last transmission, be
995 * transmission. If the first transmission succeed, 907 * it successful or not.
996 * we have mcs == tx_mcs. On the second transmission,
997 * we have mcs = tx_mcs - 1. So the number of
998 * retry is (tx_mcs - mcs).
999 */ 908 */
1000 mcs = rt2x00_get_field32(word, TXWI_W0_MCS); 909 if (rt2x00_get_field32(reg, TX_STA_FIFO_TX_SUCCESS)) {
1001 real_mcs = rt2x00_get_field32(reg, TX_STA_FIFO_MCS); 910 /*
911 * Transmission succeeded. The number of retries is
912 * mcs - real_mcs
913 */
914 __set_bit(TXDONE_SUCCESS, &txdesc.flags);
915 txdesc.retry = ((mcs > real_mcs) ? mcs - real_mcs : 0);
916 } else {
917 /*
918 * Transmission failed. The number of retries is
919 * always 7 in this case (for a total number of 8
920 * frames sent).
921 */
922 __set_bit(TXDONE_FAILURE, &txdesc.flags);
923 txdesc.retry = 7;
924 }
925
1002 __set_bit(TXDONE_FALLBACK, &txdesc.flags); 926 __set_bit(TXDONE_FALLBACK, &txdesc.flags);
1003 txdesc.retry = mcs - min(mcs, real_mcs); 927
1004 928
1005 rt2x00lib_txdone(entry, &txdesc); 929 rt2x00lib_txdone(entry, &txdesc);
1006 } 930 }
1007} 931}
1008 932
933static void rt2800pci_wakeup(struct rt2x00_dev *rt2x00dev)
934{
935 struct ieee80211_conf conf = { .flags = 0 };
936 struct rt2x00lib_conf libconf = { .conf = &conf };
937
938 rt2800_config(rt2x00dev, &libconf, IEEE80211_CONF_CHANGE_PS);
939}
940
1009static irqreturn_t rt2800pci_interrupt(int irq, void *dev_instance) 941static irqreturn_t rt2800pci_interrupt(int irq, void *dev_instance)
1010{ 942{
1011 struct rt2x00_dev *rt2x00dev = dev_instance; 943 struct rt2x00_dev *rt2x00dev = dev_instance;
@@ -1030,6 +962,9 @@ static irqreturn_t rt2800pci_interrupt(int irq, void *dev_instance)
1030 if (rt2x00_get_field32(reg, INT_SOURCE_CSR_TX_FIFO_STATUS)) 962 if (rt2x00_get_field32(reg, INT_SOURCE_CSR_TX_FIFO_STATUS))
1031 rt2800pci_txdone(rt2x00dev); 963 rt2800pci_txdone(rt2x00dev);
1032 964
965 if (rt2x00_get_field32(reg, INT_SOURCE_CSR_AUTO_WAKEUP))
966 rt2800pci_wakeup(rt2x00dev);
967
1033 return IRQ_HANDLED; 968 return IRQ_HANDLED;
1034} 969}
1035 970
@@ -1128,7 +1063,7 @@ static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = {
1128 .reset_tuner = rt2800_reset_tuner, 1063 .reset_tuner = rt2800_reset_tuner,
1129 .link_tuner = rt2800_link_tuner, 1064 .link_tuner = rt2800_link_tuner,
1130 .write_tx_desc = rt2800pci_write_tx_desc, 1065 .write_tx_desc = rt2800pci_write_tx_desc,
1131 .write_tx_data = rt2x00pci_write_tx_data, 1066 .write_tx_data = rt2800pci_write_tx_data,
1132 .write_beacon = rt2800pci_write_beacon, 1067 .write_beacon = rt2800pci_write_beacon,
1133 .kick_tx_queue = rt2800pci_kick_tx_queue, 1068 .kick_tx_queue = rt2800pci_kick_tx_queue,
1134 .kill_tx_queue = rt2800pci_kill_tx_queue, 1069 .kill_tx_queue = rt2800pci_kill_tx_queue,
@@ -1184,6 +1119,7 @@ static const struct rt2x00_ops rt2800pci_ops = {
1184/* 1119/*
1185 * RT2800pci module information. 1120 * RT2800pci module information.
1186 */ 1121 */
1122#ifdef CONFIG_RT2800PCI_PCI
1187static DEFINE_PCI_DEVICE_TABLE(rt2800pci_device_table) = { 1123static DEFINE_PCI_DEVICE_TABLE(rt2800pci_device_table) = {
1188 { PCI_DEVICE(0x1814, 0x0601), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1124 { PCI_DEVICE(0x1814, 0x0601), PCI_DEVICE_DATA(&rt2800pci_ops) },
1189 { PCI_DEVICE(0x1814, 0x0681), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1125 { PCI_DEVICE(0x1814, 0x0681), PCI_DEVICE_DATA(&rt2800pci_ops) },
@@ -1208,9 +1144,11 @@ static DEFINE_PCI_DEVICE_TABLE(rt2800pci_device_table) = {
1208 { PCI_DEVICE(0x1814, 0x3062), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1144 { PCI_DEVICE(0x1814, 0x3062), PCI_DEVICE_DATA(&rt2800pci_ops) },
1209 { PCI_DEVICE(0x1814, 0x3562), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1145 { PCI_DEVICE(0x1814, 0x3562), PCI_DEVICE_DATA(&rt2800pci_ops) },
1210 { PCI_DEVICE(0x1814, 0x3592), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1146 { PCI_DEVICE(0x1814, 0x3592), PCI_DEVICE_DATA(&rt2800pci_ops) },
1147 { PCI_DEVICE(0x1814, 0x3593), PCI_DEVICE_DATA(&rt2800pci_ops) },
1211#endif 1148#endif
1212 { 0, } 1149 { 0, }
1213}; 1150};
1151#endif /* CONFIG_RT2800PCI_PCI */
1214 1152
1215MODULE_AUTHOR(DRV_PROJECT); 1153MODULE_AUTHOR(DRV_PROJECT);
1216MODULE_VERSION(DRV_VERSION); 1154MODULE_VERSION(DRV_VERSION);