diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 2e3dfee85019..3154f12fbd89 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -3407,6 +3407,7 @@ struct cfg80211_ml_reconf_req { * @ASSOC_REQ_SPP_AMSDU: SPP A-MSDUs will be used on this connection (if any) * @ASSOC_REQ_DISABLE_UHR: Disable UHR * @ASSOC_REQ_CIP: Enable Control Integrity Protocol + * @ASSOC_REQ_PROTECTED_TWT: Enable protected TWT */ enum cfg80211_assoc_req_flags { ASSOC_REQ_DISABLE_HT = BIT(0), @@ -3419,6 +3420,7 @@ enum cfg80211_assoc_req_flags { ASSOC_REQ_SPP_AMSDU = BIT(7), ASSOC_REQ_DISABLE_UHR = BIT(8), ASSOC_REQ_CIP = BIT(9), + ASSOC_REQ_PROTECTED_TWT = BIT(10), }; /** diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 75d4c5d6a7a3..7dae0860a1b8 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -3228,6 +3228,9 @@ enum nl80211_commands { * @NL80211_ATTR_CIP_CAPABILITIES: The Control Integrity Protocol for the * station. * + * @NL80211_ATTR_ASSOC_PROTECTED_TWT: Enable protected TWT for the association, + * requires protected TWT support (flag attribute) + * * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use @@ -3833,6 +3836,8 @@ enum nl80211_attrs { NL80211_ATTR_ASSOC_CIP, NL80211_ATTR_CIP_CAPABILITIES, + NL80211_ATTR_ASSOC_PROTECTED_TWT, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 572da1d8f3d9..cbd51de57b6e 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -1100,6 +1100,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { [NL80211_ATTR_FRAME_NO_STA] = { .type = NLA_FLAG }, [NL80211_ATTR_ASSOC_CIP] = { .type = NLA_FLAG }, [NL80211_ATTR_CIP_CAPABILITIES] = { .type = NLA_U8 }, + [NL80211_ATTR_ASSOC_PROTECTED_TWT] = { .type = NLA_FLAG }, }; /* policy for the key attributes */ @@ -13422,6 +13423,13 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info) req.flags |= ASSOC_REQ_CIP; } + if (nla_get_flag(info->attrs[NL80211_ATTR_ASSOC_PROTECTED_TWT])) { + if (!wiphy_ext_feature_isset(&rdev->wiphy, + NL80211_EXT_FEATURE_PROTECTED_TWT)) + return -EINVAL; + req.flags |= ASSOC_REQ_PROTECTED_TWT; + } + req.link_id = nl80211_link_id_or_invalid(info->attrs); if (info->attrs[NL80211_ATTR_MLO_LINKS]) {