mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pooventhiran G <pooventhiran.g@oss.qualcomm.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	pooventhiran.g@oss.qualcomm.com
Subject: [PATCH wireless-next v5 08/19] wifi: nl80211/cfg80211: pack ST dynamic context along with frame
Date: Wed, 02 Dec 2026 15:58:03 +0530	[thread overview]
Message-ID: <20261202-smd-v5-8-1b020be65c7c@oss.qualcomm.com> (raw)
In-Reply-To: <20261202-smd-v5-0-1b020be65c7c@oss.qualcomm.com>

While packing the received management frame in nl80211_send_mgmt() to
send to userspace, nest the ST dynamic context along with the frame
message. This shall be used by userspace to transport the context to the
target AP MLD for programming the dynamic state of the STA session for
seamless roaming as part of ST.

Suggested-by: Jouni Malinen <jouni.malinen@oss.qualcomm.com>
Co-developed-by: Aditya Sathish <asathish@qti.qualcomm.com>
Signed-off-by: Aditya Sathish <asathish@qti.qualcomm.com>
Signed-off-by: Pooventhiran G <pooventhiran.g@oss.qualcomm.com>
---
 include/net/cfg80211.h |  13 ++++
 net/wireless/nl80211.c | 191 ++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 203 insertions(+), 1 deletion(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 8df01cc53274..ade029268548 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4926,6 +4926,17 @@ struct mgmt_frame_regs {
 	u32 global_mcast_stypes, interface_mcast_stypes;
 };
 
+/**
+ * struct cfg80211_smd_transition_info - SMD Transition info
+ *
+ * @ctx: Dynamic context to be transferred as part of ST
+ * @type: Type of ST indication
+ */
+struct cfg80211_smd_transition_info {
+	struct ieee80211_st_ctx *ctx;
+	enum nl80211_st_ctx_type type;
+};
+
 /**
  * struct cfg80211_ops - backend description for wireless configuration
  *
@@ -9740,6 +9751,7 @@ void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr,
  * @rx_tstamp: Hardware timestamp of frame RX in nanoseconds
  * @ack_tstamp: Hardware timestamp of ack TX in nanoseconds
  * @no_sta: set if no station is known for the frame (relevant for MLD)
+ * @st_info: SMD Transition data
  */
 struct cfg80211_rx_info {
 	int freq;
@@ -9752,6 +9764,7 @@ struct cfg80211_rx_info {
 	u64 rx_tstamp;
 	u64 ack_tstamp;
 	bool no_sta;
+	struct cfg80211_smd_transition_info st_info;
 };
 
 /**
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 3e51ce0155d3..bf81d67f42ac 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -20234,6 +20234,191 @@ static int nl80211_abandon_st(struct sk_buff *skb, struct genl_info *info)
 			       info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE]);
 }
 
+static int
+nl80211_put_st_ctx_ba_params(struct sk_buff *msg, unsigned long tid_bmap,
+			     const struct ieee80211_st_ctx_ba *ba_tids,
+			     bool dl)
+{
+	struct nlattr *ctx_ba;
+	u8 tid;
+
+	ctx_ba = nla_nest_start(msg, NL80211_ST_CTX_INFO_ATTR_BA_PARAMS);
+	if (!ctx_ba)
+		return -ENOBUFS;
+
+	for_each_set_bit(tid, &tid_bmap, IEEE80211_ST_CTX_NUM_TIDS) {
+		const struct ieee80211_st_ctx_ba *ba = &ba_tids[tid];
+		struct nlattr *tid_ba = nla_nest_start(msg, tid + 1);
+
+		if (!tid_ba)
+			goto nla_fail;
+
+		if (nla_put_u16(msg, NL80211_ST_CTX_BA_ATTR_BUFF_SIZE,
+				ba->buffer_size) ||
+		    nla_put_u8(msg, NL80211_ST_CTX_BA_ATTR_POLICY,
+			       ba->ba_policy) ||
+		    (ba->amsdu_supported &&
+		     nla_put_flag(msg,
+				  NL80211_ST_CTX_BA_ATTR_AMSDU_SUPPORT)) ||
+		    nla_put_u16(msg, NL80211_ST_CTX_BA_ATTR_TIMEOUT,
+				ba->timeout) ||
+		    (ba->ext_no_frag &&
+		     nla_put_flag(msg, NL80211_ST_CTX_BA_ATTR_EXT_NO_FRAG)) ||
+		    nla_put_u8(msg, NL80211_ST_CTX_BA_ATTR_EXT_FRAG_LEVEL,
+			       ba->extfrag_level) ||
+		    (dl && nla_put_u16(msg, NL80211_ST_CTX_BA_ATTR_WINSTARTO,
+				       ba->winstarto))) {
+			nla_nest_cancel(msg, tid_ba);
+			goto nla_fail;
+		}
+
+		nla_nest_end(msg, tid_ba);
+	}
+
+	nla_nest_end(msg, ctx_ba);
+	return 0;
+
+nla_fail:
+	return -ENOBUFS;
+}
+
+static int nl80211_put_st_ctx(struct sk_buff *msg,
+			      struct cfg80211_smd_transition_info *st_info)
+{
+	unsigned long dl_tid_bmap, ul_tid_bmap;
+	const struct ieee80211_st_ctx *ctx;
+	struct nlattr *st_ctx, *dl, *ul;
+
+	/* ST Type */
+	if (nla_put_u8(msg, NL80211_ATTR_ST_CTX_TYPE, st_info->type))
+		goto nla_fail;
+
+	st_ctx = nla_nest_start(msg, NL80211_ATTR_ST_CTX);
+	if (!st_ctx)
+		goto nla_fail;
+
+	ctx = st_info->ctx;
+
+	/* Build DL context */
+	dl_tid_bmap = ctx->dl.valid_tid_bmap;
+
+	dl = nla_nest_start(msg, NL80211_ST_CTX_ATTR_DL);
+	if (!dl)
+		goto nla_fail;
+
+	if (!ctx->no_dl_sn_transfer) {
+		struct nlattr *dl_sn =
+			nla_nest_start(msg, NL80211_ST_CTX_INFO_ATTR_SN);
+		u8 tid;
+
+		if (!dl_sn)
+			goto nla_fail;
+
+		for_each_set_bit(tid, &dl_tid_bmap,
+				 IEEE80211_ST_CTX_NUM_TIDS) {
+			struct nlattr *tid_sn = nla_nest_start(msg, tid + 1);
+
+			if (!tid_sn ||
+			    nla_put_u16(msg, NL80211_ST_CTX_INFO_ATTR_SN_PER_TID,
+					ctx->dl.sn[tid]))
+				goto nla_fail;
+
+			nla_nest_end(msg, tid_sn);
+		}
+		nla_nest_end(msg, dl_sn);
+	}
+
+	if (ctx->pn_valid &&
+	    nla_put(msg, NL80211_ST_CTX_INFO_ATTR_DL_PN,
+		    IEEE80211_CCMP_PN_LEN, ctx->dl.pn))
+		goto nla_fail;
+
+	if (ctx->ba_params_valid &&
+	    nl80211_put_st_ctx_ba_params(msg, dl_tid_bmap, ctx->dl.ba, true))
+		goto nla_fail;
+
+	if (!ctx->no_dl_sn_transfer && ctx->mgmt_tid_valid &&
+	    nla_put_u16(msg, NL80211_ST_CTX_INFO_ATTR_MGMT_SN, ctx->dl.mgmt_sn))
+		goto nla_fail;
+
+	nla_nest_end(msg, dl);
+
+	/* Build UL context */
+	ul_tid_bmap = ctx->ul.valid_tid_bmap;
+
+	ul = nla_nest_start(msg, NL80211_ST_CTX_ATTR_UL);
+	if (!ul)
+		goto nla_fail;
+
+	if (!ctx->no_ul_sn_transfer) {
+		struct nlattr *ul_sn =
+			nla_nest_start(msg, NL80211_ST_CTX_INFO_ATTR_SN);
+		u8 tid;
+
+		if (!ul_sn)
+			goto nla_fail;
+
+		for_each_set_bit(tid, &ul_tid_bmap,
+				 IEEE80211_ST_CTX_NUM_TIDS) {
+			struct nlattr *tid_sn = nla_nest_start(msg, tid + 1);
+
+			if (!tid_sn ||
+			    nla_put_u16(msg, NL80211_ST_CTX_INFO_ATTR_SN_PER_TID,
+					ctx->ul.sn[tid]))
+				goto nla_fail;
+
+			nla_nest_end(msg, tid_sn);
+		}
+		nla_nest_end(msg, ul_sn);
+	}
+
+	if (ctx->pn_valid) {
+		struct nlattr *ul_pn =
+			nla_nest_start(msg, NL80211_ST_CTX_INFO_ATTR_UL_PN);
+		u8 tid;
+
+		if (!ul_pn)
+			goto nla_fail;
+
+		for_each_set_bit(tid, &ul_tid_bmap,
+				 IEEE80211_ST_CTX_NUM_TIDS) {
+			struct nlattr *tid_pn = nla_nest_start(msg, tid + 1);
+
+			if (!tid_pn ||
+			    nla_put(msg, NL80211_ST_CTX_INFO_ATTR_UL_PN_PER_TID,
+				    IEEE80211_CCMP_PN_LEN, ctx->ul.pn[tid]))
+				goto nla_fail;
+			nla_nest_end(msg, tid_pn);
+		}
+		nla_nest_end(msg, ul_pn);
+	}
+
+	if (ctx->ba_params_valid &&
+	    nl80211_put_st_ctx_ba_params(msg, ul_tid_bmap, ctx->ul.ba, false))
+		goto nla_fail;
+
+	if (ctx->mgmt_tid_valid) {
+		if (!ctx->no_ul_sn_transfer &&
+		    nla_put_u16(msg, NL80211_ST_CTX_INFO_ATTR_MGMT_SN,
+				ctx->ul.mgmt_sn))
+			goto nla_fail;
+
+		if (ctx->pn_valid &&
+		    nla_put(msg, NL80211_ST_CTX_INFO_ATTR_UL_MGMT_PN,
+			    IEEE80211_CCMP_PN_LEN, ctx->ul.mgmt_pn))
+			goto nla_fail;
+	}
+
+	nla_nest_end(msg, ul);
+
+	nla_nest_end(msg, st_ctx);
+
+	return 0;
+
+nla_fail:
+	return -ENOBUFS;
+}
+
 #define NL80211_FLAG_NEED_WIPHY		0x01
 #define NL80211_FLAG_NEED_NETDEV	0x02
 #define NL80211_FLAG_NEED_RTNL		0x04
@@ -23157,7 +23342,7 @@ int nl80211_send_mgmt(struct cfg80211_registered_device *rdev,
 	struct sk_buff *msg;
 	void *hdr;
 
-	msg = nlmsg_new(100 + info->len, gfp);
+	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
 	if (!msg)
 		return -ENOMEM;
 
@@ -23193,6 +23378,10 @@ int nl80211_send_mgmt(struct cfg80211_registered_device *rdev,
 	     nla_put_flag(msg, NL80211_ATTR_FRAME_NO_STA)))
 		goto nla_put_failure;
 
+	if (info->st_info.ctx &&
+	    nl80211_put_st_ctx(msg, &info->st_info))
+		goto nla_put_failure;
+
 	genlmsg_end(msg, hdr);
 
 	return genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid);

-- 
2.34.1


  parent reply	other threads:[~2026-12-02 10:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 10:27 [PATCH wireless-next v5 00/19] wifi: Add Seamless Mobility Domain (SMD) AP support Pooventhiran G
2026-12-02 10:27 ` [PATCH wireless-next v5 01/19] wifi: nl80211: define Seamless Mobility Domain (SMD) device capability Pooventhiran G
2026-12-02 10:27 ` [PATCH wireless-next v5 02/19] wifi: nl80211/cfg80211: define interfaces for SMD STA indications Pooventhiran G
2026-12-02 10:27 ` [PATCH wireless-next v5 03/19] wifi: nl80211: add ST sub-state STA flags for non-AP MLD Pooventhiran G
2026-12-02 10:27 ` [PATCH wireless-next v5 04/19] wifi: cfg80211: define layouts for ST context transfer Pooventhiran G
2026-12-02 10:28 ` [PATCH wireless-next v5 05/19] wifi: nl80211: define interfaces " Pooventhiran G
2026-12-02 10:28 ` [PATCH wireless-next v5 06/19] wifi: ieee80211: define APIs for UHR Link Reconfiguration frame checks Pooventhiran G
2026-12-02 10:28 ` [PATCH wireless-next v5 07/19] wifi: ieee80211: define API to check if frame is class 3 Pooventhiran G
2026-12-02 10:28 ` Pooventhiran G [this message]
2026-12-02 10:28 ` [PATCH wireless-next v5 09/19] wifi: nl80211/cfg80211: add support for ST context programming Pooventhiran G
2026-12-02 10:28 ` [PATCH wireless-next v5 10/19] wifi: nl80211/cfg80211: add support for querying ST context for target AP MLD Pooventhiran G
2026-12-02 10:28 ` [PATCH wireless-next v5 11/19] wifi: nl80211/cfg80211: define API to notify ST Drain completion Pooventhiran G
2026-12-02 10:28 ` [PATCH wireless-next v5 12/19] wifi: mac80211: apply SMD indication and ST sub-states to STA Pooventhiran G
2026-12-02 10:28 ` [PATCH wireless-next v5 13/19] wifi: mac80211: add driver_op for ST substate changes Pooventhiran G
2026-12-02 10:28 ` [PATCH wireless-next v5 14/19] wifi: mac80211: filter uplink and downlink frames based on ST states Pooventhiran G
2026-12-02 10:28 ` [PATCH wireless-next v5 15/19] wifi: mac80211: pass rx_data directly from ieee80211_rx_list() Pooventhiran G
2026-12-02 10:28 ` [PATCH wireless-next v5 16/19] wifi: mac80211: handle UHR Link Reconfiguration frame Pooventhiran G
2026-12-02 10:28 ` [PATCH wireless-next v5 17/19] wifi: mac80211: add mac80211 support to handle NL80211_CMD_SET_ST_CTX Pooventhiran G
2026-12-02 10:28 ` [PATCH wireless-next v5 18/19] wifi: mac80211: add mac80211 support to handle NL80211_CMD_GET_ST_CTX Pooventhiran G
2026-12-02 10:28 ` [PATCH wireless-next v5 19/19] wifi: mac80211: define API to invoke ST Drain Completion event Pooventhiran G

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202-smd-v5-8-1b020be65c7c@oss.qualcomm.com \
    --to=pooventhiran.g@oss.qualcomm.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®