[PATCH wireless-next 01/18] net: skbuff: Add SKB extension support to wireless drivers
From: Pooventhiran G
Date: Mon Sep 07 2026 - 16:35:50 EST
IEEE P802.11bn/D2.0, Aug 2026, subclause 37.16, defines Seamless
Mobility Domain (SMD) BSS Transition, in which a station roams between
two AP MLDs within an SMD across two phases: Preparation and Execution.
During these phases, the receiving AP driver processes a query frame and
must carry the station's roaming context - per-TID sequence numbers in
downlink (DL) and uplink (UL) directions, packet number in DL and
per-TID packet numbers in UL, and per-TID BlockAck session parameters in
DL and UL, plus a variable-length driver context - up through mac80211
and nl80211 to userspace, which uses it to complete the transition.
This context does not fit in skb->cb (48 bytes). Carrying it separately,
outside the SKB, breaks when the SKB is cloned through the RX path because
the context lifetime is no longer tied to the frame; the driver would need
independent state correlated with the SKB at nl80211 encode time, adding
error-prone lifecycle management. SKB extensions avoid these problems: they
are reference-counted, copy-on-write safe, and freed automatically with the
SKB.
Add a new skbuff_wireless.h with a typed union structured to accommodate
future wireless extension types, carrying the SMD roaming context as its
first payload.
Signed-off-by: Pooventhiran G <pooventhiran.g@xxxxxxxxxxxxxxxx>
---
include/linux/skbuff.h | 3 +++
include/linux/skbuff_wireless.h | 55 +++++++++++++++++++++++++++++++++++++++++
net/core/skbuff.c | 55 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 113 insertions(+)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 421f6fc45451..fb686024e97d 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -5061,6 +5061,9 @@ enum skb_ext_id {
#endif
#if IS_ENABLED(CONFIG_CAN)
SKB_EXT_CAN,
+#endif
+#if IS_ENABLED(CONFIG_WIRELESS)
+ SKB_EXT_WIRELESS,
#endif
SKB_EXT_NUM, /* must be last */
};
diff --git a/include/linux/skbuff_wireless.h b/include/linux/skbuff_wireless.h
new file mode 100644
index 000000000000..2cb04bff061c
--- /dev/null
+++ b/include/linux/skbuff_wireless.h
@@ -0,0 +1,55 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * IEEE 802.11 WLAN skb_ext definitions
+ *
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+
+#ifndef LINUX_SKB_WIRELESS_H
+#define LINUX_SKB_WIRELESS_H
+
+#include <linux/types.h>
+#include <linux/refcount.h>
+
+/**
+ * enum wireless_skb_ext_type - type of data in wireless_skb_ext
+ * @WIRELESS_SKB_EXT_INVALID: uninitialized state
+ * @WIRELESS_SKB_EXT_UHR_SMD: payload is @uhr_smd_ctx
+ */
+enum wireless_skb_ext_type {
+ WIRELESS_SKB_EXT_INVALID,
+ WIRELESS_SKB_EXT_UHR_SMD,
+};
+
+/**
+ * struct wireless_skb_ext_smd_ctx - UHR SMD roaming context container in
+ * SKB extensions
+ * @refcnt: reference count; one count per distinct skb_ext block that holds
+ * this pointer. Plain skb_clone() shares the same skb_ext block and
+ * does not increment this counter. Only skb_ext_maybe_cow() increments
+ * this counter, when a COW produces a second independent ext block copy.
+ * @smd_ctx: pointer to the IEEE P802.11bn UHR SMD roaming context;
+ * must be a kmalloc-ed buffer, freed together with this container.
+ */
+struct wireless_skb_ext_smd_ctx {
+ refcount_t refcnt;
+ void *smd_ctx;
+};
+
+/**
+ * struct wireless_skb_ext - SKB extension data for wireless module use
+ *
+ * Carried as an skb extension (SKB_EXT_WIRELESS). The union is reserved
+ * for future wireless extension types; only one member is active per skb.
+ *
+ * @type: type of data
+ * @uhr_smd_ctx: pointer to the UHR SMD context container
+ */
+struct wireless_skb_ext {
+ enum wireless_skb_ext_type type;
+ union {
+ struct wireless_skb_ext_smd_ctx *uhr_smd_ctx;
+ };
+};
+
+#endif /* LINUX_SKB_WIRELESS_H */
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index ab195b99c853..f28ab7c3c888 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -93,6 +93,10 @@
#include <linux/indirect_call_wrapper.h>
#include <linux/textsearch.h>
+#if IS_ENABLED(CONFIG_WIRELESS)
+#include <linux/skbuff_wireless.h>
+#endif
+
#include "dev.h"
#include "devmem.h"
#include "net-sysfs.h"
@@ -5169,6 +5173,9 @@ static const u8 skb_ext_type_len[] = {
#if IS_ENABLED(CONFIG_CAN)
[SKB_EXT_CAN] = SKB_EXT_CHUNKSIZEOF(struct can_skb_ext),
#endif
+#if IS_ENABLED(CONFIG_WIRELESS)
+ [SKB_EXT_WIRELESS] = SKB_EXT_CHUNKSIZEOF(struct wireless_skb_ext),
+#endif
};
static __always_inline __no_profile unsigned int skb_ext_total_length(void)
@@ -7152,6 +7159,16 @@ static struct skb_ext *skb_ext_maybe_cow(struct skb_ext *old,
if (flow->key)
refcount_inc(&flow->key->refs);
}
+#endif
+#if IS_ENABLED(CONFIG_WIRELESS)
+ if (old_active & (1 << SKB_EXT_WIRELESS)) {
+ struct wireless_skb_ext *wifi =
+ skb_ext_get_ptr(old, SKB_EXT_WIRELESS);
+
+ if (wifi->type == WIRELESS_SKB_EXT_UHR_SMD &&
+ wifi->uhr_smd_ctx)
+ refcount_inc(&wifi->uhr_smd_ctx->refcnt);
+ }
#endif
__skb_ext_put(old);
return new;
@@ -7256,6 +7273,36 @@ static void skb_ext_put_mctp(struct mctp_flow *flow)
}
#endif
+#if IS_ENABLED(CONFIG_WIRELESS)
+static void skb_ext_put_wireless(struct wireless_skb_ext *wifi)
+{
+ switch (wifi->type) {
+ case WIRELESS_SKB_EXT_UHR_SMD:
+ if (!wifi->uhr_smd_ctx)
+ break;
+
+ if (refcount_dec_and_test(&wifi->uhr_smd_ctx->refcnt)) {
+ kfree(wifi->uhr_smd_ctx->smd_ctx);
+ kfree(wifi->uhr_smd_ctx);
+ }
+
+ /*
+ * __skb_ext_del clears active_extensions but not ext->offset[],
+ * so __skb_ext_put will call skb_ext_put_wireless again;
+ * mark NULL regardless to avoid double free in __skb_ext_put.
+ */
+ wifi->uhr_smd_ctx = NULL;
+ break;
+ case WIRELESS_SKB_EXT_INVALID:
+ /* data not yet set */
+ break;
+ default:
+ WARN_ONCE(1, "unknown wireless skb extension type=%u\n",
+ wifi->type);
+ }
+}
+#endif
+
void __skb_ext_del(struct sk_buff *skb, enum skb_ext_id id)
{
struct skb_ext *ext = skb->extensions;
@@ -7278,6 +7325,10 @@ void __skb_ext_del(struct sk_buff *skb, enum skb_ext_id id)
if (id == SKB_EXT_MCTP)
skb_ext_put_mctp(skb_ext_get_ptr(ext, SKB_EXT_MCTP));
#endif
+#if IS_ENABLED(CONFIG_WIRELESS)
+ if (id == SKB_EXT_WIRELESS)
+ skb_ext_put_wireless(skb_ext_get_ptr(ext, SKB_EXT_WIRELESS));
+#endif
}
EXPORT_SYMBOL(__skb_ext_del);
@@ -7300,6 +7351,10 @@ void __skb_ext_put(struct skb_ext *ext)
if (__skb_ext_exist(ext, SKB_EXT_MCTP))
skb_ext_put_mctp(skb_ext_get_ptr(ext, SKB_EXT_MCTP));
#endif
+#if IS_ENABLED(CONFIG_WIRELESS)
+ if (__skb_ext_exist(ext, SKB_EXT_WIRELESS))
+ skb_ext_put_wireless(skb_ext_get_ptr(ext, SKB_EXT_WIRELESS));
+#endif
kmem_cache_free(skbuff_ext_cache, ext);
}
--
2.34.1