aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2800lib.c
diff options
context:
space:
mode:
authorHelmut Schaa <helmut.schaa@googlemail.com>2010-10-02 05:27:03 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-10-05 13:35:26 -0400
commit144333313b156a9e99d80e39e034a3cba00adeaf (patch)
tree20ab5c60cbda24e21f3e69ee86538284b5559800 /drivers/net/wireless/rt2x00/rt2800lib.c
parent2a0cfeb826df6751933fd95a797ac18371992c3b (diff)
rt2x00: Split out parts of the rt2800_txdone function for easier reuse
Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2800lib.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c100
1 files changed, 53 insertions, 47 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index daa32ae4286..19534f272d7 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -630,15 +630,63 @@ static bool rt2800_txdone_entry_check(struct queue_entry *entry, u32 reg)
630 return true; 630 return true;
631} 631}
632 632
633void rt2800_txdone_entry(struct queue_entry *entry, u32 status)
634{
635 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
636 struct txdone_entry_desc txdesc;
637 u32 word;
638 u16 mcs, real_mcs;
639 __le32 *txwi;
640
641 /*
642 * Obtain the status about this packet.
643 */
644 txdesc.flags = 0;
645 txwi = rt2800_drv_get_txwi(entry);
646 rt2x00_desc_read(txwi, 0, &word);
647 mcs = rt2x00_get_field32(word, TXWI_W0_MCS);
648 real_mcs = rt2x00_get_field32(status, TX_STA_FIFO_MCS);
649
650 /*
651 * Ralink has a retry mechanism using a global fallback
652 * table. We setup this fallback table to try the immediate
653 * lower rate for all rates. In the TX_STA_FIFO, the MCS field
654 * always contains the MCS used for the last transmission, be
655 * it successful or not.
656 */
657 if (rt2x00_get_field32(status, TX_STA_FIFO_TX_SUCCESS)) {
658 /*
659 * Transmission succeeded. The number of retries is
660 * mcs - real_mcs
661 */
662 __set_bit(TXDONE_SUCCESS, &txdesc.flags);
663 txdesc.retry = ((mcs > real_mcs) ? mcs - real_mcs : 0);
664 } else {
665 /*
666 * Transmission failed. The number of retries is
667 * always 7 in this case (for a total number of 8
668 * frames sent).
669 */
670 __set_bit(TXDONE_FAILURE, &txdesc.flags);
671 txdesc.retry = rt2x00dev->long_retry;
672 }
673
674 /*
675 * the frame was retried at least once
676 * -> hw used fallback rates
677 */
678 if (txdesc.retry)
679 __set_bit(TXDONE_FALLBACK, &txdesc.flags);
680
681 rt2x00lib_txdone(entry, &txdesc);
682}
683EXPORT_SYMBOL_GPL(rt2800_txdone_entry);
684
633void rt2800_txdone(struct rt2x00_dev *rt2x00dev) 685void rt2800_txdone(struct rt2x00_dev *rt2x00dev)
634{ 686{
635 struct data_queue *queue; 687 struct data_queue *queue;
636 struct queue_entry *entry; 688 struct queue_entry *entry;
637 __le32 *txwi;
638 struct txdone_entry_desc txdesc;
639 u32 word;
640 u32 reg; 689 u32 reg;
641 u16 mcs, real_mcs;
642 u8 pid; 690 u8 pid;
643 int i; 691 int i;
644 692
@@ -673,7 +721,6 @@ void rt2800_txdone(struct rt2x00_dev *rt2x00dev)
673 * order. We first check that the queue is not empty. 721 * order. We first check that the queue is not empty.
674 */ 722 */
675 entry = NULL; 723 entry = NULL;
676 txwi = NULL;
677 while (!rt2x00queue_empty(queue)) { 724 while (!rt2x00queue_empty(queue)) {
678 entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); 725 entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
679 if (rt2800_txdone_entry_check(entry, reg)) 726 if (rt2800_txdone_entry_check(entry, reg))
@@ -683,48 +730,7 @@ void rt2800_txdone(struct rt2x00_dev *rt2x00dev)
683 if (!entry || rt2x00queue_empty(queue)) 730 if (!entry || rt2x00queue_empty(queue))
684 break; 731 break;
685 732
686 733 rt2800_txdone_entry(entry, reg);
687 /*
688 * Obtain the status about this packet.
689 */
690 txdesc.flags = 0;
691 txwi = rt2800_drv_get_txwi(entry);
692 rt2x00_desc_read(txwi, 0, &word);
693 mcs = rt2x00_get_field32(word, TXWI_W0_MCS);
694 real_mcs = rt2x00_get_field32(reg, TX_STA_FIFO_MCS);
695
696 /*
697 * Ralink has a retry mechanism using a global fallback
698 * table. We setup this fallback table to try the immediate
699 * lower rate for all rates. In the TX_STA_FIFO, the MCS field
700 * always contains the MCS used for the last transmission, be
701 * it successful or not.
702 */
703 if (rt2x00_get_field32(reg, TX_STA_FIFO_TX_SUCCESS)) {
704 /*
705 * Transmission succeeded. The number of retries is
706 * mcs - real_mcs
707 */
708 __set_bit(TXDONE_SUCCESS, &txdesc.flags);
709 txdesc.retry = ((mcs > real_mcs) ? mcs - real_mcs : 0);
710 } else {
711 /*
712 * Transmission failed. The number of retries is
713 * always 7 in this case (for a total number of 8
714 * frames sent).
715 */
716 __set_bit(TXDONE_FAILURE, &txdesc.flags);
717 txdesc.retry = rt2x00dev->long_retry;
718 }
719
720 /*
721 * the frame was retried at least once
722 * -> hw used fallback rates
723 */
724 if (txdesc.retry)
725 __set_bit(TXDONE_FALLBACK, &txdesc.flags);
726
727 rt2x00lib_txdone(entry, &txdesc);
728 } 734 }
729} 735}
730EXPORT_SYMBOL_GPL(rt2800_txdone); 736EXPORT_SYMBOL_GPL(rt2800_txdone);