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