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