diff options
author | Ivo van Doorn <ivdoorn@gmail.com> | 2008-05-10 07:46:03 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-05-21 21:47:35 -0400 |
commit | b8be63ffa5dc44324e7f507997870fa3e4b17619 (patch) | |
tree | ad9ef1c3e4e09111ad93b003baaec325bd5e40e0 /drivers/net/wireless/rt2x00/rt2x00pci.c | |
parent | dec13b6bda600c7e7da993e634562873112af50b (diff) |
rt2x00: Merge RX and TX entry private data
With the pending removal of the tx_control structure
we can merge the RX and TX entry private data structure
in advance. This will temporarily increase the required
memory for the queue, but that overhead will only be limited.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00pci.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00pci.c | 89 |
1 files changed, 28 insertions, 61 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c index a056b12fbd1c..fa7de41be049 100644 --- a/drivers/net/wireless/rt2x00/rt2x00pci.c +++ b/drivers/net/wireless/rt2x00/rt2x00pci.c | |||
@@ -39,7 +39,7 @@ int rt2x00pci_write_tx_data(struct rt2x00_dev *rt2x00dev, | |||
39 | struct ieee80211_tx_control *control) | 39 | struct ieee80211_tx_control *control) |
40 | { | 40 | { |
41 | struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX); | 41 | struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX); |
42 | struct queue_entry_priv_pci_tx *priv_tx = entry->priv_data; | 42 | struct queue_entry_priv_pci *entry_priv = entry->priv_data; |
43 | struct skb_frame_desc *skbdesc; | 43 | struct skb_frame_desc *skbdesc; |
44 | struct txentry_desc txdesc; | 44 | struct txentry_desc txdesc; |
45 | u32 word; | 45 | u32 word; |
@@ -47,7 +47,7 @@ int rt2x00pci_write_tx_data(struct rt2x00_dev *rt2x00dev, | |||
47 | if (rt2x00queue_full(queue)) | 47 | if (rt2x00queue_full(queue)) |
48 | return -EINVAL; | 48 | return -EINVAL; |
49 | 49 | ||
50 | rt2x00_desc_read(priv_tx->desc, 0, &word); | 50 | rt2x00_desc_read(entry_priv->desc, 0, &word); |
51 | 51 | ||
52 | if (rt2x00_get_field32(word, TXD_ENTRY_OWNER_NIC) || | 52 | if (rt2x00_get_field32(word, TXD_ENTRY_OWNER_NIC) || |
53 | rt2x00_get_field32(word, TXD_ENTRY_VALID)) { | 53 | rt2x00_get_field32(word, TXD_ENTRY_VALID)) { |
@@ -72,12 +72,12 @@ int rt2x00pci_write_tx_data(struct rt2x00_dev *rt2x00dev, | |||
72 | skbdesc = get_skb_frame_desc(skb); | 72 | skbdesc = get_skb_frame_desc(skb); |
73 | skbdesc->data = skb->data; | 73 | skbdesc->data = skb->data; |
74 | skbdesc->data_len = skb->len; | 74 | skbdesc->data_len = skb->len; |
75 | skbdesc->desc = priv_tx->desc; | 75 | skbdesc->desc = entry_priv->desc; |
76 | skbdesc->desc_len = queue->desc_size; | 76 | skbdesc->desc_len = queue->desc_size; |
77 | skbdesc->entry = entry; | 77 | skbdesc->entry = entry; |
78 | 78 | ||
79 | memcpy(&priv_tx->control, control, sizeof(priv_tx->control)); | 79 | memcpy(&entry_priv->control, control, sizeof(entry_priv->control)); |
80 | memcpy(priv_tx->data, skb->data, skb->len); | 80 | memcpy(entry_priv->data, skb->data, skb->len); |
81 | 81 | ||
82 | rt2x00queue_write_tx_descriptor(entry, &txdesc); | 82 | rt2x00queue_write_tx_descriptor(entry, &txdesc); |
83 | rt2x00queue_index_inc(queue, Q_INDEX); | 83 | rt2x00queue_index_inc(queue, Q_INDEX); |
@@ -93,7 +93,7 @@ void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev) | |||
93 | { | 93 | { |
94 | struct data_queue *queue = rt2x00dev->rx; | 94 | struct data_queue *queue = rt2x00dev->rx; |
95 | struct queue_entry *entry; | 95 | struct queue_entry *entry; |
96 | struct queue_entry_priv_pci_rx *priv_rx; | 96 | struct queue_entry_priv_pci *entry_priv; |
97 | struct ieee80211_hdr *hdr; | 97 | struct ieee80211_hdr *hdr; |
98 | struct skb_frame_desc *skbdesc; | 98 | struct skb_frame_desc *skbdesc; |
99 | struct rxdone_entry_desc rxdesc; | 99 | struct rxdone_entry_desc rxdesc; |
@@ -103,8 +103,8 @@ void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev) | |||
103 | 103 | ||
104 | while (1) { | 104 | while (1) { |
105 | entry = rt2x00queue_get_entry(queue, Q_INDEX); | 105 | entry = rt2x00queue_get_entry(queue, Q_INDEX); |
106 | priv_rx = entry->priv_data; | 106 | entry_priv = entry->priv_data; |
107 | rt2x00_desc_read(priv_rx->desc, 0, &word); | 107 | rt2x00_desc_read(entry_priv->desc, 0, &word); |
108 | 108 | ||
109 | if (rt2x00_get_field32(word, RXD_ENTRY_OWNER_NIC)) | 109 | if (rt2x00_get_field32(word, RXD_ENTRY_OWNER_NIC)) |
110 | break; | 110 | break; |
@@ -112,7 +112,7 @@ void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev) | |||
112 | memset(&rxdesc, 0, sizeof(rxdesc)); | 112 | memset(&rxdesc, 0, sizeof(rxdesc)); |
113 | rt2x00dev->ops->lib->fill_rxdone(entry, &rxdesc); | 113 | rt2x00dev->ops->lib->fill_rxdone(entry, &rxdesc); |
114 | 114 | ||
115 | hdr = (struct ieee80211_hdr *)priv_rx->data; | 115 | hdr = (struct ieee80211_hdr *)entry_priv->data; |
116 | header_size = | 116 | header_size = |
117 | ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)); | 117 | ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)); |
118 | 118 | ||
@@ -132,7 +132,7 @@ void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev) | |||
132 | 132 | ||
133 | skb_reserve(entry->skb, align); | 133 | skb_reserve(entry->skb, align); |
134 | memcpy(skb_put(entry->skb, rxdesc.size), | 134 | memcpy(skb_put(entry->skb, rxdesc.size), |
135 | priv_rx->data, rxdesc.size); | 135 | entry_priv->data, rxdesc.size); |
136 | 136 | ||
137 | /* | 137 | /* |
138 | * Fill in skb descriptor | 138 | * Fill in skb descriptor |
@@ -141,7 +141,7 @@ void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev) | |||
141 | memset(skbdesc, 0, sizeof(*skbdesc)); | 141 | memset(skbdesc, 0, sizeof(*skbdesc)); |
142 | skbdesc->data = entry->skb->data; | 142 | skbdesc->data = entry->skb->data; |
143 | skbdesc->data_len = entry->skb->len; | 143 | skbdesc->data_len = entry->skb->len; |
144 | skbdesc->desc = priv_rx->desc; | 144 | skbdesc->desc = entry_priv->desc; |
145 | skbdesc->desc_len = queue->desc_size; | 145 | skbdesc->desc_len = queue->desc_size; |
146 | skbdesc->entry = entry; | 146 | skbdesc->entry = entry; |
147 | 147 | ||
@@ -152,7 +152,7 @@ void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev) | |||
152 | 152 | ||
153 | if (test_bit(DEVICE_ENABLED_RADIO, &queue->rt2x00dev->flags)) { | 153 | if (test_bit(DEVICE_ENABLED_RADIO, &queue->rt2x00dev->flags)) { |
154 | rt2x00_set_field32(&word, RXD_ENTRY_OWNER_NIC, 1); | 154 | rt2x00_set_field32(&word, RXD_ENTRY_OWNER_NIC, 1); |
155 | rt2x00_desc_write(priv_rx->desc, 0, word); | 155 | rt2x00_desc_write(entry_priv->desc, 0, word); |
156 | } | 156 | } |
157 | 157 | ||
158 | rt2x00queue_index_inc(queue, Q_INDEX); | 158 | rt2x00queue_index_inc(queue, Q_INDEX); |
@@ -163,10 +163,10 @@ EXPORT_SYMBOL_GPL(rt2x00pci_rxdone); | |||
163 | void rt2x00pci_txdone(struct rt2x00_dev *rt2x00dev, struct queue_entry *entry, | 163 | void rt2x00pci_txdone(struct rt2x00_dev *rt2x00dev, struct queue_entry *entry, |
164 | struct txdone_entry_desc *txdesc) | 164 | struct txdone_entry_desc *txdesc) |
165 | { | 165 | { |
166 | struct queue_entry_priv_pci_tx *priv_tx = entry->priv_data; | 166 | struct queue_entry_priv_pci *entry_priv = entry->priv_data; |
167 | u32 word; | 167 | u32 word; |
168 | 168 | ||
169 | txdesc->control = &priv_tx->control; | 169 | txdesc->control = &entry_priv->control; |
170 | rt2x00lib_txdone(entry, txdesc); | 170 | rt2x00lib_txdone(entry, txdesc); |
171 | 171 | ||
172 | /* | 172 | /* |
@@ -174,10 +174,10 @@ void rt2x00pci_txdone(struct rt2x00_dev *rt2x00dev, struct queue_entry *entry, | |||
174 | */ | 174 | */ |
175 | entry->flags = 0; | 175 | entry->flags = 0; |
176 | 176 | ||
177 | rt2x00_desc_read(priv_tx->desc, 0, &word); | 177 | rt2x00_desc_read(entry_priv->desc, 0, &word); |
178 | rt2x00_set_field32(&word, TXD_ENTRY_OWNER_NIC, 0); | 178 | rt2x00_set_field32(&word, TXD_ENTRY_OWNER_NIC, 0); |
179 | rt2x00_set_field32(&word, TXD_ENTRY_VALID, 0); | 179 | rt2x00_set_field32(&word, TXD_ENTRY_VALID, 0); |
180 | rt2x00_desc_write(priv_tx->desc, 0, word); | 180 | rt2x00_desc_write(entry_priv->desc, 0, word); |
181 | 181 | ||
182 | rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE); | 182 | rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE); |
183 | 183 | ||
@@ -187,7 +187,7 @@ void rt2x00pci_txdone(struct rt2x00_dev *rt2x00dev, struct queue_entry *entry, | |||
187 | * is reenabled when the txdone handler has finished. | 187 | * is reenabled when the txdone handler has finished. |
188 | */ | 188 | */ |
189 | if (!rt2x00queue_full(entry->queue)) | 189 | if (!rt2x00queue_full(entry->queue)) |
190 | ieee80211_wake_queue(rt2x00dev->hw, priv_tx->control.queue); | 190 | ieee80211_wake_queue(rt2x00dev->hw, entry_priv->control.queue); |
191 | 191 | ||
192 | } | 192 | } |
193 | EXPORT_SYMBOL_GPL(rt2x00pci_txdone); | 193 | EXPORT_SYMBOL_GPL(rt2x00pci_txdone); |
@@ -226,14 +226,9 @@ static int rt2x00pci_alloc_queue_dma(struct rt2x00_dev *rt2x00dev, | |||
226 | struct data_queue *queue) | 226 | struct data_queue *queue) |
227 | { | 227 | { |
228 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); | 228 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); |
229 | struct queue_entry_priv_pci_rx *priv_rx; | 229 | struct queue_entry_priv_pci *entry_priv; |
230 | struct queue_entry_priv_pci_tx *priv_tx; | ||
231 | void *addr; | 230 | void *addr; |
232 | dma_addr_t dma; | 231 | dma_addr_t dma; |
233 | void *desc_addr; | ||
234 | dma_addr_t desc_dma; | ||
235 | void *data_addr; | ||
236 | dma_addr_t data_dma; | ||
237 | unsigned int i; | 232 | unsigned int i; |
238 | 233 | ||
239 | /* | 234 | /* |
@@ -249,24 +244,11 @@ static int rt2x00pci_alloc_queue_dma(struct rt2x00_dev *rt2x00dev, | |||
249 | * Initialize all queue entries to contain valid addresses. | 244 | * Initialize all queue entries to contain valid addresses. |
250 | */ | 245 | */ |
251 | for (i = 0; i < queue->limit; i++) { | 246 | for (i = 0; i < queue->limit; i++) { |
252 | desc_addr = desc_offset(queue, addr, i); | 247 | entry_priv = queue->entries[i].priv_data; |
253 | desc_dma = desc_offset(queue, dma, i); | 248 | entry_priv->desc = desc_offset(queue, addr, i); |
254 | data_addr = data_offset(queue, addr, i); | 249 | entry_priv->desc_dma = desc_offset(queue, dma, i); |
255 | data_dma = data_offset(queue, dma, i); | 250 | entry_priv->data = data_offset(queue, addr, i); |
256 | 251 | entry_priv->data_dma = data_offset(queue, dma, i); | |
257 | if (queue->qid == QID_RX) { | ||
258 | priv_rx = queue->entries[i].priv_data; | ||
259 | priv_rx->desc = desc_addr; | ||
260 | priv_rx->desc_dma = desc_dma; | ||
261 | priv_rx->data = data_addr; | ||
262 | priv_rx->data_dma = data_dma; | ||
263 | } else { | ||
264 | priv_tx = queue->entries[i].priv_data; | ||
265 | priv_tx->desc = desc_addr; | ||
266 | priv_tx->desc_dma = desc_dma; | ||
267 | priv_tx->data = data_addr; | ||
268 | priv_tx->data_dma = data_dma; | ||
269 | } | ||
270 | } | 252 | } |
271 | 253 | ||
272 | return 0; | 254 | return 0; |
@@ -276,28 +258,13 @@ static void rt2x00pci_free_queue_dma(struct rt2x00_dev *rt2x00dev, | |||
276 | struct data_queue *queue) | 258 | struct data_queue *queue) |
277 | { | 259 | { |
278 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); | 260 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); |
279 | struct queue_entry_priv_pci_rx *priv_rx; | 261 | struct queue_entry_priv_pci *entry_priv = |
280 | struct queue_entry_priv_pci_tx *priv_tx; | 262 | queue->entries[0].priv_data; |
281 | void *data_addr; | ||
282 | dma_addr_t data_dma; | ||
283 | |||
284 | if (queue->qid == QID_RX) { | ||
285 | priv_rx = queue->entries[0].priv_data; | ||
286 | data_addr = priv_rx->data; | ||
287 | data_dma = priv_rx->data_dma; | ||
288 | |||
289 | priv_rx->data = NULL; | ||
290 | } else { | ||
291 | priv_tx = queue->entries[0].priv_data; | ||
292 | data_addr = priv_tx->data; | ||
293 | data_dma = priv_tx->data_dma; | ||
294 | |||
295 | priv_tx->data = NULL; | ||
296 | } | ||
297 | 263 | ||
298 | if (data_addr) | 264 | if (entry_priv->data) |
299 | pci_free_consistent(pci_dev, dma_size(queue), | 265 | pci_free_consistent(pci_dev, dma_size(queue), |
300 | data_addr, data_dma); | 266 | entry_priv->data, entry_priv->data_dma); |
267 | entry_priv->data = NULL; | ||
301 | } | 268 | } |
302 | 269 | ||
303 | int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev) | 270 | int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev) |