iwlwifi: enable serialization of synchronous commands
[safe/jmp/linux-2.6] / drivers / net / wireless / adm8211.c
index b2c050b..6508515 100644 (file)
@@ -302,18 +302,6 @@ static int adm8211_get_stats(struct ieee80211_hw *dev,
        return 0;
 }
 
-static int adm8211_get_tx_stats(struct ieee80211_hw *dev,
-                               struct ieee80211_tx_queue_stats *stats)
-{
-       struct adm8211_priv *priv = dev->priv;
-
-       stats[0].len = priv->cur_tx - priv->dirty_tx;
-       stats[0].limit = priv->tx_ring_size - 2;
-       stats[0].count = priv->dirty_tx;
-
-       return 0;
-}
-
 static void adm8211_interrupt_tci(struct ieee80211_hw *dev)
 {
        struct adm8211_priv *priv = dev->priv;
@@ -341,15 +329,14 @@ static void adm8211_interrupt_tci(struct ieee80211_hw *dev)
                pci_unmap_single(priv->pdev, info->mapping,
                                 info->skb->len, PCI_DMA_TODEVICE);
 
-               memset(&txi->status, 0, sizeof(txi->status));
+               ieee80211_tx_info_clear_status(txi);
+
                skb_pull(skb, sizeof(struct adm8211_tx_hdr));
                memcpy(skb_push(skb, info->hdrlen), skb->cb, info->hdrlen);
-               if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK)) {
-                       if (status & TDES0_STATUS_ES)
-                               txi->status.excessive_retries = 1;
-                       else
-                               txi->flags |= IEEE80211_TX_STAT_ACK;
-               }
+               if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK) &&
+                   !(status & TDES0_STATUS_ES))
+                       txi->flags |= IEEE80211_TX_STAT_ACK;
+
                ieee80211_tx_status_irqsafe(dev, skb);
 
                info->skb = NULL;
@@ -453,7 +440,8 @@ static void adm8211_interrupt_rci(struct ieee80211_hw *dev)
                        rx_status.freq = adm8211_channels[priv->channel - 1].center_freq;
                        rx_status.band = IEEE80211_BAND_2GHZ;
 
-                       ieee80211_rx_irqsafe(dev, skb, &rx_status);
+                       memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status));
+                       ieee80211_rx_irqsafe(dev, skb);
                }
 
                entry = (++priv->cur_rx) % priv->rx_ring_size;
@@ -1298,25 +1286,10 @@ static void adm8211_set_bssid(struct ieee80211_hw *dev, const u8 *bssid)
        ADM8211_CSR_WRITE(ABDA1, reg);
 }
 
-static int adm8211_set_ssid(struct ieee80211_hw *dev, u8 *ssid, size_t ssid_len)
-{
-       struct adm8211_priv *priv = dev->priv;
-       u8 buf[36];
-
-       if (ssid_len > 32)
-               return -EINVAL;
-
-       memset(buf, 0, sizeof(buf));
-       buf[0] = ssid_len;
-       memcpy(buf + 1, ssid, ssid_len);
-       adm8211_write_sram_bytes(dev, ADM8211_SRAM_SSID, buf, 33);
-       /* TODO: configure beacon for adhoc? */
-       return 0;
-}
-
-static int adm8211_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
+static int adm8211_config(struct ieee80211_hw *dev, u32 changed)
 {
        struct adm8211_priv *priv = dev->priv;
+       struct ieee80211_conf *conf = &dev->conf;
        int channel = ieee80211_frequency_to_channel(conf->channel->center_freq);
 
        if (channel != priv->channel) {
@@ -1327,37 +1300,55 @@ static int adm8211_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
        return 0;
 }
 
-static int adm8211_config_interface(struct ieee80211_hw *dev,
-                                   struct ieee80211_vif *vif,
-                                   struct ieee80211_if_conf *conf)
+static void adm8211_bss_info_changed(struct ieee80211_hw *dev,
+                                    struct ieee80211_vif *vif,
+                                    struct ieee80211_bss_conf *conf,
+                                    u32 changes)
 {
        struct adm8211_priv *priv = dev->priv;
 
+       if (!(changes & BSS_CHANGED_BSSID))
+               return;
+
        if (memcmp(conf->bssid, priv->bssid, ETH_ALEN)) {
                adm8211_set_bssid(dev, conf->bssid);
                memcpy(priv->bssid, conf->bssid, ETH_ALEN);
        }
+}
 
-       if (conf->ssid_len != priv->ssid_len ||
-           memcmp(conf->ssid, priv->ssid, conf->ssid_len)) {
-               adm8211_set_ssid(dev, conf->ssid, conf->ssid_len);
-               priv->ssid_len = conf->ssid_len;
-               memcpy(priv->ssid, conf->ssid, conf->ssid_len);
+static u64 adm8211_prepare_multicast(struct ieee80211_hw *hw,
+                                    int mc_count, struct dev_addr_list *mclist)
+{
+       unsigned int bit_nr, i;
+       u32 mc_filter[2];
+
+       mc_filter[1] = mc_filter[0] = 0;
+
+       for (i = 0; i < mc_count; i++) {
+               if (!mclist)
+                       break;
+               bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
+
+               bit_nr &= 0x3F;
+               mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
+               mclist = mclist->next;
        }
 
-       return 0;
+       return mc_filter[0] | ((u64)(mc_filter[1]) << 32);
 }
 
 static void adm8211_configure_filter(struct ieee80211_hw *dev,
                                     unsigned int changed_flags,
                                     unsigned int *total_flags,
-                                    int mc_count, struct dev_mc_list *mclist)
+                                    u64 multicast)
 {
        static const u8 bcast[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
        struct adm8211_priv *priv = dev->priv;
-       unsigned int bit_nr, new_flags;
+       unsigned int new_flags;
        u32 mc_filter[2];
-       int i;
+
+       mc_filter[0] = multicast;
+       mc_filter[1] = multicast >> 32;
 
        new_flags = 0;
 
@@ -1366,23 +1357,13 @@ static void adm8211_configure_filter(struct ieee80211_hw *dev,
                priv->nar |= ADM8211_NAR_PR;
                priv->nar &= ~ADM8211_NAR_MM;
                mc_filter[1] = mc_filter[0] = ~0;
-       } else if ((*total_flags & FIF_ALLMULTI) || (mc_count > 32)) {
+       } else if (*total_flags & FIF_ALLMULTI || multicast == ~(0ULL)) {
                new_flags |= FIF_ALLMULTI;
                priv->nar &= ~ADM8211_NAR_PR;
                priv->nar |= ADM8211_NAR_MM;
                mc_filter[1] = mc_filter[0] = ~0;
        } else {
                priv->nar &= ~(ADM8211_NAR_MM | ADM8211_NAR_PR);
-               mc_filter[1] = mc_filter[0] = 0;
-               for (i = 0; i < mc_count; i++) {
-                       if (!mclist)
-                               break;
-                       bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
-
-                       bit_nr &= 0x3F;
-                       mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
-                       mclist = mclist->next;
-               }
        }
 
        ADM8211_IDLE_RX();
@@ -1407,15 +1388,15 @@ static void adm8211_configure_filter(struct ieee80211_hw *dev,
 }
 
 static int adm8211_add_interface(struct ieee80211_hw *dev,
-                                struct ieee80211_if_init_conf *conf)
+                                struct ieee80211_vif *vif)
 {
        struct adm8211_priv *priv = dev->priv;
        if (priv->mode != NL80211_IFTYPE_MONITOR)
                return -EOPNOTSUPP;
 
-       switch (conf->type) {
+       switch (vif->type) {
        case NL80211_IFTYPE_STATION:
-               priv->mode = conf->type;
+               priv->mode = vif->type;
                break;
        default:
                return -EOPNOTSUPP;
@@ -1423,8 +1404,8 @@ static int adm8211_add_interface(struct ieee80211_hw *dev,
 
        ADM8211_IDLE();
 
-       ADM8211_CSR_WRITE(PAR0, le32_to_cpu(*(__le32 *)conf->mac_addr));
-       ADM8211_CSR_WRITE(PAR1, le16_to_cpu(*(__le16 *)(conf->mac_addr + 4)));
+       ADM8211_CSR_WRITE(PAR0, le32_to_cpu(*(__le32 *)vif->addr));
+       ADM8211_CSR_WRITE(PAR1, le16_to_cpu(*(__le16 *)(vif->addr + 4)));
 
        adm8211_update_mode(dev);
 
@@ -1434,7 +1415,7 @@ static int adm8211_add_interface(struct ieee80211_hw *dev,
 }
 
 static void adm8211_remove_interface(struct ieee80211_hw *dev,
-                                    struct ieee80211_if_init_conf *conf)
+                                    struct ieee80211_vif *vif)
 {
        struct adm8211_priv *priv = dev->priv;
        priv->mode = NL80211_IFTYPE_MONITOR;
@@ -1545,7 +1526,7 @@ static int adm8211_start(struct ieee80211_hw *dev)
        adm8211_hw_init(dev);
        adm8211_rf_set_channel(dev, priv->channel);
 
-       retval = request_irq(priv->pdev->irq, &adm8211_interrupt,
+       retval = request_irq(priv->pdev->irq, adm8211_interrupt,
                             IRQF_SHARED, "adm8211", dev);
        if (retval) {
                printk(KERN_ERR "%s: failed to register IRQ handler\n",
@@ -1690,8 +1671,10 @@ static int adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
        struct ieee80211_hdr *hdr;
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        struct ieee80211_rate *txrate = ieee80211_get_tx_rate(dev, info);
+       u8 rc_flags;
 
-       short_preamble = !!(txrate->flags & IEEE80211_TX_CTL_SHORT_PREAMBLE);
+       rc_flags = info->control.rates[0].flags;
+       short_preamble = !!(rc_flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE);
        plcp_signal = txrate->bitrate;
 
        hdr = (struct ieee80211_hdr *)skb->data;
@@ -1723,10 +1706,10 @@ static int adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
        if (short_preamble)
                txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_SHORT_PREAMBLE);
 
-       if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS)
+       if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS)
                txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_ENABLE_RTS);
 
-       txhdr->retry_limit = info->control.retry_limit;
+       txhdr->retry_limit = info->control.rates[0].count;
 
        adm8211_tx_raw(dev, skb, plcp_signal, hdrlen);
 
@@ -1774,10 +1757,10 @@ static const struct ieee80211_ops adm8211_ops = {
        .add_interface          = adm8211_add_interface,
        .remove_interface       = adm8211_remove_interface,
        .config                 = adm8211_config,
-       .config_interface       = adm8211_config_interface,
+       .bss_info_changed       = adm8211_bss_info_changed,
+       .prepare_multicast      = adm8211_prepare_multicast,
        .configure_filter       = adm8211_configure_filter,
        .get_stats              = adm8211_get_stats,
-       .get_tx_stats           = adm8211_get_tx_stats,
        .get_tsf                = adm8211_get_tsft
 };
 
@@ -1791,7 +1774,6 @@ static int __devinit adm8211_probe(struct pci_dev *pdev,
        int err;
        u32 reg;
        u8 perm_addr[ETH_ALEN];
-       DECLARE_MAC_BUF(mac);
 
        err = pci_enable_device(pdev);
        if (err) {
@@ -1826,8 +1808,8 @@ static int __devinit adm8211_probe(struct pci_dev *pdev,
                return err; /* someone else grabbed it? don't disable it */
        }
 
-       if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) ||
-           pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK)) {
+       if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) ||
+           pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
                printk(KERN_ERR "%s (adm8211): No suitable DMA available\n",
                       pci_name(pdev));
                goto err_free_reg;
@@ -1925,8 +1907,8 @@ static int __devinit adm8211_probe(struct pci_dev *pdev,
                goto err_free_desc;
        }
 
-       printk(KERN_INFO "%s: hwaddr %s, Rev 0x%02x\n",
-              wiphy_name(dev->wiphy), print_mac(mac, dev->wiphy->perm_addr),
+       printk(KERN_INFO "%s: hwaddr %pM, Rev 0x%02x\n",
+              wiphy_name(dev->wiphy), dev->wiphy->perm_addr,
               pdev->revision);
 
        return 0;
@@ -1983,14 +1965,6 @@ static void __devexit adm8211_remove(struct pci_dev *pdev)
 #ifdef CONFIG_PM
 static int adm8211_suspend(struct pci_dev *pdev, pm_message_t state)
 {
-       struct ieee80211_hw *dev = pci_get_drvdata(pdev);
-       struct adm8211_priv *priv = dev->priv;
-
-       if (priv->mode != NL80211_IFTYPE_UNSPECIFIED) {
-               ieee80211_stop_queues(dev);
-               adm8211_stop(dev);
-       }
-
        pci_save_state(pdev);
        pci_set_power_state(pdev, pci_choose_state(pdev, state));
        return 0;
@@ -1998,17 +1972,8 @@ static int adm8211_suspend(struct pci_dev *pdev, pm_message_t state)
 
 static int adm8211_resume(struct pci_dev *pdev)
 {
-       struct ieee80211_hw *dev = pci_get_drvdata(pdev);
-       struct adm8211_priv *priv = dev->priv;
-
        pci_set_power_state(pdev, PCI_D0);
        pci_restore_state(pdev);
-
-       if (priv->mode != NL80211_IFTYPE_UNSPECIFIED) {
-               adm8211_start(dev);
-               ieee80211_wake_queues(dev);
-       }
-
        return 0;
 }
 #endif /* CONFIG_PM */