wifi: cfg80211/nl80211: Add support to indicate STA MLD setup links removal
[linux-block.git] / include / net / cfg80211.h
CommitLineData
d2912cb1 1/* SPDX-License-Identifier: GPL-2.0-only */
704232c2
JB
2#ifndef __NET_CFG80211_H
3#define __NET_CFG80211_H
d3236553
JB
4/*
5 * 802.11 device and configuration interface
6 *
026331c4 7 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
2740f0cf 8 * Copyright 2013-2014 Intel Mobile Communications GmbH
8585989d 9 * Copyright 2015-2017 Intel Deutschland GmbH
6cf963ed 10 * Copyright (C) 2018-2021, 2023 Intel Corporation
d3236553 11 */
704232c2 12
cc69837f 13#include <linux/ethtool.h>
6f779a66 14#include <uapi/linux/rfkill.h>
d3236553
JB
15#include <linux/netdevice.h>
16#include <linux/debugfs.h>
17#include <linux/list.h>
187f1882 18#include <linux/bug.h>
704232c2
JB
19#include <linux/netlink.h>
20#include <linux/skbuff.h>
55682965 21#include <linux/nl80211.h>
2a519311
JB
22#include <linux/if_ether.h>
23#include <linux/ieee80211.h>
2a0e047e 24#include <linux/net.h>
358ae888 25#include <linux/rfkill.h>
d3236553
JB
26#include <net/regulatory.h>
27
d70e9693
JB
28/**
29 * DOC: Introduction
30 *
31 * cfg80211 is the configuration API for 802.11 devices in Linux. It bridges
32 * userspace and drivers, and offers some utility functionality associated
33 * with 802.11. cfg80211 must, directly or indirectly via mac80211, be used
34 * by all modern wireless drivers in Linux, so that they offer a consistent
35 * API through nl80211. For backward compatibility, cfg80211 also offers
36 * wireless extensions to userspace, but hides them from drivers completely.
37 *
38 * Additionally, cfg80211 contains code to help enforce regulatory spectrum
39 * use restrictions.
40 */
41
42
43/**
44 * DOC: Device registration
45 *
46 * In order for a driver to use cfg80211, it must register the hardware device
47 * with cfg80211. This happens through a number of hardware capability structs
48 * described below.
49 *
50 * The fundamental structure for each device is the 'wiphy', of which each
51 * instance describes a physical wireless device connected to the system. Each
52 * such wiphy can have zero, one, or many virtual interfaces associated with
53 * it, which need to be identified as such by pointing the network interface's
54 * @ieee80211_ptr pointer to a &struct wireless_dev which further describes
55 * the wireless part of the interface, normally this struct is embedded in the
56 * network interface's private data area. Drivers can optionally allow creating
57 * or destroying virtual interfaces on the fly, but without at least one or the
58 * ability to create some the wireless device isn't useful.
59 *
60 * Each wiphy structure contains device capability information, and also has
61 * a pointer to the various operations the driver offers. The definitions and
62 * structures here describe these capabilities in detail.
63 */
64
9f5e8f6e
JB
65struct wiphy;
66
704232c2 67/*
d3236553
JB
68 * wireless hardware capability structures
69 */
70
2ec600d6 71/**
d3236553
JB
72 * enum ieee80211_channel_flags - channel flags
73 *
74 * Channel flags set by the regulatory control code.
75 *
76 * @IEEE80211_CHAN_DISABLED: This channel is disabled.
8fe02e16 77 * @IEEE80211_CHAN_NO_IR: do not initiate radiation, this includes
cd9b52bf 78 * sending probe requests or beaconing.
d3236553 79 * @IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
689da1b3 80 * @IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel
cd9b52bf 81 * is not permitted.
689da1b3 82 * @IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel
cd9b52bf 83 * is not permitted.
03f6b084 84 * @IEEE80211_CHAN_NO_OFDM: OFDM is not allowed on this channel.
c7a6ee27
JB
85 * @IEEE80211_CHAN_NO_80MHZ: If the driver supports 80 MHz on the band,
86 * this flag indicates that an 80 MHz channel cannot use this
87 * channel as the control or any of the secondary channels.
88 * This may be due to the driver or due to regulatory bandwidth
89 * restrictions.
90 * @IEEE80211_CHAN_NO_160MHZ: If the driver supports 160 MHz on the band,
91 * this flag indicates that an 160 MHz channel cannot use this
92 * channel as the control or any of the secondary channels.
93 * This may be due to the driver or due to regulatory bandwidth
94 * restrictions.
570dbde1 95 * @IEEE80211_CHAN_INDOOR_ONLY: see %NL80211_FREQUENCY_ATTR_INDOOR_ONLY
06f207fc 96 * @IEEE80211_CHAN_IR_CONCURRENT: see %NL80211_FREQUENCY_ATTR_IR_CONCURRENT
ea077c1c
RL
97 * @IEEE80211_CHAN_NO_20MHZ: 20 MHz bandwidth is not permitted
98 * on this channel.
99 * @IEEE80211_CHAN_NO_10MHZ: 10 MHz bandwidth is not permitted
100 * on this channel.
1e61d82c 101 * @IEEE80211_CHAN_NO_HE: HE operation is not permitted on this channel.
d65a9770
TP
102 * @IEEE80211_CHAN_1MHZ: 1 MHz bandwidth is permitted
103 * on this channel.
104 * @IEEE80211_CHAN_2MHZ: 2 MHz bandwidth is permitted
105 * on this channel.
106 * @IEEE80211_CHAN_4MHZ: 4 MHz bandwidth is permitted
107 * on this channel.
108 * @IEEE80211_CHAN_8MHZ: 8 MHz bandwidth is permitted
109 * on this channel.
110 * @IEEE80211_CHAN_16MHZ: 16 MHz bandwidth is permitted
111 * on this channel.
3743bec6
JD
112 * @IEEE80211_CHAN_NO_320MHZ: If the driver supports 320 MHz on the band,
113 * this flag indicates that a 320 MHz channel cannot use this
114 * channel as the control or any of the secondary channels.
115 * This may be due to the driver or due to regulatory bandwidth
116 * restrictions.
31846b65 117 * @IEEE80211_CHAN_NO_EHT: EHT operation is not permitted on this channel.
2ec600d6 118 */
d3236553
JB
119enum ieee80211_channel_flags {
120 IEEE80211_CHAN_DISABLED = 1<<0,
8fe02e16
LR
121 IEEE80211_CHAN_NO_IR = 1<<1,
122 /* hole at 1<<2 */
d3236553 123 IEEE80211_CHAN_RADAR = 1<<3,
689da1b3
LR
124 IEEE80211_CHAN_NO_HT40PLUS = 1<<4,
125 IEEE80211_CHAN_NO_HT40MINUS = 1<<5,
03f6b084 126 IEEE80211_CHAN_NO_OFDM = 1<<6,
c7a6ee27
JB
127 IEEE80211_CHAN_NO_80MHZ = 1<<7,
128 IEEE80211_CHAN_NO_160MHZ = 1<<8,
570dbde1 129 IEEE80211_CHAN_INDOOR_ONLY = 1<<9,
06f207fc 130 IEEE80211_CHAN_IR_CONCURRENT = 1<<10,
ea077c1c
RL
131 IEEE80211_CHAN_NO_20MHZ = 1<<11,
132 IEEE80211_CHAN_NO_10MHZ = 1<<12,
1e61d82c 133 IEEE80211_CHAN_NO_HE = 1<<13,
d65a9770
TP
134 IEEE80211_CHAN_1MHZ = 1<<14,
135 IEEE80211_CHAN_2MHZ = 1<<15,
136 IEEE80211_CHAN_4MHZ = 1<<16,
137 IEEE80211_CHAN_8MHZ = 1<<17,
138 IEEE80211_CHAN_16MHZ = 1<<18,
3743bec6 139 IEEE80211_CHAN_NO_320MHZ = 1<<19,
31846b65 140 IEEE80211_CHAN_NO_EHT = 1<<20,
2ec600d6
LCC
141};
142
038659e7 143#define IEEE80211_CHAN_NO_HT40 \
689da1b3 144 (IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS)
038659e7 145
04f39047
SW
146#define IEEE80211_DFS_MIN_CAC_TIME_MS 60000
147#define IEEE80211_DFS_MIN_NOP_TIME_MS (30 * 60 * 1000)
148
d3236553
JB
149/**
150 * struct ieee80211_channel - channel definition
151 *
152 * This structure describes a single channel for use
153 * with cfg80211.
154 *
155 * @center_freq: center frequency in MHz
934f4c7d 156 * @freq_offset: offset from @center_freq, in KHz
d3236553
JB
157 * @hw_value: hardware-specific value for the channel
158 * @flags: channel flags from &enum ieee80211_channel_flags.
159 * @orig_flags: channel flags at registration time, used by regulatory
160 * code to support devices with additional restrictions
161 * @band: band this channel belongs to.
162 * @max_antenna_gain: maximum antenna gain in dBi
163 * @max_power: maximum transmission power (in dBm)
eccc068e 164 * @max_reg_power: maximum regulatory transmission power (in dBm)
d3236553
JB
165 * @beacon_found: helper to regulatory code to indicate when a beacon
166 * has been found on this channel. Use regulatory_hint_found_beacon()
77c2061d 167 * to enable this, this is useful only on 5 GHz band.
d3236553
JB
168 * @orig_mag: internal use
169 * @orig_mpwr: internal use
04f39047
SW
170 * @dfs_state: current state of this channel. Only relevant if radar is required
171 * on this channel.
172 * @dfs_state_entered: timestamp (jiffies) when the dfs state was entered.
089027e5 173 * @dfs_cac_ms: DFS CAC time in milliseconds, this is valid for DFS channels.
179f831b 174 */
d3236553 175struct ieee80211_channel {
57fbcce3 176 enum nl80211_band band;
9cf0a0b4 177 u32 center_freq;
934f4c7d 178 u16 freq_offset;
d3236553
JB
179 u16 hw_value;
180 u32 flags;
181 int max_antenna_gain;
182 int max_power;
eccc068e 183 int max_reg_power;
d3236553
JB
184 bool beacon_found;
185 u32 orig_flags;
186 int orig_mag, orig_mpwr;
04f39047
SW
187 enum nl80211_dfs_state dfs_state;
188 unsigned long dfs_state_entered;
089027e5 189 unsigned int dfs_cac_ms;
d3236553
JB
190};
191
179f831b 192/**
d3236553
JB
193 * enum ieee80211_rate_flags - rate flags
194 *
195 * Hardware/specification flags for rates. These are structured
196 * in a way that allows using the same bitrate structure for
197 * different bands/PHY modes.
198 *
199 * @IEEE80211_RATE_SHORT_PREAMBLE: Hardware can send with short
200 * preamble on this bitrate; only relevant in 2.4GHz band and
201 * with CCK rates.
202 * @IEEE80211_RATE_MANDATORY_A: This bitrate is a mandatory rate
203 * when used with 802.11a (on the 5 GHz band); filled by the
204 * core code when registering the wiphy.
205 * @IEEE80211_RATE_MANDATORY_B: This bitrate is a mandatory rate
206 * when used with 802.11b (on the 2.4 GHz band); filled by the
207 * core code when registering the wiphy.
208 * @IEEE80211_RATE_MANDATORY_G: This bitrate is a mandatory rate
209 * when used with 802.11g (on the 2.4 GHz band); filled by the
210 * core code when registering the wiphy.
211 * @IEEE80211_RATE_ERP_G: This is an ERP rate in 802.11g mode.
30e74732
SW
212 * @IEEE80211_RATE_SUPPORTS_5MHZ: Rate can be used in 5 MHz mode
213 * @IEEE80211_RATE_SUPPORTS_10MHZ: Rate can be used in 10 MHz mode
179f831b 214 */
d3236553
JB
215enum ieee80211_rate_flags {
216 IEEE80211_RATE_SHORT_PREAMBLE = 1<<0,
217 IEEE80211_RATE_MANDATORY_A = 1<<1,
218 IEEE80211_RATE_MANDATORY_B = 1<<2,
219 IEEE80211_RATE_MANDATORY_G = 1<<3,
220 IEEE80211_RATE_ERP_G = 1<<4,
30e74732
SW
221 IEEE80211_RATE_SUPPORTS_5MHZ = 1<<5,
222 IEEE80211_RATE_SUPPORTS_10MHZ = 1<<6,
d3236553 223};
179f831b 224
6eb18137
DL
225/**
226 * enum ieee80211_bss_type - BSS type filter
227 *
228 * @IEEE80211_BSS_TYPE_ESS: Infrastructure BSS
229 * @IEEE80211_BSS_TYPE_PBSS: Personal BSS
230 * @IEEE80211_BSS_TYPE_IBSS: Independent BSS
231 * @IEEE80211_BSS_TYPE_MBSS: Mesh BSS
232 * @IEEE80211_BSS_TYPE_ANY: Wildcard value for matching any BSS type
233 */
234enum ieee80211_bss_type {
235 IEEE80211_BSS_TYPE_ESS,
236 IEEE80211_BSS_TYPE_PBSS,
237 IEEE80211_BSS_TYPE_IBSS,
238 IEEE80211_BSS_TYPE_MBSS,
239 IEEE80211_BSS_TYPE_ANY
240};
241
242/**
243 * enum ieee80211_privacy - BSS privacy filter
244 *
245 * @IEEE80211_PRIVACY_ON: privacy bit set
246 * @IEEE80211_PRIVACY_OFF: privacy bit clear
247 * @IEEE80211_PRIVACY_ANY: Wildcard value for matching any privacy setting
248 */
249enum ieee80211_privacy {
250 IEEE80211_PRIVACY_ON,
251 IEEE80211_PRIVACY_OFF,
252 IEEE80211_PRIVACY_ANY
253};
254
255#define IEEE80211_PRIVACY(x) \
256 ((x) ? IEEE80211_PRIVACY_ON : IEEE80211_PRIVACY_OFF)
257
d3236553
JB
258/**
259 * struct ieee80211_rate - bitrate definition
260 *
261 * This structure describes a bitrate that an 802.11 PHY can
262 * operate with. The two values @hw_value and @hw_value_short
263 * are only for driver use when pointers to this structure are
264 * passed around.
265 *
266 * @flags: rate-specific flags
267 * @bitrate: bitrate in units of 100 Kbps
268 * @hw_value: driver/hardware value for this rate
269 * @hw_value_short: driver/hardware value for this rate when
270 * short preamble is used
271 */
272struct ieee80211_rate {
273 u32 flags;
274 u16 bitrate;
275 u16 hw_value, hw_value_short;
276};
179f831b 277
796e90f4
JC
278/**
279 * struct ieee80211_he_obss_pd - AP settings for spatial reuse
280 *
281 * @enable: is the feature enabled.
f5bec330
RM
282 * @sr_ctrl: The SR Control field of SRP element.
283 * @non_srg_max_offset: non-SRG maximum tx power offset
796e90f4
JC
284 * @min_offset: minimal tx power offset an associated station shall use
285 * @max_offset: maximum tx power offset an associated station shall use
f5bec330
RM
286 * @bss_color_bitmap: bitmap that indicates the BSS color values used by
287 * members of the SRG
288 * @partial_bssid_bitmap: bitmap that indicates the partial BSSID values
289 * used by members of the SRG
796e90f4
JC
290 */
291struct ieee80211_he_obss_pd {
292 bool enable;
f5bec330
RM
293 u8 sr_ctrl;
294 u8 non_srg_max_offset;
796e90f4
JC
295 u8 min_offset;
296 u8 max_offset;
f5bec330
RM
297 u8 bss_color_bitmap[8];
298 u8 partial_bssid_bitmap[8];
796e90f4
JC
299};
300
5c5e52d1
JC
301/**
302 * struct cfg80211_he_bss_color - AP settings for BSS coloring
303 *
304 * @color: the current color.
75e6b594 305 * @enabled: HE BSS color is used
5c5e52d1
JC
306 * @partial: define the AID equation.
307 */
308struct cfg80211_he_bss_color {
309 u8 color;
75e6b594 310 bool enabled;
5c5e52d1
JC
311 bool partial;
312};
313
d3236553
JB
314/**
315 * struct ieee80211_sta_ht_cap - STA's HT capabilities
316 *
317 * This structure describes most essential parameters needed
318 * to describe 802.11n HT capabilities for an STA.
319 *
320 * @ht_supported: is HT supported by the STA
321 * @cap: HT capabilities map as described in 802.11n spec
322 * @ampdu_factor: Maximum A-MPDU length factor
323 * @ampdu_density: Minimum A-MPDU spacing
324 * @mcs: Supported MCS rates
325 */
326struct ieee80211_sta_ht_cap {
327 u16 cap; /* use IEEE80211_HT_CAP_ */
328 bool ht_supported;
329 u8 ampdu_factor;
330 u8 ampdu_density;
331 struct ieee80211_mcs_info mcs;
179f831b
AG
332};
333
bf0c111e
MP
334/**
335 * struct ieee80211_sta_vht_cap - STA's VHT capabilities
336 *
337 * This structure describes most essential parameters needed
338 * to describe 802.11ac VHT capabilities for an STA.
339 *
340 * @vht_supported: is VHT supported by the STA
341 * @cap: VHT capabilities map as described in 802.11ac spec
342 * @vht_mcs: Supported VHT MCS rates
343 */
344struct ieee80211_sta_vht_cap {
345 bool vht_supported;
346 u32 cap; /* use IEEE80211_VHT_CAP_ */
347 struct ieee80211_vht_mcs_info vht_mcs;
348};
349
c4cbaf79
LC
350#define IEEE80211_HE_PPE_THRES_MAX_LEN 25
351
352/**
353 * struct ieee80211_sta_he_cap - STA's HE capabilities
354 *
355 * This structure describes most essential parameters needed
356 * to describe 802.11ax HE capabilities for a STA.
357 *
358 * @has_he: true iff HE data is valid.
359 * @he_cap_elem: Fixed portion of the HE capabilities element.
360 * @he_mcs_nss_supp: The supported NSS/MCS combinations.
361 * @ppe_thres: Holds the PPE Thresholds data.
362 */
363struct ieee80211_sta_he_cap {
364 bool has_he;
365 struct ieee80211_he_cap_elem he_cap_elem;
366 struct ieee80211_he_mcs_nss_supp he_mcs_nss_supp;
367 u8 ppe_thres[IEEE80211_HE_PPE_THRES_MAX_LEN];
368};
369
5cd5a8a3
IP
370/**
371 * struct ieee80211_eht_mcs_nss_supp - EHT max supported NSS per MCS
372 *
373 * See P802.11be_D1.3 Table 9-401k - "Subfields of the Supported EHT-MCS
374 * and NSS Set field"
375 *
376 * @only_20mhz: MCS/NSS support for 20 MHz-only STA.
2d8b08fe 377 * @bw: MCS/NSS support for 80, 160 and 320 MHz
5cd5a8a3
IP
378 * @bw._80: MCS/NSS support for BW <= 80 MHz
379 * @bw._160: MCS/NSS support for BW = 160 MHz
380 * @bw._320: MCS/NSS support for BW = 320 MHz
381 */
382struct ieee80211_eht_mcs_nss_supp {
383 union {
384 struct ieee80211_eht_mcs_nss_supp_20mhz_only only_20mhz;
385 struct {
386 struct ieee80211_eht_mcs_nss_supp_bw _80;
387 struct ieee80211_eht_mcs_nss_supp_bw _160;
388 struct ieee80211_eht_mcs_nss_supp_bw _320;
389 } __packed bw;
390 } __packed;
391} __packed;
392
393#define IEEE80211_EHT_PPE_THRES_MAX_LEN 32
394
395/**
396 * struct ieee80211_sta_eht_cap - STA's EHT capabilities
397 *
398 * This structure describes most essential parameters needed
399 * to describe 802.11be EHT capabilities for a STA.
400 *
401 * @has_eht: true iff EHT data is valid.
402 * @eht_cap_elem: Fixed portion of the eht capabilities element.
403 * @eht_mcs_nss_supp: The supported NSS/MCS combinations.
404 * @eht_ppe_thres: Holds the PPE Thresholds data.
405 */
406struct ieee80211_sta_eht_cap {
407 bool has_eht;
408 struct ieee80211_eht_cap_elem_fixed eht_cap_elem;
409 struct ieee80211_eht_mcs_nss_supp eht_mcs_nss_supp;
410 u8 eht_ppe_thres[IEEE80211_EHT_PPE_THRES_MAX_LEN];
411};
412
c4cbaf79 413/**
5d9c358d 414 * struct ieee80211_sband_iftype_data - sband data per interface type
c4cbaf79
LC
415 *
416 * This structure encapsulates sband data that is relevant for the
417 * interface types defined in @types_mask. Each type in the
418 * @types_mask must be unique across all instances of iftype_data.
419 *
420 * @types_mask: interface types mask
421 * @he_cap: holds the HE capabilities
22395217
JB
422 * @he_6ghz_capa: HE 6 GHz capabilities, must be filled in for a
423 * 6 GHz band channel (and 0 may be valid value).
2d8b08fe 424 * @eht_cap: STA's EHT capabilities
f4f86505
JB
425 * @vendor_elems: vendor element(s) to advertise
426 * @vendor_elems.data: vendor element(s) data
427 * @vendor_elems.len: vendor element(s) length
c4cbaf79
LC
428 */
429struct ieee80211_sband_iftype_data {
430 u16 types_mask;
431 struct ieee80211_sta_he_cap he_cap;
22395217 432 struct ieee80211_he_6ghz_capa he_6ghz_capa;
5cd5a8a3 433 struct ieee80211_sta_eht_cap eht_cap;
f4f86505
JB
434 struct {
435 const u8 *data;
436 unsigned int len;
437 } vendor_elems;
c4cbaf79
LC
438};
439
2a38075c
AAL
440/**
441 * enum ieee80211_edmg_bw_config - allowed channel bandwidth configurations
442 *
443 * @IEEE80211_EDMG_BW_CONFIG_4: 2.16GHz
444 * @IEEE80211_EDMG_BW_CONFIG_5: 2.16GHz and 4.32GHz
445 * @IEEE80211_EDMG_BW_CONFIG_6: 2.16GHz, 4.32GHz and 6.48GHz
446 * @IEEE80211_EDMG_BW_CONFIG_7: 2.16GHz, 4.32GHz, 6.48GHz and 8.64GHz
447 * @IEEE80211_EDMG_BW_CONFIG_8: 2.16GHz and 2.16GHz + 2.16GHz
448 * @IEEE80211_EDMG_BW_CONFIG_9: 2.16GHz, 4.32GHz and 2.16GHz + 2.16GHz
449 * @IEEE80211_EDMG_BW_CONFIG_10: 2.16GHz, 4.32GHz, 6.48GHz and 2.16GHz+2.16GHz
450 * @IEEE80211_EDMG_BW_CONFIG_11: 2.16GHz, 4.32GHz, 6.48GHz, 8.64GHz and
451 * 2.16GHz+2.16GHz
452 * @IEEE80211_EDMG_BW_CONFIG_12: 2.16GHz, 2.16GHz + 2.16GHz and
453 * 4.32GHz + 4.32GHz
454 * @IEEE80211_EDMG_BW_CONFIG_13: 2.16GHz, 4.32GHz, 2.16GHz + 2.16GHz and
455 * 4.32GHz + 4.32GHz
456 * @IEEE80211_EDMG_BW_CONFIG_14: 2.16GHz, 4.32GHz, 6.48GHz, 2.16GHz + 2.16GHz
457 * and 4.32GHz + 4.32GHz
458 * @IEEE80211_EDMG_BW_CONFIG_15: 2.16GHz, 4.32GHz, 6.48GHz, 8.64GHz,
459 * 2.16GHz + 2.16GHz and 4.32GHz + 4.32GHz
460 */
461enum ieee80211_edmg_bw_config {
462 IEEE80211_EDMG_BW_CONFIG_4 = 4,
463 IEEE80211_EDMG_BW_CONFIG_5 = 5,
464 IEEE80211_EDMG_BW_CONFIG_6 = 6,
465 IEEE80211_EDMG_BW_CONFIG_7 = 7,
466 IEEE80211_EDMG_BW_CONFIG_8 = 8,
467 IEEE80211_EDMG_BW_CONFIG_9 = 9,
468 IEEE80211_EDMG_BW_CONFIG_10 = 10,
469 IEEE80211_EDMG_BW_CONFIG_11 = 11,
470 IEEE80211_EDMG_BW_CONFIG_12 = 12,
471 IEEE80211_EDMG_BW_CONFIG_13 = 13,
472 IEEE80211_EDMG_BW_CONFIG_14 = 14,
473 IEEE80211_EDMG_BW_CONFIG_15 = 15,
474};
475
476/**
477 * struct ieee80211_edmg - EDMG configuration
478 *
479 * This structure describes most essential parameters needed
480 * to describe 802.11ay EDMG configuration
481 *
482 * @channels: bitmap that indicates the 2.16 GHz channel(s)
483 * that are allowed to be used for transmissions.
484 * Bit 0 indicates channel 1, bit 1 indicates channel 2, etc.
485 * Set to 0 indicate EDMG not supported.
486 * @bw_config: Channel BW Configuration subfield encodes
487 * the allowed channel bandwidth configurations
488 */
489struct ieee80211_edmg {
490 u8 channels;
491 enum ieee80211_edmg_bw_config bw_config;
492};
493
df78a0c0
TP
494/**
495 * struct ieee80211_sta_s1g_cap - STA's S1G capabilities
496 *
497 * This structure describes most essential parameters needed
498 * to describe 802.11ah S1G capabilities for a STA.
499 *
2d8b08fe 500 * @s1g: is STA an S1G STA
df78a0c0
TP
501 * @cap: S1G capabilities information
502 * @nss_mcs: Supported NSS MCS set
503 */
504struct ieee80211_sta_s1g_cap {
505 bool s1g;
506 u8 cap[10]; /* use S1G_CAPAB_ */
507 u8 nss_mcs[5];
508};
509
d3236553
JB
510/**
511 * struct ieee80211_supported_band - frequency band definition
512 *
513 * This structure describes a frequency band a wiphy
514 * is able to operate in.
515 *
085a6c10 516 * @channels: Array of channels the hardware can operate with
d3236553
JB
517 * in this band.
518 * @band: the band this structure represents
519 * @n_channels: Number of channels in @channels
520 * @bitrates: Array of bitrates the hardware can operate with
521 * in this band. Must be sorted to give a valid "supported
522 * rates" IE, i.e. CCK rates first, then OFDM.
523 * @n_bitrates: Number of bitrates in @bitrates
abe37c4b 524 * @ht_cap: HT capabilities in this band
c9a0a302 525 * @vht_cap: VHT capabilities in this band
8a50c057 526 * @s1g_cap: S1G capabilities in this band
2a38075c 527 * @edmg_cap: EDMG capabilities in this band
9ff167e1 528 * @s1g_cap: S1G capabilities in this band (S1B band only, of course)
c4cbaf79
LC
529 * @n_iftype_data: number of iftype data entries
530 * @iftype_data: interface type data entries. Note that the bits in
531 * @types_mask inside this structure cannot overlap (i.e. only
532 * one occurrence of each type is allowed across all instances of
533 * iftype_data).
d3236553
JB
534 */
535struct ieee80211_supported_band {
536 struct ieee80211_channel *channels;
537 struct ieee80211_rate *bitrates;
57fbcce3 538 enum nl80211_band band;
d3236553
JB
539 int n_channels;
540 int n_bitrates;
541 struct ieee80211_sta_ht_cap ht_cap;
bf0c111e 542 struct ieee80211_sta_vht_cap vht_cap;
df78a0c0 543 struct ieee80211_sta_s1g_cap s1g_cap;
2a38075c 544 struct ieee80211_edmg edmg_cap;
c4cbaf79
LC
545 u16 n_iftype_data;
546 const struct ieee80211_sband_iftype_data *iftype_data;
d3236553 547};
179f831b 548
c4cbaf79
LC
549/**
550 * ieee80211_get_sband_iftype_data - return sband data for a given iftype
551 * @sband: the sband to search for the STA on
552 * @iftype: enum nl80211_iftype
553 *
554 * Return: pointer to struct ieee80211_sband_iftype_data, or NULL is none found
555 */
556static inline const struct ieee80211_sband_iftype_data *
557ieee80211_get_sband_iftype_data(const struct ieee80211_supported_band *sband,
558 u8 iftype)
559{
560 int i;
561
562 if (WARN_ON(iftype >= NL80211_IFTYPE_MAX))
563 return NULL;
564
565 for (i = 0; i < sband->n_iftype_data; i++) {
566 const struct ieee80211_sband_iftype_data *data =
567 &sband->iftype_data[i];
568
569 if (data->types_mask & BIT(iftype))
570 return data;
571 }
572
573 return NULL;
574}
575
576/**
d7edf40c
JC
577 * ieee80211_get_he_iftype_cap - return HE capabilities for an sband's iftype
578 * @sband: the sband to search for the iftype on
579 * @iftype: enum nl80211_iftype
c4cbaf79
LC
580 *
581 * Return: pointer to the struct ieee80211_sta_he_cap, or NULL is none found
582 */
583static inline const struct ieee80211_sta_he_cap *
d7edf40c
JC
584ieee80211_get_he_iftype_cap(const struct ieee80211_supported_band *sband,
585 u8 iftype)
c4cbaf79
LC
586{
587 const struct ieee80211_sband_iftype_data *data =
d7edf40c 588 ieee80211_get_sband_iftype_data(sband, iftype);
c4cbaf79
LC
589
590 if (data && data->he_cap.has_he)
591 return &data->he_cap;
592
593 return NULL;
594}
595
2ad2274c
IP
596/**
597 * ieee80211_get_he_6ghz_capa - return HE 6 GHz capabilities
598 * @sband: the sband to search for the STA on
599 * @iftype: the iftype to search for
600 *
601 * Return: the 6GHz capabilities
602 */
603static inline __le16
604ieee80211_get_he_6ghz_capa(const struct ieee80211_supported_band *sband,
605 enum nl80211_iftype iftype)
606{
607 const struct ieee80211_sband_iftype_data *data =
608 ieee80211_get_sband_iftype_data(sband, iftype);
609
610 if (WARN_ON(!data || !data->he_cap.has_he))
611 return 0;
612
613 return data->he_6ghz_capa.capa;
614}
615
5cd5a8a3
IP
616/**
617 * ieee80211_get_eht_iftype_cap - return ETH capabilities for an sband's iftype
618 * @sband: the sband to search for the iftype on
619 * @iftype: enum nl80211_iftype
620 *
621 * Return: pointer to the struct ieee80211_sta_eht_cap, or NULL is none found
622 */
623static inline const struct ieee80211_sta_eht_cap *
624ieee80211_get_eht_iftype_cap(const struct ieee80211_supported_band *sband,
625 enum nl80211_iftype iftype)
626{
627 const struct ieee80211_sband_iftype_data *data =
628 ieee80211_get_sband_iftype_data(sband, iftype);
629
630 if (data && data->eht_cap.has_eht)
631 return &data->eht_cap;
632
633 return NULL;
634}
635
e691ac2f
RM
636/**
637 * wiphy_read_of_freq_limits - read frequency limits from device tree
638 *
639 * @wiphy: the wireless device to get extra limits for
640 *
641 * Some devices may have extra limitations specified in DT. This may be useful
642 * for chipsets that normally support more bands but are limited due to board
643 * design (e.g. by antennas or external power amplifier).
644 *
645 * This function reads info from DT and uses it to *modify* channels (disable
646 * unavailable ones). It's usually a *bad* idea to use it in drivers with
647 * shared channel data as DT limitations are device specific. You should make
648 * sure to call it only if channels in wiphy are copied and can be modified
649 * without affecting other devices.
650 *
651 * As this function access device node it has to be called after set_wiphy_dev.
652 * It also modifies channels so they have to be set first.
653 * If using this helper, call it before wiphy_register().
654 */
655#ifdef CONFIG_OF
656void wiphy_read_of_freq_limits(struct wiphy *wiphy);
657#else /* CONFIG_OF */
658static inline void wiphy_read_of_freq_limits(struct wiphy *wiphy)
659{
660}
661#endif /* !CONFIG_OF */
662
663
d3236553
JB
664/*
665 * Wireless hardware/device configuration structures and methods
666 */
179f831b 667
d70e9693
JB
668/**
669 * DOC: Actions and configuration
670 *
671 * Each wireless device and each virtual interface offer a set of configuration
672 * operations and other actions that are invoked by userspace. Each of these
673 * actions is described in the operations structure, and the parameters these
674 * operations use are described separately.
675 *
676 * Additionally, some operations are asynchronous and expect to get status
677 * information via some functions that drivers need to call.
678 *
679 * Scanning and BSS list handling with its associated functionality is described
680 * in a separate chapter.
681 */
682
c6e6a0c8
AE
683#define VHT_MUMIMO_GROUPS_DATA_LEN (WLAN_MEMBERSHIP_LEN +\
684 WLAN_USER_POSITION_LEN)
685
d3236553
JB
686/**
687 * struct vif_params - describes virtual interface parameters
818a986e
JB
688 * @flags: monitor interface flags, unchanged if 0, otherwise
689 * %MONITOR_FLAG_CHANGED will be set
8b787643 690 * @use_4addr: use 4-address frames
e8f479b1
BG
691 * @macaddr: address to use for this virtual interface.
692 * If this parameter is set to zero address the driver may
693 * determine the address as needed.
694 * This feature is only fully supported by drivers that enable the
695 * %NL80211_FEATURE_MAC_ON_CREATE flag. Others may support creating
696 ** only p2p devices with specified MAC.
b0265024
JB
697 * @vht_mumimo_groups: MU-MIMO groupID, used for monitoring MU-MIMO packets
698 * belonging to that MU-MIMO groupID; %NULL if not changed
699 * @vht_mumimo_follow_addr: MU-MIMO follow address, used for monitoring
700 * MU-MIMO packets going to the specified station; %NULL if not changed
d3236553
JB
701 */
702struct vif_params {
818a986e 703 u32 flags;
c6e6a0c8
AE
704 int use_4addr;
705 u8 macaddr[ETH_ALEN];
b0265024
JB
706 const u8 *vht_mumimo_groups;
707 const u8 *vht_mumimo_follow_addr;
d3236553 708};
179f831b 709
d3236553 710/**
41ade00f
JB
711 * struct key_params - key information
712 *
713 * Information about a key
714 *
715 * @key: key material
716 * @key_len: length of key material
717 * @cipher: cipher suite selector
718 * @seq: sequence counter (IV/PN) for TKIP and CCMP keys, only used
719 * with the get_key() callback, must be in little endian,
720 * length given by @seq_len.
abe37c4b 721 * @seq_len: length of @seq.
14f34e36 722 * @vlan_id: vlan_id for VLAN group key (if nonzero)
6cdd3979 723 * @mode: key install mode (RX_TX, NO_TX or SET_TX)
41ade00f
JB
724 */
725struct key_params {
c1e5f471
JB
726 const u8 *key;
727 const u8 *seq;
41ade00f
JB
728 int key_len;
729 int seq_len;
14f34e36 730 u16 vlan_id;
41ade00f 731 u32 cipher;
6cdd3979 732 enum nl80211_key_mode mode;
41ade00f
JB
733};
734
683b6d3b
JB
735/**
736 * struct cfg80211_chan_def - channel definition
737 * @chan: the (control) channel
3d9d1d66
JB
738 * @width: channel width
739 * @center_freq1: center frequency of first segment
740 * @center_freq2: center frequency of second segment
741 * (only with 80+80 MHz)
2a38075c
AAL
742 * @edmg: define the EDMG channels configuration.
743 * If edmg is requested (i.e. the .channels member is non-zero),
744 * chan will define the primary channel and all other
745 * parameters are ignored.
934f4c7d 746 * @freq1_offset: offset from @center_freq1, in KHz
683b6d3b
JB
747 */
748struct cfg80211_chan_def {
749 struct ieee80211_channel *chan;
3d9d1d66
JB
750 enum nl80211_chan_width width;
751 u32 center_freq1;
752 u32 center_freq2;
2a38075c 753 struct ieee80211_edmg edmg;
934f4c7d 754 u16 freq1_offset;
683b6d3b
JB
755};
756
9a5f6488
TC
757/*
758 * cfg80211_bitrate_mask - masks for bitrate control
759 */
760struct cfg80211_bitrate_mask {
761 struct {
762 u32 legacy;
763 u8 ht_mcs[IEEE80211_HT_MCS_MASK_LEN];
764 u16 vht_mcs[NL80211_VHT_NSS_MAX];
eb89a6a6 765 u16 he_mcs[NL80211_HE_NSS_MAX];
9a5f6488 766 enum nl80211_txrate_gi gi;
eb89a6a6
MH
767 enum nl80211_he_gi he_gi;
768 enum nl80211_he_ltf he_ltf;
9a5f6488
TC
769 } control[NUM_NL80211_BANDS];
770};
771
772
77f576de 773/**
3710a8a6 774 * struct cfg80211_tid_cfg - TID specific configuration
77f576de
T
775 * @config_override: Flag to notify driver to reset TID configuration
776 * of the peer.
3710a8a6
JB
777 * @tids: bitmap of TIDs to modify
778 * @mask: bitmap of attributes indicating which parameter changed,
779 * similar to &nl80211_tid_config_supp.
77f576de 780 * @noack: noack configuration value for the TID
6a21d16c
T
781 * @retry_long: retry count value
782 * @retry_short: retry count value
33462e68 783 * @ampdu: Enable/Disable MPDU aggregation
04f7d142 784 * @rtscts: Enable/Disable RTS/CTS
33462e68 785 * @amsdu: Enable/Disable MSDU aggregation
9a5f6488
TC
786 * @txrate_type: Tx bitrate mask type
787 * @txrate_mask: Tx bitrate to be applied for the TID
77f576de 788 */
3710a8a6 789struct cfg80211_tid_cfg {
77f576de 790 bool config_override;
3710a8a6 791 u8 tids;
2d5d9b7f 792 u64 mask;
77f576de 793 enum nl80211_tid_config noack;
6a21d16c 794 u8 retry_long, retry_short;
ade274b2 795 enum nl80211_tid_config ampdu;
04f7d142 796 enum nl80211_tid_config rtscts;
33462e68 797 enum nl80211_tid_config amsdu;
9a5f6488
TC
798 enum nl80211_tx_rate_setting txrate_type;
799 struct cfg80211_bitrate_mask txrate_mask;
77f576de
T
800};
801
802/**
3710a8a6 803 * struct cfg80211_tid_config - TID configuration
77f576de
T
804 * @peer: Station's MAC address
805 * @n_tid_conf: Number of TID specific configurations to be applied
806 * @tid_conf: Configuration change info
807 */
3710a8a6 808struct cfg80211_tid_config {
77f576de
T
809 const u8 *peer;
810 u32 n_tid_conf;
3710a8a6 811 struct cfg80211_tid_cfg tid_conf[];
77f576de
T
812};
813
e306784a
SM
814/**
815 * struct cfg80211_fils_aad - FILS AAD data
816 * @macaddr: STA MAC address
817 * @kek: FILS KEK
818 * @kek_len: FILS KEK length
819 * @snonce: STA Nonce
820 * @anonce: AP Nonce
821 */
822struct cfg80211_fils_aad {
823 const u8 *macaddr;
824 const u8 *kek;
825 u8 kek_len;
826 const u8 *snonce;
827 const u8 *anonce;
828};
829
cbbaf2bb
AS
830/**
831 * struct cfg80211_set_hw_timestamp - enable/disable HW timestamping
832 * @macaddr: peer MAC address. NULL to enable/disable HW timestamping for all
833 * addresses.
834 * @enable: if set, enable HW timestamping for the specified MAC address.
835 * Otherwise disable HW timestamping for the specified MAC address.
836 */
837struct cfg80211_set_hw_timestamp {
838 const u8 *macaddr;
839 bool enable;
840};
841
3d9d1d66
JB
842/**
843 * cfg80211_get_chandef_type - return old channel type from chandef
844 * @chandef: the channel definition
845 *
0ae997dc 846 * Return: The old channel type (NOHT, HT20, HT40+/-) from a given
3d9d1d66
JB
847 * chandef, which must have a bandwidth allowing this conversion.
848 */
683b6d3b
JB
849static inline enum nl80211_channel_type
850cfg80211_get_chandef_type(const struct cfg80211_chan_def *chandef)
851{
3d9d1d66
JB
852 switch (chandef->width) {
853 case NL80211_CHAN_WIDTH_20_NOHT:
854 return NL80211_CHAN_NO_HT;
855 case NL80211_CHAN_WIDTH_20:
856 return NL80211_CHAN_HT20;
857 case NL80211_CHAN_WIDTH_40:
858 if (chandef->center_freq1 > chandef->chan->center_freq)
859 return NL80211_CHAN_HT40PLUS;
860 return NL80211_CHAN_HT40MINUS;
861 default:
862 WARN_ON(1);
863 return NL80211_CHAN_NO_HT;
864 }
683b6d3b
JB
865}
866
3d9d1d66
JB
867/**
868 * cfg80211_chandef_create - create channel definition using channel type
869 * @chandef: the channel definition struct to fill
870 * @channel: the control channel
871 * @chantype: the channel type
872 *
873 * Given a channel type, create a channel definition.
874 */
875void cfg80211_chandef_create(struct cfg80211_chan_def *chandef,
876 struct ieee80211_channel *channel,
877 enum nl80211_channel_type chantype);
878
879/**
880 * cfg80211_chandef_identical - check if two channel definitions are identical
881 * @chandef1: first channel definition
882 * @chandef2: second channel definition
883 *
0ae997dc 884 * Return: %true if the channels defined by the channel definitions are
3d9d1d66
JB
885 * identical, %false otherwise.
886 */
887static inline bool
888cfg80211_chandef_identical(const struct cfg80211_chan_def *chandef1,
889 const struct cfg80211_chan_def *chandef2)
890{
891 return (chandef1->chan == chandef2->chan &&
892 chandef1->width == chandef2->width &&
893 chandef1->center_freq1 == chandef2->center_freq1 &&
934f4c7d 894 chandef1->freq1_offset == chandef2->freq1_offset &&
3d9d1d66
JB
895 chandef1->center_freq2 == chandef2->center_freq2);
896}
897
2a38075c
AAL
898/**
899 * cfg80211_chandef_is_edmg - check if chandef represents an EDMG channel
900 *
901 * @chandef: the channel definition
902 *
903 * Return: %true if EDMG defined, %false otherwise.
904 */
905static inline bool
906cfg80211_chandef_is_edmg(const struct cfg80211_chan_def *chandef)
907{
908 return chandef->edmg.channels || chandef->edmg.bw_config;
909}
910
3d9d1d66
JB
911/**
912 * cfg80211_chandef_compatible - check if two channel definitions are compatible
913 * @chandef1: first channel definition
914 * @chandef2: second channel definition
915 *
0ae997dc 916 * Return: %NULL if the given channel definitions are incompatible,
3d9d1d66
JB
917 * chandef1 or chandef2 otherwise.
918 */
919const struct cfg80211_chan_def *
920cfg80211_chandef_compatible(const struct cfg80211_chan_def *chandef1,
921 const struct cfg80211_chan_def *chandef2);
922
9f5e8f6e
JB
923/**
924 * cfg80211_chandef_valid - check if a channel definition is valid
925 * @chandef: the channel definition to check
0ae997dc 926 * Return: %true if the channel definition is valid. %false otherwise.
9f5e8f6e
JB
927 */
928bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef);
929
930/**
931 * cfg80211_chandef_usable - check if secondary channels can be used
932 * @wiphy: the wiphy to validate against
933 * @chandef: the channel definition to check
0ae997dc
YB
934 * @prohibited_flags: the regulatory channel flags that must not be set
935 * Return: %true if secondary channels are usable. %false otherwise.
9f5e8f6e
JB
936 */
937bool cfg80211_chandef_usable(struct wiphy *wiphy,
938 const struct cfg80211_chan_def *chandef,
939 u32 prohibited_flags);
940
774f0734
SW
941/**
942 * cfg80211_chandef_dfs_required - checks if radar detection is required
943 * @wiphy: the wiphy to validate against
944 * @chandef: the channel definition to check
2beb6dab
LC
945 * @iftype: the interface type as specified in &enum nl80211_iftype
946 * Returns:
947 * 1 if radar detection is required, 0 if it is not, < 0 on error
774f0734
SW
948 */
949int cfg80211_chandef_dfs_required(struct wiphy *wiphy,
2beb6dab 950 const struct cfg80211_chan_def *chandef,
c3d62036 951 enum nl80211_iftype iftype);
774f0734 952
5097f844
JK
953/**
954 * nl80211_send_chandef - sends the channel definition.
955 * @msg: the msg to send channel definition
956 * @chandef: the channel definition to check
957 *
958 * Returns: 0 if sent the channel definition to msg, < 0 on error
959 **/
960int nl80211_send_chandef(struct sk_buff *msg, const struct cfg80211_chan_def *chandef);
961
30e74732 962/**
19654a61
JB
963 * ieee80211_chanwidth_rate_flags - return rate flags for channel width
964 * @width: the channel width of the channel
30e74732
SW
965 *
966 * In some channel types, not all rates may be used - for example CCK
967 * rates may not be used in 5/10 MHz channels.
968 *
19654a61 969 * Returns: rate flags which apply for this channel width
30e74732
SW
970 */
971static inline enum ieee80211_rate_flags
19654a61 972ieee80211_chanwidth_rate_flags(enum nl80211_chan_width width)
30e74732 973{
19654a61 974 switch (width) {
30e74732
SW
975 case NL80211_CHAN_WIDTH_5:
976 return IEEE80211_RATE_SUPPORTS_5MHZ;
977 case NL80211_CHAN_WIDTH_10:
978 return IEEE80211_RATE_SUPPORTS_10MHZ;
979 default:
980 break;
981 }
982 return 0;
983}
984
19654a61
JB
985/**
986 * ieee80211_chandef_rate_flags - returns rate flags for a channel
987 * @chandef: channel definition for the channel
988 *
989 * See ieee80211_chanwidth_rate_flags().
990 *
991 * Returns: rate flags which apply for this channel
992 */
993static inline enum ieee80211_rate_flags
994ieee80211_chandef_rate_flags(struct cfg80211_chan_def *chandef)
995{
996 return ieee80211_chanwidth_rate_flags(chandef->width);
997}
998
0430c883
SW
999/**
1000 * ieee80211_chandef_max_power - maximum transmission power for the chandef
1001 *
1002 * In some regulations, the transmit power may depend on the configured channel
1003 * bandwidth which may be defined as dBm/MHz. This function returns the actual
1004 * max_power for non-standard (20 MHz) channels.
1005 *
1006 * @chandef: channel definition for the channel
1007 *
1008 * Returns: maximum allowed transmission power in dBm for the chandef
1009 */
1010static inline int
1011ieee80211_chandef_max_power(struct cfg80211_chan_def *chandef)
1012{
1013 switch (chandef->width) {
1014 case NL80211_CHAN_WIDTH_5:
1015 return min(chandef->chan->max_reg_power - 6,
1016 chandef->chan->max_power);
1017 case NL80211_CHAN_WIDTH_10:
1018 return min(chandef->chan->max_reg_power - 3,
1019 chandef->chan->max_power);
1020 default:
1021 break;
1022 }
1023 return chandef->chan->max_power;
1024}
1025
be989891
JB
1026/**
1027 * cfg80211_any_usable_channels - check for usable channels
1028 * @wiphy: the wiphy to check for
1029 * @band_mask: which bands to check on
1030 * @prohibited_flags: which channels to not consider usable,
1031 * %IEEE80211_CHAN_DISABLED is always taken into account
1032 */
1033bool cfg80211_any_usable_channels(struct wiphy *wiphy,
1034 unsigned long band_mask,
1035 u32 prohibited_flags);
1036
61fa713c
HS
1037/**
1038 * enum survey_info_flags - survey information flags
1039 *
abe37c4b 1040 * @SURVEY_INFO_NOISE_DBM: noise (in dBm) was filled in
17e5a808 1041 * @SURVEY_INFO_IN_USE: channel is currently being used
4ed20beb
JB
1042 * @SURVEY_INFO_TIME: active time (in ms) was filled in
1043 * @SURVEY_INFO_TIME_BUSY: busy time was filled in
1044 * @SURVEY_INFO_TIME_EXT_BUSY: extension channel busy time was filled in
1045 * @SURVEY_INFO_TIME_RX: receive time was filled in
1046 * @SURVEY_INFO_TIME_TX: transmit time was filled in
052536ab 1047 * @SURVEY_INFO_TIME_SCAN: scan time was filled in
c8cd6e7f 1048 * @SURVEY_INFO_TIME_BSS_RX: local BSS receive time was filled in
abe37c4b 1049 *
61fa713c
HS
1050 * Used by the driver to indicate which info in &struct survey_info
1051 * it has filled in during the get_survey().
1052 */
1053enum survey_info_flags {
4ed20beb
JB
1054 SURVEY_INFO_NOISE_DBM = BIT(0),
1055 SURVEY_INFO_IN_USE = BIT(1),
1056 SURVEY_INFO_TIME = BIT(2),
1057 SURVEY_INFO_TIME_BUSY = BIT(3),
1058 SURVEY_INFO_TIME_EXT_BUSY = BIT(4),
1059 SURVEY_INFO_TIME_RX = BIT(5),
1060 SURVEY_INFO_TIME_TX = BIT(6),
052536ab 1061 SURVEY_INFO_TIME_SCAN = BIT(7),
c8cd6e7f 1062 SURVEY_INFO_TIME_BSS_RX = BIT(8),
61fa713c
HS
1063};
1064
1065/**
1066 * struct survey_info - channel survey response
1067 *
11f78ac3
JB
1068 * @channel: the channel this survey record reports, may be %NULL for a single
1069 * record to report global statistics
61fa713c
HS
1070 * @filled: bitflag of flags from &enum survey_info_flags
1071 * @noise: channel noise in dBm. This and all following fields are
ad24b0da 1072 * optional
4ed20beb
JB
1073 * @time: amount of time in ms the radio was turn on (on the channel)
1074 * @time_busy: amount of time the primary channel was sensed busy
1075 * @time_ext_busy: amount of time the extension channel was sensed busy
1076 * @time_rx: amount of time the radio spent receiving data
1077 * @time_tx: amount of time the radio spent transmitting data
052536ab 1078 * @time_scan: amount of time the radio spent for scanning
c8cd6e7f 1079 * @time_bss_rx: amount of time the radio spent receiving data on a local BSS
61fa713c 1080 *
abe37c4b
JB
1081 * Used by dump_survey() to report back per-channel survey information.
1082 *
61fa713c
HS
1083 * This structure can later be expanded with things like
1084 * channel duty cycle etc.
1085 */
1086struct survey_info {
1087 struct ieee80211_channel *channel;
4ed20beb
JB
1088 u64 time;
1089 u64 time_busy;
1090 u64 time_ext_busy;
1091 u64 time_rx;
1092 u64 time_tx;
052536ab 1093 u64 time_scan;
c8cd6e7f 1094 u64 time_bss_rx;
61fa713c
HS
1095 u32 filled;
1096 s8 noise;
1097};
1098
ecad3b0b 1099#define CFG80211_MAX_NUM_AKM_SUITES 10
b8676221 1100
5fb628e9
JM
1101/**
1102 * struct cfg80211_crypto_settings - Crypto settings
1103 * @wpa_versions: indicates which, if any, WPA versions are enabled
1104 * (from enum nl80211_wpa_versions)
1105 * @cipher_group: group key cipher suite (or 0 if unset)
1106 * @n_ciphers_pairwise: number of AP supported unicast ciphers
1107 * @ciphers_pairwise: unicast key cipher suites
1108 * @n_akm_suites: number of AKM suites
1109 * @akm_suites: AKM suites
1110 * @control_port: Whether user space controls IEEE 802.1X port, i.e.,
1111 * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is
1112 * required to assume that the port is unauthorized until authorized by
1113 * user space. Otherwise, port is marked authorized by default.
1114 * @control_port_ethertype: the control port protocol that should be
1115 * allowed through even on unauthorized ports
1116 * @control_port_no_encrypt: TRUE to prevent encryption of control port
1117 * protocol frames.
64bf3d4b
DK
1118 * @control_port_over_nl80211: TRUE if userspace expects to exchange control
1119 * port frames over NL80211 instead of the network interface.
a710d214
LR
1120 * @control_port_no_preauth: disables pre-auth rx over the nl80211 control
1121 * port for mac80211
91b5ab62 1122 * @psk: PSK (for devices supporting 4-way-handshake offload)
26f7044e
CHH
1123 * @sae_pwd: password for SAE authentication (for devices supporting SAE
1124 * offload)
1125 * @sae_pwd_len: length of SAE password (for devices supporting SAE offload)
da1e9dd3
JB
1126 * @sae_pwe: The mechanisms allowed for SAE PWE derivation:
1127 *
1128 * NL80211_SAE_PWE_UNSPECIFIED
1129 * Not-specified, used to indicate userspace did not specify any
1130 * preference. The driver should follow its internal policy in
1131 * such a scenario.
1132 *
1133 * NL80211_SAE_PWE_HUNT_AND_PECK
1134 * Allow hunting-and-pecking loop only
1135 *
1136 * NL80211_SAE_PWE_HASH_TO_ELEMENT
1137 * Allow hash-to-element only
1138 *
1139 * NL80211_SAE_PWE_BOTH
1140 * Allow either hunting-and-pecking loop or hash-to-element
5fb628e9
JM
1141 */
1142struct cfg80211_crypto_settings {
1143 u32 wpa_versions;
1144 u32 cipher_group;
1145 int n_ciphers_pairwise;
1146 u32 ciphers_pairwise[NL80211_MAX_NR_CIPHER_SUITES];
1147 int n_akm_suites;
ecad3b0b 1148 u32 akm_suites[CFG80211_MAX_NUM_AKM_SUITES];
5fb628e9
JM
1149 bool control_port;
1150 __be16 control_port_ethertype;
1151 bool control_port_no_encrypt;
64bf3d4b 1152 bool control_port_over_nl80211;
7f3f96ce 1153 bool control_port_no_preauth;
91b5ab62 1154 const u8 *psk;
26f7044e
CHH
1155 const u8 *sae_pwd;
1156 u8 sae_pwd_len;
9f0ffa41 1157 enum nl80211_sae_pwe_mechanism sae_pwe;
5fb628e9
JM
1158};
1159
dc1e3cb8
JC
1160/**
1161 * struct cfg80211_mbssid_config - AP settings for multi bssid
1162 *
1163 * @tx_wdev: pointer to the transmitted interface in the MBSSID set
1164 * @index: index of this AP in the multi bssid group.
1165 * @ema: set to true if the beacons should be sent out in EMA mode.
1166 */
1167struct cfg80211_mbssid_config {
1168 struct wireless_dev *tx_wdev;
1169 u8 index;
1170 bool ema;
1171};
1172
1173/**
1174 * struct cfg80211_mbssid_elems - Multiple BSSID elements
1175 *
1176 * @cnt: Number of elements in array %elems.
1177 *
1178 * @elem: Array of multiple BSSID element(s) to be added into Beacon frames.
1179 * @elem.data: Data for multiple BSSID elements.
1180 * @elem.len: Length of data.
1181 */
1182struct cfg80211_mbssid_elems {
1183 u8 cnt;
1184 struct {
1185 const u8 *data;
1186 size_t len;
1187 } elem[];
1188};
1189
dbbb27e1
AD
1190/**
1191 * struct cfg80211_rnr_elems - Reduced neighbor report (RNR) elements
1192 *
1193 * @cnt: Number of elements in array %elems.
1194 *
1195 * @elem: Array of RNR element(s) to be added into Beacon frames.
1196 * @elem.data: Data for RNR elements.
1197 * @elem.len: Length of data.
1198 */
1199struct cfg80211_rnr_elems {
1200 u8 cnt;
1201 struct {
1202 const u8 *data;
1203 size_t len;
1204 } elem[];
1205};
1206
ed1b6cc7 1207/**
8860020e 1208 * struct cfg80211_beacon_data - beacon data
7b0a0e3c 1209 * @link_id: the link ID for the AP MLD link sending this beacon
ed1b6cc7 1210 * @head: head portion of beacon (before TIM IE)
ad24b0da 1211 * or %NULL if not changed
ed1b6cc7 1212 * @tail: tail portion of beacon (after TIM IE)
ad24b0da 1213 * or %NULL if not changed
ed1b6cc7
JB
1214 * @head_len: length of @head
1215 * @tail_len: length of @tail
9946ecfb
JM
1216 * @beacon_ies: extra information element(s) to add into Beacon frames or %NULL
1217 * @beacon_ies_len: length of beacon_ies in octets
1218 * @proberesp_ies: extra information element(s) to add into Probe Response
1219 * frames or %NULL
1220 * @proberesp_ies_len: length of proberesp_ies in octets
1221 * @assocresp_ies: extra information element(s) to add into (Re)Association
1222 * Response frames or %NULL
1223 * @assocresp_ies_len: length of assocresp_ies in octets
00f740e1
AN
1224 * @probe_resp_len: length of probe response template (@probe_resp)
1225 * @probe_resp: probe response template (AP mode only)
dc1e3cb8 1226 * @mbssid_ies: multiple BSSID elements
dbbb27e1 1227 * @rnr_ies: reduced neighbor report elements
81e54d08
PKC
1228 * @ftm_responder: enable FTM responder functionality; -1 for no change
1229 * (which also implies no change in LCI/civic location data)
30db641e
JB
1230 * @lci: Measurement Report element content, starting with Measurement Token
1231 * (measurement type 8)
1232 * @civicloc: Measurement Report element content, starting with Measurement
1233 * Token (measurement type 11)
81e54d08
PKC
1234 * @lci_len: LCI data length
1235 * @civicloc_len: Civic location data length
3d48cb74
RS
1236 * @he_bss_color: BSS Color settings
1237 * @he_bss_color_valid: indicates whether bss color
ee0e2f51 1238 * attribute is present in beacon data or not.
ed1b6cc7 1239 */
8860020e 1240struct cfg80211_beacon_data {
7b0a0e3c
JB
1241 unsigned int link_id;
1242
8860020e
JB
1243 const u8 *head, *tail;
1244 const u8 *beacon_ies;
1245 const u8 *proberesp_ies;
1246 const u8 *assocresp_ies;
1247 const u8 *probe_resp;
81e54d08
PKC
1248 const u8 *lci;
1249 const u8 *civicloc;
dc1e3cb8 1250 struct cfg80211_mbssid_elems *mbssid_ies;
dbbb27e1 1251 struct cfg80211_rnr_elems *rnr_ies;
81e54d08 1252 s8 ftm_responder;
8860020e
JB
1253
1254 size_t head_len, tail_len;
1255 size_t beacon_ies_len;
1256 size_t proberesp_ies_len;
1257 size_t assocresp_ies_len;
1258 size_t probe_resp_len;
81e54d08
PKC
1259 size_t lci_len;
1260 size_t civicloc_len;
3d48cb74
RS
1261 struct cfg80211_he_bss_color he_bss_color;
1262 bool he_bss_color_valid;
8860020e
JB
1263};
1264
6d45a74b
VT
1265struct mac_address {
1266 u8 addr[ETH_ALEN];
1267};
1268
77765eaf
VT
1269/**
1270 * struct cfg80211_acl_data - Access control list data
1271 *
1272 * @acl_policy: ACL policy to be applied on the station's
077f897a 1273 * entry specified by mac_addr
77765eaf
VT
1274 * @n_acl_entries: Number of MAC address entries passed
1275 * @mac_addrs: List of MAC addresses of stations to be used for ACL
1276 */
1277struct cfg80211_acl_data {
1278 enum nl80211_acl_policy acl_policy;
1279 int n_acl_entries;
1280
1281 /* Keep it last */
1282 struct mac_address mac_addrs[];
1283};
1284
291c49de
AD
1285/**
1286 * struct cfg80211_fils_discovery - FILS discovery parameters from
1287 * IEEE Std 802.11ai-2016, Annex C.3 MIB detail.
1288 *
1289 * @min_interval: Minimum packet interval in TUs (0 - 10000)
1290 * @max_interval: Maximum packet interval in TUs (0 - 10000)
1291 * @tmpl_len: Template length
1292 * @tmpl: Template data for FILS discovery frame including the action
1293 * frame headers.
1294 */
1295struct cfg80211_fils_discovery {
1296 u32 min_interval;
1297 u32 max_interval;
1298 size_t tmpl_len;
1299 const u8 *tmpl;
1300};
1301
7443dcd1
AD
1302/**
1303 * struct cfg80211_unsol_bcast_probe_resp - Unsolicited broadcast probe
1304 * response parameters in 6GHz.
1305 *
1306 * @interval: Packet interval in TUs. Maximum allowed is 20 TU, as mentioned
1307 * in IEEE P802.11ax/D6.0 26.17.2.3.2 - AP behavior for fast passive
1308 * scanning
1309 * @tmpl_len: Template length
1310 * @tmpl: Template data for probe response
1311 */
1312struct cfg80211_unsol_bcast_probe_resp {
1313 u32 interval;
1314 size_t tmpl_len;
1315 const u8 *tmpl;
1316};
1317
8860020e
JB
1318/**
1319 * struct cfg80211_ap_settings - AP configuration
1320 *
1321 * Used to configure an AP interface.
1322 *
683b6d3b 1323 * @chandef: defines the channel to use
8860020e
JB
1324 * @beacon: beacon data
1325 * @beacon_interval: beacon interval
1326 * @dtim_period: DTIM period
1327 * @ssid: SSID to be used in the BSS (note: may be %NULL if not provided from
1328 * user space)
1329 * @ssid_len: length of @ssid
1330 * @hidden_ssid: whether to hide the SSID in Beacon/Probe Response frames
1331 * @crypto: crypto settings
1332 * @privacy: the BSS uses privacy
1333 * @auth_type: Authentication type (algorithm)
18998c38 1334 * @smps_mode: SMPS mode
1b658f11 1335 * @inactivity_timeout: time in seconds to determine station's inactivity.
53cabad7
JB
1336 * @p2p_ctwindow: P2P CT Window
1337 * @p2p_opp_ps: P2P opportunistic PS
77765eaf
VT
1338 * @acl: ACL configuration used by the drivers which has support for
1339 * MAC address based access control
34d50519
LD
1340 * @pbss: If set, start as a PCP instead of AP. Relevant for DMG
1341 * networks.
8564e382 1342 * @beacon_rate: bitrate to be used for beacons
66cd794e
JB
1343 * @ht_cap: HT capabilities (or %NULL if HT isn't enabled)
1344 * @vht_cap: VHT capabilities (or %NULL if VHT isn't enabled)
244eb9ae 1345 * @he_cap: HE capabilities (or %NULL if HE isn't enabled)
8bc65d38
AD
1346 * @eht_cap: EHT capabilities (or %NULL if EHT isn't enabled)
1347 * @eht_oper: EHT operation IE (or %NULL if EHT isn't enabled)
66cd794e
JB
1348 * @ht_required: stations must support HT
1349 * @vht_required: stations must support VHT
a0de1ca3 1350 * @twt_responder: Enable Target Wait Time
2a392596 1351 * @he_required: stations must support HE
d6587602 1352 * @sae_h2e_required: stations must support direct H2E technique in SAE
fe494370 1353 * @flags: flags, as defined in enum cfg80211_ap_settings_flags
796e90f4 1354 * @he_obss_pd: OBSS Packet Detection settings
7e8d6f12 1355 * @he_oper: HE operation IE (or %NULL if HE isn't enabled)
291c49de 1356 * @fils_discovery: FILS discovery transmission parameters
7443dcd1 1357 * @unsol_bcast_probe_resp: Unsolicited broadcast probe response parameters
dc1e3cb8 1358 * @mbssid_config: AP settings for multiple bssid
d7c1a9a0
AD
1359 * @punct_bitmap: Preamble puncturing bitmap. Each bit represents
1360 * a 20 MHz channel, lowest bit corresponding to the lowest channel.
1361 * Bit set to 1 indicates that the channel is punctured.
8860020e
JB
1362 */
1363struct cfg80211_ap_settings {
683b6d3b 1364 struct cfg80211_chan_def chandef;
aa430da4 1365
8860020e
JB
1366 struct cfg80211_beacon_data beacon;
1367
1368 int beacon_interval, dtim_period;
32e9de84
JM
1369 const u8 *ssid;
1370 size_t ssid_len;
1371 enum nl80211_hidden_ssid hidden_ssid;
5fb628e9
JM
1372 struct cfg80211_crypto_settings crypto;
1373 bool privacy;
1374 enum nl80211_auth_type auth_type;
18998c38 1375 enum nl80211_smps_mode smps_mode;
1b658f11 1376 int inactivity_timeout;
53cabad7
JB
1377 u8 p2p_ctwindow;
1378 bool p2p_opp_ps;
77765eaf 1379 const struct cfg80211_acl_data *acl;
34d50519 1380 bool pbss;
a7c7fbff 1381 struct cfg80211_bitrate_mask beacon_rate;
66cd794e
JB
1382
1383 const struct ieee80211_ht_cap *ht_cap;
1384 const struct ieee80211_vht_cap *vht_cap;
244eb9ae 1385 const struct ieee80211_he_cap_elem *he_cap;
7e8d6f12 1386 const struct ieee80211_he_operation *he_oper;
8bc65d38
AD
1387 const struct ieee80211_eht_cap_elem *eht_cap;
1388 const struct ieee80211_eht_operation *eht_oper;
d6587602 1389 bool ht_required, vht_required, he_required, sae_h2e_required;
a0de1ca3 1390 bool twt_responder;
fe494370 1391 u32 flags;
796e90f4 1392 struct ieee80211_he_obss_pd he_obss_pd;
291c49de 1393 struct cfg80211_fils_discovery fils_discovery;
7443dcd1 1394 struct cfg80211_unsol_bcast_probe_resp unsol_bcast_probe_resp;
dc1e3cb8 1395 struct cfg80211_mbssid_config mbssid_config;
d7c1a9a0 1396 u16 punct_bitmap;
ed1b6cc7
JB
1397};
1398
16ef1fe2
SW
1399/**
1400 * struct cfg80211_csa_settings - channel switch settings
1401 *
1402 * Used for channel switch
1403 *
1404 * @chandef: defines the channel to use after the switch
1405 * @beacon_csa: beacon data while performing the switch
9a774c78
AO
1406 * @counter_offsets_beacon: offsets of the counters within the beacon (tail)
1407 * @counter_offsets_presp: offsets of the counters within the probe response
1408 * @n_counter_offsets_beacon: number of csa counters the beacon (tail)
1409 * @n_counter_offsets_presp: number of csa counters in the probe response
16ef1fe2
SW
1410 * @beacon_after: beacon data to be used on the new channel
1411 * @radar_required: whether radar detection is required on the new channel
1412 * @block_tx: whether transmissions should be blocked while changing
1413 * @count: number of beacons until switch
d7c1a9a0
AD
1414 * @punct_bitmap: Preamble puncturing bitmap. Each bit represents
1415 * a 20 MHz channel, lowest bit corresponding to the lowest channel.
1416 * Bit set to 1 indicates that the channel is punctured.
16ef1fe2
SW
1417 */
1418struct cfg80211_csa_settings {
1419 struct cfg80211_chan_def chandef;
1420 struct cfg80211_beacon_data beacon_csa;
9a774c78
AO
1421 const u16 *counter_offsets_beacon;
1422 const u16 *counter_offsets_presp;
1423 unsigned int n_counter_offsets_beacon;
1424 unsigned int n_counter_offsets_presp;
16ef1fe2
SW
1425 struct cfg80211_beacon_data beacon_after;
1426 bool radar_required;
1427 bool block_tx;
1428 u8 count;
d7c1a9a0 1429 u16 punct_bitmap;
16ef1fe2
SW
1430};
1431
0d2ab3ae
JC
1432/**
1433 * struct cfg80211_color_change_settings - color change settings
1434 *
1435 * Used for bss color change
1436 *
1437 * @beacon_color_change: beacon data while performing the color countdown
2d8b08fe
MCC
1438 * @counter_offset_beacon: offsets of the counters within the beacon (tail)
1439 * @counter_offset_presp: offsets of the counters within the probe response
0d2ab3ae
JC
1440 * @beacon_next: beacon data to be used after the color change
1441 * @count: number of beacons until the color change
1442 * @color: the color used after the change
1443 */
1444struct cfg80211_color_change_settings {
1445 struct cfg80211_beacon_data beacon_color_change;
1446 u16 counter_offset_beacon;
1447 u16 counter_offset_presp;
1448 struct cfg80211_beacon_data beacon_next;
1449 u8 count;
1450 u8 color;
1451};
1452
e227300c
PK
1453/**
1454 * struct iface_combination_params - input parameters for interface combinations
1455 *
1456 * Used to pass interface combination parameters
1457 *
1458 * @num_different_channels: the number of different channels we want
1459 * to use for verification
1460 * @radar_detect: a bitmap where each bit corresponds to a channel
1461 * width where radar detection is needed, as in the definition of
1462 * &struct ieee80211_iface_combination.@radar_detect_widths
1463 * @iftype_num: array with the number of interfaces of each interface
1464 * type. The index is the interface type as specified in &enum
1465 * nl80211_iftype.
4c8dea63
JB
1466 * @new_beacon_int: set this to the beacon interval of a new interface
1467 * that's not operating yet, if such is to be checked as part of
1468 * the verification
e227300c
PK
1469 */
1470struct iface_combination_params {
1471 int num_different_channels;
1472 u8 radar_detect;
1473 int iftype_num[NUM_NL80211_IFTYPES];
4c8dea63 1474 u32 new_beacon_int;
e227300c
PK
1475};
1476
3b9ce80c
JB
1477/**
1478 * enum station_parameters_apply_mask - station parameter values to apply
1479 * @STATION_PARAM_APPLY_UAPSD: apply new uAPSD parameters (uapsd_queues, max_sp)
9d62a986 1480 * @STATION_PARAM_APPLY_CAPABILITY: apply new capability
f8bacc21 1481 * @STATION_PARAM_APPLY_PLINK_STATE: apply new plink state
2d8b08fe 1482 * @STATION_PARAM_APPLY_STA_TXPOWER: apply tx power for STA
3b9ce80c
JB
1483 *
1484 * Not all station parameters have in-band "no change" signalling,
1485 * for those that don't these flags will are used.
1486 */
1487enum station_parameters_apply_mask {
1488 STATION_PARAM_APPLY_UAPSD = BIT(0),
9d62a986 1489 STATION_PARAM_APPLY_CAPABILITY = BIT(1),
f8bacc21 1490 STATION_PARAM_APPLY_PLINK_STATE = BIT(2),
e96d1cd2
ARN
1491};
1492
1493/**
1494 * struct sta_txpwr - station txpower configuration
1495 *
1496 * Used to configure txpower for station.
1497 *
1498 * @power: tx power (in dBm) to be used for sending data traffic. If tx power
1499 * is not provided, the default per-interface tx power setting will be
1500 * overriding. Driver should be picking up the lowest tx power, either tx
1501 * power per-interface or per-station.
1502 * @type: In particular if TPC %type is NL80211_TX_POWER_LIMITED then tx power
1503 * will be less than or equal to specified from userspace, whereas if TPC
1504 * %type is NL80211_TX_POWER_AUTOMATIC then it indicates default tx power.
1505 * NL80211_TX_POWER_FIXED is not a valid configuration option for
1506 * per peer TPC.
1507 */
1508struct sta_txpwr {
1509 s16 power;
1510 enum nl80211_tx_power_setting type;
3b9ce80c
JB
1511};
1512
577e5b8c
ST
1513/**
1514 * struct link_station_parameters - link station parameters
1515 *
1516 * Used to change and create a new link station.
1517 *
1518 * @mld_mac: MAC address of the station
1519 * @link_id: the link id (-1 for non-MLD station)
1520 * @link_mac: MAC address of the link
1521 * @supported_rates: supported rates in IEEE 802.11 format
1522 * (or NULL for no change)
1523 * @supported_rates_len: number of supported rates
1524 * @ht_capa: HT capabilities of station
1525 * @vht_capa: VHT capabilities of station
1526 * @opmode_notif: operating mode field from Operating Mode Notification
1527 * @opmode_notif_used: information if operating mode field is used
1528 * @he_capa: HE capabilities of station
1529 * @he_capa_len: the length of the HE capabilities
1530 * @txpwr: transmit power for an associated station
1531 * @txpwr_set: txpwr field is set
1532 * @he_6ghz_capa: HE 6 GHz Band capabilities of station
1533 * @eht_capa: EHT capabilities of station
1534 * @eht_capa_len: the length of the EHT capabilities
1535 */
1536struct link_station_parameters {
1537 const u8 *mld_mac;
1538 int link_id;
1539 const u8 *link_mac;
1540 const u8 *supported_rates;
1541 u8 supported_rates_len;
1542 const struct ieee80211_ht_cap *ht_capa;
1543 const struct ieee80211_vht_cap *vht_capa;
1544 u8 opmode_notif;
1545 bool opmode_notif_used;
1546 const struct ieee80211_he_cap_elem *he_capa;
1547 u8 he_capa_len;
1548 struct sta_txpwr txpwr;
1549 bool txpwr_set;
1550 const struct ieee80211_he_6ghz_capa *he_6ghz_capa;
1551 const struct ieee80211_eht_cap_elem *eht_capa;
1552 u8 eht_capa_len;
1553};
1554
1555/**
1556 * struct link_station_del_parameters - link station deletion parameters
1557 *
1558 * Used to delete a link station entry (or all stations).
1559 *
1560 * @mld_mac: MAC address of the station
1561 * @link_id: the link id
1562 */
1563struct link_station_del_parameters {
1564 const u8 *mld_mac;
1565 u32 link_id;
1566};
1567
5727ef1b
JB
1568/**
1569 * struct station_parameters - station parameters
1570 *
1571 * Used to change and create a new station.
1572 *
1573 * @vlan: vlan interface station should belong to
eccb8e8f 1574 * @sta_flags_mask: station flags that changed
819bf593 1575 * (bitmask of BIT(%NL80211_STA_FLAG_...))
eccb8e8f 1576 * @sta_flags_set: station flags values
819bf593 1577 * (bitmask of BIT(%NL80211_STA_FLAG_...))
5727ef1b
JB
1578 * @listen_interval: listen interval or -1 for no change
1579 * @aid: AID or zero for no change
14f34e36 1580 * @vlan_id: VLAN ID for station (if nonzero)
7d27a0ba 1581 * @peer_aid: mesh peer AID or zero for no change
abe37c4b 1582 * @plink_action: plink action to take
9c3990aa 1583 * @plink_state: set the peer link state for a station
910868db
EP
1584 * @uapsd_queues: bitmap of queues configured for uapsd. same format
1585 * as the AC bitmap in the QoS info field
1586 * @max_sp: max Service Period. same format as the MAX_SP in the
1587 * QoS info field (but already shifted down)
c26887d2
JB
1588 * @sta_modify_mask: bitmap indicating which parameters changed
1589 * (for those that don't have a natural "no change" value),
1590 * see &enum station_parameters_apply_mask
3b1c5a53
MP
1591 * @local_pm: local link-specific mesh power save mode (no change when set
1592 * to unknown)
9d62a986
JM
1593 * @capability: station capability
1594 * @ext_capab: extended capabilities of the station
1595 * @ext_capab_len: number of extended capabilities
c01fc9ad
SD
1596 * @supported_channels: supported channels in IEEE 802.11 format
1597 * @supported_channels_len: number of supported channels
1598 * @supported_oper_classes: supported oper classes in IEEE 802.11 format
1599 * @supported_oper_classes_len: number of supported operating classes
17b94247 1600 * @support_p2p_ps: information if station supports P2P PS mechanism
36647055 1601 * @airtime_weight: airtime scheduler weight for this station
b95eb7f0 1602 * @link_sta_params: link related params.
5727ef1b
JB
1603 */
1604struct station_parameters {
5727ef1b 1605 struct net_device *vlan;
eccb8e8f 1606 u32 sta_flags_mask, sta_flags_set;
3b9ce80c 1607 u32 sta_modify_mask;
5727ef1b
JB
1608 int listen_interval;
1609 u16 aid;
14f34e36 1610 u16 vlan_id;
7d27a0ba 1611 u16 peer_aid;
2ec600d6 1612 u8 plink_action;
9c3990aa 1613 u8 plink_state;
c75786c9
EP
1614 u8 uapsd_queues;
1615 u8 max_sp;
3b1c5a53 1616 enum nl80211_mesh_power_mode local_pm;
9d62a986 1617 u16 capability;
2c1aabf3 1618 const u8 *ext_capab;
9d62a986 1619 u8 ext_capab_len;
c01fc9ad
SD
1620 const u8 *supported_channels;
1621 u8 supported_channels_len;
1622 const u8 *supported_oper_classes;
1623 u8 supported_oper_classes_len;
17b94247 1624 int support_p2p_ps;
36647055 1625 u16 airtime_weight;
b95eb7f0 1626 struct link_station_parameters link_sta_params;
5727ef1b
JB
1627};
1628
89c771e5
JM
1629/**
1630 * struct station_del_parameters - station deletion parameters
1631 *
1632 * Used to delete a station entry (or all stations).
1633 *
1634 * @mac: MAC address of the station to remove or NULL to remove all stations
98856866
JM
1635 * @subtype: Management frame subtype to use for indicating removal
1636 * (10 = Disassociation, 12 = Deauthentication)
1637 * @reason_code: Reason code for the Disassociation/Deauthentication frame
89c771e5
JM
1638 */
1639struct station_del_parameters {
1640 const u8 *mac;
98856866
JM
1641 u8 subtype;
1642 u16 reason_code;
89c771e5
JM
1643};
1644
77ee7c89
JB
1645/**
1646 * enum cfg80211_station_type - the type of station being modified
1647 * @CFG80211_STA_AP_CLIENT: client of an AP interface
47edb11b
AB
1648 * @CFG80211_STA_AP_CLIENT_UNASSOC: client of an AP interface that is still
1649 * unassociated (update properties for this type of client is permitted)
77ee7c89
JB
1650 * @CFG80211_STA_AP_MLME_CLIENT: client of an AP interface that has
1651 * the AP MLME in the device
1652 * @CFG80211_STA_AP_STA: AP station on managed interface
1653 * @CFG80211_STA_IBSS: IBSS station
1654 * @CFG80211_STA_TDLS_PEER_SETUP: TDLS peer on managed interface (dummy entry
1655 * while TDLS setup is in progress, it moves out of this state when
1656 * being marked authorized; use this only if TDLS with external setup is
1657 * supported/used)
1658 * @CFG80211_STA_TDLS_PEER_ACTIVE: TDLS peer on managed interface (active
1659 * entry that is operating, has been marked authorized by userspace)
eef941e6
TP
1660 * @CFG80211_STA_MESH_PEER_KERNEL: peer on mesh interface (kernel managed)
1661 * @CFG80211_STA_MESH_PEER_USER: peer on mesh interface (user managed)
77ee7c89
JB
1662 */
1663enum cfg80211_station_type {
1664 CFG80211_STA_AP_CLIENT,
47edb11b 1665 CFG80211_STA_AP_CLIENT_UNASSOC,
77ee7c89
JB
1666 CFG80211_STA_AP_MLME_CLIENT,
1667 CFG80211_STA_AP_STA,
1668 CFG80211_STA_IBSS,
1669 CFG80211_STA_TDLS_PEER_SETUP,
1670 CFG80211_STA_TDLS_PEER_ACTIVE,
eef941e6
TP
1671 CFG80211_STA_MESH_PEER_KERNEL,
1672 CFG80211_STA_MESH_PEER_USER,
77ee7c89
JB
1673};
1674
1675/**
1676 * cfg80211_check_station_change - validate parameter changes
1677 * @wiphy: the wiphy this operates on
1678 * @params: the new parameters for a station
1679 * @statype: the type of station being modified
1680 *
1681 * Utility function for the @change_station driver method. Call this function
1682 * with the appropriate station type looking up the station (and checking that
1683 * it exists). It will verify whether the station change is acceptable, and if
1684 * not will return an error code. Note that it may modify the parameters for
1685 * backward compatibility reasons, so don't use them before calling this.
1686 */
1687int cfg80211_check_station_change(struct wiphy *wiphy,
1688 struct station_parameters *params,
1689 enum cfg80211_station_type statype);
1690
420e7fab 1691/**
b1e8eb11 1692 * enum rate_info_flags - bitrate info flags
420e7fab
HR
1693 *
1694 * Used by the driver to indicate the specific rate transmission
1695 * type for 802.11n transmissions.
1696 *
db9c64cf
JB
1697 * @RATE_INFO_FLAGS_MCS: mcs field filled with HT MCS
1698 * @RATE_INFO_FLAGS_VHT_MCS: mcs field filled with VHT MCS
420e7fab 1699 * @RATE_INFO_FLAGS_SHORT_GI: 400ns guard interval
2a38075c 1700 * @RATE_INFO_FLAGS_DMG: 60GHz MCS
c4cbaf79 1701 * @RATE_INFO_FLAGS_HE_MCS: HE MCS information
2a38075c 1702 * @RATE_INFO_FLAGS_EDMG: 60GHz MCS in EDMG mode
d9c85e24 1703 * @RATE_INFO_FLAGS_EXTENDED_SC_DMG: 60GHz extended SC MCS
cfb14110 1704 * @RATE_INFO_FLAGS_EHT_MCS: EHT MCS information
2ad66fcb 1705 * @RATE_INFO_FLAGS_S1G_MCS: MCS field filled with S1G MCS
420e7fab
HR
1706 */
1707enum rate_info_flags {
db9c64cf
JB
1708 RATE_INFO_FLAGS_MCS = BIT(0),
1709 RATE_INFO_FLAGS_VHT_MCS = BIT(1),
b51f3bee 1710 RATE_INFO_FLAGS_SHORT_GI = BIT(2),
2a38075c 1711 RATE_INFO_FLAGS_DMG = BIT(3),
c4cbaf79 1712 RATE_INFO_FLAGS_HE_MCS = BIT(4),
2a38075c 1713 RATE_INFO_FLAGS_EDMG = BIT(5),
d9c85e24 1714 RATE_INFO_FLAGS_EXTENDED_SC_DMG = BIT(6),
cfb14110 1715 RATE_INFO_FLAGS_EHT_MCS = BIT(7),
2ad66fcb 1716 RATE_INFO_FLAGS_S1G_MCS = BIT(8),
b51f3bee
JB
1717};
1718
1719/**
1720 * enum rate_info_bw - rate bandwidth information
1721 *
1722 * Used by the driver to indicate the rate bandwidth.
1723 *
1724 * @RATE_INFO_BW_5: 5 MHz bandwidth
1725 * @RATE_INFO_BW_10: 10 MHz bandwidth
1726 * @RATE_INFO_BW_20: 20 MHz bandwidth
1727 * @RATE_INFO_BW_40: 40 MHz bandwidth
1728 * @RATE_INFO_BW_80: 80 MHz bandwidth
1729 * @RATE_INFO_BW_160: 160 MHz bandwidth
c4cbaf79 1730 * @RATE_INFO_BW_HE_RU: bandwidth determined by HE RU allocation
cfb14110
VJ
1731 * @RATE_INFO_BW_320: 320 MHz bandwidth
1732 * @RATE_INFO_BW_EHT_RU: bandwidth determined by EHT RU allocation
2ad66fcb
GI
1733 * @RATE_INFO_BW_1: 1 MHz bandwidth
1734 * @RATE_INFO_BW_2: 2 MHz bandwidth
1735 * @RATE_INFO_BW_4: 4 MHz bandwidth
1736 * @RATE_INFO_BW_8: 8 MHz bandwidth
1737 * @RATE_INFO_BW_16: 16 MHz bandwidth
b51f3bee
JB
1738 */
1739enum rate_info_bw {
842be75c 1740 RATE_INFO_BW_20 = 0,
b51f3bee
JB
1741 RATE_INFO_BW_5,
1742 RATE_INFO_BW_10,
b51f3bee
JB
1743 RATE_INFO_BW_40,
1744 RATE_INFO_BW_80,
1745 RATE_INFO_BW_160,
c4cbaf79 1746 RATE_INFO_BW_HE_RU,
cfb14110
VJ
1747 RATE_INFO_BW_320,
1748 RATE_INFO_BW_EHT_RU,
2ad66fcb
GI
1749 RATE_INFO_BW_1,
1750 RATE_INFO_BW_2,
1751 RATE_INFO_BW_4,
1752 RATE_INFO_BW_8,
1753 RATE_INFO_BW_16,
420e7fab
HR
1754};
1755
1756/**
1757 * struct rate_info - bitrate information
1758 *
1759 * Information about a receiving or transmitting bitrate
1760 *
1761 * @flags: bitflag of flags from &enum rate_info_flags
420e7fab 1762 * @legacy: bitrate in 100kbit/s for 802.11abg
2ad66fcb 1763 * @mcs: mcs index if struct describes an HT/VHT/HE/EHT/S1G rate
c4cbaf79 1764 * @nss: number of streams (VHT & HE only)
b51f3bee 1765 * @bw: bandwidth (from &enum rate_info_bw)
c4cbaf79
LC
1766 * @he_gi: HE guard interval (from &enum nl80211_he_gi)
1767 * @he_dcm: HE DCM value
1768 * @he_ru_alloc: HE RU allocation (from &enum nl80211_he_ru_alloc,
1769 * only valid if bw is %RATE_INFO_BW_HE_RU)
2a38075c 1770 * @n_bonded_ch: In case of EDMG the number of bonded channels (1-4)
cfb14110
VJ
1771 * @eht_gi: EHT guard interval (from &enum nl80211_eht_gi)
1772 * @eht_ru_alloc: EHT RU allocation (from &enum nl80211_eht_ru_alloc,
1773 * only valid if bw is %RATE_INFO_BW_EHT_RU)
420e7fab
HR
1774 */
1775struct rate_info {
2ad66fcb 1776 u16 flags;
420e7fab 1777 u16 legacy;
2ad66fcb 1778 u8 mcs;
db9c64cf 1779 u8 nss;
b51f3bee 1780 u8 bw;
c4cbaf79
LC
1781 u8 he_gi;
1782 u8 he_dcm;
1783 u8 he_ru_alloc;
2a38075c 1784 u8 n_bonded_ch;
cfb14110
VJ
1785 u8 eht_gi;
1786 u8 eht_ru_alloc;
fd5b74dc
JB
1787};
1788
f4263c98 1789/**
b1e8eb11 1790 * enum bss_param_flags - bitrate info flags
f4263c98
PS
1791 *
1792 * Used by the driver to indicate the specific rate transmission
1793 * type for 802.11n transmissions.
1794 *
1795 * @BSS_PARAM_FLAGS_CTS_PROT: whether CTS protection is enabled
1796 * @BSS_PARAM_FLAGS_SHORT_PREAMBLE: whether short preamble is enabled
1797 * @BSS_PARAM_FLAGS_SHORT_SLOT_TIME: whether short slot time is enabled
1798 */
1799enum bss_param_flags {
1800 BSS_PARAM_FLAGS_CTS_PROT = 1<<0,
1801 BSS_PARAM_FLAGS_SHORT_PREAMBLE = 1<<1,
1802 BSS_PARAM_FLAGS_SHORT_SLOT_TIME = 1<<2,
1803};
1804
1805/**
1806 * struct sta_bss_parameters - BSS parameters for the attached station
1807 *
1808 * Information about the currently associated BSS
1809 *
1810 * @flags: bitflag of flags from &enum bss_param_flags
1811 * @dtim_period: DTIM period for the BSS
1812 * @beacon_interval: beacon interval
1813 */
1814struct sta_bss_parameters {
1815 u8 flags;
1816 u8 dtim_period;
1817 u16 beacon_interval;
1818};
1819
52539ca8
THJ
1820/**
1821 * struct cfg80211_txq_stats - TXQ statistics for this TID
1822 * @filled: bitmap of flags using the bits of &enum nl80211_txq_stats to
1823 * indicate the relevant values in this struct are filled
1824 * @backlog_bytes: total number of bytes currently backlogged
1825 * @backlog_packets: total number of packets currently backlogged
1826 * @flows: number of new flows seen
1827 * @drops: total number of packets dropped
1828 * @ecn_marks: total number of packets marked with ECN CE
1829 * @overlimit: number of drops due to queue space overflow
1830 * @overmemory: number of drops due to memory limit overflow
1831 * @collisions: number of hash collisions
1832 * @tx_bytes: total number of bytes dequeued
1833 * @tx_packets: total number of packets dequeued
1834 * @max_flows: maximum number of flows supported
1835 */
1836struct cfg80211_txq_stats {
1837 u32 filled;
1838 u32 backlog_bytes;
1839 u32 backlog_packets;
1840 u32 flows;
1841 u32 drops;
1842 u32 ecn_marks;
1843 u32 overlimit;
1844 u32 overmemory;
1845 u32 collisions;
1846 u32 tx_bytes;
1847 u32 tx_packets;
1848 u32 max_flows;
1849};
1850
6de39808
JB
1851/**
1852 * struct cfg80211_tid_stats - per-TID statistics
1853 * @filled: bitmap of flags using the bits of &enum nl80211_tid_stats to
1854 * indicate the relevant values in this struct are filled
1855 * @rx_msdu: number of received MSDUs
1856 * @tx_msdu: number of (attempted) transmitted MSDUs
1857 * @tx_msdu_retries: number of retries (not counting the first) for
1858 * transmitted MSDUs
1859 * @tx_msdu_failed: number of failed transmitted MSDUs
52539ca8 1860 * @txq_stats: TXQ statistics
6de39808
JB
1861 */
1862struct cfg80211_tid_stats {
1863 u32 filled;
1864 u64 rx_msdu;
1865 u64 tx_msdu;
1866 u64 tx_msdu_retries;
1867 u64 tx_msdu_failed;
52539ca8 1868 struct cfg80211_txq_stats txq_stats;
6de39808
JB
1869};
1870
119363c7
FF
1871#define IEEE80211_MAX_CHAINS 4
1872
fd5b74dc 1873/**
2ec600d6 1874 * struct station_info - station information
fd5b74dc 1875 *
2ec600d6 1876 * Station information filled by driver for get_station() and dump_station.
fd5b74dc 1877 *
319090bf
JB
1878 * @filled: bitflag of flags using the bits of &enum nl80211_sta_info to
1879 * indicate the relevant values in this struct for them
ebe27c91 1880 * @connected_time: time(in secs) since a station is last connected
fd5b74dc 1881 * @inactive_time: time since last station activity (tx/rx) in milliseconds
6c7a0033 1882 * @assoc_at: bootime (ns) of the last association
8d791361
JB
1883 * @rx_bytes: bytes (size of MPDUs) received from this station
1884 * @tx_bytes: bytes (size of MPDUs) transmitted to this station
2ec600d6
LCC
1885 * @llid: mesh local link id
1886 * @plid: mesh peer link id
1887 * @plink_state: mesh peer link state
73c3df3b
JB
1888 * @signal: The signal strength, type depends on the wiphy's signal_type.
1889 * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
1890 * @signal_avg: Average signal strength, type depends on the wiphy's signal_type.
1891 * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
119363c7
FF
1892 * @chains: bitmask for filled values in @chain_signal, @chain_signal_avg
1893 * @chain_signal: per-chain signal strength of last received packet in dBm
1894 * @chain_signal_avg: per-chain signal strength average in dBm
858022aa
RD
1895 * @txrate: current unicast bitrate from this station
1896 * @rxrate: current unicast bitrate to this station
8d791361
JB
1897 * @rx_packets: packets (MSDUs & MMPDUs) received from this station
1898 * @tx_packets: packets (MSDUs & MMPDUs) transmitted to this station
1899 * @tx_retries: cumulative retry counts (MPDUs)
1900 * @tx_failed: number of failed transmissions (MPDUs) (retries exceeded, no ACK)
5a5c731a 1901 * @rx_dropped_misc: Dropped for un-specified reason.
1ba01458 1902 * @bss_param: current BSS parameters
f5ea9120
JB
1903 * @generation: generation number for nl80211 dumps.
1904 * This number should increase every time the list of stations
1905 * changes, i.e. when a station is added or removed, so that
1906 * userspace can tell whether it got a consistent snapshot.
50d3dfb7
JM
1907 * @assoc_req_ies: IEs from (Re)Association Request.
1908 * This is used only when in AP mode with drivers that do not use
1909 * user space MLME/SME implementation. The information is provided for
1910 * the cfg80211_new_sta() calls to notify user space of the IEs.
1911 * @assoc_req_ies_len: Length of assoc_req_ies buffer in octets.
c26887d2 1912 * @sta_flags: station flags mask & values
a85e1d55 1913 * @beacon_loss_count: Number of times beacon loss event has triggered.
d299a1f2 1914 * @t_offset: Time offset of the station relative to this host.
3b1c5a53
MP
1915 * @local_pm: local mesh STA power save mode
1916 * @peer_pm: peer mesh STA power save mode
1917 * @nonpeer_pm: non-peer mesh STA power save mode
867d849f
AQ
1918 * @expected_throughput: expected throughput in kbps (including 802.11 headers)
1919 * towards this station.
a76b1942
JB
1920 * @rx_beacon: number of beacons received from this peer
1921 * @rx_beacon_signal_avg: signal strength average (in dBm) for beacons received
1922 * from this peer
dbdaee7a 1923 * @connected_to_gate: true if mesh STA has a path to mesh gate
739960f1 1924 * @rx_duration: aggregate PPDU duration(usecs) for all the frames from a peer
36647055
THJ
1925 * @tx_duration: aggregate PPDU duration(usecs) for all the frames to a peer
1926 * @airtime_weight: current airtime scheduling weight
6de39808
JB
1927 * @pertid: per-TID statistics, see &struct cfg80211_tid_stats, using the last
1928 * (IEEE80211_NUM_TIDS) index for MSDUs not encapsulated in QoS-MPDUs.
8689c051 1929 * Note that this doesn't use the @filled bit, but is used if non-NULL.
c4b50cd3 1930 * @ack_signal: signal strength (in dBm) of the last ACK frame.
81d5439d
BP
1931 * @avg_ack_signal: average rssi value of ack packet for the no of msdu's has
1932 * been sent.
0d4e14a3
AB
1933 * @rx_mpdu_count: number of MPDUs received from this station
1934 * @fcs_err_count: number of packets (MPDUs) received from this station with
1935 * an FCS error. This counter should be incremented only when TA of the
1936 * received packet with an FCS error matches the peer MAC address.
ab60633c 1937 * @airtime_link_metric: mesh airtime link metric.
1303a51c 1938 * @connected_to_as: true if mesh STA has a path to authentication server
a42e59eb
VJ
1939 * @mlo_params_valid: Indicates @assoc_link_id and @mld_addr fields are filled
1940 * by driver. Drivers use this only in cfg80211_new_sta() calls when AP
1941 * MLD's MLME/SME is offload to driver. Drivers won't fill this
1942 * information in cfg80211_del_sta_sinfo(), get_station() and
1943 * dump_station() callbacks.
1944 * @assoc_link_id: Indicates MLO link ID of the AP, with which the station
1945 * completed (re)association. This information filled for both MLO
1946 * and non-MLO STA connections when the AP affiliated with an MLD.
1947 * @mld_addr: For MLO STA connection, filled with MLD address of the station.
1948 * For non-MLO STA connection, filled with all zeros.
1949 * @assoc_resp_ies: IEs from (Re)Association Response.
1950 * This is used only when in AP mode with drivers that do not use user
1951 * space MLME/SME implementation. The information is provided only for the
1952 * cfg80211_new_sta() calls to notify user space of the IEs. Drivers won't
1953 * fill this information in cfg80211_del_sta_sinfo(), get_station() and
1954 * dump_station() callbacks. User space needs this information to determine
1955 * the accepted and rejected affiliated links of the connected station.
1956 * @assoc_resp_ies_len: Length of @assoc_resp_ies buffer in octets.
fd5b74dc 1957 */
2ec600d6 1958struct station_info {
739960f1 1959 u64 filled;
ebe27c91 1960 u32 connected_time;
fd5b74dc 1961 u32 inactive_time;
6c7a0033 1962 u64 assoc_at;
42745e03
VK
1963 u64 rx_bytes;
1964 u64 tx_bytes;
2ec600d6
LCC
1965 u16 llid;
1966 u16 plid;
1967 u8 plink_state;
420e7fab 1968 s8 signal;
541a45a1 1969 s8 signal_avg;
119363c7
FF
1970
1971 u8 chains;
1972 s8 chain_signal[IEEE80211_MAX_CHAINS];
1973 s8 chain_signal_avg[IEEE80211_MAX_CHAINS];
1974
420e7fab 1975 struct rate_info txrate;
c8dcfd8a 1976 struct rate_info rxrate;
98c8a60a
JM
1977 u32 rx_packets;
1978 u32 tx_packets;
b206b4ef
BR
1979 u32 tx_retries;
1980 u32 tx_failed;
5a5c731a 1981 u32 rx_dropped_misc;
f4263c98 1982 struct sta_bss_parameters bss_param;
bb6e753e 1983 struct nl80211_sta_flag_update sta_flags;
f5ea9120
JB
1984
1985 int generation;
50d3dfb7
JM
1986
1987 const u8 *assoc_req_ies;
1988 size_t assoc_req_ies_len;
f612cedf 1989
a85e1d55 1990 u32 beacon_loss_count;
d299a1f2 1991 s64 t_offset;
3b1c5a53
MP
1992 enum nl80211_mesh_power_mode local_pm;
1993 enum nl80211_mesh_power_mode peer_pm;
1994 enum nl80211_mesh_power_mode nonpeer_pm;
a85e1d55 1995
867d849f 1996 u32 expected_throughput;
a76b1942 1997
36647055 1998 u64 tx_duration;
739960f1 1999 u64 rx_duration;
36647055 2000 u64 rx_beacon;
a76b1942 2001 u8 rx_beacon_signal_avg;
dbdaee7a
BC
2002 u8 connected_to_gate;
2003
8689c051 2004 struct cfg80211_tid_stats *pertid;
c4b50cd3 2005 s8 ack_signal;
81d5439d 2006 s8 avg_ack_signal;
0d4e14a3 2007
36647055
THJ
2008 u16 airtime_weight;
2009
0d4e14a3
AB
2010 u32 rx_mpdu_count;
2011 u32 fcs_err_count;
ab60633c
NM
2012
2013 u32 airtime_link_metric;
1303a51c
MT
2014
2015 u8 connected_to_as;
a42e59eb
VJ
2016
2017 bool mlo_params_valid;
2018 u8 assoc_link_id;
2019 u8 mld_addr[ETH_ALEN] __aligned(2);
2020 const u8 *assoc_resp_ies;
2021 size_t assoc_resp_ies_len;
fd5b74dc
JB
2022};
2023
6bdb68ce
CH
2024/**
2025 * struct cfg80211_sar_sub_specs - sub specs limit
2026 * @power: power limitation in 0.25dbm
2027 * @freq_range_index: index the power limitation applies to
2028 */
2029struct cfg80211_sar_sub_specs {
2030 s32 power;
2031 u32 freq_range_index;
2032};
2033
2034/**
2035 * struct cfg80211_sar_specs - sar limit specs
2036 * @type: it's set with power in 0.25dbm or other types
2037 * @num_sub_specs: number of sar sub specs
2038 * @sub_specs: memory to hold the sar sub specs
2039 */
2040struct cfg80211_sar_specs {
2041 enum nl80211_sar_type type;
2042 u32 num_sub_specs;
2043 struct cfg80211_sar_sub_specs sub_specs[];
2044};
2045
2046
2047/**
c2083e28 2048 * struct cfg80211_sar_freq_ranges - sar frequency ranges
6bdb68ce
CH
2049 * @start_freq: start range edge frequency
2050 * @end_freq: end range edge frequency
2051 */
2052struct cfg80211_sar_freq_ranges {
2053 u32 start_freq;
2054 u32 end_freq;
2055};
2056
2057/**
2058 * struct cfg80211_sar_capa - sar limit capability
2059 * @type: it's set via power in 0.25dbm or other types
2060 * @num_freq_ranges: number of frequency ranges
2061 * @freq_ranges: memory to hold the freq ranges.
2062 *
2063 * Note: WLAN driver may append new ranges or split an existing
2064 * range to small ones and then append them.
2065 */
2066struct cfg80211_sar_capa {
2067 enum nl80211_sar_type type;
2068 u32 num_freq_ranges;
2069 const struct cfg80211_sar_freq_ranges *freq_ranges;
2070};
2071
61aaa0e8 2072#if IS_ENABLED(CONFIG_CFG80211)
7406353d
AQ
2073/**
2074 * cfg80211_get_station - retrieve information about a given station
2075 * @dev: the device where the station is supposed to be connected to
2076 * @mac_addr: the mac address of the station of interest
2077 * @sinfo: pointer to the structure to fill with the information
2078 *
2079 * Returns 0 on success and sinfo is filled with the available information
2080 * otherwise returns a negative error code and the content of sinfo has to be
2081 * considered undefined.
2082 */
2083int cfg80211_get_station(struct net_device *dev, const u8 *mac_addr,
2084 struct station_info *sinfo);
61aaa0e8
LL
2085#else
2086static inline int cfg80211_get_station(struct net_device *dev,
2087 const u8 *mac_addr,
2088 struct station_info *sinfo)
2089{
2090 return -ENOENT;
2091}
2092#endif
7406353d 2093
66f7ac50
MW
2094/**
2095 * enum monitor_flags - monitor flags
2096 *
2097 * Monitor interface configuration flags. Note that these must be the bits
2098 * according to the nl80211 flags.
2099 *
818a986e 2100 * @MONITOR_FLAG_CHANGED: set if the flags were changed
66f7ac50
MW
2101 * @MONITOR_FLAG_FCSFAIL: pass frames with bad FCS
2102 * @MONITOR_FLAG_PLCPFAIL: pass frames with bad PLCP
2103 * @MONITOR_FLAG_CONTROL: pass control frames
2104 * @MONITOR_FLAG_OTHER_BSS: disable BSSID filtering
2105 * @MONITOR_FLAG_COOK_FRAMES: report frames after processing
e057d3c3 2106 * @MONITOR_FLAG_ACTIVE: active monitor, ACKs frames on its MAC address
66f7ac50
MW
2107 */
2108enum monitor_flags {
818a986e 2109 MONITOR_FLAG_CHANGED = 1<<__NL80211_MNTR_FLAG_INVALID,
66f7ac50
MW
2110 MONITOR_FLAG_FCSFAIL = 1<<NL80211_MNTR_FLAG_FCSFAIL,
2111 MONITOR_FLAG_PLCPFAIL = 1<<NL80211_MNTR_FLAG_PLCPFAIL,
2112 MONITOR_FLAG_CONTROL = 1<<NL80211_MNTR_FLAG_CONTROL,
2113 MONITOR_FLAG_OTHER_BSS = 1<<NL80211_MNTR_FLAG_OTHER_BSS,
2114 MONITOR_FLAG_COOK_FRAMES = 1<<NL80211_MNTR_FLAG_COOK_FRAMES,
e057d3c3 2115 MONITOR_FLAG_ACTIVE = 1<<NL80211_MNTR_FLAG_ACTIVE,
66f7ac50
MW
2116};
2117
2ec600d6
LCC
2118/**
2119 * enum mpath_info_flags - mesh path information flags
2120 *
2121 * Used by the driver to indicate which info in &struct mpath_info it has filled
2122 * in during get_station() or dump_station().
2123 *
abe37c4b
JB
2124 * @MPATH_INFO_FRAME_QLEN: @frame_qlen filled
2125 * @MPATH_INFO_SN: @sn filled
2126 * @MPATH_INFO_METRIC: @metric filled
2127 * @MPATH_INFO_EXPTIME: @exptime filled
2128 * @MPATH_INFO_DISCOVERY_TIMEOUT: @discovery_timeout filled
2129 * @MPATH_INFO_DISCOVERY_RETRIES: @discovery_retries filled
2130 * @MPATH_INFO_FLAGS: @flags filled
cc241636 2131 * @MPATH_INFO_HOP_COUNT: @hop_count filled
9874b71f 2132 * @MPATH_INFO_PATH_CHANGE: @path_change_count filled
2ec600d6
LCC
2133 */
2134enum mpath_info_flags {
2135 MPATH_INFO_FRAME_QLEN = BIT(0),
d19b3bf6 2136 MPATH_INFO_SN = BIT(1),
2ec600d6
LCC
2137 MPATH_INFO_METRIC = BIT(2),
2138 MPATH_INFO_EXPTIME = BIT(3),
2139 MPATH_INFO_DISCOVERY_TIMEOUT = BIT(4),
2140 MPATH_INFO_DISCOVERY_RETRIES = BIT(5),
2141 MPATH_INFO_FLAGS = BIT(6),
540bbcb9
JH
2142 MPATH_INFO_HOP_COUNT = BIT(7),
2143 MPATH_INFO_PATH_CHANGE = BIT(8),
2ec600d6
LCC
2144};
2145
2146/**
2147 * struct mpath_info - mesh path information
2148 *
2149 * Mesh path information filled by driver for get_mpath() and dump_mpath().
2150 *
2151 * @filled: bitfield of flags from &enum mpath_info_flags
2152 * @frame_qlen: number of queued frames for this destination
d19b3bf6 2153 * @sn: target sequence number
2ec600d6
LCC
2154 * @metric: metric (cost) of this mesh path
2155 * @exptime: expiration time for the mesh path from now, in msecs
2156 * @flags: mesh path flags
2157 * @discovery_timeout: total mesh path discovery timeout, in msecs
2158 * @discovery_retries: mesh path discovery retries
f5ea9120
JB
2159 * @generation: generation number for nl80211 dumps.
2160 * This number should increase every time the list of mesh paths
2161 * changes, i.e. when a station is added or removed, so that
2162 * userspace can tell whether it got a consistent snapshot.
cc241636 2163 * @hop_count: hops to destination
540bbcb9 2164 * @path_change_count: total number of path changes to destination
2ec600d6
LCC
2165 */
2166struct mpath_info {
2167 u32 filled;
2168 u32 frame_qlen;
d19b3bf6 2169 u32 sn;
2ec600d6
LCC
2170 u32 metric;
2171 u32 exptime;
2172 u32 discovery_timeout;
2173 u8 discovery_retries;
2174 u8 flags;
cc241636 2175 u8 hop_count;
540bbcb9 2176 u32 path_change_count;
f5ea9120
JB
2177
2178 int generation;
2ec600d6
LCC
2179};
2180
9f1ba906
JM
2181/**
2182 * struct bss_parameters - BSS parameters
2183 *
2184 * Used to change BSS parameters (mainly for AP mode).
2185 *
1e0f8cc9 2186 * @link_id: link_id or -1 for non-MLD
9f1ba906
JM
2187 * @use_cts_prot: Whether to use CTS protection
2188 * (0 = no, 1 = yes, -1 = do not change)
2189 * @use_short_preamble: Whether the use of short preambles is allowed
2190 * (0 = no, 1 = yes, -1 = do not change)
2191 * @use_short_slot_time: Whether the use of short slot time is allowed
2192 * (0 = no, 1 = yes, -1 = do not change)
90c97a04
JM
2193 * @basic_rates: basic rates in IEEE 802.11 format
2194 * (or NULL for no change)
2195 * @basic_rates_len: number of basic rates
fd8aaaf3 2196 * @ap_isolate: do not forward packets between connected stations
9d6e371d 2197 * (0 = no, 1 = yes, -1 = do not change)
50b12f59 2198 * @ht_opmode: HT Operation mode
cd9b52bf 2199 * (u16 = opmode, -1 = do not change)
53cabad7
JB
2200 * @p2p_ctwindow: P2P CT Window (-1 = no change)
2201 * @p2p_opp_ps: P2P opportunistic PS (-1 = no change)
9f1ba906
JM
2202 */
2203struct bss_parameters {
1e0f8cc9 2204 int link_id;
9f1ba906
JM
2205 int use_cts_prot;
2206 int use_short_preamble;
2207 int use_short_slot_time;
c1e5f471 2208 const u8 *basic_rates;
90c97a04 2209 u8 basic_rates_len;
fd8aaaf3 2210 int ap_isolate;
50b12f59 2211 int ht_opmode;
53cabad7 2212 s8 p2p_ctwindow, p2p_opp_ps;
9f1ba906 2213};
2ec600d6 2214
3ddd53f3 2215/**
29cbe68c
JB
2216 * struct mesh_config - 802.11s mesh configuration
2217 *
2218 * These parameters can be changed while the mesh is active.
3ddd53f3
CYY
2219 *
2220 * @dot11MeshRetryTimeout: the initial retry timeout in millisecond units used
2221 * by the Mesh Peering Open message
2222 * @dot11MeshConfirmTimeout: the initial retry timeout in millisecond units
2223 * used by the Mesh Peering Open message
2224 * @dot11MeshHoldingTimeout: the confirm timeout in millisecond units used by
2225 * the mesh peering management to close a mesh peering
2226 * @dot11MeshMaxPeerLinks: the maximum number of peer links allowed on this
2227 * mesh interface
2228 * @dot11MeshMaxRetries: the maximum number of peer link open retries that can
2229 * be sent to establish a new peer link instance in a mesh
2230 * @dot11MeshTTL: the value of TTL field set at a source mesh STA
2231 * @element_ttl: the value of TTL field set at a mesh STA for path selection
2232 * elements
2233 * @auto_open_plinks: whether we should automatically open peer links when we
2234 * detect compatible mesh peers
2235 * @dot11MeshNbrOffsetMaxNeighbor: the maximum number of neighbors to
2236 * synchronize to for 11s default synchronization method
2237 * @dot11MeshHWMPmaxPREQretries: the number of action frames containing a PREQ
2238 * that an originator mesh STA can send to a particular path target
2239 * @path_refresh_time: how frequently to refresh mesh paths in milliseconds
2240 * @min_discovery_timeout: the minimum length of time to wait until giving up on
2241 * a path discovery in milliseconds
2242 * @dot11MeshHWMPactivePathTimeout: the time (in TUs) for which mesh STAs
2243 * receiving a PREQ shall consider the forwarding information from the
2244 * root to be valid. (TU = time unit)
2245 * @dot11MeshHWMPpreqMinInterval: the minimum interval of time (in TUs) during
2246 * which a mesh STA can send only one action frame containing a PREQ
2247 * element
2248 * @dot11MeshHWMPperrMinInterval: the minimum interval of time (in TUs) during
2249 * which a mesh STA can send only one Action frame containing a PERR
2250 * element
2251 * @dot11MeshHWMPnetDiameterTraversalTime: the interval of time (in TUs) that
2252 * it takes for an HWMP information element to propagate across the mesh
2253 * @dot11MeshHWMPRootMode: the configuration of a mesh STA as root mesh STA
2254 * @dot11MeshHWMPRannInterval: the interval of time (in TUs) between root
2255 * announcements are transmitted
2256 * @dot11MeshGateAnnouncementProtocol: whether to advertise that this mesh
2257 * station has access to a broader network beyond the MBSS. (This is
2258 * missnamed in draft 12.0: dot11MeshGateAnnouncementProtocol set to true
2259 * only means that the station will announce others it's a mesh gate, but
2260 * not necessarily using the gate announcement protocol. Still keeping the
2261 * same nomenclature to be in sync with the spec)
2262 * @dot11MeshForwarding: whether the Mesh STA is forwarding or non-forwarding
2263 * entity (default is TRUE - forwarding entity)
2264 * @rssi_threshold: the threshold for average signal strength of candidate
2265 * station to establish a peer link
2266 * @ht_opmode: mesh HT protection mode
ac1073a6
CYY
2267 *
2268 * @dot11MeshHWMPactivePathToRootTimeout: The time (in TUs) for which mesh STAs
2269 * receiving a proactive PREQ shall consider the forwarding information to
2270 * the root mesh STA to be valid.
2271 *
2272 * @dot11MeshHWMProotInterval: The interval of time (in TUs) between proactive
2273 * PREQs are transmitted.
728b19e5
CYY
2274 * @dot11MeshHWMPconfirmationInterval: The minimum interval of time (in TUs)
2275 * during which a mesh STA can send only one Action frame containing
2276 * a PREQ element for root path confirmation.
3b1c5a53
MP
2277 * @power_mode: The default mesh power save mode which will be the initial
2278 * setting for new peer links.
2279 * @dot11MeshAwakeWindowDuration: The duration in TUs the STA will remain awake
2280 * after transmitting its beacon.
8e7c0538
CT
2281 * @plink_timeout: If no tx activity is seen from a STA we've established
2282 * peering with for longer than this time (in seconds), then remove it
2283 * from the STA's list of peers. Default is 30 minutes.
2d8b08fe
MCC
2284 * @dot11MeshConnectedToAuthServer: if set to true then this mesh STA
2285 * will advertise that it is connected to a authentication server
2286 * in the mesh formation field.
01d66fbd
BC
2287 * @dot11MeshConnectedToMeshGate: if set to true, advertise that this STA is
2288 * connected to a mesh gate in mesh formation info. If false, the
2289 * value in mesh formation is determined by the presence of root paths
2290 * in the mesh path table
e3718a61
LL
2291 * @dot11MeshNolearn: Try to avoid multi-hop path discovery (e.g. PREQ/PREP
2292 * for HWMP) if the destination is a direct neighbor. Note that this might
2293 * not be the optimal decision as a multi-hop route might be better. So
2294 * if using this setting you will likely also want to disable
2295 * dot11MeshForwarding and use another mesh routing protocol on top.
29cbe68c 2296 */
93da9cc1 2297struct mesh_config {
93da9cc1 2298 u16 dot11MeshRetryTimeout;
2299 u16 dot11MeshConfirmTimeout;
2300 u16 dot11MeshHoldingTimeout;
2301 u16 dot11MeshMaxPeerLinks;
a4f606ea
CYY
2302 u8 dot11MeshMaxRetries;
2303 u8 dot11MeshTTL;
2304 u8 element_ttl;
93da9cc1 2305 bool auto_open_plinks;
d299a1f2 2306 u32 dot11MeshNbrOffsetMaxNeighbor;
a4f606ea 2307 u8 dot11MeshHWMPmaxPREQretries;
93da9cc1 2308 u32 path_refresh_time;
2309 u16 min_discovery_timeout;
2310 u32 dot11MeshHWMPactivePathTimeout;
2311 u16 dot11MeshHWMPpreqMinInterval;
dca7e943 2312 u16 dot11MeshHWMPperrMinInterval;
93da9cc1 2313 u16 dot11MeshHWMPnetDiameterTraversalTime;
a4f606ea 2314 u8 dot11MeshHWMPRootMode;
01d66fbd 2315 bool dot11MeshConnectedToMeshGate;
184eebe6 2316 bool dot11MeshConnectedToAuthServer;
0507e159 2317 u16 dot11MeshHWMPRannInterval;
a4f606ea 2318 bool dot11MeshGateAnnouncementProtocol;
94f90656 2319 bool dot11MeshForwarding;
55335137 2320 s32 rssi_threshold;
70c33eaa 2321 u16 ht_opmode;
ac1073a6
CYY
2322 u32 dot11MeshHWMPactivePathToRootTimeout;
2323 u16 dot11MeshHWMProotInterval;
728b19e5 2324 u16 dot11MeshHWMPconfirmationInterval;
3b1c5a53
MP
2325 enum nl80211_mesh_power_mode power_mode;
2326 u16 dot11MeshAwakeWindowDuration;
8e7c0538 2327 u32 plink_timeout;
e3718a61 2328 bool dot11MeshNolearn;
93da9cc1 2329};
2330
29cbe68c
JB
2331/**
2332 * struct mesh_setup - 802.11s mesh setup configuration
683b6d3b 2333 * @chandef: defines the channel to use
29cbe68c
JB
2334 * @mesh_id: the mesh ID
2335 * @mesh_id_len: length of the mesh ID, at least 1 and at most 32 bytes
d299a1f2 2336 * @sync_method: which synchronization method to use
c80d545d
JC
2337 * @path_sel_proto: which path selection protocol to use
2338 * @path_metric: which metric to use
6e16d90b 2339 * @auth_id: which authentication method this mesh is using
581a8b0f
JC
2340 * @ie: vendor information elements (optional)
2341 * @ie_len: length of vendor information elements
b130e5ce
JC
2342 * @is_authenticated: this mesh requires authentication
2343 * @is_secure: this mesh uses security
bb2798d4 2344 * @user_mpm: userspace handles all MPM functions
9bdbf04d
MP
2345 * @dtim_period: DTIM period to use
2346 * @beacon_interval: beacon interval to use
4bb62344 2347 * @mcast_rate: multicat rate for Mesh Node [6Mbps is the default for 802.11a]
ffb3cf30 2348 * @basic_rates: basic rates to use when creating the mesh
8564e382 2349 * @beacon_rate: bitrate to be used for beacons
d37d49c2
BB
2350 * @userspace_handles_dfs: whether user space controls DFS operation, i.e.
2351 * changes the channel when a radar is detected. This is required
2352 * to operate on DFS channels.
1224f583
DK
2353 * @control_port_over_nl80211: TRUE if userspace expects to exchange control
2354 * port frames over NL80211 instead of the network interface.
29cbe68c
JB
2355 *
2356 * These parameters are fixed when the mesh is created.
2357 */
2358struct mesh_setup {
683b6d3b 2359 struct cfg80211_chan_def chandef;
29cbe68c
JB
2360 const u8 *mesh_id;
2361 u8 mesh_id_len;
d299a1f2
JC
2362 u8 sync_method;
2363 u8 path_sel_proto;
2364 u8 path_metric;
6e16d90b 2365 u8 auth_id;
581a8b0f
JC
2366 const u8 *ie;
2367 u8 ie_len;
b130e5ce 2368 bool is_authenticated;
15d5dda6 2369 bool is_secure;
bb2798d4 2370 bool user_mpm;
9bdbf04d
MP
2371 u8 dtim_period;
2372 u16 beacon_interval;
57fbcce3 2373 int mcast_rate[NUM_NL80211_BANDS];
ffb3cf30 2374 u32 basic_rates;
8564e382 2375 struct cfg80211_bitrate_mask beacon_rate;
d37d49c2 2376 bool userspace_handles_dfs;
1224f583 2377 bool control_port_over_nl80211;
29cbe68c
JB
2378};
2379
6e0bd6c3
RL
2380/**
2381 * struct ocb_setup - 802.11p OCB mode setup configuration
2382 * @chandef: defines the channel to use
2383 *
2384 * These parameters are fixed when connecting to the network
2385 */
2386struct ocb_setup {
2387 struct cfg80211_chan_def chandef;
2388};
2389
31888487
JM
2390/**
2391 * struct ieee80211_txq_params - TX queue parameters
a3304b0a 2392 * @ac: AC identifier
31888487
JM
2393 * @txop: Maximum burst time in units of 32 usecs, 0 meaning disabled
2394 * @cwmin: Minimum contention window [a value of the form 2^n-1 in the range
2395 * 1..32767]
2396 * @cwmax: Maximum contention window [a value of the form 2^n-1 in the range
2397 * 1..32767]
2398 * @aifs: Arbitration interframe space [0..255]
9d2bb84d 2399 * @link_id: link_id or -1 for non-MLD
31888487
JM
2400 */
2401struct ieee80211_txq_params {
a3304b0a 2402 enum nl80211_ac ac;
31888487
JM
2403 u16 txop;
2404 u16 cwmin;
2405 u16 cwmax;
2406 u8 aifs;
9d2bb84d 2407 int link_id;
31888487
JM
2408};
2409
d70e9693
JB
2410/**
2411 * DOC: Scanning and BSS list handling
2412 *
2413 * The scanning process itself is fairly simple, but cfg80211 offers quite
2414 * a bit of helper functionality. To start a scan, the scan operation will
2415 * be invoked with a scan definition. This scan definition contains the
2416 * channels to scan, and the SSIDs to send probe requests for (including the
2417 * wildcard, if desired). A passive scan is indicated by having no SSIDs to
2418 * probe. Additionally, a scan request may contain extra information elements
2419 * that should be added to the probe request. The IEs are guaranteed to be
2420 * well-formed, and will not exceed the maximum length the driver advertised
2421 * in the wiphy structure.
2422 *
2423 * When scanning finds a BSS, cfg80211 needs to be notified of that, because
2424 * it is responsible for maintaining the BSS list; the driver should not
2425 * maintain a list itself. For this notification, various functions exist.
2426 *
2427 * Since drivers do not maintain a BSS list, there are also a number of
2428 * functions to search for a BSS and obtain information about it from the
2429 * BSS structure cfg80211 maintains. The BSS list is also made available
2430 * to userspace.
2431 */
72bdcf34 2432
2a519311
JB
2433/**
2434 * struct cfg80211_ssid - SSID description
2435 * @ssid: the SSID
2436 * @ssid_len: length of the ssid
2437 */
2438struct cfg80211_ssid {
2439 u8 ssid[IEEE80211_MAX_SSID_LEN];
2440 u8 ssid_len;
2441};
2442
1d76250b
AS
2443/**
2444 * struct cfg80211_scan_info - information about completed scan
2445 * @scan_start_tsf: scan start time in terms of the TSF of the BSS that the
2446 * wireless device that requested the scan is connected to. If this
2447 * information is not available, this field is left zero.
2448 * @tsf_bssid: the BSSID according to which %scan_start_tsf is set.
2449 * @aborted: set to true if the scan was aborted for any reason,
2450 * userspace will be notified of that
2451 */
2452struct cfg80211_scan_info {
2453 u64 scan_start_tsf;
2454 u8 tsf_bssid[ETH_ALEN] __aligned(2);
2455 bool aborted;
2456};
2457
c8cb5b85
TM
2458/**
2459 * struct cfg80211_scan_6ghz_params - relevant for 6 GHz only
2460 *
2d8b08fe 2461 * @short_ssid: short ssid to scan for
c8cb5b85
TM
2462 * @bssid: bssid to scan for
2463 * @channel_idx: idx of the channel in the channel array in the scan request
2464 * which the above info relvant to
2465 * @unsolicited_probe: the AP transmits unsolicited probe response every 20 TU
2d8b08fe 2466 * @short_ssid_valid: @short_ssid is valid and can be used
c8cb5b85
TM
2467 * @psc_no_listen: when set, and the channel is a PSC channel, no need to wait
2468 * 20 TUs before starting to send probe requests.
2469 */
2470struct cfg80211_scan_6ghz_params {
2471 u32 short_ssid;
2472 u32 channel_idx;
2473 u8 bssid[ETH_ALEN];
2474 bool unsolicited_probe;
2475 bool short_ssid_valid;
2476 bool psc_no_listen;
2477};
2478
2a519311
JB
2479/**
2480 * struct cfg80211_scan_request - scan request description
2481 *
2482 * @ssids: SSIDs to scan for (active scan only)
2483 * @n_ssids: number of SSIDs
2484 * @channels: channels to scan on.
ca3dbc20 2485 * @n_channels: total number of channels to scan
dcd6eac1 2486 * @scan_width: channel width for scanning
70692ad2
JM
2487 * @ie: optional information element(s) to add into Probe Request or %NULL
2488 * @ie_len: length of ie in octets
1d76250b
AS
2489 * @duration: how long to listen on each channel, in TUs. If
2490 * %duration_mandatory is not set, this is the maximum dwell time and
2491 * the actual dwell time may be shorter.
2492 * @duration_mandatory: if set, the scan duration must be as specified by the
2493 * %duration field.
ed473771 2494 * @flags: bit field of flags controlling operation
34850ab2 2495 * @rates: bitmap of rates to advertise for each band
2a519311 2496 * @wiphy: the wiphy this was for
15d6030b 2497 * @scan_start: time (in jiffies) when the scan started
fd014284 2498 * @wdev: the wireless device to scan for
1d76250b 2499 * @info: (internal) information about completed scan
5fe231e8 2500 * @notified: (internal) scan request was notified as done or aborted
e9f935e3 2501 * @no_cck: used to send probe requests at non CCK rate in 2GHz band
ad2b26ab
JB
2502 * @mac_addr: MAC address used with randomisation
2503 * @mac_addr_mask: MAC address mask used with randomisation, bits that
2504 * are 0 in the mask should be randomised, bits that are 1 should
2505 * be taken from the @mac_addr
c8cb5b85
TM
2506 * @scan_6ghz: relevant for split scan request only,
2507 * true if this is the second scan request
2508 * @n_6ghz_params: number of 6 GHz params
2509 * @scan_6ghz_params: 6 GHz params
818965d3 2510 * @bssid: BSSID to scan for (most commonly, the wildcard BSSID)
2a519311
JB
2511 */
2512struct cfg80211_scan_request {
2513 struct cfg80211_ssid *ssids;
2514 int n_ssids;
2a519311 2515 u32 n_channels;
dcd6eac1 2516 enum nl80211_bss_scan_width scan_width;
de95a54b 2517 const u8 *ie;
70692ad2 2518 size_t ie_len;
1d76250b
AS
2519 u16 duration;
2520 bool duration_mandatory;
ed473771 2521 u32 flags;
2a519311 2522
57fbcce3 2523 u32 rates[NUM_NL80211_BANDS];
34850ab2 2524
fd014284
JB
2525 struct wireless_dev *wdev;
2526
ad2b26ab
JB
2527 u8 mac_addr[ETH_ALEN] __aligned(2);
2528 u8 mac_addr_mask[ETH_ALEN] __aligned(2);
818965d3 2529 u8 bssid[ETH_ALEN] __aligned(2);
ad2b26ab 2530
2a519311
JB
2531 /* internal */
2532 struct wiphy *wiphy;
15d6030b 2533 unsigned long scan_start;
1d76250b
AS
2534 struct cfg80211_scan_info info;
2535 bool notified;
e9f935e3 2536 bool no_cck;
c8cb5b85
TM
2537 bool scan_6ghz;
2538 u32 n_6ghz_params;
2539 struct cfg80211_scan_6ghz_params *scan_6ghz_params;
5ba63533
JB
2540
2541 /* keep last */
396fba0a 2542 struct ieee80211_channel *channels[];
2a519311
JB
2543};
2544
ad2b26ab
JB
2545static inline void get_random_mask_addr(u8 *buf, const u8 *addr, const u8 *mask)
2546{
2547 int i;
2548
2549 get_random_bytes(buf, ETH_ALEN);
2550 for (i = 0; i < ETH_ALEN; i++) {
2551 buf[i] &= ~mask[i];
2552 buf[i] |= addr[i] & mask[i];
2553 }
2554}
2555
a1f1c21c
LC
2556/**
2557 * struct cfg80211_match_set - sets of attributes to match
2558 *
3007e352
AVS
2559 * @ssid: SSID to be matched; may be zero-length in case of BSSID match
2560 * or no match (RSSI only)
2561 * @bssid: BSSID to be matched; may be all-zero BSSID in case of SSID match
2562 * or no match (RSSI only)
ea73cbce 2563 * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
1e1b11b6 2564 * @per_band_rssi_thold: Minimum rssi threshold for each band to be applied
2565 * for filtering out scan results received. Drivers advertize this support
2566 * of band specific rssi based filtering through the feature capability
2567 * %NL80211_EXT_FEATURE_SCHED_SCAN_BAND_SPECIFIC_RSSI_THOLD. These band
2568 * specific rssi thresholds take precedence over rssi_thold, if specified.
2569 * If not specified for any band, it will be assigned with rssi_thold of
2570 * corresponding matchset.
a1f1c21c
LC
2571 */
2572struct cfg80211_match_set {
2573 struct cfg80211_ssid ssid;
3007e352 2574 u8 bssid[ETH_ALEN];
ea73cbce 2575 s32 rssi_thold;
1e1b11b6 2576 s32 per_band_rssi_thold[NUM_NL80211_BANDS];
a1f1c21c
LC
2577};
2578
3b06d277
AS
2579/**
2580 * struct cfg80211_sched_scan_plan - scan plan for scheduled scan
2581 *
2582 * @interval: interval between scheduled scan iterations. In seconds.
2583 * @iterations: number of scan iterations in this scan plan. Zero means
2584 * infinite loop.
2585 * The last scan plan will always have this parameter set to zero,
2586 * all other scan plans will have a finite number of iterations.
2587 */
2588struct cfg80211_sched_scan_plan {
2589 u32 interval;
2590 u32 iterations;
2591};
2592
bf95ecdb 2593/**
2594 * struct cfg80211_bss_select_adjust - BSS selection with RSSI adjustment.
2595 *
2596 * @band: band of BSS which should match for RSSI level adjustment.
2597 * @delta: value of RSSI level adjustment.
2598 */
2599struct cfg80211_bss_select_adjust {
2600 enum nl80211_band band;
2601 s8 delta;
2602};
2603
807f8a8c
LC
2604/**
2605 * struct cfg80211_sched_scan_request - scheduled scan request description
2606 *
96b08fd6 2607 * @reqid: identifies this request.
807f8a8c
LC
2608 * @ssids: SSIDs to scan for (passed in the probe_reqs in active scans)
2609 * @n_ssids: number of SSIDs
2610 * @n_channels: total number of channels to scan
dcd6eac1 2611 * @scan_width: channel width for scanning
807f8a8c
LC
2612 * @ie: optional information element(s) to add into Probe Request or %NULL
2613 * @ie_len: length of ie in octets
ed473771 2614 * @flags: bit field of flags controlling operation
a1f1c21c 2615 * @match_sets: sets of parameters to be matched for a scan result
cd9b52bf
JP
2616 * entry to be considered valid and to be passed to the host
2617 * (others are filtered out).
a1f1c21c
LC
2618 * If ommited, all results are passed.
2619 * @n_match_sets: number of match sets
6406c919 2620 * @report_results: indicates that results were reported for this request
807f8a8c
LC
2621 * @wiphy: the wiphy this was for
2622 * @dev: the interface
077f897a 2623 * @scan_start: start time of the scheduled scan
807f8a8c 2624 * @channels: channels to scan
ea73cbce
JB
2625 * @min_rssi_thold: for drivers only supporting a single threshold, this
2626 * contains the minimum over all matchsets
ad2b26ab
JB
2627 * @mac_addr: MAC address used with randomisation
2628 * @mac_addr_mask: MAC address mask used with randomisation, bits that
2629 * are 0 in the mask should be randomised, bits that are 1 should
2630 * be taken from the @mac_addr
3b06d277
AS
2631 * @scan_plans: scan plans to be executed in this scheduled scan. Lowest
2632 * index must be executed first.
2633 * @n_scan_plans: number of scan plans, at least 1.
31a60ed1 2634 * @rcu_head: RCU callback used to free the struct
93a1e86c
JR
2635 * @owner_nlportid: netlink portid of owner (if this should is a request
2636 * owned by a particular socket)
ca986ad9
AVS
2637 * @nl_owner_dead: netlink owner socket was closed - this request be freed
2638 * @list: for keeping list of requests.
9c748934
LC
2639 * @delay: delay in seconds to use before starting the first scan
2640 * cycle. The driver may ignore this parameter and start
2641 * immediately (or at any other time), if this feature is not
2642 * supported.
bf95ecdb 2643 * @relative_rssi_set: Indicates whether @relative_rssi is set or not.
2644 * @relative_rssi: Relative RSSI threshold in dB to restrict scan result
2645 * reporting in connected state to cases where a matching BSS is determined
2646 * to have better or slightly worse RSSI than the current connected BSS.
2647 * The relative RSSI threshold values are ignored in disconnected state.
2648 * @rssi_adjust: delta dB of RSSI preference to be given to the BSSs that belong
2649 * to the specified band while deciding whether a better BSS is reported
2650 * using @relative_rssi. If delta is a negative number, the BSSs that
2651 * belong to the specified band will be penalized by delta dB in relative
2652 * comparisions.
807f8a8c
LC
2653 */
2654struct cfg80211_sched_scan_request {
96b08fd6 2655 u64 reqid;
807f8a8c
LC
2656 struct cfg80211_ssid *ssids;
2657 int n_ssids;
2658 u32 n_channels;
dcd6eac1 2659 enum nl80211_bss_scan_width scan_width;
807f8a8c
LC
2660 const u8 *ie;
2661 size_t ie_len;
ed473771 2662 u32 flags;
a1f1c21c
LC
2663 struct cfg80211_match_set *match_sets;
2664 int n_match_sets;
ea73cbce 2665 s32 min_rssi_thold;
9c748934 2666 u32 delay;
3b06d277
AS
2667 struct cfg80211_sched_scan_plan *scan_plans;
2668 int n_scan_plans;
807f8a8c 2669
ad2b26ab
JB
2670 u8 mac_addr[ETH_ALEN] __aligned(2);
2671 u8 mac_addr_mask[ETH_ALEN] __aligned(2);
2672
bf95ecdb 2673 bool relative_rssi_set;
2674 s8 relative_rssi;
2675 struct cfg80211_bss_select_adjust rssi_adjust;
2676
807f8a8c
LC
2677 /* internal */
2678 struct wiphy *wiphy;
2679 struct net_device *dev;
15d6030b 2680 unsigned long scan_start;
b34939b9 2681 bool report_results;
31a60ed1 2682 struct rcu_head rcu_head;
93a1e86c 2683 u32 owner_nlportid;
ca986ad9
AVS
2684 bool nl_owner_dead;
2685 struct list_head list;
807f8a8c
LC
2686
2687 /* keep last */
396fba0a 2688 struct ieee80211_channel *channels[];
807f8a8c
LC
2689};
2690
2a519311
JB
2691/**
2692 * enum cfg80211_signal_type - signal type
2693 *
2694 * @CFG80211_SIGNAL_TYPE_NONE: no signal strength information available
2695 * @CFG80211_SIGNAL_TYPE_MBM: signal strength in mBm (100*dBm)
2696 * @CFG80211_SIGNAL_TYPE_UNSPEC: signal strength, increasing from 0 through 100
2697 */
2698enum cfg80211_signal_type {
2699 CFG80211_SIGNAL_TYPE_NONE,
2700 CFG80211_SIGNAL_TYPE_MBM,
2701 CFG80211_SIGNAL_TYPE_UNSPEC,
2702};
2703
6e19bc4b
DS
2704/**
2705 * struct cfg80211_inform_bss - BSS inform data
2706 * @chan: channel the frame was received on
2707 * @scan_width: scan width that was used
2708 * @signal: signal strength value, according to the wiphy's
2709 * signal type
2710 * @boottime_ns: timestamp (CLOCK_BOOTTIME) when the information was
2711 * received; should match the time when the frame was actually
2712 * received by the device (not just by the host, in case it was
2713 * buffered on the device) and be accurate to about 10ms.
2714 * If the frame isn't buffered, just passing the return value of
9285ec4c 2715 * ktime_get_boottime_ns() is likely appropriate.
1d76250b
AS
2716 * @parent_tsf: the time at the start of reception of the first octet of the
2717 * timestamp field of the frame. The time is the TSF of the BSS specified
2718 * by %parent_bssid.
2719 * @parent_bssid: the BSS according to which %parent_tsf is set. This is set to
2720 * the BSS that requested the scan in which the beacon/probe was received.
983dafaa
SD
2721 * @chains: bitmask for filled values in @chain_signal.
2722 * @chain_signal: per-chain signal strength of last received BSS in dBm.
5db25290 2723 * @drv_data: Data to be passed through to @inform_bss
6e19bc4b
DS
2724 */
2725struct cfg80211_inform_bss {
2726 struct ieee80211_channel *chan;
2727 enum nl80211_bss_scan_width scan_width;
2728 s32 signal;
2729 u64 boottime_ns;
1d76250b
AS
2730 u64 parent_tsf;
2731 u8 parent_bssid[ETH_ALEN] __aligned(2);
983dafaa
SD
2732 u8 chains;
2733 s8 chain_signal[IEEE80211_MAX_CHAINS];
5db25290
BB
2734
2735 void *drv_data;
6e19bc4b
DS
2736};
2737
9caf0364 2738/**
2aa4d456 2739 * struct cfg80211_bss_ies - BSS entry IE data
8cef2c9d 2740 * @tsf: TSF contained in the frame that carried these IEs
9caf0364
JB
2741 * @rcu_head: internal use, for freeing
2742 * @len: length of the IEs
0e227084 2743 * @from_beacon: these IEs are known to come from a beacon
9caf0364
JB
2744 * @data: IE data
2745 */
2746struct cfg80211_bss_ies {
8cef2c9d 2747 u64 tsf;
9caf0364
JB
2748 struct rcu_head rcu_head;
2749 int len;
0e227084 2750 bool from_beacon;
9caf0364
JB
2751 u8 data[];
2752};
2753
2a519311
JB
2754/**
2755 * struct cfg80211_bss - BSS description
2756 *
2757 * This structure describes a BSS (which may also be a mesh network)
2758 * for use in scan results and similar.
2759 *
abe37c4b 2760 * @channel: channel this BSS is on
dcd6eac1 2761 * @scan_width: width of the control channel
2a519311 2762 * @bssid: BSSID of the BSS
2a519311
JB
2763 * @beacon_interval: the beacon interval as from the frame
2764 * @capability: the capability field in host byte order
83c7aa1a
JB
2765 * @ies: the information elements (Note that there is no guarantee that these
2766 * are well-formed!); this is a pointer to either the beacon_ies or
2767 * proberesp_ies depending on whether Probe Response frame has been
2768 * received. It is always non-%NULL.
34a6eddb 2769 * @beacon_ies: the information elements from the last Beacon frame
776b3580
JB
2770 * (implementation note: if @hidden_beacon_bss is set this struct doesn't
2771 * own the beacon_ies, but they're just pointers to the ones from the
2772 * @hidden_beacon_bss struct)
34a6eddb 2773 * @proberesp_ies: the information elements from the last Probe Response frame
776b3580
JB
2774 * @hidden_beacon_bss: in case this BSS struct represents a probe response from
2775 * a BSS that hides the SSID in its beacon, this points to the BSS struct
2776 * that holds the beacon data. @beacon_ies is still valid, of course, and
2777 * points to the same data as hidden_beacon_bss->beacon_ies in that case.
851ae31d
JB
2778 * @transmitted_bss: pointer to the transmitted BSS, if this is a
2779 * non-transmitted one (multi-BSSID support)
2780 * @nontrans_list: list of non-transmitted BSS, if this is a transmitted one
2781 * (multi-BSSID support)
77965c97 2782 * @signal: signal strength value (type depends on the wiphy's signal_type)
983dafaa
SD
2783 * @chains: bitmask for filled values in @chain_signal.
2784 * @chain_signal: per-chain signal strength of last received BSS in dBm.
0cd01efb
SS
2785 * @bssid_index: index in the multiple BSS set
2786 * @max_bssid_indicator: max number of members in the BSS set
2a519311
JB
2787 * @priv: private area for driver use, has at least wiphy->bss_priv_size bytes
2788 */
2789struct cfg80211_bss {
2790 struct ieee80211_channel *channel;
dcd6eac1 2791 enum nl80211_bss_scan_width scan_width;
2a519311 2792
9caf0364
JB
2793 const struct cfg80211_bss_ies __rcu *ies;
2794 const struct cfg80211_bss_ies __rcu *beacon_ies;
2795 const struct cfg80211_bss_ies __rcu *proberesp_ies;
2796
776b3580 2797 struct cfg80211_bss *hidden_beacon_bss;
7011ba58
SS
2798 struct cfg80211_bss *transmitted_bss;
2799 struct list_head nontrans_list;
9caf0364
JB
2800
2801 s32 signal;
2802
2a519311
JB
2803 u16 beacon_interval;
2804 u16 capability;
2a519311 2805
9caf0364 2806 u8 bssid[ETH_ALEN];
983dafaa
SD
2807 u8 chains;
2808 s8 chain_signal[IEEE80211_MAX_CHAINS];
2a519311 2809
0cd01efb
SS
2810 u8 bssid_index;
2811 u8 max_bssid_indicator;
2812
396fba0a 2813 u8 priv[] __aligned(sizeof(void *));
2a519311
JB
2814};
2815
49a68e0d
JB
2816/**
2817 * ieee80211_bss_get_elem - find element with given ID
2818 * @bss: the bss to search
2819 * @id: the element ID
2820 *
2821 * Note that the return value is an RCU-protected pointer, so
2822 * rcu_read_lock() must be held when calling this function.
2823 * Return: %NULL if not found.
2824 */
2825const struct element *ieee80211_bss_get_elem(struct cfg80211_bss *bss, u8 id);
2826
517357c6
JB
2827/**
2828 * ieee80211_bss_get_ie - find IE with given ID
2829 * @bss: the bss to search
49a68e0d 2830 * @id: the element ID
9caf0364
JB
2831 *
2832 * Note that the return value is an RCU-protected pointer, so
2833 * rcu_read_lock() must be held when calling this function.
0ae997dc 2834 * Return: %NULL if not found.
517357c6 2835 */
49a68e0d
JB
2836static inline const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 id)
2837{
7e367b06 2838 return (const void *)ieee80211_bss_get_elem(bss, id);
49a68e0d 2839}
517357c6
JB
2840
2841
636a5d36
JM
2842/**
2843 * struct cfg80211_auth_request - Authentication request data
2844 *
2845 * This structure provides information needed to complete IEEE 802.11
2846 * authentication.
19957bb3 2847 *
959867fa
JB
2848 * @bss: The BSS to authenticate with, the callee must obtain a reference
2849 * to it if it needs to keep it.
636a5d36
JM
2850 * @auth_type: Authentication type (algorithm)
2851 * @ie: Extra IEs to add to Authentication frame or %NULL
2852 * @ie_len: Length of ie buffer in octets
fffd0934
JB
2853 * @key_len: length of WEP key for shared key authentication
2854 * @key_idx: index of WEP key for shared key authentication
2855 * @key: WEP key for shared key authentication
11b6b5a4
JM
2856 * @auth_data: Fields and elements in Authentication frames. This contains
2857 * the authentication frame body (non-IE and IE data), excluding the
2858 * Authentication algorithm number, i.e., starting at the Authentication
2859 * transaction sequence number field.
2860 * @auth_data_len: Length of auth_data buffer in octets
d648c230
JB
2861 * @link_id: if >= 0, indicates authentication should be done as an MLD,
2862 * the interface address is included as the MLD address and the
2863 * necessary link (with the given link_id) will be created (and
2864 * given an MLD address) by the driver
2865 * @ap_mld_addr: AP MLD address in case of authentication request with
2866 * an AP MLD, valid iff @link_id >= 0
636a5d36
JM
2867 */
2868struct cfg80211_auth_request {
19957bb3 2869 struct cfg80211_bss *bss;
636a5d36
JM
2870 const u8 *ie;
2871 size_t ie_len;
19957bb3 2872 enum nl80211_auth_type auth_type;
fffd0934 2873 const u8 *key;
23cc6d8c
JB
2874 u8 key_len;
2875 s8 key_idx;
11b6b5a4
JM
2876 const u8 *auth_data;
2877 size_t auth_data_len;
d648c230
JB
2878 s8 link_id;
2879 const u8 *ap_mld_addr;
2880};
2881
2882/**
2883 * struct cfg80211_assoc_link - per-link information for MLO association
2884 * @bss: the BSS pointer, see also &struct cfg80211_assoc_request::bss;
2885 * if this is %NULL for a link, that link is not requested
2886 * @elems: extra elements for the per-STA profile for this link
2887 * @elems_len: length of the elements
6cf963ed
IP
2888 * @disabled: If set this link should be included during association etc. but it
2889 * should not be used until enabled by the AP MLD.
d648c230
JB
2890 */
2891struct cfg80211_assoc_link {
2892 struct cfg80211_bss *bss;
2893 const u8 *elems;
2894 size_t elems_len;
6cf963ed 2895 bool disabled;
636a5d36
JM
2896};
2897
7e7c8926
BG
2898/**
2899 * enum cfg80211_assoc_req_flags - Over-ride default behaviour in association.
2900 *
2901 * @ASSOC_REQ_DISABLE_HT: Disable HT (802.11n)
ee2aca34 2902 * @ASSOC_REQ_DISABLE_VHT: Disable VHT
bab5ab7d 2903 * @ASSOC_REQ_USE_RRM: Declare RRM capability in this association
40cbfa90
SD
2904 * @CONNECT_REQ_EXTERNAL_AUTH_SUPPORT: User space indicates external
2905 * authentication capability. Drivers can offload authentication to
2906 * userspace if this flag is set. Only applicable for cfg80211_connect()
2907 * request (connect callback).
b6db0f89 2908 * @ASSOC_REQ_DISABLE_HE: Disable HE
36f84235 2909 * @ASSOC_REQ_DISABLE_EHT: Disable EHT
efbabc11
VJ
2910 * @CONNECT_REQ_MLO_SUPPORT: Userspace indicates support for handling MLD links.
2911 * Drivers shall disable MLO features for the current association if this
2912 * flag is not set.
7e7c8926
BG
2913 */
2914enum cfg80211_assoc_req_flags {
40cbfa90
SD
2915 ASSOC_REQ_DISABLE_HT = BIT(0),
2916 ASSOC_REQ_DISABLE_VHT = BIT(1),
2917 ASSOC_REQ_USE_RRM = BIT(2),
2918 CONNECT_REQ_EXTERNAL_AUTH_SUPPORT = BIT(3),
b6db0f89 2919 ASSOC_REQ_DISABLE_HE = BIT(4),
36f84235 2920 ASSOC_REQ_DISABLE_EHT = BIT(5),
efbabc11 2921 CONNECT_REQ_MLO_SUPPORT = BIT(6),
7e7c8926
BG
2922};
2923
636a5d36
JM
2924/**
2925 * struct cfg80211_assoc_request - (Re)Association request data
2926 *
2927 * This structure provides information needed to complete IEEE 802.11
2928 * (re)association.
959867fa
JB
2929 * @bss: The BSS to associate with. If the call is successful the driver is
2930 * given a reference that it must give back to cfg80211_send_rx_assoc()
2931 * or to cfg80211_assoc_timeout(). To ensure proper refcounting, new
2932 * association requests while already associating must be rejected.
d648c230
JB
2933 * This also applies to the @links.bss parameter, which is used instead
2934 * of this one (it is %NULL) for MLO associations.
636a5d36
JM
2935 * @ie: Extra IEs to add to (Re)Association Request frame or %NULL
2936 * @ie_len: Length of ie buffer in octets
dc6382ce 2937 * @use_mfp: Use management frame protection (IEEE 802.11w) in this association
b23aa676 2938 * @crypto: crypto settings
35eb8f7b
JM
2939 * @prev_bssid: previous BSSID, if not %NULL use reassociate frame. This is used
2940 * to indicate a request to reassociate within the ESS instead of a request
2941 * do the initial association with the ESS. When included, this is set to
2942 * the BSSID of the current association, i.e., to the value that is
2943 * included in the Current AP address field of the Reassociation Request
2944 * frame.
7e7c8926
BG
2945 * @flags: See &enum cfg80211_assoc_req_flags
2946 * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
ad24b0da 2947 * will be used in ht_capa. Un-supported values will be ignored.
7e7c8926 2948 * @ht_capa_mask: The bits of ht_capa which are to be used.
ee2aca34
JB
2949 * @vht_capa: VHT capability override
2950 * @vht_capa_mask: VHT capability mask indicating which fields to use
348bd456
JM
2951 * @fils_kek: FILS KEK for protecting (Re)Association Request/Response frame or
2952 * %NULL if FILS is not used.
2953 * @fils_kek_len: Length of fils_kek in octets
2954 * @fils_nonces: FILS nonces (part of AAD) for protecting (Re)Association
2955 * Request/Response frame or %NULL if FILS is not used. This field starts
2956 * with 16 octets of STA Nonce followed by 16 octets of AP Nonce.
d2b7588a
TP
2957 * @s1g_capa: S1G capability override
2958 * @s1g_capa_mask: S1G capability override mask
d648c230
JB
2959 * @links: per-link information for MLO connections
2960 * @link_id: >= 0 for MLO connections, where links are given, and indicates
2961 * the link on which the association request should be sent
2962 * @ap_mld_addr: AP MLD address in case of MLO association request,
2963 * valid iff @link_id >= 0
636a5d36
JM
2964 */
2965struct cfg80211_assoc_request {
19957bb3 2966 struct cfg80211_bss *bss;
3e5d7649 2967 const u8 *ie, *prev_bssid;
636a5d36 2968 size_t ie_len;
b23aa676 2969 struct cfg80211_crypto_settings crypto;
19957bb3 2970 bool use_mfp;
7e7c8926
BG
2971 u32 flags;
2972 struct ieee80211_ht_cap ht_capa;
2973 struct ieee80211_ht_cap ht_capa_mask;
ee2aca34 2974 struct ieee80211_vht_cap vht_capa, vht_capa_mask;
348bd456
JM
2975 const u8 *fils_kek;
2976 size_t fils_kek_len;
2977 const u8 *fils_nonces;
d2b7588a 2978 struct ieee80211_s1g_cap s1g_capa, s1g_capa_mask;
d648c230
JB
2979 struct cfg80211_assoc_link links[IEEE80211_MLD_MAX_NUM_LINKS];
2980 const u8 *ap_mld_addr;
2981 s8 link_id;
636a5d36
JM
2982};
2983
2984/**
2985 * struct cfg80211_deauth_request - Deauthentication request data
2986 *
2987 * This structure provides information needed to complete IEEE 802.11
2988 * deauthentication.
2989 *
8f6e0dfc 2990 * @bssid: the BSSID or AP MLD address to deauthenticate from
636a5d36
JM
2991 * @ie: Extra IEs to add to Deauthentication frame or %NULL
2992 * @ie_len: Length of ie buffer in octets
19957bb3 2993 * @reason_code: The reason code for the deauthentication
077f897a
JB
2994 * @local_state_change: if set, change local state only and
2995 * do not set a deauth frame
636a5d36
JM
2996 */
2997struct cfg80211_deauth_request {
95de817b 2998 const u8 *bssid;
636a5d36
JM
2999 const u8 *ie;
3000 size_t ie_len;
19957bb3 3001 u16 reason_code;
6863255b 3002 bool local_state_change;
636a5d36
JM
3003};
3004
3005/**
3006 * struct cfg80211_disassoc_request - Disassociation request data
3007 *
3008 * This structure provides information needed to complete IEEE 802.11
66f00449 3009 * disassociation.
636a5d36 3010 *
8f6e0dfc 3011 * @ap_addr: the BSSID or AP MLD address to disassociate from
636a5d36
JM
3012 * @ie: Extra IEs to add to Disassociation frame or %NULL
3013 * @ie_len: Length of ie buffer in octets
19957bb3 3014 * @reason_code: The reason code for the disassociation
d5cdfacb
JM
3015 * @local_state_change: This is a request for a local state only, i.e., no
3016 * Disassociation frame is to be transmitted.
636a5d36
JM
3017 */
3018struct cfg80211_disassoc_request {
8f6e0dfc 3019 const u8 *ap_addr;
636a5d36
JM
3020 const u8 *ie;
3021 size_t ie_len;
19957bb3 3022 u16 reason_code;
d5cdfacb 3023 bool local_state_change;
636a5d36
JM
3024};
3025
04a773ad
JB
3026/**
3027 * struct cfg80211_ibss_params - IBSS parameters
3028 *
3029 * This structure defines the IBSS parameters for the join_ibss()
3030 * method.
3031 *
3032 * @ssid: The SSID, will always be non-null.
3033 * @ssid_len: The length of the SSID, will always be non-zero.
3034 * @bssid: Fixed BSSID requested, maybe be %NULL, if set do not
3035 * search for IBSSs with a different BSSID.
683b6d3b 3036 * @chandef: defines the channel to use if no other IBSS to join can be found
04a773ad
JB
3037 * @channel_fixed: The channel should be fixed -- do not search for
3038 * IBSSs to join on other channels.
3039 * @ie: information element(s) to include in the beacon
3040 * @ie_len: length of that
8e30bc55 3041 * @beacon_interval: beacon interval to use
fffd0934
JB
3042 * @privacy: this is a protected network, keys will be configured
3043 * after joining
267335d6
AQ
3044 * @control_port: whether user space controls IEEE 802.1X port, i.e.,
3045 * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is
3046 * required to assume that the port is unauthorized until authorized by
3047 * user space. Otherwise, port is marked authorized by default.
c3bfe1f6
DK
3048 * @control_port_over_nl80211: TRUE if userspace expects to exchange control
3049 * port frames over NL80211 instead of the network interface.
5336fa88
SW
3050 * @userspace_handles_dfs: whether user space controls DFS operation, i.e.
3051 * changes the channel when a radar is detected. This is required
3052 * to operate on DFS channels.
fbd2c8dc 3053 * @basic_rates: bitmap of basic rates to use when creating the IBSS
dd5b4cc7 3054 * @mcast_rate: per-band multicast rate index + 1 (0: disabled)
803768f5 3055 * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
ad24b0da 3056 * will be used in ht_capa. Un-supported values will be ignored.
803768f5 3057 * @ht_capa_mask: The bits of ht_capa which are to be used.
9ae3b172 3058 * @wep_keys: static WEP keys, if not NULL points to an array of
cd9b52bf 3059 * CFG80211_MAX_WEP_KEYS WEP keys
9ae3b172 3060 * @wep_tx_key: key index (0..3) of the default TX static WEP key
04a773ad
JB
3061 */
3062struct cfg80211_ibss_params {
c1e5f471
JB
3063 const u8 *ssid;
3064 const u8 *bssid;
683b6d3b 3065 struct cfg80211_chan_def chandef;
c1e5f471 3066 const u8 *ie;
04a773ad 3067 u8 ssid_len, ie_len;
8e30bc55 3068 u16 beacon_interval;
fbd2c8dc 3069 u32 basic_rates;
04a773ad 3070 bool channel_fixed;
fffd0934 3071 bool privacy;
267335d6 3072 bool control_port;
c3bfe1f6 3073 bool control_port_over_nl80211;
5336fa88 3074 bool userspace_handles_dfs;
57fbcce3 3075 int mcast_rate[NUM_NL80211_BANDS];
803768f5
SW
3076 struct ieee80211_ht_cap ht_capa;
3077 struct ieee80211_ht_cap ht_capa_mask;
9ae3b172
TM
3078 struct key_params *wep_keys;
3079 int wep_tx_key;
04a773ad
JB
3080};
3081
38de03d2
AS
3082/**
3083 * struct cfg80211_bss_selection - connection parameters for BSS selection.
3084 *
3085 * @behaviour: requested BSS selection behaviour.
3086 * @param: parameters for requestion behaviour.
3087 * @band_pref: preferred band for %NL80211_BSS_SELECT_ATTR_BAND_PREF.
3088 * @adjust: parameters for %NL80211_BSS_SELECT_ATTR_RSSI_ADJUST.
3089 */
3090struct cfg80211_bss_selection {
3091 enum nl80211_bss_select_attr behaviour;
3092 union {
57fbcce3 3093 enum nl80211_band band_pref;
38de03d2
AS
3094 struct cfg80211_bss_select_adjust adjust;
3095 } param;
3096};
3097
b23aa676
SO
3098/**
3099 * struct cfg80211_connect_params - Connection parameters
3100 *
3101 * This structure provides information needed to complete IEEE 802.11
3102 * authentication and association.
3103 *
3104 * @channel: The channel to use or %NULL if not specified (auto-select based
3105 * on scan results)
1df4a510
JM
3106 * @channel_hint: The channel of the recommended BSS for initial connection or
3107 * %NULL if not specified
b23aa676
SO
3108 * @bssid: The AP BSSID or %NULL if not specified (auto-select based on scan
3109 * results)
1df4a510
JM
3110 * @bssid_hint: The recommended AP BSSID for initial connection to the BSS or
3111 * %NULL if not specified. Unlike the @bssid parameter, the driver is
3112 * allowed to ignore this @bssid_hint if it has knowledge of a better BSS
3113 * to use.
b23aa676
SO
3114 * @ssid: SSID
3115 * @ssid_len: Length of ssid in octets
3116 * @auth_type: Authentication type (algorithm)
abe37c4b
JB
3117 * @ie: IEs for association request
3118 * @ie_len: Length of assoc_ie in octets
b23aa676 3119 * @privacy: indicates whether privacy-enabled APs should be used
cee00a95 3120 * @mfp: indicate whether management frame protection is used
b23aa676 3121 * @crypto: crypto settings
fffd0934
JB
3122 * @key_len: length of WEP key for shared key authentication
3123 * @key_idx: index of WEP key for shared key authentication
3124 * @key: WEP key for shared key authentication
7e7c8926 3125 * @flags: See &enum cfg80211_assoc_req_flags
4486ea98 3126 * @bg_scan_period: Background scan period in seconds
ad24b0da 3127 * or -1 to indicate that default value is to be used.
7e7c8926 3128 * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
ad24b0da 3129 * will be used in ht_capa. Un-supported values will be ignored.
7e7c8926 3130 * @ht_capa_mask: The bits of ht_capa which are to be used.
ee2aca34
JB
3131 * @vht_capa: VHT Capability overrides
3132 * @vht_capa_mask: The bits of vht_capa which are to be used.
34d50519
LD
3133 * @pbss: if set, connect to a PCP instead of AP. Valid for DMG
3134 * networks.
38de03d2 3135 * @bss_select: criteria to be used for BSS selection.
35eb8f7b
JM
3136 * @prev_bssid: previous BSSID, if not %NULL use reassociate frame. This is used
3137 * to indicate a request to reassociate within the ESS instead of a request
3138 * do the initial association with the ESS. When included, this is set to
3139 * the BSSID of the current association, i.e., to the value that is
3140 * included in the Current AP address field of the Reassociation Request
3141 * frame.
a3caf744
VK
3142 * @fils_erp_username: EAP re-authentication protocol (ERP) username part of the
3143 * NAI or %NULL if not specified. This is used to construct FILS wrapped
3144 * data IE.
3145 * @fils_erp_username_len: Length of @fils_erp_username in octets.
3146 * @fils_erp_realm: EAP re-authentication protocol (ERP) realm part of NAI or
3147 * %NULL if not specified. This specifies the domain name of ER server and
3148 * is used to construct FILS wrapped data IE.
3149 * @fils_erp_realm_len: Length of @fils_erp_realm in octets.
3150 * @fils_erp_next_seq_num: The next sequence number to use in the FILS ERP
3151 * messages. This is also used to construct FILS wrapped data IE.
3152 * @fils_erp_rrk: ERP re-authentication Root Key (rRK) used to derive additional
3153 * keys in FILS or %NULL if not specified.
3154 * @fils_erp_rrk_len: Length of @fils_erp_rrk in octets.
3a00df57
AS
3155 * @want_1x: indicates user-space supports and wants to use 802.1X driver
3156 * offload of 4-way handshake.
2a38075c
AAL
3157 * @edmg: define the EDMG channels.
3158 * This may specify multiple channels and bonding options for the driver
3159 * to choose from, based on BSS configuration.
b23aa676
SO
3160 */
3161struct cfg80211_connect_params {
3162 struct ieee80211_channel *channel;
1df4a510 3163 struct ieee80211_channel *channel_hint;
664834de 3164 const u8 *bssid;
1df4a510 3165 const u8 *bssid_hint;
664834de 3166 const u8 *ssid;
b23aa676
SO
3167 size_t ssid_len;
3168 enum nl80211_auth_type auth_type;
4b5800fe 3169 const u8 *ie;
b23aa676
SO
3170 size_t ie_len;
3171 bool privacy;
cee00a95 3172 enum nl80211_mfp mfp;
b23aa676 3173 struct cfg80211_crypto_settings crypto;
fffd0934
JB
3174 const u8 *key;
3175 u8 key_len, key_idx;
7e7c8926 3176 u32 flags;
4486ea98 3177 int bg_scan_period;
7e7c8926
BG
3178 struct ieee80211_ht_cap ht_capa;
3179 struct ieee80211_ht_cap ht_capa_mask;
ee2aca34
JB
3180 struct ieee80211_vht_cap vht_capa;
3181 struct ieee80211_vht_cap vht_capa_mask;
34d50519 3182 bool pbss;
38de03d2 3183 struct cfg80211_bss_selection bss_select;
ba6fbacf 3184 const u8 *prev_bssid;
a3caf744
VK
3185 const u8 *fils_erp_username;
3186 size_t fils_erp_username_len;
3187 const u8 *fils_erp_realm;
3188 size_t fils_erp_realm_len;
3189 u16 fils_erp_next_seq_num;
3190 const u8 *fils_erp_rrk;
3191 size_t fils_erp_rrk_len;
3a00df57 3192 bool want_1x;
2a38075c 3193 struct ieee80211_edmg edmg;
b23aa676
SO
3194};
3195
088e8df8 3196/**
3197 * enum cfg80211_connect_params_changed - Connection parameters being updated
3198 *
3199 * This enum provides information of all connect parameters that
3200 * have to be updated as part of update_connect_params() call.
3201 *
3202 * @UPDATE_ASSOC_IES: Indicates whether association request IEs are updated
7f9a3e15
VK
3203 * @UPDATE_FILS_ERP_INFO: Indicates that FILS connection parameters (realm,
3204 * username, erp sequence number and rrk) are updated
3205 * @UPDATE_AUTH_TYPE: Indicates that authentication type is updated
088e8df8 3206 */
3207enum cfg80211_connect_params_changed {
3208 UPDATE_ASSOC_IES = BIT(0),
7f9a3e15
VK
3209 UPDATE_FILS_ERP_INFO = BIT(1),
3210 UPDATE_AUTH_TYPE = BIT(2),
088e8df8 3211};
3212
b9a5f8ca
JM
3213/**
3214 * enum wiphy_params_flags - set_wiphy_params bitfield values
abe37c4b
JB
3215 * @WIPHY_PARAM_RETRY_SHORT: wiphy->retry_short has changed
3216 * @WIPHY_PARAM_RETRY_LONG: wiphy->retry_long has changed
3217 * @WIPHY_PARAM_FRAG_THRESHOLD: wiphy->frag_threshold has changed
3218 * @WIPHY_PARAM_RTS_THRESHOLD: wiphy->rts_threshold has changed
3219 * @WIPHY_PARAM_COVERAGE_CLASS: coverage class changed
3057dbfd 3220 * @WIPHY_PARAM_DYN_ACK: dynack has been enabled
52539ca8
THJ
3221 * @WIPHY_PARAM_TXQ_LIMIT: TXQ packet limit has been changed
3222 * @WIPHY_PARAM_TXQ_MEMORY_LIMIT: TXQ memory limit has been changed
3223 * @WIPHY_PARAM_TXQ_QUANTUM: TXQ scheduler quantum
b9a5f8ca
JM
3224 */
3225enum wiphy_params_flags {
3226 WIPHY_PARAM_RETRY_SHORT = 1 << 0,
3227 WIPHY_PARAM_RETRY_LONG = 1 << 1,
3228 WIPHY_PARAM_FRAG_THRESHOLD = 1 << 2,
3229 WIPHY_PARAM_RTS_THRESHOLD = 1 << 3,
81077e82 3230 WIPHY_PARAM_COVERAGE_CLASS = 1 << 4,
3057dbfd 3231 WIPHY_PARAM_DYN_ACK = 1 << 5,
52539ca8
THJ
3232 WIPHY_PARAM_TXQ_LIMIT = 1 << 6,
3233 WIPHY_PARAM_TXQ_MEMORY_LIMIT = 1 << 7,
3234 WIPHY_PARAM_TXQ_QUANTUM = 1 << 8,
b9a5f8ca
JM
3235};
3236
36647055
THJ
3237#define IEEE80211_DEFAULT_AIRTIME_WEIGHT 256
3238
3ace10f5
KY
3239/* The per TXQ device queue limit in airtime */
3240#define IEEE80211_DEFAULT_AQL_TXQ_LIMIT_L 5000
3241#define IEEE80211_DEFAULT_AQL_TXQ_LIMIT_H 12000
3242
3243/* The per interface airtime threshold to switch to lower queue limit */
3244#define IEEE80211_AQL_THRESHOLD 24000
3245
67fbb16b
SO
3246/**
3247 * struct cfg80211_pmksa - PMK Security Association
3248 *
3249 * This structure is passed to the set/del_pmksa() method for PMKSA
3250 * caching.
3251 *
a3caf744
VK
3252 * @bssid: The AP's BSSID (may be %NULL).
3253 * @pmkid: The identifier to refer a PMKSA.
3254 * @pmk: The PMK for the PMKSA identified by @pmkid. This is used for key
3255 * derivation by a FILS STA. Otherwise, %NULL.
3256 * @pmk_len: Length of the @pmk. The length of @pmk can differ depending on
3257 * the hash algorithm used to generate this.
3258 * @ssid: SSID to specify the ESS within which a PMKSA is valid when using FILS
3259 * cache identifier (may be %NULL).
3260 * @ssid_len: Length of the @ssid in octets.
3261 * @cache_id: 2-octet cache identifier advertized by a FILS AP identifying the
3262 * scope of PMKSA. This is valid only if @ssid_len is non-zero (may be
3263 * %NULL).
7fc82af8
VJ
3264 * @pmk_lifetime: Maximum lifetime for PMKSA in seconds
3265 * (dot11RSNAConfigPMKLifetime) or 0 if not specified.
3266 * The configured PMKSA must not be used for PMKSA caching after
3267 * expiration and any keys derived from this PMK become invalid on
3268 * expiration, i.e., the current association must be dropped if the PMK
3269 * used for it expires.
3270 * @pmk_reauth_threshold: Threshold time for reauthentication (percentage of
3271 * PMK lifetime, dot11RSNAConfigPMKReauthThreshold) or 0 if not specified.
3272 * Drivers are expected to trigger a full authentication instead of using
3273 * this PMKSA for caching when reassociating to a new BSS after this
3274 * threshold to generate a new PMK before the current one expires.
67fbb16b
SO
3275 */
3276struct cfg80211_pmksa {
c1e5f471
JB
3277 const u8 *bssid;
3278 const u8 *pmkid;
a3caf744
VK
3279 const u8 *pmk;
3280 size_t pmk_len;
3281 const u8 *ssid;
3282 size_t ssid_len;
3283 const u8 *cache_id;
7fc82af8
VJ
3284 u32 pmk_lifetime;
3285 u8 pmk_reauth_threshold;
67fbb16b 3286};
9930380f 3287
ff1b6e69 3288/**
50ac6607 3289 * struct cfg80211_pkt_pattern - packet pattern
ff1b6e69
JB
3290 * @mask: bitmask where to match pattern and where to ignore bytes,
3291 * one bit per byte, in same format as nl80211
3292 * @pattern: bytes to match where bitmask is 1
3293 * @pattern_len: length of pattern (in bytes)
bb92d199 3294 * @pkt_offset: packet offset (in bytes)
ff1b6e69
JB
3295 *
3296 * Internal note: @mask and @pattern are allocated in one chunk of
3297 * memory, free @mask only!
3298 */
50ac6607 3299struct cfg80211_pkt_pattern {
922bd80f 3300 const u8 *mask, *pattern;
ff1b6e69 3301 int pattern_len;
bb92d199 3302 int pkt_offset;
ff1b6e69
JB
3303};
3304
2a0e047e
JB
3305/**
3306 * struct cfg80211_wowlan_tcp - TCP connection parameters
3307 *
3308 * @sock: (internal) socket for source port allocation
3309 * @src: source IP address
3310 * @dst: destination IP address
3311 * @dst_mac: destination MAC address
3312 * @src_port: source port
3313 * @dst_port: destination port
3314 * @payload_len: data payload length
3315 * @payload: data payload buffer
3316 * @payload_seq: payload sequence stamping configuration
3317 * @data_interval: interval at which to send data packets
3318 * @wake_len: wakeup payload match length
3319 * @wake_data: wakeup payload match data
3320 * @wake_mask: wakeup payload match mask
3321 * @tokens_size: length of the tokens buffer
3322 * @payload_tok: payload token usage configuration
3323 */
3324struct cfg80211_wowlan_tcp {
3325 struct socket *sock;
3326 __be32 src, dst;
3327 u16 src_port, dst_port;
3328 u8 dst_mac[ETH_ALEN];
3329 int payload_len;
3330 const u8 *payload;
3331 struct nl80211_wowlan_tcp_data_seq payload_seq;
3332 u32 data_interval;
3333 u32 wake_len;
3334 const u8 *wake_data, *wake_mask;
3335 u32 tokens_size;
3336 /* must be last, variable member */
3337 struct nl80211_wowlan_tcp_data_token payload_tok;
ff1b6e69
JB
3338};
3339
3340/**
3341 * struct cfg80211_wowlan - Wake on Wireless-LAN support info
3342 *
3343 * This structure defines the enabled WoWLAN triggers for the device.
3344 * @any: wake up on any activity -- special trigger if device continues
3345 * operating as normal during suspend
3346 * @disconnect: wake up if getting disconnected
3347 * @magic_pkt: wake up on receiving magic packet
3348 * @patterns: wake up on receiving packet matching a pattern
3349 * @n_patterns: number of patterns
77dbbb13
JB
3350 * @gtk_rekey_failure: wake up on GTK rekey failure
3351 * @eap_identity_req: wake up on EAP identity request packet
3352 * @four_way_handshake: wake up on 4-way handshake
3353 * @rfkill_release: wake up when rfkill is released
2a0e047e
JB
3354 * @tcp: TCP connection establishment/wakeup parameters, see nl80211.h.
3355 * NULL if not configured.
8cd4d456 3356 * @nd_config: configuration for the scan to be used for net detect wake.
ff1b6e69
JB
3357 */
3358struct cfg80211_wowlan {
77dbbb13
JB
3359 bool any, disconnect, magic_pkt, gtk_rekey_failure,
3360 eap_identity_req, four_way_handshake,
3361 rfkill_release;
50ac6607 3362 struct cfg80211_pkt_pattern *patterns;
2a0e047e 3363 struct cfg80211_wowlan_tcp *tcp;
ff1b6e69 3364 int n_patterns;
8cd4d456 3365 struct cfg80211_sched_scan_request *nd_config;
ff1b6e69
JB
3366};
3367
be29b99a
AK
3368/**
3369 * struct cfg80211_coalesce_rules - Coalesce rule parameters
3370 *
3371 * This structure defines coalesce rule for the device.
3372 * @delay: maximum coalescing delay in msecs.
3373 * @condition: condition for packet coalescence.
3374 * see &enum nl80211_coalesce_condition.
3375 * @patterns: array of packet patterns
3376 * @n_patterns: number of patterns
3377 */
3378struct cfg80211_coalesce_rules {
3379 int delay;
3380 enum nl80211_coalesce_condition condition;
3381 struct cfg80211_pkt_pattern *patterns;
3382 int n_patterns;
3383};
3384
3385/**
3386 * struct cfg80211_coalesce - Packet coalescing settings
3387 *
3388 * This structure defines coalescing settings.
3389 * @rules: array of coalesce rules
3390 * @n_rules: number of rules
3391 */
3392struct cfg80211_coalesce {
3393 struct cfg80211_coalesce_rules *rules;
3394 int n_rules;
3395};
3396
8cd4d456
LC
3397/**
3398 * struct cfg80211_wowlan_nd_match - information about the match
3399 *
3400 * @ssid: SSID of the match that triggered the wake up
3401 * @n_channels: Number of channels where the match occurred. This
3402 * value may be zero if the driver can't report the channels.
3403 * @channels: center frequencies of the channels where a match
3404 * occurred (in MHz)
3405 */
3406struct cfg80211_wowlan_nd_match {
3407 struct cfg80211_ssid ssid;
3408 int n_channels;
3409 u32 channels[];
3410};
3411
3412/**
3413 * struct cfg80211_wowlan_nd_info - net detect wake up information
3414 *
3415 * @n_matches: Number of match information instances provided in
3416 * @matches. This value may be zero if the driver can't provide
3417 * match information.
3418 * @matches: Array of pointers to matches containing information about
3419 * the matches that triggered the wake up.
3420 */
3421struct cfg80211_wowlan_nd_info {
3422 int n_matches;
3423 struct cfg80211_wowlan_nd_match *matches[];
3424};
3425
cd8f7cb4
JB
3426/**
3427 * struct cfg80211_wowlan_wakeup - wakeup report
3428 * @disconnect: woke up by getting disconnected
3429 * @magic_pkt: woke up by receiving magic packet
3430 * @gtk_rekey_failure: woke up by GTK rekey failure
3431 * @eap_identity_req: woke up by EAP identity request packet
3432 * @four_way_handshake: woke up by 4-way handshake
3433 * @rfkill_release: woke up by rfkill being released
3434 * @pattern_idx: pattern that caused wakeup, -1 if not due to pattern
3435 * @packet_present_len: copied wakeup packet data
3436 * @packet_len: original wakeup packet length
3437 * @packet: The packet causing the wakeup, if any.
3438 * @packet_80211: For pattern match, magic packet and other data
3439 * frame triggers an 802.3 frame should be reported, for
3440 * disconnect due to deauth 802.11 frame. This indicates which
3441 * it is.
2a0e047e
JB
3442 * @tcp_match: TCP wakeup packet received
3443 * @tcp_connlost: TCP connection lost or failed to establish
3444 * @tcp_nomoretokens: TCP data ran out of tokens
8cd4d456 3445 * @net_detect: if not %NULL, woke up because of net detect
cd8f7cb4
JB
3446 */
3447struct cfg80211_wowlan_wakeup {
3448 bool disconnect, magic_pkt, gtk_rekey_failure,
3449 eap_identity_req, four_way_handshake,
2a0e047e
JB
3450 rfkill_release, packet_80211,
3451 tcp_match, tcp_connlost, tcp_nomoretokens;
cd8f7cb4
JB
3452 s32 pattern_idx;
3453 u32 packet_present_len, packet_len;
3454 const void *packet;
8cd4d456 3455 struct cfg80211_wowlan_nd_info *net_detect;
cd8f7cb4
JB
3456};
3457
e5497d76
JB
3458/**
3459 * struct cfg80211_gtk_rekey_data - rekey data
093a48d2
NE
3460 * @kek: key encryption key (@kek_len bytes)
3461 * @kck: key confirmation key (@kck_len bytes)
78f686ca 3462 * @replay_ctr: replay counter (NL80211_REPLAY_CTR_LEN bytes)
093a48d2 3463 * @kek_len: length of kek
2d8b08fe 3464 * @kck_len: length of kck
093a48d2 3465 * @akm: akm (oui, id)
e5497d76
JB
3466 */
3467struct cfg80211_gtk_rekey_data {
78f686ca 3468 const u8 *kek, *kck, *replay_ctr;
093a48d2
NE
3469 u32 akm;
3470 u8 kek_len, kck_len;
e5497d76
JB
3471};
3472
355199e0
JM
3473/**
3474 * struct cfg80211_update_ft_ies_params - FT IE Information
3475 *
3476 * This structure provides information needed to update the fast transition IE
3477 *
3478 * @md: The Mobility Domain ID, 2 Octet value
3479 * @ie: Fast Transition IEs
3480 * @ie_len: Length of ft_ie in octets
3481 */
3482struct cfg80211_update_ft_ies_params {
3483 u16 md;
3484 const u8 *ie;
3485 size_t ie_len;
3486};
3487
b176e629
AO
3488/**
3489 * struct cfg80211_mgmt_tx_params - mgmt tx parameters
3490 *
3491 * This structure provides information needed to transmit a mgmt frame
3492 *
3493 * @chan: channel to use
3494 * @offchan: indicates wether off channel operation is required
3495 * @wait: duration for ROC
3496 * @buf: buffer to transmit
3497 * @len: buffer length
3498 * @no_cck: don't use cck rates for this frame
3499 * @dont_wait_for_ack: tells the low level not to wait for an ack
34d22ce2
AO
3500 * @n_csa_offsets: length of csa_offsets array
3501 * @csa_offsets: array of all the csa offsets in the frame
95f498bb
JB
3502 * @link_id: for MLO, the link ID to transmit on, -1 if not given; note
3503 * that the link ID isn't validated (much), it's in range but the
3504 * link might not exist (or be used by the receiver STA)
b176e629
AO
3505 */
3506struct cfg80211_mgmt_tx_params {
3507 struct ieee80211_channel *chan;
3508 bool offchan;
3509 unsigned int wait;
3510 const u8 *buf;
3511 size_t len;
3512 bool no_cck;
3513 bool dont_wait_for_ack;
34d22ce2
AO
3514 int n_csa_offsets;
3515 const u16 *csa_offsets;
95f498bb 3516 int link_id;
b176e629
AO
3517};
3518
fa9ffc74
KP
3519/**
3520 * struct cfg80211_dscp_exception - DSCP exception
3521 *
3522 * @dscp: DSCP value that does not adhere to the user priority range definition
3523 * @up: user priority value to which the corresponding DSCP value belongs
3524 */
3525struct cfg80211_dscp_exception {
3526 u8 dscp;
3527 u8 up;
3528};
3529
3530/**
3531 * struct cfg80211_dscp_range - DSCP range definition for user priority
3532 *
3533 * @low: lowest DSCP value of this user priority range, inclusive
3534 * @high: highest DSCP value of this user priority range, inclusive
3535 */
3536struct cfg80211_dscp_range {
3537 u8 low;
3538 u8 high;
3539};
3540
3541/* QoS Map Set element length defined in IEEE Std 802.11-2012, 8.4.2.97 */
3542#define IEEE80211_QOS_MAP_MAX_EX 21
3543#define IEEE80211_QOS_MAP_LEN_MIN 16
3544#define IEEE80211_QOS_MAP_LEN_MAX \
3545 (IEEE80211_QOS_MAP_LEN_MIN + 2 * IEEE80211_QOS_MAP_MAX_EX)
3546
3547/**
3548 * struct cfg80211_qos_map - QoS Map Information
3549 *
3550 * This struct defines the Interworking QoS map setting for DSCP values
3551 *
3552 * @num_des: number of DSCP exceptions (0..21)
3553 * @dscp_exception: optionally up to maximum of 21 DSCP exceptions from
3554 * the user priority DSCP range definition
3555 * @up: DSCP range definition for a particular user priority
3556 */
3557struct cfg80211_qos_map {
3558 u8 num_des;
3559 struct cfg80211_dscp_exception dscp_exception[IEEE80211_QOS_MAP_MAX_EX];
3560 struct cfg80211_dscp_range up[8];
3561};
3562
cb3b7d87
AB
3563/**
3564 * struct cfg80211_nan_conf - NAN configuration
3565 *
3566 * This struct defines NAN configuration parameters
3567 *
3568 * @master_pref: master preference (1 - 255)
8585989d
LC
3569 * @bands: operating bands, a bitmap of &enum nl80211_band values.
3570 * For instance, for NL80211_BAND_2GHZ, bit 0 would be set
3571 * (i.e. BIT(NL80211_BAND_2GHZ)).
cb3b7d87
AB
3572 */
3573struct cfg80211_nan_conf {
3574 u8 master_pref;
8585989d 3575 u8 bands;
cb3b7d87
AB
3576};
3577
a5a9dcf2
AB
3578/**
3579 * enum cfg80211_nan_conf_changes - indicates changed fields in NAN
3580 * configuration
3581 *
3582 * @CFG80211_NAN_CONF_CHANGED_PREF: master preference
8585989d 3583 * @CFG80211_NAN_CONF_CHANGED_BANDS: operating bands
a5a9dcf2
AB
3584 */
3585enum cfg80211_nan_conf_changes {
3586 CFG80211_NAN_CONF_CHANGED_PREF = BIT(0),
8585989d 3587 CFG80211_NAN_CONF_CHANGED_BANDS = BIT(1),
a5a9dcf2
AB
3588};
3589
a442b761
AB
3590/**
3591 * struct cfg80211_nan_func_filter - a NAN function Rx / Tx filter
3592 *
3593 * @filter: the content of the filter
3594 * @len: the length of the filter
3595 */
3596struct cfg80211_nan_func_filter {
3597 const u8 *filter;
3598 u8 len;
3599};
3600
3601/**
3602 * struct cfg80211_nan_func - a NAN function
3603 *
3604 * @type: &enum nl80211_nan_function_type
3605 * @service_id: the service ID of the function
3606 * @publish_type: &nl80211_nan_publish_type
3607 * @close_range: if true, the range should be limited. Threshold is
3608 * implementation specific.
3609 * @publish_bcast: if true, the solicited publish should be broadcasted
3610 * @subscribe_active: if true, the subscribe is active
3611 * @followup_id: the instance ID for follow up
3612 * @followup_reqid: the requestor instance ID for follow up
3613 * @followup_dest: MAC address of the recipient of the follow up
3614 * @ttl: time to live counter in DW.
3615 * @serv_spec_info: Service Specific Info
3616 * @serv_spec_info_len: Service Specific Info length
3617 * @srf_include: if true, SRF is inclusive
3618 * @srf_bf: Bloom Filter
3619 * @srf_bf_len: Bloom Filter length
3620 * @srf_bf_idx: Bloom Filter index
3621 * @srf_macs: SRF MAC addresses
3622 * @srf_num_macs: number of MAC addresses in SRF
3623 * @rx_filters: rx filters that are matched with corresponding peer's tx_filter
3624 * @tx_filters: filters that should be transmitted in the SDF.
3625 * @num_rx_filters: length of &rx_filters.
3626 * @num_tx_filters: length of &tx_filters.
3627 * @instance_id: driver allocated id of the function.
3628 * @cookie: unique NAN function identifier.
3629 */
3630struct cfg80211_nan_func {
3631 enum nl80211_nan_function_type type;
3632 u8 service_id[NL80211_NAN_FUNC_SERVICE_ID_LEN];
3633 u8 publish_type;
3634 bool close_range;
3635 bool publish_bcast;
3636 bool subscribe_active;
3637 u8 followup_id;
3638 u8 followup_reqid;
3639 struct mac_address followup_dest;
3640 u32 ttl;
3641 const u8 *serv_spec_info;
3642 u8 serv_spec_info_len;
3643 bool srf_include;
3644 const u8 *srf_bf;
3645 u8 srf_bf_len;
3646 u8 srf_bf_idx;
3647 struct mac_address *srf_macs;
3648 int srf_num_macs;
3649 struct cfg80211_nan_func_filter *rx_filters;
3650 struct cfg80211_nan_func_filter *tx_filters;
3651 u8 num_tx_filters;
3652 u8 num_rx_filters;
3653 u8 instance_id;
3654 u64 cookie;
3655};
3656
3a00df57
AS
3657/**
3658 * struct cfg80211_pmk_conf - PMK configuration
3659 *
3660 * @aa: authenticator address
3661 * @pmk_len: PMK length in bytes.
3662 * @pmk: the PMK material
3663 * @pmk_r0_name: PMK-R0 Name. NULL if not applicable (i.e., the PMK
3664 * is not PMK-R0). When pmk_r0_name is not NULL, the pmk field
3665 * holds PMK-R0.
3666 */
3667struct cfg80211_pmk_conf {
3668 const u8 *aa;
3669 u8 pmk_len;
3670 const u8 *pmk;
3671 const u8 *pmk_r0_name;
3672};
3673
40cbfa90
SD
3674/**
3675 * struct cfg80211_external_auth_params - Trigger External authentication.
3676 *
3677 * Commonly used across the external auth request and event interfaces.
3678 *
3679 * @action: action type / trigger for external authentication. Only significant
3680 * for the authentication request event interface (driver to user space).
3681 * @bssid: BSSID of the peer with which the authentication has
3682 * to happen. Used by both the authentication request event and
3683 * authentication response command interface.
3684 * @ssid: SSID of the AP. Used by both the authentication request event and
3685 * authentication response command interface.
3686 * @key_mgmt_suite: AKM suite of the respective authentication. Used by the
3687 * authentication request event interface.
3688 * @status: status code, %WLAN_STATUS_SUCCESS for successful authentication,
3689 * use %WLAN_STATUS_UNSPECIFIED_FAILURE if user space cannot give you
3690 * the real status code for failures. Used only for the authentication
3691 * response command interface (user space to driver).
fe494370 3692 * @pmkid: The identifier to refer a PMKSA.
9a47c1ef
VJ
3693 * @mld_addr: MLD address of the peer. Used by the authentication request event
3694 * interface. Driver indicates this to enable MLO during the authentication
3695 * offload to user space. Driver shall look at %NL80211_ATTR_MLO_SUPPORT
3696 * flag capability in NL80211_CMD_CONNECT to know whether the user space
3697 * supports enabling MLO during the authentication offload.
3698 * User space should use the address of the interface (on which the
3699 * authentication request event reported) as self MLD address. User space
3700 * and driver should use MLD addresses in RA, TA and BSSID fields of
3701 * authentication frames sent or received via cfg80211. The driver
3702 * translates the MLD addresses to/from link addresses based on the link
3703 * chosen for the authentication.
40cbfa90
SD
3704 */
3705struct cfg80211_external_auth_params {
3706 enum nl80211_external_auth_action action;
3707 u8 bssid[ETH_ALEN] __aligned(2);
3708 struct cfg80211_ssid ssid;
3709 unsigned int key_mgmt_suite;
3710 u16 status;
fe494370 3711 const u8 *pmkid;
9a47c1ef 3712 u8 mld_addr[ETH_ALEN] __aligned(2);
40cbfa90
SD
3713};
3714
81e54d08 3715/**
3453de98 3716 * struct cfg80211_ftm_responder_stats - FTM responder statistics
81e54d08
PKC
3717 *
3718 * @filled: bitflag of flags using the bits of &enum nl80211_ftm_stats to
3719 * indicate the relevant values in this struct for them
3720 * @success_num: number of FTM sessions in which all frames were successfully
3721 * answered
3722 * @partial_num: number of FTM sessions in which part of frames were
3723 * successfully answered
3724 * @failed_num: number of failed FTM sessions
3725 * @asap_num: number of ASAP FTM sessions
3726 * @non_asap_num: number of non-ASAP FTM sessions
3727 * @total_duration_ms: total sessions durations - gives an indication
3728 * of how much time the responder was busy
3729 * @unknown_triggers_num: number of unknown FTM triggers - triggers from
3730 * initiators that didn't finish successfully the negotiation phase with
3731 * the responder
3732 * @reschedule_requests_num: number of FTM reschedule requests - initiator asks
3733 * for a new scheduling although it already has scheduled FTM slot
3734 * @out_of_window_triggers_num: total FTM triggers out of scheduled window
3735 */
3736struct cfg80211_ftm_responder_stats {
3737 u32 filled;
3738 u32 success_num;
3739 u32 partial_num;
3740 u32 failed_num;
3741 u32 asap_num;
3742 u32 non_asap_num;
3743 u64 total_duration_ms;
3744 u32 unknown_triggers_num;
3745 u32 reschedule_requests_num;
3746 u32 out_of_window_triggers_num;
3747};
3748
9bb7e0f2
JB
3749/**
3750 * struct cfg80211_pmsr_ftm_result - FTM result
3751 * @failure_reason: if this measurement failed (PMSR status is
3752 * %NL80211_PMSR_STATUS_FAILURE), this gives a more precise
3753 * reason than just "failure"
3754 * @burst_index: if reporting partial results, this is the index
3755 * in [0 .. num_bursts-1] of the burst that's being reported
3756 * @num_ftmr_attempts: number of FTM request frames transmitted
3757 * @num_ftmr_successes: number of FTM request frames acked
3758 * @busy_retry_time: if failure_reason is %NL80211_PMSR_FTM_FAILURE_PEER_BUSY,
3759 * fill this to indicate in how many seconds a retry is deemed possible
3760 * by the responder
3761 * @num_bursts_exp: actual number of bursts exponent negotiated
3762 * @burst_duration: actual burst duration negotiated
3763 * @ftms_per_burst: actual FTMs per burst negotiated
3764 * @lci_len: length of LCI information (if present)
3765 * @civicloc_len: length of civic location information (if present)
3766 * @lci: LCI data (may be %NULL)
3767 * @civicloc: civic location data (may be %NULL)
3768 * @rssi_avg: average RSSI over FTM action frames reported
3769 * @rssi_spread: spread of the RSSI over FTM action frames reported
3770 * @tx_rate: bitrate for transmitted FTM action frame response
3771 * @rx_rate: bitrate of received FTM action frame
3772 * @rtt_avg: average of RTTs measured (must have either this or @dist_avg)
3773 * @rtt_variance: variance of RTTs measured (note that standard deviation is
3774 * the square root of the variance)
3775 * @rtt_spread: spread of the RTTs measured
3776 * @dist_avg: average of distances (mm) measured
3777 * (must have either this or @rtt_avg)
3778 * @dist_variance: variance of distances measured (see also @rtt_variance)
3779 * @dist_spread: spread of distances measured (see also @rtt_spread)
3780 * @num_ftmr_attempts_valid: @num_ftmr_attempts is valid
3781 * @num_ftmr_successes_valid: @num_ftmr_successes is valid
3782 * @rssi_avg_valid: @rssi_avg is valid
3783 * @rssi_spread_valid: @rssi_spread is valid
3784 * @tx_rate_valid: @tx_rate is valid
3785 * @rx_rate_valid: @rx_rate is valid
3786 * @rtt_avg_valid: @rtt_avg is valid
3787 * @rtt_variance_valid: @rtt_variance is valid
3788 * @rtt_spread_valid: @rtt_spread is valid
3789 * @dist_avg_valid: @dist_avg is valid
3790 * @dist_variance_valid: @dist_variance is valid
3791 * @dist_spread_valid: @dist_spread is valid
3792 */
3793struct cfg80211_pmsr_ftm_result {
3794 const u8 *lci;
3795 const u8 *civicloc;
3796 unsigned int lci_len;
3797 unsigned int civicloc_len;
3798 enum nl80211_peer_measurement_ftm_failure_reasons failure_reason;
3799 u32 num_ftmr_attempts, num_ftmr_successes;
3800 s16 burst_index;
3801 u8 busy_retry_time;
3802 u8 num_bursts_exp;
3803 u8 burst_duration;
3804 u8 ftms_per_burst;
3805 s32 rssi_avg;
3806 s32 rssi_spread;
3807 struct rate_info tx_rate, rx_rate;
3808 s64 rtt_avg;
3809 s64 rtt_variance;
3810 s64 rtt_spread;
3811 s64 dist_avg;
3812 s64 dist_variance;
3813 s64 dist_spread;
3814
3815 u16 num_ftmr_attempts_valid:1,
3816 num_ftmr_successes_valid:1,
3817 rssi_avg_valid:1,
3818 rssi_spread_valid:1,
3819 tx_rate_valid:1,
3820 rx_rate_valid:1,
3821 rtt_avg_valid:1,
3822 rtt_variance_valid:1,
3823 rtt_spread_valid:1,
3824 dist_avg_valid:1,
3825 dist_variance_valid:1,
3826 dist_spread_valid:1;
3827};
3828
3829/**
3830 * struct cfg80211_pmsr_result - peer measurement result
3831 * @addr: address of the peer
3832 * @host_time: host time (use ktime_get_boottime() adjust to the time when the
3833 * measurement was made)
3834 * @ap_tsf: AP's TSF at measurement time
3835 * @status: status of the measurement
3836 * @final: if reporting partial results, mark this as the last one; if not
3837 * reporting partial results always set this flag
3838 * @ap_tsf_valid: indicates the @ap_tsf value is valid
3839 * @type: type of the measurement reported, note that we only support reporting
3840 * one type at a time, but you can report multiple results separately and
3841 * they're all aggregated for userspace.
2d8b08fe 3842 * @ftm: FTM result
9bb7e0f2
JB
3843 */
3844struct cfg80211_pmsr_result {
3845 u64 host_time, ap_tsf;
3846 enum nl80211_peer_measurement_status status;
3847
3848 u8 addr[ETH_ALEN];
3849
3850 u8 final:1,
3851 ap_tsf_valid:1;
3852
3853 enum nl80211_peer_measurement_type type;
3854
3855 union {
3856 struct cfg80211_pmsr_ftm_result ftm;
3857 };
3858};
3859
3860/**
3861 * struct cfg80211_pmsr_ftm_request_peer - FTM request data
3862 * @requested: indicates FTM is requested
3863 * @preamble: frame preamble to use
3864 * @burst_period: burst period to use
3865 * @asap: indicates to use ASAP mode
3866 * @num_bursts_exp: number of bursts exponent
3867 * @burst_duration: burst duration
3868 * @ftms_per_burst: number of FTMs per burst
3869 * @ftmr_retries: number of retries for FTM request
3870 * @request_lci: request LCI information
3871 * @request_civicloc: request civic location information
efb5520d
AS
3872 * @trigger_based: use trigger based ranging for the measurement
3873 * If neither @trigger_based nor @non_trigger_based is set,
3874 * EDCA based ranging will be used.
3875 * @non_trigger_based: use non trigger based ranging for the measurement
3876 * If neither @trigger_based nor @non_trigger_based is set,
3877 * EDCA based ranging will be used.
73807523 3878 * @lmr_feedback: negotiate for I2R LMR feedback. Only valid if either
dd3e4fc7
AS
3879 * @trigger_based or @non_trigger_based is set.
3880 * @bss_color: the bss color of the responder. Optional. Set to zero to
3881 * indicate the driver should set the BSS color. Only valid if
3882 * @non_trigger_based or @trigger_based is set.
9bb7e0f2
JB
3883 *
3884 * See also nl80211 for the respective attribute documentation.
3885 */
3886struct cfg80211_pmsr_ftm_request_peer {
3887 enum nl80211_preamble preamble;
3888 u16 burst_period;
3889 u8 requested:1,
3890 asap:1,
3891 request_lci:1,
efb5520d
AS
3892 request_civicloc:1,
3893 trigger_based:1,
73807523
AS
3894 non_trigger_based:1,
3895 lmr_feedback:1;
9bb7e0f2
JB
3896 u8 num_bursts_exp;
3897 u8 burst_duration;
3898 u8 ftms_per_burst;
3899 u8 ftmr_retries;
dd3e4fc7 3900 u8 bss_color;
9bb7e0f2
JB
3901};
3902
3903/**
3904 * struct cfg80211_pmsr_request_peer - peer data for a peer measurement request
3905 * @addr: MAC address
3906 * @chandef: channel to use
3907 * @report_ap_tsf: report the associated AP's TSF
3908 * @ftm: FTM data, see &struct cfg80211_pmsr_ftm_request_peer
3909 */
3910struct cfg80211_pmsr_request_peer {
3911 u8 addr[ETH_ALEN];
3912 struct cfg80211_chan_def chandef;
3913 u8 report_ap_tsf:1;
3914 struct cfg80211_pmsr_ftm_request_peer ftm;
3915};
3916
3917/**
3918 * struct cfg80211_pmsr_request - peer measurement request
3919 * @cookie: cookie, set by cfg80211
3920 * @nl_portid: netlink portid - used by cfg80211
3921 * @drv_data: driver data for this request, if required for aborting,
3922 * not otherwise freed or anything by cfg80211
3923 * @mac_addr: MAC address used for (randomised) request
3924 * @mac_addr_mask: MAC address mask used for randomisation, bits that
3925 * are 0 in the mask should be randomised, bits that are 1 should
3926 * be taken from the @mac_addr
3927 * @list: used by cfg80211 to hold on to the request
3928 * @timeout: timeout (in milliseconds) for the whole operation, if
3929 * zero it means there's no timeout
3930 * @n_peers: number of peers to do measurements with
3931 * @peers: per-peer measurement request data
3932 */
3933struct cfg80211_pmsr_request {
3934 u64 cookie;
3935 void *drv_data;
3936 u32 n_peers;
3937 u32 nl_portid;
3938
3939 u32 timeout;
3940
3941 u8 mac_addr[ETH_ALEN] __aligned(2);
3942 u8 mac_addr_mask[ETH_ALEN] __aligned(2);
3943
3944 struct list_head list;
3945
3946 struct cfg80211_pmsr_request_peer peers[];
3947};
3948
cb74e977
SD
3949/**
3950 * struct cfg80211_update_owe_info - OWE Information
3951 *
3952 * This structure provides information needed for the drivers to offload OWE
3953 * (Opportunistic Wireless Encryption) processing to the user space.
3954 *
3955 * Commonly used across update_owe_info request and event interfaces.
3956 *
3957 * @peer: MAC address of the peer device for which the OWE processing
3958 * has to be done.
3959 * @status: status code, %WLAN_STATUS_SUCCESS for successful OWE info
3960 * processing, use %WLAN_STATUS_UNSPECIFIED_FAILURE if user space
3961 * cannot give you the real status code for failures. Used only for
3962 * OWE update request command interface (user space to driver).
3963 * @ie: IEs obtained from the peer or constructed by the user space. These are
3964 * the IEs of the remote peer in the event from the host driver and
3965 * the constructed IEs by the user space in the request interface.
3966 * @ie_len: Length of IEs in octets.
8bb588d9
VJ
3967 * @assoc_link_id: MLO link ID of the AP, with which (re)association requested
3968 * by peer. This will be filled by driver for both MLO and non-MLO station
3969 * connections when the AP affiliated with an MLD. For non-MLD AP mode, it
3970 * will be -1. Used only with OWE update event (driver to user space).
3971 * @peer_mld_addr: For MLO connection, MLD address of the peer. For non-MLO
3972 * connection, it will be all zeros. This is applicable only when
3973 * @assoc_link_id is not -1, i.e., the AP affiliated with an MLD. Used only
3974 * with OWE update event (driver to user space).
cb74e977
SD
3975 */
3976struct cfg80211_update_owe_info {
3977 u8 peer[ETH_ALEN] __aligned(2);
3978 u16 status;
3979 const u8 *ie;
3980 size_t ie_len;
8bb588d9
VJ
3981 int assoc_link_id;
3982 u8 peer_mld_addr[ETH_ALEN] __aligned(2);
cb74e977
SD
3983};
3984
6cd536fe
JB
3985/**
3986 * struct mgmt_frame_regs - management frame registrations data
3987 * @global_stypes: bitmap of management frame subtypes registered
3988 * for the entire device
3989 * @interface_stypes: bitmap of management frame subtypes registered
3990 * for the given interface
2d8b08fe 3991 * @global_mcast_stypes: mcast RX is needed globally for these subtypes
9dba48a6
JB
3992 * @interface_mcast_stypes: mcast RX is needed on this interface
3993 * for these subtypes
6cd536fe
JB
3994 */
3995struct mgmt_frame_regs {
3996 u32 global_stypes, interface_stypes;
9dba48a6 3997 u32 global_mcast_stypes, interface_mcast_stypes;
6cd536fe
JB
3998};
3999
704232c2
JB
4000/**
4001 * struct cfg80211_ops - backend description for wireless configuration
4002 *
4003 * This struct is registered by fullmac card drivers and/or wireless stacks
4004 * in order to handle configuration requests on their interfaces.
4005 *
4006 * All callbacks except where otherwise noted should return 0
4007 * on success or a negative error code.
4008 *
a05829a7
JB
4009 * All operations are invoked with the wiphy mutex held. The RTNL may be
4010 * held in addition (due to wireless extensions) but this cannot be relied
4011 * upon except in cases where documented below. Note that due to ordering,
4012 * the RTNL also cannot be acquired in any handlers.
43fb45cb 4013 *
ff1b6e69
JB
4014 * @suspend: wiphy device needs to be suspended. The variable @wow will
4015 * be %NULL or contain the enabled Wake-on-Wireless triggers that are
4016 * configured for the device.
0378b3f1 4017 * @resume: wiphy device needs to be resumed
6d52563f
JB
4018 * @set_wakeup: Called when WoWLAN is enabled/disabled, use this callback
4019 * to call device_set_wakeup_enable() to enable/disable wakeup from
4020 * the device.
0378b3f1 4021 *
60719ffd 4022 * @add_virtual_intf: create a new virtual interface with the given name,
463d0183 4023 * must set the struct wireless_dev's iftype. Beware: You must create
84efbb84 4024 * the new netdev in the wiphy's network namespace! Returns the struct
98104fde
JB
4025 * wireless_dev, or an ERR_PTR. For P2P device wdevs, the driver must
4026 * also set the address member in the wdev.
a05829a7 4027 * This additionally holds the RTNL to be able to do netdev changes.
704232c2 4028 *
84efbb84 4029 * @del_virtual_intf: remove the virtual interface
a05829a7 4030 * This additionally holds the RTNL to be able to do netdev changes.
55682965 4031 *
60719ffd
JB
4032 * @change_virtual_intf: change type/configuration of virtual interface,
4033 * keep the struct wireless_dev's iftype updated.
a05829a7 4034 * This additionally holds the RTNL to be able to do netdev changes.
55682965 4035 *
f2a0290b
JB
4036 * @add_intf_link: Add a new MLO link to the given interface. Note that
4037 * the wdev->link[] data structure has been updated, so the new link
4038 * address is available.
4039 * @del_intf_link: Remove an MLO link from the given interface.
4040 *
41ade00f 4041 * @add_key: add a key with the given parameters. @mac_addr will be %NULL
e7a7b84e
VJ
4042 * when adding a group key. @link_id will be -1 for non-MLO connection.
4043 * For MLO connection, @link_id will be >= 0 for group key and -1 for
4044 * pairwise key, @mac_addr will be peer's MLD address for MLO pairwise key.
41ade00f
JB
4045 *
4046 * @get_key: get information about the key with the given parameters.
4047 * @mac_addr will be %NULL when requesting information for a group
4048 * key. All pointers given to the @callback function need not be valid
e3da574a
JB
4049 * after it returns. This function should return an error if it is
4050 * not possible to retrieve the key, -ENOENT if it doesn't exist.
e7a7b84e
VJ
4051 * @link_id will be -1 for non-MLO connection. For MLO connection,
4052 * @link_id will be >= 0 for group key and -1 for pairwise key, @mac_addr
4053 * will be peer's MLD address for MLO pairwise key.
41ade00f
JB
4054 *
4055 * @del_key: remove a key given the @mac_addr (%NULL for a group key)
e7a7b84e
VJ
4056 * and @key_index, return -ENOENT if the key doesn't exist. @link_id will
4057 * be -1 for non-MLO connection. For MLO connection, @link_id will be >= 0
4058 * for group key and -1 for pairwise key, @mac_addr will be peer's MLD
4059 * address for MLO pairwise key.
41ade00f 4060 *
e7a7b84e
VJ
4061 * @set_default_key: set the default key on an interface. @link_id will be >= 0
4062 * for MLO connection and -1 for non-MLO connection.
ed1b6cc7 4063 *
e7a7b84e
VJ
4064 * @set_default_mgmt_key: set the default management frame key on an interface.
4065 * @link_id will be >= 0 for MLO connection and -1 for non-MLO connection.
1f7e9f46 4066 *
e7a7b84e
VJ
4067 * @set_default_beacon_key: set the default Beacon frame key on an interface.
4068 * @link_id will be >= 0 for MLO connection and -1 for non-MLO connection.
3cfcf6ac 4069 *
e5497d76
JB
4070 * @set_rekey_data: give the data necessary for GTK rekeying to the driver
4071 *
c04a4ff7
JB
4072 * @start_ap: Start acting in AP mode defined by the parameters.
4073 * @change_beacon: Change the beacon parameters for an access point mode
4074 * interface. This should reject the call when AP mode wasn't started.
4075 * @stop_ap: Stop being an AP, including stopping beaconing.
5727ef1b
JB
4076 *
4077 * @add_station: Add a new station.
89c771e5 4078 * @del_station: Remove a station
bdd90d5e
JB
4079 * @change_station: Modify a given station. Note that flags changes are not much
4080 * validated in cfg80211, in particular the auth/assoc/authorized flags
4081 * might come to the driver in invalid combinations -- make sure to check
77ee7c89
JB
4082 * them, also against the existing state! Drivers must call
4083 * cfg80211_check_station_change() to validate the information.
abe37c4b
JB
4084 * @get_station: get station information for the station identified by @mac
4085 * @dump_station: dump station callback -- resume dump at index @idx
4086 *
4087 * @add_mpath: add a fixed mesh path
4088 * @del_mpath: delete a given mesh path
4089 * @change_mpath: change a given mesh path
4090 * @get_mpath: get a mesh path for the given parameters
4091 * @dump_mpath: dump mesh path callback -- resume dump at index @idx
66be7d2b
HR
4092 * @get_mpp: get a mesh proxy path for the given parameters
4093 * @dump_mpp: dump mesh proxy path callback -- resume dump at index @idx
f52555a4 4094 * @join_mesh: join the mesh network with the specified parameters
8d61ffa5 4095 * (invoked with the wireless_dev mutex held)
f52555a4 4096 * @leave_mesh: leave the current mesh network
8d61ffa5 4097 * (invoked with the wireless_dev mutex held)
2ec600d6 4098 *
24bdd9f4 4099 * @get_mesh_config: Get the current mesh configuration
93da9cc1 4100 *
24bdd9f4 4101 * @update_mesh_config: Update mesh parameters on a running mesh.
93da9cc1 4102 * The mask is a bitfield which tells us which parameters to
4103 * set, and which to leave alone.
4104 *
9f1ba906 4105 * @change_bss: Modify parameters for a given BSS.
31888487 4106 *
5db25290
BB
4107 * @inform_bss: Called by cfg80211 while being informed about new BSS data
4108 * for every BSS found within the reported data or frame. This is called
4109 * from within the cfg8011 inform_bss handlers while holding the bss_lock.
4110 * The data parameter is passed through from drv_data inside
4111 * struct cfg80211_inform_bss.
4112 * The new IE data for the BSS is explicitly passed.
4113 *
31888487 4114 * @set_txq_params: Set TX queue parameters
72bdcf34 4115 *
e8c9bd5b
JB
4116 * @libertas_set_mesh_channel: Only for backward compatibility for libertas,
4117 * as it doesn't implement join_mesh and needs to set the channel to
4118 * join the mesh instead.
4119 *
4120 * @set_monitor_channel: Set the monitor mode channel for the device. If other
4121 * interfaces are active this callback should reject the configuration.
4122 * If no interfaces are active or the device is down, the channel should
4123 * be stored for when a monitor interface becomes active.
9aed3cc1 4124 *
2a519311
JB
4125 * @scan: Request to do a scan. If returning zero, the scan request is given
4126 * the driver, and will be valid until passed to cfg80211_scan_done().
4127 * For scan results, call cfg80211_inform_bss(); you can call this outside
4128 * the scan/scan_done bracket too.
91d3ab46
VK
4129 * @abort_scan: Tell the driver to abort an ongoing scan. The driver shall
4130 * indicate the status of the scan through cfg80211_scan_done().
636a5d36
JM
4131 *
4132 * @auth: Request to authenticate with the specified peer
8d61ffa5 4133 * (invoked with the wireless_dev mutex held)
636a5d36 4134 * @assoc: Request to (re)associate with the specified peer
8d61ffa5 4135 * (invoked with the wireless_dev mutex held)
636a5d36 4136 * @deauth: Request to deauthenticate from the specified peer
8d61ffa5 4137 * (invoked with the wireless_dev mutex held)
636a5d36 4138 * @disassoc: Request to disassociate from the specified peer
8d61ffa5 4139 * (invoked with the wireless_dev mutex held)
04a773ad 4140 *
b23aa676 4141 * @connect: Connect to the ESS with the specified parameters. When connected,
bf1ecd21
JM
4142 * call cfg80211_connect_result()/cfg80211_connect_bss() with status code
4143 * %WLAN_STATUS_SUCCESS. If the connection fails for some reason, call
4144 * cfg80211_connect_result()/cfg80211_connect_bss() with the status code
4145 * from the AP or cfg80211_connect_timeout() if no frame with status code
4146 * was received.
4147 * The driver is allowed to roam to other BSSes within the ESS when the
4148 * other BSS matches the connect parameters. When such roaming is initiated
4149 * by the driver, the driver is expected to verify that the target matches
4150 * the configured security parameters and to use Reassociation Request
4151 * frame instead of Association Request frame.
4152 * The connect function can also be used to request the driver to perform a
4153 * specific roam when connected to an ESS. In that case, the prev_bssid
35eb8f7b 4154 * parameter is set to the BSSID of the currently associated BSS as an
bf1ecd21
JM
4155 * indication of requesting reassociation.
4156 * In both the driver-initiated and new connect() call initiated roaming
4157 * cases, the result of roaming is indicated with a call to
29ce6ecb 4158 * cfg80211_roamed(). (invoked with the wireless_dev mutex held)
088e8df8 4159 * @update_connect_params: Update the connect parameters while connected to a
4160 * BSS. The updated parameters can be used by driver/firmware for
4161 * subsequent BSS selection (roaming) decisions and to form the
4162 * Authentication/(Re)Association Request frames. This call does not
4163 * request an immediate disassociation or reassociation with the current
4164 * BSS, i.e., this impacts only subsequent (re)associations. The bits in
4165 * changed are defined in &enum cfg80211_connect_params_changed.
4166 * (invoked with the wireless_dev mutex held)
0711d638
IP
4167 * @disconnect: Disconnect from the BSS/ESS or stop connection attempts if
4168 * connection is in progress. Once done, call cfg80211_disconnected() in
4169 * case connection was already established (invoked with the
4170 * wireless_dev mutex held), otherwise call cfg80211_connect_timeout().
b23aa676 4171 *
04a773ad
JB
4172 * @join_ibss: Join the specified IBSS (or create if necessary). Once done, call
4173 * cfg80211_ibss_joined(), also call that function when changing BSSID due
4174 * to a merge.
8d61ffa5 4175 * (invoked with the wireless_dev mutex held)
04a773ad 4176 * @leave_ibss: Leave the IBSS.
8d61ffa5 4177 * (invoked with the wireless_dev mutex held)
b9a5f8ca 4178 *
f4e583c8
AQ
4179 * @set_mcast_rate: Set the specified multicast rate (only if vif is in ADHOC or
4180 * MESH mode)
4181 *
b9a5f8ca
JM
4182 * @set_wiphy_params: Notify that wiphy parameters have changed;
4183 * @changed bitfield (see &enum wiphy_params_flags) describes which values
4184 * have changed. The actual parameter values are available in
4185 * struct wiphy. If returning an error, no value should be changed.
7643a2c3 4186 *
1432de07 4187 * @set_tx_power: set the transmit power according to the parameters,
c8442118
JB
4188 * the power passed is in mBm, to get dBm use MBM_TO_DBM(). The
4189 * wdev may be %NULL if power was set for the wiphy, and will
4190 * always be %NULL unless the driver supports per-vif TX power
4191 * (as advertised by the nl80211 feature flag.)
7643a2c3 4192 * @get_tx_power: store the current TX power into the dbm variable;
1f87f7d3
JB
4193 * return 0 if successful
4194 *
4195 * @rfkill_poll: polls the hw rfkill line, use cfg80211 reporting
4196 * functions to adjust rfkill hw state
aff89a9b 4197 *
61fa713c
HS
4198 * @dump_survey: get site survey information.
4199 *
9588bbd5
JM
4200 * @remain_on_channel: Request the driver to remain awake on the specified
4201 * channel for the specified duration to complete an off-channel
4202 * operation (e.g., public action frame exchange). When the driver is
4203 * ready on the requested channel, it must indicate this with an event
4204 * notification by calling cfg80211_ready_on_channel().
4205 * @cancel_remain_on_channel: Cancel an on-going remain-on-channel operation.
4206 * This allows the operation to be terminated prior to timeout based on
4207 * the duration value.
f7ca38df
JB
4208 * @mgmt_tx: Transmit a management frame.
4209 * @mgmt_tx_cancel_wait: Cancel the wait time from transmitting a management
4210 * frame on another channel
9588bbd5 4211 *
fc73f11f 4212 * @testmode_cmd: run a test mode command; @wdev may be %NULL
71063f0e
WYG
4213 * @testmode_dump: Implement a test mode dump. The cb->args[2] and up may be
4214 * used by the function, but 0 and 1 must not be touched. Additionally,
4215 * return error codes other than -ENOBUFS and -ENOENT will terminate the
4216 * dump and return to userspace with an error, so be careful. If any data
4217 * was passed in from userspace then the data/len arguments will be present
4218 * and point to the data contained in %NL80211_ATTR_TESTDATA.
67fbb16b 4219 *
abe37c4b
JB
4220 * @set_bitrate_mask: set the bitrate mask configuration
4221 *
67fbb16b
SO
4222 * @set_pmksa: Cache a PMKID for a BSSID. This is mostly useful for fullmac
4223 * devices running firmwares capable of generating the (re) association
4224 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
4225 * @del_pmksa: Delete a cached PMKID.
4226 * @flush_pmksa: Flush all cached PMKIDs.
9043f3b8
JO
4227 * @set_power_mgmt: Configure WLAN power management. A timeout value of -1
4228 * allows the driver to adjust the dynamic ps timeout value.
d6dc1a38 4229 * @set_cqm_rssi_config: Configure connection quality monitor RSSI threshold.
e86abc68
JB
4230 * After configuration, the driver should (soon) send an event indicating
4231 * the current level is above/below the configured threshold; this may
4232 * need some care when the configuration is changed (without first being
4233 * disabled.)
4a4b8169
AZ
4234 * @set_cqm_rssi_range_config: Configure two RSSI thresholds in the
4235 * connection quality monitor. An event is to be sent only when the
4236 * signal level is found to be outside the two values. The driver should
4237 * set %NL80211_EXT_FEATURE_CQM_RSSI_LIST if this method is implemented.
4238 * If it is provided then there's no point providing @set_cqm_rssi_config.
84f10708
TP
4239 * @set_cqm_txe_config: Configure connection quality monitor TX error
4240 * thresholds.
807f8a8c 4241 * @sched_scan_start: Tell the driver to start a scheduled scan.
3a3ecf1d
AVS
4242 * @sched_scan_stop: Tell the driver to stop an ongoing scheduled scan with
4243 * given request id. This call must stop the scheduled scan and be ready
4244 * for starting a new one before it returns, i.e. @sched_scan_start may be
4245 * called immediately after that again and should not fail in that case.
4246 * The driver should not call cfg80211_sched_scan_stopped() for a requested
4247 * stop (when this method returns 0).
67fbb16b 4248 *
6cd536fe
JB
4249 * @update_mgmt_frame_registrations: Notify the driver that management frame
4250 * registrations were updated. The callback is allowed to sleep.
547025d5
BR
4251 *
4252 * @set_antenna: Set antenna configuration (tx_ant, rx_ant) on the device.
4253 * Parameters are bitmaps of allowed antennas to use for TX/RX. Drivers may
4254 * reject TX/RX mask combinations they cannot support by returning -EINVAL
4255 * (also see nl80211.h @NL80211_ATTR_WIPHY_ANTENNA_TX).
4256 *
4257 * @get_antenna: Get current antenna configuration from device (tx_ant, rx_ant).
3677713b 4258 *
109086ce
AN
4259 * @tdls_mgmt: Transmit a TDLS management frame.
4260 * @tdls_oper: Perform a high-level TDLS operation (e.g. TDLS link setup).
7f6cf311
JB
4261 *
4262 * @probe_client: probe an associated client, must return a cookie that it
4263 * later passes to cfg80211_probe_status().
1d9d9213
SW
4264 *
4265 * @set_noack_map: Set the NoAck Map for the TIDs.
d6199218 4266 *
5b7ccaf3
JB
4267 * @get_channel: Get the current operating channel for the virtual interface.
4268 * For monitor interfaces, it should return %NULL unless there's a single
4269 * current monitoring channel.
98104fde
JB
4270 *
4271 * @start_p2p_device: Start the given P2P device.
4272 * @stop_p2p_device: Stop the given P2P device.
77765eaf
VT
4273 *
4274 * @set_mac_acl: Sets MAC address control list in AP and P2P GO mode.
4275 * Parameters include ACL policy, an array of MAC address of stations
4276 * and the number of MAC addresses. If there is already a list in driver
4277 * this new list replaces the existing one. Driver has to clear its ACL
4278 * when number of MAC addresses entries is passed as 0. Drivers which
4279 * advertise the support for MAC based ACL have to implement this callback.
04f39047
SW
4280 *
4281 * @start_radar_detection: Start radar detection in the driver.
8bf24293 4282 *
26ec17a1
OM
4283 * @end_cac: End running CAC, probably because a related CAC
4284 * was finished on another phy.
4285 *
8bf24293
JM
4286 * @update_ft_ies: Provide updated Fast BSS Transition information to the
4287 * driver. If the SME is in the driver/firmware, this information can be
4288 * used in building Authentication and Reassociation Request frames.
5de17984
AS
4289 *
4290 * @crit_proto_start: Indicates a critical protocol needs more link reliability
4291 * for a given duration (milliseconds). The protocol is provided so the
4292 * driver can take the most appropriate actions.
4293 * @crit_proto_stop: Indicates critical protocol no longer needs increased link
4294 * reliability. This operation can not fail.
be29b99a 4295 * @set_coalesce: Set coalesce parameters.
16ef1fe2 4296 *
97dc94f1
MK
4297 * @channel_switch: initiate channel-switch procedure (with CSA). Driver is
4298 * responsible for veryfing if the switch is possible. Since this is
4299 * inherently tricky driver may decide to disconnect an interface later
4300 * with cfg80211_stop_iface(). This doesn't mean driver can accept
4301 * everything. It should do it's best to verify requests and reject them
4302 * as soon as possible.
fa9ffc74
KP
4303 *
4304 * @set_qos_map: Set QoS mapping information to the driver
e16821bc
JM
4305 *
4306 * @set_ap_chanwidth: Set the AP (including P2P GO) mode channel width for the
4307 * given interface This is used e.g. for dynamic HT 20/40 MHz channel width
4308 * changes during the lifetime of the BSS.
960d01ac
JB
4309 *
4310 * @add_tx_ts: validate (if admitted_time is 0) or add a TX TS to the device
4311 * with the given parameters; action frame exchange has been handled by
4312 * userspace so this just has to modify the TX path to take the TS into
4313 * account.
4314 * If the admitted time is 0 just validate the parameters to make sure
4315 * the session can be created at all; it is valid to just always return
4316 * success for that but that may result in inefficient behaviour (handshake
4317 * with the peer followed by immediate teardown when the addition is later
4318 * rejected)
4319 * @del_tx_ts: remove an existing TX TS
6e0bd6c3
RL
4320 *
4321 * @join_ocb: join the OCB network with the specified parameters
4322 * (invoked with the wireless_dev mutex held)
4323 * @leave_ocb: leave the current OCB network
4324 * (invoked with the wireless_dev mutex held)
1057d35e
AN
4325 *
4326 * @tdls_channel_switch: Start channel-switching with a TDLS peer. The driver
4327 * is responsible for continually initiating channel-switching operations
4328 * and returning to the base channel for communication with the AP.
4329 * @tdls_cancel_channel_switch: Stop channel-switching with a TDLS peer. Both
4330 * peers must be on the base channel when the call completes.
cb3b7d87
AB
4331 * @start_nan: Start the NAN interface.
4332 * @stop_nan: Stop the NAN interface.
a442b761
AB
4333 * @add_nan_func: Add a NAN function. Returns negative value on failure.
4334 * On success @nan_func ownership is transferred to the driver and
4335 * it may access it outside of the scope of this function. The driver
4336 * should free the @nan_func when no longer needed by calling
4337 * cfg80211_free_nan_func().
4338 * On success the driver should assign an instance_id in the
4339 * provided @nan_func.
4340 * @del_nan_func: Delete a NAN function.
a5a9dcf2
AB
4341 * @nan_change_conf: changes NAN configuration. The changed parameters must
4342 * be specified in @changes (using &enum cfg80211_nan_conf_changes);
4343 * All other parameters must be ignored.
ce0ce13a
MB
4344 *
4345 * @set_multicast_to_unicast: configure multicast to unicast conversion for BSS
3a00df57 4346 *
52539ca8
THJ
4347 * @get_txq_stats: Get TXQ stats for interface or phy. If wdev is %NULL, this
4348 * function should return phy stats, and interface stats otherwise.
4349 *
3a00df57
AS
4350 * @set_pmk: configure the PMK to be used for offloaded 802.1X 4-Way handshake.
4351 * If not deleted through @del_pmk the PMK remains valid until disconnect
4352 * upon which the driver should clear it.
4353 * (invoked with the wireless_dev mutex held)
4354 * @del_pmk: delete the previously configured PMK for the given authenticator.
4355 * (invoked with the wireless_dev mutex held)
40cbfa90
SD
4356 *
4357 * @external_auth: indicates result of offloaded authentication processing from
4358 * user space
2576a9ac
DK
4359 *
4360 * @tx_control_port: TX a control port frame (EAPoL). The noencrypt parameter
4361 * tells the driver that the frame should not be encrypted.
81e54d08
PKC
4362 *
4363 * @get_ftm_responder_stats: Retrieve FTM responder statistics, if available.
4364 * Statistics should be cumulative, currently no way to reset is provided.
9bb7e0f2
JB
4365 * @start_pmsr: start peer measurement (e.g. FTM)
4366 * @abort_pmsr: abort peer measurement
cb74e977
SD
4367 *
4368 * @update_owe_info: Provide updated OWE info to driver. Driver implementing SME
4369 * but offloading OWE processing to the user space will get the updated
4370 * DH IE through this interface.
5ab92e7f
RM
4371 *
4372 * @probe_mesh_link: Probe direct Mesh peer's link quality by sending data frame
4373 * and overrule HWMP path selection algorithm.
77f576de
T
4374 * @set_tid_config: TID specific configuration, this can be peer or BSS specific
4375 * This callback may sleep.
3710a8a6
JB
4376 * @reset_tid_config: Reset TID specific configuration for the peer, for the
4377 * given TIDs. This callback may sleep.
70b6ff35
JB
4378 *
4379 * @set_sar_specs: Update the SAR (TX power) settings.
0d2ab3ae
JC
4380 *
4381 * @color_change: Initiate a color change.
e306784a
SM
4382 *
4383 * @set_fils_aad: Set FILS AAD data to the AP driver so that the driver can use
4384 * those to decrypt (Re)Association Request and encrypt (Re)Association
4385 * Response frame.
bc2dfc02 4386 *
a95bfb87 4387 * @set_radar_background: Configure dedicated offchannel chain available for
bc2dfc02
LB
4388 * radar/CAC detection on some hw. This chain can't be used to transmit
4389 * or receive frames and it is bounded to a running wdev.
a95bfb87 4390 * Background radar/CAC detection allows to avoid the CAC downtime
bc2dfc02
LB
4391 * switching to a different channel during CAC detection on the selected
4392 * radar channel.
4393 * The caller is expected to set chandef pointer to NULL in order to
a95bfb87 4394 * disable background CAC/radar detection.
577e5b8c
ST
4395 * @add_link_station: Add a link to a station.
4396 * @mod_link_station: Modify a link of a station.
4397 * @del_link_station: Remove a link of a station.
cbbaf2bb
AS
4398 *
4399 * @set_hw_timestamp: Enable/disable HW timestamping of TM/FTM frames.
704232c2
JB
4400 */
4401struct cfg80211_ops {
ff1b6e69 4402 int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
0378b3f1 4403 int (*resume)(struct wiphy *wiphy);
6d52563f 4404 void (*set_wakeup)(struct wiphy *wiphy, bool enabled);
0378b3f1 4405
84efbb84 4406 struct wireless_dev * (*add_virtual_intf)(struct wiphy *wiphy,
552bff0c 4407 const char *name,
6bab2e19 4408 unsigned char name_assign_type,
84efbb84 4409 enum nl80211_iftype type,
84efbb84
JB
4410 struct vif_params *params);
4411 int (*del_virtual_intf)(struct wiphy *wiphy,
4412 struct wireless_dev *wdev);
e36d56b6
JB
4413 int (*change_virtual_intf)(struct wiphy *wiphy,
4414 struct net_device *dev,
818a986e 4415 enum nl80211_iftype type,
2ec600d6 4416 struct vif_params *params);
41ade00f 4417
f2a0290b
JB
4418 int (*add_intf_link)(struct wiphy *wiphy,
4419 struct wireless_dev *wdev,
4420 unsigned int link_id);
4421 void (*del_intf_link)(struct wiphy *wiphy,
4422 struct wireless_dev *wdev,
4423 unsigned int link_id);
4424
41ade00f 4425 int (*add_key)(struct wiphy *wiphy, struct net_device *netdev,
e7a7b84e
VJ
4426 int link_id, u8 key_index, bool pairwise,
4427 const u8 *mac_addr, struct key_params *params);
41ade00f 4428 int (*get_key)(struct wiphy *wiphy, struct net_device *netdev,
e7a7b84e
VJ
4429 int link_id, u8 key_index, bool pairwise,
4430 const u8 *mac_addr, void *cookie,
41ade00f
JB
4431 void (*callback)(void *cookie, struct key_params*));
4432 int (*del_key)(struct wiphy *wiphy, struct net_device *netdev,
e7a7b84e
VJ
4433 int link_id, u8 key_index, bool pairwise,
4434 const u8 *mac_addr);
41ade00f 4435 int (*set_default_key)(struct wiphy *wiphy,
e7a7b84e 4436 struct net_device *netdev, int link_id,
dbd2fd65 4437 u8 key_index, bool unicast, bool multicast);
3cfcf6ac 4438 int (*set_default_mgmt_key)(struct wiphy *wiphy,
e7a7b84e 4439 struct net_device *netdev, int link_id,
3cfcf6ac 4440 u8 key_index);
56be393f
JM
4441 int (*set_default_beacon_key)(struct wiphy *wiphy,
4442 struct net_device *netdev,
e7a7b84e 4443 int link_id,
56be393f 4444 u8 key_index);
ed1b6cc7 4445
8860020e
JB
4446 int (*start_ap)(struct wiphy *wiphy, struct net_device *dev,
4447 struct cfg80211_ap_settings *settings);
4448 int (*change_beacon)(struct wiphy *wiphy, struct net_device *dev,
4449 struct cfg80211_beacon_data *info);
7b0a0e3c
JB
4450 int (*stop_ap)(struct wiphy *wiphy, struct net_device *dev,
4451 unsigned int link_id);
5727ef1b
JB
4452
4453
4454 int (*add_station)(struct wiphy *wiphy, struct net_device *dev,
3b3a0162
JB
4455 const u8 *mac,
4456 struct station_parameters *params);
5727ef1b 4457 int (*del_station)(struct wiphy *wiphy, struct net_device *dev,
89c771e5 4458 struct station_del_parameters *params);
5727ef1b 4459 int (*change_station)(struct wiphy *wiphy, struct net_device *dev,
3b3a0162
JB
4460 const u8 *mac,
4461 struct station_parameters *params);
fd5b74dc 4462 int (*get_station)(struct wiphy *wiphy, struct net_device *dev,
3b3a0162 4463 const u8 *mac, struct station_info *sinfo);
2ec600d6 4464 int (*dump_station)(struct wiphy *wiphy, struct net_device *dev,
3b3a0162 4465 int idx, u8 *mac, struct station_info *sinfo);
2ec600d6
LCC
4466
4467 int (*add_mpath)(struct wiphy *wiphy, struct net_device *dev,
3b3a0162 4468 const u8 *dst, const u8 *next_hop);
2ec600d6 4469 int (*del_mpath)(struct wiphy *wiphy, struct net_device *dev,
3b3a0162 4470 const u8 *dst);
2ec600d6 4471 int (*change_mpath)(struct wiphy *wiphy, struct net_device *dev,
3b3a0162 4472 const u8 *dst, const u8 *next_hop);
2ec600d6 4473 int (*get_mpath)(struct wiphy *wiphy, struct net_device *dev,
3b3a0162 4474 u8 *dst, u8 *next_hop, struct mpath_info *pinfo);
2ec600d6 4475 int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev,
3b3a0162
JB
4476 int idx, u8 *dst, u8 *next_hop,
4477 struct mpath_info *pinfo);
66be7d2b
HR
4478 int (*get_mpp)(struct wiphy *wiphy, struct net_device *dev,
4479 u8 *dst, u8 *mpp, struct mpath_info *pinfo);
4480 int (*dump_mpp)(struct wiphy *wiphy, struct net_device *dev,
4481 int idx, u8 *dst, u8 *mpp,
4482 struct mpath_info *pinfo);
24bdd9f4 4483 int (*get_mesh_config)(struct wiphy *wiphy,
93da9cc1 4484 struct net_device *dev,
4485 struct mesh_config *conf);
24bdd9f4 4486 int (*update_mesh_config)(struct wiphy *wiphy,
29cbe68c
JB
4487 struct net_device *dev, u32 mask,
4488 const struct mesh_config *nconf);
4489 int (*join_mesh)(struct wiphy *wiphy, struct net_device *dev,
4490 const struct mesh_config *conf,
4491 const struct mesh_setup *setup);
4492 int (*leave_mesh)(struct wiphy *wiphy, struct net_device *dev);
4493
6e0bd6c3
RL
4494 int (*join_ocb)(struct wiphy *wiphy, struct net_device *dev,
4495 struct ocb_setup *setup);
4496 int (*leave_ocb)(struct wiphy *wiphy, struct net_device *dev);
4497
9f1ba906
JM
4498 int (*change_bss)(struct wiphy *wiphy, struct net_device *dev,
4499 struct bss_parameters *params);
31888487 4500
5db25290
BB
4501 void (*inform_bss)(struct wiphy *wiphy, struct cfg80211_bss *bss,
4502 const struct cfg80211_bss_ies *ies, void *data);
4503
f70f01c2 4504 int (*set_txq_params)(struct wiphy *wiphy, struct net_device *dev,
31888487 4505 struct ieee80211_txq_params *params);
72bdcf34 4506
e8c9bd5b
JB
4507 int (*libertas_set_mesh_channel)(struct wiphy *wiphy,
4508 struct net_device *dev,
4509 struct ieee80211_channel *chan);
4510
4511 int (*set_monitor_channel)(struct wiphy *wiphy,
683b6d3b 4512 struct cfg80211_chan_def *chandef);
9aed3cc1 4513
fd014284 4514 int (*scan)(struct wiphy *wiphy,
2a519311 4515 struct cfg80211_scan_request *request);
91d3ab46 4516 void (*abort_scan)(struct wiphy *wiphy, struct wireless_dev *wdev);
636a5d36
JM
4517
4518 int (*auth)(struct wiphy *wiphy, struct net_device *dev,
4519 struct cfg80211_auth_request *req);
4520 int (*assoc)(struct wiphy *wiphy, struct net_device *dev,
4521 struct cfg80211_assoc_request *req);
4522 int (*deauth)(struct wiphy *wiphy, struct net_device *dev,
63c9c5e7 4523 struct cfg80211_deauth_request *req);
636a5d36 4524 int (*disassoc)(struct wiphy *wiphy, struct net_device *dev,
63c9c5e7 4525 struct cfg80211_disassoc_request *req);
04a773ad 4526
b23aa676
SO
4527 int (*connect)(struct wiphy *wiphy, struct net_device *dev,
4528 struct cfg80211_connect_params *sme);
088e8df8 4529 int (*update_connect_params)(struct wiphy *wiphy,
4530 struct net_device *dev,
4531 struct cfg80211_connect_params *sme,
4532 u32 changed);
b23aa676
SO
4533 int (*disconnect)(struct wiphy *wiphy, struct net_device *dev,
4534 u16 reason_code);
4535
04a773ad
JB
4536 int (*join_ibss)(struct wiphy *wiphy, struct net_device *dev,
4537 struct cfg80211_ibss_params *params);
4538 int (*leave_ibss)(struct wiphy *wiphy, struct net_device *dev);
b9a5f8ca 4539
f4e583c8 4540 int (*set_mcast_rate)(struct wiphy *wiphy, struct net_device *dev,
57fbcce3 4541 int rate[NUM_NL80211_BANDS]);
f4e583c8 4542
b9a5f8ca 4543 int (*set_wiphy_params)(struct wiphy *wiphy, u32 changed);
7643a2c3 4544
c8442118 4545 int (*set_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev,
fa61cf70 4546 enum nl80211_tx_power_setting type, int mbm);
c8442118
JB
4547 int (*get_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev,
4548 int *dbm);
1f87f7d3
JB
4549
4550 void (*rfkill_poll)(struct wiphy *wiphy);
aff89a9b
JB
4551
4552#ifdef CONFIG_NL80211_TESTMODE
fc73f11f
DS
4553 int (*testmode_cmd)(struct wiphy *wiphy, struct wireless_dev *wdev,
4554 void *data, int len);
71063f0e
WYG
4555 int (*testmode_dump)(struct wiphy *wiphy, struct sk_buff *skb,
4556 struct netlink_callback *cb,
4557 void *data, int len);
aff89a9b 4558#endif
bc92afd9 4559
9930380f
JB
4560 int (*set_bitrate_mask)(struct wiphy *wiphy,
4561 struct net_device *dev,
7b0a0e3c 4562 unsigned int link_id,
9930380f
JB
4563 const u8 *peer,
4564 const struct cfg80211_bitrate_mask *mask);
4565
61fa713c
HS
4566 int (*dump_survey)(struct wiphy *wiphy, struct net_device *netdev,
4567 int idx, struct survey_info *info);
4568
67fbb16b
SO
4569 int (*set_pmksa)(struct wiphy *wiphy, struct net_device *netdev,
4570 struct cfg80211_pmksa *pmksa);
4571 int (*del_pmksa)(struct wiphy *wiphy, struct net_device *netdev,
4572 struct cfg80211_pmksa *pmksa);
4573 int (*flush_pmksa)(struct wiphy *wiphy, struct net_device *netdev);
4574
9588bbd5 4575 int (*remain_on_channel)(struct wiphy *wiphy,
71bbc994 4576 struct wireless_dev *wdev,
9588bbd5 4577 struct ieee80211_channel *chan,
9588bbd5
JM
4578 unsigned int duration,
4579 u64 *cookie);
4580 int (*cancel_remain_on_channel)(struct wiphy *wiphy,
71bbc994 4581 struct wireless_dev *wdev,
9588bbd5
JM
4582 u64 cookie);
4583
71bbc994 4584 int (*mgmt_tx)(struct wiphy *wiphy, struct wireless_dev *wdev,
b176e629
AO
4585 struct cfg80211_mgmt_tx_params *params,
4586 u64 *cookie);
f7ca38df 4587 int (*mgmt_tx_cancel_wait)(struct wiphy *wiphy,
71bbc994 4588 struct wireless_dev *wdev,
f7ca38df 4589 u64 cookie);
026331c4 4590
bc92afd9
JB
4591 int (*set_power_mgmt)(struct wiphy *wiphy, struct net_device *dev,
4592 bool enabled, int timeout);
d6dc1a38
JO
4593
4594 int (*set_cqm_rssi_config)(struct wiphy *wiphy,
4595 struct net_device *dev,
4596 s32 rssi_thold, u32 rssi_hyst);
271733cf 4597
4a4b8169
AZ
4598 int (*set_cqm_rssi_range_config)(struct wiphy *wiphy,
4599 struct net_device *dev,
4600 s32 rssi_low, s32 rssi_high);
4601
84f10708
TP
4602 int (*set_cqm_txe_config)(struct wiphy *wiphy,
4603 struct net_device *dev,
4604 u32 rate, u32 pkts, u32 intvl);
4605
6cd536fe
JB
4606 void (*update_mgmt_frame_registrations)(struct wiphy *wiphy,
4607 struct wireless_dev *wdev,
4608 struct mgmt_frame_regs *upd);
afe0cbf8
BR
4609
4610 int (*set_antenna)(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant);
4611 int (*get_antenna)(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant);
3677713b 4612
807f8a8c
LC
4613 int (*sched_scan_start)(struct wiphy *wiphy,
4614 struct net_device *dev,
4615 struct cfg80211_sched_scan_request *request);
3a3ecf1d
AVS
4616 int (*sched_scan_stop)(struct wiphy *wiphy, struct net_device *dev,
4617 u64 reqid);
e5497d76
JB
4618
4619 int (*set_rekey_data)(struct wiphy *wiphy, struct net_device *dev,
4620 struct cfg80211_gtk_rekey_data *data);
109086ce
AN
4621
4622 int (*tdls_mgmt)(struct wiphy *wiphy, struct net_device *dev,
c6112046
MS
4623 const u8 *peer, int link_id,
4624 u8 action_code, u8 dialog_token, u16 status_code,
4625 u32 peer_capability, bool initiator,
4626 const u8 *buf, size_t len);
109086ce 4627 int (*tdls_oper)(struct wiphy *wiphy, struct net_device *dev,
3b3a0162 4628 const u8 *peer, enum nl80211_tdls_operation oper);
7f6cf311
JB
4629
4630 int (*probe_client)(struct wiphy *wiphy, struct net_device *dev,
4631 const u8 *peer, u64 *cookie);
e999882a 4632
1d9d9213
SW
4633 int (*set_noack_map)(struct wiphy *wiphy,
4634 struct net_device *dev,
4635 u16 noack_map);
4636
683b6d3b 4637 int (*get_channel)(struct wiphy *wiphy,
5b7ccaf3 4638 struct wireless_dev *wdev,
7b0a0e3c 4639 unsigned int link_id,
683b6d3b 4640 struct cfg80211_chan_def *chandef);
98104fde
JB
4641
4642 int (*start_p2p_device)(struct wiphy *wiphy,
4643 struct wireless_dev *wdev);
4644 void (*stop_p2p_device)(struct wiphy *wiphy,
4645 struct wireless_dev *wdev);
77765eaf
VT
4646
4647 int (*set_mac_acl)(struct wiphy *wiphy, struct net_device *dev,
4648 const struct cfg80211_acl_data *params);
04f39047
SW
4649
4650 int (*start_radar_detection)(struct wiphy *wiphy,
4651 struct net_device *dev,
31559f35
JD
4652 struct cfg80211_chan_def *chandef,
4653 u32 cac_time_ms);
26ec17a1
OM
4654 void (*end_cac)(struct wiphy *wiphy,
4655 struct net_device *dev);
355199e0
JM
4656 int (*update_ft_ies)(struct wiphy *wiphy, struct net_device *dev,
4657 struct cfg80211_update_ft_ies_params *ftie);
5de17984
AS
4658 int (*crit_proto_start)(struct wiphy *wiphy,
4659 struct wireless_dev *wdev,
4660 enum nl80211_crit_proto_id protocol,
4661 u16 duration);
4662 void (*crit_proto_stop)(struct wiphy *wiphy,
4663 struct wireless_dev *wdev);
be29b99a
AK
4664 int (*set_coalesce)(struct wiphy *wiphy,
4665 struct cfg80211_coalesce *coalesce);
16ef1fe2
SW
4666
4667 int (*channel_switch)(struct wiphy *wiphy,
4668 struct net_device *dev,
4669 struct cfg80211_csa_settings *params);
e16821bc 4670
fa9ffc74
KP
4671 int (*set_qos_map)(struct wiphy *wiphy,
4672 struct net_device *dev,
4673 struct cfg80211_qos_map *qos_map);
e16821bc
JM
4674
4675 int (*set_ap_chanwidth)(struct wiphy *wiphy, struct net_device *dev,
7b0a0e3c 4676 unsigned int link_id,
e16821bc 4677 struct cfg80211_chan_def *chandef);
960d01ac
JB
4678
4679 int (*add_tx_ts)(struct wiphy *wiphy, struct net_device *dev,
4680 u8 tsid, const u8 *peer, u8 user_prio,
4681 u16 admitted_time);
4682 int (*del_tx_ts)(struct wiphy *wiphy, struct net_device *dev,
4683 u8 tsid, const u8 *peer);
1057d35e
AN
4684
4685 int (*tdls_channel_switch)(struct wiphy *wiphy,
4686 struct net_device *dev,
4687 const u8 *addr, u8 oper_class,
4688 struct cfg80211_chan_def *chandef);
4689 void (*tdls_cancel_channel_switch)(struct wiphy *wiphy,
4690 struct net_device *dev,
4691 const u8 *addr);
cb3b7d87
AB
4692 int (*start_nan)(struct wiphy *wiphy, struct wireless_dev *wdev,
4693 struct cfg80211_nan_conf *conf);
4694 void (*stop_nan)(struct wiphy *wiphy, struct wireless_dev *wdev);
a442b761
AB
4695 int (*add_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,
4696 struct cfg80211_nan_func *nan_func);
4697 void (*del_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,
4698 u64 cookie);
a5a9dcf2
AB
4699 int (*nan_change_conf)(struct wiphy *wiphy,
4700 struct wireless_dev *wdev,
4701 struct cfg80211_nan_conf *conf,
4702 u32 changes);
ce0ce13a
MB
4703
4704 int (*set_multicast_to_unicast)(struct wiphy *wiphy,
4705 struct net_device *dev,
4706 const bool enabled);
3a00df57 4707
52539ca8
THJ
4708 int (*get_txq_stats)(struct wiphy *wiphy,
4709 struct wireless_dev *wdev,
4710 struct cfg80211_txq_stats *txqstats);
4711
3a00df57
AS
4712 int (*set_pmk)(struct wiphy *wiphy, struct net_device *dev,
4713 const struct cfg80211_pmk_conf *conf);
4714 int (*del_pmk)(struct wiphy *wiphy, struct net_device *dev,
4715 const u8 *aa);
40cbfa90
SD
4716 int (*external_auth)(struct wiphy *wiphy, struct net_device *dev,
4717 struct cfg80211_external_auth_params *params);
2576a9ac
DK
4718
4719 int (*tx_control_port)(struct wiphy *wiphy,
4720 struct net_device *dev,
4721 const u8 *buf, size_t len,
8d74a623 4722 const u8 *dest, const __be16 proto,
67207bab 4723 const bool noencrypt, int link_id,
dca9ca2d 4724 u64 *cookie);
81e54d08
PKC
4725
4726 int (*get_ftm_responder_stats)(struct wiphy *wiphy,
4727 struct net_device *dev,
4728 struct cfg80211_ftm_responder_stats *ftm_stats);
9bb7e0f2
JB
4729
4730 int (*start_pmsr)(struct wiphy *wiphy, struct wireless_dev *wdev,
4731 struct cfg80211_pmsr_request *request);
4732 void (*abort_pmsr)(struct wiphy *wiphy, struct wireless_dev *wdev,
4733 struct cfg80211_pmsr_request *request);
cb74e977
SD
4734 int (*update_owe_info)(struct wiphy *wiphy, struct net_device *dev,
4735 struct cfg80211_update_owe_info *owe_info);
5ab92e7f
RM
4736 int (*probe_mesh_link)(struct wiphy *wiphy, struct net_device *dev,
4737 const u8 *buf, size_t len);
77f576de 4738 int (*set_tid_config)(struct wiphy *wiphy, struct net_device *dev,
3710a8a6 4739 struct cfg80211_tid_config *tid_conf);
77f576de 4740 int (*reset_tid_config)(struct wiphy *wiphy, struct net_device *dev,
3710a8a6 4741 const u8 *peer, u8 tids);
6bdb68ce
CH
4742 int (*set_sar_specs)(struct wiphy *wiphy,
4743 struct cfg80211_sar_specs *sar);
0d2ab3ae
JC
4744 int (*color_change)(struct wiphy *wiphy,
4745 struct net_device *dev,
4746 struct cfg80211_color_change_settings *params);
e306784a
SM
4747 int (*set_fils_aad)(struct wiphy *wiphy, struct net_device *dev,
4748 struct cfg80211_fils_aad *fils_aad);
a95bfb87
LB
4749 int (*set_radar_background)(struct wiphy *wiphy,
4750 struct cfg80211_chan_def *chandef);
577e5b8c
ST
4751 int (*add_link_station)(struct wiphy *wiphy, struct net_device *dev,
4752 struct link_station_parameters *params);
4753 int (*mod_link_station)(struct wiphy *wiphy, struct net_device *dev,
4754 struct link_station_parameters *params);
4755 int (*del_link_station)(struct wiphy *wiphy, struct net_device *dev,
4756 struct link_station_del_parameters *params);
cbbaf2bb
AS
4757 int (*set_hw_timestamp)(struct wiphy *wiphy, struct net_device *dev,
4758 struct cfg80211_set_hw_timestamp *hwts);
704232c2
JB
4759};
4760
d3236553
JB
4761/*
4762 * wireless hardware and networking interfaces structures
4763 * and registration/helper functions
4764 */
4765
4766/**
5be83de5
JB
4767 * enum wiphy_flags - wiphy capability flags
4768 *
c8cb5b85
TM
4769 * @WIPHY_FLAG_SPLIT_SCAN_6GHZ: if set to true, the scan request will be split
4770 * into two, first for legacy bands and second for UHB.
5be83de5
JB
4771 * @WIPHY_FLAG_NETNS_OK: if not set, do not allow changing the netns of this
4772 * wiphy at all
4773 * @WIPHY_FLAG_PS_ON_BY_DEFAULT: if set to true, powersave will be enabled
4774 * by default -- this flag will be set depending on the kernel's default
4775 * on wiphy_new(), but can be changed by the driver if it has a good
4776 * reason to override the default
9bc383de 4777 * @WIPHY_FLAG_4ADDR_AP: supports 4addr mode even on AP (with a single station
33d915d9
MP
4778 * on a VLAN interface). This flag also serves an extra purpose of
4779 * supporting 4ADDR AP mode on devices which do not support AP/VLAN iftype.
9bc383de 4780 * @WIPHY_FLAG_4ADDR_STATION: supports 4addr mode even as a station
c0692b8f
JB
4781 * @WIPHY_FLAG_CONTROL_PORT_PROTOCOL: This device supports setting the
4782 * control port protocol ethertype. The device also honours the
4783 * control_port_no_encrypt flag.
e31b8213 4784 * @WIPHY_FLAG_IBSS_RSN: The device supports IBSS RSN.
15d5dda6
JC
4785 * @WIPHY_FLAG_MESH_AUTH: The device supports mesh authentication by routing
4786 * auth frames to userspace. See @NL80211_MESH_SETUP_USERSPACE_AUTH.
f4b34b55
VN
4787 * @WIPHY_FLAG_SUPPORTS_FW_ROAM: The device supports roaming feature in the
4788 * firmware.
cedb5412 4789 * @WIPHY_FLAG_AP_UAPSD: The device supports uapsd on AP.
109086ce
AN
4790 * @WIPHY_FLAG_SUPPORTS_TDLS: The device supports TDLS (802.11z) operation.
4791 * @WIPHY_FLAG_TDLS_EXTERNAL_SETUP: The device does not handle TDLS (802.11z)
4792 * link setup/discovery operations internally. Setup, discovery and
4793 * teardown packets should be sent through the @NL80211_CMD_TDLS_MGMT
4794 * command. When this flag is not set, @NL80211_CMD_TDLS_OPER should be
4795 * used for asking the driver/firmware to perform a TDLS operation.
562a7480 4796 * @WIPHY_FLAG_HAVE_AP_SME: device integrates AP SME
5e760230
JB
4797 * @WIPHY_FLAG_REPORTS_OBSS: the device will report beacons from other BSSes
4798 * when there are virtual interfaces in AP mode by calling
4799 * cfg80211_report_obss_beacon().
87bbbe22
AN
4800 * @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD: When operating as an AP, the device
4801 * responds to probe-requests in hardware.
7c4ef712
JB
4802 * @WIPHY_FLAG_OFFCHAN_TX: Device supports direct off-channel TX.
4803 * @WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL: Device supports remain-on-channel call.
2f301ab2 4804 * @WIPHY_FLAG_SUPPORTS_5_10_MHZ: Device supports 5 MHz and 10 MHz channels.
16ef1fe2
SW
4805 * @WIPHY_FLAG_HAS_CHANNEL_SWITCH: Device supports channel switch in
4806 * beaconing mode (AP, IBSS, Mesh, ...).
093a48d2 4807 * @WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK: The device supports bigger kek and kck keys
7b0a0e3c
JB
4808 * @WIPHY_FLAG_SUPPORTS_MLO: This is a temporary flag gating the MLO APIs,
4809 * in order to not have them reachable in normal drivers, until we have
4810 * complete feature/interface combinations/etc. advertisement. No driver
4811 * should set this flag for now.
648fba79 4812 * @WIPHY_FLAG_SUPPORTS_EXT_KCK_32: The device supports 32-byte KCK keys.
d99975c4
WG
4813 * @WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER: The device could handle reg notify for
4814 * NL80211_REGDOM_SET_BY_DRIVER.
5be83de5
JB
4815 */
4816enum wiphy_flags {
093a48d2 4817 WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK = BIT(0),
7b0a0e3c 4818 WIPHY_FLAG_SUPPORTS_MLO = BIT(1),
c8cb5b85 4819 WIPHY_FLAG_SPLIT_SCAN_6GHZ = BIT(2),
c0692b8f
JB
4820 WIPHY_FLAG_NETNS_OK = BIT(3),
4821 WIPHY_FLAG_PS_ON_BY_DEFAULT = BIT(4),
4822 WIPHY_FLAG_4ADDR_AP = BIT(5),
4823 WIPHY_FLAG_4ADDR_STATION = BIT(6),
4824 WIPHY_FLAG_CONTROL_PORT_PROTOCOL = BIT(7),
309075cf 4825 WIPHY_FLAG_IBSS_RSN = BIT(8),
15d5dda6 4826 WIPHY_FLAG_MESH_AUTH = BIT(10),
648fba79 4827 WIPHY_FLAG_SUPPORTS_EXT_KCK_32 = BIT(11),
8e8b41f9 4828 /* use hole at 12 */
f4b34b55 4829 WIPHY_FLAG_SUPPORTS_FW_ROAM = BIT(13),
cedb5412 4830 WIPHY_FLAG_AP_UAPSD = BIT(14),
109086ce
AN
4831 WIPHY_FLAG_SUPPORTS_TDLS = BIT(15),
4832 WIPHY_FLAG_TDLS_EXTERNAL_SETUP = BIT(16),
562a7480 4833 WIPHY_FLAG_HAVE_AP_SME = BIT(17),
5e760230 4834 WIPHY_FLAG_REPORTS_OBSS = BIT(18),
87bbbe22 4835 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD = BIT(19),
7c4ef712
JB
4836 WIPHY_FLAG_OFFCHAN_TX = BIT(20),
4837 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL = BIT(21),
2f301ab2 4838 WIPHY_FLAG_SUPPORTS_5_10_MHZ = BIT(22),
16ef1fe2 4839 WIPHY_FLAG_HAS_CHANNEL_SWITCH = BIT(23),
d99975c4 4840 WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER = BIT(24),
7527a782
JB
4841};
4842
4843/**
4844 * struct ieee80211_iface_limit - limit on certain interface types
4845 * @max: maximum number of interfaces of these types
4846 * @types: interface types (bits)
4847 */
4848struct ieee80211_iface_limit {
4849 u16 max;
4850 u16 types;
4851};
4852
4853/**
4854 * struct ieee80211_iface_combination - possible interface combination
7527a782 4855 *
b80edbc1
LC
4856 * With this structure the driver can describe which interface
4857 * combinations it supports concurrently.
7527a782 4858 *
b80edbc1
LC
4859 * Examples:
4860 *
4861 * 1. Allow #STA <= 1, #AP <= 1, matching BI, channels = 1, 2 total:
7527a782 4862 *
819bf593
JB
4863 * .. code-block:: c
4864 *
4865 * struct ieee80211_iface_limit limits1[] = {
4866 * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), },
4d371d6e 4867 * { .max = 1, .types = BIT(NL80211_IFTYPE_AP), },
819bf593
JB
4868 * };
4869 * struct ieee80211_iface_combination combination1 = {
4870 * .limits = limits1,
4871 * .n_limits = ARRAY_SIZE(limits1),
4872 * .max_interfaces = 2,
4873 * .beacon_int_infra_match = true,
4874 * };
7527a782
JB
4875 *
4876 *
b80edbc1 4877 * 2. Allow #{AP, P2P-GO} <= 8, channels = 1, 8 total:
7527a782 4878 *
819bf593
JB
4879 * .. code-block:: c
4880 *
4881 * struct ieee80211_iface_limit limits2[] = {
4882 * { .max = 8, .types = BIT(NL80211_IFTYPE_AP) |
4883 * BIT(NL80211_IFTYPE_P2P_GO), },
4884 * };
4885 * struct ieee80211_iface_combination combination2 = {
4886 * .limits = limits2,
4887 * .n_limits = ARRAY_SIZE(limits2),
4888 * .max_interfaces = 8,
4889 * .num_different_channels = 1,
4890 * };
7527a782
JB
4891 *
4892 *
b80edbc1
LC
4893 * 3. Allow #STA <= 1, #{P2P-client,P2P-GO} <= 3 on two channels, 4 total.
4894 *
819bf593
JB
4895 * This allows for an infrastructure connection and three P2P connections.
4896 *
4897 * .. code-block:: c
4898 *
4899 * struct ieee80211_iface_limit limits3[] = {
4900 * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), },
4901 * { .max = 3, .types = BIT(NL80211_IFTYPE_P2P_GO) |
4902 * BIT(NL80211_IFTYPE_P2P_CLIENT), },
4903 * };
4904 * struct ieee80211_iface_combination combination3 = {
4905 * .limits = limits3,
4906 * .n_limits = ARRAY_SIZE(limits3),
4907 * .max_interfaces = 4,
4908 * .num_different_channels = 2,
4909 * };
7527a782 4910 *
7527a782
JB
4911 */
4912struct ieee80211_iface_combination {
c6c94aea
JB
4913 /**
4914 * @limits:
4915 * limits for the given interface types
4916 */
7527a782 4917 const struct ieee80211_iface_limit *limits;
c6c94aea
JB
4918
4919 /**
4920 * @num_different_channels:
4921 * can use up to this many different channels
4922 */
7527a782 4923 u32 num_different_channels;
c6c94aea
JB
4924
4925 /**
4926 * @max_interfaces:
4927 * maximum number of interfaces in total allowed in this group
4928 */
7527a782 4929 u16 max_interfaces;
c6c94aea
JB
4930
4931 /**
4932 * @n_limits:
4933 * number of limitations
4934 */
7527a782 4935 u8 n_limits;
c6c94aea
JB
4936
4937 /**
4938 * @beacon_int_infra_match:
4939 * In this combination, the beacon intervals between infrastructure
4940 * and AP types must match. This is required only in special cases.
4941 */
7527a782 4942 bool beacon_int_infra_match;
c6c94aea
JB
4943
4944 /**
4945 * @radar_detect_widths:
4946 * bitmap of channel widths supported for radar detection
4947 */
11c4a075 4948 u8 radar_detect_widths;
c6c94aea
JB
4949
4950 /**
4951 * @radar_detect_regions:
4952 * bitmap of regions supported for radar detection
4953 */
8c48b50a 4954 u8 radar_detect_regions;
c6c94aea
JB
4955
4956 /**
4957 * @beacon_int_min_gcd:
4958 * This interface combination supports different beacon intervals.
4959 *
4960 * = 0
4961 * all beacon intervals for different interface must be same.
4962 * > 0
4963 * any beacon interval for the interface part of this combination AND
4964 * GCD of all beacon intervals from beaconing interfaces of this
4965 * combination must be greater or equal to this value.
4966 */
0c317a02 4967 u32 beacon_int_min_gcd;
5be83de5
JB
4968};
4969
2e161f78
JB
4970struct ieee80211_txrx_stypes {
4971 u16 tx, rx;
4972};
4973
ff1b6e69
JB
4974/**
4975 * enum wiphy_wowlan_support_flags - WoWLAN support flags
4976 * @WIPHY_WOWLAN_ANY: supports wakeup for the special "any"
4977 * trigger that keeps the device operating as-is and
4978 * wakes up the host on any activity, for example a
4979 * received packet that passed filtering; note that the
4980 * packet should be preserved in that case
4981 * @WIPHY_WOWLAN_MAGIC_PKT: supports wakeup on magic packet
4982 * (see nl80211.h)
4983 * @WIPHY_WOWLAN_DISCONNECT: supports wakeup on disconnect
77dbbb13
JB
4984 * @WIPHY_WOWLAN_SUPPORTS_GTK_REKEY: supports GTK rekeying while asleep
4985 * @WIPHY_WOWLAN_GTK_REKEY_FAILURE: supports wakeup on GTK rekey failure
4986 * @WIPHY_WOWLAN_EAP_IDENTITY_REQ: supports wakeup on EAP identity request
4987 * @WIPHY_WOWLAN_4WAY_HANDSHAKE: supports wakeup on 4-way handshake failure
4988 * @WIPHY_WOWLAN_RFKILL_RELEASE: supports wakeup on RF-kill release
8cd4d456 4989 * @WIPHY_WOWLAN_NET_DETECT: supports wakeup on network detection
ff1b6e69
JB
4990 */
4991enum wiphy_wowlan_support_flags {
77dbbb13
JB
4992 WIPHY_WOWLAN_ANY = BIT(0),
4993 WIPHY_WOWLAN_MAGIC_PKT = BIT(1),
4994 WIPHY_WOWLAN_DISCONNECT = BIT(2),
4995 WIPHY_WOWLAN_SUPPORTS_GTK_REKEY = BIT(3),
4996 WIPHY_WOWLAN_GTK_REKEY_FAILURE = BIT(4),
4997 WIPHY_WOWLAN_EAP_IDENTITY_REQ = BIT(5),
4998 WIPHY_WOWLAN_4WAY_HANDSHAKE = BIT(6),
4999 WIPHY_WOWLAN_RFKILL_RELEASE = BIT(7),
8cd4d456 5000 WIPHY_WOWLAN_NET_DETECT = BIT(8),
ff1b6e69
JB
5001};
5002
2a0e047e
JB
5003struct wiphy_wowlan_tcp_support {
5004 const struct nl80211_wowlan_tcp_data_token_feature *tok;
5005 u32 data_payload_max;
5006 u32 data_interval_max;
5007 u32 wake_payload_max;
5008 bool seq;
5009};
5010
ff1b6e69
JB
5011/**
5012 * struct wiphy_wowlan_support - WoWLAN support data
5013 * @flags: see &enum wiphy_wowlan_support_flags
5014 * @n_patterns: number of supported wakeup patterns
5015 * (see nl80211.h for the pattern definition)
5016 * @pattern_max_len: maximum length of each pattern
5017 * @pattern_min_len: minimum length of each pattern
bb92d199 5018 * @max_pkt_offset: maximum Rx packet offset
8cd4d456
LC
5019 * @max_nd_match_sets: maximum number of matchsets for net-detect,
5020 * similar, but not necessarily identical, to max_match_sets for
5021 * scheduled scans.
5022 * See &struct cfg80211_sched_scan_request.@match_sets for more
5023 * details.
2a0e047e 5024 * @tcp: TCP wakeup support information
ff1b6e69
JB
5025 */
5026struct wiphy_wowlan_support {
5027 u32 flags;
5028 int n_patterns;
5029 int pattern_max_len;
5030 int pattern_min_len;
bb92d199 5031 int max_pkt_offset;
8cd4d456 5032 int max_nd_match_sets;
2a0e047e 5033 const struct wiphy_wowlan_tcp_support *tcp;
ff1b6e69
JB
5034};
5035
be29b99a
AK
5036/**
5037 * struct wiphy_coalesce_support - coalesce support data
5038 * @n_rules: maximum number of coalesce rules
5039 * @max_delay: maximum supported coalescing delay in msecs
5040 * @n_patterns: number of supported patterns in a rule
5041 * (see nl80211.h for the pattern definition)
5042 * @pattern_max_len: maximum length of each pattern
5043 * @pattern_min_len: minimum length of each pattern
5044 * @max_pkt_offset: maximum Rx packet offset
5045 */
5046struct wiphy_coalesce_support {
5047 int n_rules;
5048 int max_delay;
5049 int n_patterns;
5050 int pattern_max_len;
5051 int pattern_min_len;
5052 int max_pkt_offset;
5053};
5054
ad7e718c
JB
5055/**
5056 * enum wiphy_vendor_command_flags - validation flags for vendor commands
5057 * @WIPHY_VENDOR_CMD_NEED_WDEV: vendor command requires wdev
5058 * @WIPHY_VENDOR_CMD_NEED_NETDEV: vendor command requires netdev
5059 * @WIPHY_VENDOR_CMD_NEED_RUNNING: interface/wdev must be up & running
5060 * (must be combined with %_WDEV or %_NETDEV)
5061 */
5062enum wiphy_vendor_command_flags {
5063 WIPHY_VENDOR_CMD_NEED_WDEV = BIT(0),
5064 WIPHY_VENDOR_CMD_NEED_NETDEV = BIT(1),
5065 WIPHY_VENDOR_CMD_NEED_RUNNING = BIT(2),
5066};
5067
466b9936 5068/**
5069 * enum wiphy_opmode_flag - Station's ht/vht operation mode information flags
5070 *
5071 * @STA_OPMODE_MAX_BW_CHANGED: Max Bandwidth changed
5072 * @STA_OPMODE_SMPS_MODE_CHANGED: SMPS mode changed
5073 * @STA_OPMODE_N_SS_CHANGED: max N_SS (number of spatial streams) changed
5074 *
5075 */
5076enum wiphy_opmode_flag {
5077 STA_OPMODE_MAX_BW_CHANGED = BIT(0),
5078 STA_OPMODE_SMPS_MODE_CHANGED = BIT(1),
5079 STA_OPMODE_N_SS_CHANGED = BIT(2),
5080};
5081
5082/**
5083 * struct sta_opmode_info - Station's ht/vht operation mode information
5084 * @changed: contains value from &enum wiphy_opmode_flag
5e78abd0 5085 * @smps_mode: New SMPS mode value from &enum nl80211_smps_mode of a station
5086 * @bw: new max bandwidth value from &enum nl80211_chan_width of a station
466b9936 5087 * @rx_nss: new rx_nss value of a station
5088 */
5089
5090struct sta_opmode_info {
5091 u32 changed;
5e78abd0 5092 enum nl80211_smps_mode smps_mode;
5093 enum nl80211_chan_width bw;
466b9936 5094 u8 rx_nss;
5095};
5096
91046d63 5097#define VENDOR_CMD_RAW_DATA ((const struct nla_policy *)(long)(-ENODATA))
901bb989 5098
ad7e718c
JB
5099/**
5100 * struct wiphy_vendor_command - vendor command definition
5101 * @info: vendor command identifying information, as used in nl80211
5102 * @flags: flags, see &enum wiphy_vendor_command_flags
5103 * @doit: callback for the operation, note that wdev is %NULL if the
5104 * flags didn't ask for a wdev and non-%NULL otherwise; the data
5105 * pointer may be %NULL if userspace provided no data at all
7bdbe400
JB
5106 * @dumpit: dump callback, for transferring bigger/multiple items. The
5107 * @storage points to cb->args[5], ie. is preserved over the multiple
5108 * dumpit calls.
901bb989
JB
5109 * @policy: policy pointer for attributes within %NL80211_ATTR_VENDOR_DATA.
5110 * Set this to %VENDOR_CMD_RAW_DATA if no policy can be given and the
5111 * attribute is just raw data (e.g. a firmware command).
5112 * @maxattr: highest attribute number in policy
7bdbe400
JB
5113 * It's recommended to not have the same sub command with both @doit and
5114 * @dumpit, so that userspace can assume certain ones are get and others
5115 * are used with dump requests.
ad7e718c
JB
5116 */
5117struct wiphy_vendor_command {
5118 struct nl80211_vendor_cmd_info info;
5119 u32 flags;
5120 int (*doit)(struct wiphy *wiphy, struct wireless_dev *wdev,
5121 const void *data, int data_len);
7bdbe400
JB
5122 int (*dumpit)(struct wiphy *wiphy, struct wireless_dev *wdev,
5123 struct sk_buff *skb, const void *data, int data_len,
5124 unsigned long *storage);
901bb989
JB
5125 const struct nla_policy *policy;
5126 unsigned int maxattr;
ad7e718c
JB
5127};
5128
019ae3a9
KV
5129/**
5130 * struct wiphy_iftype_ext_capab - extended capabilities per interface type
5131 * @iftype: interface type
5132 * @extended_capabilities: extended capabilities supported by the driver,
5133 * additional capabilities might be supported by userspace; these are the
5134 * 802.11 extended capabilities ("Extended Capabilities element") and are
5135 * in the same format as in the information element. See IEEE Std
5136 * 802.11-2012 8.4.2.29 for the defined fields.
5137 * @extended_capabilities_mask: mask of the valid values
5138 * @extended_capabilities_len: length of the extended capabilities
4e9c3af3
JB
5139 * @eml_capabilities: EML capabilities (for MLO)
5140 * @mld_capa_and_ops: MLD capabilities and operations (for MLO)
019ae3a9
KV
5141 */
5142struct wiphy_iftype_ext_capab {
5143 enum nl80211_iftype iftype;
5144 const u8 *extended_capabilities;
5145 const u8 *extended_capabilities_mask;
5146 u8 extended_capabilities_len;
4e9c3af3
JB
5147 u16 eml_capabilities;
5148 u16 mld_capa_and_ops;
019ae3a9
KV
5149};
5150
7464f665
JB
5151/**
5152 * cfg80211_get_iftype_ext_capa - lookup interface type extended capability
5153 * @wiphy: the wiphy to look up from
5154 * @type: the interface type to look up
5155 */
5156const struct wiphy_iftype_ext_capab *
5157cfg80211_get_iftype_ext_capa(struct wiphy *wiphy, enum nl80211_iftype type);
5158
9bb7e0f2
JB
5159/**
5160 * struct cfg80211_pmsr_capabilities - cfg80211 peer measurement capabilities
5161 * @max_peers: maximum number of peers in a single measurement
5162 * @report_ap_tsf: can report assoc AP's TSF for radio resource measurement
5163 * @randomize_mac_addr: can randomize MAC address for measurement
2d8b08fe 5164 * @ftm: FTM measurement data
9bb7e0f2
JB
5165 * @ftm.supported: FTM measurement is supported
5166 * @ftm.asap: ASAP-mode is supported
5167 * @ftm.non_asap: non-ASAP-mode is supported
5168 * @ftm.request_lci: can request LCI data
5169 * @ftm.request_civicloc: can request civic location data
5170 * @ftm.preambles: bitmap of preambles supported (&enum nl80211_preamble)
5171 * @ftm.bandwidths: bitmap of bandwidths supported (&enum nl80211_chan_width)
5172 * @ftm.max_bursts_exponent: maximum burst exponent supported
5173 * (set to -1 if not limited; note that setting this will necessarily
5174 * forbid using the value 15 to let the responder pick)
5175 * @ftm.max_ftms_per_burst: maximum FTMs per burst supported (set to 0 if
5176 * not limited)
efb5520d
AS
5177 * @ftm.trigger_based: trigger based ranging measurement is supported
5178 * @ftm.non_trigger_based: non trigger based ranging measurement is supported
9bb7e0f2
JB
5179 */
5180struct cfg80211_pmsr_capabilities {
5181 unsigned int max_peers;
5182 u8 report_ap_tsf:1,
5183 randomize_mac_addr:1;
5184
5185 struct {
5186 u32 preambles;
5187 u32 bandwidths;
5188 s8 max_bursts_exponent;
5189 u8 max_ftms_per_burst;
5190 u8 supported:1,
5191 asap:1,
5192 non_asap:1,
5193 request_lci:1,
efb5520d
AS
5194 request_civicloc:1,
5195 trigger_based:1,
5196 non_trigger_based:1;
9bb7e0f2
JB
5197 } ftm;
5198};
5199
d6039a34
VJ
5200/**
5201 * struct wiphy_iftype_akm_suites - This structure encapsulates supported akm
5202 * suites for interface types defined in @iftypes_mask. Each type in the
5203 * @iftypes_mask must be unique across all instances of iftype_akm_suites.
5204 *
5205 * @iftypes_mask: bitmask of interfaces types
5206 * @akm_suites: points to an array of supported akm suites
5207 * @n_akm_suites: number of supported AKM suites
5208 */
5209struct wiphy_iftype_akm_suites {
5210 u16 iftypes_mask;
5211 const u32 *akm_suites;
5212 int n_akm_suites;
5213};
5214
cbbaf2bb
AS
5215#define CFG80211_HW_TIMESTAMP_ALL_PEERS 0xffff
5216
5be83de5
JB
5217/**
5218 * struct wiphy - wireless hardware description
a05829a7 5219 * @mtx: mutex for the data (structures) of this device
2784fe91
LR
5220 * @reg_notifier: the driver's regulatory notification callback,
5221 * note that if your driver uses wiphy_apply_custom_regulatory()
5222 * the reg_notifier's request can be passed as NULL
d3236553 5223 * @regd: the driver's regulatory domain, if one was requested via
cd9b52bf 5224 * the regulatory_hint() API. This can be used by the driver
d3236553
JB
5225 * on the reg_notifier() if it chooses to ignore future
5226 * regulatory domain changes caused by other drivers.
5227 * @signal_type: signal type reported in &struct cfg80211_bss.
5228 * @cipher_suites: supported cipher suites
5229 * @n_cipher_suites: number of supported cipher suites
d6039a34
VJ
5230 * @akm_suites: supported AKM suites. These are the default AKMs supported if
5231 * the supported AKMs not advertized for a specific interface type in
5232 * iftype_akm_suites.
ab4dfa20 5233 * @n_akm_suites: number of supported AKM suites
d6039a34
VJ
5234 * @iftype_akm_suites: array of supported akm suites info per interface type.
5235 * Note that the bits in @iftypes_mask inside this structure cannot
5236 * overlap (i.e. only one occurrence of each type is allowed across all
5237 * instances of iftype_akm_suites).
5238 * @num_iftype_akm_suites: number of interface types for which supported akm
5239 * suites are specified separately.
b9a5f8ca
JM
5240 * @retry_short: Retry limit for short frames (dot11ShortRetryLimit)
5241 * @retry_long: Retry limit for long frames (dot11LongRetryLimit)
5242 * @frag_threshold: Fragmentation threshold (dot11FragmentationThreshold);
5243 * -1 = fragmentation disabled, only odd values >= 256 used
5244 * @rts_threshold: RTS threshold (dot11RTSThreshold); -1 = RTS/CTS disabled
abe37c4b 5245 * @_net: the network namespace this wiphy currently lives in
ef15aac6
JB
5246 * @perm_addr: permanent MAC address of this device
5247 * @addr_mask: If the device supports multiple MAC addresses by masking,
5248 * set this to a mask with variable bits set to 1, e.g. if the last
0fcf8ac5 5249 * four bits are variable then set it to 00-00-00-00-00-0f. The actual
ef15aac6
JB
5250 * variable bits shall be determined by the interfaces added, with
5251 * interfaces not matching the mask being rejected to be brought up.
5252 * @n_addresses: number of addresses in @addresses.
5253 * @addresses: If the device has more than one address, set this pointer
5254 * to a list of addresses (6 bytes each). The first one will be used
5255 * by default for perm_addr. In this case, the mask should be set to
5256 * all-zeroes. In this case it is assumed that the device can handle
5257 * the same number of arbitrary MAC addresses.
fd235913
RD
5258 * @registered: protects ->resume and ->suspend sysfs callbacks against
5259 * unregister hardware
edf77192
JP
5260 * @debugfsdir: debugfs directory used for this wiphy (ieee80211/<wiphyname>).
5261 * It will be renamed automatically on wiphy renames
15bc6dfb
JP
5262 * @dev: (virtual) struct device for this wiphy. The item in
5263 * /sys/class/ieee80211/ points to this. You need use set_wiphy_dev()
5264 * (see below).
abe37c4b
JB
5265 * @wext: wireless extension handlers
5266 * @priv: driver private data (sized according to wiphy_new() parameter)
5267 * @interface_modes: bitmask of interfaces types valid for this wiphy,
5268 * must be set by driver
7527a782
JB
5269 * @iface_combinations: Valid interface combinations array, should not
5270 * list single interface types.
5271 * @n_iface_combinations: number of entries in @iface_combinations array.
5272 * @software_iftypes: bitmask of software interface types, these are not
5273 * subject to any restrictions since they are purely managed in SW.
abe37c4b 5274 * @flags: wiphy flags, see &enum wiphy_flags
a2f73b6c
LR
5275 * @regulatory_flags: wiphy regulatory flags, see
5276 * &enum ieee80211_regulatory_flags
1f074bd8 5277 * @features: features advertised to nl80211, see &enum nl80211_feature_flags.
d75bb06b
GKS
5278 * @ext_features: extended features advertised to nl80211, see
5279 * &enum nl80211_ext_feature_index.
abe37c4b
JB
5280 * @bss_priv_size: each BSS struct has private data allocated with it,
5281 * this variable determines its size
5282 * @max_scan_ssids: maximum number of SSIDs the device can scan for in
5283 * any given scan
ca986ad9
AVS
5284 * @max_sched_scan_reqs: maximum number of scheduled scan requests that
5285 * the device can run concurrently.
93b6aa69
LC
5286 * @max_sched_scan_ssids: maximum number of SSIDs the device can scan
5287 * for in any given scheduled scan
a1f1c21c
LC
5288 * @max_match_sets: maximum number of match sets the device can handle
5289 * when performing a scheduled scan, 0 if filtering is not
5290 * supported.
abe37c4b
JB
5291 * @max_scan_ie_len: maximum length of user-controlled IEs device can
5292 * add to probe request frames transmitted during a scan, must not
5293 * include fixed IEs like supported rates
5a865bad
LC
5294 * @max_sched_scan_ie_len: same as max_scan_ie_len, but for scheduled
5295 * scans
3b06d277
AS
5296 * @max_sched_scan_plans: maximum number of scan plans (scan interval and number
5297 * of iterations) for scheduled scan supported by the device.
5298 * @max_sched_scan_plan_interval: maximum interval (in seconds) for a
5299 * single scan plan supported by the device.
5300 * @max_sched_scan_plan_iterations: maximum number of iterations for a single
5301 * scan plan supported by the device.
abe37c4b
JB
5302 * @coverage_class: current coverage class
5303 * @fw_version: firmware version for ethtool reporting
5304 * @hw_version: hardware version for ethtool reporting
5305 * @max_num_pmkids: maximum number of PMKIDs supported by device
5306 * @privid: a pointer that drivers can use to identify if an arbitrary
5307 * wiphy is theirs, e.g. in global notifiers
5308 * @bands: information about bands/channels supported by this device
2e161f78
JB
5309 *
5310 * @mgmt_stypes: bitmasks of frame subtypes that can be subscribed to or
5311 * transmitted through nl80211, points to an array indexed by interface
5312 * type
a7ffac95 5313 *
7f531e03
BR
5314 * @available_antennas_tx: bitmap of antennas which are available to be
5315 * configured as TX antennas. Antenna configuration commands will be
5316 * rejected unless this or @available_antennas_rx is set.
5317 *
5318 * @available_antennas_rx: bitmap of antennas which are available to be
5319 * configured as RX antennas. Antenna configuration commands will be
5320 * rejected unless this or @available_antennas_tx is set.
a293911d 5321 *
15f0ebc2
RD
5322 * @probe_resp_offload:
5323 * Bitmap of supported protocols for probe response offloading.
5324 * See &enum nl80211_probe_resp_offload_support_attr. Only valid
5325 * when the wiphy flag @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD is set.
5326 *
a293911d
JB
5327 * @max_remain_on_channel_duration: Maximum time a remain-on-channel operation
5328 * may request, if implemented.
ff1b6e69
JB
5329 *
5330 * @wowlan: WoWLAN support information
6abb9cb9
JB
5331 * @wowlan_config: current WoWLAN configuration; this should usually not be
5332 * used since access to it is necessarily racy, use the parameter passed
5333 * to the suspend() operation instead.
562a7480
JB
5334 *
5335 * @ap_sme_capa: AP SME capabilities, flags from &enum nl80211_ap_sme_features.
7e7c8926
BG
5336 * @ht_capa_mod_mask: Specify what ht_cap values can be over-ridden.
5337 * If null, then none can be over-ridden.
ee2aca34
JB
5338 * @vht_capa_mod_mask: Specify what VHT capabilities can be over-ridden.
5339 * If null, then none can be over-ridden.
77765eaf 5340 *
53873f13
JB
5341 * @wdev_list: the list of associated (virtual) interfaces; this list must
5342 * not be modified by the driver, but can be read with RTNL/RCU protection.
5343 *
77765eaf
VT
5344 * @max_acl_mac_addrs: Maximum number of MAC addresses that the device
5345 * supports for ACL.
a50df0c4
JB
5346 *
5347 * @extended_capabilities: extended capabilities supported by the driver,
5348 * additional capabilities might be supported by userspace; these are
5349 * the 802.11 extended capabilities ("Extended Capabilities element")
5350 * and are in the same format as in the information element. See
019ae3a9
KV
5351 * 802.11-2012 8.4.2.29 for the defined fields. These are the default
5352 * extended capabilities to be used if the capabilities are not specified
5353 * for a specific interface type in iftype_ext_capab.
a50df0c4
JB
5354 * @extended_capabilities_mask: mask of the valid values
5355 * @extended_capabilities_len: length of the extended capabilities
019ae3a9
KV
5356 * @iftype_ext_capab: array of extended capabilities per interface type
5357 * @num_iftype_ext_capab: number of interface types for which extended
5358 * capabilities are specified separately.
be29b99a 5359 * @coalesce: packet coalescing support information
ad7e718c
JB
5360 *
5361 * @vendor_commands: array of vendor commands supported by the hardware
5362 * @n_vendor_commands: number of vendor commands
567ffc35
JB
5363 * @vendor_events: array of vendor events supported by the hardware
5364 * @n_vendor_events: number of vendor events
b43504cf
JM
5365 *
5366 * @max_ap_assoc_sta: maximum number of associated stations supported in AP mode
5367 * (including P2P GO) or 0 to indicate no such limit is advertised. The
5368 * driver is allowed to advertise a theoretical limit that it can reach in
5369 * some cases, but may not always reach.
c2e4323b
LC
5370 *
5371 * @max_num_csa_counters: Number of supported csa_counters in beacons
5372 * and probe responses. This value should be set if the driver
5373 * wishes to limit the number of csa counters. Default (0) means
5374 * infinite.
38de03d2
AS
5375 * @bss_select_support: bitmask indicating the BSS selection criteria supported
5376 * by the driver in the .connect() callback. The bit position maps to the
5377 * attribute indices defined in &enum nl80211_bss_select_attr.
a442b761 5378 *
8585989d
LC
5379 * @nan_supported_bands: bands supported by the device in NAN mode, a
5380 * bitmap of &enum nl80211_band values. For instance, for
5381 * NL80211_BAND_2GHZ, bit 0 would be set
5382 * (i.e. BIT(NL80211_BAND_2GHZ)).
f3a7ca64
JB
5383 *
5384 * @txq_limit: configuration of internal TX queue frame limit
5385 * @txq_memory_limit: configuration internal TX queue memory limit
5386 * @txq_quantum: configuration of internal TX queue scheduler quantum
9bb7e0f2 5387 *
a710d214
LR
5388 * @tx_queue_len: allow setting transmit queue len for drivers not using
5389 * wake_tx_queue
5390 *
213ed579
SS
5391 * @support_mbssid: can HW support association with nontransmitted AP
5392 * @support_only_he_mbssid: don't parse MBSSID elements if it is not
5393 * HE AP, in order to avoid compatibility issues.
5394 * @support_mbssid must be set for this to have any effect.
5395 *
9bb7e0f2 5396 * @pmsr_capa: peer measurement capabilities
3710a8a6
JB
5397 *
5398 * @tid_config_support: describes the per-TID config support that the
5399 * device has
5400 * @tid_config_support.vif: bitmap of attributes (configurations)
5401 * supported by the driver for each vif
5402 * @tid_config_support.peer: bitmap of attributes (configurations)
5403 * supported by the driver for each peer
6a21d16c
T
5404 * @tid_config_support.max_retry: maximum supported retry count for
5405 * long/short retry configuration
a710d214
LR
5406 *
5407 * @max_data_retry_count: maximum supported per TID retry count for
5408 * configuration through the %NL80211_TID_CONFIG_ATTR_RETRY_SHORT and
5409 * %NL80211_TID_CONFIG_ATTR_RETRY_LONG attributes
70b6ff35 5410 * @sar_capa: SAR control capabilities
358ae888 5411 * @rfkill: a pointer to the rfkill structure
dc1e3cb8
JC
5412 *
5413 * @mbssid_max_interfaces: maximum number of interfaces supported by the driver
5414 * in a multiple BSSID set. This field must be set to a non-zero value
5415 * by the driver to advertise MBSSID support.
f9d366d4 5416 * @ema_max_profile_periodicity: maximum profile periodicity supported by
dc1e3cb8
JC
5417 * the driver. Setting this field to a non-zero value indicates that the
5418 * driver supports enhanced multi-BSSID advertisements (EMA AP).
ecad3b0b
VJ
5419 * @max_num_akm_suites: maximum number of AKM suites allowed for
5420 * configuration through %NL80211_CMD_CONNECT, %NL80211_CMD_ASSOCIATE and
5421 * %NL80211_CMD_START_AP. Set to NL80211_MAX_NR_AKM_SUITES if not set by
5422 * driver. If set by driver minimum allowed value is
5423 * NL80211_MAX_NR_AKM_SUITES in order to avoid compatibility issues with
5424 * legacy userspace and maximum allowed value is
5425 * CFG80211_MAX_NUM_AKM_SUITES.
cbbaf2bb
AS
5426 *
5427 * @hw_timestamp_max_peers: maximum number of peers that the driver supports
5428 * enabling HW timestamping for concurrently. Setting this field to a
5429 * non-zero value indicates that the driver supports HW timestamping.
5430 * A value of %CFG80211_HW_TIMESTAMP_ALL_PEERS indicates the driver
5431 * supports enabling HW timestamping for all peers (i.e. no need to
5432 * specify a mac address).
d3236553
JB
5433 */
5434struct wiphy {
a05829a7
JB
5435 struct mutex mtx;
5436
d3236553
JB
5437 /* assign these fields before you register the wiphy */
5438
d3236553 5439 u8 perm_addr[ETH_ALEN];
ef15aac6
JB
5440 u8 addr_mask[ETH_ALEN];
5441
ef15aac6 5442 struct mac_address *addresses;
d3236553 5443
2e161f78
JB
5444 const struct ieee80211_txrx_stypes *mgmt_stypes;
5445
7527a782
JB
5446 const struct ieee80211_iface_combination *iface_combinations;
5447 int n_iface_combinations;
5448 u16 software_iftypes;
5449
2e161f78
JB
5450 u16 n_addresses;
5451
d3236553
JB
5452 /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */
5453 u16 interface_modes;
5454
77765eaf
VT
5455 u16 max_acl_mac_addrs;
5456
a2f73b6c 5457 u32 flags, regulatory_flags, features;
d75bb06b 5458 u8 ext_features[DIV_ROUND_UP(NUM_NL80211_EXT_FEATURES, 8)];
463d0183 5459
562a7480
JB
5460 u32 ap_sme_capa;
5461
d3236553
JB
5462 enum cfg80211_signal_type signal_type;
5463
5464 int bss_priv_size;
5465 u8 max_scan_ssids;
ca986ad9 5466 u8 max_sched_scan_reqs;
93b6aa69 5467 u8 max_sched_scan_ssids;
a1f1c21c 5468 u8 max_match_sets;
d3236553 5469 u16 max_scan_ie_len;
5a865bad 5470 u16 max_sched_scan_ie_len;
3b06d277
AS
5471 u32 max_sched_scan_plans;
5472 u32 max_sched_scan_plan_interval;
5473 u32 max_sched_scan_plan_iterations;
d3236553
JB
5474
5475 int n_cipher_suites;
5476 const u32 *cipher_suites;
5477
ab4dfa20
VJ
5478 int n_akm_suites;
5479 const u32 *akm_suites;
5480
d6039a34
VJ
5481 const struct wiphy_iftype_akm_suites *iftype_akm_suites;
5482 unsigned int num_iftype_akm_suites;
5483
b9a5f8ca
JM
5484 u8 retry_short;
5485 u8 retry_long;
5486 u32 frag_threshold;
5487 u32 rts_threshold;
81077e82 5488 u8 coverage_class;
b9a5f8ca 5489
81135548 5490 char fw_version[ETHTOOL_FWVERS_LEN];
dfce95f5
KV
5491 u32 hw_version;
5492
dfb89c56 5493#ifdef CONFIG_PM
964dc9e2 5494 const struct wiphy_wowlan_support *wowlan;
6abb9cb9 5495 struct cfg80211_wowlan *wowlan_config;
dfb89c56 5496#endif
ff1b6e69 5497
a293911d
JB
5498 u16 max_remain_on_channel_duration;
5499
67fbb16b
SO
5500 u8 max_num_pmkids;
5501
7f531e03
BR
5502 u32 available_antennas_tx;
5503 u32 available_antennas_rx;
a7ffac95 5504
87bbbe22
AN
5505 u32 probe_resp_offload;
5506
a50df0c4
JB
5507 const u8 *extended_capabilities, *extended_capabilities_mask;
5508 u8 extended_capabilities_len;
5509
019ae3a9
KV
5510 const struct wiphy_iftype_ext_capab *iftype_ext_capab;
5511 unsigned int num_iftype_ext_capab;
5512
cf5aa2f1 5513 const void *privid;
d3236553 5514
57fbcce3 5515 struct ieee80211_supported_band *bands[NUM_NL80211_BANDS];
d3236553 5516
0c0280bd
LR
5517 void (*reg_notifier)(struct wiphy *wiphy,
5518 struct regulatory_request *request);
d3236553
JB
5519
5520 /* fields below are read-only, assigned by cfg80211 */
5521
458f4f9e 5522 const struct ieee80211_regdomain __rcu *regd;
d3236553 5523
d3236553
JB
5524 struct device dev;
5525
ecb44335
SG
5526 bool registered;
5527
d3236553
JB
5528 struct dentry *debugfsdir;
5529
7e7c8926 5530 const struct ieee80211_ht_cap *ht_capa_mod_mask;
ee2aca34 5531 const struct ieee80211_vht_cap *vht_capa_mod_mask;
7e7c8926 5532
53873f13
JB
5533 struct list_head wdev_list;
5534
0c5c9fb5 5535 possible_net_t _net;
463d0183 5536
3d23e349
JB
5537#ifdef CONFIG_CFG80211_WEXT
5538 const struct iw_handler_def *wext;
5539#endif
5540
be29b99a
AK
5541 const struct wiphy_coalesce_support *coalesce;
5542
ad7e718c 5543 const struct wiphy_vendor_command *vendor_commands;
567ffc35
JB
5544 const struct nl80211_vendor_cmd_info *vendor_events;
5545 int n_vendor_commands, n_vendor_events;
ad7e718c 5546
b43504cf
JM
5547 u16 max_ap_assoc_sta;
5548
9a774c78
AO
5549 u8 max_num_csa_counters;
5550
38de03d2
AS
5551 u32 bss_select_support;
5552
8585989d
LC
5553 u8 nan_supported_bands;
5554
52539ca8
THJ
5555 u32 txq_limit;
5556 u32 txq_memory_limit;
5557 u32 txq_quantum;
5558
1f6e0baa
JC
5559 unsigned long tx_queue_len;
5560
213ed579
SS
5561 u8 support_mbssid:1,
5562 support_only_he_mbssid:1;
5563
9bb7e0f2
JB
5564 const struct cfg80211_pmsr_capabilities *pmsr_capa;
5565
3710a8a6
JB
5566 struct {
5567 u64 peer, vif;
6a21d16c 5568 u8 max_retry;
3710a8a6
JB
5569 } tid_config_support;
5570
6a21d16c
T
5571 u8 max_data_retry_count;
5572
6bdb68ce
CH
5573 const struct cfg80211_sar_capa *sar_capa;
5574
358ae888
EG
5575 struct rfkill *rfkill;
5576
dc1e3cb8
JC
5577 u8 mbssid_max_interfaces;
5578 u8 ema_max_profile_periodicity;
ecad3b0b 5579 u16 max_num_akm_suites;
dc1e3cb8 5580
cbbaf2bb
AS
5581 u16 hw_timestamp_max_peers;
5582
396fba0a 5583 char priv[] __aligned(NETDEV_ALIGN);
d3236553
JB
5584};
5585
463d0183
JB
5586static inline struct net *wiphy_net(struct wiphy *wiphy)
5587{
c2d9ba9b 5588 return read_pnet(&wiphy->_net);
463d0183
JB
5589}
5590
5591static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net)
5592{
c2d9ba9b 5593 write_pnet(&wiphy->_net, net);
463d0183 5594}
463d0183 5595
d3236553
JB
5596/**
5597 * wiphy_priv - return priv from wiphy
5598 *
5599 * @wiphy: the wiphy whose priv pointer to return
0ae997dc 5600 * Return: The priv of @wiphy.
d3236553
JB
5601 */
5602static inline void *wiphy_priv(struct wiphy *wiphy)
5603{
5604 BUG_ON(!wiphy);
5605 return &wiphy->priv;
5606}
5607
f1f74825
DK
5608/**
5609 * priv_to_wiphy - return the wiphy containing the priv
5610 *
5611 * @priv: a pointer previously returned by wiphy_priv
0ae997dc 5612 * Return: The wiphy of @priv.
f1f74825
DK
5613 */
5614static inline struct wiphy *priv_to_wiphy(void *priv)
5615{
5616 BUG_ON(!priv);
5617 return container_of(priv, struct wiphy, priv);
5618}
5619
d3236553
JB
5620/**
5621 * set_wiphy_dev - set device pointer for wiphy
5622 *
5623 * @wiphy: The wiphy whose device to bind
5624 * @dev: The device to parent it to
5625 */
5626static inline void set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
5627{
5628 wiphy->dev.parent = dev;
5629}
5630
5631/**
5632 * wiphy_dev - get wiphy dev pointer
5633 *
5634 * @wiphy: The wiphy whose device struct to look up
0ae997dc 5635 * Return: The dev of @wiphy.
d3236553
JB
5636 */
5637static inline struct device *wiphy_dev(struct wiphy *wiphy)
5638{
5639 return wiphy->dev.parent;
5640}
5641
5642/**
5643 * wiphy_name - get wiphy name
5644 *
5645 * @wiphy: The wiphy whose name to return
0ae997dc 5646 * Return: The name of @wiphy.
d3236553 5647 */
e1db74fc 5648static inline const char *wiphy_name(const struct wiphy *wiphy)
d3236553
JB
5649{
5650 return dev_name(&wiphy->dev);
5651}
5652
1998d90a
BG
5653/**
5654 * wiphy_new_nm - create a new wiphy for use with cfg80211
5655 *
5656 * @ops: The configuration operations for this device
5657 * @sizeof_priv: The size of the private area to allocate
5658 * @requested_name: Request a particular name.
5659 * NULL is valid value, and means use the default phy%d naming.
5660 *
5661 * Create a new wiphy and associate the given operations with it.
5662 * @sizeof_priv bytes are allocated for private use.
5663 *
5664 * Return: A pointer to the new wiphy. This pointer must be
5665 * assigned to each netdev's ieee80211_ptr for proper operation.
5666 */
5667struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
5668 const char *requested_name);
5669
d3236553
JB
5670/**
5671 * wiphy_new - create a new wiphy for use with cfg80211
5672 *
5673 * @ops: The configuration operations for this device
5674 * @sizeof_priv: The size of the private area to allocate
5675 *
5676 * Create a new wiphy and associate the given operations with it.
5677 * @sizeof_priv bytes are allocated for private use.
5678 *
0ae997dc
YB
5679 * Return: A pointer to the new wiphy. This pointer must be
5680 * assigned to each netdev's ieee80211_ptr for proper operation.
d3236553 5681 */
1998d90a
BG
5682static inline struct wiphy *wiphy_new(const struct cfg80211_ops *ops,
5683 int sizeof_priv)
5684{
5685 return wiphy_new_nm(ops, sizeof_priv, NULL);
5686}
d3236553
JB
5687
5688/**
5689 * wiphy_register - register a wiphy with cfg80211
5690 *
5691 * @wiphy: The wiphy to register.
5692 *
0ae997dc 5693 * Return: A non-negative wiphy index or a negative error code.
d3236553 5694 */
10dd9b7c 5695int wiphy_register(struct wiphy *wiphy);
d3236553 5696
a05829a7
JB
5697/* this is a define for better error reporting (file/line) */
5698#define lockdep_assert_wiphy(wiphy) lockdep_assert_held(&(wiphy)->mtx)
5699
5700/**
5701 * rcu_dereference_wiphy - rcu_dereference with debug checking
5702 * @wiphy: the wiphy to check the locking on
5703 * @p: The pointer to read, prior to dereferencing
5704 *
5705 * Do an rcu_dereference(p), but check caller either holds rcu_read_lock()
5706 * or RTNL. Note: Please prefer wiphy_dereference() or rcu_dereference().
5707 */
5708#define rcu_dereference_wiphy(wiphy, p) \
5709 rcu_dereference_check(p, lockdep_is_held(&wiphy->mtx))
5710
5711/**
5712 * wiphy_dereference - fetch RCU pointer when updates are prevented by wiphy mtx
5713 * @wiphy: the wiphy to check the locking on
5714 * @p: The pointer to read, prior to dereferencing
5715 *
5716 * Return the value of the specified RCU-protected pointer, but omit the
5717 * READ_ONCE(), because caller holds the wiphy mutex used for updates.
5718 */
5719#define wiphy_dereference(wiphy, p) \
5720 rcu_dereference_protected(p, lockdep_is_held(&wiphy->mtx))
5721
5722/**
5723 * get_wiphy_regdom - get custom regdomain for the given wiphy
5724 * @wiphy: the wiphy to get the regdomain from
5725 */
5726const struct ieee80211_regdomain *get_wiphy_regdom(struct wiphy *wiphy);
5727
d3236553
JB
5728/**
5729 * wiphy_unregister - deregister a wiphy from cfg80211
5730 *
5731 * @wiphy: The wiphy to unregister.
5732 *
5733 * After this call, no more requests can be made with this priv
5734 * pointer, but the call may sleep to wait for an outstanding
5735 * request that is being handled.
5736 */
10dd9b7c 5737void wiphy_unregister(struct wiphy *wiphy);
d3236553
JB
5738
5739/**
5740 * wiphy_free - free wiphy
5741 *
5742 * @wiphy: The wiphy to free
5743 */
10dd9b7c 5744void wiphy_free(struct wiphy *wiphy);
d3236553 5745
fffd0934 5746/* internal structs */
6829c878 5747struct cfg80211_conn;
19957bb3 5748struct cfg80211_internal_bss;
fffd0934 5749struct cfg80211_cached_keys;
4a4b8169 5750struct cfg80211_cqm_config;
19957bb3 5751
a05829a7
JB
5752/**
5753 * wiphy_lock - lock the wiphy
5754 * @wiphy: the wiphy to lock
5755 *
a3ee4dc8
JB
5756 * This is needed around registering and unregistering netdevs that
5757 * aren't created through cfg80211 calls, since that requires locking
5758 * in cfg80211 when the notifiers is called, but that cannot
5759 * differentiate which way it's called.
5760 *
5761 * It can also be used by drivers for their own purposes.
a05829a7
JB
5762 *
5763 * When cfg80211 ops are called, the wiphy is already locked.
a3ee4dc8
JB
5764 *
5765 * Note that this makes sure that no workers that have been queued
5766 * with wiphy_queue_work() are running.
a05829a7
JB
5767 */
5768static inline void wiphy_lock(struct wiphy *wiphy)
5769 __acquires(&wiphy->mtx)
5770{
5771 mutex_lock(&wiphy->mtx);
5772 __acquire(&wiphy->mtx);
5773}
5774
5775/**
5776 * wiphy_unlock - unlock the wiphy again
5777 * @wiphy: the wiphy to unlock
5778 */
5779static inline void wiphy_unlock(struct wiphy *wiphy)
5780 __releases(&wiphy->mtx)
5781{
5782 __release(&wiphy->mtx);
5783 mutex_unlock(&wiphy->mtx);
5784}
5785
a3ee4dc8
JB
5786struct wiphy_work;
5787typedef void (*wiphy_work_func_t)(struct wiphy *, struct wiphy_work *);
5788
5789struct wiphy_work {
5790 struct list_head entry;
5791 wiphy_work_func_t func;
5792};
5793
5794static inline void wiphy_work_init(struct wiphy_work *work,
5795 wiphy_work_func_t func)
5796{
5797 INIT_LIST_HEAD(&work->entry);
5798 work->func = func;
5799}
5800
5801/**
5802 * wiphy_work_queue - queue work for the wiphy
5803 * @wiphy: the wiphy to queue for
5804 * @work: the work item
5805 *
5806 * This is useful for work that must be done asynchronously, and work
5807 * queued here has the special property that the wiphy mutex will be
5808 * held as if wiphy_lock() was called, and that it cannot be running
5809 * after wiphy_lock() was called. Therefore, wiphy_cancel_work() can
5810 * use just cancel_work() instead of cancel_work_sync(), it requires
5811 * being in a section protected by wiphy_lock().
5812 */
5813void wiphy_work_queue(struct wiphy *wiphy, struct wiphy_work *work);
5814
5815/**
5816 * wiphy_work_cancel - cancel previously queued work
5817 * @wiphy: the wiphy, for debug purposes
5818 * @work: the work to cancel
5819 *
5820 * Cancel the work *without* waiting for it, this assumes being
5821 * called under the wiphy mutex acquired by wiphy_lock().
5822 */
5823void wiphy_work_cancel(struct wiphy *wiphy, struct wiphy_work *work);
5824
5825struct wiphy_delayed_work {
5826 struct wiphy_work work;
5827 struct wiphy *wiphy;
5828 struct timer_list timer;
5829};
5830
5831void wiphy_delayed_work_timer(struct timer_list *t);
5832
5833static inline void wiphy_delayed_work_init(struct wiphy_delayed_work *dwork,
5834 wiphy_work_func_t func)
5835{
5836 timer_setup(&dwork->timer, wiphy_delayed_work_timer, 0);
5837 wiphy_work_init(&dwork->work, func);
5838}
5839
5840/**
5841 * wiphy_delayed_work_queue - queue delayed work for the wiphy
5842 * @wiphy: the wiphy to queue for
5843 * @dwork: the delayable worker
5844 * @delay: number of jiffies to wait before queueing
5845 *
5846 * This is useful for work that must be done asynchronously, and work
5847 * queued here has the special property that the wiphy mutex will be
5848 * held as if wiphy_lock() was called, and that it cannot be running
5849 * after wiphy_lock() was called. Therefore, wiphy_cancel_work() can
5850 * use just cancel_work() instead of cancel_work_sync(), it requires
5851 * being in a section protected by wiphy_lock().
5852 */
5853void wiphy_delayed_work_queue(struct wiphy *wiphy,
5854 struct wiphy_delayed_work *dwork,
5855 unsigned long delay);
5856
5857/**
5858 * wiphy_delayed_work_cancel - cancel previously queued delayed work
5859 * @wiphy: the wiphy, for debug purposes
5860 * @dwork: the delayed work to cancel
5861 *
5862 * Cancel the work *without* waiting for it, this assumes being
5863 * called under the wiphy mutex acquired by wiphy_lock().
5864 */
5865void wiphy_delayed_work_cancel(struct wiphy *wiphy,
5866 struct wiphy_delayed_work *dwork);
5867
d3236553 5868/**
89a54e48 5869 * struct wireless_dev - wireless device state
d3236553 5870 *
89a54e48
JB
5871 * For netdevs, this structure must be allocated by the driver
5872 * that uses the ieee80211_ptr field in struct net_device (this
5873 * is intentional so it can be allocated along with the netdev.)
5874 * It need not be registered then as netdev registration will
a05829a7
JB
5875 * be intercepted by cfg80211 to see the new wireless device,
5876 * however, drivers must lock the wiphy before registering or
5877 * unregistering netdevs if they pre-create any netdevs (in ops
5878 * called from cfg80211, the wiphy is already locked.)
89a54e48
JB
5879 *
5880 * For non-netdev uses, it must also be allocated by the driver
5881 * in response to the cfg80211 callbacks that require it, as
5882 * there's no netdev registration in that case it may not be
5883 * allocated outside of callback operations that return it.
d3236553
JB
5884 *
5885 * @wiphy: pointer to hardware description
5886 * @iftype: interface type
2fe8ef10 5887 * @registered: is this wdev already registered with cfg80211
40c575d1
JB
5888 * @registering: indicates we're doing registration under wiphy lock
5889 * for the notifier
d3236553 5890 * @list: (private) Used to collect the interfaces
89a54e48
JB
5891 * @netdev: (private) Used to reference back to the netdev, may be %NULL
5892 * @identifier: (private) Identifier used in nl80211 to identify this
5893 * wireless device if it has no netdev
2d8b08fe 5894 * @u: union containing data specific to @iftype
7b0a0e3c 5895 * @connected: indicates if connected or not (STA mode)
d3236553 5896 * @bssid: (private) Used by the internal configuration code
d3236553 5897 * @wext: (private) Used by the internal wireless extensions compat code
9874b71f
JB
5898 * @wext.ibss: (private) IBSS data part of wext handling
5899 * @wext.connect: (private) connection handling data
5900 * @wext.keys: (private) (WEP) key data
5901 * @wext.ie: (private) extra elements for association
5902 * @wext.ie_len: (private) length of extra elements
5903 * @wext.bssid: (private) selected network BSSID
5904 * @wext.ssid: (private) selected network SSID
5905 * @wext.default_key: (private) selected default key index
5906 * @wext.default_mgmt_key: (private) selected default management key index
5907 * @wext.prev_bssid: (private) previous BSSID for reassociation
5908 * @wext.prev_bssid_valid: (private) previous BSSID validity
9bc383de
JB
5909 * @use_4addr: indicates 4addr mode is used on this interface, must be
5910 * set by driver (if supported) on add_interface BEFORE registering the
5911 * netdev and may otherwise be used by driver read-only, will be update
5912 * by cfg80211 on change_interface
2e161f78 5913 * @mgmt_registrations: list of registrations for management frames
79ea1e12
JB
5914 * @mgmt_registrations_need_update: mgmt registrations were updated,
5915 * need to propagate the update to the driver
8d61ffa5
JB
5916 * @mtx: mutex used to lock data in this struct, may be used by drivers
5917 * and some API functions require it held
56d1893d
JB
5918 * @beacon_interval: beacon interval used on this device for transmitting
5919 * beacons, 0 when not valid
98104fde 5920 * @address: The address for this device, valid only if @netdev is %NULL
73c7da3d
AVS
5921 * @is_running: true if this is a non-netdev device that has been started, e.g.
5922 * the P2P Device.
04f39047
SW
5923 * @cac_started: true if DFS channel availability check has been started
5924 * @cac_start_time: timestamp (jiffies) when the dfs state was entered.
31559f35 5925 * @cac_time_ms: CAC time in ms
780b40df
JB
5926 * @ps: powersave mode is enabled
5927 * @ps_timeout: dynamic powersave timeout
5928 * @ap_unexpected_nlportid: (private) netlink port ID of application
5929 * registered for unexpected class 3 frames (AP mode)
5930 * @conn: (private) cfg80211 software SME connection state machine data
5931 * @connect_keys: (private) keys to set after connection is established
34d50519 5932 * @conn_bss_type: connecting/connected BSS type
bd2522b1
AZ
5933 * @conn_owner_nlportid: (private) connection owner socket port ID
5934 * @disconnect_wk: (private) auto-disconnect work
5935 * @disconnect_bssid: (private) the BSSID to use for auto-disconnect
780b40df
JB
5936 * @event_list: (private) list for internal event processing
5937 * @event_lock: (private) lock for event list
78f22b6a 5938 * @owner_nlportid: (private) owner socket port ID
ab81007a 5939 * @nl_owner_dead: (private) owner socket went away
4a4b8169 5940 * @cqm_config: (private) nl80211 RSSI monitor state
9bb7e0f2
JB
5941 * @pmsr_list: (private) peer measurement requests
5942 * @pmsr_lock: (private) peer measurements requests/results lock
5943 * @pmsr_free_wk: (private) peer measurements cleanup work
4d797fce
JM
5944 * @unprot_beacon_reported: (private) timestamp of last
5945 * unprotected beacon report
2d8b08fe
MCC
5946 * @links: array of %IEEE80211_MLD_MAX_NUM_LINKS elements containing @addr
5947 * @ap and @client for each link
5948 * @valid_links: bitmap describing what elements of @links are valid
d3236553
JB
5949 */
5950struct wireless_dev {
5951 struct wiphy *wiphy;
5952 enum nl80211_iftype iftype;
5953
667503dd 5954 /* the remainder of this struct should be private to cfg80211 */
d3236553
JB
5955 struct list_head list;
5956 struct net_device *netdev;
5957
89a54e48
JB
5958 u32 identifier;
5959
2e161f78 5960 struct list_head mgmt_registrations;
79ea1e12 5961 u8 mgmt_registrations_need_update:1;
026331c4 5962
667503dd
JB
5963 struct mutex mtx;
5964
40c575d1 5965 bool use_4addr, is_running, registered, registering;
98104fde
JB
5966
5967 u8 address[ETH_ALEN] __aligned(sizeof(u16));
9bc383de 5968
b23aa676 5969 /* currently used for IBSS and SME - might be rearranged later */
6829c878 5970 struct cfg80211_conn *conn;
fffd0934 5971 struct cfg80211_cached_keys *connect_keys;
34d50519 5972 enum ieee80211_bss_type conn_bss_type;
bd2522b1
AZ
5973 u32 conn_owner_nlportid;
5974
5975 struct work_struct disconnect_wk;
5976 u8 disconnect_bssid[ETH_ALEN];
d3236553 5977
667503dd
JB
5978 struct list_head event_list;
5979 spinlock_t event_lock;
5980
7b0a0e3c 5981 u8 connected:1;
f4489ebe 5982
ffb9eb3d
KV
5983 bool ps;
5984 int ps_timeout;
5985
15e47304 5986 u32 ap_unexpected_nlportid;
28946da7 5987
ab81007a
JB
5988 u32 owner_nlportid;
5989 bool nl_owner_dead;
5990
7b0a0e3c 5991 /* FIXME: need to rework radar detection for MLO */
04f39047
SW
5992 bool cac_started;
5993 unsigned long cac_start_time;
31559f35 5994 unsigned int cac_time_ms;
04f39047 5995
3d23e349 5996#ifdef CONFIG_CFG80211_WEXT
d3236553 5997 /* wext data */
cbe8fa9c 5998 struct {
c238c8ac
JB
5999 struct cfg80211_ibss_params ibss;
6000 struct cfg80211_connect_params connect;
fffd0934 6001 struct cfg80211_cached_keys *keys;
c1e5f471 6002 const u8 *ie;
f2129354 6003 size_t ie_len;
9874b71f
JB
6004 u8 bssid[ETH_ALEN];
6005 u8 prev_bssid[ETH_ALEN];
f2129354 6006 u8 ssid[IEEE80211_MAX_SSID_LEN];
08645126 6007 s8 default_key, default_mgmt_key;
ffb9eb3d 6008 bool prev_bssid_valid;
cbe8fa9c 6009 } wext;
d3236553 6010#endif
4a4b8169
AZ
6011
6012 struct cfg80211_cqm_config *cqm_config;
9bb7e0f2
JB
6013
6014 struct list_head pmsr_list;
6015 spinlock_t pmsr_lock;
6016 struct work_struct pmsr_free_wk;
4d797fce
JM
6017
6018 unsigned long unprot_beacon_reported;
7b0a0e3c
JB
6019
6020 union {
6021 struct {
6022 u8 connected_addr[ETH_ALEN] __aligned(2);
6023 u8 ssid[IEEE80211_MAX_SSID_LEN];
6024 u8 ssid_len;
6025 } client;
6026 struct {
6027 int beacon_interval;
6028 struct cfg80211_chan_def preset_chandef;
6029 struct cfg80211_chan_def chandef;
6030 u8 id[IEEE80211_MAX_SSID_LEN];
6031 u8 id_len, id_up_len;
6032 } mesh;
6033 struct {
6034 struct cfg80211_chan_def preset_chandef;
6035 u8 ssid[IEEE80211_MAX_SSID_LEN];
6036 u8 ssid_len;
6037 } ap;
6038 struct {
6039 struct cfg80211_internal_bss *current_bss;
6040 struct cfg80211_chan_def chandef;
6041 int beacon_interval;
6042 u8 ssid[IEEE80211_MAX_SSID_LEN];
6043 u8 ssid_len;
6044 } ibss;
6045 struct {
6046 struct cfg80211_chan_def chandef;
6047 } ocb;
6048 } u;
6049
6050 struct {
6051 u8 addr[ETH_ALEN] __aligned(2);
6052 union {
6053 struct {
6054 unsigned int beacon_interval;
6055 struct cfg80211_chan_def chandef;
6056 } ap;
6057 struct {
6058 struct cfg80211_internal_bss *current_bss;
6059 } client;
6060 };
6061 } links[IEEE80211_MLD_MAX_NUM_LINKS];
6062 u16 valid_links;
d3236553
JB
6063};
6064
10de5a59 6065static inline const u8 *wdev_address(struct wireless_dev *wdev)
98104fde
JB
6066{
6067 if (wdev->netdev)
6068 return wdev->netdev->dev_addr;
6069 return wdev->address;
6070}
6071
73c7da3d
AVS
6072static inline bool wdev_running(struct wireless_dev *wdev)
6073{
6074 if (wdev->netdev)
6075 return netif_running(wdev->netdev);
6076 return wdev->is_running;
6077}
6078
d3236553
JB
6079/**
6080 * wdev_priv - return wiphy priv from wireless_dev
6081 *
6082 * @wdev: The wireless device whose wiphy's priv pointer to return
0ae997dc 6083 * Return: The wiphy priv of @wdev.
d3236553
JB
6084 */
6085static inline void *wdev_priv(struct wireless_dev *wdev)
6086{
6087 BUG_ON(!wdev);
6088 return wiphy_priv(wdev->wiphy);
6089}
6090
7b0a0e3c
JB
6091/**
6092 * wdev_chandef - return chandef pointer from wireless_dev
6093 * @wdev: the wdev
6094 * @link_id: the link ID for MLO
6095 *
6096 * Return: The chandef depending on the mode, or %NULL.
6097 */
6098struct cfg80211_chan_def *wdev_chandef(struct wireless_dev *wdev,
6099 unsigned int link_id);
6100
6101static inline void WARN_INVALID_LINK_ID(struct wireless_dev *wdev,
6102 unsigned int link_id)
6103{
6104 WARN_ON(link_id && !wdev->valid_links);
6105 WARN_ON(wdev->valid_links &&
6106 !(wdev->valid_links & BIT(link_id)));
6107}
6108
efbabc11
VJ
6109#define for_each_valid_link(link_info, link_id) \
6110 for (link_id = 0; \
6111 link_id < ((link_info)->valid_links ? \
6112 ARRAY_SIZE((link_info)->links) : 1); \
6113 link_id++) \
6114 if (!(link_info)->valid_links || \
6115 ((link_info)->valid_links & BIT(link_id)))
7b0a0e3c 6116
d70e9693
JB
6117/**
6118 * DOC: Utility functions
6119 *
6120 * cfg80211 offers a number of utility functions that can be useful.
d3236553
JB
6121 */
6122
934f4c7d
TP
6123/**
6124 * ieee80211_channel_equal - compare two struct ieee80211_channel
6125 *
6126 * @a: 1st struct ieee80211_channel
6127 * @b: 2nd struct ieee80211_channel
6128 * Return: true if center frequency of @a == @b
6129 */
6130static inline bool
6131ieee80211_channel_equal(struct ieee80211_channel *a,
6132 struct ieee80211_channel *b)
6133{
6134 return (a->center_freq == b->center_freq &&
6135 a->freq_offset == b->freq_offset);
6136}
6137
6138/**
6139 * ieee80211_channel_to_khz - convert ieee80211_channel to frequency in KHz
6140 * @chan: struct ieee80211_channel to convert
6141 * Return: The corresponding frequency (in KHz)
6142 */
6143static inline u32
6144ieee80211_channel_to_khz(const struct ieee80211_channel *chan)
6145{
6146 return MHZ_TO_KHZ(chan->center_freq) + chan->freq_offset;
6147}
6148
11b34737
TP
6149/**
6150 * ieee80211_s1g_channel_width - get allowed channel width from @chan
6151 *
6152 * Only allowed for band NL80211_BAND_S1GHZ
6153 * @chan: channel
6154 * Return: The allowed channel width for this center_freq
6155 */
6156enum nl80211_chan_width
6157ieee80211_s1g_channel_width(const struct ieee80211_channel *chan);
6158
934f4c7d
TP
6159/**
6160 * ieee80211_channel_to_freq_khz - convert channel number to frequency
6161 * @chan: channel number
6162 * @band: band, necessary due to channel number overlap
6163 * Return: The corresponding frequency (in KHz), or 0 if the conversion failed.
6164 */
6165u32 ieee80211_channel_to_freq_khz(int chan, enum nl80211_band band);
6166
d3236553
JB
6167/**
6168 * ieee80211_channel_to_frequency - convert channel number to frequency
abe37c4b 6169 * @chan: channel number
59eb21a6 6170 * @band: band, necessary due to channel number overlap
0ae997dc 6171 * Return: The corresponding frequency (in MHz), or 0 if the conversion failed.
d3236553 6172 */
934f4c7d
TP
6173static inline int
6174ieee80211_channel_to_frequency(int chan, enum nl80211_band band)
6175{
6176 return KHZ_TO_MHZ(ieee80211_channel_to_freq_khz(chan, band));
6177}
6178
6179/**
6180 * ieee80211_freq_khz_to_channel - convert frequency to channel number
6181 * @freq: center frequency in KHz
6182 * Return: The corresponding channel, or 0 if the conversion failed.
6183 */
6184int ieee80211_freq_khz_to_channel(u32 freq);
d3236553
JB
6185
6186/**
6187 * ieee80211_frequency_to_channel - convert frequency to channel number
934f4c7d 6188 * @freq: center frequency in MHz
0ae997dc 6189 * Return: The corresponding channel, or 0 if the conversion failed.
d3236553 6190 */
934f4c7d
TP
6191static inline int
6192ieee80211_frequency_to_channel(int freq)
6193{
6194 return ieee80211_freq_khz_to_channel(MHZ_TO_KHZ(freq));
6195}
6196
6197/**
6198 * ieee80211_get_channel_khz - get channel struct from wiphy for specified
6199 * frequency
6200 * @wiphy: the struct wiphy to get the channel for
6201 * @freq: the center frequency (in KHz) of the channel
6202 * Return: The channel struct from @wiphy at @freq.
6203 */
6204struct ieee80211_channel *
6205ieee80211_get_channel_khz(struct wiphy *wiphy, u32 freq);
d3236553 6206
d3236553
JB
6207/**
6208 * ieee80211_get_channel - get channel struct from wiphy for specified frequency
543b921b 6209 *
abe37c4b 6210 * @wiphy: the struct wiphy to get the channel for
934f4c7d 6211 * @freq: the center frequency (in MHz) of the channel
0ae997dc 6212 * Return: The channel struct from @wiphy at @freq.
d3236553 6213 */
934f4c7d
TP
6214static inline struct ieee80211_channel *
6215ieee80211_get_channel(struct wiphy *wiphy, int freq)
6216{
6217 return ieee80211_get_channel_khz(wiphy, MHZ_TO_KHZ(freq));
6218}
d3236553 6219
afbc9c9e
JB
6220/**
6221 * cfg80211_channel_is_psc - Check if the channel is a 6 GHz PSC
6222 * @chan: control channel to check
6223 *
6224 * The Preferred Scanning Channels (PSC) are defined in
6225 * Draft IEEE P802.11ax/D5.0, 26.17.2.3.3
6226 */
6227static inline bool cfg80211_channel_is_psc(struct ieee80211_channel *chan)
6228{
6229 if (chan->band != NL80211_BAND_6GHZ)
6230 return false;
6231
6232 return ieee80211_frequency_to_channel(chan->center_freq) % 16 == 5;
6233}
6234
d3236553
JB
6235/**
6236 * ieee80211_get_response_rate - get basic rate for a given rate
6237 *
6238 * @sband: the band to look for rates in
6239 * @basic_rates: bitmap of basic rates
6240 * @bitrate: the bitrate for which to find the basic rate
6241 *
0ae997dc
YB
6242 * Return: The basic rate corresponding to a given bitrate, that
6243 * is the next lower bitrate contained in the basic rate map,
6244 * which is, for this function, given as a bitmap of indices of
6245 * rates in the band's bitrate table.
d3236553 6246 */
623b988f 6247const struct ieee80211_rate *
d3236553
JB
6248ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
6249 u32 basic_rates, int bitrate);
6250
b422c6cd
AN
6251/**
6252 * ieee80211_mandatory_rates - get mandatory rates for a given band
6253 * @sband: the band to look for rates in
74608aca 6254 * @scan_width: width of the control channel
b422c6cd
AN
6255 *
6256 * This function returns a bitmap of the mandatory rates for the given
6257 * band, bits are set according to the rate position in the bitrates array.
6258 */
74608aca
SW
6259u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband,
6260 enum nl80211_bss_scan_width scan_width);
b422c6cd 6261
d3236553
JB
6262/*
6263 * Radiotap parsing functions -- for controlled injection support
6264 *
6265 * Implemented in net/wireless/radiotap.c
66d495d0 6266 * Documentation in Documentation/networking/radiotap-headers.rst
d3236553
JB
6267 */
6268
33e5a2f7
JB
6269struct radiotap_align_size {
6270 uint8_t align:4, size:4;
6271};
6272
6273struct ieee80211_radiotap_namespace {
6274 const struct radiotap_align_size *align_size;
6275 int n_bits;
6276 uint32_t oui;
6277 uint8_t subns;
6278};
6279
6280struct ieee80211_radiotap_vendor_namespaces {
6281 const struct ieee80211_radiotap_namespace *ns;
6282 int n_ns;
6283};
6284
d3236553
JB
6285/**
6286 * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args
33e5a2f7
JB
6287 * @this_arg_index: index of current arg, valid after each successful call
6288 * to ieee80211_radiotap_iterator_next()
6289 * @this_arg: pointer to current radiotap arg; it is valid after each
6290 * call to ieee80211_radiotap_iterator_next() but also after
6291 * ieee80211_radiotap_iterator_init() where it will point to
6292 * the beginning of the actual data portion
6293 * @this_arg_size: length of the current arg, for convenience
6294 * @current_namespace: pointer to the current namespace definition
6295 * (or internally %NULL if the current namespace is unknown)
6296 * @is_radiotap_ns: indicates whether the current namespace is the default
6297 * radiotap namespace or not
6298 *
33e5a2f7
JB
6299 * @_rtheader: pointer to the radiotap header we are walking through
6300 * @_max_length: length of radiotap header in cpu byte ordering
6301 * @_arg_index: next argument index
6302 * @_arg: next argument pointer
6303 * @_next_bitmap: internal pointer to next present u32
6304 * @_bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present
6305 * @_vns: vendor namespace definitions
6306 * @_next_ns_data: beginning of the next namespace's data
6307 * @_reset_on_ext: internal; reset the arg index to 0 when going to the
6308 * next bitmap word
6309 *
6310 * Describes the radiotap parser state. Fields prefixed with an underscore
6311 * must not be used by users of the parser, only by the parser internally.
d3236553
JB
6312 */
6313
6314struct ieee80211_radiotap_iterator {
33e5a2f7
JB
6315 struct ieee80211_radiotap_header *_rtheader;
6316 const struct ieee80211_radiotap_vendor_namespaces *_vns;
6317 const struct ieee80211_radiotap_namespace *current_namespace;
6318
6319 unsigned char *_arg, *_next_ns_data;
67272440 6320 __le32 *_next_bitmap;
33e5a2f7
JB
6321
6322 unsigned char *this_arg;
d3236553 6323 int this_arg_index;
33e5a2f7 6324 int this_arg_size;
d3236553 6325
33e5a2f7
JB
6326 int is_radiotap_ns;
6327
6328 int _max_length;
6329 int _arg_index;
6330 uint32_t _bitmap_shifter;
6331 int _reset_on_ext;
d3236553
JB
6332};
6333
10dd9b7c
JP
6334int
6335ieee80211_radiotap_iterator_init(struct ieee80211_radiotap_iterator *iterator,
6336 struct ieee80211_radiotap_header *radiotap_header,
6337 int max_length,
6338 const struct ieee80211_radiotap_vendor_namespaces *vns);
d3236553 6339
10dd9b7c
JP
6340int
6341ieee80211_radiotap_iterator_next(struct ieee80211_radiotap_iterator *iterator);
33e5a2f7 6342
d3236553 6343
e31a16d6
ZY
6344extern const unsigned char rfc1042_header[6];
6345extern const unsigned char bridge_tunnel_header[6];
6346
6347/**
6348 * ieee80211_get_hdrlen_from_skb - get header length from data
6349 *
0ae997dc
YB
6350 * @skb: the frame
6351 *
e31a16d6 6352 * Given an skb with a raw 802.11 header at the data pointer this function
0ae997dc 6353 * returns the 802.11 header length.
e31a16d6 6354 *
0ae997dc
YB
6355 * Return: The 802.11 header length in bytes (not including encryption
6356 * headers). Or 0 if the data in the sk_buff is too short to contain a valid
6357 * 802.11 header.
e31a16d6
ZY
6358 */
6359unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
6360
6361/**
6362 * ieee80211_hdrlen - get header length in bytes from frame control
6363 * @fc: frame control field in little-endian format
0ae997dc 6364 * Return: The header length in bytes.
e31a16d6 6365 */
633adf1a 6366unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc);
e31a16d6 6367
9b395bc3
JB
6368/**
6369 * ieee80211_get_mesh_hdrlen - get mesh extension header length
6370 * @meshhdr: the mesh extension header, only the flags field
6371 * (first byte) will be accessed
0ae997dc 6372 * Return: The length of the extension header, which is always at
9b395bc3
JB
6373 * least 6 bytes and at most 18 if address 5 and 6 are present.
6374 */
6375unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr);
6376
d70e9693
JB
6377/**
6378 * DOC: Data path helpers
6379 *
6380 * In addition to generic utilities, cfg80211 also offers
6381 * functions that help implement the data path for devices
6382 * that do not do the 802.11/802.3 conversion on the device.
6383 */
6384
7f6990c8
JB
6385/**
6386 * ieee80211_data_to_8023_exthdr - convert an 802.11 data frame to 802.3
6387 * @skb: the 802.11 data frame
6388 * @ehdr: pointer to a &struct ethhdr that will get the header, instead
6389 * of it being pushed into the SKB
6390 * @addr: the device MAC address
6391 * @iftype: the virtual interface type
24bba078 6392 * @data_offset: offset of payload after the 802.11 header
2d8b08fe 6393 * @is_amsdu: true if the 802.11 header is A-MSDU
7f6990c8
JB
6394 * Return: 0 on success. Non-zero on error.
6395 */
6396int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
24bba078 6397 const u8 *addr, enum nl80211_iftype iftype,
a1d5ff56 6398 u8 data_offset, bool is_amsdu);
7f6990c8 6399
e31a16d6
ZY
6400/**
6401 * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3
6402 * @skb: the 802.11 data frame
6403 * @addr: the device MAC address
6404 * @iftype: the virtual interface type
0ae997dc 6405 * Return: 0 on success. Non-zero on error.
e31a16d6 6406 */
7f6990c8
JB
6407static inline int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
6408 enum nl80211_iftype iftype)
6409{
a1d5ff56 6410 return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype, 0, false);
7f6990c8 6411}
e31a16d6 6412
6e4c0d04
FF
6413/**
6414 * ieee80211_is_valid_amsdu - check if subframe lengths of an A-MSDU are valid
6415 *
6416 * This is used to detect non-standard A-MSDU frames, e.g. the ones generated
6417 * by ath10k and ath11k, where the subframe length includes the length of the
6418 * mesh control field.
6419 *
6420 * @skb: The input A-MSDU frame without any headers.
fe4a6d2d
FF
6421 * @mesh_hdr: the type of mesh header to test
6422 * 0: non-mesh A-MSDU length field
6423 * 1: big-endian mesh A-MSDU length field
6424 * 2: little-endian mesh A-MSDU length field
6e4c0d04
FF
6425 * Returns: true if subframe header lengths are valid for the @mesh_hdr mode
6426 */
fe4a6d2d 6427bool ieee80211_is_valid_amsdu(struct sk_buff *skb, u8 mesh_hdr);
6e4c0d04 6428
eaf85ca7
ZY
6429/**
6430 * ieee80211_amsdu_to_8023s - decode an IEEE 802.11n A-MSDU frame
6431 *
7f6990c8
JB
6432 * Decode an IEEE 802.11 A-MSDU and convert it to a list of 802.3 frames.
6433 * The @list will be empty if the decode fails. The @skb must be fully
6434 * header-less before being passed in here; it is freed in this function.
eaf85ca7 6435 *
7f6990c8 6436 * @skb: The input A-MSDU frame without any headers.
eaf85ca7 6437 * @list: The output list of 802.3 frames. It must be allocated and
085a6c10 6438 * initialized by the caller.
eaf85ca7
ZY
6439 * @addr: The device MAC address.
6440 * @iftype: The device interface type.
6441 * @extra_headroom: The hardware extra headroom for SKBs in the @list.
8b935ee2
JB
6442 * @check_da: DA to check in the inner ethernet header, or NULL
6443 * @check_sa: SA to check in the inner ethernet header, or NULL
fe4a6d2d 6444 * @mesh_control: see mesh_hdr in ieee80211_is_valid_amsdu
eaf85ca7
ZY
6445 */
6446void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
6447 const u8 *addr, enum nl80211_iftype iftype,
8b3becad 6448 const unsigned int extra_headroom,
986e43b1 6449 const u8 *check_da, const u8 *check_sa,
fe4a6d2d 6450 u8 mesh_control);
986e43b1
FF
6451
6452/**
6453 * ieee80211_get_8023_tunnel_proto - get RFC1042 or bridge tunnel encap protocol
6454 *
6455 * Check for RFC1042 or bridge tunnel header and fetch the encapsulated
6456 * protocol.
6457 *
6458 * @hdr: pointer to the MSDU payload
6459 * @proto: destination pointer to store the protocol
6460 * Return: true if encapsulation was found
6461 */
6462bool ieee80211_get_8023_tunnel_proto(const void *hdr, __be16 *proto);
6463
6464/**
6465 * ieee80211_strip_8023_mesh_hdr - strip mesh header from converted 802.3 frames
6466 *
6467 * Strip the mesh header, which was left in by ieee80211_data_to_8023 as part
6468 * of the MSDU data. Also move any source/destination addresses from the mesh
6469 * header to the ethernet header (if present).
6470 *
6471 * @skb: The 802.3 frame with embedded mesh header
6472 */
6473int ieee80211_strip_8023_mesh_hdr(struct sk_buff *skb);
eaf85ca7 6474
e31a16d6
ZY
6475/**
6476 * cfg80211_classify8021d - determine the 802.1p/1d tag for a data frame
6477 * @skb: the data frame
fa9ffc74 6478 * @qos_map: Interworking QoS mapping or %NULL if not in use
0ae997dc 6479 * Return: The 802.1p/1d tag.
e31a16d6 6480 */
fa9ffc74
KP
6481unsigned int cfg80211_classify8021d(struct sk_buff *skb,
6482 struct cfg80211_qos_map *qos_map);
e31a16d6 6483
49a68e0d
JB
6484/**
6485 * cfg80211_find_elem_match - match information element and byte array in data
6486 *
6487 * @eid: element ID
6488 * @ies: data consisting of IEs
6489 * @len: length of data
6490 * @match: byte array to match
6491 * @match_len: number of bytes in the match array
6492 * @match_offset: offset in the IE data where the byte array should match.
6493 * Note the difference to cfg80211_find_ie_match() which considers
6494 * the offset to start from the element ID byte, but here we take
6495 * the data portion instead.
6496 *
6497 * Return: %NULL if the element ID could not be found or if
6498 * the element is invalid (claims to be longer than the given
6499 * data) or if the byte array doesn't match; otherwise return the
6500 * requested element struct.
6501 *
6502 * Note: There are no checks on the element length other than
6503 * having to fit into the given data and being large enough for the
6504 * byte array to match.
6505 */
6506const struct element *
6507cfg80211_find_elem_match(u8 eid, const u8 *ies, unsigned int len,
6508 const u8 *match, unsigned int match_len,
6509 unsigned int match_offset);
6510
fbd05e4a
LC
6511/**
6512 * cfg80211_find_ie_match - match information element and byte array in data
6513 *
6514 * @eid: element ID
6515 * @ies: data consisting of IEs
6516 * @len: length of data
6517 * @match: byte array to match
6518 * @match_len: number of bytes in the match array
6519 * @match_offset: offset in the IE where the byte array should match.
6520 * If match_len is zero, this must also be set to zero.
6521 * Otherwise this must be set to 2 or more, because the first
6522 * byte is the element id, which is already compared to eid, and
6523 * the second byte is the IE length.
6524 *
6525 * Return: %NULL if the element ID could not be found or if
6526 * the element is invalid (claims to be longer than the given
6527 * data) or if the byte array doesn't match, or a pointer to the first
6528 * byte of the requested element, that is the byte containing the
6529 * element ID.
6530 *
6531 * Note: There are no checks on the element length other than
6532 * having to fit into the given data and being large enough for the
6533 * byte array to match.
6534 */
49a68e0d
JB
6535static inline const u8 *
6536cfg80211_find_ie_match(u8 eid, const u8 *ies, unsigned int len,
6537 const u8 *match, unsigned int match_len,
6538 unsigned int match_offset)
6539{
6540 /* match_offset can't be smaller than 2, unless match_len is
6541 * zero, in which case match_offset must be zero as well.
6542 */
6543 if (WARN_ON((match_len && match_offset < 2) ||
6544 (!match_len && match_offset)))
6545 return NULL;
6546
7e367b06
JB
6547 return (const void *)cfg80211_find_elem_match(eid, ies, len,
6548 match, match_len,
6549 match_offset ?
49a68e0d
JB
6550 match_offset - 2 : 0);
6551}
6552
6553/**
6554 * cfg80211_find_elem - find information element in data
6555 *
6556 * @eid: element ID
6557 * @ies: data consisting of IEs
6558 * @len: length of data
6559 *
6560 * Return: %NULL if the element ID could not be found or if
6561 * the element is invalid (claims to be longer than the given
6562 * data) or if the byte array doesn't match; otherwise return the
6563 * requested element struct.
6564 *
6565 * Note: There are no checks on the element length other than
6566 * having to fit into the given data.
6567 */
6568static inline const struct element *
6569cfg80211_find_elem(u8 eid, const u8 *ies, int len)
6570{
6571 return cfg80211_find_elem_match(eid, ies, len, NULL, 0, 0);
6572}
fbd05e4a 6573
c21dbf92
JB
6574/**
6575 * cfg80211_find_ie - find information element in data
6576 *
6577 * @eid: element ID
6578 * @ies: data consisting of IEs
6579 * @len: length of data
6580 *
0ae997dc
YB
6581 * Return: %NULL if the element ID could not be found or if
6582 * the element is invalid (claims to be longer than the given
6583 * data), or a pointer to the first byte of the requested
6584 * element, that is the byte containing the element ID.
6585 *
6586 * Note: There are no checks on the element length other than
6587 * having to fit into the given data.
c21dbf92 6588 */
fbd05e4a
LC
6589static inline const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len)
6590{
6591 return cfg80211_find_ie_match(eid, ies, len, NULL, 0, 0);
6592}
c21dbf92 6593
49a68e0d
JB
6594/**
6595 * cfg80211_find_ext_elem - find information element with EID Extension in data
6596 *
6597 * @ext_eid: element ID Extension
6598 * @ies: data consisting of IEs
6599 * @len: length of data
6600 *
6601 * Return: %NULL if the etended element could not be found or if
6602 * the element is invalid (claims to be longer than the given
6603 * data) or if the byte array doesn't match; otherwise return the
6604 * requested element struct.
6605 *
6606 * Note: There are no checks on the element length other than
6607 * having to fit into the given data.
6608 */
6609static inline const struct element *
6610cfg80211_find_ext_elem(u8 ext_eid, const u8 *ies, int len)
6611{
6612 return cfg80211_find_elem_match(WLAN_EID_EXTENSION, ies, len,
6613 &ext_eid, 1, 0);
6614}
6615
3f817fe7
JM
6616/**
6617 * cfg80211_find_ext_ie - find information element with EID Extension in data
6618 *
6619 * @ext_eid: element ID Extension
6620 * @ies: data consisting of IEs
6621 * @len: length of data
6622 *
6623 * Return: %NULL if the extended element ID could not be found or if
6624 * the element is invalid (claims to be longer than the given
6625 * data), or a pointer to the first byte of the requested
6626 * element, that is the byte containing the element ID.
6627 *
6628 * Note: There are no checks on the element length other than
6629 * having to fit into the given data.
6630 */
6631static inline const u8 *cfg80211_find_ext_ie(u8 ext_eid, const u8 *ies, int len)
6632{
6633 return cfg80211_find_ie_match(WLAN_EID_EXTENSION, ies, len,
6634 &ext_eid, 1, 2);
6635}
6636
49a68e0d
JB
6637/**
6638 * cfg80211_find_vendor_elem - find vendor specific information element in data
6639 *
6640 * @oui: vendor OUI
6641 * @oui_type: vendor-specific OUI type (must be < 0xff), negative means any
6642 * @ies: data consisting of IEs
6643 * @len: length of data
6644 *
6645 * Return: %NULL if the vendor specific element ID could not be found or if the
6646 * element is invalid (claims to be longer than the given data); otherwise
6647 * return the element structure for the requested element.
6648 *
6649 * Note: There are no checks on the element length other than having to fit into
6650 * the given data.
6651 */
6652const struct element *cfg80211_find_vendor_elem(unsigned int oui, int oui_type,
6653 const u8 *ies,
6654 unsigned int len);
6655
0c28ec58
EP
6656/**
6657 * cfg80211_find_vendor_ie - find vendor specific information element in data
6658 *
6659 * @oui: vendor OUI
9e9ea439 6660 * @oui_type: vendor-specific OUI type (must be < 0xff), negative means any
0c28ec58
EP
6661 * @ies: data consisting of IEs
6662 * @len: length of data
6663 *
0ae997dc
YB
6664 * Return: %NULL if the vendor specific element ID could not be found or if the
6665 * element is invalid (claims to be longer than the given data), or a pointer to
6666 * the first byte of the requested element, that is the byte containing the
6667 * element ID.
6668 *
6669 * Note: There are no checks on the element length other than having to fit into
6670 * the given data.
0c28ec58 6671 */
49a68e0d
JB
6672static inline const u8 *
6673cfg80211_find_vendor_ie(unsigned int oui, int oui_type,
6674 const u8 *ies, unsigned int len)
6675{
7e367b06 6676 return (const void *)cfg80211_find_vendor_elem(oui, oui_type, ies, len);
49a68e0d 6677}
0c28ec58 6678
f837a653
BB
6679/**
6680 * cfg80211_defragment_element - Defrag the given element data into a buffer
6681 *
6682 * @elem: the element to defragment
6683 * @ies: elements where @elem is contained
6684 * @ieslen: length of @ies
6685 * @data: buffer to store element data
6686 * @data_len: length of @data
6687 * @frag_id: the element ID of fragments
6688 *
6689 * Return: length of @data, or -EINVAL on error
6690 *
6691 * Copy out all data from an element that may be fragmented into @data, while
6692 * skipping all headers.
6693 *
6694 * The function uses memmove() internally. It is acceptable to defragment an
6695 * element in-place.
6696 */
6697ssize_t cfg80211_defragment_element(const struct element *elem, const u8 *ies,
6698 size_t ieslen, u8 *data, size_t data_len,
6699 u8 frag_id);
6700
30ca1aa5
DL
6701/**
6702 * cfg80211_send_layer2_update - send layer 2 update frame
6703 *
6704 * @dev: network device
6705 * @addr: STA MAC address
6706 *
6707 * Wireless drivers can use this function to update forwarding tables in bridge
6708 * devices upon STA association.
6709 */
6710void cfg80211_send_layer2_update(struct net_device *dev, const u8 *addr);
6711
d70e9693
JB
6712/**
6713 * DOC: Regulatory enforcement infrastructure
6714 *
6715 * TODO
d3236553
JB
6716 */
6717
6718/**
6719 * regulatory_hint - driver hint to the wireless core a regulatory domain
6720 * @wiphy: the wireless device giving the hint (used only for reporting
6721 * conflicts)
6722 * @alpha2: the ISO/IEC 3166 alpha2 the driver claims its regulatory domain
cd9b52bf
JP
6723 * should be in. If @rd is set this should be NULL. Note that if you
6724 * set this to NULL you should still set rd->alpha2 to some accepted
6725 * alpha2.
d3236553
JB
6726 *
6727 * Wireless drivers can use this function to hint to the wireless core
6728 * what it believes should be the current regulatory domain by
6729 * giving it an ISO/IEC 3166 alpha2 country code it knows its regulatory
6730 * domain should be in or by providing a completely build regulatory domain.
6731 * If the driver provides an ISO/IEC 3166 alpha2 userspace will be queried
6732 * for a regulatory domain structure for the respective country.
6733 *
6734 * The wiphy must have been registered to cfg80211 prior to this call.
6735 * For cfg80211 drivers this means you must first use wiphy_register(),
6736 * for mac80211 drivers you must first use ieee80211_register_hw().
6737 *
6738 * Drivers should check the return value, its possible you can get
6739 * an -ENOMEM.
0ae997dc
YB
6740 *
6741 * Return: 0 on success. -ENOMEM.
d3236553 6742 */
10dd9b7c 6743int regulatory_hint(struct wiphy *wiphy, const char *alpha2);
d3236553 6744
b0d7aa59
JD
6745/**
6746 * regulatory_set_wiphy_regd - set regdom info for self managed drivers
6747 * @wiphy: the wireless device we want to process the regulatory domain on
6748 * @rd: the regulatory domain informatoin to use for this wiphy
6749 *
6750 * Set the regulatory domain information for self-managed wiphys, only they
6751 * may use this function. See %REGULATORY_WIPHY_SELF_MANAGED for more
6752 * information.
6753 *
6754 * Return: 0 on success. -EINVAL, -EPERM
6755 */
6756int regulatory_set_wiphy_regd(struct wiphy *wiphy,
6757 struct ieee80211_regdomain *rd);
6758
2c3e861c 6759/**
a05829a7 6760 * regulatory_set_wiphy_regd_sync - set regdom for self-managed drivers
2c3e861c
AN
6761 * @wiphy: the wireless device we want to process the regulatory domain on
6762 * @rd: the regulatory domain information to use for this wiphy
6763 *
a05829a7
JB
6764 * This functions requires the RTNL and the wiphy mutex to be held and
6765 * applies the new regdomain synchronously to this wiphy. For more details
6766 * see regulatory_set_wiphy_regd().
2c3e861c
AN
6767 *
6768 * Return: 0 on success. -EINVAL, -EPERM
6769 */
a05829a7
JB
6770int regulatory_set_wiphy_regd_sync(struct wiphy *wiphy,
6771 struct ieee80211_regdomain *rd);
2c3e861c 6772
d3236553
JB
6773/**
6774 * wiphy_apply_custom_regulatory - apply a custom driver regulatory domain
6775 * @wiphy: the wireless device we want to process the regulatory domain on
6776 * @regd: the custom regulatory domain to use for this wiphy
6777 *
6778 * Drivers can sometimes have custom regulatory domains which do not apply
6779 * to a specific country. Drivers can use this to apply such custom regulatory
6780 * domains. This routine must be called prior to wiphy registration. The
6781 * custom regulatory domain will be trusted completely and as such previous
6782 * default channel settings will be disregarded. If no rule is found for a
6783 * channel on the regulatory domain the channel will be disabled.
222ea581 6784 * Drivers using this for a wiphy should also set the wiphy flag
ce26151b 6785 * REGULATORY_CUSTOM_REG or cfg80211 will set it for the wiphy
222ea581 6786 * that called this helper.
d3236553 6787 */
10dd9b7c
JP
6788void wiphy_apply_custom_regulatory(struct wiphy *wiphy,
6789 const struct ieee80211_regdomain *regd);
d3236553
JB
6790
6791/**
6792 * freq_reg_info - get regulatory information for the given frequency
6793 * @wiphy: the wiphy for which we want to process this rule for
6794 * @center_freq: Frequency in KHz for which we want regulatory information for
d3236553
JB
6795 *
6796 * Use this function to get the regulatory rule for a specific frequency on
6797 * a given wireless device. If the device has a specific regulatory domain
6798 * it wants to follow we respect that unless a country IE has been received
6799 * and processed already.
6800 *
0ae997dc
YB
6801 * Return: A valid pointer, or, when an error occurs, for example if no rule
6802 * can be found, the return value is encoded using ERR_PTR(). Use IS_ERR() to
6803 * check and PTR_ERR() to obtain the numeric return value. The numeric return
6804 * value will be -ERANGE if we determine the given center_freq does not even
6805 * have a regulatory rule for a frequency range in the center_freq's band.
6806 * See freq_in_rule_band() for our current definition of a band -- this is
6807 * purely subjective and right now it's 802.11 specific.
d3236553 6808 */
361c9c8b
JB
6809const struct ieee80211_reg_rule *freq_reg_info(struct wiphy *wiphy,
6810 u32 center_freq);
d3236553 6811
034c6d6e
LR
6812/**
6813 * reg_initiator_name - map regulatory request initiator enum to name
6814 * @initiator: the regulatory request initiator
6815 *
6816 * You can use this to map the regulatory request initiator enum to a
6817 * proper string representation.
6818 */
6819const char *reg_initiator_name(enum nl80211_reg_initiator initiator);
6820
dc0c18ed
AK
6821/**
6822 * regulatory_pre_cac_allowed - check if pre-CAC allowed in the current regdom
6823 * @wiphy: wiphy for which pre-CAC capability is checked.
6824 *
6825 * Pre-CAC is allowed only in some regdomains (notable ETSI).
6826 */
6827bool regulatory_pre_cac_allowed(struct wiphy *wiphy);
6828
19d3577e
HD
6829/**
6830 * DOC: Internal regulatory db functions
6831 *
6832 */
6833
6834/**
6835 * reg_query_regdb_wmm - Query internal regulatory db for wmm rule
6836 * Regulatory self-managed driver can use it to proactively
6837 *
6838 * @alpha2: the ISO/IEC 3166 alpha2 wmm rule to be queried.
6839 * @freq: the freqency(in MHz) to be queried.
19d3577e
HD
6840 * @rule: pointer to store the wmm rule from the regulatory db.
6841 *
6842 * Self-managed wireless drivers can use this function to query
6843 * the internal regulatory database to check whether the given
6844 * ISO/IEC 3166 alpha2 country and freq have wmm rule limitations.
6845 *
6846 * Drivers should check the return value, its possible you can get
6847 * an -ENODATA.
6848 *
6849 * Return: 0 on success. -ENODATA.
6850 */
38cb87ee
SG
6851int reg_query_regdb_wmm(char *alpha2, int freq,
6852 struct ieee80211_reg_rule *rule);
19d3577e 6853
d3236553
JB
6854/*
6855 * callbacks for asynchronous cfg80211 methods, notification
6856 * functions and BSS handling helpers
6857 */
6858
2a519311
JB
6859/**
6860 * cfg80211_scan_done - notify that scan finished
6861 *
6862 * @request: the corresponding scan request
1d76250b 6863 * @info: information about the completed scan
2a519311 6864 */
1d76250b
AS
6865void cfg80211_scan_done(struct cfg80211_scan_request *request,
6866 struct cfg80211_scan_info *info);
2a519311 6867
807f8a8c
LC
6868/**
6869 * cfg80211_sched_scan_results - notify that new scan results are available
6870 *
6871 * @wiphy: the wiphy which got scheduled scan results
b34939b9 6872 * @reqid: identifier for the related scheduled scan request
807f8a8c 6873 */
b34939b9 6874void cfg80211_sched_scan_results(struct wiphy *wiphy, u64 reqid);
807f8a8c
LC
6875
6876/**
6877 * cfg80211_sched_scan_stopped - notify that the scheduled scan has stopped
6878 *
6879 * @wiphy: the wiphy on which the scheduled scan stopped
b34939b9 6880 * @reqid: identifier for the related scheduled scan request
807f8a8c
LC
6881 *
6882 * The driver can call this function to inform cfg80211 that the
6883 * scheduled scan had to be stopped, for whatever reason. The driver
6884 * is then called back via the sched_scan_stop operation when done.
6885 */
b34939b9 6886void cfg80211_sched_scan_stopped(struct wiphy *wiphy, u64 reqid);
807f8a8c 6887
792e6aa7 6888/**
a05829a7 6889 * cfg80211_sched_scan_stopped_locked - notify that the scheduled scan has stopped
792e6aa7
EP
6890 *
6891 * @wiphy: the wiphy on which the scheduled scan stopped
b34939b9 6892 * @reqid: identifier for the related scheduled scan request
792e6aa7
EP
6893 *
6894 * The driver can call this function to inform cfg80211 that the
6895 * scheduled scan had to be stopped, for whatever reason. The driver
6896 * is then called back via the sched_scan_stop operation when done.
a05829a7 6897 * This function should be called with the wiphy mutex held.
792e6aa7 6898 */
a05829a7 6899void cfg80211_sched_scan_stopped_locked(struct wiphy *wiphy, u64 reqid);
807f8a8c 6900
2a519311 6901/**
6e19bc4b 6902 * cfg80211_inform_bss_frame_data - inform cfg80211 of a received BSS frame
2a519311 6903 * @wiphy: the wiphy reporting the BSS
6e19bc4b 6904 * @data: the BSS metadata
abe37c4b
JB
6905 * @mgmt: the management frame (probe response or beacon)
6906 * @len: length of the management frame
2a519311
JB
6907 * @gfp: context flags
6908 *
6909 * This informs cfg80211 that BSS information was found and
6910 * the BSS should be updated/added.
ef100682 6911 *
0ae997dc
YB
6912 * Return: A referenced struct, must be released with cfg80211_put_bss()!
6913 * Or %NULL on error.
2a519311 6914 */
ef100682 6915struct cfg80211_bss * __must_check
6e19bc4b
DS
6916cfg80211_inform_bss_frame_data(struct wiphy *wiphy,
6917 struct cfg80211_inform_bss *data,
6918 struct ieee80211_mgmt *mgmt, size_t len,
6919 gfp_t gfp);
6920
6921static inline struct cfg80211_bss * __must_check
dcd6eac1 6922cfg80211_inform_bss_width_frame(struct wiphy *wiphy,
3afc2167 6923 struct ieee80211_channel *rx_channel,
dcd6eac1
SW
6924 enum nl80211_bss_scan_width scan_width,
6925 struct ieee80211_mgmt *mgmt, size_t len,
6e19bc4b
DS
6926 s32 signal, gfp_t gfp)
6927{
6928 struct cfg80211_inform_bss data = {
6929 .chan = rx_channel,
6930 .scan_width = scan_width,
6931 .signal = signal,
6932 };
6933
6934 return cfg80211_inform_bss_frame_data(wiphy, &data, mgmt, len, gfp);
6935}
dcd6eac1
SW
6936
6937static inline struct cfg80211_bss * __must_check
2a519311 6938cfg80211_inform_bss_frame(struct wiphy *wiphy,
3afc2167 6939 struct ieee80211_channel *rx_channel,
2a519311 6940 struct ieee80211_mgmt *mgmt, size_t len,
dcd6eac1
SW
6941 s32 signal, gfp_t gfp)
6942{
6e19bc4b
DS
6943 struct cfg80211_inform_bss data = {
6944 .chan = rx_channel,
6945 .scan_width = NL80211_BSS_CHAN_WIDTH_20,
6946 .signal = signal,
6947 };
6948
6949 return cfg80211_inform_bss_frame_data(wiphy, &data, mgmt, len, gfp);
dcd6eac1 6950}
2a519311 6951
7ece9c37
SS
6952/**
6953 * cfg80211_gen_new_bssid - generate a nontransmitted BSSID for multi-BSSID
6954 * @bssid: transmitter BSSID
6955 * @max_bssid: max BSSID indicator, taken from Multiple BSSID element
6956 * @mbssid_index: BSSID index, taken from Multiple BSSID index element
5d4071ab 6957 * @new_bssid: calculated nontransmitted BSSID
7ece9c37
SS
6958 */
6959static inline void cfg80211_gen_new_bssid(const u8 *bssid, u8 max_bssid,
5d4071ab 6960 u8 mbssid_index, u8 *new_bssid)
7ece9c37 6961{
5d4071ab
JB
6962 u64 bssid_u64 = ether_addr_to_u64(bssid);
6963 u64 mask = GENMASK_ULL(max_bssid - 1, 0);
6964 u64 new_bssid_u64;
7ece9c37 6965
5d4071ab 6966 new_bssid_u64 = bssid_u64 & ~mask;
7ece9c37 6967
5d4071ab 6968 new_bssid_u64 |= ((bssid_u64 & mask) + mbssid_index) & mask;
7ece9c37 6969
5d4071ab 6970 u64_to_ether_addr(new_bssid_u64, new_bssid);
7ece9c37
SS
6971}
6972
f7dacfb1
SS
6973/**
6974 * cfg80211_is_element_inherited - returns if element ID should be inherited
6975 * @element: element to check
6976 * @non_inherit_element: non inheritance element
6977 */
6978bool cfg80211_is_element_inherited(const struct element *element,
6979 const struct element *non_inherit_element);
6980
fe806e49
SS
6981/**
6982 * cfg80211_merge_profile - merges a MBSSID profile if it is split between IEs
6983 * @ie: ies
6984 * @ielen: length of IEs
6985 * @mbssid_elem: current MBSSID element
6986 * @sub_elem: current MBSSID subelement (profile)
6987 * @merged_ie: location of the merged profile
6988 * @max_copy_len: max merged profile length
6989 */
6990size_t cfg80211_merge_profile(const u8 *ie, size_t ielen,
6991 const struct element *mbssid_elem,
6992 const struct element *sub_elem,
5809a5d5 6993 u8 *merged_ie, size_t max_copy_len);
fe806e49 6994
abe37c4b 6995/**
5bc8c1f2
JB
6996 * enum cfg80211_bss_frame_type - frame type that the BSS data came from
6997 * @CFG80211_BSS_FTYPE_UNKNOWN: driver doesn't know whether the data is
6998 * from a beacon or probe response
6999 * @CFG80211_BSS_FTYPE_BEACON: data comes from a beacon
7000 * @CFG80211_BSS_FTYPE_PRESP: data comes from a probe response
7001 */
7002enum cfg80211_bss_frame_type {
7003 CFG80211_BSS_FTYPE_UNKNOWN,
7004 CFG80211_BSS_FTYPE_BEACON,
7005 CFG80211_BSS_FTYPE_PRESP,
7006};
7007
7f599aec
AB
7008/**
7009 * cfg80211_get_ies_channel_number - returns the channel number from ies
7010 * @ie: IEs
7011 * @ielen: length of IEs
7012 * @band: enum nl80211_band of the channel
7f599aec
AB
7013 *
7014 * Returns the channel number, or -1 if none could be determined.
7015 */
7016int cfg80211_get_ies_channel_number(const u8 *ie, size_t ielen,
6ff9efcf 7017 enum nl80211_band band);
7f599aec 7018
5bc8c1f2 7019/**
6e19bc4b 7020 * cfg80211_inform_bss_data - inform cfg80211 of a new BSS
abe37c4b
JB
7021 *
7022 * @wiphy: the wiphy reporting the BSS
6e19bc4b 7023 * @data: the BSS metadata
5bc8c1f2 7024 * @ftype: frame type (if known)
abe37c4b 7025 * @bssid: the BSSID of the BSS
7b8bcff2 7026 * @tsf: the TSF sent by the peer in the beacon/probe response (or 0)
abe37c4b
JB
7027 * @capability: the capability field sent by the peer
7028 * @beacon_interval: the beacon interval announced by the peer
7029 * @ie: additional IEs sent by the peer
7030 * @ielen: length of the additional IEs
abe37c4b
JB
7031 * @gfp: context flags
7032 *
7033 * This informs cfg80211 that BSS information was found and
7034 * the BSS should be updated/added.
ef100682 7035 *
0ae997dc
YB
7036 * Return: A referenced struct, must be released with cfg80211_put_bss()!
7037 * Or %NULL on error.
abe37c4b 7038 */
ef100682 7039struct cfg80211_bss * __must_check
6e19bc4b
DS
7040cfg80211_inform_bss_data(struct wiphy *wiphy,
7041 struct cfg80211_inform_bss *data,
7042 enum cfg80211_bss_frame_type ftype,
7043 const u8 *bssid, u64 tsf, u16 capability,
7044 u16 beacon_interval, const u8 *ie, size_t ielen,
7045 gfp_t gfp);
7046
7047static inline struct cfg80211_bss * __must_check
dcd6eac1 7048cfg80211_inform_bss_width(struct wiphy *wiphy,
3afc2167 7049 struct ieee80211_channel *rx_channel,
dcd6eac1 7050 enum nl80211_bss_scan_width scan_width,
5bc8c1f2 7051 enum cfg80211_bss_frame_type ftype,
dcd6eac1
SW
7052 const u8 *bssid, u64 tsf, u16 capability,
7053 u16 beacon_interval, const u8 *ie, size_t ielen,
6e19bc4b
DS
7054 s32 signal, gfp_t gfp)
7055{
7056 struct cfg80211_inform_bss data = {
7057 .chan = rx_channel,
7058 .scan_width = scan_width,
7059 .signal = signal,
7060 };
7061
7062 return cfg80211_inform_bss_data(wiphy, &data, ftype, bssid, tsf,
7063 capability, beacon_interval, ie, ielen,
7064 gfp);
7065}
dcd6eac1
SW
7066
7067static inline struct cfg80211_bss * __must_check
06aa7afa 7068cfg80211_inform_bss(struct wiphy *wiphy,
3afc2167 7069 struct ieee80211_channel *rx_channel,
5bc8c1f2 7070 enum cfg80211_bss_frame_type ftype,
7b8bcff2
JB
7071 const u8 *bssid, u64 tsf, u16 capability,
7072 u16 beacon_interval, const u8 *ie, size_t ielen,
dcd6eac1
SW
7073 s32 signal, gfp_t gfp)
7074{
6e19bc4b
DS
7075 struct cfg80211_inform_bss data = {
7076 .chan = rx_channel,
7077 .scan_width = NL80211_BSS_CHAN_WIDTH_20,
7078 .signal = signal,
7079 };
7080
7081 return cfg80211_inform_bss_data(wiphy, &data, ftype, bssid, tsf,
7082 capability, beacon_interval, ie, ielen,
7083 gfp);
dcd6eac1 7084}
06aa7afa 7085
27548677
JB
7086/**
7087 * cfg80211_get_bss - get a BSS reference
7088 * @wiphy: the wiphy this BSS struct belongs to
7089 * @channel: the channel to search on (or %NULL)
7090 * @bssid: the desired BSSID (or %NULL)
7091 * @ssid: the desired SSID (or %NULL)
7092 * @ssid_len: length of the SSID (or 0)
7093 * @bss_type: type of BSS, see &enum ieee80211_bss_type
7094 * @privacy: privacy filter, see &enum ieee80211_privacy
7095 */
2a519311
JB
7096struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
7097 struct ieee80211_channel *channel,
7098 const u8 *bssid,
79420f09 7099 const u8 *ssid, size_t ssid_len,
6eb18137 7100 enum ieee80211_bss_type bss_type,
27548677 7101 enum ieee80211_privacy privacy);
79420f09
JB
7102static inline struct cfg80211_bss *
7103cfg80211_get_ibss(struct wiphy *wiphy,
7104 struct ieee80211_channel *channel,
7105 const u8 *ssid, size_t ssid_len)
7106{
7107 return cfg80211_get_bss(wiphy, channel, NULL, ssid, ssid_len,
6eb18137
DL
7108 IEEE80211_BSS_TYPE_IBSS,
7109 IEEE80211_PRIVACY_ANY);
79420f09
JB
7110}
7111
4c0c0b75
JB
7112/**
7113 * cfg80211_ref_bss - reference BSS struct
5b112d3d 7114 * @wiphy: the wiphy this BSS struct belongs to
4c0c0b75
JB
7115 * @bss: the BSS struct to reference
7116 *
7117 * Increments the refcount of the given BSS struct.
7118 */
5b112d3d 7119void cfg80211_ref_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
4c0c0b75
JB
7120
7121/**
7122 * cfg80211_put_bss - unref BSS struct
5b112d3d 7123 * @wiphy: the wiphy this BSS struct belongs to
4c0c0b75
JB
7124 * @bss: the BSS struct
7125 *
7126 * Decrements the refcount of the given BSS struct.
7127 */
5b112d3d 7128void cfg80211_put_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
d3236553 7129
d491af19
JB
7130/**
7131 * cfg80211_unlink_bss - unlink BSS from internal data structures
7132 * @wiphy: the wiphy
7133 * @bss: the bss to remove
7134 *
7135 * This function removes the given BSS from the internal data structures
7136 * thereby making it no longer show up in scan results etc. Use this
7137 * function when you detect a BSS is gone. Normally BSSes will also time
7138 * out, so it is not necessary to use this function at all.
7139 */
7140void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
fee52678 7141
4770c8f9
IP
7142/**
7143 * cfg80211_bss_iter - iterate all BSS entries
7144 *
7145 * This function iterates over the BSS entries associated with the given wiphy
7146 * and calls the callback for the iterated BSS. The iterator function is not
7147 * allowed to call functions that might modify the internal state of the BSS DB.
7148 *
7149 * @wiphy: the wiphy
7150 * @chandef: if given, the iterator function will be called only if the channel
7151 * of the currently iterated BSS is a subset of the given channel.
7152 * @iter: the iterator function to call
7153 * @iter_data: an argument to the iterator function
7154 */
7155void cfg80211_bss_iter(struct wiphy *wiphy,
7156 struct cfg80211_chan_def *chandef,
7157 void (*iter)(struct wiphy *wiphy,
7158 struct cfg80211_bss *bss,
7159 void *data),
7160 void *iter_data);
7161
dcd6eac1
SW
7162static inline enum nl80211_bss_scan_width
7163cfg80211_chandef_to_scan_width(const struct cfg80211_chan_def *chandef)
7164{
7165 switch (chandef->width) {
7166 case NL80211_CHAN_WIDTH_5:
7167 return NL80211_BSS_CHAN_WIDTH_5;
7168 case NL80211_CHAN_WIDTH_10:
7169 return NL80211_BSS_CHAN_WIDTH_10;
7170 default:
7171 return NL80211_BSS_CHAN_WIDTH_20;
7172 }
7173}
7174
6039f6d2 7175/**
6ff57cf8 7176 * cfg80211_rx_mlme_mgmt - notification of processed MLME management frame
6039f6d2
JM
7177 * @dev: network device
7178 * @buf: authentication frame (header + body)
7179 * @len: length of the frame data
7180 *
6ff57cf8
JB
7181 * This function is called whenever an authentication, disassociation or
7182 * deauthentication frame has been received and processed in station mode.
7183 * After being asked to authenticate via cfg80211_ops::auth() the driver must
7184 * call either this function or cfg80211_auth_timeout().
7185 * After being asked to associate via cfg80211_ops::assoc() the driver must
7186 * call either this function or cfg80211_auth_timeout().
7187 * While connected, the driver must calls this for received and processed
7188 * disassociation and deauthentication frames. If the frame couldn't be used
7189 * because it was unprotected, the driver must call the function
7190 * cfg80211_rx_unprot_mlme_mgmt() instead.
7191 *
7192 * This function may sleep. The caller must hold the corresponding wdev's mutex.
6039f6d2 7193 */
6ff57cf8 7194void cfg80211_rx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len);
6039f6d2 7195
1965c853 7196/**
6ff57cf8 7197 * cfg80211_auth_timeout - notification of timed out authentication
1965c853
JM
7198 * @dev: network device
7199 * @addr: The MAC address of the device with which the authentication timed out
cb0b4beb 7200 *
8d61ffa5
JB
7201 * This function may sleep. The caller must hold the corresponding wdev's
7202 * mutex.
1965c853 7203 */
6ff57cf8 7204void cfg80211_auth_timeout(struct net_device *dev, const u8 *addr);
1965c853 7205
6039f6d2 7206/**
cd47c0f5 7207 * struct cfg80211_rx_assoc_resp - association response data
6ff57cf8 7208 * @bss: the BSS that association was requested with, ownership of the pointer
cd47c0f5 7209 * moves to cfg80211 in the call to cfg80211_rx_assoc_resp()
4d9ec73d 7210 * @buf: (Re)Association Response frame (header + body)
6039f6d2 7211 * @len: length of the frame data
f438ceb8
EG
7212 * @uapsd_queues: bitmap of queues configured for uapsd. Same format
7213 * as the AC bitmap in the QoS info field
4d9ec73d
JM
7214 * @req_ies: information elements from the (Re)Association Request frame
7215 * @req_ies_len: length of req_ies data
5cd212cb
JB
7216 * @ap_mld_addr: AP MLD address (in case of MLO)
7217 * @links: per-link information indexed by link ID, use links[0] for
7218 * non-MLO connections
53ad07e9
JB
7219 * @links.status: Set this (along with a BSS pointer) for links that
7220 * were rejected by the AP.
cd47c0f5
JB
7221 */
7222struct cfg80211_rx_assoc_resp {
cd47c0f5
JB
7223 const u8 *buf;
7224 size_t len;
7225 const u8 *req_ies;
7226 size_t req_ies_len;
7227 int uapsd_queues;
5cd212cb
JB
7228 const u8 *ap_mld_addr;
7229 struct {
7230 const u8 *addr;
7231 struct cfg80211_bss *bss;
53ad07e9 7232 u16 status;
5cd212cb 7233 } links[IEEE80211_MLD_MAX_NUM_LINKS];
cd47c0f5
JB
7234};
7235
7236/**
7237 * cfg80211_rx_assoc_resp - notification of processed association response
7238 * @dev: network device
7239 * @data: association response data, &struct cfg80211_rx_assoc_resp
6039f6d2 7240 *
6ff57cf8
JB
7241 * After being asked to associate via cfg80211_ops::assoc() the driver must
7242 * call either this function or cfg80211_auth_timeout().
7243 *
7244 * This function may sleep. The caller must hold the corresponding wdev's mutex.
6039f6d2 7245 */
6ff57cf8 7246void cfg80211_rx_assoc_resp(struct net_device *dev,
cd47c0f5 7247 struct cfg80211_rx_assoc_resp *data);
6039f6d2 7248
1965c853 7249/**
f662d2f4
JB
7250 * struct cfg80211_assoc_failure - association failure data
7251 * @ap_mld_addr: AP MLD address, or %NULL
7252 * @bss: list of BSSes, must use entry 0 for non-MLO connections
7253 * (@ap_mld_addr is %NULL)
7254 * @timeout: indicates the association failed due to timeout, otherwise
7255 * the association was abandoned for a reason reported through some
7256 * other API (e.g. deauth RX)
7257 */
7258struct cfg80211_assoc_failure {
7259 const u8 *ap_mld_addr;
7260 struct cfg80211_bss *bss[IEEE80211_MLD_MAX_NUM_LINKS];
7261 bool timeout;
7262};
1965c853 7263
e6f462df 7264/**
f662d2f4 7265 * cfg80211_assoc_failure - notification of association failure
e6f462df 7266 * @dev: network device
f662d2f4 7267 * @data: data describing the association failure
e6f462df 7268 *
e6f462df
JB
7269 * This function may sleep. The caller must hold the corresponding wdev's mutex.
7270 */
f662d2f4
JB
7271void cfg80211_assoc_failure(struct net_device *dev,
7272 struct cfg80211_assoc_failure *data);
e6f462df 7273
6039f6d2 7274/**
6ff57cf8 7275 * cfg80211_tx_mlme_mgmt - notification of transmitted deauth/disassoc frame
6039f6d2 7276 * @dev: network device
6ff57cf8 7277 * @buf: 802.11 frame (header + body)
6039f6d2 7278 * @len: length of the frame data
3bb02143 7279 * @reconnect: immediate reconnect is desired (include the nl80211 attribute)
6039f6d2
JM
7280 *
7281 * This function is called whenever deauthentication has been processed in
53b46b84 7282 * station mode. This includes both received deauthentication frames and
8d61ffa5
JB
7283 * locally generated ones. This function may sleep. The caller must hold the
7284 * corresponding wdev's mutex.
6039f6d2 7285 */
3bb02143
JB
7286void cfg80211_tx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len,
7287 bool reconnect);
ce470613 7288
6039f6d2 7289/**
6ff57cf8 7290 * cfg80211_rx_unprot_mlme_mgmt - notification of unprotected mlme mgmt frame
cf4e594e 7291 * @dev: network device
4d797fce 7292 * @buf: received management frame (header + body)
cf4e594e
JM
7293 * @len: length of the frame data
7294 *
6ff57cf8
JB
7295 * This function is called whenever a received deauthentication or dissassoc
7296 * frame has been dropped in station mode because of MFP being used but the
4d797fce
JM
7297 * frame was not protected. This is also used to notify reception of a Beacon
7298 * frame that was dropped because it did not include a valid MME MIC while
7299 * beacon protection was enabled (BIGTK configured in station mode).
7300 *
7301 * This function may sleep.
cf4e594e 7302 */
6ff57cf8
JB
7303void cfg80211_rx_unprot_mlme_mgmt(struct net_device *dev,
7304 const u8 *buf, size_t len);
cf4e594e 7305
a3b8b056
JM
7306/**
7307 * cfg80211_michael_mic_failure - notification of Michael MIC failure (TKIP)
7308 * @dev: network device
7309 * @addr: The source MAC address of the frame
7310 * @key_type: The key type that the received frame used
a66b98db 7311 * @key_id: Key identifier (0..3). Can be -1 if missing.
a3b8b056 7312 * @tsc: The TSC value of the frame that generated the MIC failure (6 octets)
e6d6e342 7313 * @gfp: allocation flags
a3b8b056
JM
7314 *
7315 * This function is called whenever the local MAC detects a MIC failure in a
7316 * received frame. This matches with MLME-MICHAELMICFAILURE.indication()
7317 * primitive.
7318 */
7319void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
7320 enum nl80211_key_type key_type, int key_id,
e6d6e342 7321 const u8 *tsc, gfp_t gfp);
a3b8b056 7322
04a773ad
JB
7323/**
7324 * cfg80211_ibss_joined - notify cfg80211 that device joined an IBSS
7325 *
7326 * @dev: network device
7327 * @bssid: the BSSID of the IBSS joined
fe94f3a4 7328 * @channel: the channel of the IBSS joined
04a773ad
JB
7329 * @gfp: allocation flags
7330 *
7331 * This function notifies cfg80211 that the device joined an IBSS or
7332 * switched to a different BSSID. Before this function can be called,
7333 * either a beacon has to have been received from the IBSS, or one of
7334 * the cfg80211_inform_bss{,_frame} functions must have been called
7335 * with the locally generated beacon -- this guarantees that there is
7336 * always a scan result for this IBSS. cfg80211 will handle the rest.
7337 */
fe94f3a4
AQ
7338void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
7339 struct ieee80211_channel *channel, gfp_t gfp);
04a773ad 7340
c93b5e71 7341/**
b1e8eb11
MCC
7342 * cfg80211_notify_new_peer_candidate - notify cfg80211 of a new mesh peer
7343 * candidate
c93b5e71
JC
7344 *
7345 * @dev: network device
7346 * @macaddr: the MAC address of the new candidate
7347 * @ie: information elements advertised by the peer candidate
5ac4a12d 7348 * @ie_len: length of the information elements buffer
2d8b08fe 7349 * @sig_dbm: signal level in dBm
c93b5e71
JC
7350 * @gfp: allocation flags
7351 *
7352 * This function notifies cfg80211 that the mesh peer candidate has been
7353 * detected, most likely via a beacon or, less likely, via a probe response.
7354 * cfg80211 then sends a notification to userspace.
7355 */
7356void cfg80211_notify_new_peer_candidate(struct net_device *dev,
ecbc12ad
BC
7357 const u8 *macaddr, const u8 *ie, u8 ie_len,
7358 int sig_dbm, gfp_t gfp);
c93b5e71 7359
d70e9693
JB
7360/**
7361 * DOC: RFkill integration
7362 *
7363 * RFkill integration in cfg80211 is almost invisible to drivers,
7364 * as cfg80211 automatically registers an rfkill instance for each
7365 * wireless device it knows about. Soft kill is also translated
7366 * into disconnecting and turning all interfaces off, drivers are
7367 * expected to turn off the device when all interfaces are down.
7368 *
7369 * However, devices may have a hard RFkill line, in which case they
7370 * also need to interact with the rfkill subsystem, via cfg80211.
7371 * They can do this with a few helper functions documented here.
7372 */
7373
1f87f7d3 7374/**
810344ed 7375 * wiphy_rfkill_set_hw_state_reason - notify cfg80211 about hw block state
1f87f7d3
JB
7376 * @wiphy: the wiphy
7377 * @blocked: block status
6f779a66 7378 * @reason: one of reasons in &enum rfkill_hard_block_reasons
1f87f7d3 7379 */
6f779a66
EG
7380void wiphy_rfkill_set_hw_state_reason(struct wiphy *wiphy, bool blocked,
7381 enum rfkill_hard_block_reasons reason);
7382
7383static inline void wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool blocked)
7384{
7385 wiphy_rfkill_set_hw_state_reason(wiphy, blocked,
7386 RFKILL_HARD_BLOCK_SIGNAL);
7387}
1f87f7d3
JB
7388
7389/**
7390 * wiphy_rfkill_start_polling - start polling rfkill
7391 * @wiphy: the wiphy
7392 */
7393void wiphy_rfkill_start_polling(struct wiphy *wiphy);
7394
7395/**
7396 * wiphy_rfkill_stop_polling - stop polling rfkill
7397 * @wiphy: the wiphy
7398 */
358ae888
EG
7399static inline void wiphy_rfkill_stop_polling(struct wiphy *wiphy)
7400{
7401 rfkill_pause_polling(wiphy->rfkill);
7402}
1f87f7d3 7403
ad7e718c
JB
7404/**
7405 * DOC: Vendor commands
7406 *
7407 * Occasionally, there are special protocol or firmware features that
7408 * can't be implemented very openly. For this and similar cases, the
7409 * vendor command functionality allows implementing the features with
7410 * (typically closed-source) userspace and firmware, using nl80211 as
7411 * the configuration mechanism.
7412 *
7413 * A driver supporting vendor commands must register them as an array
7414 * in struct wiphy, with handlers for each one, each command has an
7415 * OUI and sub command ID to identify it.
7416 *
7417 * Note that this feature should not be (ab)used to implement protocol
7418 * features that could openly be shared across drivers. In particular,
7419 * it must never be required to use vendor commands to implement any
7420 * "normal" functionality that higher-level userspace like connection
7421 * managers etc. need.
7422 */
7423
7424struct sk_buff *__cfg80211_alloc_reply_skb(struct wiphy *wiphy,
7425 enum nl80211_commands cmd,
7426 enum nl80211_attrs attr,
7427 int approxlen);
7428
567ffc35 7429struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy,
6c09e791 7430 struct wireless_dev *wdev,
567ffc35
JB
7431 enum nl80211_commands cmd,
7432 enum nl80211_attrs attr,
55c1fdf0 7433 unsigned int portid,
567ffc35
JB
7434 int vendor_event_idx,
7435 int approxlen, gfp_t gfp);
7436
7437void __cfg80211_send_event_skb(struct sk_buff *skb, gfp_t gfp);
7438
ad7e718c
JB
7439/**
7440 * cfg80211_vendor_cmd_alloc_reply_skb - allocate vendor command reply
7441 * @wiphy: the wiphy
7442 * @approxlen: an upper bound of the length of the data that will
7443 * be put into the skb
7444 *
7445 * This function allocates and pre-fills an skb for a reply to
7446 * a vendor command. Since it is intended for a reply, calling
7447 * it outside of a vendor command's doit() operation is invalid.
7448 *
7449 * The returned skb is pre-filled with some identifying data in
7450 * a way that any data that is put into the skb (with skb_put(),
7451 * nla_put() or similar) will end up being within the
7452 * %NL80211_ATTR_VENDOR_DATA attribute, so all that needs to be done
7453 * with the skb is adding data for the corresponding userspace tool
7454 * which can then read that data out of the vendor data attribute.
7455 * You must not modify the skb in any other way.
7456 *
7457 * When done, call cfg80211_vendor_cmd_reply() with the skb and return
7458 * its error code as the result of the doit() operation.
7459 *
7460 * Return: An allocated and pre-filled skb. %NULL if any errors happen.
7461 */
7462static inline struct sk_buff *
7463cfg80211_vendor_cmd_alloc_reply_skb(struct wiphy *wiphy, int approxlen)
7464{
7465 return __cfg80211_alloc_reply_skb(wiphy, NL80211_CMD_VENDOR,
7466 NL80211_ATTR_VENDOR_DATA, approxlen);
7467}
7468
7469/**
7470 * cfg80211_vendor_cmd_reply - send the reply skb
7471 * @skb: The skb, must have been allocated with
7472 * cfg80211_vendor_cmd_alloc_reply_skb()
7473 *
7474 * Since calling this function will usually be the last thing
7475 * before returning from the vendor command doit() you should
7476 * return the error code. Note that this function consumes the
7477 * skb regardless of the return value.
7478 *
7479 * Return: An error code or 0 on success.
7480 */
7481int cfg80211_vendor_cmd_reply(struct sk_buff *skb);
7482
55c1fdf0 7483/**
5d9c358d 7484 * cfg80211_vendor_cmd_get_sender - get the current sender netlink ID
55c1fdf0
JB
7485 * @wiphy: the wiphy
7486 *
7487 * Return the current netlink port ID in a vendor command handler.
7488 * Valid to call only there.
7489 */
7490unsigned int cfg80211_vendor_cmd_get_sender(struct wiphy *wiphy);
7491
567ffc35
JB
7492/**
7493 * cfg80211_vendor_event_alloc - allocate vendor-specific event skb
7494 * @wiphy: the wiphy
6c09e791 7495 * @wdev: the wireless device
567ffc35
JB
7496 * @event_idx: index of the vendor event in the wiphy's vendor_events
7497 * @approxlen: an upper bound of the length of the data that will
7498 * be put into the skb
7499 * @gfp: allocation flags
7500 *
7501 * This function allocates and pre-fills an skb for an event on the
7502 * vendor-specific multicast group.
7503 *
6c09e791
AK
7504 * If wdev != NULL, both the ifindex and identifier of the specified
7505 * wireless device are added to the event message before the vendor data
7506 * attribute.
7507 *
567ffc35
JB
7508 * When done filling the skb, call cfg80211_vendor_event() with the
7509 * skb to send the event.
7510 *
7511 * Return: An allocated and pre-filled skb. %NULL if any errors happen.
7512 */
7513static inline struct sk_buff *
6c09e791
AK
7514cfg80211_vendor_event_alloc(struct wiphy *wiphy, struct wireless_dev *wdev,
7515 int approxlen, int event_idx, gfp_t gfp)
567ffc35 7516{
6c09e791 7517 return __cfg80211_alloc_event_skb(wiphy, wdev, NL80211_CMD_VENDOR,
567ffc35 7518 NL80211_ATTR_VENDOR_DATA,
55c1fdf0
JB
7519 0, event_idx, approxlen, gfp);
7520}
7521
7522/**
7523 * cfg80211_vendor_event_alloc_ucast - alloc unicast vendor-specific event skb
7524 * @wiphy: the wiphy
7525 * @wdev: the wireless device
7526 * @event_idx: index of the vendor event in the wiphy's vendor_events
7527 * @portid: port ID of the receiver
7528 * @approxlen: an upper bound of the length of the data that will
7529 * be put into the skb
7530 * @gfp: allocation flags
7531 *
7532 * This function allocates and pre-fills an skb for an event to send to
7533 * a specific (userland) socket. This socket would previously have been
7534 * obtained by cfg80211_vendor_cmd_get_sender(), and the caller MUST take
7535 * care to register a netlink notifier to see when the socket closes.
7536 *
7537 * If wdev != NULL, both the ifindex and identifier of the specified
7538 * wireless device are added to the event message before the vendor data
7539 * attribute.
7540 *
7541 * When done filling the skb, call cfg80211_vendor_event() with the
7542 * skb to send the event.
7543 *
7544 * Return: An allocated and pre-filled skb. %NULL if any errors happen.
7545 */
7546static inline struct sk_buff *
7547cfg80211_vendor_event_alloc_ucast(struct wiphy *wiphy,
7548 struct wireless_dev *wdev,
7549 unsigned int portid, int approxlen,
7550 int event_idx, gfp_t gfp)
7551{
7552 return __cfg80211_alloc_event_skb(wiphy, wdev, NL80211_CMD_VENDOR,
7553 NL80211_ATTR_VENDOR_DATA,
7554 portid, event_idx, approxlen, gfp);
567ffc35
JB
7555}
7556
7557/**
7558 * cfg80211_vendor_event - send the event
7559 * @skb: The skb, must have been allocated with cfg80211_vendor_event_alloc()
7560 * @gfp: allocation flags
7561 *
7562 * This function sends the given @skb, which must have been allocated
7563 * by cfg80211_vendor_event_alloc(), as an event. It always consumes it.
7564 */
7565static inline void cfg80211_vendor_event(struct sk_buff *skb, gfp_t gfp)
7566{
7567 __cfg80211_send_event_skb(skb, gfp);
7568}
7569
aff89a9b 7570#ifdef CONFIG_NL80211_TESTMODE
d70e9693
JB
7571/**
7572 * DOC: Test mode
7573 *
7574 * Test mode is a set of utility functions to allow drivers to
7575 * interact with driver-specific tools to aid, for instance,
7576 * factory programming.
7577 *
7578 * This chapter describes how drivers interact with it, for more
7579 * information see the nl80211 book's chapter on it.
7580 */
7581
aff89a9b
JB
7582/**
7583 * cfg80211_testmode_alloc_reply_skb - allocate testmode reply
7584 * @wiphy: the wiphy
7585 * @approxlen: an upper bound of the length of the data that will
7586 * be put into the skb
7587 *
7588 * This function allocates and pre-fills an skb for a reply to
7589 * the testmode command. Since it is intended for a reply, calling
7590 * it outside of the @testmode_cmd operation is invalid.
7591 *
0ae997dc
YB
7592 * The returned skb is pre-filled with the wiphy index and set up in
7593 * a way that any data that is put into the skb (with skb_put(),
7594 * nla_put() or similar) will end up being within the
7595 * %NL80211_ATTR_TESTDATA attribute, so all that needs to be done
7596 * with the skb is adding data for the corresponding userspace tool
7597 * which can then read that data out of the testdata attribute. You
7598 * must not modify the skb in any other way.
aff89a9b
JB
7599 *
7600 * When done, call cfg80211_testmode_reply() with the skb and return
7601 * its error code as the result of the @testmode_cmd operation.
0ae997dc
YB
7602 *
7603 * Return: An allocated and pre-filled skb. %NULL if any errors happen.
aff89a9b 7604 */
ad7e718c
JB
7605static inline struct sk_buff *
7606cfg80211_testmode_alloc_reply_skb(struct wiphy *wiphy, int approxlen)
7607{
7608 return __cfg80211_alloc_reply_skb(wiphy, NL80211_CMD_TESTMODE,
7609 NL80211_ATTR_TESTDATA, approxlen);
7610}
aff89a9b
JB
7611
7612/**
7613 * cfg80211_testmode_reply - send the reply skb
7614 * @skb: The skb, must have been allocated with
7615 * cfg80211_testmode_alloc_reply_skb()
7616 *
0ae997dc
YB
7617 * Since calling this function will usually be the last thing
7618 * before returning from the @testmode_cmd you should return
7619 * the error code. Note that this function consumes the skb
7620 * regardless of the return value.
7621 *
7622 * Return: An error code or 0 on success.
aff89a9b 7623 */
ad7e718c
JB
7624static inline int cfg80211_testmode_reply(struct sk_buff *skb)
7625{
7626 return cfg80211_vendor_cmd_reply(skb);
7627}
aff89a9b
JB
7628
7629/**
7630 * cfg80211_testmode_alloc_event_skb - allocate testmode event
7631 * @wiphy: the wiphy
7632 * @approxlen: an upper bound of the length of the data that will
7633 * be put into the skb
7634 * @gfp: allocation flags
7635 *
7636 * This function allocates and pre-fills an skb for an event on the
7637 * testmode multicast group.
7638 *
0ae997dc
YB
7639 * The returned skb is set up in the same way as with
7640 * cfg80211_testmode_alloc_reply_skb() but prepared for an event. As
7641 * there, you should simply add data to it that will then end up in the
7642 * %NL80211_ATTR_TESTDATA attribute. Again, you must not modify the skb
7643 * in any other way.
aff89a9b
JB
7644 *
7645 * When done filling the skb, call cfg80211_testmode_event() with the
7646 * skb to send the event.
0ae997dc
YB
7647 *
7648 * Return: An allocated and pre-filled skb. %NULL if any errors happen.
aff89a9b 7649 */
567ffc35
JB
7650static inline struct sk_buff *
7651cfg80211_testmode_alloc_event_skb(struct wiphy *wiphy, int approxlen, gfp_t gfp)
7652{
6c09e791 7653 return __cfg80211_alloc_event_skb(wiphy, NULL, NL80211_CMD_TESTMODE,
55c1fdf0 7654 NL80211_ATTR_TESTDATA, 0, -1,
567ffc35
JB
7655 approxlen, gfp);
7656}
aff89a9b
JB
7657
7658/**
7659 * cfg80211_testmode_event - send the event
7660 * @skb: The skb, must have been allocated with
7661 * cfg80211_testmode_alloc_event_skb()
7662 * @gfp: allocation flags
7663 *
7664 * This function sends the given @skb, which must have been allocated
7665 * by cfg80211_testmode_alloc_event_skb(), as an event. It always
7666 * consumes it.
7667 */
567ffc35
JB
7668static inline void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
7669{
7670 __cfg80211_send_event_skb(skb, gfp);
7671}
aff89a9b
JB
7672
7673#define CFG80211_TESTMODE_CMD(cmd) .testmode_cmd = (cmd),
71063f0e 7674#define CFG80211_TESTMODE_DUMP(cmd) .testmode_dump = (cmd),
aff89a9b
JB
7675#else
7676#define CFG80211_TESTMODE_CMD(cmd)
71063f0e 7677#define CFG80211_TESTMODE_DUMP(cmd)
aff89a9b
JB
7678#endif
7679
76804d28
AVS
7680/**
7681 * struct cfg80211_fils_resp_params - FILS connection response params
7682 * @kek: KEK derived from a successful FILS connection (may be %NULL)
7683 * @kek_len: Length of @fils_kek in octets
7684 * @update_erp_next_seq_num: Boolean value to specify whether the value in
7685 * @erp_next_seq_num is valid.
7686 * @erp_next_seq_num: The next sequence number to use in ERP message in
7687 * FILS Authentication. This value should be specified irrespective of the
7688 * status for a FILS connection.
7689 * @pmk: A new PMK if derived from a successful FILS connection (may be %NULL).
7690 * @pmk_len: Length of @pmk in octets
7691 * @pmkid: A new PMKID if derived from a successful FILS connection or the PMKID
7692 * used for this FILS connection (may be %NULL).
7693 */
7694struct cfg80211_fils_resp_params {
7695 const u8 *kek;
7696 size_t kek_len;
7697 bool update_erp_next_seq_num;
7698 u16 erp_next_seq_num;
7699 const u8 *pmk;
7700 size_t pmk_len;
7701 const u8 *pmkid;
7702};
7703
5349a0f7
VK
7704/**
7705 * struct cfg80211_connect_resp_params - Connection response params
7706 * @status: Status code, %WLAN_STATUS_SUCCESS for successful connection, use
7707 * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
7708 * the real status code for failures. If this call is used to report a
7709 * failure due to a timeout (e.g., not receiving an Authentication frame
7710 * from the AP) instead of an explicit rejection by the AP, -1 is used to
7711 * indicate that this is a failure, but without a status code.
7712 * @timeout_reason is used to report the reason for the timeout in that
7713 * case.
5349a0f7
VK
7714 * @req_ie: Association request IEs (may be %NULL)
7715 * @req_ie_len: Association request IEs length
7716 * @resp_ie: Association response IEs (may be %NULL)
7717 * @resp_ie_len: Association response IEs length
76804d28 7718 * @fils: FILS connection response parameters.
5349a0f7
VK
7719 * @timeout_reason: Reason for connection timeout. This is used when the
7720 * connection fails due to a timeout instead of an explicit rejection from
7721 * the AP. %NL80211_TIMEOUT_UNSPECIFIED is used when the timeout reason is
7722 * not known. This value is used only if @status < 0 to indicate that the
7723 * failure is due to a timeout and not due to explicit rejection by the AP.
7724 * This value is ignored in other cases (@status >= 0).
efbabc11
VJ
7725 * @valid_links: For MLO connection, BIT mask of the valid link ids. Otherwise
7726 * zero.
7727 * @ap_mld_addr: For MLO connection, MLD address of the AP. Otherwise %NULL.
7728 * @links : For MLO connection, contains link info for the valid links indicated
7729 * using @valid_links. For non-MLO connection, links[0] contains the
7730 * connected AP info.
7731 * @links.addr: For MLO connection, MAC address of the STA link. Otherwise
7732 * %NULL.
7733 * @links.bssid: For MLO connection, MAC address of the AP link. For non-MLO
7734 * connection, links[0].bssid points to the BSSID of the AP (may be %NULL).
7735 * @links.bss: For MLO connection, entry of bss to which STA link is connected.
7736 * For non-MLO connection, links[0].bss points to entry of bss to which STA
7737 * is connected. It can be obtained through cfg80211_get_bss() (may be
7738 * %NULL). It is recommended to store the bss from the connect_request and
7739 * hold a reference to it and return through this param to avoid a warning
7740 * if the bss is expired during the connection, esp. for those drivers
7741 * implementing connect op. Only one parameter among @bssid and @bss needs
7742 * to be specified.
53ad07e9
JB
7743 * @links.status: per-link status code, to report a status code that's not
7744 * %WLAN_STATUS_SUCCESS for a given link, it must also be in the
7745 * @valid_links bitmap and may have a BSS pointer (which is then released)
5349a0f7
VK
7746 */
7747struct cfg80211_connect_resp_params {
7748 int status;
5349a0f7
VK
7749 const u8 *req_ie;
7750 size_t req_ie_len;
7751 const u8 *resp_ie;
7752 size_t resp_ie_len;
76804d28 7753 struct cfg80211_fils_resp_params fils;
5349a0f7 7754 enum nl80211_timeout_reason timeout_reason;
efbabc11
VJ
7755
7756 const u8 *ap_mld_addr;
7757 u16 valid_links;
7758 struct {
7759 const u8 *addr;
7760 const u8 *bssid;
7761 struct cfg80211_bss *bss;
53ad07e9 7762 u16 status;
efbabc11 7763 } links[IEEE80211_MLD_MAX_NUM_LINKS];
5349a0f7
VK
7764};
7765
7766/**
7767 * cfg80211_connect_done - notify cfg80211 of connection result
7768 *
7769 * @dev: network device
7770 * @params: connection response parameters
7771 * @gfp: allocation flags
7772 *
7773 * It should be called by the underlying driver once execution of the connection
7774 * request from connect() has been completed. This is similar to
7775 * cfg80211_connect_bss(), but takes a structure pointer for connection response
7776 * parameters. Only one of the functions among cfg80211_connect_bss(),
7777 * cfg80211_connect_result(), cfg80211_connect_timeout(),
7778 * and cfg80211_connect_done() should be called.
7779 */
7780void cfg80211_connect_done(struct net_device *dev,
7781 struct cfg80211_connect_resp_params *params,
7782 gfp_t gfp);
7783
e7054989
KV
7784/**
7785 * cfg80211_connect_bss - notify cfg80211 of connection result
7786 *
7787 * @dev: network device
7788 * @bssid: the BSSID of the AP
a3ce17d1
CT
7789 * @bss: Entry of bss to which STA got connected to, can be obtained through
7790 * cfg80211_get_bss() (may be %NULL). But it is recommended to store the
7791 * bss from the connect_request and hold a reference to it and return
7792 * through this param to avoid a warning if the bss is expired during the
7793 * connection, esp. for those drivers implementing connect op.
7794 * Only one parameter among @bssid and @bss needs to be specified.
e7054989
KV
7795 * @req_ie: association request IEs (maybe be %NULL)
7796 * @req_ie_len: association request IEs length
7797 * @resp_ie: association response IEs (may be %NULL)
7798 * @resp_ie_len: assoc response IEs length
c88215d7
JM
7799 * @status: status code, %WLAN_STATUS_SUCCESS for successful connection, use
7800 * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
7801 * the real status code for failures. If this call is used to report a
7802 * failure due to a timeout (e.g., not receiving an Authentication frame
7803 * from the AP) instead of an explicit rejection by the AP, -1 is used to
7804 * indicate that this is a failure, but without a status code.
7805 * @timeout_reason is used to report the reason for the timeout in that
7806 * case.
e7054989 7807 * @gfp: allocation flags
3093ebbe
PK
7808 * @timeout_reason: reason for connection timeout. This is used when the
7809 * connection fails due to a timeout instead of an explicit rejection from
7810 * the AP. %NL80211_TIMEOUT_UNSPECIFIED is used when the timeout reason is
7811 * not known. This value is used only if @status < 0 to indicate that the
7812 * failure is due to a timeout and not due to explicit rejection by the AP.
7813 * This value is ignored in other cases (@status >= 0).
e7054989 7814 *
c88215d7
JM
7815 * It should be called by the underlying driver once execution of the connection
7816 * request from connect() has been completed. This is similar to
7817 * cfg80211_connect_result(), but with the option of identifying the exact bss
5349a0f7
VK
7818 * entry for the connection. Only one of the functions among
7819 * cfg80211_connect_bss(), cfg80211_connect_result(),
7820 * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
e7054989 7821 */
5349a0f7
VK
7822static inline void
7823cfg80211_connect_bss(struct net_device *dev, const u8 *bssid,
7824 struct cfg80211_bss *bss, const u8 *req_ie,
7825 size_t req_ie_len, const u8 *resp_ie,
7826 size_t resp_ie_len, int status, gfp_t gfp,
7827 enum nl80211_timeout_reason timeout_reason)
7828{
7829 struct cfg80211_connect_resp_params params;
7830
7831 memset(&params, 0, sizeof(params));
7832 params.status = status;
efbabc11
VJ
7833 params.links[0].bssid = bssid;
7834 params.links[0].bss = bss;
5349a0f7
VK
7835 params.req_ie = req_ie;
7836 params.req_ie_len = req_ie_len;
7837 params.resp_ie = resp_ie;
7838 params.resp_ie_len = resp_ie_len;
7839 params.timeout_reason = timeout_reason;
7840
7841 cfg80211_connect_done(dev, &params, gfp);
7842}
e7054989 7843
b23aa676
SO
7844/**
7845 * cfg80211_connect_result - notify cfg80211 of connection result
7846 *
7847 * @dev: network device
7848 * @bssid: the BSSID of the AP
7849 * @req_ie: association request IEs (maybe be %NULL)
7850 * @req_ie_len: association request IEs length
7851 * @resp_ie: association response IEs (may be %NULL)
7852 * @resp_ie_len: assoc response IEs length
c88215d7 7853 * @status: status code, %WLAN_STATUS_SUCCESS for successful connection, use
b23aa676
SO
7854 * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
7855 * the real status code for failures.
7856 * @gfp: allocation flags
7857 *
c88215d7
JM
7858 * It should be called by the underlying driver once execution of the connection
7859 * request from connect() has been completed. This is similar to
7860 * cfg80211_connect_bss() which allows the exact bss entry to be specified. Only
5349a0f7
VK
7861 * one of the functions among cfg80211_connect_bss(), cfg80211_connect_result(),
7862 * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
b23aa676 7863 */
e7054989
KV
7864static inline void
7865cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
7866 const u8 *req_ie, size_t req_ie_len,
7867 const u8 *resp_ie, size_t resp_ie_len,
7868 u16 status, gfp_t gfp)
7869{
7870 cfg80211_connect_bss(dev, bssid, NULL, req_ie, req_ie_len, resp_ie,
3093ebbe
PK
7871 resp_ie_len, status, gfp,
7872 NL80211_TIMEOUT_UNSPECIFIED);
bf1ecd21
JM
7873}
7874
7875/**
7876 * cfg80211_connect_timeout - notify cfg80211 of connection timeout
7877 *
7878 * @dev: network device
7879 * @bssid: the BSSID of the AP
7880 * @req_ie: association request IEs (maybe be %NULL)
7881 * @req_ie_len: association request IEs length
7882 * @gfp: allocation flags
3093ebbe 7883 * @timeout_reason: reason for connection timeout.
bf1ecd21
JM
7884 *
7885 * It should be called by the underlying driver whenever connect() has failed
7886 * in a sequence where no explicit authentication/association rejection was
7887 * received from the AP. This could happen, e.g., due to not being able to send
7888 * out the Authentication or Association Request frame or timing out while
5349a0f7
VK
7889 * waiting for the response. Only one of the functions among
7890 * cfg80211_connect_bss(), cfg80211_connect_result(),
7891 * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
bf1ecd21
JM
7892 */
7893static inline void
7894cfg80211_connect_timeout(struct net_device *dev, const u8 *bssid,
3093ebbe
PK
7895 const u8 *req_ie, size_t req_ie_len, gfp_t gfp,
7896 enum nl80211_timeout_reason timeout_reason)
bf1ecd21
JM
7897{
7898 cfg80211_connect_bss(dev, bssid, NULL, req_ie, req_ie_len, NULL, 0, -1,
3093ebbe 7899 gfp, timeout_reason);
e7054989 7900}
b23aa676
SO
7901
7902/**
29ce6ecb 7903 * struct cfg80211_roam_info - driver initiated roaming information
b23aa676 7904 *
b23aa676
SO
7905 * @req_ie: association request IEs (maybe be %NULL)
7906 * @req_ie_len: association request IEs length
7907 * @resp_ie: association response IEs (may be %NULL)
7908 * @resp_ie_len: assoc response IEs length
e841b7b1 7909 * @fils: FILS related roaming information.
efbabc11
VJ
7910 * @valid_links: For MLO roaming, BIT mask of the new valid links is set.
7911 * Otherwise zero.
7912 * @ap_mld_addr: For MLO roaming, MLD address of the new AP. Otherwise %NULL.
7913 * @links : For MLO roaming, contains new link info for the valid links set in
7914 * @valid_links. For non-MLO roaming, links[0] contains the new AP info.
7915 * @links.addr: For MLO roaming, MAC address of the STA link. Otherwise %NULL.
7916 * @links.bssid: For MLO roaming, MAC address of the new AP link. For non-MLO
7917 * roaming, links[0].bssid points to the BSSID of the new AP. May be
7918 * %NULL if %links.bss is set.
7919 * @links.channel: the channel of the new AP.
7920 * @links.bss: For MLO roaming, entry of new bss to which STA link got
7921 * roamed. For non-MLO roaming, links[0].bss points to entry of bss to
7922 * which STA got roamed (may be %NULL if %links.bssid is set)
b23aa676 7923 */
29ce6ecb 7924struct cfg80211_roam_info {
29ce6ecb
AS
7925 const u8 *req_ie;
7926 size_t req_ie_len;
7927 const u8 *resp_ie;
7928 size_t resp_ie_len;
e841b7b1 7929 struct cfg80211_fils_resp_params fils;
efbabc11
VJ
7930
7931 const u8 *ap_mld_addr;
7932 u16 valid_links;
7933 struct {
7934 const u8 *addr;
7935 const u8 *bssid;
7936 struct ieee80211_channel *channel;
7937 struct cfg80211_bss *bss;
7938 } links[IEEE80211_MLD_MAX_NUM_LINKS];
29ce6ecb 7939};
b23aa676 7940
adbde344 7941/**
29ce6ecb 7942 * cfg80211_roamed - notify cfg80211 of roaming
adbde344
VT
7943 *
7944 * @dev: network device
29ce6ecb 7945 * @info: information about the new BSS. struct &cfg80211_roam_info.
adbde344
VT
7946 * @gfp: allocation flags
7947 *
29ce6ecb
AS
7948 * This function may be called with the driver passing either the BSSID of the
7949 * new AP or passing the bss entry to avoid a race in timeout of the bss entry.
7950 * It should be called by the underlying driver whenever it roamed from one AP
7951 * to another while connected. Drivers which have roaming implemented in
7952 * firmware should pass the bss entry to avoid a race in bss entry timeout where
7953 * the bss entry of the new AP is seen in the driver, but gets timed out by the
7954 * time it is accessed in __cfg80211_roamed() due to delay in scheduling
adbde344 7955 * rdev->event_work. In case of any failures, the reference is released
29ce6ecb 7956 * either in cfg80211_roamed() or in __cfg80211_romed(), Otherwise, it will be
e1b18549 7957 * released while disconnecting from the current bss.
adbde344 7958 */
29ce6ecb
AS
7959void cfg80211_roamed(struct net_device *dev, struct cfg80211_roam_info *info,
7960 gfp_t gfp);
adbde344 7961
503c1fb9
AS
7962/**
7963 * cfg80211_port_authorized - notify cfg80211 of successful security association
7964 *
7965 * @dev: network device
7966 * @bssid: the BSSID of the AP
0ff57171
VY
7967 * @td_bitmap: transition disable policy
7968 * @td_bitmap_len: Length of transition disable policy
503c1fb9
AS
7969 * @gfp: allocation flags
7970 *
7971 * This function should be called by a driver that supports 4 way handshake
7972 * offload after a security association was successfully established (i.e.,
7973 * the 4 way handshake was completed successfully). The call to this function
7974 * should be preceded with a call to cfg80211_connect_result(),
7975 * cfg80211_connect_done(), cfg80211_connect_bss() or cfg80211_roamed() to
7976 * indicate the 802.11 association.
7977 */
7978void cfg80211_port_authorized(struct net_device *dev, const u8 *bssid,
0ff57171 7979 const u8* td_bitmap, u8 td_bitmap_len, gfp_t gfp);
503c1fb9 7980
b23aa676
SO
7981/**
7982 * cfg80211_disconnected - notify cfg80211 that connection was dropped
7983 *
7984 * @dev: network device
7985 * @ie: information elements of the deauth/disassoc frame (may be %NULL)
7986 * @ie_len: length of IEs
7987 * @reason: reason code for the disconnection, set it to 0 if unknown
80279fb7 7988 * @locally_generated: disconnection was requested locally
b23aa676
SO
7989 * @gfp: allocation flags
7990 *
7991 * After it calls this function, the driver should enter an idle state
7992 * and not try to connect to any AP any more.
7993 */
7994void cfg80211_disconnected(struct net_device *dev, u16 reason,
80279fb7
JB
7995 const u8 *ie, size_t ie_len,
7996 bool locally_generated, gfp_t gfp);
b23aa676 7997
9588bbd5
JM
7998/**
7999 * cfg80211_ready_on_channel - notification of remain_on_channel start
71bbc994 8000 * @wdev: wireless device
9588bbd5
JM
8001 * @cookie: the request cookie
8002 * @chan: The current channel (from remain_on_channel request)
9588bbd5
JM
8003 * @duration: Duration in milliseconds that the driver intents to remain on the
8004 * channel
8005 * @gfp: allocation flags
8006 */
71bbc994 8007void cfg80211_ready_on_channel(struct wireless_dev *wdev, u64 cookie,
9588bbd5 8008 struct ieee80211_channel *chan,
9588bbd5
JM
8009 unsigned int duration, gfp_t gfp);
8010
8011/**
8012 * cfg80211_remain_on_channel_expired - remain_on_channel duration expired
71bbc994 8013 * @wdev: wireless device
9588bbd5
JM
8014 * @cookie: the request cookie
8015 * @chan: The current channel (from remain_on_channel request)
9588bbd5
JM
8016 * @gfp: allocation flags
8017 */
71bbc994 8018void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie,
9588bbd5 8019 struct ieee80211_channel *chan,
9588bbd5 8020 gfp_t gfp);
b23aa676 8021
1c38c7f2
JP
8022/**
8023 * cfg80211_tx_mgmt_expired - tx_mgmt duration expired
8024 * @wdev: wireless device
8025 * @cookie: the requested cookie
8026 * @chan: The current channel (from tx_mgmt request)
8027 * @gfp: allocation flags
8028 */
8029void cfg80211_tx_mgmt_expired(struct wireless_dev *wdev, u64 cookie,
8030 struct ieee80211_channel *chan, gfp_t gfp);
8031
8689c051
AS
8032/**
8033 * cfg80211_sinfo_alloc_tid_stats - allocate per-tid statistics.
8034 *
8035 * @sinfo: the station information
8036 * @gfp: allocation flags
8037 */
8038int cfg80211_sinfo_alloc_tid_stats(struct station_info *sinfo, gfp_t gfp);
98b62183 8039
7ea3e110
JB
8040/**
8041 * cfg80211_sinfo_release_content - release contents of station info
8042 * @sinfo: the station information
8043 *
8044 * Releases any potentially allocated sub-information of the station
8045 * information, but not the struct itself (since it's typically on
8046 * the stack.)
8047 */
8048static inline void cfg80211_sinfo_release_content(struct station_info *sinfo)
8049{
8050 kfree(sinfo->pertid);
8051}
8052
98b62183
JB
8053/**
8054 * cfg80211_new_sta - notify userspace about station
8055 *
8056 * @dev: the netdev
8057 * @mac_addr: the station's address
8058 * @sinfo: the station information
8059 * @gfp: allocation flags
8060 */
8061void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
8062 struct station_info *sinfo, gfp_t gfp);
8063
cf5ead82
JB
8064/**
8065 * cfg80211_del_sta_sinfo - notify userspace about deletion of a station
8066 * @dev: the netdev
bfc55167 8067 * @mac_addr: the station's address. For MLD station, MLD address is used.
cf5ead82
JB
8068 * @sinfo: the station information/statistics
8069 * @gfp: allocation flags
8070 */
8071void cfg80211_del_sta_sinfo(struct net_device *dev, const u8 *mac_addr,
8072 struct station_info *sinfo, gfp_t gfp);
8073
ec15e68b
JM
8074/**
8075 * cfg80211_del_sta - notify userspace about deletion of a station
8076 *
8077 * @dev: the netdev
bfc55167 8078 * @mac_addr: the station's address. For MLD station, MLD address is used.
ec15e68b
JM
8079 * @gfp: allocation flags
8080 */
cf5ead82
JB
8081static inline void cfg80211_del_sta(struct net_device *dev,
8082 const u8 *mac_addr, gfp_t gfp)
8083{
8084 cfg80211_del_sta_sinfo(dev, mac_addr, NULL, gfp);
8085}
ec15e68b 8086
ed44a951
PP
8087/**
8088 * cfg80211_conn_failed - connection request failed notification
8089 *
8090 * @dev: the netdev
8091 * @mac_addr: the station's address
8092 * @reason: the reason for connection failure
8093 * @gfp: allocation flags
8094 *
8095 * Whenever a station tries to connect to an AP and if the station
8096 * could not connect to the AP as the AP has rejected the connection
8097 * for some reasons, this function is called.
8098 *
8099 * The reason for connection failure can be any of the value from
8100 * nl80211_connect_failed_reason enum
8101 */
8102void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr,
8103 enum nl80211_connect_failed_reason reason,
8104 gfp_t gfp);
8105
00b3d840
AS
8106/**
8107 * struct cfg80211_rx_info - received management frame info
8108 *
8109 * @freq: Frequency on which the frame was received in kHz
8110 * @sig_dbm: signal strength in dBm, or 0 if unknown
6074c9e5
JB
8111 * @have_link_id: indicates the frame was received on a link of
8112 * an MLD, i.e. the @link_id field is valid
8113 * @link_id: the ID of the link the frame was received on
00b3d840
AS
8114 * @buf: Management frame (header + body)
8115 * @len: length of the frame data
8116 * @flags: flags, as defined in enum nl80211_rxmgmt_flags
1ff715ff
AS
8117 * @rx_tstamp: Hardware timestamp of frame RX in nanoseconds
8118 * @ack_tstamp: Hardware timestamp of ack TX in nanoseconds
00b3d840
AS
8119 */
8120struct cfg80211_rx_info {
8121 int freq;
8122 int sig_dbm;
6074c9e5
JB
8123 bool have_link_id;
8124 u8 link_id;
00b3d840
AS
8125 const u8 *buf;
8126 size_t len;
8127 u32 flags;
1ff715ff
AS
8128 u64 rx_tstamp;
8129 u64 ack_tstamp;
00b3d840
AS
8130};
8131
8132/**
8133 * cfg80211_rx_mgmt_ext - management frame notification with extended info
8134 * @wdev: wireless device receiving the frame
8135 * @info: RX info as defined in struct cfg80211_rx_info
8136 *
8137 * This function is called whenever an Action frame is received for a station
8138 * mode interface, but is not processed in kernel.
8139 *
8140 * Return: %true if a user space application has registered for this frame.
8141 * For action frames, that makes it responsible for rejecting unrecognized
8142 * action frames; %false otherwise, in which case for action frames the
8143 * driver is responsible for rejecting the frame.
8144 */
8145bool cfg80211_rx_mgmt_ext(struct wireless_dev *wdev,
8146 struct cfg80211_rx_info *info);
8147
e76fede8
TP
8148/**
8149 * cfg80211_rx_mgmt_khz - notification of received, unprocessed management frame
8150 * @wdev: wireless device receiving the frame
8151 * @freq: Frequency on which the frame was received in KHz
8152 * @sig_dbm: signal strength in dBm, or 0 if unknown
8153 * @buf: Management frame (header + body)
8154 * @len: length of the frame data
8155 * @flags: flags, as defined in enum nl80211_rxmgmt_flags
8156 *
8157 * This function is called whenever an Action frame is received for a station
8158 * mode interface, but is not processed in kernel.
8159 *
8160 * Return: %true if a user space application has registered for this frame.
8161 * For action frames, that makes it responsible for rejecting unrecognized
8162 * action frames; %false otherwise, in which case for action frames the
8163 * driver is responsible for rejecting the frame.
8164 */
00b3d840
AS
8165static inline bool cfg80211_rx_mgmt_khz(struct wireless_dev *wdev, int freq,
8166 int sig_dbm, const u8 *buf, size_t len,
8167 u32 flags)
8168{
8169 struct cfg80211_rx_info info = {
8170 .freq = freq,
8171 .sig_dbm = sig_dbm,
8172 .buf = buf,
8173 .len = len,
8174 .flags = flags
8175 };
8176
8177 return cfg80211_rx_mgmt_ext(wdev, &info);
8178}
e76fede8 8179
026331c4 8180/**
2e161f78 8181 * cfg80211_rx_mgmt - notification of received, unprocessed management frame
71bbc994 8182 * @wdev: wireless device receiving the frame
026331c4 8183 * @freq: Frequency on which the frame was received in MHz
6c2fb1e6 8184 * @sig_dbm: signal strength in dBm, or 0 if unknown
2e161f78 8185 * @buf: Management frame (header + body)
026331c4 8186 * @len: length of the frame data
19504cf5 8187 * @flags: flags, as defined in enum nl80211_rxmgmt_flags
2e161f78 8188 *
0ae997dc
YB
8189 * This function is called whenever an Action frame is received for a station
8190 * mode interface, but is not processed in kernel.
8191 *
8192 * Return: %true if a user space application has registered for this frame.
2e161f78
JB
8193 * For action frames, that makes it responsible for rejecting unrecognized
8194 * action frames; %false otherwise, in which case for action frames the
8195 * driver is responsible for rejecting the frame.
026331c4 8196 */
e76fede8
TP
8197static inline bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq,
8198 int sig_dbm, const u8 *buf, size_t len,
8199 u32 flags)
8200{
00b3d840
AS
8201 struct cfg80211_rx_info info = {
8202 .freq = MHZ_TO_KHZ(freq),
8203 .sig_dbm = sig_dbm,
8204 .buf = buf,
8205 .len = len,
8206 .flags = flags
8207 };
8208
8209 return cfg80211_rx_mgmt_ext(wdev, &info);
e76fede8 8210}
026331c4 8211
ea7d50c9
AS
8212/**
8213 * struct cfg80211_tx_status - TX status for management frame information
8214 *
8215 * @cookie: Cookie returned by cfg80211_ops::mgmt_tx()
8216 * @tx_tstamp: hardware TX timestamp in nanoseconds
8217 * @ack_tstamp: hardware ack RX timestamp in nanoseconds
8218 * @buf: Management frame (header + body)
8219 * @len: length of the frame data
8220 * @ack: Whether frame was acknowledged
8221 */
8222struct cfg80211_tx_status {
8223 u64 cookie;
8224 u64 tx_tstamp;
8225 u64 ack_tstamp;
8226 const u8 *buf;
8227 size_t len;
8228 bool ack;
8229};
8230
8231/**
8232 * cfg80211_mgmt_tx_status_ext - TX status notification with extended info
8233 * @wdev: wireless device receiving the frame
8234 * @status: TX status data
8235 * @gfp: context flags
8236 *
8237 * This function is called whenever a management frame was requested to be
8238 * transmitted with cfg80211_ops::mgmt_tx() to report the TX status of the
8239 * transmission attempt with extended info.
8240 */
8241void cfg80211_mgmt_tx_status_ext(struct wireless_dev *wdev,
8242 struct cfg80211_tx_status *status, gfp_t gfp);
8243
026331c4 8244/**
2e161f78 8245 * cfg80211_mgmt_tx_status - notification of TX status for management frame
71bbc994 8246 * @wdev: wireless device receiving the frame
2e161f78
JB
8247 * @cookie: Cookie returned by cfg80211_ops::mgmt_tx()
8248 * @buf: Management frame (header + body)
026331c4
JM
8249 * @len: length of the frame data
8250 * @ack: Whether frame was acknowledged
8251 * @gfp: context flags
8252 *
2e161f78
JB
8253 * This function is called whenever a management frame was requested to be
8254 * transmitted with cfg80211_ops::mgmt_tx() to report the TX status of the
026331c4
JM
8255 * transmission attempt.
8256 */
ea7d50c9
AS
8257static inline void cfg80211_mgmt_tx_status(struct wireless_dev *wdev,
8258 u64 cookie, const u8 *buf,
8259 size_t len, bool ack, gfp_t gfp)
8260{
8261 struct cfg80211_tx_status status = {
8262 .cookie = cookie,
8263 .buf = buf,
8264 .len = len,
8265 .ack = ack
8266 };
8267
8268 cfg80211_mgmt_tx_status_ext(wdev, &status, gfp);
8269}
026331c4 8270
dca9ca2d
MT
8271/**
8272 * cfg80211_control_port_tx_status - notification of TX status for control
8273 * port frames
8274 * @wdev: wireless device receiving the frame
8275 * @cookie: Cookie returned by cfg80211_ops::tx_control_port()
8276 * @buf: Data frame (header + body)
8277 * @len: length of the frame data
8278 * @ack: Whether frame was acknowledged
8279 * @gfp: context flags
8280 *
8281 * This function is called whenever a control port frame was requested to be
8282 * transmitted with cfg80211_ops::tx_control_port() to report the TX status of
8283 * the transmission attempt.
8284 */
8285void cfg80211_control_port_tx_status(struct wireless_dev *wdev, u64 cookie,
8286 const u8 *buf, size_t len, bool ack,
8287 gfp_t gfp);
d6dc1a38 8288
6a671a50
DK
8289/**
8290 * cfg80211_rx_control_port - notification about a received control port frame
8291 * @dev: The device the frame matched to
a948f713
DK
8292 * @skb: The skbuf with the control port frame. It is assumed that the skbuf
8293 * is 802.3 formatted (with 802.3 header). The skb can be non-linear.
8294 * This function does not take ownership of the skb, so the caller is
8295 * responsible for any cleanup. The caller must also ensure that
8296 * skb->protocol is set appropriately.
6a671a50 8297 * @unencrypted: Whether the frame was received unencrypted
4c532321 8298 * @link_id: the link the frame was received on, -1 if not applicable or unknown
6a671a50
DK
8299 *
8300 * This function is used to inform userspace about a received control port
8301 * frame. It should only be used if userspace indicated it wants to receive
8302 * control port frames over nl80211.
8303 *
8304 * The frame is the data portion of the 802.3 or 802.11 data frame with all
8305 * network layer headers removed (e.g. the raw EAPoL frame).
8306 *
8307 * Return: %true if the frame was passed to userspace
8308 */
4c532321
JB
8309bool cfg80211_rx_control_port(struct net_device *dev, struct sk_buff *skb,
8310 bool unencrypted, int link_id);
6a671a50 8311
d6dc1a38
JO
8312/**
8313 * cfg80211_cqm_rssi_notify - connection quality monitoring rssi event
8314 * @dev: network device
8315 * @rssi_event: the triggered RSSI event
bee427b8 8316 * @rssi_level: new RSSI level value or 0 if not available
d6dc1a38
JO
8317 * @gfp: context flags
8318 *
8319 * This function is called when a configured connection quality monitoring
8320 * rssi threshold reached event occurs.
8321 */
8322void cfg80211_cqm_rssi_notify(struct net_device *dev,
8323 enum nl80211_cqm_rssi_threshold_event rssi_event,
bee427b8 8324 s32 rssi_level, gfp_t gfp);
d6dc1a38 8325
c063dbf5
JB
8326/**
8327 * cfg80211_cqm_pktloss_notify - notify userspace about packetloss to peer
8328 * @dev: network device
8329 * @peer: peer's MAC address
8330 * @num_packets: how many packets were lost -- should be a fixed threshold
8331 * but probably no less than maybe 50, or maybe a throughput dependent
8332 * threshold (to account for temporary interference)
8333 * @gfp: context flags
8334 */
8335void cfg80211_cqm_pktloss_notify(struct net_device *dev,
8336 const u8 *peer, u32 num_packets, gfp_t gfp);
8337
84f10708
TP
8338/**
8339 * cfg80211_cqm_txe_notify - TX error rate event
8340 * @dev: network device
8341 * @peer: peer's MAC address
8342 * @num_packets: how many packets were lost
8343 * @rate: % of packets which failed transmission
8344 * @intvl: interval (in s) over which the TX failure threshold was breached.
8345 * @gfp: context flags
8346 *
8347 * Notify userspace when configured % TX failures over number of packets in a
8348 * given interval is exceeded.
8349 */
8350void cfg80211_cqm_txe_notify(struct net_device *dev, const u8 *peer,
8351 u32 num_packets, u32 rate, u32 intvl, gfp_t gfp);
8352
98f03342
JB
8353/**
8354 * cfg80211_cqm_beacon_loss_notify - beacon loss event
8355 * @dev: network device
8356 * @gfp: context flags
8357 *
8358 * Notify userspace about beacon loss from the connected AP.
8359 */
8360void cfg80211_cqm_beacon_loss_notify(struct net_device *dev, gfp_t gfp);
8361
5b97f49d 8362/**
c47240cb 8363 * __cfg80211_radar_event - radar detection event
5b97f49d
JB
8364 * @wiphy: the wiphy
8365 * @chandef: chandef for the current channel
c47240cb 8366 * @offchan: the radar has been detected on the offchannel chain
5b97f49d
JB
8367 * @gfp: context flags
8368 *
8369 * This function is called when a radar is detected on the current chanenl.
8370 */
c47240cb
LB
8371void __cfg80211_radar_event(struct wiphy *wiphy,
8372 struct cfg80211_chan_def *chandef,
8373 bool offchan, gfp_t gfp);
8374
8375static inline void
8376cfg80211_radar_event(struct wiphy *wiphy,
8377 struct cfg80211_chan_def *chandef,
8378 gfp_t gfp)
8379{
8380 __cfg80211_radar_event(wiphy, chandef, false, gfp);
8381}
8382
8383static inline void
a95bfb87
LB
8384cfg80211_background_radar_event(struct wiphy *wiphy,
8385 struct cfg80211_chan_def *chandef,
8386 gfp_t gfp)
c47240cb
LB
8387{
8388 __cfg80211_radar_event(wiphy, chandef, true, gfp);
8389}
5b97f49d 8390
466b9936 8391/**
8392 * cfg80211_sta_opmode_change_notify - STA's ht/vht operation mode change event
8393 * @dev: network device
8394 * @mac: MAC address of a station which opmode got modified
8395 * @sta_opmode: station's current opmode value
8396 * @gfp: context flags
8397 *
8398 * Driver should call this function when station's opmode modified via action
8399 * frame.
8400 */
8401void cfg80211_sta_opmode_change_notify(struct net_device *dev, const u8 *mac,
8402 struct sta_opmode_info *sta_opmode,
8403 gfp_t gfp);
8404
5b97f49d
JB
8405/**
8406 * cfg80211_cac_event - Channel availability check (CAC) event
8407 * @netdev: network device
8408 * @chandef: chandef for the current channel
8409 * @event: type of event
8410 * @gfp: context flags
8411 *
8412 * This function is called when a Channel availability check (CAC) is finished
8413 * or aborted. This must be called to notify the completion of a CAC process,
8414 * also by full-MAC drivers.
8415 */
8416void cfg80211_cac_event(struct net_device *netdev,
8417 const struct cfg80211_chan_def *chandef,
8418 enum nl80211_radar_event event, gfp_t gfp);
8419
bc2dfc02 8420/**
a95bfb87 8421 * cfg80211_background_cac_abort - Channel Availability Check offchan abort event
bc2dfc02 8422 * @wiphy: the wiphy
bc2dfc02 8423 *
1507b153
LB
8424 * This function is called by the driver when a Channel Availability Check
8425 * (CAC) is aborted by a offchannel dedicated chain.
bc2dfc02 8426 */
a95bfb87 8427void cfg80211_background_cac_abort(struct wiphy *wiphy);
5b97f49d 8428
e5497d76
JB
8429/**
8430 * cfg80211_gtk_rekey_notify - notify userspace about driver rekeying
8431 * @dev: network device
8432 * @bssid: BSSID of AP (to avoid races)
8433 * @replay_ctr: new replay counter
af71ff85 8434 * @gfp: allocation flags
e5497d76
JB
8435 */
8436void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid,
8437 const u8 *replay_ctr, gfp_t gfp);
8438
c9df56b4
JM
8439/**
8440 * cfg80211_pmksa_candidate_notify - notify about PMKSA caching candidate
8441 * @dev: network device
8442 * @index: candidate index (the smaller the index, the higher the priority)
8443 * @bssid: BSSID of AP
8444 * @preauth: Whether AP advertises support for RSN pre-authentication
8445 * @gfp: allocation flags
8446 */
8447void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index,
8448 const u8 *bssid, bool preauth, gfp_t gfp);
8449
28946da7
JB
8450/**
8451 * cfg80211_rx_spurious_frame - inform userspace about a spurious frame
8452 * @dev: The device the frame matched to
8453 * @addr: the transmitter address
8454 * @gfp: context flags
8455 *
8456 * This function is used in AP mode (only!) to inform userspace that
8457 * a spurious class 3 frame was received, to be able to deauth the
8458 * sender.
0ae997dc 8459 * Return: %true if the frame was passed to userspace (or this failed
28946da7
JB
8460 * for a reason other than not having a subscription.)
8461 */
8462bool cfg80211_rx_spurious_frame(struct net_device *dev,
8463 const u8 *addr, gfp_t gfp);
8464
b92ab5d8
JB
8465/**
8466 * cfg80211_rx_unexpected_4addr_frame - inform about unexpected WDS frame
8467 * @dev: The device the frame matched to
8468 * @addr: the transmitter address
8469 * @gfp: context flags
8470 *
8471 * This function is used in AP mode (only!) to inform userspace that
8472 * an associated station sent a 4addr frame but that wasn't expected.
8473 * It is allowed and desirable to send this event only once for each
8474 * station to avoid event flooding.
0ae997dc 8475 * Return: %true if the frame was passed to userspace (or this failed
b92ab5d8
JB
8476 * for a reason other than not having a subscription.)
8477 */
8478bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev,
8479 const u8 *addr, gfp_t gfp);
8480
7f6cf311
JB
8481/**
8482 * cfg80211_probe_status - notify userspace about probe status
8483 * @dev: the device the probe was sent on
8484 * @addr: the address of the peer
8485 * @cookie: the cookie filled in @probe_client previously
8486 * @acked: indicates whether probe was acked or not
c4b50cd3
VN
8487 * @ack_signal: signal strength (in dBm) of the ACK frame.
8488 * @is_valid_ack_signal: indicates the ack_signal is valid or not.
7f6cf311
JB
8489 * @gfp: allocation flags
8490 */
8491void cfg80211_probe_status(struct net_device *dev, const u8 *addr,
c4b50cd3
VN
8492 u64 cookie, bool acked, s32 ack_signal,
8493 bool is_valid_ack_signal, gfp_t gfp);
7f6cf311 8494
e76fede8
TP
8495/**
8496 * cfg80211_report_obss_beacon_khz - report beacon from other APs
8497 * @wiphy: The wiphy that received the beacon
8498 * @frame: the frame
8499 * @len: length of the frame
8500 * @freq: frequency the frame was received on in KHz
8501 * @sig_dbm: signal strength in dBm, or 0 if unknown
8502 *
8503 * Use this function to report to userspace when a beacon was
8504 * received. It is not useful to call this when there is no
8505 * netdev that is in AP/GO mode.
8506 */
8507void cfg80211_report_obss_beacon_khz(struct wiphy *wiphy, const u8 *frame,
8508 size_t len, int freq, int sig_dbm);
8509
5e760230
JB
8510/**
8511 * cfg80211_report_obss_beacon - report beacon from other APs
8512 * @wiphy: The wiphy that received the beacon
8513 * @frame: the frame
8514 * @len: length of the frame
8515 * @freq: frequency the frame was received on
6c2fb1e6 8516 * @sig_dbm: signal strength in dBm, or 0 if unknown
5e760230
JB
8517 *
8518 * Use this function to report to userspace when a beacon was
8519 * received. It is not useful to call this when there is no
8520 * netdev that is in AP/GO mode.
8521 */
e76fede8
TP
8522static inline void cfg80211_report_obss_beacon(struct wiphy *wiphy,
8523 const u8 *frame, size_t len,
8524 int freq, int sig_dbm)
8525{
8526 cfg80211_report_obss_beacon_khz(wiphy, frame, len, MHZ_TO_KHZ(freq),
8527 sig_dbm);
8528}
5e760230 8529
d58e7e37 8530/**
683b6d3b 8531 * cfg80211_reg_can_beacon - check if beaconing is allowed
54858ee5 8532 * @wiphy: the wiphy
683b6d3b 8533 * @chandef: the channel definition
174e0cd2 8534 * @iftype: interface type
d58e7e37 8535 *
0ae997dc
YB
8536 * Return: %true if there is no secondary channel or the secondary channel(s)
8537 * can be used for beaconing (i.e. is not a radar channel etc.)
54858ee5 8538 */
683b6d3b 8539bool cfg80211_reg_can_beacon(struct wiphy *wiphy,
174e0cd2
IP
8540 struct cfg80211_chan_def *chandef,
8541 enum nl80211_iftype iftype);
54858ee5 8542
923b352f
AN
8543/**
8544 * cfg80211_reg_can_beacon_relax - check if beaconing is allowed with relaxation
8545 * @wiphy: the wiphy
8546 * @chandef: the channel definition
8547 * @iftype: interface type
8548 *
8549 * Return: %true if there is no secondary channel or the secondary channel(s)
8550 * can be used for beaconing (i.e. is not a radar channel etc.). This version
8551 * also checks if IR-relaxation conditions apply, to allow beaconing under
8552 * more permissive conditions.
8553 *
a05829a7 8554 * Requires the wiphy mutex to be held.
923b352f
AN
8555 */
8556bool cfg80211_reg_can_beacon_relax(struct wiphy *wiphy,
8557 struct cfg80211_chan_def *chandef,
8558 enum nl80211_iftype iftype);
8559
5314526b
TP
8560/*
8561 * cfg80211_ch_switch_notify - update wdev channel and notify userspace
8562 * @dev: the device which switched channels
683b6d3b 8563 * @chandef: the new channel definition
7b0a0e3c 8564 * @link_id: the link ID for MLO, must be 0 for non-MLO
b345f063 8565 * @punct_bitmap: the new puncturing bitmap
5314526b 8566 *
e487eaeb
SW
8567 * Caller must acquire wdev_lock, therefore must only be called from sleepable
8568 * driver context!
5314526b 8569 */
683b6d3b 8570void cfg80211_ch_switch_notify(struct net_device *dev,
7b0a0e3c 8571 struct cfg80211_chan_def *chandef,
b345f063 8572 unsigned int link_id, u16 punct_bitmap);
5314526b 8573
f8d7552e
LC
8574/*
8575 * cfg80211_ch_switch_started_notify - notify channel switch start
8576 * @dev: the device on which the channel switch started
8577 * @chandef: the future channel definition
b8c9024e 8578 * @link_id: the link ID for MLO, must be 0 for non-MLO
f8d7552e 8579 * @count: the number of TBTTs until the channel switch happens
669b8413 8580 * @quiet: whether or not immediate quiet was requested by the AP
b345f063 8581 * @punct_bitmap: the future puncturing bitmap
f8d7552e
LC
8582 *
8583 * Inform the userspace about the channel switch that has just
8584 * started, so that it can take appropriate actions (eg. starting
8585 * channel switch on other vifs), if necessary.
8586 */
8587void cfg80211_ch_switch_started_notify(struct net_device *dev,
8588 struct cfg80211_chan_def *chandef,
b8c9024e 8589 unsigned int link_id, u8 count,
b345f063 8590 bool quiet, u16 punct_bitmap);
f8d7552e 8591
1ce3e82b
JB
8592/**
8593 * ieee80211_operating_class_to_band - convert operating class to band
8594 *
8595 * @operating_class: the operating class to convert
8596 * @band: band pointer to fill
8597 *
8598 * Returns %true if the conversion was successful, %false otherwise.
8599 */
8600bool ieee80211_operating_class_to_band(u8 operating_class,
57fbcce3 8601 enum nl80211_band *band);
1ce3e82b 8602
a38700dd
AN
8603/**
8604 * ieee80211_chandef_to_operating_class - convert chandef to operation class
8605 *
8606 * @chandef: the chandef to convert
8607 * @op_class: a pointer to the resulting operating class
8608 *
8609 * Returns %true if the conversion was successful, %false otherwise.
8610 */
8611bool ieee80211_chandef_to_operating_class(struct cfg80211_chan_def *chandef,
8612 u8 *op_class);
8613
934f4c7d
TP
8614/**
8615 * ieee80211_chandef_to_khz - convert chandef to frequency in KHz
8616 *
8617 * @chandef: the chandef to convert
8618 *
8619 * Returns the center frequency of chandef (1st segment) in KHz.
8620 */
8621static inline u32
8622ieee80211_chandef_to_khz(const struct cfg80211_chan_def *chandef)
8623{
8624 return MHZ_TO_KHZ(chandef->center_freq1) + chandef->freq1_offset;
8625}
8626
3475b094
JM
8627/*
8628 * cfg80211_tdls_oper_request - request userspace to perform TDLS operation
8629 * @dev: the device on which the operation is requested
8630 * @peer: the MAC address of the peer device
8631 * @oper: the requested TDLS operation (NL80211_TDLS_SETUP or
8632 * NL80211_TDLS_TEARDOWN)
8633 * @reason_code: the reason code for teardown request
8634 * @gfp: allocation flags
8635 *
8636 * This function is used to request userspace to perform TDLS operation that
8637 * requires knowledge of keys, i.e., link setup or teardown when the AP
8638 * connection uses encryption. This is optional mechanism for the driver to use
8639 * if it can automatically determine when a TDLS link could be useful (e.g.,
8640 * based on traffic and signal strength for a peer).
8641 */
8642void cfg80211_tdls_oper_request(struct net_device *dev, const u8 *peer,
8643 enum nl80211_tdls_operation oper,
8644 u16 reason_code, gfp_t gfp);
8645
8097e149
TP
8646/*
8647 * cfg80211_calculate_bitrate - calculate actual bitrate (in 100Kbps units)
8648 * @rate: given rate_info to calculate bitrate from
8649 *
8650 * return 0 if MCS index >= 32
8651 */
8eb41c8d 8652u32 cfg80211_calculate_bitrate(struct rate_info *rate);
8097e149 8653
98104fde
JB
8654/**
8655 * cfg80211_unregister_wdev - remove the given wdev
8656 * @wdev: struct wireless_dev to remove
8657 *
2fe8ef10
JB
8658 * This function removes the device so it can no longer be used. It is necessary
8659 * to call this function even when cfg80211 requests the removal of the device
8660 * by calling the del_virtual_intf() callback. The function must also be called
8661 * when the driver wishes to unregister the wdev, e.g. when the hardware device
8662 * is unbound from the driver.
98104fde 8663 *
a05829a7 8664 * Requires the RTNL and wiphy mutex to be held.
98104fde
JB
8665 */
8666void cfg80211_unregister_wdev(struct wireless_dev *wdev);
8667
2fe8ef10
JB
8668/**
8669 * cfg80211_register_netdevice - register the given netdev
8670 * @dev: the netdev to register
8671 *
8672 * Note: In contexts coming from cfg80211 callbacks, you must call this rather
8673 * than register_netdevice(), unregister_netdev() is impossible as the RTNL is
8674 * held. Otherwise, both register_netdevice() and register_netdev() are usable
8675 * instead as well.
a05829a7
JB
8676 *
8677 * Requires the RTNL and wiphy mutex to be held.
2fe8ef10
JB
8678 */
8679int cfg80211_register_netdevice(struct net_device *dev);
8680
8681/**
8682 * cfg80211_unregister_netdevice - unregister the given netdev
8683 * @dev: the netdev to register
8684 *
8685 * Note: In contexts coming from cfg80211 callbacks, you must call this rather
8686 * than unregister_netdevice(), unregister_netdev() is impossible as the RTNL
8687 * is held. Otherwise, both unregister_netdevice() and unregister_netdev() are
8688 * usable instead as well.
a05829a7
JB
8689 *
8690 * Requires the RTNL and wiphy mutex to be held.
2fe8ef10
JB
8691 */
8692static inline void cfg80211_unregister_netdevice(struct net_device *dev)
8693{
c304eddc 8694#if IS_ENABLED(CONFIG_CFG80211)
2fe8ef10 8695 cfg80211_unregister_wdev(dev->ieee80211_ptr);
c304eddc 8696#endif
2fe8ef10
JB
8697}
8698
355199e0 8699/**
b1e8eb11 8700 * struct cfg80211_ft_event_params - FT Information Elements
355199e0
JM
8701 * @ies: FT IEs
8702 * @ies_len: length of the FT IE in bytes
8703 * @target_ap: target AP's MAC address
8704 * @ric_ies: RIC IE
8705 * @ric_ies_len: length of the RIC IE in bytes
8706 */
8707struct cfg80211_ft_event_params {
8708 const u8 *ies;
8709 size_t ies_len;
8710 const u8 *target_ap;
8711 const u8 *ric_ies;
8712 size_t ric_ies_len;
8713};
8714
8715/**
8716 * cfg80211_ft_event - notify userspace about FT IE and RIC IE
8717 * @netdev: network device
8718 * @ft_event: IE information
8719 */
8720void cfg80211_ft_event(struct net_device *netdev,
8721 struct cfg80211_ft_event_params *ft_event);
8722
0ee45355
JB
8723/**
8724 * cfg80211_get_p2p_attr - find and copy a P2P attribute from IE buffer
8725 * @ies: the input IE buffer
8726 * @len: the input length
8727 * @attr: the attribute ID to find
8728 * @buf: output buffer, can be %NULL if the data isn't needed, e.g.
8729 * if the function is only called to get the needed buffer size
8730 * @bufsize: size of the output buffer
8731 *
8732 * The function finds a given P2P attribute in the (vendor) IEs and
8733 * copies its contents to the given buffer.
8734 *
0ae997dc
YB
8735 * Return: A negative error code (-%EILSEQ or -%ENOENT) if the data is
8736 * malformed or the attribute can't be found (respectively), or the
8737 * length of the found attribute (which can be zero).
0ee45355 8738 */
c216e641
AS
8739int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len,
8740 enum ieee80211_p2p_attr_id attr,
8741 u8 *buf, unsigned int bufsize);
0ee45355 8742
29464ccc
JB
8743/**
8744 * ieee80211_ie_split_ric - split an IE buffer according to ordering (with RIC)
8745 * @ies: the IE buffer
8746 * @ielen: the length of the IE buffer
8747 * @ids: an array with element IDs that are allowed before
2512b1b1
LK
8748 * the split. A WLAN_EID_EXTENSION value means that the next
8749 * EID in the list is a sub-element of the EXTENSION IE.
29464ccc
JB
8750 * @n_ids: the size of the element ID array
8751 * @after_ric: array IE types that come after the RIC element
8752 * @n_after_ric: size of the @after_ric array
8753 * @offset: offset where to start splitting in the buffer
8754 *
8755 * This function splits an IE buffer by updating the @offset
8756 * variable to point to the location where the buffer should be
8757 * split.
8758 *
8759 * It assumes that the given IE buffer is well-formed, this
8760 * has to be guaranteed by the caller!
8761 *
8762 * It also assumes that the IEs in the buffer are ordered
8763 * correctly, if not the result of using this function will not
8764 * be ordered correctly either, i.e. it does no reordering.
8765 *
8766 * The function returns the offset where the next part of the
8767 * buffer starts, which may be @ielen if the entire (remainder)
8768 * of the buffer should be used.
8769 */
8770size_t ieee80211_ie_split_ric(const u8 *ies, size_t ielen,
8771 const u8 *ids, int n_ids,
8772 const u8 *after_ric, int n_after_ric,
8773 size_t offset);
8774
8775/**
8776 * ieee80211_ie_split - split an IE buffer according to ordering
8777 * @ies: the IE buffer
8778 * @ielen: the length of the IE buffer
8779 * @ids: an array with element IDs that are allowed before
2512b1b1
LK
8780 * the split. A WLAN_EID_EXTENSION value means that the next
8781 * EID in the list is a sub-element of the EXTENSION IE.
29464ccc
JB
8782 * @n_ids: the size of the element ID array
8783 * @offset: offset where to start splitting in the buffer
8784 *
8785 * This function splits an IE buffer by updating the @offset
8786 * variable to point to the location where the buffer should be
8787 * split.
8788 *
8789 * It assumes that the given IE buffer is well-formed, this
8790 * has to be guaranteed by the caller!
8791 *
8792 * It also assumes that the IEs in the buffer are ordered
8793 * correctly, if not the result of using this function will not
8794 * be ordered correctly either, i.e. it does no reordering.
8795 *
8796 * The function returns the offset where the next part of the
8797 * buffer starts, which may be @ielen if the entire (remainder)
8798 * of the buffer should be used.
8799 */
0483eeac
JB
8800static inline size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
8801 const u8 *ids, int n_ids, size_t offset)
8802{
8803 return ieee80211_ie_split_ric(ies, ielen, ids, n_ids, NULL, 0, offset);
8804}
29464ccc 8805
cd8f7cb4
JB
8806/**
8807 * cfg80211_report_wowlan_wakeup - report wakeup from WoWLAN
8808 * @wdev: the wireless device reporting the wakeup
8809 * @wakeup: the wakeup report
8810 * @gfp: allocation flags
8811 *
8812 * This function reports that the given device woke up. If it
8813 * caused the wakeup, report the reason(s), otherwise you may
8814 * pass %NULL as the @wakeup parameter to advertise that something
8815 * else caused the wakeup.
8816 */
8817void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,
8818 struct cfg80211_wowlan_wakeup *wakeup,
8819 gfp_t gfp);
8820
5de17984
AS
8821/**
8822 * cfg80211_crit_proto_stopped() - indicate critical protocol stopped by driver.
8823 *
8824 * @wdev: the wireless device for which critical protocol is stopped.
03f831a6 8825 * @gfp: allocation flags
5de17984
AS
8826 *
8827 * This function can be called by the driver to indicate it has reverted
8828 * operation back to normal. One reason could be that the duration given
8829 * by .crit_proto_start() has expired.
8830 */
8831void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp);
8832
bdfbec2d
IP
8833/**
8834 * ieee80211_get_num_supported_channels - get number of channels device has
8835 * @wiphy: the wiphy
8836 *
8837 * Return: the number of channels supported by the device.
8838 */
8839unsigned int ieee80211_get_num_supported_channels(struct wiphy *wiphy);
8840
cb2d956d
LC
8841/**
8842 * cfg80211_check_combinations - check interface combinations
8843 *
8844 * @wiphy: the wiphy
e227300c 8845 * @params: the interface combinations parameter
cb2d956d
LC
8846 *
8847 * This function can be called by the driver to check whether a
8848 * combination of interfaces and their types are allowed according to
8849 * the interface combinations.
8850 */
8851int cfg80211_check_combinations(struct wiphy *wiphy,
e227300c 8852 struct iface_combination_params *params);
cb2d956d 8853
65a124dd
MK
8854/**
8855 * cfg80211_iter_combinations - iterate over matching combinations
8856 *
8857 * @wiphy: the wiphy
e227300c 8858 * @params: the interface combinations parameter
65a124dd
MK
8859 * @iter: function to call for each matching combination
8860 * @data: pointer to pass to iter function
8861 *
8862 * This function can be called by the driver to check what possible
8863 * combinations it fits in at a given moment, e.g. for channel switching
8864 * purposes.
8865 */
8866int cfg80211_iter_combinations(struct wiphy *wiphy,
e227300c 8867 struct iface_combination_params *params,
65a124dd
MK
8868 void (*iter)(const struct ieee80211_iface_combination *c,
8869 void *data),
8870 void *data);
8871
f04c2203
MK
8872/*
8873 * cfg80211_stop_iface - trigger interface disconnection
8874 *
8875 * @wiphy: the wiphy
8876 * @wdev: wireless device
8877 * @gfp: context flags
8878 *
8879 * Trigger interface to be stopped as if AP was stopped, IBSS/mesh left, STA
8880 * disconnected.
8881 *
8882 * Note: This doesn't need any locks and is asynchronous.
8883 */
8884void cfg80211_stop_iface(struct wiphy *wiphy, struct wireless_dev *wdev,
8885 gfp_t gfp);
8886
f6837ba8
JB
8887/**
8888 * cfg80211_shutdown_all_interfaces - shut down all interfaces for a wiphy
8889 * @wiphy: the wiphy to shut down
8890 *
8891 * This function shuts down all interfaces belonging to this wiphy by
8892 * calling dev_close() (and treating non-netdev interfaces as needed).
8893 * It shouldn't really be used unless there are some fatal device errors
8894 * that really can't be recovered in any other way.
8895 *
8896 * Callers must hold the RTNL and be able to deal with callbacks into
8897 * the driver while the function is running.
8898 */
8899void cfg80211_shutdown_all_interfaces(struct wiphy *wiphy);
8900
d75bb06b
GKS
8901/**
8902 * wiphy_ext_feature_set - set the extended feature flag
8903 *
8904 * @wiphy: the wiphy to modify.
8905 * @ftidx: extended feature bit index.
8906 *
8907 * The extended features are flagged in multiple bytes (see
8908 * &struct wiphy.@ext_features)
8909 */
8910static inline void wiphy_ext_feature_set(struct wiphy *wiphy,
8911 enum nl80211_ext_feature_index ftidx)
8912{
8913 u8 *ft_byte;
8914
8915 ft_byte = &wiphy->ext_features[ftidx / 8];
8916 *ft_byte |= BIT(ftidx % 8);
8917}
8918
8919/**
8920 * wiphy_ext_feature_isset - check the extended feature flag
8921 *
8922 * @wiphy: the wiphy to modify.
8923 * @ftidx: extended feature bit index.
8924 *
8925 * The extended features are flagged in multiple bytes (see
8926 * &struct wiphy.@ext_features)
8927 */
8928static inline bool
8929wiphy_ext_feature_isset(struct wiphy *wiphy,
8930 enum nl80211_ext_feature_index ftidx)
8931{
8932 u8 ft_byte;
8933
8934 ft_byte = wiphy->ext_features[ftidx / 8];
8935 return (ft_byte & BIT(ftidx % 8)) != 0;
8936}
b7ffbd7e 8937
a442b761
AB
8938/**
8939 * cfg80211_free_nan_func - free NAN function
8940 * @f: NAN function that should be freed
8941 *
8942 * Frees all the NAN function and all it's allocated members.
8943 */
8944void cfg80211_free_nan_func(struct cfg80211_nan_func *f);
8945
50bcd31d
AB
8946/**
8947 * struct cfg80211_nan_match_params - NAN match parameters
8948 * @type: the type of the function that triggered a match. If it is
8949 * %NL80211_NAN_FUNC_SUBSCRIBE it means that we replied to a subscriber.
8950 * If it is %NL80211_NAN_FUNC_PUBLISH, it means that we got a discovery
8951 * result.
8952 * If it is %NL80211_NAN_FUNC_FOLLOW_UP, we received a follow up.
8953 * @inst_id: the local instance id
8954 * @peer_inst_id: the instance id of the peer's function
8955 * @addr: the MAC address of the peer
8956 * @info_len: the length of the &info
8957 * @info: the Service Specific Info from the peer (if any)
8958 * @cookie: unique identifier of the corresponding function
8959 */
8960struct cfg80211_nan_match_params {
8961 enum nl80211_nan_function_type type;
8962 u8 inst_id;
8963 u8 peer_inst_id;
8964 const u8 *addr;
8965 u8 info_len;
8966 const u8 *info;
8967 u64 cookie;
8968};
8969
8970/**
8971 * cfg80211_nan_match - report a match for a NAN function.
8972 * @wdev: the wireless device reporting the match
8973 * @match: match notification parameters
8974 * @gfp: allocation flags
8975 *
8976 * This function reports that the a NAN function had a match. This
8977 * can be a subscribe that had a match or a solicited publish that
8978 * was sent. It can also be a follow up that was received.
8979 */
8980void cfg80211_nan_match(struct wireless_dev *wdev,
8981 struct cfg80211_nan_match_params *match, gfp_t gfp);
8982
368e5a7b
AB
8983/**
8984 * cfg80211_nan_func_terminated - notify about NAN function termination.
8985 *
8986 * @wdev: the wireless device reporting the match
8987 * @inst_id: the local instance id
8988 * @reason: termination reason (one of the NL80211_NAN_FUNC_TERM_REASON_*)
8989 * @cookie: unique NAN function identifier
8990 * @gfp: allocation flags
8991 *
8992 * This function reports that the a NAN function is terminated.
8993 */
8994void cfg80211_nan_func_terminated(struct wireless_dev *wdev,
8995 u8 inst_id,
8996 enum nl80211_nan_func_term_reason reason,
8997 u64 cookie, gfp_t gfp);
8998
b7ffbd7e
JB
8999/* ethtool helper */
9000void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info);
9001
40cbfa90
SD
9002/**
9003 * cfg80211_external_auth_request - userspace request for authentication
9004 * @netdev: network device
9005 * @params: External authentication parameters
9006 * @gfp: allocation flags
9007 * Returns: 0 on success, < 0 on error
9008 */
9009int cfg80211_external_auth_request(struct net_device *netdev,
9010 struct cfg80211_external_auth_params *params,
9011 gfp_t gfp);
9012
9bb7e0f2
JB
9013/**
9014 * cfg80211_pmsr_report - report peer measurement result data
9015 * @wdev: the wireless device reporting the measurement
9016 * @req: the original measurement request
9017 * @result: the result data
9018 * @gfp: allocation flags
9019 */
9020void cfg80211_pmsr_report(struct wireless_dev *wdev,
9021 struct cfg80211_pmsr_request *req,
9022 struct cfg80211_pmsr_result *result,
9023 gfp_t gfp);
9024
9025/**
9026 * cfg80211_pmsr_complete - report peer measurement completed
9027 * @wdev: the wireless device reporting the measurement
9028 * @req: the original measurement request
9029 * @gfp: allocation flags
9030 *
9031 * Report that the entire measurement completed, after this
9032 * the request pointer will no longer be valid.
9033 */
9034void cfg80211_pmsr_complete(struct wireless_dev *wdev,
9035 struct cfg80211_pmsr_request *req,
9036 gfp_t gfp);
9037
e6f40511
MP
9038/**
9039 * cfg80211_iftype_allowed - check whether the interface can be allowed
9040 * @wiphy: the wiphy
9041 * @iftype: interface type
9042 * @is_4addr: use_4addr flag, must be '0' when check_swif is '1'
9043 * @check_swif: check iftype against software interfaces
9044 *
9045 * Check whether the interface is allowed to operate; additionally, this API
9046 * can be used to check iftype against the software interfaces when
9047 * check_swif is '1'.
9048 */
9049bool cfg80211_iftype_allowed(struct wiphy *wiphy, enum nl80211_iftype iftype,
9050 bool is_4addr, u8 check_swif);
9051
9052
a083ee8a
IP
9053/**
9054 * cfg80211_assoc_comeback - notification of association that was
9055 * temporarly rejected with a comeback
9056 * @netdev: network device
e69dac88 9057 * @ap_addr: AP (MLD) address that rejected the assocation
a083ee8a
IP
9058 * @timeout: timeout interval value TUs.
9059 *
9060 * this function may sleep. the caller must hold the corresponding wdev's mutex.
9061 */
9062void cfg80211_assoc_comeback(struct net_device *netdev,
e69dac88 9063 const u8 *ap_addr, u32 timeout);
a083ee8a 9064
e1db74fc
JP
9065/* Logging, debugging and troubleshooting/diagnostic helpers. */
9066
9067/* wiphy_printk helpers, similar to dev_printk */
9068
9069#define wiphy_printk(level, wiphy, format, args...) \
9c376639 9070 dev_printk(level, &(wiphy)->dev, format, ##args)
e1db74fc 9071#define wiphy_emerg(wiphy, format, args...) \
9c376639 9072 dev_emerg(&(wiphy)->dev, format, ##args)
e1db74fc 9073#define wiphy_alert(wiphy, format, args...) \
9c376639 9074 dev_alert(&(wiphy)->dev, format, ##args)
e1db74fc 9075#define wiphy_crit(wiphy, format, args...) \
9c376639 9076 dev_crit(&(wiphy)->dev, format, ##args)
e1db74fc 9077#define wiphy_err(wiphy, format, args...) \
9c376639 9078 dev_err(&(wiphy)->dev, format, ##args)
e1db74fc 9079#define wiphy_warn(wiphy, format, args...) \
9c376639 9080 dev_warn(&(wiphy)->dev, format, ##args)
e1db74fc 9081#define wiphy_notice(wiphy, format, args...) \
9c376639 9082 dev_notice(&(wiphy)->dev, format, ##args)
e1db74fc 9083#define wiphy_info(wiphy, format, args...) \
9c376639 9084 dev_info(&(wiphy)->dev, format, ##args)
761025b5
DO
9085#define wiphy_info_once(wiphy, format, args...) \
9086 dev_info_once(&(wiphy)->dev, format, ##args)
073730d7 9087
a58d7525
SG
9088#define wiphy_err_ratelimited(wiphy, format, args...) \
9089 dev_err_ratelimited(&(wiphy)->dev, format, ##args)
9090#define wiphy_warn_ratelimited(wiphy, format, args...) \
9091 dev_warn_ratelimited(&(wiphy)->dev, format, ##args)
9092
9c376639 9093#define wiphy_debug(wiphy, format, args...) \
e1db74fc 9094 wiphy_printk(KERN_DEBUG, wiphy, format, ##args)
9c376639 9095
e1db74fc 9096#define wiphy_dbg(wiphy, format, args...) \
9c376639 9097 dev_dbg(&(wiphy)->dev, format, ##args)
e1db74fc
JP
9098
9099#if defined(VERBOSE_DEBUG)
9100#define wiphy_vdbg wiphy_dbg
9101#else
e1db74fc
JP
9102#define wiphy_vdbg(wiphy, format, args...) \
9103({ \
9104 if (0) \
9105 wiphy_printk(KERN_DEBUG, wiphy, format, ##args); \
9c376639 9106 0; \
e1db74fc
JP
9107})
9108#endif
9109
9110/*
9111 * wiphy_WARN() acts like wiphy_printk(), but with the key difference
9112 * of using a WARN/WARN_ON to get the message out, including the
9113 * file/line information and a backtrace.
9114 */
9115#define wiphy_WARN(wiphy, format, args...) \
9116 WARN(1, "wiphy: %s\n" format, wiphy_name(wiphy), ##args);
9117
cb74e977
SD
9118/**
9119 * cfg80211_update_owe_info_event - Notify the peer's OWE info to user space
9120 * @netdev: network device
9121 * @owe_info: peer's owe info
9122 * @gfp: allocation flags
9123 */
9124void cfg80211_update_owe_info_event(struct net_device *netdev,
9125 struct cfg80211_update_owe_info *owe_info,
9126 gfp_t gfp);
9127
2f1805ea
EG
9128/**
9129 * cfg80211_bss_flush - resets all the scan entries
9130 * @wiphy: the wiphy
9131 */
9132void cfg80211_bss_flush(struct wiphy *wiphy);
9133
0d2ab3ae
JC
9134/**
9135 * cfg80211_bss_color_notify - notify about bss color event
9136 * @dev: network device
0d2ab3ae
JC
9137 * @cmd: the actual event we want to notify
9138 * @count: the number of TBTTs until the color change happens
9139 * @color_bitmap: representations of the colors that the local BSS is aware of
9140 */
935ef47b 9141int cfg80211_bss_color_notify(struct net_device *dev,
0d2ab3ae
JC
9142 enum nl80211_commands cmd, u8 count,
9143 u64 color_bitmap);
9144
9145/**
9146 * cfg80211_obss_color_collision_notify - notify about bss color collision
9147 * @dev: network device
9148 * @color_bitmap: representations of the colors that the local BSS is aware of
9149 */
9150static inline int cfg80211_obss_color_collision_notify(struct net_device *dev,
935ef47b 9151 u64 color_bitmap)
0d2ab3ae 9152{
935ef47b 9153 return cfg80211_bss_color_notify(dev, NL80211_CMD_OBSS_COLOR_COLLISION,
0d2ab3ae
JC
9154 0, color_bitmap);
9155}
9156
9157/**
9158 * cfg80211_color_change_started_notify - notify color change start
9159 * @dev: the device on which the color is switched
9160 * @count: the number of TBTTs until the color change happens
9161 *
9162 * Inform the userspace about the color change that has started.
9163 */
9164static inline int cfg80211_color_change_started_notify(struct net_device *dev,
9165 u8 count)
9166{
935ef47b 9167 return cfg80211_bss_color_notify(dev, NL80211_CMD_COLOR_CHANGE_STARTED,
0d2ab3ae
JC
9168 count, 0);
9169}
9170
9171/**
9172 * cfg80211_color_change_aborted_notify - notify color change abort
9173 * @dev: the device on which the color is switched
9174 *
9175 * Inform the userspace about the color change that has aborted.
9176 */
9177static inline int cfg80211_color_change_aborted_notify(struct net_device *dev)
9178{
935ef47b 9179 return cfg80211_bss_color_notify(dev, NL80211_CMD_COLOR_CHANGE_ABORTED,
0d2ab3ae
JC
9180 0, 0);
9181}
9182
9183/**
9184 * cfg80211_color_change_notify - notify color change completion
9185 * @dev: the device on which the color was switched
9186 *
9187 * Inform the userspace about the color change that has completed.
9188 */
9189static inline int cfg80211_color_change_notify(struct net_device *dev)
9190{
935ef47b 9191 return cfg80211_bss_color_notify(dev,
0d2ab3ae
JC
9192 NL80211_CMD_COLOR_CHANGE_COMPLETED,
9193 0, 0);
9194}
9195
b25413fe
AD
9196/**
9197 * cfg80211_valid_disable_subchannel_bitmap - validate puncturing bitmap
9198 * @bitmap: bitmap to be validated
9199 * @chandef: channel definition
9200 *
9201 * Validate the puncturing bitmap.
9202 *
9203 * Return: %true if the bitmap is valid. %false otherwise.
9204 */
9205bool cfg80211_valid_disable_subchannel_bitmap(u16 *bitmap,
9206 const struct cfg80211_chan_def *chandef);
9207
065563b2
VJ
9208/**
9209 * cfg80211_links_removed - Notify about removed STA MLD setup links.
9210 * @dev: network device.
9211 * @link_mask: BIT mask of removed STA MLD setup link IDs.
9212 *
9213 * Inform cfg80211 and the userspace about removed STA MLD setup links due to
9214 * AP MLD removing the corresponding affiliated APs with Multi-Link
9215 * reconfiguration. Note that it's not valid to remove all links, in this
9216 * case disconnect instead.
9217 * Also note that the wdev mutex must be held.
9218 */
9219void cfg80211_links_removed(struct net_device *dev, u16 link_mask);
9220
704232c2 9221#endif /* __NET_CFG80211_H */