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