wifi: mac80211: fix and clean up protected TWT support

The "twt_protected" flag in the link/bss_conf information
really isn't right since this is negotiated via RSNX and
therefore cannot differ per link. Move it to be a per-STA
indication and also derive it from the new assoc request
flag since that gets used with security profile.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20260930120021.844fde440b63.I80999965c70e50d756ab62833fc7f53f2481cf3d@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2026-09-30 12:02:57 +03:00
parent 743c052c19
commit 1a86b4fac9
5 changed files with 21 additions and 12 deletions

View File

@ -241,6 +241,8 @@ static void iwl_mld_fill_mac_cmd_sta(struct iwl_mld *mld,
struct ieee80211_vif *vif, u32 action,
struct iwl_mac_config_cmd *cmd)
{
struct iwl_mld_vif *mld_vif = iwl_mld_vif_from_mac80211(vif);
struct ieee80211_sta *ap_sta = mld_vif->ap_sta;
struct ieee80211_bss_conf *link;
u32 twt_policy = 0;
int link_id;
@ -290,7 +292,7 @@ static void iwl_mld_fill_mac_cmd_sta(struct iwl_mld *mld,
if (link->twt_requester)
twt_policy |= TWT_SUPPORTED;
if (link->twt_protected)
if (ap_sta && ap_sta->twt_protected)
twt_policy |= PROTECTED_TWT_SUPPORTED;
if (link->twt_broadcast)
twt_policy |= BROADCAST_TWT_SUPPORTED;

View File

@ -644,11 +644,12 @@ __le32 iwl_mvm_mac_ctxt_cmd_p2p_sta_get_oppps_ctwin(struct iwl_mvm *mvm,
u32 iwl_mvm_mac_ctxt_cmd_sta_get_twt_policy(struct iwl_mvm *mvm,
struct ieee80211_vif *vif)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
u32 twt_policy = 0;
if (vif->bss_conf.twt_requester && IWL_MVM_USE_TWT)
twt_policy |= TWT_SUPPORTED;
if (vif->bss_conf.twt_protected)
if (mvmvif->ap_sta && mvmvif->ap_sta->twt_protected)
twt_policy |= PROTECTED_TWT_SUPPORTED;
if (vif->bss_conf.twt_broadcast)
twt_policy |= BROADCAST_TWT_SUPPORTED;

View File

@ -640,7 +640,6 @@ struct ieee80211_bss_npca_params {
* 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)
* @twt_protected: does this BSS support protected TWT frames
* @twt_broadcast: does this BSS support broadcast TWT
* @use_cts_prot: use CTS protection
* @use_short_preamble: use 802.11b short preamble
@ -812,7 +811,6 @@ struct ieee80211_bss_conf {
bool he_support;
bool twt_requester;
bool twt_responder;
bool twt_protected;
bool twt_broadcast;
/* erp related data */
bool use_cts_prot;
@ -2728,6 +2726,7 @@ struct ieee80211_link_sta {
* @spp_amsdu: indicates whether the STA uses SPP A-MSDU or not.
* @epp_peer: indicates that the peer is an EPP peer.
* @cip: indicates whether the STA uses control frame protection or not.
* @twt_protected: does this STA support protected TWT frames
* @nmi: For NDI stations, pointer to the NMI station of the peer.
* @nan_sched: NAN peer schedule for this station. Valid only for NMI stations.
* @ext_mld_capa_ops: the MLD's extended MLD capabilities and operations
@ -2750,6 +2749,7 @@ struct ieee80211_sta {
u16 eml_cap;
bool cip;
bool twt_protected;
struct ieee80211_sta_aggregates *cur;

View File

@ -487,6 +487,7 @@ struct ieee80211_mgd_assoc_data {
bool s1g;
bool spp_amsdu;
bool cip;
bool protected_twt;
s8 assoc_link_id;

View File

@ -6168,13 +6168,6 @@ static bool ieee80211_assoc_config_link(struct ieee80211_link_data *link,
link_sta);
bss_conf->he_support = link_sta->pub->he_cap.has_he;
if (elems->rsnx && elems->rsnx_len &&
(elems->rsnx[0] & WLAN_RSNX_CAPA_PROTECTED_TWT) &&
wiphy_ext_feature_isset(local->hw.wiphy,
NL80211_EXT_FEATURE_PROTECTED_TWT))
bss_conf->twt_protected = true;
else
bss_conf->twt_protected = false;
*changed |= ieee80211_recalc_twt_req(sdata, sband, link,
link_sta, elems);
@ -6207,7 +6200,6 @@ static bool ieee80211_assoc_config_link(struct ieee80211_link_data *link,
} else {
bss_conf->he_support = false;
bss_conf->twt_requester = false;
bss_conf->twt_protected = false;
bss_conf->eht_support = false;
bss_conf->epcs_support = false;
}
@ -7016,6 +7008,18 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
sta->sta.spp_amsdu = assoc_data->spp_amsdu;
sta->sta.cip = assoc_data->cip;
sta->sta.twt_protected = assoc_data->protected_twt;
/*
* backward compatibility - assumes that RSNX will not
* indicate anything (if present at all) _less_ than
* security profile RSNX content might
*/
if (elems->rsnx && elems->rsnx_len &&
(elems->rsnx[0] & WLAN_RSNX_CAPA_PROTECTED_TWT) &&
wiphy_ext_feature_isset(local->hw.wiphy,
NL80211_EXT_FEATURE_PROTECTED_TWT))
sta->sta.twt_protected = true;
if (ieee80211_vif_is_mld(&sdata->vif)) {
if (!elems->ml_basic)
@ -10596,6 +10600,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
assoc_data->spp_amsdu = req->flags & ASSOC_REQ_SPP_AMSDU;
assoc_data->cip = req->flags & ASSOC_REQ_CIP;
assoc_data->protected_twt = req->flags & ASSOC_REQ_PROTECTED_TWT;
if (ifmgd->auth_data && !ifmgd->auth_data->done) {
err = -EBUSY;