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