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