aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2013-10-17 03:42:19 -0400
committerJohn W. Linville <linville@tuxdriver.com>2013-10-18 14:06:59 -0400
commit9732497d4d7f6db7d5504f490f0d7631e24af396 (patch)
tree57d42c17a57dbbd46d6ba41208fdbd9552b932f8
parentd10b7547d5dcf2826e393a740d6a5d4cb8ce892e (diff)
rt2x00: rt2800pci: move RX control handler functions to the rt2800mmio module
Move the functions into a separate module, in order to make those usable from other modules. Also move the RX descriptor related defines from rt2800pci.h into rt2800mmio.h Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/rt2x00/Kconfig1
-rw-r--r--drivers/net/wireless/rt2x00/rt2800mmio.c57
-rw-r--r--drivers/net/wireless/rt2x00/rt2800mmio.h51
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.c55
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.h51
5 files changed, 108 insertions, 107 deletions
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig
index 535ad3a6970c..e86324931b63 100644
--- a/drivers/net/wireless/rt2x00/Kconfig
+++ b/drivers/net/wireless/rt2x00/Kconfig
@@ -206,6 +206,7 @@ config RT2800_LIB
206config RT2800_LIB_MMIO 206config RT2800_LIB_MMIO
207 tristate 207 tristate
208 select RT2X00_LIB_MMIO 208 select RT2X00_LIB_MMIO
209 select RT2800_LIB
209 210
210config RT2X00_LIB_MMIO 211config RT2X00_LIB_MMIO
211 tristate 212 tristate
diff --git a/drivers/net/wireless/rt2x00/rt2800mmio.c b/drivers/net/wireless/rt2x00/rt2800mmio.c
index d2ebb68b97af..32b8e5058867 100644
--- a/drivers/net/wireless/rt2x00/rt2800mmio.c
+++ b/drivers/net/wireless/rt2x00/rt2800mmio.c
@@ -34,6 +34,7 @@
34 34
35#include "rt2x00.h" 35#include "rt2x00.h"
36#include "rt2x00mmio.h" 36#include "rt2x00mmio.h"
37#include "rt2800lib.h"
37#include "rt2800mmio.h" 38#include "rt2800mmio.h"
38 39
39/* 40/*
@@ -99,7 +100,61 @@ void rt2800mmio_write_tx_desc(struct queue_entry *entry,
99} 100}
100EXPORT_SYMBOL_GPL(rt2800mmio_write_tx_desc); 101EXPORT_SYMBOL_GPL(rt2800mmio_write_tx_desc);
101 102
102#include "rt2x00.h" 103/*
104 * RX control handlers
105 */
106void rt2800mmio_fill_rxdone(struct queue_entry *entry,
107 struct rxdone_entry_desc *rxdesc)
108{
109 struct queue_entry_priv_mmio *entry_priv = entry->priv_data;
110 __le32 *rxd = entry_priv->desc;
111 u32 word;
112
113 rt2x00_desc_read(rxd, 3, &word);
114
115 if (rt2x00_get_field32(word, RXD_W3_CRC_ERROR))
116 rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
117
118 /*
119 * Unfortunately we don't know the cipher type used during
120 * decryption. This prevents us from correct providing
121 * correct statistics through debugfs.
122 */
123 rxdesc->cipher_status = rt2x00_get_field32(word, RXD_W3_CIPHER_ERROR);
124
125 if (rt2x00_get_field32(word, RXD_W3_DECRYPTED)) {
126 /*
127 * Hardware has stripped IV/EIV data from 802.11 frame during
128 * decryption. Unfortunately the descriptor doesn't contain
129 * any fields with the EIV/IV data either, so they can't
130 * be restored by rt2x00lib.
131 */
132 rxdesc->flags |= RX_FLAG_IV_STRIPPED;
133
134 /*
135 * The hardware has already checked the Michael Mic and has
136 * stripped it from the frame. Signal this to mac80211.
137 */
138 rxdesc->flags |= RX_FLAG_MMIC_STRIPPED;
139
140 if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS)
141 rxdesc->flags |= RX_FLAG_DECRYPTED;
142 else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC)
143 rxdesc->flags |= RX_FLAG_MMIC_ERROR;
144 }
145
146 if (rt2x00_get_field32(word, RXD_W3_MY_BSS))
147 rxdesc->dev_flags |= RXDONE_MY_BSS;
148
149 if (rt2x00_get_field32(word, RXD_W3_L2PAD))
150 rxdesc->dev_flags |= RXDONE_L2PAD;
151
152 /*
153 * Process the RXWI structure that is at the start of the buffer.
154 */
155 rt2800_process_rxwi(entry, rxdesc);
156}
157EXPORT_SYMBOL_GPL(rt2800mmio_fill_rxdone);
103 158
104MODULE_AUTHOR(DRV_PROJECT); 159MODULE_AUTHOR(DRV_PROJECT);
105MODULE_VERSION(DRV_VERSION); 160MODULE_VERSION(DRV_VERSION);
diff --git a/drivers/net/wireless/rt2x00/rt2800mmio.h b/drivers/net/wireless/rt2x00/rt2800mmio.h
index 026664002d01..71e3d2268436 100644
--- a/drivers/net/wireless/rt2x00/rt2800mmio.h
+++ b/drivers/net/wireless/rt2x00/rt2800mmio.h
@@ -35,6 +35,7 @@
35 * DMA descriptor defines. 35 * DMA descriptor defines.
36 */ 36 */
37#define TXD_DESC_SIZE (4 * sizeof(__le32)) 37#define TXD_DESC_SIZE (4 * sizeof(__le32))
38#define RXD_DESC_SIZE (4 * sizeof(__le32))
38 39
39/* 40/*
40 * TX descriptor format for TX, PRIO and Beacon Ring. 41 * TX descriptor format for TX, PRIO and Beacon Ring.
@@ -72,10 +73,60 @@
72#define TXD_W3_UCO FIELD32(0x40000000) 73#define TXD_W3_UCO FIELD32(0x40000000)
73#define TXD_W3_ICO FIELD32(0x80000000) 74#define TXD_W3_ICO FIELD32(0x80000000)
74 75
76/*
77 * RX descriptor format for RX Ring.
78 */
79
80/*
81 * Word0
82 */
83#define RXD_W0_SDP0 FIELD32(0xffffffff)
84
85/*
86 * Word1
87 */
88#define RXD_W1_SDL1 FIELD32(0x00003fff)
89#define RXD_W1_SDL0 FIELD32(0x3fff0000)
90#define RXD_W1_LS0 FIELD32(0x40000000)
91#define RXD_W1_DMA_DONE FIELD32(0x80000000)
92
93/*
94 * Word2
95 */
96#define RXD_W2_SDP1 FIELD32(0xffffffff)
97
98/*
99 * Word3
100 * AMSDU: RX with 802.3 header, not 802.11 header.
101 * DECRYPTED: This frame is being decrypted.
102 */
103#define RXD_W3_BA FIELD32(0x00000001)
104#define RXD_W3_DATA FIELD32(0x00000002)
105#define RXD_W3_NULLDATA FIELD32(0x00000004)
106#define RXD_W3_FRAG FIELD32(0x00000008)
107#define RXD_W3_UNICAST_TO_ME FIELD32(0x00000010)
108#define RXD_W3_MULTICAST FIELD32(0x00000020)
109#define RXD_W3_BROADCAST FIELD32(0x00000040)
110#define RXD_W3_MY_BSS FIELD32(0x00000080)
111#define RXD_W3_CRC_ERROR FIELD32(0x00000100)
112#define RXD_W3_CIPHER_ERROR FIELD32(0x00000600)
113#define RXD_W3_AMSDU FIELD32(0x00000800)
114#define RXD_W3_HTC FIELD32(0x00001000)
115#define RXD_W3_RSSI FIELD32(0x00002000)
116#define RXD_W3_L2PAD FIELD32(0x00004000)
117#define RXD_W3_AMPDU FIELD32(0x00008000)
118#define RXD_W3_DECRYPTED FIELD32(0x00010000)
119#define RXD_W3_PLCP_SIGNAL FIELD32(0x00020000)
120#define RXD_W3_PLCP_RSSI FIELD32(0x00040000)
75 121
76/* TX descriptor initialization */ 122/* TX descriptor initialization */
77__le32 *rt2800mmio_get_txwi(struct queue_entry *entry); 123__le32 *rt2800mmio_get_txwi(struct queue_entry *entry);
78void rt2800mmio_write_tx_desc(struct queue_entry *entry, 124void rt2800mmio_write_tx_desc(struct queue_entry *entry,
79 struct txentry_desc *txdesc); 125 struct txentry_desc *txdesc);
80 126
127/* RX control handlers */
128void rt2800mmio_fill_rxdone(struct queue_entry *entry,
129 struct rxdone_entry_desc *rxdesc);
130
131
81#endif /* RT2800MMIO_H */ 132#endif /* RT2800MMIO_H */
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index 37ac888ff83a..2cbaaac89e9a 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -628,61 +628,6 @@ static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev,
628} 628}
629 629
630/* 630/*
631 * RX control handlers
632 */
633static void rt2800mmio_fill_rxdone(struct queue_entry *entry,
634 struct rxdone_entry_desc *rxdesc)
635{
636 struct queue_entry_priv_mmio *entry_priv = entry->priv_data;
637 __le32 *rxd = entry_priv->desc;
638 u32 word;
639
640 rt2x00_desc_read(rxd, 3, &word);
641
642 if (rt2x00_get_field32(word, RXD_W3_CRC_ERROR))
643 rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
644
645 /*
646 * Unfortunately we don't know the cipher type used during
647 * decryption. This prevents us from correct providing
648 * correct statistics through debugfs.
649 */
650 rxdesc->cipher_status = rt2x00_get_field32(word, RXD_W3_CIPHER_ERROR);
651
652 if (rt2x00_get_field32(word, RXD_W3_DECRYPTED)) {
653 /*
654 * Hardware has stripped IV/EIV data from 802.11 frame during
655 * decryption. Unfortunately the descriptor doesn't contain
656 * any fields with the EIV/IV data either, so they can't
657 * be restored by rt2x00lib.
658 */
659 rxdesc->flags |= RX_FLAG_IV_STRIPPED;
660
661 /*
662 * The hardware has already checked the Michael Mic and has
663 * stripped it from the frame. Signal this to mac80211.
664 */
665 rxdesc->flags |= RX_FLAG_MMIC_STRIPPED;
666
667 if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS)
668 rxdesc->flags |= RX_FLAG_DECRYPTED;
669 else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC)
670 rxdesc->flags |= RX_FLAG_MMIC_ERROR;
671 }
672
673 if (rt2x00_get_field32(word, RXD_W3_MY_BSS))
674 rxdesc->dev_flags |= RXDONE_MY_BSS;
675
676 if (rt2x00_get_field32(word, RXD_W3_L2PAD))
677 rxdesc->dev_flags |= RXDONE_L2PAD;
678
679 /*
680 * Process the RXWI structure that is at the start of the buffer.
681 */
682 rt2800_process_rxwi(entry, rxdesc);
683}
684
685/*
686 * Interrupt functions. 631 * Interrupt functions.
687 */ 632 */
688static void rt2800pci_wakeup(struct rt2x00_dev *rt2x00dev) 633static void rt2800pci_wakeup(struct rt2x00_dev *rt2x00dev)
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.h b/drivers/net/wireless/rt2x00/rt2800pci.h
index ecd154ea56d0..0e551593bf16 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.h
+++ b/drivers/net/wireless/rt2x00/rt2800pci.h
@@ -50,55 +50,4 @@
50#define FIRMWARE_RT3290 "rt3290.bin" 50#define FIRMWARE_RT3290 "rt3290.bin"
51#define FIRMWARE_IMAGE_BASE 0x2000 51#define FIRMWARE_IMAGE_BASE 0x2000
52 52
53/*
54 * DMA descriptor defines.
55 */
56#define RXD_DESC_SIZE (4 * sizeof(__le32))
57
58/*
59 * RX descriptor format for RX Ring.
60 */
61
62/*
63 * Word0
64 */
65#define RXD_W0_SDP0 FIELD32(0xffffffff)
66
67/*
68 * Word1
69 */
70#define RXD_W1_SDL1 FIELD32(0x00003fff)
71#define RXD_W1_SDL0 FIELD32(0x3fff0000)
72#define RXD_W1_LS0 FIELD32(0x40000000)
73#define RXD_W1_DMA_DONE FIELD32(0x80000000)
74
75/*
76 * Word2
77 */
78#define RXD_W2_SDP1 FIELD32(0xffffffff)
79
80/*
81 * Word3
82 * AMSDU: RX with 802.3 header, not 802.11 header.
83 * DECRYPTED: This frame is being decrypted.
84 */
85#define RXD_W3_BA FIELD32(0x00000001)
86#define RXD_W3_DATA FIELD32(0x00000002)
87#define RXD_W3_NULLDATA FIELD32(0x00000004)
88#define RXD_W3_FRAG FIELD32(0x00000008)
89#define RXD_W3_UNICAST_TO_ME FIELD32(0x00000010)
90#define RXD_W3_MULTICAST FIELD32(0x00000020)
91#define RXD_W3_BROADCAST FIELD32(0x00000040)
92#define RXD_W3_MY_BSS FIELD32(0x00000080)
93#define RXD_W3_CRC_ERROR FIELD32(0x00000100)
94#define RXD_W3_CIPHER_ERROR FIELD32(0x00000600)
95#define RXD_W3_AMSDU FIELD32(0x00000800)
96#define RXD_W3_HTC FIELD32(0x00001000)
97#define RXD_W3_RSSI FIELD32(0x00002000)
98#define RXD_W3_L2PAD FIELD32(0x00004000)
99#define RXD_W3_AMPDU FIELD32(0x00008000)
100#define RXD_W3_DECRYPTED FIELD32(0x00010000)
101#define RXD_W3_PLCP_SIGNAL FIELD32(0x00020000)
102#define RXD_W3_PLCP_RSSI FIELD32(0x00040000)
103
104#endif /* RT2800PCI_H */ 53#endif /* RT2800PCI_H */