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