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