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