aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2010-12-13 06:34:22 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-12-13 15:23:35 -0500
commit5450b7e2f0b47e52175b31399d8186a74ef3c46d (patch)
tree4023a3b3cc577d12f1c733a140fce7e965e7eabe /drivers
parent094a1d92fdb18c4455758b1c33e99d647c837ee9 (diff)
rt2x00: Introduce 3 queue commands in drivers (start, kick, stop).
As part of the queue refactoring, we now introduce 3 queue commands: start, kick, stop. - Start: will enable a queue, for TX this will not mean anything, while for beacons and RX this will update the registers to enable the queue. - Kick: This will kick all pending frames to the hardware. This is needed for the TX queue to push all frames to the HW after the queue has been started - Stop: This will stop the queue in the hardware, and cancel any pending work (So this doesn't mean the queue is empty after a stop!). Move all code from the drivers into the appropriate functions, and link those calls to the old rt2x00lib callback functions (we will fix this later when we refactor the queue control inside rt2x00lib). Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c131
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c131
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c84
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.c129
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c84
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.c12
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.h8
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c154
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c84
9 files changed, 530 insertions, 287 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index 62786608951e..35d9a06a76af 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_BE:
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_BK:
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_BE:
694 case QID_AC_BK:
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,17 +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 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
890}
891
892static void rt2400pci_toggle_irq(struct rt2x00_dev *rt2x00dev, 963static void rt2400pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
893 enum dev_state state) 964 enum dev_state state)
894{ 965{
@@ -988,8 +1059,10 @@ static int rt2400pci_set_device_state(struct rt2x00_dev *rt2x00dev,
988 rt2400pci_disable_radio(rt2x00dev); 1059 rt2400pci_disable_radio(rt2x00dev);
989 break; 1060 break;
990 case STATE_RADIO_RX_ON: 1061 case STATE_RADIO_RX_ON:
1062 rt2400pci_start_queue(rt2x00dev->rx);
1063 break;
991 case STATE_RADIO_RX_OFF: 1064 case STATE_RADIO_RX_OFF:
992 rt2400pci_toggle_rx(rt2x00dev, state); 1065 rt2400pci_stop_queue(rt2x00dev->rx);
993 break; 1066 break;
994 case STATE_RADIO_IRQ_ON: 1067 case STATE_RADIO_IRQ_ON:
995 case STATE_RADIO_IRQ_ON_ISR: 1068 case STATE_RADIO_IRQ_ON_ISR:
@@ -1122,36 +1195,6 @@ static void rt2400pci_write_beacon(struct queue_entry *entry,
1122 rt2x00pci_register_write(rt2x00dev, CSR14, reg); 1195 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
1123} 1196}
1124 1197
1125static void rt2400pci_kick_tx_queue(struct data_queue *queue)
1126{
1127 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1128 u32 reg;
1129
1130 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
1131 rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO, (queue->qid == QID_AC_BE));
1132 rt2x00_set_field32(&reg, TXCSR0_KICK_TX, (queue->qid == QID_AC_BK));
1133 rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM, (queue->qid == QID_ATIM));
1134 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
1135}
1136
1137static void rt2400pci_kill_tx_queue(struct data_queue *queue)
1138{
1139 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1140 u32 reg;
1141
1142 if (queue->qid == QID_BEACON) {
1143 rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
1144 rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 0);
1145 rt2x00_set_field32(&reg, CSR14_TBCN, 0);
1146 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
1147 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
1148 } else {
1149 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
1150 rt2x00_set_field32(&reg, TXCSR0_ABORT, 1);
1151 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
1152 }
1153}
1154
1155/* 1198/*
1156 * RX control handlers 1199 * RX control handlers
1157 */ 1200 */
@@ -1631,8 +1674,8 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
1631 .link_tuner = rt2400pci_link_tuner, 1674 .link_tuner = rt2400pci_link_tuner,
1632 .write_tx_desc = rt2400pci_write_tx_desc, 1675 .write_tx_desc = rt2400pci_write_tx_desc,
1633 .write_beacon = rt2400pci_write_beacon, 1676 .write_beacon = rt2400pci_write_beacon,
1634 .kick_tx_queue = rt2400pci_kick_tx_queue, 1677 .kick_tx_queue = rt2400pci_kick_queue,
1635 .kill_tx_queue = rt2400pci_kill_tx_queue, 1678 .kill_tx_queue = rt2400pci_stop_queue,
1636 .fill_rxdone = rt2400pci_fill_rxdone, 1679 .fill_rxdone = rt2400pci_fill_rxdone,
1637 .config_filter = rt2400pci_config_filter, 1680 .config_filter = rt2400pci_config_filter,
1638 .config_intf = rt2400pci_config_intf, 1681 .config_intf = rt2400pci_config_intf,
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index ce9212f28207..bee7ce14028d 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_BE:
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_BK:
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_BE:
784 case QID_AC_BK:
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,17 +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 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
1045}
1046
1047static void rt2500pci_toggle_irq(struct rt2x00_dev *rt2x00dev, 1118static void rt2500pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
1048 enum dev_state state) 1119 enum dev_state state)
1049{ 1120{
@@ -1143,8 +1214,10 @@ static int rt2500pci_set_device_state(struct rt2x00_dev *rt2x00dev,
1143 rt2500pci_disable_radio(rt2x00dev); 1214 rt2500pci_disable_radio(rt2x00dev);
1144 break; 1215 break;
1145 case STATE_RADIO_RX_ON: 1216 case STATE_RADIO_RX_ON:
1217 rt2500pci_start_queue(rt2x00dev->rx);
1218 break;
1146 case STATE_RADIO_RX_OFF: 1219 case STATE_RADIO_RX_OFF:
1147 rt2500pci_toggle_rx(rt2x00dev, state); 1220 rt2500pci_stop_queue(rt2x00dev->rx);
1148 break; 1221 break;
1149 case STATE_RADIO_IRQ_ON: 1222 case STATE_RADIO_IRQ_ON:
1150 case STATE_RADIO_IRQ_ON_ISR: 1223 case STATE_RADIO_IRQ_ON_ISR:
@@ -1276,36 +1349,6 @@ static void rt2500pci_write_beacon(struct queue_entry *entry,
1276 rt2x00pci_register_write(rt2x00dev, CSR14, reg); 1349 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
1277} 1350}
1278 1351
1279static void rt2500pci_kick_tx_queue(struct data_queue *queue)
1280{
1281 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1282 u32 reg;
1283
1284 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
1285 rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO, (queue->qid == QID_AC_BE));
1286 rt2x00_set_field32(&reg, TXCSR0_KICK_TX, (queue->qid == QID_AC_BK));
1287 rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM, (queue->qid == QID_ATIM));
1288 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
1289}
1290
1291static void rt2500pci_kill_tx_queue(struct data_queue *queue)
1292{
1293 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1294 u32 reg;
1295
1296 if (queue->qid == QID_BEACON) {
1297 rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
1298 rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 0);
1299 rt2x00_set_field32(&reg, CSR14_TBCN, 0);
1300 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
1301 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
1302 } else {
1303 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
1304 rt2x00_set_field32(&reg, TXCSR0_ABORT, 1);
1305 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
1306 }
1307}
1308
1309/* 1352/*
1310 * RX control handlers 1353 * RX control handlers
1311 */ 1354 */
@@ -1928,8 +1971,8 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = {
1928 .link_tuner = rt2500pci_link_tuner, 1971 .link_tuner = rt2500pci_link_tuner,
1929 .write_tx_desc = rt2500pci_write_tx_desc, 1972 .write_tx_desc = rt2500pci_write_tx_desc,
1930 .write_beacon = rt2500pci_write_beacon, 1973 .write_beacon = rt2500pci_write_beacon,
1931 .kick_tx_queue = rt2500pci_kick_tx_queue, 1974 .kick_tx_queue = rt2500pci_kick_queue,
1932 .kill_tx_queue = rt2500pci_kill_tx_queue, 1975 .kill_tx_queue = rt2500pci_stop_queue,
1933 .fill_rxdone = rt2500pci_fill_rxdone, 1976 .fill_rxdone = rt2500pci_fill_rxdone,
1934 .config_filter = rt2500pci_config_filter, 1977 .config_filter = rt2500pci_config_filter,
1935 .config_intf = rt2500pci_config_intf, 1978 .config_intf = rt2500pci_config_intf,
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index bbfa671f1152..52bd0ed0872b 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -739,6 +739,57 @@ 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 rt2x00usb_stop_queue(queue);
790}
791
792/*
742 * Initialization functions. 793 * Initialization functions.
743 */ 794 */
744static int rt2500usb_init_registers(struct rt2x00_dev *rt2x00dev) 795static int rt2500usb_init_registers(struct rt2x00_dev *rt2x00dev)
@@ -931,17 +982,6 @@ static int rt2500usb_init_bbp(struct rt2x00_dev *rt2x00dev)
931/* 982/*
932 * Device state switch handlers. 983 * Device state switch handlers.
933 */ 984 */
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 rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg);
943}
944
945static int rt2500usb_enable_radio(struct rt2x00_dev *rt2x00dev) 985static int rt2500usb_enable_radio(struct rt2x00_dev *rt2x00dev)
946{ 986{
947 /* 987 /*
@@ -1018,8 +1058,10 @@ static int rt2500usb_set_device_state(struct rt2x00_dev *rt2x00dev,
1018 rt2500usb_disable_radio(rt2x00dev); 1058 rt2500usb_disable_radio(rt2x00dev);
1019 break; 1059 break;
1020 case STATE_RADIO_RX_ON: 1060 case STATE_RADIO_RX_ON:
1061 rt2500usb_start_queue(rt2x00dev->rx);
1062 break;
1021 case STATE_RADIO_RX_OFF: 1063 case STATE_RADIO_RX_OFF:
1022 rt2500usb_toggle_rx(rt2x00dev, state); 1064 rt2500usb_stop_queue(rt2x00dev->rx);
1023 break; 1065 break;
1024 case STATE_RADIO_IRQ_ON: 1066 case STATE_RADIO_IRQ_ON:
1025 case STATE_RADIO_IRQ_ON_ISR: 1067 case STATE_RADIO_IRQ_ON_ISR:
@@ -1203,22 +1245,6 @@ static int rt2500usb_get_tx_data_len(struct queue_entry *entry)
1203 return length; 1245 return length;
1204} 1246}
1205 1247
1206static void rt2500usb_kill_tx_queue(struct data_queue *queue)
1207{
1208 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1209 u16 reg;
1210
1211 if (queue->qid == QID_BEACON) {
1212 rt2500usb_register_read(rt2x00dev, TXRX_CSR19, &reg);
1213 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_COUNT, 0);
1214 rt2x00_set_field16(&reg, TXRX_CSR19_TBCN, 0);
1215 rt2x00_set_field16(&reg, TXRX_CSR19_BEACON_GEN, 0);
1216 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
1217 }
1218
1219 rt2x00usb_kill_tx_queue(queue);
1220}
1221
1222/* 1248/*
1223 * RX control handlers 1249 * RX control handlers
1224 */ 1250 */
@@ -1823,7 +1849,7 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
1823 .write_beacon = rt2500usb_write_beacon, 1849 .write_beacon = rt2500usb_write_beacon,
1824 .get_tx_data_len = rt2500usb_get_tx_data_len, 1850 .get_tx_data_len = rt2500usb_get_tx_data_len,
1825 .kick_tx_queue = rt2x00usb_kick_tx_queue, 1851 .kick_tx_queue = rt2x00usb_kick_tx_queue,
1826 .kill_tx_queue = rt2500usb_kill_tx_queue, 1852 .kill_tx_queue = rt2500usb_stop_queue,
1827 .fill_rxdone = rt2500usb_fill_rxdone, 1853 .fill_rxdone = rt2500usb_fill_rxdone,
1828 .config_shared_key = rt2500usb_config_key, 1854 .config_shared_key = rt2500usb_config_key,
1829 .config_pairwise_key = rt2500usb_config_key, 1855 .config_pairwise_key = rt2500usb_config_key,
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index 49447222e40f..a7105974a2a1 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -186,6 +186,77 @@ static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
186#endif /* CONFIG_PCI */ 186#endif /* CONFIG_PCI */
187 187
188/* 188/*
189 * Queue handlers.
190 */
191static void rt2800pci_start_queue(struct data_queue *queue)
192{
193 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
194 u32 reg;
195
196 switch (queue->qid) {
197 case QID_RX:
198 rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
199 rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX, 1);
200 rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
201 break;
202 case QID_BEACON:
203 rt2800_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
204 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 1);
205 rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 1);
206 rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 1);
207 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg);
208 break;
209 default:
210 break;
211 };
212}
213
214static void rt2800pci_kick_queue(struct data_queue *queue)
215{
216 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
217 struct queue_entry *entry;
218
219 switch (queue->qid) {
220 case QID_AC_BE:
221 case QID_AC_BK:
222 case QID_AC_VI:
223 case QID_AC_VO:
224 entry = rt2x00queue_get_entry(queue, Q_INDEX);
225 rt2800_register_write(rt2x00dev, TX_CTX_IDX(queue->qid), entry->entry_idx);
226 break;
227 case QID_MGMT:
228 entry = rt2x00queue_get_entry(queue, Q_INDEX);
229 rt2800_register_write(rt2x00dev, TX_CTX_IDX(5), entry->entry_idx);
230 break;
231 default:
232 break;
233 }
234}
235
236static void rt2800pci_stop_queue(struct data_queue *queue)
237{
238 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
239 u32 reg;
240
241 switch (queue->qid) {
242 case QID_RX:
243 rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
244 rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX, 0);
245 rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
246 break;
247 case QID_BEACON:
248 rt2800_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
249 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 0);
250 rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 0);
251 rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 0);
252 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg);
253 break;
254 default:
255 break;
256 }
257}
258
259/*
189 * Firmware functions 260 * Firmware functions
190 */ 261 */
191static char *rt2800pci_get_firmware_name(struct rt2x00_dev *rt2x00dev) 262static char *rt2800pci_get_firmware_name(struct rt2x00_dev *rt2x00dev)
@@ -323,17 +394,6 @@ static int rt2800pci_init_queues(struct rt2x00_dev *rt2x00dev)
323/* 394/*
324 * Device state switch handlers. 395 * Device state switch handlers.
325 */ 396 */
326static void rt2800pci_toggle_rx(struct rt2x00_dev *rt2x00dev,
327 enum dev_state state)
328{
329 u32 reg;
330
331 rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
332 rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX,
333 (state == STATE_RADIO_RX_ON));
334 rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
335}
336
337static void rt2800pci_toggle_irq(struct rt2x00_dev *rt2x00dev, 397static void rt2800pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
338 enum dev_state state) 398 enum dev_state state)
339{ 399{
@@ -478,8 +538,10 @@ static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev,
478 rt2800pci_set_state(rt2x00dev, STATE_SLEEP); 538 rt2800pci_set_state(rt2x00dev, STATE_SLEEP);
479 break; 539 break;
480 case STATE_RADIO_RX_ON: 540 case STATE_RADIO_RX_ON:
541 rt2800pci_start_queue(rt2x00dev->rx);
542 break;
481 case STATE_RADIO_RX_OFF: 543 case STATE_RADIO_RX_OFF:
482 rt2800pci_toggle_rx(rt2x00dev, state); 544 rt2800pci_stop_queue(rt2x00dev->rx);
483 break; 545 break;
484 case STATE_RADIO_IRQ_ON: 546 case STATE_RADIO_IRQ_ON:
485 case STATE_RADIO_IRQ_ON_ISR: 547 case STATE_RADIO_IRQ_ON_ISR:
@@ -566,45 +628,6 @@ static void rt2800pci_write_tx_desc(struct queue_entry *entry,
566} 628}
567 629
568/* 630/*
569 * TX data initialization
570 */
571static void rt2800pci_kick_tx_queue(struct data_queue *queue)
572{
573 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
574 struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX);
575 unsigned int qidx;
576
577 if (queue->qid == QID_MGMT)
578 qidx = 5;
579 else
580 qidx = queue->qid;
581
582 rt2800_register_write(rt2x00dev, TX_CTX_IDX(qidx), entry->entry_idx);
583}
584
585static void rt2800pci_kill_tx_queue(struct data_queue *queue)
586{
587 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
588 u32 reg;
589
590 if (queue->qid == QID_BEACON) {
591 rt2800_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
592 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 0);
593 rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 0);
594 rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 0);
595 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg);
596 return;
597 }
598
599 rt2800_register_read(rt2x00dev, WPDMA_RST_IDX, &reg);
600 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX0, (queue->qid == QID_AC_BE));
601 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX1, (queue->qid == QID_AC_BK));
602 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX2, (queue->qid == QID_AC_VI));
603 rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX3, (queue->qid == QID_AC_VO));
604 rt2800_register_write(rt2x00dev, WPDMA_RST_IDX, reg);
605}
606
607/*
608 * RX control handlers 631 * RX control handlers
609 */ 632 */
610static void rt2800pci_fill_rxdone(struct queue_entry *entry, 633static void rt2800pci_fill_rxdone(struct queue_entry *entry,
@@ -984,8 +1007,8 @@ static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = {
984 .write_tx_desc = rt2800pci_write_tx_desc, 1007 .write_tx_desc = rt2800pci_write_tx_desc,
985 .write_tx_data = rt2800_write_tx_data, 1008 .write_tx_data = rt2800_write_tx_data,
986 .write_beacon = rt2800_write_beacon, 1009 .write_beacon = rt2800_write_beacon,
987 .kick_tx_queue = rt2800pci_kick_tx_queue, 1010 .kick_tx_queue = rt2800pci_kick_queue,
988 .kill_tx_queue = rt2800pci_kill_tx_queue, 1011 .kill_tx_queue = rt2800pci_stop_queue,
989 .fill_rxdone = rt2800pci_fill_rxdone, 1012 .fill_rxdone = rt2800pci_fill_rxdone,
990 .config_shared_key = rt2800_config_shared_key, 1013 .config_shared_key = rt2800_config_shared_key,
991 .config_pairwise_key = rt2800_config_pairwise_key, 1014 .config_pairwise_key = rt2800_config_pairwise_key,
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index 1dfa59da9272..ee51936d8d1b 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -50,6 +50,57 @@ module_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 rt2x00usb_stop_queue(queue);
101}
102
103/*
53 * Firmware functions 104 * Firmware functions
54 */ 105 */
55static char *rt2800usb_get_firmware_name(struct rt2x00_dev *rt2x00dev) 106static char *rt2800usb_get_firmware_name(struct rt2x00_dev *rt2x00dev)
@@ -107,17 +158,6 @@ static int rt2800usb_write_firmware(struct rt2x00_dev *rt2x00dev,
107/* 158/*
108 * Device state switch handlers. 159 * Device state switch handlers.
109 */ 160 */
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 rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
119}
120
121static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev) 161static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev)
122{ 162{
123 u32 reg; 163 u32 reg;
@@ -215,8 +255,10 @@ static int rt2800usb_set_device_state(struct rt2x00_dev *rt2x00dev,
215 rt2800usb_set_state(rt2x00dev, STATE_SLEEP); 255 rt2800usb_set_state(rt2x00dev, STATE_SLEEP);
216 break; 256 break;
217 case STATE_RADIO_RX_ON: 257 case STATE_RADIO_RX_ON:
258 rt2800usb_start_queue(rt2x00dev->rx);
259 break;
218 case STATE_RADIO_RX_OFF: 260 case STATE_RADIO_RX_OFF:
219 rt2800usb_toggle_rx(rt2x00dev, state); 261 rt2800usb_stop_queue(rt2x00dev->rx);
220 break; 262 break;
221 case STATE_RADIO_IRQ_ON: 263 case STATE_RADIO_IRQ_ON:
222 case STATE_RADIO_IRQ_ON_ISR: 264 case STATE_RADIO_IRQ_ON_ISR:
@@ -389,22 +431,6 @@ static void rt2800usb_work_txdone(struct work_struct *work)
389 } 431 }
390} 432}
391 433
392static void rt2800usb_kill_tx_queue(struct data_queue *queue)
393{
394 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
395 u32 reg;
396
397 if (queue->qid == QID_BEACON) {
398 rt2800_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
399 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 0);
400 rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 0);
401 rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 0);
402 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg);
403 }
404
405 rt2x00usb_kill_tx_queue(queue);
406}
407
408/* 434/*
409 * RX control handlers 435 * RX control handlers
410 */ 436 */
@@ -605,7 +631,7 @@ static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = {
605 .write_beacon = rt2800_write_beacon, 631 .write_beacon = rt2800_write_beacon,
606 .get_tx_data_len = rt2800usb_get_tx_data_len, 632 .get_tx_data_len = rt2800usb_get_tx_data_len,
607 .kick_tx_queue = rt2x00usb_kick_tx_queue, 633 .kick_tx_queue = rt2x00usb_kick_tx_queue,
608 .kill_tx_queue = rt2800usb_kill_tx_queue, 634 .kill_tx_queue = rt2800usb_stop_queue,
609 .fill_rxdone = rt2800usb_fill_rxdone, 635 .fill_rxdone = rt2800usb_fill_rxdone,
610 .config_shared_key = rt2800_config_shared_key, 636 .config_shared_key = rt2800_config_shared_key,
611 .config_pairwise_key = rt2800_config_pairwise_key, 637 .config_pairwise_key = rt2800_config_pairwise_key,
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index 608200eaf0dc..12958a45e450 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -268,7 +268,7 @@ void rt2x00usb_kick_tx_queue(struct data_queue *queue)
268} 268}
269EXPORT_SYMBOL_GPL(rt2x00usb_kick_tx_queue); 269EXPORT_SYMBOL_GPL(rt2x00usb_kick_tx_queue);
270 270
271static void rt2x00usb_kill_tx_entry(struct queue_entry *entry) 271static void rt2x00usb_kill_entry(struct queue_entry *entry)
272{ 272{
273 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 273 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
274 struct queue_entry_priv_usb *entry_priv = entry->priv_data; 274 struct queue_entry_priv_usb *entry_priv = entry->priv_data;
@@ -287,12 +287,12 @@ static void rt2x00usb_kill_tx_entry(struct queue_entry *entry)
287 usb_kill_urb(bcn_priv->guardian_urb); 287 usb_kill_urb(bcn_priv->guardian_urb);
288} 288}
289 289
290void rt2x00usb_kill_tx_queue(struct data_queue *queue) 290void rt2x00usb_stop_queue(struct data_queue *queue)
291{ 291{
292 rt2x00queue_for_each_entry(queue, Q_INDEX_DONE, Q_INDEX, 292 rt2x00queue_for_each_entry(queue, Q_INDEX_DONE, Q_INDEX,
293 rt2x00usb_kill_tx_entry); 293 rt2x00usb_kill_entry);
294} 294}
295EXPORT_SYMBOL_GPL(rt2x00usb_kill_tx_queue); 295EXPORT_SYMBOL_GPL(rt2x00usb_stop_queue);
296 296
297static void rt2x00usb_watchdog_tx_dma(struct data_queue *queue) 297static void rt2x00usb_watchdog_tx_dma(struct data_queue *queue)
298{ 298{
@@ -316,7 +316,7 @@ static void rt2x00usb_watchdog_tx_dma(struct data_queue *queue)
316 * Kill all entries in the queue, afterwards we need to 316 * Kill all entries in the queue, afterwards we need to
317 * wait a bit for all URBs to be cancelled. 317 * wait a bit for all URBs to be cancelled.
318 */ 318 */
319 rt2x00usb_kill_tx_queue(queue); 319 rt2x00usb_stop_queue(queue);
320 320
321 /* 321 /*
322 * In case that a driver has overriden the txdone_work 322 * In case that a driver has overriden the txdone_work
@@ -423,7 +423,7 @@ void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev)
423 REGISTER_TIMEOUT); 423 REGISTER_TIMEOUT);
424 424
425 /* 425 /*
426 * The USB version of kill_tx_queue also works 426 * The USB version of also works
427 * on the RX queue. 427 * on the RX queue.
428 */ 428 */
429 rt2x00dev->ops->lib->kill_tx_queue(rt2x00dev->rx); 429 rt2x00dev->ops->lib->kill_tx_queue(rt2x00dev->rx);
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.h b/drivers/net/wireless/rt2x00/rt2x00usb.h
index c2d997f67b3e..656a35f421a3 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.h
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.h
@@ -387,13 +387,13 @@ struct queue_entry_priv_usb_bcn {
387void rt2x00usb_kick_tx_queue(struct data_queue *queue); 387void rt2x00usb_kick_tx_queue(struct data_queue *queue);
388 388
389/** 389/**
390 * rt2x00usb_kill_tx_queue - Kill data queue 390 * rt2x00usb_stop_queue - Stop 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_stop_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 6ad0c1c9ce4e..044f500ff1ab 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_BE:
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_BK:
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_VI:
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_VO:
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_BE:
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_BK:
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_VI:
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_VO:
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,17 +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 rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg);
1628}
1629
1630static void rt61pci_toggle_irq(struct rt2x00_dev *rt2x00dev, 1719static void rt61pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
1631 enum dev_state state) 1720 enum dev_state state)
1632{ 1721{
@@ -1744,8 +1833,10 @@ static int rt61pci_set_device_state(struct rt2x00_dev *rt2x00dev,
1744 rt61pci_disable_radio(rt2x00dev); 1833 rt61pci_disable_radio(rt2x00dev);
1745 break; 1834 break;
1746 case STATE_RADIO_RX_ON: 1835 case STATE_RADIO_RX_ON:
1836 rt61pci_start_queue(rt2x00dev->rx);
1837 break;
1747 case STATE_RADIO_RX_OFF: 1838 case STATE_RADIO_RX_OFF:
1748 rt61pci_toggle_rx(rt2x00dev, state); 1839 rt61pci_stop_queue(rt2x00dev->rx);
1749 break; 1840 break;
1750 case STATE_RADIO_IRQ_ON: 1841 case STATE_RADIO_IRQ_ON:
1751 case STATE_RADIO_IRQ_ON_ISR: 1842 case STATE_RADIO_IRQ_ON_ISR:
@@ -1925,41 +2016,6 @@ static void rt61pci_write_beacon(struct queue_entry *entry,
1925 entry->skb = NULL; 2016 entry->skb = NULL;
1926} 2017}
1927 2018
1928static void rt61pci_kick_tx_queue(struct data_queue *queue)
1929{
1930 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1931 u32 reg;
1932
1933 rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg);
1934 rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC0, (queue->qid == QID_AC_BE));
1935 rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC1, (queue->qid == QID_AC_BK));
1936 rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC2, (queue->qid == QID_AC_VI));
1937 rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC3, (queue->qid == QID_AC_VO));
1938 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1939}
1940
1941static void rt61pci_kill_tx_queue(struct data_queue *queue)
1942{
1943 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1944 u32 reg;
1945
1946 if (queue->qid == QID_BEACON) {
1947 rt2x00pci_register_read(rt2x00dev, TXRX_CSR9, &reg);
1948 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 0);
1949 rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 0);
1950 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0);
1951 rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, reg);
1952 return;
1953 }
1954
1955 rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg);
1956 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC0, (queue->qid == QID_AC_BE));
1957 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC1, (queue->qid == QID_AC_BK));
1958 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC2, (queue->qid == QID_AC_VI));
1959 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC3, (queue->qid == QID_AC_VO));
1960 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1961}
1962
1963/* 2019/*
1964 * RX control handlers 2020 * RX control handlers
1965 */ 2021 */
@@ -2846,8 +2902,8 @@ static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
2846 .link_tuner = rt61pci_link_tuner, 2902 .link_tuner = rt61pci_link_tuner,
2847 .write_tx_desc = rt61pci_write_tx_desc, 2903 .write_tx_desc = rt61pci_write_tx_desc,
2848 .write_beacon = rt61pci_write_beacon, 2904 .write_beacon = rt61pci_write_beacon,
2849 .kick_tx_queue = rt61pci_kick_tx_queue, 2905 .kick_tx_queue = rt61pci_kick_queue,
2850 .kill_tx_queue = rt61pci_kill_tx_queue, 2906 .kill_tx_queue = rt61pci_stop_queue,
2851 .fill_rxdone = rt61pci_fill_rxdone, 2907 .fill_rxdone = rt61pci_fill_rxdone,
2852 .config_shared_key = rt61pci_config_shared_key, 2908 .config_shared_key = rt61pci_config_shared_key,
2853 .config_pairwise_key = rt61pci_config_pairwise_key, 2909 .config_pairwise_key = rt61pci_config_pairwise_key,
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 3934dad709c6..e9b1e3d5f47c 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -1031,6 +1031,57 @@ 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 rt2x00usb_stop_queue(queue);
1082}
1083
1084/*
1034 * Firmware functions 1085 * Firmware functions
1035 */ 1086 */
1036static char *rt73usb_get_firmware_name(struct rt2x00_dev *rt2x00dev) 1087static char *rt73usb_get_firmware_name(struct rt2x00_dev *rt2x00dev)
@@ -1324,17 +1375,6 @@ static int rt73usb_init_bbp(struct rt2x00_dev *rt2x00dev)
1324/* 1375/*
1325 * Device state switch handlers. 1376 * Device state switch handlers.
1326 */ 1377 */
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 rt2x00usb_register_write(rt2x00dev, TXRX_CSR0, reg);
1336}
1337
1338static int rt73usb_enable_radio(struct rt2x00_dev *rt2x00dev) 1378static int rt73usb_enable_radio(struct rt2x00_dev *rt2x00dev)
1339{ 1379{
1340 /* 1380 /*
@@ -1402,8 +1442,10 @@ static int rt73usb_set_device_state(struct rt2x00_dev *rt2x00dev,
1402 rt73usb_disable_radio(rt2x00dev); 1442 rt73usb_disable_radio(rt2x00dev);
1403 break; 1443 break;
1404 case STATE_RADIO_RX_ON: 1444 case STATE_RADIO_RX_ON:
1445 rt73usb_start_queue(rt2x00dev->rx);
1446 break;
1405 case STATE_RADIO_RX_OFF: 1447 case STATE_RADIO_RX_OFF:
1406 rt73usb_toggle_rx(rt2x00dev, state); 1448 rt73usb_stop_queue(rt2x00dev->rx);
1407 break; 1449 break;
1408 case STATE_RADIO_IRQ_ON: 1450 case STATE_RADIO_IRQ_ON:
1409 case STATE_RADIO_IRQ_ON_ISR: 1451 case STATE_RADIO_IRQ_ON_ISR:
@@ -1579,22 +1621,6 @@ static int rt73usb_get_tx_data_len(struct queue_entry *entry)
1579 return length; 1621 return length;
1580} 1622}
1581 1623
1582static void rt73usb_kill_tx_queue(struct data_queue *queue)
1583{
1584 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
1585 u32 reg;
1586
1587 if (queue->qid == QID_BEACON) {
1588 rt2x00usb_register_read(rt2x00dev, TXRX_CSR9, &reg);
1589 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 0);
1590 rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 0);
1591 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0);
1592 rt2x00usb_register_write(rt2x00dev, TXRX_CSR9, reg);
1593 }
1594
1595 rt2x00usb_kill_tx_queue(queue);
1596}
1597
1598/* 1624/*
1599 * RX control handlers 1625 * RX control handlers
1600 */ 1626 */
@@ -2290,7 +2316,7 @@ static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
2290 .write_beacon = rt73usb_write_beacon, 2316 .write_beacon = rt73usb_write_beacon,
2291 .get_tx_data_len = rt73usb_get_tx_data_len, 2317 .get_tx_data_len = rt73usb_get_tx_data_len,
2292 .kick_tx_queue = rt2x00usb_kick_tx_queue, 2318 .kick_tx_queue = rt2x00usb_kick_tx_queue,
2293 .kill_tx_queue = rt73usb_kill_tx_queue, 2319 .kill_tx_queue = rt73usb_stop_queue,
2294 .fill_rxdone = rt73usb_fill_rxdone, 2320 .fill_rxdone = rt73usb_fill_rxdone,
2295 .config_shared_key = rt73usb_config_shared_key, 2321 .config_shared_key = rt73usb_config_shared_key,
2296 .config_pairwise_key = rt73usb_config_pairwise_key, 2322 .config_pairwise_key = rt73usb_config_pairwise_key,