ath9k: Free Beacon skbs in AP mode
[pandora-kernel.git] / drivers / net / wireless / ath9k / beacon.c
index 4dd1c1b..d874223 100644 (file)
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
- /* Implementation of beacon processing. */
-
 #include "core.h"
 
 /*
- *  Configure parameters for the beacon queue
- *
  *  This function will modify certain transmit queue properties depending on
  *  the operating mode of the station (AP or AdHoc).  Parameters are AIFS
  *  settings and channel width min/max
@@ -31,7 +27,7 @@ static int ath_beaconq_config(struct ath_softc *sc)
        struct ath9k_tx_queue_info qi;
 
        ath9k_hw_get_txq_props(ah, sc->sc_bhalq, &qi);
-       if (sc->sc_ah->ah_opmode == ATH9K_M_HOSTAP) {
+       if (sc->sc_ah->ah_opmode == NL80211_IFTYPE_AP) {
                /* Always burst out beacon and CAB traffic. */
                qi.tqi_aifs = 1;
                qi.tqi_cwmin = 0;
@@ -45,8 +41,7 @@ static int ath_beaconq_config(struct ath_softc *sc)
 
        if (!ath9k_hw_set_txq_props(ah, sc->sc_bhalq, &qi)) {
                DPRINTF(sc, ATH_DBG_FATAL,
-                       "%s: unable to update h/w beacon queue parameters\n",
-                       __func__);
+                       "unable to update h/w beacon queue parameters\n");
                return 0;
        } else {
                ath9k_hw_resettxqueue(ah, sc->sc_bhalq); /* push to h/w */
@@ -54,9 +49,15 @@ static int ath_beaconq_config(struct ath_softc *sc)
        }
 }
 
+static void ath_bstuck_process(struct ath_softc *sc)
+{
+       DPRINTF(sc, ATH_DBG_BEACON,
+               "stuck beacon; resetting (bmiss count %u)\n",
+               sc->sc_bmisscount);
+       ath_reset(sc, false);
+}
+
 /*
- *  Setup the beacon frame for transmit.
- *
  *  Associates the beacon frame buffer with a transmit descriptor.  Will set
  *  up all required antenna switch parameters, rate codes, and channel flags.
  *  Beacons are always sent out at the lowest rate, and are not retried.
@@ -68,21 +69,20 @@ static void ath_beacon_setup(struct ath_softc *sc,
        struct ath_hal *ah = sc->sc_ah;
        struct ath_desc *ds;
        struct ath9k_11n_rate_series series[4];
-       const struct ath9k_rate_table *rt;
+       struct ath_rate_table *rt;
        int flags, antenna;
        u8 rix, rate;
        int ctsrate = 0;
        int ctsduration = 0;
 
-       DPRINTF(sc, ATH_DBG_BEACON, "%s: m %p len %u\n",
-               __func__, skb, skb->len);
+       DPRINTF(sc, ATH_DBG_BEACON, "m %p len %u\n", skb, skb->len);
 
        /* setup descriptors */
        ds = bf->bf_desc;
 
        flags = ATH9K_TXDESC_NOACK;
 
-       if (sc->sc_ah->ah_opmode == ATH9K_M_IBSS &&
+       if (sc->sc_ah->ah_opmode == NL80211_IFTYPE_ADHOC &&
            (ah->ah_caps.hw_caps & ATH9K_HW_CAP_VEOL)) {
                ds->ds_link = bf->bf_daddr; /* self-linked */
                flags |= ATH9K_TXDESC_VEOL;
@@ -106,15 +106,15 @@ static void ath_beacon_setup(struct ath_softc *sc,
         * XXX everything at min xmit rate
         */
        rix = 0;
-       rt = sc->sc_currates;
-       rate = rt->info[rix].rateCode;
+       rt = sc->hw_rate_table[sc->sc_curmode];
+       rate = rt->info[rix].ratecode;
        if (sc->sc_flags & SC_OP_PREAMBLE_SHORT)
-               rate |= rt->info[rix].shortPreamble;
+               rate |= rt->info[rix].short_preamble;
 
        ath9k_hw_set11n_txdesc(ah, ds,
                               skb->len + FCS_LEN,     /* frame length */
                               ATH9K_PKT_TYPE_BEACON,  /* Atheros packet type */
-                              avp->av_btxctl.txpower, /* txpower XXX */
+                              MAX_RATE_POWER,         /* FIXME */
                               ATH9K_TXKEYIX_INVALID,  /* no encryption */
                               ATH9K_KEY_TYPE_CLEAR,   /* no encryption */
                               flags                   /* no ack,
@@ -138,31 +138,26 @@ static void ath_beacon_setup(struct ath_softc *sc,
                ctsrate, ctsduration, series, 4, 0);
 }
 
-/*
- *  Generate beacon frame and queue cab data for a vap.
- *
- *  Updates the contents of the beacon frame.  It is assumed that the buffer for
- *  the beacon frame has been allocated in the ATH object, and simply needs to
- *  be filled for this cycle.  Also, any CAB (crap after beacon?) traffic will
- *  be added to the beacon frame at this point.
-*/
+/* Generate beacon frame and queue cab data for a vap */
 static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
 {
        struct ath_buf *bf;
        struct ath_vap *avp;
        struct sk_buff *skb;
        struct ath_txq *cabq;
+       struct ieee80211_vif *vif;
        struct ieee80211_tx_info *info;
        int cabq_depth;
 
-       avp = sc->sc_vaps[if_id];
-       ASSERT(avp);
+       vif = sc->sc_vaps[if_id];
+       ASSERT(vif);
 
+       avp = (void *)vif->drv_priv;
        cabq = sc->sc_cabq;
 
        if (avp->av_bcbuf == NULL) {
-               DPRINTF(sc, ATH_DBG_BEACON, "%s: avp=%p av_bcbuf=%p\n",
-                       __func__, avp, avp->av_bcbuf);
+               DPRINTF(sc, ATH_DBG_BEACON, "avp=%p av_bcbuf=%p\n",
+                       avp, avp->av_bcbuf);
                return NULL;
        }
 
@@ -172,9 +167,10 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
                pci_unmap_single(sc->pdev, bf->bf_dmacontext,
                                 skb->len,
                                 PCI_DMA_TODEVICE);
+               dev_kfree_skb_any(skb);
        }
 
-       skb = ieee80211_beacon_get(sc->hw, avp->av_if_data);
+       skb = ieee80211_beacon_get(sc->hw, vif);
        bf->bf_mpdu = skb;
        if (skb == NULL)
                return NULL;
@@ -195,8 +191,15 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
                pci_map_single(sc->pdev, skb->data,
                               skb->len,
                               PCI_DMA_TODEVICE);
+       if (unlikely(pci_dma_mapping_error(sc->pdev, bf->bf_buf_addr))) {
+               dev_kfree_skb_any(skb);
+               bf->bf_mpdu = NULL;
+               DPRINTF(sc, ATH_DBG_CONFIG,
+                       "pci_dma_mapping_error() on beaconing\n");
+               return NULL;
+       }
 
-       skb = ieee80211_get_buffered_bc(sc->hw, avp->av_if_data);
+       skb = ieee80211_get_buffered_bc(sc->hw, vif);
 
        /*
         * if the CABQ traffic from previous DTIM is pending and the current
@@ -219,7 +222,7 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
                if (sc->sc_nvaps > 1) {
                        ath_tx_draintxq(sc, cabq, false);
                        DPRINTF(sc, ATH_DBG_BEACON,
-                               "%s: flush previous cabq traffic\n", __func__);
+                               "flush previous cabq traffic\n");
                }
        }
 
@@ -232,7 +235,7 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
         */
        while (skb) {
                ath_tx_cabq(sc, skb);
-               skb = ieee80211_get_buffered_bc(sc->hw, avp->av_if_data);
+               skb = ieee80211_get_buffered_bc(sc->hw, vif);
        }
 
        return bf;
@@ -244,17 +247,20 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
 */
 static void ath_beacon_start_adhoc(struct ath_softc *sc, int if_id)
 {
+       struct ieee80211_vif *vif;
        struct ath_hal *ah = sc->sc_ah;
        struct ath_buf *bf;
        struct ath_vap *avp;
        struct sk_buff *skb;
 
-       avp = sc->sc_vaps[if_id];
-       ASSERT(avp);
+       vif = sc->sc_vaps[if_id];
+       ASSERT(vif);
+
+       avp = (void *)vif->drv_priv;
 
        if (avp->av_bcbuf == NULL) {
-               DPRINTF(sc, ATH_DBG_BEACON, "%s: avp=%p av_bcbuf=%p\n",
-                       __func__, avp, avp != NULL ? avp->av_bcbuf : NULL);
+               DPRINTF(sc, ATH_DBG_BEACON, "avp=%p av_bcbuf=%p\n",
+                       avp, avp != NULL ? avp->av_bcbuf : NULL);
                return;
        }
        bf = avp->av_bcbuf;
@@ -266,18 +272,10 @@ static void ath_beacon_start_adhoc(struct ath_softc *sc, int if_id)
        /* NB: caller is known to have already stopped tx dma */
        ath9k_hw_puttxbuf(ah, sc->sc_bhalq, bf->bf_daddr);
        ath9k_hw_txstart(ah, sc->sc_bhalq);
-       DPRINTF(sc, ATH_DBG_BEACON, "%s: TXDP%u = %llx (%p)\n", __func__,
+       DPRINTF(sc, ATH_DBG_BEACON, "TXDP%u = %llx (%p)\n",
                sc->sc_bhalq, ito64(bf->bf_daddr), bf->bf_desc);
 }
 
-/*
- *  Setup a h/w transmit queue for beacons.
- *
- *  This function allocates an information structure (struct ath9k_txq_info)
- *  on the stack, sets some specific parameters (zero out channel width
- *  min/max, and enable aifs). The info structure does not need to be
- *  persistant.
-*/
 int ath_beaconq_setup(struct ath_hal *ah)
 {
        struct ath9k_tx_queue_info qi;
@@ -290,35 +288,29 @@ int ath_beaconq_setup(struct ath_hal *ah)
        return ath9k_hw_setuptxqueue(ah, ATH9K_TX_QUEUE_BEACON, &qi);
 }
 
-
-/*
- *  Allocate and setup an initial beacon frame.
- *
- *  Allocate a beacon state variable for a specific VAP instance created on
- *  the ATH interface.  This routine also calculates the beacon "slot" for
- *  staggared beacons in the mBSSID case.
-*/
 int ath_beacon_alloc(struct ath_softc *sc, int if_id)
 {
+       struct ieee80211_vif *vif;
        struct ath_vap *avp;
        struct ieee80211_hdr *hdr;
        struct ath_buf *bf;
        struct sk_buff *skb;
        __le64 tstamp;
 
-       avp = sc->sc_vaps[if_id];
-       ASSERT(avp);
+       vif = sc->sc_vaps[if_id];
+       ASSERT(vif);
+
+       avp = (void *)vif->drv_priv;
 
        /* Allocate a beacon descriptor if we haven't done so. */
        if (!avp->av_bcbuf) {
                /* Allocate beacon state for hostap/ibss.  We know
                 * a buffer is available. */
-
                avp->av_bcbuf = list_first_entry(&sc->sc_bbuf,
                                                 struct ath_buf, list);
                list_del(&avp->av_bcbuf->list);
 
-               if (sc->sc_ah->ah_opmode == ATH9K_M_HOSTAP ||
+               if (sc->sc_ah->ah_opmode == NL80211_IFTYPE_AP ||
                    !(sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_VEOL)) {
                        int slot;
                        /*
@@ -363,10 +355,9 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
         * FIXME: Fill avp->av_btxctl.txpower and
         * avp->av_btxctl.shortPreamble
         */
-       skb = ieee80211_beacon_get(sc->hw, avp->av_if_data);
+       skb = ieee80211_beacon_get(sc->hw, vif);
        if (skb == NULL) {
-               DPRINTF(sc, ATH_DBG_BEACON, "%s: cannot get skb\n",
-                       __func__);
+               DPRINTF(sc, ATH_DBG_BEACON, "cannot get skb\n");
                return -ENOMEM;
        }
 
@@ -402,29 +393,29 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
                val = cpu_to_le64(tsfadjust << 10);     /* TU->TSF */
 
                DPRINTF(sc, ATH_DBG_BEACON,
-                       "%s: %s beacons, bslot %d intval %u tsfadjust %llu\n",
-                       __func__, "stagger",
+                       "stagger beacons, bslot %d intval %u tsfadjust %llu\n",
                        avp->av_bslot, intval, (unsigned long long)tsfadjust);
 
                hdr = (struct ieee80211_hdr *)skb->data;
                memcpy(&hdr[1], &val, sizeof(val));
        }
 
+       bf->bf_mpdu = skb;
        bf->bf_buf_addr = bf->bf_dmacontext =
                pci_map_single(sc->pdev, skb->data,
                               skb->len,
                               PCI_DMA_TODEVICE);
-       bf->bf_mpdu = skb;
+       if (unlikely(pci_dma_mapping_error(sc->pdev, bf->bf_buf_addr))) {
+               dev_kfree_skb_any(skb);
+               bf->bf_mpdu = NULL;
+               DPRINTF(sc, ATH_DBG_CONFIG,
+                       "pci_dma_mapping_error() on beacon alloc\n");
+               return -ENOMEM;
+       }
 
        return 0;
 }
 
-/*
- *  Reclaim beacon resources and return buffer to the pool.
- *
- *  Checks the VAP to put the beacon frame buffer back to the ATH object
- *  queue, and de-allocates any skbs that were sent as CAB traffic.
-*/
 void ath_beacon_return(struct ath_softc *sc, struct ath_vap *avp)
 {
        if (avp->av_bcbuf != NULL) {
@@ -450,13 +441,6 @@ void ath_beacon_return(struct ath_softc *sc, struct ath_vap *avp)
        }
 }
 
-/*
- * Tasklet for Sending Beacons
- *
- * Transmit one or more beacon frames at SWBA.  Dynamic updates to the frame
- * contents are done as needed and the slot time is also adjusted based on
- * current state.
-*/
 void ath9k_beacon_tasklet(unsigned long data)
 {
        struct ath_softc *sc = (struct ath_softc *)data;
@@ -473,9 +457,7 @@ void ath9k_beacon_tasklet(unsigned long data)
 
        if (sc->sc_flags & SC_OP_NO_RESET) {
                show_cycles = ath9k_hw_GetMibCycleCountsPct(ah,
-                                                           &rx_clear,
-                                                           &rx_frame,
-                                                           &tx_frame);
+                                           &rx_clear, &rx_frame, &tx_frame);
        }
 
        /*
@@ -497,40 +479,38 @@ void ath9k_beacon_tasklet(unsigned long data)
                if (sc->sc_bmisscount < BSTUCK_THRESH) {
                        if (sc->sc_flags & SC_OP_NO_RESET) {
                                DPRINTF(sc, ATH_DBG_BEACON,
-                                       "%s: missed %u consecutive beacons\n",
-                                       __func__, sc->sc_bmisscount);
+                                       "missed %u consecutive beacons\n",
+                                       sc->sc_bmisscount);
                                if (show_cycles) {
                                        /*
                                         * Display cycle counter stats from HW
                                         * to aide in debug of stickiness.
                                         */
                                        DPRINTF(sc, ATH_DBG_BEACON,
-                                               "%s: busy times: rx_clear=%d, "
+                                               "busy times: rx_clear=%d, "
                                                "rx_frame=%d, tx_frame=%d\n",
-                                               __func__, rx_clear, rx_frame,
+                                               rx_clear, rx_frame,
                                                tx_frame);
                                } else {
                                        DPRINTF(sc, ATH_DBG_BEACON,
-                                               "%s: unable to obtain "
-                                               "busy times\n", __func__);
+                                               "unable to obtain "
+                                               "busy times\n");
                                }
                        } else {
                                DPRINTF(sc, ATH_DBG_BEACON,
-                                       "%s: missed %u consecutive beacons\n",
-                                       __func__, sc->sc_bmisscount);
+                                       "missed %u consecutive beacons\n",
+                                       sc->sc_bmisscount);
                        }
                } else if (sc->sc_bmisscount >= BSTUCK_THRESH) {
                        if (sc->sc_flags & SC_OP_NO_RESET) {
                                if (sc->sc_bmisscount == BSTUCK_THRESH) {
                                        DPRINTF(sc, ATH_DBG_BEACON,
-                                               "%s: beacon is officially "
-                                               "stuck\n", __func__);
-                                       ath9k_hw_dmaRegDump(ah);
+                                               "beacon is officially "
+                                               "stuck\n");
                                }
                        } else {
                                DPRINTF(sc, ATH_DBG_BEACON,
-                                       "%s: beacon is officially stuck\n",
-                                       __func__);
+                                       "beacon is officially stuck\n");
                                ath_bstuck_process(sc);
                        }
                }
@@ -540,12 +520,12 @@ void ath9k_beacon_tasklet(unsigned long data)
        if (sc->sc_bmisscount != 0) {
                if (sc->sc_flags & SC_OP_NO_RESET) {
                        DPRINTF(sc, ATH_DBG_BEACON,
-                               "%s: resume beacon xmit after %u misses\n",
-                               __func__, sc->sc_bmisscount);
+                               "resume beacon xmit after %u misses\n",
+                               sc->sc_bmisscount);
                } else {
                        DPRINTF(sc, ATH_DBG_BEACON,
-                               "%s: resume beacon xmit after %u misses\n",
-                               __func__, sc->sc_bmisscount);
+                               "resume beacon xmit after %u misses\n",
+                               sc->sc_bmisscount);
                }
                sc->sc_bmisscount = 0;
        }
@@ -565,8 +545,8 @@ void ath9k_beacon_tasklet(unsigned long data)
        if_id = sc->sc_bslot[(slot + 1) % ATH_BCBUF];
 
        DPRINTF(sc, ATH_DBG_BEACON,
-               "%s: slot %d [tsf %llu tsftu %u intval %u] if_id %d\n",
-               __func__, slot, (unsigned long long)tsf, tsftu,
+               "slot %d [tsf %llu tsftu %u intval %u] if_id %d\n",
+               slot, (unsigned long long)tsf, tsftu,
                intval, if_id);
 
        bfaddr = 0;
@@ -597,9 +577,10 @@ void ath9k_beacon_tasklet(unsigned long data)
        if (sc->sc_updateslot == UPDATE) {
                sc->sc_updateslot = COMMIT; /* commit next beacon */
                sc->sc_slotupdate = slot;
-       } else if (sc->sc_updateslot == COMMIT && sc->sc_slotupdate == slot)
-               ath_setslottime(sc);        /* commit change to hardware */
-
+       } else if (sc->sc_updateslot == COMMIT && sc->sc_slotupdate == slot) {
+               ath9k_hw_setslottime(sc->sc_ah, sc->sc_slottime);
+               sc->sc_updateslot = OK;
+       }
        if (bfaddr != 0) {
                /*
                 * Stop any current dma and put the new frame(s) on the queue.
@@ -608,8 +589,7 @@ void ath9k_beacon_tasklet(unsigned long data)
                 */
                if (!ath9k_hw_stoptxdma(ah, sc->sc_bhalq)) {
                        DPRINTF(sc, ATH_DBG_FATAL,
-                               "%s: beacon queue %u did not stop?\n",
-                               __func__, sc->sc_bhalq);
+                               "beacon queue %u did not stop?\n", sc->sc_bhalq);
                        /* NB: the HAL still stops DMA, so proceed */
                }
 
@@ -621,20 +601,6 @@ void ath9k_beacon_tasklet(unsigned long data)
        }
 }
 
-/*
- *  Tasklet for Beacon Stuck processing
- *
- *  Processing for Beacon Stuck.
- *  Basically resets the chip.
-*/
-void ath_bstuck_process(struct ath_softc *sc)
-{
-       DPRINTF(sc, ATH_DBG_BEACON,
-               "%s: stuck beacon; resetting (bmiss count %u)\n",
-               __func__, sc->sc_bmisscount);
-       ath_reset(sc, false);
-}
-
 /*
  * Configure the beacon and sleep timers.
  *
@@ -652,15 +618,21 @@ void ath_bstuck_process(struct ath_softc *sc)
  */
 void ath_beacon_config(struct ath_softc *sc, int if_id)
 {
+       struct ieee80211_vif *vif;
        struct ath_hal *ah = sc->sc_ah;
        struct ath_beacon_config conf;
-       enum ath9k_opmode av_opmode;
+       struct ath_vap *avp;
+       enum nl80211_iftype opmode;
        u32 nexttbtt, intval;
 
-       if (if_id != ATH_IF_ID_ANY)
-               av_opmode = sc->sc_vaps[if_id]->av_opmode;
-       else
-               av_opmode = sc->sc_ah->ah_opmode;
+       if (if_id != ATH_IF_ID_ANY) {
+               vif = sc->sc_vaps[if_id];
+               ASSERT(vif);
+               avp = (void *)vif->drv_priv;
+               opmode = avp->av_opmode;
+       } else {
+               opmode = sc->sc_ah->ah_opmode;
+       }
 
        memset(&conf, 0, sizeof(struct ath_beacon_config));
 
@@ -675,7 +647,7 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
        nexttbtt = TSF_TO_TU(sc->bc_tstamp >> 32, sc->bc_tstamp);
 
        /* XXX conditionalize multi-bss support? */
-       if (sc->sc_ah->ah_opmode == ATH9K_M_HOSTAP) {
+       if (sc->sc_ah->ah_opmode == NL80211_IFTYPE_AP) {
                /*
                 * For multi-bss ap support beacons are either staggered
                 * evenly over N slots or burst together.  For the former
@@ -694,11 +666,11 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
        else if (intval)        /* NB: can be 0 for monitor mode */
                nexttbtt = roundup(nexttbtt, intval);
 
-       DPRINTF(sc, ATH_DBG_BEACON, "%s: nexttbtt %u intval %u (%u)\n",
-               __func__, nexttbtt, intval, conf.beacon_interval);
+       DPRINTF(sc, ATH_DBG_BEACON, "nexttbtt %u intval %u (%u)\n",
+               nexttbtt, intval, conf.beacon_interval);
 
-       /* Check for ATH9K_M_HOSTAP and sc_nostabeacons for WDS client */
-       if (sc->sc_ah->ah_opmode == ATH9K_M_STA) {
+       /* Check for NL80211_IFTYPE_AP and sc_nostabeacons for WDS client */
+       if (sc->sc_ah->ah_opmode == NL80211_IFTYPE_STATION) {
                struct ath9k_beacon_state bs;
                u64 tsf;
                u32 tsftu;
@@ -782,7 +754,7 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
                        bs.bs_sleepduration = bs.bs_dtimperiod;
 
                DPRINTF(sc, ATH_DBG_BEACON,
-                       "%s: tsf %llu "
+                       "tsf %llu "
                        "tsf:tu %u "
                        "intval %u "
                        "nexttbtt %u "
@@ -794,7 +766,6 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
                        "maxdur %u "
                        "next %u "
                        "timoffset %u\n",
-                       __func__,
                        (unsigned long long)tsf, tsftu,
                        bs.bs_intval,
                        bs.bs_nexttbtt,
@@ -818,7 +789,7 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
                ath9k_hw_set_interrupts(ah, 0);
                if (nexttbtt == intval)
                        intval |= ATH9K_BEACON_RESET_TSF;
-               if (sc->sc_ah->ah_opmode == ATH9K_M_IBSS) {
+               if (sc->sc_ah->ah_opmode == NL80211_IFTYPE_ADHOC) {
                        /*
                         * Pull nexttbtt forward to reflect the current
                         * TSF
@@ -834,8 +805,8 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
                        }
 #undef FUDGE
                        DPRINTF(sc, ATH_DBG_BEACON,
-                               "%s: IBSS nexttbtt %u intval %u (%u)\n",
-                               __func__, nexttbtt,
+                               "IBSS nexttbtt %u intval %u (%u)\n",
+                               nexttbtt,
                                intval & ~ATH9K_BEACON_RESET_TSF,
                                conf.beacon_interval);
 
@@ -850,7 +821,7 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
                        if (!(ah->ah_caps.hw_caps & ATH9K_HW_CAP_VEOL))
                                sc->sc_imask |= ATH9K_INT_SWBA;
                        ath_beaconq_config(sc);
-               } else if (sc->sc_ah->ah_opmode == ATH9K_M_HOSTAP) {
+               } else if (sc->sc_ah->ah_opmode == NL80211_IFTYPE_AP) {
                        /*
                         * In AP mode we enable the beacon timers and
                         * SWBA interrupts to prepare beacon frames.
@@ -866,14 +837,12 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
                 * When using a self-linked beacon descriptor in
                 * ibss mode load it once here.
                 */
-               if (sc->sc_ah->ah_opmode == ATH9K_M_IBSS &&
+               if (sc->sc_ah->ah_opmode == NL80211_IFTYPE_ADHOC &&
                    (ah->ah_caps.hw_caps & ATH9K_HW_CAP_VEOL))
                        ath_beacon_start_adhoc(sc, 0);
        }
 }
 
-/* Function to collect beacon rssi data and resync beacon if necessary */
-
 void ath_beacon_sync(struct ath_softc *sc, int if_id)
 {
        /*