blob: d30bddb95e9d59b841a5e580aff7a9b008293afa [file] [log] [blame]
xjb04a4022021-11-25 15:01:52 +08001#ifndef __NET_CFG80211_H
2#define __NET_CFG80211_H
3/*
4 * 802.11 device and configuration interface
5 *
6 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
7 * Copyright 2013-2014 Intel Mobile Communications GmbH
8 * Copyright 2015-2017 Intel Deutschland GmbH
9 * Copyright (C) 2018 Intel Corporation
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#include <linux/netdevice.h>
17#include <linux/debugfs.h>
18#include <linux/list.h>
19#include <linux/bug.h>
20#include <linux/netlink.h>
21#include <linux/skbuff.h>
22#include <linux/nl80211.h>
23#include <linux/if_ether.h>
24#include <linux/ieee80211.h>
25#include <linux/net.h>
26#include <net/regulatory.h>
27
28/**
29 * DOC: Introduction
30 *
31 * cfg80211 is the configuration API for 802.11 devices in Linux. It bridges
32 * userspace and drivers, and offers some utility functionality associated
33 * with 802.11. cfg80211 must, directly or indirectly via mac80211, be used
34 * by all modern wireless drivers in Linux, so that they offer a consistent
35 * API through nl80211. For backward compatibility, cfg80211 also offers
36 * wireless extensions to userspace, but hides them from drivers completely.
37 *
38 * Additionally, cfg80211 contains code to help enforce regulatory spectrum
39 * use restrictions.
40 */
41
42
43/**
44 * DOC: Device registration
45 *
46 * In order for a driver to use cfg80211, it must register the hardware device
47 * with cfg80211. This happens through a number of hardware capability structs
48 * described below.
49 *
50 * The fundamental structure for each device is the 'wiphy', of which each
51 * instance describes a physical wireless device connected to the system. Each
52 * such wiphy can have zero, one, or many virtual interfaces associated with
53 * it, which need to be identified as such by pointing the network interface's
54 * @ieee80211_ptr pointer to a &struct wireless_dev which further describes
55 * the wireless part of the interface, normally this struct is embedded in the
56 * network interface's private data area. Drivers can optionally allow creating
57 * or destroying virtual interfaces on the fly, but without at least one or the
58 * ability to create some the wireless device isn't useful.
59 *
60 * Each wiphy structure contains device capability information, and also has
61 * a pointer to the various operations the driver offers. The definitions and
62 * structures here describe these capabilities in detail.
63 */
64
65struct wiphy;
66
67/*
68 * wireless hardware capability structures
69 */
70
71/**
72 * enum ieee80211_channel_flags - channel flags
73 *
74 * Channel flags set by the regulatory control code.
75 *
76 * @IEEE80211_CHAN_DISABLED: This channel is disabled.
77 * @IEEE80211_CHAN_NO_IR: do not initiate radiation, this includes
78 * sending probe requests or beaconing.
79 * @IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
80 * @IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel
81 * is not permitted.
82 * @IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel
83 * is not permitted.
84 * @IEEE80211_CHAN_NO_OFDM: OFDM is not allowed on this channel.
85 * @IEEE80211_CHAN_NO_80MHZ: If the driver supports 80 MHz on the band,
86 * this flag indicates that an 80 MHz channel cannot use this
87 * channel as the control or any of the secondary channels.
88 * This may be due to the driver or due to regulatory bandwidth
89 * restrictions.
90 * @IEEE80211_CHAN_NO_160MHZ: If the driver supports 160 MHz on the band,
91 * this flag indicates that an 160 MHz channel cannot use this
92 * channel as the control or any of the secondary channels.
93 * This may be due to the driver or due to regulatory bandwidth
94 * restrictions.
95 * @IEEE80211_CHAN_INDOOR_ONLY: see %NL80211_FREQUENCY_ATTR_INDOOR_ONLY
96 * @IEEE80211_CHAN_IR_CONCURRENT: see %NL80211_FREQUENCY_ATTR_IR_CONCURRENT
97 * @IEEE80211_CHAN_NO_20MHZ: 20 MHz bandwidth is not permitted
98 * on this channel.
99 * @IEEE80211_CHAN_NO_10MHZ: 10 MHz bandwidth is not permitted
100 * on this channel.
101 *
102 */
103enum ieee80211_channel_flags {
104 IEEE80211_CHAN_DISABLED = 1<<0,
105 IEEE80211_CHAN_NO_IR = 1<<1,
106 /* hole at 1<<2 */
107 IEEE80211_CHAN_RADAR = 1<<3,
108 IEEE80211_CHAN_NO_HT40PLUS = 1<<4,
109 IEEE80211_CHAN_NO_HT40MINUS = 1<<5,
110 IEEE80211_CHAN_NO_OFDM = 1<<6,
111 IEEE80211_CHAN_NO_80MHZ = 1<<7,
112 IEEE80211_CHAN_NO_160MHZ = 1<<8,
113 IEEE80211_CHAN_INDOOR_ONLY = 1<<9,
114 IEEE80211_CHAN_IR_CONCURRENT = 1<<10,
115 IEEE80211_CHAN_NO_20MHZ = 1<<11,
116 IEEE80211_CHAN_NO_10MHZ = 1<<12,
117};
118
119#define IEEE80211_CHAN_NO_HT40 \
120 (IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS)
121
122#define IEEE80211_DFS_MIN_CAC_TIME_MS 60000
123#define IEEE80211_DFS_MIN_NOP_TIME_MS (30 * 60 * 1000)
124
125/**
126 * struct ieee80211_channel - channel definition
127 *
128 * This structure describes a single channel for use
129 * with cfg80211.
130 *
131 * @center_freq: center frequency in MHz
132 * @hw_value: hardware-specific value for the channel
133 * @flags: channel flags from &enum ieee80211_channel_flags.
134 * @orig_flags: channel flags at registration time, used by regulatory
135 * code to support devices with additional restrictions
136 * @band: band this channel belongs to.
137 * @max_antenna_gain: maximum antenna gain in dBi
138 * @max_power: maximum transmission power (in dBm)
139 * @max_reg_power: maximum regulatory transmission power (in dBm)
140 * @beacon_found: helper to regulatory code to indicate when a beacon
141 * has been found on this channel. Use regulatory_hint_found_beacon()
142 * to enable this, this is useful only on 5 GHz band.
143 * @orig_mag: internal use
144 * @orig_mpwr: internal use
145 * @dfs_state: current state of this channel. Only relevant if radar is required
146 * on this channel.
147 * @dfs_state_entered: timestamp (jiffies) when the dfs state was entered.
148 * @dfs_cac_ms: DFS CAC time in milliseconds, this is valid for DFS channels.
149 */
150struct ieee80211_channel {
151 enum nl80211_band band;
152 u16 center_freq;
153 u16 hw_value;
154 u32 flags;
155 int max_antenna_gain;
156 int max_power;
157 int max_reg_power;
158 bool beacon_found;
159 u32 orig_flags;
160 int orig_mag, orig_mpwr;
161 enum nl80211_dfs_state dfs_state;
162 unsigned long dfs_state_entered;
163 unsigned int dfs_cac_ms;
164};
165
166/**
167 * enum ieee80211_rate_flags - rate flags
168 *
169 * Hardware/specification flags for rates. These are structured
170 * in a way that allows using the same bitrate structure for
171 * different bands/PHY modes.
172 *
173 * @IEEE80211_RATE_SHORT_PREAMBLE: Hardware can send with short
174 * preamble on this bitrate; only relevant in 2.4GHz band and
175 * with CCK rates.
176 * @IEEE80211_RATE_MANDATORY_A: This bitrate is a mandatory rate
177 * when used with 802.11a (on the 5 GHz band); filled by the
178 * core code when registering the wiphy.
179 * @IEEE80211_RATE_MANDATORY_B: This bitrate is a mandatory rate
180 * when used with 802.11b (on the 2.4 GHz band); filled by the
181 * core code when registering the wiphy.
182 * @IEEE80211_RATE_MANDATORY_G: This bitrate is a mandatory rate
183 * when used with 802.11g (on the 2.4 GHz band); filled by the
184 * core code when registering the wiphy.
185 * @IEEE80211_RATE_ERP_G: This is an ERP rate in 802.11g mode.
186 * @IEEE80211_RATE_SUPPORTS_5MHZ: Rate can be used in 5 MHz mode
187 * @IEEE80211_RATE_SUPPORTS_10MHZ: Rate can be used in 10 MHz mode
188 */
189enum ieee80211_rate_flags {
190 IEEE80211_RATE_SHORT_PREAMBLE = 1<<0,
191 IEEE80211_RATE_MANDATORY_A = 1<<1,
192 IEEE80211_RATE_MANDATORY_B = 1<<2,
193 IEEE80211_RATE_MANDATORY_G = 1<<3,
194 IEEE80211_RATE_ERP_G = 1<<4,
195 IEEE80211_RATE_SUPPORTS_5MHZ = 1<<5,
196 IEEE80211_RATE_SUPPORTS_10MHZ = 1<<6,
197};
198
199/**
200 * enum ieee80211_bss_type - BSS type filter
201 *
202 * @IEEE80211_BSS_TYPE_ESS: Infrastructure BSS
203 * @IEEE80211_BSS_TYPE_PBSS: Personal BSS
204 * @IEEE80211_BSS_TYPE_IBSS: Independent BSS
205 * @IEEE80211_BSS_TYPE_MBSS: Mesh BSS
206 * @IEEE80211_BSS_TYPE_ANY: Wildcard value for matching any BSS type
207 */
208enum ieee80211_bss_type {
209 IEEE80211_BSS_TYPE_ESS,
210 IEEE80211_BSS_TYPE_PBSS,
211 IEEE80211_BSS_TYPE_IBSS,
212 IEEE80211_BSS_TYPE_MBSS,
213 IEEE80211_BSS_TYPE_ANY
214};
215
216/**
217 * enum ieee80211_privacy - BSS privacy filter
218 *
219 * @IEEE80211_PRIVACY_ON: privacy bit set
220 * @IEEE80211_PRIVACY_OFF: privacy bit clear
221 * @IEEE80211_PRIVACY_ANY: Wildcard value for matching any privacy setting
222 */
223enum ieee80211_privacy {
224 IEEE80211_PRIVACY_ON,
225 IEEE80211_PRIVACY_OFF,
226 IEEE80211_PRIVACY_ANY
227};
228
229#define IEEE80211_PRIVACY(x) \
230 ((x) ? IEEE80211_PRIVACY_ON : IEEE80211_PRIVACY_OFF)
231
232/**
233 * struct ieee80211_rate - bitrate definition
234 *
235 * This structure describes a bitrate that an 802.11 PHY can
236 * operate with. The two values @hw_value and @hw_value_short
237 * are only for driver use when pointers to this structure are
238 * passed around.
239 *
240 * @flags: rate-specific flags
241 * @bitrate: bitrate in units of 100 Kbps
242 * @hw_value: driver/hardware value for this rate
243 * @hw_value_short: driver/hardware value for this rate when
244 * short preamble is used
245 */
246struct ieee80211_rate {
247 u32 flags;
248 u16 bitrate;
249 u16 hw_value, hw_value_short;
250};
251
252/**
253 * struct ieee80211_sta_ht_cap - STA's HT capabilities
254 *
255 * This structure describes most essential parameters needed
256 * to describe 802.11n HT capabilities for an STA.
257 *
258 * @ht_supported: is HT supported by the STA
259 * @cap: HT capabilities map as described in 802.11n spec
260 * @ampdu_factor: Maximum A-MPDU length factor
261 * @ampdu_density: Minimum A-MPDU spacing
262 * @mcs: Supported MCS rates
263 */
264struct ieee80211_sta_ht_cap {
265 u16 cap; /* use IEEE80211_HT_CAP_ */
266 bool ht_supported;
267 u8 ampdu_factor;
268 u8 ampdu_density;
269 struct ieee80211_mcs_info mcs;
270};
271
272/**
273 * struct ieee80211_sta_vht_cap - STA's VHT capabilities
274 *
275 * This structure describes most essential parameters needed
276 * to describe 802.11ac VHT capabilities for an STA.
277 *
278 * @vht_supported: is VHT supported by the STA
279 * @cap: VHT capabilities map as described in 802.11ac spec
280 * @vht_mcs: Supported VHT MCS rates
281 */
282struct ieee80211_sta_vht_cap {
283 bool vht_supported;
284 u32 cap; /* use IEEE80211_VHT_CAP_ */
285 struct ieee80211_vht_mcs_info vht_mcs;
286};
287
288#define IEEE80211_HE_PPE_THRES_MAX_LEN 25
289
290/**
291 * struct ieee80211_sta_he_cap - STA's HE capabilities
292 *
293 * This structure describes most essential parameters needed
294 * to describe 802.11ax HE capabilities for a STA.
295 *
296 * @has_he: true iff HE data is valid.
297 * @he_cap_elem: Fixed portion of the HE capabilities element.
298 * @he_mcs_nss_supp: The supported NSS/MCS combinations.
299 * @ppe_thres: Holds the PPE Thresholds data.
300 */
301struct ieee80211_sta_he_cap {
302 bool has_he;
303 struct ieee80211_he_cap_elem he_cap_elem;
304 struct ieee80211_he_mcs_nss_supp he_mcs_nss_supp;
305 u8 ppe_thres[IEEE80211_HE_PPE_THRES_MAX_LEN];
306};
307
308/**
309 * struct ieee80211_sband_iftype_data
310 *
311 * This structure encapsulates sband data that is relevant for the
312 * interface types defined in @types_mask. Each type in the
313 * @types_mask must be unique across all instances of iftype_data.
314 *
315 * @types_mask: interface types mask
316 * @he_cap: holds the HE capabilities
317 */
318struct ieee80211_sband_iftype_data {
319 u16 types_mask;
320 struct ieee80211_sta_he_cap he_cap;
321};
322
323/**
324 * struct ieee80211_supported_band - frequency band definition
325 *
326 * This structure describes a frequency band a wiphy
327 * is able to operate in.
328 *
329 * @channels: Array of channels the hardware can operate in
330 * in this band.
331 * @band: the band this structure represents
332 * @n_channels: Number of channels in @channels
333 * @bitrates: Array of bitrates the hardware can operate with
334 * in this band. Must be sorted to give a valid "supported
335 * rates" IE, i.e. CCK rates first, then OFDM.
336 * @n_bitrates: Number of bitrates in @bitrates
337 * @ht_cap: HT capabilities in this band
338 * @vht_cap: VHT capabilities in this band
339 * @n_iftype_data: number of iftype data entries
340 * @iftype_data: interface type data entries. Note that the bits in
341 * @types_mask inside this structure cannot overlap (i.e. only
342 * one occurrence of each type is allowed across all instances of
343 * iftype_data).
344 */
345struct ieee80211_supported_band {
346 struct ieee80211_channel *channels;
347 struct ieee80211_rate *bitrates;
348 enum nl80211_band band;
349 int n_channels;
350 int n_bitrates;
351 struct ieee80211_sta_ht_cap ht_cap;
352 struct ieee80211_sta_vht_cap vht_cap;
353 u16 n_iftype_data;
354 const struct ieee80211_sband_iftype_data *iftype_data;
355};
356
357/**
358 * ieee80211_get_sband_iftype_data - return sband data for a given iftype
359 * @sband: the sband to search for the STA on
360 * @iftype: enum nl80211_iftype
361 *
362 * Return: pointer to struct ieee80211_sband_iftype_data, or NULL is none found
363 */
364static inline const struct ieee80211_sband_iftype_data *
365ieee80211_get_sband_iftype_data(const struct ieee80211_supported_band *sband,
366 u8 iftype)
367{
368 int i;
369
370 if (WARN_ON(iftype >= NL80211_IFTYPE_MAX))
371 return NULL;
372
373 for (i = 0; i < sband->n_iftype_data; i++) {
374 const struct ieee80211_sband_iftype_data *data =
375 &sband->iftype_data[i];
376
377 if (data->types_mask & BIT(iftype))
378 return data;
379 }
380
381 return NULL;
382}
383
384/**
385 * ieee80211_get_he_sta_cap - return HE capabilities for an sband's STA
386 * @sband: the sband to search for the STA on
387 *
388 * Return: pointer to the struct ieee80211_sta_he_cap, or NULL is none found
389 */
390static inline const struct ieee80211_sta_he_cap *
391ieee80211_get_he_sta_cap(const struct ieee80211_supported_band *sband)
392{
393 const struct ieee80211_sband_iftype_data *data =
394 ieee80211_get_sband_iftype_data(sband, NL80211_IFTYPE_STATION);
395
396 if (data && data->he_cap.has_he)
397 return &data->he_cap;
398
399 return NULL;
400}
401
402/**
403 * wiphy_read_of_freq_limits - read frequency limits from device tree
404 *
405 * @wiphy: the wireless device to get extra limits for
406 *
407 * Some devices may have extra limitations specified in DT. This may be useful
408 * for chipsets that normally support more bands but are limited due to board
409 * design (e.g. by antennas or external power amplifier).
410 *
411 * This function reads info from DT and uses it to *modify* channels (disable
412 * unavailable ones). It's usually a *bad* idea to use it in drivers with
413 * shared channel data as DT limitations are device specific. You should make
414 * sure to call it only if channels in wiphy are copied and can be modified
415 * without affecting other devices.
416 *
417 * As this function access device node it has to be called after set_wiphy_dev.
418 * It also modifies channels so they have to be set first.
419 * If using this helper, call it before wiphy_register().
420 */
421#ifdef CONFIG_OF
422void wiphy_read_of_freq_limits(struct wiphy *wiphy);
423#else /* CONFIG_OF */
424static inline void wiphy_read_of_freq_limits(struct wiphy *wiphy)
425{
426}
427#endif /* !CONFIG_OF */
428
429
430/*
431 * Wireless hardware/device configuration structures and methods
432 */
433
434/**
435 * DOC: Actions and configuration
436 *
437 * Each wireless device and each virtual interface offer a set of configuration
438 * operations and other actions that are invoked by userspace. Each of these
439 * actions is described in the operations structure, and the parameters these
440 * operations use are described separately.
441 *
442 * Additionally, some operations are asynchronous and expect to get status
443 * information via some functions that drivers need to call.
444 *
445 * Scanning and BSS list handling with its associated functionality is described
446 * in a separate chapter.
447 */
448
449#define VHT_MUMIMO_GROUPS_DATA_LEN (WLAN_MEMBERSHIP_LEN +\
450 WLAN_USER_POSITION_LEN)
451
452/**
453 * struct vif_params - describes virtual interface parameters
454 * @flags: monitor interface flags, unchanged if 0, otherwise
455 * %MONITOR_FLAG_CHANGED will be set
456 * @use_4addr: use 4-address frames
457 * @macaddr: address to use for this virtual interface.
458 * If this parameter is set to zero address the driver may
459 * determine the address as needed.
460 * This feature is only fully supported by drivers that enable the
461 * %NL80211_FEATURE_MAC_ON_CREATE flag. Others may support creating
462 ** only p2p devices with specified MAC.
463 * @vht_mumimo_groups: MU-MIMO groupID, used for monitoring MU-MIMO packets
464 * belonging to that MU-MIMO groupID; %NULL if not changed
465 * @vht_mumimo_follow_addr: MU-MIMO follow address, used for monitoring
466 * MU-MIMO packets going to the specified station; %NULL if not changed
467 */
468struct vif_params {
469 u32 flags;
470 int use_4addr;
471 u8 macaddr[ETH_ALEN];
472 const u8 *vht_mumimo_groups;
473 const u8 *vht_mumimo_follow_addr;
474};
475
476/**
477 * struct key_params - key information
478 *
479 * Information about a key
480 *
481 * @key: key material
482 * @key_len: length of key material
483 * @cipher: cipher suite selector
484 * @seq: sequence counter (IV/PN) for TKIP and CCMP keys, only used
485 * with the get_key() callback, must be in little endian,
486 * length given by @seq_len.
487 * @seq_len: length of @seq.
488 */
489struct key_params {
490 const u8 *key;
491 const u8 *seq;
492 int key_len;
493 int seq_len;
494 u32 cipher;
495};
496
497/**
498 * struct cfg80211_chan_def - channel definition
499 * @chan: the (control) channel
500 * @width: channel width
501 * @center_freq1: center frequency of first segment
502 * @center_freq2: center frequency of second segment
503 * (only with 80+80 MHz)
504 */
505struct cfg80211_chan_def {
506 struct ieee80211_channel *chan;
507 enum nl80211_chan_width width;
508 u32 center_freq1;
509 u32 center_freq2;
510};
511
512/**
513 * cfg80211_get_chandef_type - return old channel type from chandef
514 * @chandef: the channel definition
515 *
516 * Return: The old channel type (NOHT, HT20, HT40+/-) from a given
517 * chandef, which must have a bandwidth allowing this conversion.
518 */
519static inline enum nl80211_channel_type
520cfg80211_get_chandef_type(const struct cfg80211_chan_def *chandef)
521{
522 switch (chandef->width) {
523 case NL80211_CHAN_WIDTH_20_NOHT:
524 return NL80211_CHAN_NO_HT;
525 case NL80211_CHAN_WIDTH_20:
526 return NL80211_CHAN_HT20;
527 case NL80211_CHAN_WIDTH_40:
528 if (chandef->center_freq1 > chandef->chan->center_freq)
529 return NL80211_CHAN_HT40PLUS;
530 return NL80211_CHAN_HT40MINUS;
531 default:
532 WARN_ON(1);
533 return NL80211_CHAN_NO_HT;
534 }
535}
536
537/**
538 * cfg80211_chandef_create - create channel definition using channel type
539 * @chandef: the channel definition struct to fill
540 * @channel: the control channel
541 * @chantype: the channel type
542 *
543 * Given a channel type, create a channel definition.
544 */
545void cfg80211_chandef_create(struct cfg80211_chan_def *chandef,
546 struct ieee80211_channel *channel,
547 enum nl80211_channel_type chantype);
548
549/**
550 * cfg80211_chandef_identical - check if two channel definitions are identical
551 * @chandef1: first channel definition
552 * @chandef2: second channel definition
553 *
554 * Return: %true if the channels defined by the channel definitions are
555 * identical, %false otherwise.
556 */
557static inline bool
558cfg80211_chandef_identical(const struct cfg80211_chan_def *chandef1,
559 const struct cfg80211_chan_def *chandef2)
560{
561 return (chandef1->chan == chandef2->chan &&
562 chandef1->width == chandef2->width &&
563 chandef1->center_freq1 == chandef2->center_freq1 &&
564 chandef1->center_freq2 == chandef2->center_freq2);
565}
566
567/**
568 * cfg80211_chandef_compatible - check if two channel definitions are compatible
569 * @chandef1: first channel definition
570 * @chandef2: second channel definition
571 *
572 * Return: %NULL if the given channel definitions are incompatible,
573 * chandef1 or chandef2 otherwise.
574 */
575const struct cfg80211_chan_def *
576cfg80211_chandef_compatible(const struct cfg80211_chan_def *chandef1,
577 const struct cfg80211_chan_def *chandef2);
578
579/**
580 * cfg80211_chandef_valid - check if a channel definition is valid
581 * @chandef: the channel definition to check
582 * Return: %true if the channel definition is valid. %false otherwise.
583 */
584bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef);
585
586/**
587 * cfg80211_chandef_usable - check if secondary channels can be used
588 * @wiphy: the wiphy to validate against
589 * @chandef: the channel definition to check
590 * @prohibited_flags: the regulatory channel flags that must not be set
591 * Return: %true if secondary channels are usable. %false otherwise.
592 */
593bool cfg80211_chandef_usable(struct wiphy *wiphy,
594 const struct cfg80211_chan_def *chandef,
595 u32 prohibited_flags);
596
597/**
598 * cfg80211_chandef_dfs_required - checks if radar detection is required
599 * @wiphy: the wiphy to validate against
600 * @chandef: the channel definition to check
601 * @iftype: the interface type as specified in &enum nl80211_iftype
602 * Returns:
603 * 1 if radar detection is required, 0 if it is not, < 0 on error
604 */
605int cfg80211_chandef_dfs_required(struct wiphy *wiphy,
606 const struct cfg80211_chan_def *chandef,
607 enum nl80211_iftype iftype);
608
609/**
610 * ieee80211_chandef_rate_flags - returns rate flags for a channel
611 *
612 * In some channel types, not all rates may be used - for example CCK
613 * rates may not be used in 5/10 MHz channels.
614 *
615 * @chandef: channel definition for the channel
616 *
617 * Returns: rate flags which apply for this channel
618 */
619static inline enum ieee80211_rate_flags
620ieee80211_chandef_rate_flags(struct cfg80211_chan_def *chandef)
621{
622 switch (chandef->width) {
623 case NL80211_CHAN_WIDTH_5:
624 return IEEE80211_RATE_SUPPORTS_5MHZ;
625 case NL80211_CHAN_WIDTH_10:
626 return IEEE80211_RATE_SUPPORTS_10MHZ;
627 default:
628 break;
629 }
630 return 0;
631}
632
633/**
634 * ieee80211_chandef_max_power - maximum transmission power for the chandef
635 *
636 * In some regulations, the transmit power may depend on the configured channel
637 * bandwidth which may be defined as dBm/MHz. This function returns the actual
638 * max_power for non-standard (20 MHz) channels.
639 *
640 * @chandef: channel definition for the channel
641 *
642 * Returns: maximum allowed transmission power in dBm for the chandef
643 */
644static inline int
645ieee80211_chandef_max_power(struct cfg80211_chan_def *chandef)
646{
647 switch (chandef->width) {
648 case NL80211_CHAN_WIDTH_5:
649 return min(chandef->chan->max_reg_power - 6,
650 chandef->chan->max_power);
651 case NL80211_CHAN_WIDTH_10:
652 return min(chandef->chan->max_reg_power - 3,
653 chandef->chan->max_power);
654 default:
655 break;
656 }
657 return chandef->chan->max_power;
658}
659
660/**
661 * enum survey_info_flags - survey information flags
662 *
663 * @SURVEY_INFO_NOISE_DBM: noise (in dBm) was filled in
664 * @SURVEY_INFO_IN_USE: channel is currently being used
665 * @SURVEY_INFO_TIME: active time (in ms) was filled in
666 * @SURVEY_INFO_TIME_BUSY: busy time was filled in
667 * @SURVEY_INFO_TIME_EXT_BUSY: extension channel busy time was filled in
668 * @SURVEY_INFO_TIME_RX: receive time was filled in
669 * @SURVEY_INFO_TIME_TX: transmit time was filled in
670 * @SURVEY_INFO_TIME_SCAN: scan time was filled in
671 *
672 * Used by the driver to indicate which info in &struct survey_info
673 * it has filled in during the get_survey().
674 */
675enum survey_info_flags {
676 SURVEY_INFO_NOISE_DBM = BIT(0),
677 SURVEY_INFO_IN_USE = BIT(1),
678 SURVEY_INFO_TIME = BIT(2),
679 SURVEY_INFO_TIME_BUSY = BIT(3),
680 SURVEY_INFO_TIME_EXT_BUSY = BIT(4),
681 SURVEY_INFO_TIME_RX = BIT(5),
682 SURVEY_INFO_TIME_TX = BIT(6),
683 SURVEY_INFO_TIME_SCAN = BIT(7),
684};
685
686/**
687 * struct survey_info - channel survey response
688 *
689 * @channel: the channel this survey record reports, may be %NULL for a single
690 * record to report global statistics
691 * @filled: bitflag of flags from &enum survey_info_flags
692 * @noise: channel noise in dBm. This and all following fields are
693 * optional
694 * @time: amount of time in ms the radio was turn on (on the channel)
695 * @time_busy: amount of time the primary channel was sensed busy
696 * @time_ext_busy: amount of time the extension channel was sensed busy
697 * @time_rx: amount of time the radio spent receiving data
698 * @time_tx: amount of time the radio spent transmitting data
699 * @time_scan: amount of time the radio spent for scanning
700 *
701 * Used by dump_survey() to report back per-channel survey information.
702 *
703 * This structure can later be expanded with things like
704 * channel duty cycle etc.
705 */
706struct survey_info {
707 struct ieee80211_channel *channel;
708 u64 time;
709 u64 time_busy;
710 u64 time_ext_busy;
711 u64 time_rx;
712 u64 time_tx;
713 u64 time_scan;
714 u32 filled;
715 s8 noise;
716};
717
718#define CFG80211_MAX_WEP_KEYS 4
719
720/**
721 * struct cfg80211_crypto_settings - Crypto settings
722 * @wpa_versions: indicates which, if any, WPA versions are enabled
723 * (from enum nl80211_wpa_versions)
724 * @cipher_group: group key cipher suite (or 0 if unset)
725 * @n_ciphers_pairwise: number of AP supported unicast ciphers
726 * @ciphers_pairwise: unicast key cipher suites
727 * @n_akm_suites: number of AKM suites
728 * @akm_suites: AKM suites
729 * @control_port: Whether user space controls IEEE 802.1X port, i.e.,
730 * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is
731 * required to assume that the port is unauthorized until authorized by
732 * user space. Otherwise, port is marked authorized by default.
733 * @control_port_ethertype: the control port protocol that should be
734 * allowed through even on unauthorized ports
735 * @control_port_no_encrypt: TRUE to prevent encryption of control port
736 * protocol frames.
737 * @control_port_over_nl80211: TRUE if userspace expects to exchange control
738 * port frames over NL80211 instead of the network interface.
739 * @wep_keys: static WEP keys, if not NULL points to an array of
740 * CFG80211_MAX_WEP_KEYS WEP keys
741 * @wep_tx_key: key index (0..3) of the default TX static WEP key
742 * @psk: PSK (for devices supporting 4-way-handshake offload)
743 */
744struct cfg80211_crypto_settings {
745 u32 wpa_versions;
746 u32 cipher_group;
747 int n_ciphers_pairwise;
748 u32 ciphers_pairwise[NL80211_MAX_NR_CIPHER_SUITES];
749 int n_akm_suites;
750 u32 akm_suites[NL80211_MAX_NR_AKM_SUITES];
751 bool control_port;
752 __be16 control_port_ethertype;
753 bool control_port_no_encrypt;
754 bool control_port_over_nl80211;
755 struct key_params *wep_keys;
756 int wep_tx_key;
757 const u8 *psk;
758};
759
760/**
761 * struct cfg80211_beacon_data - beacon data
762 * @head: head portion of beacon (before TIM IE)
763 * or %NULL if not changed
764 * @tail: tail portion of beacon (after TIM IE)
765 * or %NULL if not changed
766 * @head_len: length of @head
767 * @tail_len: length of @tail
768 * @beacon_ies: extra information element(s) to add into Beacon frames or %NULL
769 * @beacon_ies_len: length of beacon_ies in octets
770 * @proberesp_ies: extra information element(s) to add into Probe Response
771 * frames or %NULL
772 * @proberesp_ies_len: length of proberesp_ies in octets
773 * @assocresp_ies: extra information element(s) to add into (Re)Association
774 * Response frames or %NULL
775 * @assocresp_ies_len: length of assocresp_ies in octets
776 * @probe_resp_len: length of probe response template (@probe_resp)
777 * @probe_resp: probe response template (AP mode only)
778 */
779struct cfg80211_beacon_data {
780 const u8 *head, *tail;
781 const u8 *beacon_ies;
782 const u8 *proberesp_ies;
783 const u8 *assocresp_ies;
784 const u8 *probe_resp;
785
786 size_t head_len, tail_len;
787 size_t beacon_ies_len;
788 size_t proberesp_ies_len;
789 size_t assocresp_ies_len;
790 size_t probe_resp_len;
791};
792
793struct mac_address {
794 u8 addr[ETH_ALEN];
795};
796
797/**
798 * struct cfg80211_acl_data - Access control list data
799 *
800 * @acl_policy: ACL policy to be applied on the station's
801 * entry specified by mac_addr
802 * @n_acl_entries: Number of MAC address entries passed
803 * @mac_addrs: List of MAC addresses of stations to be used for ACL
804 */
805struct cfg80211_acl_data {
806 enum nl80211_acl_policy acl_policy;
807 int n_acl_entries;
808
809 /* Keep it last */
810 struct mac_address mac_addrs[];
811};
812
813/*
814 * cfg80211_bitrate_mask - masks for bitrate control
815 */
816struct cfg80211_bitrate_mask {
817 struct {
818 u32 legacy;
819 u8 ht_mcs[IEEE80211_HT_MCS_MASK_LEN];
820 u16 vht_mcs[NL80211_VHT_NSS_MAX];
821 enum nl80211_txrate_gi gi;
822 } control[NUM_NL80211_BANDS];
823};
824
825//tianyan@2021.7.27 modify for add wifi6 module start
826/**
827 * enum cfg80211_ap_settings_flags - AP settings flags
828 *
829 * Used by cfg80211_ap_settings
830 *
831 * @AP_SETTINGS_EXTERNAL_AUTH_SUPPORT: AP supports external authentication
832 */
833enum cfg80211_ap_settings_flags {
834 AP_SETTINGS_EXTERNAL_AUTH_SUPPORT = BIT(0),
835};
836//tianyan@2021.7.27 modify for add wifi6 module end
837
838
839/**
840 * struct cfg80211_ap_settings - AP configuration
841 *
842 * Used to configure an AP interface.
843 *
844 * @chandef: defines the channel to use
845 * @beacon: beacon data
846 * @beacon_interval: beacon interval
847 * @dtim_period: DTIM period
848 * @ssid: SSID to be used in the BSS (note: may be %NULL if not provided from
849 * user space)
850 * @ssid_len: length of @ssid
851 * @hidden_ssid: whether to hide the SSID in Beacon/Probe Response frames
852 * @crypto: crypto settings
853 * @privacy: the BSS uses privacy
854 * @auth_type: Authentication type (algorithm)
855 * @smps_mode: SMPS mode
856 * @inactivity_timeout: time in seconds to determine station's inactivity.
857 * @p2p_ctwindow: P2P CT Window
858 * @p2p_opp_ps: P2P opportunistic PS
859 * @acl: ACL configuration used by the drivers which has support for
860 * MAC address based access control
861 * @pbss: If set, start as a PCP instead of AP. Relevant for DMG
862 * networks.
863 * @beacon_rate: bitrate to be used for beacons
864 * @ht_cap: HT capabilities (or %NULL if HT isn't enabled)
865 * @vht_cap: VHT capabilities (or %NULL if VHT isn't enabled)
866 * @ht_required: stations must support HT
867 * @vht_required: stations must support VHT
868 * @flags: flags, as defined in enum cfg80211_ap_settings_flags
869 */
870struct cfg80211_ap_settings {
871 struct cfg80211_chan_def chandef;
872
873 struct cfg80211_beacon_data beacon;
874
875 int beacon_interval, dtim_period;
876 const u8 *ssid;
877 size_t ssid_len;
878 enum nl80211_hidden_ssid hidden_ssid;
879 struct cfg80211_crypto_settings crypto;
880 bool privacy;
881 enum nl80211_auth_type auth_type;
882 enum nl80211_smps_mode smps_mode;
883 int inactivity_timeout;
884 u8 p2p_ctwindow;
885 bool p2p_opp_ps;
886 const struct cfg80211_acl_data *acl;
887 bool pbss;
888 struct cfg80211_bitrate_mask beacon_rate;
889
890 const struct ieee80211_ht_cap *ht_cap;
891 const struct ieee80211_vht_cap *vht_cap;
892 bool ht_required, vht_required;
893//tianyan@2021.7.27 modify for add wifi6 module start
894 u32 flags;
895//tianyan@2021.7.27 modify for add wifi6 module end
896};
897
898/**
899 * struct cfg80211_csa_settings - channel switch settings
900 *
901 * Used for channel switch
902 *
903 * @chandef: defines the channel to use after the switch
904 * @beacon_csa: beacon data while performing the switch
905 * @counter_offsets_beacon: offsets of the counters within the beacon (tail)
906 * @counter_offsets_presp: offsets of the counters within the probe response
907 * @n_counter_offsets_beacon: number of csa counters the beacon (tail)
908 * @n_counter_offsets_presp: number of csa counters in the probe response
909 * @beacon_after: beacon data to be used on the new channel
910 * @radar_required: whether radar detection is required on the new channel
911 * @block_tx: whether transmissions should be blocked while changing
912 * @count: number of beacons until switch
913 */
914struct cfg80211_csa_settings {
915 struct cfg80211_chan_def chandef;
916 struct cfg80211_beacon_data beacon_csa;
917 const u16 *counter_offsets_beacon;
918 const u16 *counter_offsets_presp;
919 unsigned int n_counter_offsets_beacon;
920 unsigned int n_counter_offsets_presp;
921 struct cfg80211_beacon_data beacon_after;
922 bool radar_required;
923 bool block_tx;
924 u8 count;
925};
926
927#define CFG80211_MAX_NUM_DIFFERENT_CHANNELS 10
928
929/**
930 * struct iface_combination_params - input parameters for interface combinations
931 *
932 * Used to pass interface combination parameters
933 *
934 * @num_different_channels: the number of different channels we want
935 * to use for verification
936 * @radar_detect: a bitmap where each bit corresponds to a channel
937 * width where radar detection is needed, as in the definition of
938 * &struct ieee80211_iface_combination.@radar_detect_widths
939 * @iftype_num: array with the number of interfaces of each interface
940 * type. The index is the interface type as specified in &enum
941 * nl80211_iftype.
942 * @new_beacon_int: set this to the beacon interval of a new interface
943 * that's not operating yet, if such is to be checked as part of
944 * the verification
945 */
946struct iface_combination_params {
947 int num_different_channels;
948 u8 radar_detect;
949 int iftype_num[NUM_NL80211_IFTYPES];
950 u32 new_beacon_int;
951};
952
953/**
954 * enum station_parameters_apply_mask - station parameter values to apply
955 * @STATION_PARAM_APPLY_UAPSD: apply new uAPSD parameters (uapsd_queues, max_sp)
956 * @STATION_PARAM_APPLY_CAPABILITY: apply new capability
957 * @STATION_PARAM_APPLY_PLINK_STATE: apply new plink state
958 *
959 * Not all station parameters have in-band "no change" signalling,
960 * for those that don't these flags will are used.
961 */
962enum station_parameters_apply_mask {
963 STATION_PARAM_APPLY_UAPSD = BIT(0),
964 STATION_PARAM_APPLY_CAPABILITY = BIT(1),
965 STATION_PARAM_APPLY_PLINK_STATE = BIT(2),
966};
967
968/**
969 * struct station_parameters - station parameters
970 *
971 * Used to change and create a new station.
972 *
973 * @vlan: vlan interface station should belong to
974 * @supported_rates: supported rates in IEEE 802.11 format
975 * (or NULL for no change)
976 * @supported_rates_len: number of supported rates
977 * @sta_flags_mask: station flags that changed
978 * (bitmask of BIT(%NL80211_STA_FLAG_...))
979 * @sta_flags_set: station flags values
980 * (bitmask of BIT(%NL80211_STA_FLAG_...))
981 * @listen_interval: listen interval or -1 for no change
982 * @aid: AID or zero for no change
983 * @peer_aid: mesh peer AID or zero for no change
984 * @plink_action: plink action to take
985 * @plink_state: set the peer link state for a station
986 * @ht_capa: HT capabilities of station
987 * @vht_capa: VHT capabilities of station
988 * @uapsd_queues: bitmap of queues configured for uapsd. same format
989 * as the AC bitmap in the QoS info field
990 * @max_sp: max Service Period. same format as the MAX_SP in the
991 * QoS info field (but already shifted down)
992 * @sta_modify_mask: bitmap indicating which parameters changed
993 * (for those that don't have a natural "no change" value),
994 * see &enum station_parameters_apply_mask
995 * @local_pm: local link-specific mesh power save mode (no change when set
996 * to unknown)
997 * @capability: station capability
998 * @ext_capab: extended capabilities of the station
999 * @ext_capab_len: number of extended capabilities
1000 * @supported_channels: supported channels in IEEE 802.11 format
1001 * @supported_channels_len: number of supported channels
1002 * @supported_oper_classes: supported oper classes in IEEE 802.11 format
1003 * @supported_oper_classes_len: number of supported operating classes
1004 * @opmode_notif: operating mode field from Operating Mode Notification
1005 * @opmode_notif_used: information if operating mode field is used
1006 * @support_p2p_ps: information if station supports P2P PS mechanism
1007 * @he_capa: HE capabilities of station
1008 * @he_capa_len: the length of the HE capabilities
1009 */
1010struct station_parameters {
1011 const u8 *supported_rates;
1012 struct net_device *vlan;
1013 u32 sta_flags_mask, sta_flags_set;
1014 u32 sta_modify_mask;
1015 int listen_interval;
1016 u16 aid;
1017 u16 peer_aid;
1018 u8 supported_rates_len;
1019 u8 plink_action;
1020 u8 plink_state;
1021 const struct ieee80211_ht_cap *ht_capa;
1022 const struct ieee80211_vht_cap *vht_capa;
1023 u8 uapsd_queues;
1024 u8 max_sp;
1025 enum nl80211_mesh_power_mode local_pm;
1026 u16 capability;
1027 const u8 *ext_capab;
1028 u8 ext_capab_len;
1029 const u8 *supported_channels;
1030 u8 supported_channels_len;
1031 const u8 *supported_oper_classes;
1032 u8 supported_oper_classes_len;
1033 u8 opmode_notif;
1034 bool opmode_notif_used;
1035 int support_p2p_ps;
1036 const struct ieee80211_he_cap_elem *he_capa;
1037 u8 he_capa_len;
1038};
1039
1040/**
1041 * struct station_del_parameters - station deletion parameters
1042 *
1043 * Used to delete a station entry (or all stations).
1044 *
1045 * @mac: MAC address of the station to remove or NULL to remove all stations
1046 * @subtype: Management frame subtype to use for indicating removal
1047 * (10 = Disassociation, 12 = Deauthentication)
1048 * @reason_code: Reason code for the Disassociation/Deauthentication frame
1049 */
1050struct station_del_parameters {
1051 const u8 *mac;
1052 u8 subtype;
1053 u16 reason_code;
1054};
1055
1056/**
1057 * enum cfg80211_station_type - the type of station being modified
1058 * @CFG80211_STA_AP_CLIENT: client of an AP interface
1059 * @CFG80211_STA_AP_CLIENT_UNASSOC: client of an AP interface that is still
1060 * unassociated (update properties for this type of client is permitted)
1061 * @CFG80211_STA_AP_MLME_CLIENT: client of an AP interface that has
1062 * the AP MLME in the device
1063 * @CFG80211_STA_AP_STA: AP station on managed interface
1064 * @CFG80211_STA_IBSS: IBSS station
1065 * @CFG80211_STA_TDLS_PEER_SETUP: TDLS peer on managed interface (dummy entry
1066 * while TDLS setup is in progress, it moves out of this state when
1067 * being marked authorized; use this only if TDLS with external setup is
1068 * supported/used)
1069 * @CFG80211_STA_TDLS_PEER_ACTIVE: TDLS peer on managed interface (active
1070 * entry that is operating, has been marked authorized by userspace)
1071 * @CFG80211_STA_MESH_PEER_KERNEL: peer on mesh interface (kernel managed)
1072 * @CFG80211_STA_MESH_PEER_USER: peer on mesh interface (user managed)
1073 */
1074enum cfg80211_station_type {
1075 CFG80211_STA_AP_CLIENT,
1076 CFG80211_STA_AP_CLIENT_UNASSOC,
1077 CFG80211_STA_AP_MLME_CLIENT,
1078 CFG80211_STA_AP_STA,
1079 CFG80211_STA_IBSS,
1080 CFG80211_STA_TDLS_PEER_SETUP,
1081 CFG80211_STA_TDLS_PEER_ACTIVE,
1082 CFG80211_STA_MESH_PEER_KERNEL,
1083 CFG80211_STA_MESH_PEER_USER,
1084};
1085
1086/**
1087 * cfg80211_check_station_change - validate parameter changes
1088 * @wiphy: the wiphy this operates on
1089 * @params: the new parameters for a station
1090 * @statype: the type of station being modified
1091 *
1092 * Utility function for the @change_station driver method. Call this function
1093 * with the appropriate station type looking up the station (and checking that
1094 * it exists). It will verify whether the station change is acceptable, and if
1095 * not will return an error code. Note that it may modify the parameters for
1096 * backward compatibility reasons, so don't use them before calling this.
1097 */
1098int cfg80211_check_station_change(struct wiphy *wiphy,
1099 struct station_parameters *params,
1100 enum cfg80211_station_type statype);
1101
1102/**
1103 * enum station_info_rate_flags - bitrate info flags
1104 *
1105 * Used by the driver to indicate the specific rate transmission
1106 * type for 802.11n transmissions.
1107 *
1108 * @RATE_INFO_FLAGS_MCS: mcs field filled with HT MCS
1109 * @RATE_INFO_FLAGS_VHT_MCS: mcs field filled with VHT MCS
1110 * @RATE_INFO_FLAGS_SHORT_GI: 400ns guard interval
1111 * @RATE_INFO_FLAGS_60G: 60GHz MCS
1112 * @RATE_INFO_FLAGS_HE_MCS: HE MCS information
1113 */
1114enum rate_info_flags {
1115 RATE_INFO_FLAGS_MCS = BIT(0),
1116 RATE_INFO_FLAGS_VHT_MCS = BIT(1),
1117 RATE_INFO_FLAGS_SHORT_GI = BIT(2),
1118 RATE_INFO_FLAGS_60G = BIT(3),
1119 RATE_INFO_FLAGS_HE_MCS = BIT(4),
1120};
1121
1122/**
1123 * enum rate_info_bw - rate bandwidth information
1124 *
1125 * Used by the driver to indicate the rate bandwidth.
1126 *
1127 * @RATE_INFO_BW_5: 5 MHz bandwidth
1128 * @RATE_INFO_BW_10: 10 MHz bandwidth
1129 * @RATE_INFO_BW_20: 20 MHz bandwidth
1130 * @RATE_INFO_BW_40: 40 MHz bandwidth
1131 * @RATE_INFO_BW_80: 80 MHz bandwidth
1132 * @RATE_INFO_BW_160: 160 MHz bandwidth
1133 * @RATE_INFO_BW_HE_RU: bandwidth determined by HE RU allocation
1134 */
1135enum rate_info_bw {
1136 RATE_INFO_BW_20 = 0,
1137 RATE_INFO_BW_5,
1138 RATE_INFO_BW_10,
1139 RATE_INFO_BW_40,
1140 RATE_INFO_BW_80,
1141 RATE_INFO_BW_160,
1142 RATE_INFO_BW_HE_RU,
1143};
1144
1145/**
1146 * struct rate_info - bitrate information
1147 *
1148 * Information about a receiving or transmitting bitrate
1149 *
1150 * @flags: bitflag of flags from &enum rate_info_flags
1151 * @mcs: mcs index if struct describes an HT/VHT/HE rate
1152 * @legacy: bitrate in 100kbit/s for 802.11abg
1153 * @nss: number of streams (VHT & HE only)
1154 * @bw: bandwidth (from &enum rate_info_bw)
1155 * @he_gi: HE guard interval (from &enum nl80211_he_gi)
1156 * @he_dcm: HE DCM value
1157 * @he_ru_alloc: HE RU allocation (from &enum nl80211_he_ru_alloc,
1158 * only valid if bw is %RATE_INFO_BW_HE_RU)
1159 */
1160struct rate_info {
1161 u8 flags;
1162 u8 mcs;
1163 u16 legacy;
1164 u8 nss;
1165 u8 bw;
1166 u8 he_gi;
1167 u8 he_dcm;
1168 u8 he_ru_alloc;
1169};
1170
1171/**
1172 * enum station_info_rate_flags - bitrate info flags
1173 *
1174 * Used by the driver to indicate the specific rate transmission
1175 * type for 802.11n transmissions.
1176 *
1177 * @BSS_PARAM_FLAGS_CTS_PROT: whether CTS protection is enabled
1178 * @BSS_PARAM_FLAGS_SHORT_PREAMBLE: whether short preamble is enabled
1179 * @BSS_PARAM_FLAGS_SHORT_SLOT_TIME: whether short slot time is enabled
1180 */
1181enum bss_param_flags {
1182 BSS_PARAM_FLAGS_CTS_PROT = 1<<0,
1183 BSS_PARAM_FLAGS_SHORT_PREAMBLE = 1<<1,
1184 BSS_PARAM_FLAGS_SHORT_SLOT_TIME = 1<<2,
1185};
1186
1187/**
1188 * struct sta_bss_parameters - BSS parameters for the attached station
1189 *
1190 * Information about the currently associated BSS
1191 *
1192 * @flags: bitflag of flags from &enum bss_param_flags
1193 * @dtim_period: DTIM period for the BSS
1194 * @beacon_interval: beacon interval
1195 */
1196struct sta_bss_parameters {
1197 u8 flags;
1198 u8 dtim_period;
1199 u16 beacon_interval;
1200};
1201
1202/**
1203 * struct cfg80211_txq_stats - TXQ statistics for this TID
1204 * @filled: bitmap of flags using the bits of &enum nl80211_txq_stats to
1205 * indicate the relevant values in this struct are filled
1206 * @backlog_bytes: total number of bytes currently backlogged
1207 * @backlog_packets: total number of packets currently backlogged
1208 * @flows: number of new flows seen
1209 * @drops: total number of packets dropped
1210 * @ecn_marks: total number of packets marked with ECN CE
1211 * @overlimit: number of drops due to queue space overflow
1212 * @overmemory: number of drops due to memory limit overflow
1213 * @collisions: number of hash collisions
1214 * @tx_bytes: total number of bytes dequeued
1215 * @tx_packets: total number of packets dequeued
1216 * @max_flows: maximum number of flows supported
1217 */
1218struct cfg80211_txq_stats {
1219 u32 filled;
1220 u32 backlog_bytes;
1221 u32 backlog_packets;
1222 u32 flows;
1223 u32 drops;
1224 u32 ecn_marks;
1225 u32 overlimit;
1226 u32 overmemory;
1227 u32 collisions;
1228 u32 tx_bytes;
1229 u32 tx_packets;
1230 u32 max_flows;
1231};
1232
1233/**
1234 * struct cfg80211_tid_stats - per-TID statistics
1235 * @filled: bitmap of flags using the bits of &enum nl80211_tid_stats to
1236 * indicate the relevant values in this struct are filled
1237 * @rx_msdu: number of received MSDUs
1238 * @tx_msdu: number of (attempted) transmitted MSDUs
1239 * @tx_msdu_retries: number of retries (not counting the first) for
1240 * transmitted MSDUs
1241 * @tx_msdu_failed: number of failed transmitted MSDUs
1242 * @txq_stats: TXQ statistics
1243 */
1244struct cfg80211_tid_stats {
1245 u32 filled;
1246 u64 rx_msdu;
1247 u64 tx_msdu;
1248 u64 tx_msdu_retries;
1249 u64 tx_msdu_failed;
1250 struct cfg80211_txq_stats txq_stats;
1251};
1252
1253#define IEEE80211_MAX_CHAINS 4
1254
1255/**
1256 * struct station_info - station information
1257 *
1258 * Station information filled by driver for get_station() and dump_station.
1259 *
1260 * @filled: bitflag of flags using the bits of &enum nl80211_sta_info to
1261 * indicate the relevant values in this struct for them
1262 * @connected_time: time(in secs) since a station is last connected
1263 * @inactive_time: time since last station activity (tx/rx) in milliseconds
1264 * @rx_bytes: bytes (size of MPDUs) received from this station
1265 * @tx_bytes: bytes (size of MPDUs) transmitted to this station
1266 * @llid: mesh local link id
1267 * @plid: mesh peer link id
1268 * @plink_state: mesh peer link state
1269 * @signal: The signal strength, type depends on the wiphy's signal_type.
1270 * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
1271 * @signal_avg: Average signal strength, type depends on the wiphy's signal_type.
1272 * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
1273 * @chains: bitmask for filled values in @chain_signal, @chain_signal_avg
1274 * @chain_signal: per-chain signal strength of last received packet in dBm
1275 * @chain_signal_avg: per-chain signal strength average in dBm
1276 * @txrate: current unicast bitrate from this station
1277 * @rxrate: current unicast bitrate to this station
1278 * @rx_packets: packets (MSDUs & MMPDUs) received from this station
1279 * @tx_packets: packets (MSDUs & MMPDUs) transmitted to this station
1280 * @tx_retries: cumulative retry counts (MPDUs)
1281 * @tx_failed: number of failed transmissions (MPDUs) (retries exceeded, no ACK)
1282 * @rx_dropped_misc: Dropped for un-specified reason.
1283 * @bss_param: current BSS parameters
1284 * @generation: generation number for nl80211 dumps.
1285 * This number should increase every time the list of stations
1286 * changes, i.e. when a station is added or removed, so that
1287 * userspace can tell whether it got a consistent snapshot.
1288 * @assoc_req_ies: IEs from (Re)Association Request.
1289 * This is used only when in AP mode with drivers that do not use
1290 * user space MLME/SME implementation. The information is provided for
1291 * the cfg80211_new_sta() calls to notify user space of the IEs.
1292 * @assoc_req_ies_len: Length of assoc_req_ies buffer in octets.
1293 * @sta_flags: station flags mask & values
1294 * @beacon_loss_count: Number of times beacon loss event has triggered.
1295 * @t_offset: Time offset of the station relative to this host.
1296 * @local_pm: local mesh STA power save mode
1297 * @peer_pm: peer mesh STA power save mode
1298 * @nonpeer_pm: non-peer mesh STA power save mode
1299 * @expected_throughput: expected throughput in kbps (including 802.11 headers)
1300 * towards this station.
1301 * @rx_beacon: number of beacons received from this peer
1302 * @rx_beacon_signal_avg: signal strength average (in dBm) for beacons received
1303 * from this peer
1304 * @rx_duration: aggregate PPDU duration(usecs) for all the frames from a peer
1305 * @pertid: per-TID statistics, see &struct cfg80211_tid_stats, using the last
1306 * (IEEE80211_NUM_TIDS) index for MSDUs not encapsulated in QoS-MPDUs.
1307 * Note that this doesn't use the @filled bit, but is used if non-NULL.
1308 * @ack_signal: signal strength (in dBm) of the last ACK frame.
1309 * @avg_ack_signal: average rssi value of ack packet for the no of msdu's has
1310 * been sent.
1311 */
1312struct station_info {
1313 u64 filled;
1314 u32 connected_time;
1315 u32 inactive_time;
1316 u64 rx_bytes;
1317 u64 tx_bytes;
1318 u16 llid;
1319 u16 plid;
1320 u8 plink_state;
1321 s8 signal;
1322 s8 signal_avg;
1323
1324 u8 chains;
1325 s8 chain_signal[IEEE80211_MAX_CHAINS];
1326 s8 chain_signal_avg[IEEE80211_MAX_CHAINS];
1327
1328 struct rate_info txrate;
1329 struct rate_info rxrate;
1330 u32 rx_packets;
1331 u32 tx_packets;
1332 u32 tx_retries;
1333 u32 tx_failed;
1334 u32 rx_dropped_misc;
1335 struct sta_bss_parameters bss_param;
1336 struct nl80211_sta_flag_update sta_flags;
1337
1338 int generation;
1339
1340 const u8 *assoc_req_ies;
1341 size_t assoc_req_ies_len;
1342
1343 u32 beacon_loss_count;
1344 s64 t_offset;
1345 enum nl80211_mesh_power_mode local_pm;
1346 enum nl80211_mesh_power_mode peer_pm;
1347 enum nl80211_mesh_power_mode nonpeer_pm;
1348
1349 u32 expected_throughput;
1350
1351 u64 rx_beacon;
1352 u64 rx_duration;
1353 u8 rx_beacon_signal_avg;
1354 struct cfg80211_tid_stats *pertid;
1355 s8 ack_signal;
1356 s8 avg_ack_signal;
1357};
1358
1359#if IS_ENABLED(CONFIG_CFG80211)
1360/**
1361 * cfg80211_get_station - retrieve information about a given station
1362 * @dev: the device where the station is supposed to be connected to
1363 * @mac_addr: the mac address of the station of interest
1364 * @sinfo: pointer to the structure to fill with the information
1365 *
1366 * Returns 0 on success and sinfo is filled with the available information
1367 * otherwise returns a negative error code and the content of sinfo has to be
1368 * considered undefined.
1369 */
1370int cfg80211_get_station(struct net_device *dev, const u8 *mac_addr,
1371 struct station_info *sinfo);
1372#else
1373static inline int cfg80211_get_station(struct net_device *dev,
1374 const u8 *mac_addr,
1375 struct station_info *sinfo)
1376{
1377 return -ENOENT;
1378}
1379#endif
1380
1381/**
1382 * enum monitor_flags - monitor flags
1383 *
1384 * Monitor interface configuration flags. Note that these must be the bits
1385 * according to the nl80211 flags.
1386 *
1387 * @MONITOR_FLAG_CHANGED: set if the flags were changed
1388 * @MONITOR_FLAG_FCSFAIL: pass frames with bad FCS
1389 * @MONITOR_FLAG_PLCPFAIL: pass frames with bad PLCP
1390 * @MONITOR_FLAG_CONTROL: pass control frames
1391 * @MONITOR_FLAG_OTHER_BSS: disable BSSID filtering
1392 * @MONITOR_FLAG_COOK_FRAMES: report frames after processing
1393 * @MONITOR_FLAG_ACTIVE: active monitor, ACKs frames on its MAC address
1394 */
1395enum monitor_flags {
1396 MONITOR_FLAG_CHANGED = 1<<__NL80211_MNTR_FLAG_INVALID,
1397 MONITOR_FLAG_FCSFAIL = 1<<NL80211_MNTR_FLAG_FCSFAIL,
1398 MONITOR_FLAG_PLCPFAIL = 1<<NL80211_MNTR_FLAG_PLCPFAIL,
1399 MONITOR_FLAG_CONTROL = 1<<NL80211_MNTR_FLAG_CONTROL,
1400 MONITOR_FLAG_OTHER_BSS = 1<<NL80211_MNTR_FLAG_OTHER_BSS,
1401 MONITOR_FLAG_COOK_FRAMES = 1<<NL80211_MNTR_FLAG_COOK_FRAMES,
1402 MONITOR_FLAG_ACTIVE = 1<<NL80211_MNTR_FLAG_ACTIVE,
1403};
1404
1405/**
1406 * enum mpath_info_flags - mesh path information flags
1407 *
1408 * Used by the driver to indicate which info in &struct mpath_info it has filled
1409 * in during get_station() or dump_station().
1410 *
1411 * @MPATH_INFO_FRAME_QLEN: @frame_qlen filled
1412 * @MPATH_INFO_SN: @sn filled
1413 * @MPATH_INFO_METRIC: @metric filled
1414 * @MPATH_INFO_EXPTIME: @exptime filled
1415 * @MPATH_INFO_DISCOVERY_TIMEOUT: @discovery_timeout filled
1416 * @MPATH_INFO_DISCOVERY_RETRIES: @discovery_retries filled
1417 * @MPATH_INFO_FLAGS: @flags filled
1418 */
1419enum mpath_info_flags {
1420 MPATH_INFO_FRAME_QLEN = BIT(0),
1421 MPATH_INFO_SN = BIT(1),
1422 MPATH_INFO_METRIC = BIT(2),
1423 MPATH_INFO_EXPTIME = BIT(3),
1424 MPATH_INFO_DISCOVERY_TIMEOUT = BIT(4),
1425 MPATH_INFO_DISCOVERY_RETRIES = BIT(5),
1426 MPATH_INFO_FLAGS = BIT(6),
1427};
1428
1429/**
1430 * struct mpath_info - mesh path information
1431 *
1432 * Mesh path information filled by driver for get_mpath() and dump_mpath().
1433 *
1434 * @filled: bitfield of flags from &enum mpath_info_flags
1435 * @frame_qlen: number of queued frames for this destination
1436 * @sn: target sequence number
1437 * @metric: metric (cost) of this mesh path
1438 * @exptime: expiration time for the mesh path from now, in msecs
1439 * @flags: mesh path flags
1440 * @discovery_timeout: total mesh path discovery timeout, in msecs
1441 * @discovery_retries: mesh path discovery retries
1442 * @generation: generation number for nl80211 dumps.
1443 * This number should increase every time the list of mesh paths
1444 * changes, i.e. when a station is added or removed, so that
1445 * userspace can tell whether it got a consistent snapshot.
1446 */
1447struct mpath_info {
1448 u32 filled;
1449 u32 frame_qlen;
1450 u32 sn;
1451 u32 metric;
1452 u32 exptime;
1453 u32 discovery_timeout;
1454 u8 discovery_retries;
1455 u8 flags;
1456
1457 int generation;
1458};
1459
1460/**
1461 * struct bss_parameters - BSS parameters
1462 *
1463 * Used to change BSS parameters (mainly for AP mode).
1464 *
1465 * @use_cts_prot: Whether to use CTS protection
1466 * (0 = no, 1 = yes, -1 = do not change)
1467 * @use_short_preamble: Whether the use of short preambles is allowed
1468 * (0 = no, 1 = yes, -1 = do not change)
1469 * @use_short_slot_time: Whether the use of short slot time is allowed
1470 * (0 = no, 1 = yes, -1 = do not change)
1471 * @basic_rates: basic rates in IEEE 802.11 format
1472 * (or NULL for no change)
1473 * @basic_rates_len: number of basic rates
1474 * @ap_isolate: do not forward packets between connected stations
1475 * @ht_opmode: HT Operation mode
1476 * (u16 = opmode, -1 = do not change)
1477 * @p2p_ctwindow: P2P CT Window (-1 = no change)
1478 * @p2p_opp_ps: P2P opportunistic PS (-1 = no change)
1479 */
1480struct bss_parameters {
1481 int use_cts_prot;
1482 int use_short_preamble;
1483 int use_short_slot_time;
1484 const u8 *basic_rates;
1485 u8 basic_rates_len;
1486 int ap_isolate;
1487 int ht_opmode;
1488 s8 p2p_ctwindow, p2p_opp_ps;
1489};
1490
1491/**
1492 * struct mesh_config - 802.11s mesh configuration
1493 *
1494 * These parameters can be changed while the mesh is active.
1495 *
1496 * @dot11MeshRetryTimeout: the initial retry timeout in millisecond units used
1497 * by the Mesh Peering Open message
1498 * @dot11MeshConfirmTimeout: the initial retry timeout in millisecond units
1499 * used by the Mesh Peering Open message
1500 * @dot11MeshHoldingTimeout: the confirm timeout in millisecond units used by
1501 * the mesh peering management to close a mesh peering
1502 * @dot11MeshMaxPeerLinks: the maximum number of peer links allowed on this
1503 * mesh interface
1504 * @dot11MeshMaxRetries: the maximum number of peer link open retries that can
1505 * be sent to establish a new peer link instance in a mesh
1506 * @dot11MeshTTL: the value of TTL field set at a source mesh STA
1507 * @element_ttl: the value of TTL field set at a mesh STA for path selection
1508 * elements
1509 * @auto_open_plinks: whether we should automatically open peer links when we
1510 * detect compatible mesh peers
1511 * @dot11MeshNbrOffsetMaxNeighbor: the maximum number of neighbors to
1512 * synchronize to for 11s default synchronization method
1513 * @dot11MeshHWMPmaxPREQretries: the number of action frames containing a PREQ
1514 * that an originator mesh STA can send to a particular path target
1515 * @path_refresh_time: how frequently to refresh mesh paths in milliseconds
1516 * @min_discovery_timeout: the minimum length of time to wait until giving up on
1517 * a path discovery in milliseconds
1518 * @dot11MeshHWMPactivePathTimeout: the time (in TUs) for which mesh STAs
1519 * receiving a PREQ shall consider the forwarding information from the
1520 * root to be valid. (TU = time unit)
1521 * @dot11MeshHWMPpreqMinInterval: the minimum interval of time (in TUs) during
1522 * which a mesh STA can send only one action frame containing a PREQ
1523 * element
1524 * @dot11MeshHWMPperrMinInterval: the minimum interval of time (in TUs) during
1525 * which a mesh STA can send only one Action frame containing a PERR
1526 * element
1527 * @dot11MeshHWMPnetDiameterTraversalTime: the interval of time (in TUs) that
1528 * it takes for an HWMP information element to propagate across the mesh
1529 * @dot11MeshHWMPRootMode: the configuration of a mesh STA as root mesh STA
1530 * @dot11MeshHWMPRannInterval: the interval of time (in TUs) between root
1531 * announcements are transmitted
1532 * @dot11MeshGateAnnouncementProtocol: whether to advertise that this mesh
1533 * station has access to a broader network beyond the MBSS. (This is
1534 * missnamed in draft 12.0: dot11MeshGateAnnouncementProtocol set to true
1535 * only means that the station will announce others it's a mesh gate, but
1536 * not necessarily using the gate announcement protocol. Still keeping the
1537 * same nomenclature to be in sync with the spec)
1538 * @dot11MeshForwarding: whether the Mesh STA is forwarding or non-forwarding
1539 * entity (default is TRUE - forwarding entity)
1540 * @rssi_threshold: the threshold for average signal strength of candidate
1541 * station to establish a peer link
1542 * @ht_opmode: mesh HT protection mode
1543 *
1544 * @dot11MeshHWMPactivePathToRootTimeout: The time (in TUs) for which mesh STAs
1545 * receiving a proactive PREQ shall consider the forwarding information to
1546 * the root mesh STA to be valid.
1547 *
1548 * @dot11MeshHWMProotInterval: The interval of time (in TUs) between proactive
1549 * PREQs are transmitted.
1550 * @dot11MeshHWMPconfirmationInterval: The minimum interval of time (in TUs)
1551 * during which a mesh STA can send only one Action frame containing
1552 * a PREQ element for root path confirmation.
1553 * @power_mode: The default mesh power save mode which will be the initial
1554 * setting for new peer links.
1555 * @dot11MeshAwakeWindowDuration: The duration in TUs the STA will remain awake
1556 * after transmitting its beacon.
1557 * @plink_timeout: If no tx activity is seen from a STA we've established
1558 * peering with for longer than this time (in seconds), then remove it
1559 * from the STA's list of peers. Default is 30 minutes.
1560 */
1561struct mesh_config {
1562 u16 dot11MeshRetryTimeout;
1563 u16 dot11MeshConfirmTimeout;
1564 u16 dot11MeshHoldingTimeout;
1565 u16 dot11MeshMaxPeerLinks;
1566 u8 dot11MeshMaxRetries;
1567 u8 dot11MeshTTL;
1568 u8 element_ttl;
1569 bool auto_open_plinks;
1570 u32 dot11MeshNbrOffsetMaxNeighbor;
1571 u8 dot11MeshHWMPmaxPREQretries;
1572 u32 path_refresh_time;
1573 u16 min_discovery_timeout;
1574 u32 dot11MeshHWMPactivePathTimeout;
1575 u16 dot11MeshHWMPpreqMinInterval;
1576 u16 dot11MeshHWMPperrMinInterval;
1577 u16 dot11MeshHWMPnetDiameterTraversalTime;
1578 u8 dot11MeshHWMPRootMode;
1579 u16 dot11MeshHWMPRannInterval;
1580 bool dot11MeshGateAnnouncementProtocol;
1581 bool dot11MeshForwarding;
1582 s32 rssi_threshold;
1583 u16 ht_opmode;
1584 u32 dot11MeshHWMPactivePathToRootTimeout;
1585 u16 dot11MeshHWMProotInterval;
1586 u16 dot11MeshHWMPconfirmationInterval;
1587 enum nl80211_mesh_power_mode power_mode;
1588 u16 dot11MeshAwakeWindowDuration;
1589 u32 plink_timeout;
1590};
1591
1592/**
1593 * struct mesh_setup - 802.11s mesh setup configuration
1594 * @chandef: defines the channel to use
1595 * @mesh_id: the mesh ID
1596 * @mesh_id_len: length of the mesh ID, at least 1 and at most 32 bytes
1597 * @sync_method: which synchronization method to use
1598 * @path_sel_proto: which path selection protocol to use
1599 * @path_metric: which metric to use
1600 * @auth_id: which authentication method this mesh is using
1601 * @ie: vendor information elements (optional)
1602 * @ie_len: length of vendor information elements
1603 * @is_authenticated: this mesh requires authentication
1604 * @is_secure: this mesh uses security
1605 * @user_mpm: userspace handles all MPM functions
1606 * @dtim_period: DTIM period to use
1607 * @beacon_interval: beacon interval to use
1608 * @mcast_rate: multicat rate for Mesh Node [6Mbps is the default for 802.11a]
1609 * @basic_rates: basic rates to use when creating the mesh
1610 * @beacon_rate: bitrate to be used for beacons
1611 * @userspace_handles_dfs: whether user space controls DFS operation, i.e.
1612 * changes the channel when a radar is detected. This is required
1613 * to operate on DFS channels.
1614 * @control_port_over_nl80211: TRUE if userspace expects to exchange control
1615 * port frames over NL80211 instead of the network interface.
1616 *
1617 * These parameters are fixed when the mesh is created.
1618 */
1619struct mesh_setup {
1620 struct cfg80211_chan_def chandef;
1621 const u8 *mesh_id;
1622 u8 mesh_id_len;
1623 u8 sync_method;
1624 u8 path_sel_proto;
1625 u8 path_metric;
1626 u8 auth_id;
1627 const u8 *ie;
1628 u8 ie_len;
1629 bool is_authenticated;
1630 bool is_secure;
1631 bool user_mpm;
1632 u8 dtim_period;
1633 u16 beacon_interval;
1634 int mcast_rate[NUM_NL80211_BANDS];
1635 u32 basic_rates;
1636 struct cfg80211_bitrate_mask beacon_rate;
1637 bool userspace_handles_dfs;
1638 bool control_port_over_nl80211;
1639};
1640
1641/**
1642 * struct ocb_setup - 802.11p OCB mode setup configuration
1643 * @chandef: defines the channel to use
1644 *
1645 * These parameters are fixed when connecting to the network
1646 */
1647struct ocb_setup {
1648 struct cfg80211_chan_def chandef;
1649};
1650
1651/**
1652 * struct ieee80211_txq_params - TX queue parameters
1653 * @ac: AC identifier
1654 * @txop: Maximum burst time in units of 32 usecs, 0 meaning disabled
1655 * @cwmin: Minimum contention window [a value of the form 2^n-1 in the range
1656 * 1..32767]
1657 * @cwmax: Maximum contention window [a value of the form 2^n-1 in the range
1658 * 1..32767]
1659 * @aifs: Arbitration interframe space [0..255]
1660 */
1661struct ieee80211_txq_params {
1662 enum nl80211_ac ac;
1663 u16 txop;
1664 u16 cwmin;
1665 u16 cwmax;
1666 u8 aifs;
1667};
1668
1669/**
1670 * DOC: Scanning and BSS list handling
1671 *
1672 * The scanning process itself is fairly simple, but cfg80211 offers quite
1673 * a bit of helper functionality. To start a scan, the scan operation will
1674 * be invoked with a scan definition. This scan definition contains the
1675 * channels to scan, and the SSIDs to send probe requests for (including the
1676 * wildcard, if desired). A passive scan is indicated by having no SSIDs to
1677 * probe. Additionally, a scan request may contain extra information elements
1678 * that should be added to the probe request. The IEs are guaranteed to be
1679 * well-formed, and will not exceed the maximum length the driver advertised
1680 * in the wiphy structure.
1681 *
1682 * When scanning finds a BSS, cfg80211 needs to be notified of that, because
1683 * it is responsible for maintaining the BSS list; the driver should not
1684 * maintain a list itself. For this notification, various functions exist.
1685 *
1686 * Since drivers do not maintain a BSS list, there are also a number of
1687 * functions to search for a BSS and obtain information about it from the
1688 * BSS structure cfg80211 maintains. The BSS list is also made available
1689 * to userspace.
1690 */
1691
1692/**
1693 * struct cfg80211_ssid - SSID description
1694 * @ssid: the SSID
1695 * @ssid_len: length of the ssid
1696 */
1697struct cfg80211_ssid {
1698 u8 ssid[IEEE80211_MAX_SSID_LEN];
1699 u8 ssid_len;
1700};
1701
1702/**
1703 * struct cfg80211_scan_info - information about completed scan
1704 * @scan_start_tsf: scan start time in terms of the TSF of the BSS that the
1705 * wireless device that requested the scan is connected to. If this
1706 * information is not available, this field is left zero.
1707 * @tsf_bssid: the BSSID according to which %scan_start_tsf is set.
1708 * @aborted: set to true if the scan was aborted for any reason,
1709 * userspace will be notified of that
1710 */
1711struct cfg80211_scan_info {
1712 u64 scan_start_tsf;
1713 u8 tsf_bssid[ETH_ALEN] __aligned(2);
1714 bool aborted;
1715};
1716
1717/**
1718 * struct cfg80211_scan_request - scan request description
1719 *
1720 * @ssids: SSIDs to scan for (active scan only)
1721 * @n_ssids: number of SSIDs
1722 * @channels: channels to scan on.
1723 * @n_channels: total number of channels to scan
1724 * @scan_width: channel width for scanning
1725 * @ie: optional information element(s) to add into Probe Request or %NULL
1726 * @ie_len: length of ie in octets
1727 * @duration: how long to listen on each channel, in TUs. If
1728 * %duration_mandatory is not set, this is the maximum dwell time and
1729 * the actual dwell time may be shorter.
1730 * @duration_mandatory: if set, the scan duration must be as specified by the
1731 * %duration field.
1732 * @flags: bit field of flags controlling operation
1733 * @rates: bitmap of rates to advertise for each band
1734 * @wiphy: the wiphy this was for
1735 * @scan_start: time (in jiffies) when the scan started
1736 * @wdev: the wireless device to scan for
1737 * @info: (internal) information about completed scan
1738 * @notified: (internal) scan request was notified as done or aborted
1739 * @no_cck: used to send probe requests at non CCK rate in 2GHz band
1740 * @mac_addr: MAC address used with randomisation
1741 * @mac_addr_mask: MAC address mask used with randomisation, bits that
1742 * are 0 in the mask should be randomised, bits that are 1 should
1743 * be taken from the @mac_addr
1744 * @bssid: BSSID to scan for (most commonly, the wildcard BSSID)
1745 */
1746struct cfg80211_scan_request {
1747 struct cfg80211_ssid *ssids;
1748 int n_ssids;
1749 u32 n_channels;
1750 enum nl80211_bss_scan_width scan_width;
1751 const u8 *ie;
1752 size_t ie_len;
1753 u16 duration;
1754 bool duration_mandatory;
1755 u32 flags;
1756
1757 u32 rates[NUM_NL80211_BANDS];
1758
1759 struct wireless_dev *wdev;
1760
1761 u8 mac_addr[ETH_ALEN] __aligned(2);
1762 u8 mac_addr_mask[ETH_ALEN] __aligned(2);
1763 u8 bssid[ETH_ALEN] __aligned(2);
1764
1765 /* internal */
1766 struct wiphy *wiphy;
1767 unsigned long scan_start;
1768 struct cfg80211_scan_info info;
1769 bool notified;
1770 bool no_cck;
1771
1772 /* keep last */
1773 struct ieee80211_channel *channels[0];
1774};
1775
1776static inline void get_random_mask_addr(u8 *buf, const u8 *addr, const u8 *mask)
1777{
1778 int i;
1779
1780 get_random_bytes(buf, ETH_ALEN);
1781 for (i = 0; i < ETH_ALEN; i++) {
1782 buf[i] &= ~mask[i];
1783 buf[i] |= addr[i] & mask[i];
1784 }
1785}
1786
1787/**
1788 * struct cfg80211_match_set - sets of attributes to match
1789 *
1790 * @ssid: SSID to be matched; may be zero-length in case of BSSID match
1791 * or no match (RSSI only)
1792 * @bssid: BSSID to be matched; may be all-zero BSSID in case of SSID match
1793 * or no match (RSSI only)
1794 * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
1795 */
1796struct cfg80211_match_set {
1797 struct cfg80211_ssid ssid;
1798 u8 bssid[ETH_ALEN];
1799 s32 rssi_thold;
1800};
1801
1802/**
1803 * struct cfg80211_sched_scan_plan - scan plan for scheduled scan
1804 *
1805 * @interval: interval between scheduled scan iterations. In seconds.
1806 * @iterations: number of scan iterations in this scan plan. Zero means
1807 * infinite loop.
1808 * The last scan plan will always have this parameter set to zero,
1809 * all other scan plans will have a finite number of iterations.
1810 */
1811struct cfg80211_sched_scan_plan {
1812 u32 interval;
1813 u32 iterations;
1814};
1815
1816/**
1817 * struct cfg80211_bss_select_adjust - BSS selection with RSSI adjustment.
1818 *
1819 * @band: band of BSS which should match for RSSI level adjustment.
1820 * @delta: value of RSSI level adjustment.
1821 */
1822struct cfg80211_bss_select_adjust {
1823 enum nl80211_band band;
1824 s8 delta;
1825};
1826
1827/**
1828 * struct cfg80211_sched_scan_request - scheduled scan request description
1829 *
1830 * @reqid: identifies this request.
1831 * @ssids: SSIDs to scan for (passed in the probe_reqs in active scans)
1832 * @n_ssids: number of SSIDs
1833 * @n_channels: total number of channels to scan
1834 * @scan_width: channel width for scanning
1835 * @ie: optional information element(s) to add into Probe Request or %NULL
1836 * @ie_len: length of ie in octets
1837 * @flags: bit field of flags controlling operation
1838 * @match_sets: sets of parameters to be matched for a scan result
1839 * entry to be considered valid and to be passed to the host
1840 * (others are filtered out).
1841 * If ommited, all results are passed.
1842 * @n_match_sets: number of match sets
1843 * @report_results: indicates that results were reported for this request
1844 * @wiphy: the wiphy this was for
1845 * @dev: the interface
1846 * @scan_start: start time of the scheduled scan
1847 * @channels: channels to scan
1848 * @min_rssi_thold: for drivers only supporting a single threshold, this
1849 * contains the minimum over all matchsets
1850 * @mac_addr: MAC address used with randomisation
1851 * @mac_addr_mask: MAC address mask used with randomisation, bits that
1852 * are 0 in the mask should be randomised, bits that are 1 should
1853 * be taken from the @mac_addr
1854 * @scan_plans: scan plans to be executed in this scheduled scan. Lowest
1855 * index must be executed first.
1856 * @n_scan_plans: number of scan plans, at least 1.
1857 * @rcu_head: RCU callback used to free the struct
1858 * @owner_nlportid: netlink portid of owner (if this should is a request
1859 * owned by a particular socket)
1860 * @nl_owner_dead: netlink owner socket was closed - this request be freed
1861 * @list: for keeping list of requests.
1862 * @delay: delay in seconds to use before starting the first scan
1863 * cycle. The driver may ignore this parameter and start
1864 * immediately (or at any other time), if this feature is not
1865 * supported.
1866 * @relative_rssi_set: Indicates whether @relative_rssi is set or not.
1867 * @relative_rssi: Relative RSSI threshold in dB to restrict scan result
1868 * reporting in connected state to cases where a matching BSS is determined
1869 * to have better or slightly worse RSSI than the current connected BSS.
1870 * The relative RSSI threshold values are ignored in disconnected state.
1871 * @rssi_adjust: delta dB of RSSI preference to be given to the BSSs that belong
1872 * to the specified band while deciding whether a better BSS is reported
1873 * using @relative_rssi. If delta is a negative number, the BSSs that
1874 * belong to the specified band will be penalized by delta dB in relative
1875 * comparisions.
1876 */
1877struct cfg80211_sched_scan_request {
1878 u64 reqid;
1879 struct cfg80211_ssid *ssids;
1880 int n_ssids;
1881 u32 n_channels;
1882 enum nl80211_bss_scan_width scan_width;
1883 const u8 *ie;
1884 size_t ie_len;
1885 u32 flags;
1886 struct cfg80211_match_set *match_sets;
1887 int n_match_sets;
1888 s32 min_rssi_thold;
1889 u32 delay;
1890 struct cfg80211_sched_scan_plan *scan_plans;
1891 int n_scan_plans;
1892
1893 u8 mac_addr[ETH_ALEN] __aligned(2);
1894 u8 mac_addr_mask[ETH_ALEN] __aligned(2);
1895
1896 bool relative_rssi_set;
1897 s8 relative_rssi;
1898 struct cfg80211_bss_select_adjust rssi_adjust;
1899
1900 /* internal */
1901 struct wiphy *wiphy;
1902 struct net_device *dev;
1903 unsigned long scan_start;
1904 bool report_results;
1905 struct rcu_head rcu_head;
1906 u32 owner_nlportid;
1907 bool nl_owner_dead;
1908 struct list_head list;
1909
1910 /* keep last */
1911 struct ieee80211_channel *channels[0];
1912};
1913
1914/**
1915 * enum cfg80211_signal_type - signal type
1916 *
1917 * @CFG80211_SIGNAL_TYPE_NONE: no signal strength information available
1918 * @CFG80211_SIGNAL_TYPE_MBM: signal strength in mBm (100*dBm)
1919 * @CFG80211_SIGNAL_TYPE_UNSPEC: signal strength, increasing from 0 through 100
1920 */
1921enum cfg80211_signal_type {
1922 CFG80211_SIGNAL_TYPE_NONE,
1923 CFG80211_SIGNAL_TYPE_MBM,
1924 CFG80211_SIGNAL_TYPE_UNSPEC,
1925};
1926
1927/**
1928 * struct cfg80211_inform_bss - BSS inform data
1929 * @chan: channel the frame was received on
1930 * @scan_width: scan width that was used
1931 * @signal: signal strength value, according to the wiphy's
1932 * signal type
1933 * @boottime_ns: timestamp (CLOCK_BOOTTIME) when the information was
1934 * received; should match the time when the frame was actually
1935 * received by the device (not just by the host, in case it was
1936 * buffered on the device) and be accurate to about 10ms.
1937 * If the frame isn't buffered, just passing the return value of
1938 * ktime_get_boot_ns() is likely appropriate.
1939 * @parent_tsf: the time at the start of reception of the first octet of the
1940 * timestamp field of the frame. The time is the TSF of the BSS specified
1941 * by %parent_bssid.
1942 * @parent_bssid: the BSS according to which %parent_tsf is set. This is set to
1943 * the BSS that requested the scan in which the beacon/probe was received.
1944 * @chains: bitmask for filled values in @chain_signal.
1945 * @chain_signal: per-chain signal strength of last received BSS in dBm.
1946 */
1947struct cfg80211_inform_bss {
1948 struct ieee80211_channel *chan;
1949 enum nl80211_bss_scan_width scan_width;
1950 s32 signal;
1951 u64 boottime_ns;
1952 u64 parent_tsf;
1953 u8 parent_bssid[ETH_ALEN] __aligned(2);
1954 u8 chains;
1955 s8 chain_signal[IEEE80211_MAX_CHAINS];
1956};
1957
1958/**
1959 * struct cfg80211_bss_ies - BSS entry IE data
1960 * @tsf: TSF contained in the frame that carried these IEs
1961 * @rcu_head: internal use, for freeing
1962 * @len: length of the IEs
1963 * @from_beacon: these IEs are known to come from a beacon
1964 * @data: IE data
1965 */
1966struct cfg80211_bss_ies {
1967 u64 tsf;
1968 struct rcu_head rcu_head;
1969 int len;
1970 bool from_beacon;
1971 u8 data[];
1972};
1973
1974/**
1975 * struct cfg80211_bss - BSS description
1976 *
1977 * This structure describes a BSS (which may also be a mesh network)
1978 * for use in scan results and similar.
1979 *
1980 * @channel: channel this BSS is on
1981 * @scan_width: width of the control channel
1982 * @bssid: BSSID of the BSS
1983 * @beacon_interval: the beacon interval as from the frame
1984 * @capability: the capability field in host byte order
1985 * @ies: the information elements (Note that there is no guarantee that these
1986 * are well-formed!); this is a pointer to either the beacon_ies or
1987 * proberesp_ies depending on whether Probe Response frame has been
1988 * received. It is always non-%NULL.
1989 * @beacon_ies: the information elements from the last Beacon frame
1990 * (implementation note: if @hidden_beacon_bss is set this struct doesn't
1991 * own the beacon_ies, but they're just pointers to the ones from the
1992 * @hidden_beacon_bss struct)
1993 * @proberesp_ies: the information elements from the last Probe Response frame
1994 * @hidden_beacon_bss: in case this BSS struct represents a probe response from
1995 * a BSS that hides the SSID in its beacon, this points to the BSS struct
1996 * that holds the beacon data. @beacon_ies is still valid, of course, and
1997 * points to the same data as hidden_beacon_bss->beacon_ies in that case.
1998 * @signal: signal strength value (type depends on the wiphy's signal_type)
1999 * @chains: bitmask for filled values in @chain_signal.
2000 * @chain_signal: per-chain signal strength of last received BSS in dBm.
2001 * @priv: private area for driver use, has at least wiphy->bss_priv_size bytes
2002 */
2003struct cfg80211_bss {
2004 struct ieee80211_channel *channel;
2005 enum nl80211_bss_scan_width scan_width;
2006
2007 const struct cfg80211_bss_ies __rcu *ies;
2008 const struct cfg80211_bss_ies __rcu *beacon_ies;
2009 const struct cfg80211_bss_ies __rcu *proberesp_ies;
2010
2011 struct cfg80211_bss *hidden_beacon_bss;
2012
2013 s32 signal;
2014
2015 u16 beacon_interval;
2016 u16 capability;
2017
2018 u8 bssid[ETH_ALEN];
2019 u8 chains;
2020 s8 chain_signal[IEEE80211_MAX_CHAINS];
2021
2022 u8 priv[0] __aligned(sizeof(void *));
2023};
2024
2025/**
2026 * ieee80211_bss_get_ie - find IE with given ID
2027 * @bss: the bss to search
2028 * @ie: the IE ID
2029 *
2030 * Note that the return value is an RCU-protected pointer, so
2031 * rcu_read_lock() must be held when calling this function.
2032 * Return: %NULL if not found.
2033 */
2034const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie);
2035
2036
2037/**
2038 * struct cfg80211_auth_request - Authentication request data
2039 *
2040 * This structure provides information needed to complete IEEE 802.11
2041 * authentication.
2042 *
2043 * @bss: The BSS to authenticate with, the callee must obtain a reference
2044 * to it if it needs to keep it.
2045 * @auth_type: Authentication type (algorithm)
2046 * @ie: Extra IEs to add to Authentication frame or %NULL
2047 * @ie_len: Length of ie buffer in octets
2048 * @key_len: length of WEP key for shared key authentication
2049 * @key_idx: index of WEP key for shared key authentication
2050 * @key: WEP key for shared key authentication
2051 * @auth_data: Fields and elements in Authentication frames. This contains
2052 * the authentication frame body (non-IE and IE data), excluding the
2053 * Authentication algorithm number, i.e., starting at the Authentication
2054 * transaction sequence number field.
2055 * @auth_data_len: Length of auth_data buffer in octets
2056 */
2057struct cfg80211_auth_request {
2058 struct cfg80211_bss *bss;
2059 const u8 *ie;
2060 size_t ie_len;
2061 enum nl80211_auth_type auth_type;
2062 const u8 *key;
2063 u8 key_len, key_idx;
2064 const u8 *auth_data;
2065 size_t auth_data_len;
2066};
2067
2068/**
2069 * enum cfg80211_assoc_req_flags - Over-ride default behaviour in association.
2070 *
2071 * @ASSOC_REQ_DISABLE_HT: Disable HT (802.11n)
2072 * @ASSOC_REQ_DISABLE_VHT: Disable VHT
2073 * @ASSOC_REQ_USE_RRM: Declare RRM capability in this association
2074 * @CONNECT_REQ_EXTERNAL_AUTH_SUPPORT: User space indicates external
2075 * authentication capability. Drivers can offload authentication to
2076 * userspace if this flag is set. Only applicable for cfg80211_connect()
2077 * request (connect callback).
2078 */
2079enum cfg80211_assoc_req_flags {
2080 ASSOC_REQ_DISABLE_HT = BIT(0),
2081 ASSOC_REQ_DISABLE_VHT = BIT(1),
2082 ASSOC_REQ_USE_RRM = BIT(2),
2083 CONNECT_REQ_EXTERNAL_AUTH_SUPPORT = BIT(3),
2084};
2085
2086/**
2087 * struct cfg80211_assoc_request - (Re)Association request data
2088 *
2089 * This structure provides information needed to complete IEEE 802.11
2090 * (re)association.
2091 * @bss: The BSS to associate with. If the call is successful the driver is
2092 * given a reference that it must give back to cfg80211_send_rx_assoc()
2093 * or to cfg80211_assoc_timeout(). To ensure proper refcounting, new
2094 * association requests while already associating must be rejected.
2095 * @ie: Extra IEs to add to (Re)Association Request frame or %NULL
2096 * @ie_len: Length of ie buffer in octets
2097 * @use_mfp: Use management frame protection (IEEE 802.11w) in this association
2098 * @crypto: crypto settings
2099 * @prev_bssid: previous BSSID, if not %NULL use reassociate frame. This is used
2100 * to indicate a request to reassociate within the ESS instead of a request
2101 * do the initial association with the ESS. When included, this is set to
2102 * the BSSID of the current association, i.e., to the value that is
2103 * included in the Current AP address field of the Reassociation Request
2104 * frame.
2105 * @flags: See &enum cfg80211_assoc_req_flags
2106 * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
2107 * will be used in ht_capa. Un-supported values will be ignored.
2108 * @ht_capa_mask: The bits of ht_capa which are to be used.
2109 * @vht_capa: VHT capability override
2110 * @vht_capa_mask: VHT capability mask indicating which fields to use
2111 * @fils_kek: FILS KEK for protecting (Re)Association Request/Response frame or
2112 * %NULL if FILS is not used.
2113 * @fils_kek_len: Length of fils_kek in octets
2114 * @fils_nonces: FILS nonces (part of AAD) for protecting (Re)Association
2115 * Request/Response frame or %NULL if FILS is not used. This field starts
2116 * with 16 octets of STA Nonce followed by 16 octets of AP Nonce.
2117 */
2118struct cfg80211_assoc_request {
2119 struct cfg80211_bss *bss;
2120 const u8 *ie, *prev_bssid;
2121 size_t ie_len;
2122 struct cfg80211_crypto_settings crypto;
2123 bool use_mfp;
2124 u32 flags;
2125 struct ieee80211_ht_cap ht_capa;
2126 struct ieee80211_ht_cap ht_capa_mask;
2127 struct ieee80211_vht_cap vht_capa, vht_capa_mask;
2128 const u8 *fils_kek;
2129 size_t fils_kek_len;
2130 const u8 *fils_nonces;
2131};
2132
2133/**
2134 * struct cfg80211_deauth_request - Deauthentication request data
2135 *
2136 * This structure provides information needed to complete IEEE 802.11
2137 * deauthentication.
2138 *
2139 * @bssid: the BSSID of the BSS to deauthenticate from
2140 * @ie: Extra IEs to add to Deauthentication frame or %NULL
2141 * @ie_len: Length of ie buffer in octets
2142 * @reason_code: The reason code for the deauthentication
2143 * @local_state_change: if set, change local state only and
2144 * do not set a deauth frame
2145 */
2146struct cfg80211_deauth_request {
2147 const u8 *bssid;
2148 const u8 *ie;
2149 size_t ie_len;
2150 u16 reason_code;
2151 bool local_state_change;
2152};
2153
2154/**
2155 * struct cfg80211_disassoc_request - Disassociation request data
2156 *
2157 * This structure provides information needed to complete IEEE 802.11
2158 * disassociation.
2159 *
2160 * @bss: the BSS to disassociate from
2161 * @ie: Extra IEs to add to Disassociation frame or %NULL
2162 * @ie_len: Length of ie buffer in octets
2163 * @reason_code: The reason code for the disassociation
2164 * @local_state_change: This is a request for a local state only, i.e., no
2165 * Disassociation frame is to be transmitted.
2166 */
2167struct cfg80211_disassoc_request {
2168 struct cfg80211_bss *bss;
2169 const u8 *ie;
2170 size_t ie_len;
2171 u16 reason_code;
2172 bool local_state_change;
2173};
2174
2175/**
2176 * struct cfg80211_ibss_params - IBSS parameters
2177 *
2178 * This structure defines the IBSS parameters for the join_ibss()
2179 * method.
2180 *
2181 * @ssid: The SSID, will always be non-null.
2182 * @ssid_len: The length of the SSID, will always be non-zero.
2183 * @bssid: Fixed BSSID requested, maybe be %NULL, if set do not
2184 * search for IBSSs with a different BSSID.
2185 * @chandef: defines the channel to use if no other IBSS to join can be found
2186 * @channel_fixed: The channel should be fixed -- do not search for
2187 * IBSSs to join on other channels.
2188 * @ie: information element(s) to include in the beacon
2189 * @ie_len: length of that
2190 * @beacon_interval: beacon interval to use
2191 * @privacy: this is a protected network, keys will be configured
2192 * after joining
2193 * @control_port: whether user space controls IEEE 802.1X port, i.e.,
2194 * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is
2195 * required to assume that the port is unauthorized until authorized by
2196 * user space. Otherwise, port is marked authorized by default.
2197 * @control_port_over_nl80211: TRUE if userspace expects to exchange control
2198 * port frames over NL80211 instead of the network interface.
2199 * @userspace_handles_dfs: whether user space controls DFS operation, i.e.
2200 * changes the channel when a radar is detected. This is required
2201 * to operate on DFS channels.
2202 * @basic_rates: bitmap of basic rates to use when creating the IBSS
2203 * @mcast_rate: per-band multicast rate index + 1 (0: disabled)
2204 * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
2205 * will be used in ht_capa. Un-supported values will be ignored.
2206 * @ht_capa_mask: The bits of ht_capa which are to be used.
2207 * @wep_keys: static WEP keys, if not NULL points to an array of
2208 * CFG80211_MAX_WEP_KEYS WEP keys
2209 * @wep_tx_key: key index (0..3) of the default TX static WEP key
2210 */
2211struct cfg80211_ibss_params {
2212 const u8 *ssid;
2213 const u8 *bssid;
2214 struct cfg80211_chan_def chandef;
2215 const u8 *ie;
2216 u8 ssid_len, ie_len;
2217 u16 beacon_interval;
2218 u32 basic_rates;
2219 bool channel_fixed;
2220 bool privacy;
2221 bool control_port;
2222 bool control_port_over_nl80211;
2223 bool userspace_handles_dfs;
2224 int mcast_rate[NUM_NL80211_BANDS];
2225 struct ieee80211_ht_cap ht_capa;
2226 struct ieee80211_ht_cap ht_capa_mask;
2227 struct key_params *wep_keys;
2228 int wep_tx_key;
2229};
2230
2231/**
2232 * struct cfg80211_bss_selection - connection parameters for BSS selection.
2233 *
2234 * @behaviour: requested BSS selection behaviour.
2235 * @param: parameters for requestion behaviour.
2236 * @band_pref: preferred band for %NL80211_BSS_SELECT_ATTR_BAND_PREF.
2237 * @adjust: parameters for %NL80211_BSS_SELECT_ATTR_RSSI_ADJUST.
2238 */
2239struct cfg80211_bss_selection {
2240 enum nl80211_bss_select_attr behaviour;
2241 union {
2242 enum nl80211_band band_pref;
2243 struct cfg80211_bss_select_adjust adjust;
2244 } param;
2245};
2246
2247/**
2248 * struct cfg80211_connect_params - Connection parameters
2249 *
2250 * This structure provides information needed to complete IEEE 802.11
2251 * authentication and association.
2252 *
2253 * @channel: The channel to use or %NULL if not specified (auto-select based
2254 * on scan results)
2255 * @channel_hint: The channel of the recommended BSS for initial connection or
2256 * %NULL if not specified
2257 * @bssid: The AP BSSID or %NULL if not specified (auto-select based on scan
2258 * results)
2259 * @bssid_hint: The recommended AP BSSID for initial connection to the BSS or
2260 * %NULL if not specified. Unlike the @bssid parameter, the driver is
2261 * allowed to ignore this @bssid_hint if it has knowledge of a better BSS
2262 * to use.
2263 * @ssid: SSID
2264 * @ssid_len: Length of ssid in octets
2265 * @auth_type: Authentication type (algorithm)
2266 * @ie: IEs for association request
2267 * @ie_len: Length of assoc_ie in octets
2268 * @privacy: indicates whether privacy-enabled APs should be used
2269 * @mfp: indicate whether management frame protection is used
2270 * @crypto: crypto settings
2271 * @key_len: length of WEP key for shared key authentication
2272 * @key_idx: index of WEP key for shared key authentication
2273 * @key: WEP key for shared key authentication
2274 * @flags: See &enum cfg80211_assoc_req_flags
2275 * @bg_scan_period: Background scan period in seconds
2276 * or -1 to indicate that default value is to be used.
2277 * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
2278 * will be used in ht_capa. Un-supported values will be ignored.
2279 * @ht_capa_mask: The bits of ht_capa which are to be used.
2280 * @vht_capa: VHT Capability overrides
2281 * @vht_capa_mask: The bits of vht_capa which are to be used.
2282 * @pbss: if set, connect to a PCP instead of AP. Valid for DMG
2283 * networks.
2284 * @bss_select: criteria to be used for BSS selection.
2285 * @prev_bssid: previous BSSID, if not %NULL use reassociate frame. This is used
2286 * to indicate a request to reassociate within the ESS instead of a request
2287 * do the initial association with the ESS. When included, this is set to
2288 * the BSSID of the current association, i.e., to the value that is
2289 * included in the Current AP address field of the Reassociation Request
2290 * frame.
2291 * @fils_erp_username: EAP re-authentication protocol (ERP) username part of the
2292 * NAI or %NULL if not specified. This is used to construct FILS wrapped
2293 * data IE.
2294 * @fils_erp_username_len: Length of @fils_erp_username in octets.
2295 * @fils_erp_realm: EAP re-authentication protocol (ERP) realm part of NAI or
2296 * %NULL if not specified. This specifies the domain name of ER server and
2297 * is used to construct FILS wrapped data IE.
2298 * @fils_erp_realm_len: Length of @fils_erp_realm in octets.
2299 * @fils_erp_next_seq_num: The next sequence number to use in the FILS ERP
2300 * messages. This is also used to construct FILS wrapped data IE.
2301 * @fils_erp_rrk: ERP re-authentication Root Key (rRK) used to derive additional
2302 * keys in FILS or %NULL if not specified.
2303 * @fils_erp_rrk_len: Length of @fils_erp_rrk in octets.
2304 * @want_1x: indicates user-space supports and wants to use 802.1X driver
2305 * offload of 4-way handshake.
2306 */
2307struct cfg80211_connect_params {
2308 struct ieee80211_channel *channel;
2309 struct ieee80211_channel *channel_hint;
2310 const u8 *bssid;
2311 const u8 *bssid_hint;
2312 const u8 *ssid;
2313 size_t ssid_len;
2314 enum nl80211_auth_type auth_type;
2315 const u8 *ie;
2316 size_t ie_len;
2317 bool privacy;
2318 enum nl80211_mfp mfp;
2319 struct cfg80211_crypto_settings crypto;
2320 const u8 *key;
2321 u8 key_len, key_idx;
2322 u32 flags;
2323 int bg_scan_period;
2324 struct ieee80211_ht_cap ht_capa;
2325 struct ieee80211_ht_cap ht_capa_mask;
2326 struct ieee80211_vht_cap vht_capa;
2327 struct ieee80211_vht_cap vht_capa_mask;
2328 bool pbss;
2329 struct cfg80211_bss_selection bss_select;
2330 const u8 *prev_bssid;
2331 const u8 *fils_erp_username;
2332 size_t fils_erp_username_len;
2333 const u8 *fils_erp_realm;
2334 size_t fils_erp_realm_len;
2335 u16 fils_erp_next_seq_num;
2336 const u8 *fils_erp_rrk;
2337 size_t fils_erp_rrk_len;
2338 bool want_1x;
2339};
2340
2341/**
2342 * enum cfg80211_connect_params_changed - Connection parameters being updated
2343 *
2344 * This enum provides information of all connect parameters that
2345 * have to be updated as part of update_connect_params() call.
2346 *
2347 * @UPDATE_ASSOC_IES: Indicates whether association request IEs are updated
2348 * @UPDATE_FILS_ERP_INFO: Indicates that FILS connection parameters (realm,
2349 * username, erp sequence number and rrk) are updated
2350 * @UPDATE_AUTH_TYPE: Indicates that authentication type is updated
2351 */
2352enum cfg80211_connect_params_changed {
2353 UPDATE_ASSOC_IES = BIT(0),
2354 UPDATE_FILS_ERP_INFO = BIT(1),
2355 UPDATE_AUTH_TYPE = BIT(2),
2356};
2357
2358/**
2359 * enum wiphy_params_flags - set_wiphy_params bitfield values
2360 * @WIPHY_PARAM_RETRY_SHORT: wiphy->retry_short has changed
2361 * @WIPHY_PARAM_RETRY_LONG: wiphy->retry_long has changed
2362 * @WIPHY_PARAM_FRAG_THRESHOLD: wiphy->frag_threshold has changed
2363 * @WIPHY_PARAM_RTS_THRESHOLD: wiphy->rts_threshold has changed
2364 * @WIPHY_PARAM_COVERAGE_CLASS: coverage class changed
2365 * @WIPHY_PARAM_DYN_ACK: dynack has been enabled
2366 * @WIPHY_PARAM_TXQ_LIMIT: TXQ packet limit has been changed
2367 * @WIPHY_PARAM_TXQ_MEMORY_LIMIT: TXQ memory limit has been changed
2368 * @WIPHY_PARAM_TXQ_QUANTUM: TXQ scheduler quantum
2369 */
2370enum wiphy_params_flags {
2371 WIPHY_PARAM_RETRY_SHORT = 1 << 0,
2372 WIPHY_PARAM_RETRY_LONG = 1 << 1,
2373 WIPHY_PARAM_FRAG_THRESHOLD = 1 << 2,
2374 WIPHY_PARAM_RTS_THRESHOLD = 1 << 3,
2375 WIPHY_PARAM_COVERAGE_CLASS = 1 << 4,
2376 WIPHY_PARAM_DYN_ACK = 1 << 5,
2377 WIPHY_PARAM_TXQ_LIMIT = 1 << 6,
2378 WIPHY_PARAM_TXQ_MEMORY_LIMIT = 1 << 7,
2379 WIPHY_PARAM_TXQ_QUANTUM = 1 << 8,
2380};
2381
2382/**
2383 * struct cfg80211_pmksa - PMK Security Association
2384 *
2385 * This structure is passed to the set/del_pmksa() method for PMKSA
2386 * caching.
2387 *
2388 * @bssid: The AP's BSSID (may be %NULL).
2389 * @pmkid: The identifier to refer a PMKSA.
2390 * @pmk: The PMK for the PMKSA identified by @pmkid. This is used for key
2391 * derivation by a FILS STA. Otherwise, %NULL.
2392 * @pmk_len: Length of the @pmk. The length of @pmk can differ depending on
2393 * the hash algorithm used to generate this.
2394 * @ssid: SSID to specify the ESS within which a PMKSA is valid when using FILS
2395 * cache identifier (may be %NULL).
2396 * @ssid_len: Length of the @ssid in octets.
2397 * @cache_id: 2-octet cache identifier advertized by a FILS AP identifying the
2398 * scope of PMKSA. This is valid only if @ssid_len is non-zero (may be
2399 * %NULL).
2400 */
2401struct cfg80211_pmksa {
2402 const u8 *bssid;
2403 const u8 *pmkid;
2404 const u8 *pmk;
2405 size_t pmk_len;
2406 const u8 *ssid;
2407 size_t ssid_len;
2408 const u8 *cache_id;
2409};
2410
2411/**
2412 * struct cfg80211_pkt_pattern - packet pattern
2413 * @mask: bitmask where to match pattern and where to ignore bytes,
2414 * one bit per byte, in same format as nl80211
2415 * @pattern: bytes to match where bitmask is 1
2416 * @pattern_len: length of pattern (in bytes)
2417 * @pkt_offset: packet offset (in bytes)
2418 *
2419 * Internal note: @mask and @pattern are allocated in one chunk of
2420 * memory, free @mask only!
2421 */
2422struct cfg80211_pkt_pattern {
2423 const u8 *mask, *pattern;
2424 int pattern_len;
2425 int pkt_offset;
2426};
2427
2428/**
2429 * struct cfg80211_wowlan_tcp - TCP connection parameters
2430 *
2431 * @sock: (internal) socket for source port allocation
2432 * @src: source IP address
2433 * @dst: destination IP address
2434 * @dst_mac: destination MAC address
2435 * @src_port: source port
2436 * @dst_port: destination port
2437 * @payload_len: data payload length
2438 * @payload: data payload buffer
2439 * @payload_seq: payload sequence stamping configuration
2440 * @data_interval: interval at which to send data packets
2441 * @wake_len: wakeup payload match length
2442 * @wake_data: wakeup payload match data
2443 * @wake_mask: wakeup payload match mask
2444 * @tokens_size: length of the tokens buffer
2445 * @payload_tok: payload token usage configuration
2446 */
2447struct cfg80211_wowlan_tcp {
2448 struct socket *sock;
2449 __be32 src, dst;
2450 u16 src_port, dst_port;
2451 u8 dst_mac[ETH_ALEN];
2452 int payload_len;
2453 const u8 *payload;
2454 struct nl80211_wowlan_tcp_data_seq payload_seq;
2455 u32 data_interval;
2456 u32 wake_len;
2457 const u8 *wake_data, *wake_mask;
2458 u32 tokens_size;
2459 /* must be last, variable member */
2460 struct nl80211_wowlan_tcp_data_token payload_tok;
2461};
2462
2463/**
2464 * struct cfg80211_wowlan - Wake on Wireless-LAN support info
2465 *
2466 * This structure defines the enabled WoWLAN triggers for the device.
2467 * @any: wake up on any activity -- special trigger if device continues
2468 * operating as normal during suspend
2469 * @disconnect: wake up if getting disconnected
2470 * @magic_pkt: wake up on receiving magic packet
2471 * @patterns: wake up on receiving packet matching a pattern
2472 * @n_patterns: number of patterns
2473 * @gtk_rekey_failure: wake up on GTK rekey failure
2474 * @eap_identity_req: wake up on EAP identity request packet
2475 * @four_way_handshake: wake up on 4-way handshake
2476 * @rfkill_release: wake up when rfkill is released
2477 * @tcp: TCP connection establishment/wakeup parameters, see nl80211.h.
2478 * NULL if not configured.
2479 * @nd_config: configuration for the scan to be used for net detect wake.
2480 */
2481struct cfg80211_wowlan {
2482 bool any, disconnect, magic_pkt, gtk_rekey_failure,
2483 eap_identity_req, four_way_handshake,
2484 rfkill_release;
2485 struct cfg80211_pkt_pattern *patterns;
2486 struct cfg80211_wowlan_tcp *tcp;
2487 int n_patterns;
2488 struct cfg80211_sched_scan_request *nd_config;
2489};
2490
2491/**
2492 * struct cfg80211_coalesce_rules - Coalesce rule parameters
2493 *
2494 * This structure defines coalesce rule for the device.
2495 * @delay: maximum coalescing delay in msecs.
2496 * @condition: condition for packet coalescence.
2497 * see &enum nl80211_coalesce_condition.
2498 * @patterns: array of packet patterns
2499 * @n_patterns: number of patterns
2500 */
2501struct cfg80211_coalesce_rules {
2502 int delay;
2503 enum nl80211_coalesce_condition condition;
2504 struct cfg80211_pkt_pattern *patterns;
2505 int n_patterns;
2506};
2507
2508/**
2509 * struct cfg80211_coalesce - Packet coalescing settings
2510 *
2511 * This structure defines coalescing settings.
2512 * @rules: array of coalesce rules
2513 * @n_rules: number of rules
2514 */
2515struct cfg80211_coalesce {
2516 struct cfg80211_coalesce_rules *rules;
2517 int n_rules;
2518};
2519
2520/**
2521 * struct cfg80211_wowlan_nd_match - information about the match
2522 *
2523 * @ssid: SSID of the match that triggered the wake up
2524 * @n_channels: Number of channels where the match occurred. This
2525 * value may be zero if the driver can't report the channels.
2526 * @channels: center frequencies of the channels where a match
2527 * occurred (in MHz)
2528 */
2529struct cfg80211_wowlan_nd_match {
2530 struct cfg80211_ssid ssid;
2531 int n_channels;
2532 u32 channels[];
2533};
2534
2535/**
2536 * struct cfg80211_wowlan_nd_info - net detect wake up information
2537 *
2538 * @n_matches: Number of match information instances provided in
2539 * @matches. This value may be zero if the driver can't provide
2540 * match information.
2541 * @matches: Array of pointers to matches containing information about
2542 * the matches that triggered the wake up.
2543 */
2544struct cfg80211_wowlan_nd_info {
2545 int n_matches;
2546 struct cfg80211_wowlan_nd_match *matches[];
2547};
2548
2549/**
2550 * struct cfg80211_wowlan_wakeup - wakeup report
2551 * @disconnect: woke up by getting disconnected
2552 * @magic_pkt: woke up by receiving magic packet
2553 * @gtk_rekey_failure: woke up by GTK rekey failure
2554 * @eap_identity_req: woke up by EAP identity request packet
2555 * @four_way_handshake: woke up by 4-way handshake
2556 * @rfkill_release: woke up by rfkill being released
2557 * @pattern_idx: pattern that caused wakeup, -1 if not due to pattern
2558 * @packet_present_len: copied wakeup packet data
2559 * @packet_len: original wakeup packet length
2560 * @packet: The packet causing the wakeup, if any.
2561 * @packet_80211: For pattern match, magic packet and other data
2562 * frame triggers an 802.3 frame should be reported, for
2563 * disconnect due to deauth 802.11 frame. This indicates which
2564 * it is.
2565 * @tcp_match: TCP wakeup packet received
2566 * @tcp_connlost: TCP connection lost or failed to establish
2567 * @tcp_nomoretokens: TCP data ran out of tokens
2568 * @net_detect: if not %NULL, woke up because of net detect
2569 */
2570struct cfg80211_wowlan_wakeup {
2571 bool disconnect, magic_pkt, gtk_rekey_failure,
2572 eap_identity_req, four_way_handshake,
2573 rfkill_release, packet_80211,
2574 tcp_match, tcp_connlost, tcp_nomoretokens;
2575 s32 pattern_idx;
2576 u32 packet_present_len, packet_len;
2577 const void *packet;
2578 struct cfg80211_wowlan_nd_info *net_detect;
2579};
2580
2581/**
2582 * struct cfg80211_gtk_rekey_data - rekey data
2583 * @kek: key encryption key (NL80211_KEK_LEN bytes)
2584 * @kck: key confirmation key (NL80211_KCK_LEN bytes)
2585 * @replay_ctr: replay counter (NL80211_REPLAY_CTR_LEN bytes)
2586 */
2587struct cfg80211_gtk_rekey_data {
2588 const u8 *kek, *kck, *replay_ctr;
2589};
2590
2591/**
2592 * struct cfg80211_update_ft_ies_params - FT IE Information
2593 *
2594 * This structure provides information needed to update the fast transition IE
2595 *
2596 * @md: The Mobility Domain ID, 2 Octet value
2597 * @ie: Fast Transition IEs
2598 * @ie_len: Length of ft_ie in octets
2599 */
2600struct cfg80211_update_ft_ies_params {
2601 u16 md;
2602 const u8 *ie;
2603 size_t ie_len;
2604};
2605
2606/**
2607 * struct cfg80211_mgmt_tx_params - mgmt tx parameters
2608 *
2609 * This structure provides information needed to transmit a mgmt frame
2610 *
2611 * @chan: channel to use
2612 * @offchan: indicates wether off channel operation is required
2613 * @wait: duration for ROC
2614 * @buf: buffer to transmit
2615 * @len: buffer length
2616 * @no_cck: don't use cck rates for this frame
2617 * @dont_wait_for_ack: tells the low level not to wait for an ack
2618 * @n_csa_offsets: length of csa_offsets array
2619 * @csa_offsets: array of all the csa offsets in the frame
2620 */
2621struct cfg80211_mgmt_tx_params {
2622 struct ieee80211_channel *chan;
2623 bool offchan;
2624 unsigned int wait;
2625 const u8 *buf;
2626 size_t len;
2627 bool no_cck;
2628 bool dont_wait_for_ack;
2629 int n_csa_offsets;
2630 const u16 *csa_offsets;
2631};
2632
2633/**
2634 * struct cfg80211_dscp_exception - DSCP exception
2635 *
2636 * @dscp: DSCP value that does not adhere to the user priority range definition
2637 * @up: user priority value to which the corresponding DSCP value belongs
2638 */
2639struct cfg80211_dscp_exception {
2640 u8 dscp;
2641 u8 up;
2642};
2643
2644/**
2645 * struct cfg80211_dscp_range - DSCP range definition for user priority
2646 *
2647 * @low: lowest DSCP value of this user priority range, inclusive
2648 * @high: highest DSCP value of this user priority range, inclusive
2649 */
2650struct cfg80211_dscp_range {
2651 u8 low;
2652 u8 high;
2653};
2654
2655/* QoS Map Set element length defined in IEEE Std 802.11-2012, 8.4.2.97 */
2656#define IEEE80211_QOS_MAP_MAX_EX 21
2657#define IEEE80211_QOS_MAP_LEN_MIN 16
2658#define IEEE80211_QOS_MAP_LEN_MAX \
2659 (IEEE80211_QOS_MAP_LEN_MIN + 2 * IEEE80211_QOS_MAP_MAX_EX)
2660
2661/**
2662 * struct cfg80211_qos_map - QoS Map Information
2663 *
2664 * This struct defines the Interworking QoS map setting for DSCP values
2665 *
2666 * @num_des: number of DSCP exceptions (0..21)
2667 * @dscp_exception: optionally up to maximum of 21 DSCP exceptions from
2668 * the user priority DSCP range definition
2669 * @up: DSCP range definition for a particular user priority
2670 */
2671struct cfg80211_qos_map {
2672 u8 num_des;
2673 struct cfg80211_dscp_exception dscp_exception[IEEE80211_QOS_MAP_MAX_EX];
2674 struct cfg80211_dscp_range up[8];
2675};
2676
2677/**
2678 * struct cfg80211_nan_conf - NAN configuration
2679 *
2680 * This struct defines NAN configuration parameters
2681 *
2682 * @master_pref: master preference (1 - 255)
2683 * @bands: operating bands, a bitmap of &enum nl80211_band values.
2684 * For instance, for NL80211_BAND_2GHZ, bit 0 would be set
2685 * (i.e. BIT(NL80211_BAND_2GHZ)).
2686 */
2687struct cfg80211_nan_conf {
2688 u8 master_pref;
2689 u8 bands;
2690};
2691
2692/**
2693 * enum cfg80211_nan_conf_changes - indicates changed fields in NAN
2694 * configuration
2695 *
2696 * @CFG80211_NAN_CONF_CHANGED_PREF: master preference
2697 * @CFG80211_NAN_CONF_CHANGED_BANDS: operating bands
2698 */
2699enum cfg80211_nan_conf_changes {
2700 CFG80211_NAN_CONF_CHANGED_PREF = BIT(0),
2701 CFG80211_NAN_CONF_CHANGED_BANDS = BIT(1),
2702};
2703
2704/**
2705 * struct cfg80211_nan_func_filter - a NAN function Rx / Tx filter
2706 *
2707 * @filter: the content of the filter
2708 * @len: the length of the filter
2709 */
2710struct cfg80211_nan_func_filter {
2711 const u8 *filter;
2712 u8 len;
2713};
2714
2715/**
2716 * struct cfg80211_nan_func - a NAN function
2717 *
2718 * @type: &enum nl80211_nan_function_type
2719 * @service_id: the service ID of the function
2720 * @publish_type: &nl80211_nan_publish_type
2721 * @close_range: if true, the range should be limited. Threshold is
2722 * implementation specific.
2723 * @publish_bcast: if true, the solicited publish should be broadcasted
2724 * @subscribe_active: if true, the subscribe is active
2725 * @followup_id: the instance ID for follow up
2726 * @followup_reqid: the requestor instance ID for follow up
2727 * @followup_dest: MAC address of the recipient of the follow up
2728 * @ttl: time to live counter in DW.
2729 * @serv_spec_info: Service Specific Info
2730 * @serv_spec_info_len: Service Specific Info length
2731 * @srf_include: if true, SRF is inclusive
2732 * @srf_bf: Bloom Filter
2733 * @srf_bf_len: Bloom Filter length
2734 * @srf_bf_idx: Bloom Filter index
2735 * @srf_macs: SRF MAC addresses
2736 * @srf_num_macs: number of MAC addresses in SRF
2737 * @rx_filters: rx filters that are matched with corresponding peer's tx_filter
2738 * @tx_filters: filters that should be transmitted in the SDF.
2739 * @num_rx_filters: length of &rx_filters.
2740 * @num_tx_filters: length of &tx_filters.
2741 * @instance_id: driver allocated id of the function.
2742 * @cookie: unique NAN function identifier.
2743 */
2744struct cfg80211_nan_func {
2745 enum nl80211_nan_function_type type;
2746 u8 service_id[NL80211_NAN_FUNC_SERVICE_ID_LEN];
2747 u8 publish_type;
2748 bool close_range;
2749 bool publish_bcast;
2750 bool subscribe_active;
2751 u8 followup_id;
2752 u8 followup_reqid;
2753 struct mac_address followup_dest;
2754 u32 ttl;
2755 const u8 *serv_spec_info;
2756 u8 serv_spec_info_len;
2757 bool srf_include;
2758 const u8 *srf_bf;
2759 u8 srf_bf_len;
2760 u8 srf_bf_idx;
2761 struct mac_address *srf_macs;
2762 int srf_num_macs;
2763 struct cfg80211_nan_func_filter *rx_filters;
2764 struct cfg80211_nan_func_filter *tx_filters;
2765 u8 num_tx_filters;
2766 u8 num_rx_filters;
2767 u8 instance_id;
2768 u64 cookie;
2769};
2770
2771/**
2772 * struct cfg80211_pmk_conf - PMK configuration
2773 *
2774 * @aa: authenticator address
2775 * @pmk_len: PMK length in bytes.
2776 * @pmk: the PMK material
2777 * @pmk_r0_name: PMK-R0 Name. NULL if not applicable (i.e., the PMK
2778 * is not PMK-R0). When pmk_r0_name is not NULL, the pmk field
2779 * holds PMK-R0.
2780 */
2781struct cfg80211_pmk_conf {
2782 const u8 *aa;
2783 u8 pmk_len;
2784 const u8 *pmk;
2785 const u8 *pmk_r0_name;
2786};
2787
2788/**
2789 * struct cfg80211_external_auth_params - Trigger External authentication.
2790 *
2791 * Commonly used across the external auth request and event interfaces.
2792 *
2793 * @action: action type / trigger for external authentication. Only significant
2794 * for the authentication request event interface (driver to user space).
2795 * @bssid: BSSID of the peer with which the authentication has
2796 * to happen. Used by both the authentication request event and
2797 * authentication response command interface.
2798 * @ssid: SSID of the AP. Used by both the authentication request event and
2799 * authentication response command interface.
2800 * @key_mgmt_suite: AKM suite of the respective authentication. Used by the
2801 * authentication request event interface.
2802 * @status: status code, %WLAN_STATUS_SUCCESS for successful authentication,
2803 * use %WLAN_STATUS_UNSPECIFIED_FAILURE if user space cannot give you
2804 * the real status code for failures. Used only for the authentication
2805 * response command interface (user space to driver).
2806 * @pmkid: The identifier to refer a PMKSA.
2807 */
2808struct cfg80211_external_auth_params {
2809 enum nl80211_external_auth_action action;
2810 u8 bssid[ETH_ALEN] __aligned(2);
2811 struct cfg80211_ssid ssid;
2812 unsigned int key_mgmt_suite;
2813 u16 status;
2814//tianyan@2021.7.27 modify for add wifi6 module start
2815 const u8 *pmkid;
2816//tianyan@2021.7.27 modify for add wifi6 module end
2817};
2818
2819/**
2820 * struct cfg80211_ops - backend description for wireless configuration
2821 *
2822 * This struct is registered by fullmac card drivers and/or wireless stacks
2823 * in order to handle configuration requests on their interfaces.
2824 *
2825 * All callbacks except where otherwise noted should return 0
2826 * on success or a negative error code.
2827 *
2828 * All operations are currently invoked under rtnl for consistency with the
2829 * wireless extensions but this is subject to reevaluation as soon as this
2830 * code is used more widely and we have a first user without wext.
2831 *
2832 * @suspend: wiphy device needs to be suspended. The variable @wow will
2833 * be %NULL or contain the enabled Wake-on-Wireless triggers that are
2834 * configured for the device.
2835 * @resume: wiphy device needs to be resumed
2836 * @set_wakeup: Called when WoWLAN is enabled/disabled, use this callback
2837 * to call device_set_wakeup_enable() to enable/disable wakeup from
2838 * the device.
2839 *
2840 * @add_virtual_intf: create a new virtual interface with the given name,
2841 * must set the struct wireless_dev's iftype. Beware: You must create
2842 * the new netdev in the wiphy's network namespace! Returns the struct
2843 * wireless_dev, or an ERR_PTR. For P2P device wdevs, the driver must
2844 * also set the address member in the wdev.
2845 *
2846 * @del_virtual_intf: remove the virtual interface
2847 *
2848 * @change_virtual_intf: change type/configuration of virtual interface,
2849 * keep the struct wireless_dev's iftype updated.
2850 *
2851 * @add_key: add a key with the given parameters. @mac_addr will be %NULL
2852 * when adding a group key.
2853 *
2854 * @get_key: get information about the key with the given parameters.
2855 * @mac_addr will be %NULL when requesting information for a group
2856 * key. All pointers given to the @callback function need not be valid
2857 * after it returns. This function should return an error if it is
2858 * not possible to retrieve the key, -ENOENT if it doesn't exist.
2859 *
2860 * @del_key: remove a key given the @mac_addr (%NULL for a group key)
2861 * and @key_index, return -ENOENT if the key doesn't exist.
2862 *
2863 * @set_default_key: set the default key on an interface
2864 *
2865 * @set_default_mgmt_key: set the default management frame key on an interface
2866 *
2867 * @set_rekey_data: give the data necessary for GTK rekeying to the driver
2868 *
2869 * @start_ap: Start acting in AP mode defined by the parameters.
2870 * @change_beacon: Change the beacon parameters for an access point mode
2871 * interface. This should reject the call when AP mode wasn't started.
2872 * @stop_ap: Stop being an AP, including stopping beaconing.
2873 *
2874 * @add_station: Add a new station.
2875 * @del_station: Remove a station
2876 * @change_station: Modify a given station. Note that flags changes are not much
2877 * validated in cfg80211, in particular the auth/assoc/authorized flags
2878 * might come to the driver in invalid combinations -- make sure to check
2879 * them, also against the existing state! Drivers must call
2880 * cfg80211_check_station_change() to validate the information.
2881 * @get_station: get station information for the station identified by @mac
2882 * @dump_station: dump station callback -- resume dump at index @idx
2883 *
2884 * @add_mpath: add a fixed mesh path
2885 * @del_mpath: delete a given mesh path
2886 * @change_mpath: change a given mesh path
2887 * @get_mpath: get a mesh path for the given parameters
2888 * @dump_mpath: dump mesh path callback -- resume dump at index @idx
2889 * @get_mpp: get a mesh proxy path for the given parameters
2890 * @dump_mpp: dump mesh proxy path callback -- resume dump at index @idx
2891 * @join_mesh: join the mesh network with the specified parameters
2892 * (invoked with the wireless_dev mutex held)
2893 * @leave_mesh: leave the current mesh network
2894 * (invoked with the wireless_dev mutex held)
2895 *
2896 * @get_mesh_config: Get the current mesh configuration
2897 *
2898 * @update_mesh_config: Update mesh parameters on a running mesh.
2899 * The mask is a bitfield which tells us which parameters to
2900 * set, and which to leave alone.
2901 *
2902 * @change_bss: Modify parameters for a given BSS.
2903 *
2904 * @set_txq_params: Set TX queue parameters
2905 *
2906 * @libertas_set_mesh_channel: Only for backward compatibility for libertas,
2907 * as it doesn't implement join_mesh and needs to set the channel to
2908 * join the mesh instead.
2909 *
2910 * @set_monitor_channel: Set the monitor mode channel for the device. If other
2911 * interfaces are active this callback should reject the configuration.
2912 * If no interfaces are active or the device is down, the channel should
2913 * be stored for when a monitor interface becomes active.
2914 *
2915 * @scan: Request to do a scan. If returning zero, the scan request is given
2916 * the driver, and will be valid until passed to cfg80211_scan_done().
2917 * For scan results, call cfg80211_inform_bss(); you can call this outside
2918 * the scan/scan_done bracket too.
2919 * @abort_scan: Tell the driver to abort an ongoing scan. The driver shall
2920 * indicate the status of the scan through cfg80211_scan_done().
2921 *
2922 * @auth: Request to authenticate with the specified peer
2923 * (invoked with the wireless_dev mutex held)
2924 * @assoc: Request to (re)associate with the specified peer
2925 * (invoked with the wireless_dev mutex held)
2926 * @deauth: Request to deauthenticate from the specified peer
2927 * (invoked with the wireless_dev mutex held)
2928 * @disassoc: Request to disassociate from the specified peer
2929 * (invoked with the wireless_dev mutex held)
2930 *
2931 * @connect: Connect to the ESS with the specified parameters. When connected,
2932 * call cfg80211_connect_result()/cfg80211_connect_bss() with status code
2933 * %WLAN_STATUS_SUCCESS. If the connection fails for some reason, call
2934 * cfg80211_connect_result()/cfg80211_connect_bss() with the status code
2935 * from the AP or cfg80211_connect_timeout() if no frame with status code
2936 * was received.
2937 * The driver is allowed to roam to other BSSes within the ESS when the
2938 * other BSS matches the connect parameters. When such roaming is initiated
2939 * by the driver, the driver is expected to verify that the target matches
2940 * the configured security parameters and to use Reassociation Request
2941 * frame instead of Association Request frame.
2942 * The connect function can also be used to request the driver to perform a
2943 * specific roam when connected to an ESS. In that case, the prev_bssid
2944 * parameter is set to the BSSID of the currently associated BSS as an
2945 * indication of requesting reassociation.
2946 * In both the driver-initiated and new connect() call initiated roaming
2947 * cases, the result of roaming is indicated with a call to
2948 * cfg80211_roamed(). (invoked with the wireless_dev mutex held)
2949 * @update_connect_params: Update the connect parameters while connected to a
2950 * BSS. The updated parameters can be used by driver/firmware for
2951 * subsequent BSS selection (roaming) decisions and to form the
2952 * Authentication/(Re)Association Request frames. This call does not
2953 * request an immediate disassociation or reassociation with the current
2954 * BSS, i.e., this impacts only subsequent (re)associations. The bits in
2955 * changed are defined in &enum cfg80211_connect_params_changed.
2956 * (invoked with the wireless_dev mutex held)
2957 * @disconnect: Disconnect from the BSS/ESS or stop connection attempts if
2958 * connection is in progress. Once done, call cfg80211_disconnected() in
2959 * case connection was already established (invoked with the
2960 * wireless_dev mutex held), otherwise call cfg80211_connect_timeout().
2961 *
2962 * @join_ibss: Join the specified IBSS (or create if necessary). Once done, call
2963 * cfg80211_ibss_joined(), also call that function when changing BSSID due
2964 * to a merge.
2965 * (invoked with the wireless_dev mutex held)
2966 * @leave_ibss: Leave the IBSS.
2967 * (invoked with the wireless_dev mutex held)
2968 *
2969 * @set_mcast_rate: Set the specified multicast rate (only if vif is in ADHOC or
2970 * MESH mode)
2971 *
2972 * @set_wiphy_params: Notify that wiphy parameters have changed;
2973 * @changed bitfield (see &enum wiphy_params_flags) describes which values
2974 * have changed. The actual parameter values are available in
2975 * struct wiphy. If returning an error, no value should be changed.
2976 *
2977 * @set_tx_power: set the transmit power according to the parameters,
2978 * the power passed is in mBm, to get dBm use MBM_TO_DBM(). The
2979 * wdev may be %NULL if power was set for the wiphy, and will
2980 * always be %NULL unless the driver supports per-vif TX power
2981 * (as advertised by the nl80211 feature flag.)
2982 * @get_tx_power: store the current TX power into the dbm variable;
2983 * return 0 if successful
2984 *
2985 * @set_wds_peer: set the WDS peer for a WDS interface
2986 *
2987 * @rfkill_poll: polls the hw rfkill line, use cfg80211 reporting
2988 * functions to adjust rfkill hw state
2989 *
2990 * @dump_survey: get site survey information.
2991 *
2992 * @remain_on_channel: Request the driver to remain awake on the specified
2993 * channel for the specified duration to complete an off-channel
2994 * operation (e.g., public action frame exchange). When the driver is
2995 * ready on the requested channel, it must indicate this with an event
2996 * notification by calling cfg80211_ready_on_channel().
2997 * @cancel_remain_on_channel: Cancel an on-going remain-on-channel operation.
2998 * This allows the operation to be terminated prior to timeout based on
2999 * the duration value.
3000 * @mgmt_tx: Transmit a management frame.
3001 * @mgmt_tx_cancel_wait: Cancel the wait time from transmitting a management
3002 * frame on another channel
3003 *
3004 * @testmode_cmd: run a test mode command; @wdev may be %NULL
3005 * @testmode_dump: Implement a test mode dump. The cb->args[2] and up may be
3006 * used by the function, but 0 and 1 must not be touched. Additionally,
3007 * return error codes other than -ENOBUFS and -ENOENT will terminate the
3008 * dump and return to userspace with an error, so be careful. If any data
3009 * was passed in from userspace then the data/len arguments will be present
3010 * and point to the data contained in %NL80211_ATTR_TESTDATA.
3011 *
3012 * @set_bitrate_mask: set the bitrate mask configuration
3013 *
3014 * @set_pmksa: Cache a PMKID for a BSSID. This is mostly useful for fullmac
3015 * devices running firmwares capable of generating the (re) association
3016 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
3017 * @del_pmksa: Delete a cached PMKID.
3018 * @flush_pmksa: Flush all cached PMKIDs.
3019 * @set_power_mgmt: Configure WLAN power management. A timeout value of -1
3020 * allows the driver to adjust the dynamic ps timeout value.
3021 * @set_cqm_rssi_config: Configure connection quality monitor RSSI threshold.
3022 * After configuration, the driver should (soon) send an event indicating
3023 * the current level is above/below the configured threshold; this may
3024 * need some care when the configuration is changed (without first being
3025 * disabled.)
3026 * @set_cqm_rssi_range_config: Configure two RSSI thresholds in the
3027 * connection quality monitor. An event is to be sent only when the
3028 * signal level is found to be outside the two values. The driver should
3029 * set %NL80211_EXT_FEATURE_CQM_RSSI_LIST if this method is implemented.
3030 * If it is provided then there's no point providing @set_cqm_rssi_config.
3031 * @set_cqm_txe_config: Configure connection quality monitor TX error
3032 * thresholds.
3033 * @sched_scan_start: Tell the driver to start a scheduled scan.
3034 * @sched_scan_stop: Tell the driver to stop an ongoing scheduled scan with
3035 * given request id. This call must stop the scheduled scan and be ready
3036 * for starting a new one before it returns, i.e. @sched_scan_start may be
3037 * called immediately after that again and should not fail in that case.
3038 * The driver should not call cfg80211_sched_scan_stopped() for a requested
3039 * stop (when this method returns 0).
3040 *
3041 * @mgmt_frame_register: Notify driver that a management frame type was
3042 * registered. The callback is allowed to sleep.
3043 *
3044 * @set_antenna: Set antenna configuration (tx_ant, rx_ant) on the device.
3045 * Parameters are bitmaps of allowed antennas to use for TX/RX. Drivers may
3046 * reject TX/RX mask combinations they cannot support by returning -EINVAL
3047 * (also see nl80211.h @NL80211_ATTR_WIPHY_ANTENNA_TX).
3048 *
3049 * @get_antenna: Get current antenna configuration from device (tx_ant, rx_ant).
3050 *
3051 * @tdls_mgmt: Transmit a TDLS management frame.
3052 * @tdls_oper: Perform a high-level TDLS operation (e.g. TDLS link setup).
3053 *
3054 * @probe_client: probe an associated client, must return a cookie that it
3055 * later passes to cfg80211_probe_status().
3056 *
3057 * @set_noack_map: Set the NoAck Map for the TIDs.
3058 *
3059 * @get_channel: Get the current operating channel for the virtual interface.
3060 * For monitor interfaces, it should return %NULL unless there's a single
3061 * current monitoring channel.
3062 *
3063 * @start_p2p_device: Start the given P2P device.
3064 * @stop_p2p_device: Stop the given P2P device.
3065 *
3066 * @set_mac_acl: Sets MAC address control list in AP and P2P GO mode.
3067 * Parameters include ACL policy, an array of MAC address of stations
3068 * and the number of MAC addresses. If there is already a list in driver
3069 * this new list replaces the existing one. Driver has to clear its ACL
3070 * when number of MAC addresses entries is passed as 0. Drivers which
3071 * advertise the support for MAC based ACL have to implement this callback.
3072 *
3073 * @start_radar_detection: Start radar detection in the driver.
3074 *
3075 * @update_ft_ies: Provide updated Fast BSS Transition information to the
3076 * driver. If the SME is in the driver/firmware, this information can be
3077 * used in building Authentication and Reassociation Request frames.
3078 *
3079 * @crit_proto_start: Indicates a critical protocol needs more link reliability
3080 * for a given duration (milliseconds). The protocol is provided so the
3081 * driver can take the most appropriate actions.
3082 * @crit_proto_stop: Indicates critical protocol no longer needs increased link
3083 * reliability. This operation can not fail.
3084 * @set_coalesce: Set coalesce parameters.
3085 *
3086 * @channel_switch: initiate channel-switch procedure (with CSA). Driver is
3087 * responsible for veryfing if the switch is possible. Since this is
3088 * inherently tricky driver may decide to disconnect an interface later
3089 * with cfg80211_stop_iface(). This doesn't mean driver can accept
3090 * everything. It should do it's best to verify requests and reject them
3091 * as soon as possible.
3092 *
3093 * @set_qos_map: Set QoS mapping information to the driver
3094 *
3095 * @set_ap_chanwidth: Set the AP (including P2P GO) mode channel width for the
3096 * given interface This is used e.g. for dynamic HT 20/40 MHz channel width
3097 * changes during the lifetime of the BSS.
3098 *
3099 * @add_tx_ts: validate (if admitted_time is 0) or add a TX TS to the device
3100 * with the given parameters; action frame exchange has been handled by
3101 * userspace so this just has to modify the TX path to take the TS into
3102 * account.
3103 * If the admitted time is 0 just validate the parameters to make sure
3104 * the session can be created at all; it is valid to just always return
3105 * success for that but that may result in inefficient behaviour (handshake
3106 * with the peer followed by immediate teardown when the addition is later
3107 * rejected)
3108 * @del_tx_ts: remove an existing TX TS
3109 *
3110 * @join_ocb: join the OCB network with the specified parameters
3111 * (invoked with the wireless_dev mutex held)
3112 * @leave_ocb: leave the current OCB network
3113 * (invoked with the wireless_dev mutex held)
3114 *
3115 * @tdls_channel_switch: Start channel-switching with a TDLS peer. The driver
3116 * is responsible for continually initiating channel-switching operations
3117 * and returning to the base channel for communication with the AP.
3118 * @tdls_cancel_channel_switch: Stop channel-switching with a TDLS peer. Both
3119 * peers must be on the base channel when the call completes.
3120 * @start_nan: Start the NAN interface.
3121 * @stop_nan: Stop the NAN interface.
3122 * @add_nan_func: Add a NAN function. Returns negative value on failure.
3123 * On success @nan_func ownership is transferred to the driver and
3124 * it may access it outside of the scope of this function. The driver
3125 * should free the @nan_func when no longer needed by calling
3126 * cfg80211_free_nan_func().
3127 * On success the driver should assign an instance_id in the
3128 * provided @nan_func.
3129 * @del_nan_func: Delete a NAN function.
3130 * @nan_change_conf: changes NAN configuration. The changed parameters must
3131 * be specified in @changes (using &enum cfg80211_nan_conf_changes);
3132 * All other parameters must be ignored.
3133 *
3134 * @set_multicast_to_unicast: configure multicast to unicast conversion for BSS
3135 *
3136 * @get_txq_stats: Get TXQ stats for interface or phy. If wdev is %NULL, this
3137 * function should return phy stats, and interface stats otherwise.
3138 *
3139 * @set_pmk: configure the PMK to be used for offloaded 802.1X 4-Way handshake.
3140 * If not deleted through @del_pmk the PMK remains valid until disconnect
3141 * upon which the driver should clear it.
3142 * (invoked with the wireless_dev mutex held)
3143 * @del_pmk: delete the previously configured PMK for the given authenticator.
3144 * (invoked with the wireless_dev mutex held)
3145 *
3146 * @external_auth: indicates result of offloaded authentication processing from
3147 * user space
3148 *
3149 * @tx_control_port: TX a control port frame (EAPoL). The noencrypt parameter
3150 * tells the driver that the frame should not be encrypted.
3151 */
3152struct cfg80211_ops {
3153 int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
3154 int (*resume)(struct wiphy *wiphy);
3155 void (*set_wakeup)(struct wiphy *wiphy, bool enabled);
3156
3157 struct wireless_dev * (*add_virtual_intf)(struct wiphy *wiphy,
3158 const char *name,
3159 unsigned char name_assign_type,
3160 enum nl80211_iftype type,
3161 struct vif_params *params);
3162 int (*del_virtual_intf)(struct wiphy *wiphy,
3163 struct wireless_dev *wdev);
3164 int (*change_virtual_intf)(struct wiphy *wiphy,
3165 struct net_device *dev,
3166 enum nl80211_iftype type,
3167 struct vif_params *params);
3168
3169 int (*add_key)(struct wiphy *wiphy, struct net_device *netdev,
3170 u8 key_index, bool pairwise, const u8 *mac_addr,
3171 struct key_params *params);
3172 int (*get_key)(struct wiphy *wiphy, struct net_device *netdev,
3173 u8 key_index, bool pairwise, const u8 *mac_addr,
3174 void *cookie,
3175 void (*callback)(void *cookie, struct key_params*));
3176 int (*del_key)(struct wiphy *wiphy, struct net_device *netdev,
3177 u8 key_index, bool pairwise, const u8 *mac_addr);
3178 int (*set_default_key)(struct wiphy *wiphy,
3179 struct net_device *netdev,
3180 u8 key_index, bool unicast, bool multicast);
3181 int (*set_default_mgmt_key)(struct wiphy *wiphy,
3182 struct net_device *netdev,
3183 u8 key_index);
3184
3185 int (*start_ap)(struct wiphy *wiphy, struct net_device *dev,
3186 struct cfg80211_ap_settings *settings);
3187 int (*change_beacon)(struct wiphy *wiphy, struct net_device *dev,
3188 struct cfg80211_beacon_data *info);
3189 int (*stop_ap)(struct wiphy *wiphy, struct net_device *dev);
3190
3191
3192 int (*add_station)(struct wiphy *wiphy, struct net_device *dev,
3193 const u8 *mac,
3194 struct station_parameters *params);
3195 int (*del_station)(struct wiphy *wiphy, struct net_device *dev,
3196 struct station_del_parameters *params);
3197 int (*change_station)(struct wiphy *wiphy, struct net_device *dev,
3198 const u8 *mac,
3199 struct station_parameters *params);
3200 int (*get_station)(struct wiphy *wiphy, struct net_device *dev,
3201 const u8 *mac, struct station_info *sinfo);
3202 int (*dump_station)(struct wiphy *wiphy, struct net_device *dev,
3203 int idx, u8 *mac, struct station_info *sinfo);
3204
3205 int (*add_mpath)(struct wiphy *wiphy, struct net_device *dev,
3206 const u8 *dst, const u8 *next_hop);
3207 int (*del_mpath)(struct wiphy *wiphy, struct net_device *dev,
3208 const u8 *dst);
3209 int (*change_mpath)(struct wiphy *wiphy, struct net_device *dev,
3210 const u8 *dst, const u8 *next_hop);
3211 int (*get_mpath)(struct wiphy *wiphy, struct net_device *dev,
3212 u8 *dst, u8 *next_hop, struct mpath_info *pinfo);
3213 int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev,
3214 int idx, u8 *dst, u8 *next_hop,
3215 struct mpath_info *pinfo);
3216 int (*get_mpp)(struct wiphy *wiphy, struct net_device *dev,
3217 u8 *dst, u8 *mpp, struct mpath_info *pinfo);
3218 int (*dump_mpp)(struct wiphy *wiphy, struct net_device *dev,
3219 int idx, u8 *dst, u8 *mpp,
3220 struct mpath_info *pinfo);
3221 int (*get_mesh_config)(struct wiphy *wiphy,
3222 struct net_device *dev,
3223 struct mesh_config *conf);
3224 int (*update_mesh_config)(struct wiphy *wiphy,
3225 struct net_device *dev, u32 mask,
3226 const struct mesh_config *nconf);
3227 int (*join_mesh)(struct wiphy *wiphy, struct net_device *dev,
3228 const struct mesh_config *conf,
3229 const struct mesh_setup *setup);
3230 int (*leave_mesh)(struct wiphy *wiphy, struct net_device *dev);
3231
3232 int (*join_ocb)(struct wiphy *wiphy, struct net_device *dev,
3233 struct ocb_setup *setup);
3234 int (*leave_ocb)(struct wiphy *wiphy, struct net_device *dev);
3235
3236 int (*change_bss)(struct wiphy *wiphy, struct net_device *dev,
3237 struct bss_parameters *params);
3238
3239 int (*set_txq_params)(struct wiphy *wiphy, struct net_device *dev,
3240 struct ieee80211_txq_params *params);
3241
3242 int (*libertas_set_mesh_channel)(struct wiphy *wiphy,
3243 struct net_device *dev,
3244 struct ieee80211_channel *chan);
3245
3246 int (*set_monitor_channel)(struct wiphy *wiphy,
3247 struct cfg80211_chan_def *chandef);
3248
3249 int (*scan)(struct wiphy *wiphy,
3250 struct cfg80211_scan_request *request);
3251 void (*abort_scan)(struct wiphy *wiphy, struct wireless_dev *wdev);
3252
3253 int (*auth)(struct wiphy *wiphy, struct net_device *dev,
3254 struct cfg80211_auth_request *req);
3255 int (*assoc)(struct wiphy *wiphy, struct net_device *dev,
3256 struct cfg80211_assoc_request *req);
3257 int (*deauth)(struct wiphy *wiphy, struct net_device *dev,
3258 struct cfg80211_deauth_request *req);
3259 int (*disassoc)(struct wiphy *wiphy, struct net_device *dev,
3260 struct cfg80211_disassoc_request *req);
3261
3262 int (*connect)(struct wiphy *wiphy, struct net_device *dev,
3263 struct cfg80211_connect_params *sme);
3264 int (*update_connect_params)(struct wiphy *wiphy,
3265 struct net_device *dev,
3266 struct cfg80211_connect_params *sme,
3267 u32 changed);
3268 int (*disconnect)(struct wiphy *wiphy, struct net_device *dev,
3269 u16 reason_code);
3270
3271 int (*join_ibss)(struct wiphy *wiphy, struct net_device *dev,
3272 struct cfg80211_ibss_params *params);
3273 int (*leave_ibss)(struct wiphy *wiphy, struct net_device *dev);
3274
3275 int (*set_mcast_rate)(struct wiphy *wiphy, struct net_device *dev,
3276 int rate[NUM_NL80211_BANDS]);
3277
3278 int (*set_wiphy_params)(struct wiphy *wiphy, u32 changed);
3279
3280 int (*set_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev,
3281 enum nl80211_tx_power_setting type, int mbm);
3282 int (*get_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev,
3283 int *dbm);
3284
3285 int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev,
3286 const u8 *addr);
3287
3288 void (*rfkill_poll)(struct wiphy *wiphy);
3289
3290#ifdef CONFIG_NL80211_TESTMODE
3291 int (*testmode_cmd)(struct wiphy *wiphy, struct wireless_dev *wdev,
3292 void *data, int len);
3293 int (*testmode_dump)(struct wiphy *wiphy, struct sk_buff *skb,
3294 struct netlink_callback *cb,
3295 void *data, int len);
3296#endif
3297
3298 int (*set_bitrate_mask)(struct wiphy *wiphy,
3299 struct net_device *dev,
3300 const u8 *peer,
3301 const struct cfg80211_bitrate_mask *mask);
3302
3303 int (*dump_survey)(struct wiphy *wiphy, struct net_device *netdev,
3304 int idx, struct survey_info *info);
3305
3306 int (*set_pmksa)(struct wiphy *wiphy, struct net_device *netdev,
3307 struct cfg80211_pmksa *pmksa);
3308 int (*del_pmksa)(struct wiphy *wiphy, struct net_device *netdev,
3309 struct cfg80211_pmksa *pmksa);
3310 int (*flush_pmksa)(struct wiphy *wiphy, struct net_device *netdev);
3311
3312 int (*remain_on_channel)(struct wiphy *wiphy,
3313 struct wireless_dev *wdev,
3314 struct ieee80211_channel *chan,
3315 unsigned int duration,
3316 u64 *cookie);
3317 int (*cancel_remain_on_channel)(struct wiphy *wiphy,
3318 struct wireless_dev *wdev,
3319 u64 cookie);
3320
3321 int (*mgmt_tx)(struct wiphy *wiphy, struct wireless_dev *wdev,
3322 struct cfg80211_mgmt_tx_params *params,
3323 u64 *cookie);
3324 int (*mgmt_tx_cancel_wait)(struct wiphy *wiphy,
3325 struct wireless_dev *wdev,
3326 u64 cookie);
3327
3328 int (*set_power_mgmt)(struct wiphy *wiphy, struct net_device *dev,
3329 bool enabled, int timeout);
3330
3331 int (*set_cqm_rssi_config)(struct wiphy *wiphy,
3332 struct net_device *dev,
3333 s32 rssi_thold, u32 rssi_hyst);
3334
3335 int (*set_cqm_rssi_range_config)(struct wiphy *wiphy,
3336 struct net_device *dev,
3337 s32 rssi_low, s32 rssi_high);
3338
3339 int (*set_cqm_txe_config)(struct wiphy *wiphy,
3340 struct net_device *dev,
3341 u32 rate, u32 pkts, u32 intvl);
3342
3343 void (*mgmt_frame_register)(struct wiphy *wiphy,
3344 struct wireless_dev *wdev,
3345 u16 frame_type, bool reg);
3346
3347 int (*set_antenna)(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant);
3348 int (*get_antenna)(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant);
3349
3350 int (*sched_scan_start)(struct wiphy *wiphy,
3351 struct net_device *dev,
3352 struct cfg80211_sched_scan_request *request);
3353 int (*sched_scan_stop)(struct wiphy *wiphy, struct net_device *dev,
3354 u64 reqid);
3355
3356 int (*set_rekey_data)(struct wiphy *wiphy, struct net_device *dev,
3357 struct cfg80211_gtk_rekey_data *data);
3358
3359 int (*tdls_mgmt)(struct wiphy *wiphy, struct net_device *dev,
3360 const u8 *peer, u8 action_code, u8 dialog_token,
3361 u16 status_code, u32 peer_capability,
3362 bool initiator, const u8 *buf, size_t len);
3363 int (*tdls_oper)(struct wiphy *wiphy, struct net_device *dev,
3364 const u8 *peer, enum nl80211_tdls_operation oper);
3365
3366 int (*probe_client)(struct wiphy *wiphy, struct net_device *dev,
3367 const u8 *peer, u64 *cookie);
3368
3369 int (*set_noack_map)(struct wiphy *wiphy,
3370 struct net_device *dev,
3371 u16 noack_map);
3372
3373 int (*get_channel)(struct wiphy *wiphy,
3374 struct wireless_dev *wdev,
3375 struct cfg80211_chan_def *chandef);
3376
3377 int (*start_p2p_device)(struct wiphy *wiphy,
3378 struct wireless_dev *wdev);
3379 void (*stop_p2p_device)(struct wiphy *wiphy,
3380 struct wireless_dev *wdev);
3381
3382 int (*set_mac_acl)(struct wiphy *wiphy, struct net_device *dev,
3383 const struct cfg80211_acl_data *params);
3384
3385 int (*start_radar_detection)(struct wiphy *wiphy,
3386 struct net_device *dev,
3387 struct cfg80211_chan_def *chandef,
3388 u32 cac_time_ms);
3389 int (*update_ft_ies)(struct wiphy *wiphy, struct net_device *dev,
3390 struct cfg80211_update_ft_ies_params *ftie);
3391 int (*crit_proto_start)(struct wiphy *wiphy,
3392 struct wireless_dev *wdev,
3393 enum nl80211_crit_proto_id protocol,
3394 u16 duration);
3395 void (*crit_proto_stop)(struct wiphy *wiphy,
3396 struct wireless_dev *wdev);
3397 int (*set_coalesce)(struct wiphy *wiphy,
3398 struct cfg80211_coalesce *coalesce);
3399
3400 int (*channel_switch)(struct wiphy *wiphy,
3401 struct net_device *dev,
3402 struct cfg80211_csa_settings *params);
3403
3404 int (*set_qos_map)(struct wiphy *wiphy,
3405 struct net_device *dev,
3406 struct cfg80211_qos_map *qos_map);
3407
3408 int (*set_ap_chanwidth)(struct wiphy *wiphy, struct net_device *dev,
3409 struct cfg80211_chan_def *chandef);
3410
3411 int (*add_tx_ts)(struct wiphy *wiphy, struct net_device *dev,
3412 u8 tsid, const u8 *peer, u8 user_prio,
3413 u16 admitted_time);
3414 int (*del_tx_ts)(struct wiphy *wiphy, struct net_device *dev,
3415 u8 tsid, const u8 *peer);
3416
3417 int (*tdls_channel_switch)(struct wiphy *wiphy,
3418 struct net_device *dev,
3419 const u8 *addr, u8 oper_class,
3420 struct cfg80211_chan_def *chandef);
3421 void (*tdls_cancel_channel_switch)(struct wiphy *wiphy,
3422 struct net_device *dev,
3423 const u8 *addr);
3424 int (*start_nan)(struct wiphy *wiphy, struct wireless_dev *wdev,
3425 struct cfg80211_nan_conf *conf);
3426 void (*stop_nan)(struct wiphy *wiphy, struct wireless_dev *wdev);
3427 int (*add_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,
3428 struct cfg80211_nan_func *nan_func);
3429 void (*del_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,
3430 u64 cookie);
3431 int (*nan_change_conf)(struct wiphy *wiphy,
3432 struct wireless_dev *wdev,
3433 struct cfg80211_nan_conf *conf,
3434 u32 changes);
3435
3436 int (*set_multicast_to_unicast)(struct wiphy *wiphy,
3437 struct net_device *dev,
3438 const bool enabled);
3439
3440 int (*get_txq_stats)(struct wiphy *wiphy,
3441 struct wireless_dev *wdev,
3442 struct cfg80211_txq_stats *txqstats);
3443
3444 int (*set_pmk)(struct wiphy *wiphy, struct net_device *dev,
3445 const struct cfg80211_pmk_conf *conf);
3446 int (*del_pmk)(struct wiphy *wiphy, struct net_device *dev,
3447 const u8 *aa);
3448 int (*external_auth)(struct wiphy *wiphy, struct net_device *dev,
3449 struct cfg80211_external_auth_params *params);
3450
3451 int (*tx_control_port)(struct wiphy *wiphy,
3452 struct net_device *dev,
3453 const u8 *buf, size_t len,
3454 const u8 *dest, const __be16 proto,
3455 const bool noencrypt);
3456};
3457
3458/*
3459 * wireless hardware and networking interfaces structures
3460 * and registration/helper functions
3461 */
3462
3463/**
3464 * enum wiphy_flags - wiphy capability flags
3465 *
3466 * @WIPHY_FLAG_NETNS_OK: if not set, do not allow changing the netns of this
3467 * wiphy at all
3468 * @WIPHY_FLAG_PS_ON_BY_DEFAULT: if set to true, powersave will be enabled
3469 * by default -- this flag will be set depending on the kernel's default
3470 * on wiphy_new(), but can be changed by the driver if it has a good
3471 * reason to override the default
3472 * @WIPHY_FLAG_4ADDR_AP: supports 4addr mode even on AP (with a single station
3473 * on a VLAN interface). This flag also serves an extra purpose of
3474 * supporting 4ADDR AP mode on devices which do not support AP/VLAN iftype.
3475 * @WIPHY_FLAG_4ADDR_STATION: supports 4addr mode even as a station
3476 * @WIPHY_FLAG_CONTROL_PORT_PROTOCOL: This device supports setting the
3477 * control port protocol ethertype. The device also honours the
3478 * control_port_no_encrypt flag.
3479 * @WIPHY_FLAG_IBSS_RSN: The device supports IBSS RSN.
3480 * @WIPHY_FLAG_MESH_AUTH: The device supports mesh authentication by routing
3481 * auth frames to userspace. See @NL80211_MESH_SETUP_USERSPACE_AUTH.
3482 * @WIPHY_FLAG_SUPPORTS_FW_ROAM: The device supports roaming feature in the
3483 * firmware.
3484 * @WIPHY_FLAG_AP_UAPSD: The device supports uapsd on AP.
3485 * @WIPHY_FLAG_SUPPORTS_TDLS: The device supports TDLS (802.11z) operation.
3486 * @WIPHY_FLAG_TDLS_EXTERNAL_SETUP: The device does not handle TDLS (802.11z)
3487 * link setup/discovery operations internally. Setup, discovery and
3488 * teardown packets should be sent through the @NL80211_CMD_TDLS_MGMT
3489 * command. When this flag is not set, @NL80211_CMD_TDLS_OPER should be
3490 * used for asking the driver/firmware to perform a TDLS operation.
3491 * @WIPHY_FLAG_HAVE_AP_SME: device integrates AP SME
3492 * @WIPHY_FLAG_REPORTS_OBSS: the device will report beacons from other BSSes
3493 * when there are virtual interfaces in AP mode by calling
3494 * cfg80211_report_obss_beacon().
3495 * @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD: When operating as an AP, the device
3496 * responds to probe-requests in hardware.
3497 * @WIPHY_FLAG_OFFCHAN_TX: Device supports direct off-channel TX.
3498 * @WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL: Device supports remain-on-channel call.
3499 * @WIPHY_FLAG_SUPPORTS_5_10_MHZ: Device supports 5 MHz and 10 MHz channels.
3500 * @WIPHY_FLAG_HAS_CHANNEL_SWITCH: Device supports channel switch in
3501 * beaconing mode (AP, IBSS, Mesh, ...).
3502 * @WIPHY_FLAG_HAS_STATIC_WEP: The device supports static WEP key installation
3503 * before connection.
3504 */
3505enum wiphy_flags {
3506 /* use hole at 0 */
3507 /* use hole at 1 */
3508 /* use hole at 2 */
3509 WIPHY_FLAG_NETNS_OK = BIT(3),
3510 WIPHY_FLAG_PS_ON_BY_DEFAULT = BIT(4),
3511 WIPHY_FLAG_4ADDR_AP = BIT(5),
3512 WIPHY_FLAG_4ADDR_STATION = BIT(6),
3513 WIPHY_FLAG_CONTROL_PORT_PROTOCOL = BIT(7),
3514 WIPHY_FLAG_IBSS_RSN = BIT(8),
3515 WIPHY_FLAG_MESH_AUTH = BIT(10),
3516 /* use hole at 11 */
3517 /* use hole at 12 */
3518 WIPHY_FLAG_SUPPORTS_FW_ROAM = BIT(13),
3519 WIPHY_FLAG_AP_UAPSD = BIT(14),
3520 WIPHY_FLAG_SUPPORTS_TDLS = BIT(15),
3521 WIPHY_FLAG_TDLS_EXTERNAL_SETUP = BIT(16),
3522 WIPHY_FLAG_HAVE_AP_SME = BIT(17),
3523 WIPHY_FLAG_REPORTS_OBSS = BIT(18),
3524 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD = BIT(19),
3525 WIPHY_FLAG_OFFCHAN_TX = BIT(20),
3526 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL = BIT(21),
3527 WIPHY_FLAG_SUPPORTS_5_10_MHZ = BIT(22),
3528 WIPHY_FLAG_HAS_CHANNEL_SWITCH = BIT(23),
3529 WIPHY_FLAG_HAS_STATIC_WEP = BIT(24),
3530};
3531
3532/**
3533 * struct ieee80211_iface_limit - limit on certain interface types
3534 * @max: maximum number of interfaces of these types
3535 * @types: interface types (bits)
3536 */
3537struct ieee80211_iface_limit {
3538 u16 max;
3539 u16 types;
3540};
3541
3542/**
3543 * struct ieee80211_iface_combination - possible interface combination
3544 *
3545 * With this structure the driver can describe which interface
3546 * combinations it supports concurrently.
3547 *
3548 * Examples:
3549 *
3550 * 1. Allow #STA <= 1, #AP <= 1, matching BI, channels = 1, 2 total:
3551 *
3552 * .. code-block:: c
3553 *
3554 * struct ieee80211_iface_limit limits1[] = {
3555 * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), },
3556 * { .max = 1, .types = BIT(NL80211_IFTYPE_AP}, },
3557 * };
3558 * struct ieee80211_iface_combination combination1 = {
3559 * .limits = limits1,
3560 * .n_limits = ARRAY_SIZE(limits1),
3561 * .max_interfaces = 2,
3562 * .beacon_int_infra_match = true,
3563 * };
3564 *
3565 *
3566 * 2. Allow #{AP, P2P-GO} <= 8, channels = 1, 8 total:
3567 *
3568 * .. code-block:: c
3569 *
3570 * struct ieee80211_iface_limit limits2[] = {
3571 * { .max = 8, .types = BIT(NL80211_IFTYPE_AP) |
3572 * BIT(NL80211_IFTYPE_P2P_GO), },
3573 * };
3574 * struct ieee80211_iface_combination combination2 = {
3575 * .limits = limits2,
3576 * .n_limits = ARRAY_SIZE(limits2),
3577 * .max_interfaces = 8,
3578 * .num_different_channels = 1,
3579 * };
3580 *
3581 *
3582 * 3. Allow #STA <= 1, #{P2P-client,P2P-GO} <= 3 on two channels, 4 total.
3583 *
3584 * This allows for an infrastructure connection and three P2P connections.
3585 *
3586 * .. code-block:: c
3587 *
3588 * struct ieee80211_iface_limit limits3[] = {
3589 * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), },
3590 * { .max = 3, .types = BIT(NL80211_IFTYPE_P2P_GO) |
3591 * BIT(NL80211_IFTYPE_P2P_CLIENT), },
3592 * };
3593 * struct ieee80211_iface_combination combination3 = {
3594 * .limits = limits3,
3595 * .n_limits = ARRAY_SIZE(limits3),
3596 * .max_interfaces = 4,
3597 * .num_different_channels = 2,
3598 * };
3599 *
3600 */
3601struct ieee80211_iface_combination {
3602 /**
3603 * @limits:
3604 * limits for the given interface types
3605 */
3606 const struct ieee80211_iface_limit *limits;
3607
3608 /**
3609 * @num_different_channels:
3610 * can use up to this many different channels
3611 */
3612 u32 num_different_channels;
3613
3614 /**
3615 * @max_interfaces:
3616 * maximum number of interfaces in total allowed in this group
3617 */
3618 u16 max_interfaces;
3619
3620 /**
3621 * @n_limits:
3622 * number of limitations
3623 */
3624 u8 n_limits;
3625
3626 /**
3627 * @beacon_int_infra_match:
3628 * In this combination, the beacon intervals between infrastructure
3629 * and AP types must match. This is required only in special cases.
3630 */
3631 bool beacon_int_infra_match;
3632
3633 /**
3634 * @radar_detect_widths:
3635 * bitmap of channel widths supported for radar detection
3636 */
3637 u8 radar_detect_widths;
3638
3639 /**
3640 * @radar_detect_regions:
3641 * bitmap of regions supported for radar detection
3642 */
3643 u8 radar_detect_regions;
3644
3645 /**
3646 * @beacon_int_min_gcd:
3647 * This interface combination supports different beacon intervals.
3648 *
3649 * = 0
3650 * all beacon intervals for different interface must be same.
3651 * > 0
3652 * any beacon interval for the interface part of this combination AND
3653 * GCD of all beacon intervals from beaconing interfaces of this
3654 * combination must be greater or equal to this value.
3655 */
3656 u32 beacon_int_min_gcd;
3657};
3658
3659struct ieee80211_txrx_stypes {
3660 u16 tx, rx;
3661};
3662
3663/**
3664 * enum wiphy_wowlan_support_flags - WoWLAN support flags
3665 * @WIPHY_WOWLAN_ANY: supports wakeup for the special "any"
3666 * trigger that keeps the device operating as-is and
3667 * wakes up the host on any activity, for example a
3668 * received packet that passed filtering; note that the
3669 * packet should be preserved in that case
3670 * @WIPHY_WOWLAN_MAGIC_PKT: supports wakeup on magic packet
3671 * (see nl80211.h)
3672 * @WIPHY_WOWLAN_DISCONNECT: supports wakeup on disconnect
3673 * @WIPHY_WOWLAN_SUPPORTS_GTK_REKEY: supports GTK rekeying while asleep
3674 * @WIPHY_WOWLAN_GTK_REKEY_FAILURE: supports wakeup on GTK rekey failure
3675 * @WIPHY_WOWLAN_EAP_IDENTITY_REQ: supports wakeup on EAP identity request
3676 * @WIPHY_WOWLAN_4WAY_HANDSHAKE: supports wakeup on 4-way handshake failure
3677 * @WIPHY_WOWLAN_RFKILL_RELEASE: supports wakeup on RF-kill release
3678 * @WIPHY_WOWLAN_NET_DETECT: supports wakeup on network detection
3679 */
3680enum wiphy_wowlan_support_flags {
3681 WIPHY_WOWLAN_ANY = BIT(0),
3682 WIPHY_WOWLAN_MAGIC_PKT = BIT(1),
3683 WIPHY_WOWLAN_DISCONNECT = BIT(2),
3684 WIPHY_WOWLAN_SUPPORTS_GTK_REKEY = BIT(3),
3685 WIPHY_WOWLAN_GTK_REKEY_FAILURE = BIT(4),
3686 WIPHY_WOWLAN_EAP_IDENTITY_REQ = BIT(5),
3687 WIPHY_WOWLAN_4WAY_HANDSHAKE = BIT(6),
3688 WIPHY_WOWLAN_RFKILL_RELEASE = BIT(7),
3689 WIPHY_WOWLAN_NET_DETECT = BIT(8),
3690};
3691
3692struct wiphy_wowlan_tcp_support {
3693 const struct nl80211_wowlan_tcp_data_token_feature *tok;
3694 u32 data_payload_max;
3695 u32 data_interval_max;
3696 u32 wake_payload_max;
3697 bool seq;
3698};
3699
3700/**
3701 * struct wiphy_wowlan_support - WoWLAN support data
3702 * @flags: see &enum wiphy_wowlan_support_flags
3703 * @n_patterns: number of supported wakeup patterns
3704 * (see nl80211.h for the pattern definition)
3705 * @pattern_max_len: maximum length of each pattern
3706 * @pattern_min_len: minimum length of each pattern
3707 * @max_pkt_offset: maximum Rx packet offset
3708 * @max_nd_match_sets: maximum number of matchsets for net-detect,
3709 * similar, but not necessarily identical, to max_match_sets for
3710 * scheduled scans.
3711 * See &struct cfg80211_sched_scan_request.@match_sets for more
3712 * details.
3713 * @tcp: TCP wakeup support information
3714 */
3715struct wiphy_wowlan_support {
3716 u32 flags;
3717 int n_patterns;
3718 int pattern_max_len;
3719 int pattern_min_len;
3720 int max_pkt_offset;
3721 int max_nd_match_sets;
3722 const struct wiphy_wowlan_tcp_support *tcp;
3723};
3724
3725/**
3726 * struct wiphy_coalesce_support - coalesce support data
3727 * @n_rules: maximum number of coalesce rules
3728 * @max_delay: maximum supported coalescing delay in msecs
3729 * @n_patterns: number of supported patterns in a rule
3730 * (see nl80211.h for the pattern definition)
3731 * @pattern_max_len: maximum length of each pattern
3732 * @pattern_min_len: minimum length of each pattern
3733 * @max_pkt_offset: maximum Rx packet offset
3734 */
3735struct wiphy_coalesce_support {
3736 int n_rules;
3737 int max_delay;
3738 int n_patterns;
3739 int pattern_max_len;
3740 int pattern_min_len;
3741 int max_pkt_offset;
3742};
3743
3744/**
3745 * enum wiphy_vendor_command_flags - validation flags for vendor commands
3746 * @WIPHY_VENDOR_CMD_NEED_WDEV: vendor command requires wdev
3747 * @WIPHY_VENDOR_CMD_NEED_NETDEV: vendor command requires netdev
3748 * @WIPHY_VENDOR_CMD_NEED_RUNNING: interface/wdev must be up & running
3749 * (must be combined with %_WDEV or %_NETDEV)
3750 */
3751enum wiphy_vendor_command_flags {
3752 WIPHY_VENDOR_CMD_NEED_WDEV = BIT(0),
3753 WIPHY_VENDOR_CMD_NEED_NETDEV = BIT(1),
3754 WIPHY_VENDOR_CMD_NEED_RUNNING = BIT(2),
3755};
3756
3757/**
3758 * enum wiphy_opmode_flag - Station's ht/vht operation mode information flags
3759 *
3760 * @STA_OPMODE_MAX_BW_CHANGED: Max Bandwidth changed
3761 * @STA_OPMODE_SMPS_MODE_CHANGED: SMPS mode changed
3762 * @STA_OPMODE_N_SS_CHANGED: max N_SS (number of spatial streams) changed
3763 *
3764 */
3765enum wiphy_opmode_flag {
3766 STA_OPMODE_MAX_BW_CHANGED = BIT(0),
3767 STA_OPMODE_SMPS_MODE_CHANGED = BIT(1),
3768 STA_OPMODE_N_SS_CHANGED = BIT(2),
3769};
3770
3771/**
3772 * struct sta_opmode_info - Station's ht/vht operation mode information
3773 * @changed: contains value from &enum wiphy_opmode_flag
3774 * @smps_mode: New SMPS mode value from &enum nl80211_smps_mode of a station
3775 * @bw: new max bandwidth value from &enum nl80211_chan_width of a station
3776 * @rx_nss: new rx_nss value of a station
3777 */
3778
3779struct sta_opmode_info {
3780 u32 changed;
3781 enum nl80211_smps_mode smps_mode;
3782 enum nl80211_chan_width bw;
3783 u8 rx_nss;
3784};
3785
3786/**
3787 * struct wiphy_vendor_command - vendor command definition
3788 * @info: vendor command identifying information, as used in nl80211
3789 * @flags: flags, see &enum wiphy_vendor_command_flags
3790 * @doit: callback for the operation, note that wdev is %NULL if the
3791 * flags didn't ask for a wdev and non-%NULL otherwise; the data
3792 * pointer may be %NULL if userspace provided no data at all
3793 * @dumpit: dump callback, for transferring bigger/multiple items. The
3794 * @storage points to cb->args[5], ie. is preserved over the multiple
3795 * dumpit calls.
3796 * It's recommended to not have the same sub command with both @doit and
3797 * @dumpit, so that userspace can assume certain ones are get and others
3798 * are used with dump requests.
3799 */
3800struct wiphy_vendor_command {
3801 struct nl80211_vendor_cmd_info info;
3802 u32 flags;
3803 int (*doit)(struct wiphy *wiphy, struct wireless_dev *wdev,
3804 const void *data, int data_len);
3805 int (*dumpit)(struct wiphy *wiphy, struct wireless_dev *wdev,
3806 struct sk_buff *skb, const void *data, int data_len,
3807 unsigned long *storage);
3808};
3809
3810/**
3811 * struct wiphy_iftype_ext_capab - extended capabilities per interface type
3812 * @iftype: interface type
3813 * @extended_capabilities: extended capabilities supported by the driver,
3814 * additional capabilities might be supported by userspace; these are the
3815 * 802.11 extended capabilities ("Extended Capabilities element") and are
3816 * in the same format as in the information element. See IEEE Std
3817 * 802.11-2012 8.4.2.29 for the defined fields.
3818 * @extended_capabilities_mask: mask of the valid values
3819 * @extended_capabilities_len: length of the extended capabilities
3820 */
3821struct wiphy_iftype_ext_capab {
3822 enum nl80211_iftype iftype;
3823 const u8 *extended_capabilities;
3824 const u8 *extended_capabilities_mask;
3825 u8 extended_capabilities_len;
3826};
3827
3828/**
3829 * struct wiphy - wireless hardware description
3830 * @reg_notifier: the driver's regulatory notification callback,
3831 * note that if your driver uses wiphy_apply_custom_regulatory()
3832 * the reg_notifier's request can be passed as NULL
3833 * @regd: the driver's regulatory domain, if one was requested via
3834 * the regulatory_hint() API. This can be used by the driver
3835 * on the reg_notifier() if it chooses to ignore future
3836 * regulatory domain changes caused by other drivers.
3837 * @signal_type: signal type reported in &struct cfg80211_bss.
3838 * @cipher_suites: supported cipher suites
3839 * @n_cipher_suites: number of supported cipher suites
3840 * @retry_short: Retry limit for short frames (dot11ShortRetryLimit)
3841 * @retry_long: Retry limit for long frames (dot11LongRetryLimit)
3842 * @frag_threshold: Fragmentation threshold (dot11FragmentationThreshold);
3843 * -1 = fragmentation disabled, only odd values >= 256 used
3844 * @rts_threshold: RTS threshold (dot11RTSThreshold); -1 = RTS/CTS disabled
3845 * @_net: the network namespace this wiphy currently lives in
3846 * @perm_addr: permanent MAC address of this device
3847 * @addr_mask: If the device supports multiple MAC addresses by masking,
3848 * set this to a mask with variable bits set to 1, e.g. if the last
3849 * four bits are variable then set it to 00-00-00-00-00-0f. The actual
3850 * variable bits shall be determined by the interfaces added, with
3851 * interfaces not matching the mask being rejected to be brought up.
3852 * @n_addresses: number of addresses in @addresses.
3853 * @addresses: If the device has more than one address, set this pointer
3854 * to a list of addresses (6 bytes each). The first one will be used
3855 * by default for perm_addr. In this case, the mask should be set to
3856 * all-zeroes. In this case it is assumed that the device can handle
3857 * the same number of arbitrary MAC addresses.
3858 * @registered: protects ->resume and ->suspend sysfs callbacks against
3859 * unregister hardware
3860 * @debugfsdir: debugfs directory used for this wiphy, will be renamed
3861 * automatically on wiphy renames
3862 * @dev: (virtual) struct device for this wiphy
3863 * @registered: helps synchronize suspend/resume with wiphy unregister
3864 * @wext: wireless extension handlers
3865 * @priv: driver private data (sized according to wiphy_new() parameter)
3866 * @interface_modes: bitmask of interfaces types valid for this wiphy,
3867 * must be set by driver
3868 * @iface_combinations: Valid interface combinations array, should not
3869 * list single interface types.
3870 * @n_iface_combinations: number of entries in @iface_combinations array.
3871 * @software_iftypes: bitmask of software interface types, these are not
3872 * subject to any restrictions since they are purely managed in SW.
3873 * @flags: wiphy flags, see &enum wiphy_flags
3874 * @regulatory_flags: wiphy regulatory flags, see
3875 * &enum ieee80211_regulatory_flags
3876 * @features: features advertised to nl80211, see &enum nl80211_feature_flags.
3877 * @ext_features: extended features advertised to nl80211, see
3878 * &enum nl80211_ext_feature_index.
3879 * @bss_priv_size: each BSS struct has private data allocated with it,
3880 * this variable determines its size
3881 * @max_scan_ssids: maximum number of SSIDs the device can scan for in
3882 * any given scan
3883 * @max_sched_scan_reqs: maximum number of scheduled scan requests that
3884 * the device can run concurrently.
3885 * @max_sched_scan_ssids: maximum number of SSIDs the device can scan
3886 * for in any given scheduled scan
3887 * @max_match_sets: maximum number of match sets the device can handle
3888 * when performing a scheduled scan, 0 if filtering is not
3889 * supported.
3890 * @max_scan_ie_len: maximum length of user-controlled IEs device can
3891 * add to probe request frames transmitted during a scan, must not
3892 * include fixed IEs like supported rates
3893 * @max_sched_scan_ie_len: same as max_scan_ie_len, but for scheduled
3894 * scans
3895 * @max_sched_scan_plans: maximum number of scan plans (scan interval and number
3896 * of iterations) for scheduled scan supported by the device.
3897 * @max_sched_scan_plan_interval: maximum interval (in seconds) for a
3898 * single scan plan supported by the device.
3899 * @max_sched_scan_plan_iterations: maximum number of iterations for a single
3900 * scan plan supported by the device.
3901 * @coverage_class: current coverage class
3902 * @fw_version: firmware version for ethtool reporting
3903 * @hw_version: hardware version for ethtool reporting
3904 * @max_num_pmkids: maximum number of PMKIDs supported by device
3905 * @privid: a pointer that drivers can use to identify if an arbitrary
3906 * wiphy is theirs, e.g. in global notifiers
3907 * @bands: information about bands/channels supported by this device
3908 *
3909 * @mgmt_stypes: bitmasks of frame subtypes that can be subscribed to or
3910 * transmitted through nl80211, points to an array indexed by interface
3911 * type
3912 *
3913 * @available_antennas_tx: bitmap of antennas which are available to be
3914 * configured as TX antennas. Antenna configuration commands will be
3915 * rejected unless this or @available_antennas_rx is set.
3916 *
3917 * @available_antennas_rx: bitmap of antennas which are available to be
3918 * configured as RX antennas. Antenna configuration commands will be
3919 * rejected unless this or @available_antennas_tx is set.
3920 *
3921 * @probe_resp_offload:
3922 * Bitmap of supported protocols for probe response offloading.
3923 * See &enum nl80211_probe_resp_offload_support_attr. Only valid
3924 * when the wiphy flag @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD is set.
3925 *
3926 * @max_remain_on_channel_duration: Maximum time a remain-on-channel operation
3927 * may request, if implemented.
3928 *
3929 * @wowlan: WoWLAN support information
3930 * @wowlan_config: current WoWLAN configuration; this should usually not be
3931 * used since access to it is necessarily racy, use the parameter passed
3932 * to the suspend() operation instead.
3933 *
3934 * @ap_sme_capa: AP SME capabilities, flags from &enum nl80211_ap_sme_features.
3935 * @ht_capa_mod_mask: Specify what ht_cap values can be over-ridden.
3936 * If null, then none can be over-ridden.
3937 * @vht_capa_mod_mask: Specify what VHT capabilities can be over-ridden.
3938 * If null, then none can be over-ridden.
3939 *
3940 * @wdev_list: the list of associated (virtual) interfaces; this list must
3941 * not be modified by the driver, but can be read with RTNL/RCU protection.
3942 *
3943 * @max_acl_mac_addrs: Maximum number of MAC addresses that the device
3944 * supports for ACL.
3945 *
3946 * @extended_capabilities: extended capabilities supported by the driver,
3947 * additional capabilities might be supported by userspace; these are
3948 * the 802.11 extended capabilities ("Extended Capabilities element")
3949 * and are in the same format as in the information element. See
3950 * 802.11-2012 8.4.2.29 for the defined fields. These are the default
3951 * extended capabilities to be used if the capabilities are not specified
3952 * for a specific interface type in iftype_ext_capab.
3953 * @extended_capabilities_mask: mask of the valid values
3954 * @extended_capabilities_len: length of the extended capabilities
3955 * @iftype_ext_capab: array of extended capabilities per interface type
3956 * @num_iftype_ext_capab: number of interface types for which extended
3957 * capabilities are specified separately.
3958 * @coalesce: packet coalescing support information
3959 *
3960 * @vendor_commands: array of vendor commands supported by the hardware
3961 * @n_vendor_commands: number of vendor commands
3962 * @vendor_events: array of vendor events supported by the hardware
3963 * @n_vendor_events: number of vendor events
3964 *
3965 * @max_ap_assoc_sta: maximum number of associated stations supported in AP mode
3966 * (including P2P GO) or 0 to indicate no such limit is advertised. The
3967 * driver is allowed to advertise a theoretical limit that it can reach in
3968 * some cases, but may not always reach.
3969 *
3970 * @max_num_csa_counters: Number of supported csa_counters in beacons
3971 * and probe responses. This value should be set if the driver
3972 * wishes to limit the number of csa counters. Default (0) means
3973 * infinite.
3974 * @max_adj_channel_rssi_comp: max offset of between the channel on which the
3975 * frame was sent and the channel on which the frame was heard for which
3976 * the reported rssi is still valid. If a driver is able to compensate the
3977 * low rssi when a frame is heard on different channel, then it should set
3978 * this variable to the maximal offset for which it can compensate.
3979 * This value should be set in MHz.
3980 * @bss_select_support: bitmask indicating the BSS selection criteria supported
3981 * by the driver in the .connect() callback. The bit position maps to the
3982 * attribute indices defined in &enum nl80211_bss_select_attr.
3983 *
3984 * @cookie_counter: unique generic cookie counter, used to identify objects.
3985 * @nan_supported_bands: bands supported by the device in NAN mode, a
3986 * bitmap of &enum nl80211_band values. For instance, for
3987 * NL80211_BAND_2GHZ, bit 0 would be set
3988 * (i.e. BIT(NL80211_BAND_2GHZ)).
3989 *
3990 * @txq_limit: configuration of internal TX queue frame limit
3991 * @txq_memory_limit: configuration internal TX queue memory limit
3992 * @txq_quantum: configuration of internal TX queue scheduler quantum
3993 */
3994struct wiphy {
3995 /* assign these fields before you register the wiphy */
3996
3997 /* permanent MAC address(es) */
3998 u8 perm_addr[ETH_ALEN];
3999 u8 addr_mask[ETH_ALEN];
4000
4001 struct mac_address *addresses;
4002
4003 const struct ieee80211_txrx_stypes *mgmt_stypes;
4004
4005 const struct ieee80211_iface_combination *iface_combinations;
4006 int n_iface_combinations;
4007 u16 software_iftypes;
4008
4009 u16 n_addresses;
4010
4011 /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */
4012 u16 interface_modes;
4013
4014 u16 max_acl_mac_addrs;
4015
4016 u32 flags, regulatory_flags, features;
4017 u8 ext_features[DIV_ROUND_UP(NUM_NL80211_EXT_FEATURES, 8)];
4018
4019 u32 ap_sme_capa;
4020
4021 enum cfg80211_signal_type signal_type;
4022
4023 int bss_priv_size;
4024 u8 max_scan_ssids;
4025 u8 max_sched_scan_reqs;
4026 u8 max_sched_scan_ssids;
4027 u8 max_match_sets;
4028 u16 max_scan_ie_len;
4029 u16 max_sched_scan_ie_len;
4030 u32 max_sched_scan_plans;
4031 u32 max_sched_scan_plan_interval;
4032 u32 max_sched_scan_plan_iterations;
4033
4034 int n_cipher_suites;
4035 const u32 *cipher_suites;
4036
4037 u8 retry_short;
4038 u8 retry_long;
4039 u32 frag_threshold;
4040 u32 rts_threshold;
4041 u8 coverage_class;
4042
4043 char fw_version[ETHTOOL_FWVERS_LEN];
4044 u32 hw_version;
4045
4046#ifdef CONFIG_PM
4047 const struct wiphy_wowlan_support *wowlan;
4048 struct cfg80211_wowlan *wowlan_config;
4049#endif
4050
4051 u16 max_remain_on_channel_duration;
4052
4053 u8 max_num_pmkids;
4054
4055 u32 available_antennas_tx;
4056 u32 available_antennas_rx;
4057
4058 /*
4059 * Bitmap of supported protocols for probe response offloading
4060 * see &enum nl80211_probe_resp_offload_support_attr. Only valid
4061 * when the wiphy flag @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD is set.
4062 */
4063 u32 probe_resp_offload;
4064
4065 const u8 *extended_capabilities, *extended_capabilities_mask;
4066 u8 extended_capabilities_len;
4067
4068 const struct wiphy_iftype_ext_capab *iftype_ext_capab;
4069 unsigned int num_iftype_ext_capab;
4070
4071 /* If multiple wiphys are registered and you're handed e.g.
4072 * a regular netdev with assigned ieee80211_ptr, you won't
4073 * know whether it points to a wiphy your driver has registered
4074 * or not. Assign this to something global to your driver to
4075 * help determine whether you own this wiphy or not. */
4076 const void *privid;
4077
4078 struct ieee80211_supported_band *bands[NUM_NL80211_BANDS];
4079
4080 /* Lets us get back the wiphy on the callback */
4081 void (*reg_notifier)(struct wiphy *wiphy,
4082 struct regulatory_request *request);
4083
4084 /* fields below are read-only, assigned by cfg80211 */
4085
4086 const struct ieee80211_regdomain __rcu *regd;
4087
4088 /* the item in /sys/class/ieee80211/ points to this,
4089 * you need use set_wiphy_dev() (see below) */
4090 struct device dev;
4091
4092 /* protects ->resume, ->suspend sysfs callbacks against unregister hw */
4093 bool registered;
4094
4095 /* dir in debugfs: ieee80211/<wiphyname> */
4096 struct dentry *debugfsdir;
4097
4098 const struct ieee80211_ht_cap *ht_capa_mod_mask;
4099 const struct ieee80211_vht_cap *vht_capa_mod_mask;
4100
4101 struct list_head wdev_list;
4102
4103 /* the network namespace this phy lives in currently */
4104 possible_net_t _net;
4105
4106#ifdef CONFIG_CFG80211_WEXT
4107 const struct iw_handler_def *wext;
4108#endif
4109
4110 const struct wiphy_coalesce_support *coalesce;
4111
4112 const struct wiphy_vendor_command *vendor_commands;
4113 const struct nl80211_vendor_cmd_info *vendor_events;
4114 int n_vendor_commands, n_vendor_events;
4115
4116 u16 max_ap_assoc_sta;
4117
4118 u8 max_num_csa_counters;
4119 u8 max_adj_channel_rssi_comp;
4120
4121 u32 bss_select_support;
4122
4123 u64 cookie_counter;
4124
4125 u8 nan_supported_bands;
4126
4127 u32 txq_limit;
4128 u32 txq_memory_limit;
4129 u32 txq_quantum;
4130
4131 char priv[0] __aligned(NETDEV_ALIGN);
4132};
4133
4134static inline struct net *wiphy_net(struct wiphy *wiphy)
4135{
4136 return read_pnet(&wiphy->_net);
4137}
4138
4139static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net)
4140{
4141 write_pnet(&wiphy->_net, net);
4142}
4143
4144/**
4145 * wiphy_priv - return priv from wiphy
4146 *
4147 * @wiphy: the wiphy whose priv pointer to return
4148 * Return: The priv of @wiphy.
4149 */
4150static inline void *wiphy_priv(struct wiphy *wiphy)
4151{
4152 BUG_ON(!wiphy);
4153 return &wiphy->priv;
4154}
4155
4156/**
4157 * priv_to_wiphy - return the wiphy containing the priv
4158 *
4159 * @priv: a pointer previously returned by wiphy_priv
4160 * Return: The wiphy of @priv.
4161 */
4162static inline struct wiphy *priv_to_wiphy(void *priv)
4163{
4164 BUG_ON(!priv);
4165 return container_of(priv, struct wiphy, priv);
4166}
4167
4168/**
4169 * set_wiphy_dev - set device pointer for wiphy
4170 *
4171 * @wiphy: The wiphy whose device to bind
4172 * @dev: The device to parent it to
4173 */
4174static inline void set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
4175{
4176 wiphy->dev.parent = dev;
4177}
4178
4179/**
4180 * wiphy_dev - get wiphy dev pointer
4181 *
4182 * @wiphy: The wiphy whose device struct to look up
4183 * Return: The dev of @wiphy.
4184 */
4185static inline struct device *wiphy_dev(struct wiphy *wiphy)
4186{
4187 return wiphy->dev.parent;
4188}
4189
4190/**
4191 * wiphy_name - get wiphy name
4192 *
4193 * @wiphy: The wiphy whose name to return
4194 * Return: The name of @wiphy.
4195 */
4196static inline const char *wiphy_name(const struct wiphy *wiphy)
4197{
4198 return dev_name(&wiphy->dev);
4199}
4200
4201/**
4202 * wiphy_new_nm - create a new wiphy for use with cfg80211
4203 *
4204 * @ops: The configuration operations for this device
4205 * @sizeof_priv: The size of the private area to allocate
4206 * @requested_name: Request a particular name.
4207 * NULL is valid value, and means use the default phy%d naming.
4208 *
4209 * Create a new wiphy and associate the given operations with it.
4210 * @sizeof_priv bytes are allocated for private use.
4211 *
4212 * Return: A pointer to the new wiphy. This pointer must be
4213 * assigned to each netdev's ieee80211_ptr for proper operation.
4214 */
4215struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
4216 const char *requested_name);
4217
4218/**
4219 * wiphy_new - create a new wiphy for use with cfg80211
4220 *
4221 * @ops: The configuration operations for this device
4222 * @sizeof_priv: The size of the private area to allocate
4223 *
4224 * Create a new wiphy and associate the given operations with it.
4225 * @sizeof_priv bytes are allocated for private use.
4226 *
4227 * Return: A pointer to the new wiphy. This pointer must be
4228 * assigned to each netdev's ieee80211_ptr for proper operation.
4229 */
4230static inline struct wiphy *wiphy_new(const struct cfg80211_ops *ops,
4231 int sizeof_priv)
4232{
4233 return wiphy_new_nm(ops, sizeof_priv, NULL);
4234}
4235
4236/**
4237 * wiphy_register - register a wiphy with cfg80211
4238 *
4239 * @wiphy: The wiphy to register.
4240 *
4241 * Return: A non-negative wiphy index or a negative error code.
4242 */
4243int wiphy_register(struct wiphy *wiphy);
4244
4245/**
4246 * wiphy_unregister - deregister a wiphy from cfg80211
4247 *
4248 * @wiphy: The wiphy to unregister.
4249 *
4250 * After this call, no more requests can be made with this priv
4251 * pointer, but the call may sleep to wait for an outstanding
4252 * request that is being handled.
4253 */
4254void wiphy_unregister(struct wiphy *wiphy);
4255
4256/**
4257 * wiphy_free - free wiphy
4258 *
4259 * @wiphy: The wiphy to free
4260 */
4261void wiphy_free(struct wiphy *wiphy);
4262
4263/* internal structs */
4264struct cfg80211_conn;
4265struct cfg80211_internal_bss;
4266struct cfg80211_cached_keys;
4267struct cfg80211_cqm_config;
4268
4269/**
4270 * struct wireless_dev - wireless device state
4271 *
4272 * For netdevs, this structure must be allocated by the driver
4273 * that uses the ieee80211_ptr field in struct net_device (this
4274 * is intentional so it can be allocated along with the netdev.)
4275 * It need not be registered then as netdev registration will
4276 * be intercepted by cfg80211 to see the new wireless device.
4277 *
4278 * For non-netdev uses, it must also be allocated by the driver
4279 * in response to the cfg80211 callbacks that require it, as
4280 * there's no netdev registration in that case it may not be
4281 * allocated outside of callback operations that return it.
4282 *
4283 * @wiphy: pointer to hardware description
4284 * @iftype: interface type
4285 * @list: (private) Used to collect the interfaces
4286 * @netdev: (private) Used to reference back to the netdev, may be %NULL
4287 * @identifier: (private) Identifier used in nl80211 to identify this
4288 * wireless device if it has no netdev
4289 * @current_bss: (private) Used by the internal configuration code
4290 * @chandef: (private) Used by the internal configuration code to track
4291 * the user-set channel definition.
4292 * @preset_chandef: (private) Used by the internal configuration code to
4293 * track the channel to be used for AP later
4294 * @bssid: (private) Used by the internal configuration code
4295 * @ssid: (private) Used by the internal configuration code
4296 * @ssid_len: (private) Used by the internal configuration code
4297 * @mesh_id_len: (private) Used by the internal configuration code
4298 * @mesh_id_up_len: (private) Used by the internal configuration code
4299 * @wext: (private) Used by the internal wireless extensions compat code
4300 * @use_4addr: indicates 4addr mode is used on this interface, must be
4301 * set by driver (if supported) on add_interface BEFORE registering the
4302 * netdev and may otherwise be used by driver read-only, will be update
4303 * by cfg80211 on change_interface
4304 * @mgmt_registrations: list of registrations for management frames
4305 * @mgmt_registrations_lock: lock for the list
4306 * @mtx: mutex used to lock data in this struct, may be used by drivers
4307 * and some API functions require it held
4308 * @beacon_interval: beacon interval used on this device for transmitting
4309 * beacons, 0 when not valid
4310 * @address: The address for this device, valid only if @netdev is %NULL
4311 * @is_running: true if this is a non-netdev device that has been started, e.g.
4312 * the P2P Device.
4313 * @cac_started: true if DFS channel availability check has been started
4314 * @cac_start_time: timestamp (jiffies) when the dfs state was entered.
4315 * @cac_time_ms: CAC time in ms
4316 * @ps: powersave mode is enabled
4317 * @ps_timeout: dynamic powersave timeout
4318 * @ap_unexpected_nlportid: (private) netlink port ID of application
4319 * registered for unexpected class 3 frames (AP mode)
4320 * @conn: (private) cfg80211 software SME connection state machine data
4321 * @connect_keys: (private) keys to set after connection is established
4322 * @conn_bss_type: connecting/connected BSS type
4323 * @conn_owner_nlportid: (private) connection owner socket port ID
4324 * @disconnect_wk: (private) auto-disconnect work
4325 * @disconnect_bssid: (private) the BSSID to use for auto-disconnect
4326 * @ibss_fixed: (private) IBSS is using fixed BSSID
4327 * @ibss_dfs_possible: (private) IBSS may change to a DFS channel
4328 * @event_list: (private) list for internal event processing
4329 * @event_lock: (private) lock for event list
4330 * @owner_nlportid: (private) owner socket port ID
4331 * @nl_owner_dead: (private) owner socket went away
4332 * @cqm_config: (private) nl80211 RSSI monitor state
4333 */
4334struct wireless_dev {
4335 struct wiphy *wiphy;
4336 enum nl80211_iftype iftype;
4337
4338 /* the remainder of this struct should be private to cfg80211 */
4339 struct list_head list;
4340 struct net_device *netdev;
4341
4342 u32 identifier;
4343
4344 struct list_head mgmt_registrations;
4345 spinlock_t mgmt_registrations_lock;
4346
4347 struct mutex mtx;
4348
4349 bool use_4addr, is_running;
4350
4351 u8 address[ETH_ALEN] __aligned(sizeof(u16));
4352
4353 /* currently used for IBSS and SME - might be rearranged later */
4354 u8 ssid[IEEE80211_MAX_SSID_LEN];
4355 u8 ssid_len, mesh_id_len, mesh_id_up_len;
4356 struct cfg80211_conn *conn;
4357 struct cfg80211_cached_keys *connect_keys;
4358 enum ieee80211_bss_type conn_bss_type;
4359 u32 conn_owner_nlportid;
4360
4361 struct work_struct disconnect_wk;
4362 u8 disconnect_bssid[ETH_ALEN];
4363
4364 struct list_head event_list;
4365 spinlock_t event_lock;
4366
4367 struct cfg80211_internal_bss *current_bss; /* associated / joined */
4368 struct cfg80211_chan_def preset_chandef;
4369 struct cfg80211_chan_def chandef;
4370
4371 bool ibss_fixed;
4372 bool ibss_dfs_possible;
4373
4374 bool ps;
4375 int ps_timeout;
4376
4377 int beacon_interval;
4378
4379 u32 ap_unexpected_nlportid;
4380
4381 u32 owner_nlportid;
4382 bool nl_owner_dead;
4383
4384 bool cac_started;
4385 unsigned long cac_start_time;
4386 unsigned int cac_time_ms;
4387
4388#ifdef CONFIG_CFG80211_WEXT
4389 /* wext data */
4390 struct {
4391 struct cfg80211_ibss_params ibss;
4392 struct cfg80211_connect_params connect;
4393 struct cfg80211_cached_keys *keys;
4394 const u8 *ie;
4395 size_t ie_len;
4396 u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
4397 u8 ssid[IEEE80211_MAX_SSID_LEN];
4398 s8 default_key, default_mgmt_key;
4399 bool prev_bssid_valid;
4400 } wext;
4401#endif
4402
4403 struct cfg80211_cqm_config *cqm_config;
4404};
4405
4406static inline u8 *wdev_address(struct wireless_dev *wdev)
4407{
4408 if (wdev->netdev)
4409 return wdev->netdev->dev_addr;
4410 return wdev->address;
4411}
4412
4413static inline bool wdev_running(struct wireless_dev *wdev)
4414{
4415 if (wdev->netdev)
4416 return netif_running(wdev->netdev);
4417 return wdev->is_running;
4418}
4419
4420/**
4421 * wdev_priv - return wiphy priv from wireless_dev
4422 *
4423 * @wdev: The wireless device whose wiphy's priv pointer to return
4424 * Return: The wiphy priv of @wdev.
4425 */
4426static inline void *wdev_priv(struct wireless_dev *wdev)
4427{
4428 BUG_ON(!wdev);
4429 return wiphy_priv(wdev->wiphy);
4430}
4431
4432/**
4433 * DOC: Utility functions
4434 *
4435 * cfg80211 offers a number of utility functions that can be useful.
4436 */
4437
4438/**
4439 * ieee80211_channel_to_frequency - convert channel number to frequency
4440 * @chan: channel number
4441 * @band: band, necessary due to channel number overlap
4442 * Return: The corresponding frequency (in MHz), or 0 if the conversion failed.
4443 */
4444int ieee80211_channel_to_frequency(int chan, enum nl80211_band band);
4445
4446/**
4447 * ieee80211_frequency_to_channel - convert frequency to channel number
4448 * @freq: center frequency
4449 * Return: The corresponding channel, or 0 if the conversion failed.
4450 */
4451int ieee80211_frequency_to_channel(int freq);
4452
4453/**
4454 * ieee80211_get_channel - get channel struct from wiphy for specified frequency
4455 *
4456 * @wiphy: the struct wiphy to get the channel for
4457 * @freq: the center frequency of the channel
4458 *
4459 * Return: The channel struct from @wiphy at @freq.
4460 */
4461struct ieee80211_channel *ieee80211_get_channel(struct wiphy *wiphy, int freq);
4462
4463/**
4464 * ieee80211_get_response_rate - get basic rate for a given rate
4465 *
4466 * @sband: the band to look for rates in
4467 * @basic_rates: bitmap of basic rates
4468 * @bitrate: the bitrate for which to find the basic rate
4469 *
4470 * Return: The basic rate corresponding to a given bitrate, that
4471 * is the next lower bitrate contained in the basic rate map,
4472 * which is, for this function, given as a bitmap of indices of
4473 * rates in the band's bitrate table.
4474 */
4475struct ieee80211_rate *
4476ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
4477 u32 basic_rates, int bitrate);
4478
4479/**
4480 * ieee80211_mandatory_rates - get mandatory rates for a given band
4481 * @sband: the band to look for rates in
4482 * @scan_width: width of the control channel
4483 *
4484 * This function returns a bitmap of the mandatory rates for the given
4485 * band, bits are set according to the rate position in the bitrates array.
4486 */
4487u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband,
4488 enum nl80211_bss_scan_width scan_width);
4489
4490/*
4491 * Radiotap parsing functions -- for controlled injection support
4492 *
4493 * Implemented in net/wireless/radiotap.c
4494 * Documentation in Documentation/networking/radiotap-headers.txt
4495 */
4496
4497struct radiotap_align_size {
4498 uint8_t align:4, size:4;
4499};
4500
4501struct ieee80211_radiotap_namespace {
4502 const struct radiotap_align_size *align_size;
4503 int n_bits;
4504 uint32_t oui;
4505 uint8_t subns;
4506};
4507
4508struct ieee80211_radiotap_vendor_namespaces {
4509 const struct ieee80211_radiotap_namespace *ns;
4510 int n_ns;
4511};
4512
4513/**
4514 * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args
4515 * @this_arg_index: index of current arg, valid after each successful call
4516 * to ieee80211_radiotap_iterator_next()
4517 * @this_arg: pointer to current radiotap arg; it is valid after each
4518 * call to ieee80211_radiotap_iterator_next() but also after
4519 * ieee80211_radiotap_iterator_init() where it will point to
4520 * the beginning of the actual data portion
4521 * @this_arg_size: length of the current arg, for convenience
4522 * @current_namespace: pointer to the current namespace definition
4523 * (or internally %NULL if the current namespace is unknown)
4524 * @is_radiotap_ns: indicates whether the current namespace is the default
4525 * radiotap namespace or not
4526 *
4527 * @_rtheader: pointer to the radiotap header we are walking through
4528 * @_max_length: length of radiotap header in cpu byte ordering
4529 * @_arg_index: next argument index
4530 * @_arg: next argument pointer
4531 * @_next_bitmap: internal pointer to next present u32
4532 * @_bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present
4533 * @_vns: vendor namespace definitions
4534 * @_next_ns_data: beginning of the next namespace's data
4535 * @_reset_on_ext: internal; reset the arg index to 0 when going to the
4536 * next bitmap word
4537 *
4538 * Describes the radiotap parser state. Fields prefixed with an underscore
4539 * must not be used by users of the parser, only by the parser internally.
4540 */
4541
4542struct ieee80211_radiotap_iterator {
4543 struct ieee80211_radiotap_header *_rtheader;
4544 const struct ieee80211_radiotap_vendor_namespaces *_vns;
4545 const struct ieee80211_radiotap_namespace *current_namespace;
4546
4547 unsigned char *_arg, *_next_ns_data;
4548 __le32 *_next_bitmap;
4549
4550 unsigned char *this_arg;
4551 int this_arg_index;
4552 int this_arg_size;
4553
4554 int is_radiotap_ns;
4555
4556 int _max_length;
4557 int _arg_index;
4558 uint32_t _bitmap_shifter;
4559 int _reset_on_ext;
4560};
4561
4562int
4563ieee80211_radiotap_iterator_init(struct ieee80211_radiotap_iterator *iterator,
4564 struct ieee80211_radiotap_header *radiotap_header,
4565 int max_length,
4566 const struct ieee80211_radiotap_vendor_namespaces *vns);
4567
4568int
4569ieee80211_radiotap_iterator_next(struct ieee80211_radiotap_iterator *iterator);
4570
4571
4572extern const unsigned char rfc1042_header[6];
4573extern const unsigned char bridge_tunnel_header[6];
4574
4575/**
4576 * ieee80211_get_hdrlen_from_skb - get header length from data
4577 *
4578 * @skb: the frame
4579 *
4580 * Given an skb with a raw 802.11 header at the data pointer this function
4581 * returns the 802.11 header length.
4582 *
4583 * Return: The 802.11 header length in bytes (not including encryption
4584 * headers). Or 0 if the data in the sk_buff is too short to contain a valid
4585 * 802.11 header.
4586 */
4587unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
4588
4589/**
4590 * ieee80211_hdrlen - get header length in bytes from frame control
4591 * @fc: frame control field in little-endian format
4592 * Return: The header length in bytes.
4593 */
4594unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc);
4595
4596/**
4597 * ieee80211_get_mesh_hdrlen - get mesh extension header length
4598 * @meshhdr: the mesh extension header, only the flags field
4599 * (first byte) will be accessed
4600 * Return: The length of the extension header, which is always at
4601 * least 6 bytes and at most 18 if address 5 and 6 are present.
4602 */
4603unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr);
4604
4605/**
4606 * DOC: Data path helpers
4607 *
4608 * In addition to generic utilities, cfg80211 also offers
4609 * functions that help implement the data path for devices
4610 * that do not do the 802.11/802.3 conversion on the device.
4611 */
4612
4613/**
4614 * ieee80211_data_to_8023_exthdr - convert an 802.11 data frame to 802.3
4615 * @skb: the 802.11 data frame
4616 * @ehdr: pointer to a &struct ethhdr that will get the header, instead
4617 * of it being pushed into the SKB
4618 * @addr: the device MAC address
4619 * @iftype: the virtual interface type
4620 * @data_offset: offset of payload after the 802.11 header
4621 * Return: 0 on success. Non-zero on error.
4622 */
4623int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
4624 const u8 *addr, enum nl80211_iftype iftype,
4625 u8 data_offset);
4626
4627/**
4628 * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3
4629 * @skb: the 802.11 data frame
4630 * @addr: the device MAC address
4631 * @iftype: the virtual interface type
4632 * Return: 0 on success. Non-zero on error.
4633 */
4634static inline int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
4635 enum nl80211_iftype iftype)
4636{
4637 return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype, 0);
4638}
4639
4640/**
4641 * ieee80211_amsdu_to_8023s - decode an IEEE 802.11n A-MSDU frame
4642 *
4643 * Decode an IEEE 802.11 A-MSDU and convert it to a list of 802.3 frames.
4644 * The @list will be empty if the decode fails. The @skb must be fully
4645 * header-less before being passed in here; it is freed in this function.
4646 *
4647 * @skb: The input A-MSDU frame without any headers.
4648 * @list: The output list of 802.3 frames. It must be allocated and
4649 * initialized by by the caller.
4650 * @addr: The device MAC address.
4651 * @iftype: The device interface type.
4652 * @extra_headroom: The hardware extra headroom for SKBs in the @list.
4653 * @check_da: DA to check in the inner ethernet header, or NULL
4654 * @check_sa: SA to check in the inner ethernet header, or NULL
4655 */
4656void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
4657 const u8 *addr, enum nl80211_iftype iftype,
4658 const unsigned int extra_headroom,
4659 const u8 *check_da, const u8 *check_sa);
4660
4661/**
4662 * cfg80211_classify8021d - determine the 802.1p/1d tag for a data frame
4663 * @skb: the data frame
4664 * @qos_map: Interworking QoS mapping or %NULL if not in use
4665 * Return: The 802.1p/1d tag.
4666 */
4667unsigned int cfg80211_classify8021d(struct sk_buff *skb,
4668 struct cfg80211_qos_map *qos_map);
4669
4670/**
4671 * cfg80211_find_ie_match - match information element and byte array in data
4672 *
4673 * @eid: element ID
4674 * @ies: data consisting of IEs
4675 * @len: length of data
4676 * @match: byte array to match
4677 * @match_len: number of bytes in the match array
4678 * @match_offset: offset in the IE where the byte array should match.
4679 * If match_len is zero, this must also be set to zero.
4680 * Otherwise this must be set to 2 or more, because the first
4681 * byte is the element id, which is already compared to eid, and
4682 * the second byte is the IE length.
4683 *
4684 * Return: %NULL if the element ID could not be found or if
4685 * the element is invalid (claims to be longer than the given
4686 * data) or if the byte array doesn't match, or a pointer to the first
4687 * byte of the requested element, that is the byte containing the
4688 * element ID.
4689 *
4690 * Note: There are no checks on the element length other than
4691 * having to fit into the given data and being large enough for the
4692 * byte array to match.
4693 */
4694const u8 *cfg80211_find_ie_match(u8 eid, const u8 *ies, int len,
4695 const u8 *match, int match_len,
4696 int match_offset);
4697
4698/**
4699 * cfg80211_find_ie - find information element in data
4700 *
4701 * @eid: element ID
4702 * @ies: data consisting of IEs
4703 * @len: length of data
4704 *
4705 * Return: %NULL if the element ID could not be found or if
4706 * the element is invalid (claims to be longer than the given
4707 * data), or a pointer to the first byte of the requested
4708 * element, that is the byte containing the element ID.
4709 *
4710 * Note: There are no checks on the element length other than
4711 * having to fit into the given data.
4712 */
4713static inline const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len)
4714{
4715 return cfg80211_find_ie_match(eid, ies, len, NULL, 0, 0);
4716}
4717
4718/**
4719 * cfg80211_find_ext_ie - find information element with EID Extension in data
4720 *
4721 * @ext_eid: element ID Extension
4722 * @ies: data consisting of IEs
4723 * @len: length of data
4724 *
4725 * Return: %NULL if the extended element ID could not be found or if
4726 * the element is invalid (claims to be longer than the given
4727 * data), or a pointer to the first byte of the requested
4728 * element, that is the byte containing the element ID.
4729 *
4730 * Note: There are no checks on the element length other than
4731 * having to fit into the given data.
4732 */
4733static inline const u8 *cfg80211_find_ext_ie(u8 ext_eid, const u8 *ies, int len)
4734{
4735 return cfg80211_find_ie_match(WLAN_EID_EXTENSION, ies, len,
4736 &ext_eid, 1, 2);
4737}
4738
4739/**
4740 * cfg80211_find_vendor_ie - find vendor specific information element in data
4741 *
4742 * @oui: vendor OUI
4743 * @oui_type: vendor-specific OUI type (must be < 0xff), negative means any
4744 * @ies: data consisting of IEs
4745 * @len: length of data
4746 *
4747 * Return: %NULL if the vendor specific element ID could not be found or if the
4748 * element is invalid (claims to be longer than the given data), or a pointer to
4749 * the first byte of the requested element, that is the byte containing the
4750 * element ID.
4751 *
4752 * Note: There are no checks on the element length other than having to fit into
4753 * the given data.
4754 */
4755const u8 *cfg80211_find_vendor_ie(unsigned int oui, int oui_type,
4756 const u8 *ies, int len);
4757
4758/**
4759 * cfg80211_send_layer2_update - send layer 2 update frame
4760 *
4761 * @dev: network device
4762 * @addr: STA MAC address
4763 *
4764 * Wireless drivers can use this function to update forwarding tables in bridge
4765 * devices upon STA association.
4766 */
4767void cfg80211_send_layer2_update(struct net_device *dev, const u8 *addr);
4768
4769/**
4770 * DOC: Regulatory enforcement infrastructure
4771 *
4772 * TODO
4773 */
4774
4775/**
4776 * regulatory_hint - driver hint to the wireless core a regulatory domain
4777 * @wiphy: the wireless device giving the hint (used only for reporting
4778 * conflicts)
4779 * @alpha2: the ISO/IEC 3166 alpha2 the driver claims its regulatory domain
4780 * should be in. If @rd is set this should be NULL. Note that if you
4781 * set this to NULL you should still set rd->alpha2 to some accepted
4782 * alpha2.
4783 *
4784 * Wireless drivers can use this function to hint to the wireless core
4785 * what it believes should be the current regulatory domain by
4786 * giving it an ISO/IEC 3166 alpha2 country code it knows its regulatory
4787 * domain should be in or by providing a completely build regulatory domain.
4788 * If the driver provides an ISO/IEC 3166 alpha2 userspace will be queried
4789 * for a regulatory domain structure for the respective country.
4790 *
4791 * The wiphy must have been registered to cfg80211 prior to this call.
4792 * For cfg80211 drivers this means you must first use wiphy_register(),
4793 * for mac80211 drivers you must first use ieee80211_register_hw().
4794 *
4795 * Drivers should check the return value, its possible you can get
4796 * an -ENOMEM.
4797 *
4798 * Return: 0 on success. -ENOMEM.
4799 */
4800int regulatory_hint(struct wiphy *wiphy, const char *alpha2);
4801
4802/**
4803 * regulatory_set_wiphy_regd - set regdom info for self managed drivers
4804 * @wiphy: the wireless device we want to process the regulatory domain on
4805 * @rd: the regulatory domain informatoin to use for this wiphy
4806 *
4807 * Set the regulatory domain information for self-managed wiphys, only they
4808 * may use this function. See %REGULATORY_WIPHY_SELF_MANAGED for more
4809 * information.
4810 *
4811 * Return: 0 on success. -EINVAL, -EPERM
4812 */
4813int regulatory_set_wiphy_regd(struct wiphy *wiphy,
4814 struct ieee80211_regdomain *rd);
4815
4816/**
4817 * regulatory_set_wiphy_regd_sync_rtnl - set regdom for self-managed drivers
4818 * @wiphy: the wireless device we want to process the regulatory domain on
4819 * @rd: the regulatory domain information to use for this wiphy
4820 *
4821 * This functions requires the RTNL to be held and applies the new regdomain
4822 * synchronously to this wiphy. For more details see
4823 * regulatory_set_wiphy_regd().
4824 *
4825 * Return: 0 on success. -EINVAL, -EPERM
4826 */
4827int regulatory_set_wiphy_regd_sync_rtnl(struct wiphy *wiphy,
4828 struct ieee80211_regdomain *rd);
4829
4830/**
4831 * wiphy_apply_custom_regulatory - apply a custom driver regulatory domain
4832 * @wiphy: the wireless device we want to process the regulatory domain on
4833 * @regd: the custom regulatory domain to use for this wiphy
4834 *
4835 * Drivers can sometimes have custom regulatory domains which do not apply
4836 * to a specific country. Drivers can use this to apply such custom regulatory
4837 * domains. This routine must be called prior to wiphy registration. The
4838 * custom regulatory domain will be trusted completely and as such previous
4839 * default channel settings will be disregarded. If no rule is found for a
4840 * channel on the regulatory domain the channel will be disabled.
4841 * Drivers using this for a wiphy should also set the wiphy flag
4842 * REGULATORY_CUSTOM_REG or cfg80211 will set it for the wiphy
4843 * that called this helper.
4844 */
4845void wiphy_apply_custom_regulatory(struct wiphy *wiphy,
4846 const struct ieee80211_regdomain *regd);
4847
4848/**
4849 * freq_reg_info - get regulatory information for the given frequency
4850 * @wiphy: the wiphy for which we want to process this rule for
4851 * @center_freq: Frequency in KHz for which we want regulatory information for
4852 *
4853 * Use this function to get the regulatory rule for a specific frequency on
4854 * a given wireless device. If the device has a specific regulatory domain
4855 * it wants to follow we respect that unless a country IE has been received
4856 * and processed already.
4857 *
4858 * Return: A valid pointer, or, when an error occurs, for example if no rule
4859 * can be found, the return value is encoded using ERR_PTR(). Use IS_ERR() to
4860 * check and PTR_ERR() to obtain the numeric return value. The numeric return
4861 * value will be -ERANGE if we determine the given center_freq does not even
4862 * have a regulatory rule for a frequency range in the center_freq's band.
4863 * See freq_in_rule_band() for our current definition of a band -- this is
4864 * purely subjective and right now it's 802.11 specific.
4865 */
4866const struct ieee80211_reg_rule *freq_reg_info(struct wiphy *wiphy,
4867 u32 center_freq);
4868
4869/**
4870 * reg_initiator_name - map regulatory request initiator enum to name
4871 * @initiator: the regulatory request initiator
4872 *
4873 * You can use this to map the regulatory request initiator enum to a
4874 * proper string representation.
4875 */
4876const char *reg_initiator_name(enum nl80211_reg_initiator initiator);
4877
4878/**
4879 * DOC: Internal regulatory db functions
4880 *
4881 */
4882
4883/**
4884 * reg_query_regdb_wmm - Query internal regulatory db for wmm rule
4885 * Regulatory self-managed driver can use it to proactively
4886 *
4887 * @alpha2: the ISO/IEC 3166 alpha2 wmm rule to be queried.
4888 * @freq: the freqency(in MHz) to be queried.
4889 * @rule: pointer to store the wmm rule from the regulatory db.
4890 *
4891 * Self-managed wireless drivers can use this function to query
4892 * the internal regulatory database to check whether the given
4893 * ISO/IEC 3166 alpha2 country and freq have wmm rule limitations.
4894 *
4895 * Drivers should check the return value, its possible you can get
4896 * an -ENODATA.
4897 *
4898 * Return: 0 on success. -ENODATA.
4899 */
4900int reg_query_regdb_wmm(char *alpha2, int freq,
4901 struct ieee80211_reg_rule *rule);
4902
4903/*
4904 * callbacks for asynchronous cfg80211 methods, notification
4905 * functions and BSS handling helpers
4906 */
4907
4908/**
4909 * cfg80211_scan_done - notify that scan finished
4910 *
4911 * @request: the corresponding scan request
4912 * @info: information about the completed scan
4913 */
4914void cfg80211_scan_done(struct cfg80211_scan_request *request,
4915 struct cfg80211_scan_info *info);
4916
4917/**
4918 * cfg80211_sched_scan_results - notify that new scan results are available
4919 *
4920 * @wiphy: the wiphy which got scheduled scan results
4921 * @reqid: identifier for the related scheduled scan request
4922 */
4923void cfg80211_sched_scan_results(struct wiphy *wiphy, u64 reqid);
4924
4925/**
4926 * cfg80211_sched_scan_stopped - notify that the scheduled scan has stopped
4927 *
4928 * @wiphy: the wiphy on which the scheduled scan stopped
4929 * @reqid: identifier for the related scheduled scan request
4930 *
4931 * The driver can call this function to inform cfg80211 that the
4932 * scheduled scan had to be stopped, for whatever reason. The driver
4933 * is then called back via the sched_scan_stop operation when done.
4934 */
4935void cfg80211_sched_scan_stopped(struct wiphy *wiphy, u64 reqid);
4936
4937/**
4938 * cfg80211_sched_scan_stopped_rtnl - notify that the scheduled scan has stopped
4939 *
4940 * @wiphy: the wiphy on which the scheduled scan stopped
4941 * @reqid: identifier for the related scheduled scan request
4942 *
4943 * The driver can call this function to inform cfg80211 that the
4944 * scheduled scan had to be stopped, for whatever reason. The driver
4945 * is then called back via the sched_scan_stop operation when done.
4946 * This function should be called with rtnl locked.
4947 */
4948void cfg80211_sched_scan_stopped_rtnl(struct wiphy *wiphy, u64 reqid);
4949
4950/**
4951 * cfg80211_inform_bss_frame_data - inform cfg80211 of a received BSS frame
4952 * @wiphy: the wiphy reporting the BSS
4953 * @data: the BSS metadata
4954 * @mgmt: the management frame (probe response or beacon)
4955 * @len: length of the management frame
4956 * @gfp: context flags
4957 *
4958 * This informs cfg80211 that BSS information was found and
4959 * the BSS should be updated/added.
4960 *
4961 * Return: A referenced struct, must be released with cfg80211_put_bss()!
4962 * Or %NULL on error.
4963 */
4964struct cfg80211_bss * __must_check
4965cfg80211_inform_bss_frame_data(struct wiphy *wiphy,
4966 struct cfg80211_inform_bss *data,
4967 struct ieee80211_mgmt *mgmt, size_t len,
4968 gfp_t gfp);
4969
4970static inline struct cfg80211_bss * __must_check
4971cfg80211_inform_bss_width_frame(struct wiphy *wiphy,
4972 struct ieee80211_channel *rx_channel,
4973 enum nl80211_bss_scan_width scan_width,
4974 struct ieee80211_mgmt *mgmt, size_t len,
4975 s32 signal, gfp_t gfp)
4976{
4977 struct cfg80211_inform_bss data = {
4978 .chan = rx_channel,
4979 .scan_width = scan_width,
4980 .signal = signal,
4981 };
4982
4983 return cfg80211_inform_bss_frame_data(wiphy, &data, mgmt, len, gfp);
4984}
4985
4986static inline struct cfg80211_bss * __must_check
4987cfg80211_inform_bss_frame(struct wiphy *wiphy,
4988 struct ieee80211_channel *rx_channel,
4989 struct ieee80211_mgmt *mgmt, size_t len,
4990 s32 signal, gfp_t gfp)
4991{
4992 struct cfg80211_inform_bss data = {
4993 .chan = rx_channel,
4994 .scan_width = NL80211_BSS_CHAN_WIDTH_20,
4995 .signal = signal,
4996 };
4997
4998 return cfg80211_inform_bss_frame_data(wiphy, &data, mgmt, len, gfp);
4999}
5000
5001/**
5002 * enum cfg80211_bss_frame_type - frame type that the BSS data came from
5003 * @CFG80211_BSS_FTYPE_UNKNOWN: driver doesn't know whether the data is
5004 * from a beacon or probe response
5005 * @CFG80211_BSS_FTYPE_BEACON: data comes from a beacon
5006 * @CFG80211_BSS_FTYPE_PRESP: data comes from a probe response
5007 */
5008enum cfg80211_bss_frame_type {
5009 CFG80211_BSS_FTYPE_UNKNOWN,
5010 CFG80211_BSS_FTYPE_BEACON,
5011 CFG80211_BSS_FTYPE_PRESP,
5012};
5013
5014/**
5015 * cfg80211_inform_bss_data - inform cfg80211 of a new BSS
5016 *
5017 * @wiphy: the wiphy reporting the BSS
5018 * @data: the BSS metadata
5019 * @ftype: frame type (if known)
5020 * @bssid: the BSSID of the BSS
5021 * @tsf: the TSF sent by the peer in the beacon/probe response (or 0)
5022 * @capability: the capability field sent by the peer
5023 * @beacon_interval: the beacon interval announced by the peer
5024 * @ie: additional IEs sent by the peer
5025 * @ielen: length of the additional IEs
5026 * @gfp: context flags
5027 *
5028 * This informs cfg80211 that BSS information was found and
5029 * the BSS should be updated/added.
5030 *
5031 * Return: A referenced struct, must be released with cfg80211_put_bss()!
5032 * Or %NULL on error.
5033 */
5034struct cfg80211_bss * __must_check
5035cfg80211_inform_bss_data(struct wiphy *wiphy,
5036 struct cfg80211_inform_bss *data,
5037 enum cfg80211_bss_frame_type ftype,
5038 const u8 *bssid, u64 tsf, u16 capability,
5039 u16 beacon_interval, const u8 *ie, size_t ielen,
5040 gfp_t gfp);
5041
5042static inline struct cfg80211_bss * __must_check
5043cfg80211_inform_bss_width(struct wiphy *wiphy,
5044 struct ieee80211_channel *rx_channel,
5045 enum nl80211_bss_scan_width scan_width,
5046 enum cfg80211_bss_frame_type ftype,
5047 const u8 *bssid, u64 tsf, u16 capability,
5048 u16 beacon_interval, const u8 *ie, size_t ielen,
5049 s32 signal, gfp_t gfp)
5050{
5051 struct cfg80211_inform_bss data = {
5052 .chan = rx_channel,
5053 .scan_width = scan_width,
5054 .signal = signal,
5055 };
5056
5057 return cfg80211_inform_bss_data(wiphy, &data, ftype, bssid, tsf,
5058 capability, beacon_interval, ie, ielen,
5059 gfp);
5060}
5061
5062static inline struct cfg80211_bss * __must_check
5063cfg80211_inform_bss(struct wiphy *wiphy,
5064 struct ieee80211_channel *rx_channel,
5065 enum cfg80211_bss_frame_type ftype,
5066 const u8 *bssid, u64 tsf, u16 capability,
5067 u16 beacon_interval, const u8 *ie, size_t ielen,
5068 s32 signal, gfp_t gfp)
5069{
5070 struct cfg80211_inform_bss data = {
5071 .chan = rx_channel,
5072 .scan_width = NL80211_BSS_CHAN_WIDTH_20,
5073 .signal = signal,
5074 };
5075
5076 return cfg80211_inform_bss_data(wiphy, &data, ftype, bssid, tsf,
5077 capability, beacon_interval, ie, ielen,
5078 gfp);
5079}
5080
5081/**
5082 * cfg80211_get_bss - get a BSS reference
5083 * @wiphy: the wiphy this BSS struct belongs to
5084 * @channel: the channel to search on (or %NULL)
5085 * @bssid: the desired BSSID (or %NULL)
5086 * @ssid: the desired SSID (or %NULL)
5087 * @ssid_len: length of the SSID (or 0)
5088 * @bss_type: type of BSS, see &enum ieee80211_bss_type
5089 * @privacy: privacy filter, see &enum ieee80211_privacy
5090 */
5091struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
5092 struct ieee80211_channel *channel,
5093 const u8 *bssid,
5094 const u8 *ssid, size_t ssid_len,
5095 enum ieee80211_bss_type bss_type,
5096 enum ieee80211_privacy privacy);
5097static inline struct cfg80211_bss *
5098cfg80211_get_ibss(struct wiphy *wiphy,
5099 struct ieee80211_channel *channel,
5100 const u8 *ssid, size_t ssid_len)
5101{
5102 return cfg80211_get_bss(wiphy, channel, NULL, ssid, ssid_len,
5103 IEEE80211_BSS_TYPE_IBSS,
5104 IEEE80211_PRIVACY_ANY);
5105}
5106
5107/**
5108 * cfg80211_ref_bss - reference BSS struct
5109 * @wiphy: the wiphy this BSS struct belongs to
5110 * @bss: the BSS struct to reference
5111 *
5112 * Increments the refcount of the given BSS struct.
5113 */
5114void cfg80211_ref_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
5115
5116/**
5117 * cfg80211_put_bss - unref BSS struct
5118 * @wiphy: the wiphy this BSS struct belongs to
5119 * @bss: the BSS struct
5120 *
5121 * Decrements the refcount of the given BSS struct.
5122 */
5123void cfg80211_put_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
5124
5125/**
5126 * cfg80211_unlink_bss - unlink BSS from internal data structures
5127 * @wiphy: the wiphy
5128 * @bss: the bss to remove
5129 *
5130 * This function removes the given BSS from the internal data structures
5131 * thereby making it no longer show up in scan results etc. Use this
5132 * function when you detect a BSS is gone. Normally BSSes will also time
5133 * out, so it is not necessary to use this function at all.
5134 */
5135void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
5136
5137static inline enum nl80211_bss_scan_width
5138cfg80211_chandef_to_scan_width(const struct cfg80211_chan_def *chandef)
5139{
5140 switch (chandef->width) {
5141 case NL80211_CHAN_WIDTH_5:
5142 return NL80211_BSS_CHAN_WIDTH_5;
5143 case NL80211_CHAN_WIDTH_10:
5144 return NL80211_BSS_CHAN_WIDTH_10;
5145 default:
5146 return NL80211_BSS_CHAN_WIDTH_20;
5147 }
5148}
5149
5150/**
5151 * cfg80211_rx_mlme_mgmt - notification of processed MLME management frame
5152 * @dev: network device
5153 * @buf: authentication frame (header + body)
5154 * @len: length of the frame data
5155 *
5156 * This function is called whenever an authentication, disassociation or
5157 * deauthentication frame has been received and processed in station mode.
5158 * After being asked to authenticate via cfg80211_ops::auth() the driver must
5159 * call either this function or cfg80211_auth_timeout().
5160 * After being asked to associate via cfg80211_ops::assoc() the driver must
5161 * call either this function or cfg80211_auth_timeout().
5162 * While connected, the driver must calls this for received and processed
5163 * disassociation and deauthentication frames. If the frame couldn't be used
5164 * because it was unprotected, the driver must call the function
5165 * cfg80211_rx_unprot_mlme_mgmt() instead.
5166 *
5167 * This function may sleep. The caller must hold the corresponding wdev's mutex.
5168 */
5169void cfg80211_rx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len);
5170
5171/**
5172 * cfg80211_auth_timeout - notification of timed out authentication
5173 * @dev: network device
5174 * @addr: The MAC address of the device with which the authentication timed out
5175 *
5176 * This function may sleep. The caller must hold the corresponding wdev's
5177 * mutex.
5178 */
5179void cfg80211_auth_timeout(struct net_device *dev, const u8 *addr);
5180
5181/**
5182 * cfg80211_rx_assoc_resp - notification of processed association response
5183 * @dev: network device
5184 * @bss: the BSS that association was requested with, ownership of the pointer
5185 * moves to cfg80211 in this call
5186 * @buf: authentication frame (header + body)
5187 * @len: length of the frame data
5188 * @uapsd_queues: bitmap of queues configured for uapsd. Same format
5189 * as the AC bitmap in the QoS info field
5190 *
5191 * After being asked to associate via cfg80211_ops::assoc() the driver must
5192 * call either this function or cfg80211_auth_timeout().
5193 *
5194 * This function may sleep. The caller must hold the corresponding wdev's mutex.
5195 */
5196void cfg80211_rx_assoc_resp(struct net_device *dev,
5197 struct cfg80211_bss *bss,
5198 const u8 *buf, size_t len,
5199 int uapsd_queues);
5200
5201/**
5202 * cfg80211_assoc_timeout - notification of timed out association
5203 * @dev: network device
5204 * @bss: The BSS entry with which association timed out.
5205 *
5206 * This function may sleep. The caller must hold the corresponding wdev's mutex.
5207 */
5208void cfg80211_assoc_timeout(struct net_device *dev, struct cfg80211_bss *bss);
5209
5210/**
5211 * cfg80211_abandon_assoc - notify cfg80211 of abandoned association attempt
5212 * @dev: network device
5213 * @bss: The BSS entry with which association was abandoned.
5214 *
5215 * Call this whenever - for reasons reported through other API, like deauth RX,
5216 * an association attempt was abandoned.
5217 * This function may sleep. The caller must hold the corresponding wdev's mutex.
5218 */
5219void cfg80211_abandon_assoc(struct net_device *dev, struct cfg80211_bss *bss);
5220
5221/**
5222 * cfg80211_tx_mlme_mgmt - notification of transmitted deauth/disassoc frame
5223 * @dev: network device
5224 * @buf: 802.11 frame (header + body)
5225 * @len: length of the frame data
5226 *
5227 * This function is called whenever deauthentication has been processed in
5228 * station mode. This includes both received deauthentication frames and
5229 * locally generated ones. This function may sleep. The caller must hold the
5230 * corresponding wdev's mutex.
5231 */
5232void cfg80211_tx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len);
5233
5234/**
5235 * cfg80211_rx_unprot_mlme_mgmt - notification of unprotected mlme mgmt frame
5236 * @dev: network device
5237 * @buf: deauthentication frame (header + body)
5238 * @len: length of the frame data
5239 *
5240 * This function is called whenever a received deauthentication or dissassoc
5241 * frame has been dropped in station mode because of MFP being used but the
5242 * frame was not protected. This function may sleep.
5243 */
5244void cfg80211_rx_unprot_mlme_mgmt(struct net_device *dev,
5245 const u8 *buf, size_t len);
5246
5247/**
5248 * cfg80211_michael_mic_failure - notification of Michael MIC failure (TKIP)
5249 * @dev: network device
5250 * @addr: The source MAC address of the frame
5251 * @key_type: The key type that the received frame used
5252 * @key_id: Key identifier (0..3). Can be -1 if missing.
5253 * @tsc: The TSC value of the frame that generated the MIC failure (6 octets)
5254 * @gfp: allocation flags
5255 *
5256 * This function is called whenever the local MAC detects a MIC failure in a
5257 * received frame. This matches with MLME-MICHAELMICFAILURE.indication()
5258 * primitive.
5259 */
5260void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
5261 enum nl80211_key_type key_type, int key_id,
5262 const u8 *tsc, gfp_t gfp);
5263
5264/**
5265 * cfg80211_ibss_joined - notify cfg80211 that device joined an IBSS
5266 *
5267 * @dev: network device
5268 * @bssid: the BSSID of the IBSS joined
5269 * @channel: the channel of the IBSS joined
5270 * @gfp: allocation flags
5271 *
5272 * This function notifies cfg80211 that the device joined an IBSS or
5273 * switched to a different BSSID. Before this function can be called,
5274 * either a beacon has to have been received from the IBSS, or one of
5275 * the cfg80211_inform_bss{,_frame} functions must have been called
5276 * with the locally generated beacon -- this guarantees that there is
5277 * always a scan result for this IBSS. cfg80211 will handle the rest.
5278 */
5279void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
5280 struct ieee80211_channel *channel, gfp_t gfp);
5281
5282/**
5283 * cfg80211_notify_new_candidate - notify cfg80211 of a new mesh peer candidate
5284 *
5285 * @dev: network device
5286 * @macaddr: the MAC address of the new candidate
5287 * @ie: information elements advertised by the peer candidate
5288 * @ie_len: lenght of the information elements buffer
5289 * @gfp: allocation flags
5290 *
5291 * This function notifies cfg80211 that the mesh peer candidate has been
5292 * detected, most likely via a beacon or, less likely, via a probe response.
5293 * cfg80211 then sends a notification to userspace.
5294 */
5295void cfg80211_notify_new_peer_candidate(struct net_device *dev,
5296 const u8 *macaddr, const u8 *ie, u8 ie_len, gfp_t gfp);
5297
5298/**
5299 * DOC: RFkill integration
5300 *
5301 * RFkill integration in cfg80211 is almost invisible to drivers,
5302 * as cfg80211 automatically registers an rfkill instance for each
5303 * wireless device it knows about. Soft kill is also translated
5304 * into disconnecting and turning all interfaces off, drivers are
5305 * expected to turn off the device when all interfaces are down.
5306 *
5307 * However, devices may have a hard RFkill line, in which case they
5308 * also need to interact with the rfkill subsystem, via cfg80211.
5309 * They can do this with a few helper functions documented here.
5310 */
5311
5312/**
5313 * wiphy_rfkill_set_hw_state - notify cfg80211 about hw block state
5314 * @wiphy: the wiphy
5315 * @blocked: block status
5316 */
5317void wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool blocked);
5318
5319/**
5320 * wiphy_rfkill_start_polling - start polling rfkill
5321 * @wiphy: the wiphy
5322 */
5323void wiphy_rfkill_start_polling(struct wiphy *wiphy);
5324
5325/**
5326 * wiphy_rfkill_stop_polling - stop polling rfkill
5327 * @wiphy: the wiphy
5328 */
5329void wiphy_rfkill_stop_polling(struct wiphy *wiphy);
5330
5331/**
5332 * DOC: Vendor commands
5333 *
5334 * Occasionally, there are special protocol or firmware features that
5335 * can't be implemented very openly. For this and similar cases, the
5336 * vendor command functionality allows implementing the features with
5337 * (typically closed-source) userspace and firmware, using nl80211 as
5338 * the configuration mechanism.
5339 *
5340 * A driver supporting vendor commands must register them as an array
5341 * in struct wiphy, with handlers for each one, each command has an
5342 * OUI and sub command ID to identify it.
5343 *
5344 * Note that this feature should not be (ab)used to implement protocol
5345 * features that could openly be shared across drivers. In particular,
5346 * it must never be required to use vendor commands to implement any
5347 * "normal" functionality that higher-level userspace like connection
5348 * managers etc. need.
5349 */
5350
5351struct sk_buff *__cfg80211_alloc_reply_skb(struct wiphy *wiphy,
5352 enum nl80211_commands cmd,
5353 enum nl80211_attrs attr,
5354 int approxlen);
5355
5356struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy,
5357 struct wireless_dev *wdev,
5358 enum nl80211_commands cmd,
5359 enum nl80211_attrs attr,
5360 int vendor_event_idx,
5361 int approxlen, gfp_t gfp);
5362
5363void __cfg80211_send_event_skb(struct sk_buff *skb, gfp_t gfp);
5364
5365/**
5366 * cfg80211_vendor_cmd_alloc_reply_skb - allocate vendor command reply
5367 * @wiphy: the wiphy
5368 * @approxlen: an upper bound of the length of the data that will
5369 * be put into the skb
5370 *
5371 * This function allocates and pre-fills an skb for a reply to
5372 * a vendor command. Since it is intended for a reply, calling
5373 * it outside of a vendor command's doit() operation is invalid.
5374 *
5375 * The returned skb is pre-filled with some identifying data in
5376 * a way that any data that is put into the skb (with skb_put(),
5377 * nla_put() or similar) will end up being within the
5378 * %NL80211_ATTR_VENDOR_DATA attribute, so all that needs to be done
5379 * with the skb is adding data for the corresponding userspace tool
5380 * which can then read that data out of the vendor data attribute.
5381 * You must not modify the skb in any other way.
5382 *
5383 * When done, call cfg80211_vendor_cmd_reply() with the skb and return
5384 * its error code as the result of the doit() operation.
5385 *
5386 * Return: An allocated and pre-filled skb. %NULL if any errors happen.
5387 */
5388static inline struct sk_buff *
5389cfg80211_vendor_cmd_alloc_reply_skb(struct wiphy *wiphy, int approxlen)
5390{
5391 return __cfg80211_alloc_reply_skb(wiphy, NL80211_CMD_VENDOR,
5392 NL80211_ATTR_VENDOR_DATA, approxlen);
5393}
5394
5395/**
5396 * cfg80211_vendor_cmd_reply - send the reply skb
5397 * @skb: The skb, must have been allocated with
5398 * cfg80211_vendor_cmd_alloc_reply_skb()
5399 *
5400 * Since calling this function will usually be the last thing
5401 * before returning from the vendor command doit() you should
5402 * return the error code. Note that this function consumes the
5403 * skb regardless of the return value.
5404 *
5405 * Return: An error code or 0 on success.
5406 */
5407int cfg80211_vendor_cmd_reply(struct sk_buff *skb);
5408
5409/**
5410 * cfg80211_vendor_event_alloc - allocate vendor-specific event skb
5411 * @wiphy: the wiphy
5412 * @wdev: the wireless device
5413 * @event_idx: index of the vendor event in the wiphy's vendor_events
5414 * @approxlen: an upper bound of the length of the data that will
5415 * be put into the skb
5416 * @gfp: allocation flags
5417 *
5418 * This function allocates and pre-fills an skb for an event on the
5419 * vendor-specific multicast group.
5420 *
5421 * If wdev != NULL, both the ifindex and identifier of the specified
5422 * wireless device are added to the event message before the vendor data
5423 * attribute.
5424 *
5425 * When done filling the skb, call cfg80211_vendor_event() with the
5426 * skb to send the event.
5427 *
5428 * Return: An allocated and pre-filled skb. %NULL if any errors happen.
5429 */
5430static inline struct sk_buff *
5431cfg80211_vendor_event_alloc(struct wiphy *wiphy, struct wireless_dev *wdev,
5432 int approxlen, int event_idx, gfp_t gfp)
5433{
5434 return __cfg80211_alloc_event_skb(wiphy, wdev, NL80211_CMD_VENDOR,
5435 NL80211_ATTR_VENDOR_DATA,
5436 event_idx, approxlen, gfp);
5437}
5438
5439/**
5440 * cfg80211_vendor_event - send the event
5441 * @skb: The skb, must have been allocated with cfg80211_vendor_event_alloc()
5442 * @gfp: allocation flags
5443 *
5444 * This function sends the given @skb, which must have been allocated
5445 * by cfg80211_vendor_event_alloc(), as an event. It always consumes it.
5446 */
5447static inline void cfg80211_vendor_event(struct sk_buff *skb, gfp_t gfp)
5448{
5449 __cfg80211_send_event_skb(skb, gfp);
5450}
5451
5452#ifdef CONFIG_NL80211_TESTMODE
5453/**
5454 * DOC: Test mode
5455 *
5456 * Test mode is a set of utility functions to allow drivers to
5457 * interact with driver-specific tools to aid, for instance,
5458 * factory programming.
5459 *
5460 * This chapter describes how drivers interact with it, for more
5461 * information see the nl80211 book's chapter on it.
5462 */
5463
5464/**
5465 * cfg80211_testmode_alloc_reply_skb - allocate testmode reply
5466 * @wiphy: the wiphy
5467 * @approxlen: an upper bound of the length of the data that will
5468 * be put into the skb
5469 *
5470 * This function allocates and pre-fills an skb for a reply to
5471 * the testmode command. Since it is intended for a reply, calling
5472 * it outside of the @testmode_cmd operation is invalid.
5473 *
5474 * The returned skb is pre-filled with the wiphy index and set up in
5475 * a way that any data that is put into the skb (with skb_put(),
5476 * nla_put() or similar) will end up being within the
5477 * %NL80211_ATTR_TESTDATA attribute, so all that needs to be done
5478 * with the skb is adding data for the corresponding userspace tool
5479 * which can then read that data out of the testdata attribute. You
5480 * must not modify the skb in any other way.
5481 *
5482 * When done, call cfg80211_testmode_reply() with the skb and return
5483 * its error code as the result of the @testmode_cmd operation.
5484 *
5485 * Return: An allocated and pre-filled skb. %NULL if any errors happen.
5486 */
5487static inline struct sk_buff *
5488cfg80211_testmode_alloc_reply_skb(struct wiphy *wiphy, int approxlen)
5489{
5490 return __cfg80211_alloc_reply_skb(wiphy, NL80211_CMD_TESTMODE,
5491 NL80211_ATTR_TESTDATA, approxlen);
5492}
5493
5494/**
5495 * cfg80211_testmode_reply - send the reply skb
5496 * @skb: The skb, must have been allocated with
5497 * cfg80211_testmode_alloc_reply_skb()
5498 *
5499 * Since calling this function will usually be the last thing
5500 * before returning from the @testmode_cmd you should return
5501 * the error code. Note that this function consumes the skb
5502 * regardless of the return value.
5503 *
5504 * Return: An error code or 0 on success.
5505 */
5506static inline int cfg80211_testmode_reply(struct sk_buff *skb)
5507{
5508 return cfg80211_vendor_cmd_reply(skb);
5509}
5510
5511/**
5512 * cfg80211_testmode_alloc_event_skb - allocate testmode event
5513 * @wiphy: the wiphy
5514 * @approxlen: an upper bound of the length of the data that will
5515 * be put into the skb
5516 * @gfp: allocation flags
5517 *
5518 * This function allocates and pre-fills an skb for an event on the
5519 * testmode multicast group.
5520 *
5521 * The returned skb is set up in the same way as with
5522 * cfg80211_testmode_alloc_reply_skb() but prepared for an event. As
5523 * there, you should simply add data to it that will then end up in the
5524 * %NL80211_ATTR_TESTDATA attribute. Again, you must not modify the skb
5525 * in any other way.
5526 *
5527 * When done filling the skb, call cfg80211_testmode_event() with the
5528 * skb to send the event.
5529 *
5530 * Return: An allocated and pre-filled skb. %NULL if any errors happen.
5531 */
5532static inline struct sk_buff *
5533cfg80211_testmode_alloc_event_skb(struct wiphy *wiphy, int approxlen, gfp_t gfp)
5534{
5535 return __cfg80211_alloc_event_skb(wiphy, NULL, NL80211_CMD_TESTMODE,
5536 NL80211_ATTR_TESTDATA, -1,
5537 approxlen, gfp);
5538}
5539
5540/**
5541 * cfg80211_testmode_event - send the event
5542 * @skb: The skb, must have been allocated with
5543 * cfg80211_testmode_alloc_event_skb()
5544 * @gfp: allocation flags
5545 *
5546 * This function sends the given @skb, which must have been allocated
5547 * by cfg80211_testmode_alloc_event_skb(), as an event. It always
5548 * consumes it.
5549 */
5550static inline void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
5551{
5552 __cfg80211_send_event_skb(skb, gfp);
5553}
5554
5555#define CFG80211_TESTMODE_CMD(cmd) .testmode_cmd = (cmd),
5556#define CFG80211_TESTMODE_DUMP(cmd) .testmode_dump = (cmd),
5557#else
5558#define CFG80211_TESTMODE_CMD(cmd)
5559#define CFG80211_TESTMODE_DUMP(cmd)
5560#endif
5561
5562/**
5563 * struct cfg80211_fils_resp_params - FILS connection response params
5564 * @kek: KEK derived from a successful FILS connection (may be %NULL)
5565 * @kek_len: Length of @fils_kek in octets
5566 * @update_erp_next_seq_num: Boolean value to specify whether the value in
5567 * @erp_next_seq_num is valid.
5568 * @erp_next_seq_num: The next sequence number to use in ERP message in
5569 * FILS Authentication. This value should be specified irrespective of the
5570 * status for a FILS connection.
5571 * @pmk: A new PMK if derived from a successful FILS connection (may be %NULL).
5572 * @pmk_len: Length of @pmk in octets
5573 * @pmkid: A new PMKID if derived from a successful FILS connection or the PMKID
5574 * used for this FILS connection (may be %NULL).
5575 */
5576struct cfg80211_fils_resp_params {
5577 const u8 *kek;
5578 size_t kek_len;
5579 bool update_erp_next_seq_num;
5580 u16 erp_next_seq_num;
5581 const u8 *pmk;
5582 size_t pmk_len;
5583 const u8 *pmkid;
5584};
5585
5586/**
5587 * struct cfg80211_connect_resp_params - Connection response params
5588 * @status: Status code, %WLAN_STATUS_SUCCESS for successful connection, use
5589 * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
5590 * the real status code for failures. If this call is used to report a
5591 * failure due to a timeout (e.g., not receiving an Authentication frame
5592 * from the AP) instead of an explicit rejection by the AP, -1 is used to
5593 * indicate that this is a failure, but without a status code.
5594 * @timeout_reason is used to report the reason for the timeout in that
5595 * case.
5596 * @bssid: The BSSID of the AP (may be %NULL)
5597 * @bss: Entry of bss to which STA got connected to, can be obtained through
5598 * cfg80211_get_bss() (may be %NULL). Only one parameter among @bssid and
5599 * @bss needs to be specified.
5600 * @req_ie: Association request IEs (may be %NULL)
5601 * @req_ie_len: Association request IEs length
5602 * @resp_ie: Association response IEs (may be %NULL)
5603 * @resp_ie_len: Association response IEs length
5604 * @fils: FILS connection response parameters.
5605 * @timeout_reason: Reason for connection timeout. This is used when the
5606 * connection fails due to a timeout instead of an explicit rejection from
5607 * the AP. %NL80211_TIMEOUT_UNSPECIFIED is used when the timeout reason is
5608 * not known. This value is used only if @status < 0 to indicate that the
5609 * failure is due to a timeout and not due to explicit rejection by the AP.
5610 * This value is ignored in other cases (@status >= 0).
5611 */
5612struct cfg80211_connect_resp_params {
5613 int status;
5614 const u8 *bssid;
5615 struct cfg80211_bss *bss;
5616 const u8 *req_ie;
5617 size_t req_ie_len;
5618 const u8 *resp_ie;
5619 size_t resp_ie_len;
5620 struct cfg80211_fils_resp_params fils;
5621 enum nl80211_timeout_reason timeout_reason;
5622};
5623
5624/**
5625 * cfg80211_connect_done - notify cfg80211 of connection result
5626 *
5627 * @dev: network device
5628 * @params: connection response parameters
5629 * @gfp: allocation flags
5630 *
5631 * It should be called by the underlying driver once execution of the connection
5632 * request from connect() has been completed. This is similar to
5633 * cfg80211_connect_bss(), but takes a structure pointer for connection response
5634 * parameters. Only one of the functions among cfg80211_connect_bss(),
5635 * cfg80211_connect_result(), cfg80211_connect_timeout(),
5636 * and cfg80211_connect_done() should be called.
5637 */
5638void cfg80211_connect_done(struct net_device *dev,
5639 struct cfg80211_connect_resp_params *params,
5640 gfp_t gfp);
5641
5642/**
5643 * cfg80211_connect_bss - notify cfg80211 of connection result
5644 *
5645 * @dev: network device
5646 * @bssid: the BSSID of the AP
5647 * @bss: entry of bss to which STA got connected to, can be obtained
5648 * through cfg80211_get_bss (may be %NULL)
5649 * @req_ie: association request IEs (maybe be %NULL)
5650 * @req_ie_len: association request IEs length
5651 * @resp_ie: association response IEs (may be %NULL)
5652 * @resp_ie_len: assoc response IEs length
5653 * @status: status code, %WLAN_STATUS_SUCCESS for successful connection, use
5654 * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
5655 * the real status code for failures. If this call is used to report a
5656 * failure due to a timeout (e.g., not receiving an Authentication frame
5657 * from the AP) instead of an explicit rejection by the AP, -1 is used to
5658 * indicate that this is a failure, but without a status code.
5659 * @timeout_reason is used to report the reason for the timeout in that
5660 * case.
5661 * @gfp: allocation flags
5662 * @timeout_reason: reason for connection timeout. This is used when the
5663 * connection fails due to a timeout instead of an explicit rejection from
5664 * the AP. %NL80211_TIMEOUT_UNSPECIFIED is used when the timeout reason is
5665 * not known. This value is used only if @status < 0 to indicate that the
5666 * failure is due to a timeout and not due to explicit rejection by the AP.
5667 * This value is ignored in other cases (@status >= 0).
5668 *
5669 * It should be called by the underlying driver once execution of the connection
5670 * request from connect() has been completed. This is similar to
5671 * cfg80211_connect_result(), but with the option of identifying the exact bss
5672 * entry for the connection. Only one of the functions among
5673 * cfg80211_connect_bss(), cfg80211_connect_result(),
5674 * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
5675 */
5676static inline void
5677cfg80211_connect_bss(struct net_device *dev, const u8 *bssid,
5678 struct cfg80211_bss *bss, const u8 *req_ie,
5679 size_t req_ie_len, const u8 *resp_ie,
5680 size_t resp_ie_len, int status, gfp_t gfp,
5681 enum nl80211_timeout_reason timeout_reason)
5682{
5683 struct cfg80211_connect_resp_params params;
5684
5685 memset(&params, 0, sizeof(params));
5686 params.status = status;
5687 params.bssid = bssid;
5688 params.bss = bss;
5689 params.req_ie = req_ie;
5690 params.req_ie_len = req_ie_len;
5691 params.resp_ie = resp_ie;
5692 params.resp_ie_len = resp_ie_len;
5693 params.timeout_reason = timeout_reason;
5694
5695 cfg80211_connect_done(dev, &params, gfp);
5696}
5697
5698/**
5699 * cfg80211_connect_result - notify cfg80211 of connection result
5700 *
5701 * @dev: network device
5702 * @bssid: the BSSID of the AP
5703 * @req_ie: association request IEs (maybe be %NULL)
5704 * @req_ie_len: association request IEs length
5705 * @resp_ie: association response IEs (may be %NULL)
5706 * @resp_ie_len: assoc response IEs length
5707 * @status: status code, %WLAN_STATUS_SUCCESS for successful connection, use
5708 * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
5709 * the real status code for failures.
5710 * @gfp: allocation flags
5711 *
5712 * It should be called by the underlying driver once execution of the connection
5713 * request from connect() has been completed. This is similar to
5714 * cfg80211_connect_bss() which allows the exact bss entry to be specified. Only
5715 * one of the functions among cfg80211_connect_bss(), cfg80211_connect_result(),
5716 * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
5717 */
5718static inline void
5719cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
5720 const u8 *req_ie, size_t req_ie_len,
5721 const u8 *resp_ie, size_t resp_ie_len,
5722 u16 status, gfp_t gfp)
5723{
5724 cfg80211_connect_bss(dev, bssid, NULL, req_ie, req_ie_len, resp_ie,
5725 resp_ie_len, status, gfp,
5726 NL80211_TIMEOUT_UNSPECIFIED);
5727}
5728
5729/**
5730 * cfg80211_connect_timeout - notify cfg80211 of connection timeout
5731 *
5732 * @dev: network device
5733 * @bssid: the BSSID of the AP
5734 * @req_ie: association request IEs (maybe be %NULL)
5735 * @req_ie_len: association request IEs length
5736 * @gfp: allocation flags
5737 * @timeout_reason: reason for connection timeout.
5738 *
5739 * It should be called by the underlying driver whenever connect() has failed
5740 * in a sequence where no explicit authentication/association rejection was
5741 * received from the AP. This could happen, e.g., due to not being able to send
5742 * out the Authentication or Association Request frame or timing out while
5743 * waiting for the response. Only one of the functions among
5744 * cfg80211_connect_bss(), cfg80211_connect_result(),
5745 * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
5746 */
5747static inline void
5748cfg80211_connect_timeout(struct net_device *dev, const u8 *bssid,
5749 const u8 *req_ie, size_t req_ie_len, gfp_t gfp,
5750 enum nl80211_timeout_reason timeout_reason)
5751{
5752 cfg80211_connect_bss(dev, bssid, NULL, req_ie, req_ie_len, NULL, 0, -1,
5753 gfp, timeout_reason);
5754}
5755
5756/**
5757 * struct cfg80211_roam_info - driver initiated roaming information
5758 *
5759 * @channel: the channel of the new AP
5760 * @bss: entry of bss to which STA got roamed (may be %NULL if %bssid is set)
5761 * @bssid: the BSSID of the new AP (may be %NULL if %bss is set)
5762 * @req_ie: association request IEs (maybe be %NULL)
5763 * @req_ie_len: association request IEs length
5764 * @resp_ie: association response IEs (may be %NULL)
5765 * @resp_ie_len: assoc response IEs length
5766 * @fils: FILS related roaming information.
5767 */
5768struct cfg80211_roam_info {
5769 struct ieee80211_channel *channel;
5770 struct cfg80211_bss *bss;
5771 const u8 *bssid;
5772 const u8 *req_ie;
5773 size_t req_ie_len;
5774 const u8 *resp_ie;
5775 size_t resp_ie_len;
5776 struct cfg80211_fils_resp_params fils;
5777};
5778
5779/**
5780 * cfg80211_roamed - notify cfg80211 of roaming
5781 *
5782 * @dev: network device
5783 * @info: information about the new BSS. struct &cfg80211_roam_info.
5784 * @gfp: allocation flags
5785 *
5786 * This function may be called with the driver passing either the BSSID of the
5787 * new AP or passing the bss entry to avoid a race in timeout of the bss entry.
5788 * It should be called by the underlying driver whenever it roamed from one AP
5789 * to another while connected. Drivers which have roaming implemented in
5790 * firmware should pass the bss entry to avoid a race in bss entry timeout where
5791 * the bss entry of the new AP is seen in the driver, but gets timed out by the
5792 * time it is accessed in __cfg80211_roamed() due to delay in scheduling
5793 * rdev->event_work. In case of any failures, the reference is released
5794 * either in cfg80211_roamed() or in __cfg80211_romed(), Otherwise, it will be
5795 * released while diconneting from the current bss.
5796 */
5797void cfg80211_roamed(struct net_device *dev, struct cfg80211_roam_info *info,
5798 gfp_t gfp);
5799
5800/**
5801 * cfg80211_port_authorized - notify cfg80211 of successful security association
5802 *
5803 * @dev: network device
5804 * @bssid: the BSSID of the AP
5805 * @gfp: allocation flags
5806 *
5807 * This function should be called by a driver that supports 4 way handshake
5808 * offload after a security association was successfully established (i.e.,
5809 * the 4 way handshake was completed successfully). The call to this function
5810 * should be preceded with a call to cfg80211_connect_result(),
5811 * cfg80211_connect_done(), cfg80211_connect_bss() or cfg80211_roamed() to
5812 * indicate the 802.11 association.
5813 */
5814void cfg80211_port_authorized(struct net_device *dev, const u8 *bssid,
5815 gfp_t gfp);
5816
5817/**
5818 * cfg80211_disconnected - notify cfg80211 that connection was dropped
5819 *
5820 * @dev: network device
5821 * @ie: information elements of the deauth/disassoc frame (may be %NULL)
5822 * @ie_len: length of IEs
5823 * @reason: reason code for the disconnection, set it to 0 if unknown
5824 * @locally_generated: disconnection was requested locally
5825 * @gfp: allocation flags
5826 *
5827 * After it calls this function, the driver should enter an idle state
5828 * and not try to connect to any AP any more.
5829 */
5830void cfg80211_disconnected(struct net_device *dev, u16 reason,
5831 const u8 *ie, size_t ie_len,
5832 bool locally_generated, gfp_t gfp);
5833
5834/**
5835 * cfg80211_ready_on_channel - notification of remain_on_channel start
5836 * @wdev: wireless device
5837 * @cookie: the request cookie
5838 * @chan: The current channel (from remain_on_channel request)
5839 * @duration: Duration in milliseconds that the driver intents to remain on the
5840 * channel
5841 * @gfp: allocation flags
5842 */
5843void cfg80211_ready_on_channel(struct wireless_dev *wdev, u64 cookie,
5844 struct ieee80211_channel *chan,
5845 unsigned int duration, gfp_t gfp);
5846
5847/**
5848 * cfg80211_remain_on_channel_expired - remain_on_channel duration expired
5849 * @wdev: wireless device
5850 * @cookie: the request cookie
5851 * @chan: The current channel (from remain_on_channel request)
5852 * @gfp: allocation flags
5853 */
5854void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie,
5855 struct ieee80211_channel *chan,
5856 gfp_t gfp);
5857
5858/**
5859 * cfg80211_sinfo_alloc_tid_stats - allocate per-tid statistics.
5860 *
5861 * @sinfo: the station information
5862 * @gfp: allocation flags
5863 */
5864int cfg80211_sinfo_alloc_tid_stats(struct station_info *sinfo, gfp_t gfp);
5865
5866/**
5867 * cfg80211_sinfo_release_content - release contents of station info
5868 * @sinfo: the station information
5869 *
5870 * Releases any potentially allocated sub-information of the station
5871 * information, but not the struct itself (since it's typically on
5872 * the stack.)
5873 */
5874static inline void cfg80211_sinfo_release_content(struct station_info *sinfo)
5875{
5876 kfree(sinfo->pertid);
5877}
5878
5879/**
5880 * cfg80211_new_sta - notify userspace about station
5881 *
5882 * @dev: the netdev
5883 * @mac_addr: the station's address
5884 * @sinfo: the station information
5885 * @gfp: allocation flags
5886 */
5887void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
5888 struct station_info *sinfo, gfp_t gfp);
5889
5890/**
5891 * cfg80211_del_sta_sinfo - notify userspace about deletion of a station
5892 * @dev: the netdev
5893 * @mac_addr: the station's address
5894 * @sinfo: the station information/statistics
5895 * @gfp: allocation flags
5896 */
5897void cfg80211_del_sta_sinfo(struct net_device *dev, const u8 *mac_addr,
5898 struct station_info *sinfo, gfp_t gfp);
5899
5900/**
5901 * cfg80211_del_sta - notify userspace about deletion of a station
5902 *
5903 * @dev: the netdev
5904 * @mac_addr: the station's address
5905 * @gfp: allocation flags
5906 */
5907static inline void cfg80211_del_sta(struct net_device *dev,
5908 const u8 *mac_addr, gfp_t gfp)
5909{
5910 cfg80211_del_sta_sinfo(dev, mac_addr, NULL, gfp);
5911}
5912
5913/**
5914 * cfg80211_conn_failed - connection request failed notification
5915 *
5916 * @dev: the netdev
5917 * @mac_addr: the station's address
5918 * @reason: the reason for connection failure
5919 * @gfp: allocation flags
5920 *
5921 * Whenever a station tries to connect to an AP and if the station
5922 * could not connect to the AP as the AP has rejected the connection
5923 * for some reasons, this function is called.
5924 *
5925 * The reason for connection failure can be any of the value from
5926 * nl80211_connect_failed_reason enum
5927 */
5928void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr,
5929 enum nl80211_connect_failed_reason reason,
5930 gfp_t gfp);
5931
5932/**
5933 * cfg80211_rx_mgmt - notification of received, unprocessed management frame
5934 * @wdev: wireless device receiving the frame
5935 * @freq: Frequency on which the frame was received in MHz
5936 * @sig_dbm: signal strength in dBm, or 0 if unknown
5937 * @buf: Management frame (header + body)
5938 * @len: length of the frame data
5939 * @flags: flags, as defined in enum nl80211_rxmgmt_flags
5940 *
5941 * This function is called whenever an Action frame is received for a station
5942 * mode interface, but is not processed in kernel.
5943 *
5944 * Return: %true if a user space application has registered for this frame.
5945 * For action frames, that makes it responsible for rejecting unrecognized
5946 * action frames; %false otherwise, in which case for action frames the
5947 * driver is responsible for rejecting the frame.
5948 */
5949bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_dbm,
5950 const u8 *buf, size_t len, u32 flags);
5951
5952/**
5953 * cfg80211_mgmt_tx_status - notification of TX status for management frame
5954 * @wdev: wireless device receiving the frame
5955 * @cookie: Cookie returned by cfg80211_ops::mgmt_tx()
5956 * @buf: Management frame (header + body)
5957 * @len: length of the frame data
5958 * @ack: Whether frame was acknowledged
5959 * @gfp: context flags
5960 *
5961 * This function is called whenever a management frame was requested to be
5962 * transmitted with cfg80211_ops::mgmt_tx() to report the TX status of the
5963 * transmission attempt.
5964 */
5965void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie,
5966 const u8 *buf, size_t len, bool ack, gfp_t gfp);
5967
5968
5969/**
5970 * cfg80211_rx_control_port - notification about a received control port frame
5971 * @dev: The device the frame matched to
5972 * @skb: The skbuf with the control port frame. It is assumed that the skbuf
5973 * is 802.3 formatted (with 802.3 header). The skb can be non-linear.
5974 * This function does not take ownership of the skb, so the caller is
5975 * responsible for any cleanup. The caller must also ensure that
5976 * skb->protocol is set appropriately.
5977 * @unencrypted: Whether the frame was received unencrypted
5978 *
5979 * This function is used to inform userspace about a received control port
5980 * frame. It should only be used if userspace indicated it wants to receive
5981 * control port frames over nl80211.
5982 *
5983 * The frame is the data portion of the 802.3 or 802.11 data frame with all
5984 * network layer headers removed (e.g. the raw EAPoL frame).
5985 *
5986 * Return: %true if the frame was passed to userspace
5987 */
5988bool cfg80211_rx_control_port(struct net_device *dev,
5989 struct sk_buff *skb, bool unencrypted);
5990
5991/**
5992 * cfg80211_cqm_rssi_notify - connection quality monitoring rssi event
5993 * @dev: network device
5994 * @rssi_event: the triggered RSSI event
5995 * @rssi_level: new RSSI level value or 0 if not available
5996 * @gfp: context flags
5997 *
5998 * This function is called when a configured connection quality monitoring
5999 * rssi threshold reached event occurs.
6000 */
6001void cfg80211_cqm_rssi_notify(struct net_device *dev,
6002 enum nl80211_cqm_rssi_threshold_event rssi_event,
6003 s32 rssi_level, gfp_t gfp);
6004
6005/**
6006 * cfg80211_cqm_pktloss_notify - notify userspace about packetloss to peer
6007 * @dev: network device
6008 * @peer: peer's MAC address
6009 * @num_packets: how many packets were lost -- should be a fixed threshold
6010 * but probably no less than maybe 50, or maybe a throughput dependent
6011 * threshold (to account for temporary interference)
6012 * @gfp: context flags
6013 */
6014void cfg80211_cqm_pktloss_notify(struct net_device *dev,
6015 const u8 *peer, u32 num_packets, gfp_t gfp);
6016
6017/**
6018 * cfg80211_cqm_txe_notify - TX error rate event
6019 * @dev: network device
6020 * @peer: peer's MAC address
6021 * @num_packets: how many packets were lost
6022 * @rate: % of packets which failed transmission
6023 * @intvl: interval (in s) over which the TX failure threshold was breached.
6024 * @gfp: context flags
6025 *
6026 * Notify userspace when configured % TX failures over number of packets in a
6027 * given interval is exceeded.
6028 */
6029void cfg80211_cqm_txe_notify(struct net_device *dev, const u8 *peer,
6030 u32 num_packets, u32 rate, u32 intvl, gfp_t gfp);
6031
6032/**
6033 * cfg80211_cqm_beacon_loss_notify - beacon loss event
6034 * @dev: network device
6035 * @gfp: context flags
6036 *
6037 * Notify userspace about beacon loss from the connected AP.
6038 */
6039void cfg80211_cqm_beacon_loss_notify(struct net_device *dev, gfp_t gfp);
6040
6041/**
6042 * cfg80211_radar_event - radar detection event
6043 * @wiphy: the wiphy
6044 * @chandef: chandef for the current channel
6045 * @gfp: context flags
6046 *
6047 * This function is called when a radar is detected on the current chanenl.
6048 */
6049void cfg80211_radar_event(struct wiphy *wiphy,
6050 struct cfg80211_chan_def *chandef, gfp_t gfp);
6051
6052/**
6053 * cfg80211_sta_opmode_change_notify - STA's ht/vht operation mode change event
6054 * @dev: network device
6055 * @mac: MAC address of a station which opmode got modified
6056 * @sta_opmode: station's current opmode value
6057 * @gfp: context flags
6058 *
6059 * Driver should call this function when station's opmode modified via action
6060 * frame.
6061 */
6062void cfg80211_sta_opmode_change_notify(struct net_device *dev, const u8 *mac,
6063 struct sta_opmode_info *sta_opmode,
6064 gfp_t gfp);
6065
6066/**
6067 * cfg80211_cac_event - Channel availability check (CAC) event
6068 * @netdev: network device
6069 * @chandef: chandef for the current channel
6070 * @event: type of event
6071 * @gfp: context flags
6072 *
6073 * This function is called when a Channel availability check (CAC) is finished
6074 * or aborted. This must be called to notify the completion of a CAC process,
6075 * also by full-MAC drivers.
6076 */
6077void cfg80211_cac_event(struct net_device *netdev,
6078 const struct cfg80211_chan_def *chandef,
6079 enum nl80211_radar_event event, gfp_t gfp);
6080
6081
6082/**
6083 * cfg80211_gtk_rekey_notify - notify userspace about driver rekeying
6084 * @dev: network device
6085 * @bssid: BSSID of AP (to avoid races)
6086 * @replay_ctr: new replay counter
6087 * @gfp: allocation flags
6088 */
6089void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid,
6090 const u8 *replay_ctr, gfp_t gfp);
6091
6092/**
6093 * cfg80211_pmksa_candidate_notify - notify about PMKSA caching candidate
6094 * @dev: network device
6095 * @index: candidate index (the smaller the index, the higher the priority)
6096 * @bssid: BSSID of AP
6097 * @preauth: Whether AP advertises support for RSN pre-authentication
6098 * @gfp: allocation flags
6099 */
6100void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index,
6101 const u8 *bssid, bool preauth, gfp_t gfp);
6102
6103/**
6104 * cfg80211_rx_spurious_frame - inform userspace about a spurious frame
6105 * @dev: The device the frame matched to
6106 * @addr: the transmitter address
6107 * @gfp: context flags
6108 *
6109 * This function is used in AP mode (only!) to inform userspace that
6110 * a spurious class 3 frame was received, to be able to deauth the
6111 * sender.
6112 * Return: %true if the frame was passed to userspace (or this failed
6113 * for a reason other than not having a subscription.)
6114 */
6115bool cfg80211_rx_spurious_frame(struct net_device *dev,
6116 const u8 *addr, gfp_t gfp);
6117
6118/**
6119 * cfg80211_rx_unexpected_4addr_frame - inform about unexpected WDS frame
6120 * @dev: The device the frame matched to
6121 * @addr: the transmitter address
6122 * @gfp: context flags
6123 *
6124 * This function is used in AP mode (only!) to inform userspace that
6125 * an associated station sent a 4addr frame but that wasn't expected.
6126 * It is allowed and desirable to send this event only once for each
6127 * station to avoid event flooding.
6128 * Return: %true if the frame was passed to userspace (or this failed
6129 * for a reason other than not having a subscription.)
6130 */
6131bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev,
6132 const u8 *addr, gfp_t gfp);
6133
6134/**
6135 * cfg80211_probe_status - notify userspace about probe status
6136 * @dev: the device the probe was sent on
6137 * @addr: the address of the peer
6138 * @cookie: the cookie filled in @probe_client previously
6139 * @acked: indicates whether probe was acked or not
6140 * @ack_signal: signal strength (in dBm) of the ACK frame.
6141 * @is_valid_ack_signal: indicates the ack_signal is valid or not.
6142 * @gfp: allocation flags
6143 */
6144void cfg80211_probe_status(struct net_device *dev, const u8 *addr,
6145 u64 cookie, bool acked, s32 ack_signal,
6146 bool is_valid_ack_signal, gfp_t gfp);
6147
6148/**
6149 * cfg80211_report_obss_beacon - report beacon from other APs
6150 * @wiphy: The wiphy that received the beacon
6151 * @frame: the frame
6152 * @len: length of the frame
6153 * @freq: frequency the frame was received on
6154 * @sig_dbm: signal strength in dBm, or 0 if unknown
6155 *
6156 * Use this function to report to userspace when a beacon was
6157 * received. It is not useful to call this when there is no
6158 * netdev that is in AP/GO mode.
6159 */
6160void cfg80211_report_obss_beacon(struct wiphy *wiphy,
6161 const u8 *frame, size_t len,
6162 int freq, int sig_dbm);
6163
6164/**
6165 * cfg80211_reg_can_beacon - check if beaconing is allowed
6166 * @wiphy: the wiphy
6167 * @chandef: the channel definition
6168 * @iftype: interface type
6169 *
6170 * Return: %true if there is no secondary channel or the secondary channel(s)
6171 * can be used for beaconing (i.e. is not a radar channel etc.)
6172 */
6173bool cfg80211_reg_can_beacon(struct wiphy *wiphy,
6174 struct cfg80211_chan_def *chandef,
6175 enum nl80211_iftype iftype);
6176
6177/**
6178 * cfg80211_reg_can_beacon_relax - check if beaconing is allowed with relaxation
6179 * @wiphy: the wiphy
6180 * @chandef: the channel definition
6181 * @iftype: interface type
6182 *
6183 * Return: %true if there is no secondary channel or the secondary channel(s)
6184 * can be used for beaconing (i.e. is not a radar channel etc.). This version
6185 * also checks if IR-relaxation conditions apply, to allow beaconing under
6186 * more permissive conditions.
6187 *
6188 * Requires the RTNL to be held.
6189 */
6190bool cfg80211_reg_can_beacon_relax(struct wiphy *wiphy,
6191 struct cfg80211_chan_def *chandef,
6192 enum nl80211_iftype iftype);
6193
6194/*
6195 * cfg80211_ch_switch_notify - update wdev channel and notify userspace
6196 * @dev: the device which switched channels
6197 * @chandef: the new channel definition
6198 *
6199 * Caller must acquire wdev_lock, therefore must only be called from sleepable
6200 * driver context!
6201 */
6202void cfg80211_ch_switch_notify(struct net_device *dev,
6203 struct cfg80211_chan_def *chandef);
6204
6205/*
6206 * cfg80211_ch_switch_started_notify - notify channel switch start
6207 * @dev: the device on which the channel switch started
6208 * @chandef: the future channel definition
6209 * @count: the number of TBTTs until the channel switch happens
6210 *
6211 * Inform the userspace about the channel switch that has just
6212 * started, so that it can take appropriate actions (eg. starting
6213 * channel switch on other vifs), if necessary.
6214 */
6215void cfg80211_ch_switch_started_notify(struct net_device *dev,
6216 struct cfg80211_chan_def *chandef,
6217 u8 count);
6218
6219/**
6220 * ieee80211_operating_class_to_band - convert operating class to band
6221 *
6222 * @operating_class: the operating class to convert
6223 * @band: band pointer to fill
6224 *
6225 * Returns %true if the conversion was successful, %false otherwise.
6226 */
6227bool ieee80211_operating_class_to_band(u8 operating_class,
6228 enum nl80211_band *band);
6229
6230/**
6231 * ieee80211_chandef_to_operating_class - convert chandef to operation class
6232 *
6233 * @chandef: the chandef to convert
6234 * @op_class: a pointer to the resulting operating class
6235 *
6236 * Returns %true if the conversion was successful, %false otherwise.
6237 */
6238bool ieee80211_chandef_to_operating_class(struct cfg80211_chan_def *chandef,
6239 u8 *op_class);
6240
6241/*
6242 * cfg80211_tdls_oper_request - request userspace to perform TDLS operation
6243 * @dev: the device on which the operation is requested
6244 * @peer: the MAC address of the peer device
6245 * @oper: the requested TDLS operation (NL80211_TDLS_SETUP or
6246 * NL80211_TDLS_TEARDOWN)
6247 * @reason_code: the reason code for teardown request
6248 * @gfp: allocation flags
6249 *
6250 * This function is used to request userspace to perform TDLS operation that
6251 * requires knowledge of keys, i.e., link setup or teardown when the AP
6252 * connection uses encryption. This is optional mechanism for the driver to use
6253 * if it can automatically determine when a TDLS link could be useful (e.g.,
6254 * based on traffic and signal strength for a peer).
6255 */
6256void cfg80211_tdls_oper_request(struct net_device *dev, const u8 *peer,
6257 enum nl80211_tdls_operation oper,
6258 u16 reason_code, gfp_t gfp);
6259
6260/*
6261 * cfg80211_calculate_bitrate - calculate actual bitrate (in 100Kbps units)
6262 * @rate: given rate_info to calculate bitrate from
6263 *
6264 * return 0 if MCS index >= 32
6265 */
6266u32 cfg80211_calculate_bitrate(struct rate_info *rate);
6267
6268/**
6269 * cfg80211_unregister_wdev - remove the given wdev
6270 * @wdev: struct wireless_dev to remove
6271 *
6272 * Call this function only for wdevs that have no netdev assigned,
6273 * e.g. P2P Devices. It removes the device from the list so that
6274 * it can no longer be used. It is necessary to call this function
6275 * even when cfg80211 requests the removal of the interface by
6276 * calling the del_virtual_intf() callback. The function must also
6277 * be called when the driver wishes to unregister the wdev, e.g.
6278 * when the device is unbound from the driver.
6279 *
6280 * Requires the RTNL to be held.
6281 */
6282void cfg80211_unregister_wdev(struct wireless_dev *wdev);
6283
6284/**
6285 * struct cfg80211_ft_event - FT Information Elements
6286 * @ies: FT IEs
6287 * @ies_len: length of the FT IE in bytes
6288 * @target_ap: target AP's MAC address
6289 * @ric_ies: RIC IE
6290 * @ric_ies_len: length of the RIC IE in bytes
6291 */
6292struct cfg80211_ft_event_params {
6293 const u8 *ies;
6294 size_t ies_len;
6295 const u8 *target_ap;
6296 const u8 *ric_ies;
6297 size_t ric_ies_len;
6298};
6299
6300/**
6301 * cfg80211_ft_event - notify userspace about FT IE and RIC IE
6302 * @netdev: network device
6303 * @ft_event: IE information
6304 */
6305void cfg80211_ft_event(struct net_device *netdev,
6306 struct cfg80211_ft_event_params *ft_event);
6307
6308/**
6309 * cfg80211_get_p2p_attr - find and copy a P2P attribute from IE buffer
6310 * @ies: the input IE buffer
6311 * @len: the input length
6312 * @attr: the attribute ID to find
6313 * @buf: output buffer, can be %NULL if the data isn't needed, e.g.
6314 * if the function is only called to get the needed buffer size
6315 * @bufsize: size of the output buffer
6316 *
6317 * The function finds a given P2P attribute in the (vendor) IEs and
6318 * copies its contents to the given buffer.
6319 *
6320 * Return: A negative error code (-%EILSEQ or -%ENOENT) if the data is
6321 * malformed or the attribute can't be found (respectively), or the
6322 * length of the found attribute (which can be zero).
6323 */
6324int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len,
6325 enum ieee80211_p2p_attr_id attr,
6326 u8 *buf, unsigned int bufsize);
6327
6328/**
6329 * ieee80211_ie_split_ric - split an IE buffer according to ordering (with RIC)
6330 * @ies: the IE buffer
6331 * @ielen: the length of the IE buffer
6332 * @ids: an array with element IDs that are allowed before
6333 * the split. A WLAN_EID_EXTENSION value means that the next
6334 * EID in the list is a sub-element of the EXTENSION IE.
6335 * @n_ids: the size of the element ID array
6336 * @after_ric: array IE types that come after the RIC element
6337 * @n_after_ric: size of the @after_ric array
6338 * @offset: offset where to start splitting in the buffer
6339 *
6340 * This function splits an IE buffer by updating the @offset
6341 * variable to point to the location where the buffer should be
6342 * split.
6343 *
6344 * It assumes that the given IE buffer is well-formed, this
6345 * has to be guaranteed by the caller!
6346 *
6347 * It also assumes that the IEs in the buffer are ordered
6348 * correctly, if not the result of using this function will not
6349 * be ordered correctly either, i.e. it does no reordering.
6350 *
6351 * The function returns the offset where the next part of the
6352 * buffer starts, which may be @ielen if the entire (remainder)
6353 * of the buffer should be used.
6354 */
6355size_t ieee80211_ie_split_ric(const u8 *ies, size_t ielen,
6356 const u8 *ids, int n_ids,
6357 const u8 *after_ric, int n_after_ric,
6358 size_t offset);
6359
6360/**
6361 * ieee80211_ie_split - split an IE buffer according to ordering
6362 * @ies: the IE buffer
6363 * @ielen: the length of the IE buffer
6364 * @ids: an array with element IDs that are allowed before
6365 * the split. A WLAN_EID_EXTENSION value means that the next
6366 * EID in the list is a sub-element of the EXTENSION IE.
6367 * @n_ids: the size of the element ID array
6368 * @offset: offset where to start splitting in the buffer
6369 *
6370 * This function splits an IE buffer by updating the @offset
6371 * variable to point to the location where the buffer should be
6372 * split.
6373 *
6374 * It assumes that the given IE buffer is well-formed, this
6375 * has to be guaranteed by the caller!
6376 *
6377 * It also assumes that the IEs in the buffer are ordered
6378 * correctly, if not the result of using this function will not
6379 * be ordered correctly either, i.e. it does no reordering.
6380 *
6381 * The function returns the offset where the next part of the
6382 * buffer starts, which may be @ielen if the entire (remainder)
6383 * of the buffer should be used.
6384 */
6385static inline size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
6386 const u8 *ids, int n_ids, size_t offset)
6387{
6388 return ieee80211_ie_split_ric(ies, ielen, ids, n_ids, NULL, 0, offset);
6389}
6390
6391/**
6392 * cfg80211_report_wowlan_wakeup - report wakeup from WoWLAN
6393 * @wdev: the wireless device reporting the wakeup
6394 * @wakeup: the wakeup report
6395 * @gfp: allocation flags
6396 *
6397 * This function reports that the given device woke up. If it
6398 * caused the wakeup, report the reason(s), otherwise you may
6399 * pass %NULL as the @wakeup parameter to advertise that something
6400 * else caused the wakeup.
6401 */
6402void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,
6403 struct cfg80211_wowlan_wakeup *wakeup,
6404 gfp_t gfp);
6405
6406/**
6407 * cfg80211_crit_proto_stopped() - indicate critical protocol stopped by driver.
6408 *
6409 * @wdev: the wireless device for which critical protocol is stopped.
6410 * @gfp: allocation flags
6411 *
6412 * This function can be called by the driver to indicate it has reverted
6413 * operation back to normal. One reason could be that the duration given
6414 * by .crit_proto_start() has expired.
6415 */
6416void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp);
6417
6418/**
6419 * ieee80211_get_num_supported_channels - get number of channels device has
6420 * @wiphy: the wiphy
6421 *
6422 * Return: the number of channels supported by the device.
6423 */
6424unsigned int ieee80211_get_num_supported_channels(struct wiphy *wiphy);
6425
6426/**
6427 * cfg80211_check_combinations - check interface combinations
6428 *
6429 * @wiphy: the wiphy
6430 * @params: the interface combinations parameter
6431 *
6432 * This function can be called by the driver to check whether a
6433 * combination of interfaces and their types are allowed according to
6434 * the interface combinations.
6435 */
6436int cfg80211_check_combinations(struct wiphy *wiphy,
6437 struct iface_combination_params *params);
6438
6439/**
6440 * cfg80211_iter_combinations - iterate over matching combinations
6441 *
6442 * @wiphy: the wiphy
6443 * @params: the interface combinations parameter
6444 * @iter: function to call for each matching combination
6445 * @data: pointer to pass to iter function
6446 *
6447 * This function can be called by the driver to check what possible
6448 * combinations it fits in at a given moment, e.g. for channel switching
6449 * purposes.
6450 */
6451int cfg80211_iter_combinations(struct wiphy *wiphy,
6452 struct iface_combination_params *params,
6453 void (*iter)(const struct ieee80211_iface_combination *c,
6454 void *data),
6455 void *data);
6456
6457/*
6458 * cfg80211_stop_iface - trigger interface disconnection
6459 *
6460 * @wiphy: the wiphy
6461 * @wdev: wireless device
6462 * @gfp: context flags
6463 *
6464 * Trigger interface to be stopped as if AP was stopped, IBSS/mesh left, STA
6465 * disconnected.
6466 *
6467 * Note: This doesn't need any locks and is asynchronous.
6468 */
6469void cfg80211_stop_iface(struct wiphy *wiphy, struct wireless_dev *wdev,
6470 gfp_t gfp);
6471
6472/**
6473 * cfg80211_shutdown_all_interfaces - shut down all interfaces for a wiphy
6474 * @wiphy: the wiphy to shut down
6475 *
6476 * This function shuts down all interfaces belonging to this wiphy by
6477 * calling dev_close() (and treating non-netdev interfaces as needed).
6478 * It shouldn't really be used unless there are some fatal device errors
6479 * that really can't be recovered in any other way.
6480 *
6481 * Callers must hold the RTNL and be able to deal with callbacks into
6482 * the driver while the function is running.
6483 */
6484void cfg80211_shutdown_all_interfaces(struct wiphy *wiphy);
6485
6486/**
6487 * wiphy_ext_feature_set - set the extended feature flag
6488 *
6489 * @wiphy: the wiphy to modify.
6490 * @ftidx: extended feature bit index.
6491 *
6492 * The extended features are flagged in multiple bytes (see
6493 * &struct wiphy.@ext_features)
6494 */
6495static inline void wiphy_ext_feature_set(struct wiphy *wiphy,
6496 enum nl80211_ext_feature_index ftidx)
6497{
6498 u8 *ft_byte;
6499
6500 ft_byte = &wiphy->ext_features[ftidx / 8];
6501 *ft_byte |= BIT(ftidx % 8);
6502}
6503
6504/**
6505 * wiphy_ext_feature_isset - check the extended feature flag
6506 *
6507 * @wiphy: the wiphy to modify.
6508 * @ftidx: extended feature bit index.
6509 *
6510 * The extended features are flagged in multiple bytes (see
6511 * &struct wiphy.@ext_features)
6512 */
6513static inline bool
6514wiphy_ext_feature_isset(struct wiphy *wiphy,
6515 enum nl80211_ext_feature_index ftidx)
6516{
6517 u8 ft_byte;
6518
6519 ft_byte = wiphy->ext_features[ftidx / 8];
6520 return (ft_byte & BIT(ftidx % 8)) != 0;
6521}
6522
6523/**
6524 * cfg80211_free_nan_func - free NAN function
6525 * @f: NAN function that should be freed
6526 *
6527 * Frees all the NAN function and all it's allocated members.
6528 */
6529void cfg80211_free_nan_func(struct cfg80211_nan_func *f);
6530
6531/**
6532 * struct cfg80211_nan_match_params - NAN match parameters
6533 * @type: the type of the function that triggered a match. If it is
6534 * %NL80211_NAN_FUNC_SUBSCRIBE it means that we replied to a subscriber.
6535 * If it is %NL80211_NAN_FUNC_PUBLISH, it means that we got a discovery
6536 * result.
6537 * If it is %NL80211_NAN_FUNC_FOLLOW_UP, we received a follow up.
6538 * @inst_id: the local instance id
6539 * @peer_inst_id: the instance id of the peer's function
6540 * @addr: the MAC address of the peer
6541 * @info_len: the length of the &info
6542 * @info: the Service Specific Info from the peer (if any)
6543 * @cookie: unique identifier of the corresponding function
6544 */
6545struct cfg80211_nan_match_params {
6546 enum nl80211_nan_function_type type;
6547 u8 inst_id;
6548 u8 peer_inst_id;
6549 const u8 *addr;
6550 u8 info_len;
6551 const u8 *info;
6552 u64 cookie;
6553};
6554
6555/**
6556 * cfg80211_nan_match - report a match for a NAN function.
6557 * @wdev: the wireless device reporting the match
6558 * @match: match notification parameters
6559 * @gfp: allocation flags
6560 *
6561 * This function reports that the a NAN function had a match. This
6562 * can be a subscribe that had a match or a solicited publish that
6563 * was sent. It can also be a follow up that was received.
6564 */
6565void cfg80211_nan_match(struct wireless_dev *wdev,
6566 struct cfg80211_nan_match_params *match, gfp_t gfp);
6567
6568/**
6569 * cfg80211_nan_func_terminated - notify about NAN function termination.
6570 *
6571 * @wdev: the wireless device reporting the match
6572 * @inst_id: the local instance id
6573 * @reason: termination reason (one of the NL80211_NAN_FUNC_TERM_REASON_*)
6574 * @cookie: unique NAN function identifier
6575 * @gfp: allocation flags
6576 *
6577 * This function reports that the a NAN function is terminated.
6578 */
6579void cfg80211_nan_func_terminated(struct wireless_dev *wdev,
6580 u8 inst_id,
6581 enum nl80211_nan_func_term_reason reason,
6582 u64 cookie, gfp_t gfp);
6583
6584/* ethtool helper */
6585void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info);
6586
6587/**
6588 * cfg80211_external_auth_request - userspace request for authentication
6589 * @netdev: network device
6590 * @params: External authentication parameters
6591 * @gfp: allocation flags
6592 * Returns: 0 on success, < 0 on error
6593 */
6594int cfg80211_external_auth_request(struct net_device *netdev,
6595 struct cfg80211_external_auth_params *params,
6596 gfp_t gfp);
6597
6598/**
6599 * cfg80211_iftype_allowed - check whether the interface can be allowed
6600 * @wiphy: the wiphy
6601 * @iftype: interface type
6602 * @is_4addr: use_4addr flag, must be '0' when check_swif is '1'
6603 * @check_swif: check iftype against software interfaces
6604 *
6605 * Check whether the interface is allowed to operate; additionally, this API
6606 * can be used to check iftype against the software interfaces when
6607 * check_swif is '1'.
6608 */
6609bool cfg80211_iftype_allowed(struct wiphy *wiphy, enum nl80211_iftype iftype,
6610 bool is_4addr, u8 check_swif);
6611
6612
6613/* Logging, debugging and troubleshooting/diagnostic helpers. */
6614
6615/* wiphy_printk helpers, similar to dev_printk */
6616
6617#define wiphy_printk(level, wiphy, format, args...) \
6618 dev_printk(level, &(wiphy)->dev, format, ##args)
6619#define wiphy_emerg(wiphy, format, args...) \
6620 dev_emerg(&(wiphy)->dev, format, ##args)
6621#define wiphy_alert(wiphy, format, args...) \
6622 dev_alert(&(wiphy)->dev, format, ##args)
6623#define wiphy_crit(wiphy, format, args...) \
6624 dev_crit(&(wiphy)->dev, format, ##args)
6625#define wiphy_err(wiphy, format, args...) \
6626 dev_err(&(wiphy)->dev, format, ##args)
6627#define wiphy_warn(wiphy, format, args...) \
6628 dev_warn(&(wiphy)->dev, format, ##args)
6629#define wiphy_notice(wiphy, format, args...) \
6630 dev_notice(&(wiphy)->dev, format, ##args)
6631#define wiphy_info(wiphy, format, args...) \
6632 dev_info(&(wiphy)->dev, format, ##args)
6633
6634#define wiphy_debug(wiphy, format, args...) \
6635 wiphy_printk(KERN_DEBUG, wiphy, format, ##args)
6636
6637#define wiphy_dbg(wiphy, format, args...) \
6638 dev_dbg(&(wiphy)->dev, format, ##args)
6639
6640#if defined(VERBOSE_DEBUG)
6641#define wiphy_vdbg wiphy_dbg
6642#else
6643#define wiphy_vdbg(wiphy, format, args...) \
6644({ \
6645 if (0) \
6646 wiphy_printk(KERN_DEBUG, wiphy, format, ##args); \
6647 0; \
6648})
6649#endif
6650
6651/*
6652 * wiphy_WARN() acts like wiphy_printk(), but with the key difference
6653 * of using a WARN/WARN_ON to get the message out, including the
6654 * file/line information and a backtrace.
6655 */
6656#define wiphy_WARN(wiphy, format, args...) \
6657 WARN(1, "wiphy: %s\n" format, wiphy_name(wiphy), ##args);
6658
6659#endif /* __NET_CFG80211_H */