ath9k_htc: add support of channel switch
authorChun-Yeow Yeoh <yeohchunyeow@gmail.com>
Tue, 9 Jun 2015 07:59:49 +0000 (15:59 +0800)
committerKalle Valo <kvalo@codeaurora.org>
Mon, 15 Jun 2015 09:44:34 +0000 (12:44 +0300)
Add the support of channel switching functionality, similar
to ath9k support.

Tested with TP-Link TL-WN722N and TL-WN821N.

Signed-off-by: Chun-Yeow Yeoh <yeohchunyeow@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/ath9k/htc.h
drivers/net/wireless/ath/ath9k/htc_drv_beacon.c
drivers/net/wireless/ath/ath9k/htc_drv_init.c
drivers/net/wireless/ath/ath9k/htc_drv_main.c

index 5dbc617ecf8a824eb61e5cf8d0bd231717f72a3f..16dff4b89a86fc43635f0e91c2981372e575eda6 100644 (file)
@@ -531,6 +531,7 @@ struct ath9k_htc_priv {
        struct ath9k_debug debug;
 #endif
        struct mutex mutex;
+       struct ieee80211_vif *csa_vif;
 };
 
 static inline void ath_read_cachesize(struct ath_common *common, int *csz)
@@ -584,6 +585,7 @@ void ath9k_htc_tx_drain(struct ath9k_htc_priv *priv);
 void ath9k_htc_txstatus(struct ath9k_htc_priv *priv, void *wmi_event);
 void ath9k_tx_failed_tasklet(unsigned long data);
 void ath9k_htc_tx_cleanup_timer(unsigned long data);
+bool ath9k_htc_csa_is_finished(struct ath9k_htc_priv *priv);
 
 int ath9k_rx_init(struct ath9k_htc_priv *priv);
 void ath9k_rx_cleanup(struct ath9k_htc_priv *priv);
index e8b6ec3c1dbbb01bd2ea7d122dbe747c9d8f6d96..e6bcb4c90fa0120c9e96abe2f2d586877b6f12cf 100644 (file)
@@ -257,6 +257,8 @@ static void ath9k_htc_send_beacon(struct ath9k_htc_priv *priv,
        }
 
        spin_unlock_bh(&priv->beacon_lock);
+
+       ath9k_htc_csa_is_finished(priv);
 }
 
 static int ath9k_htc_choose_bslot(struct ath9k_htc_priv *priv,
@@ -503,3 +505,20 @@ void ath9k_htc_beacon_reconfig(struct ath9k_htc_priv *priv)
                return;
        }
 }
+
+bool ath9k_htc_csa_is_finished(struct ath9k_htc_priv *priv)
+{
+       struct ieee80211_vif *vif;
+
+       vif = priv->csa_vif;
+       if (!vif || !vif->csa_active)
+               return false;
+
+       if (!ieee80211_csa_is_complete(vif))
+               return false;
+
+       ieee80211_csa_finish(vif);
+
+       priv->csa_vif = NULL;
+       return true;
+}
index 746856243bff610d9e10773046b9005851214646..95690109ee11fdb10ba3db1837381b9632cf87a5 100644 (file)
@@ -744,7 +744,8 @@ static void ath9k_set_hw_capab(struct ath9k_htc_priv *priv,
        hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
 
        hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN |
-                           WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
+                           WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
+                           WIPHY_FLAG_HAS_CHANNEL_SWITCH;
 
        hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS;
 
index b71f3072fd9a937ca5f67f2471d85e05761b1d32..dab1323dfec76a1b09183bb8779e482dd7299c49 100644 (file)
@@ -1134,6 +1134,9 @@ static void ath9k_htc_remove_interface(struct ieee80211_hw *hw,
        priv->nvifs--;
        priv->vif_slot &= ~(1 << avp->index);
 
+       if (priv->csa_vif == vif)
+               priv->csa_vif = NULL;
+
        ath9k_htc_remove_station(priv, vif, NULL);
 
        DEC_VIF(priv, vif->type);
@@ -1841,6 +1844,19 @@ static int ath9k_htc_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant,
        return 0;
 }
 
+static void ath9k_htc_channel_switch_beacon(struct ieee80211_hw *hw,
+                                           struct ieee80211_vif *vif,
+                                           struct cfg80211_chan_def *chandef)
+{
+       struct ath9k_htc_priv *priv = hw->priv;
+
+       /* mac80211 does not support CSA in multi-if cases (yet) */
+       if (WARN_ON(priv->csa_vif))
+               return;
+
+       priv->csa_vif = vif;
+}
+
 struct ieee80211_ops ath9k_htc_ops = {
        .tx                 = ath9k_htc_tx,
        .start              = ath9k_htc_start,
@@ -1867,6 +1883,7 @@ struct ieee80211_ops ath9k_htc_ops = {
        .set_bitrate_mask   = ath9k_htc_set_bitrate_mask,
        .get_stats          = ath9k_htc_get_stats,
        .get_antenna        = ath9k_htc_get_antenna,
+       .channel_switch_beacon  = ath9k_htc_channel_switch_beacon,
 
 #ifdef CONFIG_ATH9K_HTC_DEBUGFS
        .get_et_sset_count  = ath9k_htc_get_et_sset_count,