From: Arend van Spriel <arend.vanspriel@broadcom.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org, brcm80211@lists.linux.dev,
Arend van Spriel <arend.vanspriel@broadcom.com>
Subject: [PATCH -next 01/10] wifi: cfg80211: pre-assign cookie for remain_on_channel, mgmt_tx, probe_peer and tx_control_port
Date: Sun, 26 Jul 2026 21:25:32 +0200 [thread overview]
Message-ID: <20260726192541.2816743-2-arend.vanspriel@broadcom.com> (raw)
In-Reply-To: <20260726192541.2816743-1-arend.vanspriel@broadcom.com>
Having a single place for cookie assignment and keeping that
responsibility in the cfg80211 subsystem is a logical choice as it
handles the userspace nl80211 API. add_nan_func already does this:
cfg80211 calls cfg80211_assign_cookie() before invoking the driver.
Apply the same pattern to remain_on_channel, mgmt_tx, probe_peer and
tx_control_port by pre-assigning the cookie in the nl80211 command
handlers before the rdev_* call. For tx_control_port the cookie is
only pre-assigned when the caller requests an ack (cookie pointer
non-NULL).
Drivers may still overwrite the value for now; subsequent patches will
remove per-driver cookie generation. Update the cfg80211_ops kerneldoc
to note that the cookie is pre-assigned and drivers must not modify it.
Assisted-by: Claude:claude-sonnet-4-6
---
include/net/cfg80211.h | 12 ++++++++----
net/wireless/nl80211.c | 5 +++++
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 15c08b24502f..a30550f356ab 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5048,11 +5048,13 @@ struct mgmt_frame_regs {
* channel for the specified duration to complete an off-channel
* operation (e.g., public action frame exchange). When the driver is
* ready on the requested channel, it must indicate this with an event
- * notification by calling cfg80211_ready_on_channel().
+ * notification by calling cfg80211_ready_on_channel(). The @cookie is
+ * pre-assigned by cfg80211; drivers must not modify it.
* @cancel_remain_on_channel: Cancel an on-going remain-on-channel operation.
* This allows the operation to be terminated prior to timeout based on
* the duration value.
- * @mgmt_tx: Transmit a management frame.
+ * @mgmt_tx: Transmit a management frame. The @cookie is pre-assigned by
+ * cfg80211; drivers must not modify it.
* @mgmt_tx_cancel_wait: Cancel the wait time from transmitting a management
* frame on another channel
*
@@ -5107,7 +5109,8 @@ struct mgmt_frame_regs {
* @tdls_oper: Perform a high-level TDLS operation (e.g. TDLS link setup).
*
* @probe_peer: probe a connected peer (AP: STA MAC required; STA: no MAC),
- * must return a cookie that is later passed to cfg80211_probe_status().
+ * uses the @cookie pre-assigned by cfg80211 (drivers must not modify it)
+ * which is later passed to cfg80211_probe_status().
*
* @set_noack_map: Set the NoAck Map for the TIDs.
*
@@ -5218,7 +5221,8 @@ struct mgmt_frame_regs {
* user space
*
* @tx_control_port: TX a control port frame (EAPoL). The noencrypt parameter
- * tells the driver that the frame should not be encrypted.
+ * tells the driver that the frame should not be encrypted. When @cookie is
+ * non-NULL it is pre-assigned by cfg80211; drivers must not modify it.
*
* @get_ftm_responder_stats: Retrieve FTM responder statistics, if available.
* Statistics should be cumulative, currently no way to reset is provided.
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index ac0c0da45241..bfb3005c23a7 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -14630,6 +14630,7 @@ static int nl80211_remain_on_channel(struct sk_buff *skb,
goto free_msg;
}
+ cookie = cfg80211_assign_cookie(rdev);
err = rdev_remain_on_channel(rdev, wdev, chandef.chan,
duration, &cookie, rx_addr);
@@ -14871,6 +14872,7 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info)
}
params.chan = chandef.chan;
+ cookie = cfg80211_assign_cookie(rdev);
err = cfg80211_mlme_mgmt_tx(rdev, wdev, ¶ms, &cookie);
if (err)
goto free_msg;
@@ -16359,6 +16361,7 @@ static int nl80211_probe_peer(struct sk_buff *skb, struct genl_info *info)
goto free_msg;
}
+ cookie = cfg80211_assign_cookie(rdev);
err = rdev_probe_peer(rdev, dev, addr, &cookie);
if (err)
goto free_msg;
@@ -18574,6 +18577,8 @@ static int nl80211_tx_control_port(struct sk_buff *skb, struct genl_info *info)
link_id = nl80211_link_id_or_invalid(info->attrs);
+ if (!dont_wait_for_ack)
+ cookie = cfg80211_assign_cookie(rdev);
err = rdev_tx_control_port(rdev, dev, buf, len,
dest, cpu_to_be16(proto), noencrypt, link_id,
dont_wait_for_ack ? NULL : &cookie);
--
2.54.0
next prev parent reply other threads:[~2026-07-26 19:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-26 19:25 [PATCH -next 00/10] wifi: cfg80211: consolidate cookie assignment for async ops Arend van Spriel
2026-07-26 19:25 ` Arend van Spriel [this message]
2026-07-26 19:37 ` [PATCH -next 01/10] wifi: cfg80211: pre-assign cookie for remain_on_channel, mgmt_tx, probe_peer and tx_control_port Johannes Berg
2026-07-26 20:29 ` Jeff Johnson
2026-07-26 22:11 ` Arend van Spriel
2026-07-26 19:25 ` [PATCH -next 02/10] wifi: mac80211: stop using ieee80211_mgmt_tx_cookie() Arend van Spriel
2026-07-26 19:25 ` [PATCH -next 03/10] wifi: ath6kl: use pre-assigned cookie for remain_on_channel and mgmt_tx Arend van Spriel
2026-07-26 19:25 ` [PATCH -next 04/10] wifi: wil6210: use pre-assigned cookie for remain_on_channel, mgmt_tx and probe_peer Arend van Spriel
2026-07-26 19:25 ` [PATCH -next 05/10] wifi: brcmfmac: use pre-assigned cookie for remain_on_channel and mgmt_tx Arend van Spriel
2026-07-26 19:25 ` [PATCH -next 06/10] wifi: mwifiex: " Arend van Spriel
2026-07-26 19:25 ` [PATCH -next 07/10] wifi: wilc1000: " Arend van Spriel
2026-07-26 19:25 ` [PATCH -next 08/10] wifi: nxpwifi: " Arend van Spriel
2026-07-26 19:25 ` [PATCH -next 09/10] wifi: qtnfmac: use pre-assigned cookie for mgmt_tx Arend van Spriel
2026-07-26 19:25 ` [PATCH -next 10/10] wifi: cfg80211: convert cookie output to input parameter Arend van Spriel
2026-07-26 19:37 ` Johannes Berg
2026-07-26 22:12 ` Arend van Spriel
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=20260726192541.2816743-2-arend.vanspriel@broadcom.com \
--to=arend.vanspriel@broadcom.com \
--cc=brcm80211@lists.linux.dev \
--cc=johannes@sipsolutions.net \
--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