aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2013-10-17 03:42:17 -0400
committerJohn W. Linville <linville@tuxdriver.com>2013-10-18 14:06:58 -0400
commit0bc202b3bbea5106677b8b142a09d3d57a2bb263 (patch)
tree8f5f64d138fa184c138f1b9ff319d17d8e0386f8 /drivers/net/wireless/rt2x00
parent45c67550ad72be5c892d7b001fc835aae18a7a62 (diff)
rt2x00: rt2800pci: move TX descriptor functions to the rt2800mmio module
Move the functions into a separate module, in order to make those usable from other modules. Also move the TX 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>
Diffstat (limited to 'drivers/net/wireless/rt2x00')
-rw-r--r--drivers/net/wireless/rt2x00/Kconfig1
-rw-r--r--drivers/net/wireless/rt2x00/rt2800mmio.c68
-rw-r--r--drivers/net/wireless/rt2x00/rt2800mmio.h47
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.c62
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.h37
5 files changed, 117 insertions, 98 deletions
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig
index 2232b1155983..535ad3a6970c 100644
--- a/drivers/net/wireless/rt2x00/Kconfig
+++ b/drivers/net/wireless/rt2x00/Kconfig
@@ -205,6 +205,7 @@ config RT2800_LIB
205 205
206config RT2800_LIB_MMIO 206config RT2800_LIB_MMIO
207 tristate 207 tristate
208 select RT2X00_LIB_MMIO
208 209
209config RT2X00_LIB_MMIO 210config RT2X00_LIB_MMIO
210 tristate 211 tristate
diff --git a/drivers/net/wireless/rt2x00/rt2800mmio.c b/drivers/net/wireless/rt2x00/rt2800mmio.c
index a2b9848f4012..d2ebb68b97af 100644
--- a/drivers/net/wireless/rt2x00/rt2800mmio.c
+++ b/drivers/net/wireless/rt2x00/rt2800mmio.c
@@ -30,6 +30,74 @@
30 30
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/export.h>
34
35#include "rt2x00.h"
36#include "rt2x00mmio.h"
37#include "rt2800mmio.h"
38
39/*
40 * TX descriptor initialization
41 */
42__le32 *rt2800mmio_get_txwi(struct queue_entry *entry)
43{
44 return (__le32 *) entry->skb->data;
45}
46EXPORT_SYMBOL_GPL(rt2800mmio_get_txwi);
47
48void rt2800mmio_write_tx_desc(struct queue_entry *entry,
49 struct txentry_desc *txdesc)
50{
51 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
52 struct queue_entry_priv_mmio *entry_priv = entry->priv_data;
53 __le32 *txd = entry_priv->desc;
54 u32 word;
55 const unsigned int txwi_size = entry->queue->winfo_size;
56
57 /*
58 * The buffers pointed by SD_PTR0/SD_LEN0 and SD_PTR1/SD_LEN1
59 * must contains a TXWI structure + 802.11 header + padding + 802.11
60 * data. We choose to have SD_PTR0/SD_LEN0 only contains TXWI and
61 * SD_PTR1/SD_LEN1 contains 802.11 header + padding + 802.11
62 * data. It means that LAST_SEC0 is always 0.
63 */
64
65 /*
66 * Initialize TX descriptor
67 */
68 word = 0;
69 rt2x00_set_field32(&word, TXD_W0_SD_PTR0, skbdesc->skb_dma);
70 rt2x00_desc_write(txd, 0, word);
71
72 word = 0;
73 rt2x00_set_field32(&word, TXD_W1_SD_LEN1, entry->skb->len);
74 rt2x00_set_field32(&word, TXD_W1_LAST_SEC1,
75 !test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
76 rt2x00_set_field32(&word, TXD_W1_BURST,
77 test_bit(ENTRY_TXD_BURST, &txdesc->flags));
78 rt2x00_set_field32(&word, TXD_W1_SD_LEN0, txwi_size);
79 rt2x00_set_field32(&word, TXD_W1_LAST_SEC0, 0);
80 rt2x00_set_field32(&word, TXD_W1_DMA_DONE, 0);
81 rt2x00_desc_write(txd, 1, word);
82
83 word = 0;
84 rt2x00_set_field32(&word, TXD_W2_SD_PTR1,
85 skbdesc->skb_dma + txwi_size);
86 rt2x00_desc_write(txd, 2, word);
87
88 word = 0;
89 rt2x00_set_field32(&word, TXD_W3_WIV,
90 !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags));
91 rt2x00_set_field32(&word, TXD_W3_QSEL, 2);
92 rt2x00_desc_write(txd, 3, word);
93
94 /*
95 * Register descriptor details in skb frame descriptor.
96 */
97 skbdesc->desc = txd;
98 skbdesc->desc_len = TXD_DESC_SIZE;
99}
100EXPORT_SYMBOL_GPL(rt2800mmio_write_tx_desc);
33 101
34#include "rt2x00.h" 102#include "rt2x00.h"
35 103
diff --git a/drivers/net/wireless/rt2x00/rt2800mmio.h b/drivers/net/wireless/rt2x00/rt2800mmio.h
index 32f9dcde9fad..026664002d01 100644
--- a/drivers/net/wireless/rt2x00/rt2800mmio.h
+++ b/drivers/net/wireless/rt2x00/rt2800mmio.h
@@ -31,4 +31,51 @@
31#ifndef RT2800MMIO_H 31#ifndef RT2800MMIO_H
32#define RT2800MMIO_H 32#define RT2800MMIO_H
33 33
34/*
35 * DMA descriptor defines.
36 */
37#define TXD_DESC_SIZE (4 * sizeof(__le32))
38
39/*
40 * TX descriptor format for TX, PRIO and Beacon Ring.
41 */
42
43/*
44 * Word0
45 */
46#define TXD_W0_SD_PTR0 FIELD32(0xffffffff)
47
48/*
49 * Word1
50 */
51#define TXD_W1_SD_LEN1 FIELD32(0x00003fff)
52#define TXD_W1_LAST_SEC1 FIELD32(0x00004000)
53#define TXD_W1_BURST FIELD32(0x00008000)
54#define TXD_W1_SD_LEN0 FIELD32(0x3fff0000)
55#define TXD_W1_LAST_SEC0 FIELD32(0x40000000)
56#define TXD_W1_DMA_DONE FIELD32(0x80000000)
57
58/*
59 * Word2
60 */
61#define TXD_W2_SD_PTR1 FIELD32(0xffffffff)
62
63/*
64 * Word3
65 * WIV: Wireless Info Valid. 1: Driver filled WI, 0: DMA needs to copy WI
66 * QSEL: Select on-chip FIFO ID for 2nd-stage output scheduler.
67 * 0:MGMT, 1:HCCA 2:EDCA
68 */
69#define TXD_W3_WIV FIELD32(0x01000000)
70#define TXD_W3_QSEL FIELD32(0x06000000)
71#define TXD_W3_TCO FIELD32(0x20000000)
72#define TXD_W3_UCO FIELD32(0x40000000)
73#define TXD_W3_ICO FIELD32(0x80000000)
74
75
76/* TX descriptor initialization */
77__le32 *rt2800mmio_get_txwi(struct queue_entry *entry);
78void rt2800mmio_write_tx_desc(struct queue_entry *entry,
79 struct txentry_desc *txdesc);
80
34#endif /* RT2800MMIO_H */ 81#endif /* RT2800MMIO_H */
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index ddc6a42ad7b9..b2e2b091dabb 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -45,6 +45,7 @@
45#include "rt2x00pci.h" 45#include "rt2x00pci.h"
46#include "rt2x00soc.h" 46#include "rt2x00soc.h"
47#include "rt2800lib.h" 47#include "rt2800lib.h"
48#include "rt2800mmio.h"
48#include "rt2800.h" 49#include "rt2800.h"
49#include "rt2800pci.h" 50#include "rt2800pci.h"
50 51
@@ -627,67 +628,6 @@ static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev,
627} 628}
628 629
629/* 630/*
630 * TX descriptor initialization
631 */
632static __le32 *rt2800mmio_get_txwi(struct queue_entry *entry)
633{
634 return (__le32 *) entry->skb->data;
635}
636
637static void rt2800mmio_write_tx_desc(struct queue_entry *entry,
638 struct txentry_desc *txdesc)
639{
640 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
641 struct queue_entry_priv_mmio *entry_priv = entry->priv_data;
642 __le32 *txd = entry_priv->desc;
643 u32 word;
644 const unsigned int txwi_size = entry->queue->winfo_size;
645
646 /*
647 * The buffers pointed by SD_PTR0/SD_LEN0 and SD_PTR1/SD_LEN1
648 * must contains a TXWI structure + 802.11 header + padding + 802.11
649 * data. We choose to have SD_PTR0/SD_LEN0 only contains TXWI and
650 * SD_PTR1/SD_LEN1 contains 802.11 header + padding + 802.11
651 * data. It means that LAST_SEC0 is always 0.
652 */
653
654 /*
655 * Initialize TX descriptor
656 */
657 word = 0;
658 rt2x00_set_field32(&word, TXD_W0_SD_PTR0, skbdesc->skb_dma);
659 rt2x00_desc_write(txd, 0, word);
660
661 word = 0;
662 rt2x00_set_field32(&word, TXD_W1_SD_LEN1, entry->skb->len);
663 rt2x00_set_field32(&word, TXD_W1_LAST_SEC1,
664 !test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
665 rt2x00_set_field32(&word, TXD_W1_BURST,
666 test_bit(ENTRY_TXD_BURST, &txdesc->flags));
667 rt2x00_set_field32(&word, TXD_W1_SD_LEN0, txwi_size);
668 rt2x00_set_field32(&word, TXD_W1_LAST_SEC0, 0);
669 rt2x00_set_field32(&word, TXD_W1_DMA_DONE, 0);
670 rt2x00_desc_write(txd, 1, word);
671
672 word = 0;
673 rt2x00_set_field32(&word, TXD_W2_SD_PTR1,
674 skbdesc->skb_dma + txwi_size);
675 rt2x00_desc_write(txd, 2, word);
676
677 word = 0;
678 rt2x00_set_field32(&word, TXD_W3_WIV,
679 !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags));
680 rt2x00_set_field32(&word, TXD_W3_QSEL, 2);
681 rt2x00_desc_write(txd, 3, word);
682
683 /*
684 * Register descriptor details in skb frame descriptor.
685 */
686 skbdesc->desc = txd;
687 skbdesc->desc_len = TXD_DESC_SIZE;
688}
689
690/*
691 * RX control handlers 631 * RX control handlers
692 */ 632 */
693static void rt2800pci_fill_rxdone(struct queue_entry *entry, 633static void rt2800pci_fill_rxdone(struct queue_entry *entry,
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.h b/drivers/net/wireless/rt2x00/rt2800pci.h
index ab22a087c50d..ecd154ea56d0 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.h
+++ b/drivers/net/wireless/rt2x00/rt2800pci.h
@@ -53,46 +53,9 @@
53/* 53/*
54 * DMA descriptor defines. 54 * DMA descriptor defines.
55 */ 55 */
56#define TXD_DESC_SIZE (4 * sizeof(__le32))
57#define RXD_DESC_SIZE (4 * sizeof(__le32)) 56#define RXD_DESC_SIZE (4 * sizeof(__le32))
58 57
59/* 58/*
60 * TX descriptor format for TX, PRIO and Beacon Ring.
61 */
62
63/*
64 * Word0
65 */
66#define TXD_W0_SD_PTR0 FIELD32(0xffffffff)
67
68/*
69 * Word1
70 */
71#define TXD_W1_SD_LEN1 FIELD32(0x00003fff)
72#define TXD_W1_LAST_SEC1 FIELD32(0x00004000)
73#define TXD_W1_BURST FIELD32(0x00008000)
74#define TXD_W1_SD_LEN0 FIELD32(0x3fff0000)
75#define TXD_W1_LAST_SEC0 FIELD32(0x40000000)
76#define TXD_W1_DMA_DONE FIELD32(0x80000000)
77
78/*
79 * Word2
80 */
81#define TXD_W2_SD_PTR1 FIELD32(0xffffffff)
82
83/*
84 * Word3
85 * WIV: Wireless Info Valid. 1: Driver filled WI, 0: DMA needs to copy WI
86 * QSEL: Select on-chip FIFO ID for 2nd-stage output scheduler.
87 * 0:MGMT, 1:HCCA 2:EDCA
88 */
89#define TXD_W3_WIV FIELD32(0x01000000)
90#define TXD_W3_QSEL FIELD32(0x06000000)
91#define TXD_W3_TCO FIELD32(0x20000000)
92#define TXD_W3_UCO FIELD32(0x40000000)
93#define TXD_W3_ICO FIELD32(0x80000000)
94
95/*
96 * RX descriptor format for RX Ring. 59 * RX descriptor format for RX Ring.
97 */ 60 */
98 61