mac80211: allow turning TWT responder support on and off via netlink
authorJohn Crispin <john@phrozen.org>
Tue, 28 May 2019 11:49:48 +0000 (13:49 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 14 Jun 2019 12:14:10 +0000 (14:14 +0200)
Allow the userland daemon to en/disable TWT support for an AP.

Signed-off-by: Shashidhar Lakkavalli <slakkavalli@datto.com>
Signed-off-by: John Crispin <john@phrozen.org>
[simplify parsing code]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/cfg80211.h
include/net/mac80211.h
include/uapi/linux/nl80211.h
net/mac80211/cfg.c
net/wireless/nl80211.c

index 7c4aa868e7a55873bcf12f1267f2cf6888de3b35..ac758a54e97144c7385f2a2342ed0cdd4a608f7c 100644 (file)
@@ -897,6 +897,7 @@ enum cfg80211_ap_settings_flags {
  * @he_cap: HE capabilities (or %NULL if HE isn't enabled)
  * @ht_required: stations must support HT
  * @vht_required: stations must support VHT
+ * @twt_responder: Enable Target Wait Time
  * @flags: flags, as defined in enum cfg80211_ap_settings_flags
  */
 struct cfg80211_ap_settings {
@@ -923,6 +924,7 @@ struct cfg80211_ap_settings {
        const struct ieee80211_vht_cap *vht_cap;
        const struct ieee80211_he_cap_elem *he_cap;
        bool ht_required, vht_required;
+       bool twt_responder;
        u32 flags;
 };
 
index e8fdb786b228b3da91f29d65c3f1517a287038fa..ed4911306f030361e71a9f18808a321efeb12e36 100644 (file)
@@ -506,6 +506,8 @@ struct ieee80211_ftm_responder_params {
  * @he_support: does this BSS support HE
  * @twt_requester: does this BSS support TWT requester (relevant for managed
  *     mode only, set if the AP advertises TWT responder role)
+ * @twt_responder: does this BSS support TWT requester (relevant for managed
+ *     mode only, set if the AP advertises TWT responder role)
  * @assoc: association status
  * @ibss_joined: indicates whether this station is part of an IBSS
  *     or not
@@ -613,6 +615,7 @@ struct ieee80211_bss_conf {
        u16 frame_time_rts_th;
        bool he_support;
        bool twt_requester;
+       bool twt_responder;
        /* association related data */
        bool assoc, ibss_joined;
        bool ibss_creator;
index 8b1e43fecd256168ed135c70dbb6f608add1607a..8fc3a43cac75a4545a3bd0fba414addd519d1b5a 100644 (file)
@@ -2354,6 +2354,8 @@ enum nl80211_commands {
  *     is used with %NL80211_CMD_CONNECT to provide password for offloading
  *     SAE authentication for WPA3-Personal networks.
  *
+ * @NL80211_ATTR_TWT_RESPONDER: Enable target wait time responder support.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2809,6 +2811,8 @@ enum nl80211_attrs {
 
        NL80211_ATTR_SAE_PASSWORD,
 
+       NL80211_ATTR_TWT_RESPONDER,
+
        /* add attributes here, update the policy in nl80211.c */
 
        __NL80211_ATTR_AFTER_LAST,
index 52e6a091b7e40800a989fdb12fe6acfffb00124f..023e8751d2234d13bd7df0ef25206e7ca2556d2d 100644 (file)
@@ -975,7 +975,8 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
                      BSS_CHANGED_BEACON |
                      BSS_CHANGED_SSID |
                      BSS_CHANGED_P2P_PS |
-                     BSS_CHANGED_TXPOWER;
+                     BSS_CHANGED_TXPOWER |
+                     BSS_CHANGED_TWT;
        int err;
        int prev_beacon_int;
 
@@ -1045,6 +1046,7 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
        sdata->vif.bss_conf.dtim_period = params->dtim_period;
        sdata->vif.bss_conf.enable_beacon = true;
        sdata->vif.bss_conf.allow_p2p_go_ps = sdata->vif.p2p;
+       sdata->vif.bss_conf.twt_responder = params->twt_responder;
 
        sdata->vif.bss_conf.ssid_len = params->ssid_len;
        if (params->ssid_len)
index 34e86539552e9f235b107b00a313af80008045ca..68e5ab5394ddfd3fe9f61001501d3629cd8af219 100644 (file)
@@ -573,6 +573,7 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
        [NL80211_ATTR_AIRTIME_WEIGHT] = NLA_POLICY_MIN(NLA_U16, 1),
        [NL80211_ATTR_SAE_PASSWORD] = { .type = NLA_BINARY,
                                        .len = SAE_PASSWORD_MAX_LEN },
+       [NL80211_ATTR_TWT_RESPONDER] = { .type = NLA_FLAG },
 };
 
 /* policy for the key attributes */
@@ -4628,6 +4629,9 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
                        return PTR_ERR(params.acl);
        }
 
+       params.twt_responder =
+                   nla_get_flag(info->attrs[NL80211_ATTR_TWT_RESPONDER]);
+
        nl80211_calculate_ap_params(&params);
 
        if (info->attrs[NL80211_ATTR_EXTERNAL_AUTH_SUPPORT])