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