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