]> Pileus Git - ~andy/linux/blobdiff - drivers/net/wireless/rt2x00/rt2800pci.c
rt2x00: txdone implementation supporting hw encryption.
[~andy/linux] / drivers / net / wireless / rt2x00 / rt2800pci.c
index daea0b7c416eec5052ed084ed6a6c39cb8d2b4e0..2f42e01eb99d4b5ef27466c60810737d47c690dd 100644 (file)
@@ -907,14 +907,12 @@ static void rt2800pci_txdone(struct rt2x00_dev *rt2x00dev)
 {
        struct data_queue *queue;
        struct queue_entry *entry;
-       struct queue_entry *entry_done;
-       struct queue_entry_priv_pci *entry_priv;
+       __le32 *txwi;
        struct txdone_entry_desc txdesc;
        u32 word;
        u32 reg;
        u32 old_reg;
-       unsigned int type;
-       unsigned int index;
+       int wcid, ack, pid, tx_wcid, tx_ack, tx_pid;
        u16 mcs, real_mcs;
 
        /*
@@ -936,47 +934,41 @@ static void rt2800pci_txdone(struct rt2x00_dev *rt2x00dev)
                        break;
                old_reg = reg;
 
+               wcid    = rt2x00_get_field32(reg, TX_STA_FIFO_WCID);
+               ack     = rt2x00_get_field32(reg, TX_STA_FIFO_TX_ACK_REQUIRED);
+               pid     = rt2x00_get_field32(reg, TX_STA_FIFO_PID_TYPE);
+
                /*
                 * Skip this entry when it contains an invalid
                 * queue identication number.
                 */
-               type = rt2x00_get_field32(reg, TX_STA_FIFO_PID_TYPE) - 1;
-               if (type >= QID_RX)
+               if (pid <= 0 || pid > QID_RX)
                        continue;
 
-               queue = rt2x00queue_get_queue(rt2x00dev, type);
+               queue = rt2x00queue_get_queue(rt2x00dev, pid - 1);
                if (unlikely(!queue))
                        continue;
 
                /*
-                * Skip this entry when it contains an invalid
-                * index number.
+                * Inside each queue, we process each entry in a chronological
+                * order. We first check that the queue is not empty.
                 */
-               index = rt2x00_get_field32(reg, TX_STA_FIFO_WCID) - 1;
-               if (unlikely(index >= queue->limit))
+               if (rt2x00queue_empty(queue))
                        continue;
+               entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
 
-               entry = &queue->entries[index];
-               entry_priv = entry->priv_data;
-               rt2x00_desc_read((__le32 *)entry->skb->data, 0, &word);
-
-               entry_done = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
-               while (entry != entry_done) {
-                       /*
-                        * Catch up.
-                        * Just report any entries we missed as failed.
-                        */
-                       WARNING(rt2x00dev,
-                               "TX status report missed for entry %d\n",
-                               entry_done->entry_idx);
-
-                       txdesc.flags = 0;
-                       __set_bit(TXDONE_UNKNOWN, &txdesc.flags);
-                       txdesc.retry = 0;
-
-                       rt2x00lib_txdone(entry_done, &txdesc);
-                       entry_done = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
-               }
+               /* Check if we got a match by looking at WCID/ACK/PID
+                * fields */
+               txwi = (__le32 *)(entry->skb->data -
+                                 rt2x00dev->ops->extra_tx_headroom);
+
+               rt2x00_desc_read(txwi, 1, &word);
+               tx_wcid = rt2x00_get_field32(word, TXWI_W1_WIRELESS_CLI_ID);
+               tx_ack  = rt2x00_get_field32(word, TXWI_W1_ACK);
+               tx_pid  = rt2x00_get_field32(word, TXWI_W1_PACKETID);
+
+               if ((wcid != tx_wcid) || (ack != tx_ack) || (pid != tx_pid))
+                       WARNING(rt2x00dev, "invalid TX_STA_FIFO content\n");
 
                /*
                 * Obtain the status about this packet.
@@ -997,6 +989,7 @@ static void rt2800pci_txdone(struct rt2x00_dev *rt2x00dev)
                 * we have mcs = tx_mcs - 1. So the number of
                 * retry is (tx_mcs - mcs).
                 */
+               rt2x00_desc_read(txwi, 0, &word);
                mcs = rt2x00_get_field32(word, TXWI_W0_MCS);
                real_mcs = rt2x00_get_field32(reg, TX_STA_FIFO_MCS);
                __set_bit(TXDONE_FALLBACK, &txdesc.flags);
@@ -1041,18 +1034,12 @@ static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
        /*
         * Read EEPROM into buffer
         */
-       switch (rt2x00dev->chip.rt) {
-       case RT2880:
-       case RT3052:
+       if (rt2x00_is_soc(rt2x00dev))
                rt2800pci_read_eeprom_soc(rt2x00dev);
-               break;
-       default:
-               if (rt2800pci_efuse_detect(rt2x00dev))
-                       rt2800pci_read_eeprom_efuse(rt2x00dev);
-               else
-                       rt2800pci_read_eeprom_pci(rt2x00dev);
-               break;
-       }
+       else if (rt2800pci_efuse_detect(rt2x00dev))
+               rt2800pci_read_eeprom_efuse(rt2x00dev);
+       else
+               rt2800pci_read_eeprom_pci(rt2x00dev);
 
        return rt2800_validate_eeprom(rt2x00dev);
 }
@@ -1103,7 +1090,7 @@ static int rt2800pci_probe_hw(struct rt2x00_dev *rt2x00dev)
        /*
         * This device requires firmware.
         */
-       if (!rt2x00_rt(rt2x00dev, RT2880) && !rt2x00_rt(rt2x00dev, RT3052))
+       if (!rt2x00_is_soc(rt2x00dev))
                __set_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags);
        __set_bit(DRIVER_REQUIRE_DMA, &rt2x00dev->flags);
        __set_bit(DRIVER_REQUIRE_L2PAD, &rt2x00dev->flags);
@@ -1190,8 +1177,12 @@ static const struct rt2x00_ops rt2800pci_ops = {
 /*
  * RT2800pci module information.
  */
-static struct pci_device_id rt2800pci_device_table[] = {
-       { PCI_DEVICE(0x1462, 0x891a), PCI_DEVICE_DATA(&rt2800pci_ops) },
+#ifdef CONFIG_RT2800PCI_PCI
+static DEFINE_PCI_DEVICE_TABLE(rt2800pci_device_table) = {
+       { PCI_DEVICE(0x1814, 0x0601), PCI_DEVICE_DATA(&rt2800pci_ops) },
+       { PCI_DEVICE(0x1814, 0x0681), PCI_DEVICE_DATA(&rt2800pci_ops) },
+       { PCI_DEVICE(0x1814, 0x0701), PCI_DEVICE_DATA(&rt2800pci_ops) },
+       { PCI_DEVICE(0x1814, 0x0781), PCI_DEVICE_DATA(&rt2800pci_ops) },
        { PCI_DEVICE(0x1432, 0x7708), PCI_DEVICE_DATA(&rt2800pci_ops) },
        { PCI_DEVICE(0x1432, 0x7727), PCI_DEVICE_DATA(&rt2800pci_ops) },
        { PCI_DEVICE(0x1432, 0x7728), PCI_DEVICE_DATA(&rt2800pci_ops) },
@@ -1199,20 +1190,22 @@ static struct pci_device_id rt2800pci_device_table[] = {
        { PCI_DEVICE(0x1432, 0x7748), PCI_DEVICE_DATA(&rt2800pci_ops) },
        { PCI_DEVICE(0x1432, 0x7758), PCI_DEVICE_DATA(&rt2800pci_ops) },
        { PCI_DEVICE(0x1432, 0x7768), PCI_DEVICE_DATA(&rt2800pci_ops) },
-       { PCI_DEVICE(0x1814, 0x0601), PCI_DEVICE_DATA(&rt2800pci_ops) },
-       { PCI_DEVICE(0x1814, 0x0681), PCI_DEVICE_DATA(&rt2800pci_ops) },
-       { PCI_DEVICE(0x1814, 0x0701), PCI_DEVICE_DATA(&rt2800pci_ops) },
-       { PCI_DEVICE(0x1814, 0x0781), PCI_DEVICE_DATA(&rt2800pci_ops) },
-       { PCI_DEVICE(0x1814, 0x3060), PCI_DEVICE_DATA(&rt2800pci_ops) },
-       { PCI_DEVICE(0x1814, 0x3062), PCI_DEVICE_DATA(&rt2800pci_ops) },
+       { PCI_DEVICE(0x1a3b, 0x1059), PCI_DEVICE_DATA(&rt2800pci_ops) },
+#ifdef CONFIG_RT2800PCI_RT30XX
        { PCI_DEVICE(0x1814, 0x3090), PCI_DEVICE_DATA(&rt2800pci_ops) },
        { PCI_DEVICE(0x1814, 0x3091), PCI_DEVICE_DATA(&rt2800pci_ops) },
        { PCI_DEVICE(0x1814, 0x3092), PCI_DEVICE_DATA(&rt2800pci_ops) },
+       { PCI_DEVICE(0x1462, 0x891a), PCI_DEVICE_DATA(&rt2800pci_ops) },
+#endif
+#ifdef CONFIG_RT2800PCI_RT35XX
+       { PCI_DEVICE(0x1814, 0x3060), PCI_DEVICE_DATA(&rt2800pci_ops) },
+       { PCI_DEVICE(0x1814, 0x3062), PCI_DEVICE_DATA(&rt2800pci_ops) },
        { PCI_DEVICE(0x1814, 0x3562), PCI_DEVICE_DATA(&rt2800pci_ops) },
        { PCI_DEVICE(0x1814, 0x3592), PCI_DEVICE_DATA(&rt2800pci_ops) },
-       { PCI_DEVICE(0x1a3b, 0x1059), PCI_DEVICE_DATA(&rt2800pci_ops) },
+#endif
        { 0, }
 };
+#endif /* CONFIG_RT2800PCI_PCI */
 
 MODULE_AUTHOR(DRV_PROJECT);
 MODULE_VERSION(DRV_VERSION);
@@ -1225,11 +1218,10 @@ MODULE_DEVICE_TABLE(pci, rt2800pci_device_table);
 MODULE_LICENSE("GPL");
 
 #ifdef CONFIG_RT2800PCI_SOC
-#if defined(CONFIG_RALINK_RT288X)
-__rt2x00soc_probe(RT2880, &rt2800pci_ops);
-#elif defined(CONFIG_RALINK_RT305X)
-__rt2x00soc_probe(RT3052, &rt2800pci_ops);
-#endif
+static int rt2800soc_probe(struct platform_device *pdev)
+{
+       return rt2x00soc_probe(pdev, &rt2800pci_ops);
+}
 
 static struct platform_driver rt2800soc_driver = {
        .driver         = {
@@ -1237,7 +1229,7 @@ static struct platform_driver rt2800soc_driver = {
                .owner          = THIS_MODULE,
                .mod_name       = KBUILD_MODNAME,
        },
-       .probe          = __rt2x00soc_probe,
+       .probe          = rt2800soc_probe,
        .remove         = __devexit_p(rt2x00soc_remove),
        .suspend        = rt2x00soc_suspend,
        .resume         = rt2x00soc_resume,