[PATCH wireless-next v5 05/19] wifi: nl80211: define interfaces for ST context transfer

From: Pooventhiran G

Date: Wed Dec 02 2026 - 05:29:03 EST


Define nl80211 attributes and policies required to pack SMD Transition
context along with NL80211_CMD_FRAME to be sent to userspace, and to set
and get the context during roaming via current AP MLD and roaming via
target AP MLD. Without these, userspace will not be able to transport the
context to the target AP MLD, program the context on the target AP MLD TX
and RX queues, nor fetch the context on behalf of the target AP MLD if
the ST Execution frame is sent directly to the target.

Suggested-by: Jouni Malinen <jouni.malinen@xxxxxxxxxxxxxxxx>
Signed-off-by: Pooventhiran G <pooventhiran.g@xxxxxxxxxxxxxxxx>
---
include/uapi/linux/nl80211.h | 161 +++++++++++++++++++++++++++++++++++++++++++
net/wireless/nl80211.c | 40 +++++++++++
2 files changed, 201 insertions(+)

diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 5ef6f704be0f..0e59769161dc 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -429,6 +429,19 @@
* ST Execution.
* %NL80211_STA_FLAG_ST_{EXECUTING,DL_DRAIN}, on the other hand, can be
* set using %NL80211_CMD_SET_STATION on the current AP MLD.
+ *
+ * Drivers can use %NL80211_ATTR_ST_CTX to pack the dynamic context of the
+ * non-AP MLD along with the ST Preparation or ST Execution Request frames in
+ * the %NL80211_CMD_FRAME event.
+ *
+ * On the target AP MLD, this collected context, received in the
+ * userspace-managed backhaul between the AP MLDs, can be programmed using
+ * %NL80211_CMD_SET_ST_CTX.
+ *
+ * In case the non-AP MLD executes directly with the target AP MLD, the current
+ * AP MLD can request the context from the driver on the target's behalf using
+ * %NL80211_CMD_GET_ST_CTX and the response can be reported back using
+ * %NL80211_CMD_ST_CTX_EVENT.
*/

/**
@@ -1589,6 +1602,19 @@
* addresses (%NL80211_ATTR_MLO_LINKS, each nested link with
* %NL80211_ATTR_MLO_LINK_ID, %NL80211_ATTR_BSSID and %NL80211_ATTR_MAC).
*
+ * @NL80211_CMD_SET_ST_CTX: Set the ST dynamic context for a non-AP MLD sent
+ * from the current AP MLD on the target AP MLD managed by an SMD-ME.
+ * This command carries %NL80211_ATTR_MLD_ADDR, %NL80211_ATTR_ST_CTX_TYPE,
+ * and %NL80211_ATTR_ST_CTX. The station must be present on the target AP
+ * MLD in the "prepared" state with a default key installed.
+ * @NL80211_CMD_GET_ST_CTX: Get the ST dynamic context for a non-AP MLD
+ * associated to an AP MLD managed by an SMD-ME. This command carries
+ * %NL80211_ATTR_MLD_ADDR and %NL80211_ATTR_ST_CTX_TYPE.
+ * @NL80211_CMD_ST_CTX_EVENT: Event reporting the collected ST context
+ * (requested via %NL80211_CMD_GET_ST_CTX) to userspace. It carries
+ * %NL80211_ATTR_MLD_ADDR, %NL80211_ATTR_ST_CTX_TYPE, and
+ * %NL80211_ATTR_ST_CTX.
+ *
* @NL80211_CMD_MAX: highest used command number
* @__NL80211_CMD_AFTER_LAST: internal use
*/
@@ -1876,6 +1902,10 @@ enum nl80211_commands {
NL80211_CMD_EXECUTE_SMD_TRANSITION,
NL80211_CMD_COMPLETED_SMD_TRANSITION,

+ NL80211_CMD_SET_ST_CTX,
+ NL80211_CMD_GET_ST_CTX,
+ NL80211_CMD_ST_CTX_EVENT,
+
/* add new commands above here */

/* used to define NL80211_CMD_MAX below */
@@ -3371,6 +3401,12 @@ enum nl80211_commands {
*
* @NL80211_ATTR_SMD: Flag attribute to indicate that the station has negotiated
* SMD.
+ * @NL80211_ATTR_ST_CTX: Nested attribute associated with ST context data.
+ * Used with %NL80211_CMD_FRAME, %NL80211_CMD_SET_ST_CTX, and
+ * %NL80211_CMD_ST_CTX_EVENT. See &enum nl80211_st_ctx.
+ * @NL80211_ATTR_ST_CTX_TYPE: u8 attribute specifying the type of ST context.
+ * Used with %NL80211_CMD_FRAME, %NL80211_CMD_SET_ST_CTX,
+ * %NL80211_CMD_GET_ST_CTX, and %NL80211_CMD_ST_CTX_EVENT.
*
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
* @NL80211_ATTR_MAX: highest attribute number currently defined
@@ -3980,6 +4016,8 @@ enum nl80211_attrs {
NL80211_ATTR_ASSOC_PROTECTED_TWT,

NL80211_ATTR_SMD,
+ NL80211_ATTR_ST_CTX,
+ NL80211_ATTR_ST_CTX_TYPE,

/* add attributes here, update the policy in nl80211.c */

@@ -9343,4 +9381,127 @@ enum nl80211_nan_peer_map_attrs {

#define NL80211_NAN_SCHED_NOT_AVAIL_SLOT 0xff

+/**
+ * enum nl80211_st_ctx_type - ST Request Type values
+ *
+ * Used with %NL80211_ATTR_ST_CTX_TYPE.
+ *
+ * @NL80211_ST_CTX_TYPE_PREP: ST Preparation.
+ * @NL80211_ST_CTX_TYPE_EXEC: ST Execution.
+ * @NUM_ST_CTX_TYPES: internal.
+ * @NL80211_ST_CTX_TYPE_MAX: Max type of ST context.
+ */
+enum nl80211_st_ctx_type {
+ NL80211_ST_CTX_TYPE_PREP,
+ NL80211_ST_CTX_TYPE_EXEC,
+
+ NUM_ST_CTX_TYPES,
+ NL80211_ST_CTX_TYPE_MAX = NUM_ST_CTX_TYPES - 1,
+};
+
+/**
+ * enum nl80211_st_ctx_ba_param - ST Block Ack Context attributes
+ *
+ * @__NL80211_ST_CTX_BA_ATTR_INVALID: Invalid attribute.
+ * @NL80211_ST_CTX_BA_ATTR_BUFF_SIZE: Required (u16) full BA buffer size.
+ * @NL80211_ST_CTX_BA_ATTR_POLICY: Required (u8) BA policy.
+ * @NL80211_ST_CTX_BA_ATTR_AMSDU_SUPPORT: Flag attribute to indicate
+ * AMSDU support.
+ * @NL80211_ST_CTX_BA_ATTR_TIMEOUT: Required (u16) Block Ack timeout.
+ * @NL80211_ST_CTX_BA_ATTR_EXT_NO_FRAG: Flag attribute to indicate
+ * fragmentation support.
+ * @NL80211_ST_CTX_BA_ATTR_EXT_FRAG_LEVEL: Required (u8) HE fragmentation
+ * level.
+ * @NL80211_ST_CTX_BA_ATTR_WINSTARTO: Required (u16) Starting Sequence Number
+ * of the BA window.
+ * Applicable only when %NL80211_ST_CTX_INFO_ATTR_BA_PARAMS is used with
+ * %NL80211_ST_CTX_ATTR_DL.
+ * @__NL80211_ST_CTX_BA_ATTR_LAST: Last attribute, used internally.
+ * @NL80211_ST_CTX_BA_ATTR_MAX: Max attribute.
+ *
+ * Used with %NL80211_ST_CTX_INFO_ATTR_BA_PARAMS.
+ */
+enum nl80211_st_ctx_ba_param {
+ __NL80211_ST_CTX_BA_ATTR_INVALID,
+ NL80211_ST_CTX_BA_ATTR_BUFF_SIZE,
+ NL80211_ST_CTX_BA_ATTR_POLICY,
+ NL80211_ST_CTX_BA_ATTR_AMSDU_SUPPORT,
+ NL80211_ST_CTX_BA_ATTR_TIMEOUT,
+ NL80211_ST_CTX_BA_ATTR_EXT_NO_FRAG,
+ NL80211_ST_CTX_BA_ATTR_EXT_FRAG_LEVEL,
+ NL80211_ST_CTX_BA_ATTR_WINSTARTO,
+
+ __NL80211_ST_CTX_BA_ATTR_LAST,
+ NL80211_ST_CTX_BA_ATTR_MAX = __NL80211_ST_CTX_BA_ATTR_LAST - 1
+};
+
+/**
+ * enum nl80211_st_ctx_info - ST Dynamic Context Information
+ *
+ * @__NL80211_ST_CTX_INFO_ATTR_INVALID: Invalid attribute.
+ * @NL80211_ST_CTX_INFO_ATTR_SN: Optional (nested), next SN per-TID to be
+ * assigned or last SN received per-TID for DL/UL individually addressed
+ * frames.
+ * @NL80211_ST_CTX_INFO_ATTR_SN_PER_TID: Per-TID SN (u16) used with
+ * %NL80211_ST_CTX_INFO_ATTR_SN nest.
+ * @NL80211_ST_CTX_INFO_ATTR_BA_PARAMS: Optional (nested) Block Ack parameters
+ * in DL/UL (uses &enum nl80211_st_ctx_ba_param).
+ * @NL80211_ST_CTX_INFO_ATTR_MGMT_SN: Optional (u16) next SN to be assigned or
+ * last SN received for DL/UL individually addressed management frames.
+ * @NL80211_ST_CTX_INFO_ATTR_DL_PN: Optional (binary) starting PN for
+ * DL individually addressed frames.
+ * @NL80211_ST_CTX_INFO_ATTR_UL_PN: Optional (nested) last PN received per TID
+ * for UL individually addressed frames.
+ * @NL80211_ST_CTX_INFO_ATTR_UL_PN_PER_TID: Per-TID UL PN (binary) used
+ * with %NL80211_ST_CTX_INFO_ATTR_UL_PN nest.
+ * @NL80211_ST_CTX_INFO_ATTR_UL_MGMT_PN: Optional (binary) last PN
+ * received for UL individually addressed management frames.
+ * @__NL80211_ST_CTX_INFO_ATTR_LAST: Last attribute, used internally.
+ * @NL80211_ST_CTX_INFO_ATTR_MAX: Max attribute.
+ *
+ * This defines the namespace for context information that are either common to
+ * both DL and UL, or direction-specific. Used with %NL80211_ST_CTX_ATTR_DL and
+ * %NL80211_ST_CTX_ATTR_UL, appropriately.
+ */
+enum nl80211_st_ctx_info {
+ __NL80211_ST_CTX_INFO_ATTR_INVALID,
+ NL80211_ST_CTX_INFO_ATTR_SN,
+ NL80211_ST_CTX_INFO_ATTR_SN_PER_TID,
+ NL80211_ST_CTX_INFO_ATTR_BA_PARAMS,
+ NL80211_ST_CTX_INFO_ATTR_MGMT_SN,
+ NL80211_ST_CTX_INFO_ATTR_DL_PN,
+ NL80211_ST_CTX_INFO_ATTR_UL_PN,
+ NL80211_ST_CTX_INFO_ATTR_UL_PN_PER_TID,
+ NL80211_ST_CTX_INFO_ATTR_UL_MGMT_PN,
+
+ __NL80211_ST_CTX_INFO_ATTR_LAST,
+ NL80211_ST_CTX_INFO_ATTR_MAX = __NL80211_ST_CTX_INFO_ATTR_LAST - 1
+};
+
+/**
+ * enum nl80211_st_ctx - ST Context information
+ *
+ * Top-level container for SMD Transition dynamic context. Carried in
+ * %NL80211_ATTR_ST_CTX with %NL80211_CMD_SET_ST_CTX (target AP MLD) or
+ * with %NL80211_CMD_FRAME (current AP MLD reporting context to userspace)
+ * and %NL80211_CMD_ST_CTX_EVENT (current AP MLD reporting the requested
+ * context on behalf of the target AP MLD).
+ *
+ * @__NL80211_ST_CTX_ATTR_INVALID: Invalid attribute.
+ * @NL80211_ST_CTX_ATTR_DL: Optional (nested) DL parameters.
+ * See &enum nl80211_st_ctx_dl.
+ * @NL80211_ST_CTX_ATTR_UL: Optional (nested) UL parameters.
+ * See &enum nl80211_st_ctx_ul.
+ * @__NL80211_ST_CTX_ATTR_LAST: Last attribute, used internally.
+ * @NL80211_ST_CTX_ATTR_MAX: Max attribute.
+ */
+enum nl80211_st_ctx {
+ __NL80211_ST_CTX_ATTR_INVALID,
+ NL80211_ST_CTX_ATTR_DL,
+ NL80211_ST_CTX_ATTR_UL,
+
+ __NL80211_ST_CTX_ATTR_LAST,
+ NL80211_ST_CTX_ATTR_MAX = __NL80211_ST_CTX_ATTR_LAST - 1
+};
+
#endif /* __LINUX_NL80211_H */
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index f15ddf5a94a6..3e51ce0155d3 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -808,6 +808,43 @@ nl80211_nan_conf_policy[NL80211_NAN_CONF_ATTR_MAX + 1] = {
[NL80211_NAN_CONF_INSTANT_COMM] = { .type = NLA_FLAG },
};

+static const struct nla_policy
+nl80211_st_ctx_ba_policy[NL80211_ST_CTX_BA_ATTR_MAX + 1] = {
+ [NL80211_ST_CTX_BA_ATTR_BUFF_SIZE] = { .type = NLA_U16 },
+ [NL80211_ST_CTX_BA_ATTR_POLICY] = { .type = NLA_U8 },
+ [NL80211_ST_CTX_BA_ATTR_AMSDU_SUPPORT] = { .type = NLA_FLAG },
+ [NL80211_ST_CTX_BA_ATTR_TIMEOUT] = { .type = NLA_U16 },
+ [NL80211_ST_CTX_BA_ATTR_EXT_NO_FRAG] = { .type = NLA_FLAG },
+ [NL80211_ST_CTX_BA_ATTR_EXT_FRAG_LEVEL] = { .type = NLA_U8 },
+ [NL80211_ST_CTX_BA_ATTR_WINSTARTO] = { .type = NLA_U16 },
+};
+
+static const struct nla_policy
+nl80211_st_ctx_info_policy[NL80211_ST_CTX_INFO_ATTR_MAX + 1] = {
+ [NL80211_ST_CTX_INFO_ATTR_SN] =
+ NLA_POLICY_NESTED_ARRAY(nl80211_st_ctx_info_policy),
+ [NL80211_ST_CTX_INFO_ATTR_SN_PER_TID] = { .type = NLA_U16 },
+ [NL80211_ST_CTX_INFO_ATTR_BA_PARAMS] =
+ NLA_POLICY_NESTED_ARRAY(nl80211_st_ctx_ba_policy),
+ [NL80211_ST_CTX_INFO_ATTR_MGMT_SN] = { .type = NLA_U16 },
+ [NL80211_ST_CTX_INFO_ATTR_DL_PN] =
+ NLA_POLICY_EXACT_LEN(IEEE80211_CCMP_PN_LEN),
+ [NL80211_ST_CTX_INFO_ATTR_UL_PN] =
+ NLA_POLICY_NESTED_ARRAY(nl80211_st_ctx_info_policy),
+ [NL80211_ST_CTX_INFO_ATTR_UL_PN_PER_TID] =
+ NLA_POLICY_EXACT_LEN(IEEE80211_CCMP_PN_LEN),
+ [NL80211_ST_CTX_INFO_ATTR_UL_MGMT_PN] =
+ NLA_POLICY_EXACT_LEN(IEEE80211_CCMP_PN_LEN),
+};
+
+static const struct nla_policy
+nl80211_st_ctx_policy[NL80211_ST_CTX_ATTR_MAX + 1] = {
+ [NL80211_ST_CTX_ATTR_DL] =
+ NLA_POLICY_NESTED(nl80211_st_ctx_info_policy),
+ [NL80211_ST_CTX_ATTR_UL] =
+ NLA_POLICY_NESTED(nl80211_st_ctx_info_policy),
+};
+
static const struct netlink_range_validation nl80211_punct_bitmap_range = {
.min = 0,
.max = 0xffff,
@@ -1221,6 +1258,9 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
[NL80211_ATTR_CIP_CAPABILITIES] = { .type = NLA_U8 },
[NL80211_ATTR_ASSOC_PROTECTED_TWT] = { .type = NLA_FLAG },
[NL80211_ATTR_SMD] = { .type = NLA_FLAG },
+ [NL80211_ATTR_ST_CTX] = NLA_POLICY_NESTED(nl80211_st_ctx_policy),
+ [NL80211_ATTR_ST_CTX_TYPE] =
+ NLA_POLICY_MAX(NLA_U8, NL80211_ST_CTX_TYPE_MAX),
};

/* policy for the key attributes */

--
2.34.1