Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH -next 00/10] wifi: cfg80211: consolidate cookie assignment for async ops
@ 2026-07-26 19:25 Arend van Spriel
  2026-07-26 19:25 ` [PATCH -next 01/10] wifi: cfg80211: pre-assign cookie for remain_on_channel, mgmt_tx, probe_peer and tx_control_port Arend van Spriel
                   ` (9 more replies)
  0 siblings, 10 replies; 16+ messages in thread
From: Arend van Spriel @ 2026-07-26 19:25 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, brcm80211, Arend van Spriel

NL80211_ATTR_COOKIE is a userspace-visible u64 that correlates an async
nl80211 operation with its completion event. Three cfg80211 ops currently
delegate cookie generation to the driver: remain_on_channel, mgmt_tx, and
probe_peer. This produces inconsistent strategies across drivers: some use
an incrementing counter, some use get_random_u32(), some use a CID cast to
u64, and brcmfmac's mgmt_tx always assigned zero - which is arguably broken
since cfg80211 treats zero as an invalid cookie.

The add_nan_func op already does this correctly: cfg80211 calls
cfg80211_assign_cookie() before invoking the driver, ensuring a unique
non-zero value without any driver involvement. This series applies the same
pattern to remain_on_channel, mgmt_tx, probe_peer, and tx_control_port.

Structure
---------

Patch 1 is the enabling change: cfg80211 pre-assigns the cookie in the
nl80211 command handlers before the rdev_* call. Drivers may still
overwrite the value at this point; subsequent patches remove the per-driver
generation. Patch 2 updates mac80211, which has its own internal cookie
counter (roc_cookie_counter) that becomes redundant. Patches 3-9 are
per-driver cleanups. Patch 10 finalises the interface by converting the
u64 *cookie output parameter to a u64 cookie input parameter, making the
direction of data flow explicit. tx_control_port is excluded from patch 10
because its cookie pointer is nullable (passed as NULL when dont_wait_for_ack
is set) and that nullable semantics cannot be expressed with a value.

Non-obvious aspects
-------------------

ath6kl (patch 3): when the destination STA is in power-save mode, ath6kl
queues the management frame in a software queue (struct ath6kl_mgmt_buff).
The cookie must survive enqueue and dequeue so that cfg80211_mgmt_tx_status()
is called with the correct value after the frame is eventually transmitted.
This means the cookie field is threaded through ath6kl_mgmt_powersave_ap()
and into the queue entry. The vif->last_roc_id and last_cancel_roc_id fields
are widened from u32 to u64 to hold the full 64-bit cookie.

Synchronous mgmt_tx (brcmfmac, wil6210): these drivers call
cfg80211_mgmt_tx_status() before the mgmt_tx callback returns. The status
event is therefore sent to userspace before the nl80211 command reply that
carries the cookie. Userspace must buffer the status event and match it
once the reply arrives. The pre-assigned cookie being consistent across both
the status event and the reply is what makes that correlation possible.
Previously brcmfmac passed cookie=0 to cfg80211_mgmt_tx_status(), which was
broken; this series fixes that as a side effect.

qtnfmac (patch 9): the qlink firmware protocol has no frame-TX-status event
type. qtnfmac never calls cfg80211_mgmt_tx_status(). The previous code
generated a random u32 short_cookie and sent it to firmware purely as a
debug identifier; it was never used for nl80211 cookie correlation. After
this series qtnfmac simply uses the pre-assigned cookie for the same debug
purpose and discards it. The absence of tx status reporting for the
wait_for_ack case is a pre-existing driver limitation not addressed here.

mac80211 0xffffffff removal (patch 2): the old code assigned *cookie =
0xffffffff for the dont_wait_for_ack + need_offchan case to ensure
roc->mgmt_tx_cookie was non-zero, which distinguishes a mgmt-tx ROC from a
regular remain-on-channel ROC internally. That dummy value is no longer
needed because cfg80211_assign_cookie() guarantees a non-zero result (it
warns and skips zero if the counter wraps). The cookie is still not sent to
userspace in the dont_wait_for_ack case.

Arend van Spriel (10):
  wifi: cfg80211: pre-assign cookie for remain_on_channel, mgmt_tx,
    probe_peer and tx_control_port
  wifi: mac80211: stop using ieee80211_mgmt_tx_cookie()
  wifi: ath6kl: use pre-assigned cookie for remain_on_channel and
    mgmt_tx
  wifi: wil6210: use pre-assigned cookie for remain_on_channel, mgmt_tx
    and probe_peer
  wifi: brcmfmac: use pre-assigned cookie for remain_on_channel and
    mgmt_tx
  wifi: mwifiex: use pre-assigned cookie for remain_on_channel and
    mgmt_tx
  wifi: wilc1000: use pre-assigned cookie for remain_on_channel and
    mgmt_tx
  wifi: nxpwifi: use pre-assigned cookie for remain_on_channel and
    mgmt_tx
  wifi: qtnfmac: use pre-assigned cookie for mgmt_tx
  wifi: cfg80211: convert cookie output to input parameter

 drivers/net/wireless/ath/ath6kl/cfg80211.c    | 22 ++++++---------
 drivers/net/wireless/ath/ath6kl/core.h        |  5 ++--
 drivers/net/wireless/ath/ath6kl/main.c        |  1 +
 drivers/net/wireless/ath/ath6kl/txrx.c        |  1 +
 drivers/net/wireless/ath/ath6kl/wmi.c         |  2 +-
 drivers/net/wireless/ath/ath6kl/wmi.h         |  1 +
 drivers/net/wireless/ath/wil6210/cfg80211.c   | 12 ++++-----
 drivers/net/wireless/ath/wil6210/p2p.c        |  6 ++---
 drivers/net/wireless/ath/wil6210/wil6210.h    |  4 +--
 .../broadcom/brcm80211/brcmfmac/cfg80211.c    | 12 ++++-----
 .../broadcom/brcm80211/brcmfmac/cfg80211.h    |  2 +-
 .../broadcom/brcm80211/brcmfmac/cyw/core.c    |  8 +++---
 .../broadcom/brcm80211/brcmfmac/p2p.c         | 10 +++----
 .../broadcom/brcm80211/brcmfmac/p2p.h         |  2 +-
 .../net/wireless/marvell/mwifiex/cfg80211.c   | 20 +++++++-------
 .../wireless/microchip/wilc1000/cfg80211.c    | 19 +++++--------
 drivers/net/wireless/nxp/nxpwifi/cfg80211.c   | 20 +++++++-------
 .../net/wireless/quantenna/qtnfmac/cfg80211.c |  4 +--
 include/net/cfg80211.h                        | 18 ++++++++-----
 net/mac80211/cfg.c                            | 18 ++-----------
 net/mac80211/ieee80211_i.h                    |  7 ++---
 net/mac80211/offchannel.c                     | 27 +++++++------------
 net/mac80211/tx.c                             |  4 +--
 net/wireless/core.h                           |  2 +-
 net/wireless/mlme.c                           |  2 +-
 net/wireless/nl80211.c                        | 11 +++++---
 net/wireless/rdev-ops.h                       | 12 ++++-----
 27 files changed, 105 insertions(+), 147 deletions(-)


base-commit: 90883c513ca01e77c56b8d94be7de11420c1dacf
-- 
2.54.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-07-26 22:12 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH -next 01/10] wifi: cfg80211: pre-assign cookie for remain_on_channel, mgmt_tx, probe_peer and tx_control_port Arend van Spriel
2026-07-26 19:37   ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox