aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00')
-rw-r--r--drivers/net/wireless/rt2x00/Kconfig72
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c144
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.h6
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c150
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.h4
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c98
-rw-r--r--drivers/net/wireless/rt2x00/rt2800.h218
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c223
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.c215
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.h12
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c363
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.h4
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h114
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c14
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00debug.c15
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c104
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00ht.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00lib.h12
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00link.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c63
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00pci.c11
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00pci.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c270
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.h74
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00reg.h4
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00soc.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.c305
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.h12
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c185
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.h64
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c107
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.h38
33 files changed, 1798 insertions, 1117 deletions
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig
index 4396d4b9bfb9..6f383cd684b0 100644
--- a/drivers/net/wireless/rt2x00/Kconfig
+++ b/drivers/net/wireless/rt2x00/Kconfig
@@ -53,51 +53,41 @@ config RT61PCI
53 53
54 When compiled as a module, this driver will be called rt61pci. 54 When compiled as a module, this driver will be called rt61pci.
55 55
56config RT2800PCI_PCI
57 boolean
58 depends on PCI
59 default y
60
61config RT2800PCI_SOC
62 boolean
63 depends on RALINK_RT288X || RALINK_RT305X
64 default y
65
66config RT2800PCI 56config RT2800PCI
67 tristate "Ralink rt28xx/rt30xx/rt35xx (PCI/PCIe/PCMCIA) support (EXPERIMENTAL)" 57 tristate "Ralink rt27xx/rt28xx/rt30xx (PCI/PCIe/PCMCIA) support"
68 depends on (RT2800PCI_PCI || RT2800PCI_SOC) && EXPERIMENTAL 58 depends on PCI || RALINK_RT288X || RALINK_RT305X
69 select RT2800_LIB 59 select RT2800_LIB
70 select RT2X00_LIB_PCI if RT2800PCI_PCI 60 select RT2X00_LIB_PCI if PCI
71 select RT2X00_LIB_SOC if RT2800PCI_SOC 61 select RT2X00_LIB_SOC if RALINK_RT288X || RALINK_RT305X
72 select RT2X00_LIB_HT 62 select RT2X00_LIB_HT
73 select RT2X00_LIB_FIRMWARE 63 select RT2X00_LIB_FIRMWARE
74 select RT2X00_LIB_CRYPTO 64 select RT2X00_LIB_CRYPTO
75 select CRC_CCITT 65 select CRC_CCITT
76 select EEPROM_93CX6 66 select EEPROM_93CX6
77 ---help--- 67 ---help---
78 This adds support for rt2800/rt3000/rt3500 wireless chipset family. 68 This adds support for rt27xx/rt28xx/rt30xx wireless chipset family.
79 Supported chips: RT2760, RT2790, RT2860, RT2880, RT2890 & RT3052 69 Supported chips: RT2760, RT2790, RT2860, RT2880, RT2890, RT3052,
80 70 RT3090, RT3091 & RT3092
81 This driver is non-functional at the moment and is intended for
82 developers.
83 71
84 When compiled as a module, this driver will be called "rt2800pci.ko". 72 When compiled as a module, this driver will be called "rt2800pci.ko".
85 73
86if RT2800PCI 74if RT2800PCI
87 75
88config RT2800PCI_RT30XX 76config RT2800PCI_RT33XX
89 bool "rt2800pci - Include support for rt30xx (PCI/PCIe/PCMCIA) devices" 77 bool "rt2800pci - Include support for rt33xx devices (EXPERIMENTAL)"
90 default y 78 depends on EXPERIMENTAL
79 default n
91 ---help--- 80 ---help---
92 This adds support for rt30xx wireless chipset family to the 81 This adds support for rt33xx wireless chipset family to the
93 rt2800pci driver. 82 rt2800pci driver.
94 Supported chips: RT3090, RT3091 & RT3092 83 Supported chips: RT3390
95 84
96 Support for these devices is non-functional at the moment and is 85 Support for these devices is non-functional at the moment and is
97 intended for testers and developers. 86 intended for testers and developers.
98 87
99config RT2800PCI_RT35XX 88config RT2800PCI_RT35XX
100 bool "rt2800pci - Include support for rt35xx (PCI/PCIe/PCMCIA) devices" 89 bool "rt2800pci - Include support for rt35xx devices (EXPERIMENTAL)"
90 depends on EXPERIMENTAL
101 default n 91 default n
102 ---help--- 92 ---help---
103 This adds support for rt35xx wireless chipset family to the 93 This adds support for rt35xx wireless chipset family to the
@@ -134,8 +124,8 @@ config RT73USB
134 When compiled as a module, this driver will be called rt73usb. 124 When compiled as a module, this driver will be called rt73usb.
135 125
136config RT2800USB 126config RT2800USB
137 tristate "Ralink rt2800 (USB) support (EXPERIMENTAL)" 127 tristate "Ralink rt27xx/rt28xx/rt30xx (USB) support"
138 depends on USB && EXPERIMENTAL 128 depends on USB
139 select RT2800_LIB 129 select RT2800_LIB
140 select RT2X00_LIB_USB 130 select RT2X00_LIB_USB
141 select RT2X00_LIB_HT 131 select RT2X00_LIB_HT
@@ -143,30 +133,28 @@ config RT2800USB
143 select RT2X00_LIB_CRYPTO 133 select RT2X00_LIB_CRYPTO
144 select CRC_CCITT 134 select CRC_CCITT
145 ---help--- 135 ---help---
146 This adds experimental support for rt2800 wireless chipset family. 136 This adds support for rt27xx/rt28xx/rt30xx wireless chipset family.
147 Supported chips: RT2770, RT2870 & RT3070. 137 Supported chips: RT2770, RT2870 & RT3070, RT3071 & RT3072
148
149 Known issues:
150 - support for RT2870 chips doesn't work with 802.11n APs yet
151 - support for RT3070 chips is non-functional at the moment
152 138
153 When compiled as a module, this driver will be called "rt2800usb.ko". 139 When compiled as a module, this driver will be called "rt2800usb.ko".
154 140
155if RT2800USB 141if RT2800USB
156 142
157config RT2800USB_RT30XX 143config RT2800USB_RT33XX
158 bool "rt2800usb - Include support for rt30xx (USB) devices" 144 bool "rt2800usb - Include support for rt33xx devices (EXPERIMENTAL)"
159 default y 145 depends on EXPERIMENTAL
146 default n
160 ---help--- 147 ---help---
161 This adds support for rt30xx wireless chipset family to the 148 This adds support for rt33xx wireless chipset family to the
162 rt2800usb driver. 149 rt2800usb driver.
163 Supported chips: RT3070, RT3071 & RT3072 150 Supported chips: RT3370
164 151
165 Support for these devices is non-functional at the moment and is 152 Support for these devices is non-functional at the moment and is
166 intended for testers and developers. 153 intended for testers and developers.
167 154
168config RT2800USB_RT35XX 155config RT2800USB_RT35XX
169 bool "rt2800usb - Include support for rt35xx (USB) devices" 156 bool "rt2800usb - Include support for rt35xx devices (EXPERIMENTAL)"
157 depends on EXPERIMENTAL
170 default n 158 default n
171 ---help--- 159 ---help---
172 This adds support for rt35xx wireless chipset family to the 160 This adds support for rt35xx wireless chipset family to the
@@ -180,9 +168,9 @@ config RT2800USB_UNKNOWN
180 bool "rt2800usb - Include support for unknown (USB) devices" 168 bool "rt2800usb - Include support for unknown (USB) devices"
181 default n 169 default n
182 ---help--- 170 ---help---
183 This adds support for rt2800 family devices that are known to 171 This adds support for rt2800usb devices that are known to
184 have a rt2800 family chipset, but for which the exact chipset 172 have a rt28xx family compatible chipset, but for which the exact
185 is unknown. 173 chipset is unknown.
186 174
187 Support status for these devices is unknown, and enabling these 175 Support status for these devices is unknown, and enabling these
188 devices may or may not work. 176 devices may or may not work.
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index 4f420a9ec5dc..54ca49ad3472 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -633,6 +633,88 @@ static void rt2400pci_link_tuner(struct rt2x00_dev *rt2x00dev,
633} 633}
634 634
635/* 635/*
636 * Queue handlers.
637 */
638static void rt2400pci_start_queue(struct data_queue *queue)
639{
640 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
641 u32 reg;
642
643 switch (queue->qid) {
644 case QID_RX:
645 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
646 rt2x00_set_field32(&reg, RXCSR0_DISABLE_RX, 0);
647 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
648 break;
649 case QID_BEACON:
650 rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
651 rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
652 rt2x00_set_field32(&reg, CSR14_TBCN, 1);
653 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 1);
654 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
655 break;
656 default:
657 break;
658 }
659}
660
661static void rt2400pci_kick_queue(struct data_queue *queue)
662{
663 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
664 u32 reg;
665
666 switch (queue->qid) {
667 case QID_AC_VO:
668 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
669 rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO, 1);
670 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
671 break;
672 case QID_AC_VI:
673 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
674 rt2x00_set_field32(&reg, TXCSR0_KICK_TX, 1);
675 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
676 break;
677 case QID_ATIM:
678 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
679 rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM, 1);
680 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
681 break;
682 default:
683 break;
684 }
685}
686
687static void rt2400pci_stop_queue(struct data_queue *queue)
688{
689 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
690 u32 reg;
691
692 switch (queue->qid) {
693 case QID_AC_VO:
694 case QID_AC_VI:
695 case QID_ATIM:
696 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
697 rt2x00_set_field32(&reg, TXCSR0_ABORT, 1);
698 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
699 break;
700 case QID_RX:
701 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
702 rt2x00_set_field32(&reg, RXCSR0_DISABLE_RX, 1);
703 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
704 break;
705 case QID_BEACON:
706 rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
707 rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 0);
708 rt2x00_set_field32(&reg, CSR14_TBCN, 0);
709 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
710 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
711 break;
712 default:
713 break;
714 }
715}
716
717/*
636 * Initialization functions. 718 * Initialization functions.
637 */ 719 */
638static bool rt2400pci_get_entry_state(struct queue_entry *entry) 720static bool rt2400pci_get_entry_state(struct queue_entry *entry)
@@ -878,18 +960,6 @@ static int rt2400pci_init_bbp(struct rt2x00_dev *rt2x00dev)
878/* 960/*
879 * Device state switch handlers. 961 * Device state switch handlers.
880 */ 962 */
881static void rt2400pci_toggle_rx(struct rt2x00_dev *rt2x00dev,
882 enum dev_state state)
883{
884 u32 reg;
885
886 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
887 rt2x00_set_field32(&reg, RXCSR0_DISABLE_RX,
888 (state == STATE_RADIO_RX_OFF) ||
889 (state == STATE_RADIO_RX_OFF_LINK));
890 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
891}
892
893static void rt2400pci_toggle_irq(struct rt2x00_dev *rt2x00dev, 963static void rt2400pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
894 enum dev_state state) 964 enum dev_state state)
895{ 965{
@@ -988,12 +1058,6 @@ static int rt2400pci_set_device_state(struct rt2x00_dev *rt2x00dev,
988 case STATE_RADIO_OFF: 1058 case STATE_RADIO_OFF:
989 rt2400pci_disable_radio(rt2x00dev); 1059 rt2400pci_disable_radio(rt2x00dev);
990 break; 1060 break;
991 case STATE_RADIO_RX_ON:
992 case STATE_RADIO_RX_ON_LINK:
993 case STATE_RADIO_RX_OFF:
994 case STATE_RADIO_RX_OFF_LINK:
995 rt2400pci_toggle_rx(rt2x00dev, state);
996 break;
997 case STATE_RADIO_IRQ_ON: 1061 case STATE_RADIO_IRQ_ON:
998 case STATE_RADIO_IRQ_ON_ISR: 1062 case STATE_RADIO_IRQ_ON_ISR:
999 case STATE_RADIO_IRQ_OFF: 1063 case STATE_RADIO_IRQ_OFF:
@@ -1125,32 +1189,6 @@ static void rt2400pci_write_beacon(struct queue_entry *entry,
1125 rt2x00pci_register_write(rt2x00dev, CSR14, reg); 1189 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
1126} 1190}
1127 1191
1128static void rt2400pci_kick_tx_queue(struct data_queue *queue)
1129{
1130 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1131 u32 reg;
1132
1133 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
1134 rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO, (queue->qid == QID_AC_BE));
1135 rt2x00_set_field32(&reg, TXCSR0_KICK_TX, (queue->qid == QID_AC_BK));
1136 rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM, (queue->qid == QID_ATIM));
1137 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
1138}
1139
1140static void rt2400pci_kill_tx_queue(struct data_queue *queue)
1141{
1142 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1143 u32 reg;
1144
1145 if (queue->qid == QID_BEACON) {
1146 rt2x00pci_register_write(rt2x00dev, CSR14, 0);
1147 } else {
1148 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
1149 rt2x00_set_field32(&reg, TXCSR0_ABORT, 1);
1150 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
1151 }
1152}
1153
1154/* 1192/*
1155 * RX control handlers 1193 * RX control handlers
1156 */ 1194 */
@@ -1284,13 +1322,13 @@ static irqreturn_t rt2400pci_interrupt_thread(int irq, void *dev_instance)
1284 * 4 - Priority ring transmit done interrupt. 1322 * 4 - Priority ring transmit done interrupt.
1285 */ 1323 */
1286 if (rt2x00_get_field32(reg, CSR7_TXDONE_PRIORING)) 1324 if (rt2x00_get_field32(reg, CSR7_TXDONE_PRIORING))
1287 rt2400pci_txdone(rt2x00dev, QID_AC_BE); 1325 rt2400pci_txdone(rt2x00dev, QID_AC_VO);
1288 1326
1289 /* 1327 /*
1290 * 5 - Tx ring transmit done interrupt. 1328 * 5 - Tx ring transmit done interrupt.
1291 */ 1329 */
1292 if (rt2x00_get_field32(reg, CSR7_TXDONE_TXRING)) 1330 if (rt2x00_get_field32(reg, CSR7_TXDONE_TXRING))
1293 rt2400pci_txdone(rt2x00dev, QID_AC_BK); 1331 rt2400pci_txdone(rt2x00dev, QID_AC_VI);
1294 1332
1295 /* Enable interrupts again. */ 1333 /* Enable interrupts again. */
1296 rt2x00dev->ops->lib->set_device_state(rt2x00dev, 1334 rt2x00dev->ops->lib->set_device_state(rt2x00dev,
@@ -1612,6 +1650,7 @@ static const struct ieee80211_ops rt2400pci_mac80211_ops = {
1612 .get_tsf = rt2400pci_get_tsf, 1650 .get_tsf = rt2400pci_get_tsf,
1613 .tx_last_beacon = rt2400pci_tx_last_beacon, 1651 .tx_last_beacon = rt2400pci_tx_last_beacon,
1614 .rfkill_poll = rt2x00mac_rfkill_poll, 1652 .rfkill_poll = rt2x00mac_rfkill_poll,
1653 .flush = rt2x00mac_flush,
1615}; 1654};
1616 1655
1617static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = { 1656static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
@@ -1627,10 +1666,11 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
1627 .link_stats = rt2400pci_link_stats, 1666 .link_stats = rt2400pci_link_stats,
1628 .reset_tuner = rt2400pci_reset_tuner, 1667 .reset_tuner = rt2400pci_reset_tuner,
1629 .link_tuner = rt2400pci_link_tuner, 1668 .link_tuner = rt2400pci_link_tuner,
1669 .start_queue = rt2400pci_start_queue,
1670 .kick_queue = rt2400pci_kick_queue,
1671 .stop_queue = rt2400pci_stop_queue,
1630 .write_tx_desc = rt2400pci_write_tx_desc, 1672 .write_tx_desc = rt2400pci_write_tx_desc,
1631 .write_beacon = rt2400pci_write_beacon, 1673 .write_beacon = rt2400pci_write_beacon,
1632 .kick_tx_queue = rt2400pci_kick_tx_queue,
1633 .kill_tx_queue = rt2400pci_kill_tx_queue,
1634 .fill_rxdone = rt2400pci_fill_rxdone, 1674 .fill_rxdone = rt2400pci_fill_rxdone,
1635 .config_filter = rt2400pci_config_filter, 1675 .config_filter = rt2400pci_config_filter,
1636 .config_intf = rt2400pci_config_intf, 1676 .config_intf = rt2400pci_config_intf,
@@ -1640,28 +1680,28 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
1640}; 1680};
1641 1681
1642static const struct data_queue_desc rt2400pci_queue_rx = { 1682static const struct data_queue_desc rt2400pci_queue_rx = {
1643 .entry_num = RX_ENTRIES, 1683 .entry_num = 24,
1644 .data_size = DATA_FRAME_SIZE, 1684 .data_size = DATA_FRAME_SIZE,
1645 .desc_size = RXD_DESC_SIZE, 1685 .desc_size = RXD_DESC_SIZE,
1646 .priv_size = sizeof(struct queue_entry_priv_pci), 1686 .priv_size = sizeof(struct queue_entry_priv_pci),
1647}; 1687};
1648 1688
1649static const struct data_queue_desc rt2400pci_queue_tx = { 1689static const struct data_queue_desc rt2400pci_queue_tx = {
1650 .entry_num = TX_ENTRIES, 1690 .entry_num = 24,
1651 .data_size = DATA_FRAME_SIZE, 1691 .data_size = DATA_FRAME_SIZE,
1652 .desc_size = TXD_DESC_SIZE, 1692 .desc_size = TXD_DESC_SIZE,
1653 .priv_size = sizeof(struct queue_entry_priv_pci), 1693 .priv_size = sizeof(struct queue_entry_priv_pci),
1654}; 1694};
1655 1695
1656static const struct data_queue_desc rt2400pci_queue_bcn = { 1696static const struct data_queue_desc rt2400pci_queue_bcn = {
1657 .entry_num = BEACON_ENTRIES, 1697 .entry_num = 1,
1658 .data_size = MGMT_FRAME_SIZE, 1698 .data_size = MGMT_FRAME_SIZE,
1659 .desc_size = TXD_DESC_SIZE, 1699 .desc_size = TXD_DESC_SIZE,
1660 .priv_size = sizeof(struct queue_entry_priv_pci), 1700 .priv_size = sizeof(struct queue_entry_priv_pci),
1661}; 1701};
1662 1702
1663static const struct data_queue_desc rt2400pci_queue_atim = { 1703static const struct data_queue_desc rt2400pci_queue_atim = {
1664 .entry_num = ATIM_ENTRIES, 1704 .entry_num = 8,
1665 .data_size = DATA_FRAME_SIZE, 1705 .data_size = DATA_FRAME_SIZE,
1666 .desc_size = TXD_DESC_SIZE, 1706 .desc_size = TXD_DESC_SIZE,
1667 .priv_size = sizeof(struct queue_entry_priv_pci), 1707 .priv_size = sizeof(struct queue_entry_priv_pci),
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.h b/drivers/net/wireless/rt2x00/rt2400pci.h
index c048b18f4133..d3a4a68cc439 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.h
+++ b/drivers/net/wireless/rt2x00/rt2400pci.h
@@ -809,8 +809,8 @@
809/* 809/*
810 * DMA descriptor defines. 810 * DMA descriptor defines.
811 */ 811 */
812#define TXD_DESC_SIZE ( 8 * sizeof(__le32) ) 812#define TXD_DESC_SIZE (8 * sizeof(__le32))
813#define RXD_DESC_SIZE ( 8 * sizeof(__le32) ) 813#define RXD_DESC_SIZE (8 * sizeof(__le32))
814 814
815/* 815/*
816 * TX descriptor format for TX, PRIO, ATIM and Beacon Ring. 816 * TX descriptor format for TX, PRIO, ATIM and Beacon Ring.
@@ -948,6 +948,6 @@
948 ((__CLAMP_TX(__txpower) - MAX_TXPOWER) + MIN_TXPOWER) 948 ((__CLAMP_TX(__txpower) - MAX_TXPOWER) + MIN_TXPOWER)
949 949
950#define TXPOWER_TO_DEV(__txpower) \ 950#define TXPOWER_TO_DEV(__txpower) \
951 MAX_TXPOWER - (__CLAMP_TX(__txpower) - MIN_TXPOWER) 951 (MAX_TXPOWER - (__CLAMP_TX(__txpower) - MIN_TXPOWER))
952 952
953#endif /* RT2400PCI_H */ 953#endif /* RT2400PCI_H */
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 97feb7aef809..a9ff26a27724 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -723,6 +723,88 @@ dynamic_cca_tune:
723} 723}
724 724
725/* 725/*
726 * Queue handlers.
727 */
728static void rt2500pci_start_queue(struct data_queue *queue)
729{
730 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
731 u32 reg;
732
733 switch (queue->qid) {
734 case QID_RX:
735 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
736 rt2x00_set_field32(&reg, RXCSR0_DISABLE_RX, 0);
737 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
738 break;
739 case QID_BEACON:
740 rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
741 rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
742 rt2x00_set_field32(&reg, CSR14_TBCN, 1);
743 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 1);
744 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
745 break;
746 default:
747 break;
748 }
749}
750
751static void rt2500pci_kick_queue(struct data_queue *queue)
752{
753 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
754 u32 reg;
755
756 switch (queue->qid) {
757 case QID_AC_VO:
758 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
759 rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO, 1);
760 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
761 break;
762 case QID_AC_VI:
763 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
764 rt2x00_set_field32(&reg, TXCSR0_KICK_TX, 1);
765 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
766 break;
767 case QID_ATIM:
768 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
769 rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM, 1);
770 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
771 break;
772 default:
773 break;
774 }
775}
776
777static void rt2500pci_stop_queue(struct data_queue *queue)
778{
779 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
780 u32 reg;
781
782 switch (queue->qid) {
783 case QID_AC_VO:
784 case QID_AC_VI:
785 case QID_ATIM:
786 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
787 rt2x00_set_field32(&reg, TXCSR0_ABORT, 1);
788 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
789 break;
790 case QID_RX:
791 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
792 rt2x00_set_field32(&reg, RXCSR0_DISABLE_RX, 1);
793 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
794 break;
795 case QID_BEACON:
796 rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
797 rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 0);
798 rt2x00_set_field32(&reg, CSR14_TBCN, 0);
799 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
800 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
801 break;
802 default:
803 break;
804 }
805}
806
807/*
726 * Initialization functions. 808 * Initialization functions.
727 */ 809 */
728static bool rt2500pci_get_entry_state(struct queue_entry *entry) 810static bool rt2500pci_get_entry_state(struct queue_entry *entry)
@@ -1033,18 +1115,6 @@ static int rt2500pci_init_bbp(struct rt2x00_dev *rt2x00dev)
1033/* 1115/*
1034 * Device state switch handlers. 1116 * Device state switch handlers.
1035 */ 1117 */
1036static void rt2500pci_toggle_rx(struct rt2x00_dev *rt2x00dev,
1037 enum dev_state state)
1038{
1039 u32 reg;
1040
1041 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
1042 rt2x00_set_field32(&reg, RXCSR0_DISABLE_RX,
1043 (state == STATE_RADIO_RX_OFF) ||
1044 (state == STATE_RADIO_RX_OFF_LINK));
1045 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
1046}
1047
1048static void rt2500pci_toggle_irq(struct rt2x00_dev *rt2x00dev, 1118static void rt2500pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
1049 enum dev_state state) 1119 enum dev_state state)
1050{ 1120{
@@ -1143,12 +1213,6 @@ static int rt2500pci_set_device_state(struct rt2x00_dev *rt2x00dev,
1143 case STATE_RADIO_OFF: 1213 case STATE_RADIO_OFF:
1144 rt2500pci_disable_radio(rt2x00dev); 1214 rt2500pci_disable_radio(rt2x00dev);
1145 break; 1215 break;
1146 case STATE_RADIO_RX_ON:
1147 case STATE_RADIO_RX_ON_LINK:
1148 case STATE_RADIO_RX_OFF:
1149 case STATE_RADIO_RX_OFF_LINK:
1150 rt2500pci_toggle_rx(rt2x00dev, state);
1151 break;
1152 case STATE_RADIO_IRQ_ON: 1216 case STATE_RADIO_IRQ_ON:
1153 case STATE_RADIO_IRQ_ON_ISR: 1217 case STATE_RADIO_IRQ_ON_ISR:
1154 case STATE_RADIO_IRQ_OFF: 1218 case STATE_RADIO_IRQ_OFF:
@@ -1193,9 +1257,9 @@ static void rt2500pci_write_tx_desc(struct queue_entry *entry,
1193 1257
1194 rt2x00_desc_read(txd, 2, &word); 1258 rt2x00_desc_read(txd, 2, &word);
1195 rt2x00_set_field32(&word, TXD_W2_IV_OFFSET, IEEE80211_HEADER); 1259 rt2x00_set_field32(&word, TXD_W2_IV_OFFSET, IEEE80211_HEADER);
1196 rt2x00_set_field32(&word, TXD_W2_AIFS, txdesc->aifs); 1260 rt2x00_set_field32(&word, TXD_W2_AIFS, entry->queue->aifs);
1197 rt2x00_set_field32(&word, TXD_W2_CWMIN, txdesc->cw_min); 1261 rt2x00_set_field32(&word, TXD_W2_CWMIN, entry->queue->cw_min);
1198 rt2x00_set_field32(&word, TXD_W2_CWMAX, txdesc->cw_max); 1262 rt2x00_set_field32(&word, TXD_W2_CWMAX, entry->queue->cw_max);
1199 rt2x00_desc_write(txd, 2, word); 1263 rt2x00_desc_write(txd, 2, word);
1200 1264
1201 rt2x00_desc_read(txd, 3, &word); 1265 rt2x00_desc_read(txd, 3, &word);
@@ -1279,32 +1343,6 @@ static void rt2500pci_write_beacon(struct queue_entry *entry,
1279 rt2x00pci_register_write(rt2x00dev, CSR14, reg); 1343 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
1280} 1344}
1281 1345
1282static void rt2500pci_kick_tx_queue(struct data_queue *queue)
1283{
1284 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1285 u32 reg;
1286
1287 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
1288 rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO, (queue->qid == QID_AC_BE));
1289 rt2x00_set_field32(&reg, TXCSR0_KICK_TX, (queue->qid == QID_AC_BK));
1290 rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM, (queue->qid == QID_ATIM));
1291 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
1292}
1293
1294static void rt2500pci_kill_tx_queue(struct data_queue *queue)
1295{
1296 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1297 u32 reg;
1298
1299 if (queue->qid == QID_BEACON) {
1300 rt2x00pci_register_write(rt2x00dev, CSR14, 0);
1301 } else {
1302 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
1303 rt2x00_set_field32(&reg, TXCSR0_ABORT, 1);
1304 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
1305 }
1306}
1307
1308/* 1346/*
1309 * RX control handlers 1347 * RX control handlers
1310 */ 1348 */
@@ -1417,13 +1455,13 @@ static irqreturn_t rt2500pci_interrupt_thread(int irq, void *dev_instance)
1417 * 4 - Priority ring transmit done interrupt. 1455 * 4 - Priority ring transmit done interrupt.
1418 */ 1456 */
1419 if (rt2x00_get_field32(reg, CSR7_TXDONE_PRIORING)) 1457 if (rt2x00_get_field32(reg, CSR7_TXDONE_PRIORING))
1420 rt2500pci_txdone(rt2x00dev, QID_AC_BE); 1458 rt2500pci_txdone(rt2x00dev, QID_AC_VO);
1421 1459
1422 /* 1460 /*
1423 * 5 - Tx ring transmit done interrupt. 1461 * 5 - Tx ring transmit done interrupt.
1424 */ 1462 */
1425 if (rt2x00_get_field32(reg, CSR7_TXDONE_TXRING)) 1463 if (rt2x00_get_field32(reg, CSR7_TXDONE_TXRING))
1426 rt2500pci_txdone(rt2x00dev, QID_AC_BK); 1464 rt2500pci_txdone(rt2x00dev, QID_AC_VI);
1427 1465
1428 /* Enable interrupts again. */ 1466 /* Enable interrupts again. */
1429 rt2x00dev->ops->lib->set_device_state(rt2x00dev, 1467 rt2x00dev->ops->lib->set_device_state(rt2x00dev,
@@ -1909,6 +1947,7 @@ static const struct ieee80211_ops rt2500pci_mac80211_ops = {
1909 .get_tsf = rt2500pci_get_tsf, 1947 .get_tsf = rt2500pci_get_tsf,
1910 .tx_last_beacon = rt2500pci_tx_last_beacon, 1948 .tx_last_beacon = rt2500pci_tx_last_beacon,
1911 .rfkill_poll = rt2x00mac_rfkill_poll, 1949 .rfkill_poll = rt2x00mac_rfkill_poll,
1950 .flush = rt2x00mac_flush,
1912}; 1951};
1913 1952
1914static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = { 1953static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = {
@@ -1924,10 +1963,11 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = {
1924 .link_stats = rt2500pci_link_stats, 1963 .link_stats = rt2500pci_link_stats,
1925 .reset_tuner = rt2500pci_reset_tuner, 1964 .reset_tuner = rt2500pci_reset_tuner,
1926 .link_tuner = rt2500pci_link_tuner, 1965 .link_tuner = rt2500pci_link_tuner,
1966 .start_queue = rt2500pci_start_queue,
1967 .kick_queue = rt2500pci_kick_queue,
1968 .stop_queue = rt2500pci_stop_queue,
1927 .write_tx_desc = rt2500pci_write_tx_desc, 1969 .write_tx_desc = rt2500pci_write_tx_desc,
1928 .write_beacon = rt2500pci_write_beacon, 1970 .write_beacon = rt2500pci_write_beacon,
1929 .kick_tx_queue = rt2500pci_kick_tx_queue,
1930 .kill_tx_queue = rt2500pci_kill_tx_queue,
1931 .fill_rxdone = rt2500pci_fill_rxdone, 1971 .fill_rxdone = rt2500pci_fill_rxdone,
1932 .config_filter = rt2500pci_config_filter, 1972 .config_filter = rt2500pci_config_filter,
1933 .config_intf = rt2500pci_config_intf, 1973 .config_intf = rt2500pci_config_intf,
@@ -1937,28 +1977,28 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = {
1937}; 1977};
1938 1978
1939static const struct data_queue_desc rt2500pci_queue_rx = { 1979static const struct data_queue_desc rt2500pci_queue_rx = {
1940 .entry_num = RX_ENTRIES, 1980 .entry_num = 32,
1941 .data_size = DATA_FRAME_SIZE, 1981 .data_size = DATA_FRAME_SIZE,
1942 .desc_size = RXD_DESC_SIZE, 1982 .desc_size = RXD_DESC_SIZE,
1943 .priv_size = sizeof(struct queue_entry_priv_pci), 1983 .priv_size = sizeof(struct queue_entry_priv_pci),
1944}; 1984};
1945 1985
1946static const struct data_queue_desc rt2500pci_queue_tx = { 1986static const struct data_queue_desc rt2500pci_queue_tx = {
1947 .entry_num = TX_ENTRIES, 1987 .entry_num = 32,
1948 .data_size = DATA_FRAME_SIZE, 1988 .data_size = DATA_FRAME_SIZE,
1949 .desc_size = TXD_DESC_SIZE, 1989 .desc_size = TXD_DESC_SIZE,
1950 .priv_size = sizeof(struct queue_entry_priv_pci), 1990 .priv_size = sizeof(struct queue_entry_priv_pci),
1951}; 1991};
1952 1992
1953static const struct data_queue_desc rt2500pci_queue_bcn = { 1993static const struct data_queue_desc rt2500pci_queue_bcn = {
1954 .entry_num = BEACON_ENTRIES, 1994 .entry_num = 1,
1955 .data_size = MGMT_FRAME_SIZE, 1995 .data_size = MGMT_FRAME_SIZE,
1956 .desc_size = TXD_DESC_SIZE, 1996 .desc_size = TXD_DESC_SIZE,
1957 .priv_size = sizeof(struct queue_entry_priv_pci), 1997 .priv_size = sizeof(struct queue_entry_priv_pci),
1958}; 1998};
1959 1999
1960static const struct data_queue_desc rt2500pci_queue_atim = { 2000static const struct data_queue_desc rt2500pci_queue_atim = {
1961 .entry_num = ATIM_ENTRIES, 2001 .entry_num = 8,
1962 .data_size = DATA_FRAME_SIZE, 2002 .data_size = DATA_FRAME_SIZE,
1963 .desc_size = TXD_DESC_SIZE, 2003 .desc_size = TXD_DESC_SIZE,
1964 .priv_size = sizeof(struct queue_entry_priv_pci), 2004 .priv_size = sizeof(struct queue_entry_priv_pci),
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.h b/drivers/net/wireless/rt2x00/rt2500pci.h
index d708031361ac..2aad7ba8a100 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.h
+++ b/drivers/net/wireless/rt2x00/rt2500pci.h
@@ -1088,8 +1088,8 @@
1088/* 1088/*
1089 * DMA descriptor defines. 1089 * DMA descriptor defines.
1090 */ 1090 */
1091#define TXD_DESC_SIZE ( 11 * sizeof(__le32) ) 1091#define TXD_DESC_SIZE (11 * sizeof(__le32))
1092#define RXD_DESC_SIZE ( 11 * sizeof(__le32) ) 1092#define RXD_DESC_SIZE (11 * sizeof(__le32))
1093 1093
1094/* 1094/*
1095 * TX descriptor format for TX, PRIO, ATIM and Beacon Ring. 1095 * TX descriptor format for TX, PRIO, ATIM and Beacon Ring.
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 93e44c7f3a74..6b3b1de46792 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -39,7 +39,7 @@
39/* 39/*
40 * Allow hardware encryption to be disabled. 40 * Allow hardware encryption to be disabled.
41 */ 41 */
42static int modparam_nohwcrypt = 0; 42static int modparam_nohwcrypt;
43module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO); 43module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO);
44MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption."); 44MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
45 45
@@ -739,6 +739,55 @@ static void rt2500usb_reset_tuner(struct rt2x00_dev *rt2x00dev,
739} 739}
740 740
741/* 741/*
742 * Queue handlers.
743 */
744static void rt2500usb_start_queue(struct data_queue *queue)
745{
746 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
747 u16 reg;
748
749 switch (queue->qid) {
750 case QID_RX:
751 rt2500usb_register_read(rt2x00dev, TXRX_CSR2, &reg);
752 rt2x00_set_field16(&reg, TXRX_CSR2_DISABLE_RX, 0);
753 rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg);
754 break;
755 case QID_BEACON:
756 rt2500usb_register_read(rt2x00dev, TXRX_CSR19, &reg);
757 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_COUNT, 1);
758 rt2x00_set_field16(&reg, TXRX_CSR19_TBCN, 1);
759 rt2x00_set_field16(&reg, TXRX_CSR19_BEACON_GEN, 1);
760 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
761 break;
762 default:
763 break;
764 }
765}
766
767static void rt2500usb_stop_queue(struct data_queue *queue)
768{
769 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
770 u16 reg;
771
772 switch (queue->qid) {
773 case QID_RX:
774 rt2500usb_register_read(rt2x00dev, TXRX_CSR2, &reg);
775 rt2x00_set_field16(&reg, TXRX_CSR2_DISABLE_RX, 1);
776 rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg);
777 break;
778 case QID_BEACON:
779 rt2500usb_register_read(rt2x00dev, TXRX_CSR19, &reg);
780 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_COUNT, 0);
781 rt2x00_set_field16(&reg, TXRX_CSR19_TBCN, 0);
782 rt2x00_set_field16(&reg, TXRX_CSR19_BEACON_GEN, 0);
783 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
784 break;
785 default:
786 break;
787 }
788}
789
790/*
742 * Initialization functions. 791 * Initialization functions.
743 */ 792 */
744static int rt2500usb_init_registers(struct rt2x00_dev *rt2x00dev) 793static int rt2500usb_init_registers(struct rt2x00_dev *rt2x00dev)
@@ -931,18 +980,6 @@ static int rt2500usb_init_bbp(struct rt2x00_dev *rt2x00dev)
931/* 980/*
932 * Device state switch handlers. 981 * Device state switch handlers.
933 */ 982 */
934static void rt2500usb_toggle_rx(struct rt2x00_dev *rt2x00dev,
935 enum dev_state state)
936{
937 u16 reg;
938
939 rt2500usb_register_read(rt2x00dev, TXRX_CSR2, &reg);
940 rt2x00_set_field16(&reg, TXRX_CSR2_DISABLE_RX,
941 (state == STATE_RADIO_RX_OFF) ||
942 (state == STATE_RADIO_RX_OFF_LINK));
943 rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg);
944}
945
946static int rt2500usb_enable_radio(struct rt2x00_dev *rt2x00dev) 983static int rt2500usb_enable_radio(struct rt2x00_dev *rt2x00dev)
947{ 984{
948 /* 985 /*
@@ -1018,12 +1055,6 @@ static int rt2500usb_set_device_state(struct rt2x00_dev *rt2x00dev,
1018 case STATE_RADIO_OFF: 1055 case STATE_RADIO_OFF:
1019 rt2500usb_disable_radio(rt2x00dev); 1056 rt2500usb_disable_radio(rt2x00dev);
1020 break; 1057 break;
1021 case STATE_RADIO_RX_ON:
1022 case STATE_RADIO_RX_ON_LINK:
1023 case STATE_RADIO_RX_OFF:
1024 case STATE_RADIO_RX_OFF_LINK:
1025 rt2500usb_toggle_rx(rt2x00dev, state);
1026 break;
1027 case STATE_RADIO_IRQ_ON: 1058 case STATE_RADIO_IRQ_ON:
1028 case STATE_RADIO_IRQ_ON_ISR: 1059 case STATE_RADIO_IRQ_ON_ISR:
1029 case STATE_RADIO_IRQ_OFF: 1060 case STATE_RADIO_IRQ_OFF:
@@ -1081,9 +1112,9 @@ static void rt2500usb_write_tx_desc(struct queue_entry *entry,
1081 1112
1082 rt2x00_desc_read(txd, 1, &word); 1113 rt2x00_desc_read(txd, 1, &word);
1083 rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, txdesc->iv_offset); 1114 rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, txdesc->iv_offset);
1084 rt2x00_set_field32(&word, TXD_W1_AIFS, txdesc->aifs); 1115 rt2x00_set_field32(&word, TXD_W1_AIFS, entry->queue->aifs);
1085 rt2x00_set_field32(&word, TXD_W1_CWMIN, txdesc->cw_min); 1116 rt2x00_set_field32(&word, TXD_W1_CWMIN, entry->queue->cw_min);
1086 rt2x00_set_field32(&word, TXD_W1_CWMAX, txdesc->cw_max); 1117 rt2x00_set_field32(&word, TXD_W1_CWMAX, entry->queue->cw_max);
1087 rt2x00_desc_write(txd, 1, word); 1118 rt2x00_desc_write(txd, 1, word);
1088 1119
1089 rt2x00_desc_read(txd, 2, &word); 1120 rt2x00_desc_read(txd, 2, &word);
@@ -1206,14 +1237,6 @@ static int rt2500usb_get_tx_data_len(struct queue_entry *entry)
1206 return length; 1237 return length;
1207} 1238}
1208 1239
1209static void rt2500usb_kill_tx_queue(struct data_queue *queue)
1210{
1211 if (queue->qid == QID_BEACON)
1212 rt2500usb_register_write(queue->rt2x00dev, TXRX_CSR19, 0);
1213
1214 rt2x00usb_kill_tx_queue(queue);
1215}
1216
1217/* 1240/*
1218 * RX control handlers 1241 * RX control handlers
1219 */ 1242 */
@@ -1801,6 +1824,7 @@ static const struct ieee80211_ops rt2500usb_mac80211_ops = {
1801 .bss_info_changed = rt2x00mac_bss_info_changed, 1824 .bss_info_changed = rt2x00mac_bss_info_changed,
1802 .conf_tx = rt2x00mac_conf_tx, 1825 .conf_tx = rt2x00mac_conf_tx,
1803 .rfkill_poll = rt2x00mac_rfkill_poll, 1826 .rfkill_poll = rt2x00mac_rfkill_poll,
1827 .flush = rt2x00mac_flush,
1804}; 1828};
1805 1829
1806static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = { 1830static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
@@ -1813,11 +1837,13 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
1813 .link_stats = rt2500usb_link_stats, 1837 .link_stats = rt2500usb_link_stats,
1814 .reset_tuner = rt2500usb_reset_tuner, 1838 .reset_tuner = rt2500usb_reset_tuner,
1815 .watchdog = rt2x00usb_watchdog, 1839 .watchdog = rt2x00usb_watchdog,
1840 .start_queue = rt2500usb_start_queue,
1841 .kick_queue = rt2x00usb_kick_queue,
1842 .stop_queue = rt2500usb_stop_queue,
1843 .flush_queue = rt2x00usb_flush_queue,
1816 .write_tx_desc = rt2500usb_write_tx_desc, 1844 .write_tx_desc = rt2500usb_write_tx_desc,
1817 .write_beacon = rt2500usb_write_beacon, 1845 .write_beacon = rt2500usb_write_beacon,
1818 .get_tx_data_len = rt2500usb_get_tx_data_len, 1846 .get_tx_data_len = rt2500usb_get_tx_data_len,
1819 .kick_tx_queue = rt2x00usb_kick_tx_queue,
1820 .kill_tx_queue = rt2500usb_kill_tx_queue,
1821 .fill_rxdone = rt2500usb_fill_rxdone, 1847 .fill_rxdone = rt2500usb_fill_rxdone,
1822 .config_shared_key = rt2500usb_config_key, 1848 .config_shared_key = rt2500usb_config_key,
1823 .config_pairwise_key = rt2500usb_config_key, 1849 .config_pairwise_key = rt2500usb_config_key,
@@ -1829,28 +1855,28 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
1829}; 1855};
1830 1856
1831static const struct data_queue_desc rt2500usb_queue_rx = { 1857static const struct data_queue_desc rt2500usb_queue_rx = {
1832 .entry_num = RX_ENTRIES, 1858 .entry_num = 32,
1833 .data_size = DATA_FRAME_SIZE, 1859 .data_size = DATA_FRAME_SIZE,
1834 .desc_size = RXD_DESC_SIZE, 1860 .desc_size = RXD_DESC_SIZE,
1835 .priv_size = sizeof(struct queue_entry_priv_usb), 1861 .priv_size = sizeof(struct queue_entry_priv_usb),
1836}; 1862};
1837 1863
1838static const struct data_queue_desc rt2500usb_queue_tx = { 1864static const struct data_queue_desc rt2500usb_queue_tx = {
1839 .entry_num = TX_ENTRIES, 1865 .entry_num = 32,
1840 .data_size = DATA_FRAME_SIZE, 1866 .data_size = DATA_FRAME_SIZE,
1841 .desc_size = TXD_DESC_SIZE, 1867 .desc_size = TXD_DESC_SIZE,
1842 .priv_size = sizeof(struct queue_entry_priv_usb), 1868 .priv_size = sizeof(struct queue_entry_priv_usb),
1843}; 1869};
1844 1870
1845static const struct data_queue_desc rt2500usb_queue_bcn = { 1871static const struct data_queue_desc rt2500usb_queue_bcn = {
1846 .entry_num = BEACON_ENTRIES, 1872 .entry_num = 1,
1847 .data_size = MGMT_FRAME_SIZE, 1873 .data_size = MGMT_FRAME_SIZE,
1848 .desc_size = TXD_DESC_SIZE, 1874 .desc_size = TXD_DESC_SIZE,
1849 .priv_size = sizeof(struct queue_entry_priv_usb_bcn), 1875 .priv_size = sizeof(struct queue_entry_priv_usb_bcn),
1850}; 1876};
1851 1877
1852static const struct data_queue_desc rt2500usb_queue_atim = { 1878static const struct data_queue_desc rt2500usb_queue_atim = {
1853 .entry_num = ATIM_ENTRIES, 1879 .entry_num = 8,
1854 .data_size = DATA_FRAME_SIZE, 1880 .data_size = DATA_FRAME_SIZE,
1855 .desc_size = TXD_DESC_SIZE, 1881 .desc_size = TXD_DESC_SIZE,
1856 .priv_size = sizeof(struct queue_entry_priv_usb), 1882 .priv_size = sizeof(struct queue_entry_priv_usb),
diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index eb8b6cab9925..4c55e8525cad 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -46,7 +46,11 @@
46 * RF2020 2.4G B/G 46 * RF2020 2.4G B/G
47 * RF3021 2.4G 1T2R 47 * RF3021 2.4G 1T2R
48 * RF3022 2.4G 2T2R 48 * RF3022 2.4G 2T2R
49 * RF3052 2.4G 2T2R 49 * RF3052 2.4G/5G 2T2R
50 * RF2853 2.4G/5G 3T3R
51 * RF3320 2.4G 1T1R(RT3350/RT3370/RT3390)
52 * RF3322 2.4G 2T2R(RT3352/RT3371/RT3372/RT3391/RT3392)
53 * RF3853 2.4G/5G 3T3R(RT3883/RT3563/RT3573/RT3593/RT3662)
50 */ 54 */
51#define RF2820 0x0001 55#define RF2820 0x0001
52#define RF2850 0x0002 56#define RF2850 0x0002
@@ -57,7 +61,10 @@
57#define RF3021 0x0007 61#define RF3021 0x0007
58#define RF3022 0x0008 62#define RF3022 0x0008
59#define RF3052 0x0009 63#define RF3052 0x0009
64#define RF2853 0x000a
60#define RF3320 0x000b 65#define RF3320 0x000b
66#define RF3322 0x000c
67#define RF3853 0x000d
61 68
62/* 69/*
63 * Chipset revisions. 70 * Chipset revisions.
@@ -206,10 +213,10 @@
206 213
207/* 214/*
208 * WMM_AIFSN_CFG: Aifsn for each EDCA AC 215 * WMM_AIFSN_CFG: Aifsn for each EDCA AC
209 * AIFSN0: AC_BE 216 * AIFSN0: AC_VO
210 * AIFSN1: AC_BK 217 * AIFSN1: AC_VI
211 * AIFSN2: AC_VI 218 * AIFSN2: AC_BE
212 * AIFSN3: AC_VO 219 * AIFSN3: AC_BK
213 */ 220 */
214#define WMM_AIFSN_CFG 0x0214 221#define WMM_AIFSN_CFG 0x0214
215#define WMM_AIFSN_CFG_AIFSN0 FIELD32(0x0000000f) 222#define WMM_AIFSN_CFG_AIFSN0 FIELD32(0x0000000f)
@@ -219,10 +226,10 @@
219 226
220/* 227/*
221 * WMM_CWMIN_CSR: CWmin for each EDCA AC 228 * WMM_CWMIN_CSR: CWmin for each EDCA AC
222 * CWMIN0: AC_BE 229 * CWMIN0: AC_VO
223 * CWMIN1: AC_BK 230 * CWMIN1: AC_VI
224 * CWMIN2: AC_VI 231 * CWMIN2: AC_BE
225 * CWMIN3: AC_VO 232 * CWMIN3: AC_BK
226 */ 233 */
227#define WMM_CWMIN_CFG 0x0218 234#define WMM_CWMIN_CFG 0x0218
228#define WMM_CWMIN_CFG_CWMIN0 FIELD32(0x0000000f) 235#define WMM_CWMIN_CFG_CWMIN0 FIELD32(0x0000000f)
@@ -232,10 +239,10 @@
232 239
233/* 240/*
234 * WMM_CWMAX_CSR: CWmax for each EDCA AC 241 * WMM_CWMAX_CSR: CWmax for each EDCA AC
235 * CWMAX0: AC_BE 242 * CWMAX0: AC_VO
236 * CWMAX1: AC_BK 243 * CWMAX1: AC_VI
237 * CWMAX2: AC_VI 244 * CWMAX2: AC_BE
238 * CWMAX3: AC_VO 245 * CWMAX3: AC_BK
239 */ 246 */
240#define WMM_CWMAX_CFG 0x021c 247#define WMM_CWMAX_CFG 0x021c
241#define WMM_CWMAX_CFG_CWMAX0 FIELD32(0x0000000f) 248#define WMM_CWMAX_CFG_CWMAX0 FIELD32(0x0000000f)
@@ -244,18 +251,18 @@
244#define WMM_CWMAX_CFG_CWMAX3 FIELD32(0x0000f000) 251#define WMM_CWMAX_CFG_CWMAX3 FIELD32(0x0000f000)
245 252
246/* 253/*
247 * AC_TXOP0: AC_BK/AC_BE TXOP register 254 * AC_TXOP0: AC_VO/AC_VI TXOP register
248 * AC0TXOP: AC_BK in unit of 32us 255 * AC0TXOP: AC_VO in unit of 32us
249 * AC1TXOP: AC_BE in unit of 32us 256 * AC1TXOP: AC_VI in unit of 32us
250 */ 257 */
251#define WMM_TXOP0_CFG 0x0220 258#define WMM_TXOP0_CFG 0x0220
252#define WMM_TXOP0_CFG_AC0TXOP FIELD32(0x0000ffff) 259#define WMM_TXOP0_CFG_AC0TXOP FIELD32(0x0000ffff)
253#define WMM_TXOP0_CFG_AC1TXOP FIELD32(0xffff0000) 260#define WMM_TXOP0_CFG_AC1TXOP FIELD32(0xffff0000)
254 261
255/* 262/*
256 * AC_TXOP1: AC_VO/AC_VI TXOP register 263 * AC_TXOP1: AC_BE/AC_BK TXOP register
257 * AC2TXOP: AC_VI in unit of 32us 264 * AC2TXOP: AC_BE in unit of 32us
258 * AC3TXOP: AC_VO in unit of 32us 265 * AC3TXOP: AC_BK in unit of 32us
259 */ 266 */
260#define WMM_TXOP1_CFG 0x0224 267#define WMM_TXOP1_CFG 0x0224
261#define WMM_TXOP1_CFG_AC2TXOP FIELD32(0x0000ffff) 268#define WMM_TXOP1_CFG_AC2TXOP FIELD32(0x0000ffff)
@@ -281,7 +288,7 @@
281#define MCU_CMD_CFG 0x022c 288#define MCU_CMD_CFG 0x022c
282 289
283/* 290/*
284 * AC_BK register offsets 291 * AC_VO register offsets
285 */ 292 */
286#define TX_BASE_PTR0 0x0230 293#define TX_BASE_PTR0 0x0230
287#define TX_MAX_CNT0 0x0234 294#define TX_MAX_CNT0 0x0234
@@ -289,7 +296,7 @@
289#define TX_DTX_IDX0 0x023c 296#define TX_DTX_IDX0 0x023c
290 297
291/* 298/*
292 * AC_BE register offsets 299 * AC_VI register offsets
293 */ 300 */
294#define TX_BASE_PTR1 0x0240 301#define TX_BASE_PTR1 0x0240
295#define TX_MAX_CNT1 0x0244 302#define TX_MAX_CNT1 0x0244
@@ -297,7 +304,7 @@
297#define TX_DTX_IDX1 0x024c 304#define TX_DTX_IDX1 0x024c
298 305
299/* 306/*
300 * AC_VI register offsets 307 * AC_BE register offsets
301 */ 308 */
302#define TX_BASE_PTR2 0x0250 309#define TX_BASE_PTR2 0x0250
303#define TX_MAX_CNT2 0x0254 310#define TX_MAX_CNT2 0x0254
@@ -305,7 +312,7 @@
305#define TX_DTX_IDX2 0x025c 312#define TX_DTX_IDX2 0x025c
306 313
307/* 314/*
308 * AC_VO register offsets 315 * AC_BK register offsets
309 */ 316 */
310#define TX_BASE_PTR3 0x0260 317#define TX_BASE_PTR3 0x0260
311#define TX_MAX_CNT3 0x0264 318#define TX_MAX_CNT3 0x0264
@@ -412,10 +419,22 @@
412#define BCN_OFFSET1_BCN7 FIELD32(0xff000000) 419#define BCN_OFFSET1_BCN7 FIELD32(0xff000000)
413 420
414/* 421/*
415 * PBF registers 422 * TXRXQ_PCNT: PBF register
416 * Most are for debug. Driver doesn't touch PBF register. 423 * PCNT_TX0Q: Page count for TX hardware queue 0
424 * PCNT_TX1Q: Page count for TX hardware queue 1
425 * PCNT_TX2Q: Page count for TX hardware queue 2
426 * PCNT_RX0Q: Page count for RX hardware queue
417 */ 427 */
418#define TXRXQ_PCNT 0x0438 428#define TXRXQ_PCNT 0x0438
429#define TXRXQ_PCNT_TX0Q FIELD32(0x000000ff)
430#define TXRXQ_PCNT_TX1Q FIELD32(0x0000ff00)
431#define TXRXQ_PCNT_TX2Q FIELD32(0x00ff0000)
432#define TXRXQ_PCNT_RX0Q FIELD32(0xff000000)
433
434/*
435 * PBF register
436 * Debug. Driver doesn't touch PBF register.
437 */
419#define PBF_DBG 0x043c 438#define PBF_DBG 0x043c
420 439
421/* 440/*
@@ -686,8 +705,18 @@
686 705
687/* 706/*
688 * CH_TIME_CFG: count as channel busy 707 * CH_TIME_CFG: count as channel busy
708 * EIFS_BUSY: Count EIFS as channel busy
709 * NAV_BUSY: Count NAS as channel busy
710 * RX_BUSY: Count RX as channel busy
711 * TX_BUSY: Count TX as channel busy
712 * TMR_EN: Enable channel statistics timer
689 */ 713 */
690#define CH_TIME_CFG 0x110c 714#define CH_TIME_CFG 0x110c
715#define CH_TIME_CFG_EIFS_BUSY FIELD32(0x00000010)
716#define CH_TIME_CFG_NAV_BUSY FIELD32(0x00000008)
717#define CH_TIME_CFG_RX_BUSY FIELD32(0x00000004)
718#define CH_TIME_CFG_TX_BUSY FIELD32(0x00000002)
719#define CH_TIME_CFG_TMR_EN FIELD32(0x00000001)
691 720
692/* 721/*
693 * PBF_LIFE_TIMER: TX/RX MPDU timestamp timer (free run) Unit: 1us 722 * PBF_LIFE_TIMER: TX/RX MPDU timestamp timer (free run) Unit: 1us
@@ -960,8 +989,31 @@
960 989
961/* 990/*
962 * TXOP_CTRL_CFG: 991 * TXOP_CTRL_CFG:
992 * TIMEOUT_TRUN_EN: Enable/Disable TXOP timeout truncation
993 * AC_TRUN_EN: Enable/Disable truncation for AC change
994 * TXRATEGRP_TRUN_EN: Enable/Disable truncation for TX rate group change
995 * USER_MODE_TRUN_EN: Enable/Disable truncation for user TXOP mode
996 * MIMO_PS_TRUN_EN: Enable/Disable truncation for MIMO PS RTS/CTS
997 * RESERVED_TRUN_EN: Reserved
998 * LSIG_TXOP_EN: Enable/Disable L-SIG TXOP protection
999 * EXT_CCA_EN: Enable/Disable extension channel CCA reference (Defer 40Mhz
1000 * transmissions if extension CCA is clear).
1001 * EXT_CCA_DLY: Extension CCA signal delay time (unit: us)
1002 * EXT_CWMIN: CwMin for extension channel backoff
1003 * 0: Disabled
1004 *
963 */ 1005 */
964#define TXOP_CTRL_CFG 0x1340 1006#define TXOP_CTRL_CFG 0x1340
1007#define TXOP_CTRL_CFG_TIMEOUT_TRUN_EN FIELD32(0x00000001)
1008#define TXOP_CTRL_CFG_AC_TRUN_EN FIELD32(0x00000002)
1009#define TXOP_CTRL_CFG_TXRATEGRP_TRUN_EN FIELD32(0x00000004)
1010#define TXOP_CTRL_CFG_USER_MODE_TRUN_EN FIELD32(0x00000008)
1011#define TXOP_CTRL_CFG_MIMO_PS_TRUN_EN FIELD32(0x00000010)
1012#define TXOP_CTRL_CFG_RESERVED_TRUN_EN FIELD32(0x00000020)
1013#define TXOP_CTRL_CFG_LSIG_TXOP_EN FIELD32(0x00000040)
1014#define TXOP_CTRL_CFG_EXT_CCA_EN FIELD32(0x00000080)
1015#define TXOP_CTRL_CFG_EXT_CCA_DLY FIELD32(0x0000ff00)
1016#define TXOP_CTRL_CFG_EXT_CWMIN FIELD32(0x000f0000)
965 1017
966/* 1018/*
967 * TX_RTS_CFG: 1019 * TX_RTS_CFG:
@@ -1485,17 +1537,17 @@
1485#define SHARED_KEY_MODE_BASE 0x7000 1537#define SHARED_KEY_MODE_BASE 0x7000
1486 1538
1487#define MAC_WCID_ENTRY(__idx) \ 1539#define MAC_WCID_ENTRY(__idx) \
1488 ( MAC_WCID_BASE + ((__idx) * sizeof(struct mac_wcid_entry)) ) 1540 (MAC_WCID_BASE + ((__idx) * sizeof(struct mac_wcid_entry)))
1489#define PAIRWISE_KEY_ENTRY(__idx) \ 1541#define PAIRWISE_KEY_ENTRY(__idx) \
1490 ( PAIRWISE_KEY_TABLE_BASE + ((__idx) * sizeof(struct hw_key_entry)) ) 1542 (PAIRWISE_KEY_TABLE_BASE + ((__idx) * sizeof(struct hw_key_entry)))
1491#define MAC_IVEIV_ENTRY(__idx) \ 1543#define MAC_IVEIV_ENTRY(__idx) \
1492 ( MAC_IVEIV_TABLE_BASE + ((__idx) * sizeof(struct mac_iveiv_entry)) ) 1544 (MAC_IVEIV_TABLE_BASE + ((__idx) * sizeof(struct mac_iveiv_entry)))
1493#define MAC_WCID_ATTR_ENTRY(__idx) \ 1545#define MAC_WCID_ATTR_ENTRY(__idx) \
1494 ( MAC_WCID_ATTRIBUTE_BASE + ((__idx) * sizeof(u32)) ) 1546 (MAC_WCID_ATTRIBUTE_BASE + ((__idx) * sizeof(u32)))
1495#define SHARED_KEY_ENTRY(__idx) \ 1547#define SHARED_KEY_ENTRY(__idx) \
1496 ( SHARED_KEY_TABLE_BASE + ((__idx) * sizeof(struct hw_key_entry)) ) 1548 (SHARED_KEY_TABLE_BASE + ((__idx) * sizeof(struct hw_key_entry)))
1497#define SHARED_KEY_MODE_ENTRY(__idx) \ 1549#define SHARED_KEY_MODE_ENTRY(__idx) \
1498 ( SHARED_KEY_MODE_BASE + ((__idx) * sizeof(u32)) ) 1550 (SHARED_KEY_MODE_BASE + ((__idx) * sizeof(u32)))
1499 1551
1500struct mac_wcid_entry { 1552struct mac_wcid_entry {
1501 u8 mac[6]; 1553 u8 mac[6];
@@ -1635,9 +1687,9 @@ struct mac_iveiv_entry {
1635#define HW_BEACON_BASE7 0x5bc0 1687#define HW_BEACON_BASE7 0x5bc0
1636 1688
1637#define HW_BEACON_OFFSET(__index) \ 1689#define HW_BEACON_OFFSET(__index) \
1638 ( ((__index) < 4) ? ( HW_BEACON_BASE0 + (__index * 0x0200) ) : \ 1690 (((__index) < 4) ? (HW_BEACON_BASE0 + (__index * 0x0200)) : \
1639 (((__index) < 6) ? ( HW_BEACON_BASE4 + ((__index - 4) * 0x0200) ) : \ 1691 (((__index) < 6) ? (HW_BEACON_BASE4 + ((__index - 4) * 0x0200)) : \
1640 (HW_BEACON_BASE6 - ((__index - 6) * 0x0200))) ) 1692 (HW_BEACON_BASE6 - ((__index - 6) * 0x0200))))
1641 1693
1642/* 1694/*
1643 * BBP registers. 1695 * BBP registers.
@@ -1805,32 +1857,51 @@ struct mac_iveiv_entry {
1805#define EEPROM_MAC_ADDR_BYTE5 FIELD16(0xff00) 1857#define EEPROM_MAC_ADDR_BYTE5 FIELD16(0xff00)
1806 1858
1807/* 1859/*
1808 * EEPROM ANTENNA config 1860 * EEPROM NIC Configuration 0
1809 * RXPATH: 1: 1R, 2: 2R, 3: 3R 1861 * RXPATH: 1: 1R, 2: 2R, 3: 3R
1810 * TXPATH: 1: 1T, 2: 2T 1862 * TXPATH: 1: 1T, 2: 2T, 3: 3T
1811 */ 1863 * RF_TYPE: RFIC type
1812#define EEPROM_ANTENNA 0x001a 1864 */
1813#define EEPROM_ANTENNA_RXPATH FIELD16(0x000f) 1865#define EEPROM_NIC_CONF0 0x001a
1814#define EEPROM_ANTENNA_TXPATH FIELD16(0x00f0) 1866#define EEPROM_NIC_CONF0_RXPATH FIELD16(0x000f)
1815#define EEPROM_ANTENNA_RF_TYPE FIELD16(0x0f00) 1867#define EEPROM_NIC_CONF0_TXPATH FIELD16(0x00f0)
1816 1868#define EEPROM_NIC_CONF0_RF_TYPE FIELD16(0x0f00)
1817/* 1869
1818 * EEPROM NIC config 1870/*
1819 * CARDBUS_ACCEL: 0 - enable, 1 - disable 1871 * EEPROM NIC Configuration 1
1820 */ 1872 * HW_RADIO: 0: disable, 1: enable
1821#define EEPROM_NIC 0x001b 1873 * EXTERNAL_TX_ALC: 0: disable, 1: enable
1822#define EEPROM_NIC_HW_RADIO FIELD16(0x0001) 1874 * EXTERNAL_LNA_2G: 0: disable, 1: enable
1823#define EEPROM_NIC_DYNAMIC_TX_AGC FIELD16(0x0002) 1875 * EXTERNAL_LNA_5G: 0: disable, 1: enable
1824#define EEPROM_NIC_EXTERNAL_LNA_BG FIELD16(0x0004) 1876 * CARDBUS_ACCEL: 0: enable, 1: disable
1825#define EEPROM_NIC_EXTERNAL_LNA_A FIELD16(0x0008) 1877 * BW40M_SB_2G: 0: disable, 1: enable
1826#define EEPROM_NIC_CARDBUS_ACCEL FIELD16(0x0010) 1878 * BW40M_SB_5G: 0: disable, 1: enable
1827#define EEPROM_NIC_BW40M_SB_BG FIELD16(0x0020) 1879 * WPS_PBC: 0: disable, 1: enable
1828#define EEPROM_NIC_BW40M_SB_A FIELD16(0x0040) 1880 * BW40M_2G: 0: enable, 1: disable
1829#define EEPROM_NIC_WPS_PBC FIELD16(0x0080) 1881 * BW40M_5G: 0: enable, 1: disable
1830#define EEPROM_NIC_BW40M_BG FIELD16(0x0100) 1882 * BROADBAND_EXT_LNA: 0: disable, 1: enable
1831#define EEPROM_NIC_BW40M_A FIELD16(0x0200) 1883 * ANT_DIVERSITY: 00: Disable, 01: Diversity,
1832#define EEPROM_NIC_ANT_DIVERSITY FIELD16(0x0800) 1884 * 10: Main antenna, 11: Aux antenna
1833#define EEPROM_NIC_DAC_TEST FIELD16(0x8000) 1885 * INTERNAL_TX_ALC: 0: disable, 1: enable
1886 * BT_COEXIST: 0: disable, 1: enable
1887 * DAC_TEST: 0: disable, 1: enable
1888 */
1889#define EEPROM_NIC_CONF1 0x001b
1890#define EEPROM_NIC_CONF1_HW_RADIO FIELD16(0x0001)
1891#define EEPROM_NIC_CONF1_EXTERNAL_TX_ALC FIELD16(0x0002)
1892#define EEPROM_NIC_CONF1_EXTERNAL_LNA_2G FIELD16(0x0004)
1893#define EEPROM_NIC_CONF1_EXTERNAL_LNA_5G FIELD16(0x0008)
1894#define EEPROM_NIC_CONF1_CARDBUS_ACCEL FIELD16(0x0010)
1895#define EEPROM_NIC_CONF1_BW40M_SB_2G FIELD16(0x0020)
1896#define EEPROM_NIC_CONF1_BW40M_SB_5G FIELD16(0x0040)
1897#define EEPROM_NIC_CONF1_WPS_PBC FIELD16(0x0080)
1898#define EEPROM_NIC_CONF1_BW40M_2G FIELD16(0x0100)
1899#define EEPROM_NIC_CONF1_BW40M_5G FIELD16(0x0200)
1900#define EEPROM_NIC_CONF1_BROADBAND_EXT_LNA FIELD16(0x400)
1901#define EEPROM_NIC_CONF1_ANT_DIVERSITY FIELD16(0x1800)
1902#define EEPROM_NIC_CONF1_INTERNAL_TX_ALC FIELD16(0x2000)
1903#define EEPROM_NIC_CONF1_BT_COEXIST FIELD16(0x4000)
1904#define EEPROM_NIC_CONF1_DAC_TEST FIELD16(0x8000)
1834 1905
1835/* 1906/*
1836 * EEPROM frequency 1907 * EEPROM frequency
@@ -1852,9 +1923,9 @@ struct mac_iveiv_entry {
1852 * POLARITY_GPIO_4: Polarity GPIO4 setting. 1923 * POLARITY_GPIO_4: Polarity GPIO4 setting.
1853 * LED_MODE: Led mode. 1924 * LED_MODE: Led mode.
1854 */ 1925 */
1855#define EEPROM_LED1 0x001e 1926#define EEPROM_LED_AG_CONF 0x001e
1856#define EEPROM_LED2 0x001f 1927#define EEPROM_LED_ACT_CONF 0x001f
1857#define EEPROM_LED3 0x0020 1928#define EEPROM_LED_POLARITY 0x0020
1858#define EEPROM_LED_POLARITY_RDY_BG FIELD16(0x0001) 1929#define EEPROM_LED_POLARITY_RDY_BG FIELD16(0x0001)
1859#define EEPROM_LED_POLARITY_RDY_A FIELD16(0x0002) 1930#define EEPROM_LED_POLARITY_RDY_A FIELD16(0x0002)
1860#define EEPROM_LED_POLARITY_ACT FIELD16(0x0004) 1931#define EEPROM_LED_POLARITY_ACT FIELD16(0x0004)
@@ -1866,6 +1937,17 @@ struct mac_iveiv_entry {
1866#define EEPROM_LED_LED_MODE FIELD16(0x1f00) 1937#define EEPROM_LED_LED_MODE FIELD16(0x1f00)
1867 1938
1868/* 1939/*
1940 * EEPROM NIC Configuration 2
1941 * RX_STREAM: 0: Reserved, 1: 1 Stream, 2: 2 Stream
1942 * TX_STREAM: 0: Reserved, 1: 1 Stream, 2: 2 Stream
1943 * CRYSTAL: 00: Reserved, 01: One crystal, 10: Two crystal, 11: Reserved
1944 */
1945#define EEPROM_NIC_CONF2 0x0021
1946#define EEPROM_NIC_CONF2_RX_STREAM FIELD16(0x000f)
1947#define EEPROM_NIC_CONF2_TX_STREAM FIELD16(0x00f0)
1948#define EEPROM_NIC_CONF2_CRYSTAL FIELD16(0x0600)
1949
1950/*
1869 * EEPROM LNA 1951 * EEPROM LNA
1870 */ 1952 */
1871#define EEPROM_LNA 0x0022 1953#define EEPROM_LNA 0x0022
@@ -1915,7 +1997,7 @@ struct mac_iveiv_entry {
1915 1997
1916/* 1998/*
1917 * EEPROM TXpower delta: 20MHZ AND 40 MHZ use different power. 1999 * EEPROM TXpower delta: 20MHZ AND 40 MHZ use different power.
1918 * This is delta in 40MHZ. 2000 * This is delta in 40MHZ.
1919 * VALUE: Tx Power dalta value (MAX=4) 2001 * VALUE: Tx Power dalta value (MAX=4)
1920 * TYPE: 1: Plus the delta value, 0: minus the delta value 2002 * TYPE: 1: Plus the delta value, 0: minus the delta value
1921 * TXPOWER: Enable: 2003 * TXPOWER: Enable:
@@ -1971,9 +2053,9 @@ struct mac_iveiv_entry {
1971#define MCU_CURRENT 0x36 2053#define MCU_CURRENT 0x36
1972#define MCU_LED 0x50 2054#define MCU_LED 0x50
1973#define MCU_LED_STRENGTH 0x51 2055#define MCU_LED_STRENGTH 0x51
1974#define MCU_LED_1 0x52 2056#define MCU_LED_AG_CONF 0x52
1975#define MCU_LED_2 0x53 2057#define MCU_LED_ACT_CONF 0x53
1976#define MCU_LED_3 0x54 2058#define MCU_LED_LED_POLARITY 0x54
1977#define MCU_RADAR 0x60 2059#define MCU_RADAR 0x60
1978#define MCU_BOOT_SIGNAL 0x72 2060#define MCU_BOOT_SIGNAL 0x72
1979#define MCU_BBP_SIGNAL 0x80 2061#define MCU_BBP_SIGNAL 0x80
@@ -1987,8 +2069,8 @@ struct mac_iveiv_entry {
1987/* 2069/*
1988 * DMA descriptor defines. 2070 * DMA descriptor defines.
1989 */ 2071 */
1990#define TXWI_DESC_SIZE ( 4 * sizeof(__le32) ) 2072#define TXWI_DESC_SIZE (4 * sizeof(__le32))
1991#define RXWI_DESC_SIZE ( 4 * sizeof(__le32) ) 2073#define RXWI_DESC_SIZE (4 * sizeof(__le32))
1992 2074
1993/* 2075/*
1994 * TX WI structure 2076 * TX WI structure
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 5f00e00789d8..54917a281398 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -277,13 +277,17 @@ int rt2800_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev)
277 unsigned int i; 277 unsigned int i;
278 u32 reg; 278 u32 reg;
279 279
280 /*
281 * Some devices are really slow to respond here. Wait a whole second
282 * before timing out.
283 */
280 for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 284 for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
281 rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, &reg); 285 rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, &reg);
282 if (!rt2x00_get_field32(reg, WPDMA_GLO_CFG_TX_DMA_BUSY) && 286 if (!rt2x00_get_field32(reg, WPDMA_GLO_CFG_TX_DMA_BUSY) &&
283 !rt2x00_get_field32(reg, WPDMA_GLO_CFG_RX_DMA_BUSY)) 287 !rt2x00_get_field32(reg, WPDMA_GLO_CFG_RX_DMA_BUSY))
284 return 0; 288 return 0;
285 289
286 msleep(1); 290 msleep(10);
287 } 291 }
288 292
289 ERROR(rt2x00dev, "WPDMA TX/RX busy, aborting.\n"); 293 ERROR(rt2x00dev, "WPDMA TX/RX busy, aborting.\n");
@@ -483,7 +487,7 @@ void rt2800_write_tx_data(struct queue_entry *entry,
483 txdesc->key_idx : 0xff); 487 txdesc->key_idx : 0xff);
484 rt2x00_set_field32(&word, TXWI_W1_MPDU_TOTAL_BYTE_COUNT, 488 rt2x00_set_field32(&word, TXWI_W1_MPDU_TOTAL_BYTE_COUNT,
485 txdesc->length); 489 txdesc->length);
486 rt2x00_set_field32(&word, TXWI_W1_PACKETID_QUEUE, txdesc->qid); 490 rt2x00_set_field32(&word, TXWI_W1_PACKETID_QUEUE, entry->queue->qid);
487 rt2x00_set_field32(&word, TXWI_W1_PACKETID_ENTRY, (entry->entry_idx % 3) + 1); 491 rt2x00_set_field32(&word, TXWI_W1_PACKETID_ENTRY, (entry->entry_idx % 3) + 1);
488 rt2x00_desc_write(txwi, 1, word); 492 rt2x00_desc_write(txwi, 1, word);
489 493
@@ -727,7 +731,7 @@ void rt2800_txdone(struct rt2x00_dev *rt2x00dev)
727 * that the TX_STA_FIFO stack has a size of 16. We stick to our 731 * that the TX_STA_FIFO stack has a size of 16. We stick to our
728 * tx ring size for now. 732 * tx ring size for now.
729 */ 733 */
730 for (i = 0; i < TX_ENTRIES; i++) { 734 for (i = 0; i < rt2x00dev->ops->tx->entry_num; i++) {
731 rt2800_register_read(rt2x00dev, TX_STA_FIFO, &reg); 735 rt2800_register_read(rt2x00dev, TX_STA_FIFO, &reg);
732 if (!rt2x00_get_field32(reg, TX_STA_FIFO_VALID)) 736 if (!rt2x00_get_field32(reg, TX_STA_FIFO_VALID))
733 break; 737 break;
@@ -768,6 +772,7 @@ void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc)
768 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 772 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
769 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); 773 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
770 unsigned int beacon_base; 774 unsigned int beacon_base;
775 unsigned int padding_len;
771 u32 reg; 776 u32 reg;
772 777
773 /* 778 /*
@@ -802,11 +807,13 @@ void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc)
802 rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry->skb); 807 rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry->skb);
803 808
804 /* 809 /*
805 * Write entire beacon with TXWI to register. 810 * Write entire beacon with TXWI and padding to register.
806 */ 811 */
812 padding_len = roundup(entry->skb->len, 4) - entry->skb->len;
813 skb_pad(entry->skb, padding_len);
807 beacon_base = HW_BEACON_OFFSET(entry->entry_idx); 814 beacon_base = HW_BEACON_OFFSET(entry->entry_idx);
808 rt2800_register_multiwrite(rt2x00dev, beacon_base, 815 rt2800_register_multiwrite(rt2x00dev, beacon_base, entry->skb->data,
809 entry->skb->data, entry->skb->len); 816 entry->skb->len + padding_len);
810 817
811 /* 818 /*
812 * Enable beaconing again. 819 * Enable beaconing again.
@@ -824,7 +831,7 @@ void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc)
824} 831}
825EXPORT_SYMBOL_GPL(rt2800_write_beacon); 832EXPORT_SYMBOL_GPL(rt2800_write_beacon);
826 833
827static void inline rt2800_clear_beacon(struct rt2x00_dev *rt2x00dev, 834static inline void rt2800_clear_beacon(struct rt2x00_dev *rt2x00dev,
828 unsigned int beacon_base) 835 unsigned int beacon_base)
829{ 836{
830 int i; 837 int i;
@@ -1144,6 +1151,7 @@ void rt2800_config_intf(struct rt2x00_dev *rt2x00dev, struct rt2x00_intf *intf,
1144 struct rt2x00intf_conf *conf, const unsigned int flags) 1151 struct rt2x00intf_conf *conf, const unsigned int flags)
1145{ 1152{
1146 u32 reg; 1153 u32 reg;
1154 bool update_bssid = false;
1147 1155
1148 if (flags & CONFIG_UPDATE_TYPE) { 1156 if (flags & CONFIG_UPDATE_TYPE) {
1149 /* 1157 /*
@@ -1173,6 +1181,16 @@ void rt2800_config_intf(struct rt2x00_dev *rt2x00dev, struct rt2x00_intf *intf,
1173 } 1181 }
1174 1182
1175 if (flags & CONFIG_UPDATE_MAC) { 1183 if (flags & CONFIG_UPDATE_MAC) {
1184 if (flags & CONFIG_UPDATE_TYPE &&
1185 conf->sync == TSF_SYNC_AP_NONE) {
1186 /*
1187 * The BSSID register has to be set to our own mac
1188 * address in AP mode.
1189 */
1190 memcpy(conf->bssid, conf->mac, sizeof(conf->mac));
1191 update_bssid = true;
1192 }
1193
1176 if (!is_zero_ether_addr((const u8 *)conf->mac)) { 1194 if (!is_zero_ether_addr((const u8 *)conf->mac)) {
1177 reg = le32_to_cpu(conf->mac[1]); 1195 reg = le32_to_cpu(conf->mac[1]);
1178 rt2x00_set_field32(&reg, MAC_ADDR_DW1_UNICAST_TO_ME_MASK, 0xff); 1196 rt2x00_set_field32(&reg, MAC_ADDR_DW1_UNICAST_TO_ME_MASK, 0xff);
@@ -1183,7 +1201,7 @@ void rt2800_config_intf(struct rt2x00_dev *rt2x00dev, struct rt2x00_intf *intf,
1183 conf->mac, sizeof(conf->mac)); 1201 conf->mac, sizeof(conf->mac));
1184 } 1202 }
1185 1203
1186 if (flags & CONFIG_UPDATE_BSSID) { 1204 if ((flags & CONFIG_UPDATE_BSSID) || update_bssid) {
1187 if (!is_zero_ether_addr((const u8 *)conf->bssid)) { 1205 if (!is_zero_ether_addr((const u8 *)conf->bssid)) {
1188 reg = le32_to_cpu(conf->bssid[1]); 1206 reg = le32_to_cpu(conf->bssid[1]);
1189 rt2x00_set_field32(&reg, MAC_BSSID_DW1_BSS_ID_MASK, 3); 1207 rt2x00_set_field32(&reg, MAC_BSSID_DW1_BSS_ID_MASK, 3);
@@ -1529,7 +1547,8 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
1529 rt2x00_rf(rt2x00dev, RF3020) || 1547 rt2x00_rf(rt2x00dev, RF3020) ||
1530 rt2x00_rf(rt2x00dev, RF3021) || 1548 rt2x00_rf(rt2x00dev, RF3021) ||
1531 rt2x00_rf(rt2x00dev, RF3022) || 1549 rt2x00_rf(rt2x00dev, RF3022) ||
1532 rt2x00_rf(rt2x00dev, RF3052)) 1550 rt2x00_rf(rt2x00dev, RF3052) ||
1551 rt2x00_rf(rt2x00dev, RF3320))
1533 rt2800_config_channel_rf3xxx(rt2x00dev, conf, rf, info); 1552 rt2800_config_channel_rf3xxx(rt2x00dev, conf, rf, info);
1534 else 1553 else
1535 rt2800_config_channel_rf2xxx(rt2x00dev, conf, rf, info); 1554 rt2800_config_channel_rf2xxx(rt2x00dev, conf, rf, info);
@@ -1609,6 +1628,13 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
1609 } 1628 }
1610 1629
1611 msleep(1); 1630 msleep(1);
1631
1632 /*
1633 * Clear channel statistic counters
1634 */
1635 rt2800_register_read(rt2x00dev, CH_IDLE_STA, &reg);
1636 rt2800_register_read(rt2x00dev, CH_BUSY_STA, &reg);
1637 rt2800_register_read(rt2x00dev, CH_BUSY_STA_SEC, &reg);
1612} 1638}
1613 1639
1614static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev, 1640static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
@@ -1914,8 +1940,8 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
1914 if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) || 1940 if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) ||
1915 rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E) || 1941 rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E) ||
1916 rt2x00_rt_rev_lt(rt2x00dev, RT3390, REV_RT3390E)) { 1942 rt2x00_rt_rev_lt(rt2x00dev, RT3390, REV_RT3390E)) {
1917 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &eeprom); 1943 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
1918 if (rt2x00_get_field16(eeprom, EEPROM_NIC_DAC_TEST)) 1944 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_DAC_TEST))
1919 rt2800_register_write(rt2x00dev, TX_SW_CFG2, 1945 rt2800_register_write(rt2x00dev, TX_SW_CFG2,
1920 0x0000002c); 1946 0x0000002c);
1921 else 1947 else
@@ -2097,7 +2123,23 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
2097 rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg); 2123 rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
2098 } 2124 }
2099 2125
2100 rt2800_register_write(rt2x00dev, TXOP_CTRL_CFG, 0x0000583f); 2126 /*
2127 * The legacy driver also sets TXOP_CTRL_CFG_RESERVED_TRUN_EN to 1
2128 * although it is reserved.
2129 */
2130 rt2800_register_read(rt2x00dev, TXOP_CTRL_CFG, &reg);
2131 rt2x00_set_field32(&reg, TXOP_CTRL_CFG_TIMEOUT_TRUN_EN, 1);
2132 rt2x00_set_field32(&reg, TXOP_CTRL_CFG_AC_TRUN_EN, 1);
2133 rt2x00_set_field32(&reg, TXOP_CTRL_CFG_TXRATEGRP_TRUN_EN, 1);
2134 rt2x00_set_field32(&reg, TXOP_CTRL_CFG_USER_MODE_TRUN_EN, 1);
2135 rt2x00_set_field32(&reg, TXOP_CTRL_CFG_MIMO_PS_TRUN_EN, 1);
2136 rt2x00_set_field32(&reg, TXOP_CTRL_CFG_RESERVED_TRUN_EN, 1);
2137 rt2x00_set_field32(&reg, TXOP_CTRL_CFG_LSIG_TXOP_EN, 0);
2138 rt2x00_set_field32(&reg, TXOP_CTRL_CFG_EXT_CCA_EN, 0);
2139 rt2x00_set_field32(&reg, TXOP_CTRL_CFG_EXT_CCA_DLY, 88);
2140 rt2x00_set_field32(&reg, TXOP_CTRL_CFG_EXT_CWMIN, 0);
2141 rt2800_register_write(rt2x00dev, TXOP_CTRL_CFG, reg);
2142
2101 rt2800_register_write(rt2x00dev, TXOP_HLDR_ET, 0x00000002); 2143 rt2800_register_write(rt2x00dev, TXOP_HLDR_ET, 0x00000002);
2102 2144
2103 rt2800_register_read(rt2x00dev, TX_RTS_CFG, &reg); 2145 rt2800_register_read(rt2x00dev, TX_RTS_CFG, &reg);
@@ -2134,7 +2176,7 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
2134 SHARED_KEY_MODE_ENTRY(i), 0); 2176 SHARED_KEY_MODE_ENTRY(i), 0);
2135 2177
2136 for (i = 0; i < 256; i++) { 2178 for (i = 0; i < 256; i++) {
2137 u32 wcid[2] = { 0xffffffff, 0x00ffffff }; 2179 static const u32 wcid[2] = { 0xffffffff, 0x00ffffff };
2138 rt2800_register_multiwrite(rt2x00dev, MAC_WCID_ENTRY(i), 2180 rt2800_register_multiwrite(rt2x00dev, MAC_WCID_ENTRY(i),
2139 wcid, sizeof(wcid)); 2181 wcid, sizeof(wcid));
2140 2182
@@ -2227,6 +2269,17 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
2227 rt2x00_set_field32(&reg, INT_TIMER_CFG_PRE_TBTT_TIMER, 6 << 4); 2269 rt2x00_set_field32(&reg, INT_TIMER_CFG_PRE_TBTT_TIMER, 6 << 4);
2228 rt2800_register_write(rt2x00dev, INT_TIMER_CFG, reg); 2270 rt2800_register_write(rt2x00dev, INT_TIMER_CFG, reg);
2229 2271
2272 /*
2273 * Set up channel statistics timer
2274 */
2275 rt2800_register_read(rt2x00dev, CH_TIME_CFG, &reg);
2276 rt2x00_set_field32(&reg, CH_TIME_CFG_EIFS_BUSY, 1);
2277 rt2x00_set_field32(&reg, CH_TIME_CFG_NAV_BUSY, 1);
2278 rt2x00_set_field32(&reg, CH_TIME_CFG_RX_BUSY, 1);
2279 rt2x00_set_field32(&reg, CH_TIME_CFG_TX_BUSY, 1);
2280 rt2x00_set_field32(&reg, CH_TIME_CFG_TMR_EN, 1);
2281 rt2800_register_write(rt2x00dev, CH_TIME_CFG, reg);
2282
2230 return 0; 2283 return 0;
2231} 2284}
2232 2285
@@ -2344,10 +2397,10 @@ static int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)
2344 rt2x00_rt(rt2x00dev, RT3390)) { 2397 rt2x00_rt(rt2x00dev, RT3390)) {
2345 rt2800_bbp_read(rt2x00dev, 138, &value); 2398 rt2800_bbp_read(rt2x00dev, 138, &value);
2346 2399
2347 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom); 2400 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
2348 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) == 1) 2401 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
2349 value |= 0x20; 2402 value |= 0x20;
2350 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) == 1) 2403 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1)
2351 value &= ~0x02; 2404 value &= ~0x02;
2352 2405
2353 rt2800_bbp_write(rt2x00dev, 138, value); 2406 rt2800_bbp_write(rt2x00dev, 138, value);
@@ -2559,8 +2612,8 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
2559 rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1); 2612 rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1);
2560 if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) || 2613 if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) ||
2561 rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E)) { 2614 rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E)) {
2562 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &eeprom); 2615 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
2563 if (rt2x00_get_field16(eeprom, EEPROM_NIC_DAC_TEST)) 2616 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_DAC_TEST))
2564 rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 3); 2617 rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 3);
2565 else 2618 else
2566 rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 0); 2619 rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 0);
@@ -2633,10 +2686,10 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
2633 if (rt2x00_rt(rt2x00dev, RT3090)) { 2686 if (rt2x00_rt(rt2x00dev, RT3090)) {
2634 rt2800_bbp_read(rt2x00dev, 138, &bbp); 2687 rt2800_bbp_read(rt2x00dev, 138, &bbp);
2635 2688
2636 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom); 2689 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
2637 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) == 1) 2690 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1)
2638 rt2x00_set_field8(&bbp, BBP138_RX_ADC1, 0); 2691 rt2x00_set_field8(&bbp, BBP138_RX_ADC1, 0);
2639 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) == 1) 2692 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
2640 rt2x00_set_field8(&bbp, BBP138_TX_DAC1, 1); 2693 rt2x00_set_field8(&bbp, BBP138_TX_DAC1, 1);
2641 2694
2642 rt2800_bbp_write(rt2x00dev, 138, bbp); 2695 rt2800_bbp_write(rt2x00dev, 138, bbp);
@@ -2735,16 +2788,16 @@ int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev)
2735 /* 2788 /*
2736 * Initialize LED control 2789 * Initialize LED control
2737 */ 2790 */
2738 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED1, &word); 2791 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED_AG_CONF, &word);
2739 rt2800_mcu_request(rt2x00dev, MCU_LED_1, 0xff, 2792 rt2800_mcu_request(rt2x00dev, MCU_LED_AG_CONF, 0xff,
2740 word & 0xff, (word >> 8) & 0xff); 2793 word & 0xff, (word >> 8) & 0xff);
2741 2794
2742 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED2, &word); 2795 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED_ACT_CONF, &word);
2743 rt2800_mcu_request(rt2x00dev, MCU_LED_2, 0xff, 2796 rt2800_mcu_request(rt2x00dev, MCU_LED_ACT_CONF, 0xff,
2744 word & 0xff, (word >> 8) & 0xff); 2797 word & 0xff, (word >> 8) & 0xff);
2745 2798
2746 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED3, &word); 2799 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED_POLARITY, &word);
2747 rt2800_mcu_request(rt2x00dev, MCU_LED_3, 0xff, 2800 rt2800_mcu_request(rt2x00dev, MCU_LED_LED_POLARITY, 0xff,
2748 word & 0xff, (word >> 8) & 0xff); 2801 word & 0xff, (word >> 8) & 0xff);
2749 2802
2750 return 0; 2803 return 0;
@@ -2838,38 +2891,41 @@ int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
2838 EEPROM(rt2x00dev, "MAC: %pM\n", mac); 2891 EEPROM(rt2x00dev, "MAC: %pM\n", mac);
2839 } 2892 }
2840 2893
2841 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word); 2894 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &word);
2842 if (word == 0xffff) { 2895 if (word == 0xffff) {
2843 rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2); 2896 rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RXPATH, 2);
2844 rt2x00_set_field16(&word, EEPROM_ANTENNA_TXPATH, 1); 2897 rt2x00_set_field16(&word, EEPROM_NIC_CONF0_TXPATH, 1);
2845 rt2x00_set_field16(&word, EEPROM_ANTENNA_RF_TYPE, RF2820); 2898 rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RF_TYPE, RF2820);
2846 rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word); 2899 rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word);
2847 EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word); 2900 EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word);
2848 } else if (rt2x00_rt(rt2x00dev, RT2860) || 2901 } else if (rt2x00_rt(rt2x00dev, RT2860) ||
2849 rt2x00_rt(rt2x00dev, RT2872)) { 2902 rt2x00_rt(rt2x00dev, RT2872)) {
2850 /* 2903 /*
2851 * There is a max of 2 RX streams for RT28x0 series 2904 * There is a max of 2 RX streams for RT28x0 series
2852 */ 2905 */
2853 if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2) 2906 if (rt2x00_get_field16(word, EEPROM_NIC_CONF0_RXPATH) > 2)
2854 rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2); 2907 rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RXPATH, 2);
2855 rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word); 2908 rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word);
2856 } 2909 }
2857 2910
2858 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &word); 2911 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &word);
2859 if (word == 0xffff) { 2912 if (word == 0xffff) {
2860 rt2x00_set_field16(&word, EEPROM_NIC_HW_RADIO, 0); 2913 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_HW_RADIO, 0);
2861 rt2x00_set_field16(&word, EEPROM_NIC_DYNAMIC_TX_AGC, 0); 2914 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_EXTERNAL_TX_ALC, 0);
2862 rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_BG, 0); 2915 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_EXTERNAL_LNA_2G, 0);
2863 rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_A, 0); 2916 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_EXTERNAL_LNA_5G, 0);
2864 rt2x00_set_field16(&word, EEPROM_NIC_CARDBUS_ACCEL, 0); 2917 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_CARDBUS_ACCEL, 0);
2865 rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_BG, 0); 2918 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_BW40M_SB_2G, 0);
2866 rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_A, 0); 2919 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_BW40M_SB_5G, 0);
2867 rt2x00_set_field16(&word, EEPROM_NIC_WPS_PBC, 0); 2920 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_WPS_PBC, 0);
2868 rt2x00_set_field16(&word, EEPROM_NIC_BW40M_BG, 0); 2921 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_BW40M_2G, 0);
2869 rt2x00_set_field16(&word, EEPROM_NIC_BW40M_A, 0); 2922 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_BW40M_5G, 0);
2870 rt2x00_set_field16(&word, EEPROM_NIC_ANT_DIVERSITY, 0); 2923 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_BROADBAND_EXT_LNA, 0);
2871 rt2x00_set_field16(&word, EEPROM_NIC_DAC_TEST, 0); 2924 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_ANT_DIVERSITY, 0);
2872 rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC, word); 2925 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_INTERNAL_TX_ALC, 0);
2926 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_BT_COEXIST, 0);
2927 rt2x00_set_field16(&word, EEPROM_NIC_CONF1_DAC_TEST, 0);
2928 rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC_CONF1, word);
2873 EEPROM(rt2x00dev, "NIC: 0x%04x\n", word); 2929 EEPROM(rt2x00dev, "NIC: 0x%04x\n", word);
2874 } 2930 }
2875 2931
@@ -2884,9 +2940,9 @@ int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
2884 LED_MODE_TXRX_ACTIVITY); 2940 LED_MODE_TXRX_ACTIVITY);
2885 rt2x00_set_field16(&word, EEPROM_FREQ_LED_POLARITY, 0); 2941 rt2x00_set_field16(&word, EEPROM_FREQ_LED_POLARITY, 0);
2886 rt2x00_eeprom_write(rt2x00dev, EEPROM_FREQ, word); 2942 rt2x00_eeprom_write(rt2x00dev, EEPROM_FREQ, word);
2887 rt2x00_eeprom_write(rt2x00dev, EEPROM_LED1, 0x5555); 2943 rt2x00_eeprom_write(rt2x00dev, EEPROM_LED_AG_CONF, 0x5555);
2888 rt2x00_eeprom_write(rt2x00dev, EEPROM_LED2, 0x2221); 2944 rt2x00_eeprom_write(rt2x00dev, EEPROM_LED_ACT_CONF, 0x2221);
2889 rt2x00_eeprom_write(rt2x00dev, EEPROM_LED3, 0xa9f8); 2945 rt2x00_eeprom_write(rt2x00dev, EEPROM_LED_POLARITY, 0xa9f8);
2890 EEPROM(rt2x00dev, "Led Mode: 0x%04x\n", word); 2946 EEPROM(rt2x00dev, "Led Mode: 0x%04x\n", word);
2891 } 2947 }
2892 2948
@@ -2950,12 +3006,12 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
2950 /* 3006 /*
2951 * Read EEPROM word for configuration. 3007 * Read EEPROM word for configuration.
2952 */ 3008 */
2953 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom); 3009 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
2954 3010
2955 /* 3011 /*
2956 * Identify RF chipset. 3012 * Identify RF chipset.
2957 */ 3013 */
2958 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE); 3014 value = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RF_TYPE);
2959 rt2800_register_read(rt2x00dev, MAC_CSR0, &reg); 3015 rt2800_register_read(rt2x00dev, MAC_CSR0, &reg);
2960 3016
2961 rt2x00_set_chip(rt2x00dev, rt2x00_get_field32(reg, MAC_CSR0_CHIPSET), 3017 rt2x00_set_chip(rt2x00dev, rt2x00_get_field32(reg, MAC_CSR0_CHIPSET),
@@ -2981,7 +3037,8 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
2981 !rt2x00_rf(rt2x00dev, RF2020) && 3037 !rt2x00_rf(rt2x00dev, RF2020) &&
2982 !rt2x00_rf(rt2x00dev, RF3021) && 3038 !rt2x00_rf(rt2x00dev, RF3021) &&
2983 !rt2x00_rf(rt2x00dev, RF3022) && 3039 !rt2x00_rf(rt2x00dev, RF3022) &&
2984 !rt2x00_rf(rt2x00dev, RF3052)) { 3040 !rt2x00_rf(rt2x00dev, RF3052) &&
3041 !rt2x00_rf(rt2x00dev, RF3320)) {
2985 ERROR(rt2x00dev, "Invalid RF chipset detected.\n"); 3042 ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
2986 return -ENODEV; 3043 return -ENODEV;
2987 } 3044 }
@@ -2990,9 +3047,9 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
2990 * Identify default antenna configuration. 3047 * Identify default antenna configuration.
2991 */ 3048 */
2992 rt2x00dev->default_ant.tx = 3049 rt2x00dev->default_ant.tx =
2993 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH); 3050 rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH);
2994 rt2x00dev->default_ant.rx = 3051 rt2x00dev->default_ant.rx =
2995 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH); 3052 rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH);
2996 3053
2997 /* 3054 /*
2998 * Read frequency offset and RF programming sequence. 3055 * Read frequency offset and RF programming sequence.
@@ -3003,17 +3060,17 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
3003 /* 3060 /*
3004 * Read external LNA informations. 3061 * Read external LNA informations.
3005 */ 3062 */
3006 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &eeprom); 3063 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
3007 3064
3008 if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_A)) 3065 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_EXTERNAL_LNA_5G))
3009 __set_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags); 3066 __set_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags);
3010 if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_BG)) 3067 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_EXTERNAL_LNA_2G))
3011 __set_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags); 3068 __set_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags);
3012 3069
3013 /* 3070 /*
3014 * Detect if this device has an hardware controlled radio. 3071 * Detect if this device has an hardware controlled radio.
3015 */ 3072 */
3016 if (rt2x00_get_field16(eeprom, EEPROM_NIC_HW_RADIO)) 3073 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_HW_RADIO))
3017 __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); 3074 __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
3018 3075
3019 /* 3076 /*
@@ -3225,7 +3282,7 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
3225 rt2x00dev->hw->max_report_rates = 7; 3282 rt2x00dev->hw->max_report_rates = 7;
3226 rt2x00dev->hw->max_rate_tries = 1; 3283 rt2x00dev->hw->max_rate_tries = 1;
3227 3284
3228 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom); 3285 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
3229 3286
3230 /* 3287 /*
3231 * Initialize hw_mode information. 3288 * Initialize hw_mode information.
@@ -3245,7 +3302,8 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
3245 } else if (rt2x00_rf(rt2x00dev, RF3020) || 3302 } else if (rt2x00_rf(rt2x00dev, RF3020) ||
3246 rt2x00_rf(rt2x00dev, RF2020) || 3303 rt2x00_rf(rt2x00dev, RF2020) ||
3247 rt2x00_rf(rt2x00dev, RF3021) || 3304 rt2x00_rf(rt2x00dev, RF3021) ||
3248 rt2x00_rf(rt2x00dev, RF3022)) { 3305 rt2x00_rf(rt2x00dev, RF3022) ||
3306 rt2x00_rf(rt2x00dev, RF3320)) {
3249 spec->num_channels = 14; 3307 spec->num_channels = 14;
3250 spec->channels = rf_vals_3x; 3308 spec->channels = rf_vals_3x;
3251 } else if (rt2x00_rf(rt2x00dev, RF3052)) { 3309 } else if (rt2x00_rf(rt2x00dev, RF3052)) {
@@ -3268,11 +3326,11 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
3268 IEEE80211_HT_CAP_SGI_20 | 3326 IEEE80211_HT_CAP_SGI_20 |
3269 IEEE80211_HT_CAP_SGI_40; 3327 IEEE80211_HT_CAP_SGI_40;
3270 3328
3271 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) >= 2) 3329 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) >= 2)
3272 spec->ht.cap |= IEEE80211_HT_CAP_TX_STBC; 3330 spec->ht.cap |= IEEE80211_HT_CAP_TX_STBC;
3273 3331
3274 spec->ht.cap |= 3332 spec->ht.cap |=
3275 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) << 3333 rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) <<
3276 IEEE80211_HT_CAP_RX_STBC_SHIFT; 3334 IEEE80211_HT_CAP_RX_STBC_SHIFT;
3277 3335
3278 spec->ht.ampdu_factor = 3; 3336 spec->ht.ampdu_factor = 3;
@@ -3280,10 +3338,10 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
3280 spec->ht.mcs.tx_params = 3338 spec->ht.mcs.tx_params =
3281 IEEE80211_HT_MCS_TX_DEFINED | 3339 IEEE80211_HT_MCS_TX_DEFINED |
3282 IEEE80211_HT_MCS_TX_RX_DIFF | 3340 IEEE80211_HT_MCS_TX_RX_DIFF |
3283 ((rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) - 1) << 3341 ((rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) - 1) <<
3284 IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT); 3342 IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT);
3285 3343
3286 switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH)) { 3344 switch (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH)) {
3287 case 3: 3345 case 3:
3288 spec->ht.mcs.rx_mask[2] = 0xff; 3346 spec->ht.mcs.rx_mask[2] = 0xff;
3289 case 2: 3347 case 2:
@@ -3502,6 +3560,37 @@ int rt2800_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
3502} 3560}
3503EXPORT_SYMBOL_GPL(rt2800_ampdu_action); 3561EXPORT_SYMBOL_GPL(rt2800_ampdu_action);
3504 3562
3563int rt2800_get_survey(struct ieee80211_hw *hw, int idx,
3564 struct survey_info *survey)
3565{
3566 struct rt2x00_dev *rt2x00dev = hw->priv;
3567 struct ieee80211_conf *conf = &hw->conf;
3568 u32 idle, busy, busy_ext;
3569
3570 if (idx != 0)
3571 return -ENOENT;
3572
3573 survey->channel = conf->channel;
3574
3575 rt2800_register_read(rt2x00dev, CH_IDLE_STA, &idle);
3576 rt2800_register_read(rt2x00dev, CH_BUSY_STA, &busy);
3577 rt2800_register_read(rt2x00dev, CH_BUSY_STA_SEC, &busy_ext);
3578
3579 if (idle || busy) {
3580 survey->filled = SURVEY_INFO_CHANNEL_TIME |
3581 SURVEY_INFO_CHANNEL_TIME_BUSY |
3582 SURVEY_INFO_CHANNEL_TIME_EXT_BUSY;
3583
3584 survey->channel_time = (idle + busy) / 1000;
3585 survey->channel_time_busy = busy / 1000;
3586 survey->channel_time_ext_busy = busy_ext / 1000;
3587 }
3588
3589 return 0;
3590
3591}
3592EXPORT_SYMBOL_GPL(rt2800_get_survey);
3593
3505MODULE_AUTHOR(DRV_PROJECT ", Bartlomiej Zolnierkiewicz"); 3594MODULE_AUTHOR(DRV_PROJECT ", Bartlomiej Zolnierkiewicz");
3506MODULE_VERSION(DRV_VERSION); 3595MODULE_VERSION(DRV_VERSION);
3507MODULE_DESCRIPTION("Ralink RT2800 library"); 3596MODULE_DESCRIPTION("Ralink RT2800 library");
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.h b/drivers/net/wireless/rt2x00/rt2800lib.h
index 81cbc92e7857..e3c995a9dec4 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.h
+++ b/drivers/net/wireless/rt2x00/rt2800lib.h
@@ -199,5 +199,7 @@ u64 rt2800_get_tsf(struct ieee80211_hw *hw);
199int rt2800_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 199int rt2800_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
200 enum ieee80211_ampdu_mlme_action action, 200 enum ieee80211_ampdu_mlme_action action,
201 struct ieee80211_sta *sta, u16 tid, u16 *ssn); 201 struct ieee80211_sta *sta, u16 tid, u16 *ssn);
202int rt2800_get_survey(struct ieee80211_hw *hw, int idx,
203 struct survey_info *survey);
202 204
203#endif /* RT2800LIB_H */ 205#endif /* RT2800LIB_H */
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index b26739535986..aa97971a38af 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -84,20 +84,22 @@ static void rt2800pci_mcu_status(struct rt2x00_dev *rt2x00dev, const u8 token)
84 rt2800_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0); 84 rt2800_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
85} 85}
86 86
87#ifdef CONFIG_RT2800PCI_SOC 87#if defined(CONFIG_RALINK_RT288X) || defined(CONFIG_RALINK_RT305X)
88static void rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev) 88static void rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
89{ 89{
90 u32 *base_addr = (u32 *) KSEG1ADDR(0x1F040000); /* XXX for RT3052 */ 90 void __iomem *base_addr = ioremap(0x1F040000, EEPROM_SIZE);
91 91
92 memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE); 92 memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE);
93
94 iounmap(base_addr);
93} 95}
94#else 96#else
95static inline void rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev) 97static inline void rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev)
96{ 98{
97} 99}
98#endif /* CONFIG_RT2800PCI_SOC */ 100#endif /* CONFIG_RALINK_RT288X || CONFIG_RALINK_RT305X */
99 101
100#ifdef CONFIG_RT2800PCI_PCI 102#ifdef CONFIG_PCI
101static void rt2800pci_eepromregister_read(struct eeprom_93cx6 *eeprom) 103static void rt2800pci_eepromregister_read(struct eeprom_93cx6 *eeprom)
102{ 104{
103 struct rt2x00_dev *rt2x00dev = eeprom->data; 105 struct rt2x00_dev *rt2x00dev = eeprom->data;
@@ -181,7 +183,78 @@ static inline int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
181static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) 183static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
182{ 184{
183} 185}
184#endif /* CONFIG_RT2800PCI_PCI */ 186#endif /* CONFIG_PCI */
187
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_VO:
221 case QID_AC_VI:
222 case QID_AC_BE:
223 case QID_AC_BK:
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}
185 258
186/* 259/*
187 * Firmware functions 260 * Firmware functions
@@ -321,18 +394,6 @@ static int rt2800pci_init_queues(struct rt2x00_dev *rt2x00dev)
321/* 394/*
322 * Device state switch handlers. 395 * Device state switch handlers.
323 */ 396 */
324static void rt2800pci_toggle_rx(struct rt2x00_dev *rt2x00dev,
325 enum dev_state state)
326{
327 u32 reg;
328
329 rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
330 rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX,
331 (state == STATE_RADIO_RX_ON) ||
332 (state == STATE_RADIO_RX_ON_LINK));
333 rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
334}
335
336static void rt2800pci_toggle_irq(struct rt2x00_dev *rt2x00dev, 397static void rt2800pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
337 enum dev_state state) 398 enum dev_state state)
338{ 399{
@@ -442,7 +503,7 @@ static int rt2800pci_set_state(struct rt2x00_dev *rt2x00dev,
442 * if the device is booting and wasn't asleep it will return 503 * if the device is booting and wasn't asleep it will return
443 * failure when attempting to wakeup. 504 * failure when attempting to wakeup.
444 */ 505 */
445 rt2800_mcu_request(rt2x00dev, MCU_SLEEP, 0xff, 0, 2); 506 rt2800_mcu_request(rt2x00dev, MCU_SLEEP, 0xff, 0xff, 2);
446 507
447 if (state == STATE_AWAKE) { 508 if (state == STATE_AWAKE) {
448 rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, TOKEN_WAKUP, 0, 0); 509 rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, TOKEN_WAKUP, 0, 0);
@@ -476,12 +537,6 @@ static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev,
476 rt2800pci_disable_radio(rt2x00dev); 537 rt2800pci_disable_radio(rt2x00dev);
477 rt2800pci_set_state(rt2x00dev, STATE_SLEEP); 538 rt2800pci_set_state(rt2x00dev, STATE_SLEEP);
478 break; 539 break;
479 case STATE_RADIO_RX_ON:
480 case STATE_RADIO_RX_ON_LINK:
481 case STATE_RADIO_RX_OFF:
482 case STATE_RADIO_RX_OFF_LINK:
483 rt2800pci_toggle_rx(rt2x00dev, state);
484 break;
485 case STATE_RADIO_IRQ_ON: 540 case STATE_RADIO_IRQ_ON:
486 case STATE_RADIO_IRQ_ON_ISR: 541 case STATE_RADIO_IRQ_ON_ISR:
487 case STATE_RADIO_IRQ_OFF: 542 case STATE_RADIO_IRQ_OFF:
@@ -567,41 +622,6 @@ static void rt2800pci_write_tx_desc(struct queue_entry *entry,
567} 622}
568 623
569/* 624/*
570 * TX data initialization
571 */
572static void rt2800pci_kick_tx_queue(struct data_queue *queue)
573{
574 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
575 struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX);
576 unsigned int qidx;
577
578 if (queue->qid == QID_MGMT)
579 qidx = 5;
580 else
581 qidx = queue->qid;
582
583 rt2800_register_write(rt2x00dev, TX_CTX_IDX(qidx), entry->entry_idx);
584}
585
586static void rt2800pci_kill_tx_queue(struct data_queue *queue)
587{
588 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
589 u32 reg;
590
591 if (queue->qid == QID_BEACON) {
592 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, 0);
593 return;
594 }
595
596 rt2800_register_read(rt2x00dev, WPDMA_RST_IDX, &reg);
597 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX0, (queue->qid == QID_AC_BE));
598 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX1, (queue->qid == QID_AC_BK));
599 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX2, (queue->qid == QID_AC_VI));
600 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX3, (queue->qid == QID_AC_VO));
601 rt2800_register_write(rt2x00dev, WPDMA_RST_IDX, reg);
602}
603
604/*
605 * RX control handlers 625 * RX control handlers
606 */ 626 */
607static void rt2800pci_fill_rxdone(struct queue_entry *entry, 627static void rt2800pci_fill_rxdone(struct queue_entry *entry,
@@ -668,14 +688,7 @@ static void rt2800pci_txdone(struct rt2x00_dev *rt2x00dev)
668 u32 status; 688 u32 status;
669 u8 qid; 689 u8 qid;
670 690
671 while (!kfifo_is_empty(&rt2x00dev->txstatus_fifo)) { 691 while (kfifo_get(&rt2x00dev->txstatus_fifo, &status)) {
672 /* Now remove the tx status from the FIFO */
673 if (kfifo_out(&rt2x00dev->txstatus_fifo, &status,
674 sizeof(status)) != sizeof(status)) {
675 WARN_ON(1);
676 break;
677 }
678
679 qid = rt2x00_get_field32(status, TX_STA_FIFO_PID_QUEUE); 692 qid = rt2x00_get_field32(status, TX_STA_FIFO_PID_QUEUE);
680 if (qid >= QID_RX) { 693 if (qid >= QID_RX) {
681 /* 694 /*
@@ -683,7 +696,7 @@ static void rt2800pci_txdone(struct rt2x00_dev *rt2x00dev)
683 * this tx status. 696 * this tx status.
684 */ 697 */
685 WARNING(rt2x00dev, "Got TX status report with " 698 WARNING(rt2x00dev, "Got TX status report with "
686 "unexpected pid %u, dropping", qid); 699 "unexpected pid %u, dropping\n", qid);
687 break; 700 break;
688 } 701 }
689 702
@@ -694,7 +707,7 @@ static void rt2800pci_txdone(struct rt2x00_dev *rt2x00dev)
694 * processing here and drop the tx status 707 * processing here and drop the tx status
695 */ 708 */
696 WARNING(rt2x00dev, "Got TX status for an unavailable " 709 WARNING(rt2x00dev, "Got TX status for an unavailable "
697 "queue %u, dropping", qid); 710 "queue %u, dropping\n", qid);
698 break; 711 break;
699 } 712 }
700 713
@@ -704,7 +717,7 @@ static void rt2800pci_txdone(struct rt2x00_dev *rt2x00dev)
704 * and drop the tx status. 717 * and drop the tx status.
705 */ 718 */
706 WARNING(rt2x00dev, "Got TX status for an empty " 719 WARNING(rt2x00dev, "Got TX status for an empty "
707 "queue %u, dropping", qid); 720 "queue %u, dropping\n", qid);
708 break; 721 break;
709 } 722 }
710 723
@@ -777,20 +790,13 @@ static void rt2800pci_txstatus_interrupt(struct rt2x00_dev *rt2x00dev)
777 * Since we have only one producer and one consumer we don't 790 * Since we have only one producer and one consumer we don't
778 * need to lock the kfifo. 791 * need to lock the kfifo.
779 */ 792 */
780 for (i = 0; i < TX_ENTRIES; i++) { 793 for (i = 0; i < rt2x00dev->ops->tx->entry_num; i++) {
781 rt2800_register_read(rt2x00dev, TX_STA_FIFO, &status); 794 rt2800_register_read(rt2x00dev, TX_STA_FIFO, &status);
782 795
783 if (!rt2x00_get_field32(status, TX_STA_FIFO_VALID)) 796 if (!rt2x00_get_field32(status, TX_STA_FIFO_VALID))
784 break; 797 break;
785 798
786 if (kfifo_is_full(&rt2x00dev->txstatus_fifo)) { 799 if (!kfifo_put(&rt2x00dev->txstatus_fifo, &status)) {
787 WARNING(rt2x00dev, "TX status FIFO overrun,"
788 " drop tx status report.\n");
789 break;
790 }
791
792 if (kfifo_in(&rt2x00dev->txstatus_fifo, &status,
793 sizeof(status)) != sizeof(status)) {
794 WARNING(rt2x00dev, "TX status FIFO overrun," 800 WARNING(rt2x00dev, "TX status FIFO overrun,"
795 "drop tx status report.\n"); 801 "drop tx status report.\n");
796 break; 802 break;
@@ -912,6 +918,7 @@ static int rt2800pci_probe_hw(struct rt2x00_dev *rt2x00dev)
912 __set_bit(DRIVER_REQUIRE_DMA, &rt2x00dev->flags); 918 __set_bit(DRIVER_REQUIRE_DMA, &rt2x00dev->flags);
913 __set_bit(DRIVER_REQUIRE_L2PAD, &rt2x00dev->flags); 919 __set_bit(DRIVER_REQUIRE_L2PAD, &rt2x00dev->flags);
914 __set_bit(DRIVER_REQUIRE_TXSTATUS_FIFO, &rt2x00dev->flags); 920 __set_bit(DRIVER_REQUIRE_TXSTATUS_FIFO, &rt2x00dev->flags);
921 __set_bit(DRIVER_REQUIRE_TASKLET_CONTEXT, &rt2x00dev->flags);
915 if (!modparam_nohwcrypt) 922 if (!modparam_nohwcrypt)
916 __set_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags); 923 __set_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags);
917 __set_bit(DRIVER_SUPPORT_LINK_TUNING, &rt2x00dev->flags); 924 __set_bit(DRIVER_SUPPORT_LINK_TUNING, &rt2x00dev->flags);
@@ -943,6 +950,8 @@ static const struct ieee80211_ops rt2800pci_mac80211_ops = {
943 .get_tsf = rt2800_get_tsf, 950 .get_tsf = rt2800_get_tsf,
944 .rfkill_poll = rt2x00mac_rfkill_poll, 951 .rfkill_poll = rt2x00mac_rfkill_poll,
945 .ampdu_action = rt2800_ampdu_action, 952 .ampdu_action = rt2800_ampdu_action,
953 .flush = rt2x00mac_flush,
954 .get_survey = rt2800_get_survey,
946}; 955};
947 956
948static const struct rt2800_ops rt2800pci_rt2800_ops = { 957static const struct rt2800_ops rt2800pci_rt2800_ops = {
@@ -975,11 +984,12 @@ static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = {
975 .link_stats = rt2800_link_stats, 984 .link_stats = rt2800_link_stats,
976 .reset_tuner = rt2800_reset_tuner, 985 .reset_tuner = rt2800_reset_tuner,
977 .link_tuner = rt2800_link_tuner, 986 .link_tuner = rt2800_link_tuner,
987 .start_queue = rt2800pci_start_queue,
988 .kick_queue = rt2800pci_kick_queue,
989 .stop_queue = rt2800pci_stop_queue,
978 .write_tx_desc = rt2800pci_write_tx_desc, 990 .write_tx_desc = rt2800pci_write_tx_desc,
979 .write_tx_data = rt2800_write_tx_data, 991 .write_tx_data = rt2800_write_tx_data,
980 .write_beacon = rt2800_write_beacon, 992 .write_beacon = rt2800_write_beacon,
981 .kick_tx_queue = rt2800pci_kick_tx_queue,
982 .kill_tx_queue = rt2800pci_kill_tx_queue,
983 .fill_rxdone = rt2800pci_fill_rxdone, 993 .fill_rxdone = rt2800pci_fill_rxdone,
984 .config_shared_key = rt2800_config_shared_key, 994 .config_shared_key = rt2800_config_shared_key,
985 .config_pairwise_key = rt2800_config_pairwise_key, 995 .config_pairwise_key = rt2800_config_pairwise_key,
@@ -991,21 +1001,21 @@ static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = {
991}; 1001};
992 1002
993static const struct data_queue_desc rt2800pci_queue_rx = { 1003static const struct data_queue_desc rt2800pci_queue_rx = {
994 .entry_num = RX_ENTRIES, 1004 .entry_num = 128,
995 .data_size = AGGREGATION_SIZE, 1005 .data_size = AGGREGATION_SIZE,
996 .desc_size = RXD_DESC_SIZE, 1006 .desc_size = RXD_DESC_SIZE,
997 .priv_size = sizeof(struct queue_entry_priv_pci), 1007 .priv_size = sizeof(struct queue_entry_priv_pci),
998}; 1008};
999 1009
1000static const struct data_queue_desc rt2800pci_queue_tx = { 1010static const struct data_queue_desc rt2800pci_queue_tx = {
1001 .entry_num = TX_ENTRIES, 1011 .entry_num = 64,
1002 .data_size = AGGREGATION_SIZE, 1012 .data_size = AGGREGATION_SIZE,
1003 .desc_size = TXD_DESC_SIZE, 1013 .desc_size = TXD_DESC_SIZE,
1004 .priv_size = sizeof(struct queue_entry_priv_pci), 1014 .priv_size = sizeof(struct queue_entry_priv_pci),
1005}; 1015};
1006 1016
1007static const struct data_queue_desc rt2800pci_queue_bcn = { 1017static const struct data_queue_desc rt2800pci_queue_bcn = {
1008 .entry_num = 8 * BEACON_ENTRIES, 1018 .entry_num = 8,
1009 .data_size = 0, /* No DMA required for beacons */ 1019 .data_size = 0, /* No DMA required for beacons */
1010 .desc_size = TXWI_DESC_SIZE, 1020 .desc_size = TXWI_DESC_SIZE,
1011 .priv_size = sizeof(struct queue_entry_priv_pci), 1021 .priv_size = sizeof(struct queue_entry_priv_pci),
@@ -1033,12 +1043,15 @@ static const struct rt2x00_ops rt2800pci_ops = {
1033/* 1043/*
1034 * RT2800pci module information. 1044 * RT2800pci module information.
1035 */ 1045 */
1036#ifdef CONFIG_RT2800PCI_PCI 1046#ifdef CONFIG_PCI
1037static DEFINE_PCI_DEVICE_TABLE(rt2800pci_device_table) = { 1047static DEFINE_PCI_DEVICE_TABLE(rt2800pci_device_table) = {
1038 { PCI_DEVICE(0x1814, 0x0601), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1048 { PCI_DEVICE(0x1814, 0x0601), PCI_DEVICE_DATA(&rt2800pci_ops) },
1039 { PCI_DEVICE(0x1814, 0x0681), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1049 { PCI_DEVICE(0x1814, 0x0681), PCI_DEVICE_DATA(&rt2800pci_ops) },
1040 { PCI_DEVICE(0x1814, 0x0701), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1050 { PCI_DEVICE(0x1814, 0x0701), PCI_DEVICE_DATA(&rt2800pci_ops) },
1041 { PCI_DEVICE(0x1814, 0x0781), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1051 { PCI_DEVICE(0x1814, 0x0781), PCI_DEVICE_DATA(&rt2800pci_ops) },
1052 { PCI_DEVICE(0x1814, 0x3090), PCI_DEVICE_DATA(&rt2800pci_ops) },
1053 { PCI_DEVICE(0x1814, 0x3091), PCI_DEVICE_DATA(&rt2800pci_ops) },
1054 { PCI_DEVICE(0x1814, 0x3092), PCI_DEVICE_DATA(&rt2800pci_ops) },
1042 { PCI_DEVICE(0x1432, 0x7708), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1055 { PCI_DEVICE(0x1432, 0x7708), PCI_DEVICE_DATA(&rt2800pci_ops) },
1043 { PCI_DEVICE(0x1432, 0x7727), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1056 { PCI_DEVICE(0x1432, 0x7727), PCI_DEVICE_DATA(&rt2800pci_ops) },
1044 { PCI_DEVICE(0x1432, 0x7728), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1057 { PCI_DEVICE(0x1432, 0x7728), PCI_DEVICE_DATA(&rt2800pci_ops) },
@@ -1046,12 +1059,10 @@ static DEFINE_PCI_DEVICE_TABLE(rt2800pci_device_table) = {
1046 { PCI_DEVICE(0x1432, 0x7748), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1059 { PCI_DEVICE(0x1432, 0x7748), PCI_DEVICE_DATA(&rt2800pci_ops) },
1047 { PCI_DEVICE(0x1432, 0x7758), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1060 { PCI_DEVICE(0x1432, 0x7758), PCI_DEVICE_DATA(&rt2800pci_ops) },
1048 { PCI_DEVICE(0x1432, 0x7768), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1061 { PCI_DEVICE(0x1432, 0x7768), PCI_DEVICE_DATA(&rt2800pci_ops) },
1049 { PCI_DEVICE(0x1a3b, 0x1059), PCI_DEVICE_DATA(&rt2800pci_ops) },
1050#ifdef CONFIG_RT2800PCI_RT30XX
1051 { PCI_DEVICE(0x1814, 0x3090), PCI_DEVICE_DATA(&rt2800pci_ops) },
1052 { PCI_DEVICE(0x1814, 0x3091), PCI_DEVICE_DATA(&rt2800pci_ops) },
1053 { PCI_DEVICE(0x1814, 0x3092), PCI_DEVICE_DATA(&rt2800pci_ops) },
1054 { PCI_DEVICE(0x1462, 0x891a), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1062 { PCI_DEVICE(0x1462, 0x891a), PCI_DEVICE_DATA(&rt2800pci_ops) },
1063 { PCI_DEVICE(0x1a3b, 0x1059), PCI_DEVICE_DATA(&rt2800pci_ops) },
1064#ifdef CONFIG_RT2800PCI_RT33XX
1065 { PCI_DEVICE(0x1814, 0x3390), PCI_DEVICE_DATA(&rt2800pci_ops) },
1055#endif 1066#endif
1056#ifdef CONFIG_RT2800PCI_RT35XX 1067#ifdef CONFIG_RT2800PCI_RT35XX
1057 { PCI_DEVICE(0x1814, 0x3060), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1068 { PCI_DEVICE(0x1814, 0x3060), PCI_DEVICE_DATA(&rt2800pci_ops) },
@@ -1062,19 +1073,19 @@ static DEFINE_PCI_DEVICE_TABLE(rt2800pci_device_table) = {
1062#endif 1073#endif
1063 { 0, } 1074 { 0, }
1064}; 1075};
1065#endif /* CONFIG_RT2800PCI_PCI */ 1076#endif /* CONFIG_PCI */
1066 1077
1067MODULE_AUTHOR(DRV_PROJECT); 1078MODULE_AUTHOR(DRV_PROJECT);
1068MODULE_VERSION(DRV_VERSION); 1079MODULE_VERSION(DRV_VERSION);
1069MODULE_DESCRIPTION("Ralink RT2800 PCI & PCMCIA Wireless LAN driver."); 1080MODULE_DESCRIPTION("Ralink RT2800 PCI & PCMCIA Wireless LAN driver.");
1070MODULE_SUPPORTED_DEVICE("Ralink RT2860 PCI & PCMCIA chipset based cards"); 1081MODULE_SUPPORTED_DEVICE("Ralink RT2860 PCI & PCMCIA chipset based cards");
1071#ifdef CONFIG_RT2800PCI_PCI 1082#ifdef CONFIG_PCI
1072MODULE_FIRMWARE(FIRMWARE_RT2860); 1083MODULE_FIRMWARE(FIRMWARE_RT2860);
1073MODULE_DEVICE_TABLE(pci, rt2800pci_device_table); 1084MODULE_DEVICE_TABLE(pci, rt2800pci_device_table);
1074#endif /* CONFIG_RT2800PCI_PCI */ 1085#endif /* CONFIG_PCI */
1075MODULE_LICENSE("GPL"); 1086MODULE_LICENSE("GPL");
1076 1087
1077#ifdef CONFIG_RT2800PCI_SOC 1088#if defined(CONFIG_RALINK_RT288X) || defined(CONFIG_RALINK_RT305X)
1078static int rt2800soc_probe(struct platform_device *pdev) 1089static int rt2800soc_probe(struct platform_device *pdev)
1079{ 1090{
1080 return rt2x00soc_probe(pdev, &rt2800pci_ops); 1091 return rt2x00soc_probe(pdev, &rt2800pci_ops);
@@ -1091,9 +1102,9 @@ static struct platform_driver rt2800soc_driver = {
1091 .suspend = rt2x00soc_suspend, 1102 .suspend = rt2x00soc_suspend,
1092 .resume = rt2x00soc_resume, 1103 .resume = rt2x00soc_resume,
1093}; 1104};
1094#endif /* CONFIG_RT2800PCI_SOC */ 1105#endif /* CONFIG_RALINK_RT288X || CONFIG_RALINK_RT305X */
1095 1106
1096#ifdef CONFIG_RT2800PCI_PCI 1107#ifdef CONFIG_PCI
1097static struct pci_driver rt2800pci_driver = { 1108static struct pci_driver rt2800pci_driver = {
1098 .name = KBUILD_MODNAME, 1109 .name = KBUILD_MODNAME,
1099 .id_table = rt2800pci_device_table, 1110 .id_table = rt2800pci_device_table,
@@ -1102,21 +1113,21 @@ static struct pci_driver rt2800pci_driver = {
1102 .suspend = rt2x00pci_suspend, 1113 .suspend = rt2x00pci_suspend,
1103 .resume = rt2x00pci_resume, 1114 .resume = rt2x00pci_resume,
1104}; 1115};
1105#endif /* CONFIG_RT2800PCI_PCI */ 1116#endif /* CONFIG_PCI */
1106 1117
1107static int __init rt2800pci_init(void) 1118static int __init rt2800pci_init(void)
1108{ 1119{
1109 int ret = 0; 1120 int ret = 0;
1110 1121
1111#ifdef CONFIG_RT2800PCI_SOC 1122#if defined(CONFIG_RALINK_RT288X) || defined(CONFIG_RALINK_RT305X)
1112 ret = platform_driver_register(&rt2800soc_driver); 1123 ret = platform_driver_register(&rt2800soc_driver);
1113 if (ret) 1124 if (ret)
1114 return ret; 1125 return ret;
1115#endif 1126#endif
1116#ifdef CONFIG_RT2800PCI_PCI 1127#ifdef CONFIG_PCI
1117 ret = pci_register_driver(&rt2800pci_driver); 1128 ret = pci_register_driver(&rt2800pci_driver);
1118 if (ret) { 1129 if (ret) {
1119#ifdef CONFIG_RT2800PCI_SOC 1130#if defined(CONFIG_RALINK_RT288X) || defined(CONFIG_RALINK_RT305X)
1120 platform_driver_unregister(&rt2800soc_driver); 1131 platform_driver_unregister(&rt2800soc_driver);
1121#endif 1132#endif
1122 return ret; 1133 return ret;
@@ -1128,10 +1139,10 @@ static int __init rt2800pci_init(void)
1128 1139
1129static void __exit rt2800pci_exit(void) 1140static void __exit rt2800pci_exit(void)
1130{ 1141{
1131#ifdef CONFIG_RT2800PCI_PCI 1142#ifdef CONFIG_PCI
1132 pci_unregister_driver(&rt2800pci_driver); 1143 pci_unregister_driver(&rt2800pci_driver);
1133#endif 1144#endif
1134#ifdef CONFIG_RT2800PCI_SOC 1145#if defined(CONFIG_RALINK_RT288X) || defined(CONFIG_RALINK_RT305X)
1135 platform_driver_unregister(&rt2800soc_driver); 1146 platform_driver_unregister(&rt2800soc_driver);
1136#endif 1147#endif
1137} 1148}
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.h b/drivers/net/wireless/rt2x00/rt2800pci.h
index 5a8dda9b5b5a..70e050d904c8 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.h
+++ b/drivers/net/wireless/rt2x00/rt2800pci.h
@@ -38,10 +38,10 @@
38 * Queue register offset macros 38 * Queue register offset macros
39 */ 39 */
40#define TX_QUEUE_REG_OFFSET 0x10 40#define TX_QUEUE_REG_OFFSET 0x10
41#define TX_BASE_PTR(__x) TX_BASE_PTR0 + ((__x) * TX_QUEUE_REG_OFFSET) 41#define TX_BASE_PTR(__x) (TX_BASE_PTR0 + ((__x) * TX_QUEUE_REG_OFFSET))
42#define TX_MAX_CNT(__x) TX_MAX_CNT0 + ((__x) * TX_QUEUE_REG_OFFSET) 42#define TX_MAX_CNT(__x) (TX_MAX_CNT0 + ((__x) * TX_QUEUE_REG_OFFSET))
43#define TX_CTX_IDX(__x) TX_CTX_IDX0 + ((__x) * TX_QUEUE_REG_OFFSET) 43#define TX_CTX_IDX(__x) (TX_CTX_IDX0 + ((__x) * TX_QUEUE_REG_OFFSET))
44#define TX_DTX_IDX(__x) TX_DTX_IDX0 + ((__x) * TX_QUEUE_REG_OFFSET) 44#define TX_DTX_IDX(__x) (TX_DTX_IDX0 + ((__x) * TX_QUEUE_REG_OFFSET))
45 45
46/* 46/*
47 * 8051 firmware image. 47 * 8051 firmware image.
@@ -52,8 +52,8 @@
52/* 52/*
53 * DMA descriptor defines. 53 * DMA descriptor defines.
54 */ 54 */
55#define TXD_DESC_SIZE ( 4 * sizeof(__le32) ) 55#define TXD_DESC_SIZE (4 * sizeof(__le32))
56#define RXD_DESC_SIZE ( 4 * sizeof(__le32) ) 56#define RXD_DESC_SIZE (4 * sizeof(__le32))
57 57
58/* 58/*
59 * TX descriptor format for TX, PRIO and Beacon Ring. 59 * TX descriptor format for TX, PRIO and Beacon Ring.
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index 3dff56ec195a..b97a4a54ff4c 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -45,11 +45,60 @@
45/* 45/*
46 * Allow hardware encryption to be disabled. 46 * Allow hardware encryption to be disabled.
47 */ 47 */
48static int modparam_nohwcrypt = 0; 48static int modparam_nohwcrypt;
49module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO); 49module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO);
50MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption."); 50MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
51 51
52/* 52/*
53 * Queue handlers.
54 */
55static void rt2800usb_start_queue(struct data_queue *queue)
56{
57 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
58 u32 reg;
59
60 switch (queue->qid) {
61 case QID_RX:
62 rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
63 rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX, 1);
64 rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
65 break;
66 case QID_BEACON:
67 rt2800_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
68 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 1);
69 rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 1);
70 rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 1);
71 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg);
72 break;
73 default:
74 break;
75 }
76}
77
78static void rt2800usb_stop_queue(struct data_queue *queue)
79{
80 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
81 u32 reg;
82
83 switch (queue->qid) {
84 case QID_RX:
85 rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
86 rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX, 0);
87 rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
88 break;
89 case QID_BEACON:
90 rt2800_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
91 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 0);
92 rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 0);
93 rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 0);
94 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg);
95 break;
96 default:
97 break;
98 }
99}
100
101/*
53 * Firmware functions 102 * Firmware functions
54 */ 103 */
55static char *rt2800usb_get_firmware_name(struct rt2x00_dev *rt2x00dev) 104static char *rt2800usb_get_firmware_name(struct rt2x00_dev *rt2x00dev)
@@ -107,18 +156,6 @@ static int rt2800usb_write_firmware(struct rt2x00_dev *rt2x00dev,
107/* 156/*
108 * Device state switch handlers. 157 * Device state switch handlers.
109 */ 158 */
110static void rt2800usb_toggle_rx(struct rt2x00_dev *rt2x00dev,
111 enum dev_state state)
112{
113 u32 reg;
114
115 rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
116 rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX,
117 (state == STATE_RADIO_RX_ON) ||
118 (state == STATE_RADIO_RX_ON_LINK));
119 rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
120}
121
122static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev) 159static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev)
123{ 160{
124 u32 reg; 161 u32 reg;
@@ -165,7 +202,8 @@ static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev)
165 * this limit so reduce the number to prevent errors. 202 * this limit so reduce the number to prevent errors.
166 */ 203 */
167 rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_AGG_LIMIT, 204 rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_AGG_LIMIT,
168 ((RX_ENTRIES * DATA_FRAME_SIZE) / 1024) - 3); 205 ((rt2x00dev->ops->rx->entry_num * DATA_FRAME_SIZE)
206 / 1024) - 3);
169 rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_EN, 1); 207 rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_EN, 1);
170 rt2x00_set_field32(&reg, USB_DMA_CFG_TX_BULK_EN, 1); 208 rt2x00_set_field32(&reg, USB_DMA_CFG_TX_BULK_EN, 1);
171 rt2800_register_write(rt2x00dev, USB_DMA_CFG, reg); 209 rt2800_register_write(rt2x00dev, USB_DMA_CFG, reg);
@@ -183,9 +221,9 @@ static int rt2800usb_set_state(struct rt2x00_dev *rt2x00dev,
183 enum dev_state state) 221 enum dev_state state)
184{ 222{
185 if (state == STATE_AWAKE) 223 if (state == STATE_AWAKE)
186 rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, 0xff, 0, 0); 224 rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, 0xff, 0, 2);
187 else 225 else
188 rt2800_mcu_request(rt2x00dev, MCU_SLEEP, 0xff, 0, 2); 226 rt2800_mcu_request(rt2x00dev, MCU_SLEEP, 0xff, 0xff, 2);
189 227
190 return 0; 228 return 0;
191} 229}
@@ -214,12 +252,6 @@ static int rt2800usb_set_device_state(struct rt2x00_dev *rt2x00dev,
214 rt2800usb_disable_radio(rt2x00dev); 252 rt2800usb_disable_radio(rt2x00dev);
215 rt2800usb_set_state(rt2x00dev, STATE_SLEEP); 253 rt2800usb_set_state(rt2x00dev, STATE_SLEEP);
216 break; 254 break;
217 case STATE_RADIO_RX_ON:
218 case STATE_RADIO_RX_ON_LINK:
219 case STATE_RADIO_RX_OFF:
220 case STATE_RADIO_RX_OFF_LINK:
221 rt2800usb_toggle_rx(rt2x00dev, state);
222 break;
223 case STATE_RADIO_IRQ_ON: 255 case STATE_RADIO_IRQ_ON:
224 case STATE_RADIO_IRQ_ON_ISR: 256 case STATE_RADIO_IRQ_ON_ISR:
225 case STATE_RADIO_IRQ_OFF: 257 case STATE_RADIO_IRQ_OFF:
@@ -245,6 +277,49 @@ static int rt2800usb_set_device_state(struct rt2x00_dev *rt2x00dev,
245} 277}
246 278
247/* 279/*
280 * Watchdog handlers
281 */
282static void rt2800usb_watchdog(struct rt2x00_dev *rt2x00dev)
283{
284 unsigned int i;
285 u32 reg;
286
287 rt2800_register_read(rt2x00dev, TXRXQ_PCNT, &reg);
288 if (rt2x00_get_field32(reg, TXRXQ_PCNT_TX0Q)) {
289 WARNING(rt2x00dev, "TX HW queue 0 timed out,"
290 " invoke forced kick\n");
291
292 rt2800_register_write(rt2x00dev, PBF_CFG, 0xf40012);
293
294 for (i = 0; i < 10; i++) {
295 udelay(10);
296 if (!rt2x00_get_field32(reg, TXRXQ_PCNT_TX0Q))
297 break;
298 }
299
300 rt2800_register_write(rt2x00dev, PBF_CFG, 0xf40006);
301 }
302
303 rt2800_register_read(rt2x00dev, TXRXQ_PCNT, &reg);
304 if (rt2x00_get_field32(reg, TXRXQ_PCNT_TX1Q)) {
305 WARNING(rt2x00dev, "TX HW queue 1 timed out,"
306 " invoke forced kick\n");
307
308 rt2800_register_write(rt2x00dev, PBF_CFG, 0xf4000a);
309
310 for (i = 0; i < 10; i++) {
311 udelay(10);
312 if (!rt2x00_get_field32(reg, TXRXQ_PCNT_TX1Q))
313 break;
314 }
315
316 rt2800_register_write(rt2x00dev, PBF_CFG, 0xf40006);
317 }
318
319 rt2x00usb_watchdog(rt2x00dev);
320}
321
322/*
248 * TX descriptor initialization 323 * TX descriptor initialization
249 */ 324 */
250static __le32 *rt2800usb_get_txwi(struct queue_entry *entry) 325static __le32 *rt2800usb_get_txwi(struct queue_entry *entry)
@@ -266,8 +341,14 @@ static void rt2800usb_write_tx_desc(struct queue_entry *entry,
266 * Initialize TXINFO descriptor 341 * Initialize TXINFO descriptor
267 */ 342 */
268 rt2x00_desc_read(txi, 0, &word); 343 rt2x00_desc_read(txi, 0, &word);
344
345 /*
346 * The size of TXINFO_W0_USB_DMA_TX_PKT_LEN is
347 * TXWI + 802.11 header + L2 pad + payload + pad,
348 * so need to decrease size of TXINFO and USB end pad.
349 */
269 rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_PKT_LEN, 350 rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_PKT_LEN,
270 entry->skb->len - TXINFO_DESC_SIZE); 351 entry->skb->len - TXINFO_DESC_SIZE - 4);
271 rt2x00_set_field32(&word, TXINFO_W0_WIV, 352 rt2x00_set_field32(&word, TXINFO_W0_WIV,
272 !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags)); 353 !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags));
273 rt2x00_set_field32(&word, TXINFO_W0_QSEL, 2); 354 rt2x00_set_field32(&word, TXINFO_W0_QSEL, 2);
@@ -285,22 +366,37 @@ static void rt2800usb_write_tx_desc(struct queue_entry *entry,
285 skbdesc->desc_len = TXINFO_DESC_SIZE + TXWI_DESC_SIZE; 366 skbdesc->desc_len = TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
286} 367}
287 368
288/* 369static void rt2800usb_write_tx_data(struct queue_entry *entry,
289 * TX data initialization 370 struct txentry_desc *txdesc)
290 */
291static int rt2800usb_get_tx_data_len(struct queue_entry *entry)
292{ 371{
293 int length; 372 unsigned int len;
373 int err;
374
375 rt2800_write_tx_data(entry, txdesc);
294 376
295 /* 377 /*
296 * The length _must_ include 4 bytes padding, 378 * pad(1~3 bytes) is added after each 802.11 payload.
297 * it should always be multiple of 4, 379 * USB end pad(4 bytes) is added at each USB bulk out packet end.
298 * but it must _not_ be a multiple of the USB packet size. 380 * TX frame format is :
381 * | TXINFO | TXWI | 802.11 header | L2 pad | payload | pad | USB end pad |
382 * |<------------- tx_pkt_len ------------->|
299 */ 383 */
300 length = roundup(entry->skb->len + 4, 4); 384 len = roundup(entry->skb->len, 4) + 4;
301 length += (4 * !(length % entry->queue->usb_maxpacket)); 385 err = skb_padto(entry->skb, len);
386 if (unlikely(err)) {
387 WARNING(entry->queue->rt2x00dev, "TX SKB padding error, out of memory\n");
388 return;
389 }
302 390
303 return length; 391 entry->skb->len = len;
392}
393
394/*
395 * TX data initialization
396 */
397static int rt2800usb_get_tx_data_len(struct queue_entry *entry)
398{
399 return entry->skb->len;
304} 400}
305 401
306/* 402/*
@@ -335,14 +431,6 @@ static void rt2800usb_work_txdone(struct work_struct *work)
335 } 431 }
336} 432}
337 433
338static void rt2800usb_kill_tx_queue(struct data_queue *queue)
339{
340 if (queue->qid == QID_BEACON)
341 rt2x00usb_register_write(queue->rt2x00dev, BCN_TIME_CFG, 0);
342
343 rt2x00usb_kill_tx_queue(queue);
344}
345
346/* 434/*
347 * RX control handlers 435 * RX control handlers
348 */ 436 */
@@ -507,6 +595,8 @@ static const struct ieee80211_ops rt2800usb_mac80211_ops = {
507 .get_tsf = rt2800_get_tsf, 595 .get_tsf = rt2800_get_tsf,
508 .rfkill_poll = rt2x00mac_rfkill_poll, 596 .rfkill_poll = rt2x00mac_rfkill_poll,
509 .ampdu_action = rt2800_ampdu_action, 597 .ampdu_action = rt2800_ampdu_action,
598 .flush = rt2x00mac_flush,
599 .get_survey = rt2800_get_survey,
510}; 600};
511 601
512static const struct rt2800_ops rt2800usb_rt2800_ops = { 602static const struct rt2800_ops rt2800usb_rt2800_ops = {
@@ -535,13 +625,15 @@ static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = {
535 .link_stats = rt2800_link_stats, 625 .link_stats = rt2800_link_stats,
536 .reset_tuner = rt2800_reset_tuner, 626 .reset_tuner = rt2800_reset_tuner,
537 .link_tuner = rt2800_link_tuner, 627 .link_tuner = rt2800_link_tuner,
538 .watchdog = rt2x00usb_watchdog, 628 .watchdog = rt2800usb_watchdog,
629 .start_queue = rt2800usb_start_queue,
630 .kick_queue = rt2x00usb_kick_queue,
631 .stop_queue = rt2800usb_stop_queue,
632 .flush_queue = rt2x00usb_flush_queue,
539 .write_tx_desc = rt2800usb_write_tx_desc, 633 .write_tx_desc = rt2800usb_write_tx_desc,
540 .write_tx_data = rt2800_write_tx_data, 634 .write_tx_data = rt2800usb_write_tx_data,
541 .write_beacon = rt2800_write_beacon, 635 .write_beacon = rt2800_write_beacon,
542 .get_tx_data_len = rt2800usb_get_tx_data_len, 636 .get_tx_data_len = rt2800usb_get_tx_data_len,
543 .kick_tx_queue = rt2x00usb_kick_tx_queue,
544 .kill_tx_queue = rt2800usb_kill_tx_queue,
545 .fill_rxdone = rt2800usb_fill_rxdone, 637 .fill_rxdone = rt2800usb_fill_rxdone,
546 .config_shared_key = rt2800_config_shared_key, 638 .config_shared_key = rt2800_config_shared_key,
547 .config_pairwise_key = rt2800_config_pairwise_key, 639 .config_pairwise_key = rt2800_config_pairwise_key,
@@ -553,21 +645,21 @@ static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = {
553}; 645};
554 646
555static const struct data_queue_desc rt2800usb_queue_rx = { 647static const struct data_queue_desc rt2800usb_queue_rx = {
556 .entry_num = RX_ENTRIES, 648 .entry_num = 128,
557 .data_size = AGGREGATION_SIZE, 649 .data_size = AGGREGATION_SIZE,
558 .desc_size = RXINFO_DESC_SIZE + RXWI_DESC_SIZE, 650 .desc_size = RXINFO_DESC_SIZE + RXWI_DESC_SIZE,
559 .priv_size = sizeof(struct queue_entry_priv_usb), 651 .priv_size = sizeof(struct queue_entry_priv_usb),
560}; 652};
561 653
562static const struct data_queue_desc rt2800usb_queue_tx = { 654static const struct data_queue_desc rt2800usb_queue_tx = {
563 .entry_num = TX_ENTRIES, 655 .entry_num = 64,
564 .data_size = AGGREGATION_SIZE, 656 .data_size = AGGREGATION_SIZE,
565 .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE, 657 .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE,
566 .priv_size = sizeof(struct queue_entry_priv_usb), 658 .priv_size = sizeof(struct queue_entry_priv_usb),
567}; 659};
568 660
569static const struct data_queue_desc rt2800usb_queue_bcn = { 661static const struct data_queue_desc rt2800usb_queue_bcn = {
570 .entry_num = 8 * BEACON_ENTRIES, 662 .entry_num = 8,
571 .data_size = MGMT_FRAME_SIZE, 663 .data_size = MGMT_FRAME_SIZE,
572 .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE, 664 .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE,
573 .priv_size = sizeof(struct queue_entry_priv_usb), 665 .priv_size = sizeof(struct queue_entry_priv_usb),
@@ -599,11 +691,19 @@ static struct usb_device_id rt2800usb_device_table[] = {
599 /* Abocom */ 691 /* Abocom */
600 { USB_DEVICE(0x07b8, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) }, 692 { USB_DEVICE(0x07b8, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) },
601 { USB_DEVICE(0x07b8, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) }, 693 { USB_DEVICE(0x07b8, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) },
694 { USB_DEVICE(0x07b8, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) },
695 { USB_DEVICE(0x07b8, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) },
696 { USB_DEVICE(0x07b8, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) },
602 { USB_DEVICE(0x1482, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) }, 697 { USB_DEVICE(0x1482, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) },
698 /* AirTies */
699 { USB_DEVICE(0x1eda, 0x2310), USB_DEVICE_DATA(&rt2800usb_ops) },
603 /* Allwin */ 700 /* Allwin */
604 { USB_DEVICE(0x8516, 0x2070), USB_DEVICE_DATA(&rt2800usb_ops) }, 701 { USB_DEVICE(0x8516, 0x2070), USB_DEVICE_DATA(&rt2800usb_ops) },
605 { USB_DEVICE(0x8516, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) }, 702 { USB_DEVICE(0x8516, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) },
606 { USB_DEVICE(0x8516, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) }, 703 { USB_DEVICE(0x8516, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) },
704 { USB_DEVICE(0x8516, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) },
705 { USB_DEVICE(0x8516, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) },
706 { USB_DEVICE(0x8516, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) },
607 /* Amit */ 707 /* Amit */
608 { USB_DEVICE(0x15c5, 0x0008), USB_DEVICE_DATA(&rt2800usb_ops) }, 708 { USB_DEVICE(0x15c5, 0x0008), USB_DEVICE_DATA(&rt2800usb_ops) },
609 /* Askey */ 709 /* Askey */
@@ -612,8 +712,13 @@ static struct usb_device_id rt2800usb_device_table[] = {
612 { USB_DEVICE(0x0b05, 0x1731), USB_DEVICE_DATA(&rt2800usb_ops) }, 712 { USB_DEVICE(0x0b05, 0x1731), USB_DEVICE_DATA(&rt2800usb_ops) },
613 { USB_DEVICE(0x0b05, 0x1732), USB_DEVICE_DATA(&rt2800usb_ops) }, 713 { USB_DEVICE(0x0b05, 0x1732), USB_DEVICE_DATA(&rt2800usb_ops) },
614 { USB_DEVICE(0x0b05, 0x1742), USB_DEVICE_DATA(&rt2800usb_ops) }, 714 { USB_DEVICE(0x0b05, 0x1742), USB_DEVICE_DATA(&rt2800usb_ops) },
715 { USB_DEVICE(0x0b05, 0x1784), USB_DEVICE_DATA(&rt2800usb_ops) },
615 /* AzureWave */ 716 /* AzureWave */
616 { USB_DEVICE(0x13d3, 0x3247), USB_DEVICE_DATA(&rt2800usb_ops) }, 717 { USB_DEVICE(0x13d3, 0x3247), USB_DEVICE_DATA(&rt2800usb_ops) },
718 { USB_DEVICE(0x13d3, 0x3273), USB_DEVICE_DATA(&rt2800usb_ops) },
719 { USB_DEVICE(0x13d3, 0x3305), USB_DEVICE_DATA(&rt2800usb_ops) },
720 { USB_DEVICE(0x13d3, 0x3307), USB_DEVICE_DATA(&rt2800usb_ops) },
721 { USB_DEVICE(0x13d3, 0x3321), USB_DEVICE_DATA(&rt2800usb_ops) },
617 /* Belkin */ 722 /* Belkin */
618 { USB_DEVICE(0x050d, 0x8053), USB_DEVICE_DATA(&rt2800usb_ops) }, 723 { USB_DEVICE(0x050d, 0x8053), USB_DEVICE_DATA(&rt2800usb_ops) },
619 { USB_DEVICE(0x050d, 0x805c), USB_DEVICE_DATA(&rt2800usb_ops) }, 724 { USB_DEVICE(0x050d, 0x805c), USB_DEVICE_DATA(&rt2800usb_ops) },
@@ -624,6 +729,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
624 { USB_DEVICE(0x14b2, 0x3c06), USB_DEVICE_DATA(&rt2800usb_ops) }, 729 { USB_DEVICE(0x14b2, 0x3c06), USB_DEVICE_DATA(&rt2800usb_ops) },
625 { USB_DEVICE(0x14b2, 0x3c07), USB_DEVICE_DATA(&rt2800usb_ops) }, 730 { USB_DEVICE(0x14b2, 0x3c07), USB_DEVICE_DATA(&rt2800usb_ops) },
626 { USB_DEVICE(0x14b2, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) }, 731 { USB_DEVICE(0x14b2, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) },
732 { USB_DEVICE(0x14b2, 0x3c12), USB_DEVICE_DATA(&rt2800usb_ops) },
627 { USB_DEVICE(0x14b2, 0x3c23), USB_DEVICE_DATA(&rt2800usb_ops) }, 733 { USB_DEVICE(0x14b2, 0x3c23), USB_DEVICE_DATA(&rt2800usb_ops) },
628 { USB_DEVICE(0x14b2, 0x3c25), USB_DEVICE_DATA(&rt2800usb_ops) }, 734 { USB_DEVICE(0x14b2, 0x3c25), USB_DEVICE_DATA(&rt2800usb_ops) },
629 { USB_DEVICE(0x14b2, 0x3c27), USB_DEVICE_DATA(&rt2800usb_ops) }, 735 { USB_DEVICE(0x14b2, 0x3c27), USB_DEVICE_DATA(&rt2800usb_ops) },
@@ -632,17 +738,36 @@ static struct usb_device_id rt2800usb_device_table[] = {
632 { USB_DEVICE(0x07aa, 0x002f), USB_DEVICE_DATA(&rt2800usb_ops) }, 738 { USB_DEVICE(0x07aa, 0x002f), USB_DEVICE_DATA(&rt2800usb_ops) },
633 { USB_DEVICE(0x07aa, 0x003c), USB_DEVICE_DATA(&rt2800usb_ops) }, 739 { USB_DEVICE(0x07aa, 0x003c), USB_DEVICE_DATA(&rt2800usb_ops) },
634 { USB_DEVICE(0x07aa, 0x003f), USB_DEVICE_DATA(&rt2800usb_ops) }, 740 { USB_DEVICE(0x07aa, 0x003f), USB_DEVICE_DATA(&rt2800usb_ops) },
741 { USB_DEVICE(0x18c5, 0x0012), USB_DEVICE_DATA(&rt2800usb_ops) },
635 /* D-Link */ 742 /* D-Link */
636 { USB_DEVICE(0x07d1, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) }, 743 { USB_DEVICE(0x07d1, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) },
744 { USB_DEVICE(0x07d1, 0x3c0a), USB_DEVICE_DATA(&rt2800usb_ops) },
745 { USB_DEVICE(0x07d1, 0x3c0d), USB_DEVICE_DATA(&rt2800usb_ops) },
746 { USB_DEVICE(0x07d1, 0x3c0e), USB_DEVICE_DATA(&rt2800usb_ops) },
747 { USB_DEVICE(0x07d1, 0x3c0f), USB_DEVICE_DATA(&rt2800usb_ops) },
637 { USB_DEVICE(0x07d1, 0x3c11), USB_DEVICE_DATA(&rt2800usb_ops) }, 748 { USB_DEVICE(0x07d1, 0x3c11), USB_DEVICE_DATA(&rt2800usb_ops) },
749 { USB_DEVICE(0x07d1, 0x3c16), USB_DEVICE_DATA(&rt2800usb_ops) },
750 /* Draytek */
751 { USB_DEVICE(0x07fa, 0x7712), USB_DEVICE_DATA(&rt2800usb_ops) },
638 /* Edimax */ 752 /* Edimax */
753 { USB_DEVICE(0x7392, 0x7711), USB_DEVICE_DATA(&rt2800usb_ops) },
639 { USB_DEVICE(0x7392, 0x7717), USB_DEVICE_DATA(&rt2800usb_ops) }, 754 { USB_DEVICE(0x7392, 0x7717), USB_DEVICE_DATA(&rt2800usb_ops) },
640 { USB_DEVICE(0x7392, 0x7718), USB_DEVICE_DATA(&rt2800usb_ops) }, 755 { USB_DEVICE(0x7392, 0x7718), USB_DEVICE_DATA(&rt2800usb_ops) },
756 /* Encore */
757 { USB_DEVICE(0x203d, 0x1480), USB_DEVICE_DATA(&rt2800usb_ops) },
758 { USB_DEVICE(0x203d, 0x14a9), USB_DEVICE_DATA(&rt2800usb_ops) },
641 /* EnGenius */ 759 /* EnGenius */
642 { USB_DEVICE(0x1740, 0x9701), USB_DEVICE_DATA(&rt2800usb_ops) }, 760 { USB_DEVICE(0x1740, 0x9701), USB_DEVICE_DATA(&rt2800usb_ops) },
643 { USB_DEVICE(0x1740, 0x9702), USB_DEVICE_DATA(&rt2800usb_ops) }, 761 { USB_DEVICE(0x1740, 0x9702), USB_DEVICE_DATA(&rt2800usb_ops) },
762 { USB_DEVICE(0x1740, 0x9703), USB_DEVICE_DATA(&rt2800usb_ops) },
763 { USB_DEVICE(0x1740, 0x9705), USB_DEVICE_DATA(&rt2800usb_ops) },
764 { USB_DEVICE(0x1740, 0x9706), USB_DEVICE_DATA(&rt2800usb_ops) },
765 { USB_DEVICE(0x1740, 0x9707), USB_DEVICE_DATA(&rt2800usb_ops) },
766 { USB_DEVICE(0x1740, 0x9708), USB_DEVICE_DATA(&rt2800usb_ops) },
767 { USB_DEVICE(0x1740, 0x9709), USB_DEVICE_DATA(&rt2800usb_ops) },
644 /* Gigabyte */ 768 /* Gigabyte */
645 { USB_DEVICE(0x1044, 0x800b), USB_DEVICE_DATA(&rt2800usb_ops) }, 769 { USB_DEVICE(0x1044, 0x800b), USB_DEVICE_DATA(&rt2800usb_ops) },
770 { USB_DEVICE(0x1044, 0x800d), USB_DEVICE_DATA(&rt2800usb_ops) },
646 /* Hawking */ 771 /* Hawking */
647 { USB_DEVICE(0x0e66, 0x0001), USB_DEVICE_DATA(&rt2800usb_ops) }, 772 { USB_DEVICE(0x0e66, 0x0001), USB_DEVICE_DATA(&rt2800usb_ops) },
648 { USB_DEVICE(0x0e66, 0x0003), USB_DEVICE_DATA(&rt2800usb_ops) }, 773 { USB_DEVICE(0x0e66, 0x0003), USB_DEVICE_DATA(&rt2800usb_ops) },
@@ -651,6 +776,10 @@ static struct usb_device_id rt2800usb_device_table[] = {
651 { USB_DEVICE(0x0e66, 0x0013), USB_DEVICE_DATA(&rt2800usb_ops) }, 776 { USB_DEVICE(0x0e66, 0x0013), USB_DEVICE_DATA(&rt2800usb_ops) },
652 { USB_DEVICE(0x0e66, 0x0017), USB_DEVICE_DATA(&rt2800usb_ops) }, 777 { USB_DEVICE(0x0e66, 0x0017), USB_DEVICE_DATA(&rt2800usb_ops) },
653 { USB_DEVICE(0x0e66, 0x0018), USB_DEVICE_DATA(&rt2800usb_ops) }, 778 { USB_DEVICE(0x0e66, 0x0018), USB_DEVICE_DATA(&rt2800usb_ops) },
779 /* I-O DATA */
780 { USB_DEVICE(0x04bb, 0x0945), USB_DEVICE_DATA(&rt2800usb_ops) },
781 { USB_DEVICE(0x04bb, 0x0947), USB_DEVICE_DATA(&rt2800usb_ops) },
782 { USB_DEVICE(0x04bb, 0x0948), USB_DEVICE_DATA(&rt2800usb_ops) },
654 /* Linksys */ 783 /* Linksys */
655 { USB_DEVICE(0x1737, 0x0070), USB_DEVICE_DATA(&rt2800usb_ops) }, 784 { USB_DEVICE(0x1737, 0x0070), USB_DEVICE_DATA(&rt2800usb_ops) },
656 { USB_DEVICE(0x1737, 0x0071), USB_DEVICE_DATA(&rt2800usb_ops) }, 785 { USB_DEVICE(0x1737, 0x0071), USB_DEVICE_DATA(&rt2800usb_ops) },
@@ -658,17 +787,44 @@ static struct usb_device_id rt2800usb_device_table[] = {
658 { USB_DEVICE(0x0789, 0x0162), USB_DEVICE_DATA(&rt2800usb_ops) }, 787 { USB_DEVICE(0x0789, 0x0162), USB_DEVICE_DATA(&rt2800usb_ops) },
659 { USB_DEVICE(0x0789, 0x0163), USB_DEVICE_DATA(&rt2800usb_ops) }, 788 { USB_DEVICE(0x0789, 0x0163), USB_DEVICE_DATA(&rt2800usb_ops) },
660 { USB_DEVICE(0x0789, 0x0164), USB_DEVICE_DATA(&rt2800usb_ops) }, 789 { USB_DEVICE(0x0789, 0x0164), USB_DEVICE_DATA(&rt2800usb_ops) },
790 { USB_DEVICE(0x0789, 0x0166), USB_DEVICE_DATA(&rt2800usb_ops) },
661 /* Motorola */ 791 /* Motorola */
662 { USB_DEVICE(0x100d, 0x9031), USB_DEVICE_DATA(&rt2800usb_ops) }, 792 { USB_DEVICE(0x100d, 0x9031), USB_DEVICE_DATA(&rt2800usb_ops) },
663 /* MSI */ 793 /* MSI */
794 { USB_DEVICE(0x0db0, 0x3820), USB_DEVICE_DATA(&rt2800usb_ops) },
795 { USB_DEVICE(0x0db0, 0x3821), USB_DEVICE_DATA(&rt2800usb_ops) },
796 { USB_DEVICE(0x0db0, 0x3822), USB_DEVICE_DATA(&rt2800usb_ops) },
797 { USB_DEVICE(0x0db0, 0x3870), USB_DEVICE_DATA(&rt2800usb_ops) },
798 { USB_DEVICE(0x0db0, 0x3871), USB_DEVICE_DATA(&rt2800usb_ops) },
664 { USB_DEVICE(0x0db0, 0x6899), USB_DEVICE_DATA(&rt2800usb_ops) }, 799 { USB_DEVICE(0x0db0, 0x6899), USB_DEVICE_DATA(&rt2800usb_ops) },
800 { USB_DEVICE(0x0db0, 0x821a), USB_DEVICE_DATA(&rt2800usb_ops) },
801 { USB_DEVICE(0x0db0, 0x822a), USB_DEVICE_DATA(&rt2800usb_ops) },
802 { USB_DEVICE(0x0db0, 0x822b), USB_DEVICE_DATA(&rt2800usb_ops) },
803 { USB_DEVICE(0x0db0, 0x822c), USB_DEVICE_DATA(&rt2800usb_ops) },
804 { USB_DEVICE(0x0db0, 0x870a), USB_DEVICE_DATA(&rt2800usb_ops) },
805 { USB_DEVICE(0x0db0, 0x871a), USB_DEVICE_DATA(&rt2800usb_ops) },
806 { USB_DEVICE(0x0db0, 0x871b), USB_DEVICE_DATA(&rt2800usb_ops) },
807 { USB_DEVICE(0x0db0, 0x871c), USB_DEVICE_DATA(&rt2800usb_ops) },
808 { USB_DEVICE(0x0db0, 0x899a), USB_DEVICE_DATA(&rt2800usb_ops) },
809 /* Para */
810 { USB_DEVICE(0x20b8, 0x8888), USB_DEVICE_DATA(&rt2800usb_ops) },
811 /* Pegatron */
812 { USB_DEVICE(0x1d4d, 0x000c), USB_DEVICE_DATA(&rt2800usb_ops) },
813 { USB_DEVICE(0x1d4d, 0x000e), USB_DEVICE_DATA(&rt2800usb_ops) },
665 /* Philips */ 814 /* Philips */
666 { USB_DEVICE(0x0471, 0x200f), USB_DEVICE_DATA(&rt2800usb_ops) }, 815 { USB_DEVICE(0x0471, 0x200f), USB_DEVICE_DATA(&rt2800usb_ops) },
667 /* Planex */ 816 /* Planex */
817 { USB_DEVICE(0x2019, 0xab25), USB_DEVICE_DATA(&rt2800usb_ops) },
668 { USB_DEVICE(0x2019, 0xed06), USB_DEVICE_DATA(&rt2800usb_ops) }, 818 { USB_DEVICE(0x2019, 0xed06), USB_DEVICE_DATA(&rt2800usb_ops) },
819 /* Quanta */
820 { USB_DEVICE(0x1a32, 0x0304), USB_DEVICE_DATA(&rt2800usb_ops) },
669 /* Ralink */ 821 /* Ralink */
822 { USB_DEVICE(0x148f, 0x2070), USB_DEVICE_DATA(&rt2800usb_ops) },
670 { USB_DEVICE(0x148f, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) }, 823 { USB_DEVICE(0x148f, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) },
671 { USB_DEVICE(0x148f, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) }, 824 { USB_DEVICE(0x148f, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) },
825 { USB_DEVICE(0x148f, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) },
826 { USB_DEVICE(0x148f, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) },
827 { USB_DEVICE(0x148f, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) },
672 /* Samsung */ 828 /* Samsung */
673 { USB_DEVICE(0x04e8, 0x2018), USB_DEVICE_DATA(&rt2800usb_ops) }, 829 { USB_DEVICE(0x04e8, 0x2018), USB_DEVICE_DATA(&rt2800usb_ops) },
674 /* Siemens */ 830 /* Siemens */
@@ -681,13 +837,22 @@ static struct usb_device_id rt2800usb_device_table[] = {
681 { USB_DEVICE(0x0df6, 0x0039), USB_DEVICE_DATA(&rt2800usb_ops) }, 837 { USB_DEVICE(0x0df6, 0x0039), USB_DEVICE_DATA(&rt2800usb_ops) },
682 { USB_DEVICE(0x0df6, 0x003b), USB_DEVICE_DATA(&rt2800usb_ops) }, 838 { USB_DEVICE(0x0df6, 0x003b), USB_DEVICE_DATA(&rt2800usb_ops) },
683 { USB_DEVICE(0x0df6, 0x003d), USB_DEVICE_DATA(&rt2800usb_ops) }, 839 { USB_DEVICE(0x0df6, 0x003d), USB_DEVICE_DATA(&rt2800usb_ops) },
840 { USB_DEVICE(0x0df6, 0x003e), USB_DEVICE_DATA(&rt2800usb_ops) },
684 { USB_DEVICE(0x0df6, 0x003f), USB_DEVICE_DATA(&rt2800usb_ops) }, 841 { USB_DEVICE(0x0df6, 0x003f), USB_DEVICE_DATA(&rt2800usb_ops) },
842 { USB_DEVICE(0x0df6, 0x0040), USB_DEVICE_DATA(&rt2800usb_ops) },
843 { USB_DEVICE(0x0df6, 0x0042), USB_DEVICE_DATA(&rt2800usb_ops) },
844 { USB_DEVICE(0x0df6, 0x0047), USB_DEVICE_DATA(&rt2800usb_ops) },
845 { USB_DEVICE(0x0df6, 0x0048), USB_DEVICE_DATA(&rt2800usb_ops) },
685 /* SMC */ 846 /* SMC */
686 { USB_DEVICE(0x083a, 0x6618), USB_DEVICE_DATA(&rt2800usb_ops) }, 847 { USB_DEVICE(0x083a, 0x6618), USB_DEVICE_DATA(&rt2800usb_ops) },
848 { USB_DEVICE(0x083a, 0x7511), USB_DEVICE_DATA(&rt2800usb_ops) },
687 { USB_DEVICE(0x083a, 0x7512), USB_DEVICE_DATA(&rt2800usb_ops) }, 849 { USB_DEVICE(0x083a, 0x7512), USB_DEVICE_DATA(&rt2800usb_ops) },
688 { USB_DEVICE(0x083a, 0x7522), USB_DEVICE_DATA(&rt2800usb_ops) }, 850 { USB_DEVICE(0x083a, 0x7522), USB_DEVICE_DATA(&rt2800usb_ops) },
689 { USB_DEVICE(0x083a, 0x8522), USB_DEVICE_DATA(&rt2800usb_ops) }, 851 { USB_DEVICE(0x083a, 0x8522), USB_DEVICE_DATA(&rt2800usb_ops) },
690 { USB_DEVICE(0x083a, 0xa618), USB_DEVICE_DATA(&rt2800usb_ops) }, 852 { USB_DEVICE(0x083a, 0xa618), USB_DEVICE_DATA(&rt2800usb_ops) },
853 { USB_DEVICE(0x083a, 0xa701), USB_DEVICE_DATA(&rt2800usb_ops) },
854 { USB_DEVICE(0x083a, 0xa702), USB_DEVICE_DATA(&rt2800usb_ops) },
855 { USB_DEVICE(0x083a, 0xa703), USB_DEVICE_DATA(&rt2800usb_ops) },
691 { USB_DEVICE(0x083a, 0xb522), USB_DEVICE_DATA(&rt2800usb_ops) }, 856 { USB_DEVICE(0x083a, 0xb522), USB_DEVICE_DATA(&rt2800usb_ops) },
692 /* Sparklan */ 857 /* Sparklan */
693 { USB_DEVICE(0x15a9, 0x0006), USB_DEVICE_DATA(&rt2800usb_ops) }, 858 { USB_DEVICE(0x15a9, 0x0006), USB_DEVICE_DATA(&rt2800usb_ops) },
@@ -701,101 +866,16 @@ static struct usb_device_id rt2800usb_device_table[] = {
701 /* Zinwell */ 866 /* Zinwell */
702 { USB_DEVICE(0x5a57, 0x0280), USB_DEVICE_DATA(&rt2800usb_ops) }, 867 { USB_DEVICE(0x5a57, 0x0280), USB_DEVICE_DATA(&rt2800usb_ops) },
703 { USB_DEVICE(0x5a57, 0x0282), USB_DEVICE_DATA(&rt2800usb_ops) }, 868 { USB_DEVICE(0x5a57, 0x0282), USB_DEVICE_DATA(&rt2800usb_ops) },
869 { USB_DEVICE(0x5a57, 0x0283), USB_DEVICE_DATA(&rt2800usb_ops) },
870 { USB_DEVICE(0x5a57, 0x5257), USB_DEVICE_DATA(&rt2800usb_ops) },
704 /* Zyxel */ 871 /* Zyxel */
705 { USB_DEVICE(0x0586, 0x3416), USB_DEVICE_DATA(&rt2800usb_ops) }, 872 { USB_DEVICE(0x0586, 0x3416), USB_DEVICE_DATA(&rt2800usb_ops) },
706#ifdef CONFIG_RT2800USB_RT30XX 873#ifdef CONFIG_RT2800USB_RT33XX
707 /* Abocom */
708 { USB_DEVICE(0x07b8, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) },
709 { USB_DEVICE(0x07b8, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) },
710 { USB_DEVICE(0x07b8, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) },
711 /* AirTies */
712 { USB_DEVICE(0x1eda, 0x2310), USB_DEVICE_DATA(&rt2800usb_ops) },
713 /* Allwin */
714 { USB_DEVICE(0x8516, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) },
715 { USB_DEVICE(0x8516, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) },
716 { USB_DEVICE(0x8516, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) },
717 /* ASUS */
718 { USB_DEVICE(0x0b05, 0x1784), USB_DEVICE_DATA(&rt2800usb_ops) },
719 /* AzureWave */
720 { USB_DEVICE(0x13d3, 0x3273), USB_DEVICE_DATA(&rt2800usb_ops) },
721 { USB_DEVICE(0x13d3, 0x3305), USB_DEVICE_DATA(&rt2800usb_ops) },
722 { USB_DEVICE(0x13d3, 0x3307), USB_DEVICE_DATA(&rt2800usb_ops) },
723 { USB_DEVICE(0x13d3, 0x3321), USB_DEVICE_DATA(&rt2800usb_ops) },
724 /* Conceptronic */
725 { USB_DEVICE(0x14b2, 0x3c12), USB_DEVICE_DATA(&rt2800usb_ops) },
726 /* Corega */
727 { USB_DEVICE(0x18c5, 0x0012), USB_DEVICE_DATA(&rt2800usb_ops) },
728 /* D-Link */
729 { USB_DEVICE(0x07d1, 0x3c0a), USB_DEVICE_DATA(&rt2800usb_ops) },
730 { USB_DEVICE(0x07d1, 0x3c0d), USB_DEVICE_DATA(&rt2800usb_ops) },
731 { USB_DEVICE(0x07d1, 0x3c0e), USB_DEVICE_DATA(&rt2800usb_ops) },
732 { USB_DEVICE(0x07d1, 0x3c0f), USB_DEVICE_DATA(&rt2800usb_ops) },
733 { USB_DEVICE(0x07d1, 0x3c16), USB_DEVICE_DATA(&rt2800usb_ops) },
734 /* Draytek */
735 { USB_DEVICE(0x07fa, 0x7712), USB_DEVICE_DATA(&rt2800usb_ops) },
736 /* Edimax */
737 { USB_DEVICE(0x7392, 0x7711), USB_DEVICE_DATA(&rt2800usb_ops) },
738 /* Encore */
739 { USB_DEVICE(0x203d, 0x1480), USB_DEVICE_DATA(&rt2800usb_ops) },
740 { USB_DEVICE(0x203d, 0x14a9), USB_DEVICE_DATA(&rt2800usb_ops) },
741 /* EnGenius */
742 { USB_DEVICE(0x1740, 0x9703), USB_DEVICE_DATA(&rt2800usb_ops) },
743 { USB_DEVICE(0x1740, 0x9705), USB_DEVICE_DATA(&rt2800usb_ops) },
744 { USB_DEVICE(0x1740, 0x9706), USB_DEVICE_DATA(&rt2800usb_ops) },
745 { USB_DEVICE(0x1740, 0x9707), USB_DEVICE_DATA(&rt2800usb_ops) },
746 { USB_DEVICE(0x1740, 0x9708), USB_DEVICE_DATA(&rt2800usb_ops) },
747 { USB_DEVICE(0x1740, 0x9709), USB_DEVICE_DATA(&rt2800usb_ops) },
748 /* Gigabyte */
749 { USB_DEVICE(0x1044, 0x800d), USB_DEVICE_DATA(&rt2800usb_ops) },
750 /* I-O DATA */
751 { USB_DEVICE(0x04bb, 0x0945), USB_DEVICE_DATA(&rt2800usb_ops) },
752 { USB_DEVICE(0x04bb, 0x0947), USB_DEVICE_DATA(&rt2800usb_ops) },
753 { USB_DEVICE(0x04bb, 0x0948), USB_DEVICE_DATA(&rt2800usb_ops) },
754 /* Logitec */
755 { USB_DEVICE(0x0789, 0x0166), USB_DEVICE_DATA(&rt2800usb_ops) },
756 /* MSI */
757 { USB_DEVICE(0x0db0, 0x3820), USB_DEVICE_DATA(&rt2800usb_ops) },
758 { USB_DEVICE(0x0db0, 0x3821), USB_DEVICE_DATA(&rt2800usb_ops) },
759 { USB_DEVICE(0x0db0, 0x3822), USB_DEVICE_DATA(&rt2800usb_ops) },
760 { USB_DEVICE(0x0db0, 0x3870), USB_DEVICE_DATA(&rt2800usb_ops) },
761 { USB_DEVICE(0x0db0, 0x3871), USB_DEVICE_DATA(&rt2800usb_ops) },
762 { USB_DEVICE(0x0db0, 0x821a), USB_DEVICE_DATA(&rt2800usb_ops) },
763 { USB_DEVICE(0x0db0, 0x822a), USB_DEVICE_DATA(&rt2800usb_ops) },
764 { USB_DEVICE(0x0db0, 0x822b), USB_DEVICE_DATA(&rt2800usb_ops) },
765 { USB_DEVICE(0x0db0, 0x822c), USB_DEVICE_DATA(&rt2800usb_ops) },
766 { USB_DEVICE(0x0db0, 0x870a), USB_DEVICE_DATA(&rt2800usb_ops) },
767 { USB_DEVICE(0x0db0, 0x871a), USB_DEVICE_DATA(&rt2800usb_ops) },
768 { USB_DEVICE(0x0db0, 0x871b), USB_DEVICE_DATA(&rt2800usb_ops) },
769 { USB_DEVICE(0x0db0, 0x871c), USB_DEVICE_DATA(&rt2800usb_ops) },
770 { USB_DEVICE(0x0db0, 0x899a), USB_DEVICE_DATA(&rt2800usb_ops) },
771 /* Para */
772 { USB_DEVICE(0x20b8, 0x8888), USB_DEVICE_DATA(&rt2800usb_ops) },
773 /* Pegatron */
774 { USB_DEVICE(0x1d4d, 0x000c), USB_DEVICE_DATA(&rt2800usb_ops) },
775 { USB_DEVICE(0x1d4d, 0x000e), USB_DEVICE_DATA(&rt2800usb_ops) },
776 /* Planex */
777 { USB_DEVICE(0x2019, 0xab25), USB_DEVICE_DATA(&rt2800usb_ops) },
778 /* Quanta */
779 { USB_DEVICE(0x1a32, 0x0304), USB_DEVICE_DATA(&rt2800usb_ops) },
780 /* Ralink */ 874 /* Ralink */
781 { USB_DEVICE(0x148f, 0x2070), USB_DEVICE_DATA(&rt2800usb_ops) }, 875 { USB_DEVICE(0x148f, 0x3370), USB_DEVICE_DATA(&rt2800usb_ops) },
782 { USB_DEVICE(0x148f, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) }, 876 { USB_DEVICE(0x148f, 0x8070), USB_DEVICE_DATA(&rt2800usb_ops) },
783 { USB_DEVICE(0x148f, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) },
784 { USB_DEVICE(0x148f, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) },
785 /* Sitecom */ 877 /* Sitecom */
786 { USB_DEVICE(0x0df6, 0x003e), USB_DEVICE_DATA(&rt2800usb_ops) }, 878 { USB_DEVICE(0x0df6, 0x0050), USB_DEVICE_DATA(&rt2800usb_ops) },
787 { USB_DEVICE(0x0df6, 0x0040), USB_DEVICE_DATA(&rt2800usb_ops) },
788 { USB_DEVICE(0x0df6, 0x0042), USB_DEVICE_DATA(&rt2800usb_ops) },
789 { USB_DEVICE(0x0df6, 0x0047), USB_DEVICE_DATA(&rt2800usb_ops) },
790 { USB_DEVICE(0x0df6, 0x0048), USB_DEVICE_DATA(&rt2800usb_ops) },
791 /* SMC */
792 { USB_DEVICE(0x083a, 0x7511), USB_DEVICE_DATA(&rt2800usb_ops) },
793 { USB_DEVICE(0x083a, 0xa701), USB_DEVICE_DATA(&rt2800usb_ops) },
794 { USB_DEVICE(0x083a, 0xa702), USB_DEVICE_DATA(&rt2800usb_ops) },
795 { USB_DEVICE(0x083a, 0xa703), USB_DEVICE_DATA(&rt2800usb_ops) },
796 /* Zinwell */
797 { USB_DEVICE(0x5a57, 0x0283), USB_DEVICE_DATA(&rt2800usb_ops) },
798 { USB_DEVICE(0x5a57, 0x5257), USB_DEVICE_DATA(&rt2800usb_ops) },
799#endif 879#endif
800#ifdef CONFIG_RT2800USB_RT35XX 880#ifdef CONFIG_RT2800USB_RT35XX
801 /* Allwin */ 881 /* Allwin */
@@ -809,12 +889,9 @@ static struct usb_device_id rt2800usb_device_table[] = {
809 /* I-O DATA */ 889 /* I-O DATA */
810 { USB_DEVICE(0x04bb, 0x0944), USB_DEVICE_DATA(&rt2800usb_ops) }, 890 { USB_DEVICE(0x04bb, 0x0944), USB_DEVICE_DATA(&rt2800usb_ops) },
811 /* Ralink */ 891 /* Ralink */
812 { USB_DEVICE(0x148f, 0x3370), USB_DEVICE_DATA(&rt2800usb_ops) },
813 { USB_DEVICE(0x148f, 0x3572), USB_DEVICE_DATA(&rt2800usb_ops) }, 892 { USB_DEVICE(0x148f, 0x3572), USB_DEVICE_DATA(&rt2800usb_ops) },
814 { USB_DEVICE(0x148f, 0x8070), USB_DEVICE_DATA(&rt2800usb_ops) },
815 /* Sitecom */ 893 /* Sitecom */
816 { USB_DEVICE(0x0df6, 0x0041), USB_DEVICE_DATA(&rt2800usb_ops) }, 894 { USB_DEVICE(0x0df6, 0x0041), USB_DEVICE_DATA(&rt2800usb_ops) },
817 { USB_DEVICE(0x0df6, 0x0050), USB_DEVICE_DATA(&rt2800usb_ops) },
818 /* Zinwell */ 895 /* Zinwell */
819 { USB_DEVICE(0x5a57, 0x0284), USB_DEVICE_DATA(&rt2800usb_ops) }, 896 { USB_DEVICE(0x5a57, 0x0284), USB_DEVICE_DATA(&rt2800usb_ops) },
820#endif 897#endif
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.h b/drivers/net/wireless/rt2x00/rt2800usb.h
index 0722badccf86..671ea3592610 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.h
+++ b/drivers/net/wireless/rt2x00/rt2800usb.h
@@ -40,8 +40,8 @@
40/* 40/*
41 * DMA descriptor defines. 41 * DMA descriptor defines.
42 */ 42 */
43#define TXINFO_DESC_SIZE ( 1 * sizeof(__le32) ) 43#define TXINFO_DESC_SIZE (1 * sizeof(__le32))
44#define RXINFO_DESC_SIZE ( 1 * sizeof(__le32) ) 44#define RXINFO_DESC_SIZE (1 * sizeof(__le32))
45 45
46/* 46/*
47 * TX Info structure 47 * TX Info structure
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 94fe589acfaa..84aaf393da43 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -66,7 +66,7 @@
66 66
67#ifdef CONFIG_RT2X00_DEBUG 67#ifdef CONFIG_RT2X00_DEBUG
68#define DEBUG_PRINTK(__dev, __kernlvl, __lvl, __msg, __args...) \ 68#define DEBUG_PRINTK(__dev, __kernlvl, __lvl, __msg, __args...) \
69 DEBUG_PRINTK_MSG(__dev, __kernlvl, __lvl, __msg, ##__args); 69 DEBUG_PRINTK_MSG(__dev, __kernlvl, __lvl, __msg, ##__args)
70#else 70#else
71#define DEBUG_PRINTK(__dev, __kernlvl, __lvl, __msg, __args...) \ 71#define DEBUG_PRINTK(__dev, __kernlvl, __lvl, __msg, __args...) \
72 do { } while (0) 72 do { } while (0)
@@ -347,6 +347,10 @@ struct link {
347 struct delayed_work watchdog_work; 347 struct delayed_work watchdog_work;
348}; 348};
349 349
350enum rt2x00_delayed_flags {
351 DELAYED_UPDATE_BEACON,
352};
353
350/* 354/*
351 * Interface structure 355 * Interface structure
352 * Per interface configuration details, this structure 356 * Per interface configuration details, this structure
@@ -354,22 +358,6 @@ struct link {
354 */ 358 */
355struct rt2x00_intf { 359struct rt2x00_intf {
356 /* 360 /*
357 * All fields within the rt2x00_intf structure
358 * must be protected with a spinlock.
359 */
360 spinlock_t lock;
361
362 /*
363 * MAC of the device.
364 */
365 u8 mac[ETH_ALEN];
366
367 /*
368 * BBSID of the AP to associate with.
369 */
370 u8 bssid[ETH_ALEN];
371
372 /*
373 * beacon->skb must be protected with the mutex. 361 * beacon->skb must be protected with the mutex.
374 */ 362 */
375 struct mutex beacon_skb_mutex; 363 struct mutex beacon_skb_mutex;
@@ -384,8 +372,7 @@ struct rt2x00_intf {
384 /* 372 /*
385 * Actions that needed rescheduling. 373 * Actions that needed rescheduling.
386 */ 374 */
387 unsigned int delayed_flags; 375 unsigned long delayed_flags;
388#define DELAYED_UPDATE_BEACON 0x00000001
389 376
390 /* 377 /*
391 * Software sequence counter, this is only required 378 * Software sequence counter, this is only required
@@ -567,7 +554,15 @@ struct rt2x00lib_ops {
567 struct link_qual *qual); 554 struct link_qual *qual);
568 void (*link_tuner) (struct rt2x00_dev *rt2x00dev, 555 void (*link_tuner) (struct rt2x00_dev *rt2x00dev,
569 struct link_qual *qual, const u32 count); 556 struct link_qual *qual, const u32 count);
557
558 /*
559 * Data queue handlers.
560 */
570 void (*watchdog) (struct rt2x00_dev *rt2x00dev); 561 void (*watchdog) (struct rt2x00_dev *rt2x00dev);
562 void (*start_queue) (struct data_queue *queue);
563 void (*kick_queue) (struct data_queue *queue);
564 void (*stop_queue) (struct data_queue *queue);
565 void (*flush_queue) (struct data_queue *queue);
571 566
572 /* 567 /*
573 * TX control handlers 568 * TX control handlers
@@ -579,8 +574,6 @@ struct rt2x00lib_ops {
579 void (*write_beacon) (struct queue_entry *entry, 574 void (*write_beacon) (struct queue_entry *entry,
580 struct txentry_desc *txdesc); 575 struct txentry_desc *txdesc);
581 int (*get_tx_data_len) (struct queue_entry *entry); 576 int (*get_tx_data_len) (struct queue_entry *entry);
582 void (*kick_tx_queue) (struct data_queue *queue);
583 void (*kill_tx_queue) (struct data_queue *queue);
584 577
585 /* 578 /*
586 * RX control handlers 579 * RX control handlers
@@ -664,6 +657,7 @@ enum rt2x00_flags {
664 DRIVER_REQUIRE_COPY_IV, 657 DRIVER_REQUIRE_COPY_IV,
665 DRIVER_REQUIRE_L2PAD, 658 DRIVER_REQUIRE_L2PAD,
666 DRIVER_REQUIRE_TXSTATUS_FIFO, 659 DRIVER_REQUIRE_TXSTATUS_FIFO,
660 DRIVER_REQUIRE_TASKLET_CONTEXT,
667 661
668 /* 662 /*
669 * Driver features 663 * Driver features
@@ -901,7 +895,7 @@ struct rt2x00_dev {
901 /* 895 /*
902 * FIFO for storing tx status reports between isr and tasklet. 896 * FIFO for storing tx status reports between isr and tasklet.
903 */ 897 */
904 struct kfifo txstatus_fifo; 898 DECLARE_KFIFO_PTR(txstatus_fifo, u32);
905 899
906 /* 900 /*
907 * Tasklet for processing tx status reports (rt2800pci). 901 * Tasklet for processing tx status reports (rt2800pci).
@@ -915,7 +909,7 @@ struct rt2x00_dev {
915 * in those cases REGISTER_BUSY_COUNT attempts should be 909 * in those cases REGISTER_BUSY_COUNT attempts should be
916 * taken with a REGISTER_BUSY_DELAY interval. 910 * taken with a REGISTER_BUSY_DELAY interval.
917 */ 911 */
918#define REGISTER_BUSY_COUNT 5 912#define REGISTER_BUSY_COUNT 100
919#define REGISTER_BUSY_DELAY 100 913#define REGISTER_BUSY_DELAY 100
920 914
921/* 915/*
@@ -1067,6 +1061,78 @@ struct data_queue *rt2x00queue_get_queue(struct rt2x00_dev *rt2x00dev,
1067struct queue_entry *rt2x00queue_get_entry(struct data_queue *queue, 1061struct queue_entry *rt2x00queue_get_entry(struct data_queue *queue,
1068 enum queue_index index); 1062 enum queue_index index);
1069 1063
1064/**
1065 * rt2x00queue_pause_queue - Pause a data queue
1066 * @queue: Pointer to &struct data_queue.
1067 *
1068 * This function will pause the data queue locally, preventing
1069 * new frames to be added to the queue (while the hardware is
1070 * still allowed to run).
1071 */
1072void rt2x00queue_pause_queue(struct data_queue *queue);
1073
1074/**
1075 * rt2x00queue_unpause_queue - unpause a data queue
1076 * @queue: Pointer to &struct data_queue.
1077 *
1078 * This function will unpause the data queue locally, allowing
1079 * new frames to be added to the queue again.
1080 */
1081void rt2x00queue_unpause_queue(struct data_queue *queue);
1082
1083/**
1084 * rt2x00queue_start_queue - Start a data queue
1085 * @queue: Pointer to &struct data_queue.
1086 *
1087 * This function will start handling all pending frames in the queue.
1088 */
1089void rt2x00queue_start_queue(struct data_queue *queue);
1090
1091/**
1092 * rt2x00queue_stop_queue - Halt a data queue
1093 * @queue: Pointer to &struct data_queue.
1094 *
1095 * This function will stop all pending frames in the queue.
1096 */
1097void rt2x00queue_stop_queue(struct data_queue *queue);
1098
1099/**
1100 * rt2x00queue_flush_queue - Flush a data queue
1101 * @queue: Pointer to &struct data_queue.
1102 * @drop: True to drop all pending frames.
1103 *
1104 * This function will flush the queue. After this call
1105 * the queue is guarenteed to be empty.
1106 */
1107void rt2x00queue_flush_queue(struct data_queue *queue, bool drop);
1108
1109/**
1110 * rt2x00queue_start_queues - Start all data queues
1111 * @rt2x00dev: Pointer to &struct rt2x00_dev.
1112 *
1113 * This function will loop through all available queues to start them
1114 */
1115void rt2x00queue_start_queues(struct rt2x00_dev *rt2x00dev);
1116
1117/**
1118 * rt2x00queue_stop_queues - Halt all data queues
1119 * @rt2x00dev: Pointer to &struct rt2x00_dev.
1120 *
1121 * This function will loop through all available queues to stop
1122 * any pending frames.
1123 */
1124void rt2x00queue_stop_queues(struct rt2x00_dev *rt2x00dev);
1125
1126/**
1127 * rt2x00queue_flush_queues - Flush all data queues
1128 * @rt2x00dev: Pointer to &struct rt2x00_dev.
1129 * @drop: True to drop all pending frames.
1130 *
1131 * This function will loop through all available queues to flush
1132 * any pending frames.
1133 */
1134void rt2x00queue_flush_queues(struct rt2x00_dev *rt2x00dev, bool drop);
1135
1070/* 1136/*
1071 * Debugfs handlers. 1137 * Debugfs handlers.
1072 */ 1138 */
@@ -1092,6 +1158,7 @@ static inline void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
1092 */ 1158 */
1093void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev); 1159void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev);
1094void rt2x00lib_pretbtt(struct rt2x00_dev *rt2x00dev); 1160void rt2x00lib_pretbtt(struct rt2x00_dev *rt2x00dev);
1161void rt2x00lib_dmastart(struct queue_entry *entry);
1095void rt2x00lib_dmadone(struct queue_entry *entry); 1162void rt2x00lib_dmadone(struct queue_entry *entry);
1096void rt2x00lib_txdone(struct queue_entry *entry, 1163void rt2x00lib_txdone(struct queue_entry *entry,
1097 struct txdone_entry_desc *txdesc); 1164 struct txdone_entry_desc *txdesc);
@@ -1133,6 +1200,7 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
1133int rt2x00mac_conf_tx(struct ieee80211_hw *hw, u16 queue, 1200int rt2x00mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
1134 const struct ieee80211_tx_queue_params *params); 1201 const struct ieee80211_tx_queue_params *params);
1135void rt2x00mac_rfkill_poll(struct ieee80211_hw *hw); 1202void rt2x00mac_rfkill_poll(struct ieee80211_hw *hw);
1203void rt2x00mac_flush(struct ieee80211_hw *hw, bool drop);
1136 1204
1137/* 1205/*
1138 * Driver allocation handlers. 1206 * Driver allocation handlers.
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c
index 54ffb5aeb34e..e7f67d5eda52 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -62,13 +62,13 @@ void rt2x00lib_config_intf(struct rt2x00_dev *rt2x00dev,
62 * This will prevent the device being confused when it wants 62 * This will prevent the device being confused when it wants
63 * to ACK frames or consideres itself associated. 63 * to ACK frames or consideres itself associated.
64 */ 64 */
65 memset(&conf.mac, 0, sizeof(conf.mac)); 65 memset(conf.mac, 0, sizeof(conf.mac));
66 if (mac) 66 if (mac)
67 memcpy(&conf.mac, mac, ETH_ALEN); 67 memcpy(conf.mac, mac, ETH_ALEN);
68 68
69 memset(&conf.bssid, 0, sizeof(conf.bssid)); 69 memset(conf.bssid, 0, sizeof(conf.bssid));
70 if (bssid) 70 if (bssid)
71 memcpy(&conf.bssid, bssid, ETH_ALEN); 71 memcpy(conf.bssid, bssid, ETH_ALEN);
72 72
73 flags |= CONFIG_UPDATE_TYPE; 73 flags |= CONFIG_UPDATE_TYPE;
74 if (mac || (!rt2x00dev->intf_ap_count && !rt2x00dev->intf_sta_count)) 74 if (mac || (!rt2x00dev->intf_ap_count && !rt2x00dev->intf_sta_count))
@@ -133,7 +133,7 @@ void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
133 */ 133 */
134 if (!(ant->flags & ANTENNA_RX_DIVERSITY)) 134 if (!(ant->flags & ANTENNA_RX_DIVERSITY))
135 config.rx = rt2x00lib_config_antenna_check(config.rx, def->rx); 135 config.rx = rt2x00lib_config_antenna_check(config.rx, def->rx);
136 else if(config.rx == ANTENNA_SW_DIVERSITY) 136 else if (config.rx == ANTENNA_SW_DIVERSITY)
137 config.rx = active->rx; 137 config.rx = active->rx;
138 138
139 if (!(ant->flags & ANTENNA_TX_DIVERSITY)) 139 if (!(ant->flags & ANTENNA_TX_DIVERSITY))
@@ -146,7 +146,7 @@ void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
146 * else the changes will be ignored by the device. 146 * else the changes will be ignored by the device.
147 */ 147 */
148 if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) 148 if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
149 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF_LINK); 149 rt2x00queue_stop_queue(rt2x00dev->rx);
150 150
151 /* 151 /*
152 * Write new antenna setup to device and reset the link tuner. 152 * Write new antenna setup to device and reset the link tuner.
@@ -160,7 +160,7 @@ void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
160 memcpy(active, &config, sizeof(config)); 160 memcpy(active, &config, sizeof(config));
161 161
162 if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) 162 if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
163 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON_LINK); 163 rt2x00queue_start_queue(rt2x00dev->rx);
164} 164}
165 165
166void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, 166void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
diff --git a/drivers/net/wireless/rt2x00/rt2x00debug.c b/drivers/net/wireless/rt2x00/rt2x00debug.c
index fcdb6b0dc40f..c92db3264741 100644
--- a/drivers/net/wireless/rt2x00/rt2x00debug.c
+++ b/drivers/net/wireless/rt2x00/rt2x00debug.c
@@ -162,11 +162,11 @@ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
162 struct timeval timestamp; 162 struct timeval timestamp;
163 u32 data_len; 163 u32 data_len;
164 164
165 do_gettimeofday(&timestamp); 165 if (likely(!test_bit(FRAME_DUMP_FILE_OPEN, &intf->frame_dump_flags)))
166
167 if (!test_bit(FRAME_DUMP_FILE_OPEN, &intf->frame_dump_flags))
168 return; 166 return;
169 167
168 do_gettimeofday(&timestamp);
169
170 if (skb_queue_len(&intf->frame_dump_skbqueue) > 20) { 170 if (skb_queue_len(&intf->frame_dump_skbqueue) > 20) {
171 DEBUG(rt2x00dev, "txrx dump queue length exceeded.\n"); 171 DEBUG(rt2x00dev, "txrx dump queue length exceeded.\n");
172 return; 172 return;
@@ -339,18 +339,19 @@ static ssize_t rt2x00debug_read_queue_stats(struct file *file,
339 return -ENOMEM; 339 return -ENOMEM;
340 340
341 temp = data + 341 temp = data +
342 sprintf(data, "qid\tcount\tlimit\tlength\tindex\tdma done\tdone\n"); 342 sprintf(data, "qid\tflags\t\tcount\tlimit\tlength\tindex\tdma done\tdone\n");
343 343
344 queue_for_each(intf->rt2x00dev, queue) { 344 queue_for_each(intf->rt2x00dev, queue) {
345 spin_lock_irqsave(&queue->lock, irqflags); 345 spin_lock_irqsave(&queue->index_lock, irqflags);
346 346
347 temp += sprintf(temp, "%d\t%d\t%d\t%d\t%d\t%d\t%d\n", queue->qid, 347 temp += sprintf(temp, "%d\t0x%.8x\t%d\t%d\t%d\t%d\t%d\t\t%d\n",
348 queue->qid, (unsigned int)queue->flags,
348 queue->count, queue->limit, queue->length, 349 queue->count, queue->limit, queue->length,
349 queue->index[Q_INDEX], 350 queue->index[Q_INDEX],
350 queue->index[Q_INDEX_DMA_DONE], 351 queue->index[Q_INDEX_DMA_DONE],
351 queue->index[Q_INDEX_DONE]); 352 queue->index[Q_INDEX_DONE]);
352 353
353 spin_unlock_irqrestore(&queue->lock, irqflags); 354 spin_unlock_irqrestore(&queue->index_lock, irqflags);
354 } 355 }
355 356
356 size = strlen(data); 357 size = strlen(data);
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 5ba79b935f09..9597a03242cc 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -66,20 +66,16 @@ int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev)
66 set_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags); 66 set_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags);
67 67
68 /* 68 /*
69 * Enable RX. 69 * Enable queues.
70 */ 70 */
71 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON); 71 rt2x00queue_start_queues(rt2x00dev);
72 rt2x00link_start_tuner(rt2x00dev);
72 73
73 /* 74 /*
74 * Start watchdog monitoring. 75 * Start watchdog monitoring.
75 */ 76 */
76 rt2x00link_start_watchdog(rt2x00dev); 77 rt2x00link_start_watchdog(rt2x00dev);
77 78
78 /*
79 * Start the TX queues.
80 */
81 ieee80211_wake_queues(rt2x00dev->hw);
82
83 return 0; 79 return 0;
84} 80}
85 81
@@ -89,20 +85,16 @@ void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev)
89 return; 85 return;
90 86
91 /* 87 /*
92 * Stop the TX queues in mac80211.
93 */
94 ieee80211_stop_queues(rt2x00dev->hw);
95 rt2x00queue_stop_queues(rt2x00dev);
96
97 /*
98 * Stop watchdog monitoring. 88 * Stop watchdog monitoring.
99 */ 89 */
100 rt2x00link_stop_watchdog(rt2x00dev); 90 rt2x00link_stop_watchdog(rt2x00dev);
101 91
102 /* 92 /*
103 * Disable RX. 93 * Stop all queues
104 */ 94 */
105 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF); 95 rt2x00link_stop_tuner(rt2x00dev);
96 rt2x00queue_stop_queues(rt2x00dev);
97 rt2x00queue_flush_queues(rt2x00dev, true);
106 98
107 /* 99 /*
108 * Disable radio. 100 * Disable radio.
@@ -113,41 +105,11 @@ void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev)
113 rt2x00leds_led_radio(rt2x00dev, false); 105 rt2x00leds_led_radio(rt2x00dev, false);
114} 106}
115 107
116void rt2x00lib_toggle_rx(struct rt2x00_dev *rt2x00dev, enum dev_state state)
117{
118 /*
119 * When we are disabling the RX, we should also stop the link tuner.
120 */
121 if (state == STATE_RADIO_RX_OFF)
122 rt2x00link_stop_tuner(rt2x00dev);
123
124 rt2x00dev->ops->lib->set_device_state(rt2x00dev, state);
125
126 /*
127 * When we are enabling the RX, we should also start the link tuner.
128 */
129 if (state == STATE_RADIO_RX_ON)
130 rt2x00link_start_tuner(rt2x00dev);
131}
132
133static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac, 108static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac,
134 struct ieee80211_vif *vif) 109 struct ieee80211_vif *vif)
135{ 110{
136 struct rt2x00_dev *rt2x00dev = data; 111 struct rt2x00_dev *rt2x00dev = data;
137 struct rt2x00_intf *intf = vif_to_intf(vif); 112 struct rt2x00_intf *intf = vif_to_intf(vif);
138 int delayed_flags;
139
140 /*
141 * Copy all data we need during this action under the protection
142 * of a spinlock. Otherwise race conditions might occur which results
143 * into an invalid configuration.
144 */
145 spin_lock(&intf->lock);
146
147 delayed_flags = intf->delayed_flags;
148 intf->delayed_flags = 0;
149
150 spin_unlock(&intf->lock);
151 113
152 /* 114 /*
153 * It is possible the radio was disabled while the work had been 115 * It is possible the radio was disabled while the work had been
@@ -158,7 +120,7 @@ static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac,
158 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) 120 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
159 return; 121 return;
160 122
161 if (delayed_flags & DELAYED_UPDATE_BEACON) 123 if (test_and_clear_bit(DELAYED_UPDATE_BEACON, &intf->delayed_flags))
162 rt2x00queue_update_beacon(rt2x00dev, vif, true); 124 rt2x00queue_update_beacon(rt2x00dev, vif, true);
163} 125}
164 126
@@ -251,8 +213,16 @@ void rt2x00lib_pretbtt(struct rt2x00_dev *rt2x00dev)
251} 213}
252EXPORT_SYMBOL_GPL(rt2x00lib_pretbtt); 214EXPORT_SYMBOL_GPL(rt2x00lib_pretbtt);
253 215
216void rt2x00lib_dmastart(struct queue_entry *entry)
217{
218 set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags);
219 rt2x00queue_index_inc(entry->queue, Q_INDEX);
220}
221EXPORT_SYMBOL_GPL(rt2x00lib_dmastart);
222
254void rt2x00lib_dmadone(struct queue_entry *entry) 223void rt2x00lib_dmadone(struct queue_entry *entry)
255{ 224{
225 set_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags);
256 clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags); 226 clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags);
257 rt2x00queue_index_inc(entry->queue, Q_INDEX_DMA_DONE); 227 rt2x00queue_index_inc(entry->queue, Q_INDEX_DMA_DONE);
258} 228}
@@ -264,11 +234,9 @@ void rt2x00lib_txdone(struct queue_entry *entry,
264 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 234 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
265 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); 235 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb);
266 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); 236 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
267 enum data_queue_qid qid = skb_get_queue_mapping(entry->skb); 237 unsigned int header_length, i;
268 unsigned int header_length = ieee80211_get_hdrlen_from_skb(entry->skb);
269 u8 rate_idx, rate_flags, retry_rates; 238 u8 rate_idx, rate_flags, retry_rates;
270 u8 skbdesc_flags = skbdesc->flags; 239 u8 skbdesc_flags = skbdesc->flags;
271 unsigned int i;
272 bool success; 240 bool success;
273 241
274 /* 242 /*
@@ -287,6 +255,11 @@ void rt2x00lib_txdone(struct queue_entry *entry,
287 skbdesc->flags &= ~SKBDESC_DESC_IN_SKB; 255 skbdesc->flags &= ~SKBDESC_DESC_IN_SKB;
288 256
289 /* 257 /*
258 * Determine the length of 802.11 header.
259 */
260 header_length = ieee80211_get_hdrlen_from_skb(entry->skb);
261
262 /*
290 * Remove L2 padding which was added during 263 * Remove L2 padding which was added during
291 */ 264 */
292 if (test_bit(DRIVER_REQUIRE_L2PAD, &rt2x00dev->flags)) 265 if (test_bit(DRIVER_REQUIRE_L2PAD, &rt2x00dev->flags))
@@ -390,9 +363,12 @@ void rt2x00lib_txdone(struct queue_entry *entry,
390 * through a mac80211 library call (RTS/CTS) then we should not 363 * through a mac80211 library call (RTS/CTS) then we should not
391 * send the status report back. 364 * send the status report back.
392 */ 365 */
393 if (!(skbdesc_flags & SKBDESC_NOT_MAC80211)) 366 if (!(skbdesc_flags & SKBDESC_NOT_MAC80211)) {
394 ieee80211_tx_status(rt2x00dev->hw, entry->skb); 367 if (test_bit(DRIVER_REQUIRE_TASKLET_CONTEXT, &rt2x00dev->flags))
395 else 368 ieee80211_tx_status(rt2x00dev->hw, entry->skb);
369 else
370 ieee80211_tx_status_ni(rt2x00dev->hw, entry->skb);
371 } else
396 dev_kfree_skb_any(entry->skb); 372 dev_kfree_skb_any(entry->skb);
397 373
398 /* 374 /*
@@ -411,7 +387,7 @@ void rt2x00lib_txdone(struct queue_entry *entry,
411 * is reenabled when the txdone handler has finished. 387 * is reenabled when the txdone handler has finished.
412 */ 388 */
413 if (!rt2x00queue_threshold(entry->queue)) 389 if (!rt2x00queue_threshold(entry->queue))
414 ieee80211_wake_queue(rt2x00dev->hw, qid); 390 rt2x00queue_unpause_queue(entry->queue);
415} 391}
416EXPORT_SYMBOL_GPL(rt2x00lib_txdone); 392EXPORT_SYMBOL_GPL(rt2x00lib_txdone);
417 393
@@ -483,6 +459,10 @@ void rt2x00lib_rxdone(struct queue_entry *entry)
483 unsigned int header_length; 459 unsigned int header_length;
484 int rate_idx; 460 int rate_idx;
485 461
462 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) ||
463 !test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
464 goto submit_entry;
465
486 if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags)) 466 if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags))
487 goto submit_entry; 467 goto submit_entry;
488 468
@@ -567,9 +547,11 @@ void rt2x00lib_rxdone(struct queue_entry *entry)
567 entry->skb = skb; 547 entry->skb = skb;
568 548
569submit_entry: 549submit_entry:
570 rt2x00dev->ops->lib->clear_entry(entry); 550 entry->flags = 0;
571 rt2x00queue_index_inc(entry->queue, Q_INDEX);
572 rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE); 551 rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE);
552 if (test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) &&
553 test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
554 rt2x00dev->ops->lib->clear_entry(entry);
573} 555}
574EXPORT_SYMBOL_GPL(rt2x00lib_rxdone); 556EXPORT_SYMBOL_GPL(rt2x00lib_rxdone);
575 557
@@ -678,7 +660,7 @@ static void rt2x00lib_rate(struct ieee80211_rate *entry,
678{ 660{
679 entry->flags = 0; 661 entry->flags = 0;
680 entry->bitrate = rate->bitrate; 662 entry->bitrate = rate->bitrate;
681 entry->hw_value =index; 663 entry->hw_value = index;
682 entry->hw_value_short = index; 664 entry->hw_value_short = index;
683 665
684 if (rate->flags & DEV_RATE_SHORT_PREAMBLE) 666 if (rate->flags & DEV_RATE_SHORT_PREAMBLE)
@@ -818,8 +800,7 @@ static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev)
818 /* 800 /*
819 * Allocate tx status FIFO for driver use. 801 * Allocate tx status FIFO for driver use.
820 */ 802 */
821 if (test_bit(DRIVER_REQUIRE_TXSTATUS_FIFO, &rt2x00dev->flags) && 803 if (test_bit(DRIVER_REQUIRE_TXSTATUS_FIFO, &rt2x00dev->flags)) {
822 rt2x00dev->ops->lib->txstatus_tasklet) {
823 /* 804 /*
824 * Allocate txstatus fifo and tasklet, we use a size of 512 805 * Allocate txstatus fifo and tasklet, we use a size of 512
825 * for the kfifo which is big enough to store 512/4=128 tx 806 * for the kfifo which is big enough to store 512/4=128 tx
@@ -833,9 +814,10 @@ static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev)
833 return status; 814 return status;
834 815
835 /* tasklet for processing the tx status reports. */ 816 /* tasklet for processing the tx status reports. */
836 tasklet_init(&rt2x00dev->txstatus_tasklet, 817 if (rt2x00dev->ops->lib->txstatus_tasklet)
837 rt2x00dev->ops->lib->txstatus_tasklet, 818 tasklet_init(&rt2x00dev->txstatus_tasklet,
838 (unsigned long)rt2x00dev); 819 rt2x00dev->ops->lib->txstatus_tasklet,
820 (unsigned long)rt2x00dev);
839 821
840 } 822 }
841 823
diff --git a/drivers/net/wireless/rt2x00/rt2x00ht.c b/drivers/net/wireless/rt2x00/rt2x00ht.c
index c637bcaec5f8..b7ad46ecaa1d 100644
--- a/drivers/net/wireless/rt2x00/rt2x00ht.c
+++ b/drivers/net/wireless/rt2x00/rt2x00ht.c
@@ -40,8 +40,6 @@ void rt2x00ht_create_tx_descriptor(struct queue_entry *entry,
40 if (tx_info->control.sta) 40 if (tx_info->control.sta)
41 txdesc->mpdu_density = 41 txdesc->mpdu_density =
42 tx_info->control.sta->ht_cap.ampdu_density; 42 tx_info->control.sta->ht_cap.ampdu_density;
43 else
44 txdesc->mpdu_density = 0;
45 43
46 txdesc->ba_size = 7; /* FIXME: What value is needed? */ 44 txdesc->ba_size = 7; /* FIXME: What value is needed? */
47 45
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
index 619da23b7b56..a105c500627b 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -57,7 +57,7 @@ static inline const struct rt2x00_rate *rt2x00_get_rate(const u16 hw_value)
57} 57}
58 58
59#define RATE_MCS(__mode, __mcs) \ 59#define RATE_MCS(__mode, __mcs) \
60 ( (((__mode) & 0x00ff) << 8) | ((__mcs) & 0x00ff) ) 60 ((((__mode) & 0x00ff) << 8) | ((__mcs) & 0x00ff))
61 61
62static inline int rt2x00_get_rate_mcs(const u16 mcs_value) 62static inline int rt2x00_get_rate_mcs(const u16 mcs_value)
63{ 63{
@@ -69,7 +69,6 @@ static inline int rt2x00_get_rate_mcs(const u16 mcs_value)
69 */ 69 */
70int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev); 70int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev);
71void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev); 71void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev);
72void rt2x00lib_toggle_rx(struct rt2x00_dev *rt2x00dev, enum dev_state state);
73 72
74/* 73/*
75 * Initialization handlers. 74 * Initialization handlers.
@@ -179,15 +178,6 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
179void rt2x00queue_index_inc(struct data_queue *queue, enum queue_index index); 178void rt2x00queue_index_inc(struct data_queue *queue, enum queue_index index);
180 179
181/** 180/**
182 * rt2x00queue_stop_queues - Halt all data queues
183 * @rt2x00dev: Pointer to &struct rt2x00_dev.
184 *
185 * This function will loop through all available queues to stop
186 * any pending outgoing frames.
187 */
188void rt2x00queue_stop_queues(struct rt2x00_dev *rt2x00dev);
189
190/**
191 * rt2x00queue_init_queues - Initialize all data queues 181 * rt2x00queue_init_queues - Initialize all data queues
192 * @rt2x00dev: Pointer to &struct rt2x00_dev. 182 * @rt2x00dev: Pointer to &struct rt2x00_dev.
193 * 183 *
diff --git a/drivers/net/wireless/rt2x00/rt2x00link.c b/drivers/net/wireless/rt2x00/rt2x00link.c
index b971d8798ebf..bfda60eaf4ef 100644
--- a/drivers/net/wireless/rt2x00/rt2x00link.c
+++ b/drivers/net/wireless/rt2x00/rt2x00link.c
@@ -67,7 +67,7 @@
67 (__avg).avg_weight ? \ 67 (__avg).avg_weight ? \
68 ((((__avg).avg_weight * ((AVG_SAMPLES) - 1)) + \ 68 ((((__avg).avg_weight * ((AVG_SAMPLES) - 1)) + \
69 ((__val) * (AVG_FACTOR))) / \ 69 ((__val) * (AVG_FACTOR))) / \
70 (AVG_SAMPLES) ) : \ 70 (AVG_SAMPLES)) : \
71 ((__val) * (AVG_FACTOR)); \ 71 ((__val) * (AVG_FACTOR)); \
72 __new.avg = __new.avg_weight / (AVG_FACTOR); \ 72 __new.avg = __new.avg_weight / (AVG_FACTOR); \
73 __new; \ 73 __new; \
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index c3c206a97d54..f3da051df39e 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -104,7 +104,7 @@ int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
104 struct rt2x00_dev *rt2x00dev = hw->priv; 104 struct rt2x00_dev *rt2x00dev = hw->priv;
105 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 105 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
106 enum data_queue_qid qid = skb_get_queue_mapping(skb); 106 enum data_queue_qid qid = skb_get_queue_mapping(skb);
107 struct data_queue *queue; 107 struct data_queue *queue = NULL;
108 108
109 /* 109 /*
110 * Mac80211 might be calling this function while we are trying 110 * Mac80211 might be calling this function while we are trying
@@ -153,7 +153,7 @@ int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
153 goto exit_fail; 153 goto exit_fail;
154 154
155 if (rt2x00queue_threshold(queue)) 155 if (rt2x00queue_threshold(queue))
156 ieee80211_stop_queue(rt2x00dev->hw, qid); 156 rt2x00queue_pause_queue(queue);
157 157
158 return NETDEV_TX_OK; 158 return NETDEV_TX_OK;
159 159
@@ -268,13 +268,12 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw,
268 else 268 else
269 rt2x00dev->intf_sta_count++; 269 rt2x00dev->intf_sta_count++;
270 270
271 spin_lock_init(&intf->lock);
272 spin_lock_init(&intf->seqlock); 271 spin_lock_init(&intf->seqlock);
273 mutex_init(&intf->beacon_skb_mutex); 272 mutex_init(&intf->beacon_skb_mutex);
274 intf->beacon = entry; 273 intf->beacon = entry;
275 274
276 /* 275 /*
277 * The MAC adddress must be configured after the device 276 * The MAC address must be configured after the device
278 * has been initialized. Otherwise the device can reset 277 * has been initialized. Otherwise the device can reset
279 * the MAC registers. 278 * the MAC registers.
280 * The BSSID address must only be configured in AP mode, 279 * The BSSID address must only be configured in AP mode,
@@ -282,15 +281,8 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw,
282 * STA interfaces at this time, since this can cause 281 * STA interfaces at this time, since this can cause
283 * invalid behavior in the device. 282 * invalid behavior in the device.
284 */ 283 */
285 memcpy(&intf->mac, vif->addr, ETH_ALEN); 284 rt2x00lib_config_intf(rt2x00dev, intf, vif->type,
286 if (vif->type == NL80211_IFTYPE_AP) { 285 vif->addr, NULL);
287 memcpy(&intf->bssid, vif->addr, ETH_ALEN);
288 rt2x00lib_config_intf(rt2x00dev, intf, vif->type,
289 intf->mac, intf->bssid);
290 } else {
291 rt2x00lib_config_intf(rt2x00dev, intf, vif->type,
292 intf->mac, NULL);
293 }
294 286
295 /* 287 /*
296 * Some filters depend on the current working mode. We can force 288 * Some filters depend on the current working mode. We can force
@@ -358,7 +350,7 @@ int rt2x00mac_config(struct ieee80211_hw *hw, u32 changed)
358 * if for any reason the link tuner must be reset, this will be 350 * if for any reason the link tuner must be reset, this will be
359 * handled by rt2x00lib_config(). 351 * handled by rt2x00lib_config().
360 */ 352 */
361 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF_LINK); 353 rt2x00queue_stop_queue(rt2x00dev->rx);
362 354
363 /* 355 /*
364 * When we've just turned on the radio, we want to reprogram 356 * When we've just turned on the radio, we want to reprogram
@@ -376,7 +368,7 @@ int rt2x00mac_config(struct ieee80211_hw *hw, u32 changed)
376 rt2x00lib_config_antenna(rt2x00dev, rt2x00dev->default_ant); 368 rt2x00lib_config_antenna(rt2x00dev, rt2x00dev->default_ant);
377 369
378 /* Turn RX back on */ 370 /* Turn RX back on */
379 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON_LINK); 371 rt2x00queue_start_queue(rt2x00dev->rx);
380 372
381 return 0; 373 return 0;
382} 374}
@@ -451,9 +443,7 @@ static void rt2x00mac_set_tim_iter(void *data, u8 *mac,
451 vif->type != NL80211_IFTYPE_WDS) 443 vif->type != NL80211_IFTYPE_WDS)
452 return; 444 return;
453 445
454 spin_lock(&intf->lock); 446 set_bit(DELAYED_UPDATE_BEACON, &intf->delayed_flags);
455 intf->delayed_flags |= DELAYED_UPDATE_BEACON;
456 spin_unlock(&intf->lock);
457} 447}
458 448
459int rt2x00mac_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, 449int rt2x00mac_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
@@ -478,17 +468,17 @@ EXPORT_SYMBOL_GPL(rt2x00mac_set_tim);
478static void memcpy_tkip(struct rt2x00lib_crypto *crypto, u8 *key, u8 key_len) 468static void memcpy_tkip(struct rt2x00lib_crypto *crypto, u8 *key, u8 key_len)
479{ 469{
480 if (key_len > NL80211_TKIP_DATA_OFFSET_ENCR_KEY) 470 if (key_len > NL80211_TKIP_DATA_OFFSET_ENCR_KEY)
481 memcpy(&crypto->key, 471 memcpy(crypto->key,
482 &key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY], 472 &key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY],
483 sizeof(crypto->key)); 473 sizeof(crypto->key));
484 474
485 if (key_len > NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY) 475 if (key_len > NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY)
486 memcpy(&crypto->tx_mic, 476 memcpy(crypto->tx_mic,
487 &key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY], 477 &key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY],
488 sizeof(crypto->tx_mic)); 478 sizeof(crypto->tx_mic));
489 479
490 if (key_len > NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY) 480 if (key_len > NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY)
491 memcpy(&crypto->rx_mic, 481 memcpy(crypto->rx_mic,
492 &key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY], 482 &key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY],
493 sizeof(crypto->rx_mic)); 483 sizeof(crypto->rx_mic));
494} 484}
@@ -498,7 +488,6 @@ int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
498 struct ieee80211_key_conf *key) 488 struct ieee80211_key_conf *key)
499{ 489{
500 struct rt2x00_dev *rt2x00dev = hw->priv; 490 struct rt2x00_dev *rt2x00dev = hw->priv;
501 struct rt2x00_intf *intf = vif_to_intf(vif);
502 int (*set_key) (struct rt2x00_dev *rt2x00dev, 491 int (*set_key) (struct rt2x00_dev *rt2x00dev,
503 struct rt2x00lib_crypto *crypto, 492 struct rt2x00lib_crypto *crypto,
504 struct ieee80211_key_conf *key); 493 struct ieee80211_key_conf *key);
@@ -522,7 +511,7 @@ int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
522 if (rt2x00dev->intf_sta_count) 511 if (rt2x00dev->intf_sta_count)
523 crypto.bssidx = 0; 512 crypto.bssidx = 0;
524 else 513 else
525 crypto.bssidx = intf->mac[5] & (rt2x00dev->ops->max_ap_intf - 1); 514 crypto.bssidx = vif->addr[5] & (rt2x00dev->ops->max_ap_intf - 1);
526 515
527 crypto.cipher = rt2x00crypto_key_to_cipher(key); 516 crypto.cipher = rt2x00crypto_key_to_cipher(key);
528 if (crypto.cipher == CIPHER_NONE) 517 if (crypto.cipher == CIPHER_NONE)
@@ -540,7 +529,7 @@ int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
540 if (crypto.cipher == CIPHER_TKIP) 529 if (crypto.cipher == CIPHER_TKIP)
541 memcpy_tkip(&crypto, &key->key[0], key->keylen); 530 memcpy_tkip(&crypto, &key->key[0], key->keylen);
542 else 531 else
543 memcpy(&crypto.key, &key->key[0], key->keylen); 532 memcpy(crypto.key, &key->key[0], key->keylen);
544 /* 533 /*
545 * Each BSS has a maximum of 4 shared keys. 534 * Each BSS has a maximum of 4 shared keys.
546 * Shared key index values: 535 * Shared key index values:
@@ -620,22 +609,8 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
620 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags)) 609 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
621 return; 610 return;
622 611
623 spin_lock(&intf->lock);
624
625 /* 612 /*
626 * conf->bssid can be NULL if coming from the internal 613 * Update the BSSID.
627 * beacon update routine.
628 */
629 if (changes & BSS_CHANGED_BSSID)
630 memcpy(&intf->bssid, bss_conf->bssid, ETH_ALEN);
631
632 spin_unlock(&intf->lock);
633
634 /*
635 * Call rt2x00_config_intf() outside of the spinlock context since
636 * the call will sleep for USB drivers. By using the ieee80211_if_conf
637 * values as arguments we make keep access to rt2x00_intf thread safe
638 * even without the lock.
639 */ 614 */
640 if (changes & BSS_CHANGED_BSSID) 615 if (changes & BSS_CHANGED_BSSID)
641 rt2x00lib_config_intf(rt2x00dev, intf, vif->type, NULL, 616 rt2x00lib_config_intf(rt2x00dev, intf, vif->type, NULL,
@@ -719,3 +694,13 @@ void rt2x00mac_rfkill_poll(struct ieee80211_hw *hw)
719 wiphy_rfkill_set_hw_state(hw->wiphy, !active); 694 wiphy_rfkill_set_hw_state(hw->wiphy, !active);
720} 695}
721EXPORT_SYMBOL_GPL(rt2x00mac_rfkill_poll); 696EXPORT_SYMBOL_GPL(rt2x00mac_rfkill_poll);
697
698void rt2x00mac_flush(struct ieee80211_hw *hw, bool drop)
699{
700 struct rt2x00_dev *rt2x00dev = hw->priv;
701 struct data_queue *queue;
702
703 tx_queue_for_each(rt2x00dev, queue)
704 rt2x00queue_flush_queue(queue, drop);
705}
706EXPORT_SYMBOL_GPL(rt2x00mac_flush);
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c
index 4fd4c33de6ae..ace0b668c04e 100644
--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
+++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
@@ -82,6 +82,13 @@ void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev)
82 skbdesc->desc_len = entry->queue->desc_size; 82 skbdesc->desc_len = entry->queue->desc_size;
83 83
84 /* 84 /*
85 * DMA is already done, notify rt2x00lib that
86 * it finished successfully.
87 */
88 rt2x00lib_dmastart(entry);
89 rt2x00lib_dmadone(entry);
90
91 /*
85 * Send the frame to rt2x00lib for further processing. 92 * Send the frame to rt2x00lib for further processing.
86 */ 93 */
87 rt2x00lib_rxdone(entry); 94 rt2x00lib_rxdone(entry);
@@ -105,7 +112,7 @@ static int rt2x00pci_alloc_queue_dma(struct rt2x00_dev *rt2x00dev,
105 */ 112 */
106 addr = dma_alloc_coherent(rt2x00dev->dev, 113 addr = dma_alloc_coherent(rt2x00dev->dev,
107 queue->limit * queue->desc_size, 114 queue->limit * queue->desc_size,
108 &dma, GFP_KERNEL | GFP_DMA); 115 &dma, GFP_KERNEL);
109 if (!addr) 116 if (!addr)
110 return -ENOMEM; 117 return -ENOMEM;
111 118
@@ -279,7 +286,7 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
279 rt2x00dev->irq = pci_dev->irq; 286 rt2x00dev->irq = pci_dev->irq;
280 rt2x00dev->name = pci_name(pci_dev); 287 rt2x00dev->name = pci_name(pci_dev);
281 288
282 if (pci_dev->is_pcie) 289 if (pci_is_pcie(pci_dev))
283 rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_PCIE); 290 rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_PCIE);
284 else 291 else
285 rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_PCI); 292 rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_PCI);
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.h b/drivers/net/wireless/rt2x00/rt2x00pci.h
index b854d62ff99b..746ce8fe8cf4 100644
--- a/drivers/net/wireless/rt2x00/rt2x00pci.h
+++ b/drivers/net/wireless/rt2x00/rt2x00pci.h
@@ -64,7 +64,7 @@ static inline void rt2x00pci_register_multiwrite(struct rt2x00_dev *rt2x00dev,
64 const void *value, 64 const void *value,
65 const u32 length) 65 const u32 length)
66{ 66{
67 memcpy_toio(rt2x00dev->csr.base + offset, value, length); 67 __iowrite32_copy(rt2x00dev->csr.base + offset, value, length >> 2);
68} 68}
69 69
70/** 70/**
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index e360d287defb..ca82b3a91697 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -199,7 +199,12 @@ void rt2x00queue_insert_l2pad(struct sk_buff *skb, unsigned int header_length)
199 199
200void rt2x00queue_remove_l2pad(struct sk_buff *skb, unsigned int header_length) 200void rt2x00queue_remove_l2pad(struct sk_buff *skb, unsigned int header_length)
201{ 201{
202 unsigned int l2pad = L2PAD_SIZE(header_length); 202 /*
203 * L2 padding is only present if the skb contains more than just the
204 * IEEE 802.11 header.
205 */
206 unsigned int l2pad = (skb->len > header_length) ?
207 L2PAD_SIZE(header_length) : 0;
203 208
204 if (!l2pad) 209 if (!l2pad)
205 return; 210 return;
@@ -311,14 +316,6 @@ static void rt2x00queue_create_tx_descriptor(struct queue_entry *entry,
311 memset(txdesc, 0, sizeof(*txdesc)); 316 memset(txdesc, 0, sizeof(*txdesc));
312 317
313 /* 318 /*
314 * Initialize information from queue
315 */
316 txdesc->qid = entry->queue->qid;
317 txdesc->cw_min = entry->queue->cw_min;
318 txdesc->cw_max = entry->queue->cw_max;
319 txdesc->aifs = entry->queue->aifs;
320
321 /*
322 * Header and frame information. 319 * Header and frame information.
323 */ 320 */
324 txdesc->length = entry->skb->len; 321 txdesc->length = entry->skb->len;
@@ -460,12 +457,9 @@ static void rt2x00queue_write_tx_descriptor(struct queue_entry *entry,
460 rt2x00debug_dump_frame(queue->rt2x00dev, DUMP_FRAME_TX, entry->skb); 457 rt2x00debug_dump_frame(queue->rt2x00dev, DUMP_FRAME_TX, entry->skb);
461} 458}
462 459
463static void rt2x00queue_kick_tx_queue(struct queue_entry *entry, 460static void rt2x00queue_kick_tx_queue(struct data_queue *queue,
464 struct txentry_desc *txdesc) 461 struct txentry_desc *txdesc)
465{ 462{
466 struct data_queue *queue = entry->queue;
467 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
468
469 /* 463 /*
470 * Check if we need to kick the queue, there are however a few rules 464 * Check if we need to kick the queue, there are however a few rules
471 * 1) Don't kick unless this is the last in frame in a burst. 465 * 1) Don't kick unless this is the last in frame in a burst.
@@ -477,7 +471,7 @@ static void rt2x00queue_kick_tx_queue(struct queue_entry *entry,
477 */ 471 */
478 if (rt2x00queue_threshold(queue) || 472 if (rt2x00queue_threshold(queue) ||
479 !test_bit(ENTRY_TXD_BURST, &txdesc->flags)) 473 !test_bit(ENTRY_TXD_BURST, &txdesc->flags))
480 rt2x00dev->ops->lib->kick_tx_queue(queue); 474 queue->rt2x00dev->ops->lib->kick_queue(queue);
481} 475}
482 476
483int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb, 477int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
@@ -567,7 +561,7 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
567 561
568 rt2x00queue_index_inc(queue, Q_INDEX); 562 rt2x00queue_index_inc(queue, Q_INDEX);
569 rt2x00queue_write_tx_descriptor(entry, &txdesc); 563 rt2x00queue_write_tx_descriptor(entry, &txdesc);
570 rt2x00queue_kick_tx_queue(entry, &txdesc); 564 rt2x00queue_kick_tx_queue(queue, &txdesc);
571 565
572 return 0; 566 return 0;
573} 567}
@@ -591,7 +585,7 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
591 rt2x00queue_free_skb(intf->beacon); 585 rt2x00queue_free_skb(intf->beacon);
592 586
593 if (!enable_beacon) { 587 if (!enable_beacon) {
594 rt2x00dev->ops->lib->kill_tx_queue(intf->beacon->queue); 588 rt2x00queue_stop_queue(intf->beacon->queue);
595 mutex_unlock(&intf->beacon_skb_mutex); 589 mutex_unlock(&intf->beacon_skb_mutex);
596 return 0; 590 return 0;
597 } 591 }
@@ -649,10 +643,10 @@ void rt2x00queue_for_each_entry(struct data_queue *queue,
649 * it should not be kicked during this run, since it 643 * it should not be kicked during this run, since it
650 * is part of another TX operation. 644 * is part of another TX operation.
651 */ 645 */
652 spin_lock_irqsave(&queue->lock, irqflags); 646 spin_lock_irqsave(&queue->index_lock, irqflags);
653 index_start = queue->index[start]; 647 index_start = queue->index[start];
654 index_end = queue->index[end]; 648 index_end = queue->index[end];
655 spin_unlock_irqrestore(&queue->lock, irqflags); 649 spin_unlock_irqrestore(&queue->index_lock, irqflags);
656 650
657 /* 651 /*
658 * Start from the TX done pointer, this guarentees that we will 652 * Start from the TX done pointer, this guarentees that we will
@@ -706,11 +700,11 @@ struct queue_entry *rt2x00queue_get_entry(struct data_queue *queue,
706 return NULL; 700 return NULL;
707 } 701 }
708 702
709 spin_lock_irqsave(&queue->lock, irqflags); 703 spin_lock_irqsave(&queue->index_lock, irqflags);
710 704
711 entry = &queue->entries[queue->index[index]]; 705 entry = &queue->entries[queue->index[index]];
712 706
713 spin_unlock_irqrestore(&queue->lock, irqflags); 707 spin_unlock_irqrestore(&queue->index_lock, irqflags);
714 708
715 return entry; 709 return entry;
716} 710}
@@ -726,7 +720,7 @@ void rt2x00queue_index_inc(struct data_queue *queue, enum queue_index index)
726 return; 720 return;
727 } 721 }
728 722
729 spin_lock_irqsave(&queue->lock, irqflags); 723 spin_lock_irqsave(&queue->index_lock, irqflags);
730 724
731 queue->index[index]++; 725 queue->index[index]++;
732 if (queue->index[index] >= queue->limit) 726 if (queue->index[index] >= queue->limit)
@@ -741,15 +735,219 @@ void rt2x00queue_index_inc(struct data_queue *queue, enum queue_index index)
741 queue->count++; 735 queue->count++;
742 } 736 }
743 737
744 spin_unlock_irqrestore(&queue->lock, irqflags); 738 spin_unlock_irqrestore(&queue->index_lock, irqflags);
745} 739}
746 740
741void rt2x00queue_pause_queue(struct data_queue *queue)
742{
743 if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
744 !test_bit(QUEUE_STARTED, &queue->flags) ||
745 test_and_set_bit(QUEUE_PAUSED, &queue->flags))
746 return;
747
748 switch (queue->qid) {
749 case QID_AC_VO:
750 case QID_AC_VI:
751 case QID_AC_BE:
752 case QID_AC_BK:
753 /*
754 * For TX queues, we have to disable the queue
755 * inside mac80211.
756 */
757 ieee80211_stop_queue(queue->rt2x00dev->hw, queue->qid);
758 break;
759 default:
760 break;
761 }
762}
763EXPORT_SYMBOL_GPL(rt2x00queue_pause_queue);
764
765void rt2x00queue_unpause_queue(struct data_queue *queue)
766{
767 if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
768 !test_bit(QUEUE_STARTED, &queue->flags) ||
769 !test_and_clear_bit(QUEUE_PAUSED, &queue->flags))
770 return;
771
772 switch (queue->qid) {
773 case QID_AC_VO:
774 case QID_AC_VI:
775 case QID_AC_BE:
776 case QID_AC_BK:
777 /*
778 * For TX queues, we have to enable the queue
779 * inside mac80211.
780 */
781 ieee80211_wake_queue(queue->rt2x00dev->hw, queue->qid);
782 break;
783 case QID_RX:
784 /*
785 * For RX we need to kick the queue now in order to
786 * receive frames.
787 */
788 queue->rt2x00dev->ops->lib->kick_queue(queue);
789 default:
790 break;
791 }
792}
793EXPORT_SYMBOL_GPL(rt2x00queue_unpause_queue);
794
795void rt2x00queue_start_queue(struct data_queue *queue)
796{
797 mutex_lock(&queue->status_lock);
798
799 if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
800 test_and_set_bit(QUEUE_STARTED, &queue->flags)) {
801 mutex_unlock(&queue->status_lock);
802 return;
803 }
804
805 set_bit(QUEUE_PAUSED, &queue->flags);
806
807 queue->rt2x00dev->ops->lib->start_queue(queue);
808
809 rt2x00queue_unpause_queue(queue);
810
811 mutex_unlock(&queue->status_lock);
812}
813EXPORT_SYMBOL_GPL(rt2x00queue_start_queue);
814
815void rt2x00queue_stop_queue(struct data_queue *queue)
816{
817 mutex_lock(&queue->status_lock);
818
819 if (!test_and_clear_bit(QUEUE_STARTED, &queue->flags)) {
820 mutex_unlock(&queue->status_lock);
821 return;
822 }
823
824 rt2x00queue_pause_queue(queue);
825
826 queue->rt2x00dev->ops->lib->stop_queue(queue);
827
828 mutex_unlock(&queue->status_lock);
829}
830EXPORT_SYMBOL_GPL(rt2x00queue_stop_queue);
831
832void rt2x00queue_flush_queue(struct data_queue *queue, bool drop)
833{
834 unsigned int i;
835 bool started;
836 bool tx_queue =
837 (queue->qid == QID_AC_VO) ||
838 (queue->qid == QID_AC_VI) ||
839 (queue->qid == QID_AC_BE) ||
840 (queue->qid == QID_AC_BK);
841
842 mutex_lock(&queue->status_lock);
843
844 /*
845 * If the queue has been started, we must stop it temporarily
846 * to prevent any new frames to be queued on the device. If
847 * we are not dropping the pending frames, the queue must
848 * only be stopped in the software and not the hardware,
849 * otherwise the queue will never become empty on its own.
850 */
851 started = test_bit(QUEUE_STARTED, &queue->flags);
852 if (started) {
853 /*
854 * Pause the queue
855 */
856 rt2x00queue_pause_queue(queue);
857
858 /*
859 * If we are not supposed to drop any pending
860 * frames, this means we must force a start (=kick)
861 * to the queue to make sure the hardware will
862 * start transmitting.
863 */
864 if (!drop && tx_queue)
865 queue->rt2x00dev->ops->lib->kick_queue(queue);
866 }
867
868 /*
869 * Check if driver supports flushing, we can only guarentee
870 * full support for flushing if the driver is able
871 * to cancel all pending frames (drop = true).
872 */
873 if (drop && queue->rt2x00dev->ops->lib->flush_queue)
874 queue->rt2x00dev->ops->lib->flush_queue(queue);
875
876 /*
877 * When we don't want to drop any frames, or when
878 * the driver doesn't fully flush the queue correcly,
879 * we must wait for the queue to become empty.
880 */
881 for (i = 0; !rt2x00queue_empty(queue) && i < 100; i++)
882 msleep(10);
883
884 /*
885 * The queue flush has failed...
886 */
887 if (unlikely(!rt2x00queue_empty(queue)))
888 WARNING(queue->rt2x00dev, "Queue %d failed to flush", queue->qid);
889
890 /*
891 * Restore the queue to the previous status
892 */
893 if (started)
894 rt2x00queue_unpause_queue(queue);
895
896 mutex_unlock(&queue->status_lock);
897}
898EXPORT_SYMBOL_GPL(rt2x00queue_flush_queue);
899
900void rt2x00queue_start_queues(struct rt2x00_dev *rt2x00dev)
901{
902 struct data_queue *queue;
903
904 /*
905 * rt2x00queue_start_queue will call ieee80211_wake_queue
906 * for each queue after is has been properly initialized.
907 */
908 tx_queue_for_each(rt2x00dev, queue)
909 rt2x00queue_start_queue(queue);
910
911 rt2x00queue_start_queue(rt2x00dev->rx);
912}
913EXPORT_SYMBOL_GPL(rt2x00queue_start_queues);
914
915void rt2x00queue_stop_queues(struct rt2x00_dev *rt2x00dev)
916{
917 struct data_queue *queue;
918
919 /*
920 * rt2x00queue_stop_queue will call ieee80211_stop_queue
921 * as well, but we are completely shutting doing everything
922 * now, so it is much safer to stop all TX queues at once,
923 * and use rt2x00queue_stop_queue for cleaning up.
924 */
925 ieee80211_stop_queues(rt2x00dev->hw);
926
927 tx_queue_for_each(rt2x00dev, queue)
928 rt2x00queue_stop_queue(queue);
929
930 rt2x00queue_stop_queue(rt2x00dev->rx);
931}
932EXPORT_SYMBOL_GPL(rt2x00queue_stop_queues);
933
934void rt2x00queue_flush_queues(struct rt2x00_dev *rt2x00dev, bool drop)
935{
936 struct data_queue *queue;
937
938 tx_queue_for_each(rt2x00dev, queue)
939 rt2x00queue_flush_queue(queue, drop);
940
941 rt2x00queue_flush_queue(rt2x00dev->rx, drop);
942}
943EXPORT_SYMBOL_GPL(rt2x00queue_flush_queues);
944
747static void rt2x00queue_reset(struct data_queue *queue) 945static void rt2x00queue_reset(struct data_queue *queue)
748{ 946{
749 unsigned long irqflags; 947 unsigned long irqflags;
750 unsigned int i; 948 unsigned int i;
751 949
752 spin_lock_irqsave(&queue->lock, irqflags); 950 spin_lock_irqsave(&queue->index_lock, irqflags);
753 951
754 queue->count = 0; 952 queue->count = 0;
755 queue->length = 0; 953 queue->length = 0;
@@ -759,15 +957,7 @@ static void rt2x00queue_reset(struct data_queue *queue)
759 queue->last_action[i] = jiffies; 957 queue->last_action[i] = jiffies;
760 } 958 }
761 959
762 spin_unlock_irqrestore(&queue->lock, irqflags); 960 spin_unlock_irqrestore(&queue->index_lock, irqflags);
763}
764
765void rt2x00queue_stop_queues(struct rt2x00_dev *rt2x00dev)
766{
767 struct data_queue *queue;
768
769 txall_queue_for_each(rt2x00dev, queue)
770 rt2x00dev->ops->lib->kill_tx_queue(queue);
771} 961}
772 962
773void rt2x00queue_init_queues(struct rt2x00_dev *rt2x00dev) 963void rt2x00queue_init_queues(struct rt2x00_dev *rt2x00dev)
@@ -778,11 +968,8 @@ void rt2x00queue_init_queues(struct rt2x00_dev *rt2x00dev)
778 queue_for_each(rt2x00dev, queue) { 968 queue_for_each(rt2x00dev, queue) {
779 rt2x00queue_reset(queue); 969 rt2x00queue_reset(queue);
780 970
781 for (i = 0; i < queue->limit; i++) { 971 for (i = 0; i < queue->limit; i++)
782 rt2x00dev->ops->lib->clear_entry(&queue->entries[i]); 972 rt2x00dev->ops->lib->clear_entry(&queue->entries[i]);
783 if (queue->qid == QID_RX)
784 rt2x00queue_index_inc(queue, Q_INDEX);
785 }
786 } 973 }
787} 974}
788 975
@@ -809,8 +996,8 @@ static int rt2x00queue_alloc_entries(struct data_queue *queue,
809 return -ENOMEM; 996 return -ENOMEM;
810 997
811#define QUEUE_ENTRY_PRIV_OFFSET(__base, __index, __limit, __esize, __psize) \ 998#define QUEUE_ENTRY_PRIV_OFFSET(__base, __index, __limit, __esize, __psize) \
812 ( ((char *)(__base)) + ((__limit) * (__esize)) + \ 999 (((char *)(__base)) + ((__limit) * (__esize)) + \
813 ((__index) * (__psize)) ) 1000 ((__index) * (__psize)))
814 1001
815 for (i = 0; i < queue->limit; i++) { 1002 for (i = 0; i < queue->limit; i++) {
816 entries[i].flags = 0; 1003 entries[i].flags = 0;
@@ -911,7 +1098,8 @@ void rt2x00queue_uninitialize(struct rt2x00_dev *rt2x00dev)
911static void rt2x00queue_init(struct rt2x00_dev *rt2x00dev, 1098static void rt2x00queue_init(struct rt2x00_dev *rt2x00dev,
912 struct data_queue *queue, enum data_queue_qid qid) 1099 struct data_queue *queue, enum data_queue_qid qid)
913{ 1100{
914 spin_lock_init(&queue->lock); 1101 mutex_init(&queue->status_lock);
1102 spin_lock_init(&queue->index_lock);
915 1103
916 queue->rt2x00dev = rt2x00dev; 1104 queue->rt2x00dev = rt2x00dev;
917 queue->qid = qid; 1105 queue->qid = qid;
@@ -953,7 +1141,7 @@ int rt2x00queue_allocate(struct rt2x00_dev *rt2x00dev)
953 /* 1141 /*
954 * Initialize queue parameters. 1142 * Initialize queue parameters.
955 * RX: qid = QID_RX 1143 * RX: qid = QID_RX
956 * TX: qid = QID_AC_BE + index 1144 * TX: qid = QID_AC_VO + index
957 * TX: cw_min: 2^5 = 32. 1145 * TX: cw_min: 2^5 = 32.
958 * TX: cw_max: 2^10 = 1024. 1146 * TX: cw_max: 2^10 = 1024.
959 * BCN: qid = QID_BEACON 1147 * BCN: qid = QID_BEACON
@@ -961,7 +1149,7 @@ int rt2x00queue_allocate(struct rt2x00_dev *rt2x00dev)
961 */ 1149 */
962 rt2x00queue_init(rt2x00dev, rt2x00dev->rx, QID_RX); 1150 rt2x00queue_init(rt2x00dev, rt2x00dev->rx, QID_RX);
963 1151
964 qid = QID_AC_BE; 1152 qid = QID_AC_VO;
965 tx_queue_for_each(rt2x00dev, queue) 1153 tx_queue_for_each(rt2x00dev, queue)
966 rt2x00queue_init(rt2x00dev, queue, qid++); 1154 rt2x00queue_init(rt2x00dev, queue, qid++);
967 1155
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.h b/drivers/net/wireless/rt2x00/rt2x00queue.h
index d81d85f34866..fab8e2687f29 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.h
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.h
@@ -43,28 +43,12 @@
43#define AGGREGATION_SIZE 3840 43#define AGGREGATION_SIZE 3840
44 44
45/** 45/**
46 * DOC: Number of entries per queue
47 *
48 * Under normal load without fragmentation, 12 entries are sufficient
49 * without the queue being filled up to the maximum. When using fragmentation
50 * and the queue threshold code, we need to add some additional margins to
51 * make sure the queue will never (or only under extreme load) fill up
52 * completely.
53 * Since we don't use preallocated DMA, having a large number of queue entries
54 * will have minimal impact on the memory requirements for the queue.
55 */
56#define RX_ENTRIES 24
57#define TX_ENTRIES 24
58#define BEACON_ENTRIES 1
59#define ATIM_ENTRIES 8
60
61/**
62 * enum data_queue_qid: Queue identification 46 * enum data_queue_qid: Queue identification
63 * 47 *
48 * @QID_AC_VO: AC VO queue
49 * @QID_AC_VI: AC VI queue
64 * @QID_AC_BE: AC BE queue 50 * @QID_AC_BE: AC BE queue
65 * @QID_AC_BK: AC BK queue 51 * @QID_AC_BK: AC BK queue
66 * @QID_AC_VI: AC VI queue
67 * @QID_AC_VO: AC VO queue
68 * @QID_HCCA: HCCA queue 52 * @QID_HCCA: HCCA queue
69 * @QID_MGMT: MGMT queue (prio queue) 53 * @QID_MGMT: MGMT queue (prio queue)
70 * @QID_RX: RX queue 54 * @QID_RX: RX queue
@@ -73,10 +57,10 @@
73 * @QID_ATIM: Atim queue (value unspeficied, don't send it to device) 57 * @QID_ATIM: Atim queue (value unspeficied, don't send it to device)
74 */ 58 */
75enum data_queue_qid { 59enum data_queue_qid {
76 QID_AC_BE = 0, 60 QID_AC_VO = 0,
77 QID_AC_BK = 1, 61 QID_AC_VI = 1,
78 QID_AC_VI = 2, 62 QID_AC_BE = 2,
79 QID_AC_VO = 3, 63 QID_AC_BK = 3,
80 QID_HCCA = 4, 64 QID_HCCA = 4,
81 QID_MGMT = 13, 65 QID_MGMT = 13,
82 QID_RX = 14, 66 QID_RX = 14,
@@ -296,7 +280,6 @@ enum txentry_desc_flags {
296 * Summary of information for the frame descriptor before sending a TX frame. 280 * Summary of information for the frame descriptor before sending a TX frame.
297 * 281 *
298 * @flags: Descriptor flags (See &enum queue_entry_flags). 282 * @flags: Descriptor flags (See &enum queue_entry_flags).
299 * @qid: Queue identification (See &enum data_queue_qid).
300 * @length: Length of the entire frame. 283 * @length: Length of the entire frame.
301 * @header_length: Length of 802.11 header. 284 * @header_length: Length of 802.11 header.
302 * @length_high: PLCP length high word. 285 * @length_high: PLCP length high word.
@@ -309,11 +292,8 @@ enum txentry_desc_flags {
309 * @rate_mode: Rate mode (See @enum rate_modulation). 292 * @rate_mode: Rate mode (See @enum rate_modulation).
310 * @mpdu_density: MDPU density. 293 * @mpdu_density: MDPU density.
311 * @retry_limit: Max number of retries. 294 * @retry_limit: Max number of retries.
312 * @aifs: AIFS value.
313 * @ifs: IFS value. 295 * @ifs: IFS value.
314 * @txop: IFS value for 11n capable chips. 296 * @txop: IFS value for 11n capable chips.
315 * @cw_min: cwmin value.
316 * @cw_max: cwmax value.
317 * @cipher: Cipher type used for encryption. 297 * @cipher: Cipher type used for encryption.
318 * @key_idx: Key index used for encryption. 298 * @key_idx: Key index used for encryption.
319 * @iv_offset: Position where IV should be inserted by hardware. 299 * @iv_offset: Position where IV should be inserted by hardware.
@@ -322,8 +302,6 @@ enum txentry_desc_flags {
322struct txentry_desc { 302struct txentry_desc {
323 unsigned long flags; 303 unsigned long flags;
324 304
325 enum data_queue_qid qid;
326
327 u16 length; 305 u16 length;
328 u16 header_length; 306 u16 header_length;
329 307
@@ -339,11 +317,8 @@ struct txentry_desc {
339 u16 mpdu_density; 317 u16 mpdu_density;
340 318
341 short retry_limit; 319 short retry_limit;
342 short aifs;
343 short ifs; 320 short ifs;
344 short txop; 321 short txop;
345 short cw_min;
346 short cw_max;
347 322
348 enum cipher cipher; 323 enum cipher cipher;
349 u16 key_idx; 324 u16 key_idx;
@@ -365,12 +340,16 @@ struct txentry_desc {
365 * @ENTRY_DATA_IO_FAILED: Hardware indicated that an IO error occured 340 * @ENTRY_DATA_IO_FAILED: Hardware indicated that an IO error occured
366 * while transfering the data to the hardware. No TX status report will 341 * while transfering the data to the hardware. No TX status report will
367 * be expected from the hardware. 342 * be expected from the hardware.
343 * @ENTRY_DATA_STATUS_PENDING: The entry has been send to the device and
344 * returned. It is now waiting for the status reporting before the
345 * entry can be reused again.
368 */ 346 */
369enum queue_entry_flags { 347enum queue_entry_flags {
370 ENTRY_BCN_ASSIGNED, 348 ENTRY_BCN_ASSIGNED,
371 ENTRY_OWNER_DEVICE_DATA, 349 ENTRY_OWNER_DEVICE_DATA,
372 ENTRY_DATA_PENDING, 350 ENTRY_DATA_PENDING,
373 ENTRY_DATA_IO_FAILED 351 ENTRY_DATA_IO_FAILED,
352 ENTRY_DATA_STATUS_PENDING,
374}; 353};
375 354
376/** 355/**
@@ -417,13 +396,33 @@ enum queue_index {
417}; 396};
418 397
419/** 398/**
399 * enum data_queue_flags: Status flags for data queues
400 *
401 * @QUEUE_STARTED: The queue has been started. Fox RX queues this means the
402 * device might be DMA'ing skbuffers. TX queues will accept skbuffers to
403 * be transmitted and beacon queues will start beaconing the configured
404 * beacons.
405 * @QUEUE_PAUSED: The queue has been started but is currently paused.
406 * When this bit is set, the queue has been stopped in mac80211,
407 * preventing new frames to be enqueued. However, a few frames
408 * might still appear shortly after the pausing...
409 */
410enum data_queue_flags {
411 QUEUE_STARTED,
412 QUEUE_PAUSED,
413};
414
415/**
420 * struct data_queue: Data queue 416 * struct data_queue: Data queue
421 * 417 *
422 * @rt2x00dev: Pointer to main &struct rt2x00dev where this queue belongs to. 418 * @rt2x00dev: Pointer to main &struct rt2x00dev where this queue belongs to.
423 * @entries: Base address of the &struct queue_entry which are 419 * @entries: Base address of the &struct queue_entry which are
424 * part of this queue. 420 * part of this queue.
425 * @qid: The queue identification, see &enum data_queue_qid. 421 * @qid: The queue identification, see &enum data_queue_qid.
426 * @lock: Spinlock to protect index handling. Whenever @index, @index_done or 422 * @flags: Entry flags, see &enum queue_entry_flags.
423 * @status_lock: The mutex for protecting the start/stop/flush
424 * handling on this queue.
425 * @index_lock: Spinlock to protect index handling. Whenever @index, @index_done or
427 * @index_crypt needs to be changed this lock should be grabbed to prevent 426 * @index_crypt needs to be changed this lock should be grabbed to prevent
428 * index corruption due to concurrency. 427 * index corruption due to concurrency.
429 * @count: Number of frames handled in the queue. 428 * @count: Number of frames handled in the queue.
@@ -446,8 +445,11 @@ struct data_queue {
446 struct queue_entry *entries; 445 struct queue_entry *entries;
447 446
448 enum data_queue_qid qid; 447 enum data_queue_qid qid;
448 unsigned long flags;
449
450 struct mutex status_lock;
451 spinlock_t index_lock;
449 452
450 spinlock_t lock;
451 unsigned int count; 453 unsigned int count;
452 unsigned short limit; 454 unsigned short limit;
453 unsigned short threshold; 455 unsigned short threshold;
@@ -618,10 +620,10 @@ static inline int rt2x00queue_threshold(struct data_queue *queue)
618} 620}
619 621
620/** 622/**
621 * rt2x00queue_timeout - Check if a timeout occured for STATUS reorts 623 * rt2x00queue_status_timeout - Check if a timeout occured for STATUS reports
622 * @queue: Queue to check. 624 * @queue: Queue to check.
623 */ 625 */
624static inline int rt2x00queue_timeout(struct data_queue *queue) 626static inline int rt2x00queue_status_timeout(struct data_queue *queue)
625{ 627{
626 return time_after(queue->last_action[Q_INDEX_DMA_DONE], 628 return time_after(queue->last_action[Q_INDEX_DMA_DONE],
627 queue->last_action[Q_INDEX_DONE] + (HZ / 10)); 629 queue->last_action[Q_INDEX_DONE] + (HZ / 10));
diff --git a/drivers/net/wireless/rt2x00/rt2x00reg.h b/drivers/net/wireless/rt2x00/rt2x00reg.h
index cef94621cef7..e8259ae48ced 100644
--- a/drivers/net/wireless/rt2x00/rt2x00reg.h
+++ b/drivers/net/wireless/rt2x00/rt2x00reg.h
@@ -83,10 +83,6 @@ enum dev_state {
83 */ 83 */
84 STATE_RADIO_ON, 84 STATE_RADIO_ON,
85 STATE_RADIO_OFF, 85 STATE_RADIO_OFF,
86 STATE_RADIO_RX_ON,
87 STATE_RADIO_RX_OFF,
88 STATE_RADIO_RX_ON_LINK,
89 STATE_RADIO_RX_OFF_LINK,
90 STATE_RADIO_IRQ_ON, 86 STATE_RADIO_IRQ_ON,
91 STATE_RADIO_IRQ_OFF, 87 STATE_RADIO_IRQ_OFF,
92 STATE_RADIO_IRQ_ON_ISR, 88 STATE_RADIO_IRQ_ON_ISR,
diff --git a/drivers/net/wireless/rt2x00/rt2x00soc.c b/drivers/net/wireless/rt2x00/rt2x00soc.c
index fc98063de71d..2aa5c38022f3 100644
--- a/drivers/net/wireless/rt2x00/rt2x00soc.c
+++ b/drivers/net/wireless/rt2x00/rt2x00soc.c
@@ -40,6 +40,8 @@ static void rt2x00soc_free_reg(struct rt2x00_dev *rt2x00dev)
40 40
41 kfree(rt2x00dev->eeprom); 41 kfree(rt2x00dev->eeprom);
42 rt2x00dev->eeprom = NULL; 42 rt2x00dev->eeprom = NULL;
43
44 iounmap(rt2x00dev->csr.base);
43} 45}
44 46
45static int rt2x00soc_alloc_reg(struct rt2x00_dev *rt2x00dev) 47static int rt2x00soc_alloc_reg(struct rt2x00_dev *rt2x00dev)
@@ -51,9 +53,9 @@ static int rt2x00soc_alloc_reg(struct rt2x00_dev *rt2x00dev)
51 if (!res) 53 if (!res)
52 return -ENODEV; 54 return -ENODEV;
53 55
54 rt2x00dev->csr.base = (void __iomem *)KSEG1ADDR(res->start); 56 rt2x00dev->csr.base = ioremap(res->start, resource_size(res));
55 if (!rt2x00dev->csr.base) 57 if (!rt2x00dev->csr.base)
56 goto exit; 58 return -ENOMEM;
57 59
58 rt2x00dev->eeprom = kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL); 60 rt2x00dev->eeprom = kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL);
59 if (!rt2x00dev->eeprom) 61 if (!rt2x00dev->eeprom)
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index b3317df7a7d4..1a9937d5aff6 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -195,7 +195,8 @@ static void rt2x00usb_work_txdone(struct work_struct *work)
195 while (!rt2x00queue_empty(queue)) { 195 while (!rt2x00queue_empty(queue)) {
196 entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); 196 entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
197 197
198 if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) 198 if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) ||
199 !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))
199 break; 200 break;
200 201
201 rt2x00usb_work_txdone_entry(entry); 202 rt2x00usb_work_txdone_entry(entry);
@@ -226,9 +227,7 @@ static void rt2x00usb_interrupt_txdone(struct urb *urb)
226 * Schedule the delayed work for reading the TX status 227 * Schedule the delayed work for reading the TX status
227 * from the device. 228 * from the device.
228 */ 229 */
229 if (test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) && 230 ieee80211_queue_work(rt2x00dev->hw, &rt2x00dev->txdone_work);
230 test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
231 ieee80211_queue_work(rt2x00dev->hw, &rt2x00dev->txdone_work);
232} 231}
233 232
234static void rt2x00usb_kick_tx_entry(struct queue_entry *entry) 233static void rt2x00usb_kick_tx_entry(struct queue_entry *entry)
@@ -237,8 +236,10 @@ static void rt2x00usb_kick_tx_entry(struct queue_entry *entry)
237 struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev); 236 struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev);
238 struct queue_entry_priv_usb *entry_priv = entry->priv_data; 237 struct queue_entry_priv_usb *entry_priv = entry->priv_data;
239 u32 length; 238 u32 length;
239 int status;
240 240
241 if (!test_and_clear_bit(ENTRY_DATA_PENDING, &entry->flags)) 241 if (!test_and_clear_bit(ENTRY_DATA_PENDING, &entry->flags) ||
242 test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))
242 return; 243 return;
243 244
244 /* 245 /*
@@ -253,121 +254,15 @@ static void rt2x00usb_kick_tx_entry(struct queue_entry *entry)
253 entry->skb->data, length, 254 entry->skb->data, length,
254 rt2x00usb_interrupt_txdone, entry); 255 rt2x00usb_interrupt_txdone, entry);
255 256
256 if (usb_submit_urb(entry_priv->urb, GFP_ATOMIC)) { 257 status = usb_submit_urb(entry_priv->urb, GFP_ATOMIC);
258 if (status) {
259 if (status == -ENODEV)
260 clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
257 set_bit(ENTRY_DATA_IO_FAILED, &entry->flags); 261 set_bit(ENTRY_DATA_IO_FAILED, &entry->flags);
258 rt2x00lib_dmadone(entry); 262 rt2x00lib_dmadone(entry);
259 } 263 }
260} 264}
261 265
262void rt2x00usb_kick_tx_queue(struct data_queue *queue)
263{
264 rt2x00queue_for_each_entry(queue, Q_INDEX_DONE, Q_INDEX,
265 rt2x00usb_kick_tx_entry);
266}
267EXPORT_SYMBOL_GPL(rt2x00usb_kick_tx_queue);
268
269static void rt2x00usb_kill_tx_entry(struct queue_entry *entry)
270{
271 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
272 struct queue_entry_priv_usb *entry_priv = entry->priv_data;
273 struct queue_entry_priv_usb_bcn *bcn_priv = entry->priv_data;
274
275 if (!test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))
276 return;
277
278 usb_kill_urb(entry_priv->urb);
279
280 /*
281 * Kill guardian urb (if required by driver).
282 */
283 if ((entry->queue->qid == QID_BEACON) &&
284 (test_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags)))
285 usb_kill_urb(bcn_priv->guardian_urb);
286}
287
288void rt2x00usb_kill_tx_queue(struct data_queue *queue)
289{
290 rt2x00queue_for_each_entry(queue, Q_INDEX_DONE, Q_INDEX,
291 rt2x00usb_kill_tx_entry);
292}
293EXPORT_SYMBOL_GPL(rt2x00usb_kill_tx_queue);
294
295static void rt2x00usb_watchdog_tx_dma(struct data_queue *queue)
296{
297 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
298 unsigned short threshold = queue->threshold;
299
300 WARNING(queue->rt2x00dev, "TX queue %d DMA timed out,"
301 " invoke forced forced reset", queue->qid);
302
303 /*
304 * Temporarily disable the TX queue, this will force mac80211
305 * to use the other queues until this queue has been restored.
306 *
307 * Set the queue threshold to the queue limit. This prevents the
308 * queue from being enabled during the txdone handler.
309 */
310 queue->threshold = queue->limit;
311 ieee80211_stop_queue(rt2x00dev->hw, queue->qid);
312
313 /*
314 * Kill all entries in the queue, afterwards we need to
315 * wait a bit for all URBs to be cancelled.
316 */
317 rt2x00usb_kill_tx_queue(queue);
318
319 /*
320 * In case that a driver has overriden the txdone_work
321 * function, we invoke the TX done through there.
322 */
323 rt2x00dev->txdone_work.func(&rt2x00dev->txdone_work);
324
325 /*
326 * Security measure: if the driver did override the
327 * txdone_work function, and the hardware did arrive
328 * in a state which causes it to malfunction, it is
329 * possible that the driver couldn't handle the txdone
330 * event correctly. So after giving the driver the
331 * chance to cleanup, we now force a cleanup of any
332 * leftovers.
333 */
334 if (!rt2x00queue_empty(queue)) {
335 WARNING(queue->rt2x00dev, "TX queue %d DMA timed out,"
336 " status handling failed, invoke hard reset", queue->qid);
337 rt2x00usb_work_txdone(&rt2x00dev->txdone_work);
338 }
339
340 /*
341 * The queue has been reset, and mac80211 is allowed to use the
342 * queue again.
343 */
344 queue->threshold = threshold;
345 ieee80211_wake_queue(rt2x00dev->hw, queue->qid);
346}
347
348static void rt2x00usb_watchdog_tx_status(struct data_queue *queue)
349{
350 WARNING(queue->rt2x00dev, "TX queue %d status timed out,"
351 " invoke forced tx handler", queue->qid);
352
353 ieee80211_queue_work(queue->rt2x00dev->hw, &queue->rt2x00dev->txdone_work);
354}
355
356void rt2x00usb_watchdog(struct rt2x00_dev *rt2x00dev)
357{
358 struct data_queue *queue;
359
360 tx_queue_for_each(rt2x00dev, queue) {
361 if (!rt2x00queue_empty(queue)) {
362 if (rt2x00queue_dma_timeout(queue))
363 rt2x00usb_watchdog_tx_dma(queue);
364 if (rt2x00queue_timeout(queue))
365 rt2x00usb_watchdog_tx_status(queue);
366 }
367 }
368}
369EXPORT_SYMBOL_GPL(rt2x00usb_watchdog);
370
371/* 266/*
372 * RX data handlers. 267 * RX data handlers.
373 */ 268 */
@@ -382,7 +277,8 @@ static void rt2x00usb_work_rxdone(struct work_struct *work)
382 while (!rt2x00queue_empty(rt2x00dev->rx)) { 277 while (!rt2x00queue_empty(rt2x00dev->rx)) {
383 entry = rt2x00queue_get_entry(rt2x00dev->rx, Q_INDEX_DONE); 278 entry = rt2x00queue_get_entry(rt2x00dev->rx, Q_INDEX_DONE);
384 279
385 if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) 280 if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) ||
281 !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))
386 break; 282 break;
387 283
388 /* 284 /*
@@ -424,11 +320,157 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb)
424 * Schedule the delayed work for reading the RX status 320 * Schedule the delayed work for reading the RX status
425 * from the device. 321 * from the device.
426 */ 322 */
427 if (test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) && 323 ieee80211_queue_work(rt2x00dev->hw, &rt2x00dev->rxdone_work);
428 test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
429 ieee80211_queue_work(rt2x00dev->hw, &rt2x00dev->rxdone_work);
430} 324}
431 325
326static void rt2x00usb_kick_rx_entry(struct queue_entry *entry)
327{
328 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
329 struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev);
330 struct queue_entry_priv_usb *entry_priv = entry->priv_data;
331 int status;
332
333 if (test_and_set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) ||
334 test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))
335 return;
336
337 rt2x00lib_dmastart(entry);
338
339 usb_fill_bulk_urb(entry_priv->urb, usb_dev,
340 usb_rcvbulkpipe(usb_dev, entry->queue->usb_endpoint),
341 entry->skb->data, entry->skb->len,
342 rt2x00usb_interrupt_rxdone, entry);
343
344 status = usb_submit_urb(entry_priv->urb, GFP_ATOMIC);
345 if (status) {
346 if (status == -ENODEV)
347 clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
348 set_bit(ENTRY_DATA_IO_FAILED, &entry->flags);
349 rt2x00lib_dmadone(entry);
350 }
351}
352
353void rt2x00usb_kick_queue(struct data_queue *queue)
354{
355 switch (queue->qid) {
356 case QID_AC_VO:
357 case QID_AC_VI:
358 case QID_AC_BE:
359 case QID_AC_BK:
360 if (!rt2x00queue_empty(queue))
361 rt2x00queue_for_each_entry(queue, Q_INDEX_DONE, Q_INDEX,
362 rt2x00usb_kick_tx_entry);
363 break;
364 case QID_RX:
365 if (!rt2x00queue_full(queue))
366 rt2x00queue_for_each_entry(queue, Q_INDEX_DONE, Q_INDEX,
367 rt2x00usb_kick_rx_entry);
368 break;
369 default:
370 break;
371 }
372}
373EXPORT_SYMBOL_GPL(rt2x00usb_kick_queue);
374
375static void rt2x00usb_flush_entry(struct queue_entry *entry)
376{
377 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
378 struct queue_entry_priv_usb *entry_priv = entry->priv_data;
379 struct queue_entry_priv_usb_bcn *bcn_priv = entry->priv_data;
380
381 if (!test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))
382 return;
383
384 usb_kill_urb(entry_priv->urb);
385
386 /*
387 * Kill guardian urb (if required by driver).
388 */
389 if ((entry->queue->qid == QID_BEACON) &&
390 (test_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags)))
391 usb_kill_urb(bcn_priv->guardian_urb);
392}
393
394void rt2x00usb_flush_queue(struct data_queue *queue)
395{
396 struct work_struct *completion;
397 unsigned int i;
398
399 rt2x00queue_for_each_entry(queue, Q_INDEX_DONE, Q_INDEX,
400 rt2x00usb_flush_entry);
401
402 /*
403 * Obtain the queue completion handler
404 */
405 switch (queue->qid) {
406 case QID_AC_VO:
407 case QID_AC_VI:
408 case QID_AC_BE:
409 case QID_AC_BK:
410 completion = &queue->rt2x00dev->txdone_work;
411 break;
412 case QID_RX:
413 completion = &queue->rt2x00dev->rxdone_work;
414 break;
415 default:
416 return;
417 }
418
419 for (i = 0; i < 20; i++) {
420 /*
421 * Check if the driver is already done, otherwise we
422 * have to sleep a little while to give the driver/hw
423 * the oppurtunity to complete interrupt process itself.
424 */
425 if (rt2x00queue_empty(queue))
426 break;
427
428 /*
429 * Schedule the completion handler manually, when this
430 * worker function runs, it should cleanup the queue.
431 */
432 ieee80211_queue_work(queue->rt2x00dev->hw, completion);
433
434 /*
435 * Wait for a little while to give the driver
436 * the oppurtunity to recover itself.
437 */
438 msleep(10);
439 }
440}
441EXPORT_SYMBOL_GPL(rt2x00usb_flush_queue);
442
443static void rt2x00usb_watchdog_tx_dma(struct data_queue *queue)
444{
445 WARNING(queue->rt2x00dev, "TX queue %d DMA timed out,"
446 " invoke forced forced reset\n", queue->qid);
447
448 rt2x00queue_flush_queue(queue, true);
449}
450
451static void rt2x00usb_watchdog_tx_status(struct data_queue *queue)
452{
453 WARNING(queue->rt2x00dev, "TX queue %d status timed out,"
454 " invoke forced tx handler\n", queue->qid);
455
456 ieee80211_queue_work(queue->rt2x00dev->hw, &queue->rt2x00dev->txdone_work);
457}
458
459void rt2x00usb_watchdog(struct rt2x00_dev *rt2x00dev)
460{
461 struct data_queue *queue;
462
463 tx_queue_for_each(rt2x00dev, queue) {
464 if (!rt2x00queue_empty(queue)) {
465 if (rt2x00queue_dma_timeout(queue))
466 rt2x00usb_watchdog_tx_dma(queue);
467 if (rt2x00queue_status_timeout(queue))
468 rt2x00usb_watchdog_tx_status(queue);
469 }
470 }
471}
472EXPORT_SYMBOL_GPL(rt2x00usb_watchdog);
473
432/* 474/*
433 * Radio handlers 475 * Radio handlers
434 */ 476 */
@@ -436,12 +478,6 @@ void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev)
436{ 478{
437 rt2x00usb_vendor_request_sw(rt2x00dev, USB_RX_CONTROL, 0, 0, 479 rt2x00usb_vendor_request_sw(rt2x00dev, USB_RX_CONTROL, 0, 0,
438 REGISTER_TIMEOUT); 480 REGISTER_TIMEOUT);
439
440 /*
441 * The USB version of kill_tx_queue also works
442 * on the RX queue.
443 */
444 rt2x00dev->ops->lib->kill_tx_queue(rt2x00dev->rx);
445} 481}
446EXPORT_SYMBOL_GPL(rt2x00usb_disable_radio); 482EXPORT_SYMBOL_GPL(rt2x00usb_disable_radio);
447 483
@@ -450,25 +486,10 @@ EXPORT_SYMBOL_GPL(rt2x00usb_disable_radio);
450 */ 486 */
451void rt2x00usb_clear_entry(struct queue_entry *entry) 487void rt2x00usb_clear_entry(struct queue_entry *entry)
452{ 488{
453 struct usb_device *usb_dev =
454 to_usb_device_intf(entry->queue->rt2x00dev->dev);
455 struct queue_entry_priv_usb *entry_priv = entry->priv_data;
456 int pipe;
457
458 entry->flags = 0; 489 entry->flags = 0;
459 490
460 if (entry->queue->qid == QID_RX) { 491 if (entry->queue->qid == QID_RX)
461 pipe = usb_rcvbulkpipe(usb_dev, entry->queue->usb_endpoint); 492 rt2x00usb_kick_rx_entry(entry);
462 usb_fill_bulk_urb(entry_priv->urb, usb_dev, pipe,
463 entry->skb->data, entry->skb->len,
464 rt2x00usb_interrupt_rxdone, entry);
465
466 set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags);
467 if (usb_submit_urb(entry_priv->urb, GFP_ATOMIC)) {
468 set_bit(ENTRY_DATA_IO_FAILED, &entry->flags);
469 rt2x00lib_dmadone(entry);
470 }
471 }
472} 493}
473EXPORT_SYMBOL_GPL(rt2x00usb_clear_entry); 494EXPORT_SYMBOL_GPL(rt2x00usb_clear_entry);
474 495
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.h b/drivers/net/wireless/rt2x00/rt2x00usb.h
index c2d997f67b3e..6aaf51fc7ad8 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.h
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.h
@@ -378,22 +378,22 @@ struct queue_entry_priv_usb_bcn {
378}; 378};
379 379
380/** 380/**
381 * rt2x00usb_kick_tx_queue - Kick data queue 381 * rt2x00usb_kick_queue - Kick data queue
382 * @queue: Data queue to kick 382 * @queue: Data queue to kick
383 * 383 *
384 * This will walk through all entries of the queue and push all pending 384 * This will walk through all entries of the queue and push all pending
385 * frames to the hardware as a single burst. 385 * frames to the hardware as a single burst.
386 */ 386 */
387void rt2x00usb_kick_tx_queue(struct data_queue *queue); 387void rt2x00usb_kick_queue(struct data_queue *queue);
388 388
389/** 389/**
390 * rt2x00usb_kill_tx_queue - Kill data queue 390 * rt2x00usb_flush_queue - Flush data queue
391 * @queue: Data queue to kill 391 * @queue: Data queue to stop
392 * 392 *
393 * This will walk through all entries of the queue and kill all 393 * This will walk through all entries of the queue and kill all
394 * previously kicked frames before they can be send. 394 * URB's which were send to the device.
395 */ 395 */
396void rt2x00usb_kill_tx_queue(struct data_queue *queue); 396void rt2x00usb_flush_queue(struct data_queue *queue);
397 397
398/** 398/**
399 * rt2x00usb_watchdog - Watchdog for USB communication 399 * rt2x00usb_watchdog - Watchdog for USB communication
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index af548c87f108..8de44dd401e0 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -1140,6 +1140,106 @@ dynamic_cca_tune:
1140} 1140}
1141 1141
1142/* 1142/*
1143 * Queue handlers.
1144 */
1145static void rt61pci_start_queue(struct data_queue *queue)
1146{
1147 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1148 u32 reg;
1149
1150 switch (queue->qid) {
1151 case QID_RX:
1152 rt2x00pci_register_read(rt2x00dev, TXRX_CSR0, &reg);
1153 rt2x00_set_field32(&reg, TXRX_CSR0_DISABLE_RX, 0);
1154 rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg);
1155 break;
1156 case QID_BEACON:
1157 rt2x00pci_register_read(rt2x00dev, TXRX_CSR9, &reg);
1158 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 1);
1159 rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 1);
1160 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 1);
1161 rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, reg);
1162 break;
1163 default:
1164 break;
1165 }
1166}
1167
1168static void rt61pci_kick_queue(struct data_queue *queue)
1169{
1170 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1171 u32 reg;
1172
1173 switch (queue->qid) {
1174 case QID_AC_VO:
1175 rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg);
1176 rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC0, 1);
1177 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1178 break;
1179 case QID_AC_VI:
1180 rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg);
1181 rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC1, 1);
1182 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1183 break;
1184 case QID_AC_BE:
1185 rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg);
1186 rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC2, 1);
1187 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1188 break;
1189 case QID_AC_BK:
1190 rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg);
1191 rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC3, 1);
1192 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1193 break;
1194 default:
1195 break;
1196 }
1197}
1198
1199static void rt61pci_stop_queue(struct data_queue *queue)
1200{
1201 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1202 u32 reg;
1203
1204 switch (queue->qid) {
1205 case QID_AC_VO:
1206 rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg);
1207 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC0, 1);
1208 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1209 break;
1210 case QID_AC_VI:
1211 rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg);
1212 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC1, 1);
1213 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1214 break;
1215 case QID_AC_BE:
1216 rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg);
1217 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC2, 1);
1218 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1219 break;
1220 case QID_AC_BK:
1221 rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg);
1222 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC3, 1);
1223 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1224 break;
1225 case QID_RX:
1226 rt2x00pci_register_read(rt2x00dev, TXRX_CSR0, &reg);
1227 rt2x00_set_field32(&reg, TXRX_CSR0_DISABLE_RX, 1);
1228 rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg);
1229 break;
1230 case QID_BEACON:
1231 rt2x00pci_register_read(rt2x00dev, TXRX_CSR9, &reg);
1232 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 0);
1233 rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 0);
1234 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0);
1235 rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, reg);
1236 break;
1237 default:
1238 break;
1239 }
1240}
1241
1242/*
1143 * Firmware functions 1243 * Firmware functions
1144 */ 1244 */
1145static char *rt61pci_get_firmware_name(struct rt2x00_dev *rt2x00dev) 1245static char *rt61pci_get_firmware_name(struct rt2x00_dev *rt2x00dev)
@@ -1616,18 +1716,6 @@ static int rt61pci_init_bbp(struct rt2x00_dev *rt2x00dev)
1616/* 1716/*
1617 * Device state switch handlers. 1717 * Device state switch handlers.
1618 */ 1718 */
1619static void rt61pci_toggle_rx(struct rt2x00_dev *rt2x00dev,
1620 enum dev_state state)
1621{
1622 u32 reg;
1623
1624 rt2x00pci_register_read(rt2x00dev, TXRX_CSR0, &reg);
1625 rt2x00_set_field32(&reg, TXRX_CSR0_DISABLE_RX,
1626 (state == STATE_RADIO_RX_OFF) ||
1627 (state == STATE_RADIO_RX_OFF_LINK));
1628 rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg);
1629}
1630
1631static void rt61pci_toggle_irq(struct rt2x00_dev *rt2x00dev, 1719static void rt61pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
1632 enum dev_state state) 1720 enum dev_state state)
1633{ 1721{
@@ -1744,12 +1832,6 @@ static int rt61pci_set_device_state(struct rt2x00_dev *rt2x00dev,
1744 case STATE_RADIO_OFF: 1832 case STATE_RADIO_OFF:
1745 rt61pci_disable_radio(rt2x00dev); 1833 rt61pci_disable_radio(rt2x00dev);
1746 break; 1834 break;
1747 case STATE_RADIO_RX_ON:
1748 case STATE_RADIO_RX_ON_LINK:
1749 case STATE_RADIO_RX_OFF:
1750 case STATE_RADIO_RX_OFF_LINK:
1751 rt61pci_toggle_rx(rt2x00dev, state);
1752 break;
1753 case STATE_RADIO_IRQ_ON: 1835 case STATE_RADIO_IRQ_ON:
1754 case STATE_RADIO_IRQ_ON_ISR: 1836 case STATE_RADIO_IRQ_ON_ISR:
1755 case STATE_RADIO_IRQ_OFF: 1837 case STATE_RADIO_IRQ_OFF:
@@ -1789,10 +1871,10 @@ static void rt61pci_write_tx_desc(struct queue_entry *entry,
1789 * Start writing the descriptor words. 1871 * Start writing the descriptor words.
1790 */ 1872 */
1791 rt2x00_desc_read(txd, 1, &word); 1873 rt2x00_desc_read(txd, 1, &word);
1792 rt2x00_set_field32(&word, TXD_W1_HOST_Q_ID, txdesc->qid); 1874 rt2x00_set_field32(&word, TXD_W1_HOST_Q_ID, entry->queue->qid);
1793 rt2x00_set_field32(&word, TXD_W1_AIFSN, txdesc->aifs); 1875 rt2x00_set_field32(&word, TXD_W1_AIFSN, entry->queue->aifs);
1794 rt2x00_set_field32(&word, TXD_W1_CWMIN, txdesc->cw_min); 1876 rt2x00_set_field32(&word, TXD_W1_CWMIN, entry->queue->cw_min);
1795 rt2x00_set_field32(&word, TXD_W1_CWMAX, txdesc->cw_max); 1877 rt2x00_set_field32(&word, TXD_W1_CWMAX, entry->queue->cw_max);
1796 rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, txdesc->iv_offset); 1878 rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, txdesc->iv_offset);
1797 rt2x00_set_field32(&word, TXD_W1_HW_SEQUENCE, 1879 rt2x00_set_field32(&word, TXD_W1_HW_SEQUENCE,
1798 test_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags)); 1880 test_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags));
@@ -1820,7 +1902,7 @@ static void rt61pci_write_tx_desc(struct queue_entry *entry,
1820 rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1); 1902 rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1);
1821 rt2x00_desc_write(txd, 5, word); 1903 rt2x00_desc_write(txd, 5, word);
1822 1904
1823 if (txdesc->qid != QID_BEACON) { 1905 if (entry->queue->qid != QID_BEACON) {
1824 rt2x00_desc_read(txd, 6, &word); 1906 rt2x00_desc_read(txd, 6, &word);
1825 rt2x00_set_field32(&word, TXD_W6_BUFFER_PHYSICAL_ADDRESS, 1907 rt2x00_set_field32(&word, TXD_W6_BUFFER_PHYSICAL_ADDRESS,
1826 skbdesc->skb_dma); 1908 skbdesc->skb_dma);
@@ -1866,8 +1948,8 @@ static void rt61pci_write_tx_desc(struct queue_entry *entry,
1866 * Register descriptor details in skb frame descriptor. 1948 * Register descriptor details in skb frame descriptor.
1867 */ 1949 */
1868 skbdesc->desc = txd; 1950 skbdesc->desc = txd;
1869 skbdesc->desc_len = 1951 skbdesc->desc_len = (entry->queue->qid == QID_BEACON) ? TXINFO_SIZE :
1870 (txdesc->qid == QID_BEACON) ? TXINFO_SIZE : TXD_DESC_SIZE; 1952 TXD_DESC_SIZE;
1871} 1953}
1872 1954
1873/* 1955/*
@@ -1879,6 +1961,7 @@ static void rt61pci_write_beacon(struct queue_entry *entry,
1879 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 1961 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1880 struct queue_entry_priv_pci *entry_priv = entry->priv_data; 1962 struct queue_entry_priv_pci *entry_priv = entry->priv_data;
1881 unsigned int beacon_base; 1963 unsigned int beacon_base;
1964 unsigned int padding_len;
1882 u32 reg; 1965 u32 reg;
1883 1966
1884 /* 1967 /*
@@ -1900,13 +1983,16 @@ static void rt61pci_write_beacon(struct queue_entry *entry,
1900 rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry->skb); 1983 rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry->skb);
1901 1984
1902 /* 1985 /*
1903 * Write entire beacon with descriptor to register. 1986 * Write entire beacon with descriptor and padding to register.
1904 */ 1987 */
1988 padding_len = roundup(entry->skb->len, 4) - entry->skb->len;
1989 skb_pad(entry->skb, padding_len);
1905 beacon_base = HW_BEACON_OFFSET(entry->entry_idx); 1990 beacon_base = HW_BEACON_OFFSET(entry->entry_idx);
1906 rt2x00pci_register_multiwrite(rt2x00dev, beacon_base, 1991 rt2x00pci_register_multiwrite(rt2x00dev, beacon_base,
1907 entry_priv->desc, TXINFO_SIZE); 1992 entry_priv->desc, TXINFO_SIZE);
1908 rt2x00pci_register_multiwrite(rt2x00dev, beacon_base + TXINFO_SIZE, 1993 rt2x00pci_register_multiwrite(rt2x00dev, beacon_base + TXINFO_SIZE,
1909 entry->skb->data, entry->skb->len); 1994 entry->skb->data,
1995 entry->skb->len + padding_len);
1910 1996
1911 /* 1997 /*
1912 * Enable beaconing again. 1998 * Enable beaconing again.
@@ -1928,37 +2014,6 @@ static void rt61pci_write_beacon(struct queue_entry *entry,
1928 entry->skb = NULL; 2014 entry->skb = NULL;
1929} 2015}
1930 2016
1931static void rt61pci_kick_tx_queue(struct data_queue *queue)
1932{
1933 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1934 u32 reg;
1935
1936 rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg);
1937 rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC0, (queue->qid == QID_AC_BE));
1938 rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC1, (queue->qid == QID_AC_BK));
1939 rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC2, (queue->qid == QID_AC_VI));
1940 rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC3, (queue->qid == QID_AC_VO));
1941 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1942}
1943
1944static void rt61pci_kill_tx_queue(struct data_queue *queue)
1945{
1946 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1947 u32 reg;
1948
1949 if (queue->qid == QID_BEACON) {
1950 rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, 0);
1951 return;
1952 }
1953
1954 rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg);
1955 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC0, (queue->qid == QID_AC_BE));
1956 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC1, (queue->qid == QID_AC_BK));
1957 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC2, (queue->qid == QID_AC_VI));
1958 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC3, (queue->qid == QID_AC_VO));
1959 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1960}
1961
1962/* 2017/*
1963 * RX control handlers 2018 * RX control handlers
1964 */ 2019 */
@@ -2078,7 +2133,7 @@ static void rt61pci_txdone(struct rt2x00_dev *rt2x00dev)
2078 * that the TX_STA_FIFO stack has a size of 16. We stick to our 2133 * that the TX_STA_FIFO stack has a size of 16. We stick to our
2079 * tx ring size for now. 2134 * tx ring size for now.
2080 */ 2135 */
2081 for (i = 0; i < TX_ENTRIES; i++) { 2136 for (i = 0; i < rt2x00dev->ops->tx->entry_num; i++) {
2082 rt2x00pci_register_read(rt2x00dev, STA_CSR4, &reg); 2137 rt2x00pci_register_read(rt2x00dev, STA_CSR4, &reg);
2083 if (!rt2x00_get_field32(reg, STA_CSR4_VALID)) 2138 if (!rt2x00_get_field32(reg, STA_CSR4_VALID))
2084 break; 2139 break;
@@ -2824,6 +2879,7 @@ static const struct ieee80211_ops rt61pci_mac80211_ops = {
2824 .conf_tx = rt61pci_conf_tx, 2879 .conf_tx = rt61pci_conf_tx,
2825 .get_tsf = rt61pci_get_tsf, 2880 .get_tsf = rt61pci_get_tsf,
2826 .rfkill_poll = rt2x00mac_rfkill_poll, 2881 .rfkill_poll = rt2x00mac_rfkill_poll,
2882 .flush = rt2x00mac_flush,
2827}; 2883};
2828 2884
2829static const struct rt2x00lib_ops rt61pci_rt2x00_ops = { 2885static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
@@ -2842,10 +2898,11 @@ static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
2842 .link_stats = rt61pci_link_stats, 2898 .link_stats = rt61pci_link_stats,
2843 .reset_tuner = rt61pci_reset_tuner, 2899 .reset_tuner = rt61pci_reset_tuner,
2844 .link_tuner = rt61pci_link_tuner, 2900 .link_tuner = rt61pci_link_tuner,
2901 .start_queue = rt61pci_start_queue,
2902 .kick_queue = rt61pci_kick_queue,
2903 .stop_queue = rt61pci_stop_queue,
2845 .write_tx_desc = rt61pci_write_tx_desc, 2904 .write_tx_desc = rt61pci_write_tx_desc,
2846 .write_beacon = rt61pci_write_beacon, 2905 .write_beacon = rt61pci_write_beacon,
2847 .kick_tx_queue = rt61pci_kick_tx_queue,
2848 .kill_tx_queue = rt61pci_kill_tx_queue,
2849 .fill_rxdone = rt61pci_fill_rxdone, 2906 .fill_rxdone = rt61pci_fill_rxdone,
2850 .config_shared_key = rt61pci_config_shared_key, 2907 .config_shared_key = rt61pci_config_shared_key,
2851 .config_pairwise_key = rt61pci_config_pairwise_key, 2908 .config_pairwise_key = rt61pci_config_pairwise_key,
@@ -2857,21 +2914,21 @@ static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
2857}; 2914};
2858 2915
2859static const struct data_queue_desc rt61pci_queue_rx = { 2916static const struct data_queue_desc rt61pci_queue_rx = {
2860 .entry_num = RX_ENTRIES, 2917 .entry_num = 32,
2861 .data_size = DATA_FRAME_SIZE, 2918 .data_size = DATA_FRAME_SIZE,
2862 .desc_size = RXD_DESC_SIZE, 2919 .desc_size = RXD_DESC_SIZE,
2863 .priv_size = sizeof(struct queue_entry_priv_pci), 2920 .priv_size = sizeof(struct queue_entry_priv_pci),
2864}; 2921};
2865 2922
2866static const struct data_queue_desc rt61pci_queue_tx = { 2923static const struct data_queue_desc rt61pci_queue_tx = {
2867 .entry_num = TX_ENTRIES, 2924 .entry_num = 32,
2868 .data_size = DATA_FRAME_SIZE, 2925 .data_size = DATA_FRAME_SIZE,
2869 .desc_size = TXD_DESC_SIZE, 2926 .desc_size = TXD_DESC_SIZE,
2870 .priv_size = sizeof(struct queue_entry_priv_pci), 2927 .priv_size = sizeof(struct queue_entry_priv_pci),
2871}; 2928};
2872 2929
2873static const struct data_queue_desc rt61pci_queue_bcn = { 2930static const struct data_queue_desc rt61pci_queue_bcn = {
2874 .entry_num = 4 * BEACON_ENTRIES, 2931 .entry_num = 4,
2875 .data_size = 0, /* No DMA required for beacons */ 2932 .data_size = 0, /* No DMA required for beacons */
2876 .desc_size = TXINFO_SIZE, 2933 .desc_size = TXINFO_SIZE,
2877 .priv_size = sizeof(struct queue_entry_priv_pci), 2934 .priv_size = sizeof(struct queue_entry_priv_pci),
diff --git a/drivers/net/wireless/rt2x00/rt61pci.h b/drivers/net/wireless/rt2x00/rt61pci.h
index e2e728ab0b2e..e3cd6db76b0e 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.h
+++ b/drivers/net/wireless/rt2x00/rt61pci.h
@@ -412,7 +412,7 @@ struct hw_pairwise_ta_entry {
412 * DROP_VERSION_ERROR: Drop version error frame. 412 * DROP_VERSION_ERROR: Drop version error frame.
413 * DROP_MULTICAST: Drop multicast frames. 413 * DROP_MULTICAST: Drop multicast frames.
414 * DROP_BORADCAST: Drop broadcast frames. 414 * DROP_BORADCAST: Drop broadcast frames.
415 * ROP_ACK_CTS: Drop received ACK and CTS. 415 * DROP_ACK_CTS: Drop received ACK and CTS.
416 */ 416 */
417#define TXRX_CSR0 0x3040 417#define TXRX_CSR0 0x3040
418#define TXRX_CSR0_RX_ACK_TIMEOUT FIELD32(0x000001ff) 418#define TXRX_CSR0_RX_ACK_TIMEOUT FIELD32(0x000001ff)
@@ -784,25 +784,25 @@ struct hw_pairwise_ta_entry {
784 */ 784 */
785 785
786/* 786/*
787 * AC0_BASE_CSR: AC_BK base address. 787 * AC0_BASE_CSR: AC_VO base address.
788 */ 788 */
789#define AC0_BASE_CSR 0x3400 789#define AC0_BASE_CSR 0x3400
790#define AC0_BASE_CSR_RING_REGISTER FIELD32(0xffffffff) 790#define AC0_BASE_CSR_RING_REGISTER FIELD32(0xffffffff)
791 791
792/* 792/*
793 * AC1_BASE_CSR: AC_BE base address. 793 * AC1_BASE_CSR: AC_VI base address.
794 */ 794 */
795#define AC1_BASE_CSR 0x3404 795#define AC1_BASE_CSR 0x3404
796#define AC1_BASE_CSR_RING_REGISTER FIELD32(0xffffffff) 796#define AC1_BASE_CSR_RING_REGISTER FIELD32(0xffffffff)
797 797
798/* 798/*
799 * AC2_BASE_CSR: AC_VI base address. 799 * AC2_BASE_CSR: AC_BE base address.
800 */ 800 */
801#define AC2_BASE_CSR 0x3408 801#define AC2_BASE_CSR 0x3408
802#define AC2_BASE_CSR_RING_REGISTER FIELD32(0xffffffff) 802#define AC2_BASE_CSR_RING_REGISTER FIELD32(0xffffffff)
803 803
804/* 804/*
805 * AC3_BASE_CSR: AC_VO base address. 805 * AC3_BASE_CSR: AC_BK base address.
806 */ 806 */
807#define AC3_BASE_CSR 0x340c 807#define AC3_BASE_CSR 0x340c
808#define AC3_BASE_CSR_RING_REGISTER FIELD32(0xffffffff) 808#define AC3_BASE_CSR_RING_REGISTER FIELD32(0xffffffff)
@@ -814,7 +814,7 @@ struct hw_pairwise_ta_entry {
814#define MGMT_BASE_CSR_RING_REGISTER FIELD32(0xffffffff) 814#define MGMT_BASE_CSR_RING_REGISTER FIELD32(0xffffffff)
815 815
816/* 816/*
817 * TX_RING_CSR0: TX Ring size for AC_BK, AC_BE, AC_VI, AC_VO. 817 * TX_RING_CSR0: TX Ring size for AC_VO, AC_VI, AC_BE, AC_BK.
818 */ 818 */
819#define TX_RING_CSR0 0x3418 819#define TX_RING_CSR0 0x3418
820#define TX_RING_CSR0_AC0_RING_SIZE FIELD32(0x000000ff) 820#define TX_RING_CSR0_AC0_RING_SIZE FIELD32(0x000000ff)
@@ -833,10 +833,10 @@ struct hw_pairwise_ta_entry {
833 833
834/* 834/*
835 * AIFSN_CSR: AIFSN for each EDCA AC. 835 * AIFSN_CSR: AIFSN for each EDCA AC.
836 * AIFSN0: For AC_BK. 836 * AIFSN0: For AC_VO.
837 * AIFSN1: For AC_BE. 837 * AIFSN1: For AC_VI.
838 * AIFSN2: For AC_VI. 838 * AIFSN2: For AC_BE.
839 * AIFSN3: For AC_VO. 839 * AIFSN3: For AC_BK.
840 */ 840 */
841#define AIFSN_CSR 0x3420 841#define AIFSN_CSR 0x3420
842#define AIFSN_CSR_AIFSN0 FIELD32(0x0000000f) 842#define AIFSN_CSR_AIFSN0 FIELD32(0x0000000f)
@@ -846,10 +846,10 @@ struct hw_pairwise_ta_entry {
846 846
847/* 847/*
848 * CWMIN_CSR: CWmin for each EDCA AC. 848 * CWMIN_CSR: CWmin for each EDCA AC.
849 * CWMIN0: For AC_BK. 849 * CWMIN0: For AC_VO.
850 * CWMIN1: For AC_BE. 850 * CWMIN1: For AC_VI.
851 * CWMIN2: For AC_VI. 851 * CWMIN2: For AC_BE.
852 * CWMIN3: For AC_VO. 852 * CWMIN3: For AC_BK.
853 */ 853 */
854#define CWMIN_CSR 0x3424 854#define CWMIN_CSR 0x3424
855#define CWMIN_CSR_CWMIN0 FIELD32(0x0000000f) 855#define CWMIN_CSR_CWMIN0 FIELD32(0x0000000f)
@@ -859,10 +859,10 @@ struct hw_pairwise_ta_entry {
859 859
860/* 860/*
861 * CWMAX_CSR: CWmax for each EDCA AC. 861 * CWMAX_CSR: CWmax for each EDCA AC.
862 * CWMAX0: For AC_BK. 862 * CWMAX0: For AC_VO.
863 * CWMAX1: For AC_BE. 863 * CWMAX1: For AC_VI.
864 * CWMAX2: For AC_VI. 864 * CWMAX2: For AC_BE.
865 * CWMAX3: For AC_VO. 865 * CWMAX3: For AC_BK.
866 */ 866 */
867#define CWMAX_CSR 0x3428 867#define CWMAX_CSR 0x3428
868#define CWMAX_CSR_CWMAX0 FIELD32(0x0000000f) 868#define CWMAX_CSR_CWMAX0 FIELD32(0x0000000f)
@@ -883,14 +883,14 @@ struct hw_pairwise_ta_entry {
883 883
884/* 884/*
885 * TX_CNTL_CSR: KICK/Abort TX. 885 * TX_CNTL_CSR: KICK/Abort TX.
886 * KICK_TX_AC0: For AC_BK. 886 * KICK_TX_AC0: For AC_VO.
887 * KICK_TX_AC1: For AC_BE. 887 * KICK_TX_AC1: For AC_VI.
888 * KICK_TX_AC2: For AC_VI. 888 * KICK_TX_AC2: For AC_BE.
889 * KICK_TX_AC3: For AC_VO. 889 * KICK_TX_AC3: For AC_BK.
890 * ABORT_TX_AC0: For AC_BK. 890 * ABORT_TX_AC0: For AC_VO.
891 * ABORT_TX_AC1: For AC_BE. 891 * ABORT_TX_AC1: For AC_VI.
892 * ABORT_TX_AC2: For AC_VI. 892 * ABORT_TX_AC2: For AC_BE.
893 * ABORT_TX_AC3: For AC_VO. 893 * ABORT_TX_AC3: For AC_BK.
894 */ 894 */
895#define TX_CNTL_CSR 0x3430 895#define TX_CNTL_CSR 0x3430
896#define TX_CNTL_CSR_KICK_TX_AC0 FIELD32(0x00000001) 896#define TX_CNTL_CSR_KICK_TX_AC0 FIELD32(0x00000001)
@@ -1010,18 +1010,18 @@ struct hw_pairwise_ta_entry {
1010#define E2PROM_CSR_LOAD_STATUS FIELD32(0x00000040) 1010#define E2PROM_CSR_LOAD_STATUS FIELD32(0x00000040)
1011 1011
1012/* 1012/*
1013 * AC_TXOP_CSR0: AC_BK/AC_BE TXOP register. 1013 * AC_TXOP_CSR0: AC_VO/AC_VI TXOP register.
1014 * AC0_TX_OP: For AC_BK, in unit of 32us. 1014 * AC0_TX_OP: For AC_VO, in unit of 32us.
1015 * AC1_TX_OP: For AC_BE, in unit of 32us. 1015 * AC1_TX_OP: For AC_VI, in unit of 32us.
1016 */ 1016 */
1017#define AC_TXOP_CSR0 0x3474 1017#define AC_TXOP_CSR0 0x3474
1018#define AC_TXOP_CSR0_AC0_TX_OP FIELD32(0x0000ffff) 1018#define AC_TXOP_CSR0_AC0_TX_OP FIELD32(0x0000ffff)
1019#define AC_TXOP_CSR0_AC1_TX_OP FIELD32(0xffff0000) 1019#define AC_TXOP_CSR0_AC1_TX_OP FIELD32(0xffff0000)
1020 1020
1021/* 1021/*
1022 * AC_TXOP_CSR1: AC_VO/AC_VI TXOP register. 1022 * AC_TXOP_CSR1: AC_BE/AC_BK TXOP register.
1023 * AC2_TX_OP: For AC_VI, in unit of 32us. 1023 * AC2_TX_OP: For AC_BE, in unit of 32us.
1024 * AC3_TX_OP: For AC_VO, in unit of 32us. 1024 * AC3_TX_OP: For AC_BK, in unit of 32us.
1025 */ 1025 */
1026#define AC_TXOP_CSR1 0x3478 1026#define AC_TXOP_CSR1 0x3478
1027#define AC_TXOP_CSR1_AC2_TX_OP FIELD32(0x0000ffff) 1027#define AC_TXOP_CSR1_AC2_TX_OP FIELD32(0x0000ffff)
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 9be8089317e4..0b4e8590cbb7 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -40,7 +40,7 @@
40/* 40/*
41 * Allow hardware encryption to be disabled. 41 * Allow hardware encryption to be disabled.
42 */ 42 */
43static int modparam_nohwcrypt = 0; 43static int modparam_nohwcrypt;
44module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO); 44module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO);
45MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption."); 45MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
46 46
@@ -1031,6 +1031,55 @@ dynamic_cca_tune:
1031} 1031}
1032 1032
1033/* 1033/*
1034 * Queue handlers.
1035 */
1036static void rt73usb_start_queue(struct data_queue *queue)
1037{
1038 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1039 u32 reg;
1040
1041 switch (queue->qid) {
1042 case QID_RX:
1043 rt2x00usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
1044 rt2x00_set_field32(&reg, TXRX_CSR0_DISABLE_RX, 0);
1045 rt2x00usb_register_write(rt2x00dev, TXRX_CSR0, reg);
1046 break;
1047 case QID_BEACON:
1048 rt2x00usb_register_read(rt2x00dev, TXRX_CSR9, &reg);
1049 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 1);
1050 rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 1);
1051 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 1);
1052 rt2x00usb_register_write(rt2x00dev, TXRX_CSR9, reg);
1053 break;
1054 default:
1055 break;
1056 }
1057}
1058
1059static void rt73usb_stop_queue(struct data_queue *queue)
1060{
1061 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1062 u32 reg;
1063
1064 switch (queue->qid) {
1065 case QID_RX:
1066 rt2x00usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
1067 rt2x00_set_field32(&reg, TXRX_CSR0_DISABLE_RX, 1);
1068 rt2x00usb_register_write(rt2x00dev, TXRX_CSR0, reg);
1069 break;
1070 case QID_BEACON:
1071 rt2x00usb_register_read(rt2x00dev, TXRX_CSR9, &reg);
1072 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 0);
1073 rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 0);
1074 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0);
1075 rt2x00usb_register_write(rt2x00dev, TXRX_CSR9, reg);
1076 break;
1077 default:
1078 break;
1079 }
1080}
1081
1082/*
1034 * Firmware functions 1083 * Firmware functions
1035 */ 1084 */
1036static char *rt73usb_get_firmware_name(struct rt2x00_dev *rt2x00dev) 1085static char *rt73usb_get_firmware_name(struct rt2x00_dev *rt2x00dev)
@@ -1324,18 +1373,6 @@ static int rt73usb_init_bbp(struct rt2x00_dev *rt2x00dev)
1324/* 1373/*
1325 * Device state switch handlers. 1374 * Device state switch handlers.
1326 */ 1375 */
1327static void rt73usb_toggle_rx(struct rt2x00_dev *rt2x00dev,
1328 enum dev_state state)
1329{
1330 u32 reg;
1331
1332 rt2x00usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
1333 rt2x00_set_field32(&reg, TXRX_CSR0_DISABLE_RX,
1334 (state == STATE_RADIO_RX_OFF) ||
1335 (state == STATE_RADIO_RX_OFF_LINK));
1336 rt2x00usb_register_write(rt2x00dev, TXRX_CSR0, reg);
1337}
1338
1339static int rt73usb_enable_radio(struct rt2x00_dev *rt2x00dev) 1376static int rt73usb_enable_radio(struct rt2x00_dev *rt2x00dev)
1340{ 1377{
1341 /* 1378 /*
@@ -1402,12 +1439,6 @@ static int rt73usb_set_device_state(struct rt2x00_dev *rt2x00dev,
1402 case STATE_RADIO_OFF: 1439 case STATE_RADIO_OFF:
1403 rt73usb_disable_radio(rt2x00dev); 1440 rt73usb_disable_radio(rt2x00dev);
1404 break; 1441 break;
1405 case STATE_RADIO_RX_ON:
1406 case STATE_RADIO_RX_ON_LINK:
1407 case STATE_RADIO_RX_OFF:
1408 case STATE_RADIO_RX_OFF_LINK:
1409 rt73usb_toggle_rx(rt2x00dev, state);
1410 break;
1411 case STATE_RADIO_IRQ_ON: 1442 case STATE_RADIO_IRQ_ON:
1412 case STATE_RADIO_IRQ_ON_ISR: 1443 case STATE_RADIO_IRQ_ON_ISR:
1413 case STATE_RADIO_IRQ_OFF: 1444 case STATE_RADIO_IRQ_OFF:
@@ -1472,10 +1503,10 @@ static void rt73usb_write_tx_desc(struct queue_entry *entry,
1472 rt2x00_desc_write(txd, 0, word); 1503 rt2x00_desc_write(txd, 0, word);
1473 1504
1474 rt2x00_desc_read(txd, 1, &word); 1505 rt2x00_desc_read(txd, 1, &word);
1475 rt2x00_set_field32(&word, TXD_W1_HOST_Q_ID, txdesc->qid); 1506 rt2x00_set_field32(&word, TXD_W1_HOST_Q_ID, entry->queue->qid);
1476 rt2x00_set_field32(&word, TXD_W1_AIFSN, txdesc->aifs); 1507 rt2x00_set_field32(&word, TXD_W1_AIFSN, entry->queue->aifs);
1477 rt2x00_set_field32(&word, TXD_W1_CWMIN, txdesc->cw_min); 1508 rt2x00_set_field32(&word, TXD_W1_CWMIN, entry->queue->cw_min);
1478 rt2x00_set_field32(&word, TXD_W1_CWMAX, txdesc->cw_max); 1509 rt2x00_set_field32(&word, TXD_W1_CWMAX, entry->queue->cw_max);
1479 rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, txdesc->iv_offset); 1510 rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, txdesc->iv_offset);
1480 rt2x00_set_field32(&word, TXD_W1_HW_SEQUENCE, 1511 rt2x00_set_field32(&word, TXD_W1_HW_SEQUENCE,
1481 test_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags)); 1512 test_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags));
@@ -1515,6 +1546,7 @@ static void rt73usb_write_beacon(struct queue_entry *entry,
1515{ 1546{
1516 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 1547 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1517 unsigned int beacon_base; 1548 unsigned int beacon_base;
1549 unsigned int padding_len;
1518 u32 reg; 1550 u32 reg;
1519 1551
1520 /* 1552 /*
@@ -1542,11 +1574,13 @@ static void rt73usb_write_beacon(struct queue_entry *entry,
1542 rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry->skb); 1574 rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry->skb);
1543 1575
1544 /* 1576 /*
1545 * Write entire beacon with descriptor to register. 1577 * Write entire beacon with descriptor and padding to register.
1546 */ 1578 */
1579 padding_len = roundup(entry->skb->len, 4) - entry->skb->len;
1580 skb_pad(entry->skb, padding_len);
1547 beacon_base = HW_BEACON_OFFSET(entry->entry_idx); 1581 beacon_base = HW_BEACON_OFFSET(entry->entry_idx);
1548 rt2x00usb_register_multiwrite(rt2x00dev, beacon_base, 1582 rt2x00usb_register_multiwrite(rt2x00dev, beacon_base, entry->skb->data,
1549 entry->skb->data, entry->skb->len); 1583 entry->skb->len + padding_len);
1550 1584
1551 /* 1585 /*
1552 * Enable beaconing again. 1586 * Enable beaconing again.
@@ -1582,14 +1616,6 @@ static int rt73usb_get_tx_data_len(struct queue_entry *entry)
1582 return length; 1616 return length;
1583} 1617}
1584 1618
1585static void rt73usb_kill_tx_queue(struct data_queue *queue)
1586{
1587 if (queue->qid == QID_BEACON)
1588 rt2x00usb_register_write(queue->rt2x00dev, TXRX_CSR9, 0);
1589
1590 rt2x00usb_kill_tx_queue(queue);
1591}
1592
1593/* 1619/*
1594 * RX control handlers 1620 * RX control handlers
1595 */ 1621 */
@@ -2264,6 +2290,7 @@ static const struct ieee80211_ops rt73usb_mac80211_ops = {
2264 .conf_tx = rt73usb_conf_tx, 2290 .conf_tx = rt73usb_conf_tx,
2265 .get_tsf = rt73usb_get_tsf, 2291 .get_tsf = rt73usb_get_tsf,
2266 .rfkill_poll = rt2x00mac_rfkill_poll, 2292 .rfkill_poll = rt2x00mac_rfkill_poll,
2293 .flush = rt2x00mac_flush,
2267}; 2294};
2268 2295
2269static const struct rt2x00lib_ops rt73usb_rt2x00_ops = { 2296static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
@@ -2280,11 +2307,13 @@ static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
2280 .reset_tuner = rt73usb_reset_tuner, 2307 .reset_tuner = rt73usb_reset_tuner,
2281 .link_tuner = rt73usb_link_tuner, 2308 .link_tuner = rt73usb_link_tuner,
2282 .watchdog = rt2x00usb_watchdog, 2309 .watchdog = rt2x00usb_watchdog,
2310 .start_queue = rt73usb_start_queue,
2311 .kick_queue = rt2x00usb_kick_queue,
2312 .stop_queue = rt73usb_stop_queue,
2313 .flush_queue = rt2x00usb_flush_queue,
2283 .write_tx_desc = rt73usb_write_tx_desc, 2314 .write_tx_desc = rt73usb_write_tx_desc,
2284 .write_beacon = rt73usb_write_beacon, 2315 .write_beacon = rt73usb_write_beacon,
2285 .get_tx_data_len = rt73usb_get_tx_data_len, 2316 .get_tx_data_len = rt73usb_get_tx_data_len,
2286 .kick_tx_queue = rt2x00usb_kick_tx_queue,
2287 .kill_tx_queue = rt73usb_kill_tx_queue,
2288 .fill_rxdone = rt73usb_fill_rxdone, 2317 .fill_rxdone = rt73usb_fill_rxdone,
2289 .config_shared_key = rt73usb_config_shared_key, 2318 .config_shared_key = rt73usb_config_shared_key,
2290 .config_pairwise_key = rt73usb_config_pairwise_key, 2319 .config_pairwise_key = rt73usb_config_pairwise_key,
@@ -2296,21 +2325,21 @@ static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
2296}; 2325};
2297 2326
2298static const struct data_queue_desc rt73usb_queue_rx = { 2327static const struct data_queue_desc rt73usb_queue_rx = {
2299 .entry_num = RX_ENTRIES, 2328 .entry_num = 32,
2300 .data_size = DATA_FRAME_SIZE, 2329 .data_size = DATA_FRAME_SIZE,
2301 .desc_size = RXD_DESC_SIZE, 2330 .desc_size = RXD_DESC_SIZE,
2302 .priv_size = sizeof(struct queue_entry_priv_usb), 2331 .priv_size = sizeof(struct queue_entry_priv_usb),
2303}; 2332};
2304 2333
2305static const struct data_queue_desc rt73usb_queue_tx = { 2334static const struct data_queue_desc rt73usb_queue_tx = {
2306 .entry_num = TX_ENTRIES, 2335 .entry_num = 32,
2307 .data_size = DATA_FRAME_SIZE, 2336 .data_size = DATA_FRAME_SIZE,
2308 .desc_size = TXD_DESC_SIZE, 2337 .desc_size = TXD_DESC_SIZE,
2309 .priv_size = sizeof(struct queue_entry_priv_usb), 2338 .priv_size = sizeof(struct queue_entry_priv_usb),
2310}; 2339};
2311 2340
2312static const struct data_queue_desc rt73usb_queue_bcn = { 2341static const struct data_queue_desc rt73usb_queue_bcn = {
2313 .entry_num = 4 * BEACON_ENTRIES, 2342 .entry_num = 4,
2314 .data_size = MGMT_FRAME_SIZE, 2343 .data_size = MGMT_FRAME_SIZE,
2315 .desc_size = TXINFO_SIZE, 2344 .desc_size = TXINFO_SIZE,
2316 .priv_size = sizeof(struct queue_entry_priv_usb), 2345 .priv_size = sizeof(struct queue_entry_priv_usb),
diff --git a/drivers/net/wireless/rt2x00/rt73usb.h b/drivers/net/wireless/rt2x00/rt73usb.h
index 44d5b2bebd39..9f6b470414d3 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.h
+++ b/drivers/net/wireless/rt2x00/rt73usb.h
@@ -322,7 +322,7 @@ struct hw_pairwise_ta_entry {
322 * DROP_VERSION_ERROR: Drop version error frame. 322 * DROP_VERSION_ERROR: Drop version error frame.
323 * DROP_MULTICAST: Drop multicast frames. 323 * DROP_MULTICAST: Drop multicast frames.
324 * DROP_BORADCAST: Drop broadcast frames. 324 * DROP_BORADCAST: Drop broadcast frames.
325 * ROP_ACK_CTS: Drop received ACK and CTS. 325 * DROP_ACK_CTS: Drop received ACK and CTS.
326 */ 326 */
327#define TXRX_CSR0 0x3040 327#define TXRX_CSR0 0x3040
328#define TXRX_CSR0_RX_ACK_TIMEOUT FIELD32(0x000001ff) 328#define TXRX_CSR0_RX_ACK_TIMEOUT FIELD32(0x000001ff)
@@ -689,10 +689,10 @@ struct hw_pairwise_ta_entry {
689 689
690/* 690/*
691 * AIFSN_CSR: AIFSN for each EDCA AC. 691 * AIFSN_CSR: AIFSN for each EDCA AC.
692 * AIFSN0: For AC_BK. 692 * AIFSN0: For AC_VO.
693 * AIFSN1: For AC_BE. 693 * AIFSN1: For AC_VI.
694 * AIFSN2: For AC_VI. 694 * AIFSN2: For AC_BE.
695 * AIFSN3: For AC_VO. 695 * AIFSN3: For AC_BK.
696 */ 696 */
697#define AIFSN_CSR 0x0400 697#define AIFSN_CSR 0x0400
698#define AIFSN_CSR_AIFSN0 FIELD32(0x0000000f) 698#define AIFSN_CSR_AIFSN0 FIELD32(0x0000000f)
@@ -702,10 +702,10 @@ struct hw_pairwise_ta_entry {
702 702
703/* 703/*
704 * CWMIN_CSR: CWmin for each EDCA AC. 704 * CWMIN_CSR: CWmin for each EDCA AC.
705 * CWMIN0: For AC_BK. 705 * CWMIN0: For AC_VO.
706 * CWMIN1: For AC_BE. 706 * CWMIN1: For AC_VI.
707 * CWMIN2: For AC_VI. 707 * CWMIN2: For AC_BE.
708 * CWMIN3: For AC_VO. 708 * CWMIN3: For AC_BK.
709 */ 709 */
710#define CWMIN_CSR 0x0404 710#define CWMIN_CSR 0x0404
711#define CWMIN_CSR_CWMIN0 FIELD32(0x0000000f) 711#define CWMIN_CSR_CWMIN0 FIELD32(0x0000000f)
@@ -715,10 +715,10 @@ struct hw_pairwise_ta_entry {
715 715
716/* 716/*
717 * CWMAX_CSR: CWmax for each EDCA AC. 717 * CWMAX_CSR: CWmax for each EDCA AC.
718 * CWMAX0: For AC_BK. 718 * CWMAX0: For AC_VO.
719 * CWMAX1: For AC_BE. 719 * CWMAX1: For AC_VI.
720 * CWMAX2: For AC_VI. 720 * CWMAX2: For AC_BE.
721 * CWMAX3: For AC_VO. 721 * CWMAX3: For AC_BK.
722 */ 722 */
723#define CWMAX_CSR 0x0408 723#define CWMAX_CSR 0x0408
724#define CWMAX_CSR_CWMAX0 FIELD32(0x0000000f) 724#define CWMAX_CSR_CWMAX0 FIELD32(0x0000000f)
@@ -727,18 +727,18 @@ struct hw_pairwise_ta_entry {
727#define CWMAX_CSR_CWMAX3 FIELD32(0x0000f000) 727#define CWMAX_CSR_CWMAX3 FIELD32(0x0000f000)
728 728
729/* 729/*
730 * AC_TXOP_CSR0: AC_BK/AC_BE TXOP register. 730 * AC_TXOP_CSR0: AC_VO/AC_VI TXOP register.
731 * AC0_TX_OP: For AC_BK, in unit of 32us. 731 * AC0_TX_OP: For AC_VO, in unit of 32us.
732 * AC1_TX_OP: For AC_BE, in unit of 32us. 732 * AC1_TX_OP: For AC_VI, in unit of 32us.
733 */ 733 */
734#define AC_TXOP_CSR0 0x040c 734#define AC_TXOP_CSR0 0x040c
735#define AC_TXOP_CSR0_AC0_TX_OP FIELD32(0x0000ffff) 735#define AC_TXOP_CSR0_AC0_TX_OP FIELD32(0x0000ffff)
736#define AC_TXOP_CSR0_AC1_TX_OP FIELD32(0xffff0000) 736#define AC_TXOP_CSR0_AC1_TX_OP FIELD32(0xffff0000)
737 737
738/* 738/*
739 * AC_TXOP_CSR1: AC_VO/AC_VI TXOP register. 739 * AC_TXOP_CSR1: AC_BE/AC_BK TXOP register.
740 * AC2_TX_OP: For AC_VI, in unit of 32us. 740 * AC2_TX_OP: For AC_BE, in unit of 32us.
741 * AC3_TX_OP: For AC_VO, in unit of 32us. 741 * AC3_TX_OP: For AC_BK, in unit of 32us.
742 */ 742 */
743#define AC_TXOP_CSR1 0x0410 743#define AC_TXOP_CSR1 0x0410
744#define AC_TXOP_CSR1_AC2_TX_OP FIELD32(0x0000ffff) 744#define AC_TXOP_CSR1_AC2_TX_OP FIELD32(0x0000ffff)