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