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