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