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