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 10/19] wifi: nl80211/cfg80211: add support for querying ST context for target AP MLD
Date: Wed, 02 Dec 2026 15:58:05 +0530	[thread overview]
Message-ID: <20261202-smd-v5-10-1b020be65c7c@oss.qualcomm.com> (raw)
In-Reply-To: <20261202-smd-v5-0-1b020be65c7c@oss.qualcomm.com>

During ST, the non-AP MLD that has been prepared with a target AP MLD
may send the ST Execution frame directly to the target AP MLD. In such
scenarios, the target AP MLD should pull the context from the current
AP MLD to program TX and RX queues.

Add nl80211 support to handle NL80211_CMD_GET_ST_CTX, which is sent by
userspace of the current AP MLD on behalf of the target AP MLD. This
command carries the context type to indicate to the drivers which context
needs to be collected. Once the collection is complete, the context is
sent back to userspace as an asynchronous multicast event using
NL80211_CMD_ST_CTX_EVENT with full context data carried in
NL80211_ATTR_ST_CTX.

Signed-off-by: Pooventhiran G <pooventhiran.g@oss.qualcomm.com>
---
 include/net/cfg80211.h  | 20 +++++++++++++
 net/wireless/nl80211.c  | 77 +++++++++++++++++++++++++++++++++++++++++++++++--
 net/wireless/nl80211.h  |  3 ++
 net/wireless/rdev-ops.h | 14 +++++++++
 net/wireless/trace.h    | 26 +++++++++++++++++
 5 files changed, 138 insertions(+), 2 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 5269719c8d15..f07b7064dcb1 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5411,6 +5411,7 @@ struct cfg80211_smd_transition_info {
  * @set_st_ctx: Set ST context data for the non-AP MLD. @st_info->ctx is freed
  *	immediately after this call returns; drivers must copy @st_info->ctx
  *	if asynchronous processing is required.
+ * @get_st_ctx: Get ST context data for the non-AP MLD.
  */
 struct cfg80211_ops {
 	int	(*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -5818,6 +5819,8 @@ struct cfg80211_ops {
 	int	(*set_st_ctx)(struct wiphy *wiphy, struct wireless_dev *wdev,
 			      const u8 *addr,
 			      struct cfg80211_smd_transition_info *st_info);
+	int	(*get_st_ctx)(struct wiphy *wiphy, struct wireless_dev *wdev,
+			      const u8 *addr, enum nl80211_st_ctx_type type);
 };
 
 /*
@@ -11522,4 +11525,21 @@ struct ieee80211_st_ctx {
 	} ul;
 };
 
+/**
+ * cfg80211_notify_get_st_ctx_done - deliver async GET_ST_CTX result to
+ *	userspace
+ * @wdev: wireless device that handled the request
+ * @sta_addr: non-AP MLD address the context was collected for
+ * @st_info: SMD Transition Info (set @st_info->ctx to NULL to indicate
+ *	failure)
+ *
+ * Sends a multicast %NL80211_CMD_ST_CTX_EVENT reply to userspace (MLME group).
+ *
+ * Return: None
+ */
+void
+cfg80211_notify_get_st_ctx_done(struct wireless_dev *wdev,
+				const u8 *sta_addr,
+				struct cfg80211_smd_transition_info *st_info);
+
 #endif /* __NET_CFG80211_H */
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index f76198cc0e84..ae54b96bc573 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -20282,8 +20282,8 @@ nl80211_put_st_ctx_ba_params(struct sk_buff *msg, unsigned long tid_bmap,
 	return -ENOBUFS;
 }
 
-static int nl80211_put_st_ctx(struct sk_buff *msg,
-			      struct cfg80211_smd_transition_info *st_info)
+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;
@@ -21166,6 +21166,36 @@ static int nl80211_set_st_ctx(struct sk_buff *skb, struct genl_info *info)
 	return err;
 }
 
+static int nl80211_get_st_ctx(struct sk_buff *skb, struct genl_info *info)
+{
+	struct cfg80211_registered_device *rdev = info->user_ptr[0];
+	struct net_device *dev = info->user_ptr[1];
+	struct wireless_dev *wdev = dev->ieee80211_ptr;
+	enum nl80211_st_ctx_type type;
+	const u8 *addr = NULL;
+	int err;
+
+	if (!rdev->ops->get_st_ctx)
+		return -EOPNOTSUPP;
+
+	if (wdev->iftype != NL80211_IFTYPE_AP &&
+	    wdev->iftype != NL80211_IFTYPE_AP_VLAN)
+		return -EINVAL;
+
+	if (!info->attrs[NL80211_ATTR_MLD_ADDR] ||
+	    !info->attrs[NL80211_ATTR_ST_CTX_TYPE]) {
+		GENL_SET_ERR_MSG(info, "required attributes are missing");
+		return -EINVAL;
+	}
+
+	addr = nla_data(info->attrs[NL80211_ATTR_MLD_ADDR]);
+	type = nla_get_u8(info->attrs[NL80211_ATTR_ST_CTX_TYPE]);
+
+	err = rdev_get_st_ctx(rdev, wdev, addr, type);
+
+	return err;
+}
+
 #define SELECTOR(__sel, name, value) \
 	((__sel) == (value)) ? NL80211_IFL_SEL_##name :
 int __missing_selector(void);
@@ -22108,6 +22138,12 @@ static const struct genl_small_ops nl80211_small_ops[] = {
 		.internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP |
 					 NL80211_FLAG_CLEAR_SKB),
 	},
+	{
+		.cmd = NL80211_CMD_GET_ST_CTX,
+		.doit = nl80211_get_st_ctx,
+		.flags = GENL_UNS_ADMIN_PERM,
+		.internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP),
+	},
 };
 
 static struct genl_family nl80211_fam __ro_after_init = {
@@ -25304,6 +25340,43 @@ void cfg80211_nan_channel_evac(struct wireless_dev *wdev,
 }
 EXPORT_SYMBOL(cfg80211_nan_channel_evac);
 
+void
+cfg80211_notify_get_st_ctx_done(struct wireless_dev *wdev,
+				const u8 *sta_addr,
+				struct cfg80211_smd_transition_info *st_info)
+{
+	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
+	struct net_device *dev = wdev->netdev;
+	struct sk_buff *msg;
+	void *hdr;
+
+	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
+	if (!msg)
+		return;
+
+	hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_ST_CTX_EVENT);
+	if (!hdr)
+		goto nla_put_failure;
+
+	if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
+	    nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
+	    nla_put(msg, NL80211_ATTR_MLD_ADDR, ETH_ALEN, sta_addr))
+		goto nla_put_failure;
+
+	if (st_info->ctx && nl80211_put_st_ctx(msg, st_info))
+		goto nla_put_failure;
+
+	genlmsg_end(msg, hdr);
+
+	genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
+				NL80211_MCGRP_MLME, GFP_ATOMIC);
+	return;
+
+nla_put_failure:
+	nlmsg_free(msg);
+}
+EXPORT_SYMBOL(cfg80211_notify_get_st_ctx_done);
+
 /* initialisation/exit functions */
 
 int __init nl80211_init(void)
diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h
index 1e75b38ad88d..075988f03d51 100644
--- a/net/wireless/nl80211.h
+++ b/net/wireless/nl80211.h
@@ -140,4 +140,7 @@ void nl80211_st_execution_response(struct cfg80211_registered_device *rdev,
 void nl80211_st_done(struct cfg80211_registered_device *rdev,
 		     struct net_device *dev);
 
+int nl80211_put_st_ctx(struct sk_buff *msg,
+		       struct cfg80211_smd_transition_info *st_info);
+
 #endif /* __NET_WIRELESS_NL80211_H */
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h
index 824b606479db..eb555e0c0d6a 100644
--- a/net/wireless/rdev-ops.h
+++ b/net/wireless/rdev-ops.h
@@ -1769,4 +1769,18 @@ static inline int rdev_set_st_ctx(struct cfg80211_registered_device *rdev,
 	return ret;
 }
 
+static inline int rdev_get_st_ctx(struct cfg80211_registered_device *rdev,
+				  struct wireless_dev *wdev, const u8 *addr,
+				  enum nl80211_st_ctx_type type)
+{
+	int ret = -EOPNOTSUPP;
+
+	trace_rdev_get_st_ctx(&rdev->wiphy, wdev, addr, type);
+	if (rdev->ops->get_st_ctx)
+		ret = rdev->ops->get_st_ctx(&rdev->wiphy, wdev, addr, type);
+	trace_rdev_return_int(&rdev->wiphy, ret);
+
+	return ret;
+}
+
 #endif /* __CFG80211_RDEV_OPS */
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 7806a2edb26f..fbd8068edb93 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -4736,6 +4736,32 @@ TRACE_EVENT(rdev_set_st_ctx,
 		  __entry->dl_tid_bitmap, __entry->ul_tid_bitmap
 	)
 );
+
+TRACE_EVENT(rdev_get_st_ctx,
+	TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, const u8 *addr,
+		 enum nl80211_st_ctx_type type),
+
+	TP_ARGS(wiphy, wdev, addr, type),
+
+	TP_STRUCT__entry(
+		WIPHY_ENTRY
+		WDEV_ENTRY
+		MAC_ENTRY(sta_addr)
+		__field(u8, st_type)
+	),
+
+	TP_fast_assign(
+		WIPHY_ASSIGN;
+		WDEV_ASSIGN;
+		MAC_ASSIGN(sta_addr, addr);
+		__entry->st_type = type;
+	),
+
+	TP_printk(WIPHY_PR_FMT  ", " WDEV_PR_FMT
+		  ", sta=%pM, ST type=%u",
+		  WIPHY_PR_ARG, WDEV_PR_ARG, __entry->sta_addr,
+		  __entry->st_type)
+);
 #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */
 
 #undef TRACE_INCLUDE_PATH

-- 
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 ` [PATCH wireless-next v5 08/19] wifi: nl80211/cfg80211: pack ST dynamic context along with frame Pooventhiran G
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 ` Pooventhiran G [this message]
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-10-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®