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-2026 Intel Corporation
11 */
12
13 #include <linux/ethtool.h>
14 #include <uapi/linux/rfkill.h>
15 #include <linux/netdevice.h>
16 #include <linux/debugfs.h>
17 #include <linux/list.h>
18 #include <linux/bug.h>
19 #include <linux/netlink.h>
20 #include <linux/skbuff.h>
21 #include <linux/nl80211.h>
22 #include <linux/if_ether.h>
23 #include <linux/ieee80211.h>
24 #include <linux/net.h>
25 #include <linux/rfkill.h>
26 #include <net/regulatory.h>
27
28 /**
29 * DOC: Introduction
30 *
31 * cfg80211 is the configuration API for 802.11 devices in Linux. It bridges
32 * userspace and drivers, and offers some utility functionality associated
33 * with 802.11. cfg80211 must, directly or indirectly via mac80211, be used
34 * by all modern wireless drivers in Linux, so that they offer a consistent
35 * API through nl80211. For backward compatibility, cfg80211 also offers
36 * wireless extensions to userspace, but hides them from drivers completely.
37 *
38 * Additionally, cfg80211 contains code to help enforce regulatory spectrum
39 * use restrictions.
40 */
41
42
43 /**
44 * DOC: Device registration
45 *
46 * In order for a driver to use cfg80211, it must register the hardware device
47 * with cfg80211. This happens through a number of hardware capability structs
48 * described below.
49 *
50 * The fundamental structure for each device is the 'wiphy', of which each
51 * instance describes a physical wireless device connected to the system. Each
52 * such wiphy can have zero, one, or many virtual interfaces associated with
53 * it, which need to be identified as such by pointing the network interface's
54 * @ieee80211_ptr pointer to a &struct wireless_dev which further describes
55 * the wireless part of the interface. Normally this struct is embedded in the
56 * network interface's private data area. Drivers can optionally allow creating
57 * or destroying virtual interfaces on the fly, but without at least one or the
58 * ability to create some the wireless device isn't useful.
59 *
60 * Each wiphy structure contains device capability information, and also has
61 * a pointer to the various operations the driver offers. The definitions and
62 * structures here describe these capabilities in detail.
63 */
64
65 struct wiphy;
66
67 /*
68 * wireless hardware capability structures
69 */
70
71 /**
72 * enum ieee80211_channel_flags - channel flags
73 *
74 * Channel flags set by the regulatory control code.
75 *
76 * @IEEE80211_CHAN_DISABLED: This channel is disabled.
77 * @IEEE80211_CHAN_NO_IR: do not initiate radiation, this includes
78 * sending probe requests or beaconing.
79 * @IEEE80211_CHAN_PSD: Power spectral density (in dBm) is set for this
80 * channel.
81 * @IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
82 * @IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel
83 * is not permitted.
84 * @IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel
85 * is not permitted.
86 * @IEEE80211_CHAN_NO_OFDM: OFDM is not allowed on this channel.
87 * @IEEE80211_CHAN_NO_80MHZ: If the driver supports 80 MHz on the band,
88 * this flag indicates that an 80 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_NO_160MHZ: If the driver supports 160 MHz on the band,
93 * this flag indicates that an 160 MHz channel cannot use this
94 * channel as the control or any of the secondary channels.
95 * This may be due to the driver or due to regulatory bandwidth
96 * restrictions.
97 * @IEEE80211_CHAN_INDOOR_ONLY: see %NL80211_FREQUENCY_ATTR_INDOOR_ONLY
98 * @IEEE80211_CHAN_IR_CONCURRENT: see %NL80211_FREQUENCY_ATTR_IR_CONCURRENT
99 * @IEEE80211_CHAN_NO_20MHZ: 20 MHz bandwidth is not permitted
100 * on this channel.
101 * @IEEE80211_CHAN_NO_10MHZ: 10 MHz bandwidth is not permitted
102 * on this channel.
103 * @IEEE80211_CHAN_NO_HE: HE operation is not permitted on this channel.
104 * @IEEE80211_CHAN_NO_320MHZ: If the driver supports 320 MHz on the band,
105 * this flag indicates that a 320 MHz channel cannot use this
106 * channel as the control or any of the secondary channels.
107 * This may be due to the driver or due to regulatory bandwidth
108 * restrictions.
109 * @IEEE80211_CHAN_NO_EHT: EHT operation is not permitted on this channel.
110 * @IEEE80211_CHAN_DFS_CONCURRENT: See %NL80211_RRF_DFS_CONCURRENT
111 * @IEEE80211_CHAN_NO_6GHZ_VLP_CLIENT: Client connection with VLP AP
112 * not permitted using this channel
113 * @IEEE80211_CHAN_NO_6GHZ_AFC_CLIENT: Client connection with AFC AP
114 * not permitted using this channel
115 * @IEEE80211_CHAN_CAN_MONITOR: This channel can be used for monitor
116 * mode even in the presence of other (regulatory) restrictions,
117 * even if it is otherwise disabled.
118 * @IEEE80211_CHAN_ALLOW_6GHZ_VLP_AP: Allow using this channel for AP operation
119 * with very low power (VLP), even if otherwise set to NO_IR.
120 * @IEEE80211_CHAN_ALLOW_20MHZ_ACTIVITY: Allow activity on a 20 MHz channel,
121 * even if otherwise set to NO_IR.
122 * @IEEE80211_CHAN_S1G_NO_PRIMARY: Prevents the channel for use as an S1G
123 * primary channel. Does not prevent the wider operating channel
124 * described by the chandef from being used. In order for a 2MHz primary
125 * to be used, both 1MHz subchannels shall not contain this flag.
126 * @IEEE80211_CHAN_NO_4MHZ: 4 MHz bandwidth is not permitted on this channel.
127 * @IEEE80211_CHAN_NO_8MHZ: 8 MHz bandwidth is not permitted on this channel.
128 * @IEEE80211_CHAN_NO_16MHZ: 16 MHz bandwidth is not permitted on this channel.
129 * @IEEE80211_CHAN_NO_UHR: UHR operation is not permitted on this channel.
130 */
131 enum ieee80211_channel_flags {
132 IEEE80211_CHAN_DISABLED = BIT(0),
133 IEEE80211_CHAN_NO_IR = BIT(1),
134 IEEE80211_CHAN_PSD = BIT(2),
135 IEEE80211_CHAN_RADAR = BIT(3),
136 IEEE80211_CHAN_NO_HT40PLUS = BIT(4),
137 IEEE80211_CHAN_NO_HT40MINUS = BIT(5),
138 IEEE80211_CHAN_NO_OFDM = BIT(6),
139 IEEE80211_CHAN_NO_80MHZ = BIT(7),
140 IEEE80211_CHAN_NO_160MHZ = BIT(8),
141 IEEE80211_CHAN_INDOOR_ONLY = BIT(9),
142 IEEE80211_CHAN_IR_CONCURRENT = BIT(10),
143 IEEE80211_CHAN_NO_20MHZ = BIT(11),
144 IEEE80211_CHAN_NO_10MHZ = BIT(12),
145 IEEE80211_CHAN_NO_HE = BIT(13),
146 /* can use free bits here */
147 IEEE80211_CHAN_NO_UHR = BIT(18),
148 IEEE80211_CHAN_NO_320MHZ = BIT(19),
149 IEEE80211_CHAN_NO_EHT = BIT(20),
150 IEEE80211_CHAN_DFS_CONCURRENT = BIT(21),
151 IEEE80211_CHAN_NO_6GHZ_VLP_CLIENT = BIT(22),
152 IEEE80211_CHAN_NO_6GHZ_AFC_CLIENT = BIT(23),
153 IEEE80211_CHAN_CAN_MONITOR = BIT(24),
154 IEEE80211_CHAN_ALLOW_6GHZ_VLP_AP = BIT(25),
155 IEEE80211_CHAN_ALLOW_20MHZ_ACTIVITY = BIT(26),
156 IEEE80211_CHAN_S1G_NO_PRIMARY = BIT(27),
157 IEEE80211_CHAN_NO_4MHZ = BIT(28),
158 IEEE80211_CHAN_NO_8MHZ = BIT(29),
159 IEEE80211_CHAN_NO_16MHZ = BIT(30),
160 };
161
162 #define IEEE80211_CHAN_NO_HT40 \
163 (IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS)
164
165 #define IEEE80211_DFS_MIN_CAC_TIME_MS 60000
166 #define IEEE80211_DFS_MIN_NOP_TIME_MS (30 * 60 * 1000)
167
168 /**
169 * struct ieee80211_channel - channel definition
170 *
171 * This structure describes a single channel for use
172 * with cfg80211.
173 *
174 * @center_freq: center frequency in MHz
175 * @freq_offset: offset from @center_freq, in KHz
176 * @hw_value: hardware-specific value for the channel
177 * @flags: channel flags from &enum ieee80211_channel_flags.
178 * @orig_flags: channel flags at registration time, used by regulatory
179 * code to support devices with additional restrictions
180 * @band: band this channel belongs to.
181 * @max_antenna_gain: maximum antenna gain in dBi
182 * @max_power: maximum transmission power (in dBm)
183 * @max_reg_power: maximum regulatory transmission power (in dBm)
184 * @beacon_found: helper to regulatory code to indicate when a beacon
185 * has been found on this channel. Use regulatory_hint_found_beacon()
186 * to enable this, this is useful only on 5 GHz band.
187 * @orig_mag: internal use
188 * @orig_mpwr: internal use
189 * @dfs_state: current state of this channel. Only relevant if radar is required
190 * on this channel.
191 * @dfs_state_entered: timestamp (jiffies) when the dfs state was entered.
192 * @dfs_cac_ms: DFS CAC time in milliseconds, this is valid for DFS channels.
193 * @cac_start_time: timestamp (CLOCK_BOOTTIME, nanoseconds) when CAC was
194 * started on this channel. Zero when CAC is not in progress.
195 * @psd: power spectral density (in dBm)
196 */
197 struct ieee80211_channel {
198 enum nl80211_band band;
199 u32 center_freq;
200 u16 freq_offset;
201 u16 hw_value;
202 u32 flags;
203 int max_antenna_gain;
204 int max_power;
205 int max_reg_power;
206 bool beacon_found;
207 u32 orig_flags;
208 int orig_mag, orig_mpwr;
209 enum nl80211_dfs_state dfs_state;
210 unsigned long dfs_state_entered;
211 unsigned int dfs_cac_ms;
212 u64 cac_start_time;
213 s8 psd;
214 };
215
216 /**
217 * enum ieee80211_rate_flags - rate flags
218 *
219 * Hardware/specification flags for rates. These are structured
220 * in a way that allows using the same bitrate structure for
221 * different bands/PHY modes.
222 *
223 * @IEEE80211_RATE_SHORT_PREAMBLE: Hardware can send with short
224 * preamble on this bitrate; only relevant in 2.4GHz band and
225 * with CCK rates.
226 * @IEEE80211_RATE_MANDATORY_A: This bitrate is a mandatory rate
227 * when used with 802.11a (on the 5 GHz band); filled by the
228 * core code when registering the wiphy.
229 * @IEEE80211_RATE_MANDATORY_B: This bitrate is a mandatory rate
230 * when used with 802.11b (on the 2.4 GHz band); filled by the
231 * core code when registering the wiphy.
232 * @IEEE80211_RATE_MANDATORY_G: This bitrate is a mandatory rate
233 * when used with 802.11g (on the 2.4 GHz band); filled by the
234 * core code when registering the wiphy.
235 * @IEEE80211_RATE_ERP_G: This is an ERP rate in 802.11g mode.
236 * @IEEE80211_RATE_SUPPORTS_5MHZ: Rate can be used in 5 MHz mode
237 * @IEEE80211_RATE_SUPPORTS_10MHZ: Rate can be used in 10 MHz mode
238 */
239 enum ieee80211_rate_flags {
240 IEEE80211_RATE_SHORT_PREAMBLE = BIT(0),
241 IEEE80211_RATE_MANDATORY_A = BIT(1),
242 IEEE80211_RATE_MANDATORY_B = BIT(2),
243 IEEE80211_RATE_MANDATORY_G = BIT(3),
244 IEEE80211_RATE_ERP_G = BIT(4),
245 IEEE80211_RATE_SUPPORTS_5MHZ = BIT(5),
246 IEEE80211_RATE_SUPPORTS_10MHZ = BIT(6),
247 };
248
249 /**
250 * enum ieee80211_bss_type - BSS type filter
251 *
252 * @IEEE80211_BSS_TYPE_ESS: Infrastructure BSS
253 * @IEEE80211_BSS_TYPE_PBSS: Personal BSS
254 * @IEEE80211_BSS_TYPE_IBSS: Independent BSS
255 * @IEEE80211_BSS_TYPE_MBSS: Mesh BSS
256 * @IEEE80211_BSS_TYPE_ANY: Wildcard value for matching any BSS type
257 */
258 enum ieee80211_bss_type {
259 IEEE80211_BSS_TYPE_ESS,
260 IEEE80211_BSS_TYPE_PBSS,
261 IEEE80211_BSS_TYPE_IBSS,
262 IEEE80211_BSS_TYPE_MBSS,
263 IEEE80211_BSS_TYPE_ANY
264 };
265
266 /**
267 * enum ieee80211_privacy - BSS privacy filter
268 *
269 * @IEEE80211_PRIVACY_ON: privacy bit set
270 * @IEEE80211_PRIVACY_OFF: privacy bit clear
271 * @IEEE80211_PRIVACY_ANY: Wildcard value for matching any privacy setting
272 */
273 enum ieee80211_privacy {
274 IEEE80211_PRIVACY_ON,
275 IEEE80211_PRIVACY_OFF,
276 IEEE80211_PRIVACY_ANY
277 };
278
279 #define IEEE80211_PRIVACY(x) \
280 ((x) ? IEEE80211_PRIVACY_ON : IEEE80211_PRIVACY_OFF)
281
282 /**
283 * struct ieee80211_rate - bitrate definition
284 *
285 * This structure describes a bitrate that an 802.11 PHY can
286 * operate with. The two values @hw_value and @hw_value_short
287 * are only for driver use when pointers to this structure are
288 * passed around.
289 *
290 * @flags: rate-specific flags from &enum ieee80211_rate_flags
291 * @bitrate: bitrate in units of 100 Kbps
292 * @hw_value: driver/hardware value for this rate
293 * @hw_value_short: driver/hardware value for this rate when
294 * short preamble is used
295 */
296 struct ieee80211_rate {
297 u32 flags;
298 u16 bitrate;
299 u16 hw_value, hw_value_short;
300 };
301
302 /**
303 * struct ieee80211_he_obss_pd - AP settings for spatial reuse
304 *
305 * @enable: is the feature enabled.
306 * @sr_ctrl: The SR Control field of SRP element.
307 * @non_srg_max_offset: non-SRG maximum tx power offset
308 * @min_offset: minimal tx power offset an associated station shall use
309 * @max_offset: maximum tx power offset an associated station shall use
310 * @bss_color_bitmap: bitmap that indicates the BSS color values used by
311 * members of the SRG
312 * @partial_bssid_bitmap: bitmap that indicates the partial BSSID values
313 * used by members of the SRG
314 */
315 struct ieee80211_he_obss_pd {
316 bool enable;
317 u8 sr_ctrl;
318 u8 non_srg_max_offset;
319 u8 min_offset;
320 u8 max_offset;
321 u8 bss_color_bitmap[8];
322 u8 partial_bssid_bitmap[8];
323 };
324
325 /**
326 * struct cfg80211_he_bss_color - AP settings for BSS coloring
327 *
328 * @color: the current color.
329 * @enabled: HE BSS color is used
330 * @partial: define the AID equation.
331 */
332 struct cfg80211_he_bss_color {
333 u8 color;
334 bool enabled;
335 bool partial;
336 };
337
338 /**
339 * struct ieee80211_sta_ht_cap - STA's HT capabilities
340 *
341 * This structure describes most essential parameters needed
342 * to describe 802.11n HT capabilities for an STA.
343 *
344 * @ht_supported: is HT supported by the STA
345 * @cap: HT capabilities map as described in 802.11n spec
346 * @ampdu_factor: Maximum A-MPDU length factor
347 * @ampdu_density: Minimum A-MPDU spacing
348 * @mcs: Supported MCS rates
349 */
350 struct ieee80211_sta_ht_cap {
351 u16 cap; /* use IEEE80211_HT_CAP_ */
352 bool ht_supported;
353 u8 ampdu_factor;
354 u8 ampdu_density;
355 struct ieee80211_mcs_info mcs;
356 };
357
358 /**
359 * struct ieee80211_sta_vht_cap - STA's VHT capabilities
360 *
361 * This structure describes most essential parameters needed
362 * to describe 802.11ac VHT capabilities for an STA.
363 *
364 * @vht_supported: is VHT supported by the STA
365 * @cap: VHT capabilities map as described in 802.11ac spec
366 * @vht_mcs: Supported VHT MCS rates
367 */
368 struct ieee80211_sta_vht_cap {
369 bool vht_supported;
370 u32 cap; /* use IEEE80211_VHT_CAP_ */
371 struct ieee80211_vht_mcs_info vht_mcs;
372 };
373
374 #define IEEE80211_HE_PPE_THRES_MAX_LEN 25
375
376 /**
377 * struct ieee80211_sta_he_cap - STA's HE capabilities
378 *
379 * This structure describes most essential parameters needed
380 * to describe 802.11ax HE capabilities for a STA.
381 *
382 * @has_he: true iff HE data is valid.
383 * @he_cap_elem: Fixed portion of the HE capabilities element.
384 * @he_mcs_nss_supp: The supported NSS/MCS combinations.
385 * @ppe_thres: Holds the PPE Thresholds data.
386 */
387 struct ieee80211_sta_he_cap {
388 bool has_he;
389 struct ieee80211_he_cap_elem he_cap_elem;
390 struct ieee80211_he_mcs_nss_supp he_mcs_nss_supp;
391 u8 ppe_thres[IEEE80211_HE_PPE_THRES_MAX_LEN];
392 };
393
394 /**
395 * struct ieee80211_eht_mcs_nss_supp - EHT max supported NSS per MCS
396 *
397 * See P802.11be_D1.3 Table 9-401k - "Subfields of the Supported EHT-MCS
398 * and NSS Set field"
399 *
400 * @only_20mhz: MCS/NSS support for 20 MHz-only STA.
401 * @bw: MCS/NSS support for 80, 160 and 320 MHz
402 * @bw._80: MCS/NSS support for BW <= 80 MHz
403 * @bw._160: MCS/NSS support for BW = 160 MHz
404 * @bw._320: MCS/NSS support for BW = 320 MHz
405 */
406 struct ieee80211_eht_mcs_nss_supp {
407 union {
408 struct ieee80211_eht_mcs_nss_supp_20mhz_only only_20mhz;
409 struct {
410 struct ieee80211_eht_mcs_nss_supp_bw _80;
411 struct ieee80211_eht_mcs_nss_supp_bw _160;
412 struct ieee80211_eht_mcs_nss_supp_bw _320;
413 } __packed bw;
414 } __packed;
415 } __packed;
416
417 #define IEEE80211_EHT_PPE_THRES_MAX_LEN 32
418
419 /**
420 * struct ieee80211_sta_eht_cap - STA's EHT capabilities
421 *
422 * This structure describes most essential parameters needed
423 * to describe 802.11be EHT capabilities for a STA.
424 *
425 * @has_eht: true iff EHT data is valid.
426 * @eht_cap_elem: Fixed portion of the eht capabilities element.
427 * @eht_mcs_nss_supp: The supported NSS/MCS combinations.
428 * @eht_ppe_thres: Holds the PPE Thresholds data.
429 */
430 struct ieee80211_sta_eht_cap {
431 bool has_eht;
432 struct ieee80211_eht_cap_elem_fixed eht_cap_elem;
433 struct ieee80211_eht_mcs_nss_supp eht_mcs_nss_supp;
434 u8 eht_ppe_thres[IEEE80211_EHT_PPE_THRES_MAX_LEN];
435 };
436
437 /**
438 * struct ieee80211_sta_uhr_cap - STA's UHR capabilities
439 * @has_uhr: true iff UHR is supported and data is valid
440 * @mac: fixed MAC capabilities
441 * @phy: fixed PHY capabilities
442 */
443 struct ieee80211_sta_uhr_cap {
444 bool has_uhr;
445 struct ieee80211_uhr_cap_mac mac;
446 struct ieee80211_uhr_cap_phy phy;
447 };
448
449 /* sparse defines __CHECKER__; see Documentation/dev-tools/sparse.rst */
450 #ifdef __CHECKER__
451 /*
452 * This is used to mark the sband->iftype_data pointer which is supposed
453 * to be an array with special access semantics (per iftype), but a lot
454 * of code got it wrong in the past, so with this marking sparse will be
455 * noisy when the pointer is used directly.
456 */
457 # define __iftd __attribute__((noderef, address_space(__iftype_data)))
458 #else
459 # define __iftd
460 #endif /* __CHECKER__ */
461
462 /**
463 * struct ieee80211_sband_iftype_data - sband data per interface type
464 *
465 * This structure encapsulates sband data that is relevant for the
466 * interface types defined in @types_mask. Each type in the
467 * @types_mask must be unique across all instances of iftype_data.
468 *
469 * @types_mask: interface types mask
470 * @he_cap: holds the HE capabilities
471 * @he_6ghz_capa: HE 6 GHz capabilities, must be filled in for a
472 * 6 GHz band channel (and 0 may be valid value).
473 * @eht_cap: STA's EHT capabilities
474 * @uhr_cap: STA's UHR capabilities
475 * @vendor_elems: vendor element(s) to advertise
476 * @vendor_elems.data: vendor element(s) data
477 * @vendor_elems.len: vendor element(s) length
478 */
479 struct ieee80211_sband_iftype_data {
480 u16 types_mask;
481 struct ieee80211_sta_he_cap he_cap;
482 struct ieee80211_he_6ghz_capa he_6ghz_capa;
483 struct ieee80211_sta_eht_cap eht_cap;
484 struct ieee80211_sta_uhr_cap uhr_cap;
485 struct {
486 const u8 *data;
487 unsigned int len;
488 } vendor_elems;
489 };
490
491 /**
492 * enum ieee80211_edmg_bw_config - allowed channel bandwidth configurations
493 *
494 * @IEEE80211_EDMG_BW_CONFIG_4: 2.16GHz
495 * @IEEE80211_EDMG_BW_CONFIG_5: 2.16GHz and 4.32GHz
496 * @IEEE80211_EDMG_BW_CONFIG_6: 2.16GHz, 4.32GHz and 6.48GHz
497 * @IEEE80211_EDMG_BW_CONFIG_7: 2.16GHz, 4.32GHz, 6.48GHz and 8.64GHz
498 * @IEEE80211_EDMG_BW_CONFIG_8: 2.16GHz and 2.16GHz + 2.16GHz
499 * @IEEE80211_EDMG_BW_CONFIG_9: 2.16GHz, 4.32GHz and 2.16GHz + 2.16GHz
500 * @IEEE80211_EDMG_BW_CONFIG_10: 2.16GHz, 4.32GHz, 6.48GHz and 2.16GHz+2.16GHz
501 * @IEEE80211_EDMG_BW_CONFIG_11: 2.16GHz, 4.32GHz, 6.48GHz, 8.64GHz and
502 * 2.16GHz+2.16GHz
503 * @IEEE80211_EDMG_BW_CONFIG_12: 2.16GHz, 2.16GHz + 2.16GHz and
504 * 4.32GHz + 4.32GHz
505 * @IEEE80211_EDMG_BW_CONFIG_13: 2.16GHz, 4.32GHz, 2.16GHz + 2.16GHz and
506 * 4.32GHz + 4.32GHz
507 * @IEEE80211_EDMG_BW_CONFIG_14: 2.16GHz, 4.32GHz, 6.48GHz, 2.16GHz + 2.16GHz
508 * and 4.32GHz + 4.32GHz
509 * @IEEE80211_EDMG_BW_CONFIG_15: 2.16GHz, 4.32GHz, 6.48GHz, 8.64GHz,
510 * 2.16GHz + 2.16GHz and 4.32GHz + 4.32GHz
511 */
512 enum ieee80211_edmg_bw_config {
513 IEEE80211_EDMG_BW_CONFIG_4 = 4,
514 IEEE80211_EDMG_BW_CONFIG_5 = 5,
515 IEEE80211_EDMG_BW_CONFIG_6 = 6,
516 IEEE80211_EDMG_BW_CONFIG_7 = 7,
517 IEEE80211_EDMG_BW_CONFIG_8 = 8,
518 IEEE80211_EDMG_BW_CONFIG_9 = 9,
519 IEEE80211_EDMG_BW_CONFIG_10 = 10,
520 IEEE80211_EDMG_BW_CONFIG_11 = 11,
521 IEEE80211_EDMG_BW_CONFIG_12 = 12,
522 IEEE80211_EDMG_BW_CONFIG_13 = 13,
523 IEEE80211_EDMG_BW_CONFIG_14 = 14,
524 IEEE80211_EDMG_BW_CONFIG_15 = 15,
525 };
526
527 /**
528 * struct ieee80211_edmg - EDMG configuration
529 *
530 * This structure describes most essential parameters needed
531 * to describe 802.11ay EDMG configuration
532 *
533 * @channels: bitmap that indicates the 2.16 GHz channel(s)
534 * that are allowed to be used for transmissions.
535 * Bit 0 indicates channel 1, bit 1 indicates channel 2, etc.
536 * Set to 0 indicate EDMG not supported.
537 * @bw_config: Channel BW Configuration subfield encodes
538 * the allowed channel bandwidth configurations
539 */
540 struct ieee80211_edmg {
541 u8 channels;
542 enum ieee80211_edmg_bw_config bw_config;
543 };
544
545 /**
546 * struct ieee80211_sta_s1g_cap - STA's S1G capabilities
547 *
548 * This structure describes most essential parameters needed
549 * to describe 802.11ah S1G capabilities for a STA.
550 *
551 * @s1g: is STA an S1G STA
552 * @cap: S1G capabilities information
553 * @nss_mcs: Supported NSS MCS set
554 */
555 struct ieee80211_sta_s1g_cap {
556 bool s1g;
557 u8 cap[10]; /* use S1G_CAPAB_ */
558 u8 nss_mcs[5];
559 };
560
561 /**
562 * struct ieee80211_supported_band - frequency band definition
563 *
564 * This structure describes a frequency band a wiphy
565 * is able to operate in.
566 *
567 * @channels: Array of channels the hardware can operate with
568 * in this band.
569 * @band: the band this structure represents
570 * @n_channels: Number of channels in @channels
571 * @bitrates: Array of bitrates the hardware can operate with
572 * in this band. Must be sorted to give a valid "supported
573 * rates" IE, i.e. CCK rates first, then OFDM.
574 * @n_bitrates: Number of bitrates in @bitrates
575 * @ht_cap: HT capabilities in this band
576 * @vht_cap: VHT capabilities in this band
577 * @s1g_cap: S1G capabilities in this band
578 * @edmg_cap: EDMG capabilities in this band
579 * @s1g_cap: S1G capabilities in this band (S1G band only, of course)
580 * @n_iftype_data: number of iftype data entries
581 * @iftype_data: interface type data entries. Note that the bits in
582 * @types_mask inside this structure cannot overlap (i.e. only
583 * one occurrence of each type is allowed across all instances of
584 * iftype_data).
585 */
586 struct ieee80211_supported_band {
587 struct ieee80211_channel *channels;
588 struct ieee80211_rate *bitrates;
589 enum nl80211_band band;
590 int n_channels;
591 int n_bitrates;
592 struct ieee80211_sta_ht_cap ht_cap;
593 struct ieee80211_sta_vht_cap vht_cap;
594 struct ieee80211_sta_s1g_cap s1g_cap;
595 struct ieee80211_edmg edmg_cap;
596 u16 n_iftype_data;
597 const struct ieee80211_sband_iftype_data __iftd *iftype_data;
598 };
599
600 /**
601 * _ieee80211_set_sband_iftype_data - set sband iftype data array
602 * @sband: the sband to initialize
603 * @iftd: the iftype data array pointer
604 * @n_iftd: the length of the iftype data array
605 *
606 * Set the sband iftype data array; use this where the length cannot
607 * be derived from the ARRAY_SIZE() of the argument, but prefer
608 * ieee80211_set_sband_iftype_data() where it can be used.
609 */
610 static inline void
_ieee80211_set_sband_iftype_data(struct ieee80211_supported_band * sband,const struct ieee80211_sband_iftype_data * iftd,u16 n_iftd)611 _ieee80211_set_sband_iftype_data(struct ieee80211_supported_band *sband,
612 const struct ieee80211_sband_iftype_data *iftd,
613 u16 n_iftd)
614 {
615 sband->iftype_data = (const void __iftd __force *)iftd;
616 sband->n_iftype_data = n_iftd;
617 }
618
619 /**
620 * ieee80211_set_sband_iftype_data - set sband iftype data array
621 * @sband: the sband to initialize
622 * @iftd: the iftype data array
623 */
624 #define ieee80211_set_sband_iftype_data(sband, iftd) \
625 _ieee80211_set_sband_iftype_data(sband, iftd, ARRAY_SIZE(iftd))
626
627 /**
628 * for_each_sband_iftype_data - iterate sband iftype data entries
629 * @sband: the sband whose iftype_data array to iterate
630 * @i: iterator counter
631 * @iftd: iftype data pointer to set
632 */
633 #define for_each_sband_iftype_data(sband, i, iftd) \
634 for (i = 0, iftd = (const void __force *)&(sband)->iftype_data[i]; \
635 i < (sband)->n_iftype_data; \
636 i++, iftd = (const void __force *)&(sband)->iftype_data[i])
637
638 /**
639 * ieee80211_get_sband_iftype_data - return sband data for a given iftype
640 * @sband: the sband to search for the STA on
641 * @iftype: enum nl80211_iftype
642 *
643 * Return: pointer to struct ieee80211_sband_iftype_data, or NULL is none found
644 */
645 static inline const struct ieee80211_sband_iftype_data *
ieee80211_get_sband_iftype_data(const struct ieee80211_supported_band * sband,u8 iftype)646 ieee80211_get_sband_iftype_data(const struct ieee80211_supported_band *sband,
647 u8 iftype)
648 {
649 const struct ieee80211_sband_iftype_data *data;
650 int i;
651
652 if (WARN_ON(iftype >= NUM_NL80211_IFTYPES))
653 return NULL;
654
655 if (iftype == NL80211_IFTYPE_AP_VLAN)
656 iftype = NL80211_IFTYPE_AP;
657
658 for_each_sband_iftype_data(sband, i, data) {
659 if (data->types_mask & BIT(iftype))
660 return data;
661 }
662
663 return NULL;
664 }
665
666 /**
667 * ieee80211_get_he_iftype_cap - return HE capabilities for an sband's iftype
668 * @sband: the sband to search for the iftype on
669 * @iftype: enum nl80211_iftype
670 *
671 * Return: pointer to the struct ieee80211_sta_he_cap, or NULL is none found
672 */
673 static inline const struct ieee80211_sta_he_cap *
ieee80211_get_he_iftype_cap(const struct ieee80211_supported_band * sband,u8 iftype)674 ieee80211_get_he_iftype_cap(const struct ieee80211_supported_band *sband,
675 u8 iftype)
676 {
677 const struct ieee80211_sband_iftype_data *data =
678 ieee80211_get_sband_iftype_data(sband, iftype);
679
680 if (data && data->he_cap.has_he)
681 return &data->he_cap;
682
683 return NULL;
684 }
685
686 /**
687 * ieee80211_get_he_6ghz_capa - return HE 6 GHz capabilities
688 * @sband: the sband to search for the STA on
689 * @iftype: the iftype to search for
690 *
691 * Return: the 6GHz capabilities
692 */
693 static inline __le16
ieee80211_get_he_6ghz_capa(const struct ieee80211_supported_band * sband,enum nl80211_iftype iftype)694 ieee80211_get_he_6ghz_capa(const struct ieee80211_supported_band *sband,
695 enum nl80211_iftype iftype)
696 {
697 const struct ieee80211_sband_iftype_data *data =
698 ieee80211_get_sband_iftype_data(sband, iftype);
699
700 if (WARN_ON(!data || !data->he_cap.has_he))
701 return 0;
702
703 return data->he_6ghz_capa.capa;
704 }
705
706 /**
707 * ieee80211_get_eht_iftype_cap - return EHT capabilities for an sband's iftype
708 * @sband: the sband to search for the iftype on
709 * @iftype: enum nl80211_iftype
710 *
711 * Return: pointer to the struct ieee80211_sta_eht_cap, or NULL is none found
712 */
713 static inline const struct ieee80211_sta_eht_cap *
ieee80211_get_eht_iftype_cap(const struct ieee80211_supported_band * sband,enum nl80211_iftype iftype)714 ieee80211_get_eht_iftype_cap(const struct ieee80211_supported_band *sband,
715 enum nl80211_iftype iftype)
716 {
717 const struct ieee80211_sband_iftype_data *data =
718 ieee80211_get_sband_iftype_data(sband, iftype);
719
720 if (data && data->eht_cap.has_eht)
721 return &data->eht_cap;
722
723 return NULL;
724 }
725
726 /**
727 * ieee80211_get_uhr_iftype_cap - return UHR capabilities for an sband's iftype
728 * @sband: the sband to search for the iftype on
729 * @iftype: enum nl80211_iftype
730 *
731 * Return: pointer to the struct ieee80211_sta_uhr_cap, or NULL is none found
732 */
733 static inline const struct ieee80211_sta_uhr_cap *
ieee80211_get_uhr_iftype_cap(const struct ieee80211_supported_band * sband,enum nl80211_iftype iftype)734 ieee80211_get_uhr_iftype_cap(const struct ieee80211_supported_band *sband,
735 enum nl80211_iftype iftype)
736 {
737 const struct ieee80211_sband_iftype_data *data =
738 ieee80211_get_sband_iftype_data(sband, iftype);
739
740 if (data && data->uhr_cap.has_uhr)
741 return &data->uhr_cap;
742
743 return NULL;
744 }
745
746 /**
747 * wiphy_read_of_freq_limits - read frequency limits from device tree
748 *
749 * @wiphy: the wireless device to get extra limits for
750 *
751 * Some devices may have extra limitations specified in DT. This may be useful
752 * for chipsets that normally support more bands but are limited due to board
753 * design (e.g. by antennas or external power amplifier).
754 *
755 * This function reads info from DT and uses it to *modify* channels (disable
756 * unavailable ones). It's usually a *bad* idea to use it in drivers with
757 * shared channel data as DT limitations are device specific. You should make
758 * sure to call it only if channels in wiphy are copied and can be modified
759 * without affecting other devices.
760 *
761 * As this function access device node it has to be called after set_wiphy_dev.
762 * It also modifies channels so they have to be set first.
763 * If using this helper, call it before wiphy_register().
764 */
765 #ifdef CONFIG_OF
766 void wiphy_read_of_freq_limits(struct wiphy *wiphy);
767 #else /* CONFIG_OF */
wiphy_read_of_freq_limits(struct wiphy * wiphy)768 static inline void wiphy_read_of_freq_limits(struct wiphy *wiphy)
769 {
770 }
771 #endif /* !CONFIG_OF */
772
773
774 /*
775 * Wireless hardware/device configuration structures and methods
776 */
777
778 /**
779 * DOC: Actions and configuration
780 *
781 * Each wireless device and each virtual interface offer a set of configuration
782 * operations and other actions that are invoked by userspace. Each of these
783 * actions is described in the operations structure, and the parameters these
784 * operations use are described separately.
785 *
786 * Additionally, some operations are asynchronous and expect to get status
787 * information via some functions that drivers need to call.
788 *
789 * Scanning and BSS list handling with its associated functionality is described
790 * in a separate chapter.
791 */
792
793 #define VHT_MUMIMO_GROUPS_DATA_LEN (WLAN_MEMBERSHIP_LEN +\
794 WLAN_USER_POSITION_LEN)
795
796 /**
797 * struct vif_params - describes virtual interface parameters
798 * @flags: monitor interface flags, unchanged if 0, otherwise
799 * %MONITOR_FLAG_CHANGED will be set
800 * @use_4addr: use 4-address frames
801 * @macaddr: address to use for this virtual interface.
802 * If this parameter is set to zero address the driver may
803 * determine the address as needed.
804 * This feature is only fully supported by drivers that enable the
805 * %NL80211_FEATURE_MAC_ON_CREATE flag. Others may support creating
806 ** only p2p devices with specified MAC.
807 * @vht_mumimo_groups: MU-MIMO groupID, used for monitoring MU-MIMO packets
808 * belonging to that MU-MIMO groupID; %NULL if not changed
809 * @vht_mumimo_follow_addr: MU-MIMO follow address, used for monitoring
810 * MU-MIMO packets going to the specified station; %NULL if not changed
811 */
812 struct vif_params {
813 u32 flags;
814 int use_4addr;
815 u8 macaddr[ETH_ALEN];
816 const u8 *vht_mumimo_groups;
817 const u8 *vht_mumimo_follow_addr;
818 };
819
820 /**
821 * struct key_params - key information
822 *
823 * Information about a key
824 *
825 * @key: key material
826 * @key_len: length of key material
827 * @cipher: cipher suite selector
828 * @seq: sequence counter (IV/PN), must be in little endian,
829 * length given by @seq_len.
830 * @seq_len: length of @seq.
831 * @vlan_id: vlan_id for VLAN group key (if nonzero)
832 * @mode: key install mode (RX_TX, NO_TX or SET_TX)
833 * @ltf_keyseed: LTF key seed material
834 * @ltf_keyseed_len: length of LTF key seed material
835 */
836 struct key_params {
837 const u8 *key;
838 const u8 *seq;
839 int key_len;
840 int seq_len;
841 u16 vlan_id;
842 u32 cipher;
843 enum nl80211_key_mode mode;
844 const u8 *ltf_keyseed;
845 size_t ltf_keyseed_len;
846 };
847
848 /**
849 * struct cfg80211_chan_def - channel definition
850 * @chan: the (control) channel
851 * @npca_chan: the NPCA primary channel
852 * Note that if DBE is in use, this channel may appear to be
853 * inside the primary half of the chandef. Implementations
854 * can use the position of this channel to understand how
855 * NPCA is used.
856 * @width: channel width
857 * @center_freq1: center frequency of first segment
858 * @center_freq2: center frequency of second segment
859 * (only with 80+80 MHz)
860 * @edmg: define the EDMG channels configuration.
861 * If edmg is requested (i.e. the .channels member is non-zero),
862 * chan will define the primary channel and all other
863 * parameters are ignored.
864 * @freq1_offset: offset from @center_freq1, in KHz
865 * @punctured: mask of the punctured 20 MHz subchannels, with
866 * bits turned on being disabled (punctured); numbered
867 * from lower to higher frequency (like in the spec)
868 * @npca_punctured: NPCA puncturing bitmap, like @punctured but for
869 * NPCA transmissions. If NPCA is used (@npca_chan is not %NULL)
870 * this will be a superset of the @punctured bimap.
871 * Note that if DBE is used, this bitmap is also shifted to be in
872 * accordance with the overall chandef bandwidth.
873 * @s1g_primary_2mhz: Indicates if the control channel pointed to
874 * by 'chan' exists as a 1MHz primary subchannel within an
875 * S1G 2MHz primary channel.
876 */
877 struct cfg80211_chan_def {
878 struct ieee80211_channel *chan;
879 struct ieee80211_channel *npca_chan;
880 enum nl80211_chan_width width;
881 u32 center_freq1;
882 u32 center_freq2;
883 struct ieee80211_edmg edmg;
884 u16 freq1_offset;
885 u16 punctured, npca_punctured;
886 bool s1g_primary_2mhz;
887 };
888
889 /*
890 * cfg80211_bitrate_mask - masks for bitrate control
891 */
892 struct cfg80211_bitrate_mask {
893 struct {
894 u32 legacy;
895 u8 ht_mcs[IEEE80211_HT_MCS_MASK_LEN];
896 u16 vht_mcs[NL80211_VHT_NSS_MAX];
897 u16 he_mcs[NL80211_HE_NSS_MAX];
898 u16 eht_mcs[NL80211_EHT_NSS_MAX];
899 enum nl80211_txrate_gi gi;
900 enum nl80211_he_gi he_gi;
901 enum nl80211_eht_gi eht_gi;
902 enum nl80211_he_ltf he_ltf;
903 enum nl80211_eht_ltf eht_ltf;
904 } control[NUM_NL80211_BANDS];
905 };
906
907
908 /**
909 * struct cfg80211_tid_cfg - TID specific configuration
910 * @config_override: Flag to notify driver to reset TID configuration
911 * of the peer.
912 * @tids: bitmap of TIDs to modify
913 * @mask: bitmap of attributes indicating which parameter changed,
914 * similar to &nl80211_tid_config_supp.
915 * @noack: noack configuration value for the TID
916 * @retry_long: retry count value
917 * @retry_short: retry count value
918 * @ampdu: Enable/Disable MPDU aggregation
919 * @rtscts: Enable/Disable RTS/CTS
920 * @amsdu: Enable/Disable MSDU aggregation
921 * @txrate_type: Tx bitrate mask type
922 * @txrate_mask: Tx bitrate to be applied for the TID
923 */
924 struct cfg80211_tid_cfg {
925 bool config_override;
926 u8 tids;
927 u64 mask;
928 enum nl80211_tid_config noack;
929 u8 retry_long, retry_short;
930 enum nl80211_tid_config ampdu;
931 enum nl80211_tid_config rtscts;
932 enum nl80211_tid_config amsdu;
933 enum nl80211_tx_rate_setting txrate_type;
934 struct cfg80211_bitrate_mask txrate_mask;
935 };
936
937 /**
938 * struct cfg80211_tid_config - TID configuration
939 * @peer: Station's MAC address
940 * @n_tid_conf: Number of TID specific configurations to be applied
941 * @tid_conf: Configuration change info
942 */
943 struct cfg80211_tid_config {
944 const u8 *peer;
945 u32 n_tid_conf;
946 struct cfg80211_tid_cfg tid_conf[] __counted_by(n_tid_conf);
947 };
948
949 /**
950 * struct cfg80211_fils_aad - FILS AAD data
951 * @macaddr: STA MAC address
952 * @kek: FILS KEK
953 * @kek_len: FILS KEK length
954 * @snonce: STA Nonce
955 * @anonce: AP Nonce
956 */
957 struct cfg80211_fils_aad {
958 const u8 *macaddr;
959 const u8 *kek;
960 u8 kek_len;
961 const u8 *snonce;
962 const u8 *anonce;
963 };
964
965 /**
966 * struct cfg80211_set_hw_timestamp - enable/disable HW timestamping
967 * @macaddr: peer MAC address. NULL to enable/disable HW timestamping for all
968 * addresses.
969 * @enable: if set, enable HW timestamping for the specified MAC address.
970 * Otherwise disable HW timestamping for the specified MAC address.
971 */
972 struct cfg80211_set_hw_timestamp {
973 const u8 *macaddr;
974 bool enable;
975 };
976
977 /**
978 * cfg80211_get_chandef_type - return old channel type from chandef
979 * @chandef: the channel definition
980 *
981 * Return: The old channel type (NOHT, HT20, HT40+/-) from a given
982 * chandef, which must have a bandwidth allowing this conversion.
983 */
984 static inline enum nl80211_channel_type
cfg80211_get_chandef_type(const struct cfg80211_chan_def * chandef)985 cfg80211_get_chandef_type(const struct cfg80211_chan_def *chandef)
986 {
987 switch (chandef->width) {
988 case NL80211_CHAN_WIDTH_20_NOHT:
989 return NL80211_CHAN_NO_HT;
990 case NL80211_CHAN_WIDTH_20:
991 return NL80211_CHAN_HT20;
992 case NL80211_CHAN_WIDTH_40:
993 if (chandef->center_freq1 > chandef->chan->center_freq)
994 return NL80211_CHAN_HT40PLUS;
995 return NL80211_CHAN_HT40MINUS;
996 default:
997 WARN_ON(1);
998 return NL80211_CHAN_NO_HT;
999 }
1000 }
1001
1002 /**
1003 * cfg80211_chandef_create - create channel definition using channel type
1004 * @chandef: the channel definition struct to fill
1005 * @channel: the control channel
1006 * @chantype: the channel type
1007 *
1008 * Given a channel type, create a channel definition.
1009 */
1010 void cfg80211_chandef_create(struct cfg80211_chan_def *chandef,
1011 struct ieee80211_channel *channel,
1012 enum nl80211_channel_type chantype);
1013
1014 /**
1015 * cfg80211_chandef_identical - check if two channel definitions are identical
1016 * @chandef1: first channel definition
1017 * @chandef2: second channel definition
1018 *
1019 * Return: %true if the channels defined by the channel definitions are
1020 * identical, %false otherwise.
1021 */
1022 static inline bool
cfg80211_chandef_identical(const struct cfg80211_chan_def * chandef1,const struct cfg80211_chan_def * chandef2)1023 cfg80211_chandef_identical(const struct cfg80211_chan_def *chandef1,
1024 const struct cfg80211_chan_def *chandef2)
1025 {
1026 return (chandef1->chan == chandef2->chan &&
1027 chandef1->width == chandef2->width &&
1028 chandef1->center_freq1 == chandef2->center_freq1 &&
1029 chandef1->freq1_offset == chandef2->freq1_offset &&
1030 chandef1->center_freq2 == chandef2->center_freq2 &&
1031 chandef1->punctured == chandef2->punctured &&
1032 chandef1->s1g_primary_2mhz == chandef2->s1g_primary_2mhz &&
1033 chandef1->npca_chan == chandef2->npca_chan &&
1034 chandef1->npca_punctured == chandef2->npca_punctured);
1035 }
1036
1037 /**
1038 * cfg80211_chandef_is_edmg - check if chandef represents an EDMG channel
1039 *
1040 * @chandef: the channel definition
1041 *
1042 * Return: %true if EDMG defined, %false otherwise.
1043 */
1044 static inline bool
cfg80211_chandef_is_edmg(const struct cfg80211_chan_def * chandef)1045 cfg80211_chandef_is_edmg(const struct cfg80211_chan_def *chandef)
1046 {
1047 return chandef->edmg.channels || chandef->edmg.bw_config;
1048 }
1049
1050 /**
1051 * cfg80211_chandef_is_s1g - check if chandef represents an S1G channel
1052 * @chandef: the channel definition
1053 *
1054 * Return: %true if S1G.
1055 */
1056 static inline bool
cfg80211_chandef_is_s1g(const struct cfg80211_chan_def * chandef)1057 cfg80211_chandef_is_s1g(const struct cfg80211_chan_def *chandef)
1058 {
1059 return chandef->chan->band == NL80211_BAND_S1GHZ;
1060 }
1061
1062 /**
1063 * cfg80211_chandef_compatible - check if two channel definitions are compatible
1064 * @chandef1: first channel definition
1065 * @chandef2: second channel definition
1066 *
1067 * Return: %NULL if the given channel definitions are incompatible,
1068 * chandef1 or chandef2 otherwise.
1069 */
1070 const struct cfg80211_chan_def *
1071 cfg80211_chandef_compatible(const struct cfg80211_chan_def *chandef1,
1072 const struct cfg80211_chan_def *chandef2);
1073
1074
1075 /**
1076 * nl80211_chan_width_to_mhz - get the channel width in MHz
1077 * @chan_width: the channel width from &enum nl80211_chan_width
1078 *
1079 * Return: channel width in MHz if the chan_width from &enum nl80211_chan_width
1080 * is valid. -1 otherwise.
1081 */
1082 int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width);
1083
1084 /**
1085 * cfg80211_chandef_get_width - return chandef width in MHz
1086 * @c: chandef to return bandwidth for
1087 * Return: channel width in MHz for the given chandef; note that it returns
1088 * 80 for 80+80 configurations
1089 */
cfg80211_chandef_get_width(const struct cfg80211_chan_def * c)1090 static inline int cfg80211_chandef_get_width(const struct cfg80211_chan_def *c)
1091 {
1092 return nl80211_chan_width_to_mhz(c->width);
1093 }
1094
1095 /**
1096 * cfg80211_chandef_valid - check if a channel definition is valid
1097 * @chandef: the channel definition to check
1098 * Return: %true if the channel definition is valid. %false otherwise.
1099 */
1100 bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef);
1101
1102 /**
1103 * cfg80211_chandef_usable - check if secondary channels can be used
1104 * @wiphy: the wiphy to validate against
1105 * @chandef: the channel definition to check
1106 * @prohibited_flags: the regulatory channel flags that must not be set
1107 * Return: %true if secondary channels are usable. %false otherwise.
1108 */
1109 bool cfg80211_chandef_usable(struct wiphy *wiphy,
1110 const struct cfg80211_chan_def *chandef,
1111 u32 prohibited_flags);
1112
1113 /**
1114 * cfg80211_chandef_dfs_required - checks if radar detection is required
1115 * @wiphy: the wiphy to validate against
1116 * @chandef: the channel definition to check
1117 * @iftype: the interface type as specified in &enum nl80211_iftype
1118 * Returns:
1119 * 1 if radar detection is required, 0 if it is not, < 0 on error
1120 */
1121 int cfg80211_chandef_dfs_required(struct wiphy *wiphy,
1122 const struct cfg80211_chan_def *chandef,
1123 enum nl80211_iftype iftype);
1124
1125 /**
1126 * cfg80211_chandef_dfs_usable - checks if chandef is DFS usable and we
1127 * can/need start CAC on such channel
1128 * @wiphy: the wiphy to validate against
1129 * @chandef: the channel definition to check
1130 *
1131 * Return: true if all channels available and at least
1132 * one channel requires CAC (NL80211_DFS_USABLE)
1133 */
1134 bool cfg80211_chandef_dfs_usable(struct wiphy *wiphy,
1135 const struct cfg80211_chan_def *chandef);
1136
1137 /**
1138 * cfg80211_chandef_dfs_cac_time - get the DFS CAC time (in ms) for given
1139 * channel definition
1140 * @wiphy: the wiphy to validate against
1141 * @chandef: the channel definition to check
1142 *
1143 * Returns: DFS CAC time (in ms) which applies for this channel definition
1144 */
1145 unsigned int
1146 cfg80211_chandef_dfs_cac_time(struct wiphy *wiphy,
1147 const struct cfg80211_chan_def *chandef);
1148
1149 /**
1150 * cfg80211_chandef_primary - calculate primary 40/80/160 MHz freq
1151 * @chandef: chandef to calculate for
1152 * @primary_chan_width: primary channel width to calculate center for
1153 * @punctured: punctured sub-channel bitmap, will be recalculated
1154 * according to the new bandwidth, can be %NULL
1155 *
1156 * Returns: the primary 40/80/160 MHz channel center frequency, or -1
1157 * for errors, updating the punctured bitmap
1158 */
1159 int cfg80211_chandef_primary(const struct cfg80211_chan_def *chandef,
1160 enum nl80211_chan_width primary_chan_width,
1161 u16 *punctured);
1162
1163 /**
1164 * cfg80211_chandef_npca_valid - check that NPCA information is valid
1165 * @wiphy: the wiphy to check for, for channel pointer lookup
1166 * @chandef: the BSS channel chandef to check against
1167 * @npca: NPCA information, can be %NULL in which case this
1168 * always returns %true
1169 *
1170 * Note that DBE must not have been configured into the chandef yet
1171 * before checking NPCA, i.e. @chandef must represent the BSS channel.
1172 *
1173 * Returns: %true if the NPCA channel and puncturing bitmap are valid
1174 * according to the chandef, %false otherwise
1175 */
1176 bool cfg80211_chandef_npca_valid(struct wiphy *wiphy,
1177 const struct cfg80211_chan_def *chandef,
1178 const struct ieee80211_uhr_npca_info *npca);
1179
1180 /**
1181 * cfg80211_chandef_add_npca - parse and add NPCA information to chandef
1182 * @wiphy: the wiphy this will be used for, for channel pointer lookup
1183 * @chandef: the chandef to modify, must be a valid chandef without NPCA
1184 * @npca: the NPCA information, can be %NULL
1185 *
1186 * Returns: 0 if the NPCA information was added and the resulting
1187 * chandef is valid, a negative error code on errors
1188 */
1189 int cfg80211_chandef_add_npca(struct wiphy *wiphy,
1190 struct cfg80211_chan_def *chandef,
1191 const struct ieee80211_uhr_npca_info *npca);
1192
1193 /**
1194 * cfg80211_chandef_add_dbe - parse and add DBE information to chandef
1195 * @chandef: the chandef to expand
1196 * @dbe: the DBE information, must be size-checked if not %NULL
1197 *
1198 * Returns: 0 for success, a negative error code otherwise
1199 */
1200 int cfg80211_chandef_add_dbe(struct cfg80211_chan_def *chandef,
1201 const struct ieee80211_uhr_dbe_info *dbe);
1202
1203 /**
1204 * nl80211_send_chandef - sends the channel definition.
1205 * @msg: the msg to send channel definition
1206 * @chandef: the channel definition to check
1207 *
1208 * Returns: 0 if sent the channel definition to msg, < 0 on error
1209 **/
1210 int nl80211_send_chandef(struct sk_buff *msg, const struct cfg80211_chan_def *chandef);
1211
1212 /**
1213 * ieee80211_chandef_max_power - maximum transmission power for the chandef
1214 *
1215 * In some regulations, the transmit power may depend on the configured channel
1216 * bandwidth which may be defined as dBm/MHz. This function returns the actual
1217 * max_power for non-standard (20 MHz) channels.
1218 *
1219 * @chandef: channel definition for the channel
1220 *
1221 * Returns: maximum allowed transmission power in dBm for the chandef
1222 */
1223 static inline int
ieee80211_chandef_max_power(struct cfg80211_chan_def * chandef)1224 ieee80211_chandef_max_power(struct cfg80211_chan_def *chandef)
1225 {
1226 switch (chandef->width) {
1227 case NL80211_CHAN_WIDTH_5:
1228 return min(chandef->chan->max_reg_power - 6,
1229 chandef->chan->max_power);
1230 case NL80211_CHAN_WIDTH_10:
1231 return min(chandef->chan->max_reg_power - 3,
1232 chandef->chan->max_power);
1233 default:
1234 break;
1235 }
1236 return chandef->chan->max_power;
1237 }
1238
1239 /**
1240 * cfg80211_chandef_s1g_pri_width - return S1G primary width in MHz
1241 *
1242 * An S1G interface may have a primary channel width of either 1
1243 * or 2MHz depending on whether chandef::s1g_primary_2mhz is set.
1244 *
1245 * Note: There is _always_ a 1MHz primary subchannel, regardless
1246 * of the primary width. So chandef::chan always points to this
1247 * 1MHz primary channel.
1248 *
1249 * @chandef: the chandef to use
1250 *
1251 * Returns: width in MHz of the S1G primary channel in use
1252 */
1253 static inline int
cfg80211_chandef_s1g_pri_width(struct cfg80211_chan_def * chandef)1254 cfg80211_chandef_s1g_pri_width(struct cfg80211_chan_def *chandef)
1255 {
1256 return chandef->s1g_primary_2mhz ? 2 : 1;
1257 }
1258
1259 /**
1260 * cfg80211_any_usable_channels - check for usable channels
1261 * @wiphy: the wiphy to check for
1262 * @band_mask: which bands to check on
1263 * @prohibited_flags: which channels to not consider usable,
1264 * %IEEE80211_CHAN_DISABLED is always taken into account
1265 *
1266 * Return: %true if usable channels found, %false otherwise
1267 */
1268 bool cfg80211_any_usable_channels(struct wiphy *wiphy,
1269 unsigned long band_mask,
1270 u32 prohibited_flags);
1271
1272 /**
1273 * enum survey_info_flags - survey information flags
1274 *
1275 * @SURVEY_INFO_NOISE_DBM: noise (in dBm) was filled in
1276 * @SURVEY_INFO_IN_USE: channel is currently being used
1277 * @SURVEY_INFO_TIME: active time (in ms) was filled in
1278 * @SURVEY_INFO_TIME_BUSY: busy time was filled in
1279 * @SURVEY_INFO_TIME_EXT_BUSY: extension channel busy time was filled in
1280 * @SURVEY_INFO_TIME_RX: receive time was filled in
1281 * @SURVEY_INFO_TIME_TX: transmit time was filled in
1282 * @SURVEY_INFO_TIME_SCAN: scan time was filled in
1283 * @SURVEY_INFO_TIME_BSS_RX: local BSS receive time was filled in
1284 *
1285 * Used by the driver to indicate which info in &struct survey_info
1286 * it has filled in during the get_survey().
1287 */
1288 enum survey_info_flags {
1289 SURVEY_INFO_NOISE_DBM = BIT(0),
1290 SURVEY_INFO_IN_USE = BIT(1),
1291 SURVEY_INFO_TIME = BIT(2),
1292 SURVEY_INFO_TIME_BUSY = BIT(3),
1293 SURVEY_INFO_TIME_EXT_BUSY = BIT(4),
1294 SURVEY_INFO_TIME_RX = BIT(5),
1295 SURVEY_INFO_TIME_TX = BIT(6),
1296 SURVEY_INFO_TIME_SCAN = BIT(7),
1297 SURVEY_INFO_TIME_BSS_RX = BIT(8),
1298 };
1299
1300 /**
1301 * struct survey_info - channel survey response
1302 *
1303 * @channel: the channel this survey record reports, may be %NULL for a single
1304 * record to report global statistics
1305 * @filled: bitflag of flags from &enum survey_info_flags
1306 * @noise: channel noise in dBm. This and all following fields are
1307 * optional
1308 * @time: amount of time in ms the radio was turn on (on the channel)
1309 * @time_busy: amount of time the primary channel was sensed busy
1310 * @time_ext_busy: amount of time the extension channel was sensed busy
1311 * @time_rx: amount of time the radio spent receiving data
1312 * @time_tx: amount of time the radio spent transmitting data
1313 * @time_scan: amount of time the radio spent for scanning
1314 * @time_bss_rx: amount of time the radio spent receiving data on a local BSS
1315 *
1316 * Used by dump_survey() to report back per-channel survey information.
1317 *
1318 * This structure can later be expanded with things like
1319 * channel duty cycle etc.
1320 */
1321 struct survey_info {
1322 struct ieee80211_channel *channel;
1323 u64 time;
1324 u64 time_busy;
1325 u64 time_ext_busy;
1326 u64 time_rx;
1327 u64 time_tx;
1328 u64 time_scan;
1329 u64 time_bss_rx;
1330 u32 filled;
1331 s8 noise;
1332 };
1333
1334 #define CFG80211_MAX_NUM_AKM_SUITES 10
1335
1336 /**
1337 * struct cfg80211_crypto_settings - Crypto settings
1338 * @wpa_versions: indicates which, if any, WPA versions are enabled
1339 * (from enum nl80211_wpa_versions)
1340 * @cipher_group: group key cipher suite (or 0 if unset)
1341 * @n_ciphers_pairwise: number of AP supported unicast ciphers
1342 * @ciphers_pairwise: unicast key cipher suites
1343 * @n_akm_suites: number of AKM suites
1344 * @akm_suites: AKM suites
1345 * @control_port: Whether user space controls IEEE 802.1X port, i.e.,
1346 * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is
1347 * required to assume that the port is unauthorized until authorized by
1348 * user space. Otherwise, port is marked authorized by default.
1349 * @control_port_ethertype: the control port protocol that should be
1350 * allowed through even on unauthorized ports
1351 * @control_port_no_encrypt: TRUE to prevent encryption of control port
1352 * protocol frames.
1353 * @control_port_over_nl80211: TRUE if userspace expects to exchange control
1354 * port frames over NL80211 instead of the network interface.
1355 * @control_port_no_preauth: disables pre-auth rx over the nl80211 control
1356 * port for mac80211
1357 * @psk: PSK (for devices supporting 4-way-handshake offload)
1358 * @sae_pwd: password for SAE authentication (for devices supporting SAE
1359 * offload)
1360 * @sae_pwd_len: length of SAE password (for devices supporting SAE offload)
1361 * @sae_pwe: The mechanisms allowed for SAE PWE derivation:
1362 *
1363 * NL80211_SAE_PWE_UNSPECIFIED
1364 * Not-specified, used to indicate userspace did not specify any
1365 * preference. The driver should follow its internal policy in
1366 * such a scenario.
1367 *
1368 * NL80211_SAE_PWE_HUNT_AND_PECK
1369 * Allow hunting-and-pecking loop only
1370 *
1371 * NL80211_SAE_PWE_HASH_TO_ELEMENT
1372 * Allow hash-to-element only
1373 *
1374 * NL80211_SAE_PWE_BOTH
1375 * Allow either hunting-and-pecking loop or hash-to-element
1376 */
1377 struct cfg80211_crypto_settings {
1378 u32 wpa_versions;
1379 u32 cipher_group;
1380 int n_ciphers_pairwise;
1381 u32 ciphers_pairwise[NL80211_MAX_NR_CIPHER_SUITES];
1382 int n_akm_suites;
1383 u32 akm_suites[CFG80211_MAX_NUM_AKM_SUITES];
1384 bool control_port;
1385 __be16 control_port_ethertype;
1386 bool control_port_no_encrypt;
1387 bool control_port_over_nl80211;
1388 bool control_port_no_preauth;
1389 const u8 *psk;
1390 const u8 *sae_pwd;
1391 u8 sae_pwd_len;
1392 enum nl80211_sae_pwe_mechanism sae_pwe;
1393 };
1394
1395 /**
1396 * struct cfg80211_mbssid_config - AP settings for multi bssid
1397 *
1398 * @tx_wdev: pointer to the transmitted interface in the MBSSID set
1399 * @tx_link_id: link ID of the transmitted profile in an MLD.
1400 * @index: index of this AP in the multi bssid group.
1401 * @ema: set to true if the beacons should be sent out in EMA mode.
1402 */
1403 struct cfg80211_mbssid_config {
1404 struct wireless_dev *tx_wdev;
1405 u8 tx_link_id;
1406 u8 index;
1407 bool ema;
1408 };
1409
1410 /**
1411 * struct cfg80211_mbssid_elems - Multiple BSSID elements
1412 *
1413 * @cnt: Number of elements in array %elems.
1414 *
1415 * @elem: Array of multiple BSSID element(s) to be added into Beacon frames.
1416 * @elem.data: Data for multiple BSSID elements.
1417 * @elem.len: Length of data.
1418 */
1419 struct cfg80211_mbssid_elems {
1420 u8 cnt;
1421 struct {
1422 const u8 *data;
1423 size_t len;
1424 } elem[] __counted_by(cnt);
1425 };
1426
1427 /**
1428 * struct cfg80211_rnr_elems - Reduced neighbor report (RNR) elements
1429 *
1430 * @cnt: Number of elements in array %elems.
1431 *
1432 * @elem: Array of RNR element(s) to be added into Beacon frames.
1433 * @elem.data: Data for RNR elements.
1434 * @elem.len: Length of data.
1435 */
1436 struct cfg80211_rnr_elems {
1437 u8 cnt;
1438 struct {
1439 const u8 *data;
1440 size_t len;
1441 } elem[] __counted_by(cnt);
1442 };
1443
1444 /**
1445 * struct cfg80211_beacon_data - beacon data
1446 * @link_id: the link ID for the AP MLD link sending this beacon
1447 * @head: head portion of beacon (before TIM IE)
1448 * or %NULL if not changed
1449 * @tail: tail portion of beacon (after TIM IE)
1450 * or %NULL if not changed
1451 * @head_len: length of @head
1452 * @tail_len: length of @tail
1453 * @beacon_ies: extra information element(s) to add into Beacon frames or %NULL
1454 * @beacon_ies_len: length of beacon_ies in octets
1455 * @proberesp_ies: extra information element(s) to add into Probe Response
1456 * frames or %NULL
1457 * @proberesp_ies_len: length of proberesp_ies in octets
1458 * @assocresp_ies: extra information element(s) to add into (Re)Association
1459 * Response frames or %NULL
1460 * @assocresp_ies_len: length of assocresp_ies in octets
1461 * @probe_resp_len: length of probe response template (@probe_resp)
1462 * @probe_resp: probe response template (AP mode only)
1463 * @mbssid_ies: multiple BSSID elements
1464 * @rnr_ies: reduced neighbor report elements
1465 * @ftm_responder: enable FTM responder functionality; -1 for no change
1466 * (which also implies no change in LCI/civic location data)
1467 * @lci: Measurement Report element content, starting with Measurement Token
1468 * (measurement type 8)
1469 * @civicloc: Measurement Report element content, starting with Measurement
1470 * Token (measurement type 11)
1471 * @lci_len: LCI data length
1472 * @civicloc_len: Civic location data length
1473 * @he_bss_color: BSS Color settings
1474 * @he_bss_color_valid: indicates whether bss color
1475 * attribute is present in beacon data or not.
1476 * @ht_required: stations must support HT
1477 * @vht_required: stations must support VHT
1478 * @ht_oper: HT operation element (or %NULL if HT isn't enabled)
1479 * @vht_oper: VHT operation element (or %NULL if VHT isn't enabled)
1480 * @he_oper: HE operation IE (or %NULL if HE isn't enabled)
1481 * @eht_oper: EHT operation IE (or %NULL if EHT isn't enabled)
1482 * @uhr_oper: UHR operation (or %NULL if UHR isn't enabled)
1483 */
1484 struct cfg80211_beacon_data {
1485 unsigned int link_id;
1486
1487 const u8 *head, *tail;
1488 const u8 *beacon_ies;
1489 const u8 *proberesp_ies;
1490 const u8 *assocresp_ies;
1491 const u8 *probe_resp;
1492 const u8 *lci;
1493 const u8 *civicloc;
1494 struct cfg80211_mbssid_elems *mbssid_ies;
1495 struct cfg80211_rnr_elems *rnr_ies;
1496 s8 ftm_responder;
1497
1498 size_t head_len, tail_len;
1499 size_t beacon_ies_len;
1500 size_t proberesp_ies_len;
1501 size_t assocresp_ies_len;
1502 size_t probe_resp_len;
1503 size_t lci_len;
1504 size_t civicloc_len;
1505 struct cfg80211_he_bss_color he_bss_color;
1506 bool he_bss_color_valid;
1507
1508 bool ht_required, vht_required;
1509 const struct ieee80211_ht_operation *ht_oper;
1510 const struct ieee80211_vht_operation *vht_oper;
1511 const struct ieee80211_he_operation *he_oper;
1512 const struct ieee80211_eht_operation *eht_oper;
1513 const struct ieee80211_uhr_operation *uhr_oper;
1514 };
1515
1516 struct mac_address {
1517 u8 addr[ETH_ALEN];
1518 };
1519
1520 /**
1521 * struct cfg80211_acl_data - Access control list data
1522 *
1523 * @acl_policy: ACL policy to be applied on the station's
1524 * entry specified by mac_addr
1525 * @n_acl_entries: Number of MAC address entries passed
1526 * @mac_addrs: List of MAC addresses of stations to be used for ACL
1527 */
1528 struct cfg80211_acl_data {
1529 enum nl80211_acl_policy acl_policy;
1530 int n_acl_entries;
1531
1532 /* Keep it last */
1533 struct mac_address mac_addrs[] __counted_by(n_acl_entries);
1534 };
1535
1536 /**
1537 * struct cfg80211_fils_discovery - FILS discovery parameters from
1538 * IEEE Std 802.11ai-2016, Annex C.3 MIB detail.
1539 *
1540 * @update: Set to true if the feature configuration should be updated.
1541 * @min_interval: Minimum packet interval in TUs (0 - 10000)
1542 * @max_interval: Maximum packet interval in TUs (0 - 10000)
1543 * @tmpl_len: Template length
1544 * @tmpl: Template data for FILS discovery frame including the action
1545 * frame headers.
1546 */
1547 struct cfg80211_fils_discovery {
1548 bool update;
1549 u32 min_interval;
1550 u32 max_interval;
1551 size_t tmpl_len;
1552 const u8 *tmpl;
1553 };
1554
1555 /**
1556 * struct cfg80211_unsol_bcast_probe_resp - Unsolicited broadcast probe
1557 * response parameters in 6GHz.
1558 *
1559 * @update: Set to true if the feature configuration should be updated.
1560 * @interval: Packet interval in TUs. Maximum allowed is 20 TU, as mentioned
1561 * in IEEE P802.11ax/D6.0 26.17.2.3.2 - AP behavior for fast passive
1562 * scanning
1563 * @tmpl_len: Template length
1564 * @tmpl: Template data for probe response
1565 */
1566 struct cfg80211_unsol_bcast_probe_resp {
1567 bool update;
1568 u32 interval;
1569 size_t tmpl_len;
1570 const u8 *tmpl;
1571 };
1572
1573 /**
1574 * struct cfg80211_s1g_short_beacon - S1G short beacon data.
1575 *
1576 * @update: Set to true if the feature configuration should be updated.
1577 * @short_head: Short beacon head.
1578 * @short_tail: Short beacon tail.
1579 * @short_head_len: Short beacon head len.
1580 * @short_tail_len: Short beacon tail len.
1581 */
1582 struct cfg80211_s1g_short_beacon {
1583 bool update;
1584 const u8 *short_head;
1585 const u8 *short_tail;
1586 size_t short_head_len;
1587 size_t short_tail_len;
1588 };
1589
1590 /**
1591 * struct cfg80211_ap_settings - AP configuration
1592 *
1593 * Used to configure an AP interface.
1594 *
1595 * @chandef: defines the channel to use
1596 * @beacon: beacon data
1597 * @beacon_interval: beacon interval
1598 * @dtim_period: DTIM period
1599 * @ssid: SSID to be used in the BSS (note: may be %NULL if not provided from
1600 * user space)
1601 * @ssid_len: length of @ssid
1602 * @hidden_ssid: whether to hide the SSID in Beacon/Probe Response frames
1603 * @crypto: crypto settings
1604 * @privacy: the BSS uses privacy
1605 * @auth_type: Authentication type (algorithm)
1606 * @inactivity_timeout: time in seconds to determine station's inactivity.
1607 * @p2p_ctwindow: P2P CT Window
1608 * @p2p_opp_ps: P2P opportunistic PS
1609 * @acl: ACL configuration used by the drivers which has support for
1610 * MAC address based access control
1611 * @pbss: If set, start as a PCP instead of AP. Relevant for DMG
1612 * networks.
1613 * @beacon_rate: bitrate to be used for beacons
1614 * @ht_cap: HT capabilities (or %NULL if HT isn't enabled)
1615 * @vht_cap: VHT capabilities (or %NULL if VHT isn't enabled)
1616 * @he_cap: HE capabilities (or %NULL if HE isn't enabled)
1617 * @eht_cap: EHT capabilities (or %NULL if EHT isn't enabled)
1618 * @twt_responder: Enable Target Wait Time
1619 * @flags: flags, as defined in &enum nl80211_ap_settings_flags
1620 * @he_obss_pd: OBSS Packet Detection settings
1621 * @fils_discovery: FILS discovery transmission parameters
1622 * @unsol_bcast_probe_resp: Unsolicited broadcast probe response parameters
1623 * @mbssid_config: AP settings for multiple bssid
1624 * @s1g_long_beacon_period: S1G long beacon period
1625 * @s1g_short_beacon: S1G short beacon data
1626 */
1627 struct cfg80211_ap_settings {
1628 struct cfg80211_chan_def chandef;
1629
1630 struct cfg80211_beacon_data beacon;
1631
1632 int beacon_interval, dtim_period;
1633 const u8 *ssid;
1634 size_t ssid_len;
1635 enum nl80211_hidden_ssid hidden_ssid;
1636 struct cfg80211_crypto_settings crypto;
1637 bool privacy;
1638 enum nl80211_auth_type auth_type;
1639 int inactivity_timeout;
1640 u8 p2p_ctwindow;
1641 bool p2p_opp_ps;
1642 const struct cfg80211_acl_data *acl;
1643 bool pbss;
1644 struct cfg80211_bitrate_mask beacon_rate;
1645
1646 const struct ieee80211_ht_cap *ht_cap;
1647 const struct ieee80211_vht_cap *vht_cap;
1648 const struct ieee80211_he_cap_elem *he_cap;
1649 const struct ieee80211_eht_cap_elem *eht_cap;
1650 bool twt_responder;
1651 u32 flags;
1652 struct ieee80211_he_obss_pd he_obss_pd;
1653 struct cfg80211_fils_discovery fils_discovery;
1654 struct cfg80211_unsol_bcast_probe_resp unsol_bcast_probe_resp;
1655 struct cfg80211_mbssid_config mbssid_config;
1656 u8 s1g_long_beacon_period;
1657 struct cfg80211_s1g_short_beacon s1g_short_beacon;
1658 };
1659
1660
1661 /**
1662 * struct cfg80211_ap_update - AP configuration update
1663 *
1664 * Subset of &struct cfg80211_ap_settings, for updating a running AP.
1665 *
1666 * @beacon: beacon data
1667 * @fils_discovery: FILS discovery transmission parameters
1668 * @unsol_bcast_probe_resp: Unsolicited broadcast probe response parameters
1669 * @s1g_short_beacon: S1G short beacon data
1670 */
1671 struct cfg80211_ap_update {
1672 struct cfg80211_beacon_data beacon;
1673 struct cfg80211_fils_discovery fils_discovery;
1674 struct cfg80211_unsol_bcast_probe_resp unsol_bcast_probe_resp;
1675 struct cfg80211_s1g_short_beacon s1g_short_beacon;
1676 };
1677
1678 /**
1679 * struct cfg80211_csa_settings - channel switch settings
1680 *
1681 * Used for channel switch
1682 *
1683 * @chandef: defines the channel to use after the switch
1684 * @beacon_csa: beacon data while performing the switch
1685 * @counter_offsets_beacon: offsets of the counters within the beacon (tail)
1686 * @counter_offsets_presp: offsets of the counters within the probe response
1687 * @n_counter_offsets_beacon: number of csa counters the beacon (tail)
1688 * @n_counter_offsets_presp: number of csa counters in the probe response
1689 * @beacon_after: beacon data to be used on the new channel
1690 * @unsol_bcast_probe_resp: Unsolicited broadcast probe response parameters
1691 * @radar_required: whether radar detection is required on the new channel
1692 * @block_tx: whether transmissions should be blocked while changing
1693 * @count: number of beacons until switch
1694 * @link_id: defines the link on which channel switch is expected during
1695 * MLO. 0 in case of non-MLO.
1696 */
1697 struct cfg80211_csa_settings {
1698 struct cfg80211_chan_def chandef;
1699 struct cfg80211_beacon_data beacon_csa;
1700 const u16 *counter_offsets_beacon;
1701 const u16 *counter_offsets_presp;
1702 unsigned int n_counter_offsets_beacon;
1703 unsigned int n_counter_offsets_presp;
1704 struct cfg80211_beacon_data beacon_after;
1705 struct cfg80211_unsol_bcast_probe_resp unsol_bcast_probe_resp;
1706 bool radar_required;
1707 bool block_tx;
1708 u8 count;
1709 u8 link_id;
1710 };
1711
1712 /**
1713 * struct cfg80211_color_change_settings - color change settings
1714 *
1715 * Used for bss color change
1716 *
1717 * @beacon_color_change: beacon data while performing the color countdown
1718 * @counter_offset_beacon: offsets of the counters within the beacon (tail)
1719 * @counter_offset_presp: offsets of the counters within the probe response
1720 * @beacon_next: beacon data to be used after the color change
1721 * @unsol_bcast_probe_resp: Unsolicited broadcast probe response parameters
1722 * @count: number of beacons until the color change
1723 * @color: the color used after the change
1724 * @link_id: defines the link on which color change is expected during MLO.
1725 * 0 in case of non-MLO.
1726 */
1727 struct cfg80211_color_change_settings {
1728 struct cfg80211_beacon_data beacon_color_change;
1729 u16 counter_offset_beacon;
1730 u16 counter_offset_presp;
1731 struct cfg80211_beacon_data beacon_next;
1732 struct cfg80211_unsol_bcast_probe_resp unsol_bcast_probe_resp;
1733 u8 count;
1734 u8 color;
1735 u8 link_id;
1736 };
1737
1738 /**
1739 * struct iface_combination_params - input parameters for interface combinations
1740 *
1741 * Used to pass interface combination parameters
1742 *
1743 * @radio_idx: wiphy radio index or -1 for global
1744 * @num_different_channels: the number of different channels we want
1745 * to use for verification
1746 * @radar_detect: a bitmap where each bit corresponds to a channel
1747 * width where radar detection is needed, as in the definition of
1748 * &struct ieee80211_iface_combination.@radar_detect_widths
1749 * @iftype_num: array with the number of interfaces of each interface
1750 * type. The index is the interface type as specified in &enum
1751 * nl80211_iftype.
1752 * @new_beacon_int: set this to the beacon interval of a new interface
1753 * that's not operating yet, if such is to be checked as part of
1754 * the verification
1755 */
1756 struct iface_combination_params {
1757 int radio_idx;
1758 int num_different_channels;
1759 u8 radar_detect;
1760 int iftype_num[NUM_NL80211_IFTYPES];
1761 u32 new_beacon_int;
1762 };
1763
1764 /**
1765 * enum station_parameters_apply_mask - station parameter values to apply
1766 * @STATION_PARAM_APPLY_UAPSD: apply new uAPSD parameters (uapsd_queues, max_sp)
1767 * @STATION_PARAM_APPLY_CAPABILITY: apply new capability
1768 * @STATION_PARAM_APPLY_PLINK_STATE: apply new plink state
1769 *
1770 * Not all station parameters have in-band "no change" signalling,
1771 * for those that don't these flags will are used.
1772 */
1773 enum station_parameters_apply_mask {
1774 STATION_PARAM_APPLY_UAPSD = BIT(0),
1775 STATION_PARAM_APPLY_CAPABILITY = BIT(1),
1776 STATION_PARAM_APPLY_PLINK_STATE = BIT(2),
1777 };
1778
1779 /**
1780 * struct sta_txpwr - station txpower configuration
1781 *
1782 * Used to configure txpower for station.
1783 *
1784 * @power: tx power (in dBm) to be used for sending data traffic. If tx power
1785 * is not provided, the default per-interface tx power setting will be
1786 * overriding. Driver should be picking up the lowest tx power, either tx
1787 * power per-interface or per-station.
1788 * @type: In particular if TPC %type is NL80211_TX_POWER_LIMITED then tx power
1789 * will be less than or equal to specified from userspace, whereas if TPC
1790 * %type is NL80211_TX_POWER_AUTOMATIC then it indicates default tx power.
1791 * NL80211_TX_POWER_FIXED is not a valid configuration option for
1792 * per peer TPC.
1793 */
1794 struct sta_txpwr {
1795 s16 power;
1796 enum nl80211_tx_power_setting type;
1797 };
1798
1799 /**
1800 * struct link_station_parameters - link station parameters
1801 *
1802 * Used to change and create a new link station.
1803 *
1804 * @mld_mac: MAC address of the station
1805 * @link_id: the link id (-1 for non-MLD station)
1806 * @link_mac: MAC address of the link
1807 * @supported_rates: supported rates in IEEE 802.11 format
1808 * (or NULL for no change)
1809 * @supported_rates_len: number of supported rates
1810 * @ht_capa: HT capabilities of station
1811 * @vht_capa: VHT capabilities of station
1812 * @opmode_notif: operating mode field from Operating Mode Notification
1813 * @opmode_notif_used: information if operating mode field is used
1814 * @he_capa: HE capabilities of station
1815 * @he_capa_len: the length of the HE capabilities
1816 * @txpwr: transmit power for an associated station
1817 * @txpwr_set: txpwr field is set
1818 * @he_6ghz_capa: HE 6 GHz Band capabilities of station
1819 * @eht_capa: EHT capabilities of station
1820 * @eht_capa_len: the length of the EHT capabilities
1821 * @s1g_capa: S1G capabilities of station
1822 * @uhr_capa: UHR capabilities of the station
1823 * @uhr_capa_len: the length of the UHR capabilities
1824 */
1825 struct link_station_parameters {
1826 const u8 *mld_mac;
1827 int link_id;
1828 const u8 *link_mac;
1829 const u8 *supported_rates;
1830 u8 supported_rates_len;
1831 const struct ieee80211_ht_cap *ht_capa;
1832 const struct ieee80211_vht_cap *vht_capa;
1833 u8 opmode_notif;
1834 bool opmode_notif_used;
1835 const struct ieee80211_he_cap_elem *he_capa;
1836 u8 he_capa_len;
1837 struct sta_txpwr txpwr;
1838 bool txpwr_set;
1839 const struct ieee80211_he_6ghz_capa *he_6ghz_capa;
1840 const struct ieee80211_eht_cap_elem *eht_capa;
1841 u8 eht_capa_len;
1842 const struct ieee80211_s1g_cap *s1g_capa;
1843 const struct ieee80211_uhr_cap *uhr_capa;
1844 u8 uhr_capa_len;
1845 };
1846
1847 /**
1848 * struct link_station_del_parameters - link station deletion parameters
1849 *
1850 * Used to delete a link station entry (or all stations).
1851 *
1852 * @mld_mac: MAC address of the station
1853 * @link_id: the link id
1854 */
1855 struct link_station_del_parameters {
1856 const u8 *mld_mac;
1857 u32 link_id;
1858 };
1859
1860 /**
1861 * struct cfg80211_ttlm_params: TID to link mapping parameters
1862 *
1863 * Used for setting a TID to link mapping.
1864 *
1865 * @dlink: Downlink TID to link mapping, as defined in section 9.4.2.314
1866 * (TID-To-Link Mapping element) in Draft P802.11be_D4.0.
1867 * @ulink: Uplink TID to link mapping, as defined in section 9.4.2.314
1868 * (TID-To-Link Mapping element) in Draft P802.11be_D4.0.
1869 */
1870 struct cfg80211_ttlm_params {
1871 u16 dlink[8];
1872 u16 ulink[8];
1873 };
1874
1875 /**
1876 * struct station_parameters - station parameters
1877 *
1878 * Used to change and create a new station.
1879 *
1880 * @vlan: vlan interface station should belong to
1881 * @sta_flags_mask: station flags that changed
1882 * (bitmask of BIT(%NL80211_STA_FLAG_...))
1883 * @sta_flags_set: station flags values
1884 * (bitmask of BIT(%NL80211_STA_FLAG_...))
1885 * @listen_interval: listen interval or -1 for no change
1886 * @aid: AID or zero for no change
1887 * @vlan_id: VLAN ID for station (if nonzero)
1888 * @peer_aid: mesh peer AID or zero for no change
1889 * @plink_action: plink action to take
1890 * @plink_state: set the peer link state for a station
1891 * @uapsd_queues: bitmap of queues configured for uapsd. same format
1892 * as the AC bitmap in the QoS info field
1893 * @max_sp: max Service Period. same format as the MAX_SP in the
1894 * QoS info field (but already shifted down)
1895 * @sta_modify_mask: bitmap indicating which parameters changed
1896 * (for those that don't have a natural "no change" value),
1897 * see &enum station_parameters_apply_mask
1898 * @local_pm: local link-specific mesh power save mode (no change when set
1899 * to unknown)
1900 * @capability: station capability
1901 * @ext_capab: extended capabilities of the station
1902 * @ext_capab_len: number of extended capabilities
1903 * @supported_channels: supported channels in IEEE 802.11 format
1904 * @supported_channels_len: number of supported channels
1905 * @supported_oper_classes: supported oper classes in IEEE 802.11 format
1906 * @supported_oper_classes_len: number of supported operating classes
1907 * @support_p2p_ps: information if station supports P2P PS mechanism
1908 * @airtime_weight: airtime scheduler weight for this station
1909 * @eml_cap_present: Specifies if EML capabilities field (@eml_cap) is
1910 * present/updated
1911 * @eml_cap: EML capabilities of this station
1912 * @link_sta_params: link related params.
1913 * @epp_peer: EPP peer indication
1914 * @nmi_mac: MAC address of the NMI station of the NAN peer
1915 */
1916 struct station_parameters {
1917 struct net_device *vlan;
1918 u32 sta_flags_mask, sta_flags_set;
1919 u32 sta_modify_mask;
1920 int listen_interval;
1921 u16 aid;
1922 u16 vlan_id;
1923 u16 peer_aid;
1924 u8 plink_action;
1925 u8 plink_state;
1926 u8 uapsd_queues;
1927 u8 max_sp;
1928 enum nl80211_mesh_power_mode local_pm;
1929 u16 capability;
1930 const u8 *ext_capab;
1931 u8 ext_capab_len;
1932 const u8 *supported_channels;
1933 u8 supported_channels_len;
1934 const u8 *supported_oper_classes;
1935 u8 supported_oper_classes_len;
1936 int support_p2p_ps;
1937 u16 airtime_weight;
1938 bool eml_cap_present;
1939 u16 eml_cap;
1940 struct link_station_parameters link_sta_params;
1941 bool epp_peer;
1942 const u8 *nmi_mac;
1943 };
1944
1945 /**
1946 * struct station_del_parameters - station deletion parameters
1947 *
1948 * Used to delete a station entry (or all stations).
1949 *
1950 * @mac: MAC address of the station to remove or NULL to remove all stations
1951 * @subtype: Management frame subtype to use for indicating removal
1952 * (10 = Disassociation, 12 = Deauthentication)
1953 * @reason_code: Reason code for the Disassociation/Deauthentication frame
1954 * @link_id: Link ID indicating a link that stations to be flushed must be
1955 * using; valid only for MLO, but can also be -1 for MLO to really
1956 * remove all stations.
1957 */
1958 struct station_del_parameters {
1959 const u8 *mac;
1960 u8 subtype;
1961 u16 reason_code;
1962 int link_id;
1963 };
1964
1965 /**
1966 * enum cfg80211_station_type - the type of station being modified
1967 * @CFG80211_STA_AP_CLIENT: client of an AP interface
1968 * @CFG80211_STA_AP_CLIENT_UNASSOC: client of an AP interface that is still
1969 * unassociated (update properties for this type of client is permitted)
1970 * @CFG80211_STA_AP_MLME_CLIENT: client of an AP interface that has
1971 * the AP MLME in the device
1972 * @CFG80211_STA_AP_STA: AP station on managed interface
1973 * @CFG80211_STA_IBSS: IBSS station
1974 * @CFG80211_STA_TDLS_PEER_SETUP: TDLS peer on managed interface (dummy entry
1975 * while TDLS setup is in progress, it moves out of this state when
1976 * being marked authorized; use this only if TDLS with external setup is
1977 * supported/used)
1978 * @CFG80211_STA_TDLS_PEER_ACTIVE: TDLS peer on managed interface (active
1979 * entry that is operating, has been marked authorized by userspace)
1980 * @CFG80211_STA_MESH_PEER_KERNEL: peer on mesh interface (kernel managed)
1981 * @CFG80211_STA_MESH_PEER_USER: peer on mesh interface (user managed)
1982 * @CFG80211_STA_NAN_MGMT: NAN management interface station
1983 * @CFG80211_STA_NAN_DATA: NAN data path station
1984 */
1985 enum cfg80211_station_type {
1986 CFG80211_STA_AP_CLIENT,
1987 CFG80211_STA_AP_CLIENT_UNASSOC,
1988 CFG80211_STA_AP_MLME_CLIENT,
1989 CFG80211_STA_AP_STA,
1990 CFG80211_STA_IBSS,
1991 CFG80211_STA_TDLS_PEER_SETUP,
1992 CFG80211_STA_TDLS_PEER_ACTIVE,
1993 CFG80211_STA_MESH_PEER_KERNEL,
1994 CFG80211_STA_MESH_PEER_USER,
1995 CFG80211_STA_NAN_MGMT,
1996 CFG80211_STA_NAN_DATA,
1997 };
1998
1999 /**
2000 * cfg80211_check_station_change - validate parameter changes
2001 * @wiphy: the wiphy this operates on
2002 * @params: the new parameters for a station
2003 * @statype: the type of station being modified
2004 *
2005 * Utility function for the @change_station driver method. Call this function
2006 * with the appropriate station type looking up the station (and checking that
2007 * it exists). It will verify whether the station change is acceptable.
2008 *
2009 * Return: 0 if the change is acceptable, otherwise an error code. Note that
2010 * it may modify the parameters for backward compatibility reasons, so don't
2011 * use them before calling this.
2012 */
2013 int cfg80211_check_station_change(struct wiphy *wiphy,
2014 struct station_parameters *params,
2015 enum cfg80211_station_type statype);
2016
2017 /**
2018 * enum rate_info_flags - bitrate info flags
2019 *
2020 * Used by the driver to indicate the specific rate transmission
2021 * type for 802.11n transmissions.
2022 *
2023 * @RATE_INFO_FLAGS_MCS: mcs field filled with HT MCS
2024 * @RATE_INFO_FLAGS_VHT_MCS: mcs field filled with VHT MCS
2025 * @RATE_INFO_FLAGS_SHORT_GI: 400ns guard interval
2026 * @RATE_INFO_FLAGS_DMG: 60GHz MCS
2027 * @RATE_INFO_FLAGS_HE_MCS: HE MCS information
2028 * @RATE_INFO_FLAGS_EDMG: 60GHz MCS in EDMG mode
2029 * @RATE_INFO_FLAGS_EXTENDED_SC_DMG: 60GHz extended SC MCS
2030 * @RATE_INFO_FLAGS_EHT_MCS: EHT MCS information
2031 * @RATE_INFO_FLAGS_S1G_MCS: MCS field filled with S1G MCS
2032 * @RATE_INFO_FLAGS_UHR_MCS: UHR MCS information
2033 * @RATE_INFO_FLAGS_UHR_ELR_MCS: UHR ELR MCS was used
2034 * (set together with @RATE_INFO_FLAGS_UHR_MCS)
2035 * @RATE_INFO_FLAGS_UHR_IM: UHR Interference Mitigation
2036 * was used
2037 */
2038 enum rate_info_flags {
2039 RATE_INFO_FLAGS_MCS = BIT(0),
2040 RATE_INFO_FLAGS_VHT_MCS = BIT(1),
2041 RATE_INFO_FLAGS_SHORT_GI = BIT(2),
2042 RATE_INFO_FLAGS_DMG = BIT(3),
2043 RATE_INFO_FLAGS_HE_MCS = BIT(4),
2044 RATE_INFO_FLAGS_EDMG = BIT(5),
2045 RATE_INFO_FLAGS_EXTENDED_SC_DMG = BIT(6),
2046 RATE_INFO_FLAGS_EHT_MCS = BIT(7),
2047 RATE_INFO_FLAGS_S1G_MCS = BIT(8),
2048 RATE_INFO_FLAGS_UHR_MCS = BIT(9),
2049 RATE_INFO_FLAGS_UHR_ELR_MCS = BIT(10),
2050 RATE_INFO_FLAGS_UHR_IM = BIT(11),
2051 };
2052
2053 /**
2054 * enum rate_info_bw - rate bandwidth information
2055 *
2056 * Used by the driver to indicate the rate bandwidth.
2057 *
2058 * @RATE_INFO_BW_5: 5 MHz bandwidth
2059 * @RATE_INFO_BW_10: 10 MHz bandwidth
2060 * @RATE_INFO_BW_20: 20 MHz bandwidth
2061 * @RATE_INFO_BW_40: 40 MHz bandwidth
2062 * @RATE_INFO_BW_80: 80 MHz bandwidth
2063 * @RATE_INFO_BW_160: 160 MHz bandwidth
2064 * @RATE_INFO_BW_HE_RU: bandwidth determined by HE RU allocation
2065 * @RATE_INFO_BW_320: 320 MHz bandwidth
2066 * @RATE_INFO_BW_EHT_RU: bandwidth determined by EHT/UHR RU allocation
2067 * @RATE_INFO_BW_1: 1 MHz bandwidth
2068 * @RATE_INFO_BW_2: 2 MHz bandwidth
2069 * @RATE_INFO_BW_4: 4 MHz bandwidth
2070 * @RATE_INFO_BW_8: 8 MHz bandwidth
2071 * @RATE_INFO_BW_16: 16 MHz bandwidth
2072 */
2073 enum rate_info_bw {
2074 RATE_INFO_BW_20 = 0,
2075 RATE_INFO_BW_5,
2076 RATE_INFO_BW_10,
2077 RATE_INFO_BW_40,
2078 RATE_INFO_BW_80,
2079 RATE_INFO_BW_160,
2080 RATE_INFO_BW_HE_RU,
2081 RATE_INFO_BW_320,
2082 RATE_INFO_BW_EHT_RU,
2083 RATE_INFO_BW_1,
2084 RATE_INFO_BW_2,
2085 RATE_INFO_BW_4,
2086 RATE_INFO_BW_8,
2087 RATE_INFO_BW_16,
2088 };
2089
2090 /**
2091 * struct rate_info - bitrate information
2092 *
2093 * Information about a receiving or transmitting bitrate
2094 *
2095 * @flags: bitflag of flags from &enum rate_info_flags
2096 * @legacy: bitrate in 100kbit/s for 802.11abg
2097 * @mcs: mcs index if struct describes an HT/VHT/HE/EHT/S1G/UHR rate
2098 * @nss: number of streams (VHT & HE only)
2099 * @bw: bandwidth (from &enum rate_info_bw)
2100 * @he_gi: HE guard interval (from &enum nl80211_he_gi)
2101 * @he_dcm: HE DCM value
2102 * @he_ru_alloc: HE RU allocation (from &enum nl80211_he_ru_alloc,
2103 * only valid if bw is %RATE_INFO_BW_HE_RU)
2104 * @n_bonded_ch: In case of EDMG the number of bonded channels (1-4)
2105 * @eht_gi: EHT guard interval (from &enum nl80211_eht_gi)
2106 * @eht_ru_alloc: EHT RU allocation (from &enum nl80211_eht_ru_alloc,
2107 * only valid if bw is %RATE_INFO_BW_EHT_RU)
2108 */
2109 struct rate_info {
2110 u16 flags;
2111 u16 legacy;
2112 u8 mcs;
2113 u8 nss;
2114 u8 bw;
2115 u8 he_gi;
2116 u8 he_dcm;
2117 u8 he_ru_alloc;
2118 u8 n_bonded_ch;
2119 u8 eht_gi;
2120 u8 eht_ru_alloc;
2121 };
2122
2123 /**
2124 * enum bss_param_flags - bitrate info flags
2125 *
2126 * Used by the driver to indicate the specific rate transmission
2127 * type for 802.11n transmissions.
2128 *
2129 * @BSS_PARAM_FLAGS_CTS_PROT: whether CTS protection is enabled
2130 * @BSS_PARAM_FLAGS_SHORT_PREAMBLE: whether short preamble is enabled
2131 * @BSS_PARAM_FLAGS_SHORT_SLOT_TIME: whether short slot time is enabled
2132 */
2133 enum bss_param_flags {
2134 BSS_PARAM_FLAGS_CTS_PROT = BIT(0),
2135 BSS_PARAM_FLAGS_SHORT_PREAMBLE = BIT(1),
2136 BSS_PARAM_FLAGS_SHORT_SLOT_TIME = BIT(2),
2137 };
2138
2139 /**
2140 * struct sta_bss_parameters - BSS parameters for the attached station
2141 *
2142 * Information about the currently associated BSS
2143 *
2144 * @flags: bitflag of flags from &enum bss_param_flags
2145 * @dtim_period: DTIM period for the BSS
2146 * @beacon_interval: beacon interval
2147 */
2148 struct sta_bss_parameters {
2149 u8 flags;
2150 u8 dtim_period;
2151 u16 beacon_interval;
2152 };
2153
2154 /**
2155 * struct cfg80211_txq_stats - TXQ statistics for this TID
2156 * @filled: bitmap of flags using the bits of &enum nl80211_txq_stats to
2157 * indicate the relevant values in this struct are filled
2158 * @backlog_bytes: total number of bytes currently backlogged
2159 * @backlog_packets: total number of packets currently backlogged
2160 * @flows: number of new flows seen
2161 * @drops: total number of packets dropped
2162 * @ecn_marks: total number of packets marked with ECN CE
2163 * @overlimit: number of drops due to queue space overflow
2164 * @overmemory: number of drops due to memory limit overflow
2165 * @collisions: number of hash collisions
2166 * @tx_bytes: total number of bytes dequeued
2167 * @tx_packets: total number of packets dequeued
2168 * @max_flows: maximum number of flows supported
2169 */
2170 struct cfg80211_txq_stats {
2171 u32 filled;
2172 u32 backlog_bytes;
2173 u32 backlog_packets;
2174 u32 flows;
2175 u32 drops;
2176 u32 ecn_marks;
2177 u32 overlimit;
2178 u32 overmemory;
2179 u32 collisions;
2180 u32 tx_bytes;
2181 u32 tx_packets;
2182 u32 max_flows;
2183 };
2184
2185 /**
2186 * struct cfg80211_tid_stats - per-TID statistics
2187 * @filled: bitmap of flags using the bits of &enum nl80211_tid_stats to
2188 * indicate the relevant values in this struct are filled
2189 * @rx_msdu: number of received MSDUs
2190 * @tx_msdu: number of (attempted) transmitted MSDUs
2191 * @tx_msdu_retries: number of retries (not counting the first) for
2192 * transmitted MSDUs
2193 * @tx_msdu_failed: number of failed transmitted MSDUs
2194 * @txq_stats: TXQ statistics
2195 */
2196 struct cfg80211_tid_stats {
2197 u32 filled;
2198 u64 rx_msdu;
2199 u64 tx_msdu;
2200 u64 tx_msdu_retries;
2201 u64 tx_msdu_failed;
2202 struct cfg80211_txq_stats txq_stats;
2203 };
2204
2205 #define IEEE80211_MAX_CHAINS 4
2206
2207 /**
2208 * struct link_station_info - link station information
2209 *
2210 * Link station information filled by driver for get_station() and
2211 * dump_station().
2212 * @filled: bit flag of flags using the bits of &enum nl80211_sta_info to
2213 * indicate the relevant values in this struct for them
2214 * @connected_time: time(in secs) since a link of station is last connected
2215 * @inactive_time: time since last activity for link station(tx/rx)
2216 * in milliseconds
2217 * @assoc_at: bootime (ns) of the last association of link of station
2218 * @rx_bytes: bytes (size of MPDUs) received from this link of station
2219 * @tx_bytes: bytes (size of MPDUs) transmitted to this link of station
2220 * @signal: The signal strength, type depends on the wiphy's signal_type.
2221 * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
2222 * @signal_avg: Average signal strength, type depends on the wiphy's
2223 * signal_type. For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_
2224 * @chains: bitmask for filled values in @chain_signal, @chain_signal_avg
2225 * @chain_signal: per-chain signal strength of last received packet in dBm
2226 * @chain_signal_avg: per-chain signal strength average in dBm
2227 * @txrate: current unicast bitrate from this link of station
2228 * @rxrate: current unicast bitrate to this link of station
2229 * @rx_packets: packets (MSDUs & MMPDUs) received from this link of station
2230 * @tx_packets: packets (MSDUs & MMPDUs) transmitted to this link of station
2231 * @tx_retries: cumulative retry counts (MPDUs) for this link of station
2232 * @tx_failed: number of failed transmissions (MPDUs) (retries exceeded, no ACK)
2233 * @rx_dropped_misc: Dropped for un-specified reason.
2234 * @bss_param: current BSS parameters
2235 * @beacon_loss_count: Number of times beacon loss event has triggered.
2236 * @expected_throughput: expected throughput in kbps (including 802.11 headers)
2237 * towards this station.
2238 * @rx_beacon: number of beacons received from this peer
2239 * @rx_beacon_signal_avg: signal strength average (in dBm) for beacons received
2240 * from this peer
2241 * @rx_duration: aggregate PPDU duration(usecs) for all the frames from a peer
2242 * @tx_duration: aggregate PPDU duration(usecs) for all the frames to a peer
2243 * @airtime_weight: current airtime scheduling weight
2244 * @pertid: per-TID statistics, see &struct cfg80211_tid_stats, using the last
2245 * (IEEE80211_NUM_TIDS) index for MSDUs not encapsulated in QoS-MPDUs.
2246 * Note that this doesn't use the @filled bit, but is used if non-NULL.
2247 * @ack_signal: signal strength (in dBm) of the last ACK frame.
2248 * @avg_ack_signal: average rssi value of ack packet for the no of msdu's has
2249 * been sent.
2250 * @rx_mpdu_count: number of MPDUs received from this station
2251 * @fcs_err_count: number of packets (MPDUs) received from this station with
2252 * an FCS error. This counter should be incremented only when TA of the
2253 * received packet with an FCS error matches the peer MAC address.
2254 * @addr: For MLO STA connection, filled with address of the link of station.
2255 */
2256 struct link_station_info {
2257 u64 filled;
2258 u32 connected_time;
2259 u32 inactive_time;
2260 u64 assoc_at;
2261 u64 rx_bytes;
2262 u64 tx_bytes;
2263 s8 signal;
2264 s8 signal_avg;
2265
2266 u8 chains;
2267 s8 chain_signal[IEEE80211_MAX_CHAINS];
2268 s8 chain_signal_avg[IEEE80211_MAX_CHAINS];
2269
2270 struct rate_info txrate;
2271 struct rate_info rxrate;
2272 u32 rx_packets;
2273 u32 tx_packets;
2274 u32 tx_retries;
2275 u32 tx_failed;
2276 u32 rx_dropped_misc;
2277 struct sta_bss_parameters bss_param;
2278
2279 u32 beacon_loss_count;
2280
2281 u32 expected_throughput;
2282
2283 u64 tx_duration;
2284 u64 rx_duration;
2285 u64 rx_beacon;
2286 u8 rx_beacon_signal_avg;
2287
2288 u16 airtime_weight;
2289
2290 s8 ack_signal;
2291 s8 avg_ack_signal;
2292 struct cfg80211_tid_stats *pertid;
2293
2294 u32 rx_mpdu_count;
2295 u32 fcs_err_count;
2296
2297 u8 addr[ETH_ALEN] __aligned(2);
2298 };
2299
2300 /**
2301 * struct station_info - station information
2302 *
2303 * Station information filled by driver for get_station() and dump_station.
2304 *
2305 * @filled: bitflag of flags using the bits of &enum nl80211_sta_info to
2306 * indicate the relevant values in this struct for them
2307 * @connected_time: time(in secs) since a station is last connected
2308 * @inactive_time: time since last station activity (tx/rx) in milliseconds
2309 * @assoc_at: bootime (ns) of the last association
2310 * @rx_bytes: bytes (size of MPDUs) received from this station
2311 * @tx_bytes: bytes (size of MPDUs) transmitted to this station
2312 * @signal: The signal strength, type depends on the wiphy's signal_type.
2313 * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
2314 * @signal_avg: Average signal strength, type depends on the wiphy's signal_type.
2315 * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
2316 * @chains: bitmask for filled values in @chain_signal, @chain_signal_avg
2317 * @chain_signal: per-chain signal strength of last received packet in dBm
2318 * @chain_signal_avg: per-chain signal strength average in dBm
2319 * @txrate: current unicast bitrate from this station
2320 * @rxrate: current unicast bitrate to this station
2321 * @rx_packets: packets (MSDUs & MMPDUs) received from this station
2322 * @tx_packets: packets (MSDUs & MMPDUs) transmitted to this station
2323 * @tx_retries: cumulative retry counts (MPDUs)
2324 * @tx_failed: number of failed transmissions (MPDUs) (retries exceeded, no ACK)
2325 * @rx_dropped_misc: Dropped for un-specified reason.
2326 * @bss_param: current BSS parameters
2327 * @generation: generation number for nl80211 dumps.
2328 * This number should increase every time the list of stations
2329 * changes, i.e. when a station is added or removed, so that
2330 * userspace can tell whether it got a consistent snapshot.
2331 * @beacon_loss_count: Number of times beacon loss event has triggered.
2332 * @assoc_req_ies: IEs from (Re)Association Request.
2333 * This is used only when in AP mode with drivers that do not use
2334 * user space MLME/SME implementation. The information is provided for
2335 * the cfg80211_new_sta() calls to notify user space of the IEs.
2336 * @assoc_req_ies_len: Length of assoc_req_ies buffer in octets.
2337 * @sta_flags: station flags mask & values
2338 * @t_offset: Time offset of the station relative to this host.
2339 * @llid: mesh local link id
2340 * @plid: mesh peer link id
2341 * @plink_state: mesh peer link state
2342 * @connected_to_gate: true if mesh STA has a path to mesh gate
2343 * @connected_to_as: true if mesh STA has a path to authentication server
2344 * @airtime_link_metric: mesh airtime link metric.
2345 * @local_pm: local mesh STA power save mode
2346 * @peer_pm: peer mesh STA power save mode
2347 * @nonpeer_pm: non-peer mesh STA power save mode
2348 * @expected_throughput: expected throughput in kbps (including 802.11 headers)
2349 * towards this station.
2350 * @rx_beacon: number of beacons received from this peer
2351 * @rx_beacon_signal_avg: signal strength average (in dBm) for beacons received
2352 * from this peer
2353 * @rx_duration: aggregate PPDU duration(usecs) for all the frames from a peer
2354 * @tx_duration: aggregate PPDU duration(usecs) for all the frames to a peer
2355 * @airtime_weight: current airtime scheduling weight
2356 * @pertid: per-TID statistics, see &struct cfg80211_tid_stats, using the last
2357 * (IEEE80211_NUM_TIDS) index for MSDUs not encapsulated in QoS-MPDUs.
2358 * Note that this doesn't use the @filled bit, but is used if non-NULL.
2359 * @ack_signal: signal strength (in dBm) of the last ACK frame.
2360 * @avg_ack_signal: average rssi value of ack packet for the no of msdu's has
2361 * been sent.
2362 * @rx_mpdu_count: number of MPDUs received from this station
2363 * @fcs_err_count: number of packets (MPDUs) received from this station with
2364 * an FCS error. This counter should be incremented only when TA of the
2365 * received packet with an FCS error matches the peer MAC address.
2366 * @mlo_params_valid: Indicates @assoc_link_id and @mld_addr fields are filled
2367 * by driver. Drivers use this only in cfg80211_new_sta() calls when AP
2368 * MLD's MLME/SME is offload to driver. Drivers won't fill this
2369 * information in cfg80211_del_sta_sinfo(), get_station() and
2370 * dump_station() callbacks.
2371 * @assoc_link_id: Indicates MLO link ID of the AP, with which the station
2372 * completed (re)association. This information filled for both MLO
2373 * and non-MLO STA connections when the AP affiliated with an MLD.
2374 * @mld_addr: For MLO STA connection, filled with MLD address of the station.
2375 * For non-MLO STA connection, filled with all zeros.
2376 * @assoc_resp_ies: IEs from (Re)Association Response.
2377 * This is used only when in AP mode with drivers that do not use user
2378 * space MLME/SME implementation. The information is provided only for the
2379 * cfg80211_new_sta() calls to notify user space of the IEs. Drivers won't
2380 * fill this information in cfg80211_del_sta_sinfo(), get_station() and
2381 * dump_station() callbacks. User space needs this information to determine
2382 * the accepted and rejected affiliated links of the connected station.
2383 * @assoc_resp_ies_len: Length of @assoc_resp_ies buffer in octets.
2384 * @valid_links: bitmap of valid links, or 0 for non-MLO. Drivers fill this
2385 * information in cfg80211_new_sta(), cfg80211_del_sta_sinfo(),
2386 * get_station() and dump_station() callbacks.
2387 * @links: reference to Link sta entries for MLO STA, all link specific
2388 * information is accessed through links[link_id].
2389 */
2390 struct station_info {
2391 u64 filled;
2392 u32 connected_time;
2393 u32 inactive_time;
2394 u64 assoc_at;
2395 u64 rx_bytes;
2396 u64 tx_bytes;
2397 s8 signal;
2398 s8 signal_avg;
2399
2400 u8 chains;
2401 s8 chain_signal[IEEE80211_MAX_CHAINS];
2402 s8 chain_signal_avg[IEEE80211_MAX_CHAINS];
2403
2404 struct rate_info txrate;
2405 struct rate_info rxrate;
2406 u32 rx_packets;
2407 u32 tx_packets;
2408 u32 tx_retries;
2409 u32 tx_failed;
2410 u32 rx_dropped_misc;
2411 struct sta_bss_parameters bss_param;
2412 struct nl80211_sta_flag_update sta_flags;
2413
2414 int generation;
2415
2416 u32 beacon_loss_count;
2417
2418 const u8 *assoc_req_ies;
2419 size_t assoc_req_ies_len;
2420
2421 s64 t_offset;
2422 u16 llid;
2423 u16 plid;
2424 u8 plink_state;
2425 u8 connected_to_gate;
2426 u8 connected_to_as;
2427 u32 airtime_link_metric;
2428 enum nl80211_mesh_power_mode local_pm;
2429 enum nl80211_mesh_power_mode peer_pm;
2430 enum nl80211_mesh_power_mode nonpeer_pm;
2431
2432 u32 expected_throughput;
2433
2434 u16 airtime_weight;
2435
2436 s8 ack_signal;
2437 s8 avg_ack_signal;
2438 struct cfg80211_tid_stats *pertid;
2439
2440 u64 tx_duration;
2441 u64 rx_duration;
2442 u64 rx_beacon;
2443 u8 rx_beacon_signal_avg;
2444
2445 u32 rx_mpdu_count;
2446 u32 fcs_err_count;
2447
2448 bool mlo_params_valid;
2449 u8 assoc_link_id;
2450 u8 mld_addr[ETH_ALEN] __aligned(2);
2451 const u8 *assoc_resp_ies;
2452 size_t assoc_resp_ies_len;
2453
2454 u16 valid_links;
2455 struct link_station_info *links[IEEE80211_MLD_MAX_NUM_LINKS];
2456 };
2457
2458 /**
2459 * struct cfg80211_sar_sub_specs - sub specs limit
2460 * @power: power limitation in 0.25dbm
2461 * @freq_range_index: index the power limitation applies to
2462 */
2463 struct cfg80211_sar_sub_specs {
2464 s32 power;
2465 u32 freq_range_index;
2466 };
2467
2468 /**
2469 * struct cfg80211_sar_specs - sar limit specs
2470 * @type: it's set with power in 0.25dbm or other types
2471 * @num_sub_specs: number of sar sub specs
2472 * @sub_specs: memory to hold the sar sub specs
2473 */
2474 struct cfg80211_sar_specs {
2475 enum nl80211_sar_type type;
2476 u32 num_sub_specs;
2477 struct cfg80211_sar_sub_specs sub_specs[] __counted_by(num_sub_specs);
2478 };
2479
2480
2481 /**
2482 * struct cfg80211_sar_freq_ranges - sar frequency ranges
2483 * @start_freq: start range edge frequency
2484 * @end_freq: end range edge frequency
2485 */
2486 struct cfg80211_sar_freq_ranges {
2487 u32 start_freq;
2488 u32 end_freq;
2489 };
2490
2491 /**
2492 * struct cfg80211_sar_capa - sar limit capability
2493 * @type: it's set via power in 0.25dbm or other types
2494 * @num_freq_ranges: number of frequency ranges
2495 * @freq_ranges: memory to hold the freq ranges.
2496 *
2497 * Note: WLAN driver may append new ranges or split an existing
2498 * range to small ones and then append them.
2499 */
2500 struct cfg80211_sar_capa {
2501 enum nl80211_sar_type type;
2502 u32 num_freq_ranges;
2503 const struct cfg80211_sar_freq_ranges *freq_ranges;
2504 };
2505
2506 #if IS_ENABLED(CONFIG_CFG80211)
2507 /**
2508 * cfg80211_get_station - retrieve information about a given station
2509 * @dev: the device where the station is supposed to be connected to
2510 * @mac_addr: the mac address of the station of interest
2511 * @sinfo: pointer to the structure to fill with the information
2512 *
2513 * Return: 0 on success and sinfo is filled with the available information
2514 * otherwise returns a negative error code and the content of sinfo has to be
2515 * considered undefined.
2516 */
2517 int cfg80211_get_station(struct net_device *dev, const u8 *mac_addr,
2518 struct station_info *sinfo);
2519 #else
cfg80211_get_station(struct net_device * dev,const u8 * mac_addr,struct station_info * sinfo)2520 static inline int cfg80211_get_station(struct net_device *dev,
2521 const u8 *mac_addr,
2522 struct station_info *sinfo)
2523 {
2524 return -ENOENT;
2525 }
2526 #endif
2527
2528 /**
2529 * enum monitor_flags - monitor flags
2530 *
2531 * Monitor interface configuration flags. Note that these must be the bits
2532 * according to the nl80211 flags.
2533 *
2534 * @MONITOR_FLAG_CHANGED: set if the flags were changed
2535 * @MONITOR_FLAG_FCSFAIL: pass frames with bad FCS
2536 * @MONITOR_FLAG_PLCPFAIL: pass frames with bad PLCP
2537 * @MONITOR_FLAG_CONTROL: pass control frames
2538 * @MONITOR_FLAG_OTHER_BSS: disable BSSID filtering
2539 * @MONITOR_FLAG_COOK_FRAMES: deprecated, will unconditionally be refused
2540 * @MONITOR_FLAG_ACTIVE: active monitor, ACKs frames on its MAC address
2541 * @MONITOR_FLAG_SKIP_TX: do not pass locally transmitted frames
2542 */
2543 enum monitor_flags {
2544 MONITOR_FLAG_CHANGED = BIT(__NL80211_MNTR_FLAG_INVALID),
2545 MONITOR_FLAG_FCSFAIL = BIT(NL80211_MNTR_FLAG_FCSFAIL),
2546 MONITOR_FLAG_PLCPFAIL = BIT(NL80211_MNTR_FLAG_PLCPFAIL),
2547 MONITOR_FLAG_CONTROL = BIT(NL80211_MNTR_FLAG_CONTROL),
2548 MONITOR_FLAG_OTHER_BSS = BIT(NL80211_MNTR_FLAG_OTHER_BSS),
2549 MONITOR_FLAG_COOK_FRAMES = BIT(NL80211_MNTR_FLAG_COOK_FRAMES),
2550 MONITOR_FLAG_ACTIVE = BIT(NL80211_MNTR_FLAG_ACTIVE),
2551 MONITOR_FLAG_SKIP_TX = BIT(NL80211_MNTR_FLAG_SKIP_TX),
2552 };
2553
2554 /**
2555 * enum mpath_info_flags - mesh path information flags
2556 *
2557 * Used by the driver to indicate which info in &struct mpath_info it has filled
2558 * in during get_station() or dump_station().
2559 *
2560 * @MPATH_INFO_FRAME_QLEN: @frame_qlen filled
2561 * @MPATH_INFO_SN: @sn filled
2562 * @MPATH_INFO_METRIC: @metric filled
2563 * @MPATH_INFO_EXPTIME: @exptime filled
2564 * @MPATH_INFO_DISCOVERY_TIMEOUT: @discovery_timeout filled
2565 * @MPATH_INFO_DISCOVERY_RETRIES: @discovery_retries filled
2566 * @MPATH_INFO_FLAGS: @flags filled
2567 * @MPATH_INFO_HOP_COUNT: @hop_count filled
2568 * @MPATH_INFO_PATH_CHANGE: @path_change_count filled
2569 */
2570 enum mpath_info_flags {
2571 MPATH_INFO_FRAME_QLEN = BIT(0),
2572 MPATH_INFO_SN = BIT(1),
2573 MPATH_INFO_METRIC = BIT(2),
2574 MPATH_INFO_EXPTIME = BIT(3),
2575 MPATH_INFO_DISCOVERY_TIMEOUT = BIT(4),
2576 MPATH_INFO_DISCOVERY_RETRIES = BIT(5),
2577 MPATH_INFO_FLAGS = BIT(6),
2578 MPATH_INFO_HOP_COUNT = BIT(7),
2579 MPATH_INFO_PATH_CHANGE = BIT(8),
2580 };
2581
2582 /**
2583 * struct mpath_info - mesh path information
2584 *
2585 * Mesh path information filled by driver for get_mpath() and dump_mpath().
2586 *
2587 * @filled: bitfield of flags from &enum mpath_info_flags
2588 * @frame_qlen: number of queued frames for this destination
2589 * @sn: target sequence number
2590 * @metric: metric (cost) of this mesh path
2591 * @exptime: expiration time for the mesh path from now, in msecs
2592 * @flags: mesh path flags from &enum mesh_path_flags
2593 * @discovery_timeout: total mesh path discovery timeout, in msecs
2594 * @discovery_retries: mesh path discovery retries
2595 * @generation: generation number for nl80211 dumps.
2596 * This number should increase every time the list of mesh paths
2597 * changes, i.e. when a station is added or removed, so that
2598 * userspace can tell whether it got a consistent snapshot.
2599 * @hop_count: hops to destination
2600 * @path_change_count: total number of path changes to destination
2601 */
2602 struct mpath_info {
2603 u32 filled;
2604 u32 frame_qlen;
2605 u32 sn;
2606 u32 metric;
2607 u32 exptime;
2608 u32 discovery_timeout;
2609 u8 discovery_retries;
2610 u8 flags;
2611 u8 hop_count;
2612 u32 path_change_count;
2613
2614 int generation;
2615 };
2616
2617 /**
2618 * enum wiphy_bss_param_flags - bit positions for supported bss parameters.
2619 *
2620 * @WIPHY_BSS_PARAM_CTS_PROT: support changing CTS protection.
2621 * @WIPHY_BSS_PARAM_SHORT_PREAMBLE: support changing short preamble usage.
2622 * @WIPHY_BSS_PARAM_SHORT_SLOT_TIME: support changing short slot time usage.
2623 * @WIPHY_BSS_PARAM_BASIC_RATES: support reconfiguring basic rates.
2624 * @WIPHY_BSS_PARAM_AP_ISOLATE: support changing AP isolation.
2625 * @WIPHY_BSS_PARAM_HT_OPMODE: support changing HT operating mode.
2626 * @WIPHY_BSS_PARAM_P2P_CTWINDOW: support reconfiguring ctwindow.
2627 * @WIPHY_BSS_PARAM_P2P_OPPPS: support changing P2P opportunistic power-save.
2628 */
2629 enum wiphy_bss_param_flags {
2630 WIPHY_BSS_PARAM_CTS_PROT = BIT(0),
2631 WIPHY_BSS_PARAM_SHORT_PREAMBLE = BIT(1),
2632 WIPHY_BSS_PARAM_SHORT_SLOT_TIME = BIT(2),
2633 WIPHY_BSS_PARAM_BASIC_RATES = BIT(3),
2634 WIPHY_BSS_PARAM_AP_ISOLATE = BIT(4),
2635 WIPHY_BSS_PARAM_HT_OPMODE = BIT(5),
2636 WIPHY_BSS_PARAM_P2P_CTWINDOW = BIT(6),
2637 WIPHY_BSS_PARAM_P2P_OPPPS = BIT(7),
2638 };
2639
2640 /**
2641 * struct bss_parameters - BSS parameters
2642 *
2643 * Used to change BSS parameters (mainly for AP mode).
2644 *
2645 * @link_id: link_id or -1 for non-MLD
2646 * @use_cts_prot: Whether to use CTS protection
2647 * (0 = no, 1 = yes, -1 = do not change)
2648 * @use_short_preamble: Whether the use of short preambles is allowed
2649 * (0 = no, 1 = yes, -1 = do not change)
2650 * @use_short_slot_time: Whether the use of short slot time is allowed
2651 * (0 = no, 1 = yes, -1 = do not change)
2652 * @basic_rates: basic rates in IEEE 802.11 format
2653 * (or NULL for no change)
2654 * @basic_rates_len: number of basic rates
2655 * @ap_isolate: do not forward packets between connected stations
2656 * (0 = no, 1 = yes, -1 = do not change)
2657 * @ht_opmode: HT Operation mode
2658 * (u16 = opmode, -1 = do not change)
2659 * @p2p_ctwindow: P2P CT Window (-1 = no change)
2660 * @p2p_opp_ps: P2P opportunistic PS (-1 = no change)
2661 */
2662 struct bss_parameters {
2663 int link_id;
2664 int use_cts_prot;
2665 int use_short_preamble;
2666 int use_short_slot_time;
2667 const u8 *basic_rates;
2668 u8 basic_rates_len;
2669 int ap_isolate;
2670 int ht_opmode;
2671 s8 p2p_ctwindow, p2p_opp_ps;
2672 };
2673
2674 /**
2675 * struct mesh_config - 802.11s mesh configuration
2676 *
2677 * These parameters can be changed while the mesh is active.
2678 *
2679 * @dot11MeshRetryTimeout: the initial retry timeout in millisecond units used
2680 * by the Mesh Peering Open message
2681 * @dot11MeshConfirmTimeout: the initial retry timeout in millisecond units
2682 * used by the Mesh Peering Open message
2683 * @dot11MeshHoldingTimeout: the confirm timeout in millisecond units used by
2684 * the mesh peering management to close a mesh peering
2685 * @dot11MeshMaxPeerLinks: the maximum number of peer links allowed on this
2686 * mesh interface
2687 * @dot11MeshMaxRetries: the maximum number of peer link open retries that can
2688 * be sent to establish a new peer link instance in a mesh
2689 * @dot11MeshTTL: the value of TTL field set at a source mesh STA
2690 * @element_ttl: the value of TTL field set at a mesh STA for path selection
2691 * elements
2692 * @auto_open_plinks: whether we should automatically open peer links when we
2693 * detect compatible mesh peers
2694 * @dot11MeshNbrOffsetMaxNeighbor: the maximum number of neighbors to
2695 * synchronize to for 11s default synchronization method
2696 * @dot11MeshHWMPmaxPREQretries: the number of action frames containing a PREQ
2697 * that an originator mesh STA can send to a particular path target
2698 * @path_refresh_time: how frequently to refresh mesh paths in milliseconds
2699 * @min_discovery_timeout: the minimum length of time to wait until giving up on
2700 * a path discovery in milliseconds
2701 * @dot11MeshHWMPactivePathTimeout: the time (in TUs) for which mesh STAs
2702 * receiving a PREQ shall consider the forwarding information from the
2703 * root to be valid. (TU = time unit)
2704 * @dot11MeshHWMPpreqMinInterval: the minimum interval of time (in TUs) during
2705 * which a mesh STA can send only one action frame containing a PREQ
2706 * element
2707 * @dot11MeshHWMPperrMinInterval: the minimum interval of time (in TUs) during
2708 * which a mesh STA can send only one Action frame containing a PERR
2709 * element
2710 * @dot11MeshHWMPnetDiameterTraversalTime: the interval of time (in TUs) that
2711 * it takes for an HWMP information element to propagate across the mesh
2712 * @dot11MeshHWMPRootMode: the configuration of a mesh STA as root mesh STA
2713 * @dot11MeshHWMPRannInterval: the interval of time (in TUs) between root
2714 * announcements are transmitted
2715 * @dot11MeshGateAnnouncementProtocol: whether to advertise that this mesh
2716 * station has access to a broader network beyond the MBSS. (This is
2717 * missnamed in draft 12.0: dot11MeshGateAnnouncementProtocol set to true
2718 * only means that the station will announce others it's a mesh gate, but
2719 * not necessarily using the gate announcement protocol. Still keeping the
2720 * same nomenclature to be in sync with the spec)
2721 * @dot11MeshForwarding: whether the Mesh STA is forwarding or non-forwarding
2722 * entity (default is TRUE - forwarding entity)
2723 * @rssi_threshold: the threshold for average signal strength of candidate
2724 * station to establish a peer link
2725 * @ht_opmode: mesh HT protection mode
2726 *
2727 * @dot11MeshHWMPactivePathToRootTimeout: The time (in TUs) for which mesh STAs
2728 * receiving a proactive PREQ shall consider the forwarding information to
2729 * the root mesh STA to be valid.
2730 *
2731 * @dot11MeshHWMProotInterval: The interval of time (in TUs) between proactive
2732 * PREQs are transmitted.
2733 * @dot11MeshHWMPconfirmationInterval: The minimum interval of time (in TUs)
2734 * during which a mesh STA can send only one Action frame containing
2735 * a PREQ element for root path confirmation.
2736 * @power_mode: The default mesh power save mode which will be the initial
2737 * setting for new peer links.
2738 * @dot11MeshAwakeWindowDuration: The duration in TUs the STA will remain awake
2739 * after transmitting its beacon.
2740 * @plink_timeout: If no tx activity is seen from a STA we've established
2741 * peering with for longer than this time (in seconds), then remove it
2742 * from the STA's list of peers. Default is 30 minutes.
2743 * @dot11MeshConnectedToAuthServer: if set to true then this mesh STA
2744 * will advertise that it is connected to a authentication server
2745 * in the mesh formation field.
2746 * @dot11MeshConnectedToMeshGate: if set to true, advertise that this STA is
2747 * connected to a mesh gate in mesh formation info. If false, the
2748 * value in mesh formation is determined by the presence of root paths
2749 * in the mesh path table
2750 * @dot11MeshNolearn: Try to avoid multi-hop path discovery (e.g. PREQ/PREP
2751 * for HWMP) if the destination is a direct neighbor. Note that this might
2752 * not be the optimal decision as a multi-hop route might be better. So
2753 * if using this setting you will likely also want to disable
2754 * dot11MeshForwarding and use another mesh routing protocol on top.
2755 */
2756 struct mesh_config {
2757 u16 dot11MeshRetryTimeout;
2758 u16 dot11MeshConfirmTimeout;
2759 u16 dot11MeshHoldingTimeout;
2760 u16 dot11MeshMaxPeerLinks;
2761 u8 dot11MeshMaxRetries;
2762 u8 dot11MeshTTL;
2763 u8 element_ttl;
2764 bool auto_open_plinks;
2765 u32 dot11MeshNbrOffsetMaxNeighbor;
2766 u8 dot11MeshHWMPmaxPREQretries;
2767 u32 path_refresh_time;
2768 u16 min_discovery_timeout;
2769 u32 dot11MeshHWMPactivePathTimeout;
2770 u16 dot11MeshHWMPpreqMinInterval;
2771 u16 dot11MeshHWMPperrMinInterval;
2772 u16 dot11MeshHWMPnetDiameterTraversalTime;
2773 u8 dot11MeshHWMPRootMode;
2774 bool dot11MeshConnectedToMeshGate;
2775 bool dot11MeshConnectedToAuthServer;
2776 u16 dot11MeshHWMPRannInterval;
2777 bool dot11MeshGateAnnouncementProtocol;
2778 bool dot11MeshForwarding;
2779 s32 rssi_threshold;
2780 u16 ht_opmode;
2781 u32 dot11MeshHWMPactivePathToRootTimeout;
2782 u16 dot11MeshHWMProotInterval;
2783 u16 dot11MeshHWMPconfirmationInterval;
2784 enum nl80211_mesh_power_mode power_mode;
2785 u16 dot11MeshAwakeWindowDuration;
2786 u32 plink_timeout;
2787 bool dot11MeshNolearn;
2788 };
2789
2790 /**
2791 * struct mesh_setup - 802.11s mesh setup configuration
2792 * @chandef: defines the channel to use
2793 * @mesh_id: the mesh ID
2794 * @mesh_id_len: length of the mesh ID, at least 1 and at most 32 bytes
2795 * @sync_method: which synchronization method to use
2796 * @path_sel_proto: which path selection protocol to use
2797 * @path_metric: which metric to use
2798 * @auth_id: which authentication method this mesh is using
2799 * @ie: vendor information elements (optional)
2800 * @ie_len: length of vendor information elements
2801 * @is_authenticated: this mesh requires authentication
2802 * @is_secure: this mesh uses security
2803 * @user_mpm: userspace handles all MPM functions
2804 * @dtim_period: DTIM period to use
2805 * @beacon_interval: beacon interval to use
2806 * @mcast_rate: multicast rate for Mesh Node [6Mbps is the default for 802.11a]
2807 * @basic_rates: basic rates to use when creating the mesh
2808 * @beacon_rate: bitrate to be used for beacons
2809 * @userspace_handles_dfs: whether user space controls DFS operation, i.e.
2810 * changes the channel when a radar is detected. This is required
2811 * to operate on DFS channels.
2812 * @control_port_over_nl80211: TRUE if userspace expects to exchange control
2813 * port frames over NL80211 instead of the network interface.
2814 *
2815 * These parameters are fixed when the mesh is created.
2816 */
2817 struct mesh_setup {
2818 struct cfg80211_chan_def chandef;
2819 const u8 *mesh_id;
2820 u8 mesh_id_len;
2821 u8 sync_method;
2822 u8 path_sel_proto;
2823 u8 path_metric;
2824 u8 auth_id;
2825 const u8 *ie;
2826 size_t ie_len;
2827 bool is_authenticated;
2828 bool is_secure;
2829 bool user_mpm;
2830 u8 dtim_period;
2831 u16 beacon_interval;
2832 int mcast_rate[NUM_NL80211_BANDS];
2833 u32 basic_rates;
2834 struct cfg80211_bitrate_mask beacon_rate;
2835 bool userspace_handles_dfs;
2836 bool control_port_over_nl80211;
2837 };
2838
2839 /**
2840 * struct ocb_setup - 802.11p OCB mode setup configuration
2841 * @chandef: defines the channel to use
2842 *
2843 * These parameters are fixed when connecting to the network
2844 */
2845 struct ocb_setup {
2846 struct cfg80211_chan_def chandef;
2847 };
2848
2849 /**
2850 * struct ieee80211_txq_params - TX queue parameters
2851 * @ac: AC identifier
2852 * @txop: Maximum burst time in units of 32 usecs, 0 meaning disabled
2853 * @cwmin: Minimum contention window [a value of the form 2^n-1 in the range
2854 * 1..32767]
2855 * @cwmax: Maximum contention window [a value of the form 2^n-1 in the range
2856 * 1..32767]
2857 * @aifs: Arbitration interframe space [0..255]
2858 * @link_id: link_id or -1 for non-MLD
2859 */
2860 struct ieee80211_txq_params {
2861 enum nl80211_ac ac;
2862 u16 txop;
2863 u16 cwmin;
2864 u16 cwmax;
2865 u8 aifs;
2866 int link_id;
2867 };
2868
2869 /**
2870 * DOC: Scanning and BSS list handling
2871 *
2872 * The scanning process itself is fairly simple, but cfg80211 offers quite
2873 * a bit of helper functionality. To start a scan, the scan operation will
2874 * be invoked with a scan definition. This scan definition contains the
2875 * channels to scan, and the SSIDs to send probe requests for (including the
2876 * wildcard, if desired). A passive scan is indicated by having no SSIDs to
2877 * probe. Additionally, a scan request may contain extra information elements
2878 * that should be added to the probe request. The IEs are guaranteed to be
2879 * well-formed, and will not exceed the maximum length the driver advertised
2880 * in the wiphy structure.
2881 *
2882 * When scanning finds a BSS, cfg80211 needs to be notified of that, because
2883 * it is responsible for maintaining the BSS list; the driver should not
2884 * maintain a list itself. For this notification, various functions exist.
2885 *
2886 * Since drivers do not maintain a BSS list, there are also a number of
2887 * functions to search for a BSS and obtain information about it from the
2888 * BSS structure cfg80211 maintains. The BSS list is also made available
2889 * to userspace.
2890 */
2891
2892 /**
2893 * struct cfg80211_ssid - SSID description
2894 * @ssid: the SSID
2895 * @ssid_len: length of the ssid
2896 */
2897 struct cfg80211_ssid {
2898 u8 ssid[IEEE80211_MAX_SSID_LEN];
2899 u8 ssid_len;
2900 };
2901
2902 /**
2903 * struct cfg80211_scan_info - information about completed scan
2904 * @scan_start_tsf: scan start time in terms of the TSF of the BSS that the
2905 * wireless device that requested the scan is connected to. If this
2906 * information is not available, this field is left zero.
2907 * @tsf_bssid: the BSSID according to which %scan_start_tsf is set.
2908 * @aborted: set to true if the scan was aborted for any reason,
2909 * userspace will be notified of that
2910 */
2911 struct cfg80211_scan_info {
2912 u64 scan_start_tsf;
2913 u8 tsf_bssid[ETH_ALEN] __aligned(2);
2914 bool aborted;
2915 };
2916
2917 /**
2918 * struct cfg80211_scan_6ghz_params - relevant for 6 GHz only
2919 *
2920 * @short_ssid: short ssid to scan for
2921 * @bssid: bssid to scan for
2922 * @channel_idx: idx of the channel in the channel array in the scan request
2923 * which the above info is relevant to
2924 * @unsolicited_probe: the AP transmits unsolicited probe response every 20 TU
2925 * @short_ssid_valid: @short_ssid is valid and can be used
2926 * @psc_no_listen: when set, and the channel is a PSC channel, no need to wait
2927 * 20 TUs before starting to send probe requests.
2928 * @psd_20: The AP's 20 MHz PSD value.
2929 */
2930 struct cfg80211_scan_6ghz_params {
2931 u32 short_ssid;
2932 u32 channel_idx;
2933 u8 bssid[ETH_ALEN];
2934 bool unsolicited_probe;
2935 bool short_ssid_valid;
2936 bool psc_no_listen;
2937 s8 psd_20;
2938 };
2939
2940 /**
2941 * struct cfg80211_scan_request - scan request description
2942 *
2943 * @ssids: SSIDs to scan for (active scan only)
2944 * @n_ssids: number of SSIDs
2945 * @channels: channels to scan on.
2946 * @n_channels: total number of channels to scan
2947 * @ie: optional information element(s) to add into Probe Request or %NULL
2948 * @ie_len: length of ie in octets
2949 * @duration: how long to listen on each channel, in TUs. If
2950 * %duration_mandatory is not set, this is the maximum dwell time and
2951 * the actual dwell time may be shorter.
2952 * @duration_mandatory: if set, the scan duration must be as specified by the
2953 * %duration field.
2954 * @flags: control flags from &enum nl80211_scan_flags
2955 * @rates: bitmap of rates to advertise for each band
2956 * @wiphy: the wiphy this was for
2957 * @scan_start: time (in jiffies) when the scan started
2958 * @wdev: the wireless device to scan for
2959 * @no_cck: used to send probe requests at non CCK rate in 2GHz band
2960 * @mac_addr: MAC address used with randomisation
2961 * @mac_addr_mask: MAC address mask used with randomisation, bits that
2962 * are 0 in the mask should be randomised, bits that are 1 should
2963 * be taken from the @mac_addr
2964 * @scan_6ghz: relevant for split scan request only,
2965 * true if this is a 6 GHz scan request
2966 * @first_part: %true if this is the first part of a split scan request or a
2967 * scan that was not split. May be %true for a @scan_6ghz scan if no other
2968 * channels were requested
2969 * @n_6ghz_params: number of 6 GHz params
2970 * @scan_6ghz_params: 6 GHz params
2971 * @bssid: BSSID to scan for (most commonly, the wildcard BSSID)
2972 * @tsf_report_link_id: for MLO, indicates the link ID of the BSS that should be
2973 * used for TSF reporting. Can be set to -1 to indicate no preference.
2974 */
2975 struct cfg80211_scan_request {
2976 struct cfg80211_ssid *ssids;
2977 int n_ssids;
2978 u32 n_channels;
2979 const u8 *ie;
2980 size_t ie_len;
2981 u16 duration;
2982 bool duration_mandatory;
2983 u32 flags;
2984
2985 u32 rates[NUM_NL80211_BANDS];
2986
2987 struct wireless_dev *wdev;
2988
2989 u8 mac_addr[ETH_ALEN] __aligned(2);
2990 u8 mac_addr_mask[ETH_ALEN] __aligned(2);
2991 u8 bssid[ETH_ALEN] __aligned(2);
2992 struct wiphy *wiphy;
2993 unsigned long scan_start;
2994 bool no_cck;
2995 bool scan_6ghz;
2996 bool first_part;
2997 u32 n_6ghz_params;
2998 struct cfg80211_scan_6ghz_params *scan_6ghz_params;
2999 s8 tsf_report_link_id;
3000
3001 /* keep last */
3002 struct ieee80211_channel *channels[];
3003 };
3004
get_random_mask_addr(u8 * buf,const u8 * addr,const u8 * mask)3005 static inline void get_random_mask_addr(u8 *buf, const u8 *addr, const u8 *mask)
3006 {
3007 int i;
3008
3009 get_random_bytes(buf, ETH_ALEN);
3010 for (i = 0; i < ETH_ALEN; i++) {
3011 buf[i] &= ~mask[i];
3012 buf[i] |= addr[i] & mask[i];
3013 }
3014 }
3015
3016 /**
3017 * struct cfg80211_match_set - sets of attributes to match
3018 *
3019 * @ssid: SSID to be matched; may be zero-length in case of BSSID match
3020 * or no match (RSSI only)
3021 * @bssid: BSSID to be matched; may be all-zero BSSID in case of SSID match
3022 * or no match (RSSI only)
3023 * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
3024 */
3025 struct cfg80211_match_set {
3026 struct cfg80211_ssid ssid;
3027 u8 bssid[ETH_ALEN];
3028 s32 rssi_thold;
3029 };
3030
3031 /**
3032 * struct cfg80211_sched_scan_plan - scan plan for scheduled scan
3033 *
3034 * @interval: interval between scheduled scan iterations. In seconds.
3035 * @iterations: number of scan iterations in this scan plan. Zero means
3036 * infinite loop.
3037 * The last scan plan will always have this parameter set to zero,
3038 * all other scan plans will have a finite number of iterations.
3039 */
3040 struct cfg80211_sched_scan_plan {
3041 u32 interval;
3042 u32 iterations;
3043 };
3044
3045 /**
3046 * struct cfg80211_bss_select_adjust - BSS selection with RSSI adjustment.
3047 *
3048 * @band: band of BSS which should match for RSSI level adjustment.
3049 * @delta: value of RSSI level adjustment.
3050 */
3051 struct cfg80211_bss_select_adjust {
3052 enum nl80211_band band;
3053 s8 delta;
3054 };
3055
3056 /**
3057 * struct cfg80211_sched_scan_request - scheduled scan request description
3058 *
3059 * @reqid: identifies this request.
3060 * @ssids: SSIDs to scan for (passed in the probe_reqs in active scans)
3061 * @n_ssids: number of SSIDs
3062 * @n_channels: total number of channels to scan
3063 * @ie: optional information element(s) to add into Probe Request or %NULL
3064 * @ie_len: length of ie in octets
3065 * @flags: control flags from &enum nl80211_scan_flags
3066 * @match_sets: sets of parameters to be matched for a scan result
3067 * entry to be considered valid and to be passed to the host
3068 * (others are filtered out).
3069 * If omitted, all results are passed.
3070 * @n_match_sets: number of match sets
3071 * @report_results: indicates that results were reported for this request
3072 * @wiphy: the wiphy this was for
3073 * @dev: the interface
3074 * @scan_start: start time of the scheduled scan
3075 * @channels: channels to scan
3076 * @min_rssi_thold: for drivers only supporting a single threshold, this
3077 * contains the minimum over all matchsets
3078 * @mac_addr: MAC address used with randomisation
3079 * @mac_addr_mask: MAC address mask used with randomisation, bits that
3080 * are 0 in the mask should be randomised, bits that are 1 should
3081 * be taken from the @mac_addr
3082 * @scan_plans: scan plans to be executed in this scheduled scan. Lowest
3083 * index must be executed first.
3084 * @n_scan_plans: number of scan plans, at least 1.
3085 * @rcu_head: RCU callback used to free the struct
3086 * @owner_nlportid: netlink portid of owner (if this should is a request
3087 * owned by a particular socket)
3088 * @nl_owner_dead: netlink owner socket was closed - this request be freed
3089 * @list: for keeping list of requests.
3090 * @delay: delay in seconds to use before starting the first scan
3091 * cycle. The driver may ignore this parameter and start
3092 * immediately (or at any other time), if this feature is not
3093 * supported.
3094 * @relative_rssi_set: Indicates whether @relative_rssi is set or not.
3095 * @relative_rssi: Relative RSSI threshold in dB to restrict scan result
3096 * reporting in connected state to cases where a matching BSS is determined
3097 * to have better or slightly worse RSSI than the current connected BSS.
3098 * The relative RSSI threshold values are ignored in disconnected state.
3099 * @rssi_adjust: delta dB of RSSI preference to be given to the BSSs that belong
3100 * to the specified band while deciding whether a better BSS is reported
3101 * using @relative_rssi. If delta is a negative number, the BSSs that
3102 * belong to the specified band will be penalized by delta dB in relative
3103 * comparisons.
3104 */
3105 struct cfg80211_sched_scan_request {
3106 u64 reqid;
3107 struct cfg80211_ssid *ssids;
3108 int n_ssids;
3109 u32 n_channels;
3110 const u8 *ie;
3111 size_t ie_len;
3112 u32 flags;
3113 struct cfg80211_match_set *match_sets;
3114 int n_match_sets;
3115 s32 min_rssi_thold;
3116 u32 delay;
3117 struct cfg80211_sched_scan_plan *scan_plans;
3118 int n_scan_plans;
3119
3120 u8 mac_addr[ETH_ALEN] __aligned(2);
3121 u8 mac_addr_mask[ETH_ALEN] __aligned(2);
3122
3123 bool relative_rssi_set;
3124 s8 relative_rssi;
3125 struct cfg80211_bss_select_adjust rssi_adjust;
3126
3127 /* internal */
3128 struct wiphy *wiphy;
3129 struct net_device *dev;
3130 unsigned long scan_start;
3131 bool report_results;
3132 struct rcu_head rcu_head;
3133 u32 owner_nlportid;
3134 bool nl_owner_dead;
3135 struct list_head list;
3136
3137 /* keep last */
3138 struct ieee80211_channel *channels[] __counted_by(n_channels);
3139 };
3140
3141 /**
3142 * enum cfg80211_signal_type - signal type
3143 *
3144 * @CFG80211_SIGNAL_TYPE_NONE: no signal strength information available
3145 * @CFG80211_SIGNAL_TYPE_MBM: signal strength in mBm (100*dBm)
3146 * @CFG80211_SIGNAL_TYPE_UNSPEC: signal strength, increasing from 0 through 100
3147 */
3148 enum cfg80211_signal_type {
3149 CFG80211_SIGNAL_TYPE_NONE,
3150 CFG80211_SIGNAL_TYPE_MBM,
3151 CFG80211_SIGNAL_TYPE_UNSPEC,
3152 };
3153
3154 /**
3155 * struct cfg80211_inform_bss - BSS inform data
3156 * @chan: channel the frame was received on
3157 * @signal: signal strength value, according to the wiphy's
3158 * signal type
3159 * @boottime_ns: timestamp (CLOCK_BOOTTIME) when the information was
3160 * received; should match the time when the frame was actually
3161 * received by the device (not just by the host, in case it was
3162 * buffered on the device) and be accurate to about 10ms.
3163 * If the frame isn't buffered, just passing the return value of
3164 * ktime_get_boottime_ns() is likely appropriate.
3165 * @parent_tsf: the time at the start of reception of the first octet of the
3166 * timestamp field of the frame. The time is the TSF of the BSS specified
3167 * by %parent_bssid.
3168 * @parent_bssid: the BSS according to which %parent_tsf is set. This is set to
3169 * the BSS that requested the scan in which the beacon/probe was received.
3170 * @chains: bitmask for filled values in @chain_signal.
3171 * @chain_signal: per-chain signal strength of last received BSS in dBm.
3172 * @restrict_use: restrict usage, if not set, assume @use_for is
3173 * %NL80211_BSS_USE_FOR_NORMAL.
3174 * @use_for: bitmap of possible usage for this BSS, see
3175 * &enum nl80211_bss_use_for
3176 * @cannot_use_reasons: the reasons (bitmap) for not being able to connect,
3177 * if @restrict_use is set and @use_for is zero (empty); may be 0 for
3178 * unspecified reasons; see &enum nl80211_bss_cannot_use_reasons
3179 * @drv_data: Data to be passed through to @inform_bss
3180 */
3181 struct cfg80211_inform_bss {
3182 struct ieee80211_channel *chan;
3183 s32 signal;
3184 u64 boottime_ns;
3185 u64 parent_tsf;
3186 u8 parent_bssid[ETH_ALEN] __aligned(2);
3187 u8 chains;
3188 s8 chain_signal[IEEE80211_MAX_CHAINS];
3189
3190 u8 restrict_use:1, use_for:7;
3191 u8 cannot_use_reasons;
3192
3193 void *drv_data;
3194 };
3195
3196 /**
3197 * struct cfg80211_bss_ies - BSS entry IE data
3198 * @tsf: TSF contained in the frame that carried these IEs
3199 * @rcu_head: internal use, for freeing
3200 * @len: length of the IEs
3201 * @from_beacon: these IEs are known to come from a beacon
3202 * @data: IE data
3203 */
3204 struct cfg80211_bss_ies {
3205 u64 tsf;
3206 struct rcu_head rcu_head;
3207 int len;
3208 bool from_beacon;
3209 u8 data[];
3210 };
3211
3212 /**
3213 * struct cfg80211_bss - BSS description
3214 *
3215 * This structure describes a BSS (which may also be a mesh network)
3216 * for use in scan results and similar.
3217 *
3218 * @channel: channel this BSS is on
3219 * @bssid: BSSID of the BSS
3220 * @beacon_interval: the beacon interval as from the frame
3221 * @capability: the capability field in host byte order
3222 * @ies: the information elements (Note that there is no guarantee that these
3223 * are well-formed!); this is a pointer to either the beacon_ies or
3224 * proberesp_ies depending on whether Probe Response frame has been
3225 * received. It is always non-%NULL.
3226 * @beacon_ies: the information elements from the last Beacon frame
3227 * (implementation note: if @hidden_beacon_bss is set this struct doesn't
3228 * own the beacon_ies, but they're just pointers to the ones from the
3229 * @hidden_beacon_bss struct)
3230 * @proberesp_ies: the information elements from the last Probe Response frame
3231 * @proberesp_ecsa_stuck: ECSA element is stuck in the Probe Response frame,
3232 * cannot rely on it having valid data
3233 * @hidden_beacon_bss: in case this BSS struct represents a probe response from
3234 * a BSS that hides the SSID in its beacon, this points to the BSS struct
3235 * that holds the beacon data. @beacon_ies is still valid, of course, and
3236 * points to the same data as hidden_beacon_bss->beacon_ies in that case.
3237 * @transmitted_bss: pointer to the transmitted BSS, if this is a
3238 * non-transmitted one (multi-BSSID support)
3239 * @nontrans_list: list of non-transmitted BSS, if this is a transmitted one
3240 * (multi-BSSID support)
3241 * @signal: signal strength value (type depends on the wiphy's signal_type)
3242 * @ts_boottime: timestamp of the last BSS update in nanoseconds since boot
3243 * @chains: bitmask for filled values in @chain_signal.
3244 * @chain_signal: per-chain signal strength of last received BSS in dBm.
3245 * @bssid_index: index in the multiple BSS set
3246 * @max_bssid_indicator: max number of members in the BSS set
3247 * @use_for: bitmap of possible usage for this BSS, see
3248 * &enum nl80211_bss_use_for
3249 * @cannot_use_reasons: the reasons (bitmap) for not being able to connect,
3250 * if @restrict_use is set and @use_for is zero (empty); may be 0 for
3251 * unspecified reasons; see &enum nl80211_bss_cannot_use_reasons
3252 * @priv: private area for driver use, has at least wiphy->bss_priv_size bytes
3253 */
3254 struct cfg80211_bss {
3255 struct ieee80211_channel *channel;
3256
3257 const struct cfg80211_bss_ies __rcu *ies;
3258 const struct cfg80211_bss_ies __rcu *beacon_ies;
3259 const struct cfg80211_bss_ies __rcu *proberesp_ies;
3260
3261 struct cfg80211_bss *hidden_beacon_bss;
3262 struct cfg80211_bss *transmitted_bss;
3263 struct list_head nontrans_list;
3264
3265 s32 signal;
3266
3267 u64 ts_boottime;
3268
3269 u16 beacon_interval;
3270 u16 capability;
3271
3272 u8 bssid[ETH_ALEN];
3273 u8 chains;
3274 s8 chain_signal[IEEE80211_MAX_CHAINS];
3275
3276 u8 proberesp_ecsa_stuck:1;
3277
3278 u8 bssid_index;
3279 u8 max_bssid_indicator;
3280
3281 u8 use_for;
3282 u8 cannot_use_reasons;
3283
3284 u8 priv[] __aligned(sizeof(void *));
3285 };
3286
3287 /**
3288 * ieee80211_bss_get_elem - find element with given ID
3289 * @bss: the bss to search
3290 * @id: the element ID
3291 *
3292 * Note that the return value is an RCU-protected pointer, so
3293 * rcu_read_lock() must be held when calling this function.
3294 * Return: %NULL if not found.
3295 */
3296 const struct element *ieee80211_bss_get_elem(struct cfg80211_bss *bss, u8 id);
3297
3298 /**
3299 * ieee80211_bss_get_ie - find IE with given ID
3300 * @bss: the bss to search
3301 * @id: the element ID
3302 *
3303 * Note that the return value is an RCU-protected pointer, so
3304 * rcu_read_lock() must be held when calling this function.
3305 * Return: %NULL if not found.
3306 */
ieee80211_bss_get_ie(struct cfg80211_bss * bss,u8 id)3307 static inline const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 id)
3308 {
3309 return (const void *)ieee80211_bss_get_elem(bss, id);
3310 }
3311
3312
3313 /**
3314 * struct cfg80211_auth_request - Authentication request data
3315 *
3316 * This structure provides information needed to complete IEEE 802.11
3317 * authentication.
3318 *
3319 * @bss: The BSS to authenticate with, the callee must obtain a reference
3320 * to it if it needs to keep it.
3321 * @supported_selectors: List of selectors that should be assumed to be
3322 * supported by the station.
3323 * SAE_H2E must be assumed supported if set to %NULL.
3324 * @supported_selectors_len: Length of supported_selectors in octets.
3325 * @auth_type: Authentication type (algorithm)
3326 * @ie: Extra IEs to add to Authentication frame or %NULL
3327 * @ie_len: Length of ie buffer in octets
3328 * @key_len: length of WEP key for shared key authentication
3329 * @key_idx: index of WEP key for shared key authentication
3330 * @key: WEP key for shared key authentication
3331 * @auth_data: Fields and elements in Authentication frames. This contains
3332 * the authentication frame body (non-IE and IE data), excluding the
3333 * Authentication algorithm number, i.e., starting at the Authentication
3334 * transaction sequence number field.
3335 * @auth_data_len: Length of auth_data buffer in octets
3336 * @link_id: if >= 0, indicates authentication should be done as an MLD,
3337 * the interface address is included as the MLD address and the
3338 * necessary link (with the given link_id) will be created (and
3339 * given an MLD address) by the driver
3340 * @ap_mld_addr: AP MLD address in case of authentication request with
3341 * an AP MLD, valid iff @link_id >= 0
3342 */
3343 struct cfg80211_auth_request {
3344 struct cfg80211_bss *bss;
3345 const u8 *ie;
3346 size_t ie_len;
3347 const u8 *supported_selectors;
3348 u8 supported_selectors_len;
3349 enum nl80211_auth_type auth_type;
3350 const u8 *key;
3351 u8 key_len;
3352 s8 key_idx;
3353 const u8 *auth_data;
3354 size_t auth_data_len;
3355 s8 link_id;
3356 const u8 *ap_mld_addr;
3357 };
3358
3359 /**
3360 * struct cfg80211_assoc_link - per-link information for MLO association
3361 * @bss: the BSS pointer, see also &struct cfg80211_assoc_request::bss;
3362 * if this is %NULL for a link, that link is not requested
3363 * @elems: extra elements for the per-STA profile for this link
3364 * @elems_len: length of the elements
3365 * @error: per-link error code, must be <= 0. If there is an error, then the
3366 * operation as a whole must fail.
3367 */
3368 struct cfg80211_assoc_link {
3369 struct cfg80211_bss *bss;
3370 const u8 *elems;
3371 size_t elems_len;
3372 int error;
3373 };
3374
3375 /**
3376 * struct cfg80211_ml_reconf_req - MLO link reconfiguration request
3377 * @add_links: data for links to add, see &struct cfg80211_assoc_link
3378 * @rem_links: bitmap of links to remove
3379 * @ext_mld_capa_ops: extended MLD capabilities and operations set by
3380 * userspace for the ML reconfiguration action frame
3381 */
3382 struct cfg80211_ml_reconf_req {
3383 struct cfg80211_assoc_link add_links[IEEE80211_MLD_MAX_NUM_LINKS];
3384 u16 rem_links;
3385 u16 ext_mld_capa_ops;
3386 };
3387
3388 /**
3389 * enum cfg80211_assoc_req_flags - Over-ride default behaviour in association.
3390 *
3391 * @ASSOC_REQ_DISABLE_HT: Disable HT (802.11n)
3392 * @ASSOC_REQ_DISABLE_VHT: Disable VHT
3393 * @ASSOC_REQ_USE_RRM: Declare RRM capability in this association
3394 * @CONNECT_REQ_EXTERNAL_AUTH_SUPPORT: User space indicates external
3395 * authentication capability. Drivers can offload authentication to
3396 * userspace if this flag is set. Only applicable for cfg80211_connect()
3397 * request (connect callback).
3398 * @ASSOC_REQ_DISABLE_HE: Disable HE
3399 * @ASSOC_REQ_DISABLE_EHT: Disable EHT
3400 * @CONNECT_REQ_MLO_SUPPORT: Userspace indicates support for handling MLD links.
3401 * Drivers shall disable MLO features for the current association if this
3402 * flag is not set.
3403 * @ASSOC_REQ_SPP_AMSDU: SPP A-MSDUs will be used on this connection (if any)
3404 * @ASSOC_REQ_DISABLE_UHR: Disable UHR
3405 */
3406 enum cfg80211_assoc_req_flags {
3407 ASSOC_REQ_DISABLE_HT = BIT(0),
3408 ASSOC_REQ_DISABLE_VHT = BIT(1),
3409 ASSOC_REQ_USE_RRM = BIT(2),
3410 CONNECT_REQ_EXTERNAL_AUTH_SUPPORT = BIT(3),
3411 ASSOC_REQ_DISABLE_HE = BIT(4),
3412 ASSOC_REQ_DISABLE_EHT = BIT(5),
3413 CONNECT_REQ_MLO_SUPPORT = BIT(6),
3414 ASSOC_REQ_SPP_AMSDU = BIT(7),
3415 ASSOC_REQ_DISABLE_UHR = BIT(8),
3416 };
3417
3418 /**
3419 * struct cfg80211_assoc_request - (Re)Association request data
3420 *
3421 * This structure provides information needed to complete IEEE 802.11
3422 * (re)association.
3423 * @bss: The BSS to associate with. If the call is successful the driver is
3424 * given a reference that it must give back to cfg80211_send_rx_assoc()
3425 * or to cfg80211_assoc_timeout(). To ensure proper refcounting, new
3426 * association requests while already associating must be rejected.
3427 * This also applies to the @links.bss parameter, which is used instead
3428 * of this one (it is %NULL) for MLO associations.
3429 * @ie: Extra IEs to add to (Re)Association Request frame or %NULL
3430 * @ie_len: Length of ie buffer in octets
3431 * @use_mfp: Use management frame protection (IEEE 802.11w) in this association
3432 * @crypto: crypto settings
3433 * @prev_bssid: previous BSSID, if not %NULL use reassociate frame. This is used
3434 * to indicate a request to reassociate within the ESS instead of a request
3435 * do the initial association with the ESS. When included, this is set to
3436 * the BSSID of the current association, i.e., to the value that is
3437 * included in the Current AP address field of the Reassociation Request
3438 * frame.
3439 * @flags: See &enum cfg80211_assoc_req_flags
3440 * @supported_selectors: supported BSS selectors in IEEE 802.11 format
3441 * (or %NULL for no change).
3442 * If %NULL, then support for SAE_H2E should be assumed.
3443 * @supported_selectors_len: number of supported BSS selectors
3444 * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
3445 * will be used in ht_capa. Un-supported values will be ignored.
3446 * @ht_capa_mask: The bits of ht_capa which are to be used.
3447 * @vht_capa: VHT capability override
3448 * @vht_capa_mask: VHT capability mask indicating which fields to use
3449 * @fils_kek: FILS KEK for protecting (Re)Association Request/Response frame or
3450 * %NULL if FILS is not used.
3451 * @fils_kek_len: Length of fils_kek in octets
3452 * @fils_nonces: FILS nonces (part of AAD) for protecting (Re)Association
3453 * Request/Response frame or %NULL if FILS is not used. This field starts
3454 * with 16 octets of STA Nonce followed by 16 octets of AP Nonce.
3455 * @s1g_capa: S1G capability override
3456 * @s1g_capa_mask: S1G capability override mask
3457 * @links: per-link information for MLO connections
3458 * @link_id: >= 0 for MLO connections, where links are given, and indicates
3459 * the link on which the association request should be sent
3460 * @ap_mld_addr: AP MLD address in case of MLO association request,
3461 * valid iff @link_id >= 0
3462 * @ext_mld_capa_ops: extended MLD capabilities and operations set by
3463 * userspace for the association
3464 */
3465 struct cfg80211_assoc_request {
3466 struct cfg80211_bss *bss;
3467 const u8 *ie, *prev_bssid;
3468 size_t ie_len;
3469 struct cfg80211_crypto_settings crypto;
3470 bool use_mfp;
3471 u32 flags;
3472 const u8 *supported_selectors;
3473 u8 supported_selectors_len;
3474 struct ieee80211_ht_cap ht_capa;
3475 struct ieee80211_ht_cap ht_capa_mask;
3476 struct ieee80211_vht_cap vht_capa, vht_capa_mask;
3477 const u8 *fils_kek;
3478 size_t fils_kek_len;
3479 const u8 *fils_nonces;
3480 struct ieee80211_s1g_cap s1g_capa, s1g_capa_mask;
3481 struct cfg80211_assoc_link links[IEEE80211_MLD_MAX_NUM_LINKS];
3482 const u8 *ap_mld_addr;
3483 s8 link_id;
3484 u16 ext_mld_capa_ops;
3485 };
3486
3487 /**
3488 * struct cfg80211_deauth_request - Deauthentication request data
3489 *
3490 * This structure provides information needed to complete IEEE 802.11
3491 * deauthentication.
3492 *
3493 * @bssid: the BSSID or AP MLD address to deauthenticate from
3494 * @ie: Extra IEs to add to Deauthentication frame or %NULL
3495 * @ie_len: Length of ie buffer in octets
3496 * @reason_code: The reason code for the deauthentication
3497 * @local_state_change: if set, change local state only and
3498 * do not set a deauth frame
3499 */
3500 struct cfg80211_deauth_request {
3501 const u8 *bssid;
3502 const u8 *ie;
3503 size_t ie_len;
3504 u16 reason_code;
3505 bool local_state_change;
3506 };
3507
3508 /**
3509 * struct cfg80211_disassoc_request - Disassociation request data
3510 *
3511 * This structure provides information needed to complete IEEE 802.11
3512 * disassociation.
3513 *
3514 * @ap_addr: the BSSID or AP MLD address to disassociate from
3515 * @ie: Extra IEs to add to Disassociation frame or %NULL
3516 * @ie_len: Length of ie buffer in octets
3517 * @reason_code: The reason code for the disassociation
3518 * @local_state_change: This is a request for a local state only, i.e., no
3519 * Disassociation frame is to be transmitted.
3520 */
3521 struct cfg80211_disassoc_request {
3522 const u8 *ap_addr;
3523 const u8 *ie;
3524 size_t ie_len;
3525 u16 reason_code;
3526 bool local_state_change;
3527 };
3528
3529 /**
3530 * struct cfg80211_ibss_params - IBSS parameters
3531 *
3532 * This structure defines the IBSS parameters for the join_ibss()
3533 * method.
3534 *
3535 * @ssid: The SSID, will always be non-null.
3536 * @ssid_len: The length of the SSID, will always be non-zero.
3537 * @bssid: Fixed BSSID requested, maybe be %NULL, if set do not
3538 * search for IBSSs with a different BSSID.
3539 * @chandef: defines the channel to use if no other IBSS to join can be found
3540 * @channel_fixed: The channel should be fixed -- do not search for
3541 * IBSSs to join on other channels.
3542 * @ie: information element(s) to include in the beacon
3543 * @ie_len: length of that
3544 * @beacon_interval: beacon interval to use
3545 * @privacy: this is a protected network, keys will be configured
3546 * after joining
3547 * @control_port: whether user space controls IEEE 802.1X port, i.e.,
3548 * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is
3549 * required to assume that the port is unauthorized until authorized by
3550 * user space. Otherwise, port is marked authorized by default.
3551 * @control_port_over_nl80211: TRUE if userspace expects to exchange control
3552 * port frames over NL80211 instead of the network interface.
3553 * @userspace_handles_dfs: whether user space controls DFS operation, i.e.
3554 * changes the channel when a radar is detected. This is required
3555 * to operate on DFS channels.
3556 * @basic_rates: bitmap of basic rates to use when creating the IBSS
3557 * @mcast_rate: per-band multicast rate index + 1 (0: disabled)
3558 * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
3559 * will be used in ht_capa. Un-supported values will be ignored.
3560 * @ht_capa_mask: The bits of ht_capa which are to be used.
3561 * @wep_keys: static WEP keys, if not NULL points to an array of
3562 * CFG80211_MAX_WEP_KEYS WEP keys
3563 * @wep_tx_key: key index (0..3) of the default TX static WEP key
3564 */
3565 struct cfg80211_ibss_params {
3566 const u8 *ssid;
3567 const u8 *bssid;
3568 struct cfg80211_chan_def chandef;
3569 const u8 *ie;
3570 u8 ssid_len, ie_len;
3571 u16 beacon_interval;
3572 u32 basic_rates;
3573 bool channel_fixed;
3574 bool privacy;
3575 bool control_port;
3576 bool control_port_over_nl80211;
3577 bool userspace_handles_dfs;
3578 int mcast_rate[NUM_NL80211_BANDS];
3579 struct ieee80211_ht_cap ht_capa;
3580 struct ieee80211_ht_cap ht_capa_mask;
3581 struct key_params *wep_keys;
3582 int wep_tx_key;
3583 };
3584
3585 /**
3586 * struct cfg80211_bss_selection - connection parameters for BSS selection.
3587 *
3588 * @behaviour: requested BSS selection behaviour.
3589 * @param: parameters for requestion behaviour.
3590 * @param.band_pref: preferred band for %NL80211_BSS_SELECT_ATTR_BAND_PREF.
3591 * @param.adjust: parameters for %NL80211_BSS_SELECT_ATTR_RSSI_ADJUST.
3592 */
3593 struct cfg80211_bss_selection {
3594 enum nl80211_bss_select_attr behaviour;
3595 union {
3596 enum nl80211_band band_pref;
3597 struct cfg80211_bss_select_adjust adjust;
3598 } param;
3599 };
3600
3601 /**
3602 * struct cfg80211_connect_params - Connection parameters
3603 *
3604 * This structure provides information needed to complete IEEE 802.11
3605 * authentication and association.
3606 *
3607 * @channel: The channel to use or %NULL if not specified (auto-select based
3608 * on scan results)
3609 * @channel_hint: The channel of the recommended BSS for initial connection or
3610 * %NULL if not specified
3611 * @bssid: The AP BSSID or %NULL if not specified (auto-select based on scan
3612 * results)
3613 * @bssid_hint: The recommended AP BSSID for initial connection to the BSS or
3614 * %NULL if not specified. Unlike the @bssid parameter, the driver is
3615 * allowed to ignore this @bssid_hint if it has knowledge of a better BSS
3616 * to use.
3617 * @ssid: SSID
3618 * @ssid_len: Length of ssid in octets
3619 * @auth_type: Authentication type (algorithm)
3620 * @ie: IEs for association request
3621 * @ie_len: Length of assoc_ie in octets
3622 * @privacy: indicates whether privacy-enabled APs should be used
3623 * @mfp: indicate whether management frame protection is used
3624 * @crypto: crypto settings
3625 * @key_len: length of WEP key for shared key authentication
3626 * @key_idx: index of WEP key for shared key authentication
3627 * @key: WEP key for shared key authentication
3628 * @flags: See &enum cfg80211_assoc_req_flags
3629 * @bg_scan_period: Background scan period in seconds
3630 * or -1 to indicate that default value is to be used.
3631 * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
3632 * will be used in ht_capa. Un-supported values will be ignored.
3633 * @ht_capa_mask: The bits of ht_capa which are to be used.
3634 * @vht_capa: VHT Capability overrides
3635 * @vht_capa_mask: The bits of vht_capa which are to be used.
3636 * @pbss: if set, connect to a PCP instead of AP. Valid for DMG
3637 * networks.
3638 * @bss_select: criteria to be used for BSS selection.
3639 * @prev_bssid: previous BSSID, if not %NULL use reassociate frame. This is used
3640 * to indicate a request to reassociate within the ESS instead of a request
3641 * do the initial association with the ESS. When included, this is set to
3642 * the BSSID of the current association, i.e., to the value that is
3643 * included in the Current AP address field of the Reassociation Request
3644 * frame.
3645 * @fils_erp_username: EAP re-authentication protocol (ERP) username part of the
3646 * NAI or %NULL if not specified. This is used to construct FILS wrapped
3647 * data IE.
3648 * @fils_erp_username_len: Length of @fils_erp_username in octets.
3649 * @fils_erp_realm: EAP re-authentication protocol (ERP) realm part of NAI or
3650 * %NULL if not specified. This specifies the domain name of ER server and
3651 * is used to construct FILS wrapped data IE.
3652 * @fils_erp_realm_len: Length of @fils_erp_realm in octets.
3653 * @fils_erp_next_seq_num: The next sequence number to use in the FILS ERP
3654 * messages. This is also used to construct FILS wrapped data IE.
3655 * @fils_erp_rrk: ERP re-authentication Root Key (rRK) used to derive additional
3656 * keys in FILS or %NULL if not specified.
3657 * @fils_erp_rrk_len: Length of @fils_erp_rrk in octets.
3658 * @want_1x: indicates user-space supports and wants to use 802.1X driver
3659 * offload of 4-way handshake.
3660 * @edmg: define the EDMG channels.
3661 * This may specify multiple channels and bonding options for the driver
3662 * to choose from, based on BSS configuration.
3663 */
3664 struct cfg80211_connect_params {
3665 struct ieee80211_channel *channel;
3666 struct ieee80211_channel *channel_hint;
3667 const u8 *bssid;
3668 const u8 *bssid_hint;
3669 const u8 *ssid;
3670 size_t ssid_len;
3671 enum nl80211_auth_type auth_type;
3672 const u8 *ie;
3673 size_t ie_len;
3674 bool privacy;
3675 enum nl80211_mfp mfp;
3676 struct cfg80211_crypto_settings crypto;
3677 const u8 *key;
3678 u8 key_len, key_idx;
3679 u32 flags;
3680 int bg_scan_period;
3681 struct ieee80211_ht_cap ht_capa;
3682 struct ieee80211_ht_cap ht_capa_mask;
3683 struct ieee80211_vht_cap vht_capa;
3684 struct ieee80211_vht_cap vht_capa_mask;
3685 bool pbss;
3686 struct cfg80211_bss_selection bss_select;
3687 const u8 *prev_bssid;
3688 const u8 *fils_erp_username;
3689 size_t fils_erp_username_len;
3690 const u8 *fils_erp_realm;
3691 size_t fils_erp_realm_len;
3692 u16 fils_erp_next_seq_num;
3693 const u8 *fils_erp_rrk;
3694 size_t fils_erp_rrk_len;
3695 bool want_1x;
3696 struct ieee80211_edmg edmg;
3697 };
3698
3699 /**
3700 * enum cfg80211_connect_params_changed - Connection parameters being updated
3701 *
3702 * This enum provides information of all connect parameters that
3703 * have to be updated as part of update_connect_params() call.
3704 *
3705 * @UPDATE_ASSOC_IES: Indicates whether association request IEs are updated
3706 * @UPDATE_FILS_ERP_INFO: Indicates that FILS connection parameters (realm,
3707 * username, erp sequence number and rrk) are updated
3708 * @UPDATE_AUTH_TYPE: Indicates that authentication type is updated
3709 */
3710 enum cfg80211_connect_params_changed {
3711 UPDATE_ASSOC_IES = BIT(0),
3712 UPDATE_FILS_ERP_INFO = BIT(1),
3713 UPDATE_AUTH_TYPE = BIT(2),
3714 };
3715
3716 /**
3717 * enum wiphy_params_flags - set_wiphy_params bitfield values
3718 * @WIPHY_PARAM_RETRY_SHORT: wiphy->retry_short has changed
3719 * @WIPHY_PARAM_RETRY_LONG: wiphy->retry_long has changed
3720 * @WIPHY_PARAM_FRAG_THRESHOLD: wiphy->frag_threshold has changed
3721 * @WIPHY_PARAM_RTS_THRESHOLD: wiphy->rts_threshold has changed
3722 * @WIPHY_PARAM_COVERAGE_CLASS: coverage class changed
3723 * @WIPHY_PARAM_DYN_ACK: dynack has been enabled
3724 * @WIPHY_PARAM_TXQ_LIMIT: TXQ packet limit has been changed
3725 * @WIPHY_PARAM_TXQ_MEMORY_LIMIT: TXQ memory limit has been changed
3726 * @WIPHY_PARAM_TXQ_QUANTUM: TXQ scheduler quantum
3727 */
3728 enum wiphy_params_flags {
3729 WIPHY_PARAM_RETRY_SHORT = BIT(0),
3730 WIPHY_PARAM_RETRY_LONG = BIT(1),
3731 WIPHY_PARAM_FRAG_THRESHOLD = BIT(2),
3732 WIPHY_PARAM_RTS_THRESHOLD = BIT(3),
3733 WIPHY_PARAM_COVERAGE_CLASS = BIT(4),
3734 WIPHY_PARAM_DYN_ACK = BIT(5),
3735 WIPHY_PARAM_TXQ_LIMIT = BIT(6),
3736 WIPHY_PARAM_TXQ_MEMORY_LIMIT = BIT(7),
3737 WIPHY_PARAM_TXQ_QUANTUM = BIT(8),
3738 };
3739
3740 #define IEEE80211_DEFAULT_AIRTIME_WEIGHT 256
3741
3742 /* The per TXQ device queue limit in airtime */
3743 #define IEEE80211_DEFAULT_AQL_TXQ_LIMIT_L 5000
3744 #define IEEE80211_DEFAULT_AQL_TXQ_LIMIT_H 12000
3745 #define IEEE80211_DEFAULT_AQL_TXQ_LIMIT_MC 50000
3746
3747 /* The per interface airtime threshold to switch to lower queue limit */
3748 #define IEEE80211_AQL_THRESHOLD 24000
3749
3750 /**
3751 * struct cfg80211_pmksa - PMK Security Association
3752 *
3753 * This structure is passed to the set/del_pmksa() method for PMKSA
3754 * caching.
3755 *
3756 * @bssid: The AP's BSSID (may be %NULL).
3757 * @pmkid: The identifier to refer a PMKSA.
3758 * @pmk: The PMK for the PMKSA identified by @pmkid. This is used for key
3759 * derivation by a FILS STA. Otherwise, %NULL.
3760 * @pmk_len: Length of the @pmk. The length of @pmk can differ depending on
3761 * the hash algorithm used to generate this.
3762 * @ssid: SSID to specify the ESS within which a PMKSA is valid when using FILS
3763 * cache identifier (may be %NULL).
3764 * @ssid_len: Length of the @ssid in octets.
3765 * @cache_id: 2-octet cache identifier advertized by a FILS AP identifying the
3766 * scope of PMKSA. This is valid only if @ssid_len is non-zero (may be
3767 * %NULL).
3768 * @pmk_lifetime: Maximum lifetime for PMKSA in seconds
3769 * (dot11RSNAConfigPMKLifetime) or 0 if not specified.
3770 * The configured PMKSA must not be used for PMKSA caching after
3771 * expiration and any keys derived from this PMK become invalid on
3772 * expiration, i.e., the current association must be dropped if the PMK
3773 * used for it expires.
3774 * @pmk_reauth_threshold: Threshold time for reauthentication (percentage of
3775 * PMK lifetime, dot11RSNAConfigPMKReauthThreshold) or 0 if not specified.
3776 * Drivers are expected to trigger a full authentication instead of using
3777 * this PMKSA for caching when reassociating to a new BSS after this
3778 * threshold to generate a new PMK before the current one expires.
3779 */
3780 struct cfg80211_pmksa {
3781 const u8 *bssid;
3782 const u8 *pmkid;
3783 const u8 *pmk;
3784 size_t pmk_len;
3785 const u8 *ssid;
3786 size_t ssid_len;
3787 const u8 *cache_id;
3788 u32 pmk_lifetime;
3789 u8 pmk_reauth_threshold;
3790 };
3791
3792 /**
3793 * struct cfg80211_pkt_pattern - packet pattern
3794 * @mask: bitmask where to match pattern and where to ignore bytes,
3795 * one bit per byte, in same format as nl80211
3796 * @pattern: bytes to match where bitmask is 1
3797 * @pattern_len: length of pattern (in bytes)
3798 * @pkt_offset: packet offset (in bytes)
3799 *
3800 * Internal note: @mask and @pattern are allocated in one chunk of
3801 * memory, free @mask only!
3802 */
3803 struct cfg80211_pkt_pattern {
3804 const u8 *mask, *pattern;
3805 int pattern_len;
3806 int pkt_offset;
3807 };
3808
3809 /**
3810 * struct cfg80211_wowlan_tcp - TCP connection parameters
3811 *
3812 * @sock: (internal) socket for source port allocation
3813 * @src: source IP address
3814 * @dst: destination IP address
3815 * @dst_mac: destination MAC address
3816 * @src_port: source port
3817 * @dst_port: destination port
3818 * @payload_len: data payload length
3819 * @payload: data payload buffer
3820 * @payload_seq: payload sequence stamping configuration
3821 * @data_interval: interval at which to send data packets
3822 * @wake_len: wakeup payload match length
3823 * @wake_data: wakeup payload match data
3824 * @wake_mask: wakeup payload match mask
3825 * @tokens_size: length of the tokens buffer
3826 * @payload_tok: payload token usage configuration
3827 */
3828 struct cfg80211_wowlan_tcp {
3829 struct socket *sock;
3830 __be32 src, dst;
3831 u16 src_port, dst_port;
3832 u8 dst_mac[ETH_ALEN];
3833 int payload_len;
3834 const u8 *payload;
3835 struct nl80211_wowlan_tcp_data_seq payload_seq;
3836 u32 data_interval;
3837 u32 wake_len;
3838 const u8 *wake_data, *wake_mask;
3839 u32 tokens_size;
3840 /* must be last, variable member */
3841 struct nl80211_wowlan_tcp_data_token payload_tok;
3842 };
3843
3844 /**
3845 * struct cfg80211_wowlan - Wake on Wireless-LAN support info
3846 *
3847 * This structure defines the enabled WoWLAN triggers for the device.
3848 * @any: wake up on any activity -- special trigger if device continues
3849 * operating as normal during suspend
3850 * @disconnect: wake up if getting disconnected
3851 * @magic_pkt: wake up on receiving magic packet
3852 * @patterns: wake up on receiving packet matching a pattern
3853 * @n_patterns: number of patterns
3854 * @gtk_rekey_failure: wake up on GTK rekey failure
3855 * @eap_identity_req: wake up on EAP identity request packet
3856 * @four_way_handshake: wake up on 4-way handshake
3857 * @rfkill_release: wake up when rfkill is released
3858 * @tcp: TCP connection establishment/wakeup parameters, see nl80211.h.
3859 * NULL if not configured.
3860 * @nd_config: configuration for the scan to be used for net detect wake.
3861 */
3862 struct cfg80211_wowlan {
3863 bool any, disconnect, magic_pkt, gtk_rekey_failure,
3864 eap_identity_req, four_way_handshake,
3865 rfkill_release;
3866 struct cfg80211_pkt_pattern *patterns;
3867 struct cfg80211_wowlan_tcp *tcp;
3868 int n_patterns;
3869 struct cfg80211_sched_scan_request *nd_config;
3870 };
3871
3872 /**
3873 * struct cfg80211_coalesce_rules - Coalesce rule parameters
3874 *
3875 * This structure defines coalesce rule for the device.
3876 * @delay: maximum coalescing delay in msecs.
3877 * @condition: condition for packet coalescence.
3878 * see &enum nl80211_coalesce_condition.
3879 * @patterns: array of packet patterns
3880 * @n_patterns: number of patterns
3881 */
3882 struct cfg80211_coalesce_rules {
3883 int delay;
3884 enum nl80211_coalesce_condition condition;
3885 struct cfg80211_pkt_pattern *patterns;
3886 int n_patterns;
3887 };
3888
3889 /**
3890 * struct cfg80211_coalesce - Packet coalescing settings
3891 *
3892 * This structure defines coalescing settings.
3893 * @rules: array of coalesce rules
3894 * @n_rules: number of rules
3895 */
3896 struct cfg80211_coalesce {
3897 int n_rules;
3898 struct cfg80211_coalesce_rules rules[] __counted_by(n_rules);
3899 };
3900
3901 /**
3902 * struct cfg80211_wowlan_nd_match - information about the match
3903 *
3904 * @ssid: SSID of the match that triggered the wake up
3905 * @n_channels: Number of channels where the match occurred. This
3906 * value may be zero if the driver can't report the channels.
3907 * @channels: center frequencies of the channels where a match
3908 * occurred (in MHz)
3909 */
3910 struct cfg80211_wowlan_nd_match {
3911 struct cfg80211_ssid ssid;
3912 int n_channels;
3913 u32 channels[] __counted_by(n_channels);
3914 };
3915
3916 /**
3917 * struct cfg80211_wowlan_nd_info - net detect wake up information
3918 *
3919 * @n_matches: Number of match information instances provided in
3920 * @matches. This value may be zero if the driver can't provide
3921 * match information.
3922 * @matches: Array of pointers to matches containing information about
3923 * the matches that triggered the wake up.
3924 */
3925 struct cfg80211_wowlan_nd_info {
3926 int n_matches;
3927 struct cfg80211_wowlan_nd_match *matches[] __counted_by(n_matches);
3928 };
3929
3930 /**
3931 * struct cfg80211_wowlan_wakeup - wakeup report
3932 * @disconnect: woke up by getting disconnected
3933 * @magic_pkt: woke up by receiving magic packet
3934 * @gtk_rekey_failure: woke up by GTK rekey failure
3935 * @eap_identity_req: woke up by EAP identity request packet
3936 * @four_way_handshake: woke up by 4-way handshake
3937 * @rfkill_release: woke up by rfkill being released
3938 * @pattern_idx: pattern that caused wakeup, -1 if not due to pattern
3939 * @packet_present_len: copied wakeup packet data
3940 * @packet_len: original wakeup packet length
3941 * @packet: The packet causing the wakeup, if any.
3942 * @packet_80211: For pattern match, magic packet and other data
3943 * frame triggers an 802.3 frame should be reported, for
3944 * disconnect due to deauth 802.11 frame. This indicates which
3945 * it is.
3946 * @tcp_match: TCP wakeup packet received
3947 * @tcp_connlost: TCP connection lost or failed to establish
3948 * @tcp_nomoretokens: TCP data ran out of tokens
3949 * @net_detect: if not %NULL, woke up because of net detect
3950 * @unprot_deauth_disassoc: woke up due to unprotected deauth or
3951 * disassoc frame (in MFP).
3952 */
3953 struct cfg80211_wowlan_wakeup {
3954 bool disconnect, magic_pkt, gtk_rekey_failure,
3955 eap_identity_req, four_way_handshake,
3956 rfkill_release, packet_80211,
3957 tcp_match, tcp_connlost, tcp_nomoretokens,
3958 unprot_deauth_disassoc;
3959 s32 pattern_idx;
3960 u32 packet_present_len, packet_len;
3961 const void *packet;
3962 struct cfg80211_wowlan_nd_info *net_detect;
3963 };
3964
3965 /**
3966 * struct cfg80211_gtk_rekey_data - rekey data
3967 * @kek: key encryption key (@kek_len bytes)
3968 * @kck: key confirmation key (@kck_len bytes)
3969 * @replay_ctr: replay counter (NL80211_REPLAY_CTR_LEN bytes)
3970 * @kek_len: length of kek
3971 * @kck_len: length of kck
3972 * @akm: akm (oui, id)
3973 */
3974 struct cfg80211_gtk_rekey_data {
3975 const u8 *kek, *kck, *replay_ctr;
3976 u32 akm;
3977 u8 kek_len, kck_len;
3978 };
3979
3980 /**
3981 * struct cfg80211_update_ft_ies_params - FT IE Information
3982 *
3983 * This structure provides information needed to update the fast transition IE
3984 *
3985 * @md: The Mobility Domain ID, 2 Octet value
3986 * @ie: Fast Transition IEs
3987 * @ie_len: Length of ft_ie in octets
3988 */
3989 struct cfg80211_update_ft_ies_params {
3990 u16 md;
3991 const u8 *ie;
3992 size_t ie_len;
3993 };
3994
3995 /**
3996 * struct cfg80211_mgmt_tx_params - mgmt tx parameters
3997 *
3998 * This structure provides information needed to transmit a mgmt frame
3999 *
4000 * @chan: channel to use
4001 * @offchan: indicates whether off channel operation is required
4002 * @wait: duration for ROC
4003 * @buf: buffer to transmit
4004 * @len: buffer length
4005 * @no_cck: don't use cck rates for this frame
4006 * @dont_wait_for_ack: tells the low level not to wait for an ack
4007 * @n_csa_offsets: length of csa_offsets array
4008 * @csa_offsets: array of all the csa offsets in the frame
4009 * @link_id: for MLO, the link ID to transmit on, -1 if not given; note
4010 * that the link ID isn't validated (much), it's in range but the
4011 * link might not exist (or be used by the receiver STA)
4012 */
4013 struct cfg80211_mgmt_tx_params {
4014 struct ieee80211_channel *chan;
4015 bool offchan;
4016 unsigned int wait;
4017 const u8 *buf;
4018 size_t len;
4019 bool no_cck;
4020 bool dont_wait_for_ack;
4021 int n_csa_offsets;
4022 const u16 *csa_offsets;
4023 int link_id;
4024 };
4025
4026 /**
4027 * struct cfg80211_dscp_exception - DSCP exception
4028 *
4029 * @dscp: DSCP value that does not adhere to the user priority range definition
4030 * @up: user priority value to which the corresponding DSCP value belongs
4031 */
4032 struct cfg80211_dscp_exception {
4033 u8 dscp;
4034 u8 up;
4035 };
4036
4037 /**
4038 * struct cfg80211_dscp_range - DSCP range definition for user priority
4039 *
4040 * @low: lowest DSCP value of this user priority range, inclusive
4041 * @high: highest DSCP value of this user priority range, inclusive
4042 */
4043 struct cfg80211_dscp_range {
4044 u8 low;
4045 u8 high;
4046 };
4047
4048 /* QoS Map Set element length defined in IEEE Std 802.11-2012, 8.4.2.97 */
4049 #define IEEE80211_QOS_MAP_MAX_EX 21
4050 #define IEEE80211_QOS_MAP_LEN_MIN 16
4051 #define IEEE80211_QOS_MAP_LEN_MAX \
4052 (IEEE80211_QOS_MAP_LEN_MIN + 2 * IEEE80211_QOS_MAP_MAX_EX)
4053
4054 /**
4055 * struct cfg80211_qos_map - QoS Map Information
4056 *
4057 * This struct defines the Interworking QoS map setting for DSCP values
4058 *
4059 * @num_des: number of DSCP exceptions (0..21)
4060 * @dscp_exception: optionally up to maximum of 21 DSCP exceptions from
4061 * the user priority DSCP range definition
4062 * @up: DSCP range definition for a particular user priority
4063 */
4064 struct cfg80211_qos_map {
4065 u8 num_des;
4066 struct cfg80211_dscp_exception dscp_exception[IEEE80211_QOS_MAP_MAX_EX];
4067 struct cfg80211_dscp_range up[8];
4068 };
4069
4070 /**
4071 * DOC: Neighbor Awareness Networking (NAN)
4072 *
4073 * NAN uses two interface types:
4074 *
4075 * - %NL80211_IFTYPE_NAN: a non-netdev interface. This has two roles: (1) holds
4076 * the configuration of all NAN activities (DE parameters, synchronisation
4077 * parameters, local schedule, etc.), and (2) uses as the NAN Management
4078 * Interface (NMI), which is used for NAN management communication.
4079 *
4080 * - %NL80211_IFTYPE_NAN_DATA: The NAN Data Interface (NDI), used for data
4081 * communication with NAN peers.
4082 *
4083 * An NDI interface can only be started (IFF_UP) if the NMI one is running and
4084 * NAN is started. Before NAN is stopped, all associated NDI interfaces
4085 * must be stopped first.
4086 *
4087 * The local schedule specifies which channels the device is available on and
4088 * when. Must be cancelled before NAN is stopped.
4089 *
4090 * NAN Stations
4091 * ~~~~~~~~~~~~
4092 *
4093 * There are two types of stations corresponding to the two interface types:
4094 *
4095 * - NMI station: Represents the NAN peer. Peer-specific data such as the peer's
4096 * schedule and the HT, VHT and HE capabilities belongs to the NMI station.
4097 * Also used for Tx/Rx of NAN management frames to/from the peer.
4098 * Added on the %NL80211_IFTYPE_NAN interface.
4099 *
4100 * - NDI station: Used for Tx/Rx of data frames (and non-NAN management frames)
4101 * for a specific NDP established with the NAN peer. Added on the
4102 * %NL80211_IFTYPE_NAN_DATA interface.
4103 *
4104 * A peer may reuse its NMI address as the NDI address. In that case, two
4105 * separate stations should be added even though they share the same MAC
4106 * address.
4107 *
4108 * HT, VHT and HE capabilities should not changes after it was set. It is the
4109 * driver's responsibility to check that.
4110 *
4111 * An NDI station can only be added if the corresponding NMI station has already
4112 * been configured with HT (and possibly VHT and HE) capabilities. It is the
4113 * driver's responsibility to check that.
4114 *
4115 * All NDI stations must be removed before corresponding NMI station is removed.
4116 * Therefore, removing a NMI station implies that the associated NDI station(s)
4117 * (if any) will be removed first.
4118 *
4119 * NAN Dependencies
4120 * ~~~~~~~~~~~~~~~~
4121 *
4122 * The following diagram shows the dependencies between NAN components.
4123 * An arrow from A to B means A must be started/added before B, and B must be
4124 * stopped/removed before A:
4125 *
4126 * +-------------+
4127 * | NMI iface |---(local schedule)
4128 * +------+------+
4129 * / \
4130 * v v
4131 * +-----------+ +-------------+
4132 * | NDI iface | | NMI sta |---(peer schedule)
4133 * +-----+-----+ +------+------+
4134 * \ /
4135 * v v
4136 * +----------+
4137 * | NDI sta |
4138 * +----------+
4139 */
4140
4141 /**
4142 * struct cfg80211_nan_band_config - NAN band specific configuration
4143 *
4144 * @chan: Pointer to the IEEE 802.11 channel structure. The channel to be used
4145 * for NAN operations on this band. For 2.4 GHz band, this is always
4146 * channel 6. For 5 GHz band, the channel is either 44 or 149, according
4147 * to the regulatory constraints. If chan pointer is NULL the entire band
4148 * configuration entry is considered invalid and should not be used.
4149 * @rssi_close: RSSI close threshold used for NAN state transition algorithm
4150 * as described in chapters 3.3.6 and 3.3.7 "NAN Device Role and State
4151 * Transition" of Wi-Fi Aware Specification v4.0. If not
4152 * specified (set to 0), default device value is used. The value should
4153 * be greater than -60 dBm.
4154 * @rssi_middle: RSSI middle threshold used for NAN state transition algorithm.
4155 * as described in chapters 3.3.6 and 3.3.7 "NAN Device Role and State
4156 * Transition" of Wi-Fi Aware Specification v4.0. If not
4157 * specified (set to 0), default device value is used. The value should be
4158 * greater than -75 dBm and less than rssi_close.
4159 * @awake_dw_interval: Committed DW interval. Valid values range: 0-5. 0
4160 * indicates no wakeup for DW and can't be used on 2.4GHz band, otherwise
4161 * 2^(n-1).
4162 * @disable_scan: If true, the device will not scan this band for cluster
4163 * merge. Disabling scan on 2.4 GHz band is not allowed.
4164 */
4165 struct cfg80211_nan_band_config {
4166 struct ieee80211_channel *chan;
4167 s8 rssi_close;
4168 s8 rssi_middle;
4169 u8 awake_dw_interval;
4170 bool disable_scan;
4171 };
4172
4173 /**
4174 * struct cfg80211_nan_conf - NAN configuration
4175 *
4176 * This struct defines NAN configuration parameters
4177 *
4178 * @master_pref: master preference (1 - 255)
4179 * @bands: operating bands, a bitmap of &enum nl80211_band values.
4180 * For instance, for NL80211_BAND_2GHZ, bit 0 would be set
4181 * (i.e. BIT(NL80211_BAND_2GHZ)).
4182 * @cluster_id: cluster ID used for NAN synchronization. This is a MAC address
4183 * that can take a value from 50-6F-9A-01-00-00 to 50-6F-9A-01-FF-FF.
4184 * @scan_period: period (in seconds) between NAN scans.
4185 * @scan_dwell_time: dwell time (in milliseconds) for NAN scans.
4186 * @discovery_beacon_interval: interval (in TUs) for discovery beacons.
4187 * @enable_dw_notification: flag to enable/disable discovery window
4188 * notifications.
4189 * @band_cfgs: array of band specific configurations, indexed by
4190 * &enum nl80211_band values.
4191 * @extra_nan_attrs: pointer to additional NAN attributes.
4192 * @extra_nan_attrs_len: length of the additional NAN attributes.
4193 * @vendor_elems: pointer to vendor-specific elements.
4194 * @vendor_elems_len: length of the vendor-specific elements.
4195 */
4196 struct cfg80211_nan_conf {
4197 u8 master_pref;
4198 u8 bands;
4199 u8 cluster_id[ETH_ALEN] __aligned(2);
4200 u16 scan_period;
4201 u16 scan_dwell_time;
4202 u8 discovery_beacon_interval;
4203 bool enable_dw_notification;
4204 struct cfg80211_nan_band_config band_cfgs[NUM_NL80211_BANDS];
4205 const u8 *extra_nan_attrs;
4206 u16 extra_nan_attrs_len;
4207 const u8 *vendor_elems;
4208 u16 vendor_elems_len;
4209 };
4210
4211 #define CFG80211_NAN_SCHED_NUM_TIME_SLOTS 32
4212
4213 /**
4214 * struct cfg80211_nan_channel - NAN channel configuration
4215 *
4216 * This struct defines a NAN channel configuration
4217 *
4218 * @chandef: the channel definition
4219 * @channel_entry: pointer to the Channel Entry blob as defined in Wi-Fi Aware
4220 * (TM) 4.0 specification Table 100 (Channel Entry format for the NAN
4221 * Availability attribute).
4222 * @rx_nss: number of spatial streams supported on this channel
4223 */
4224 struct cfg80211_nan_channel {
4225 struct cfg80211_chan_def chandef;
4226 const u8 *channel_entry;
4227 u8 rx_nss;
4228 };
4229
4230 /**
4231 * struct cfg80211_nan_local_sched - NAN local schedule
4232 *
4233 * This struct defines NAN local schedule parameters
4234 *
4235 * @schedule: a mapping of time slots to chandef indexes in %nan_channels.
4236 * An unscheduled slot will be set to %NL80211_NAN_SCHED_NOT_AVAIL_SLOT.
4237 * @n_channels: number of channel definitions in %nan_channels.
4238 * @nan_avail_blob: pointer to NAN Availability attribute blob.
4239 * See %NL80211_ATTR_NAN_AVAIL_BLOB for more details.
4240 * @nan_avail_blob_len: length of the @nan_avail_blob in bytes.
4241 * @deferred: if true, the command containing this schedule configuration is a
4242 * request from the device to perform an announced schedule update. This
4243 * means that it needs to send the updated NAN availability to the peers,
4244 * and do the actual switch on the right time (i.e. at the end of the slot
4245 * after the slot in which the updated NAN Availability was sent).
4246 * See %NL80211_ATTR_NAN_SCHED_DEFERRED for more details.
4247 * If false, the schedule is applied immediately.
4248 * @nan_channels: array of NAN channel definitions that can be scheduled.
4249 */
4250 struct cfg80211_nan_local_sched {
4251 u8 schedule[CFG80211_NAN_SCHED_NUM_TIME_SLOTS];
4252 u8 n_channels;
4253 const u8 *nan_avail_blob;
4254 u16 nan_avail_blob_len;
4255 bool deferred;
4256 struct cfg80211_nan_channel nan_channels[] __counted_by(n_channels);
4257 };
4258
4259 /**
4260 * struct cfg80211_nan_peer_map - NAN peer schedule map
4261 *
4262 * This struct defines a single NAN peer schedule map
4263 *
4264 * @map_id: map ID of this schedule map
4265 * @schedule: a mapping of time slots to chandef indexes in the schedule's
4266 * @nan_channels. Each slot lasts 16TUs. An unscheduled slot will be
4267 * set to %NL80211_NAN_SCHED_NOT_AVAIL_SLOT.
4268 */
4269 struct cfg80211_nan_peer_map {
4270 u8 map_id;
4271 u8 schedule[CFG80211_NAN_SCHED_NUM_TIME_SLOTS];
4272 };
4273
4274 #define CFG80211_NAN_MAX_PEER_MAPS 2
4275 #define CFG80211_NAN_INVALID_MAP_ID 0xff
4276
4277 /**
4278 * struct cfg80211_nan_peer_sched - NAN peer schedule
4279 *
4280 * This struct defines NAN peer schedule parameters for a peer.
4281 *
4282 * @peer_addr: MAC address of the peer (NMI address)
4283 * @seq_id: sequence ID of the peer schedule.
4284 * @committed_dw: committed DW as published by the peer.
4285 * See %NL80211_ATTR_NAN_COMMITTED_DW
4286 * @max_chan_switch: maximum channel switch time in microseconds as published
4287 * by the peer. See %NL80211_ATTR_NAN_MAX_CHAN_SWITCH_TIME.
4288 * @init_ulw: initial ULWs as published by the peer.
4289 * @ulw_size: number of bytes in @init_ulw.
4290 * @n_channels: number of channel definitions in @nan_channels.
4291 * @nan_channels: array of NAN channel definitions for this schedule.
4292 * @maps: array of peer schedule maps. Unused entries have
4293 * map_id = %CFG80211_NAN_INVALID_MAP_ID.
4294 */
4295 struct cfg80211_nan_peer_sched {
4296 const u8 *peer_addr;
4297 u8 seq_id;
4298 u16 committed_dw;
4299 u16 max_chan_switch;
4300 const u8 *init_ulw;
4301 u16 ulw_size;
4302 u8 n_channels;
4303 struct cfg80211_nan_channel *nan_channels;
4304 struct cfg80211_nan_peer_map maps[CFG80211_NAN_MAX_PEER_MAPS];
4305 };
4306
4307 /**
4308 * enum cfg80211_nan_conf_changes - indicates changed fields in NAN
4309 * configuration
4310 *
4311 * @CFG80211_NAN_CONF_CHANGED_PREF: master preference
4312 * @CFG80211_NAN_CONF_CHANGED_BANDS: operating bands
4313 * @CFG80211_NAN_CONF_CHANGED_CONFIG: changed additional configuration.
4314 * When this flag is set, it indicates that some additional attribute(s)
4315 * (other then master_pref and bands) have been changed. In this case,
4316 * all the unchanged attributes will be properly configured to their
4317 * previous values. The driver doesn't need to store any
4318 * previous configuration besides master_pref and bands.
4319 */
4320 enum cfg80211_nan_conf_changes {
4321 CFG80211_NAN_CONF_CHANGED_PREF = BIT(0),
4322 CFG80211_NAN_CONF_CHANGED_BANDS = BIT(1),
4323 CFG80211_NAN_CONF_CHANGED_CONFIG = BIT(2),
4324 };
4325
4326 /**
4327 * struct cfg80211_nan_func_filter - a NAN function Rx / Tx filter
4328 *
4329 * @filter: the content of the filter
4330 * @len: the length of the filter
4331 */
4332 struct cfg80211_nan_func_filter {
4333 const u8 *filter;
4334 u8 len;
4335 };
4336
4337 /**
4338 * struct cfg80211_nan_func - a NAN function
4339 *
4340 * @type: &enum nl80211_nan_function_type
4341 * @service_id: the service ID of the function
4342 * @publish_type: &nl80211_nan_publish_type
4343 * @close_range: if true, the range should be limited. Threshold is
4344 * implementation specific.
4345 * @publish_bcast: if true, the solicited publish should be broadcasted
4346 * @subscribe_active: if true, the subscribe is active
4347 * @followup_id: the instance ID for follow up
4348 * @followup_reqid: the requester instance ID for follow up
4349 * @followup_dest: MAC address of the recipient of the follow up
4350 * @ttl: time to live counter in DW.
4351 * @serv_spec_info: Service Specific Info
4352 * @serv_spec_info_len: Service Specific Info length
4353 * @srf_include: if true, SRF is inclusive
4354 * @srf_bf: Bloom Filter
4355 * @srf_bf_len: Bloom Filter length
4356 * @srf_bf_idx: Bloom Filter index
4357 * @srf_macs: SRF MAC addresses
4358 * @srf_num_macs: number of MAC addresses in SRF
4359 * @rx_filters: rx filters that are matched with corresponding peer's tx_filter
4360 * @tx_filters: filters that should be transmitted in the SDF.
4361 * @num_rx_filters: length of &rx_filters.
4362 * @num_tx_filters: length of &tx_filters.
4363 * @instance_id: driver allocated id of the function.
4364 * @cookie: unique NAN function identifier.
4365 */
4366 struct cfg80211_nan_func {
4367 enum nl80211_nan_function_type type;
4368 u8 service_id[NL80211_NAN_FUNC_SERVICE_ID_LEN];
4369 u8 publish_type;
4370 bool close_range;
4371 bool publish_bcast;
4372 bool subscribe_active;
4373 u8 followup_id;
4374 u8 followup_reqid;
4375 struct mac_address followup_dest;
4376 u32 ttl;
4377 const u8 *serv_spec_info;
4378 u8 serv_spec_info_len;
4379 bool srf_include;
4380 const u8 *srf_bf;
4381 u8 srf_bf_len;
4382 u8 srf_bf_idx;
4383 struct mac_address *srf_macs;
4384 int srf_num_macs;
4385 struct cfg80211_nan_func_filter *rx_filters;
4386 struct cfg80211_nan_func_filter *tx_filters;
4387 u8 num_tx_filters;
4388 u8 num_rx_filters;
4389 u8 instance_id;
4390 u64 cookie;
4391 };
4392
4393 /**
4394 * struct cfg80211_pmk_conf - PMK configuration
4395 *
4396 * @aa: authenticator address
4397 * @pmk_len: PMK length in bytes.
4398 * @pmk: the PMK material
4399 * @pmk_r0_name: PMK-R0 Name. NULL if not applicable (i.e., the PMK
4400 * is not PMK-R0). When pmk_r0_name is not NULL, the pmk field
4401 * holds PMK-R0.
4402 */
4403 struct cfg80211_pmk_conf {
4404 const u8 *aa;
4405 u8 pmk_len;
4406 const u8 *pmk;
4407 const u8 *pmk_r0_name;
4408 };
4409
4410 /**
4411 * struct cfg80211_external_auth_params - Trigger External authentication.
4412 *
4413 * Commonly used across the external auth request and event interfaces.
4414 *
4415 * @action: action type / trigger for external authentication. Only significant
4416 * for the authentication request event interface (driver to user space).
4417 * @bssid: BSSID of the peer with which the authentication has
4418 * to happen. Used by both the authentication request event and
4419 * authentication response command interface.
4420 * @ssid: SSID of the AP. Used by both the authentication request event and
4421 * authentication response command interface.
4422 * @key_mgmt_suite: AKM suite of the respective authentication. Used by the
4423 * authentication request event interface.
4424 * @status: status code, %WLAN_STATUS_SUCCESS for successful authentication,
4425 * use %WLAN_STATUS_UNSPECIFIED_FAILURE if user space cannot give you
4426 * the real status code for failures. Used only for the authentication
4427 * response command interface (user space to driver).
4428 * @pmkid: The identifier to refer a PMKSA.
4429 * @mld_addr: MLD address of the peer. Used by the authentication request event
4430 * interface. Driver indicates this to enable MLO during the authentication
4431 * offload to user space. Driver shall look at %NL80211_ATTR_MLO_SUPPORT
4432 * flag capability in NL80211_CMD_CONNECT to know whether the user space
4433 * supports enabling MLO during the authentication offload.
4434 * User space should use the address of the interface (on which the
4435 * authentication request event reported) as self MLD address. User space
4436 * and driver should use MLD addresses in RA, TA and BSSID fields of
4437 * authentication frames sent or received via cfg80211. The driver
4438 * translates the MLD addresses to/from link addresses based on the link
4439 * chosen for the authentication.
4440 */
4441 struct cfg80211_external_auth_params {
4442 enum nl80211_external_auth_action action;
4443 u8 bssid[ETH_ALEN] __aligned(2);
4444 struct cfg80211_ssid ssid;
4445 unsigned int key_mgmt_suite;
4446 u16 status;
4447 const u8 *pmkid;
4448 u8 mld_addr[ETH_ALEN] __aligned(2);
4449 };
4450
4451 /**
4452 * struct cfg80211_ftm_responder_stats - FTM responder statistics
4453 *
4454 * @filled: bitflag of flags using the bits of &enum nl80211_ftm_stats to
4455 * indicate the relevant values in this struct for them
4456 * @success_num: number of FTM sessions in which all frames were successfully
4457 * answered
4458 * @partial_num: number of FTM sessions in which part of frames were
4459 * successfully answered
4460 * @failed_num: number of failed FTM sessions
4461 * @asap_num: number of ASAP FTM sessions
4462 * @non_asap_num: number of non-ASAP FTM sessions
4463 * @total_duration_ms: total sessions durations - gives an indication
4464 * of how much time the responder was busy
4465 * @unknown_triggers_num: number of unknown FTM triggers - triggers from
4466 * initiators that didn't finish successfully the negotiation phase with
4467 * the responder
4468 * @reschedule_requests_num: number of FTM reschedule requests - initiator asks
4469 * for a new scheduling although it already has scheduled FTM slot
4470 * @out_of_window_triggers_num: total FTM triggers out of scheduled window
4471 */
4472 struct cfg80211_ftm_responder_stats {
4473 u32 filled;
4474 u32 success_num;
4475 u32 partial_num;
4476 u32 failed_num;
4477 u32 asap_num;
4478 u32 non_asap_num;
4479 u64 total_duration_ms;
4480 u32 unknown_triggers_num;
4481 u32 reschedule_requests_num;
4482 u32 out_of_window_triggers_num;
4483 };
4484
4485 /**
4486 * struct cfg80211_pmsr_ftm_result - FTM result
4487 * @failure_reason: if this measurement failed (PMSR status is
4488 * %NL80211_PMSR_STATUS_FAILURE), this gives a more precise
4489 * reason than just "failure"
4490 * @burst_index: if reporting partial results, this is the index
4491 * in [0 .. num_bursts-1] of the burst that's being reported
4492 * @num_ftmr_attempts: number of FTM request frames transmitted
4493 * @num_ftmr_successes: number of FTM request frames acked
4494 * @busy_retry_time: if failure_reason is %NL80211_PMSR_FTM_FAILURE_PEER_BUSY,
4495 * fill this to indicate in how many seconds a retry is deemed possible
4496 * by the responder
4497 * @num_bursts_exp: actual number of bursts exponent negotiated
4498 * @burst_duration: actual burst duration negotiated
4499 * @ftms_per_burst: actual FTMs per burst negotiated
4500 * @burst_period: actual burst period negotiated in units of 100ms
4501 * @lci_len: length of LCI information (if present)
4502 * @civicloc_len: length of civic location information (if present)
4503 * @lci: LCI data (may be %NULL)
4504 * @civicloc: civic location data (may be %NULL)
4505 * @rssi_avg: average RSSI over FTM action frames reported
4506 * @rssi_spread: spread of the RSSI over FTM action frames reported
4507 * @tx_rate: bitrate for transmitted FTM action frame response
4508 * @rx_rate: bitrate of received FTM action frame
4509 * @rtt_avg: average of RTTs measured (must have either this or @dist_avg)
4510 * @rtt_variance: variance of RTTs measured (note that standard deviation is
4511 * the square root of the variance)
4512 * @rtt_spread: spread of the RTTs measured
4513 * @dist_avg: average of distances (mm) measured
4514 * (must have either this or @rtt_avg)
4515 * @dist_variance: variance of distances measured (see also @rtt_variance)
4516 * @dist_spread: spread of distances measured (see also @rtt_spread)
4517 * @tx_ltf_repetition_count: negotiated value of number of tx ltf repetitions
4518 * in NDP frames
4519 * @rx_ltf_repetition_count: negotiated value of number of rx ltf repetitions
4520 * in NDP frames
4521 * @max_time_between_measurements: the negotiated maximum interval (in units of
4522 * 10 ms) by which the ISTA must complete the next measurement cycle.
4523 * @min_time_between_measurements: the negotiated minimum interval (in units of
4524 * 100 us) between two consecutive range measurements initiated by the
4525 * ISTA.
4526 * @num_tx_spatial_streams: number of Tx space-time streams used in the NDP
4527 * frame during the measurement sounding phase.
4528 * @num_rx_spatial_streams: number of Rx space-time streams used in the NDP
4529 * frame during the measurement sounding phase.
4530 * @nominal_time: negotiated nominal duration between adjacent availability
4531 * windows in units of milliseconds (u32).
4532 * @availability_window: negotiated availability window time used in this
4533 * session in units of milliseconds (u8).
4534 * @chan_width: band width used for measurement.
4535 * @preamble: preamble used for measurement.
4536 * @num_ftmr_attempts_valid: @num_ftmr_attempts is valid
4537 * @num_ftmr_successes_valid: @num_ftmr_successes is valid
4538 * @rssi_avg_valid: @rssi_avg is valid
4539 * @rssi_spread_valid: @rssi_spread is valid
4540 * @tx_rate_valid: @tx_rate is valid
4541 * @rx_rate_valid: @rx_rate is valid
4542 * @rtt_avg_valid: @rtt_avg is valid
4543 * @rtt_variance_valid: @rtt_variance is valid
4544 * @rtt_spread_valid: @rtt_spread is valid
4545 * @dist_avg_valid: @dist_avg is valid
4546 * @dist_variance_valid: @dist_variance is valid
4547 * @dist_spread_valid: @dist_spread is valid
4548 * @tx_ltf_repetition_count_valid: @tx_ltf_repetition_count is valid
4549 * @rx_ltf_repetition_count_valid: @rx_ltf_repetition_count is valid
4550 * @max_time_between_measurements_valid: @max_time_between_measurements is valid
4551 * @min_time_between_measurements_valid: @min_time_between_measurements is valid
4552 * @num_tx_spatial_streams_valid: @num_tx_spatial_streams is valid
4553 * @num_rx_spatial_streams_valid: @num_rx_spatial_streams is valid
4554 * @nominal_time_valid: @nominal_time is valid
4555 * @availability_window_valid: @availability_window is valid
4556 * @chan_width_valid: @chan_width is valid.
4557 * @preamble_valid: @preamble is valid.
4558 * @is_delayed_lmr: indicates if the reported LMR is of the current burst or the
4559 * previous burst, flag.
4560 */
4561 struct cfg80211_pmsr_ftm_result {
4562 const u8 *lci;
4563 const u8 *civicloc;
4564 unsigned int lci_len;
4565 unsigned int civicloc_len;
4566 enum nl80211_peer_measurement_ftm_failure_reasons failure_reason;
4567 u32 num_ftmr_attempts, num_ftmr_successes;
4568 s16 burst_index;
4569 u8 busy_retry_time;
4570 u8 num_bursts_exp;
4571 u8 burst_duration;
4572 u8 ftms_per_burst;
4573 u16 burst_period;
4574 s32 rssi_avg;
4575 s32 rssi_spread;
4576 struct rate_info tx_rate, rx_rate;
4577 s64 rtt_avg;
4578 s64 rtt_variance;
4579 s64 rtt_spread;
4580 s64 dist_avg;
4581 s64 dist_variance;
4582 s64 dist_spread;
4583 u32 tx_ltf_repetition_count;
4584 u32 rx_ltf_repetition_count;
4585 u32 max_time_between_measurements;
4586 u32 min_time_between_measurements;
4587 u8 num_tx_spatial_streams;
4588 u8 num_rx_spatial_streams;
4589 u32 nominal_time;
4590 u8 availability_window;
4591 enum nl80211_chan_width chan_width;
4592 enum nl80211_preamble preamble;
4593
4594 u32 num_ftmr_attempts_valid:1,
4595 num_ftmr_successes_valid:1,
4596 rssi_avg_valid:1,
4597 rssi_spread_valid:1,
4598 tx_rate_valid:1,
4599 rx_rate_valid:1,
4600 rtt_avg_valid:1,
4601 rtt_variance_valid:1,
4602 rtt_spread_valid:1,
4603 dist_avg_valid:1,
4604 dist_variance_valid:1,
4605 dist_spread_valid:1,
4606 tx_ltf_repetition_count_valid:1,
4607 rx_ltf_repetition_count_valid:1,
4608 max_time_between_measurements_valid:1,
4609 min_time_between_measurements_valid:1,
4610 num_tx_spatial_streams_valid:1,
4611 num_rx_spatial_streams_valid:1,
4612 nominal_time_valid:1,
4613 availability_window_valid:1,
4614 chan_width_valid:1,
4615 preamble_valid:1,
4616 is_delayed_lmr:1;
4617 };
4618
4619 /**
4620 * struct cfg80211_pmsr_result - peer measurement result
4621 * @addr: address of the peer
4622 * @host_time: host time (use ktime_get_boottime() adjust to the time when the
4623 * measurement was made)
4624 * @ap_tsf: AP's TSF at measurement time
4625 * @status: status of the measurement
4626 * @final: if reporting partial results, mark this as the last one; if not
4627 * reporting partial results always set this flag
4628 * @ap_tsf_valid: indicates the @ap_tsf value is valid
4629 * @type: type of the measurement reported, note that we only support reporting
4630 * one type at a time, but you can report multiple results separately and
4631 * they're all aggregated for userspace.
4632 * @ftm: FTM result
4633 */
4634 struct cfg80211_pmsr_result {
4635 u64 host_time, ap_tsf;
4636 enum nl80211_peer_measurement_status status;
4637
4638 u8 addr[ETH_ALEN];
4639
4640 u8 final:1,
4641 ap_tsf_valid:1;
4642
4643 enum nl80211_peer_measurement_type type;
4644
4645 union {
4646 struct cfg80211_pmsr_ftm_result ftm;
4647 };
4648 };
4649
4650 /**
4651 * struct cfg80211_pmsr_ftm_request_peer - FTM request data
4652 * @requested: indicates FTM is requested
4653 * @preamble: frame preamble to use
4654 * @burst_period: burst period to use
4655 * @asap: indicates to use ASAP mode
4656 * @num_bursts_exp: number of bursts exponent
4657 * @burst_duration: burst duration. If @trigger_based or @non_trigger_based is
4658 * set, this is the burst duration in milliseconds, and zero means the
4659 * device should pick an appropriate value based on @ftms_per_burst.
4660 * @ftms_per_burst: number of FTMs per burst. If set to 0, the firmware or
4661 * driver can automatically select an appropriate value.
4662 * @ftmr_retries: number of retries for FTM request
4663 * @request_lci: request LCI information
4664 * @request_civicloc: request civic location information
4665 * @trigger_based: use trigger based ranging for the measurement
4666 * If neither @trigger_based nor @non_trigger_based is set,
4667 * EDCA based ranging will be used.
4668 * @non_trigger_based: use non trigger based ranging for the measurement
4669 * If neither @trigger_based nor @non_trigger_based is set,
4670 * EDCA based ranging will be used.
4671 * @lmr_feedback: negotiate for I2R LMR feedback. Only valid if either
4672 * @trigger_based or @non_trigger_based is set.
4673 * @rsta: Operate as the RSTA in the measurement. Only valid if @lmr_feedback
4674 * and either @trigger_based or @non_trigger_based is set.
4675 * @bss_color: the bss color of the responder. Optional. Set to zero to
4676 * indicate the driver should set the BSS color. Only valid if
4677 * @non_trigger_based or @trigger_based is set.
4678 * @request_type: ranging request type, one of
4679 * &enum nl80211_peer_measurement_ftm_req_type. Defaults to
4680 * %NL80211_PMSR_FTM_REQ_TYPE_INFRA if not specified.
4681 * @min_time_between_measurements: minimum time between two consecutive range
4682 * measurements in units of 100 microseconds, for non-trigger based
4683 * ranging. Should be set as short as possible to minimize turnaround
4684 * time, since two-way ranging with delayed LMR requires two measurements.
4685 * Only valid if @non_trigger_based is set.
4686 * @max_time_between_measurements: maximum time between two consecutive range
4687 * measurements in units of 10 milliseconds, for non-trigger based
4688 * ranging. Acts as a session timeout; if exceeded, the ranging session
4689 * should be terminated. Only valid if @non_trigger_based is set.
4690 * @availability_window: duration of the availability window (AW) in units of
4691 * 1 millisecond (0-255 ms). Only valid if @non_trigger_based is set.
4692 * If set to 0, the firmware or driver can automatically select an
4693 * appropriate value.
4694 * @nominal_time: Nominal duration between adjacent availability windows
4695 * in units of milli seconds. Only valid if @non_trigger_based is set.
4696 * If set to 0, the firmware or driver can automatically select an
4697 * appropriate value.
4698 * @num_measurements: number of Availability Windows (AWs) to schedule
4699 * for non-trigger-based ranging. Each AW may contain multiple FTM
4700 * exchanges as configured by @ftms_per_burst. Only valid if
4701 * @non_trigger_based is set. If set to 0, the firmware or driver
4702 * can automatically select an appropriate value.
4703 * @ingress_distance: optional ingress threshold in units of mm. When set,
4704 * the measurement result of the peer needs to be indicated if the device
4705 * moves into this range. Measurement results need to be sent on a burst
4706 * index basis in this case.
4707 * @egress_distance: optional egress threshold in units of mm. When set,
4708 * the measurement result of the peer needs to be indicated if the device
4709 * moves out of this range. Measurement results need to be sent on a burst
4710 * index basis in this case.
4711 * If neither or only one of @ingress_distance and @egress_distance
4712 * is set, only the specified threshold is used. If both are set, both
4713 * thresholds are applied. If neither is set, results are reported without
4714 * threshold filtering.
4715 * @pd_suppress_range_results: flag to suppress ranging results for PD
4716 * requests. When set, the device performs ranging measurements to
4717 * provide ranging services to a peer (e.g. in RSTA role) but does
4718 * not report the measurement results to userspace. Only valid when
4719 * @request_type is %NL80211_PMSR_FTM_REQ_TYPE_PD.
4720 *
4721 * See also nl80211 for the respective attribute documentation.
4722 */
4723 struct cfg80211_pmsr_ftm_request_peer {
4724 enum nl80211_preamble preamble;
4725 u16 burst_period;
4726 u8 requested:1,
4727 asap:1,
4728 request_lci:1,
4729 request_civicloc:1,
4730 trigger_based:1,
4731 non_trigger_based:1,
4732 lmr_feedback:1,
4733 rsta:1;
4734 u8 num_bursts_exp;
4735 u8 burst_duration;
4736 u8 ftms_per_burst;
4737 u8 ftmr_retries;
4738 u8 bss_color;
4739
4740 u32 request_type;
4741 u32 min_time_between_measurements;
4742 u32 max_time_between_measurements;
4743 u8 availability_window;
4744 u32 nominal_time;
4745 u32 num_measurements;
4746 u64 ingress_distance;
4747 u64 egress_distance;
4748 u8 pd_suppress_range_results:1;
4749 };
4750
4751 /**
4752 * struct cfg80211_pmsr_request_peer - peer data for a peer measurement request
4753 * @addr: MAC address
4754 * @chandef: channel to use
4755 * @report_ap_tsf: report the associated AP's TSF
4756 * @ftm: FTM data, see &struct cfg80211_pmsr_ftm_request_peer
4757 */
4758 struct cfg80211_pmsr_request_peer {
4759 u8 addr[ETH_ALEN];
4760 struct cfg80211_chan_def chandef;
4761 u8 report_ap_tsf:1;
4762 struct cfg80211_pmsr_ftm_request_peer ftm;
4763 };
4764
4765 /**
4766 * struct cfg80211_pmsr_request - peer measurement request
4767 * @cookie: cookie, set by cfg80211
4768 * @nl_portid: netlink portid - used by cfg80211
4769 * @drv_data: driver data for this request, if required for aborting,
4770 * not otherwise freed or anything by cfg80211
4771 * @mac_addr: MAC address used for (randomised) request
4772 * @mac_addr_mask: MAC address mask used for randomisation, bits that
4773 * are 0 in the mask should be randomised, bits that are 1 should
4774 * be taken from the @mac_addr
4775 * @list: used by cfg80211 to hold on to the request
4776 * @timeout: timeout (in milliseconds) for the whole operation, if
4777 * zero it means there's no timeout
4778 * @n_peers: number of peers to do measurements with
4779 * @peers: per-peer measurement request data
4780 */
4781 struct cfg80211_pmsr_request {
4782 u64 cookie;
4783 void *drv_data;
4784 u32 n_peers;
4785 u32 nl_portid;
4786
4787 u32 timeout;
4788
4789 u8 mac_addr[ETH_ALEN] __aligned(2);
4790 u8 mac_addr_mask[ETH_ALEN] __aligned(2);
4791
4792 struct list_head list;
4793
4794 struct cfg80211_pmsr_request_peer peers[] __counted_by(n_peers);
4795 };
4796
4797 /**
4798 * struct cfg80211_update_owe_info - OWE Information
4799 *
4800 * This structure provides information needed for the drivers to offload OWE
4801 * (Opportunistic Wireless Encryption) processing to the user space.
4802 *
4803 * Commonly used across update_owe_info request and event interfaces.
4804 *
4805 * @peer: MAC address of the peer device for which the OWE processing
4806 * has to be done.
4807 * @status: status code, %WLAN_STATUS_SUCCESS for successful OWE info
4808 * processing, use %WLAN_STATUS_UNSPECIFIED_FAILURE if user space
4809 * cannot give you the real status code for failures. Used only for
4810 * OWE update request command interface (user space to driver).
4811 * @ie: IEs obtained from the peer or constructed by the user space. These are
4812 * the IEs of the remote peer in the event from the host driver and
4813 * the constructed IEs by the user space in the request interface.
4814 * @ie_len: Length of IEs in octets.
4815 * @assoc_link_id: MLO link ID of the AP, with which (re)association requested
4816 * by peer. This will be filled by driver for both MLO and non-MLO station
4817 * connections when the AP affiliated with an MLD. For non-MLD AP mode, it
4818 * will be -1. Used only with OWE update event (driver to user space).
4819 * @peer_mld_addr: For MLO connection, MLD address of the peer. For non-MLO
4820 * connection, it will be all zeros. This is applicable only when
4821 * @assoc_link_id is not -1, i.e., the AP affiliated with an MLD. Used only
4822 * with OWE update event (driver to user space).
4823 */
4824 struct cfg80211_update_owe_info {
4825 u8 peer[ETH_ALEN] __aligned(2);
4826 u16 status;
4827 const u8 *ie;
4828 size_t ie_len;
4829 int assoc_link_id;
4830 u8 peer_mld_addr[ETH_ALEN] __aligned(2);
4831 };
4832
4833 /**
4834 * struct mgmt_frame_regs - management frame registrations data
4835 * @global_stypes: bitmap of management frame subtypes registered
4836 * for the entire device
4837 * @interface_stypes: bitmap of management frame subtypes registered
4838 * for the given interface
4839 * @global_mcast_stypes: mcast RX is needed globally for these subtypes
4840 * @interface_mcast_stypes: mcast RX is needed on this interface
4841 * for these subtypes
4842 */
4843 struct mgmt_frame_regs {
4844 u32 global_stypes, interface_stypes;
4845 u32 global_mcast_stypes, interface_mcast_stypes;
4846 };
4847
4848 /**
4849 * struct cfg80211_ops - backend description for wireless configuration
4850 *
4851 * This struct is registered by fullmac card drivers and/or wireless stacks
4852 * in order to handle configuration requests on their interfaces.
4853 *
4854 * All callbacks except where otherwise noted should return 0
4855 * on success or a negative error code.
4856 *
4857 * All operations are invoked with the wiphy mutex held. The RTNL may be
4858 * held in addition (due to wireless extensions) but this cannot be relied
4859 * upon except in cases where documented below. Note that due to ordering,
4860 * the RTNL also cannot be acquired in any handlers.
4861 *
4862 * @suspend: wiphy device needs to be suspended. The variable @wow will
4863 * be %NULL or contain the enabled Wake-on-Wireless triggers that are
4864 * configured for the device.
4865 * @resume: wiphy device needs to be resumed
4866 * @set_wakeup: Called when WoWLAN is enabled/disabled, use this callback
4867 * to call device_set_wakeup_enable() to enable/disable wakeup from
4868 * the device.
4869 *
4870 * @add_virtual_intf: create a new virtual interface with the given name,
4871 * must set the struct wireless_dev's iftype. Beware: You must create
4872 * the new netdev in the wiphy's network namespace! Returns the struct
4873 * wireless_dev, or an ERR_PTR. For P2P device wdevs, the driver must
4874 * also set the address member in the wdev.
4875 * This additionally holds the RTNL to be able to do netdev changes.
4876 *
4877 * @del_virtual_intf: remove the virtual interface
4878 * This additionally holds the RTNL to be able to do netdev changes.
4879 *
4880 * @change_virtual_intf: change type/configuration of virtual interface,
4881 * keep the struct wireless_dev's iftype updated.
4882 * This additionally holds the RTNL to be able to do netdev changes.
4883 *
4884 * @add_intf_link: Add a new MLO link to the given interface. Note that
4885 * the wdev->link[] data structure has been updated, so the new link
4886 * address is available.
4887 * @del_intf_link: Remove an MLO link from the given interface.
4888 *
4889 * @add_key: add a key with the given parameters. @mac_addr will be %NULL
4890 * when adding a group key. @link_id will be -1 for non-MLO connection.
4891 * For MLO connection, @link_id will be >= 0 for group key and -1 for
4892 * pairwise key, @mac_addr will be peer's MLD address for MLO pairwise key.
4893 *
4894 * @get_key: get information about the key with the given parameters.
4895 * @mac_addr will be %NULL when requesting information for a group
4896 * key. All pointers given to the @callback function need not be valid
4897 * after it returns. This function should return an error if it is
4898 * not possible to retrieve the key, -ENOENT if it doesn't exist.
4899 * @link_id will be -1 for non-MLO connection. For MLO connection,
4900 * @link_id will be >= 0 for group key and -1 for pairwise key, @mac_addr
4901 * will be peer's MLD address for MLO pairwise key.
4902 *
4903 * @del_key: remove a key given the @mac_addr (%NULL for a group key)
4904 * and @key_index, return -ENOENT if the key doesn't exist. @link_id will
4905 * be -1 for non-MLO connection. For MLO connection, @link_id will be >= 0
4906 * for group key and -1 for pairwise key, @mac_addr will be peer's MLD
4907 * address for MLO pairwise key.
4908 *
4909 * @set_default_key: set the default key on an interface. @link_id will be >= 0
4910 * for MLO connection and -1 for non-MLO connection.
4911 *
4912 * @set_default_mgmt_key: set the default management frame key on an interface.
4913 * @link_id will be >= 0 for MLO connection and -1 for non-MLO connection.
4914 *
4915 * @set_default_beacon_key: set the default Beacon frame key on an interface.
4916 * @link_id will be >= 0 for MLO connection and -1 for non-MLO connection.
4917 *
4918 * @set_rekey_data: give the data necessary for GTK rekeying to the driver
4919 *
4920 * @start_ap: Start acting in AP mode defined by the parameters.
4921 * @change_beacon: Change the beacon parameters for an access point mode
4922 * interface. This should reject the call when AP mode wasn't started.
4923 * @stop_ap: Stop being an AP, including stopping beaconing.
4924 *
4925 * @add_station: Add a new station.
4926 * @del_station: Remove a station
4927 * @change_station: Modify a given station. Note that flags changes are not much
4928 * validated in cfg80211, in particular the auth/assoc/authorized flags
4929 * might come to the driver in invalid combinations -- make sure to check
4930 * them, also against the existing state! Drivers must call
4931 * cfg80211_check_station_change() to validate the information.
4932 * @get_station: get station information for the station identified by @mac
4933 * @dump_station: dump station callback -- resume dump at index @idx
4934 *
4935 * @add_mpath: add a fixed mesh path
4936 * @del_mpath: delete a given mesh path
4937 * @change_mpath: change a given mesh path
4938 * @get_mpath: get a mesh path for the given parameters
4939 * @dump_mpath: dump mesh path callback -- resume dump at index @idx
4940 * @get_mpp: get a mesh proxy path for the given parameters
4941 * @dump_mpp: dump mesh proxy path callback -- resume dump at index @idx
4942 * @join_mesh: join the mesh network with the specified parameters
4943 * (invoked with the wireless_dev mutex held)
4944 * @leave_mesh: leave the current mesh network
4945 * (invoked with the wireless_dev mutex held)
4946 *
4947 * @get_mesh_config: Get the current mesh configuration
4948 *
4949 * @update_mesh_config: Update mesh parameters on a running mesh.
4950 * The mask is a bitfield which tells us which parameters to
4951 * set, and which to leave alone.
4952 *
4953 * @change_bss: Modify parameters for a given BSS.
4954 *
4955 * @inform_bss: Called by cfg80211 while being informed about new BSS data
4956 * for every BSS found within the reported data or frame. This is called
4957 * from within the cfg8011 inform_bss handlers while holding the bss_lock.
4958 * The data parameter is passed through from drv_data inside
4959 * struct cfg80211_inform_bss.
4960 * The new IE data for the BSS is explicitly passed.
4961 *
4962 * @set_txq_params: Set TX queue parameters
4963 *
4964 * @libertas_set_mesh_channel: Only for backward compatibility for libertas,
4965 * as it doesn't implement join_mesh and needs to set the channel to
4966 * join the mesh instead.
4967 *
4968 * @set_monitor_channel: Set the monitor mode channel for the device. If other
4969 * interfaces are active this callback should reject the configuration.
4970 * If no interfaces are active or the device is down, the channel should
4971 * be stored for when a monitor interface becomes active.
4972 *
4973 * @scan: Request to do a scan. If returning zero, the scan request is given
4974 * the driver, and will be valid until passed to cfg80211_scan_done().
4975 * For scan results, call cfg80211_inform_bss(); you can call this outside
4976 * the scan/scan_done bracket too.
4977 * @abort_scan: Tell the driver to abort an ongoing scan. The driver shall
4978 * indicate the status of the scan through cfg80211_scan_done().
4979 *
4980 * @auth: Request to authenticate with the specified peer
4981 * (invoked with the wireless_dev mutex held)
4982 * @assoc: Request to (re)associate with the specified peer
4983 * (invoked with the wireless_dev mutex held)
4984 * @deauth: Request to deauthenticate from the specified peer
4985 * (invoked with the wireless_dev mutex held)
4986 * @disassoc: Request to disassociate from the specified peer
4987 * (invoked with the wireless_dev mutex held)
4988 *
4989 * @connect: Connect to the ESS with the specified parameters. When connected,
4990 * call cfg80211_connect_result()/cfg80211_connect_bss() with status code
4991 * %WLAN_STATUS_SUCCESS. If the connection fails for some reason, call
4992 * cfg80211_connect_result()/cfg80211_connect_bss() with the status code
4993 * from the AP or cfg80211_connect_timeout() if no frame with status code
4994 * was received.
4995 * The driver is allowed to roam to other BSSes within the ESS when the
4996 * other BSS matches the connect parameters. When such roaming is initiated
4997 * by the driver, the driver is expected to verify that the target matches
4998 * the configured security parameters and to use Reassociation Request
4999 * frame instead of Association Request frame.
5000 * The connect function can also be used to request the driver to perform a
5001 * specific roam when connected to an ESS. In that case, the prev_bssid
5002 * parameter is set to the BSSID of the currently associated BSS as an
5003 * indication of requesting reassociation.
5004 * In both the driver-initiated and new connect() call initiated roaming
5005 * cases, the result of roaming is indicated with a call to
5006 * cfg80211_roamed(). (invoked with the wireless_dev mutex held)
5007 * @update_connect_params: Update the connect parameters while connected to a
5008 * BSS. The updated parameters can be used by driver/firmware for
5009 * subsequent BSS selection (roaming) decisions and to form the
5010 * Authentication/(Re)Association Request frames. This call does not
5011 * request an immediate disassociation or reassociation with the current
5012 * BSS, i.e., this impacts only subsequent (re)associations. The bits in
5013 * changed are defined in &enum cfg80211_connect_params_changed.
5014 * (invoked with the wireless_dev mutex held)
5015 * @disconnect: Disconnect from the BSS/ESS or stop connection attempts if
5016 * connection is in progress. Once done, call cfg80211_disconnected() in
5017 * case connection was already established (invoked with the
5018 * wireless_dev mutex held), otherwise call cfg80211_connect_timeout().
5019 *
5020 * @join_ibss: Join the specified IBSS (or create if necessary). Once done, call
5021 * cfg80211_ibss_joined(), also call that function when changing BSSID due
5022 * to a merge.
5023 * (invoked with the wireless_dev mutex held)
5024 * @leave_ibss: Leave the IBSS.
5025 * (invoked with the wireless_dev mutex held)
5026 *
5027 * @set_mcast_rate: Set the specified multicast rate (only if vif is in ADHOC or
5028 * MESH mode)
5029 *
5030 * @set_wiphy_params: Notify that wiphy parameters have changed;
5031 * @changed bitfield (see &enum wiphy_params_flags) describes which values
5032 * have changed. The actual parameter values are available in
5033 * struct wiphy. If returning an error, no value should be changed.
5034 *
5035 * @set_tx_power: set the transmit power according to the parameters,
5036 * the power passed is in mBm, to get dBm use MBM_TO_DBM(). The
5037 * wdev may be %NULL if power was set for the wiphy, and will
5038 * always be %NULL unless the driver supports per-vif TX power
5039 * (as advertised by the nl80211 feature flag.)
5040 * @get_tx_power: store the current TX power into the dbm variable;
5041 * return 0 if successful
5042 *
5043 * @rfkill_poll: polls the hw rfkill line, use cfg80211 reporting
5044 * functions to adjust rfkill hw state
5045 *
5046 * @dump_survey: get site survey information.
5047 *
5048 * @remain_on_channel: Request the driver to remain awake on the specified
5049 * channel for the specified duration to complete an off-channel
5050 * operation (e.g., public action frame exchange). When the driver is
5051 * ready on the requested channel, it must indicate this with an event
5052 * notification by calling cfg80211_ready_on_channel().
5053 * @cancel_remain_on_channel: Cancel an on-going remain-on-channel operation.
5054 * This allows the operation to be terminated prior to timeout based on
5055 * the duration value.
5056 * @mgmt_tx: Transmit a management frame.
5057 * @mgmt_tx_cancel_wait: Cancel the wait time from transmitting a management
5058 * frame on another channel
5059 *
5060 * @testmode_cmd: run a test mode command; @wdev may be %NULL
5061 * @testmode_dump: Implement a test mode dump. The cb->args[2] and up may be
5062 * used by the function, but 0 and 1 must not be touched. Additionally,
5063 * return error codes other than -ENOBUFS and -ENOENT will terminate the
5064 * dump and return to userspace with an error, so be careful. If any data
5065 * was passed in from userspace then the data/len arguments will be present
5066 * and point to the data contained in %NL80211_ATTR_TESTDATA.
5067 *
5068 * @set_bitrate_mask: set the bitrate mask configuration
5069 *
5070 * @set_pmksa: Cache a PMKID for a BSSID. This is mostly useful for fullmac
5071 * devices running firmwares capable of generating the (re) association
5072 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
5073 * @del_pmksa: Delete a cached PMKID.
5074 * @flush_pmksa: Flush all cached PMKIDs.
5075 * @set_power_mgmt: Configure WLAN power management. A timeout value of -1
5076 * allows the driver to adjust the dynamic ps timeout value.
5077 * @set_cqm_rssi_config: Configure connection quality monitor RSSI threshold.
5078 * After configuration, the driver should (soon) send an event indicating
5079 * the current level is above/below the configured threshold; this may
5080 * need some care when the configuration is changed (without first being
5081 * disabled.)
5082 * @set_cqm_rssi_range_config: Configure two RSSI thresholds in the
5083 * connection quality monitor. An event is to be sent only when the
5084 * signal level is found to be outside the two values. The driver should
5085 * set %NL80211_EXT_FEATURE_CQM_RSSI_LIST if this method is implemented.
5086 * If it is provided then there's no point providing @set_cqm_rssi_config.
5087 * @set_cqm_txe_config: Configure connection quality monitor TX error
5088 * thresholds.
5089 * @sched_scan_start: Tell the driver to start a scheduled scan.
5090 * @sched_scan_stop: Tell the driver to stop an ongoing scheduled scan with
5091 * given request id. This call must stop the scheduled scan and be ready
5092 * for starting a new one before it returns, i.e. @sched_scan_start may be
5093 * called immediately after that again and should not fail in that case.
5094 * The driver should not call cfg80211_sched_scan_stopped() for a requested
5095 * stop (when this method returns 0).
5096 *
5097 * @update_mgmt_frame_registrations: Notify the driver that management frame
5098 * registrations were updated. The callback is allowed to sleep.
5099 *
5100 * @set_antenna: Set antenna configuration (tx_ant, rx_ant) on the device.
5101 * Parameters are bitmaps of allowed antennas to use for TX/RX. Drivers may
5102 * reject TX/RX mask combinations they cannot support by returning -EINVAL
5103 * (also see nl80211.h @NL80211_ATTR_WIPHY_ANTENNA_TX).
5104 *
5105 * @get_antenna: Get current antenna configuration from device (tx_ant, rx_ant).
5106 *
5107 * @tdls_mgmt: Transmit a TDLS management frame.
5108 * @tdls_oper: Perform a high-level TDLS operation (e.g. TDLS link setup).
5109 *
5110 * @probe_peer: probe a connected peer (AP: STA MAC required; STA: no MAC),
5111 * must use the @cookie as provided which is later passed to
5112 * cfg80211_probe_status().
5113 *
5114 * @set_noack_map: Set the NoAck Map for the TIDs.
5115 *
5116 * @get_channel: Get the current operating channel for the virtual interface.
5117 * For monitor interfaces, it should return %NULL unless there's a single
5118 * current monitoring channel.
5119 *
5120 * @start_p2p_device: Start the given P2P device.
5121 * @stop_p2p_device: Stop the given P2P device.
5122 *
5123 * @set_mac_acl: Sets MAC address control list in AP and P2P GO mode.
5124 * Parameters include ACL policy, an array of MAC address of stations
5125 * and the number of MAC addresses. If there is already a list in driver
5126 * this new list replaces the existing one. Driver has to clear its ACL
5127 * when number of MAC addresses entries is passed as 0. Drivers which
5128 * advertise the support for MAC based ACL have to implement this callback.
5129 *
5130 * @start_radar_detection: Start radar detection in the driver.
5131 *
5132 * @end_cac: End running CAC, probably because a related CAC
5133 * was finished on another phy.
5134 *
5135 * @update_ft_ies: Provide updated Fast BSS Transition information to the
5136 * driver. If the SME is in the driver/firmware, this information can be
5137 * used in building Authentication and Reassociation Request frames.
5138 *
5139 * @crit_proto_start: Indicates a critical protocol needs more link reliability
5140 * for a given duration (milliseconds). The protocol is provided so the
5141 * driver can take the most appropriate actions.
5142 * @crit_proto_stop: Indicates critical protocol no longer needs increased link
5143 * reliability. This operation can not fail.
5144 * @set_coalesce: Set coalesce parameters.
5145 *
5146 * @channel_switch: initiate channel-switch procedure (with CSA). Driver is
5147 * responsible for veryfing if the switch is possible. Since this is
5148 * inherently tricky driver may decide to disconnect an interface later
5149 * with cfg80211_stop_iface(). This doesn't mean driver can accept
5150 * everything. It should do it's best to verify requests and reject them
5151 * as soon as possible.
5152 *
5153 * @set_qos_map: Set QoS mapping information to the driver
5154 *
5155 * @set_ap_chanwidth: Set the AP (including P2P GO) mode channel width for the
5156 * given interface This is used e.g. for dynamic HT 20/40 MHz channel width
5157 * changes during the lifetime of the BSS.
5158 *
5159 * @add_tx_ts: validate (if admitted_time is 0) or add a TX TS to the device
5160 * with the given parameters; action frame exchange has been handled by
5161 * userspace so this just has to modify the TX path to take the TS into
5162 * account.
5163 * If the admitted time is 0 just validate the parameters to make sure
5164 * the session can be created at all; it is valid to just always return
5165 * success for that but that may result in inefficient behaviour (handshake
5166 * with the peer followed by immediate teardown when the addition is later
5167 * rejected)
5168 * @del_tx_ts: remove an existing TX TS
5169 *
5170 * @join_ocb: join the OCB network with the specified parameters
5171 * (invoked with the wireless_dev mutex held)
5172 * @leave_ocb: leave the current OCB network
5173 * (invoked with the wireless_dev mutex held)
5174 *
5175 * @tdls_channel_switch: Start channel-switching with a TDLS peer. The driver
5176 * is responsible for continually initiating channel-switching operations
5177 * and returning to the base channel for communication with the AP.
5178 * @tdls_cancel_channel_switch: Stop channel-switching with a TDLS peer. Both
5179 * peers must be on the base channel when the call completes.
5180 * @start_nan: Start the NAN interface.
5181 * @stop_nan: Stop the NAN interface.
5182 * @add_nan_func: Add a NAN function. Returns negative value on failure.
5183 * On success @nan_func ownership is transferred to the driver and
5184 * it may access it outside of the scope of this function. The driver
5185 * should free the @nan_func when no longer needed by calling
5186 * cfg80211_free_nan_func().
5187 * On success the driver should assign an instance_id in the
5188 * provided @nan_func.
5189 * @del_nan_func: Delete a NAN function.
5190 * @nan_change_conf: changes NAN configuration. The changed parameters must
5191 * be specified in @changes (using &enum cfg80211_nan_conf_changes);
5192 * All other parameters must be ignored.
5193 * @nan_set_local_sched: configure the local schedule for NAN. The schedule
5194 * consists of an array of %cfg80211_nan_channel and the schedule itself,
5195 * in which each entry maps each time slot to the channel on which the
5196 * radio should operate on. If the chandef of a NAN channel is not
5197 * changed, the channel entry must also remain unchanged. It is the
5198 * driver's responsibility to verify this.
5199 * @nan_set_peer_sched: configure the peer schedule for NAN. The schedule
5200 * consists of an array of %cfg80211_nan_channel and the schedule itself,
5201 * in which each entry maps each time slot to a channel on which the
5202 * radio should operate on. In addition, it contains more peer's schedule
5203 * information such as committed DW, etc. When updating an existing peer
5204 * schedule, the full new schedule is provided - partial updates are not
5205 * supported, and the new schedule completely replaces the previous one.
5206 *
5207 * @set_multicast_to_unicast: configure multicast to unicast conversion for BSS
5208 *
5209 * @get_txq_stats: Get TXQ stats for interface or phy. If wdev is %NULL, this
5210 * function should return phy stats, and interface stats otherwise.
5211 *
5212 * @set_pmk: configure the PMK to be used for offloaded 802.1X 4-Way handshake.
5213 * If not deleted through @del_pmk the PMK remains valid until disconnect
5214 * upon which the driver should clear it.
5215 * (invoked with the wireless_dev mutex held)
5216 * @del_pmk: delete the previously configured PMK for the given authenticator.
5217 * (invoked with the wireless_dev mutex held)
5218 *
5219 * @external_auth: indicates result of offloaded authentication processing from
5220 * user space
5221 *
5222 * @tx_control_port: TX a control port frame (EAPoL). The noencrypt parameter
5223 * tells the driver that the frame should not be encrypted. A @cookie
5224 * value of 0 means the caller does not want TX status reporting.
5225 *
5226 * @get_ftm_responder_stats: Retrieve FTM responder statistics, if available.
5227 * Statistics should be cumulative, currently no way to reset is provided.
5228 * @start_pmsr: start peer measurement (e.g. FTM)
5229 * @abort_pmsr: abort peer measurement
5230 *
5231 * @update_owe_info: Provide updated OWE info to driver. Driver implementing SME
5232 * but offloading OWE processing to the user space will get the updated
5233 * DH IE through this interface.
5234 *
5235 * @probe_mesh_link: Probe direct Mesh peer's link quality by sending data frame
5236 * and overrule HWMP path selection algorithm.
5237 * @set_tid_config: TID specific configuration, this can be peer or BSS specific
5238 * This callback may sleep.
5239 * @reset_tid_config: Reset TID specific configuration for the peer, for the
5240 * given TIDs. This callback may sleep.
5241 *
5242 * @set_sar_specs: Update the SAR (TX power) settings.
5243 *
5244 * @color_change: Initiate a color change.
5245 *
5246 * @set_fils_aad: Set FILS AAD data to the AP driver so that the driver can use
5247 * those to decrypt (Re)Association Request and encrypt (Re)Association
5248 * Response frame.
5249 *
5250 * @set_radar_background: Configure dedicated offchannel chain available for
5251 * radar/CAC detection on some hw. This chain can't be used to transmit
5252 * or receive frames and it is bounded to a running wdev.
5253 * Background radar/CAC detection allows to avoid the CAC downtime
5254 * switching to a different channel during CAC detection on the selected
5255 * radar channel.
5256 * The caller is expected to set chandef pointer to NULL in order to
5257 * disable background CAC/radar detection.
5258 * @add_link_station: Add a link to a station.
5259 * @mod_link_station: Modify a link of a station.
5260 * @del_link_station: Remove a link of a station.
5261 *
5262 * @set_hw_timestamp: Enable/disable HW timestamping of TM/FTM frames.
5263 * @set_ttlm: set the TID to link mapping.
5264 * @set_epcs: Enable/Disable EPCS for station mode.
5265 * @get_radio_mask: get bitmask of radios in use.
5266 * (invoked with the wiphy mutex held)
5267 * @assoc_ml_reconf: Request a non-AP MLO connection to perform ML
5268 * reconfiguration, i.e., add and/or remove links to/from the
5269 * association using ML reconfiguration action frames. Successfully added
5270 * links will be added to the set of valid links. Successfully removed
5271 * links will be removed from the set of valid links. The driver must
5272 * indicate removed links by calling cfg80211_links_removed() and added
5273 * links by calling cfg80211_mlo_reconf_add_done(). When calling
5274 * cfg80211_mlo_reconf_add_done() the bss pointer must be given for each
5275 * link for which MLO reconfiguration 'add' operation was requested.
5276 *
5277 * @start_pd: Start the PD interface.
5278 * @stop_pd: Stop the PD interface.
5279 */
5280 struct cfg80211_ops {
5281 int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
5282 int (*resume)(struct wiphy *wiphy);
5283 void (*set_wakeup)(struct wiphy *wiphy, bool enabled);
5284
5285 struct wireless_dev * (*add_virtual_intf)(struct wiphy *wiphy,
5286 const char *name,
5287 unsigned char name_assign_type,
5288 enum nl80211_iftype type,
5289 struct vif_params *params);
5290 int (*del_virtual_intf)(struct wiphy *wiphy,
5291 struct wireless_dev *wdev);
5292 int (*change_virtual_intf)(struct wiphy *wiphy,
5293 struct net_device *dev,
5294 enum nl80211_iftype type,
5295 struct vif_params *params);
5296
5297 int (*add_intf_link)(struct wiphy *wiphy,
5298 struct wireless_dev *wdev,
5299 unsigned int link_id);
5300 void (*del_intf_link)(struct wiphy *wiphy,
5301 struct wireless_dev *wdev,
5302 unsigned int link_id);
5303
5304 int (*add_key)(struct wiphy *wiphy, struct wireless_dev *wdev,
5305 int link_id, u8 key_index, bool pairwise,
5306 const u8 *mac_addr, struct key_params *params);
5307 int (*get_key)(struct wiphy *wiphy, struct wireless_dev *wdev,
5308 int link_id, u8 key_index, bool pairwise,
5309 const u8 *mac_addr, void *cookie,
5310 void (*callback)(void *cookie, struct key_params*));
5311 int (*del_key)(struct wiphy *wiphy, struct wireless_dev *wdev,
5312 int link_id, u8 key_index, bool pairwise,
5313 const u8 *mac_addr);
5314 int (*set_default_key)(struct wiphy *wiphy,
5315 struct net_device *netdev, int link_id,
5316 u8 key_index, bool unicast, bool multicast);
5317 int (*set_default_mgmt_key)(struct wiphy *wiphy,
5318 struct wireless_dev *wdev, int link_id,
5319 u8 key_index);
5320 int (*set_default_beacon_key)(struct wiphy *wiphy,
5321 struct wireless_dev *wdev,
5322 int link_id,
5323 u8 key_index);
5324
5325 int (*start_ap)(struct wiphy *wiphy, struct net_device *dev,
5326 struct cfg80211_ap_settings *settings);
5327 int (*change_beacon)(struct wiphy *wiphy, struct net_device *dev,
5328 struct cfg80211_ap_update *info);
5329 int (*stop_ap)(struct wiphy *wiphy, struct net_device *dev,
5330 unsigned int link_id);
5331
5332
5333 int (*add_station)(struct wiphy *wiphy, struct wireless_dev *wdev,
5334 const u8 *mac,
5335 struct station_parameters *params);
5336 int (*del_station)(struct wiphy *wiphy, struct wireless_dev *wdev,
5337 struct station_del_parameters *params);
5338 int (*change_station)(struct wiphy *wiphy, struct wireless_dev *wdev,
5339 const u8 *mac,
5340 struct station_parameters *params);
5341 int (*get_station)(struct wiphy *wiphy, struct wireless_dev *wdev,
5342 const u8 *mac, struct station_info *sinfo);
5343 int (*dump_station)(struct wiphy *wiphy, struct wireless_dev *wdev,
5344 int idx, u8 *mac, struct station_info *sinfo);
5345
5346 int (*add_mpath)(struct wiphy *wiphy, struct net_device *dev,
5347 const u8 *dst, const u8 *next_hop);
5348 int (*del_mpath)(struct wiphy *wiphy, struct net_device *dev,
5349 const u8 *dst);
5350 int (*change_mpath)(struct wiphy *wiphy, struct net_device *dev,
5351 const u8 *dst, const u8 *next_hop);
5352 int (*get_mpath)(struct wiphy *wiphy, struct net_device *dev,
5353 u8 *dst, u8 *next_hop, struct mpath_info *pinfo);
5354 int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev,
5355 int idx, u8 *dst, u8 *next_hop,
5356 struct mpath_info *pinfo);
5357 int (*get_mpp)(struct wiphy *wiphy, struct net_device *dev,
5358 u8 *dst, u8 *mpp, struct mpath_info *pinfo);
5359 int (*dump_mpp)(struct wiphy *wiphy, struct net_device *dev,
5360 int idx, u8 *dst, u8 *mpp,
5361 struct mpath_info *pinfo);
5362 int (*get_mesh_config)(struct wiphy *wiphy,
5363 struct net_device *dev,
5364 struct mesh_config *conf);
5365 int (*update_mesh_config)(struct wiphy *wiphy,
5366 struct net_device *dev, u32 mask,
5367 const struct mesh_config *nconf);
5368 int (*join_mesh)(struct wiphy *wiphy, struct net_device *dev,
5369 const struct mesh_config *conf,
5370 const struct mesh_setup *setup);
5371 int (*leave_mesh)(struct wiphy *wiphy, struct net_device *dev);
5372
5373 int (*join_ocb)(struct wiphy *wiphy, struct net_device *dev,
5374 struct ocb_setup *setup);
5375 int (*leave_ocb)(struct wiphy *wiphy, struct net_device *dev);
5376
5377 int (*change_bss)(struct wiphy *wiphy, struct net_device *dev,
5378 struct bss_parameters *params);
5379
5380 void (*inform_bss)(struct wiphy *wiphy, struct cfg80211_bss *bss,
5381 const struct cfg80211_bss_ies *ies, void *data);
5382
5383 int (*set_txq_params)(struct wiphy *wiphy, struct net_device *dev,
5384 struct ieee80211_txq_params *params);
5385
5386 int (*libertas_set_mesh_channel)(struct wiphy *wiphy,
5387 struct net_device *dev,
5388 struct ieee80211_channel *chan);
5389
5390 int (*set_monitor_channel)(struct wiphy *wiphy,
5391 struct net_device *dev,
5392 struct cfg80211_chan_def *chandef);
5393
5394 int (*scan)(struct wiphy *wiphy,
5395 struct cfg80211_scan_request *request);
5396 void (*abort_scan)(struct wiphy *wiphy, struct wireless_dev *wdev);
5397
5398 int (*auth)(struct wiphy *wiphy, struct net_device *dev,
5399 struct cfg80211_auth_request *req);
5400 int (*assoc)(struct wiphy *wiphy, struct net_device *dev,
5401 struct cfg80211_assoc_request *req);
5402 int (*deauth)(struct wiphy *wiphy, struct net_device *dev,
5403 struct cfg80211_deauth_request *req);
5404 int (*disassoc)(struct wiphy *wiphy, struct net_device *dev,
5405 struct cfg80211_disassoc_request *req);
5406
5407 int (*connect)(struct wiphy *wiphy, struct net_device *dev,
5408 struct cfg80211_connect_params *sme);
5409 int (*update_connect_params)(struct wiphy *wiphy,
5410 struct net_device *dev,
5411 struct cfg80211_connect_params *sme,
5412 u32 changed);
5413 int (*disconnect)(struct wiphy *wiphy, struct net_device *dev,
5414 u16 reason_code);
5415
5416 int (*join_ibss)(struct wiphy *wiphy, struct net_device *dev,
5417 struct cfg80211_ibss_params *params);
5418 int (*leave_ibss)(struct wiphy *wiphy, struct net_device *dev);
5419
5420 int (*set_mcast_rate)(struct wiphy *wiphy, struct net_device *dev,
5421 int rate[NUM_NL80211_BANDS]);
5422
5423 int (*set_wiphy_params)(struct wiphy *wiphy, int radio_idx,
5424 u32 changed);
5425
5426 int (*set_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev,
5427 int radio_idx,
5428 enum nl80211_tx_power_setting type, int mbm);
5429 int (*get_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev,
5430 int radio_idx, unsigned int link_id, int *dbm);
5431
5432 void (*rfkill_poll)(struct wiphy *wiphy);
5433
5434 #ifdef CONFIG_NL80211_TESTMODE
5435 int (*testmode_cmd)(struct wiphy *wiphy, struct wireless_dev *wdev,
5436 void *data, int len);
5437 int (*testmode_dump)(struct wiphy *wiphy, struct sk_buff *skb,
5438 struct netlink_callback *cb,
5439 void *data, int len);
5440 #endif
5441
5442 int (*set_bitrate_mask)(struct wiphy *wiphy,
5443 struct net_device *dev,
5444 unsigned int link_id,
5445 const u8 *peer,
5446 const struct cfg80211_bitrate_mask *mask);
5447
5448 int (*dump_survey)(struct wiphy *wiphy, struct net_device *netdev,
5449 int idx, struct survey_info *info);
5450
5451 int (*set_pmksa)(struct wiphy *wiphy, struct net_device *netdev,
5452 struct cfg80211_pmksa *pmksa);
5453 int (*del_pmksa)(struct wiphy *wiphy, struct net_device *netdev,
5454 struct cfg80211_pmksa *pmksa);
5455 int (*flush_pmksa)(struct wiphy *wiphy, struct net_device *netdev);
5456
5457 int (*remain_on_channel)(struct wiphy *wiphy,
5458 struct wireless_dev *wdev,
5459 struct ieee80211_channel *chan,
5460 unsigned int duration,
5461 u64 cookie, const u8 *rx_addr);
5462 int (*cancel_remain_on_channel)(struct wiphy *wiphy,
5463 struct wireless_dev *wdev,
5464 u64 cookie);
5465
5466 int (*mgmt_tx)(struct wiphy *wiphy, struct wireless_dev *wdev,
5467 struct cfg80211_mgmt_tx_params *params,
5468 u64 cookie);
5469 int (*mgmt_tx_cancel_wait)(struct wiphy *wiphy,
5470 struct wireless_dev *wdev,
5471 u64 cookie);
5472
5473 int (*set_power_mgmt)(struct wiphy *wiphy, struct net_device *dev,
5474 bool enabled, int timeout);
5475
5476 int (*set_cqm_rssi_config)(struct wiphy *wiphy,
5477 struct net_device *dev,
5478 s32 rssi_thold, u32 rssi_hyst);
5479
5480 int (*set_cqm_rssi_range_config)(struct wiphy *wiphy,
5481 struct net_device *dev,
5482 s32 rssi_low, s32 rssi_high);
5483
5484 int (*set_cqm_txe_config)(struct wiphy *wiphy,
5485 struct net_device *dev,
5486 u32 rate, u32 pkts, u32 intvl);
5487
5488 void (*update_mgmt_frame_registrations)(struct wiphy *wiphy,
5489 struct wireless_dev *wdev,
5490 struct mgmt_frame_regs *upd);
5491
5492 int (*set_antenna)(struct wiphy *wiphy, int radio_idx,
5493 u32 tx_ant, u32 rx_ant);
5494 int (*get_antenna)(struct wiphy *wiphy, int radio_idx,
5495 u32 *tx_ant, u32 *rx_ant);
5496
5497 int (*sched_scan_start)(struct wiphy *wiphy,
5498 struct net_device *dev,
5499 struct cfg80211_sched_scan_request *request);
5500 int (*sched_scan_stop)(struct wiphy *wiphy, struct net_device *dev,
5501 u64 reqid);
5502
5503 int (*set_rekey_data)(struct wiphy *wiphy, struct net_device *dev,
5504 struct cfg80211_gtk_rekey_data *data);
5505
5506 int (*tdls_mgmt)(struct wiphy *wiphy, struct net_device *dev,
5507 const u8 *peer, int link_id,
5508 u8 action_code, u8 dialog_token, u16 status_code,
5509 u32 peer_capability, bool initiator,
5510 const u8 *buf, size_t len);
5511 int (*tdls_oper)(struct wiphy *wiphy, struct net_device *dev,
5512 const u8 *peer, enum nl80211_tdls_operation oper);
5513
5514 int (*probe_peer)(struct wiphy *wiphy, struct net_device *dev,
5515 const u8 *peer, u64 cookie);
5516
5517 int (*set_noack_map)(struct wiphy *wiphy,
5518 struct net_device *dev,
5519 u16 noack_map);
5520
5521 int (*get_channel)(struct wiphy *wiphy,
5522 struct wireless_dev *wdev,
5523 unsigned int link_id,
5524 struct cfg80211_chan_def *chandef);
5525
5526 int (*start_p2p_device)(struct wiphy *wiphy,
5527 struct wireless_dev *wdev);
5528 void (*stop_p2p_device)(struct wiphy *wiphy,
5529 struct wireless_dev *wdev);
5530
5531 int (*set_mac_acl)(struct wiphy *wiphy, struct net_device *dev,
5532 const struct cfg80211_acl_data *params);
5533
5534 int (*start_radar_detection)(struct wiphy *wiphy,
5535 struct net_device *dev,
5536 struct cfg80211_chan_def *chandef,
5537 u32 cac_time_ms, int link_id);
5538 void (*end_cac)(struct wiphy *wiphy,
5539 struct net_device *dev, unsigned int link_id);
5540 int (*update_ft_ies)(struct wiphy *wiphy, struct net_device *dev,
5541 struct cfg80211_update_ft_ies_params *ftie);
5542 int (*crit_proto_start)(struct wiphy *wiphy,
5543 struct wireless_dev *wdev,
5544 enum nl80211_crit_proto_id protocol,
5545 u16 duration);
5546 void (*crit_proto_stop)(struct wiphy *wiphy,
5547 struct wireless_dev *wdev);
5548 int (*set_coalesce)(struct wiphy *wiphy,
5549 struct cfg80211_coalesce *coalesce);
5550
5551 int (*channel_switch)(struct wiphy *wiphy,
5552 struct net_device *dev,
5553 struct cfg80211_csa_settings *params);
5554
5555 int (*set_qos_map)(struct wiphy *wiphy,
5556 struct net_device *dev,
5557 struct cfg80211_qos_map *qos_map);
5558
5559 int (*set_ap_chanwidth)(struct wiphy *wiphy, struct net_device *dev,
5560 unsigned int link_id,
5561 struct cfg80211_chan_def *chandef);
5562
5563 int (*add_tx_ts)(struct wiphy *wiphy, struct net_device *dev,
5564 u8 tsid, const u8 *peer, u8 user_prio,
5565 u16 admitted_time);
5566 int (*del_tx_ts)(struct wiphy *wiphy, struct net_device *dev,
5567 u8 tsid, const u8 *peer);
5568
5569 int (*tdls_channel_switch)(struct wiphy *wiphy,
5570 struct net_device *dev,
5571 const u8 *addr, u8 oper_class,
5572 struct cfg80211_chan_def *chandef);
5573 void (*tdls_cancel_channel_switch)(struct wiphy *wiphy,
5574 struct net_device *dev,
5575 const u8 *addr);
5576 int (*start_nan)(struct wiphy *wiphy, struct wireless_dev *wdev,
5577 struct cfg80211_nan_conf *conf);
5578 void (*stop_nan)(struct wiphy *wiphy, struct wireless_dev *wdev);
5579 int (*add_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,
5580 struct cfg80211_nan_func *nan_func);
5581 void (*del_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,
5582 u64 cookie);
5583 int (*nan_change_conf)(struct wiphy *wiphy,
5584 struct wireless_dev *wdev,
5585 struct cfg80211_nan_conf *conf,
5586 u32 changes);
5587 int (*nan_set_local_sched)(struct wiphy *wiphy,
5588 struct wireless_dev *wdev,
5589 struct cfg80211_nan_local_sched *sched);
5590 int (*nan_set_peer_sched)(struct wiphy *wiphy,
5591 struct wireless_dev *wdev,
5592 struct cfg80211_nan_peer_sched *sched);
5593 int (*set_multicast_to_unicast)(struct wiphy *wiphy,
5594 struct net_device *dev,
5595 const bool enabled);
5596
5597 int (*get_txq_stats)(struct wiphy *wiphy,
5598 struct wireless_dev *wdev,
5599 struct cfg80211_txq_stats *txqstats);
5600
5601 int (*set_pmk)(struct wiphy *wiphy, struct net_device *dev,
5602 const struct cfg80211_pmk_conf *conf);
5603 int (*del_pmk)(struct wiphy *wiphy, struct net_device *dev,
5604 const u8 *aa);
5605 int (*external_auth)(struct wiphy *wiphy, struct net_device *dev,
5606 struct cfg80211_external_auth_params *params);
5607
5608 int (*tx_control_port)(struct wiphy *wiphy,
5609 struct net_device *dev,
5610 const u8 *buf, size_t len,
5611 const u8 *dest, const __be16 proto,
5612 const bool noencrypt, int link_id,
5613 u64 cookie);
5614
5615 int (*get_ftm_responder_stats)(struct wiphy *wiphy,
5616 struct net_device *dev,
5617 struct cfg80211_ftm_responder_stats *ftm_stats);
5618
5619 int (*start_pmsr)(struct wiphy *wiphy, struct wireless_dev *wdev,
5620 struct cfg80211_pmsr_request *request);
5621 void (*abort_pmsr)(struct wiphy *wiphy, struct wireless_dev *wdev,
5622 struct cfg80211_pmsr_request *request);
5623 int (*update_owe_info)(struct wiphy *wiphy, struct net_device *dev,
5624 struct cfg80211_update_owe_info *owe_info);
5625 int (*probe_mesh_link)(struct wiphy *wiphy, struct net_device *dev,
5626 const u8 *buf, size_t len);
5627 int (*set_tid_config)(struct wiphy *wiphy, struct net_device *dev,
5628 struct cfg80211_tid_config *tid_conf);
5629 int (*reset_tid_config)(struct wiphy *wiphy, struct net_device *dev,
5630 const u8 *peer, u8 tids);
5631 int (*set_sar_specs)(struct wiphy *wiphy,
5632 struct cfg80211_sar_specs *sar);
5633 int (*color_change)(struct wiphy *wiphy,
5634 struct net_device *dev,
5635 struct cfg80211_color_change_settings *params);
5636 int (*set_fils_aad)(struct wiphy *wiphy, struct net_device *dev,
5637 struct cfg80211_fils_aad *fils_aad);
5638 int (*set_radar_background)(struct wiphy *wiphy,
5639 struct cfg80211_chan_def *chandef);
5640 int (*add_link_station)(struct wiphy *wiphy, struct net_device *dev,
5641 struct link_station_parameters *params);
5642 int (*mod_link_station)(struct wiphy *wiphy, struct net_device *dev,
5643 struct link_station_parameters *params);
5644 int (*del_link_station)(struct wiphy *wiphy, struct net_device *dev,
5645 struct link_station_del_parameters *params);
5646 int (*set_hw_timestamp)(struct wiphy *wiphy, struct net_device *dev,
5647 struct cfg80211_set_hw_timestamp *hwts);
5648 int (*set_ttlm)(struct wiphy *wiphy, struct net_device *dev,
5649 struct cfg80211_ttlm_params *params);
5650 u32 (*get_radio_mask)(struct wiphy *wiphy, struct net_device *dev);
5651 int (*assoc_ml_reconf)(struct wiphy *wiphy, struct net_device *dev,
5652 struct cfg80211_ml_reconf_req *req);
5653 int (*set_epcs)(struct wiphy *wiphy, struct net_device *dev,
5654 bool val);
5655 int (*start_pd)(struct wiphy *wiphy, struct wireless_dev *wdev);
5656 void (*stop_pd)(struct wiphy *wiphy, struct wireless_dev *wdev);
5657 };
5658
5659 /*
5660 * wireless hardware and networking interfaces structures
5661 * and registration/helper functions
5662 */
5663
5664 /**
5665 * enum wiphy_flags - wiphy capability flags
5666 *
5667 * @WIPHY_FLAG_SPLIT_SCAN_6GHZ: if set to true, the scan request will be split
5668 * into two, first for legacy bands and second for 6 GHz.
5669 * @WIPHY_FLAG_NETNS_OK: if not set, do not allow changing the netns of this
5670 * wiphy at all
5671 * @WIPHY_FLAG_PS_ON_BY_DEFAULT: if set to true, powersave will be enabled
5672 * by default -- this flag will be set depending on the kernel's default
5673 * on wiphy_new(), but can be changed by the driver if it has a good
5674 * reason to override the default
5675 * @WIPHY_FLAG_4ADDR_AP: supports 4addr mode even on AP (with a single station
5676 * on a VLAN interface). This flag also serves an extra purpose of
5677 * supporting 4ADDR AP mode on devices which do not support AP/VLAN iftype.
5678 * @WIPHY_FLAG_4ADDR_STATION: supports 4addr mode even as a station
5679 * @WIPHY_FLAG_CONTROL_PORT_PROTOCOL: This device supports setting the
5680 * control port protocol ethertype. The device also honours the
5681 * control_port_no_encrypt flag.
5682 * @WIPHY_FLAG_IBSS_RSN: The device supports IBSS RSN.
5683 * @WIPHY_FLAG_MESH_AUTH: The device supports mesh authentication by routing
5684 * auth frames to userspace. See @NL80211_MESH_SETUP_USERSPACE_AUTH.
5685 * @WIPHY_FLAG_SUPPORTS_FW_ROAM: The device supports roaming feature in the
5686 * firmware.
5687 * @WIPHY_FLAG_AP_UAPSD: The device supports uapsd on AP.
5688 * @WIPHY_FLAG_SUPPORTS_TDLS: The device supports TDLS (802.11z) operation.
5689 * @WIPHY_FLAG_TDLS_EXTERNAL_SETUP: The device does not handle TDLS (802.11z)
5690 * link setup/discovery operations internally. Setup, discovery and
5691 * teardown packets should be sent through the @NL80211_CMD_TDLS_MGMT
5692 * command. When this flag is not set, @NL80211_CMD_TDLS_OPER should be
5693 * used for asking the driver/firmware to perform a TDLS operation.
5694 * @WIPHY_FLAG_HAVE_AP_SME: device integrates AP SME
5695 * @WIPHY_FLAG_REPORTS_OBSS: the device will report beacons from other BSSes
5696 * when there are virtual interfaces in AP mode by calling
5697 * cfg80211_report_obss_beacon().
5698 * @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD: When operating as an AP, the device
5699 * responds to probe-requests in hardware.
5700 * @WIPHY_FLAG_OFFCHAN_TX: Device supports direct off-channel TX.
5701 * @WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL: Device supports remain-on-channel call.
5702 * @WIPHY_FLAG_HAS_CHANNEL_SWITCH: Device supports channel switch in
5703 * beaconing mode (AP, IBSS, Mesh, ...).
5704 * @WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK: The device supports bigger kek and kck keys
5705 * @WIPHY_FLAG_SUPPORTS_MLO: This is a temporary flag gating the MLO APIs,
5706 * in order to not have them reachable in normal drivers, until we have
5707 * complete feature/interface combinations/etc. advertisement. No driver
5708 * should set this flag for now.
5709 * @WIPHY_FLAG_SUPPORTS_EXT_KCK_32: The device supports 32-byte KCK keys.
5710 * @WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER: The device could handle reg notify for
5711 * NL80211_REGDOM_SET_BY_DRIVER.
5712 * @WIPHY_FLAG_CHANNEL_CHANGE_ON_BEACON: reg_call_notifier() is called if driver
5713 * set this flag to update channels on beacon hints.
5714 * @WIPHY_FLAG_SUPPORTS_NSTR_NONPRIMARY: support connection to non-primary link
5715 * of an NSTR mobile AP MLD.
5716 */
5717 enum wiphy_flags {
5718 WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK = BIT(0),
5719 WIPHY_FLAG_SUPPORTS_MLO = BIT(1),
5720 WIPHY_FLAG_SPLIT_SCAN_6GHZ = BIT(2),
5721 WIPHY_FLAG_NETNS_OK = BIT(3),
5722 WIPHY_FLAG_PS_ON_BY_DEFAULT = BIT(4),
5723 WIPHY_FLAG_4ADDR_AP = BIT(5),
5724 WIPHY_FLAG_4ADDR_STATION = BIT(6),
5725 WIPHY_FLAG_CONTROL_PORT_PROTOCOL = BIT(7),
5726 WIPHY_FLAG_IBSS_RSN = BIT(8),
5727 /* reuse bit 9 */
5728 WIPHY_FLAG_MESH_AUTH = BIT(10),
5729 WIPHY_FLAG_SUPPORTS_EXT_KCK_32 = BIT(11),
5730 WIPHY_FLAG_SUPPORTS_NSTR_NONPRIMARY = BIT(12),
5731 WIPHY_FLAG_SUPPORTS_FW_ROAM = BIT(13),
5732 WIPHY_FLAG_AP_UAPSD = BIT(14),
5733 WIPHY_FLAG_SUPPORTS_TDLS = BIT(15),
5734 WIPHY_FLAG_TDLS_EXTERNAL_SETUP = BIT(16),
5735 WIPHY_FLAG_HAVE_AP_SME = BIT(17),
5736 WIPHY_FLAG_REPORTS_OBSS = BIT(18),
5737 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD = BIT(19),
5738 WIPHY_FLAG_OFFCHAN_TX = BIT(20),
5739 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL = BIT(21),
5740 WIPHY_FLAG_HAS_CHANNEL_SWITCH = BIT(23),
5741 WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER = BIT(24),
5742 WIPHY_FLAG_CHANNEL_CHANGE_ON_BEACON = BIT(25),
5743 };
5744
5745 /**
5746 * struct ieee80211_iface_limit - limit on certain interface types
5747 * @max: maximum number of interfaces of these types
5748 * @types: interface types (bits)
5749 */
5750 struct ieee80211_iface_limit {
5751 u16 max;
5752 u16 types;
5753 };
5754
5755 /**
5756 * struct ieee80211_iface_combination - possible interface combination
5757 *
5758 * With this structure the driver can describe which interface
5759 * combinations it supports concurrently. When set in a struct wiphy_radio,
5760 * the combinations refer to combinations of interfaces currently active on
5761 * that radio.
5762 *
5763 * Examples:
5764 *
5765 * 1. Allow #STA <= 1, #AP <= 1, matching BI, channels = 1, 2 total:
5766 *
5767 * .. code-block:: c
5768 *
5769 * struct ieee80211_iface_limit limits1[] = {
5770 * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), },
5771 * { .max = 1, .types = BIT(NL80211_IFTYPE_AP), },
5772 * };
5773 * struct ieee80211_iface_combination combination1 = {
5774 * .limits = limits1,
5775 * .n_limits = ARRAY_SIZE(limits1),
5776 * .max_interfaces = 2,
5777 * .beacon_int_infra_match = true,
5778 * };
5779 *
5780 *
5781 * 2. Allow #{AP, P2P-GO} <= 8, channels = 1, 8 total:
5782 *
5783 * .. code-block:: c
5784 *
5785 * struct ieee80211_iface_limit limits2[] = {
5786 * { .max = 8, .types = BIT(NL80211_IFTYPE_AP) |
5787 * BIT(NL80211_IFTYPE_P2P_GO), },
5788 * };
5789 * struct ieee80211_iface_combination combination2 = {
5790 * .limits = limits2,
5791 * .n_limits = ARRAY_SIZE(limits2),
5792 * .max_interfaces = 8,
5793 * .num_different_channels = 1,
5794 * };
5795 *
5796 *
5797 * 3. Allow #STA <= 1, #{P2P-client,P2P-GO} <= 3 on two channels, 4 total.
5798 *
5799 * This allows for an infrastructure connection and three P2P connections.
5800 *
5801 * .. code-block:: c
5802 *
5803 * struct ieee80211_iface_limit limits3[] = {
5804 * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), },
5805 * { .max = 3, .types = BIT(NL80211_IFTYPE_P2P_GO) |
5806 * BIT(NL80211_IFTYPE_P2P_CLIENT), },
5807 * };
5808 * struct ieee80211_iface_combination combination3 = {
5809 * .limits = limits3,
5810 * .n_limits = ARRAY_SIZE(limits3),
5811 * .max_interfaces = 4,
5812 * .num_different_channels = 2,
5813 * };
5814 *
5815 */
5816 struct ieee80211_iface_combination {
5817 /**
5818 * @limits:
5819 * limits for the given interface types
5820 */
5821 const struct ieee80211_iface_limit *limits;
5822
5823 /**
5824 * @num_different_channels:
5825 * can use up to this many different channels
5826 */
5827 u32 num_different_channels;
5828
5829 /**
5830 * @max_interfaces:
5831 * maximum number of interfaces in total allowed in this group
5832 */
5833 u16 max_interfaces;
5834
5835 /**
5836 * @n_limits:
5837 * number of limitations
5838 */
5839 u8 n_limits;
5840
5841 /**
5842 * @beacon_int_infra_match:
5843 * In this combination, the beacon intervals between infrastructure
5844 * and AP types must match. This is required only in special cases.
5845 */
5846 bool beacon_int_infra_match;
5847
5848 /**
5849 * @radar_detect_widths:
5850 * bitmap of channel widths supported for radar detection
5851 */
5852 u8 radar_detect_widths;
5853
5854 /**
5855 * @radar_detect_regions:
5856 * bitmap of regions supported for radar detection
5857 */
5858 u8 radar_detect_regions;
5859
5860 /**
5861 * @beacon_int_min_gcd:
5862 * This interface combination supports different beacon intervals.
5863 *
5864 * = 0
5865 * all beacon intervals for different interface must be same.
5866 * > 0
5867 * any beacon interval for the interface part of this combination AND
5868 * GCD of all beacon intervals from beaconing interfaces of this
5869 * combination must be greater or equal to this value.
5870 */
5871 u32 beacon_int_min_gcd;
5872 };
5873
5874 struct ieee80211_txrx_stypes {
5875 u16 tx, rx;
5876 };
5877
5878 /**
5879 * enum wiphy_wowlan_support_flags - WoWLAN support flags
5880 * @WIPHY_WOWLAN_ANY: supports wakeup for the special "any"
5881 * trigger that keeps the device operating as-is and
5882 * wakes up the host on any activity, for example a
5883 * received packet that passed filtering; note that the
5884 * packet should be preserved in that case
5885 * @WIPHY_WOWLAN_MAGIC_PKT: supports wakeup on magic packet
5886 * (see nl80211.h)
5887 * @WIPHY_WOWLAN_DISCONNECT: supports wakeup on disconnect
5888 * @WIPHY_WOWLAN_SUPPORTS_GTK_REKEY: supports GTK rekeying while asleep
5889 * @WIPHY_WOWLAN_GTK_REKEY_FAILURE: supports wakeup on GTK rekey failure
5890 * @WIPHY_WOWLAN_EAP_IDENTITY_REQ: supports wakeup on EAP identity request
5891 * @WIPHY_WOWLAN_4WAY_HANDSHAKE: supports wakeup on 4-way handshake failure
5892 * @WIPHY_WOWLAN_RFKILL_RELEASE: supports wakeup on RF-kill release
5893 * @WIPHY_WOWLAN_NET_DETECT: supports wakeup on network detection
5894 */
5895 enum wiphy_wowlan_support_flags {
5896 WIPHY_WOWLAN_ANY = BIT(0),
5897 WIPHY_WOWLAN_MAGIC_PKT = BIT(1),
5898 WIPHY_WOWLAN_DISCONNECT = BIT(2),
5899 WIPHY_WOWLAN_SUPPORTS_GTK_REKEY = BIT(3),
5900 WIPHY_WOWLAN_GTK_REKEY_FAILURE = BIT(4),
5901 WIPHY_WOWLAN_EAP_IDENTITY_REQ = BIT(5),
5902 WIPHY_WOWLAN_4WAY_HANDSHAKE = BIT(6),
5903 WIPHY_WOWLAN_RFKILL_RELEASE = BIT(7),
5904 WIPHY_WOWLAN_NET_DETECT = BIT(8),
5905 };
5906
5907 struct wiphy_wowlan_tcp_support {
5908 const struct nl80211_wowlan_tcp_data_token_feature *tok;
5909 u32 data_payload_max;
5910 u32 data_interval_max;
5911 u32 wake_payload_max;
5912 bool seq;
5913 };
5914
5915 /**
5916 * struct wiphy_wowlan_support - WoWLAN support data
5917 * @flags: see &enum wiphy_wowlan_support_flags
5918 * @n_patterns: number of supported wakeup patterns
5919 * (see nl80211.h for the pattern definition)
5920 * @pattern_max_len: maximum length of each pattern
5921 * @pattern_min_len: minimum length of each pattern
5922 * @max_pkt_offset: maximum Rx packet offset
5923 * @max_nd_match_sets: maximum number of matchsets for net-detect,
5924 * similar, but not necessarily identical, to max_match_sets for
5925 * scheduled scans.
5926 * See &struct cfg80211_sched_scan_request.@match_sets for more
5927 * details.
5928 * @tcp: TCP wakeup support information
5929 */
5930 struct wiphy_wowlan_support {
5931 u32 flags;
5932 int n_patterns;
5933 int pattern_max_len;
5934 int pattern_min_len;
5935 int max_pkt_offset;
5936 int max_nd_match_sets;
5937 const struct wiphy_wowlan_tcp_support *tcp;
5938 };
5939
5940 /**
5941 * struct wiphy_coalesce_support - coalesce support data
5942 * @n_rules: maximum number of coalesce rules
5943 * @max_delay: maximum supported coalescing delay in msecs
5944 * @n_patterns: number of supported patterns in a rule
5945 * (see nl80211.h for the pattern definition)
5946 * @pattern_max_len: maximum length of each pattern
5947 * @pattern_min_len: minimum length of each pattern
5948 * @max_pkt_offset: maximum Rx packet offset
5949 */
5950 struct wiphy_coalesce_support {
5951 int n_rules;
5952 int max_delay;
5953 int n_patterns;
5954 int pattern_max_len;
5955 int pattern_min_len;
5956 int max_pkt_offset;
5957 };
5958
5959 /**
5960 * enum wiphy_vendor_command_flags - validation flags for vendor commands
5961 * @WIPHY_VENDOR_CMD_NEED_WDEV: vendor command requires wdev
5962 * @WIPHY_VENDOR_CMD_NEED_NETDEV: vendor command requires netdev
5963 * @WIPHY_VENDOR_CMD_NEED_RUNNING: interface/wdev must be up & running
5964 * (must be combined with %_WDEV or %_NETDEV)
5965 */
5966 enum wiphy_vendor_command_flags {
5967 WIPHY_VENDOR_CMD_NEED_WDEV = BIT(0),
5968 WIPHY_VENDOR_CMD_NEED_NETDEV = BIT(1),
5969 WIPHY_VENDOR_CMD_NEED_RUNNING = BIT(2),
5970 };
5971
5972 /**
5973 * enum wiphy_opmode_flag - Station's ht/vht operation mode information flags
5974 *
5975 * @STA_OPMODE_MAX_BW_CHANGED: Max Bandwidth changed
5976 * @STA_OPMODE_SMPS_MODE_CHANGED: SMPS mode changed
5977 * @STA_OPMODE_N_SS_CHANGED: max N_SS (number of spatial streams) changed
5978 *
5979 */
5980 enum wiphy_opmode_flag {
5981 STA_OPMODE_MAX_BW_CHANGED = BIT(0),
5982 STA_OPMODE_SMPS_MODE_CHANGED = BIT(1),
5983 STA_OPMODE_N_SS_CHANGED = BIT(2),
5984 };
5985
5986 /**
5987 * struct sta_opmode_info - Station's ht/vht operation mode information
5988 * @changed: contains value from &enum wiphy_opmode_flag
5989 * @smps_mode: New SMPS mode value from &enum nl80211_smps_mode of a station
5990 * @bw: new max bandwidth value from &enum nl80211_chan_width of a station
5991 * @rx_nss: new rx_nss value of a station
5992 */
5993
5994 struct sta_opmode_info {
5995 u32 changed;
5996 enum nl80211_smps_mode smps_mode;
5997 enum nl80211_chan_width bw;
5998 u8 rx_nss;
5999 };
6000
6001 #define VENDOR_CMD_RAW_DATA ((const struct nla_policy *)(long)(-ENODATA))
6002
6003 /**
6004 * struct wiphy_vendor_command - vendor command definition
6005 * @info: vendor command identifying information, as used in nl80211
6006 * @flags: flags, see &enum wiphy_vendor_command_flags
6007 * @doit: callback for the operation, note that wdev is %NULL if the
6008 * flags didn't ask for a wdev and non-%NULL otherwise; the data
6009 * pointer may be %NULL if userspace provided no data at all
6010 * @dumpit: dump callback, for transferring bigger/multiple items. The
6011 * @storage points to cb->args[5], ie. is preserved over the multiple
6012 * dumpit calls.
6013 * @policy: policy pointer for attributes within %NL80211_ATTR_VENDOR_DATA.
6014 * Set this to %VENDOR_CMD_RAW_DATA if no policy can be given and the
6015 * attribute is just raw data (e.g. a firmware command).
6016 * @maxattr: highest attribute number in policy
6017 * It's recommended to not have the same sub command with both @doit and
6018 * @dumpit, so that userspace can assume certain ones are get and others
6019 * are used with dump requests.
6020 */
6021 struct wiphy_vendor_command {
6022 struct nl80211_vendor_cmd_info info;
6023 u32 flags;
6024 int (*doit)(struct wiphy *wiphy, struct wireless_dev *wdev,
6025 const void *data, int data_len);
6026 int (*dumpit)(struct wiphy *wiphy, struct wireless_dev *wdev,
6027 struct sk_buff *skb, const void *data, int data_len,
6028 unsigned long *storage);
6029 const struct nla_policy *policy;
6030 unsigned int maxattr;
6031 };
6032
6033 /**
6034 * struct wiphy_iftype_ext_capab - extended capabilities per interface type
6035 * @iftype: interface type
6036 * @extended_capabilities: extended capabilities supported by the driver,
6037 * additional capabilities might be supported by userspace; these are the
6038 * 802.11 extended capabilities ("Extended Capabilities element") and are
6039 * in the same format as in the information element. See IEEE Std
6040 * 802.11-2012 8.4.2.29 for the defined fields.
6041 * @extended_capabilities_mask: mask of the valid values
6042 * @extended_capabilities_len: length of the extended capabilities
6043 * @eml_capabilities: EML capabilities (for MLO)
6044 * @mld_capa_and_ops: MLD capabilities and operations (for MLO)
6045 * @ext_mld_capa_and_ops: Extended MLD capabilities and operations (for MLO)
6046 */
6047 struct wiphy_iftype_ext_capab {
6048 enum nl80211_iftype iftype;
6049 const u8 *extended_capabilities;
6050 const u8 *extended_capabilities_mask;
6051 u8 extended_capabilities_len;
6052 u16 eml_capabilities;
6053 u16 mld_capa_and_ops;
6054 u16 ext_mld_capa_and_ops;
6055 };
6056
6057 /**
6058 * cfg80211_get_iftype_ext_capa - lookup interface type extended capability
6059 * @wiphy: the wiphy to look up from
6060 * @type: the interface type to look up
6061 *
6062 * Return: The extended capability for the given interface @type, may be %NULL
6063 */
6064 const struct wiphy_iftype_ext_capab *
6065 cfg80211_get_iftype_ext_capa(struct wiphy *wiphy, enum nl80211_iftype type);
6066
6067 /**
6068 * struct cfg80211_pmsr_capabilities - cfg80211 peer measurement capabilities
6069 * @max_peers: maximum number of peers in a single measurement
6070 * @report_ap_tsf: can report assoc AP's TSF for radio resource measurement
6071 * @randomize_mac_addr: can randomize MAC address for measurement
6072 * @ftm: FTM measurement data
6073 * @ftm.supported: FTM measurement is supported
6074 * @ftm.asap: ASAP-mode is supported
6075 * @ftm.non_asap: non-ASAP-mode is supported
6076 * @ftm.request_lci: can request LCI data
6077 * @ftm.request_civicloc: can request civic location data
6078 * @ftm.preambles: bitmap of preambles supported (&enum nl80211_preamble)
6079 * @ftm.bandwidths: bitmap of bandwidths supported (&enum nl80211_chan_width)
6080 * @ftm.max_bursts_exponent: maximum burst exponent supported
6081 * (set to -1 if not limited; note that setting this will necessarily
6082 * forbid using the value 15 to let the responder pick)
6083 * @ftm.max_ftms_per_burst: maximum FTMs per burst supported (set to 0 if
6084 * not limited)
6085 * @ftm.trigger_based: trigger based ranging measurement is supported
6086 * @ftm.non_trigger_based: non trigger based ranging measurement is supported
6087 * @ftm.support_6ghz: supports ranging in 6 GHz band
6088 * @ftm.max_tx_ltf_rep: maximum number of TX LTF repetitions supported (0 means
6089 * only one LTF, no repetitions)
6090 * @ftm.max_rx_ltf_rep: maximum number of RX LTF repetitions supported (0 means
6091 * only one LTF, no repetitions)
6092 * @ftm.max_tx_sts: maximum number of TX STS supported (zero based)
6093 * @ftm.max_rx_sts: maximum number of RX STS supported (zero based)
6094 * @ftm.max_total_ltf_tx: maximum total number of LTFs that can be transmitted
6095 * (0 means unknown)
6096 * @ftm.max_total_ltf_rx: maximum total number of LTFs that can be received
6097 * (0 means unknown)
6098 * @ftm.ista: initiator role capabilities
6099 * @ftm.ista.support_ntb: supports operating as ISTA in PMSR FTM request for
6100 * NTB ranging.
6101 * @ftm.ista.support_tb: supports operating as ISTA in PMSR FTM request for
6102 * TB ranging.
6103 * @ftm.ista.support_edca: supports operating as ISTA in PMSR FTM request for
6104 * EDCA based ranging.
6105 * @ftm.ista.max_peers: maximum number of peers supported in the ISTA role.
6106 * If zero, no role-specific peer limit applies.
6107 * @ftm.rsta: responder role capabilities
6108 * @ftm.rsta.support_ntb: supports operating as RSTA in PMSR FTM request for
6109 * NTB ranging.
6110 * @ftm.rsta.support_tb: supports operating as RSTA in PMSR FTM request for
6111 * TB ranging.
6112 * @ftm.rsta.support_edca: supports operating as RSTA in PMSR FTM request for
6113 * EDCA based ranging.
6114 * @ftm.rsta.max_peers: maximum number of peers supported in the RSTA role.
6115 * If zero, no role-specific peer limit applies.
6116 * @ftm.max_no_of_tx_antennas: maximum number of transmit antennas supported for
6117 * EDCA based ranging (0 means unknown)
6118 * @ftm.max_no_of_rx_antennas: maximum number of receive antennas supported for
6119 * EDCA based ranging (0 means unknown)
6120 * @ftm.min_allowed_ranging_interval_edca: Minimum EDCA ranging
6121 * interval supported by the device in milli seconds. (0 means unknown).
6122 * Applications can use this value to estimate the burst period to be
6123 * given in the FTM request for the EDCA based ranging case. If
6124 * non-zero, this value will be used to validate the burst period in
6125 * the FTM request.
6126 * @ftm.min_allowed_ranging_interval_ntb: Minimum NTB ranging
6127 * interval supported by the device in milli seconds. (0 means unknown).
6128 * Applications can use this value to estimate the burst period to be
6129 * given in the FTM request for the NTB ranging case. If non-zero,
6130 * this value will be used to validate the nominal time in the FTM
6131 * request.
6132 * @ftm.type: ranging type capabilities
6133 * @ftm.type.infra_support: supports infrastructure ranging (STA-to-AP or
6134 * AP-to-STA) as part of Proximity Detection
6135 * @ftm.type.pd_support: supports peer-to-peer ranging as mentioned in the
6136 * specification "PR Implementation Consideration Draft 1.9 rev 1" where
6137 * PD stands for proximity detection
6138 * @ftm.concurrent_ista_rsta_support: indicates if the device can
6139 * simultaneously act as initiator and responder in a multi-peer
6140 * measurement request. Only valid if @ftm.rsta_support is set.
6141 * @ftm.pd_preambles: bitmap of preambles supported (&enum nl80211_preamble)
6142 * for PD ranging requests. Ignored if @ftm.type.pd_support is not set.
6143 * @ftm.pd_bandwidths: bitmap of bandwidths supported (&enum nl80211_chan_width)
6144 * for PD ranging requests. Ignored if @ftm.type.pd_support is not set.
6145 */
6146 struct cfg80211_pmsr_capabilities {
6147 unsigned int max_peers;
6148 u8 report_ap_tsf:1,
6149 randomize_mac_addr:1;
6150
6151 struct {
6152 u32 preambles;
6153 u32 bandwidths;
6154 s8 max_bursts_exponent;
6155 u8 max_ftms_per_burst;
6156 u8 supported:1,
6157 asap:1,
6158 non_asap:1,
6159 request_lci:1,
6160 request_civicloc:1,
6161 trigger_based:1,
6162 non_trigger_based:1,
6163 support_6ghz:1;
6164 u8 max_tx_ltf_rep;
6165 u8 max_rx_ltf_rep;
6166 u8 max_tx_sts;
6167 u8 max_rx_sts;
6168 u8 max_total_ltf_tx;
6169 u8 max_total_ltf_rx;
6170 struct {
6171 u8 support_ntb:1,
6172 support_tb:1,
6173 support_edca:1;
6174 u32 max_peers;
6175 } ista;
6176 struct {
6177 u8 support_ntb:1,
6178 support_tb:1,
6179 support_edca:1;
6180 u32 max_peers;
6181 } rsta;
6182 u8 max_no_of_tx_antennas;
6183 u8 max_no_of_rx_antennas;
6184 u32 min_allowed_ranging_interval_edca;
6185 u32 min_allowed_ranging_interval_ntb;
6186 struct {
6187 u8 infra_support:1,
6188 pd_support:1;
6189 } type;
6190 u8 concurrent_ista_rsta_support:1;
6191 u32 pd_preambles;
6192 u32 pd_bandwidths;
6193 } ftm;
6194 };
6195
6196 /**
6197 * struct wiphy_iftype_akm_suites - This structure encapsulates supported akm
6198 * suites for interface types defined in @iftypes_mask. Each type in the
6199 * @iftypes_mask must be unique across all instances of iftype_akm_suites.
6200 *
6201 * @iftypes_mask: bitmask of interfaces types
6202 * @akm_suites: points to an array of supported akm suites
6203 * @n_akm_suites: number of supported AKM suites
6204 */
6205 struct wiphy_iftype_akm_suites {
6206 u16 iftypes_mask;
6207 const u32 *akm_suites;
6208 int n_akm_suites;
6209 };
6210
6211 /**
6212 * struct wiphy_radio_cfg - physical radio config of a wiphy
6213 * This structure describes the configurations of a physical radio in a
6214 * wiphy. It is used to denote per-radio attributes belonging to a wiphy.
6215 *
6216 * @rts_threshold: RTS threshold (dot11RTSThreshold);
6217 * -1 (default) = RTS/CTS disabled
6218 * @radio_debugfsdir: Pointer to debugfs directory containing the radio-
6219 * specific parameters.
6220 * NULL (default) = Debugfs directory not created
6221 */
6222 struct wiphy_radio_cfg {
6223 u32 rts_threshold;
6224 struct dentry *radio_debugfsdir;
6225 };
6226
6227 /**
6228 * struct wiphy_radio_freq_range - wiphy frequency range
6229 * @start_freq: start range edge frequency (kHz)
6230 * @end_freq: end range edge frequency (kHz)
6231 */
6232 struct wiphy_radio_freq_range {
6233 u32 start_freq;
6234 u32 end_freq;
6235 };
6236
6237
6238 /**
6239 * struct wiphy_radio - physical radio of a wiphy
6240 * This structure describes a physical radio belonging to a wiphy.
6241 * It is used to describe concurrent-channel capabilities. Only one channel
6242 * can be active on the radio described by struct wiphy_radio.
6243 *
6244 * @freq_range: frequency range that the radio can operate on.
6245 * @n_freq_range: number of elements in @freq_range
6246 *
6247 * @iface_combinations: Valid interface combinations array, should not
6248 * list single interface types.
6249 * @n_iface_combinations: number of entries in @iface_combinations array.
6250 *
6251 * @antenna_mask: bitmask of antennas connected to this radio.
6252 */
6253 struct wiphy_radio {
6254 const struct wiphy_radio_freq_range *freq_range;
6255 int n_freq_range;
6256
6257 const struct ieee80211_iface_combination *iface_combinations;
6258 int n_iface_combinations;
6259
6260 u32 antenna_mask;
6261 };
6262
6263 /**
6264 * enum wiphy_nan_flags - NAN capabilities
6265 *
6266 * @WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC: Device supports NAN configurable
6267 * synchronization.
6268 * @WIPHY_NAN_FLAGS_USERSPACE_DE: Device doesn't support DE offload.
6269 */
6270 enum wiphy_nan_flags {
6271 WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC = BIT(0),
6272 WIPHY_NAN_FLAGS_USERSPACE_DE = BIT(1),
6273 };
6274
6275 /**
6276 * struct wiphy_nan_capa - NAN capabilities
6277 *
6278 * This structure describes the NAN capabilities of a wiphy.
6279 *
6280 * @flags: NAN capabilities flags, see &enum wiphy_nan_flags
6281 * @op_mode: NAN operation mode, as defined in Wi-Fi Aware (TM) specification
6282 * Table 81.
6283 * @n_antennas: number of antennas supported by the device for Tx/Rx. Lower
6284 * nibble indicates the number of TX antennas and upper nibble indicates the
6285 * number of RX antennas. Value 0 indicates the information is not
6286 * available.
6287 * @max_channel_switch_time: maximum channel switch time in microseconds.
6288 * @dev_capabilities: NAN device capabilities as defined in Wi-Fi Aware (TM)
6289 * specification Table 79 (Capabilities field).
6290 * @phy: Band-agnostic capabilities for NAN data interfaces. Since NAN
6291 * operates on multiple channels simultaneously, these capabilities apply
6292 * across all bands. Valid only if NL80211_IFTYPE_NAN_DATA is supported.
6293 * @phy.ht: HT capabilities (mandatory for NAN data)
6294 * @phy.vht: VHT capabilities (optional)
6295 * @phy.he: HE capabilities (optional)
6296 */
6297 struct wiphy_nan_capa {
6298 u32 flags;
6299 u8 op_mode;
6300 u8 n_antennas;
6301 u16 max_channel_switch_time;
6302 u8 dev_capabilities;
6303 struct {
6304 struct ieee80211_sta_ht_cap ht;
6305 struct ieee80211_sta_vht_cap vht;
6306 struct ieee80211_sta_he_cap he;
6307 } phy;
6308 };
6309
6310 #define CFG80211_HW_TIMESTAMP_ALL_PEERS 0xffff
6311
6312 /**
6313 * struct wiphy - wireless hardware description
6314 * @mtx: mutex for the data (structures) of this device
6315 * @reg_notifier: the driver's regulatory notification callback,
6316 * note that if your driver uses wiphy_apply_custom_regulatory()
6317 * the reg_notifier's request can be passed as NULL
6318 * @regd: the driver's regulatory domain, if one was requested via
6319 * the regulatory_hint() API. This can be used by the driver
6320 * on the reg_notifier() if it chooses to ignore future
6321 * regulatory domain changes caused by other drivers.
6322 * @signal_type: signal type reported in &struct cfg80211_bss.
6323 * @cipher_suites: supported cipher suites
6324 * @n_cipher_suites: number of supported cipher suites
6325 * @akm_suites: supported AKM suites. These are the default AKMs supported if
6326 * the supported AKMs not advertized for a specific interface type in
6327 * iftype_akm_suites.
6328 * @n_akm_suites: number of supported AKM suites
6329 * @iftype_akm_suites: array of supported akm suites info per interface type.
6330 * Note that the bits in @iftypes_mask inside this structure cannot
6331 * overlap (i.e. only one occurrence of each type is allowed across all
6332 * instances of iftype_akm_suites).
6333 * @num_iftype_akm_suites: number of interface types for which supported akm
6334 * suites are specified separately.
6335 * @retry_short: Retry limit for short frames (dot11ShortRetryLimit)
6336 * @retry_long: Retry limit for long frames (dot11LongRetryLimit)
6337 * @frag_threshold: Fragmentation threshold (dot11FragmentationThreshold);
6338 * -1 = fragmentation disabled, only odd values >= 256 used
6339 * @rts_threshold: RTS threshold (dot11RTSThreshold); -1 = RTS/CTS disabled
6340 * @_net: the network namespace this wiphy currently lives in
6341 * @perm_addr: permanent MAC address of this device
6342 * @addr_mask: If the device supports multiple MAC addresses by masking,
6343 * set this to a mask with variable bits set to 1, e.g. if the last
6344 * four bits are variable then set it to 00-00-00-00-00-0f. The actual
6345 * variable bits shall be determined by the interfaces added, with
6346 * interfaces not matching the mask being rejected to be brought up.
6347 * @n_addresses: number of addresses in @addresses.
6348 * @addresses: If the device has more than one address, set this pointer
6349 * to a list of addresses (6 bytes each). The first one will be used
6350 * by default for perm_addr. In this case, the mask should be set to
6351 * all-zeroes. In this case it is assumed that the device can handle
6352 * the same number of arbitrary MAC addresses.
6353 * @registered: protects ->resume and ->suspend sysfs callbacks against
6354 * unregister hardware
6355 * @debugfsdir: debugfs directory used for this wiphy (ieee80211/<wiphyname>).
6356 * It will be renamed automatically on wiphy renames
6357 * @dev: (virtual) struct device for this wiphy. The item in
6358 * /sys/class/ieee80211/ points to this. You need use set_wiphy_dev()
6359 * (see below).
6360 * @wext: wireless extension handlers
6361 * @priv: driver private data (sized according to wiphy_new() parameter)
6362 * @interface_modes: bitmask of interfaces types valid for this wiphy,
6363 * must be set by driver
6364 * @iface_combinations: Valid interface combinations array, should not
6365 * list single interface types.
6366 * @n_iface_combinations: number of entries in @iface_combinations array.
6367 * @software_iftypes: bitmask of software interface types, these are not
6368 * subject to any restrictions since they are purely managed in SW.
6369 * @flags: wiphy flags, see &enum wiphy_flags
6370 * @regulatory_flags: wiphy regulatory flags, see
6371 * &enum ieee80211_regulatory_flags
6372 * @features: features advertised to nl80211, see &enum nl80211_feature_flags.
6373 * @ext_features: extended features advertised to nl80211, see
6374 * &enum nl80211_ext_feature_index.
6375 * @bss_priv_size: each BSS struct has private data allocated with it,
6376 * this variable determines its size
6377 * @max_scan_ssids: maximum number of SSIDs the device can scan for in
6378 * any given scan
6379 * @max_sched_scan_reqs: maximum number of scheduled scan requests that
6380 * the device can run concurrently.
6381 * @max_sched_scan_ssids: maximum number of SSIDs the device can scan
6382 * for in any given scheduled scan
6383 * @max_match_sets: maximum number of match sets the device can handle
6384 * when performing a scheduled scan, 0 if filtering is not
6385 * supported.
6386 * @max_scan_ie_len: maximum length of user-controlled IEs device can
6387 * add to probe request frames transmitted during a scan, must not
6388 * include fixed IEs like supported rates
6389 * @max_sched_scan_ie_len: same as max_scan_ie_len, but for scheduled
6390 * scans
6391 * @max_sched_scan_plans: maximum number of scan plans (scan interval and number
6392 * of iterations) for scheduled scan supported by the device.
6393 * @max_sched_scan_plan_interval: maximum interval (in seconds) for a
6394 * single scan plan supported by the device.
6395 * @max_sched_scan_plan_iterations: maximum number of iterations for a single
6396 * scan plan supported by the device.
6397 * @coverage_class: current coverage class
6398 * @fw_version: firmware version for ethtool reporting
6399 * @hw_version: hardware version for ethtool reporting
6400 * @max_num_pmkids: maximum number of PMKIDs supported by device
6401 * @privid: a pointer that drivers can use to identify if an arbitrary
6402 * wiphy is theirs, e.g. in global notifiers
6403 * @bands: information about bands/channels supported by this device
6404 *
6405 * @mgmt_stypes: bitmasks of frame subtypes that can be subscribed to or
6406 * transmitted through nl80211, points to an array indexed by interface
6407 * type
6408 *
6409 * @available_antennas_tx: bitmap of antennas which are available to be
6410 * configured as TX antennas. Antenna configuration commands will be
6411 * rejected unless this or @available_antennas_rx is set.
6412 *
6413 * @available_antennas_rx: bitmap of antennas which are available to be
6414 * configured as RX antennas. Antenna configuration commands will be
6415 * rejected unless this or @available_antennas_tx is set.
6416 *
6417 * @probe_resp_offload:
6418 * Bitmap of supported protocols for probe response offloading.
6419 * See &enum nl80211_probe_resp_offload_support_attr. Only valid
6420 * when the wiphy flag @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD is set.
6421 *
6422 * @max_remain_on_channel_duration: Maximum time a remain-on-channel operation
6423 * may request, if implemented.
6424 *
6425 * @wowlan: WoWLAN support information
6426 * @wowlan_config: current WoWLAN configuration; this should usually not be
6427 * used since access to it is necessarily racy, use the parameter passed
6428 * to the suspend() operation instead.
6429 *
6430 * @ap_sme_capa: AP SME capabilities, flags from &enum nl80211_ap_sme_features.
6431 * @ht_capa_mod_mask: Specify what ht_cap values can be over-ridden.
6432 * If null, then none can be over-ridden.
6433 * @vht_capa_mod_mask: Specify what VHT capabilities can be over-ridden.
6434 * If null, then none can be over-ridden.
6435 *
6436 * @wdev_list: the list of associated (virtual) interfaces; this list must
6437 * not be modified by the driver, but can be read with RTNL/RCU protection.
6438 *
6439 * @max_acl_mac_addrs: Maximum number of MAC addresses that the device
6440 * supports for ACL.
6441 *
6442 * @extended_capabilities: extended capabilities supported by the driver,
6443 * additional capabilities might be supported by userspace; these are
6444 * the 802.11 extended capabilities ("Extended Capabilities element")
6445 * and are in the same format as in the information element. See
6446 * 802.11-2012 8.4.2.29 for the defined fields. These are the default
6447 * extended capabilities to be used if the capabilities are not specified
6448 * for a specific interface type in iftype_ext_capab.
6449 * @extended_capabilities_mask: mask of the valid values
6450 * @extended_capabilities_len: length of the extended capabilities
6451 * @iftype_ext_capab: array of extended capabilities per interface type
6452 * @num_iftype_ext_capab: number of interface types for which extended
6453 * capabilities are specified separately.
6454 * @coalesce: packet coalescing support information
6455 *
6456 * @vendor_commands: array of vendor commands supported by the hardware
6457 * @n_vendor_commands: number of vendor commands
6458 * @vendor_events: array of vendor events supported by the hardware
6459 * @n_vendor_events: number of vendor events
6460 *
6461 * @max_ap_assoc_sta: maximum number of associated stations supported in AP mode
6462 * (including P2P GO) or 0 to indicate no such limit is advertised. The
6463 * driver is allowed to advertise a theoretical limit that it can reach in
6464 * some cases, but may not always reach.
6465 *
6466 * @max_num_csa_counters: Number of supported csa_counters in beacons
6467 * and probe responses. This value should be set if the driver
6468 * wishes to limit the number of csa counters. Default (0) means
6469 * infinite.
6470 * @bss_param_support: bitmask indicating which bss_parameters as defined in
6471 * &struct bss_parameters the driver can actually handle in the
6472 * .change_bss() callback. The bit positions are defined in &enum
6473 * wiphy_bss_param_flags.
6474 *
6475 * @bss_select_support: bitmask indicating the BSS selection criteria supported
6476 * by the driver in the .connect() callback. The bit position maps to the
6477 * attribute indices defined in &enum nl80211_bss_select_attr.
6478 *
6479 * @nan_supported_bands: bands supported by the device in NAN mode, a
6480 * bitmap of &enum nl80211_band values. For instance, for
6481 * NL80211_BAND_2GHZ, bit 0 would be set
6482 * (i.e. BIT(NL80211_BAND_2GHZ)).
6483 * @nan_capa: NAN capabilities
6484 *
6485 * @txq_limit: configuration of internal TX queue frame limit
6486 * @txq_memory_limit: configuration internal TX queue memory limit
6487 * @txq_quantum: configuration of internal TX queue scheduler quantum
6488 *
6489 * @tx_queue_len: allow setting transmit queue len for drivers not using
6490 * wake_tx_queue
6491 *
6492 * @support_mbssid: can HW support association with nontransmitted AP
6493 * @support_only_he_mbssid: don't parse MBSSID elements if it is not
6494 * HE AP, in order to avoid compatibility issues.
6495 * @support_mbssid must be set for this to have any effect.
6496 *
6497 * @pmsr_capa: peer measurement capabilities
6498 *
6499 * @tid_config_support: describes the per-TID config support that the
6500 * device has
6501 * @tid_config_support.vif: bitmap of attributes (configurations)
6502 * supported by the driver for each vif
6503 * @tid_config_support.peer: bitmap of attributes (configurations)
6504 * supported by the driver for each peer
6505 * @tid_config_support.max_retry: maximum supported retry count for
6506 * long/short retry configuration
6507 *
6508 * @max_data_retry_count: maximum supported per TID retry count for
6509 * configuration through the %NL80211_TID_CONFIG_ATTR_RETRY_SHORT and
6510 * %NL80211_TID_CONFIG_ATTR_RETRY_LONG attributes
6511 * @sar_capa: SAR control capabilities
6512 * @rfkill: a pointer to the rfkill structure
6513 *
6514 * @mbssid_max_interfaces: maximum number of interfaces supported by the driver
6515 * in a multiple BSSID set. This field must be set to a non-zero value
6516 * by the driver to advertise MBSSID support.
6517 * @ema_max_profile_periodicity: maximum profile periodicity supported by
6518 * the driver. Setting this field to a non-zero value indicates that the
6519 * driver supports enhanced multi-BSSID advertisements (EMA AP).
6520 * @max_num_akm_suites: maximum number of AKM suites allowed for
6521 * configuration through %NL80211_CMD_CONNECT, %NL80211_CMD_ASSOCIATE and
6522 * %NL80211_CMD_START_AP. Set to NL80211_MAX_NR_AKM_SUITES if not set by
6523 * driver. If set by driver minimum allowed value is
6524 * NL80211_MAX_NR_AKM_SUITES in order to avoid compatibility issues with
6525 * legacy userspace and maximum allowed value is
6526 * CFG80211_MAX_NUM_AKM_SUITES.
6527 *
6528 * @hw_timestamp_max_peers: maximum number of peers that the driver supports
6529 * enabling HW timestamping for concurrently. Setting this field to a
6530 * non-zero value indicates that the driver supports HW timestamping.
6531 * A value of %CFG80211_HW_TIMESTAMP_ALL_PEERS indicates the driver
6532 * supports enabling HW timestamping for all peers (i.e. no need to
6533 * specify a mac address).
6534 *
6535 * @radio_cfg: configuration of radios belonging to a muli-radio wiphy. This
6536 * struct contains a list of all radio specific attributes and should be
6537 * used only for multi-radio wiphy.
6538 *
6539 * @radio: radios belonging to this wiphy
6540 * @n_radio: number of radios
6541 */
6542 struct wiphy {
6543 struct mutex mtx;
6544
6545 /* assign these fields before you register the wiphy */
6546
6547 u8 perm_addr[ETH_ALEN];
6548 u8 addr_mask[ETH_ALEN];
6549
6550 struct mac_address *addresses;
6551
6552 const struct ieee80211_txrx_stypes *mgmt_stypes;
6553
6554 const struct ieee80211_iface_combination *iface_combinations;
6555 int n_iface_combinations;
6556 u16 software_iftypes;
6557
6558 u16 n_addresses;
6559
6560 /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */
6561 u16 interface_modes;
6562
6563 u16 max_acl_mac_addrs;
6564
6565 u32 flags, regulatory_flags, features;
6566 u8 ext_features[DIV_ROUND_UP(NUM_NL80211_EXT_FEATURES, 8)];
6567
6568 u32 ap_sme_capa;
6569
6570 enum cfg80211_signal_type signal_type;
6571
6572 int bss_priv_size;
6573 u8 max_scan_ssids;
6574 u8 max_sched_scan_reqs;
6575 u8 max_sched_scan_ssids;
6576 u8 max_match_sets;
6577 u16 max_scan_ie_len;
6578 u16 max_sched_scan_ie_len;
6579 u32 max_sched_scan_plans;
6580 u32 max_sched_scan_plan_interval;
6581 u32 max_sched_scan_plan_iterations;
6582
6583 int n_cipher_suites;
6584 const u32 *cipher_suites;
6585
6586 int n_akm_suites;
6587 const u32 *akm_suites;
6588
6589 const struct wiphy_iftype_akm_suites *iftype_akm_suites;
6590 unsigned int num_iftype_akm_suites;
6591
6592 u8 retry_short;
6593 u8 retry_long;
6594 u32 frag_threshold;
6595 u32 rts_threshold;
6596 u8 coverage_class;
6597
6598 char fw_version[ETHTOOL_FWVERS_LEN];
6599 u32 hw_version;
6600
6601 #ifdef CONFIG_PM
6602 const struct wiphy_wowlan_support *wowlan;
6603 struct cfg80211_wowlan *wowlan_config;
6604 #endif
6605
6606 u16 max_remain_on_channel_duration;
6607
6608 u8 max_num_pmkids;
6609
6610 u32 available_antennas_tx;
6611 u32 available_antennas_rx;
6612
6613 u32 probe_resp_offload;
6614
6615 const u8 *extended_capabilities, *extended_capabilities_mask;
6616 u8 extended_capabilities_len;
6617
6618 const struct wiphy_iftype_ext_capab *iftype_ext_capab;
6619 unsigned int num_iftype_ext_capab;
6620
6621 const void *privid;
6622
6623 struct ieee80211_supported_band *bands[NUM_NL80211_BANDS];
6624
6625 void (*reg_notifier)(struct wiphy *wiphy,
6626 struct regulatory_request *request);
6627
6628 struct wiphy_radio_cfg *radio_cfg;
6629
6630 /* fields below are read-only, assigned by cfg80211 */
6631
6632 const struct ieee80211_regdomain __rcu *regd;
6633
6634 struct device dev;
6635
6636 bool registered;
6637
6638 struct dentry *debugfsdir;
6639
6640 const struct ieee80211_ht_cap *ht_capa_mod_mask;
6641 const struct ieee80211_vht_cap *vht_capa_mod_mask;
6642
6643 struct list_head wdev_list;
6644
6645 possible_net_t _net;
6646
6647 #ifdef CONFIG_CFG80211_WEXT
6648 const struct iw_handler_def *wext;
6649 #endif
6650
6651 const struct wiphy_coalesce_support *coalesce;
6652
6653 const struct wiphy_vendor_command *vendor_commands;
6654 const struct nl80211_vendor_cmd_info *vendor_events;
6655 int n_vendor_commands, n_vendor_events;
6656
6657 u16 max_ap_assoc_sta;
6658
6659 u8 max_num_csa_counters;
6660
6661 u32 bss_param_support;
6662 u32 bss_select_support;
6663
6664 u8 nan_supported_bands;
6665 struct wiphy_nan_capa nan_capa;
6666
6667 u32 txq_limit;
6668 u32 txq_memory_limit;
6669 u32 txq_quantum;
6670
6671 unsigned long tx_queue_len;
6672
6673 u8 support_mbssid:1,
6674 support_only_he_mbssid:1;
6675
6676 const struct cfg80211_pmsr_capabilities *pmsr_capa;
6677
6678 struct {
6679 u64 peer, vif;
6680 u8 max_retry;
6681 } tid_config_support;
6682
6683 u8 max_data_retry_count;
6684
6685 const struct cfg80211_sar_capa *sar_capa;
6686
6687 struct rfkill *rfkill;
6688
6689 u8 mbssid_max_interfaces;
6690 u8 ema_max_profile_periodicity;
6691 u16 max_num_akm_suites;
6692
6693 u16 hw_timestamp_max_peers;
6694
6695 int n_radio;
6696 const struct wiphy_radio *radio;
6697
6698 char priv[] __aligned(NETDEV_ALIGN);
6699 };
6700
wiphy_net(struct wiphy * wiphy)6701 static inline struct net *wiphy_net(struct wiphy *wiphy)
6702 {
6703 return read_pnet(&wiphy->_net);
6704 }
6705
wiphy_net_set(struct wiphy * wiphy,struct net * net)6706 static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net)
6707 {
6708 write_pnet(&wiphy->_net, net);
6709 }
6710
6711 /**
6712 * wiphy_priv - return priv from wiphy
6713 *
6714 * @wiphy: the wiphy whose priv pointer to return
6715 * Return: The priv of @wiphy.
6716 */
wiphy_priv(struct wiphy * wiphy)6717 static inline void *wiphy_priv(struct wiphy *wiphy)
6718 {
6719 BUG_ON(!wiphy);
6720 return &wiphy->priv;
6721 }
6722
6723 /**
6724 * priv_to_wiphy - return the wiphy containing the priv
6725 *
6726 * @priv: a pointer previously returned by wiphy_priv
6727 * Return: The wiphy of @priv.
6728 */
priv_to_wiphy(void * priv)6729 static inline struct wiphy *priv_to_wiphy(void *priv)
6730 {
6731 BUG_ON(!priv);
6732 return container_of(priv, struct wiphy, priv);
6733 }
6734
6735 /**
6736 * set_wiphy_dev - set device pointer for wiphy
6737 *
6738 * @wiphy: The wiphy whose device to bind
6739 * @dev: The device to parent it to
6740 */
set_wiphy_dev(struct wiphy * wiphy,struct device * dev)6741 static inline void set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
6742 {
6743 wiphy->dev.parent = dev;
6744 }
6745
6746 /**
6747 * wiphy_dev - get wiphy dev pointer
6748 *
6749 * @wiphy: The wiphy whose device struct to look up
6750 * Return: The dev of @wiphy.
6751 */
wiphy_dev(struct wiphy * wiphy)6752 static inline struct device *wiphy_dev(struct wiphy *wiphy)
6753 {
6754 return wiphy->dev.parent;
6755 }
6756
6757 /**
6758 * wiphy_name - get wiphy name
6759 *
6760 * @wiphy: The wiphy whose name to return
6761 * Return: The name of @wiphy.
6762 */
wiphy_name(const struct wiphy * wiphy)6763 static inline const char *wiphy_name(const struct wiphy *wiphy)
6764 {
6765 return dev_name(&wiphy->dev);
6766 }
6767
6768 /**
6769 * wiphy_new_nm - create a new wiphy for use with cfg80211
6770 *
6771 * @ops: The configuration operations for this device
6772 * @sizeof_priv: The size of the private area to allocate
6773 * @requested_name: Request a particular name.
6774 * NULL is valid value, and means use the default phy%d naming.
6775 *
6776 * Create a new wiphy and associate the given operations with it.
6777 * @sizeof_priv bytes are allocated for private use.
6778 *
6779 * Return: A pointer to the new wiphy. This pointer must be
6780 * assigned to each netdev's ieee80211_ptr for proper operation.
6781 */
6782 struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
6783 const char *requested_name);
6784
6785 /**
6786 * wiphy_new - create a new wiphy for use with cfg80211
6787 *
6788 * @ops: The configuration operations for this device
6789 * @sizeof_priv: The size of the private area to allocate
6790 *
6791 * Create a new wiphy and associate the given operations with it.
6792 * @sizeof_priv bytes are allocated for private use.
6793 *
6794 * Return: A pointer to the new wiphy. This pointer must be
6795 * assigned to each netdev's ieee80211_ptr for proper operation.
6796 */
wiphy_new(const struct cfg80211_ops * ops,int sizeof_priv)6797 static inline struct wiphy *wiphy_new(const struct cfg80211_ops *ops,
6798 int sizeof_priv)
6799 {
6800 return wiphy_new_nm(ops, sizeof_priv, NULL);
6801 }
6802
6803 /**
6804 * wiphy_register - register a wiphy with cfg80211
6805 *
6806 * @wiphy: The wiphy to register.
6807 *
6808 * Return: A non-negative wiphy index or a negative error code.
6809 */
6810 int wiphy_register(struct wiphy *wiphy);
6811
6812 /* this is a define for better error reporting (file/line) */
6813 #define lockdep_assert_wiphy(wiphy) lockdep_assert_held(&(wiphy)->mtx)
6814
6815 /**
6816 * rcu_dereference_wiphy - rcu_dereference with debug checking
6817 * @wiphy: the wiphy to check the locking on
6818 * @p: The pointer to read, prior to dereferencing
6819 *
6820 * Do an rcu_dereference(p), but check caller either holds rcu_read_lock()
6821 * or RTNL. Note: Please prefer wiphy_dereference() or rcu_dereference().
6822 */
6823 #define rcu_dereference_wiphy(wiphy, p) \
6824 rcu_dereference_check(p, lockdep_is_held(&wiphy->mtx))
6825
6826 /**
6827 * wiphy_dereference - fetch RCU pointer when updates are prevented by wiphy mtx
6828 * @wiphy: the wiphy to check the locking on
6829 * @p: The pointer to read, prior to dereferencing
6830 *
6831 * Return: the value of the specified RCU-protected pointer, but omit the
6832 * READ_ONCE(), because caller holds the wiphy mutex used for updates.
6833 */
6834 #define wiphy_dereference(wiphy, p) \
6835 rcu_dereference_protected(p, lockdep_is_held(&wiphy->mtx))
6836
6837 /**
6838 * get_wiphy_regdom - get custom regdomain for the given wiphy
6839 * @wiphy: the wiphy to get the regdomain from
6840 *
6841 * Context: Requires any of RTNL, wiphy mutex or RCU protection.
6842 *
6843 * Return: pointer to the regulatory domain associated with the wiphy
6844 */
6845 const struct ieee80211_regdomain *get_wiphy_regdom(struct wiphy *wiphy);
6846
6847 /**
6848 * wiphy_unregister - deregister a wiphy from cfg80211
6849 *
6850 * @wiphy: The wiphy to unregister.
6851 *
6852 * After this call, no more requests can be made with this priv
6853 * pointer, but the call may sleep to wait for an outstanding
6854 * request that is being handled.
6855 */
6856 void wiphy_unregister(struct wiphy *wiphy);
6857
6858 /**
6859 * wiphy_free - free wiphy
6860 *
6861 * @wiphy: The wiphy to free
6862 */
6863 void wiphy_free(struct wiphy *wiphy);
6864
6865 /* internal structs */
6866 struct cfg80211_conn;
6867 struct cfg80211_internal_bss;
6868 struct cfg80211_cached_keys;
6869 struct cfg80211_cqm_config;
6870
6871 /**
6872 * wiphy_lock - lock the wiphy
6873 * @wiphy: the wiphy to lock
6874 *
6875 * This is needed around registering and unregistering netdevs that
6876 * aren't created through cfg80211 calls, since that requires locking
6877 * in cfg80211 when the notifiers is called, but that cannot
6878 * differentiate which way it's called.
6879 *
6880 * It can also be used by drivers for their own purposes.
6881 *
6882 * When cfg80211 ops are called, the wiphy is already locked.
6883 *
6884 * Note that this makes sure that no workers that have been queued
6885 * with wiphy_queue_work() are running.
6886 */
wiphy_lock(struct wiphy * wiphy)6887 static inline void wiphy_lock(struct wiphy *wiphy)
6888 __acquires(&wiphy->mtx)
6889 {
6890 mutex_lock(&wiphy->mtx);
6891 __acquire(&wiphy->mtx);
6892 }
6893
6894 /**
6895 * wiphy_unlock - unlock the wiphy again
6896 * @wiphy: the wiphy to unlock
6897 */
wiphy_unlock(struct wiphy * wiphy)6898 static inline void wiphy_unlock(struct wiphy *wiphy)
6899 __releases(&wiphy->mtx)
6900 {
6901 __release(&wiphy->mtx);
6902 mutex_unlock(&wiphy->mtx);
6903 }
6904
6905 DEFINE_GUARD(wiphy, struct wiphy *,
6906 mutex_lock(&_T->mtx),
6907 mutex_unlock(&_T->mtx))
6908
6909 struct wiphy_work;
6910 typedef void (*wiphy_work_func_t)(struct wiphy *, struct wiphy_work *);
6911
6912 struct wiphy_work {
6913 struct list_head entry;
6914 wiphy_work_func_t func;
6915 };
6916
wiphy_work_init(struct wiphy_work * work,wiphy_work_func_t func)6917 static inline void wiphy_work_init(struct wiphy_work *work,
6918 wiphy_work_func_t func)
6919 {
6920 INIT_LIST_HEAD(&work->entry);
6921 work->func = func;
6922 }
6923
6924 /**
6925 * wiphy_work_queue - queue work for the wiphy
6926 * @wiphy: the wiphy to queue for
6927 * @work: the work item
6928 *
6929 * This is useful for work that must be done asynchronously, and work
6930 * queued here has the special property that the wiphy mutex will be
6931 * held as if wiphy_lock() was called, and that it cannot be running
6932 * after wiphy_lock() was called. Therefore, wiphy_cancel_work() can
6933 * use just cancel_work() instead of cancel_work_sync(), it requires
6934 * being in a section protected by wiphy_lock().
6935 */
6936 void wiphy_work_queue(struct wiphy *wiphy, struct wiphy_work *work);
6937
6938 /**
6939 * wiphy_work_cancel - cancel previously queued work
6940 * @wiphy: the wiphy, for debug purposes
6941 * @work: the work to cancel
6942 *
6943 * Cancel the work *without* waiting for it, this assumes being
6944 * called under the wiphy mutex acquired by wiphy_lock().
6945 */
6946 void wiphy_work_cancel(struct wiphy *wiphy, struct wiphy_work *work);
6947
6948 /**
6949 * wiphy_work_flush - flush previously queued work
6950 * @wiphy: the wiphy, for debug purposes
6951 * @work: the work to flush, this can be %NULL to flush all work
6952 *
6953 * Flush the work (i.e. run it if pending). This must be called
6954 * under the wiphy mutex acquired by wiphy_lock().
6955 */
6956 void wiphy_work_flush(struct wiphy *wiphy, struct wiphy_work *work);
6957
6958 struct wiphy_delayed_work {
6959 struct wiphy_work work;
6960 struct wiphy *wiphy;
6961 struct timer_list timer;
6962 };
6963
6964 void wiphy_delayed_work_timer(struct timer_list *t);
6965
wiphy_delayed_work_init(struct wiphy_delayed_work * dwork,wiphy_work_func_t func)6966 static inline void wiphy_delayed_work_init(struct wiphy_delayed_work *dwork,
6967 wiphy_work_func_t func)
6968 {
6969 timer_setup(&dwork->timer, wiphy_delayed_work_timer, 0);
6970 wiphy_work_init(&dwork->work, func);
6971 }
6972
6973 /**
6974 * wiphy_delayed_work_queue - queue delayed work for the wiphy
6975 * @wiphy: the wiphy to queue for
6976 * @dwork: the delayable worker
6977 * @delay: number of jiffies to wait before queueing
6978 *
6979 * This is useful for work that must be done asynchronously, and work
6980 * queued here has the special property that the wiphy mutex will be
6981 * held as if wiphy_lock() was called, and that it cannot be running
6982 * after wiphy_lock() was called. Therefore, wiphy_cancel_work() can
6983 * use just cancel_work() instead of cancel_work_sync(), it requires
6984 * being in a section protected by wiphy_lock().
6985 *
6986 * Note that these are scheduled with a timer where the accuracy
6987 * becomes less the longer in the future the scheduled timer is. Use
6988 * wiphy_hrtimer_work_queue() if the timer must be not be late by more
6989 * than approximately 10 percent.
6990 */
6991 void wiphy_delayed_work_queue(struct wiphy *wiphy,
6992 struct wiphy_delayed_work *dwork,
6993 unsigned long delay);
6994
6995 /**
6996 * wiphy_delayed_work_cancel - cancel previously queued delayed work
6997 * @wiphy: the wiphy, for debug purposes
6998 * @dwork: the delayed work to cancel
6999 *
7000 * Cancel the work *without* waiting for it, this assumes being
7001 * called under the wiphy mutex acquired by wiphy_lock().
7002 */
7003 void wiphy_delayed_work_cancel(struct wiphy *wiphy,
7004 struct wiphy_delayed_work *dwork);
7005
7006 /**
7007 * wiphy_delayed_work_flush - flush previously queued delayed work
7008 * @wiphy: the wiphy, for debug purposes
7009 * @dwork: the delayed work to flush
7010 *
7011 * Flush the work (i.e. run it if pending). This must be called
7012 * under the wiphy mutex acquired by wiphy_lock().
7013 */
7014 void wiphy_delayed_work_flush(struct wiphy *wiphy,
7015 struct wiphy_delayed_work *dwork);
7016
7017 /**
7018 * wiphy_delayed_work_pending - Find out whether a wiphy delayable
7019 * work item is currently pending.
7020 *
7021 * @wiphy: the wiphy, for debug purposes
7022 * @dwork: the delayed work in question
7023 *
7024 * Return: true if timer is pending, false otherwise
7025 *
7026 * How wiphy_delayed_work_queue() works is by setting a timer which
7027 * when it expires calls wiphy_work_queue() to queue the wiphy work.
7028 * Because wiphy_delayed_work_queue() uses mod_timer(), if it is
7029 * called twice and the second call happens before the first call
7030 * deadline, the work will rescheduled for the second deadline and
7031 * won't run before that.
7032 *
7033 * wiphy_delayed_work_pending() can be used to detect if calling
7034 * wiphy_work_delayed_work_queue() would start a new work schedule
7035 * or delayed a previous one. As seen below it cannot be used to
7036 * detect precisely if the work has finished to execute nor if it
7037 * is currently executing.
7038 *
7039 * CPU0 CPU1
7040 * wiphy_delayed_work_queue(wk)
7041 * mod_timer(wk->timer)
7042 * wiphy_delayed_work_pending(wk) -> true
7043 *
7044 * [...]
7045 * expire_timers(wk->timer)
7046 * detach_timer(wk->timer)
7047 * wiphy_delayed_work_pending(wk) -> false
7048 * wk->timer->function() |
7049 * wiphy_work_queue(wk) | delayed work pending
7050 * list_add_tail() | returns false but
7051 * queue_work(cfg80211_wiphy_work) | wk->func() has not
7052 * | been run yet
7053 * [...] |
7054 * cfg80211_wiphy_work() |
7055 * wk->func() V
7056 *
7057 */
7058 bool wiphy_delayed_work_pending(struct wiphy *wiphy,
7059 struct wiphy_delayed_work *dwork);
7060
7061 struct wiphy_hrtimer_work {
7062 struct wiphy_work work;
7063 struct wiphy *wiphy;
7064 struct hrtimer timer;
7065 };
7066
7067 enum hrtimer_restart wiphy_hrtimer_work_timer(struct hrtimer *t);
7068
wiphy_hrtimer_work_init(struct wiphy_hrtimer_work * hrwork,wiphy_work_func_t func)7069 static inline void wiphy_hrtimer_work_init(struct wiphy_hrtimer_work *hrwork,
7070 wiphy_work_func_t func)
7071 {
7072 hrtimer_setup(&hrwork->timer, wiphy_hrtimer_work_timer,
7073 CLOCK_BOOTTIME, HRTIMER_MODE_REL);
7074 wiphy_work_init(&hrwork->work, func);
7075 }
7076
7077 /**
7078 * wiphy_hrtimer_work_queue - queue hrtimer work for the wiphy
7079 * @wiphy: the wiphy to queue for
7080 * @hrwork: the high resolution timer worker
7081 * @delay: the delay given as a ktime_t
7082 *
7083 * Please refer to wiphy_delayed_work_queue(). The difference is that
7084 * the hrtimer work uses a high resolution timer for scheduling. This
7085 * may be needed if timeouts might be scheduled further in the future
7086 * and the accuracy of the normal timer is not sufficient.
7087 *
7088 * Expect a delay of a few milliseconds as the timer is scheduled
7089 * with some slack and some more time may pass between queueing the
7090 * work and its start.
7091 */
7092 void wiphy_hrtimer_work_queue(struct wiphy *wiphy,
7093 struct wiphy_hrtimer_work *hrwork,
7094 ktime_t delay);
7095
7096 /**
7097 * wiphy_hrtimer_work_cancel - cancel previously queued hrtimer work
7098 * @wiphy: the wiphy, for debug purposes
7099 * @hrtimer: the hrtimer work to cancel
7100 *
7101 * Cancel the work *without* waiting for it, this assumes being
7102 * called under the wiphy mutex acquired by wiphy_lock().
7103 */
7104 void wiphy_hrtimer_work_cancel(struct wiphy *wiphy,
7105 struct wiphy_hrtimer_work *hrtimer);
7106
7107 /**
7108 * wiphy_hrtimer_work_flush - flush previously queued hrtimer work
7109 * @wiphy: the wiphy, for debug purposes
7110 * @hrwork: the hrtimer work to flush
7111 *
7112 * Flush the work (i.e. run it if pending). This must be called
7113 * under the wiphy mutex acquired by wiphy_lock().
7114 */
7115 void wiphy_hrtimer_work_flush(struct wiphy *wiphy,
7116 struct wiphy_hrtimer_work *hrwork);
7117
7118 /**
7119 * wiphy_hrtimer_work_pending - Find out whether a wiphy hrtimer
7120 * work item is currently pending.
7121 *
7122 * @wiphy: the wiphy, for debug purposes
7123 * @hrwork: the hrtimer work in question
7124 *
7125 * Return: true if timer is pending, false otherwise
7126 *
7127 * Please refer to the wiphy_delayed_work_pending() documentation as
7128 * this is the equivalent function for hrtimer based delayed work
7129 * items.
7130 */
7131 bool wiphy_hrtimer_work_pending(struct wiphy *wiphy,
7132 struct wiphy_hrtimer_work *hrwork);
7133
7134 /**
7135 * enum ieee80211_ap_reg_power - regulatory power for an Access Point
7136 *
7137 * @IEEE80211_REG_UNSET_AP: Access Point has no regulatory power mode
7138 * @IEEE80211_REG_LPI_AP: Indoor Access Point
7139 * @IEEE80211_REG_SP_AP: Standard power Access Point
7140 * @IEEE80211_REG_VLP_AP: Very low power Access Point
7141 */
7142 enum ieee80211_ap_reg_power {
7143 IEEE80211_REG_UNSET_AP,
7144 IEEE80211_REG_LPI_AP,
7145 IEEE80211_REG_SP_AP,
7146 IEEE80211_REG_VLP_AP,
7147 };
7148
7149 /**
7150 * struct wireless_dev - wireless device state
7151 *
7152 * For netdevs, this structure must be allocated by the driver
7153 * that uses the ieee80211_ptr field in struct net_device (this
7154 * is intentional so it can be allocated along with the netdev.)
7155 * It need not be registered then as netdev registration will
7156 * be intercepted by cfg80211 to see the new wireless device,
7157 * however, drivers must lock the wiphy before registering or
7158 * unregistering netdevs if they pre-create any netdevs (in ops
7159 * called from cfg80211, the wiphy is already locked.)
7160 *
7161 * For non-netdev uses, it must also be allocated by the driver
7162 * in response to the cfg80211 callbacks that require it, as
7163 * there's no netdev registration in that case it may not be
7164 * allocated outside of callback operations that return it.
7165 *
7166 * @wiphy: pointer to hardware description
7167 * @iftype: interface type
7168 * @registered: is this wdev already registered with cfg80211
7169 * @registering: indicates we're doing registration under wiphy lock
7170 * for the notifier
7171 * @list: (private) Used to collect the interfaces
7172 * @netdev: (private) Used to reference back to the netdev, may be %NULL
7173 * @identifier: (private) Identifier used in nl80211 to identify this
7174 * wireless device if it has no netdev
7175 * @u: union containing data specific to @iftype
7176 * @connected: indicates if connected or not (STA mode)
7177 * @wext: (private) Used by the internal wireless extensions compat code
7178 * @wext.ibss: (private) IBSS data part of wext handling
7179 * @wext.connect: (private) connection handling data
7180 * @wext.keys: (private) (WEP) key data
7181 * @wext.ie: (private) extra elements for association
7182 * @wext.ie_len: (private) length of extra elements
7183 * @wext.bssid: (private) selected network BSSID
7184 * @wext.ssid: (private) selected network SSID
7185 * @wext.default_key: (private) selected default key index
7186 * @wext.default_mgmt_key: (private) selected default management key index
7187 * @wext.prev_bssid: (private) previous BSSID for reassociation
7188 * @wext.prev_bssid_valid: (private) previous BSSID validity
7189 * @use_4addr: indicates 4addr mode is used on this interface, must be
7190 * set by driver (if supported) on add_interface BEFORE registering the
7191 * netdev and may otherwise be used by driver read-only, will be update
7192 * by cfg80211 on change_interface
7193 * @mgmt_registrations: list of registrations for management frames
7194 * @mgmt_registrations_need_update: mgmt registrations were updated,
7195 * need to propagate the update to the driver
7196 * @address: The address for this device, valid only if @netdev is %NULL
7197 * @is_running: true if this is a non-netdev device that has been started, e.g.
7198 * the P2P Device.
7199 * @ps: powersave mode is enabled
7200 * @ps_timeout: dynamic powersave timeout
7201 * @unexpected_nlportid: (private) netlink port ID of application
7202 * registered for unexpected frames (AP mode or NAN_DATA mode)
7203 * @conn: (private) cfg80211 software SME connection state machine data
7204 * @connect_keys: (private) keys to set after connection is established
7205 * @conn_bss_type: connecting/connected BSS type
7206 * @conn_owner_nlportid: (private) connection owner socket port ID
7207 * @disconnect_wk: (private) auto-disconnect work
7208 * @disconnect_bssid: (private) the BSSID to use for auto-disconnect
7209 * @event_list: (private) list for internal event processing
7210 * @event_lock: (private) lock for event list
7211 * @owner_nlportid: (private) owner socket port ID
7212 * @nl_owner_dead: (private) owner socket went away
7213 * @cqm_rssi_work: (private) CQM RSSI reporting work
7214 * @cqm_config: (private) nl80211 RSSI monitor state
7215 * @pmsr_list: (private) peer measurement requests
7216 * @pmsr_lock: (private) peer measurements requests/results lock
7217 * @pmsr_free_wk: (private) peer measurements cleanup work
7218 * @unprot_beacon_reported: (private) timestamp of last
7219 * unprotected beacon report
7220 * @links: array of %IEEE80211_MLD_MAX_NUM_LINKS elements containing @addr
7221 * @ap and @client for each link
7222 * @links.cac_started: true if DFS channel availability check has been
7223 * started
7224 * @links.cac_start_time: timestamp (jiffies) when the dfs state was
7225 * entered.
7226 * @links.cac_time_ms: CAC time in ms
7227 * @valid_links: bitmap describing what elements of @links are valid
7228 * @radio_mask: Bitmask of radios that this interface is allowed to operate on.
7229 */
7230 struct wireless_dev {
7231 struct wiphy *wiphy;
7232 enum nl80211_iftype iftype;
7233
7234 /* the remainder of this struct should be private to cfg80211 */
7235 struct list_head list;
7236 struct net_device *netdev;
7237
7238 u32 identifier;
7239
7240 struct list_head mgmt_registrations;
7241 u8 mgmt_registrations_need_update:1;
7242
7243 bool use_4addr, is_running, registered, registering;
7244
7245 u8 address[ETH_ALEN] __aligned(sizeof(u16));
7246
7247 /* currently used for IBSS and SME - might be rearranged later */
7248 struct cfg80211_conn *conn;
7249 struct cfg80211_cached_keys *connect_keys;
7250 enum ieee80211_bss_type conn_bss_type;
7251 u32 conn_owner_nlportid;
7252
7253 struct wiphy_work disconnect_wk;
7254 u8 disconnect_bssid[ETH_ALEN];
7255
7256 struct list_head event_list;
7257 spinlock_t event_lock;
7258
7259 u8 connected:1;
7260
7261 bool ps;
7262 int ps_timeout;
7263
7264 u32 unexpected_nlportid;
7265
7266 u32 owner_nlportid;
7267 bool nl_owner_dead;
7268
7269 #ifdef CONFIG_CFG80211_WEXT
7270 /* wext data */
7271 struct {
7272 struct cfg80211_ibss_params ibss;
7273 struct cfg80211_connect_params connect;
7274 struct cfg80211_cached_keys *keys;
7275 const u8 *ie;
7276 size_t ie_len;
7277 u8 bssid[ETH_ALEN];
7278 u8 prev_bssid[ETH_ALEN];
7279 u8 ssid[IEEE80211_MAX_SSID_LEN];
7280 s8 default_key, default_mgmt_key;
7281 bool prev_bssid_valid;
7282 } wext;
7283 #endif
7284
7285 struct wiphy_work cqm_rssi_work;
7286 struct cfg80211_cqm_config __rcu *cqm_config;
7287
7288 struct list_head pmsr_list;
7289 spinlock_t pmsr_lock;
7290 struct wiphy_work pmsr_free_wk;
7291
7292 unsigned long unprot_beacon_reported;
7293
7294 union {
7295 struct {
7296 u8 connected_addr[ETH_ALEN] __aligned(2);
7297 u8 ssid[IEEE80211_MAX_SSID_LEN];
7298 u8 ssid_len;
7299 } client;
7300 struct {
7301 int beacon_interval;
7302 struct cfg80211_chan_def preset_chandef;
7303 struct cfg80211_chan_def chandef;
7304 u8 id[IEEE80211_MAX_MESH_ID_LEN];
7305 u8 id_len, id_up_len;
7306 } mesh;
7307 struct {
7308 struct cfg80211_chan_def preset_chandef;
7309 u8 ssid[IEEE80211_MAX_SSID_LEN];
7310 u8 ssid_len;
7311 } ap;
7312 struct {
7313 struct cfg80211_internal_bss *current_bss;
7314 struct cfg80211_chan_def chandef;
7315 int beacon_interval;
7316 u8 ssid[IEEE80211_MAX_SSID_LEN];
7317 u8 ssid_len;
7318 } ibss;
7319 struct {
7320 struct cfg80211_chan_def chandef;
7321 } ocb;
7322 struct {
7323 u8 cluster_id[ETH_ALEN] __aligned(2);
7324 u8 n_channels;
7325 struct cfg80211_chan_def *chandefs;
7326 bool sched_update_pending;
7327 } nan;
7328 } u;
7329
7330 struct {
7331 u8 addr[ETH_ALEN] __aligned(2);
7332 union {
7333 struct {
7334 unsigned int beacon_interval;
7335 struct cfg80211_chan_def chandef;
7336 } ap;
7337 struct {
7338 struct cfg80211_internal_bss *current_bss;
7339 } client;
7340 };
7341
7342 bool cac_started;
7343 unsigned long cac_start_time;
7344 unsigned int cac_time_ms;
7345 } links[IEEE80211_MLD_MAX_NUM_LINKS];
7346 u16 valid_links;
7347
7348 u32 radio_mask;
7349 };
7350
wdev_address(struct wireless_dev * wdev)7351 static inline const u8 *wdev_address(struct wireless_dev *wdev)
7352 {
7353 if (wdev->netdev)
7354 return wdev->netdev->dev_addr;
7355 return wdev->address;
7356 }
7357
wdev_running(struct wireless_dev * wdev)7358 static inline bool wdev_running(struct wireless_dev *wdev)
7359 {
7360 if (wdev->netdev)
7361 return netif_running(wdev->netdev);
7362 return wdev->is_running;
7363 }
7364
7365 /**
7366 * wdev_priv - return wiphy priv from wireless_dev
7367 *
7368 * @wdev: The wireless device whose wiphy's priv pointer to return
7369 * Return: The wiphy priv of @wdev.
7370 */
wdev_priv(struct wireless_dev * wdev)7371 static inline void *wdev_priv(struct wireless_dev *wdev)
7372 {
7373 BUG_ON(!wdev);
7374 return wiphy_priv(wdev->wiphy);
7375 }
7376
7377 /**
7378 * wdev_chandef - return chandef pointer from wireless_dev
7379 * @wdev: the wdev
7380 * @link_id: the link ID for MLO
7381 *
7382 * Return: The chandef depending on the mode, or %NULL.
7383 */
7384 struct cfg80211_chan_def *wdev_chandef(struct wireless_dev *wdev,
7385 unsigned int link_id);
7386
WARN_INVALID_LINK_ID(struct wireless_dev * wdev,unsigned int link_id)7387 static inline void WARN_INVALID_LINK_ID(struct wireless_dev *wdev,
7388 unsigned int link_id)
7389 {
7390 WARN_ON(link_id && !wdev->valid_links);
7391 WARN_ON(wdev->valid_links &&
7392 !(wdev->valid_links & BIT(link_id)));
7393 }
7394
7395 #define for_each_valid_link(link_info, link_id) \
7396 for (link_id = 0; \
7397 link_id < ((link_info)->valid_links ? \
7398 ARRAY_SIZE((link_info)->links) : 1); \
7399 link_id++) \
7400 if (!(link_info)->valid_links || \
7401 ((link_info)->valid_links & BIT(link_id)))
7402
7403 /**
7404 * DOC: Utility functions
7405 *
7406 * cfg80211 offers a number of utility functions that can be useful.
7407 */
7408
7409 /**
7410 * ieee80211_channel_equal - compare two struct ieee80211_channel
7411 *
7412 * @a: 1st struct ieee80211_channel
7413 * @b: 2nd struct ieee80211_channel
7414 * Return: true if center frequency of @a == @b
7415 */
7416 static inline bool
ieee80211_channel_equal(struct ieee80211_channel * a,struct ieee80211_channel * b)7417 ieee80211_channel_equal(struct ieee80211_channel *a,
7418 struct ieee80211_channel *b)
7419 {
7420 return (a->center_freq == b->center_freq &&
7421 a->freq_offset == b->freq_offset);
7422 }
7423
7424 /**
7425 * ieee80211_channel_to_khz - convert ieee80211_channel to frequency in KHz
7426 * @chan: struct ieee80211_channel to convert
7427 * Return: The corresponding frequency (in KHz)
7428 */
7429 static inline u32
ieee80211_channel_to_khz(const struct ieee80211_channel * chan)7430 ieee80211_channel_to_khz(const struct ieee80211_channel *chan)
7431 {
7432 return MHZ_TO_KHZ(chan->center_freq) + chan->freq_offset;
7433 }
7434
7435 /**
7436 * ieee80211_channel_to_freq_khz - convert channel number to frequency
7437 * @chan: channel number
7438 * @band: band, necessary due to channel number overlap
7439 * Return: The corresponding frequency (in KHz), or 0 if the conversion failed.
7440 */
7441 u32 ieee80211_channel_to_freq_khz(int chan, enum nl80211_band band);
7442
7443 /**
7444 * ieee80211_channel_to_frequency - convert channel number to frequency
7445 * @chan: channel number
7446 * @band: band, necessary due to channel number overlap
7447 * Return: The corresponding frequency (in MHz), or 0 if the conversion failed.
7448 */
7449 static inline int
ieee80211_channel_to_frequency(int chan,enum nl80211_band band)7450 ieee80211_channel_to_frequency(int chan, enum nl80211_band band)
7451 {
7452 return KHZ_TO_MHZ(ieee80211_channel_to_freq_khz(chan, band));
7453 }
7454
7455 /**
7456 * ieee80211_freq_khz_to_channel - convert frequency to channel number
7457 * @freq: center frequency in KHz
7458 * Return: The corresponding channel, or 0 if the conversion failed.
7459 */
7460 int ieee80211_freq_khz_to_channel(u32 freq);
7461
7462 /**
7463 * ieee80211_frequency_to_channel - convert frequency to channel number
7464 * @freq: center frequency in MHz
7465 * Return: The corresponding channel, or 0 if the conversion failed.
7466 */
7467 static inline int
ieee80211_frequency_to_channel(int freq)7468 ieee80211_frequency_to_channel(int freq)
7469 {
7470 return ieee80211_freq_khz_to_channel(MHZ_TO_KHZ(freq));
7471 }
7472
7473 /**
7474 * ieee80211_get_channel_khz - get channel struct from wiphy for specified
7475 * frequency
7476 * @wiphy: the struct wiphy to get the channel for
7477 * @freq: the center frequency (in KHz) of the channel
7478 * Return: The channel struct from @wiphy at @freq.
7479 */
7480 struct ieee80211_channel *
7481 ieee80211_get_channel_khz(struct wiphy *wiphy, u32 freq);
7482
7483 /**
7484 * ieee80211_get_channel - get channel struct from wiphy for specified frequency
7485 *
7486 * @wiphy: the struct wiphy to get the channel for
7487 * @freq: the center frequency (in MHz) of the channel
7488 * Return: The channel struct from @wiphy at @freq.
7489 */
7490 static inline struct ieee80211_channel *
ieee80211_get_channel(struct wiphy * wiphy,int freq)7491 ieee80211_get_channel(struct wiphy *wiphy, int freq)
7492 {
7493 return ieee80211_get_channel_khz(wiphy, MHZ_TO_KHZ(freq));
7494 }
7495
7496 /**
7497 * cfg80211_channel_is_psc - Check if the channel is a 6 GHz PSC
7498 * @chan: control channel to check
7499 *
7500 * The Preferred Scanning Channels (PSC) are defined in
7501 * Draft IEEE P802.11ax/D5.0, 26.17.2.3.3
7502 *
7503 * Return: %true if channel is a PSC, %false otherwise
7504 */
cfg80211_channel_is_psc(struct ieee80211_channel * chan)7505 static inline bool cfg80211_channel_is_psc(struct ieee80211_channel *chan)
7506 {
7507 if (chan->band != NL80211_BAND_6GHZ)
7508 return false;
7509
7510 return ieee80211_frequency_to_channel(chan->center_freq) % 16 == 5;
7511 }
7512
7513 /**
7514 * ieee80211_radio_freq_range_valid - Check if the radio supports the
7515 * specified frequency range
7516 *
7517 * @radio: wiphy radio
7518 * @freq: the frequency (in KHz) to be queried
7519 * @width: the bandwidth (in KHz) to be queried
7520 *
7521 * Return: whether or not the given frequency range is valid for the given radio
7522 */
7523 bool ieee80211_radio_freq_range_valid(const struct wiphy_radio *radio,
7524 u32 freq, u32 width);
7525
7526 /**
7527 * cfg80211_radio_chandef_valid - Check if the radio supports the chandef
7528 *
7529 * @radio: wiphy radio
7530 * @chandef: chandef for current channel
7531 *
7532 * Return: whether or not the given chandef is valid for the given radio
7533 */
7534 bool cfg80211_radio_chandef_valid(const struct wiphy_radio *radio,
7535 const struct cfg80211_chan_def *chandef);
7536
7537 /**
7538 * cfg80211_wdev_channel_allowed - Check if the wdev may use the channel
7539 *
7540 * @wdev: the wireless device
7541 * @chan: channel to check
7542 *
7543 * Return: whether or not the wdev may use the channel
7544 */
7545 bool cfg80211_wdev_channel_allowed(struct wireless_dev *wdev,
7546 struct ieee80211_channel *chan);
7547
7548 /**
7549 * ieee80211_get_response_rate - get basic rate for a given rate
7550 *
7551 * @sband: the band to look for rates in
7552 * @basic_rates: bitmap of basic rates
7553 * @bitrate: the bitrate for which to find the basic rate
7554 *
7555 * Return: The basic rate corresponding to a given bitrate, that
7556 * is the next lower bitrate contained in the basic rate map,
7557 * which is, for this function, given as a bitmap of indices of
7558 * rates in the band's bitrate table.
7559 */
7560 const struct ieee80211_rate *
7561 ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
7562 u32 basic_rates, int bitrate);
7563
7564 /**
7565 * ieee80211_mandatory_rates - get mandatory rates for a given band
7566 * @sband: the band to look for rates in
7567 *
7568 * Return: a bitmap of the mandatory rates for the given band, bits
7569 * are set according to the rate position in the bitrates array.
7570 */
7571 u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband);
7572
7573 /*
7574 * Radiotap parsing functions -- for controlled injection support
7575 *
7576 * Implemented in net/wireless/radiotap.c
7577 * Documentation in Documentation/networking/radiotap-headers.rst
7578 */
7579
7580 struct radiotap_align_size {
7581 uint8_t align:4, size:4;
7582 };
7583
7584 struct ieee80211_radiotap_namespace {
7585 const struct radiotap_align_size *align_size;
7586 int n_bits;
7587 uint32_t oui;
7588 uint8_t subns;
7589 };
7590
7591 struct ieee80211_radiotap_vendor_namespaces {
7592 const struct ieee80211_radiotap_namespace *ns;
7593 int n_ns;
7594 };
7595
7596 /**
7597 * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args
7598 * @this_arg_index: index of current arg, valid after each successful call
7599 * to ieee80211_radiotap_iterator_next()
7600 * @this_arg: pointer to current radiotap arg; it is valid after each
7601 * call to ieee80211_radiotap_iterator_next() but also after
7602 * ieee80211_radiotap_iterator_init() where it will point to
7603 * the beginning of the actual data portion
7604 * @this_arg_size: length of the current arg, for convenience
7605 * @current_namespace: pointer to the current namespace definition
7606 * (or internally %NULL if the current namespace is unknown)
7607 * @is_radiotap_ns: indicates whether the current namespace is the default
7608 * radiotap namespace or not
7609 *
7610 * @_rtheader: pointer to the radiotap header we are walking through
7611 * @_max_length: length of radiotap header in cpu byte ordering
7612 * @_arg_index: next argument index
7613 * @_arg: next argument pointer
7614 * @_next_bitmap: internal pointer to next present u32
7615 * @_bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present
7616 * @_vns: vendor namespace definitions
7617 * @_next_ns_data: beginning of the next namespace's data
7618 * @_reset_on_ext: internal; reset the arg index to 0 when going to the
7619 * next bitmap word
7620 *
7621 * Describes the radiotap parser state. Fields prefixed with an underscore
7622 * must not be used by users of the parser, only by the parser internally.
7623 */
7624
7625 struct ieee80211_radiotap_iterator {
7626 struct ieee80211_radiotap_header *_rtheader;
7627 const struct ieee80211_radiotap_vendor_namespaces *_vns;
7628 const struct ieee80211_radiotap_namespace *current_namespace;
7629
7630 unsigned char *_arg, *_next_ns_data;
7631 __le32 *_next_bitmap;
7632
7633 unsigned char *this_arg;
7634 int this_arg_index;
7635 int this_arg_size;
7636
7637 int is_radiotap_ns;
7638
7639 int _max_length;
7640 int _arg_index;
7641 uint32_t _bitmap_shifter;
7642 int _reset_on_ext;
7643 };
7644
7645 int
7646 ieee80211_radiotap_iterator_init(struct ieee80211_radiotap_iterator *iterator,
7647 struct ieee80211_radiotap_header *radiotap_header,
7648 int max_length,
7649 const struct ieee80211_radiotap_vendor_namespaces *vns);
7650
7651 int
7652 ieee80211_radiotap_iterator_next(struct ieee80211_radiotap_iterator *iterator);
7653
7654
7655 extern const unsigned char rfc1042_header[6];
7656 extern const unsigned char bridge_tunnel_header[6];
7657
7658 /**
7659 * ieee80211_get_hdrlen_from_skb - get header length from data
7660 *
7661 * @skb: the frame
7662 *
7663 * Given an skb with a raw 802.11 header at the data pointer this function
7664 * returns the 802.11 header length.
7665 *
7666 * Return: The 802.11 header length in bytes (not including encryption
7667 * headers). Or 0 if the data in the sk_buff is too short to contain a valid
7668 * 802.11 header.
7669 */
7670 unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
7671
7672 /**
7673 * ieee80211_hdrlen - get header length in bytes from frame control
7674 * @fc: frame control field in little-endian format
7675 * Return: The header length in bytes.
7676 */
7677 unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc);
7678
7679 /**
7680 * ieee80211_get_mesh_hdrlen - get mesh extension header length
7681 * @meshhdr: the mesh extension header, only the flags field
7682 * (first byte) will be accessed
7683 * Return: The length of the extension header, which is always at
7684 * least 6 bytes and at most 18 if address 5 and 6 are present.
7685 */
7686 unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr);
7687
7688 /**
7689 * DOC: Data path helpers
7690 *
7691 * In addition to generic utilities, cfg80211 also offers
7692 * functions that help implement the data path for devices
7693 * that do not do the 802.11/802.3 conversion on the device.
7694 */
7695
7696 /**
7697 * ieee80211_data_to_8023_exthdr - convert an 802.11 data frame to 802.3
7698 * @skb: the 802.11 data frame
7699 * @ehdr: pointer to a &struct ethhdr that will get the header, instead
7700 * of it being pushed into the SKB
7701 * @addr: the device MAC address
7702 * @iftype: the virtual interface type
7703 * @data_offset: offset of payload after the 802.11 header
7704 * @is_amsdu: true if the 802.11 header is A-MSDU
7705 * Return: 0 on success. Non-zero on error.
7706 */
7707 int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
7708 const u8 *addr, enum nl80211_iftype iftype,
7709 u8 data_offset, bool is_amsdu);
7710
7711 /**
7712 * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3
7713 * @skb: the 802.11 data frame
7714 * @addr: the device MAC address
7715 * @iftype: the virtual interface type
7716 * Return: 0 on success. Non-zero on error.
7717 */
ieee80211_data_to_8023(struct sk_buff * skb,const u8 * addr,enum nl80211_iftype iftype)7718 static inline int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
7719 enum nl80211_iftype iftype)
7720 {
7721 return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype, 0, false);
7722 }
7723
7724 /**
7725 * ieee80211_is_valid_amsdu - check if subframe lengths of an A-MSDU are valid
7726 *
7727 * This is used to detect non-standard A-MSDU frames, e.g. the ones generated
7728 * by ath10k and ath11k, where the subframe length includes the length of the
7729 * mesh control field.
7730 *
7731 * @skb: The input A-MSDU frame without any headers.
7732 * @mesh_hdr: the type of mesh header to test
7733 * 0: non-mesh A-MSDU length field
7734 * 1: big-endian mesh A-MSDU length field
7735 * 2: little-endian mesh A-MSDU length field
7736 * Returns: true if subframe header lengths are valid for the @mesh_hdr mode
7737 */
7738 bool ieee80211_is_valid_amsdu(struct sk_buff *skb, u8 mesh_hdr);
7739
7740 /**
7741 * ieee80211_amsdu_to_8023s - decode an IEEE 802.11n A-MSDU frame
7742 *
7743 * Decode an IEEE 802.11 A-MSDU and convert it to a list of 802.3 frames.
7744 * The @list will be empty if the decode fails. The @skb must be fully
7745 * header-less before being passed in here; it is freed in this function.
7746 *
7747 * @skb: The input A-MSDU frame without any headers.
7748 * @list: The output list of 802.3 frames. It must be allocated and
7749 * initialized by the caller.
7750 * @addr: The device MAC address.
7751 * @iftype: The device interface type.
7752 * @extra_headroom: The hardware extra headroom for SKBs in the @list.
7753 * @check_da: DA to check in the inner ethernet header, or NULL
7754 * @check_sa: SA to check in the inner ethernet header, or NULL
7755 * @mesh_control: see mesh_hdr in ieee80211_is_valid_amsdu
7756 */
7757 void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
7758 const u8 *addr, enum nl80211_iftype iftype,
7759 const unsigned int extra_headroom,
7760 const u8 *check_da, const u8 *check_sa,
7761 u8 mesh_control);
7762
7763 /**
7764 * ieee80211_get_8023_tunnel_proto - get RFC1042 or bridge tunnel encap protocol
7765 *
7766 * Check for RFC1042 or bridge tunnel header and fetch the encapsulated
7767 * protocol.
7768 *
7769 * @hdr: pointer to the MSDU payload
7770 * @proto: destination pointer to store the protocol
7771 * Return: true if encapsulation was found
7772 */
7773 bool ieee80211_get_8023_tunnel_proto(const void *hdr, __be16 *proto);
7774
7775 /**
7776 * ieee80211_strip_8023_mesh_hdr - strip mesh header from converted 802.3 frames
7777 *
7778 * Strip the mesh header, which was left in by ieee80211_data_to_8023 as part
7779 * of the MSDU data. Also move any source/destination addresses from the mesh
7780 * header to the ethernet header (if present).
7781 *
7782 * @skb: The 802.3 frame with embedded mesh header
7783 *
7784 * Return: 0 on success. Non-zero on error.
7785 */
7786 int ieee80211_strip_8023_mesh_hdr(struct sk_buff *skb);
7787
7788 /**
7789 * cfg80211_classify8021d - determine the 802.1p/1d tag for a data frame
7790 * @skb: the data frame
7791 * @qos_map: Interworking QoS mapping or %NULL if not in use
7792 * Return: The 802.1p/1d tag.
7793 */
7794 unsigned int cfg80211_classify8021d(struct sk_buff *skb,
7795 struct cfg80211_qos_map *qos_map);
7796
7797 /**
7798 * cfg80211_find_elem_match - match information element and byte array in data
7799 *
7800 * @eid: element ID
7801 * @ies: data consisting of IEs
7802 * @len: length of data
7803 * @match: byte array to match
7804 * @match_len: number of bytes in the match array
7805 * @match_offset: offset in the IE data where the byte array should match.
7806 * Note the difference to cfg80211_find_ie_match() which considers
7807 * the offset to start from the element ID byte, but here we take
7808 * the data portion instead.
7809 *
7810 * Return: %NULL if the element ID could not be found or if
7811 * the element is invalid (claims to be longer than the given
7812 * data) or if the byte array doesn't match; otherwise return the
7813 * requested element struct.
7814 *
7815 * Note: There are no checks on the element length other than
7816 * having to fit into the given data and being large enough for the
7817 * byte array to match.
7818 */
7819 const struct element *
7820 cfg80211_find_elem_match(u8 eid, const u8 *ies, unsigned int len,
7821 const u8 *match, unsigned int match_len,
7822 unsigned int match_offset);
7823
7824 /**
7825 * cfg80211_find_ie_match - match information element and byte array in data
7826 *
7827 * @eid: element ID
7828 * @ies: data consisting of IEs
7829 * @len: length of data
7830 * @match: byte array to match
7831 * @match_len: number of bytes in the match array
7832 * @match_offset: offset in the IE where the byte array should match.
7833 * If match_len is zero, this must also be set to zero.
7834 * Otherwise this must be set to 2 or more, because the first
7835 * byte is the element id, which is already compared to eid, and
7836 * the second byte is the IE length.
7837 *
7838 * Return: %NULL if the element ID could not be found or if
7839 * the element is invalid (claims to be longer than the given
7840 * data) or if the byte array doesn't match, or a pointer to the first
7841 * byte of the requested element, that is the byte containing the
7842 * element ID.
7843 *
7844 * Note: There are no checks on the element length other than
7845 * having to fit into the given data and being large enough for the
7846 * byte array to match.
7847 */
7848 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)7849 cfg80211_find_ie_match(u8 eid, const u8 *ies, unsigned int len,
7850 const u8 *match, unsigned int match_len,
7851 unsigned int match_offset)
7852 {
7853 /* match_offset can't be smaller than 2, unless match_len is
7854 * zero, in which case match_offset must be zero as well.
7855 */
7856 if (WARN_ON((match_len && match_offset < 2) ||
7857 (!match_len && match_offset)))
7858 return NULL;
7859
7860 return (const void *)cfg80211_find_elem_match(eid, ies, len,
7861 match, match_len,
7862 match_offset ?
7863 match_offset - 2 : 0);
7864 }
7865
7866 /**
7867 * cfg80211_find_elem - find information element in data
7868 *
7869 * @eid: element ID
7870 * @ies: data consisting of IEs
7871 * @len: length of data
7872 *
7873 * Return: %NULL if the element ID could not be found or if
7874 * the element is invalid (claims to be longer than the given
7875 * data) or if the byte array doesn't match; otherwise return the
7876 * requested element struct.
7877 *
7878 * Note: There are no checks on the element length other than
7879 * having to fit into the given data.
7880 */
7881 static inline const struct element *
cfg80211_find_elem(u8 eid,const u8 * ies,int len)7882 cfg80211_find_elem(u8 eid, const u8 *ies, int len)
7883 {
7884 return cfg80211_find_elem_match(eid, ies, len, NULL, 0, 0);
7885 }
7886
7887 /**
7888 * cfg80211_find_ie - find information element in data
7889 *
7890 * @eid: element ID
7891 * @ies: data consisting of IEs
7892 * @len: length of data
7893 *
7894 * Return: %NULL if the element ID could not be found or if
7895 * the element is invalid (claims to be longer than the given
7896 * data), or a pointer to the first byte of the requested
7897 * element, that is the byte containing the element ID.
7898 *
7899 * Note: There are no checks on the element length other than
7900 * having to fit into the given data.
7901 */
cfg80211_find_ie(u8 eid,const u8 * ies,int len)7902 static inline const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len)
7903 {
7904 return cfg80211_find_ie_match(eid, ies, len, NULL, 0, 0);
7905 }
7906
7907 /**
7908 * cfg80211_find_ext_elem - find information element with EID Extension in data
7909 *
7910 * @ext_eid: element ID Extension
7911 * @ies: data consisting of IEs
7912 * @len: length of data
7913 *
7914 * Return: %NULL if the extended element could not be found or if
7915 * the element is invalid (claims to be longer than the given
7916 * data) or if the byte array doesn't match; otherwise return the
7917 * requested element struct.
7918 *
7919 * Note: There are no checks on the element length other than
7920 * having to fit into the given data.
7921 */
7922 static inline const struct element *
cfg80211_find_ext_elem(u8 ext_eid,const u8 * ies,int len)7923 cfg80211_find_ext_elem(u8 ext_eid, const u8 *ies, int len)
7924 {
7925 return cfg80211_find_elem_match(WLAN_EID_EXTENSION, ies, len,
7926 &ext_eid, 1, 0);
7927 }
7928
7929 /**
7930 * cfg80211_find_ext_ie - find information element with EID Extension in data
7931 *
7932 * @ext_eid: element ID Extension
7933 * @ies: data consisting of IEs
7934 * @len: length of data
7935 *
7936 * Return: %NULL if the extended element ID could not be found or if
7937 * the element is invalid (claims to be longer than the given
7938 * data), or a pointer to the first byte of the requested
7939 * element, that is the byte containing the element ID.
7940 *
7941 * Note: There are no checks on the element length other than
7942 * having to fit into the given data.
7943 */
cfg80211_find_ext_ie(u8 ext_eid,const u8 * ies,int len)7944 static inline const u8 *cfg80211_find_ext_ie(u8 ext_eid, const u8 *ies, int len)
7945 {
7946 return cfg80211_find_ie_match(WLAN_EID_EXTENSION, ies, len,
7947 &ext_eid, 1, 2);
7948 }
7949
7950 /**
7951 * cfg80211_find_vendor_elem - find vendor specific information element in data
7952 *
7953 * @oui: vendor OUI
7954 * @oui_type: vendor-specific OUI type (must be < 0xff), negative means any
7955 * @ies: data consisting of IEs
7956 * @len: length of data
7957 *
7958 * Return: %NULL if the vendor specific element ID could not be found or if the
7959 * element is invalid (claims to be longer than the given data); otherwise
7960 * return the element structure for the requested element.
7961 *
7962 * Note: There are no checks on the element length other than having to fit into
7963 * the given data.
7964 */
7965 const struct element *cfg80211_find_vendor_elem(unsigned int oui, int oui_type,
7966 const u8 *ies,
7967 unsigned int len);
7968
7969 /**
7970 * cfg80211_find_vendor_ie - find vendor specific information element in data
7971 *
7972 * @oui: vendor OUI
7973 * @oui_type: vendor-specific OUI type (must be < 0xff), negative means any
7974 * @ies: data consisting of IEs
7975 * @len: length of data
7976 *
7977 * Return: %NULL if the vendor specific element ID could not be found or if the
7978 * element is invalid (claims to be longer than the given data), or a pointer to
7979 * the first byte of the requested element, that is the byte containing the
7980 * element ID.
7981 *
7982 * Note: There are no checks on the element length other than having to fit into
7983 * the given data.
7984 */
7985 static inline const u8 *
cfg80211_find_vendor_ie(unsigned int oui,int oui_type,const u8 * ies,unsigned int len)7986 cfg80211_find_vendor_ie(unsigned int oui, int oui_type,
7987 const u8 *ies, unsigned int len)
7988 {
7989 return (const void *)cfg80211_find_vendor_elem(oui, oui_type, ies, len);
7990 }
7991
7992 /**
7993 * enum cfg80211_rnr_iter_ret - reduced neighbor report iteration state
7994 * @RNR_ITER_CONTINUE: continue iterating with the next entry
7995 * @RNR_ITER_BREAK: break iteration and return success
7996 * @RNR_ITER_ERROR: break iteration and return error
7997 */
7998 enum cfg80211_rnr_iter_ret {
7999 RNR_ITER_CONTINUE,
8000 RNR_ITER_BREAK,
8001 RNR_ITER_ERROR,
8002 };
8003
8004 /**
8005 * cfg80211_iter_rnr - iterate reduced neighbor report entries
8006 * @elems: the frame elements to iterate RNR elements and then
8007 * their entries in
8008 * @elems_len: length of the elements
8009 * @iter: iteration function, see also &enum cfg80211_rnr_iter_ret
8010 * for the return value
8011 * @iter_data: additional data passed to the iteration function
8012 * Return: %true on success (after successfully iterating all entries
8013 * or if the iteration function returned %RNR_ITER_BREAK),
8014 * %false on error (iteration function returned %RNR_ITER_ERROR
8015 * or elements were malformed.)
8016 */
8017 bool cfg80211_iter_rnr(const u8 *elems, size_t elems_len,
8018 enum cfg80211_rnr_iter_ret
8019 (*iter)(void *data, u8 type,
8020 const struct ieee80211_neighbor_ap_info *info,
8021 const u8 *tbtt_info, u8 tbtt_info_len),
8022 void *iter_data);
8023
8024 /**
8025 * cfg80211_defragment_element - Defrag the given element data into a buffer
8026 *
8027 * @elem: the element to defragment
8028 * @ies: elements where @elem is contained
8029 * @ieslen: length of @ies
8030 * @data: buffer to store element data, or %NULL to just determine size
8031 * @data_len: length of @data, or 0
8032 * @frag_id: the element ID of fragments
8033 *
8034 * Return: length of @data, or -EINVAL on error
8035 *
8036 * Copy out all data from an element that may be fragmented into @data, while
8037 * skipping all headers.
8038 *
8039 * The function uses memmove() internally. It is acceptable to defragment an
8040 * element in-place.
8041 */
8042 ssize_t cfg80211_defragment_element(const struct element *elem, const u8 *ies,
8043 size_t ieslen, u8 *data, size_t data_len,
8044 u8 frag_id);
8045
8046 /**
8047 * cfg80211_send_layer2_update - send layer 2 update frame
8048 *
8049 * @dev: network device
8050 * @addr: STA MAC address
8051 *
8052 * Wireless drivers can use this function to update forwarding tables in bridge
8053 * devices upon STA association.
8054 */
8055 void cfg80211_send_layer2_update(struct net_device *dev, const u8 *addr);
8056
8057 /**
8058 * DOC: Regulatory enforcement infrastructure
8059 *
8060 * TODO
8061 */
8062
8063 /**
8064 * regulatory_hint - driver hint to the wireless core a regulatory domain
8065 * @wiphy: the wireless device giving the hint (used only for reporting
8066 * conflicts)
8067 * @alpha2: the ISO/IEC 3166 alpha2 the driver claims its regulatory domain
8068 * should be in. If @rd is set this should be NULL. Note that if you
8069 * set this to NULL you should still set rd->alpha2 to some accepted
8070 * alpha2.
8071 *
8072 * Wireless drivers can use this function to hint to the wireless core
8073 * what it believes should be the current regulatory domain by
8074 * giving it an ISO/IEC 3166 alpha2 country code it knows its regulatory
8075 * domain should be in or by providing a completely build regulatory domain.
8076 * If the driver provides an ISO/IEC 3166 alpha2 userspace will be queried
8077 * for a regulatory domain structure for the respective country.
8078 *
8079 * The wiphy must have been registered to cfg80211 prior to this call.
8080 * For cfg80211 drivers this means you must first use wiphy_register(),
8081 * for mac80211 drivers you must first use ieee80211_register_hw().
8082 *
8083 * Drivers should check the return value, its possible you can get
8084 * an -ENOMEM.
8085 *
8086 * Return: 0 on success. -ENOMEM.
8087 */
8088 int regulatory_hint(struct wiphy *wiphy, const char *alpha2);
8089
8090 /**
8091 * regulatory_set_wiphy_regd - set regdom info for self managed drivers
8092 * @wiphy: the wireless device we want to process the regulatory domain on
8093 * @rd: the regulatory domain information to use for this wiphy
8094 *
8095 * Set the regulatory domain information for self-managed wiphys, only they
8096 * may use this function. See %REGULATORY_WIPHY_SELF_MANAGED for more
8097 * information.
8098 *
8099 * Return: 0 on success. -EINVAL, -EPERM
8100 */
8101 int regulatory_set_wiphy_regd(struct wiphy *wiphy,
8102 struct ieee80211_regdomain *rd);
8103
8104 /**
8105 * regulatory_set_wiphy_regd_sync - set regdom for self-managed drivers
8106 * @wiphy: the wireless device we want to process the regulatory domain on
8107 * @rd: the regulatory domain information to use for this wiphy
8108 *
8109 * This functions requires the RTNL and the wiphy mutex to be held and
8110 * applies the new regdomain synchronously to this wiphy. For more details
8111 * see regulatory_set_wiphy_regd().
8112 *
8113 * Return: 0 on success. -EINVAL, -EPERM
8114 */
8115 int regulatory_set_wiphy_regd_sync(struct wiphy *wiphy,
8116 struct ieee80211_regdomain *rd);
8117
8118 /**
8119 * wiphy_apply_custom_regulatory - apply a custom driver regulatory domain
8120 * @wiphy: the wireless device we want to process the regulatory domain on
8121 * @regd: the custom regulatory domain to use for this wiphy
8122 *
8123 * Drivers can sometimes have custom regulatory domains which do not apply
8124 * to a specific country. Drivers can use this to apply such custom regulatory
8125 * domains. This routine must be called prior to wiphy registration. The
8126 * custom regulatory domain will be trusted completely and as such previous
8127 * default channel settings will be disregarded. If no rule is found for a
8128 * channel on the regulatory domain the channel will be disabled.
8129 * Drivers using this for a wiphy should also set the wiphy flag
8130 * REGULATORY_CUSTOM_REG or cfg80211 will set it for the wiphy
8131 * that called this helper.
8132 */
8133 void wiphy_apply_custom_regulatory(struct wiphy *wiphy,
8134 const struct ieee80211_regdomain *regd);
8135
8136 /**
8137 * freq_reg_info - get regulatory information for the given frequency
8138 * @wiphy: the wiphy for which we want to process this rule for
8139 * @center_freq: Frequency in KHz for which we want regulatory information for
8140 *
8141 * Use this function to get the regulatory rule for a specific frequency on
8142 * a given wireless device. If the device has a specific regulatory domain
8143 * it wants to follow we respect that unless a country IE has been received
8144 * and processed already.
8145 *
8146 * Return: A valid pointer, or, when an error occurs, for example if no rule
8147 * can be found, the return value is encoded using ERR_PTR(). Use IS_ERR() to
8148 * check and PTR_ERR() to obtain the numeric return value. The numeric return
8149 * value will be -ERANGE if we determine the given center_freq does not even
8150 * have a regulatory rule for a frequency range in the center_freq's band.
8151 * See freq_in_rule_band() for our current definition of a band -- this is
8152 * purely subjective and right now it's 802.11 specific.
8153 */
8154 const struct ieee80211_reg_rule *freq_reg_info(struct wiphy *wiphy,
8155 u32 center_freq);
8156
8157 /**
8158 * reg_initiator_name - map regulatory request initiator enum to name
8159 * @initiator: the regulatory request initiator
8160 *
8161 * You can use this to map the regulatory request initiator enum to a
8162 * proper string representation.
8163 *
8164 * Return: pointer to string representation of the initiator
8165 */
8166 const char *reg_initiator_name(enum nl80211_reg_initiator initiator);
8167
8168 /**
8169 * regulatory_pre_cac_allowed - check if pre-CAC allowed in the current regdom
8170 * @wiphy: wiphy for which pre-CAC capability is checked.
8171 *
8172 * Pre-CAC is allowed only in some regdomains (notable ETSI).
8173 *
8174 * Return: %true if allowed, %false otherwise
8175 */
8176 bool regulatory_pre_cac_allowed(struct wiphy *wiphy);
8177
8178 /**
8179 * DOC: Internal regulatory db functions
8180 *
8181 */
8182
8183 /**
8184 * reg_query_regdb_wmm - Query internal regulatory db for wmm rule
8185 * Regulatory self-managed driver can use it to proactively
8186 *
8187 * @alpha2: the ISO/IEC 3166 alpha2 wmm rule to be queried.
8188 * @freq: the frequency (in MHz) to be queried.
8189 * @rule: pointer to store the wmm rule from the regulatory db.
8190 *
8191 * Self-managed wireless drivers can use this function to query
8192 * the internal regulatory database to check whether the given
8193 * ISO/IEC 3166 alpha2 country and freq have wmm rule limitations.
8194 *
8195 * Drivers should check the return value, its possible you can get
8196 * an -ENODATA.
8197 *
8198 * Return: 0 on success. -ENODATA.
8199 */
8200 int reg_query_regdb_wmm(char *alpha2, int freq,
8201 struct ieee80211_reg_rule *rule);
8202
8203 /*
8204 * callbacks for asynchronous cfg80211 methods, notification
8205 * functions and BSS handling helpers
8206 */
8207
8208 /**
8209 * cfg80211_scan_done - notify that scan finished
8210 *
8211 * @request: the corresponding scan request
8212 * @info: information about the completed scan
8213 */
8214 void cfg80211_scan_done(struct cfg80211_scan_request *request,
8215 struct cfg80211_scan_info *info);
8216
8217 /**
8218 * cfg80211_sched_scan_results - notify that new scan results are available
8219 *
8220 * @wiphy: the wiphy which got scheduled scan results
8221 * @reqid: identifier for the related scheduled scan request
8222 */
8223 void cfg80211_sched_scan_results(struct wiphy *wiphy, u64 reqid);
8224
8225 /**
8226 * cfg80211_sched_scan_stopped - notify that the scheduled scan has stopped
8227 *
8228 * @wiphy: the wiphy on which the scheduled scan stopped
8229 * @reqid: identifier for the related scheduled scan request
8230 *
8231 * The driver can call this function to inform cfg80211 that the
8232 * scheduled scan had to be stopped, for whatever reason. The driver
8233 * is then called back via the sched_scan_stop operation when done.
8234 */
8235 void cfg80211_sched_scan_stopped(struct wiphy *wiphy, u64 reqid);
8236
8237 /**
8238 * cfg80211_sched_scan_stopped_locked - notify that the scheduled scan has stopped
8239 *
8240 * @wiphy: the wiphy on which the scheduled scan stopped
8241 * @reqid: identifier for the related scheduled scan request
8242 *
8243 * The driver can call this function to inform cfg80211 that the
8244 * scheduled scan had to be stopped, for whatever reason. The driver
8245 * is then called back via the sched_scan_stop operation when done.
8246 * This function should be called with the wiphy mutex held.
8247 */
8248 void cfg80211_sched_scan_stopped_locked(struct wiphy *wiphy, u64 reqid);
8249
8250 /**
8251 * cfg80211_inform_bss_frame_data - inform cfg80211 of a received BSS frame
8252 * @wiphy: the wiphy reporting the BSS
8253 * @data: the BSS metadata
8254 * @mgmt: the management frame (probe response or beacon)
8255 * @len: length of the management frame
8256 * @gfp: context flags
8257 *
8258 * This informs cfg80211 that BSS information was found and
8259 * the BSS should be updated/added.
8260 *
8261 * Return: A referenced struct, must be released with cfg80211_put_bss()!
8262 * Or %NULL on error.
8263 */
8264 struct cfg80211_bss * __must_check
8265 cfg80211_inform_bss_frame_data(struct wiphy *wiphy,
8266 struct cfg80211_inform_bss *data,
8267 struct ieee80211_mgmt *mgmt, size_t len,
8268 gfp_t gfp);
8269
8270 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)8271 cfg80211_inform_bss_frame(struct wiphy *wiphy,
8272 struct ieee80211_channel *rx_channel,
8273 struct ieee80211_mgmt *mgmt, size_t len,
8274 s32 signal, gfp_t gfp)
8275 {
8276 struct cfg80211_inform_bss data = {
8277 .chan = rx_channel,
8278 .signal = signal,
8279 };
8280
8281 return cfg80211_inform_bss_frame_data(wiphy, &data, mgmt, len, gfp);
8282 }
8283
8284 /**
8285 * cfg80211_gen_new_bssid - generate a nontransmitted BSSID for multi-BSSID
8286 * @bssid: transmitter BSSID
8287 * @max_bssid: max BSSID indicator, taken from Multiple BSSID element
8288 * @mbssid_index: BSSID index, taken from Multiple BSSID index element
8289 * @new_bssid: calculated nontransmitted BSSID
8290 */
cfg80211_gen_new_bssid(const u8 * bssid,u8 max_bssid,u8 mbssid_index,u8 * new_bssid)8291 static inline void cfg80211_gen_new_bssid(const u8 *bssid, u8 max_bssid,
8292 u8 mbssid_index, u8 *new_bssid)
8293 {
8294 u64 bssid_u64 = ether_addr_to_u64(bssid);
8295 u64 mask = GENMASK_ULL(max_bssid - 1, 0);
8296 u64 new_bssid_u64;
8297
8298 new_bssid_u64 = bssid_u64 & ~mask;
8299
8300 new_bssid_u64 |= ((bssid_u64 & mask) + mbssid_index) & mask;
8301
8302 u64_to_ether_addr(new_bssid_u64, new_bssid);
8303 }
8304
8305 /**
8306 * cfg80211_is_element_inherited - returns if element ID should be inherited
8307 * @element: element to check
8308 * @non_inherit_element: non inheritance element
8309 *
8310 * Return: %true if should be inherited, %false otherwise
8311 */
8312 bool cfg80211_is_element_inherited(const struct element *element,
8313 const struct element *non_inherit_element);
8314
8315 /**
8316 * cfg80211_merge_profile - merges a MBSSID profile if it is split between IEs
8317 * @ie: ies
8318 * @ielen: length of IEs
8319 * @mbssid_elem: current MBSSID element
8320 * @sub_elem: current MBSSID subelement (profile)
8321 * @merged_ie: location of the merged profile
8322 * @max_copy_len: max merged profile length
8323 *
8324 * Return: the number of bytes merged
8325 */
8326 size_t cfg80211_merge_profile(const u8 *ie, size_t ielen,
8327 const struct element *mbssid_elem,
8328 const struct element *sub_elem,
8329 u8 *merged_ie, size_t max_copy_len);
8330
8331 /**
8332 * enum cfg80211_bss_frame_type - frame type that the BSS data came from
8333 * @CFG80211_BSS_FTYPE_UNKNOWN: driver doesn't know whether the data is
8334 * from a beacon or probe response
8335 * @CFG80211_BSS_FTYPE_BEACON: data comes from a beacon
8336 * @CFG80211_BSS_FTYPE_PRESP: data comes from a probe response
8337 * @CFG80211_BSS_FTYPE_S1G_BEACON: data comes from an S1G beacon
8338 */
8339 enum cfg80211_bss_frame_type {
8340 CFG80211_BSS_FTYPE_UNKNOWN,
8341 CFG80211_BSS_FTYPE_BEACON,
8342 CFG80211_BSS_FTYPE_PRESP,
8343 CFG80211_BSS_FTYPE_S1G_BEACON,
8344 };
8345
8346 /**
8347 * cfg80211_get_ies_channel_number - returns the channel number from ies
8348 * @ie: IEs
8349 * @ielen: length of IEs
8350 * @band: enum nl80211_band of the channel
8351 *
8352 * Return: the channel number, or -1 if none could be determined.
8353 */
8354 int cfg80211_get_ies_channel_number(const u8 *ie, size_t ielen,
8355 enum nl80211_band band);
8356
8357 /**
8358 * cfg80211_ssid_eq - compare two SSIDs
8359 * @a: first SSID
8360 * @b: second SSID
8361 *
8362 * Return: %true if SSIDs are equal, %false otherwise.
8363 */
8364 static inline bool
cfg80211_ssid_eq(struct cfg80211_ssid * a,struct cfg80211_ssid * b)8365 cfg80211_ssid_eq(struct cfg80211_ssid *a, struct cfg80211_ssid *b)
8366 {
8367 if (WARN_ON(!a || !b))
8368 return false;
8369 if (a->ssid_len != b->ssid_len)
8370 return false;
8371 return memcmp(a->ssid, b->ssid, a->ssid_len) ? false : true;
8372 }
8373
8374 /**
8375 * cfg80211_inform_bss_data - inform cfg80211 of a new BSS
8376 *
8377 * @wiphy: the wiphy reporting the BSS
8378 * @data: the BSS metadata
8379 * @ftype: frame type (if known)
8380 * @bssid: the BSSID of the BSS
8381 * @tsf: the TSF sent by the peer in the beacon/probe response (or 0)
8382 * @capability: the capability field sent by the peer
8383 * @beacon_interval: the beacon interval announced by the peer
8384 * @ie: additional IEs sent by the peer
8385 * @ielen: length of the additional IEs
8386 * @gfp: context flags
8387 *
8388 * This informs cfg80211 that BSS information was found and
8389 * the BSS should be updated/added.
8390 *
8391 * Return: A referenced struct, must be released with cfg80211_put_bss()!
8392 * Or %NULL on error.
8393 */
8394 struct cfg80211_bss * __must_check
8395 cfg80211_inform_bss_data(struct wiphy *wiphy,
8396 struct cfg80211_inform_bss *data,
8397 enum cfg80211_bss_frame_type ftype,
8398 const u8 *bssid, u64 tsf, u16 capability,
8399 u16 beacon_interval, const u8 *ie, size_t ielen,
8400 gfp_t gfp);
8401
8402 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)8403 cfg80211_inform_bss(struct wiphy *wiphy,
8404 struct ieee80211_channel *rx_channel,
8405 enum cfg80211_bss_frame_type ftype,
8406 const u8 *bssid, u64 tsf, u16 capability,
8407 u16 beacon_interval, const u8 *ie, size_t ielen,
8408 s32 signal, gfp_t gfp)
8409 {
8410 struct cfg80211_inform_bss data = {
8411 .chan = rx_channel,
8412 .signal = signal,
8413 };
8414
8415 return cfg80211_inform_bss_data(wiphy, &data, ftype, bssid, tsf,
8416 capability, beacon_interval, ie, ielen,
8417 gfp);
8418 }
8419
8420 /**
8421 * __cfg80211_get_bss - get a BSS reference
8422 * @wiphy: the wiphy this BSS struct belongs to
8423 * @channel: the channel to search on (or %NULL)
8424 * @bssid: the desired BSSID (or %NULL)
8425 * @ssid: the desired SSID (or %NULL)
8426 * @ssid_len: length of the SSID (or 0)
8427 * @bss_type: type of BSS, see &enum ieee80211_bss_type
8428 * @privacy: privacy filter, see &enum ieee80211_privacy
8429 * @use_for: indicates which use is intended
8430 * @extack: (optional) extack that is filled with the reason when no
8431 * usable entry was found; may be %NULL
8432 *
8433 * Return: Reference-counted BSS on success. %NULL on error.
8434 */
8435 struct cfg80211_bss *__cfg80211_get_bss(struct wiphy *wiphy,
8436 struct ieee80211_channel *channel,
8437 const u8 *bssid,
8438 const u8 *ssid, size_t ssid_len,
8439 enum ieee80211_bss_type bss_type,
8440 enum ieee80211_privacy privacy,
8441 u32 use_for,
8442 struct netlink_ext_ack *extack);
8443
8444 /**
8445 * cfg80211_get_bss - get a BSS reference
8446 * @wiphy: the wiphy this BSS struct belongs to
8447 * @channel: the channel to search on (or %NULL)
8448 * @bssid: the desired BSSID (or %NULL)
8449 * @ssid: the desired SSID (or %NULL)
8450 * @ssid_len: length of the SSID (or 0)
8451 * @bss_type: type of BSS, see &enum ieee80211_bss_type
8452 * @privacy: privacy filter, see &enum ieee80211_privacy
8453 *
8454 * This version implies regular usage, %NL80211_BSS_USE_FOR_NORMAL.
8455 *
8456 * Return: Reference-counted BSS on success. %NULL on error.
8457 */
8458 static inline struct cfg80211_bss *
cfg80211_get_bss(struct wiphy * wiphy,struct ieee80211_channel * channel,const u8 * bssid,const u8 * ssid,size_t ssid_len,enum ieee80211_bss_type bss_type,enum ieee80211_privacy privacy)8459 cfg80211_get_bss(struct wiphy *wiphy, struct ieee80211_channel *channel,
8460 const u8 *bssid, const u8 *ssid, size_t ssid_len,
8461 enum ieee80211_bss_type bss_type,
8462 enum ieee80211_privacy privacy)
8463 {
8464 return __cfg80211_get_bss(wiphy, channel, bssid, ssid, ssid_len,
8465 bss_type, privacy,
8466 NL80211_BSS_USE_FOR_NORMAL, NULL);
8467 }
8468
8469 static inline struct cfg80211_bss *
cfg80211_get_ibss(struct wiphy * wiphy,struct ieee80211_channel * channel,const u8 * ssid,size_t ssid_len)8470 cfg80211_get_ibss(struct wiphy *wiphy,
8471 struct ieee80211_channel *channel,
8472 const u8 *ssid, size_t ssid_len)
8473 {
8474 return cfg80211_get_bss(wiphy, channel, NULL, ssid, ssid_len,
8475 IEEE80211_BSS_TYPE_IBSS,
8476 IEEE80211_PRIVACY_ANY);
8477 }
8478
8479 /**
8480 * cfg80211_ref_bss - reference BSS struct
8481 * @wiphy: the wiphy this BSS struct belongs to
8482 * @bss: the BSS struct to reference
8483 *
8484 * Increments the refcount of the given BSS struct.
8485 */
8486 void cfg80211_ref_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
8487
8488 /**
8489 * cfg80211_put_bss - unref BSS struct
8490 * @wiphy: the wiphy this BSS struct belongs to
8491 * @bss: the BSS struct
8492 *
8493 * Decrements the refcount of the given BSS struct.
8494 */
8495 void cfg80211_put_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
8496
8497 /**
8498 * cfg80211_unlink_bss - unlink BSS from internal data structures
8499 * @wiphy: the wiphy
8500 * @bss: the bss to remove
8501 *
8502 * This function removes the given BSS from the internal data structures
8503 * thereby making it no longer show up in scan results etc. Use this
8504 * function when you detect a BSS is gone. Normally BSSes will also time
8505 * out, so it is not necessary to use this function at all.
8506 */
8507 void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
8508
8509 /**
8510 * cfg80211_bss_iter - iterate all BSS entries
8511 *
8512 * This function iterates over the BSS entries associated with the given wiphy
8513 * and calls the callback for the iterated BSS. The iterator function is not
8514 * allowed to call functions that might modify the internal state of the BSS DB.
8515 *
8516 * @wiphy: the wiphy
8517 * @chandef: if given, the iterator function will be called only if the channel
8518 * of the currently iterated BSS is a subset of the given channel.
8519 * @iter: the iterator function to call
8520 * @iter_data: an argument to the iterator function
8521 */
8522 void cfg80211_bss_iter(struct wiphy *wiphy,
8523 struct cfg80211_chan_def *chandef,
8524 void (*iter)(struct wiphy *wiphy,
8525 struct cfg80211_bss *bss,
8526 void *data),
8527 void *iter_data);
8528
8529 /**
8530 * cfg80211_rx_mlme_mgmt - notification of processed MLME management frame
8531 * @dev: network device
8532 * @buf: authentication frame (header + body)
8533 * @len: length of the frame data
8534 *
8535 * This function is called whenever an authentication, disassociation or
8536 * deauthentication frame has been received and processed in station mode.
8537 * After being asked to authenticate via cfg80211_ops::auth() the driver must
8538 * call either this function or cfg80211_auth_timeout().
8539 * After being asked to associate via cfg80211_ops::assoc() the driver must
8540 * call either this function or cfg80211_auth_timeout().
8541 * While connected, the driver must calls this for received and processed
8542 * disassociation and deauthentication frames. If the frame couldn't be used
8543 * because it was unprotected, the driver must call the function
8544 * cfg80211_rx_unprot_mlme_mgmt() instead.
8545 *
8546 * This function may sleep. The caller must hold the corresponding wdev's mutex.
8547 */
8548 void cfg80211_rx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len);
8549
8550 /**
8551 * cfg80211_auth_timeout - notification of timed out authentication
8552 * @dev: network device
8553 * @addr: The MAC address of the device with which the authentication timed out
8554 *
8555 * This function may sleep. The caller must hold the corresponding wdev's
8556 * mutex.
8557 */
8558 void cfg80211_auth_timeout(struct net_device *dev, const u8 *addr);
8559
8560 /**
8561 * struct cfg80211_rx_assoc_resp_data - association response data
8562 * @buf: (Re)Association Response frame (header + body)
8563 * @len: length of the frame data
8564 * @uapsd_queues: bitmap of queues configured for uapsd. Same format
8565 * as the AC bitmap in the QoS info field
8566 * @req_ies: information elements from the (Re)Association Request frame
8567 * @req_ies_len: length of req_ies data
8568 * @assoc_encrypted: indicate if the (re)association exchange is encrypted.
8569 * @ap_mld_addr: AP MLD address (in case of MLO)
8570 * @links: per-link information indexed by link ID, use links[0] for
8571 * non-MLO connections
8572 * @links.bss: the BSS that association was requested with, ownership of the
8573 * pointer moves to cfg80211 in the call to cfg80211_rx_assoc_resp()
8574 * @links.status: Set this (along with a BSS pointer) for links that
8575 * were rejected by the AP.
8576 */
8577 struct cfg80211_rx_assoc_resp_data {
8578 const u8 *buf;
8579 size_t len;
8580 const u8 *req_ies;
8581 size_t req_ies_len;
8582 int uapsd_queues;
8583 bool assoc_encrypted;
8584 const u8 *ap_mld_addr;
8585 struct {
8586 u8 addr[ETH_ALEN] __aligned(2);
8587 struct cfg80211_bss *bss;
8588 u16 status;
8589 } links[IEEE80211_MLD_MAX_NUM_LINKS];
8590 };
8591
8592 /**
8593 * cfg80211_rx_assoc_resp - notification of processed association response
8594 * @dev: network device
8595 * @data: association response data, &struct cfg80211_rx_assoc_resp_data
8596 *
8597 * After being asked to associate via cfg80211_ops::assoc() the driver must
8598 * call either this function or cfg80211_auth_timeout().
8599 *
8600 * This function may sleep. The caller must hold the corresponding wdev's mutex.
8601 */
8602 void cfg80211_rx_assoc_resp(struct net_device *dev,
8603 const struct cfg80211_rx_assoc_resp_data *data);
8604
8605 /**
8606 * struct cfg80211_assoc_failure - association failure data
8607 * @ap_mld_addr: AP MLD address, or %NULL
8608 * @bss: list of BSSes, must use entry 0 for non-MLO connections
8609 * (@ap_mld_addr is %NULL)
8610 * @timeout: indicates the association failed due to timeout, otherwise
8611 * the association was abandoned for a reason reported through some
8612 * other API (e.g. deauth RX)
8613 */
8614 struct cfg80211_assoc_failure {
8615 const u8 *ap_mld_addr;
8616 struct cfg80211_bss *bss[IEEE80211_MLD_MAX_NUM_LINKS];
8617 bool timeout;
8618 };
8619
8620 /**
8621 * cfg80211_assoc_failure - notification of association failure
8622 * @dev: network device
8623 * @data: data describing the association failure
8624 *
8625 * This function may sleep. The caller must hold the corresponding wdev's mutex.
8626 */
8627 void cfg80211_assoc_failure(struct net_device *dev,
8628 struct cfg80211_assoc_failure *data);
8629
8630 /**
8631 * cfg80211_tx_mlme_mgmt - notification of transmitted deauth/disassoc frame
8632 * @dev: network device
8633 * @buf: 802.11 frame (header + body)
8634 * @len: length of the frame data
8635 * @reconnect: immediate reconnect is desired (include the nl80211 attribute)
8636 *
8637 * This function is called whenever deauthentication has been processed in
8638 * station mode. This includes both received deauthentication frames and
8639 * locally generated ones. This function may sleep. The caller must hold the
8640 * corresponding wdev's mutex.
8641 */
8642 void cfg80211_tx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len,
8643 bool reconnect);
8644
8645 /**
8646 * cfg80211_rx_unprot_mlme_mgmt - notification of unprotected mlme mgmt frame
8647 * @dev: network device
8648 * @buf: received management frame (header + body)
8649 * @len: length of the frame data
8650 *
8651 * This function is called whenever a received deauthentication or dissassoc
8652 * frame has been dropped in station mode because of MFP being used but the
8653 * frame was not protected. This is also used to notify reception of a Beacon
8654 * frame that was dropped because it did not include a valid MME MIC while
8655 * beacon protection was enabled (BIGTK configured in station mode).
8656 *
8657 * This function may sleep.
8658 */
8659 void cfg80211_rx_unprot_mlme_mgmt(struct net_device *dev,
8660 const u8 *buf, size_t len);
8661
8662 /**
8663 * cfg80211_michael_mic_failure - notification of Michael MIC failure (TKIP)
8664 * @dev: network device
8665 * @addr: The source MAC address of the frame
8666 * @key_type: The key type that the received frame used
8667 * @key_id: Key identifier (0..3). Can be -1 if missing.
8668 * @tsc: The TSC value of the frame that generated the MIC failure (6 octets)
8669 * @gfp: allocation flags
8670 *
8671 * This function is called whenever the local MAC detects a MIC failure in a
8672 * received frame. This matches with MLME-MICHAELMICFAILURE.indication()
8673 * primitive.
8674 */
8675 void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
8676 enum nl80211_key_type key_type, int key_id,
8677 const u8 *tsc, gfp_t gfp);
8678
8679 /**
8680 * cfg80211_ibss_joined - notify cfg80211 that device joined an IBSS
8681 *
8682 * @dev: network device
8683 * @bssid: the BSSID of the IBSS joined
8684 * @channel: the channel of the IBSS joined
8685 * @gfp: allocation flags
8686 *
8687 * This function notifies cfg80211 that the device joined an IBSS or
8688 * switched to a different BSSID. Before this function can be called,
8689 * either a beacon has to have been received from the IBSS, or one of
8690 * the cfg80211_inform_bss{,_frame} functions must have been called
8691 * with the locally generated beacon -- this guarantees that there is
8692 * always a scan result for this IBSS. cfg80211 will handle the rest.
8693 */
8694 void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
8695 struct ieee80211_channel *channel, gfp_t gfp);
8696
8697 /**
8698 * cfg80211_notify_new_peer_candidate - notify cfg80211 of a new mesh peer
8699 * candidate
8700 *
8701 * @dev: network device
8702 * @macaddr: the MAC address of the new candidate
8703 * @ie: information elements advertised by the peer candidate
8704 * @ie_len: length of the information elements buffer
8705 * @sig_dbm: signal level in dBm
8706 * @gfp: allocation flags
8707 *
8708 * This function notifies cfg80211 that the mesh peer candidate has been
8709 * detected, most likely via a beacon or, less likely, via a probe response.
8710 * cfg80211 then sends a notification to userspace.
8711 */
8712 void cfg80211_notify_new_peer_candidate(struct net_device *dev,
8713 const u8 *macaddr, const u8 *ie, size_t ie_len,
8714 int sig_dbm, gfp_t gfp);
8715
8716 /**
8717 * DOC: RFkill integration
8718 *
8719 * RFkill integration in cfg80211 is almost invisible to drivers,
8720 * as cfg80211 automatically registers an rfkill instance for each
8721 * wireless device it knows about. Soft kill is also translated
8722 * into disconnecting and turning all interfaces off. Drivers are
8723 * expected to turn off the device when all interfaces are down.
8724 *
8725 * However, devices may have a hard RFkill line, in which case they
8726 * also need to interact with the rfkill subsystem, via cfg80211.
8727 * They can do this with a few helper functions documented here.
8728 */
8729
8730 /**
8731 * wiphy_rfkill_set_hw_state_reason - notify cfg80211 about hw block state
8732 * @wiphy: the wiphy
8733 * @blocked: block status
8734 * @reason: one of reasons in &enum rfkill_hard_block_reasons
8735 */
8736 void wiphy_rfkill_set_hw_state_reason(struct wiphy *wiphy, bool blocked,
8737 enum rfkill_hard_block_reasons reason);
8738
wiphy_rfkill_set_hw_state(struct wiphy * wiphy,bool blocked)8739 static inline void wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool blocked)
8740 {
8741 wiphy_rfkill_set_hw_state_reason(wiphy, blocked,
8742 RFKILL_HARD_BLOCK_SIGNAL);
8743 }
8744
8745 /**
8746 * wiphy_rfkill_start_polling - start polling rfkill
8747 * @wiphy: the wiphy
8748 */
8749 void wiphy_rfkill_start_polling(struct wiphy *wiphy);
8750
8751 /**
8752 * wiphy_rfkill_stop_polling - stop polling rfkill
8753 * @wiphy: the wiphy
8754 */
wiphy_rfkill_stop_polling(struct wiphy * wiphy)8755 static inline void wiphy_rfkill_stop_polling(struct wiphy *wiphy)
8756 {
8757 rfkill_pause_polling(wiphy->rfkill);
8758 }
8759
8760 /**
8761 * DOC: Vendor commands
8762 *
8763 * Occasionally, there are special protocol or firmware features that
8764 * can't be implemented very openly. For this and similar cases, the
8765 * vendor command functionality allows implementing the features with
8766 * (typically closed-source) userspace and firmware, using nl80211 as
8767 * the configuration mechanism.
8768 *
8769 * A driver supporting vendor commands must register them as an array
8770 * in struct wiphy, with handlers for each one. Each command has an
8771 * OUI and sub command ID to identify it.
8772 *
8773 * Note that this feature should not be (ab)used to implement protocol
8774 * features that could openly be shared across drivers. In particular,
8775 * it must never be required to use vendor commands to implement any
8776 * "normal" functionality that higher-level userspace like connection
8777 * managers etc. need.
8778 */
8779
8780 struct sk_buff *__cfg80211_alloc_reply_skb(struct wiphy *wiphy,
8781 enum nl80211_commands cmd,
8782 enum nl80211_attrs attr,
8783 int approxlen);
8784
8785 struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy,
8786 struct wireless_dev *wdev,
8787 enum nl80211_commands cmd,
8788 enum nl80211_attrs attr,
8789 unsigned int portid,
8790 int vendor_event_idx,
8791 int approxlen, gfp_t gfp);
8792
8793 void __cfg80211_send_event_skb(struct sk_buff *skb, gfp_t gfp);
8794
8795 /**
8796 * cfg80211_vendor_cmd_alloc_reply_skb - allocate vendor command reply
8797 * @wiphy: the wiphy
8798 * @approxlen: an upper bound of the length of the data that will
8799 * be put into the skb
8800 *
8801 * This function allocates and pre-fills an skb for a reply to
8802 * a vendor command. Since it is intended for a reply, calling
8803 * it outside of a vendor command's doit() operation is invalid.
8804 *
8805 * The returned skb is pre-filled with some identifying data in
8806 * a way that any data that is put into the skb (with skb_put(),
8807 * nla_put() or similar) will end up being within the
8808 * %NL80211_ATTR_VENDOR_DATA attribute, so all that needs to be done
8809 * with the skb is adding data for the corresponding userspace tool
8810 * which can then read that data out of the vendor data attribute.
8811 * You must not modify the skb in any other way.
8812 *
8813 * When done, call cfg80211_vendor_cmd_reply() with the skb and return
8814 * its error code as the result of the doit() operation.
8815 *
8816 * Return: An allocated and pre-filled skb. %NULL if any errors happen.
8817 */
8818 static inline struct sk_buff *
cfg80211_vendor_cmd_alloc_reply_skb(struct wiphy * wiphy,int approxlen)8819 cfg80211_vendor_cmd_alloc_reply_skb(struct wiphy *wiphy, int approxlen)
8820 {
8821 return __cfg80211_alloc_reply_skb(wiphy, NL80211_CMD_VENDOR,
8822 NL80211_ATTR_VENDOR_DATA, approxlen);
8823 }
8824
8825 /**
8826 * cfg80211_vendor_cmd_reply - send the reply skb
8827 * @skb: The skb, must have been allocated with
8828 * cfg80211_vendor_cmd_alloc_reply_skb()
8829 *
8830 * Since calling this function will usually be the last thing
8831 * before returning from the vendor command doit() you should
8832 * return the error code. Note that this function consumes the
8833 * skb regardless of the return value.
8834 *
8835 * Return: An error code or 0 on success.
8836 */
8837 int cfg80211_vendor_cmd_reply(struct sk_buff *skb);
8838
8839 /**
8840 * cfg80211_vendor_cmd_get_sender - get the current sender netlink ID
8841 * @wiphy: the wiphy
8842 *
8843 * Return: the current netlink port ID in a vendor command handler.
8844 *
8845 * Context: May only be called from a vendor command handler
8846 */
8847 unsigned int cfg80211_vendor_cmd_get_sender(struct wiphy *wiphy);
8848
8849 /**
8850 * cfg80211_vendor_event_alloc - allocate vendor-specific event skb
8851 * @wiphy: the wiphy
8852 * @wdev: the wireless device
8853 * @event_idx: index of the vendor event in the wiphy's vendor_events
8854 * @approxlen: an upper bound of the length of the data that will
8855 * be put into the skb
8856 * @gfp: allocation flags
8857 *
8858 * This function allocates and pre-fills an skb for an event on the
8859 * vendor-specific multicast group.
8860 *
8861 * If wdev != NULL, both the ifindex and identifier of the specified
8862 * wireless device are added to the event message before the vendor data
8863 * attribute.
8864 *
8865 * When done filling the skb, call cfg80211_vendor_event() with the
8866 * skb to send the event.
8867 *
8868 * Return: An allocated and pre-filled skb. %NULL if any errors happen.
8869 */
8870 static inline struct sk_buff *
cfg80211_vendor_event_alloc(struct wiphy * wiphy,struct wireless_dev * wdev,int approxlen,int event_idx,gfp_t gfp)8871 cfg80211_vendor_event_alloc(struct wiphy *wiphy, struct wireless_dev *wdev,
8872 int approxlen, int event_idx, gfp_t gfp)
8873 {
8874 return __cfg80211_alloc_event_skb(wiphy, wdev, NL80211_CMD_VENDOR,
8875 NL80211_ATTR_VENDOR_DATA,
8876 0, event_idx, approxlen, gfp);
8877 }
8878
8879 /**
8880 * cfg80211_vendor_event_alloc_ucast - alloc unicast vendor-specific event skb
8881 * @wiphy: the wiphy
8882 * @wdev: the wireless device
8883 * @event_idx: index of the vendor event in the wiphy's vendor_events
8884 * @portid: port ID of the receiver
8885 * @approxlen: an upper bound of the length of the data that will
8886 * be put into the skb
8887 * @gfp: allocation flags
8888 *
8889 * This function allocates and pre-fills an skb for an event to send to
8890 * a specific (userland) socket. This socket would previously have been
8891 * obtained by cfg80211_vendor_cmd_get_sender(), and the caller MUST take
8892 * care to register a netlink notifier to see when the socket closes.
8893 *
8894 * If wdev != NULL, both the ifindex and identifier of the specified
8895 * wireless device are added to the event message before the vendor data
8896 * attribute.
8897 *
8898 * When done filling the skb, call cfg80211_vendor_event() with the
8899 * skb to send the event.
8900 *
8901 * Return: An allocated and pre-filled skb. %NULL if any errors happen.
8902 */
8903 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)8904 cfg80211_vendor_event_alloc_ucast(struct wiphy *wiphy,
8905 struct wireless_dev *wdev,
8906 unsigned int portid, int approxlen,
8907 int event_idx, gfp_t gfp)
8908 {
8909 return __cfg80211_alloc_event_skb(wiphy, wdev, NL80211_CMD_VENDOR,
8910 NL80211_ATTR_VENDOR_DATA,
8911 portid, event_idx, approxlen, gfp);
8912 }
8913
8914 /**
8915 * cfg80211_vendor_event - send the event
8916 * @skb: The skb, must have been allocated with cfg80211_vendor_event_alloc()
8917 * @gfp: allocation flags
8918 *
8919 * This function sends the given @skb, which must have been allocated
8920 * by cfg80211_vendor_event_alloc(), as an event. It always consumes it.
8921 */
cfg80211_vendor_event(struct sk_buff * skb,gfp_t gfp)8922 static inline void cfg80211_vendor_event(struct sk_buff *skb, gfp_t gfp)
8923 {
8924 __cfg80211_send_event_skb(skb, gfp);
8925 }
8926
8927 #ifdef CONFIG_NL80211_TESTMODE
8928 /**
8929 * DOC: Test mode
8930 *
8931 * Test mode is a set of utility functions to allow drivers to
8932 * interact with driver-specific tools to aid, for instance,
8933 * factory programming.
8934 *
8935 * This chapter describes how drivers interact with it. For more
8936 * information see the nl80211 book's chapter on it.
8937 */
8938
8939 /**
8940 * cfg80211_testmode_alloc_reply_skb - allocate testmode reply
8941 * @wiphy: the wiphy
8942 * @approxlen: an upper bound of the length of the data that will
8943 * be put into the skb
8944 *
8945 * This function allocates and pre-fills an skb for a reply to
8946 * the testmode command. Since it is intended for a reply, calling
8947 * it outside of the @testmode_cmd operation is invalid.
8948 *
8949 * The returned skb is pre-filled with the wiphy index and set up in
8950 * a way that any data that is put into the skb (with skb_put(),
8951 * nla_put() or similar) will end up being within the
8952 * %NL80211_ATTR_TESTDATA attribute, so all that needs to be done
8953 * with the skb is adding data for the corresponding userspace tool
8954 * which can then read that data out of the testdata attribute. You
8955 * must not modify the skb in any other way.
8956 *
8957 * When done, call cfg80211_testmode_reply() with the skb and return
8958 * its error code as the result of the @testmode_cmd operation.
8959 *
8960 * Return: An allocated and pre-filled skb. %NULL if any errors happen.
8961 */
8962 static inline struct sk_buff *
cfg80211_testmode_alloc_reply_skb(struct wiphy * wiphy,int approxlen)8963 cfg80211_testmode_alloc_reply_skb(struct wiphy *wiphy, int approxlen)
8964 {
8965 return __cfg80211_alloc_reply_skb(wiphy, NL80211_CMD_TESTMODE,
8966 NL80211_ATTR_TESTDATA, approxlen);
8967 }
8968
8969 /**
8970 * cfg80211_testmode_reply - send the reply skb
8971 * @skb: The skb, must have been allocated with
8972 * cfg80211_testmode_alloc_reply_skb()
8973 *
8974 * Since calling this function will usually be the last thing
8975 * before returning from the @testmode_cmd you should return
8976 * the error code. Note that this function consumes the skb
8977 * regardless of the return value.
8978 *
8979 * Return: An error code or 0 on success.
8980 */
cfg80211_testmode_reply(struct sk_buff * skb)8981 static inline int cfg80211_testmode_reply(struct sk_buff *skb)
8982 {
8983 return cfg80211_vendor_cmd_reply(skb);
8984 }
8985
8986 /**
8987 * cfg80211_testmode_alloc_event_skb - allocate testmode event
8988 * @wiphy: the wiphy
8989 * @approxlen: an upper bound of the length of the data that will
8990 * be put into the skb
8991 * @gfp: allocation flags
8992 *
8993 * This function allocates and pre-fills an skb for an event on the
8994 * testmode multicast group.
8995 *
8996 * The returned skb is set up in the same way as with
8997 * cfg80211_testmode_alloc_reply_skb() but prepared for an event. As
8998 * there, you should simply add data to it that will then end up in the
8999 * %NL80211_ATTR_TESTDATA attribute. Again, you must not modify the skb
9000 * in any other way.
9001 *
9002 * When done filling the skb, call cfg80211_testmode_event() with the
9003 * skb to send the event.
9004 *
9005 * Return: An allocated and pre-filled skb. %NULL if any errors happen.
9006 */
9007 static inline struct sk_buff *
cfg80211_testmode_alloc_event_skb(struct wiphy * wiphy,int approxlen,gfp_t gfp)9008 cfg80211_testmode_alloc_event_skb(struct wiphy *wiphy, int approxlen, gfp_t gfp)
9009 {
9010 return __cfg80211_alloc_event_skb(wiphy, NULL, NL80211_CMD_TESTMODE,
9011 NL80211_ATTR_TESTDATA, 0, -1,
9012 approxlen, gfp);
9013 }
9014
9015 /**
9016 * cfg80211_testmode_event - send the event
9017 * @skb: The skb, must have been allocated with
9018 * cfg80211_testmode_alloc_event_skb()
9019 * @gfp: allocation flags
9020 *
9021 * This function sends the given @skb, which must have been allocated
9022 * by cfg80211_testmode_alloc_event_skb(), as an event. It always
9023 * consumes it.
9024 */
cfg80211_testmode_event(struct sk_buff * skb,gfp_t gfp)9025 static inline void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
9026 {
9027 __cfg80211_send_event_skb(skb, gfp);
9028 }
9029
9030 #define CFG80211_TESTMODE_CMD(cmd) .testmode_cmd = (cmd),
9031 #define CFG80211_TESTMODE_DUMP(cmd) .testmode_dump = (cmd),
9032 #else
9033 #define CFG80211_TESTMODE_CMD(cmd)
9034 #define CFG80211_TESTMODE_DUMP(cmd)
9035 #endif
9036
9037 /**
9038 * struct cfg80211_fils_resp_params - FILS connection response params
9039 * @kek: KEK derived from a successful FILS connection (may be %NULL)
9040 * @kek_len: Length of @fils_kek in octets
9041 * @update_erp_next_seq_num: Boolean value to specify whether the value in
9042 * @erp_next_seq_num is valid.
9043 * @erp_next_seq_num: The next sequence number to use in ERP message in
9044 * FILS Authentication. This value should be specified irrespective of the
9045 * status for a FILS connection.
9046 * @pmk: A new PMK if derived from a successful FILS connection (may be %NULL).
9047 * @pmk_len: Length of @pmk in octets
9048 * @pmkid: A new PMKID if derived from a successful FILS connection or the PMKID
9049 * used for this FILS connection (may be %NULL).
9050 */
9051 struct cfg80211_fils_resp_params {
9052 const u8 *kek;
9053 size_t kek_len;
9054 bool update_erp_next_seq_num;
9055 u16 erp_next_seq_num;
9056 const u8 *pmk;
9057 size_t pmk_len;
9058 const u8 *pmkid;
9059 };
9060
9061 /**
9062 * struct cfg80211_connect_resp_params - Connection response params
9063 * @status: Status code, %WLAN_STATUS_SUCCESS for successful connection, use
9064 * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
9065 * the real status code for failures. If this call is used to report a
9066 * failure due to a timeout (e.g., not receiving an Authentication frame
9067 * from the AP) instead of an explicit rejection by the AP, -1 is used to
9068 * indicate that this is a failure, but without a status code.
9069 * @timeout_reason is used to report the reason for the timeout in that
9070 * case.
9071 * @req_ie: Association request IEs (may be %NULL)
9072 * @req_ie_len: Association request IEs length
9073 * @resp_ie: Association response IEs (may be %NULL)
9074 * @resp_ie_len: Association response IEs length
9075 * @fils: FILS connection response parameters.
9076 * @timeout_reason: Reason for connection timeout. This is used when the
9077 * connection fails due to a timeout instead of an explicit rejection from
9078 * the AP. %NL80211_TIMEOUT_UNSPECIFIED is used when the timeout reason is
9079 * not known. This value is used only if @status < 0 to indicate that the
9080 * failure is due to a timeout and not due to explicit rejection by the AP.
9081 * This value is ignored in other cases (@status >= 0).
9082 * @valid_links: For MLO connection, BIT mask of the valid link ids. Otherwise
9083 * zero.
9084 * @ap_mld_addr: For MLO connection, MLD address of the AP. Otherwise %NULL.
9085 * @links : For MLO connection, contains link info for the valid links indicated
9086 * using @valid_links. For non-MLO connection, links[0] contains the
9087 * connected AP info.
9088 * @links.addr: For MLO connection, MAC address of the STA link. Otherwise
9089 * %NULL.
9090 * @links.bssid: For MLO connection, MAC address of the AP link. For non-MLO
9091 * connection, links[0].bssid points to the BSSID of the AP (may be %NULL).
9092 * @links.bss: For MLO connection, entry of bss to which STA link is connected.
9093 * For non-MLO connection, links[0].bss points to entry of bss to which STA
9094 * is connected. It can be obtained through cfg80211_get_bss() (may be
9095 * %NULL). It is recommended to store the bss from the connect_request and
9096 * hold a reference to it and return through this param to avoid a warning
9097 * if the bss is expired during the connection, esp. for those drivers
9098 * implementing connect op. Only one parameter among @bssid and @bss needs
9099 * to be specified.
9100 * @links.status: per-link status code, to report a status code that's not
9101 * %WLAN_STATUS_SUCCESS for a given link, it must also be in the
9102 * @valid_links bitmap and may have a BSS pointer (which is then released)
9103 * @assoc_encrypted: The driver should set this flag to indicate that the
9104 * (Re)Association Request/Response frames are transmitted encrypted over
9105 * the air.
9106 */
9107 struct cfg80211_connect_resp_params {
9108 int status;
9109 const u8 *req_ie;
9110 size_t req_ie_len;
9111 const u8 *resp_ie;
9112 size_t resp_ie_len;
9113 struct cfg80211_fils_resp_params fils;
9114 enum nl80211_timeout_reason timeout_reason;
9115 bool assoc_encrypted;
9116
9117 const u8 *ap_mld_addr;
9118 u16 valid_links;
9119 struct {
9120 const u8 *addr;
9121 const u8 *bssid;
9122 struct cfg80211_bss *bss;
9123 u16 status;
9124 } links[IEEE80211_MLD_MAX_NUM_LINKS];
9125 };
9126
9127 /**
9128 * cfg80211_connect_done - notify cfg80211 of connection result
9129 *
9130 * @dev: network device
9131 * @params: connection response parameters
9132 * @gfp: allocation flags
9133 *
9134 * It should be called by the underlying driver once execution of the connection
9135 * request from connect() has been completed. This is similar to
9136 * cfg80211_connect_bss(), but takes a structure pointer for connection response
9137 * parameters. Only one of the functions among cfg80211_connect_bss(),
9138 * cfg80211_connect_result(), cfg80211_connect_timeout(),
9139 * and cfg80211_connect_done() should be called.
9140 */
9141 void cfg80211_connect_done(struct net_device *dev,
9142 struct cfg80211_connect_resp_params *params,
9143 gfp_t gfp);
9144
9145 /**
9146 * cfg80211_connect_bss - notify cfg80211 of connection result
9147 *
9148 * @dev: network device
9149 * @bssid: the BSSID of the AP
9150 * @bss: Entry of bss to which STA got connected to, can be obtained through
9151 * cfg80211_get_bss() (may be %NULL). But it is recommended to store the
9152 * bss from the connect_request and hold a reference to it and return
9153 * through this param to avoid a warning if the bss is expired during the
9154 * connection, esp. for those drivers implementing connect op.
9155 * Only one parameter among @bssid and @bss needs to be specified.
9156 * @req_ie: association request IEs (maybe be %NULL)
9157 * @req_ie_len: association request IEs length
9158 * @resp_ie: association response IEs (may be %NULL)
9159 * @resp_ie_len: assoc response IEs length
9160 * @status: status code, %WLAN_STATUS_SUCCESS for successful connection, use
9161 * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
9162 * the real status code for failures. If this call is used to report a
9163 * failure due to a timeout (e.g., not receiving an Authentication frame
9164 * from the AP) instead of an explicit rejection by the AP, -1 is used to
9165 * indicate that this is a failure, but without a status code.
9166 * @timeout_reason is used to report the reason for the timeout in that
9167 * case.
9168 * @gfp: allocation flags
9169 * @timeout_reason: reason for connection timeout. This is used when the
9170 * connection fails due to a timeout instead of an explicit rejection from
9171 * the AP. %NL80211_TIMEOUT_UNSPECIFIED is used when the timeout reason is
9172 * not known. This value is used only if @status < 0 to indicate that the
9173 * failure is due to a timeout and not due to explicit rejection by the AP.
9174 * This value is ignored in other cases (@status >= 0).
9175 *
9176 * It should be called by the underlying driver once execution of the connection
9177 * request from connect() has been completed. This is similar to
9178 * cfg80211_connect_result(), but with the option of identifying the exact bss
9179 * entry for the connection. Only one of the functions among
9180 * cfg80211_connect_bss(), cfg80211_connect_result(),
9181 * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
9182 */
9183 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)9184 cfg80211_connect_bss(struct net_device *dev, const u8 *bssid,
9185 struct cfg80211_bss *bss, const u8 *req_ie,
9186 size_t req_ie_len, const u8 *resp_ie,
9187 size_t resp_ie_len, int status, gfp_t gfp,
9188 enum nl80211_timeout_reason timeout_reason)
9189 {
9190 struct cfg80211_connect_resp_params params;
9191
9192 memset(¶ms, 0, sizeof(params));
9193 params.status = status;
9194 params.links[0].bssid = bssid;
9195 params.links[0].bss = bss;
9196 params.req_ie = req_ie;
9197 params.req_ie_len = req_ie_len;
9198 params.resp_ie = resp_ie;
9199 params.resp_ie_len = resp_ie_len;
9200 params.timeout_reason = timeout_reason;
9201
9202 cfg80211_connect_done(dev, ¶ms, gfp);
9203 }
9204
9205 /**
9206 * cfg80211_connect_result - notify cfg80211 of connection result
9207 *
9208 * @dev: network device
9209 * @bssid: the BSSID of the AP
9210 * @req_ie: association request IEs (maybe be %NULL)
9211 * @req_ie_len: association request IEs length
9212 * @resp_ie: association response IEs (may be %NULL)
9213 * @resp_ie_len: assoc response IEs length
9214 * @status: status code, %WLAN_STATUS_SUCCESS for successful connection, use
9215 * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
9216 * the real status code for failures.
9217 * @gfp: allocation flags
9218 *
9219 * It should be called by the underlying driver once execution of the connection
9220 * request from connect() has been completed. This is similar to
9221 * cfg80211_connect_bss() which allows the exact bss entry to be specified. Only
9222 * one of the functions among cfg80211_connect_bss(), cfg80211_connect_result(),
9223 * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
9224 */
9225 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)9226 cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
9227 const u8 *req_ie, size_t req_ie_len,
9228 const u8 *resp_ie, size_t resp_ie_len,
9229 u16 status, gfp_t gfp)
9230 {
9231 cfg80211_connect_bss(dev, bssid, NULL, req_ie, req_ie_len, resp_ie,
9232 resp_ie_len, status, gfp,
9233 NL80211_TIMEOUT_UNSPECIFIED);
9234 }
9235
9236 /**
9237 * cfg80211_connect_timeout - notify cfg80211 of connection timeout
9238 *
9239 * @dev: network device
9240 * @bssid: the BSSID of the AP
9241 * @req_ie: association request IEs (maybe be %NULL)
9242 * @req_ie_len: association request IEs length
9243 * @gfp: allocation flags
9244 * @timeout_reason: reason for connection timeout.
9245 *
9246 * It should be called by the underlying driver whenever connect() has failed
9247 * in a sequence where no explicit authentication/association rejection was
9248 * received from the AP. This could happen, e.g., due to not being able to send
9249 * out the Authentication or Association Request frame or timing out while
9250 * waiting for the response. Only one of the functions among
9251 * cfg80211_connect_bss(), cfg80211_connect_result(),
9252 * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
9253 */
9254 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)9255 cfg80211_connect_timeout(struct net_device *dev, const u8 *bssid,
9256 const u8 *req_ie, size_t req_ie_len, gfp_t gfp,
9257 enum nl80211_timeout_reason timeout_reason)
9258 {
9259 cfg80211_connect_bss(dev, bssid, NULL, req_ie, req_ie_len, NULL, 0, -1,
9260 gfp, timeout_reason);
9261 }
9262
9263 /**
9264 * struct cfg80211_roam_info - driver initiated roaming information
9265 *
9266 * @req_ie: association request IEs (maybe be %NULL)
9267 * @req_ie_len: association request IEs length
9268 * @resp_ie: association response IEs (may be %NULL)
9269 * @resp_ie_len: assoc response IEs length
9270 * @fils: FILS related roaming information.
9271 * @valid_links: For MLO roaming, BIT mask of the new valid links is set.
9272 * Otherwise zero.
9273 * @ap_mld_addr: For MLO roaming, MLD address of the new AP. Otherwise %NULL.
9274 * @links : For MLO roaming, contains new link info for the valid links set in
9275 * @valid_links. For non-MLO roaming, links[0] contains the new AP info.
9276 * @links.addr: For MLO roaming, MAC address of the STA link. Otherwise %NULL.
9277 * @links.bssid: For MLO roaming, MAC address of the new AP link. For non-MLO
9278 * roaming, links[0].bssid points to the BSSID of the new AP. May be
9279 * %NULL if %links.bss is set.
9280 * @links.channel: the channel of the new AP.
9281 * @links.bss: For MLO roaming, entry of new bss to which STA link got
9282 * roamed. For non-MLO roaming, links[0].bss points to entry of bss to
9283 * which STA got roamed (may be %NULL if %links.bssid is set)
9284 */
9285 struct cfg80211_roam_info {
9286 const u8 *req_ie;
9287 size_t req_ie_len;
9288 const u8 *resp_ie;
9289 size_t resp_ie_len;
9290 struct cfg80211_fils_resp_params fils;
9291
9292 const u8 *ap_mld_addr;
9293 u16 valid_links;
9294 struct {
9295 const u8 *addr;
9296 const u8 *bssid;
9297 struct ieee80211_channel *channel;
9298 struct cfg80211_bss *bss;
9299 } links[IEEE80211_MLD_MAX_NUM_LINKS];
9300 };
9301
9302 /**
9303 * cfg80211_roamed - notify cfg80211 of roaming
9304 *
9305 * @dev: network device
9306 * @info: information about the new BSS. struct &cfg80211_roam_info.
9307 * @gfp: allocation flags
9308 *
9309 * This function may be called with the driver passing either the BSSID of the
9310 * new AP or passing the bss entry to avoid a race in timeout of the bss entry.
9311 * It should be called by the underlying driver whenever it roamed from one AP
9312 * to another while connected. Drivers which have roaming implemented in
9313 * firmware should pass the bss entry to avoid a race in bss entry timeout where
9314 * the bss entry of the new AP is seen in the driver, but gets timed out by the
9315 * time it is accessed in __cfg80211_roamed() due to delay in scheduling
9316 * rdev->event_work. In case of any failures, the reference is released
9317 * either in cfg80211_roamed() or in __cfg80211_romed(), Otherwise, it will be
9318 * released while disconnecting from the current bss.
9319 */
9320 void cfg80211_roamed(struct net_device *dev, struct cfg80211_roam_info *info,
9321 gfp_t gfp);
9322
9323 /**
9324 * cfg80211_port_authorized - notify cfg80211 of successful security association
9325 *
9326 * @dev: network device
9327 * @peer_addr: BSSID of the AP/P2P GO in case of STA/GC or STA/GC MAC address
9328 * in case of AP/P2P GO
9329 * @td_bitmap: transition disable policy
9330 * @td_bitmap_len: Length of transition disable policy
9331 * @gfp: allocation flags
9332 *
9333 * This function should be called by a driver that supports 4 way handshake
9334 * offload after a security association was successfully established (i.e.,
9335 * the 4 way handshake was completed successfully). The call to this function
9336 * should be preceded with a call to cfg80211_connect_result(),
9337 * cfg80211_connect_done(), cfg80211_connect_bss() or cfg80211_roamed() to
9338 * indicate the 802.11 association.
9339 * This function can also be called by AP/P2P GO driver that supports
9340 * authentication offload. In this case the peer_mac passed is that of
9341 * associated STA/GC.
9342 */
9343 void cfg80211_port_authorized(struct net_device *dev, const u8 *peer_addr,
9344 const u8* td_bitmap, u8 td_bitmap_len, gfp_t gfp);
9345
9346 /**
9347 * cfg80211_disconnected - notify cfg80211 that connection was dropped
9348 *
9349 * @dev: network device
9350 * @ie: information elements of the deauth/disassoc frame (may be %NULL)
9351 * @ie_len: length of IEs
9352 * @reason: reason code for the disconnection, set it to 0 if unknown
9353 * @locally_generated: disconnection was requested locally
9354 * @gfp: allocation flags
9355 *
9356 * After it calls this function, the driver should enter an idle state
9357 * and not try to connect to any AP any more.
9358 */
9359 void cfg80211_disconnected(struct net_device *dev, u16 reason,
9360 const u8 *ie, size_t ie_len,
9361 bool locally_generated, gfp_t gfp);
9362
9363 /**
9364 * cfg80211_ready_on_channel - notification of remain_on_channel start
9365 * @wdev: wireless device
9366 * @cookie: the request cookie
9367 * @chan: The current channel (from remain_on_channel request)
9368 * @duration: Duration in milliseconds that the driver intents to remain on the
9369 * channel
9370 * @gfp: allocation flags
9371 */
9372 void cfg80211_ready_on_channel(struct wireless_dev *wdev, u64 cookie,
9373 struct ieee80211_channel *chan,
9374 unsigned int duration, gfp_t gfp);
9375
9376 /**
9377 * cfg80211_remain_on_channel_expired - remain_on_channel duration expired
9378 * @wdev: wireless device
9379 * @cookie: the request cookie
9380 * @chan: The current channel (from remain_on_channel request)
9381 * @gfp: allocation flags
9382 */
9383 void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie,
9384 struct ieee80211_channel *chan,
9385 gfp_t gfp);
9386
9387 /**
9388 * cfg80211_tx_mgmt_expired - tx_mgmt duration expired
9389 * @wdev: wireless device
9390 * @cookie: the requested cookie
9391 * @chan: The current channel (from tx_mgmt request)
9392 * @gfp: allocation flags
9393 */
9394 void cfg80211_tx_mgmt_expired(struct wireless_dev *wdev, u64 cookie,
9395 struct ieee80211_channel *chan, gfp_t gfp);
9396
9397 /**
9398 * cfg80211_sinfo_alloc_tid_stats - allocate per-tid statistics.
9399 *
9400 * @sinfo: the station information
9401 * @gfp: allocation flags
9402 *
9403 * Return: 0 on success. Non-zero on error.
9404 */
9405 int cfg80211_sinfo_alloc_tid_stats(struct station_info *sinfo, gfp_t gfp);
9406
9407 /**
9408 * cfg80211_link_sinfo_alloc_tid_stats - allocate per-tid statistics.
9409 *
9410 * @link_sinfo: the link station information
9411 * @gfp: allocation flags
9412 *
9413 * Return: 0 on success. Non-zero on error.
9414 */
9415 int cfg80211_link_sinfo_alloc_tid_stats(struct link_station_info *link_sinfo,
9416 gfp_t gfp);
9417
9418 /**
9419 * cfg80211_sinfo_release_content - release contents of station info
9420 * @sinfo: the station information
9421 *
9422 * Releases any potentially allocated sub-information of the station
9423 * information, but not the struct itself (since it's typically on
9424 * the stack.)
9425 */
cfg80211_sinfo_release_content(struct station_info * sinfo)9426 static inline void cfg80211_sinfo_release_content(struct station_info *sinfo)
9427 {
9428 kfree(sinfo->pertid);
9429
9430 for (int link_id = 0; link_id < ARRAY_SIZE(sinfo->links); link_id++) {
9431 if (sinfo->links[link_id]) {
9432 kfree(sinfo->links[link_id]->pertid);
9433 kfree(sinfo->links[link_id]);
9434 }
9435 }
9436 }
9437
9438 /**
9439 * cfg80211_new_sta - notify userspace about station
9440 *
9441 * @wdev: the wireless device
9442 * @mac_addr: the station's address
9443 * @sinfo: the station information
9444 * @gfp: allocation flags
9445 */
9446 void cfg80211_new_sta(struct wireless_dev *wdev, const u8 *mac_addr,
9447 struct station_info *sinfo, gfp_t gfp);
9448
9449 /**
9450 * cfg80211_del_sta_sinfo - notify userspace about deletion of a station
9451 * @wdev: the wireless device
9452 * @mac_addr: the station's address. For MLD station, MLD address is used.
9453 * @sinfo: the station information/statistics
9454 * @gfp: allocation flags
9455 */
9456 void cfg80211_del_sta_sinfo(struct wireless_dev *wdev, const u8 *mac_addr,
9457 struct station_info *sinfo, gfp_t gfp);
9458
9459 /**
9460 * cfg80211_del_sta - notify userspace about deletion of a station
9461 *
9462 * @wdev: the wireless device
9463 * @mac_addr: the station's address. For MLD station, MLD address is used.
9464 * @gfp: allocation flags
9465 */
cfg80211_del_sta(struct wireless_dev * wdev,const u8 * mac_addr,gfp_t gfp)9466 static inline void cfg80211_del_sta(struct wireless_dev *wdev,
9467 const u8 *mac_addr, gfp_t gfp)
9468 {
9469 cfg80211_del_sta_sinfo(wdev, mac_addr, NULL, gfp);
9470 }
9471
9472 /**
9473 * cfg80211_conn_failed - connection request failed notification
9474 *
9475 * @dev: the netdev
9476 * @mac_addr: the station's address
9477 * @reason: the reason for connection failure
9478 * @gfp: allocation flags
9479 *
9480 * Whenever a station tries to connect to an AP and if the station
9481 * could not connect to the AP as the AP has rejected the connection
9482 * for some reasons, this function is called.
9483 *
9484 * The reason for connection failure can be any of the value from
9485 * nl80211_connect_failed_reason enum
9486 */
9487 void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr,
9488 enum nl80211_connect_failed_reason reason,
9489 gfp_t gfp);
9490
9491 /**
9492 * struct cfg80211_rx_info - received management frame info
9493 *
9494 * @freq: Frequency on which the frame was received in kHz
9495 * @sig_dbm: signal strength in dBm, or 0 if unknown
9496 * @have_link_id: indicates the frame was received on a link of
9497 * an MLD, i.e. the @link_id field is valid
9498 * @link_id: the ID of the link the frame was received on
9499 * @buf: Management frame (header + body)
9500 * @len: length of the frame data
9501 * @flags: flags, as defined in &enum nl80211_rxmgmt_flags
9502 * @rx_tstamp: Hardware timestamp of frame RX in nanoseconds
9503 * @ack_tstamp: Hardware timestamp of ack TX in nanoseconds
9504 */
9505 struct cfg80211_rx_info {
9506 int freq;
9507 int sig_dbm;
9508 bool have_link_id;
9509 u8 link_id;
9510 const u8 *buf;
9511 size_t len;
9512 u32 flags;
9513 u64 rx_tstamp;
9514 u64 ack_tstamp;
9515 };
9516
9517 /**
9518 * cfg80211_rx_mgmt_ext - management frame notification with extended info
9519 * @wdev: wireless device receiving the frame
9520 * @info: RX info as defined in struct cfg80211_rx_info
9521 *
9522 * This function is called whenever an Action frame is received for a station
9523 * mode interface, but is not processed in kernel.
9524 *
9525 * Return: %true if a user space application has registered for this frame.
9526 * For action frames, that makes it responsible for rejecting unrecognized
9527 * action frames; %false otherwise, in which case for action frames the
9528 * driver is responsible for rejecting the frame.
9529 */
9530 bool cfg80211_rx_mgmt_ext(struct wireless_dev *wdev,
9531 struct cfg80211_rx_info *info);
9532
9533 /**
9534 * cfg80211_rx_mgmt_khz - notification of received, unprocessed management frame
9535 * @wdev: wireless device receiving the frame
9536 * @freq: Frequency on which the frame was received in KHz
9537 * @sig_dbm: signal strength in dBm, or 0 if unknown
9538 * @buf: Management frame (header + body)
9539 * @len: length of the frame data
9540 * @flags: flags, as defined in enum nl80211_rxmgmt_flags
9541 *
9542 * This function is called whenever an Action frame is received for a station
9543 * mode interface, but is not processed in kernel.
9544 *
9545 * Return: %true if a user space application has registered for this frame.
9546 * For action frames, that makes it responsible for rejecting unrecognized
9547 * action frames; %false otherwise, in which case for action frames the
9548 * driver is responsible for rejecting the frame.
9549 */
cfg80211_rx_mgmt_khz(struct wireless_dev * wdev,int freq,int sig_dbm,const u8 * buf,size_t len,u32 flags)9550 static inline bool cfg80211_rx_mgmt_khz(struct wireless_dev *wdev, int freq,
9551 int sig_dbm, const u8 *buf, size_t len,
9552 u32 flags)
9553 {
9554 struct cfg80211_rx_info info = {
9555 .freq = freq,
9556 .sig_dbm = sig_dbm,
9557 .buf = buf,
9558 .len = len,
9559 .flags = flags
9560 };
9561
9562 return cfg80211_rx_mgmt_ext(wdev, &info);
9563 }
9564
9565 /**
9566 * cfg80211_rx_mgmt - notification of received, unprocessed management frame
9567 * @wdev: wireless device receiving the frame
9568 * @freq: Frequency on which the frame was received in MHz
9569 * @sig_dbm: signal strength in dBm, or 0 if unknown
9570 * @buf: Management frame (header + body)
9571 * @len: length of the frame data
9572 * @flags: flags, as defined in enum nl80211_rxmgmt_flags
9573 *
9574 * This function is called whenever an Action frame is received for a station
9575 * mode interface, but is not processed in kernel.
9576 *
9577 * Return: %true if a user space application has registered for this frame.
9578 * For action frames, that makes it responsible for rejecting unrecognized
9579 * action frames; %false otherwise, in which case for action frames the
9580 * driver is responsible for rejecting the frame.
9581 */
cfg80211_rx_mgmt(struct wireless_dev * wdev,int freq,int sig_dbm,const u8 * buf,size_t len,u32 flags)9582 static inline bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq,
9583 int sig_dbm, const u8 *buf, size_t len,
9584 u32 flags)
9585 {
9586 struct cfg80211_rx_info info = {
9587 .freq = MHZ_TO_KHZ(freq),
9588 .sig_dbm = sig_dbm,
9589 .buf = buf,
9590 .len = len,
9591 .flags = flags
9592 };
9593
9594 return cfg80211_rx_mgmt_ext(wdev, &info);
9595 }
9596
9597 /**
9598 * struct cfg80211_tx_status - TX status for management frame information
9599 *
9600 * @cookie: Cookie returned by cfg80211_ops::mgmt_tx()
9601 * @tx_tstamp: hardware TX timestamp in nanoseconds
9602 * @ack_tstamp: hardware ack RX timestamp in nanoseconds
9603 * @buf: Management frame (header + body)
9604 * @len: length of the frame data
9605 * @ack: Whether frame was acknowledged
9606 */
9607 struct cfg80211_tx_status {
9608 u64 cookie;
9609 u64 tx_tstamp;
9610 u64 ack_tstamp;
9611 const u8 *buf;
9612 size_t len;
9613 bool ack;
9614 };
9615
9616 /**
9617 * cfg80211_mgmt_tx_status_ext - TX status notification with extended info
9618 * @wdev: wireless device receiving the frame
9619 * @status: TX status data
9620 * @gfp: context flags
9621 *
9622 * This function is called whenever a management frame was requested to be
9623 * transmitted with cfg80211_ops::mgmt_tx() to report the TX status of the
9624 * transmission attempt with extended info.
9625 */
9626 void cfg80211_mgmt_tx_status_ext(struct wireless_dev *wdev,
9627 struct cfg80211_tx_status *status, gfp_t gfp);
9628
9629 /**
9630 * cfg80211_mgmt_tx_status - notification of TX status for management frame
9631 * @wdev: wireless device receiving the frame
9632 * @cookie: Cookie returned by cfg80211_ops::mgmt_tx()
9633 * @buf: Management frame (header + body)
9634 * @len: length of the frame data
9635 * @ack: Whether frame was acknowledged
9636 * @gfp: context flags
9637 *
9638 * This function is called whenever a management frame was requested to be
9639 * transmitted with cfg80211_ops::mgmt_tx() to report the TX status of the
9640 * transmission attempt.
9641 */
cfg80211_mgmt_tx_status(struct wireless_dev * wdev,u64 cookie,const u8 * buf,size_t len,bool ack,gfp_t gfp)9642 static inline void cfg80211_mgmt_tx_status(struct wireless_dev *wdev,
9643 u64 cookie, const u8 *buf,
9644 size_t len, bool ack, gfp_t gfp)
9645 {
9646 struct cfg80211_tx_status status = {
9647 .cookie = cookie,
9648 .buf = buf,
9649 .len = len,
9650 .ack = ack
9651 };
9652
9653 cfg80211_mgmt_tx_status_ext(wdev, &status, gfp);
9654 }
9655
9656 /**
9657 * cfg80211_control_port_tx_status - notification of TX status for control
9658 * port frames
9659 * @wdev: wireless device receiving the frame
9660 * @cookie: Cookie returned by cfg80211_ops::tx_control_port()
9661 * @buf: Data frame (header + body)
9662 * @len: length of the frame data
9663 * @ack: Whether frame was acknowledged
9664 * @gfp: context flags
9665 *
9666 * This function is called whenever a control port frame was requested to be
9667 * transmitted with cfg80211_ops::tx_control_port() to report the TX status of
9668 * the transmission attempt.
9669 */
9670 void cfg80211_control_port_tx_status(struct wireless_dev *wdev, u64 cookie,
9671 const u8 *buf, size_t len, bool ack,
9672 gfp_t gfp);
9673
9674 /**
9675 * cfg80211_rx_control_port - notification about a received control port frame
9676 * @dev: The device the frame matched to
9677 * @skb: The skbuf with the control port frame. It is assumed that the skbuf
9678 * is 802.3 formatted (with 802.3 header). The skb can be non-linear.
9679 * This function does not take ownership of the skb, so the caller is
9680 * responsible for any cleanup. The caller must also ensure that
9681 * skb->protocol is set appropriately.
9682 * @unencrypted: Whether the frame was received unencrypted
9683 * @link_id: the link the frame was received on, -1 if not applicable or unknown
9684 *
9685 * This function is used to inform userspace about a received control port
9686 * frame. It should only be used if userspace indicated it wants to receive
9687 * control port frames over nl80211.
9688 *
9689 * The frame is the data portion of the 802.3 or 802.11 data frame with all
9690 * network layer headers removed (e.g. the raw EAPoL frame).
9691 *
9692 * Return: %true if the frame was passed to userspace
9693 */
9694 bool cfg80211_rx_control_port(struct net_device *dev, struct sk_buff *skb,
9695 bool unencrypted, int link_id);
9696
9697 /**
9698 * cfg80211_cqm_rssi_notify - connection quality monitoring rssi event
9699 * @dev: network device
9700 * @rssi_event: the triggered RSSI event
9701 * @rssi_level: new RSSI level value or 0 if not available
9702 * @gfp: context flags
9703 *
9704 * This function is called when a configured connection quality monitoring
9705 * rssi threshold reached event occurs.
9706 */
9707 void cfg80211_cqm_rssi_notify(struct net_device *dev,
9708 enum nl80211_cqm_rssi_threshold_event rssi_event,
9709 s32 rssi_level, gfp_t gfp);
9710
9711 /**
9712 * cfg80211_cqm_pktloss_notify - notify userspace about packetloss to peer
9713 * @dev: network device
9714 * @peer: peer's MAC address
9715 * @num_packets: how many packets were lost -- should be a fixed threshold
9716 * but probably no less than maybe 50, or maybe a throughput dependent
9717 * threshold (to account for temporary interference)
9718 * @gfp: context flags
9719 */
9720 void cfg80211_cqm_pktloss_notify(struct net_device *dev,
9721 const u8 *peer, u32 num_packets, gfp_t gfp);
9722
9723 /**
9724 * cfg80211_cqm_txe_notify - TX error rate event
9725 * @dev: network device
9726 * @peer: peer's MAC address
9727 * @num_packets: how many packets were lost
9728 * @rate: % of packets which failed transmission
9729 * @intvl: interval (in s) over which the TX failure threshold was breached.
9730 * @gfp: context flags
9731 *
9732 * Notify userspace when configured % TX failures over number of packets in a
9733 * given interval is exceeded.
9734 */
9735 void cfg80211_cqm_txe_notify(struct net_device *dev, const u8 *peer,
9736 u32 num_packets, u32 rate, u32 intvl, gfp_t gfp);
9737
9738 /**
9739 * cfg80211_cqm_beacon_loss_notify - beacon loss event
9740 * @dev: network device
9741 * @gfp: context flags
9742 *
9743 * Notify userspace about beacon loss from the connected AP.
9744 */
9745 void cfg80211_cqm_beacon_loss_notify(struct net_device *dev, gfp_t gfp);
9746
9747 /**
9748 * __cfg80211_radar_event - radar detection event
9749 * @wiphy: the wiphy
9750 * @chandef: chandef for the current channel
9751 * @offchan: the radar has been detected on the offchannel chain
9752 * @gfp: context flags
9753 *
9754 * This function is called when a radar is detected on the current chanenl.
9755 */
9756 void __cfg80211_radar_event(struct wiphy *wiphy,
9757 struct cfg80211_chan_def *chandef,
9758 bool offchan, gfp_t gfp);
9759
9760 static inline void
cfg80211_radar_event(struct wiphy * wiphy,struct cfg80211_chan_def * chandef,gfp_t gfp)9761 cfg80211_radar_event(struct wiphy *wiphy,
9762 struct cfg80211_chan_def *chandef,
9763 gfp_t gfp)
9764 {
9765 __cfg80211_radar_event(wiphy, chandef, false, gfp);
9766 }
9767
9768 static inline void
cfg80211_background_radar_event(struct wiphy * wiphy,struct cfg80211_chan_def * chandef,gfp_t gfp)9769 cfg80211_background_radar_event(struct wiphy *wiphy,
9770 struct cfg80211_chan_def *chandef,
9771 gfp_t gfp)
9772 {
9773 __cfg80211_radar_event(wiphy, chandef, true, gfp);
9774 }
9775
9776 /**
9777 * cfg80211_sta_opmode_change_notify - STA's ht/vht operation mode change event
9778 * @dev: network device
9779 * @mac: MAC address of a station which opmode got modified
9780 * @sta_opmode: station's current opmode value
9781 * @gfp: context flags
9782 *
9783 * Driver should call this function when station's opmode modified via action
9784 * frame.
9785 */
9786 void cfg80211_sta_opmode_change_notify(struct net_device *dev, const u8 *mac,
9787 struct sta_opmode_info *sta_opmode,
9788 gfp_t gfp);
9789
9790 /**
9791 * cfg80211_cac_event - Channel availability check (CAC) event
9792 * @netdev: network device
9793 * @chandef: chandef for the current channel
9794 * @event: type of event
9795 * @gfp: context flags
9796 * @link_id: valid link_id for MLO operation or 0 otherwise.
9797 *
9798 * This function is called when a Channel availability check (CAC) is finished
9799 * or aborted. This must be called to notify the completion of a CAC process,
9800 * also by full-MAC drivers.
9801 */
9802 void cfg80211_cac_event(struct net_device *netdev,
9803 const struct cfg80211_chan_def *chandef,
9804 enum nl80211_radar_event event, gfp_t gfp,
9805 unsigned int link_id);
9806
9807 /**
9808 * cfg80211_background_cac_abort - Channel Availability Check offchan abort event
9809 * @wiphy: the wiphy
9810 *
9811 * This function is called by the driver when a Channel Availability Check
9812 * (CAC) is aborted by a offchannel dedicated chain.
9813 */
9814 void cfg80211_background_cac_abort(struct wiphy *wiphy);
9815
9816 /**
9817 * cfg80211_gtk_rekey_notify - notify userspace about driver rekeying
9818 * @dev: network device
9819 * @bssid: BSSID of AP (to avoid races)
9820 * @replay_ctr: new replay counter
9821 * @gfp: allocation flags
9822 */
9823 void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid,
9824 const u8 *replay_ctr, gfp_t gfp);
9825
9826 /**
9827 * cfg80211_pmksa_candidate_notify - notify about PMKSA caching candidate
9828 * @dev: network device
9829 * @index: candidate index (the smaller the index, the higher the priority)
9830 * @bssid: BSSID of AP
9831 * @preauth: Whether AP advertises support for RSN pre-authentication
9832 * @gfp: allocation flags
9833 */
9834 void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index,
9835 const u8 *bssid, bool preauth, gfp_t gfp);
9836
9837 /**
9838 * cfg80211_rx_spurious_frame - inform userspace about a spurious frame
9839 * @dev: The device the frame matched to
9840 * @link_id: the link the frame was received on, -1 if not applicable or unknown
9841 * @addr: the transmitter address
9842 * @gfp: context flags
9843 *
9844 * This function is used in AP mode to inform userspace that a spurious
9845 * class 3 frame was received, to be able to deauth the sender.
9846 * It is also used in NAN_DATA mode to report frames from unknown peers
9847 * (A2 not assigned to any active NDP), per Wi-Fi Aware (TM) 4.0 specification 6.2.5.
9848 * Return: %true if the frame was passed to userspace (or this failed
9849 * for a reason other than not having a subscription.)
9850 */
9851 bool cfg80211_rx_spurious_frame(struct net_device *dev, const u8 *addr,
9852 int link_id, gfp_t gfp);
9853
9854 /**
9855 * cfg80211_rx_unexpected_4addr_frame - inform about unexpected WDS frame
9856 * @dev: The device the frame matched to
9857 * @addr: the transmitter address
9858 * @link_id: the link the frame was received on, -1 if not applicable or unknown
9859 * @gfp: context flags
9860 *
9861 * This function is used in AP mode (only!) to inform userspace that
9862 * an associated station sent a 4addr frame but that wasn't expected.
9863 * It is allowed and desirable to send this event only once for each
9864 * station to avoid event flooding.
9865 * Return: %true if the frame was passed to userspace (or this failed
9866 * for a reason other than not having a subscription.)
9867 */
9868 bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev, const u8 *addr,
9869 int link_id, gfp_t gfp);
9870
9871 /**
9872 * cfg80211_probe_status - notify userspace about probe status
9873 * @dev: the device the probe was sent on
9874 * @peer: The peer MAC address (or MLD address for MLO) or %NULL if not
9875 * applicable (e.g. for STA/P2P-client)
9876 * @cookie: the cookie filled in @probe_peer previously
9877 * @link_id: The link ID on which the probe was sent (or -1 for non-MLO)
9878 * @acked: indicates whether probe was acked or not
9879 * @ack_signal: signal strength (in dBm) of the ACK frame.
9880 * @is_valid_ack_signal: indicates the ack_signal is valid or not.
9881 * @gfp: allocation flags
9882 */
9883 void cfg80211_probe_status(struct net_device *dev, const u8 *peer, u64 cookie,
9884 int link_id, bool acked, s32 ack_signal,
9885 bool is_valid_ack_signal, gfp_t gfp);
9886
9887 /**
9888 * cfg80211_report_obss_beacon_khz - report beacon from other APs
9889 * @wiphy: The wiphy that received the beacon
9890 * @frame: the frame
9891 * @len: length of the frame
9892 * @freq: frequency the frame was received on in KHz
9893 * @sig_dbm: signal strength in dBm, or 0 if unknown
9894 *
9895 * Use this function to report to userspace when a beacon was
9896 * received. It is not useful to call this when there is no
9897 * netdev that is in AP/GO mode.
9898 */
9899 void cfg80211_report_obss_beacon_khz(struct wiphy *wiphy, const u8 *frame,
9900 size_t len, int freq, int sig_dbm);
9901
9902 /**
9903 * cfg80211_report_obss_beacon - report beacon from other APs
9904 * @wiphy: The wiphy that received the beacon
9905 * @frame: the frame
9906 * @len: length of the frame
9907 * @freq: frequency the frame was received on
9908 * @sig_dbm: signal strength in dBm, or 0 if unknown
9909 *
9910 * Use this function to report to userspace when a beacon was
9911 * received. It is not useful to call this when there is no
9912 * netdev that is in AP/GO mode.
9913 */
cfg80211_report_obss_beacon(struct wiphy * wiphy,const u8 * frame,size_t len,int freq,int sig_dbm)9914 static inline void cfg80211_report_obss_beacon(struct wiphy *wiphy,
9915 const u8 *frame, size_t len,
9916 int freq, int sig_dbm)
9917 {
9918 cfg80211_report_obss_beacon_khz(wiphy, frame, len, MHZ_TO_KHZ(freq),
9919 sig_dbm);
9920 }
9921
9922 /**
9923 * struct cfg80211_beaconing_check_config - beacon check configuration
9924 * @iftype: the interface type to check for
9925 * @relax: allow IR-relaxation conditions to apply (e.g. another
9926 * interface connected already on the same channel)
9927 * NOTE: If this is set, wiphy mutex must be held.
9928 * @reg_power: &enum ieee80211_ap_reg_power value indicating the
9929 * advertised/used 6 GHz regulatory power setting
9930 */
9931 struct cfg80211_beaconing_check_config {
9932 enum nl80211_iftype iftype;
9933 enum ieee80211_ap_reg_power reg_power;
9934 bool relax;
9935 };
9936
9937 /**
9938 * cfg80211_reg_check_beaconing - check if beaconing is allowed
9939 * @wiphy: the wiphy
9940 * @chandef: the channel definition
9941 * @cfg: additional parameters for the checking
9942 *
9943 * Return: %true if there is no secondary channel or the secondary channel(s)
9944 * can be used for beaconing (i.e. is not a radar channel etc.)
9945 */
9946 bool cfg80211_reg_check_beaconing(struct wiphy *wiphy,
9947 struct cfg80211_chan_def *chandef,
9948 struct cfg80211_beaconing_check_config *cfg);
9949
9950 /**
9951 * cfg80211_reg_can_beacon - check if beaconing is allowed
9952 * @wiphy: the wiphy
9953 * @chandef: the channel definition
9954 * @iftype: interface type
9955 *
9956 * Return: %true if there is no secondary channel or the secondary channel(s)
9957 * can be used for beaconing (i.e. is not a radar channel etc.)
9958 */
9959 static inline bool
cfg80211_reg_can_beacon(struct wiphy * wiphy,struct cfg80211_chan_def * chandef,enum nl80211_iftype iftype)9960 cfg80211_reg_can_beacon(struct wiphy *wiphy,
9961 struct cfg80211_chan_def *chandef,
9962 enum nl80211_iftype iftype)
9963 {
9964 struct cfg80211_beaconing_check_config config = {
9965 .iftype = iftype,
9966 };
9967
9968 return cfg80211_reg_check_beaconing(wiphy, chandef, &config);
9969 }
9970
9971 /**
9972 * cfg80211_reg_can_beacon_relax - check if beaconing is allowed with relaxation
9973 * @wiphy: the wiphy
9974 * @chandef: the channel definition
9975 * @iftype: interface type
9976 *
9977 * Return: %true if there is no secondary channel or the secondary channel(s)
9978 * can be used for beaconing (i.e. is not a radar channel etc.). This version
9979 * also checks if IR-relaxation conditions apply, to allow beaconing under
9980 * more permissive conditions.
9981 *
9982 * Context: Requires the wiphy mutex to be held.
9983 */
9984 static inline bool
cfg80211_reg_can_beacon_relax(struct wiphy * wiphy,struct cfg80211_chan_def * chandef,enum nl80211_iftype iftype)9985 cfg80211_reg_can_beacon_relax(struct wiphy *wiphy,
9986 struct cfg80211_chan_def *chandef,
9987 enum nl80211_iftype iftype)
9988 {
9989 struct cfg80211_beaconing_check_config config = {
9990 .iftype = iftype,
9991 .relax = true,
9992 };
9993
9994 return cfg80211_reg_check_beaconing(wiphy, chandef, &config);
9995 }
9996
9997 /**
9998 * cfg80211_ch_switch_notify - update wdev channel and notify userspace
9999 * @dev: the device which switched channels
10000 * @chandef: the new channel definition
10001 * @link_id: the link ID for MLO, must be 0 for non-MLO
10002 *
10003 * Caller must hold wiphy mutex, therefore must only be called from sleepable
10004 * driver context!
10005 */
10006 void cfg80211_ch_switch_notify(struct net_device *dev,
10007 struct cfg80211_chan_def *chandef,
10008 unsigned int link_id);
10009
10010 /**
10011 * cfg80211_ch_switch_started_notify - notify channel switch start
10012 * @dev: the device on which the channel switch started
10013 * @chandef: the future channel definition
10014 * @link_id: the link ID for MLO, must be 0 for non-MLO
10015 * @count: the number of TBTTs until the channel switch happens
10016 * @quiet: whether or not immediate quiet was requested by the AP
10017 *
10018 * Inform the userspace about the channel switch that has just
10019 * started, so that it can take appropriate actions (eg. starting
10020 * channel switch on other vifs), if necessary.
10021 */
10022 void cfg80211_ch_switch_started_notify(struct net_device *dev,
10023 struct cfg80211_chan_def *chandef,
10024 unsigned int link_id, u8 count,
10025 bool quiet);
10026
10027 /**
10028 * ieee80211_operating_class_to_band - convert operating class to band
10029 *
10030 * @operating_class: the operating class to convert
10031 * @band: band pointer to fill
10032 *
10033 * Return: %true if the conversion was successful, %false otherwise.
10034 */
10035 bool ieee80211_operating_class_to_band(u8 operating_class,
10036 enum nl80211_band *band);
10037
10038 /**
10039 * ieee80211_operating_class_to_chandef - convert operating class to chandef
10040 *
10041 * @operating_class: the operating class to convert
10042 * @chan: the ieee80211_channel to convert
10043 * @chandef: a pointer to the resulting chandef
10044 *
10045 * Return: %true if the conversion was successful, %false otherwise.
10046 */
10047 bool ieee80211_operating_class_to_chandef(u8 operating_class,
10048 struct ieee80211_channel *chan,
10049 struct cfg80211_chan_def *chandef);
10050
10051 /**
10052 * ieee80211_chandef_to_operating_class - convert chandef to operation class
10053 *
10054 * @chandef: the chandef to convert
10055 * @op_class: a pointer to the resulting operating class
10056 *
10057 * Return: %true if the conversion was successful, %false otherwise.
10058 */
10059 bool ieee80211_chandef_to_operating_class(struct cfg80211_chan_def *chandef,
10060 u8 *op_class);
10061
10062 /**
10063 * ieee80211_chandef_to_khz - convert chandef to frequency in KHz
10064 *
10065 * @chandef: the chandef to convert
10066 *
10067 * Return: the center frequency of chandef (1st segment) in KHz.
10068 */
10069 static inline u32
ieee80211_chandef_to_khz(const struct cfg80211_chan_def * chandef)10070 ieee80211_chandef_to_khz(const struct cfg80211_chan_def *chandef)
10071 {
10072 return MHZ_TO_KHZ(chandef->center_freq1) + chandef->freq1_offset;
10073 }
10074
10075 /**
10076 * cfg80211_tdls_oper_request - request userspace to perform TDLS operation
10077 * @dev: the device on which the operation is requested
10078 * @peer: the MAC address of the peer device
10079 * @oper: the requested TDLS operation (NL80211_TDLS_SETUP or
10080 * NL80211_TDLS_TEARDOWN)
10081 * @reason_code: the reason code for teardown request
10082 * @gfp: allocation flags
10083 *
10084 * This function is used to request userspace to perform TDLS operation that
10085 * requires knowledge of keys, i.e., link setup or teardown when the AP
10086 * connection uses encryption. This is optional mechanism for the driver to use
10087 * if it can automatically determine when a TDLS link could be useful (e.g.,
10088 * based on traffic and signal strength for a peer).
10089 */
10090 void cfg80211_tdls_oper_request(struct net_device *dev, const u8 *peer,
10091 enum nl80211_tdls_operation oper,
10092 u16 reason_code, gfp_t gfp);
10093
10094 /**
10095 * cfg80211_calculate_bitrate - calculate actual bitrate (in 100Kbps units)
10096 * @rate: given rate_info to calculate bitrate from
10097 *
10098 * Return: calculated bitrate
10099 */
10100 u32 cfg80211_calculate_bitrate(struct rate_info *rate);
10101
10102 /**
10103 * cfg80211_unregister_wdev - remove the given wdev
10104 * @wdev: struct wireless_dev to remove
10105 *
10106 * This function removes the device so it can no longer be used. It is necessary
10107 * to call this function even when cfg80211 requests the removal of the device
10108 * by calling the del_virtual_intf() callback. The function must also be called
10109 * when the driver wishes to unregister the wdev, e.g. when the hardware device
10110 * is unbound from the driver.
10111 *
10112 * Context: Requires the RTNL and wiphy mutex to be held.
10113 */
10114 void cfg80211_unregister_wdev(struct wireless_dev *wdev);
10115
10116 /**
10117 * cfg80211_register_netdevice - register the given netdev
10118 * @dev: the netdev to register
10119 *
10120 * Note: In contexts coming from cfg80211 callbacks, you must call this rather
10121 * than register_netdevice(), unregister_netdev() is impossible as the RTNL is
10122 * held. Otherwise, both register_netdevice() and register_netdev() are usable
10123 * instead as well.
10124 *
10125 * Context: Requires the RTNL and wiphy mutex to be held.
10126 *
10127 * Return: 0 on success. Non-zero on error.
10128 */
10129 int cfg80211_register_netdevice(struct net_device *dev);
10130
10131 /**
10132 * cfg80211_unregister_netdevice - unregister the given netdev
10133 * @dev: the netdev to register
10134 *
10135 * Note: In contexts coming from cfg80211 callbacks, you must call this rather
10136 * than unregister_netdevice(), unregister_netdev() is impossible as the RTNL
10137 * is held. Otherwise, both unregister_netdevice() and unregister_netdev() are
10138 * usable instead as well.
10139 *
10140 * Context: Requires the RTNL and wiphy mutex to be held.
10141 */
cfg80211_unregister_netdevice(struct net_device * dev)10142 static inline void cfg80211_unregister_netdevice(struct net_device *dev)
10143 {
10144 #if IS_ENABLED(CONFIG_CFG80211)
10145 cfg80211_unregister_wdev(dev->ieee80211_ptr);
10146 #endif
10147 }
10148
10149 /**
10150 * struct cfg80211_ft_event_params - FT Information Elements
10151 * @ies: FT IEs
10152 * @ies_len: length of the FT IE in bytes
10153 * @target_ap: target AP's MAC address
10154 * @ric_ies: RIC IE
10155 * @ric_ies_len: length of the RIC IE in bytes
10156 */
10157 struct cfg80211_ft_event_params {
10158 const u8 *ies;
10159 size_t ies_len;
10160 const u8 *target_ap;
10161 const u8 *ric_ies;
10162 size_t ric_ies_len;
10163 };
10164
10165 /**
10166 * cfg80211_ft_event - notify userspace about FT IE and RIC IE
10167 * @netdev: network device
10168 * @ft_event: IE information
10169 */
10170 void cfg80211_ft_event(struct net_device *netdev,
10171 struct cfg80211_ft_event_params *ft_event);
10172
10173 /**
10174 * cfg80211_get_p2p_attr - find and copy a P2P attribute from IE buffer
10175 * @ies: the input IE buffer
10176 * @len: the input length
10177 * @attr: the attribute ID to find
10178 * @buf: output buffer, can be %NULL if the data isn't needed, e.g.
10179 * if the function is only called to get the needed buffer size
10180 * @bufsize: size of the output buffer
10181 *
10182 * The function finds a given P2P attribute in the (vendor) IEs and
10183 * copies its contents to the given buffer.
10184 *
10185 * Return: A negative error code (-%EILSEQ or -%ENOENT) if the data is
10186 * malformed or the attribute can't be found (respectively), or the
10187 * length of the found attribute (which can be zero).
10188 */
10189 int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len,
10190 enum ieee80211_p2p_attr_id attr,
10191 u8 *buf, unsigned int bufsize);
10192
10193 /**
10194 * ieee80211_ie_split_ric - split an IE buffer according to ordering (with RIC)
10195 * @ies: the IE buffer
10196 * @ielen: the length of the IE buffer
10197 * @ids: an array with element IDs that are allowed before
10198 * the split. A WLAN_EID_EXTENSION value means that the next
10199 * EID in the list is a sub-element of the EXTENSION IE.
10200 * @n_ids: the size of the element ID array
10201 * @after_ric: array IE types that come after the RIC element
10202 * @n_after_ric: size of the @after_ric array
10203 * @offset: offset where to start splitting in the buffer
10204 *
10205 * This function splits an IE buffer by updating the @offset
10206 * variable to point to the location where the buffer should be
10207 * split.
10208 *
10209 * It assumes that the given IE buffer is well-formed, this
10210 * has to be guaranteed by the caller!
10211 *
10212 * It also assumes that the IEs in the buffer are ordered
10213 * correctly, if not the result of using this function will not
10214 * be ordered correctly either, i.e. it does no reordering.
10215 *
10216 * Return: The offset where the next part of the buffer starts, which
10217 * may be @ielen if the entire (remainder) of the buffer should be
10218 * used.
10219 */
10220 size_t ieee80211_ie_split_ric(const u8 *ies, size_t ielen,
10221 const u8 *ids, int n_ids,
10222 const u8 *after_ric, int n_after_ric,
10223 size_t offset);
10224
10225 /**
10226 * ieee80211_ie_split - split an IE buffer according to ordering
10227 * @ies: the IE buffer
10228 * @ielen: the length of the IE buffer
10229 * @ids: an array with element IDs that are allowed before
10230 * the split. A WLAN_EID_EXTENSION value means that the next
10231 * EID in the list is a sub-element of the EXTENSION IE.
10232 * @n_ids: the size of the element ID array
10233 * @offset: offset where to start splitting in the buffer
10234 *
10235 * This function splits an IE buffer by updating the @offset
10236 * variable to point to the location where the buffer should be
10237 * split.
10238 *
10239 * It assumes that the given IE buffer is well-formed, this
10240 * has to be guaranteed by the caller!
10241 *
10242 * It also assumes that the IEs in the buffer are ordered
10243 * correctly, if not the result of using this function will not
10244 * be ordered correctly either, i.e. it does no reordering.
10245 *
10246 * Return: The offset where the next part of the buffer starts, which
10247 * may be @ielen if the entire (remainder) of the buffer should be
10248 * used.
10249 */
ieee80211_ie_split(const u8 * ies,size_t ielen,const u8 * ids,int n_ids,size_t offset)10250 static inline size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
10251 const u8 *ids, int n_ids, size_t offset)
10252 {
10253 return ieee80211_ie_split_ric(ies, ielen, ids, n_ids, NULL, 0, offset);
10254 }
10255
10256 /**
10257 * ieee80211_fragment_element - fragment the last element in skb
10258 * @skb: The skbuf that the element was added to
10259 * @len_pos: Pointer to length of the element to fragment
10260 * @frag_id: The element ID to use for fragments
10261 *
10262 * This function fragments all data after @len_pos, adding fragmentation
10263 * elements with the given ID as appropriate. The SKB will grow in size
10264 * accordingly.
10265 */
10266 void ieee80211_fragment_element(struct sk_buff *skb, u8 *len_pos, u8 frag_id);
10267
10268 /**
10269 * cfg80211_report_wowlan_wakeup - report wakeup from WoWLAN
10270 * @wdev: the wireless device reporting the wakeup
10271 * @wakeup: the wakeup report
10272 * @gfp: allocation flags
10273 *
10274 * This function reports that the given device woke up. If it
10275 * caused the wakeup, report the reason(s), otherwise you may
10276 * pass %NULL as the @wakeup parameter to advertise that something
10277 * else caused the wakeup.
10278 */
10279 void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,
10280 struct cfg80211_wowlan_wakeup *wakeup,
10281 gfp_t gfp);
10282
10283 /**
10284 * cfg80211_crit_proto_stopped() - indicate critical protocol stopped by driver.
10285 *
10286 * @wdev: the wireless device for which critical protocol is stopped.
10287 * @gfp: allocation flags
10288 *
10289 * This function can be called by the driver to indicate it has reverted
10290 * operation back to normal. One reason could be that the duration given
10291 * by .crit_proto_start() has expired.
10292 */
10293 void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp);
10294
10295 /**
10296 * ieee80211_get_num_supported_channels - get number of channels device has
10297 * @wiphy: the wiphy
10298 *
10299 * Return: the number of channels supported by the device.
10300 */
10301 unsigned int ieee80211_get_num_supported_channels(struct wiphy *wiphy);
10302
10303 /**
10304 * cfg80211_check_combinations - check interface combinations
10305 *
10306 * @wiphy: the wiphy
10307 * @params: the interface combinations parameter
10308 *
10309 * This function can be called by the driver to check whether a
10310 * combination of interfaces and their types are allowed according to
10311 * the interface combinations.
10312 *
10313 * Return: 0 if combinations are allowed. Non-zero on error.
10314 */
10315 int cfg80211_check_combinations(struct wiphy *wiphy,
10316 struct iface_combination_params *params);
10317
10318 /**
10319 * cfg80211_iter_combinations - iterate over matching combinations
10320 *
10321 * @wiphy: the wiphy
10322 * @params: the interface combinations parameter
10323 * @iter: function to call for each matching combination
10324 * @data: pointer to pass to iter function
10325 *
10326 * This function can be called by the driver to check what possible
10327 * combinations it fits in at a given moment, e.g. for channel switching
10328 * purposes.
10329 *
10330 * Return: 0 on success. Non-zero on error.
10331 */
10332 int cfg80211_iter_combinations(struct wiphy *wiphy,
10333 struct iface_combination_params *params,
10334 void (*iter)(const struct ieee80211_iface_combination *c,
10335 void *data),
10336 void *data);
10337 /**
10338 * cfg80211_get_radio_idx_by_chan - get the radio index by the channel
10339 *
10340 * @wiphy: the wiphy
10341 * @chan: channel for which the supported radio index is required
10342 *
10343 * Return: radio index on success or -EINVAL otherwise
10344 */
10345 int cfg80211_get_radio_idx_by_chan(struct wiphy *wiphy,
10346 const struct ieee80211_channel *chan);
10347
10348 /**
10349 * cfg80211_stop_link - stop AP/P2P_GO link if link_id is non-negative or stops
10350 * all links on the interface.
10351 *
10352 * @wiphy: the wiphy
10353 * @wdev: wireless device
10354 * @link_id: valid link ID in case of MLO AP/P2P_GO Operation or else -1
10355 * @gfp: context flags
10356 *
10357 * If link_id is set during MLO operation, stops only the specified AP/P2P_GO
10358 * link and if link_id is set to -1 or last link is stopped, the entire
10359 * interface is stopped as if AP was stopped, IBSS/mesh left, STA disconnected.
10360 */
10361 void cfg80211_stop_link(struct wiphy *wiphy, struct wireless_dev *wdev,
10362 int link_id, gfp_t gfp);
10363
10364 /**
10365 * cfg80211_stop_iface - trigger interface disconnection
10366 *
10367 * @wiphy: the wiphy
10368 * @wdev: wireless device
10369 * @gfp: context flags
10370 *
10371 * Trigger interface to be stopped as if AP was stopped, IBSS/mesh left, STA
10372 * disconnected.
10373 *
10374 * Note: This doesn't need any locks and is asynchronous.
10375 */
10376 static inline void
cfg80211_stop_iface(struct wiphy * wiphy,struct wireless_dev * wdev,gfp_t gfp)10377 cfg80211_stop_iface(struct wiphy *wiphy, struct wireless_dev *wdev, gfp_t gfp)
10378 {
10379 cfg80211_stop_link(wiphy, wdev, -1, gfp);
10380 }
10381
10382 /**
10383 * cfg80211_shutdown_all_interfaces - shut down all interfaces for a wiphy
10384 * @wiphy: the wiphy to shut down
10385 *
10386 * This function shuts down all interfaces belonging to this wiphy by
10387 * calling dev_close() (and treating non-netdev interfaces as needed).
10388 * It shouldn't really be used unless there are some fatal device errors
10389 * that really can't be recovered in any other way.
10390 *
10391 * Callers must hold the RTNL and be able to deal with callbacks into
10392 * the driver while the function is running.
10393 */
10394 void cfg80211_shutdown_all_interfaces(struct wiphy *wiphy);
10395
10396 /**
10397 * wiphy_ext_feature_set - set the extended feature flag
10398 *
10399 * @wiphy: the wiphy to modify.
10400 * @ftidx: extended feature bit index.
10401 *
10402 * The extended features are flagged in multiple bytes (see
10403 * &struct wiphy.@ext_features)
10404 */
wiphy_ext_feature_set(struct wiphy * wiphy,enum nl80211_ext_feature_index ftidx)10405 static inline void wiphy_ext_feature_set(struct wiphy *wiphy,
10406 enum nl80211_ext_feature_index ftidx)
10407 {
10408 u8 *ft_byte;
10409
10410 ft_byte = &wiphy->ext_features[ftidx / 8];
10411 *ft_byte |= BIT(ftidx % 8);
10412 }
10413
10414 /**
10415 * wiphy_ext_feature_isset - check the extended feature flag
10416 *
10417 * @wiphy: the wiphy to modify.
10418 * @ftidx: extended feature bit index.
10419 *
10420 * The extended features are flagged in multiple bytes (see
10421 * &struct wiphy.@ext_features)
10422 *
10423 * Return: %true if extended feature flag is set, %false otherwise
10424 */
10425 static inline bool
wiphy_ext_feature_isset(struct wiphy * wiphy,enum nl80211_ext_feature_index ftidx)10426 wiphy_ext_feature_isset(struct wiphy *wiphy,
10427 enum nl80211_ext_feature_index ftidx)
10428 {
10429 u8 ft_byte;
10430
10431 ft_byte = wiphy->ext_features[ftidx / 8];
10432 return (ft_byte & BIT(ftidx % 8)) != 0;
10433 }
10434
10435 /**
10436 * cfg80211_free_nan_func - free NAN function
10437 * @f: NAN function that should be freed
10438 *
10439 * Frees all the NAN function and all it's allocated members.
10440 */
10441 void cfg80211_free_nan_func(struct cfg80211_nan_func *f);
10442
10443 /**
10444 * struct cfg80211_nan_match_params - NAN match parameters
10445 * @type: the type of the function that triggered a match. If it is
10446 * %NL80211_NAN_FUNC_SUBSCRIBE it means that we replied to a subscriber.
10447 * If it is %NL80211_NAN_FUNC_PUBLISH, it means that we got a discovery
10448 * result.
10449 * If it is %NL80211_NAN_FUNC_FOLLOW_UP, we received a follow up.
10450 * @inst_id: the local instance id
10451 * @peer_inst_id: the instance id of the peer's function
10452 * @addr: the MAC address of the peer
10453 * @info_len: the length of the &info
10454 * @info: the Service Specific Info from the peer (if any)
10455 * @cookie: unique identifier of the corresponding function
10456 */
10457 struct cfg80211_nan_match_params {
10458 enum nl80211_nan_function_type type;
10459 u8 inst_id;
10460 u8 peer_inst_id;
10461 const u8 *addr;
10462 u8 info_len;
10463 const u8 *info;
10464 u64 cookie;
10465 };
10466
10467 /**
10468 * cfg80211_nan_match - report a match for a NAN function.
10469 * @wdev: the wireless device reporting the match
10470 * @match: match notification parameters
10471 * @gfp: allocation flags
10472 *
10473 * This function reports that the a NAN function had a match. This
10474 * can be a subscribe that had a match or a solicited publish that
10475 * was sent. It can also be a follow up that was received.
10476 */
10477 void cfg80211_nan_match(struct wireless_dev *wdev,
10478 struct cfg80211_nan_match_params *match, gfp_t gfp);
10479
10480 /**
10481 * cfg80211_nan_func_terminated - notify about NAN function termination.
10482 *
10483 * @wdev: the wireless device reporting the match
10484 * @inst_id: the local instance id
10485 * @reason: termination reason (one of the NL80211_NAN_FUNC_TERM_REASON_*)
10486 * @cookie: unique NAN function identifier
10487 * @gfp: allocation flags
10488 *
10489 * This function reports that the a NAN function is terminated.
10490 */
10491 void cfg80211_nan_func_terminated(struct wireless_dev *wdev,
10492 u8 inst_id,
10493 enum nl80211_nan_func_term_reason reason,
10494 u64 cookie, gfp_t gfp);
10495
10496 /**
10497 * cfg80211_nan_sched_update_done - notify deferred schedule update completion
10498 * @wdev: the wireless device reporting the event
10499 * @success: whether or not the schedule update was successful
10500 * @gfp: allocation flags
10501 *
10502 * This function notifies user space that a deferred local NAN schedule update
10503 * (requested with %NL80211_ATTR_NAN_SCHED_DEFERRED) has been completed.
10504 */
10505 void cfg80211_nan_sched_update_done(struct wireless_dev *wdev, bool success,
10506 gfp_t gfp);
10507
10508 /* ethtool helper */
10509 void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info);
10510
10511 /**
10512 * cfg80211_external_auth_request - userspace request for authentication
10513 * @netdev: network device
10514 * @params: External authentication parameters
10515 * @gfp: allocation flags
10516 * Returns: 0 on success, < 0 on error
10517 */
10518 int cfg80211_external_auth_request(struct net_device *netdev,
10519 struct cfg80211_external_auth_params *params,
10520 gfp_t gfp);
10521
10522 /**
10523 * cfg80211_pmsr_report - report peer measurement result data
10524 * @wdev: the wireless device reporting the measurement
10525 * @req: the original measurement request
10526 * @result: the result data
10527 * @gfp: allocation flags
10528 */
10529 void cfg80211_pmsr_report(struct wireless_dev *wdev,
10530 struct cfg80211_pmsr_request *req,
10531 struct cfg80211_pmsr_result *result,
10532 gfp_t gfp);
10533
10534 /**
10535 * cfg80211_pmsr_complete - report peer measurement completed
10536 * @wdev: the wireless device reporting the measurement
10537 * @req: the original measurement request
10538 * @gfp: allocation flags
10539 *
10540 * Report that the entire measurement completed, after this
10541 * the request pointer will no longer be valid.
10542 */
10543 void cfg80211_pmsr_complete(struct wireless_dev *wdev,
10544 struct cfg80211_pmsr_request *req,
10545 gfp_t gfp);
10546
10547 /**
10548 * cfg80211_iftype_allowed - check whether the interface can be allowed
10549 * @wiphy: the wiphy
10550 * @iftype: interface type
10551 * @is_4addr: use_4addr flag, must be '0' when check_swif is '1'
10552 * @check_swif: check iftype against software interfaces
10553 *
10554 * Check whether the interface is allowed to operate; additionally, this API
10555 * can be used to check iftype against the software interfaces when
10556 * check_swif is '1'.
10557 *
10558 * Return: %true if allowed, %false otherwise
10559 */
10560 bool cfg80211_iftype_allowed(struct wiphy *wiphy, enum nl80211_iftype iftype,
10561 bool is_4addr, u8 check_swif);
10562
10563
10564 /**
10565 * cfg80211_assoc_comeback - notification of association that was
10566 * temporarily rejected with a comeback
10567 * @netdev: network device
10568 * @ap_addr: AP (MLD) address that rejected the association
10569 * @timeout: timeout interval value TUs.
10570 *
10571 * this function may sleep. the caller must hold the corresponding wdev's mutex.
10572 */
10573 void cfg80211_assoc_comeback(struct net_device *netdev,
10574 const u8 *ap_addr, u32 timeout);
10575
10576 /* Logging, debugging and troubleshooting/diagnostic helpers. */
10577
10578 /* wiphy_printk helpers, similar to dev_printk */
10579
10580 #define wiphy_printk(level, wiphy, format, args...) \
10581 dev_printk(level, &(wiphy)->dev, format, ##args)
10582 #define wiphy_emerg(wiphy, format, args...) \
10583 dev_emerg(&(wiphy)->dev, format, ##args)
10584 #define wiphy_alert(wiphy, format, args...) \
10585 dev_alert(&(wiphy)->dev, format, ##args)
10586 #define wiphy_crit(wiphy, format, args...) \
10587 dev_crit(&(wiphy)->dev, format, ##args)
10588 #define wiphy_err(wiphy, format, args...) \
10589 dev_err(&(wiphy)->dev, format, ##args)
10590 #define wiphy_warn(wiphy, format, args...) \
10591 dev_warn(&(wiphy)->dev, format, ##args)
10592 #define wiphy_notice(wiphy, format, args...) \
10593 dev_notice(&(wiphy)->dev, format, ##args)
10594 #define wiphy_info(wiphy, format, args...) \
10595 dev_info(&(wiphy)->dev, format, ##args)
10596 #define wiphy_info_once(wiphy, format, args...) \
10597 dev_info_once(&(wiphy)->dev, format, ##args)
10598
10599 #define wiphy_err_ratelimited(wiphy, format, args...) \
10600 dev_err_ratelimited(&(wiphy)->dev, format, ##args)
10601 #define wiphy_warn_ratelimited(wiphy, format, args...) \
10602 dev_warn_ratelimited(&(wiphy)->dev, format, ##args)
10603
10604 #define wiphy_debug(wiphy, format, args...) \
10605 wiphy_printk(KERN_DEBUG, wiphy, format, ##args)
10606
10607 #define wiphy_dbg(wiphy, format, args...) \
10608 dev_dbg(&(wiphy)->dev, format, ##args)
10609
10610 #if defined(VERBOSE_DEBUG)
10611 #define wiphy_vdbg wiphy_dbg
10612 #else
10613 #define wiphy_vdbg(wiphy, format, args...) \
10614 ({ \
10615 if (0) \
10616 wiphy_printk(KERN_DEBUG, wiphy, format, ##args); \
10617 0; \
10618 })
10619 #endif
10620
10621 /*
10622 * wiphy_WARN() acts like wiphy_printk(), but with the key difference
10623 * of using a WARN/WARN_ON to get the message out, including the
10624 * file/line information and a backtrace.
10625 */
10626 #define wiphy_WARN(wiphy, format, args...) \
10627 WARN(1, "wiphy: %s\n" format, wiphy_name(wiphy), ##args);
10628
10629 /**
10630 * cfg80211_update_owe_info_event - Notify the peer's OWE info to user space
10631 * @netdev: network device
10632 * @owe_info: peer's owe info
10633 * @gfp: allocation flags
10634 */
10635 void cfg80211_update_owe_info_event(struct net_device *netdev,
10636 struct cfg80211_update_owe_info *owe_info,
10637 gfp_t gfp);
10638
10639 /**
10640 * cfg80211_bss_flush - resets all the scan entries
10641 * @wiphy: the wiphy
10642 */
10643 void cfg80211_bss_flush(struct wiphy *wiphy);
10644
10645 /**
10646 * cfg80211_bss_color_notify - notify about bss color event
10647 * @dev: network device
10648 * @cmd: the actual event we want to notify
10649 * @count: the number of TBTTs until the color change happens
10650 * @color_bitmap: representations of the colors that the local BSS is aware of
10651 * @link_id: valid link_id in case of MLO or 0 for non-MLO.
10652 *
10653 * Return: 0 on success. Non-zero on error.
10654 */
10655 int cfg80211_bss_color_notify(struct net_device *dev,
10656 enum nl80211_commands cmd, u8 count,
10657 u64 color_bitmap, u8 link_id);
10658
10659 /**
10660 * cfg80211_obss_color_collision_notify - notify about bss color collision
10661 * @dev: network device
10662 * @color_bitmap: representations of the colors that the local BSS is aware of
10663 * @link_id: valid link_id in case of MLO or 0 for non-MLO.
10664 *
10665 * Return: 0 on success. Non-zero on error.
10666 */
cfg80211_obss_color_collision_notify(struct net_device * dev,u64 color_bitmap,u8 link_id)10667 static inline int cfg80211_obss_color_collision_notify(struct net_device *dev,
10668 u64 color_bitmap,
10669 u8 link_id)
10670 {
10671 return cfg80211_bss_color_notify(dev, NL80211_CMD_OBSS_COLOR_COLLISION,
10672 0, color_bitmap, link_id);
10673 }
10674
10675 /**
10676 * cfg80211_color_change_started_notify - notify color change start
10677 * @dev: the device on which the color is switched
10678 * @count: the number of TBTTs until the color change happens
10679 * @link_id: valid link_id in case of MLO or 0 for non-MLO.
10680 *
10681 * Inform the userspace about the color change that has started.
10682 *
10683 * Return: 0 on success. Non-zero on error.
10684 */
cfg80211_color_change_started_notify(struct net_device * dev,u8 count,u8 link_id)10685 static inline int cfg80211_color_change_started_notify(struct net_device *dev,
10686 u8 count, u8 link_id)
10687 {
10688 return cfg80211_bss_color_notify(dev, NL80211_CMD_COLOR_CHANGE_STARTED,
10689 count, 0, link_id);
10690 }
10691
10692 /**
10693 * cfg80211_color_change_aborted_notify - notify color change abort
10694 * @dev: the device on which the color is switched
10695 * @link_id: valid link_id in case of MLO or 0 for non-MLO.
10696 *
10697 * Inform the userspace about the color change that has aborted.
10698 *
10699 * Return: 0 on success. Non-zero on error.
10700 */
cfg80211_color_change_aborted_notify(struct net_device * dev,u8 link_id)10701 static inline int cfg80211_color_change_aborted_notify(struct net_device *dev,
10702 u8 link_id)
10703 {
10704 return cfg80211_bss_color_notify(dev, NL80211_CMD_COLOR_CHANGE_ABORTED,
10705 0, 0, link_id);
10706 }
10707
10708 /**
10709 * cfg80211_color_change_notify - notify color change completion
10710 * @dev: the device on which the color was switched
10711 * @link_id: valid link_id in case of MLO or 0 for non-MLO.
10712 *
10713 * Inform the userspace about the color change that has completed.
10714 *
10715 * Return: 0 on success. Non-zero on error.
10716 */
cfg80211_color_change_notify(struct net_device * dev,u8 link_id)10717 static inline int cfg80211_color_change_notify(struct net_device *dev,
10718 u8 link_id)
10719 {
10720 return cfg80211_bss_color_notify(dev,
10721 NL80211_CMD_COLOR_CHANGE_COMPLETED,
10722 0, 0, link_id);
10723 }
10724
10725 /**
10726 * cfg80211_6ghz_power_type - determine AP regulatory power type
10727 * @control: control flags
10728 * @client_flags: &enum ieee80211_channel_flags for station mode to enable
10729 * SP to LPI fallback, zero otherwise.
10730 *
10731 * Return: regulatory power type from &enum ieee80211_ap_reg_power
10732 */
10733 static inline enum ieee80211_ap_reg_power
cfg80211_6ghz_power_type(u8 control,u32 client_flags)10734 cfg80211_6ghz_power_type(u8 control, u32 client_flags)
10735 {
10736 switch (u8_get_bits(control, IEEE80211_HE_6GHZ_OPER_CTRL_REG_INFO)) {
10737 case IEEE80211_6GHZ_CTRL_REG_LPI_AP:
10738 case IEEE80211_6GHZ_CTRL_REG_INDOOR_LPI_AP:
10739 case IEEE80211_6GHZ_CTRL_REG_AP_ROLE_NOT_RELEVANT:
10740 case IEEE80211_6GHZ_CTRL_REG_INDOOR_SP_AP_OLD:
10741 return IEEE80211_REG_LPI_AP;
10742 case IEEE80211_6GHZ_CTRL_REG_SP_AP:
10743 return IEEE80211_REG_SP_AP;
10744 case IEEE80211_6GHZ_CTRL_REG_VLP_AP:
10745 return IEEE80211_REG_VLP_AP;
10746 case IEEE80211_6GHZ_CTRL_REG_INDOOR_SP_AP:
10747 if (client_flags & IEEE80211_CHAN_NO_6GHZ_AFC_CLIENT)
10748 return IEEE80211_REG_LPI_AP;
10749 return IEEE80211_REG_SP_AP;
10750 default:
10751 return IEEE80211_REG_UNSET_AP;
10752 }
10753 }
10754
10755 /**
10756 * cfg80211_links_removed - Notify about removed STA MLD setup links.
10757 * @dev: network device.
10758 * @link_mask: BIT mask of removed STA MLD setup link IDs.
10759 *
10760 * Inform cfg80211 and the userspace about removed STA MLD setup links due to
10761 * AP MLD removing the corresponding affiliated APs with Multi-Link
10762 * reconfiguration. Note that it's not valid to remove all links, in this
10763 * case disconnect instead.
10764 * Also note that the wdev mutex must be held.
10765 */
10766 void cfg80211_links_removed(struct net_device *dev, u16 link_mask);
10767
10768 /**
10769 * struct cfg80211_mlo_reconf_done_data - MLO reconfiguration data
10770 * @buf: MLO Reconfiguration Response frame (header + body)
10771 * @len: length of the frame data
10772 * @driver_initiated: Indicates whether the add links request is initiated by
10773 * driver. This is set to true when the link reconfiguration request
10774 * initiated by driver due to AP link recommendation requests
10775 * (Ex: BTM (BSS Transition Management) request) handling offloaded to
10776 * driver.
10777 * @added_links: BIT mask of links successfully added to the association
10778 * @links: per-link information indexed by link ID
10779 * @links.bss: the BSS that MLO reconfiguration was requested for, ownership of
10780 * the pointer moves to cfg80211 in the call to
10781 * cfg80211_mlo_reconf_add_done().
10782 *
10783 * The BSS pointer must be set for each link for which 'add' operation was
10784 * requested in the assoc_ml_reconf callback.
10785 */
10786 struct cfg80211_mlo_reconf_done_data {
10787 const u8 *buf;
10788 size_t len;
10789 bool driver_initiated;
10790 u16 added_links;
10791 struct {
10792 struct cfg80211_bss *bss;
10793 u8 *addr;
10794 } links[IEEE80211_MLD_MAX_NUM_LINKS];
10795 };
10796
10797 /**
10798 * cfg80211_mlo_reconf_add_done - Notify about MLO reconfiguration result
10799 * @dev: network device.
10800 * @data: MLO reconfiguration done data, &struct cfg80211_mlo_reconf_done_data
10801 *
10802 * Inform cfg80211 and the userspace that processing of ML reconfiguration
10803 * request to add links to the association is done.
10804 */
10805 void cfg80211_mlo_reconf_add_done(struct net_device *dev,
10806 struct cfg80211_mlo_reconf_done_data *data);
10807
10808 /**
10809 * cfg80211_schedule_channels_check - schedule regulatory check if needed
10810 * @wdev: the wireless device to check
10811 *
10812 * In case the device supports NO_IR or DFS relaxations, schedule regulatory
10813 * channels check, as previous concurrent operation conditions may not
10814 * hold anymore.
10815 */
10816 void cfg80211_schedule_channels_check(struct wireless_dev *wdev);
10817
10818 /**
10819 * cfg80211_epcs_changed - Notify about a change in EPCS state
10820 * @netdev: the wireless device whose EPCS state changed
10821 * @enabled: set to true if EPCS was enabled, otherwise set to false.
10822 */
10823 void cfg80211_epcs_changed(struct net_device *netdev, bool enabled);
10824
10825 /**
10826 * cfg80211_next_nan_dw_notif - Notify about the next NAN Discovery Window (DW)
10827 * @wdev: Pointer to the wireless device structure
10828 * @chan: DW channel (6, 44 or 149)
10829 * @gfp: Memory allocation flags
10830 */
10831 void cfg80211_next_nan_dw_notif(struct wireless_dev *wdev,
10832 struct ieee80211_channel *chan, gfp_t gfp);
10833
10834 /**
10835 * cfg80211_nan_cluster_joined - Notify about NAN cluster join
10836 * @wdev: Pointer to the wireless device structure
10837 * @cluster_id: Cluster ID of the NAN cluster that was joined or started
10838 * @new_cluster: Indicates if this is a new cluster or an existing one
10839 * @gfp: Memory allocation flags
10840 *
10841 * This function is used to notify user space when a NAN cluster has been
10842 * joined, providing the cluster ID and a flag whether it is a new cluster.
10843 */
10844 void cfg80211_nan_cluster_joined(struct wireless_dev *wdev,
10845 const u8 *cluster_id, bool new_cluster,
10846 gfp_t gfp);
10847
10848 /**
10849 * cfg80211_nan_ulw_update - Notify user space about ULW update
10850 * @wdev: Pointer to the wireless device structure
10851 * @ulw: Pointer to the ULW blob data
10852 * @ulw_len: Length of the ULW blob in bytes
10853 * @gfp: Memory allocation flags
10854 *
10855 * This function is used by drivers to notify user space when the device's
10856 * ULW (Unaligned Schedule) blob has been updated. User space can use this
10857 * blob to attach to frames sent to peers.
10858 */
10859 void cfg80211_nan_ulw_update(struct wireless_dev *wdev,
10860 const u8 *ulw, size_t ulw_len, gfp_t gfp);
10861
10862 /**
10863 * cfg80211_nan_channel_evac - Notify user space about NAN channel evacuation
10864 * @wdev: Pointer to the wireless device structure
10865 * @chandef: Pointer to the channel definition of the NAN channel that was
10866 * evacuated
10867 * @gfp: Memory allocation flags
10868 *
10869 * This function is used by drivers to notify user space when a NAN
10870 * channel has been evacuated (i.e. ULWed) due to channel resource conflicts
10871 * with other interfaces.
10872 * This can happen when another interface sharing the channel resource with NAN
10873 * needs to move to a different channel (e.g. due to channel switch or link
10874 * switch). User space may reconfigure the local schedule to exclude the
10875 * evacuated channel.
10876 */
10877 void cfg80211_nan_channel_evac(struct wireless_dev *wdev,
10878 const struct cfg80211_chan_def *chandef,
10879 gfp_t gfp);
10880
10881 #ifdef CONFIG_CFG80211_DEBUGFS
10882 /**
10883 * wiphy_locked_debugfs_read - do a locked read in debugfs
10884 * @wiphy: the wiphy to use
10885 * @file: the file being read
10886 * @buf: the buffer to fill and then read from
10887 * @bufsize: size of the buffer
10888 * @userbuf: the user buffer to copy to
10889 * @count: read count
10890 * @ppos: read position
10891 * @handler: the read handler to call (under wiphy lock)
10892 * @data: additional data to pass to the read handler
10893 *
10894 * Return: the number of characters read, or a negative errno
10895 */
10896 ssize_t wiphy_locked_debugfs_read(struct wiphy *wiphy, struct file *file,
10897 char *buf, size_t bufsize,
10898 char __user *userbuf, size_t count,
10899 loff_t *ppos,
10900 ssize_t (*handler)(struct wiphy *wiphy,
10901 struct file *file,
10902 char *buf,
10903 size_t bufsize,
10904 void *data),
10905 void *data);
10906
10907 /**
10908 * wiphy_locked_debugfs_write - do a locked write in debugfs
10909 * @wiphy: the wiphy to use
10910 * @file: the file being written to
10911 * @buf: the buffer to copy the user data to
10912 * @bufsize: size of the buffer
10913 * @userbuf: the user buffer to copy from
10914 * @count: read count
10915 * @handler: the write handler to call (under wiphy lock)
10916 * @data: additional data to pass to the write handler
10917 *
10918 * Return: the number of characters written, or a negative errno
10919 */
10920 ssize_t wiphy_locked_debugfs_write(struct wiphy *wiphy, struct file *file,
10921 char *buf, size_t bufsize,
10922 const char __user *userbuf, size_t count,
10923 ssize_t (*handler)(struct wiphy *wiphy,
10924 struct file *file,
10925 char *buf,
10926 size_t count,
10927 void *data),
10928 void *data);
10929 #endif
10930
10931 /**
10932 * cfg80211_s1g_get_start_freq_khz - get S1G chandef start frequency
10933 * @chandef: the chandef to use
10934 *
10935 * Return: the chandefs starting frequency in KHz
10936 */
10937 static inline u32
cfg80211_s1g_get_start_freq_khz(const struct cfg80211_chan_def * chandef)10938 cfg80211_s1g_get_start_freq_khz(const struct cfg80211_chan_def *chandef)
10939 {
10940 u32 bw_mhz = cfg80211_chandef_get_width(chandef);
10941 u32 center_khz =
10942 MHZ_TO_KHZ(chandef->center_freq1) + chandef->freq1_offset;
10943 return center_khz - bw_mhz * 500 + 500;
10944 }
10945
10946 /**
10947 * cfg80211_s1g_get_end_freq_khz - get S1G chandef end frequency
10948 * @chandef: the chandef to use
10949 *
10950 * Return: the chandefs ending frequency in KHz
10951 */
10952 static inline u32
cfg80211_s1g_get_end_freq_khz(const struct cfg80211_chan_def * chandef)10953 cfg80211_s1g_get_end_freq_khz(const struct cfg80211_chan_def *chandef)
10954 {
10955 u32 bw_mhz = cfg80211_chandef_get_width(chandef);
10956 u32 center_khz =
10957 MHZ_TO_KHZ(chandef->center_freq1) + chandef->freq1_offset;
10958 return center_khz + bw_mhz * 500 - 500;
10959 }
10960
10961 /**
10962 * cfg80211_s1g_get_primary_sibling - retrieve the sibling 1MHz subchannel
10963 * for an S1G chandef using a 2MHz primary channel.
10964 * @wiphy: wiphy the channel belongs to
10965 * @chandef: the chandef to use
10966 *
10967 * When chandef::s1g_primary_2mhz is set to true, we are operating on a 2MHz
10968 * primary channel. The 1MHz subchannel designated by the primary channel
10969 * location exists within chandef::chan, whilst the 'sibling' is denoted as
10970 * being the other 1MHz subchannel that make up the 2MHz primary channel.
10971 *
10972 * Returns: the sibling 1MHz &struct ieee80211_channel, or %NULL on failure.
10973 */
10974 static inline struct ieee80211_channel *
cfg80211_s1g_get_primary_sibling(struct wiphy * wiphy,const struct cfg80211_chan_def * chandef)10975 cfg80211_s1g_get_primary_sibling(struct wiphy *wiphy,
10976 const struct cfg80211_chan_def *chandef)
10977 {
10978 int width_mhz = cfg80211_chandef_get_width(chandef);
10979 u32 pri_1mhz_khz, sibling_1mhz_khz, op_low_1mhz_khz, pri_index;
10980
10981 if (!chandef->s1g_primary_2mhz || width_mhz < 2)
10982 return NULL;
10983
10984 pri_1mhz_khz = ieee80211_channel_to_khz(chandef->chan);
10985 op_low_1mhz_khz = cfg80211_s1g_get_start_freq_khz(chandef);
10986
10987 /*
10988 * Compute the index of the primary 1 MHz subchannel within the
10989 * operating channel, relative to the lowest 1 MHz center frequency.
10990 * Flip the least significant bit to select the even/odd sibling,
10991 * then translate that index back into a channel frequency.
10992 */
10993 pri_index = (pri_1mhz_khz - op_low_1mhz_khz) / 1000;
10994 sibling_1mhz_khz = op_low_1mhz_khz + ((pri_index ^ 1) * 1000);
10995
10996 return ieee80211_get_channel_khz(wiphy, sibling_1mhz_khz);
10997 }
10998
10999
11000 /**
11001 * cfg80211_incumbent_signal_notify - Notify userspace of incumbent signal detection
11002 * @wiphy: the wiphy to use
11003 * @chandef: channel definition in which the interference was detected
11004 * @signal_interference_bitmap: bitmap indicating interference across 20 MHz segments
11005 * @gfp: allocation context for message creation and multicast; pass GFP_ATOMIC
11006 * if called from atomic context (e.g. firmware event handler), otherwise
11007 * GFP_KERNEL
11008 *
11009 * Use this function to notify userspace when an incumbent signal is detected on
11010 * the operating channel in the 6 GHz band. The notification includes the
11011 * current channel definition and a bitmap representing interference across
11012 * the operating bandwidth. Each bit in the bitmap corresponds to a 20 MHz
11013 * segment, with the lowest bit representing the lowest frequency segment.
11014 * Punctured sub-channels are included in the bitmap structure but are always
11015 * set to zero since interference detection is not performed on them.
11016 */
11017 void cfg80211_incumbent_signal_notify(struct wiphy *wiphy,
11018 const struct cfg80211_chan_def *chandef,
11019 u32 signal_interference_bitmap,
11020 gfp_t gfp);
11021
11022 #endif /* __NET_CFG80211_H */
11023