Skip to contentSkip to conversation

mac80211: notify the driver when it should enable TWT

PATCH In review John Crispin 3 participants 11 messages Apr 26, 2019 – Apr 30, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover mac80211: notify the driver when it should enable TWT

The ath11k FW has dedicated calls for setting the TWT state. Trigger these via the BSS config changes.

In a later step we need to also add calls for manually starting TWT dialogs.

Changes in V2
* add NLA_POLICY_RANGE for NL80211_ATTR_TWT_RESPONDER

John Crispin (3):
mac80211: allow turning TWT responder support on and off via netlink
mac80211: dynamically turn TWT requester support on and off
ath11k: add TWT support

 drivers/net/wireless/ath/ath11k/mac.c |  7 +++
 drivers/net/wireless/ath/ath11k/wmi.c | 91 +++++++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath11k/wmi.h | 71 +++++++++++++++++++++++++++
 include/net/cfg80211.h                |  2 +
 include/net/mac80211.h                |  5 ++
 include/uapi/linux/nl80211.h          |  4 ++
 net/mac80211/cfg.c                    |  6 +++
 net/mac80211/mlme.c                   | 20 +++++++-
 net/wireless/nl80211.c                |  6 +++
 9 files changed, 210 insertions(+), 2 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH v2 1/3 mac80211: allow turning TWT responder support on and off via netlink

Allow the userland daemon to en/disable TWT support for an AP.

---
 include/net/cfg80211.h       | 2 ++
 include/net/mac80211.h       | 5 +++++
 include/uapi/linux/nl80211.h | 4 ++++
 net/mac80211/cfg.c           | 6 ++++++
 net/wireless/nl80211.c       | 6 ++++++
 5 files changed, 23 insertions(+)
include/net/cfg80211.h +2 -0
index bb307a11ee63..8a20f5a42977 100644
@@ -1511,6 +1511,7 @@ struct mpath_info {
  * 	(u16 = opmode, -1 = do not change)
  * @p2p_ctwindow: P2P CT Window (-1 = no change)
  * @p2p_opp_ps: P2P opportunistic PS (-1 = no change)
+ * @twt_responder: HE Target Wait Time support.
  */
 struct bss_parameters {
 	int use_cts_prot;
@@ -1521,6 +1522,7 @@ struct bss_parameters {
 	int ap_isolate;
 	int ht_opmode;
 	s8 p2p_ctwindow, p2p_opp_ps;
+	int twt_responder;
 };
 
 /**
include/net/mac80211.h +5 -0
index ac2ed8ec662b..87a6e149abda 100644
@@ -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 enable 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 */
 };
@@ -504,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 responder (relevant for AP
+ *	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
@@ -611,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;
include/uapi/linux/nl80211.h +4 -0
index dd4f86ee286e..ba1f69751a4a 100644
@@ -2308,6 +2308,8 @@ enum nl80211_commands {
  * @NL80211_ATTR_AIRTIME_WEIGHT: Station's weight when scheduled by the airtime
  *	scheduler.
  *
+ * @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
@@ -2759,6 +2761,8 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_AIRTIME_WEIGHT,
 
+	NL80211_ATTR_TWT_RESPONDER,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
net/mac80211/cfg.c +6 -0
index 09dd1c2860fc..a66600bf9cef 100644
@@ -2176,6 +2176,12 @@ static int ieee80211_change_bss(struct wiphy *wiphy,
 		changed |= BSS_CHANGED_P2P_PS;
 	}
 
+	if (params->twt_responder >= 0) {
+		sdata->vif.bss_conf.twt_responder =
+			params->twt_responder;
+		changed |= BSS_CHANGED_TWT;
+	}
+
 	ieee80211_bss_info_change_notify(sdata, changed);
 
 	return 0;
net/wireless/nl80211.c +6 -0
index 25a9e3b5c154..afd04a98a601 100644
@@ -541,6 +541,7 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_PEER_MEASUREMENTS] =
 		NLA_POLICY_NESTED(nl80211_pmsr_attr_policy),
 	[NL80211_ATTR_AIRTIME_WEIGHT] = NLA_POLICY_MIN(NLA_U16, 1),
+	[NL80211_ATTR_BSS_SHORT_PREAMBLE] = NLA_POLICY_RANGE(NLA_U8, 0, 1),
 };
 
 /* policy for the key attributes */
@@ -6105,6 +6106,7 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
 	params.ht_opmode = -1;
 	params.p2p_ctwindow = -1;
 	params.p2p_opp_ps = -1;
+	params.twt_responder = -1;
 
 	if (info->attrs[NL80211_ATTR_BSS_CTS_PROT])
 		params.use_cts_prot =
@@ -6149,6 +6151,10 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
 			return -EINVAL;
 	}
 
+	if (info->attrs[NL80211_ATTR_TWT_RESPONDER])
+		params.twt_responder =
+		    nla_get_u8(info->attrs[NL80211_ATTR_TWT_RESPONDER]);
+
 	if (!rdev->ops->change_bss)
 		return -EOPNOTSUPP;
 
Signature · 7 lines
2.11.0


_______________________________________________
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
#2 lore raw

Re: [PATCH V2 1/3] mac80211: allow turning TWT responder support on and off via netlink

Quoted 9 lines · John Crispin
net/wireless/nl80211.c +1 -0
@@ -6105,6 +6106,7 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
  	params.ht_opmode = -1;
  	params.p2p_ctwindow = -1;
  	params.p2p_opp_ps = -1;
+	params.twt_responder = -1;
 
  	if (info->attrs[NL80211_ATTR_BSS_CTS_PROT])
  		params.use_cts_prot =

net/wireless/nl80211.c static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info) · line 6159

Quoted 9 lines
net/wireless/nl80211.c +4 -0
@@ -6149,6 +6151,10 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
  			return -EINVAL;
  	}
 
+	if (info->attrs[NL80211_ATTR_TWT_RESPONDER])
+		params.twt_responder =
+		    nla_get_u8(info->attrs[NL80211_ATTR_TWT_RESPONDER]);
+
  	if (!rdev->ops->change_bss)
  		return -EOPNOTSUPP;

Hi,

this should probably be moved to nl80211_start_ap() instead of nl80211_set_bss() as we probably dont want to change this at runtime ?

    John

_______________________________________________
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k

maintainer
#3 lore raw

Re: [PATCH V2 1/3] mac80211: allow turning TWT responder support on and off via netlink

Quoted 22 lines · John Crispin
Quoted 9 lines · John Crispin
net/wireless/nl80211.c +1 -0
@@ -6105,6 +6106,7 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
  	params.ht_opmode = -1;
  	params.p2p_ctwindow = -1;
  	params.p2p_opp_ps = -1;
+	params.twt_responder = -1;
 
  	if (info->attrs[NL80211_ATTR_BSS_CTS_PROT])
  		params.use_cts_prot =

net/wireless/nl80211.c static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info) · line 6159

Quoted 9 lines
net/wireless/nl80211.c +4 -0
@@ -6149,6 +6151,10 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
  			return -EINVAL;
  	}
 
+	if (info->attrs[NL80211_ATTR_TWT_RESPONDER])
+		params.twt_responder =
+		    nla_get_u8(info->attrs[NL80211_ATTR_TWT_RESPONDER]);
+
  	if (!rdev->ops->change_bss)
  		return -EOPNOTSUPP;

Hi,

Quoted 2 lines

this should probably be moved to nl80211_start_ap() instead of nl80211_set_bss() as we probably dont want to change this at runtime ?

I have no idea, can we change it at runtime? Is it a capability or an operational state?

johannes

#4 lore raw

Re: [PATCH V2 1/3] mac80211: allow turning TWT responder support on and off via netlink

Quoted 22 lines · Johannes Berg
Quoted 21 lines · John Crispin
Quoted 9 lines · John Crispin
net/wireless/nl80211.c +1 -0
@@ -6105,6 +6106,7 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
   	params.ht_opmode = -1;
   	params.p2p_ctwindow = -1;
   	params.p2p_opp_ps = -1;
+	params.twt_responder = -1;
 
   	if (info->attrs[NL80211_ATTR_BSS_CTS_PROT])
   		params.use_cts_prot =

net/wireless/nl80211.c static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info) · line 6159

Quoted 9 lines
net/wireless/nl80211.c +4 -0
@@ -6149,6 +6151,10 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
   			return -EINVAL;
   	}
 
+	if (info->attrs[NL80211_ATTR_TWT_RESPONDER])
+		params.twt_responder =
+		    nla_get_u8(info->attrs[NL80211_ATTR_TWT_RESPONDER]);
+
   	if (!rdev->ops->change_bss)
   		return -EOPNOTSUPP;

Hi,

Quoted 6 lines
Quoted 2 lines

this should probably be moved to nl80211_start_ap() instead of nl80211_set_bss() as we probably dont want to change this at runtime ?

I have no idea, can we change it at runtime? Is it a capability or an operational state?

johannes

its a capability, only the twt_required bit is an operational state. so I shall send a V3 moving it to start_ap() :-)

    John

_______________________________________________
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k

#5 lore raw

Re: [PATCH V2 1/3] mac80211: allow turning TWT responder support on and off via netlink

In reply to John Crispin
Quoted 17 lines · John Crispin

Allow the userland daemon to en/disable TWT support for an AP.

---
 include/net/cfg80211.h       | 2 ++
 include/net/mac80211.h       | 5 +++++
 include/uapi/linux/nl80211.h | 4 ++++
 net/mac80211/cfg.c           | 6 ++++++
 net/wireless/nl80211.c       | 6 ++++++
 5 files changed, 23 insertions(+)
include/net/cfg80211.h +0 -0
index bb307a11ee63..8a20f5a42977 100644

include/net/cfg80211.h struct mpath_info { · line 1515

Quoted 5 lines
include/net/cfg80211.h +1 -0
@@ -1511,6 +1511,7 @@ struct mpath_info {
  * 	(u16 = opmode, -1 = do not change)
  * @p2p_ctwindow: P2P CT Window (-1 = no change)
  * @p2p_opp_ps: P2P opportunistic PS (-1 = no change)
+ * @twt_responder: HE Target Wait Time support.
 

Responder support. Perhaps it could named as he_twt_resp to differentiate from ah.

include/net/cfg80211.h struct bss_parameters { · line 1527

Quoted 10 lines
include/net/cfg80211.h +0 -0
  */
 struct bss_parameters {
include/net/cfg80211.h +1 -0
 	int use_cts_prot;
@@ -1521,6 +1522,7 @@ struct bss_parameters {
 	int ap_isolate;
 	int ht_opmode;
 	s8 p2p_ctwindow, p2p_opp_ps;
+	int twt_responder;
 };
 

Same here. Better fix he_ in other places as well. thoughts?

Quoted 35 lines
include/net/cfg80211.h +0 -0
 /**
include/net/mac80211.h +0 -0
index ac2ed8ec662b..87a6e149abda 100644
@@ -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 enable status changed
*
*/
enum ieee80211_bss_change {

include/net/mac80211.h +1 -0
@@ -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 */
 };
@@ -504,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 responder (relevant for AP
+ * 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

include/net/mac80211.h struct ieee80211_bss_conf { · line 619

Quoted 5 lines
include/net/mac80211.h +1 -0
@@ -611,6 +615,7 @@ struct ieee80211_bss_conf {
 	u16 frame_time_rts_th;
 	bool he_support;
 	bool twt_requester;
+	bool twt_responder;
 

ah.. I see existing twt_requester config.

Quoted 50 lines
include/net/mac80211.h +0 -0
 	/* association related data */
 	bool assoc, ibss_joined;
include/net/mac80211.h +0 -0
 	bool ibss_creator;
include/uapi/linux/nl80211.h +0 -0
index dd4f86ee286e..ba1f69751a4a 100644
@@ -2308,6 +2308,8 @@ enum nl80211_commands {
  * @NL80211_ATTR_AIRTIME_WEIGHT: Station's weight when scheduled by 

the airtime
* scheduler.
*
+ * @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

include/uapi/linux/nl80211.h +2 -0
@@ -2759,6 +2761,8 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_AIRTIME_WEIGHT,
 
+	NL80211_ATTR_TWT_RESPONDER,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
net/mac80211/cfg.c +6 -0
index 09dd1c2860fc..a66600bf9cef 100644
@@ -2176,6 +2176,12 @@ static int ieee80211_change_bss(struct wiphy 
 *wiphy,
 		changed |= BSS_CHANGED_P2P_PS;
 	}
 
+	if (params->twt_responder >= 0) {
+		sdata->vif.bss_conf.twt_responder =
+			params->twt_responder;
+		changed |= BSS_CHANGED_TWT;
+	}
+
 	ieee80211_bss_info_change_notify(sdata, changed);
 
net/mac80211/cfg.c +0 -0
 	return 0;
net/wireless/nl80211.c +0 -0
index 25a9e3b5c154..afd04a98a601 100644

net/wireless/nl80211.c const struct nla_policy · line 547

Quoted 7 lines
net/wireless/nl80211.c +1 -0
@@ -541,6 +541,7 @@ const struct nla_policy 
 nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_PEER_MEASUREMENTS] =
 		NLA_POLICY_NESTED(nl80211_pmsr_attr_policy),
 	[NL80211_ATTR_AIRTIME_WEIGHT] = NLA_POLICY_MIN(NLA_U16, 1),
+	[NL80211_ATTR_BSS_SHORT_PREAMBLE] = NLA_POLICY_RANGE(NLA_U8, 0, 1),
 };
 

Why SHORT_PREAMBLE? Why not attribute be NLA_FLAG?

-Rajkumar

_______________________________________________
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k

#6 lore raw

PATCH v2 2/3 mac80211: dynamically turn TWT requester support on and off

In reply to John Crispin

Turn TWT on/off for STA interfaces when they associate and/or receive a beacon where the twt_responder bit has changed.

---
 net/mac80211/mlme.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
net/mac80211/mlme.c +18 -2
index 2dbcf5d5512e..f3563670ed58 100644
@@ -3151,6 +3151,21 @@ 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_req;
+
+	twt_req = ieee80211_twt_req_supported(sta, elems);
+
+	if (sdata->vif.bss_conf.twt_requester != twt_req) {
+		sdata->vif.bss_conf.twt_requester = twt_req;
+		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)
@@ -3333,8 +3348,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;
@@ -3994,6 +4008,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,
Signature · 1 line
2.11.0
#7 lore raw

Re: [PATCH V2 2/3] mac80211: dynamically turn TWT requester support on and off

Quoted 3 lines · John Crispin

Turn TWT on/off for STA interfaces when they associate and/or receive a beacon where the twt_responder bit has changed.

Does it mean that TWT responder can be turn on/off when AP is UP and running? I thought any change in beacon needs AP restart. no?

-Rajkumar

_______________________________________________
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k

#8 lore raw

Re: [PATCH V2 2/3] mac80211: dynamically turn TWT requester support on and off

Quoted 8 lines · Rajkumar Manoharan
Quoted 3 lines · John Crispin

Turn TWT on/off for STA interfaces when they associate and/or receive a beacon where the twt_responder bit has changed.

Does it mean that TWT responder can be turn on/off when AP is UP and running? I thought any change in beacon needs AP restart. no?

Quoted 6 lines

-Rajkumar

_______________________________________________
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k

Hi Rajkumar,

I am about to send a V2 that already addresses allthose comments, Thanks for the review

    John

_______________________________________________
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k

#9 lore raw

PATCH v2 3/3 ath11k: add TWT support

In reply to John Crispin

Add target wait time wmi calls to the driver. En/disable the support from when the bss_config changes. We ignore the cmd completion events.

---
 drivers/net/wireless/ath/ath11k/mac.c |  7 +++
 drivers/net/wireless/ath/ath11k/wmi.c | 91 +++++++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath11k/wmi.h | 71 +++++++++++++++++++++++++++
 3 files changed, 169 insertions(+)
drivers/net/wireless/ath/ath11k/mac.c +7 -0
index 8bb4ff82fb6f..a38c101e0140 100644
@@ -1938,6 +1938,13 @@ static void ath11k_bss_info_changed(struct ieee80211_hw *hw,
 		ath11k_mac_txpower_recalc(ar);
 	}
 
+	if (changed & BSS_CHANGED_TWT) {
+		if (info->twt_responder || info->twt_responder)
+			ath11k_wmi_send_twt_enable_cmd(ar, ar->pdev_idx);
+		else
+			ath11k_wmi_send_twt_disable_cmd(ar, ar->pdev_idx);
+	}
+
 	mutex_unlock(&ar->conf_mutex);
 }
 
drivers/net/wireless/ath/ath11k/wmi.c +91 -0

121 lines not on this page · raw message

drivers/net/wireless/ath/ath11k/wmi.h +71 -0

123 lines not on this page · raw message

Signature · 1 line
2.11.0
#10 lore raw

Re: [PATCH V2 3/3] ath11k: add TWT support

drivers/net/wireless/ath/ath11k/mac.c static void ath11k_bss_info_changed(struct · line 1944

Quoted 13 lines · John Crispin
drivers/net/wireless/ath/ath11k/mac.c +2 -0
index 8bb4ff82fb6f..a38c101e0140 100644
@@ -1938,6 +1938,13 @@ static void ath11k_bss_info_changed(struct
 ieee80211_hw *hw,
 		ath11k_mac_txpower_recalc(ar);
 	}
 
+	if (changed & BSS_CHANGED_TWT) {
+		if (info->twt_responder || info->twt_responder)
 

typo? two twt_responder checks?

-Rajkumar

_______________________________________________
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k