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