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