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