]> xenbits.xensource.com Git - people/liuw/freebsd.git/commitdiff
net80211: WME callback cleanup in various drivers
authoravos <avos@FreeBSD.org>
Thu, 5 Nov 2015 17:58:18 +0000 (17:58 +0000)
committeravos <avos@FreeBSD.org>
Thu, 5 Nov 2015 17:58:18 +0000 (17:58 +0000)
Since r288350, ic_wme_task() is called via ieee80211_runtask(),
so, any additional deferring from the driver side is not needed.

Approved by: adrian (mentor)
Differential Revision: https://reviews.freebsd.org/D4072

sys/dev/iwi/if_iwi.c
sys/dev/iwi/if_iwivar.h
sys/dev/otus/if_otus.c
sys/dev/otus/if_otusreg.h
sys/dev/usb/wlan/if_rum.c
sys/dev/usb/wlan/if_rumvar.h
sys/dev/usb/wlan/if_run.c

index c45a37ffe55e5d471f07297049b8743389b57800..53141e1e449536c5add8bd45443af55ddc15ab1b 100644 (file)
@@ -155,7 +155,6 @@ static void iwi_media_status(struct ifnet *, struct ifmediareq *);
 static int     iwi_newstate(struct ieee80211vap *, enum ieee80211_state, int);
 static void    iwi_wme_init(struct iwi_softc *);
 static int     iwi_wme_setparams(struct iwi_softc *);
-static void    iwi_update_wme(void *, int);
 static int     iwi_wme_update(struct ieee80211com *);
 static uint16_t        iwi_read_prom_word(struct iwi_softc *, uint8_t);
 static void    iwi_frame_intr(struct iwi_softc *, struct iwi_rx_data *, int,
@@ -286,7 +285,6 @@ iwi_attach(device_t dev)
        TASK_INIT(&sc->sc_radiofftask, 0, iwi_radio_off, sc);
        TASK_INIT(&sc->sc_restarttask, 0, iwi_restart, sc);
        TASK_INIT(&sc->sc_disassoctask, 0, iwi_disassoc, sc);
-       TASK_INIT(&sc->sc_wmetask, 0, iwi_update_wme, sc);
        TASK_INIT(&sc->sc_monitortask, 0, iwi_monitor_scan, sc);
 
        callout_init_mtx(&sc->sc_wdtimer, &sc->sc_mtx, 0);
@@ -1060,22 +1058,12 @@ iwi_wme_setparams(struct iwi_softc *sc)
 #undef IWI_USEC
 #undef IWI_EXP2
 
-static void
-iwi_update_wme(void *arg, int npending)
-{
-       struct iwi_softc *sc = arg;
-       IWI_LOCK_DECL;
-
-       IWI_LOCK(sc);
-       (void) iwi_wme_setparams(sc);
-       IWI_UNLOCK(sc);
-}
-
 static int
 iwi_wme_update(struct ieee80211com *ic)
 {
        struct iwi_softc *sc = ic->ic_softc;
        struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
+       IWI_LOCK_DECL;
 
        /*
         * We may be called to update the WME parameters in
@@ -1085,8 +1073,11 @@ iwi_wme_update(struct ieee80211com *ic)
         * to the adapter as part of the work iwi_auth_and_assoc
         * does.
         */
-       if (vap->iv_state == IEEE80211_S_RUN)
-               ieee80211_runtask(ic, &sc->sc_wmetask);
+       if (vap->iv_state == IEEE80211_S_RUN) {
+               IWI_LOCK(sc);
+               iwi_wme_setparams(sc);
+               IWI_UNLOCK(sc);
+       }
        return (0);
 }
 
index 47848e16c8222b1620ae26ca0f534371794a7498..88138cf0ed679f2efb67531cc3ed3638e8a8440a 100644 (file)
@@ -192,7 +192,6 @@ struct iwi_softc {
        struct task             sc_radiofftask; /* radio off processing */
        struct task             sc_restarttask; /* restart adapter processing */
        struct task             sc_disassoctask;
-       struct task             sc_wmetask;     /* set wme parameters */
        struct task             sc_monitortask;
 
        unsigned int            sc_running : 1, /* initialized */
index a61e344e6debac2c7c540c7e3bfa554426b542eb..0d59278050e088572eecaf51beebf0d7285fb929 100644 (file)
@@ -155,7 +155,6 @@ static void otus_free_txcmd(struct otus_softc *, struct otus_tx_cmd *);
 
 void           otus_next_scan(void *, int);
 static void    otus_tx_task(void *, int pending);
-static void    otus_wme_update_task(void *, int pending);
 void           otus_do_async(struct otus_softc *,
                    void (*)(struct otus_softc *, void *), void *, int);
 int            otus_newstate(struct ieee80211vap *, enum ieee80211_state,
@@ -177,8 +176,9 @@ static int  otus_tx(struct otus_softc *, struct ieee80211_node *,
                    const struct ieee80211_bpf_params *);
 int            otus_ioctl(struct ifnet *, u_long, caddr_t);
 int            otus_set_multi(struct otus_softc *);
-static void    otus_updateedca(struct otus_softc *sc);
-static void    otus_updateslot(struct otus_softc *sc);
+static int     otus_updateedca(struct ieee80211com *);
+static void    otus_updateedca_locked(struct otus_softc *);
+static void    otus_updateslot(struct otus_softc *);
 int            otus_init_mac(struct otus_softc *);
 uint32_t       otus_phy_get_def(struct otus_softc *, uint32_t);
 int            otus_set_board_values(struct otus_softc *,
@@ -300,7 +300,6 @@ otus_attach(device_t self)
        TIMEOUT_TASK_INIT(taskqueue_thread, &sc->scan_to, 0, otus_next_scan, sc);
        TIMEOUT_TASK_INIT(taskqueue_thread, &sc->calib_to, 0, otus_calibrate_to, sc);
        TASK_INIT(&sc->tx_task, 0, otus_tx_task, sc);
-       TASK_INIT(&sc->wme_update_task, 0, otus_wme_update_task, sc);
        mbufq_init(&sc->sc_snd, ifqmaxlen);
 
        iface_index = 0;
@@ -345,7 +344,6 @@ otus_detach(device_t self)
        taskqueue_drain_timeout(taskqueue_thread, &sc->scan_to);
        taskqueue_drain_timeout(taskqueue_thread, &sc->calib_to);
        taskqueue_drain(taskqueue_thread, &sc->tx_task);
-       taskqueue_drain(taskqueue_thread, &sc->wme_update_task);
 
        otus_close_pipes(sc);
 #if 0
@@ -590,44 +588,6 @@ otus_set_channel(struct ieee80211com *ic)
        OTUS_UNLOCK(sc);
 }
 
-static void
-otus_wme_update_task(void *arg, int pending)
-{
-       struct otus_softc *sc = arg;
-
-       OTUS_LOCK(sc);
-       /*
-        * XXX TODO: take temporary copy of EDCA information
-        * when scheduling this so we have a more time-correct view
-        * of things.
-        */
-       otus_updateedca(sc);
-       OTUS_UNLOCK(sc);
-}
-
-static void
-otus_wme_schedule_update(struct otus_softc *sc)
-{
-
-       taskqueue_enqueue(taskqueue_thread, &sc->wme_update_task);
-}
-
-/*
- * This is called by net80211 in RX packet context, so we
- * can't sleep here.
- *
- * TODO: have net80211 schedule an update itself for its
- * own internal taskqueue.
- */
-static int
-otus_wme_update(struct ieee80211com *ic)
-{
-       struct otus_softc *sc = ic->ic_softc;
-
-       otus_wme_schedule_update(sc);
-       return (0);
-}
-
 static int
 otus_ampdu_enable(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap)
 {
@@ -811,7 +771,7 @@ otus_attachhook(struct otus_softc *sc)
        ic->ic_transmit = otus_transmit;
        ic->ic_update_chw = otus_update_chw;
        ic->ic_ampdu_enable = otus_ampdu_enable;
-       ic->ic_wme.wme_update = otus_wme_update;
+       ic->ic_wme.wme_update = otus_updateedca;
        ic->ic_newassoc = otus_newassoc;
        ic->ic_node_alloc = otus_node_alloc;
 
@@ -2383,8 +2343,25 @@ otus_set_multi(struct otus_softc *sc)
        return (r);
 }
 
+static int
+otus_updateedca(struct ieee80211com *ic)
+{
+       struct otus_softc *sc = ic->ic_softc;
+
+       OTUS_LOCK(sc);
+       /*
+        * XXX TODO: take temporary copy of EDCA information
+        * when scheduling this so we have a more time-correct view
+        * of things.
+        * XXX TODO: this can be done on the net80211 level
+        */
+       otus_updateedca_locked(sc);
+       OTUS_UNLOCK(sc);
+       return (0);
+}
+
 static void
-otus_updateedca(struct otus_softc *sc)
+otus_updateedca_locked(struct otus_softc *sc)
 {
 #define EXP2(val)      ((1 << (val)) - 1)
 #define AIFS(val)      ((val) * 9 + 10)
@@ -2508,7 +2485,7 @@ otus_init_mac(struct otus_softc *sc)
                return error;
 
        /* Set default EDCA parameters. */
-       otus_updateedca(sc);
+       otus_updateedca_locked(sc);
 
        return 0;
 }
@@ -3185,7 +3162,6 @@ otus_stop(struct otus_softc *sc)
        taskqueue_drain_timeout(taskqueue_thread, &sc->scan_to);
        taskqueue_drain_timeout(taskqueue_thread, &sc->calib_to);
        taskqueue_drain(taskqueue_thread, &sc->tx_task);
-       taskqueue_drain(taskqueue_thread, &sc->wme_update_task);
 
        OTUS_LOCK(sc);
        sc->sc_running = 0;
index 491e52972092cc199164bf0c27a9e7402ab0768e..c7e2c2b9b237f6fc09af11b39927a3efc4439eb4 100644 (file)
@@ -1009,7 +1009,6 @@ struct otus_softc {
        struct ieee80211_channel        *sc_curchan;
 
        struct task                     tx_task;
-       struct task                     wme_update_task;
        struct timeout_task             scan_to;
        struct timeout_task             calib_to;
 
index de7b8806e80099709f5eeb31cc8ef29cd05b5371..9d2203da5494bca18e5febddae5b8faf39f8f609 100644 (file)
@@ -216,8 +216,6 @@ static void         rum_get_tsf(struct rum_softc *, uint64_t *);
 static void            rum_update_slot_cb(struct rum_softc *,
                            union sec_param *, uint8_t);
 static void            rum_update_slot(struct ieee80211com *);
-static void            rum_wme_update_cb(struct rum_softc *,
-                           union sec_param *, uint8_t);
 static int             rum_wme_update(struct ieee80211com *);
 static void            rum_set_bssid(struct rum_softc *, const uint8_t *);
 static void            rum_set_macaddr(struct rum_softc *, const uint8_t *);
@@ -2083,14 +2081,15 @@ rum_update_slot(struct ieee80211com *ic)
        rum_cmd_sleepable(ic->ic_softc, NULL, 0, 0, rum_update_slot_cb);
 }
 
-static void
-rum_wme_update_cb(struct rum_softc *sc, union sec_param *data, uint8_t rvp_id)
+static int
+rum_wme_update(struct ieee80211com *ic)
 {
-       struct ieee80211com *ic = &sc->sc_ic;
        const struct wmeParams *chanp =
            ic->ic_wme.wme_chanParams.cap_wmeParams;
+       struct rum_softc *sc = ic->ic_softc;
        int error = 0;
 
+       RUM_LOCK(sc);
        error = rum_write(sc, RT2573_AIFSN_CSR,
            chanp[WME_AC_VO].wmep_aifsn  << 12 |
            chanp[WME_AC_VI].wmep_aifsn  <<  8 |
@@ -2125,21 +2124,14 @@ rum_wme_update_cb(struct rum_softc *sc, union sec_param *data, uint8_t rvp_id)
 
        memcpy(sc->wme_params, chanp, sizeof(*chanp) * WME_NUM_AC);
 
-       return;
-
 print_err:
-       device_printf(sc->sc_dev, "%s: WME update failed, error %d\n",
-           __func__, error);
-}
-
-static int
-rum_wme_update(struct ieee80211com *ic)
-{
-       struct rum_softc *sc = ic->ic_softc;
-
-       rum_cmd_sleepable(sc, NULL, 0, 0, rum_wme_update_cb);
+       RUM_UNLOCK(sc);
+       if (error != 0) {
+               device_printf(sc->sc_dev, "%s: WME update failed, error %d\n",
+                   __func__, error);
+       }
 
-       return (0);
+       return (error);
 }
 
 static void
index 9fa733e4c5f967aa66c12b21b43bfa85919bc93c..d4944680803dd64c4f44569a86d8e4731e06d1ea 100644 (file)
@@ -73,7 +73,6 @@ typedef STAILQ_HEAD(, rum_tx_data) rum_txdhead;
 
 union sec_param {
        struct ieee80211_key            key;
-       struct wmeParams                wme_params[WME_NUM_AC];
        uint8_t                         macaddr[IEEE80211_ADDR_LEN];
        struct ieee80211vap             *vap;
 };
index d5b52887ba3f6e12a4bef78173c2360c112aaa21..bb52a09322cb998eaea1ad0fd9aee8b7e5316025 100644 (file)
@@ -381,7 +381,6 @@ static struct ieee80211_node *run_node_alloc(struct ieee80211vap *,
 static int     run_media_change(struct ifnet *);
 static int     run_newstate(struct ieee80211vap *, enum ieee80211_state, int);
 static int     run_wme_update(struct ieee80211com *);
-static void    run_wme_update_cb(void *);
 static void    run_key_set_cb(void *);
 static int     run_key_set(struct ieee80211vap *, struct ieee80211_key *);
 static void    run_key_delete_cb(void *);
@@ -2174,19 +2173,16 @@ run_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
        return(rvp->newstate(vap, nstate, arg));
 }
 
-/* ARGSUSED */
-static void
-run_wme_update_cb(void *arg)
+static int
+run_wme_update(struct ieee80211com *ic)
 {
-       struct ieee80211com *ic = arg;
        struct run_softc *sc = ic->ic_softc;
        const struct wmeParams *ac =
            ic->ic_wme.wme_chanParams.cap_wmeParams;
        int aci, error = 0;
 
-       RUN_LOCK_ASSERT(sc, MA_OWNED);
-
        /* update MAC TX configuration registers */
+       RUN_LOCK(sc);
        for (aci = 0; aci < WME_NUM_AC; aci++) {
                error = run_write(sc, RT2860_EDCA_AC_CFG(aci),
                    ac[aci].wmep_logcwmax << 16 |
@@ -2224,33 +2220,11 @@ run_wme_update_cb(void *arg)
            ac[WME_AC_VI].wmep_txopLimit);
 
 err:
+       RUN_UNLOCK(sc);
        if (error)
                DPRINTF("WME update failed\n");
 
-       return;
-}
-
-static int
-run_wme_update(struct ieee80211com *ic)
-{
-       struct run_softc *sc = ic->ic_softc;
-
-       /* sometime called wothout lock */
-       if (mtx_owned(&ic->ic_comlock.mtx)) {
-               uint32_t i = RUN_CMDQ_GET(&sc->cmdq_store);
-               DPRINTF("cmdq_store=%d\n", i);
-               sc->cmdq[i].func = run_wme_update_cb;
-               sc->cmdq[i].arg0 = ic;
-               ieee80211_runtask(ic, &sc->cmdq_task);
-               return (0);
-       }
-
-       RUN_LOCK(sc);
-       run_wme_update_cb(ic);
-       RUN_UNLOCK(sc);
-
-       /* return whatever, upper layer doesn't care anyway */
-       return (0);
+       return (error);
 }
 
 static void