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