mac80211: add code to explicitly enable TWT support inside the driver
v2 cover mac80211: add code to explicitly enable TWT support inside the driver
At least ath11k needs an extra FW call to enable TWT inside the HW. This series adds code to trigger this from within start_ap() and also STA assoc events.
Changes in V2
* fix 2 typos
* move from bbs_config to start_ap
John Crispin (3):
mac80211: dynamically enable the TWT requester support on STA
interfaces
mac80211: allow turning TWT responder support on and off via netlink
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 | 4 +- net/mac80211/mlme.c | 18 ++++++- net/wireless/nl80211.c | 5 ++ 9 files changed, 204 insertions(+), 3 deletions(-)
Signature · 1 line
2.11.0
PATCH v2 1/3 mac80211: dynamically enable the TWT requester support on STA interfaces
Turn TWT for STA interfaces when they associate and/or receive a beacon where the twt_responder bit has changed.
--- include/net/mac80211.h | 2 ++ net/mac80211/mlme.c | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-)
include/net/mac80211.h +2 -0
@@ -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 */ };
net/mac80211/mlme.c +16 -2
@@ -3151,6 +3151,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)
@@ -3333,8 +3346,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 +4006,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
Re: [PATCH V2 1/3] mac80211: dynamically enable the TWT requester support on STA interfaces
Quoted 5 lines · John Crispin
Turn TWT for STA interfaces when they associate and/or receive a beacon where the
twt_responderbit has changed.Signed-off-by Shashidhar Lakkavalli <[email protected]>Signed-off-by John Crispin <[email protected]>
Nothing important, but nowadays we have Co-developed-by which is a nice way to document multiple authors (I'm assuming that's the case here):
Signature · 1 line
Kalle Valo
PATCH v2 2/3 mac80211: allow turning TWT responder support on and off via netlink
In reply to John CrispinAllow the userland daemon to en/disable TWT support for an AP.
--- include/net/cfg80211.h | 2 ++ include/net/mac80211.h | 3 +++ include/uapi/linux/nl80211.h | 4 ++++ net/mac80211/cfg.c | 4 +++- net/wireless/nl80211.c | 5 +++++ 5 files changed, 17 insertions(+), 1 deletion(-)
include/net/cfg80211.h +2 -0
@@ -876,6 +876,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 {
@@ -902,6 +903,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; };
include/net/mac80211.h +3 -0
@@ -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;
include/uapi/linux/nl80211.h +4 -0
@@ -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 +3 -1
@@ -939,7 +939,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;
@@ -1009,6 +1010,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)
net/wireless/nl80211.c +5 -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_TWT_RESPONDER] = { .type = NLA_FLAG }, };/* policy for the key attributes */
@@ -4531,6 +4532,10 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)return PTR_ERR (params.acl); } +if (info->attrs[NL80211_ATTR_TWT_RESPONDER ]) + params.twt_responder = +nla_get_flag (info->attrs[NL80211_ATTR_TWT_RESPONDER ]); +nl80211_calculate_ap_params (¶ms);if (info->attrs[NL80211_ATTR_EXTERNAL_AUTH_SUPPORT ])
Signature · 1 line
2.11.0
PATCH v2 3/3 ath11k: add TWT support
In reply to John CrispinAdd 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
@@ -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_requester || 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