mac80211: dynamically enable the TWT requester support on STA interfaces
authorJohn Crispin <john@phrozen.org>
Tue, 28 May 2019 11:49:47 +0000 (13:49 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 14 Jun 2019 12:12:13 +0000 (14:12 +0200)
Turn TWT for STA interfaces when they associate and/or receive a
beacon where the twt_responder bit has changed.

Signed-off-by: Shashidhar Lakkavalli <slakkavalli@datto.com>
Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/mac80211.h
net/mac80211/mlme.c

index b7f0b56a09f4fa810f8dc7e17e780ee830aaad9e..e8fdb786b228b3da91f29d65c3f1517a287038fa 100644 (file)
@@ -317,6 +317,7 @@ struct ieee80211_vif_chanctx_switch {
  * @BSS_CHANGED_MCAST_RATE: Multicast Rate setting changed for this interface
  * @BSS_CHANGED_FTM_RESPONDER: fime timing reasurement request responder
  *     functionality changed for this BSS (AP mode).
+ * @BSS_CHANGED_TWT: TWT status changed
  *
  */
 enum ieee80211_bss_change {
@@ -347,6 +348,7 @@ enum ieee80211_bss_change {
        BSS_CHANGED_KEEP_ALIVE          = 1<<24,
        BSS_CHANGED_MCAST_RATE          = 1<<25,
        BSS_CHANGED_FTM_RESPONDER       = 1<<26,
+       BSS_CHANGED_TWT                 = 1<<27,
 
        /* when adding here, make sure to change ieee80211_reconfig */
 };
index b7a9fe3d5fcb75dfb15e27c536d19066993b0c6d..281319c826dd6f78fab4201736756598bf0bec25 100644 (file)
@@ -3148,6 +3148,19 @@ static bool ieee80211_twt_req_supported(const struct sta_info *sta,
                IEEE80211_HE_MAC_CAP0_TWT_RES;
 }
 
+static int ieee80211_recalc_twt_req(struct ieee80211_sub_if_data *sdata,
+                                   struct sta_info *sta,
+                                   struct ieee802_11_elems *elems)
+{
+       bool twt = ieee80211_twt_req_supported(sta, elems);
+
+       if (sdata->vif.bss_conf.twt_requester != twt) {
+               sdata->vif.bss_conf.twt_requester = twt;
+               return BSS_CHANGED_TWT;
+       }
+       return 0;
+}
+
 static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
                                    struct cfg80211_bss *cbss,
                                    struct ieee80211_mgmt *mgmt, size_t len)
@@ -3330,8 +3343,7 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
                                                  sta);
 
                bss_conf->he_support = sta->sta.he_cap.has_he;
-               bss_conf->twt_requester =
-                       ieee80211_twt_req_supported(sta, &elems);
+               changed |= ieee80211_recalc_twt_req(sdata, sta, &elems);
        } else {
                bss_conf->he_support = false;
                bss_conf->twt_requester = false;
@@ -3991,6 +4003,8 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
        mutex_lock(&local->sta_mtx);
        sta = sta_info_get(sdata, bssid);
 
+       changed |= ieee80211_recalc_twt_req(sdata, sta, &elems);
+
        if (ieee80211_config_bw(sdata, sta,
                                elems.ht_cap_elem, elems.ht_operation,
                                elems.vht_operation, elems.he_operation,