]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wireless/ath5k/base.c
ath5k: honor FIF_BCN_PRBRESP_PROMISC in STA mode
[linux-2.6-omap-h63xx.git] / drivers / net / wireless / ath5k / base.c
index 85260c39aa2b80dce9b463d75042a94ec67c234a..9e47d727e2206ff28c647f648bb29caf4888057d 100644 (file)
@@ -72,7 +72,7 @@ MODULE_AUTHOR("Nick Kossifidis");
 MODULE_DESCRIPTION("Support for 5xxx series of Atheros 802.11 wireless LAN cards.");
 MODULE_SUPPORTED_DEVICE("Atheros 5xxx WLAN cards");
 MODULE_LICENSE("Dual BSD/GPL");
-MODULE_VERSION("0.5.0 (EXPERIMENTAL)");
+MODULE_VERSION("0.6.0 (EXPERIMENTAL)");
 
 
 /* Known PCI ids */
@@ -93,41 +93,48 @@ static struct pci_device_id ath5k_pci_id_table[] __devinitdata = {
        { PCI_VDEVICE(ATHEROS, 0x0019), .driver_data = AR5K_AR5212 }, /* 5212 combatible */
        { PCI_VDEVICE(ATHEROS, 0x001a), .driver_data = AR5K_AR5212 }, /* 2413 Griffin-lite */
        { PCI_VDEVICE(ATHEROS, 0x001b), .driver_data = AR5K_AR5212 }, /* 5413 Eagle */
-       { PCI_VDEVICE(ATHEROS, 0x001c), .driver_data = AR5K_AR5212 }, /* 5424 Condor (PCI-E)*/
+       { PCI_VDEVICE(ATHEROS, 0x001c), .driver_data = AR5K_AR5212 }, /* PCI-E cards */
+       { PCI_VDEVICE(ATHEROS, 0x001d), .driver_data = AR5K_AR5212 }, /* 2417 Nala */
        { 0 }
 };
 MODULE_DEVICE_TABLE(pci, ath5k_pci_id_table);
 
 /* Known SREVs */
 static struct ath5k_srev_name srev_names[] = {
-       { "5210",       AR5K_VERSION_VER,       AR5K_SREV_VER_AR5210 },
-       { "5311",       AR5K_VERSION_VER,       AR5K_SREV_VER_AR5311 },
-       { "5311A",      AR5K_VERSION_VER,       AR5K_SREV_VER_AR5311A },
-       { "5311B",      AR5K_VERSION_VER,       AR5K_SREV_VER_AR5311B },
-       { "5211",       AR5K_VERSION_VER,       AR5K_SREV_VER_AR5211 },
-       { "5212",       AR5K_VERSION_VER,       AR5K_SREV_VER_AR5212 },
-       { "5213",       AR5K_VERSION_VER,       AR5K_SREV_VER_AR5213 },
-       { "5213A",      AR5K_VERSION_VER,       AR5K_SREV_VER_AR5213A },
-       { "2413",       AR5K_VERSION_VER,       AR5K_SREV_VER_AR2413 },
-       { "2414",       AR5K_VERSION_VER,       AR5K_SREV_VER_AR2414 },
-       { "2424",       AR5K_VERSION_VER,       AR5K_SREV_VER_AR2424 },
-       { "5424",       AR5K_VERSION_VER,       AR5K_SREV_VER_AR5424 },
-       { "5413",       AR5K_VERSION_VER,       AR5K_SREV_VER_AR5413 },
-       { "5414",       AR5K_VERSION_VER,       AR5K_SREV_VER_AR5414 },
-       { "5416",       AR5K_VERSION_VER,       AR5K_SREV_VER_AR5416 },
-       { "5418",       AR5K_VERSION_VER,       AR5K_SREV_VER_AR5418 },
-       { "2425",       AR5K_VERSION_VER,       AR5K_SREV_VER_AR2425 },
-       { "xxxxx",      AR5K_VERSION_VER,       AR5K_SREV_UNKNOWN },
+       { "5210",       AR5K_VERSION_MAC,       AR5K_SREV_AR5210 },
+       { "5311",       AR5K_VERSION_MAC,       AR5K_SREV_AR5311 },
+       { "5311A",      AR5K_VERSION_MAC,       AR5K_SREV_AR5311A },
+       { "5311B",      AR5K_VERSION_MAC,       AR5K_SREV_AR5311B },
+       { "5211",       AR5K_VERSION_MAC,       AR5K_SREV_AR5211 },
+       { "5212",       AR5K_VERSION_MAC,       AR5K_SREV_AR5212 },
+       { "5213",       AR5K_VERSION_MAC,       AR5K_SREV_AR5213 },
+       { "5213A",      AR5K_VERSION_MAC,       AR5K_SREV_AR5213A },
+       { "2413",       AR5K_VERSION_MAC,       AR5K_SREV_AR2413 },
+       { "2414",       AR5K_VERSION_MAC,       AR5K_SREV_AR2414 },
+       { "5424",       AR5K_VERSION_MAC,       AR5K_SREV_AR5424 },
+       { "5413",       AR5K_VERSION_MAC,       AR5K_SREV_AR5413 },
+       { "5414",       AR5K_VERSION_MAC,       AR5K_SREV_AR5414 },
+       { "2415",       AR5K_VERSION_MAC,       AR5K_SREV_AR2415 },
+       { "5416",       AR5K_VERSION_MAC,       AR5K_SREV_AR5416 },
+       { "5418",       AR5K_VERSION_MAC,       AR5K_SREV_AR5418 },
+       { "2425",       AR5K_VERSION_MAC,       AR5K_SREV_AR2425 },
+       { "2417",       AR5K_VERSION_MAC,       AR5K_SREV_AR2417 },
+       { "xxxxx",      AR5K_VERSION_MAC,       AR5K_SREV_UNKNOWN },
        { "5110",       AR5K_VERSION_RAD,       AR5K_SREV_RAD_5110 },
        { "5111",       AR5K_VERSION_RAD,       AR5K_SREV_RAD_5111 },
+       { "5111A",      AR5K_VERSION_RAD,       AR5K_SREV_RAD_5111A },
        { "2111",       AR5K_VERSION_RAD,       AR5K_SREV_RAD_2111 },
        { "5112",       AR5K_VERSION_RAD,       AR5K_SREV_RAD_5112 },
        { "5112A",      AR5K_VERSION_RAD,       AR5K_SREV_RAD_5112A },
+       { "5112B",      AR5K_VERSION_RAD,       AR5K_SREV_RAD_5112B },
        { "2112",       AR5K_VERSION_RAD,       AR5K_SREV_RAD_2112 },
        { "2112A",      AR5K_VERSION_RAD,       AR5K_SREV_RAD_2112A },
-       { "SChip",      AR5K_VERSION_RAD,       AR5K_SREV_RAD_SC0 },
-       { "SChip",      AR5K_VERSION_RAD,       AR5K_SREV_RAD_SC1 },
-       { "SChip",      AR5K_VERSION_RAD,       AR5K_SREV_RAD_SC2 },
+       { "2112B",      AR5K_VERSION_RAD,       AR5K_SREV_RAD_2112B },
+       { "2413",       AR5K_VERSION_RAD,       AR5K_SREV_RAD_2413 },
+       { "5413",       AR5K_VERSION_RAD,       AR5K_SREV_RAD_5413 },
+       { "2316",       AR5K_VERSION_RAD,       AR5K_SREV_RAD_2316 },
+       { "2317",       AR5K_VERSION_RAD,       AR5K_SREV_RAD_2317 },
+       { "5424",       AR5K_VERSION_RAD,       AR5K_SREV_RAD_5424 },
        { "5133",       AR5K_VERSION_RAD,       AR5K_SREV_RAD_5133 },
        { "xxxxx",      AR5K_VERSION_RAD,       AR5K_SREV_UNKNOWN },
 };
@@ -333,9 +340,9 @@ static inline u64 ath5k_extend_tsf(struct ath5k_hw *ah, u32 rstamp)
 }
 
 /* Interrupt handling */
-static int     ath5k_init(struct ath5k_softc *sc);
+static int     ath5k_init(struct ath5k_softc *sc, bool is_resume);
 static int     ath5k_stop_locked(struct ath5k_softc *sc);
-static int     ath5k_stop_hw(struct ath5k_softc *sc);
+static int     ath5k_stop_hw(struct ath5k_softc *sc, bool is_suspend);
 static irqreturn_t ath5k_intr(int irq, void *dev_id);
 static void    ath5k_tasklet_reset(unsigned long data);
 
@@ -390,7 +397,11 @@ ath5k_chip_name(enum ath5k_srev_type type, u_int16_t val)
        for (i = 0; i < ARRAY_SIZE(srev_names); i++) {
                if (srev_names[i].sr_type != type)
                        continue;
-               if ((val & 0xff) < srev_names[i + 1].sr_val) {
+
+               if ((val & 0xf0) == srev_names[i].sr_val)
+                       name = srev_names[i].sr_name;
+
+               if ((val & 0xff) == srev_names[i].sr_val) {
                        name = srev_names[i].sr_name;
                        break;
                }
@@ -507,7 +518,7 @@ ath5k_pci_probe(struct pci_dev *pdev,
 
        sc->iobase = mem; /* So we can unmap it on detach */
        sc->cachelsz = csz * sizeof(u32); /* convert to bytes */
-       sc->opmode = IEEE80211_IF_TYPE_STA;
+       sc->opmode = NL80211_IFTYPE_STATION;
        mutex_init(&sc->lock);
        spin_lock_init(&sc->rxbuflock);
        spin_lock_init(&sc->txbuflock);
@@ -530,13 +541,19 @@ ath5k_pci_probe(struct pci_dev *pdev,
                goto err_irq;
        }
 
+       /* set up multi-rate retry capabilities */
+       if (sc->ah->ah_version == AR5K_AR5212) {
+               hw->max_altrates = 3;
+               hw->max_altrate_tries = 11;
+       }
+
        /* Finish private driver data initialization */
        ret = ath5k_attach(pdev, hw);
        if (ret)
                goto err_ah;
 
        ATH5K_INFO(sc, "Atheros AR%s chip found (MAC: 0x%x, PHY: 0x%x)\n",
-                       ath5k_chip_name(AR5K_VERSION_VER,sc->ah->ah_mac_srev),
+                       ath5k_chip_name(AR5K_VERSION_MAC, sc->ah->ah_mac_srev),
                                        sc->ah->ah_mac_srev,
                                        sc->ah->ah_phy_revision);
 
@@ -629,7 +646,7 @@ ath5k_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 
        ath5k_led_off(sc);
 
-       ath5k_stop_hw(sc);
+       ath5k_stop_hw(sc, true);
 
        free_irq(pdev->irq, sc);
        pci_save_state(pdev);
@@ -644,8 +661,7 @@ ath5k_pci_resume(struct pci_dev *pdev)
 {
        struct ieee80211_hw *hw = pci_get_drvdata(pdev);
        struct ath5k_softc *sc = hw->priv;
-       struct ath5k_hw *ah = sc->ah;
-       int i, err;
+       int err;
 
        pci_restore_state(pdev);
 
@@ -666,21 +682,11 @@ ath5k_pci_resume(struct pci_dev *pdev)
                goto err_no_irq;
        }
 
-       err = ath5k_init(sc);
+       err = ath5k_init(sc, true);
        if (err)
                goto err_irq;
        ath5k_led_enable(sc);
 
-       /*
-        * Reset the key cache since some parts do not
-        * reset the contents on initial power up or resume.
-        *
-        * FIXME: This may need to be revisited when mac80211 becomes
-        *        aware of suspend/resume.
-        */
-       for (i = 0; i < AR5K_KEYTABLE_SIZE; i++)
-               ath5k_hw_reset_key(ah, i);
-
        return 0;
 err_irq:
        free_irq(pdev->irq, sc);
@@ -701,7 +707,6 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)
        struct ath5k_softc *sc = hw->priv;
        struct ath5k_hw *ah = sc->ah;
        u8 mac[ETH_ALEN];
-       unsigned int i;
        int ret;
 
        ATH5K_DBG(sc, ATH5K_DEBUG_ANY, "devid 0x%x\n", pdev->device);
@@ -719,13 +724,6 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)
        if (ret > 0)
                __set_bit(ATH_STAT_MRRETRY, sc->status);
 
-       /*
-        * Reset the key cache since some parts do not
-        * reset the contents on initial power up.
-        */
-       for (i = 0; i < AR5K_KEYTABLE_SIZE; i++)
-               ath5k_hw_reset_key(ah, i);
-
        /*
         * Collect the channel list.  The 802.11 layer
         * is resposible for filtering this list based
@@ -1162,7 +1160,9 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
        struct sk_buff *skb = bf->skb;
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        unsigned int pktlen, flags, keyidx = AR5K_TXKEYIX_INVALID;
-       int ret;
+       struct ieee80211_rate *rate;
+       unsigned int mrr_rate[3], mrr_tries[3];
+       int i, ret;
 
        flags = AR5K_TXDESC_INTREQ | AR5K_TXDESC_CLRDMASK;
 
@@ -1177,7 +1177,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
 
        if (info->control.hw_key) {
                keyidx = info->control.hw_key->hw_key_idx;
-               pktlen += info->control.icv_len;
+               pktlen += info->control.hw_key->icv_len;
        }
        ret = ah->ah_setup_tx_desc(ah, ds, pktlen,
                ieee80211_get_hdrlen_from_skb(skb), AR5K_PKT_TYPE_NORMAL,
@@ -1187,6 +1187,22 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
        if (ret)
                goto err_unmap;
 
+       memset(mrr_rate, 0, sizeof(mrr_rate));
+       memset(mrr_tries, 0, sizeof(mrr_tries));
+       for (i = 0; i < 3; i++) {
+               rate = ieee80211_get_alt_retry_rate(sc->hw, info, i);
+               if (!rate)
+                       break;
+
+               mrr_rate[i] = rate->hw_value;
+               mrr_tries[i] = info->control.retries[i].limit;
+       }
+
+       ah->ah_setup_mrr_tx_desc(ah, ds,
+               mrr_rate[0], mrr_tries[0],
+               mrr_rate[1], mrr_tries[1],
+               mrr_rate[2], mrr_tries[2]);
+
        ds->ds_link = 0;
        ds->ds_data = bf->skbaddr;
 
@@ -1377,8 +1393,8 @@ ath5k_beaconq_config(struct ath5k_softc *sc)
        ret = ath5k_hw_get_tx_queueprops(ah, sc->bhalq, &qi);
        if (ret)
                return ret;
-       if (sc->opmode == IEEE80211_IF_TYPE_AP ||
-               sc->opmode == IEEE80211_IF_TYPE_MESH_POINT) {
+       if (sc->opmode == NL80211_IFTYPE_AP ||
+               sc->opmode == NL80211_IFTYPE_MESH_POINT) {
                /*
                 * Always burst out beacon and CAB traffic
                 * (aifs = cwmin = cwmax = 0)
@@ -1386,7 +1402,7 @@ ath5k_beaconq_config(struct ath5k_softc *sc)
                qi.tqi_aifs = 0;
                qi.tqi_cw_min = 0;
                qi.tqi_cw_max = 0;
-       } else if (sc->opmode == IEEE80211_IF_TYPE_IBSS) {
+       } else if (sc->opmode == NL80211_IFTYPE_ADHOC) {
                /*
                 * Adhoc mode; backoff between 0 and (2 * cw_min).
                 */
@@ -1714,7 +1730,7 @@ ath5k_tasklet_rx(unsigned long data)
                        /* let crypto-error packets fall through in MNTR */
                        if ((rs.rs_status &
                                ~(AR5K_RXERR_DECRYPT|AR5K_RXERR_MIC)) ||
-                                       sc->opmode != IEEE80211_IF_TYPE_MNTR)
+                                       sc->opmode != NL80211_IFTYPE_MONITOR)
                                goto next;
                }
 accept:
@@ -1777,7 +1793,7 @@ accept:
                ath5k_debug_dump_skb(sc, skb, "RX  ", 0);
 
                /* check beacons in IBSS mode */
-               if (sc->opmode == IEEE80211_IF_TYPE_IBSS)
+               if (sc->opmode == NL80211_IFTYPE_ADHOC)
                        ath5k_check_ibss_tsf(sc, skb, &rxs);
 
                __ieee80211_rx(sc->hw, skb, &rxs);
@@ -1803,7 +1819,7 @@ ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq)
        struct ath5k_desc *ds;
        struct sk_buff *skb;
        struct ieee80211_tx_info *info;
-       int ret;
+       int i, ret;
 
        spin_lock(&txq->lock);
        list_for_each_entry_safe(bf, bf0, &txq->q, list) {
@@ -1825,7 +1841,25 @@ ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq)
                pci_unmap_single(sc->pdev, bf->skbaddr, skb->len,
                                PCI_DMA_TODEVICE);
 
-               info->status.retry_count = ts.ts_shortretry + ts.ts_longretry / 6;
+               memset(&info->status, 0, sizeof(info->status));
+               info->tx_rate_idx = ath5k_hw_to_driver_rix(sc,
+                               ts.ts_rate[ts.ts_final_idx]);
+               info->status.retry_count = ts.ts_longretry;
+
+               for (i = 0; i < 4; i++) {
+                       struct ieee80211_tx_altrate *r =
+                               &info->status.retries[i];
+
+                       if (ts.ts_rate[i]) {
+                               r->rate_idx = ath5k_hw_to_driver_rix(sc, ts.ts_rate[i]);
+                               r->limit = ts.ts_retry[i];
+                       } else {
+                               r->rate_idx = -1;
+                               r->limit = 0;
+                       }
+               }
+
+               info->status.excessive_retries = 0;
                if (unlikely(ts.ts_status)) {
                        sc->ll_stats.dot11ACKFailureCount++;
                        if (ts.ts_status & AR5K_TXERR_XRETRY)
@@ -1892,7 +1926,7 @@ ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
        ds = bf->desc;
 
        flags = AR5K_TXDESC_NOACK;
-       if (sc->opmode == IEEE80211_IF_TYPE_IBSS && ath5k_hw_hasveol(ah)) {
+       if (sc->opmode == NL80211_IFTYPE_ADHOC && ath5k_hw_hasveol(ah)) {
                ds->ds_link = bf->daddr;        /* self-linked */
                flags |= AR5K_TXDESC_VEOL;
                /*
@@ -1941,8 +1975,8 @@ ath5k_beacon_send(struct ath5k_softc *sc)
 
        ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, "in beacon_send\n");
 
-       if (unlikely(bf->skb == NULL || sc->opmode == IEEE80211_IF_TYPE_STA ||
-                       sc->opmode == IEEE80211_IF_TYPE_MNTR)) {
+       if (unlikely(bf->skb == NULL || sc->opmode == NL80211_IFTYPE_STATION ||
+                       sc->opmode == NL80211_IFTYPE_MONITOR)) {
                ATH5K_WARN(sc, "bf=%p bf_skb=%p\n", bf, bf ? bf->skb : NULL);
                return;
        }
@@ -2116,9 +2150,9 @@ ath5k_beacon_config(struct ath5k_softc *sc)
        sc->bmisscount = 0;
        sc->imask &= ~(AR5K_INT_BMISS | AR5K_INT_SWBA);
 
-       if (sc->opmode == IEEE80211_IF_TYPE_STA) {
+       if (sc->opmode == NL80211_IFTYPE_STATION) {
                sc->imask |= AR5K_INT_BMISS;
-       } else if (sc->opmode == IEEE80211_IF_TYPE_IBSS) {
+       } else if (sc->opmode == NL80211_IFTYPE_ADHOC) {
                /*
                 * In IBSS mode we use a self-linked tx descriptor and let the
                 * hardware send the beacons automatically. We have to load it
@@ -2147,12 +2181,18 @@ ath5k_beacon_config(struct ath5k_softc *sc)
 \********************/
 
 static int
-ath5k_init(struct ath5k_softc *sc)
+ath5k_init(struct ath5k_softc *sc, bool is_resume)
 {
-       int ret;
+       struct ath5k_hw *ah = sc->ah;
+       int ret, i;
 
        mutex_lock(&sc->lock);
 
+       if (is_resume && !test_bit(ATH_STAT_STARTED, sc->status))
+               goto out_ok;
+
+       __clear_bit(ATH_STAT_STARTED, sc->status);
+
        ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "mode %d\n", sc->opmode);
 
        /*
@@ -2177,12 +2217,22 @@ ath5k_init(struct ath5k_softc *sc)
        if (ret)
                goto done;
 
+       /*
+        * Reset the key cache since some parts do not reset the
+        * contents on initial power up or resume from suspend.
+        */
+       for (i = 0; i < AR5K_KEYTABLE_SIZE; i++)
+               ath5k_hw_reset_key(ah, i);
+
+       __set_bit(ATH_STAT_STARTED, sc->status);
+
        /* Set ack to be sent at low bit-rates */
-       ath5k_hw_set_ack_bitrate_high(sc->ah, false);
+       ath5k_hw_set_ack_bitrate_high(ah, false);
 
        mod_timer(&sc->calib_tim, round_jiffies(jiffies +
                        msecs_to_jiffies(ath5k_calinterval * 1000)));
 
+out_ok:
        ret = 0;
 done:
        mmiowb();
@@ -2237,7 +2287,7 @@ ath5k_stop_locked(struct ath5k_softc *sc)
  * stop is preempted).
  */
 static int
-ath5k_stop_hw(struct ath5k_softc *sc)
+ath5k_stop_hw(struct ath5k_softc *sc, bool is_suspend)
 {
        int ret;
 
@@ -2268,6 +2318,9 @@ ath5k_stop_hw(struct ath5k_softc *sc)
                }
        }
        ath5k_txbuf_free(sc, sc->bbuf);
+       if (!is_suspend)
+               __clear_bit(ATH_STAT_STARTED, sc->status);
+
        mmiowb();
        mutex_unlock(&sc->lock);
 
@@ -2323,7 +2376,7 @@ ath5k_intr(int irq, void *dev_id)
                                * transmission time) in order to detect wether
                                * automatic TSF updates happened.
                                */
-                               if (sc->opmode == IEEE80211_IF_TYPE_IBSS) {
+                               if (sc->opmode == NL80211_IFTYPE_ADHOC) {
                                         /* XXX: only if VEOL suppported */
                                        u64 tsf = ath5k_hw_get_tsf64(ah);
                                        sc->nexttbtt += sc->bintval;
@@ -2553,7 +2606,7 @@ ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
 
        ath5k_debug_dump_skb(sc, skb, "TX  ", 1);
 
-       if (sc->opmode == IEEE80211_IF_TYPE_MNTR)
+       if (sc->opmode == NL80211_IFTYPE_MONITOR)
                ATH5K_DBG(sc, ATH5K_DEBUG_XMIT, "tx in monitor (scan?)\n");
 
        /*
@@ -2665,12 +2718,12 @@ ath5k_reset_wake(struct ath5k_softc *sc)
 
 static int ath5k_start(struct ieee80211_hw *hw)
 {
-       return ath5k_init(hw->priv);
+       return ath5k_init(hw->priv, false);
 }
 
 static void ath5k_stop(struct ieee80211_hw *hw)
 {
-       ath5k_stop_hw(hw->priv);
+       ath5k_stop_hw(hw->priv, false);
 }
 
 static int ath5k_add_interface(struct ieee80211_hw *hw,
@@ -2688,9 +2741,9 @@ static int ath5k_add_interface(struct ieee80211_hw *hw,
        sc->vif = conf->vif;
 
        switch (conf->type) {
-       case IEEE80211_IF_TYPE_STA:
-       case IEEE80211_IF_TYPE_IBSS:
-       case IEEE80211_IF_TYPE_MNTR:
+       case NL80211_IFTYPE_STATION:
+       case NL80211_IFTYPE_ADHOC:
+       case NL80211_IFTYPE_MONITOR:
                sc->opmode = conf->type;
                break;
        default:
@@ -2761,7 +2814,7 @@ ath5k_config_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
        }
 
        if (conf->changed & IEEE80211_IFCC_BEACON &&
-           vif->type == IEEE80211_IF_TYPE_IBSS) {
+           vif->type == NL80211_IFTYPE_ADHOC) {
                struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
                if (!beacon) {
                        ret = -ENOMEM;
@@ -2880,19 +2933,17 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw,
 
        /* XXX move these to mac80211, and add a beacon IFF flag to mac80211 */
 
-       if (sc->opmode == IEEE80211_IF_TYPE_MNTR)
+       if (sc->opmode == NL80211_IFTYPE_MONITOR)
                rfilt |= AR5K_RX_FILTER_CONTROL | AR5K_RX_FILTER_BEACON |
                        AR5K_RX_FILTER_PROBEREQ | AR5K_RX_FILTER_PROM;
-       if (sc->opmode != IEEE80211_IF_TYPE_STA)
+       if (sc->opmode != NL80211_IFTYPE_STATION)
                rfilt |= AR5K_RX_FILTER_PROBEREQ;
-       if (sc->opmode != IEEE80211_IF_TYPE_AP &&
-               sc->opmode != IEEE80211_IF_TYPE_MESH_POINT &&
+       if (sc->opmode != NL80211_IFTYPE_AP &&
+               sc->opmode != NL80211_IFTYPE_MESH_POINT &&
                test_bit(ATH_STAT_PROMISC, sc->status))
                rfilt |= AR5K_RX_FILTER_PROM;
-       if (sc->opmode == IEEE80211_IF_TYPE_STA ||
-               sc->opmode == IEEE80211_IF_TYPE_IBSS) {
+       if (sc->opmode == NL80211_IFTYPE_ADHOC)
                rfilt |= AR5K_RX_FILTER_BEACON;
-       }
 
        /* Set filters */
        ath5k_hw_set_rx_filter(ah,rfilt);
@@ -2995,7 +3046,7 @@ ath5k_reset_tsf(struct ieee80211_hw *hw)
         * in IBSS mode we need to update the beacon timers too.
         * this will also reset the TSF if we call it with 0
         */
-       if (sc->opmode == IEEE80211_IF_TYPE_IBSS)
+       if (sc->opmode == NL80211_IFTYPE_ADHOC)
                ath5k_beacon_update_timers(sc, 0);
        else
                ath5k_hw_reset_tsf(sc->ah);
@@ -3010,7 +3061,7 @@ ath5k_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
 
        ath5k_debug_dump_skb(sc, skb, "BC  ", 1);
 
-       if (sc->opmode != IEEE80211_IF_TYPE_IBSS) {
+       if (sc->opmode != NL80211_IFTYPE_ADHOC) {
                ret = -EIO;
                goto end;
        }