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