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