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 09/19] wifi: nl80211/cfg80211: add support for ST context programming
Date: Wed, 02 Dec 2026 15:58:04 +0530 [thread overview]
Message-ID: <20261202-smd-v5-9-1b020be65c7c@oss.qualcomm.com> (raw)
In-Reply-To: <20261202-smd-v5-0-1b020be65c7c@oss.qualcomm.com>
On the target AP MLD to which the STA will be transitioning, the dynamic
context collected and sent by the current AP MLD needs to be programmed
on the TX and RX queues to enable seamless transition and reception.
Such data include Sequence Number (SN), Packet Number (PN), BlockAck
sessions, and any driver-specific data.
Add nl80211 support to handle NL80211_CMD_SET_ST_CTX, parse the ST
context attributes, and invoke the cfg80211 operation on the target AP
MLD.
Signed-off-by: Pooventhiran G <pooventhiran.g@oss.qualcomm.com>
---
include/net/cfg80211.h | 7 ++
net/wireless/nl80211.c | 323 ++++++++++++++++++++++++++++++++++++++++++++++++
net/wireless/rdev-ops.h | 14 +++
net/wireless/trace.h | 34 +++++
4 files changed, 378 insertions(+)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index ade029268548..5269719c8d15 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5407,6 +5407,10 @@ struct cfg80211_smd_transition_info {
* @execute_st: Execute a previously prepared SMD transition
* @abandon_st: Abandon a prepared SMD transition to the given AP MLD.
* If @local_only is true don't send the ST abandon action frame.
+ *
+ * @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.
*/
struct cfg80211_ops {
int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -5811,6 +5815,9 @@ struct cfg80211_ops {
struct cfg80211_st_exec_request *req);
int (*abandon_st)(struct wiphy *wiphy, struct net_device *dev,
const u8 *ap_mld_addr, bool local_only);
+ int (*set_st_ctx)(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const u8 *addr,
+ struct cfg80211_smd_transition_info *st_info);
};
/*
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index bf81d67f42ac..f76198cc0e84 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -20419,6 +20419,286 @@ static int nl80211_put_st_ctx(struct sk_buff *msg,
return -ENOBUFS;
}
+static int nl80211_parse_st_ctx_ba_params(struct nlattr *tb,
+ struct ieee80211_st_ctx_ba *ba_tids,
+ u8 *valid_tid_bmap)
+{
+ struct nlattr *ba_attr;
+ int n_tids = 0;
+ int rem;
+
+ nla_for_each_nested(ba_attr, tb, rem) {
+ struct nlattr *ba_tb[NL80211_ST_CTX_BA_ATTR_MAX + 1];
+ struct ieee80211_st_ctx_ba *ba;
+ int tid = nla_type(ba_attr) - 1;
+
+ if (tid < 0 || tid >= IEEE80211_ST_CTX_NUM_TIDS)
+ return -EINVAL;
+
+ nla_parse_nested(ba_tb, NL80211_ST_CTX_BA_ATTR_MAX,
+ ba_attr, NULL, NULL);
+
+ ba = &ba_tids[tid];
+
+ if (ba_tb[NL80211_ST_CTX_BA_ATTR_BUFF_SIZE])
+ ba->buffer_size =
+ nla_get_u16(ba_tb[NL80211_ST_CTX_BA_ATTR_BUFF_SIZE]);
+
+ if (ba_tb[NL80211_ST_CTX_BA_ATTR_POLICY])
+ ba->ba_policy =
+ nla_get_u8(ba_tb[NL80211_ST_CTX_BA_ATTR_POLICY]);
+
+ ba->amsdu_supported =
+ nla_get_flag(ba_tb[NL80211_ST_CTX_BA_ATTR_AMSDU_SUPPORT]);
+
+ if (ba_tb[NL80211_ST_CTX_BA_ATTR_TIMEOUT])
+ ba->timeout =
+ nla_get_u16(ba_tb[NL80211_ST_CTX_BA_ATTR_TIMEOUT]);
+
+ ba->ext_no_frag =
+ nla_get_flag(ba_tb[NL80211_ST_CTX_BA_ATTR_EXT_NO_FRAG]);
+
+ if (ba_tb[NL80211_ST_CTX_BA_ATTR_EXT_FRAG_LEVEL])
+ ba->extfrag_level =
+ nla_get_u8(ba_tb[NL80211_ST_CTX_BA_ATTR_EXT_FRAG_LEVEL]);
+
+ if (ba_tb[NL80211_ST_CTX_BA_ATTR_WINSTARTO])
+ ba->winstarto =
+ nla_get_u16(ba_tb[NL80211_ST_CTX_BA_ATTR_WINSTARTO]);
+
+ *valid_tid_bmap |= BIT(tid);
+ n_tids++;
+ }
+
+ if (!n_tids)
+ return -EINVAL;
+
+ return 0;
+}
+
+static int nl80211_parse_st_ctx(struct genl_info *info,
+ struct cfg80211_smd_transition_info *st_info)
+{
+ struct nlattr *ctx_tb[NL80211_ST_CTX_INFO_ATTR_MAX + 1];
+ struct nlattr *tb[NL80211_ST_CTX_ATTR_MAX + 1];
+ struct ieee80211_st_ctx *ctx;
+ struct nlattr *ba_attr;
+
+ st_info->ctx = NULL;
+
+ ctx = kzalloc_obj(*ctx);
+ if (!ctx)
+ return -ENOMEM;
+
+ nla_parse_nested(tb, NL80211_ST_CTX_ATTR_MAX,
+ info->attrs[NL80211_ATTR_ST_CTX], NULL, NULL);
+
+ ctx->no_dl_sn_transfer = 1;
+ ctx->no_ul_sn_transfer = 1;
+
+ /* DL Context */
+ if (tb[NL80211_ST_CTX_ATTR_DL]) {
+ nla_parse_nested(ctx_tb, NL80211_ST_CTX_INFO_ATTR_MAX,
+ tb[NL80211_ST_CTX_ATTR_DL], NULL, NULL);
+
+ if (ctx_tb[NL80211_ST_CTX_INFO_ATTR_SN]) {
+ struct nlattr *sn_attr;
+ int n_tids = 0;
+ int rem, tid;
+
+ nla_for_each_nested(sn_attr,
+ ctx_tb[NL80211_ST_CTX_INFO_ATTR_SN],
+ rem) {
+ struct nlattr *per_tid[NL80211_ST_CTX_INFO_ATTR_MAX + 1];
+ struct nlattr *sn;
+
+ tid = nla_type(sn_attr) - 1;
+ if (tid < 0 ||
+ tid >= IEEE80211_ST_CTX_NUM_TIDS) {
+ GENL_SET_ERR_MSG(info,
+ "invalid DL SN tid");
+ goto err_free_ctx;
+ }
+
+ nla_parse_nested(per_tid,
+ NL80211_ST_CTX_INFO_ATTR_MAX,
+ sn_attr, NULL, NULL);
+
+ sn = per_tid[NL80211_ST_CTX_INFO_ATTR_SN_PER_TID];
+ if (!sn) {
+ GENL_SET_ERR_MSG(info,
+ "no DL SN for tid");
+ goto err_free_ctx;
+ }
+
+ ctx->dl.sn[tid] = nla_get_u16(sn);
+ ctx->dl.valid_tid_bmap |= BIT(tid);
+ n_tids++;
+ }
+
+ if (!n_tids) {
+ GENL_SET_ERR_MSG(info, "empty DL SN nesting");
+ goto err_free_ctx;
+ }
+
+ ctx->no_dl_sn_transfer = 0;
+ }
+
+ if (ctx_tb[NL80211_ST_CTX_INFO_ATTR_DL_PN]) {
+ memcpy(ctx->dl.pn,
+ nla_data(ctx_tb[NL80211_ST_CTX_INFO_ATTR_DL_PN]),
+ nla_len(ctx_tb[NL80211_ST_CTX_INFO_ATTR_DL_PN]));
+ ctx->pn_valid = 1;
+ }
+
+ ba_attr = ctx_tb[NL80211_ST_CTX_INFO_ATTR_BA_PARAMS];
+ if (ba_attr) {
+ if (nl80211_parse_st_ctx_ba_params(ba_attr,
+ ctx->dl.ba,
+ &ctx->dl.valid_tid_bmap)) {
+ GENL_SET_ERR_MSG(info,
+ "failed to parse DL BlockAck params");
+ goto err_free_ctx;
+ }
+ ctx->ba_params_valid = 1;
+ }
+
+ if (ctx_tb[NL80211_ST_CTX_INFO_ATTR_MGMT_SN]) {
+ ctx->dl.mgmt_sn =
+ nla_get_u16(ctx_tb[NL80211_ST_CTX_INFO_ATTR_MGMT_SN]);
+ ctx->mgmt_tid_valid = 1;
+ ctx->no_dl_sn_transfer = 0;
+ }
+ }
+
+ /* UL Context */
+ if (tb[NL80211_ST_CTX_ATTR_UL]) {
+ nla_parse_nested(ctx_tb, NL80211_ST_CTX_INFO_ATTR_MAX,
+ tb[NL80211_ST_CTX_ATTR_UL], NULL, NULL);
+
+ if (ctx_tb[NL80211_ST_CTX_INFO_ATTR_SN]) {
+ struct nlattr *sn_attr;
+ int n_tids = 0;
+ int rem, tid;
+
+ nla_for_each_nested(sn_attr,
+ ctx_tb[NL80211_ST_CTX_INFO_ATTR_SN],
+ rem) {
+ struct nlattr *per_tid[NL80211_ST_CTX_INFO_ATTR_MAX + 1];
+ struct nlattr *sn;
+
+ tid = nla_type(sn_attr) - 1;
+ if (tid < 0 ||
+ tid >= IEEE80211_ST_CTX_NUM_TIDS) {
+ GENL_SET_ERR_MSG(info,
+ "invalid UL SN tid");
+ goto err_free_ctx;
+ }
+
+ nla_parse_nested(per_tid,
+ NL80211_ST_CTX_INFO_ATTR_MAX,
+ sn_attr, NULL, NULL);
+
+ sn = per_tid[NL80211_ST_CTX_INFO_ATTR_SN_PER_TID];
+ if (!sn) {
+ GENL_SET_ERR_MSG(info,
+ "no UL SN for tid");
+ goto err_free_ctx;
+ }
+
+ ctx->ul.sn[tid] = nla_get_u16(sn);
+ ctx->ul.valid_tid_bmap |= BIT(tid);
+ n_tids++;
+ }
+
+ if (!n_tids) {
+ GENL_SET_ERR_MSG(info, "empty UL SN nesting");
+ goto err_free_ctx;
+ }
+
+ ctx->no_ul_sn_transfer = 0;
+ }
+
+ if (ctx_tb[NL80211_ST_CTX_INFO_ATTR_UL_PN]) {
+ struct nlattr *pn_attr;
+ int n_tids = 0;
+ int rem, tid;
+
+ nla_for_each_nested(pn_attr,
+ ctx_tb[NL80211_ST_CTX_INFO_ATTR_UL_PN],
+ rem) {
+ struct nlattr *per_tid[NL80211_ST_CTX_INFO_ATTR_MAX + 1];
+ struct nlattr *pn;
+
+ tid = nla_type(pn_attr) - 1;
+ if (tid < 0 ||
+ tid >= IEEE80211_ST_CTX_NUM_TIDS) {
+ GENL_SET_ERR_MSG(info,
+ "invalid UL PN tid");
+ goto err_free_ctx;
+ }
+
+ nla_parse_nested(per_tid,
+ NL80211_ST_CTX_INFO_ATTR_MAX,
+ pn_attr, NULL, NULL);
+
+ pn = per_tid[NL80211_ST_CTX_INFO_ATTR_UL_PN_PER_TID];
+ if (!pn) {
+ GENL_SET_ERR_MSG(info,
+ "no UL PN for tid");
+ goto err_free_ctx;
+ }
+
+ memcpy(ctx->ul.pn[tid], pn, nla_len(pn));
+ n_tids++;
+ }
+
+ if (!n_tids) {
+ GENL_SET_ERR_MSG(info, "empty UL PN nesting");
+ goto err_free_ctx;
+ }
+
+ ctx->pn_valid = 1;
+ }
+
+ ba_attr = ctx_tb[NL80211_ST_CTX_INFO_ATTR_BA_PARAMS];
+ if (ba_attr) {
+ if (nl80211_parse_st_ctx_ba_params(ba_attr,
+ ctx->ul.ba,
+ &ctx->ul.valid_tid_bmap)) {
+ GENL_SET_ERR_MSG(info,
+ "failed to parse UL BlockAck params");
+ goto err_free_ctx;
+ }
+ ctx->ba_params_valid = 1;
+ }
+
+ if (ctx_tb[NL80211_ST_CTX_INFO_ATTR_MGMT_SN]) {
+ ctx->ul.mgmt_sn =
+ nla_get_u16(ctx_tb[NL80211_ST_CTX_INFO_ATTR_MGMT_SN]);
+ ctx->mgmt_tid_valid = 1;
+ ctx->no_ul_sn_transfer = 0;
+ }
+
+ if (ctx_tb[NL80211_ST_CTX_INFO_ATTR_UL_MGMT_PN]) {
+ memcpy(ctx->ul.mgmt_pn,
+ nla_data(ctx_tb[NL80211_ST_CTX_INFO_ATTR_UL_MGMT_PN]),
+ IEEE80211_CCMP_PN_LEN);
+ ctx->mgmt_tid_valid = 1;
+ ctx->pn_valid = 1;
+ }
+ }
+
+ st_info->type = nla_get_u8(info->attrs[NL80211_ATTR_ST_CTX_TYPE]);
+ st_info->ctx = ctx;
+
+ return 0;
+
+err_free_ctx:
+ kfree(ctx);
+ return -EINVAL;
+}
+
#define NL80211_FLAG_NEED_WIPHY 0x01
#define NL80211_FLAG_NEED_NETDEV 0x02
#define NL80211_FLAG_NEED_RTNL 0x04
@@ -20850,6 +21130,42 @@ static int nl80211_set_sar_specs(struct sk_buff *skb, struct genl_info *info)
return err;
}
+static int nl80211_set_st_ctx(struct sk_buff *skb, struct genl_info *info)
+{
+ struct cfg80211_registered_device *rdev = info->user_ptr[0];
+ struct cfg80211_smd_transition_info st_info = {};
+ struct net_device *dev = info->user_ptr[1];
+ struct wireless_dev *wdev = dev->ieee80211_ptr;
+ const u8 *addr;
+ int err;
+
+ if (!rdev->ops->set_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] ||
+ !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]);
+
+ err = nl80211_parse_st_ctx(info, &st_info);
+ if (err)
+ return err;
+
+ /* drivers must copy @ctx for any deferred processing */
+ err = rdev_set_st_ctx(rdev, wdev, addr, &st_info);
+
+ kfree(st_info.ctx);
+ return err;
+}
+
#define SELECTOR(__sel, name, value) \
((__sel) == (value)) ? NL80211_IFL_SEL_##name :
int __missing_selector(void);
@@ -21785,6 +22101,13 @@ static const struct genl_small_ops nl80211_small_ops[] = {
.flags = GENL_UNS_ADMIN_PERM,
.internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP),
},
+ {
+ .cmd = NL80211_CMD_SET_ST_CTX,
+ .doit = nl80211_set_st_ctx,
+ .flags = GENL_UNS_ADMIN_PERM,
+ .internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP |
+ NL80211_FLAG_CLEAR_SKB),
+ },
};
static struct genl_family nl80211_fam __ro_after_init = {
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h
index 44a4255bbc03..824b606479db 100644
--- a/net/wireless/rdev-ops.h
+++ b/net/wireless/rdev-ops.h
@@ -1755,4 +1755,18 @@ static inline int rdev_abandon_st(struct cfg80211_registered_device *rdev,
return ret;
}
+static inline int rdev_set_st_ctx(struct cfg80211_registered_device *rdev,
+ struct wireless_dev *wdev, const u8 *addr,
+ struct cfg80211_smd_transition_info *st_info)
+{
+ int ret = -EOPNOTSUPP;
+
+ trace_rdev_set_st_ctx(&rdev->wiphy, wdev, addr, st_info);
+ if (rdev->ops->set_st_ctx)
+ ret = rdev->ops->set_st_ctx(&rdev->wiphy, wdev, addr, st_info);
+ 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 b0ff3cc4176d..7806a2edb26f 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -4702,6 +4702,40 @@ DEFINE_EVENT(cfg80211_st_evt, cfg80211_st_abandoned,
struct cfg80211_bss **links),
TP_ARGS(netdev, links)
);
+
+TRACE_EVENT(rdev_set_st_ctx,
+ TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, const u8 *addr,
+ struct cfg80211_smd_transition_info *st_info),
+
+ TP_ARGS(wiphy, wdev, addr, st_info),
+
+ TP_STRUCT__entry(
+ WIPHY_ENTRY
+ WDEV_ENTRY
+ MAC_ENTRY(sta_addr)
+ __field(u8, st_type)
+ __field(u8, dl_tid_bitmap)
+ __field(u8, ul_tid_bitmap)
+ ),
+
+ TP_fast_assign(
+ struct ieee80211_st_ctx *ctx = st_info->ctx;
+
+ WIPHY_ASSIGN;
+ WDEV_ASSIGN;
+ MAC_ASSIGN(sta_addr, addr);
+ __entry->st_type = st_info->type;
+ __entry->dl_tid_bitmap = ctx->dl.valid_tid_bmap;
+ __entry->ul_tid_bitmap = ctx->ul.valid_tid_bmap;
+ ),
+
+ TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT
+ ", sta=%pM, ST type=%u DL TIDs: 0x%x, UL TIDs: 0x%x",
+ WIPHY_PR_ARG, WDEV_PR_ARG, __entry->sta_addr,
+ __entry->st_type,
+ __entry->dl_tid_bitmap, __entry->ul_tid_bitmap
+ )
+);
#endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */
#undef TRACE_INCLUDE_PATH
--
2.34.1
next prev 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 ` Pooventhiran G [this message]
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-9-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®