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