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