rt2x00: Implement TX status reporting for rt2800usb
[linux-2.6-block.git] / drivers / net / wireless / rt2x00 / rt2800usb.c
index 9084b9a36b5799db2773e61861f4e5894d6fe198..9ad28be294ebb95d8049edfb54dd0b5ce6a9776b 100644 (file)
@@ -1,5 +1,6 @@
 /*
-       Copyright (C) 2009 Ivo van Doorn <IvDoorn@gmail.com>
+       Copyright (C) 2010 Willow Garage <http://www.willowgarage.com>
+       Copyright (C) 2009 - 2010 Ivo van Doorn <IvDoorn@gmail.com>
        Copyright (C) 2009 Mattias Nissler <mattias.nissler@gmx.de>
        Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org>
        Copyright (C) 2009 Xose Vazquez Perez <xose.vazquez@gmail.com>
@@ -377,6 +378,38 @@ static int rt2800usb_get_tx_data_len(struct queue_entry *entry)
        return length;
 }
 
+/*
+ * TX control handlers
+ */
+static void rt2800usb_work_txdone(struct work_struct *work)
+{
+       struct rt2x00_dev *rt2x00dev =
+           container_of(work, struct rt2x00_dev, txdone_work);
+       struct data_queue *queue;
+       struct queue_entry *entry;
+
+       rt2800_txdone(rt2x00dev);
+
+       /*
+        * Process any trailing TX status reports for IO failures,
+        * we loop until we find the first non-IO error entry. This
+        * can either be a frame which is free, is being uploaded,
+        * or has completed the upload but didn't have an entry
+        * in the TX_STAT_FIFO register yet.
+        */
+       tx_queue_for_each(rt2x00dev, queue) {
+               while (!rt2x00queue_empty(queue)) {
+                       entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
+
+                       if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) ||
+                           !test_bit(ENTRY_DATA_IO_FAILED, &entry->flags))
+                               break;
+
+                       rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE);
+               }
+       }
+}
+
 /*
  * RX control handlers
  */
@@ -513,6 +546,11 @@ static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev)
         */
        rt2x00dev->rssi_offset = DEFAULT_RSSI_OFFSET;
 
+       /*
+        * Overwrite TX done handler
+        */
+       PREPARE_WORK(&rt2x00dev->txdone_work, rt2800usb_work_txdone);
+
        return 0;
 }