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