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