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