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