]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ath9k: Add a simple virtual wiphy scheduler
authorJouni Malinen <jouni.malinen@atheros.com>
Tue, 3 Mar 2009 17:23:39 +0000 (19:23 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 5 Mar 2009 19:39:48 +0000 (14:39 -0500)
This is a very simple scheduler that goes through the wiphys and
schedules one at a time every N milliseconds (current default value:
500 ms). This is enough for initial testing, but there are number of
areas where a more complex scheduler can improve operations greatly.

Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath9k/ath9k.h
drivers/net/wireless/ath9k/main.c
drivers/net/wireless/ath9k/virtual.c

index 983f53daa1cc77008779dc6d9ede365acba4ffc8..f0b105a11ae2b6144fbfe7601775ed3e02c9846f 100644 (file)
@@ -569,6 +569,9 @@ struct ath_softc {
        struct work_struct chan_work;
        int wiphy_select_failures;
        unsigned long wiphy_select_first_fail;
+       struct delayed_work wiphy_work;
+       unsigned long wiphy_scheduler_int;
+       int wiphy_scheduler_index;
 
        struct tasklet_struct intr_tq;
        struct tasklet_struct bcon_tasklet;
@@ -713,10 +716,12 @@ void ath9k_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb);
 int ath9k_wiphy_pause(struct ath_wiphy *aphy);
 int ath9k_wiphy_unpause(struct ath_wiphy *aphy);
 int ath9k_wiphy_select(struct ath_wiphy *aphy);
+void ath9k_wiphy_set_scheduler(struct ath_softc *sc, unsigned int msec_int);
 void ath9k_wiphy_chan_work(struct work_struct *work);
 bool ath9k_wiphy_started(struct ath_softc *sc);
 void ath9k_wiphy_pause_all_forced(struct ath_softc *sc,
                                  struct ath_wiphy *selected);
 bool ath9k_wiphy_scanning(struct ath_softc *sc);
+void ath9k_wiphy_work(struct work_struct *work);
 
 #endif /* ATH9K_H */
index 626392241d43e1e19b9becfffaa566de43beb988..f473fee72a2e49666b0011ae714e55c68ac9953c 100644 (file)
@@ -1325,6 +1325,7 @@ void ath_detach(struct ath_softc *sc)
 #endif
        ath_deinit_leds(sc);
        cancel_work_sync(&sc->chan_work);
+       cancel_delayed_work_sync(&sc->wiphy_work);
 
        for (i = 0; i < sc->num_sec_wiphy; i++) {
                struct ath_wiphy *aphy = sc->sec_wiphy[i];
@@ -1672,6 +1673,8 @@ int ath_attach(u16 devid, struct ath_softc *sc)
        ath9k_reg_apply_world_flags(hw->wiphy, REGDOM_SET_BY_INIT);
 
        INIT_WORK(&sc->chan_work, ath9k_wiphy_chan_work);
+       INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work);
+       sc->wiphy_scheduler_int = msecs_to_jiffies(500);
 
        error = ieee80211_register_hw(hw);
 
index 2b545319408d9871437bcda0063f38af0c85a21c..1ff429b027d7299380e0ec80bfea48222ee6eeec 100644 (file)
@@ -154,6 +154,11 @@ int ath9k_wiphy_add(struct ath_softc *sc)
 
        error = ieee80211_register_hw(hw);
 
+       if (error == 0) {
+               /* Make sure wiphy scheduler is started (if enabled) */
+               ath9k_wiphy_set_scheduler(sc, sc->wiphy_scheduler_int);
+       }
+
        return error;
 }
 
@@ -596,3 +601,62 @@ void ath9k_wiphy_pause_all_forced(struct ath_softc *sc,
        }
        spin_unlock_bh(&sc->wiphy_lock);
 }
+
+void ath9k_wiphy_work(struct work_struct *work)
+{
+       struct ath_softc *sc = container_of(work, struct ath_softc,
+                                           wiphy_work.work);
+       struct ath_wiphy *aphy = NULL;
+       bool first = true;
+
+       spin_lock_bh(&sc->wiphy_lock);
+
+       if (sc->wiphy_scheduler_int == 0) {
+               /* wiphy scheduler is disabled */
+               spin_unlock_bh(&sc->wiphy_lock);
+               return;
+       }
+
+try_again:
+       sc->wiphy_scheduler_index++;
+       while (sc->wiphy_scheduler_index <= sc->num_sec_wiphy) {
+               aphy = sc->sec_wiphy[sc->wiphy_scheduler_index - 1];
+               if (aphy && aphy->state != ATH_WIPHY_INACTIVE)
+                       break;
+
+               sc->wiphy_scheduler_index++;
+               aphy = NULL;
+       }
+       if (aphy == NULL) {
+               sc->wiphy_scheduler_index = 0;
+               if (sc->pri_wiphy->state == ATH_WIPHY_INACTIVE) {
+                       if (first) {
+                               first = false;
+                               goto try_again;
+                       }
+                       /* No wiphy is ready to be scheduled */
+               } else
+                       aphy = sc->pri_wiphy;
+       }
+
+       spin_unlock_bh(&sc->wiphy_lock);
+
+       if (aphy &&
+           aphy->state != ATH_WIPHY_ACTIVE && aphy->state != ATH_WIPHY_SCAN &&
+           ath9k_wiphy_select(aphy)) {
+               printk(KERN_DEBUG "ath9k: Failed to schedule virtual wiphy "
+                      "change\n");
+       }
+
+       queue_delayed_work(sc->hw->workqueue, &sc->wiphy_work,
+                          sc->wiphy_scheduler_int);
+}
+
+void ath9k_wiphy_set_scheduler(struct ath_softc *sc, unsigned int msec_int)
+{
+       cancel_delayed_work_sync(&sc->wiphy_work);
+       sc->wiphy_scheduler_int = msecs_to_jiffies(msec_int);
+       if (sc->wiphy_scheduler_int)
+               queue_delayed_work(sc->hw->workqueue, &sc->wiphy_work,
+                                  sc->wiphy_scheduler_int);
+}