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