aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2800pci.c
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2010-12-13 06:34:22 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-12-13 15:23:35 -0500
commit5450b7e2f0b47e52175b31399d8186a74ef3c46d (patch)
tree4023a3b3cc577d12f1c733a140fce7e965e7eabe /drivers/net/wireless/rt2x00/rt2800pci.c
parent094a1d92fdb18c4455758b1c33e99d647c837ee9 (diff)
rt2x00: Introduce 3 queue commands in drivers (start, kick, stop).
As part of the queue refactoring, we now introduce 3 queue commands: start, kick, stop. - Start: will enable a queue, for TX this will not mean anything, while for beacons and RX this will update the registers to enable the queue. - Kick: This will kick all pending frames to the hardware. This is needed for the TX queue to push all frames to the HW after the queue has been started - Stop: This will stop the queue in the hardware, and cancel any pending work (So this doesn't mean the queue is empty after a stop!). Move all code from the drivers into the appropriate functions, and link those calls to the old rt2x00lib callback functions (we will fix this later when we refactor the queue control inside rt2x00lib). Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2800pci.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.c129
1 files changed, 76 insertions, 53 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index 49447222e40f..a7105974a2a1 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -186,6 +186,77 @@ static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
186#endif /* CONFIG_PCI */ 186#endif /* CONFIG_PCI */
187 187
188/* 188/*
189 * Queue handlers.
190 */
191static void rt2800pci_start_queue(struct data_queue *queue)
192{
193 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
194 u32 reg;
195
196 switch (queue->qid) {
197 case QID_RX:
198 rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
199 rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX, 1);
200 rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
201 break;
202 case QID_BEACON:
203 rt2800_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
204 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 1);
205 rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 1);
206 rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 1);
207 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg);
208 break;
209 default:
210 break;
211 };
212}
213
214static void rt2800pci_kick_queue(struct data_queue *queue)
215{
216 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
217 struct queue_entry *entry;
218
219 switch (queue->qid) {
220 case QID_AC_BE:
221 case QID_AC_BK:
222 case QID_AC_VI:
223 case QID_AC_VO:
224 entry = rt2x00queue_get_entry(queue, Q_INDEX);
225 rt2800_register_write(rt2x00dev, TX_CTX_IDX(queue->qid), entry->entry_idx);
226 break;
227 case QID_MGMT:
228 entry = rt2x00queue_get_entry(queue, Q_INDEX);
229 rt2800_register_write(rt2x00dev, TX_CTX_IDX(5), entry->entry_idx);
230 break;
231 default:
232 break;
233 }
234}
235
236static void rt2800pci_stop_queue(struct data_queue *queue)
237{
238 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
239 u32 reg;
240
241 switch (queue->qid) {
242 case QID_RX:
243 rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
244 rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX, 0);
245 rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
246 break;
247 case QID_BEACON:
248 rt2800_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
249 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 0);
250 rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 0);
251 rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 0);
252 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg);
253 break;
254 default:
255 break;
256 }
257}
258
259/*
189 * Firmware functions 260 * Firmware functions
190 */ 261 */
191static char *rt2800pci_get_firmware_name(struct rt2x00_dev *rt2x00dev) 262static char *rt2800pci_get_firmware_name(struct rt2x00_dev *rt2x00dev)
@@ -323,17 +394,6 @@ static int rt2800pci_init_queues(struct rt2x00_dev *rt2x00dev)
323/* 394/*
324 * Device state switch handlers. 395 * Device state switch handlers.
325 */ 396 */
326static void rt2800pci_toggle_rx(struct rt2x00_dev *rt2x00dev,
327 enum dev_state state)
328{
329 u32 reg;
330
331 rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
332 rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX,
333 (state == STATE_RADIO_RX_ON));
334 rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
335}
336
337static void rt2800pci_toggle_irq(struct rt2x00_dev *rt2x00dev, 397static void rt2800pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
338 enum dev_state state) 398 enum dev_state state)
339{ 399{
@@ -478,8 +538,10 @@ static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev,
478 rt2800pci_set_state(rt2x00dev, STATE_SLEEP); 538 rt2800pci_set_state(rt2x00dev, STATE_SLEEP);
479 break; 539 break;
480 case STATE_RADIO_RX_ON: 540 case STATE_RADIO_RX_ON:
541 rt2800pci_start_queue(rt2x00dev->rx);
542 break;
481 case STATE_RADIO_RX_OFF: 543 case STATE_RADIO_RX_OFF:
482 rt2800pci_toggle_rx(rt2x00dev, state); 544 rt2800pci_stop_queue(rt2x00dev->rx);
483 break; 545 break;
484 case STATE_RADIO_IRQ_ON: 546 case STATE_RADIO_IRQ_ON:
485 case STATE_RADIO_IRQ_ON_ISR: 547 case STATE_RADIO_IRQ_ON_ISR:
@@ -566,45 +628,6 @@ static void rt2800pci_write_tx_desc(struct queue_entry *entry,
566} 628}
567 629
568/* 630/*
569 * TX data initialization
570 */
571static void rt2800pci_kick_tx_queue(struct data_queue *queue)
572{
573 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
574 struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX);
575 unsigned int qidx;
576
577 if (queue->qid == QID_MGMT)
578 qidx = 5;
579 else
580 qidx = queue->qid;
581
582 rt2800_register_write(rt2x00dev, TX_CTX_IDX(qidx), entry->entry_idx);
583}
584
585static void rt2800pci_kill_tx_queue(struct data_queue *queue)
586{
587 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
588 u32 reg;
589
590 if (queue->qid == QID_BEACON) {
591 rt2800_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
592 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 0);
593 rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 0);
594 rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 0);
595 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg);
596 return;
597 }
598
599 rt2800_register_read(rt2x00dev, WPDMA_RST_IDX, &reg);
600 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX0, (queue->qid == QID_AC_BE));
601 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX1, (queue->qid == QID_AC_BK));
602 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX2, (queue->qid == QID_AC_VI));
603 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX3, (queue->qid == QID_AC_VO));
604 rt2800_register_write(rt2x00dev, WPDMA_RST_IDX, reg);
605}
606
607/*
608 * RX control handlers 631 * RX control handlers
609 */ 632 */
610static void rt2800pci_fill_rxdone(struct queue_entry *entry, 633static void rt2800pci_fill_rxdone(struct queue_entry *entry,
@@ -984,8 +1007,8 @@ static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = {
984 .write_tx_desc = rt2800pci_write_tx_desc, 1007 .write_tx_desc = rt2800pci_write_tx_desc,
985 .write_tx_data = rt2800_write_tx_data, 1008 .write_tx_data = rt2800_write_tx_data,
986 .write_beacon = rt2800_write_beacon, 1009 .write_beacon = rt2800_write_beacon,
987 .kick_tx_queue = rt2800pci_kick_tx_queue, 1010 .kick_tx_queue = rt2800pci_kick_queue,
988 .kill_tx_queue = rt2800pci_kill_tx_queue, 1011 .kill_tx_queue = rt2800pci_stop_queue,
989 .fill_rxdone = rt2800pci_fill_rxdone, 1012 .fill_rxdone = rt2800pci_fill_rxdone,
990 .config_shared_key = rt2800_config_shared_key, 1013 .config_shared_key = rt2800_config_shared_key,
991 .config_pairwise_key = rt2800_config_pairwise_key, 1014 .config_pairwise_key = rt2800_config_pairwise_key,