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