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