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