OSDN Git Service

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