]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wireless/rt2x00/rt2400pci.c
Merge branch 'timers-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-omap-h63xx.git] / drivers / net / wireless / rt2x00 / rt2400pci.c
index bb3d83560d02ae2e1ae6d4dfffa11c14dd185266..4c0538d6099bb2503646d091e4a9e9a1d3417095 100644 (file)
@@ -632,15 +632,15 @@ static void rt2400pci_init_rxentry(struct rt2x00_dev *rt2x00dev,
                                   struct queue_entry *entry)
 {
        struct queue_entry_priv_pci *entry_priv = entry->priv_data;
+       struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
        u32 word;
 
        rt2x00_desc_read(entry_priv->desc, 2, &word);
-       rt2x00_set_field32(&word, RXD_W2_BUFFER_LENGTH,
-                          entry->queue->data_size);
+       rt2x00_set_field32(&word, RXD_W2_BUFFER_LENGTH, entry->skb->len);
        rt2x00_desc_write(entry_priv->desc, 2, word);
 
        rt2x00_desc_read(entry_priv->desc, 1, &word);
-       rt2x00_set_field32(&word, RXD_W1_BUFFER_ADDRESS, entry_priv->data_dma);
+       rt2x00_set_field32(&word, RXD_W1_BUFFER_ADDRESS, skbdesc->skb_dma);
        rt2x00_desc_write(entry_priv->desc, 1, word);
 
        rt2x00_desc_read(entry_priv->desc, 0, &word);
@@ -733,6 +733,17 @@ static int rt2400pci_init_registers(struct rt2x00_dev *rt2x00dev)
                           (rt2x00dev->rx->data_size / 128));
        rt2x00pci_register_write(rt2x00dev, CSR9, reg);
 
+       rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
+       rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 0);
+       rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 0);
+       rt2x00_set_field32(&reg, CSR14_TBCN, 0);
+       rt2x00_set_field32(&reg, CSR14_TCFP, 0);
+       rt2x00_set_field32(&reg, CSR14_TATIMW, 0);
+       rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
+       rt2x00_set_field32(&reg, CSR14_CFP_COUNT_PRELOAD, 0);
+       rt2x00_set_field32(&reg, CSR14_TBCM_PRELOAD, 0);
+       rt2x00pci_register_write(rt2x00dev, CSR14, reg);
+
        rt2x00pci_register_write(rt2x00dev, CNT3, 0x3f080000);
 
        rt2x00pci_register_read(rt2x00dev, ARCSR0, &reg);
@@ -1012,7 +1023,7 @@ static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
         * Start writing the descriptor words.
         */
        rt2x00_desc_read(entry_priv->desc, 1, &word);
-       rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS, entry_priv->data_dma);
+       rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS, skbdesc->skb_dma);
        rt2x00_desc_write(entry_priv->desc, 1, word);
 
        rt2x00_desc_read(txd, 2, &word);
@@ -1058,6 +1069,40 @@ static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
 /*
  * TX data initialization
  */
+static void rt2400pci_write_beacon(struct queue_entry *entry)
+{
+       struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
+       struct queue_entry_priv_pci *entry_priv = entry->priv_data;
+       struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
+       u32 word;
+       u32 reg;
+
+       /*
+        * Disable beaconing while we are reloading the beacon data,
+        * otherwise we might be sending out invalid data.
+        */
+       rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
+       rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 0);
+       rt2x00_set_field32(&reg, CSR14_TBCN, 0);
+       rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
+       rt2x00pci_register_write(rt2x00dev, CSR14, reg);
+
+       /*
+        * Replace rt2x00lib allocated descriptor with the
+        * pointer to the _real_ hardware descriptor.
+        * After that, map the beacon to DMA and update the
+        * descriptor.
+        */
+       memcpy(entry_priv->desc, skbdesc->desc, skbdesc->desc_len);
+       skbdesc->desc = entry_priv->desc;
+
+       rt2x00queue_map_txskb(rt2x00dev, entry->skb);
+
+       rt2x00_desc_read(entry_priv->desc, 1, &word);
+       rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS, skbdesc->skb_dma);
+       rt2x00_desc_write(entry_priv->desc, 1, word);
+}
+
 static void rt2400pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
                                    const enum data_queue_qid queue)
 {
@@ -1087,25 +1132,48 @@ static void rt2400pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
 static void rt2400pci_fill_rxdone(struct queue_entry *entry,
                                  struct rxdone_entry_desc *rxdesc)
 {
+       struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
        struct queue_entry_priv_pci *entry_priv = entry->priv_data;
        u32 word0;
        u32 word2;
        u32 word3;
+       u32 word4;
+       u64 tsf;
+       u32 rx_low;
+       u32 rx_high;
 
        rt2x00_desc_read(entry_priv->desc, 0, &word0);
        rt2x00_desc_read(entry_priv->desc, 2, &word2);
        rt2x00_desc_read(entry_priv->desc, 3, &word3);
+       rt2x00_desc_read(entry_priv->desc, 4, &word4);
 
        if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR))
                rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
        if (rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR))
                rxdesc->flags |= RX_FLAG_FAILED_PLCP_CRC;
 
+       /*
+        * We only get the lower 32bits from the timestamp,
+        * to get the full 64bits we must complement it with
+        * the timestamp from get_tsf().
+        * Note that when a wraparound of the lower 32bits
+        * has occurred between the frame arrival and the get_tsf()
+        * call, we must decrease the higher 32bits with 1 to get
+        * to correct value.
+        */
+       tsf = rt2x00dev->ops->hw->get_tsf(rt2x00dev->hw);
+       rx_low = rt2x00_get_field32(word4, RXD_W4_RX_END_TIME);
+       rx_high = upper_32_bits(tsf);
+
+       if ((u32)tsf <= rx_low)
+               rx_high--;
+
        /*
         * Obtain the status about this packet.
         * The signal is the PLCP value, and needs to be stripped
         * of the preamble bit (0x08).
         */
+       rxdesc->timestamp = ((u64)rx_high << 32) | rx_low;
        rxdesc->signal = rt2x00_get_field32(word2, RXD_W2_SIGNAL) & ~0x08;
        rxdesc->rssi = rt2x00_get_field32(word2, RXD_W3_RSSI) -
            entry->queue->rt2x00dev->rssi_offset;
@@ -1154,7 +1222,7 @@ static void rt2400pci_txdone(struct rt2x00_dev *rt2x00dev,
                }
                txdesc.retry = rt2x00_get_field32(word, TXD_W0_RETRY_COUNT);
 
-               rt2x00pci_txdone(rt2x00dev, entry, &txdesc);
+               rt2x00lib_txdone(entry, &txdesc);
        }
 }
 
@@ -1366,7 +1434,7 @@ static void rt2400pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
                               IEEE80211_HW_SIGNAL_DBM;
        rt2x00dev->hw->extra_tx_headroom = 0;
 
-       SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_pci(rt2x00dev)->dev);
+       SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
        SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
                                rt2x00_eeprom_addr(rt2x00dev,
                                                   EEPROM_MAC_ADDR_0));
@@ -1412,9 +1480,10 @@ static int rt2400pci_probe_hw(struct rt2x00_dev *rt2x00dev)
        rt2400pci_probe_hw_mode(rt2x00dev);
 
        /*
-        * This device requires the atim queue
+        * This device requires the atim queue and DMA-mapped skbs.
         */
        __set_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags);
+       __set_bit(DRIVER_REQUIRE_DMA, &rt2x00dev->flags);
 
        /*
         * Set the rssi offset.
@@ -1480,59 +1549,6 @@ static u64 rt2400pci_get_tsf(struct ieee80211_hw *hw)
        return tsf;
 }
 
-static int rt2400pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
-{
-       struct rt2x00_dev *rt2x00dev = hw->priv;
-       struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
-       struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif);
-       struct queue_entry_priv_pci *entry_priv;
-       struct skb_frame_desc *skbdesc;
-       struct txentry_desc txdesc;
-       u32 reg;
-
-       if (unlikely(!intf->beacon))
-               return -ENOBUFS;
-       entry_priv = intf->beacon->priv_data;
-
-       /*
-        * Copy all TX descriptor information into txdesc,
-        * after that we are free to use the skb->cb array
-        * for our information.
-        */
-       intf->beacon->skb = skb;
-       rt2x00queue_create_tx_descriptor(intf->beacon, &txdesc);
-
-       /*
-        * Fill in skb descriptor
-        */
-       skbdesc = get_skb_frame_desc(skb);
-       memset(skbdesc, 0, sizeof(*skbdesc));
-       skbdesc->desc = entry_priv->desc;
-       skbdesc->desc_len = intf->beacon->queue->desc_size;
-       skbdesc->entry = intf->beacon;
-
-       /*
-        * Disable beaconing while we are reloading the beacon data,
-        * otherwise we might be sending out invalid data.
-        */
-       rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
-       rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 0);
-       rt2x00_set_field32(&reg, CSR14_TBCN, 0);
-       rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
-       rt2x00pci_register_write(rt2x00dev, CSR14, reg);
-
-       /*
-        * Enable beacon generation.
-        * Write entire beacon with descriptor to register,
-        * and kick the beacon generator.
-        */
-       memcpy(entry_priv->data, skb->data, skb->len);
-       rt2x00queue_write_tx_descriptor(intf->beacon, &txdesc);
-       rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, QID_BEACON);
-
-       return 0;
-}
-
 static int rt2400pci_tx_last_beacon(struct ieee80211_hw *hw)
 {
        struct rt2x00_dev *rt2x00dev = hw->priv;
@@ -1557,7 +1573,6 @@ static const struct ieee80211_ops rt2400pci_mac80211_ops = {
        .conf_tx                = rt2400pci_conf_tx,
        .get_tx_stats           = rt2x00mac_get_tx_stats,
        .get_tsf                = rt2400pci_get_tsf,
-       .beacon_update          = rt2400pci_beacon_update,
        .tx_last_beacon         = rt2400pci_tx_last_beacon,
 };
 
@@ -1575,6 +1590,7 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
        .link_tuner             = rt2400pci_link_tuner,
        .write_tx_desc          = rt2400pci_write_tx_desc,
        .write_tx_data          = rt2x00pci_write_tx_data,
+       .write_beacon           = rt2400pci_write_beacon,
        .kick_tx_queue          = rt2400pci_kick_tx_queue,
        .fill_rxdone            = rt2400pci_fill_rxdone,
        .config_filter          = rt2400pci_config_filter,