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