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