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