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