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