1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * mac80211 configuration hooks for cfg80211 4 * 5 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net> 6 * Copyright 2013-2015 Intel Mobile Communications GmbH 7 * Copyright (C) 2015-2017 Intel Deutschland GmbH 8 * Copyright (C) 2018-2022 Intel Corporation 9 */ 10 11 #include <linux/ieee80211.h> 12 #include <linux/nl80211.h> 13 #include <linux/rtnetlink.h> 14 #include <linux/slab.h> 15 #include <net/net_namespace.h> 16 #include <linux/rcupdate.h> 17 #include <linux/fips.h> 18 #include <linux/if_ether.h> 19 #include <net/cfg80211.h> 20 #include "ieee80211_i.h" 21 #include "driver-ops.h" 22 #include "rate.h" 23 #include "mesh.h" 24 #include "wme.h" 25 26 static void ieee80211_set_mu_mimo_follow(struct ieee80211_sub_if_data *sdata, 27 struct vif_params *params) 28 { 29 bool mu_mimo_groups = false; 30 bool mu_mimo_follow = false; 31 32 if (params->vht_mumimo_groups) { 33 u64 membership; 34 35 BUILD_BUG_ON(sizeof(membership) != WLAN_MEMBERSHIP_LEN); 36 37 memcpy(sdata->vif.bss_conf.mu_group.membership, 38 params->vht_mumimo_groups, WLAN_MEMBERSHIP_LEN); 39 memcpy(sdata->vif.bss_conf.mu_group.position, 40 params->vht_mumimo_groups + WLAN_MEMBERSHIP_LEN, 41 WLAN_USER_POSITION_LEN); 42 ieee80211_link_info_change_notify(sdata, &sdata->deflink, 43 BSS_CHANGED_MU_GROUPS); 44 /* don't care about endianness - just check for 0 */ 45 memcpy(&membership, params->vht_mumimo_groups, 46 WLAN_MEMBERSHIP_LEN); 47 mu_mimo_groups = membership != 0; 48 } 49 50 if (params->vht_mumimo_follow_addr) { 51 mu_mimo_follow = 52 is_valid_ether_addr(params->vht_mumimo_follow_addr); 53 ether_addr_copy(sdata->u.mntr.mu_follow_addr, 54 params->vht_mumimo_follow_addr); 55 } 56 57 sdata->vif.bss_conf.mu_mimo_owner = mu_mimo_groups || mu_mimo_follow; 58 } 59 60 static int ieee80211_set_mon_options(struct ieee80211_sub_if_data *sdata, 61 struct vif_params *params) 62 { 63 struct ieee80211_local *local = sdata->local; 64 struct ieee80211_sub_if_data *monitor_sdata; 65 66 /* check flags first */ 67 if (params->flags && ieee80211_sdata_running(sdata)) { 68 u32 mask = MONITOR_FLAG_COOK_FRAMES | MONITOR_FLAG_ACTIVE; 69 70 /* 71 * Prohibit MONITOR_FLAG_COOK_FRAMES and 72 * MONITOR_FLAG_ACTIVE to be changed while the 73 * interface is up. 74 * Else we would need to add a lot of cruft 75 * to update everything: 76 * cooked_mntrs, monitor and all fif_* counters 77 * reconfigure hardware 78 */ 79 if ((params->flags & mask) != (sdata->u.mntr.flags & mask)) 80 return -EBUSY; 81 } 82 83 /* also validate MU-MIMO change */ 84 monitor_sdata = wiphy_dereference(local->hw.wiphy, 85 local->monitor_sdata); 86 87 if (!monitor_sdata && 88 (params->vht_mumimo_groups || params->vht_mumimo_follow_addr)) 89 return -EOPNOTSUPP; 90 91 /* apply all changes now - no failures allowed */ 92 93 if (monitor_sdata) 94 ieee80211_set_mu_mimo_follow(monitor_sdata, params); 95 96 if (params->flags) { 97 if (ieee80211_sdata_running(sdata)) { 98 ieee80211_adjust_monitor_flags(sdata, -1); 99 sdata->u.mntr.flags = params->flags; 100 ieee80211_adjust_monitor_flags(sdata, 1); 101 102 ieee80211_configure_filter(local); 103 } else { 104 /* 105 * Because the interface is down, ieee80211_do_stop 106 * and ieee80211_do_open take care of "everything" 107 * mentioned in the comment above. 108 */ 109 sdata->u.mntr.flags = params->flags; 110 } 111 } 112 113 return 0; 114 } 115 116 static int ieee80211_set_ap_mbssid_options(struct ieee80211_sub_if_data *sdata, 117 struct cfg80211_mbssid_config params, 118 struct ieee80211_bss_conf *link_conf) 119 { 120 struct ieee80211_sub_if_data *tx_sdata; 121 122 sdata->vif.mbssid_tx_vif = NULL; 123 link_conf->bssid_index = 0; 124 link_conf->nontransmitted = false; 125 link_conf->ema_ap = false; 126 127 if (sdata->vif.type != NL80211_IFTYPE_AP || !params.tx_wdev) 128 return -EINVAL; 129 130 tx_sdata = IEEE80211_WDEV_TO_SUB_IF(params.tx_wdev); 131 if (!tx_sdata) 132 return -EINVAL; 133 134 if (tx_sdata == sdata) { 135 sdata->vif.mbssid_tx_vif = &sdata->vif; 136 } else { 137 sdata->vif.mbssid_tx_vif = &tx_sdata->vif; 138 link_conf->nontransmitted = true; 139 link_conf->bssid_index = params.index; 140 } 141 if (params.ema) 142 link_conf->ema_ap = true; 143 144 return 0; 145 } 146 147 static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy, 148 const char *name, 149 unsigned char name_assign_type, 150 enum nl80211_iftype type, 151 struct vif_params *params) 152 { 153 struct ieee80211_local *local = wiphy_priv(wiphy); 154 struct wireless_dev *wdev; 155 struct ieee80211_sub_if_data *sdata; 156 int err; 157 158 err = ieee80211_if_add(local, name, name_assign_type, &wdev, type, params); 159 if (err) 160 return ERR_PTR(err); 161 162 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 163 164 if (type == NL80211_IFTYPE_MONITOR) { 165 err = ieee80211_set_mon_options(sdata, params); 166 if (err) { 167 ieee80211_if_remove(sdata); 168 return NULL; 169 } 170 } 171 172 return wdev; 173 } 174 175 static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev) 176 { 177 ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev)); 178 179 return 0; 180 } 181 182 static int ieee80211_change_iface(struct wiphy *wiphy, 183 struct net_device *dev, 184 enum nl80211_iftype type, 185 struct vif_params *params) 186 { 187 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 188 struct ieee80211_local *local = sdata->local; 189 struct sta_info *sta; 190 int ret; 191 192 ret = ieee80211_if_change_type(sdata, type); 193 if (ret) 194 return ret; 195 196 if (type == NL80211_IFTYPE_AP_VLAN && params->use_4addr == 0) { 197 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL); 198 ieee80211_check_fast_rx_iface(sdata); 199 } else if (type == NL80211_IFTYPE_STATION && params->use_4addr >= 0) { 200 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 201 202 if (params->use_4addr == ifmgd->use_4addr) 203 return 0; 204 205 sdata->u.mgd.use_4addr = params->use_4addr; 206 if (!ifmgd->associated) 207 return 0; 208 209 mutex_lock(&local->sta_mtx); 210 sta = sta_info_get(sdata, sdata->deflink.u.mgd.bssid); 211 if (sta) 212 drv_sta_set_4addr(local, sdata, &sta->sta, 213 params->use_4addr); 214 mutex_unlock(&local->sta_mtx); 215 216 if (params->use_4addr) 217 ieee80211_send_4addr_nullfunc(local, sdata); 218 } 219 220 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) { 221 ret = ieee80211_set_mon_options(sdata, params); 222 if (ret) 223 return ret; 224 } 225 226 return 0; 227 } 228 229 static int ieee80211_start_p2p_device(struct wiphy *wiphy, 230 struct wireless_dev *wdev) 231 { 232 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 233 int ret; 234 235 mutex_lock(&sdata->local->chanctx_mtx); 236 ret = ieee80211_check_combinations(sdata, NULL, 0, 0); 237 mutex_unlock(&sdata->local->chanctx_mtx); 238 if (ret < 0) 239 return ret; 240 241 return ieee80211_do_open(wdev, true); 242 } 243 244 static void ieee80211_stop_p2p_device(struct wiphy *wiphy, 245 struct wireless_dev *wdev) 246 { 247 ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev)); 248 } 249 250 static int ieee80211_start_nan(struct wiphy *wiphy, 251 struct wireless_dev *wdev, 252 struct cfg80211_nan_conf *conf) 253 { 254 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 255 int ret; 256 257 mutex_lock(&sdata->local->chanctx_mtx); 258 ret = ieee80211_check_combinations(sdata, NULL, 0, 0); 259 mutex_unlock(&sdata->local->chanctx_mtx); 260 if (ret < 0) 261 return ret; 262 263 ret = ieee80211_do_open(wdev, true); 264 if (ret) 265 return ret; 266 267 ret = drv_start_nan(sdata->local, sdata, conf); 268 if (ret) 269 ieee80211_sdata_stop(sdata); 270 271 sdata->u.nan.conf = *conf; 272 273 return ret; 274 } 275 276 static void ieee80211_stop_nan(struct wiphy *wiphy, 277 struct wireless_dev *wdev) 278 { 279 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 280 281 drv_stop_nan(sdata->local, sdata); 282 ieee80211_sdata_stop(sdata); 283 } 284 285 static int ieee80211_nan_change_conf(struct wiphy *wiphy, 286 struct wireless_dev *wdev, 287 struct cfg80211_nan_conf *conf, 288 u32 changes) 289 { 290 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 291 struct cfg80211_nan_conf new_conf; 292 int ret = 0; 293 294 if (sdata->vif.type != NL80211_IFTYPE_NAN) 295 return -EOPNOTSUPP; 296 297 if (!ieee80211_sdata_running(sdata)) 298 return -ENETDOWN; 299 300 new_conf = sdata->u.nan.conf; 301 302 if (changes & CFG80211_NAN_CONF_CHANGED_PREF) 303 new_conf.master_pref = conf->master_pref; 304 305 if (changes & CFG80211_NAN_CONF_CHANGED_BANDS) 306 new_conf.bands = conf->bands; 307 308 ret = drv_nan_change_conf(sdata->local, sdata, &new_conf, changes); 309 if (!ret) 310 sdata->u.nan.conf = new_conf; 311 312 return ret; 313 } 314 315 static int ieee80211_add_nan_func(struct wiphy *wiphy, 316 struct wireless_dev *wdev, 317 struct cfg80211_nan_func *nan_func) 318 { 319 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 320 int ret; 321 322 if (sdata->vif.type != NL80211_IFTYPE_NAN) 323 return -EOPNOTSUPP; 324 325 if (!ieee80211_sdata_running(sdata)) 326 return -ENETDOWN; 327 328 spin_lock_bh(&sdata->u.nan.func_lock); 329 330 ret = idr_alloc(&sdata->u.nan.function_inst_ids, 331 nan_func, 1, sdata->local->hw.max_nan_de_entries + 1, 332 GFP_ATOMIC); 333 spin_unlock_bh(&sdata->u.nan.func_lock); 334 335 if (ret < 0) 336 return ret; 337 338 nan_func->instance_id = ret; 339 340 WARN_ON(nan_func->instance_id == 0); 341 342 ret = drv_add_nan_func(sdata->local, sdata, nan_func); 343 if (ret) { 344 spin_lock_bh(&sdata->u.nan.func_lock); 345 idr_remove(&sdata->u.nan.function_inst_ids, 346 nan_func->instance_id); 347 spin_unlock_bh(&sdata->u.nan.func_lock); 348 } 349 350 return ret; 351 } 352 353 static struct cfg80211_nan_func * 354 ieee80211_find_nan_func_by_cookie(struct ieee80211_sub_if_data *sdata, 355 u64 cookie) 356 { 357 struct cfg80211_nan_func *func; 358 int id; 359 360 lockdep_assert_held(&sdata->u.nan.func_lock); 361 362 idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, id) { 363 if (func->cookie == cookie) 364 return func; 365 } 366 367 return NULL; 368 } 369 370 static void ieee80211_del_nan_func(struct wiphy *wiphy, 371 struct wireless_dev *wdev, u64 cookie) 372 { 373 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 374 struct cfg80211_nan_func *func; 375 u8 instance_id = 0; 376 377 if (sdata->vif.type != NL80211_IFTYPE_NAN || 378 !ieee80211_sdata_running(sdata)) 379 return; 380 381 spin_lock_bh(&sdata->u.nan.func_lock); 382 383 func = ieee80211_find_nan_func_by_cookie(sdata, cookie); 384 if (func) 385 instance_id = func->instance_id; 386 387 spin_unlock_bh(&sdata->u.nan.func_lock); 388 389 if (instance_id) 390 drv_del_nan_func(sdata->local, sdata, instance_id); 391 } 392 393 static int ieee80211_set_noack_map(struct wiphy *wiphy, 394 struct net_device *dev, 395 u16 noack_map) 396 { 397 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 398 399 sdata->noack_map = noack_map; 400 401 ieee80211_check_fast_xmit_iface(sdata); 402 403 return 0; 404 } 405 406 static int ieee80211_set_tx(struct ieee80211_sub_if_data *sdata, 407 const u8 *mac_addr, u8 key_idx) 408 { 409 struct ieee80211_local *local = sdata->local; 410 struct ieee80211_key *key; 411 struct sta_info *sta; 412 int ret = -EINVAL; 413 414 if (!wiphy_ext_feature_isset(local->hw.wiphy, 415 NL80211_EXT_FEATURE_EXT_KEY_ID)) 416 return -EINVAL; 417 418 sta = sta_info_get_bss(sdata, mac_addr); 419 420 if (!sta) 421 return -EINVAL; 422 423 if (sta->ptk_idx == key_idx) 424 return 0; 425 426 mutex_lock(&local->key_mtx); 427 key = key_mtx_dereference(local, sta->ptk[key_idx]); 428 429 if (key && key->conf.flags & IEEE80211_KEY_FLAG_NO_AUTO_TX) 430 ret = ieee80211_set_tx_key(key); 431 432 mutex_unlock(&local->key_mtx); 433 return ret; 434 } 435 436 static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, 437 u8 key_idx, bool pairwise, const u8 *mac_addr, 438 struct key_params *params) 439 { 440 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 441 struct ieee80211_local *local = sdata->local; 442 struct sta_info *sta = NULL; 443 struct ieee80211_key *key; 444 int err; 445 446 if (!ieee80211_sdata_running(sdata)) 447 return -ENETDOWN; 448 449 if (pairwise && params->mode == NL80211_KEY_SET_TX) 450 return ieee80211_set_tx(sdata, mac_addr, key_idx); 451 452 /* reject WEP and TKIP keys if WEP failed to initialize */ 453 switch (params->cipher) { 454 case WLAN_CIPHER_SUITE_WEP40: 455 case WLAN_CIPHER_SUITE_TKIP: 456 case WLAN_CIPHER_SUITE_WEP104: 457 if (WARN_ON_ONCE(fips_enabled)) 458 return -EINVAL; 459 break; 460 default: 461 break; 462 } 463 464 key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len, 465 params->key, params->seq_len, params->seq); 466 if (IS_ERR(key)) 467 return PTR_ERR(key); 468 469 if (pairwise) 470 key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE; 471 472 if (params->mode == NL80211_KEY_NO_TX) 473 key->conf.flags |= IEEE80211_KEY_FLAG_NO_AUTO_TX; 474 475 mutex_lock(&local->sta_mtx); 476 477 if (mac_addr) { 478 sta = sta_info_get_bss(sdata, mac_addr); 479 /* 480 * The ASSOC test makes sure the driver is ready to 481 * receive the key. When wpa_supplicant has roamed 482 * using FT, it attempts to set the key before 483 * association has completed, this rejects that attempt 484 * so it will set the key again after association. 485 * 486 * TODO: accept the key if we have a station entry and 487 * add it to the device after the station. 488 */ 489 if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) { 490 ieee80211_key_free_unused(key); 491 err = -ENOENT; 492 goto out_unlock; 493 } 494 } 495 496 switch (sdata->vif.type) { 497 case NL80211_IFTYPE_STATION: 498 if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED) 499 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; 500 break; 501 case NL80211_IFTYPE_AP: 502 case NL80211_IFTYPE_AP_VLAN: 503 /* Keys without a station are used for TX only */ 504 if (sta && test_sta_flag(sta, WLAN_STA_MFP)) 505 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; 506 break; 507 case NL80211_IFTYPE_ADHOC: 508 /* no MFP (yet) */ 509 break; 510 case NL80211_IFTYPE_MESH_POINT: 511 #ifdef CONFIG_MAC80211_MESH 512 if (sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE) 513 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; 514 break; 515 #endif 516 case NL80211_IFTYPE_WDS: 517 case NL80211_IFTYPE_MONITOR: 518 case NL80211_IFTYPE_P2P_DEVICE: 519 case NL80211_IFTYPE_NAN: 520 case NL80211_IFTYPE_UNSPECIFIED: 521 case NUM_NL80211_IFTYPES: 522 case NL80211_IFTYPE_P2P_CLIENT: 523 case NL80211_IFTYPE_P2P_GO: 524 case NL80211_IFTYPE_OCB: 525 /* shouldn't happen */ 526 WARN_ON_ONCE(1); 527 break; 528 } 529 530 err = ieee80211_key_link(key, sdata, sta); 531 532 out_unlock: 533 mutex_unlock(&local->sta_mtx); 534 535 return err; 536 } 537 538 static struct ieee80211_key * 539 ieee80211_lookup_key(struct ieee80211_sub_if_data *sdata, 540 u8 key_idx, bool pairwise, const u8 *mac_addr) 541 { 542 struct ieee80211_local *local = sdata->local; 543 struct ieee80211_key *key; 544 struct sta_info *sta; 545 546 if (mac_addr) { 547 sta = sta_info_get_bss(sdata, mac_addr); 548 if (!sta) 549 return NULL; 550 551 if (pairwise && key_idx < NUM_DEFAULT_KEYS) 552 return rcu_dereference_check_key_mtx(local, 553 sta->ptk[key_idx]); 554 555 if (!pairwise && 556 key_idx < NUM_DEFAULT_KEYS + 557 NUM_DEFAULT_MGMT_KEYS + 558 NUM_DEFAULT_BEACON_KEYS) 559 return rcu_dereference_check_key_mtx(local, 560 sta->deflink.gtk[key_idx]); 561 562 return NULL; 563 } 564 565 if (pairwise && key_idx < NUM_DEFAULT_KEYS) 566 return rcu_dereference_check_key_mtx(local, 567 sdata->keys[key_idx]); 568 569 key = rcu_dereference_check_key_mtx(local, sdata->deflink.gtk[key_idx]); 570 if (key) 571 return key; 572 573 /* or maybe it was a WEP key */ 574 if (key_idx < NUM_DEFAULT_KEYS) 575 return rcu_dereference_check_key_mtx(local, sdata->keys[key_idx]); 576 577 return NULL; 578 } 579 580 static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, 581 u8 key_idx, bool pairwise, const u8 *mac_addr) 582 { 583 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 584 struct ieee80211_local *local = sdata->local; 585 struct ieee80211_key *key; 586 int ret; 587 588 mutex_lock(&local->sta_mtx); 589 mutex_lock(&local->key_mtx); 590 591 key = ieee80211_lookup_key(sdata, key_idx, pairwise, mac_addr); 592 if (!key) { 593 ret = -ENOENT; 594 goto out_unlock; 595 } 596 597 ieee80211_key_free(key, sdata->vif.type == NL80211_IFTYPE_STATION); 598 599 ret = 0; 600 out_unlock: 601 mutex_unlock(&local->key_mtx); 602 mutex_unlock(&local->sta_mtx); 603 604 return ret; 605 } 606 607 static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev, 608 u8 key_idx, bool pairwise, const u8 *mac_addr, 609 void *cookie, 610 void (*callback)(void *cookie, 611 struct key_params *params)) 612 { 613 struct ieee80211_sub_if_data *sdata; 614 u8 seq[6] = {0}; 615 struct key_params params; 616 struct ieee80211_key *key; 617 u64 pn64; 618 u32 iv32; 619 u16 iv16; 620 int err = -ENOENT; 621 struct ieee80211_key_seq kseq = {}; 622 623 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 624 625 rcu_read_lock(); 626 627 key = ieee80211_lookup_key(sdata, key_idx, pairwise, mac_addr); 628 if (!key) 629 goto out; 630 631 memset(¶ms, 0, sizeof(params)); 632 633 params.cipher = key->conf.cipher; 634 635 switch (key->conf.cipher) { 636 case WLAN_CIPHER_SUITE_TKIP: 637 pn64 = atomic64_read(&key->conf.tx_pn); 638 iv32 = TKIP_PN_TO_IV32(pn64); 639 iv16 = TKIP_PN_TO_IV16(pn64); 640 641 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE && 642 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) { 643 drv_get_key_seq(sdata->local, key, &kseq); 644 iv32 = kseq.tkip.iv32; 645 iv16 = kseq.tkip.iv16; 646 } 647 648 seq[0] = iv16 & 0xff; 649 seq[1] = (iv16 >> 8) & 0xff; 650 seq[2] = iv32 & 0xff; 651 seq[3] = (iv32 >> 8) & 0xff; 652 seq[4] = (iv32 >> 16) & 0xff; 653 seq[5] = (iv32 >> 24) & 0xff; 654 params.seq = seq; 655 params.seq_len = 6; 656 break; 657 case WLAN_CIPHER_SUITE_CCMP: 658 case WLAN_CIPHER_SUITE_CCMP_256: 659 case WLAN_CIPHER_SUITE_AES_CMAC: 660 case WLAN_CIPHER_SUITE_BIP_CMAC_256: 661 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) != 662 offsetof(typeof(kseq), aes_cmac)); 663 fallthrough; 664 case WLAN_CIPHER_SUITE_BIP_GMAC_128: 665 case WLAN_CIPHER_SUITE_BIP_GMAC_256: 666 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) != 667 offsetof(typeof(kseq), aes_gmac)); 668 fallthrough; 669 case WLAN_CIPHER_SUITE_GCMP: 670 case WLAN_CIPHER_SUITE_GCMP_256: 671 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) != 672 offsetof(typeof(kseq), gcmp)); 673 674 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE && 675 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) { 676 drv_get_key_seq(sdata->local, key, &kseq); 677 memcpy(seq, kseq.ccmp.pn, 6); 678 } else { 679 pn64 = atomic64_read(&key->conf.tx_pn); 680 seq[0] = pn64; 681 seq[1] = pn64 >> 8; 682 seq[2] = pn64 >> 16; 683 seq[3] = pn64 >> 24; 684 seq[4] = pn64 >> 32; 685 seq[5] = pn64 >> 40; 686 } 687 params.seq = seq; 688 params.seq_len = 6; 689 break; 690 default: 691 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) 692 break; 693 if (WARN_ON(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) 694 break; 695 drv_get_key_seq(sdata->local, key, &kseq); 696 params.seq = kseq.hw.seq; 697 params.seq_len = kseq.hw.seq_len; 698 break; 699 } 700 701 params.key = key->conf.key; 702 params.key_len = key->conf.keylen; 703 704 callback(cookie, ¶ms); 705 err = 0; 706 707 out: 708 rcu_read_unlock(); 709 return err; 710 } 711 712 static int ieee80211_config_default_key(struct wiphy *wiphy, 713 struct net_device *dev, 714 u8 key_idx, bool uni, 715 bool multi) 716 { 717 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 718 719 ieee80211_set_default_key(sdata, key_idx, uni, multi); 720 721 return 0; 722 } 723 724 static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy, 725 struct net_device *dev, 726 u8 key_idx) 727 { 728 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 729 730 ieee80211_set_default_mgmt_key(sdata, key_idx); 731 732 return 0; 733 } 734 735 static int ieee80211_config_default_beacon_key(struct wiphy *wiphy, 736 struct net_device *dev, 737 u8 key_idx) 738 { 739 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 740 741 ieee80211_set_default_beacon_key(sdata, key_idx); 742 743 return 0; 744 } 745 746 void sta_set_rate_info_tx(struct sta_info *sta, 747 const struct ieee80211_tx_rate *rate, 748 struct rate_info *rinfo) 749 { 750 rinfo->flags = 0; 751 if (rate->flags & IEEE80211_TX_RC_MCS) { 752 rinfo->flags |= RATE_INFO_FLAGS_MCS; 753 rinfo->mcs = rate->idx; 754 } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) { 755 rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS; 756 rinfo->mcs = ieee80211_rate_get_vht_mcs(rate); 757 rinfo->nss = ieee80211_rate_get_vht_nss(rate); 758 } else { 759 struct ieee80211_supported_band *sband; 760 int shift = ieee80211_vif_get_shift(&sta->sdata->vif); 761 u16 brate; 762 763 sband = ieee80211_get_sband(sta->sdata); 764 WARN_ON_ONCE(sband && !sband->bitrates); 765 if (sband && sband->bitrates) { 766 brate = sband->bitrates[rate->idx].bitrate; 767 rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift); 768 } 769 } 770 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) 771 rinfo->bw = RATE_INFO_BW_40; 772 else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) 773 rinfo->bw = RATE_INFO_BW_80; 774 else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH) 775 rinfo->bw = RATE_INFO_BW_160; 776 else 777 rinfo->bw = RATE_INFO_BW_20; 778 if (rate->flags & IEEE80211_TX_RC_SHORT_GI) 779 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; 780 } 781 782 static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev, 783 int idx, u8 *mac, struct station_info *sinfo) 784 { 785 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 786 struct ieee80211_local *local = sdata->local; 787 struct sta_info *sta; 788 int ret = -ENOENT; 789 790 mutex_lock(&local->sta_mtx); 791 792 sta = sta_info_get_by_idx(sdata, idx); 793 if (sta) { 794 ret = 0; 795 memcpy(mac, sta->sta.addr, ETH_ALEN); 796 sta_set_sinfo(sta, sinfo, true); 797 } 798 799 mutex_unlock(&local->sta_mtx); 800 801 return ret; 802 } 803 804 static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev, 805 int idx, struct survey_info *survey) 806 { 807 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 808 809 return drv_get_survey(local, idx, survey); 810 } 811 812 static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev, 813 const u8 *mac, struct station_info *sinfo) 814 { 815 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 816 struct ieee80211_local *local = sdata->local; 817 struct sta_info *sta; 818 int ret = -ENOENT; 819 820 mutex_lock(&local->sta_mtx); 821 822 sta = sta_info_get_bss(sdata, mac); 823 if (sta) { 824 ret = 0; 825 sta_set_sinfo(sta, sinfo, true); 826 } 827 828 mutex_unlock(&local->sta_mtx); 829 830 return ret; 831 } 832 833 static int ieee80211_set_monitor_channel(struct wiphy *wiphy, 834 struct cfg80211_chan_def *chandef) 835 { 836 struct ieee80211_local *local = wiphy_priv(wiphy); 837 struct ieee80211_sub_if_data *sdata; 838 int ret = 0; 839 840 if (cfg80211_chandef_identical(&local->monitor_chandef, chandef)) 841 return 0; 842 843 mutex_lock(&local->mtx); 844 if (local->use_chanctx) { 845 sdata = wiphy_dereference(local->hw.wiphy, 846 local->monitor_sdata); 847 if (sdata) { 848 ieee80211_link_release_channel(&sdata->deflink); 849 ret = ieee80211_link_use_channel(&sdata->deflink, 850 chandef, 851 IEEE80211_CHANCTX_EXCLUSIVE); 852 } 853 } else if (local->open_count == local->monitors) { 854 local->_oper_chandef = *chandef; 855 ieee80211_hw_config(local, 0); 856 } 857 858 if (ret == 0) 859 local->monitor_chandef = *chandef; 860 mutex_unlock(&local->mtx); 861 862 return ret; 863 } 864 865 static int 866 ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata, 867 const u8 *resp, size_t resp_len, 868 const struct ieee80211_csa_settings *csa, 869 const struct ieee80211_color_change_settings *cca, 870 struct ieee80211_link_data *link) 871 { 872 struct probe_resp *new, *old; 873 874 if (!resp || !resp_len) 875 return 1; 876 877 old = sdata_dereference(link->u.ap.probe_resp, sdata); 878 879 new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL); 880 if (!new) 881 return -ENOMEM; 882 883 new->len = resp_len; 884 memcpy(new->data, resp, resp_len); 885 886 if (csa) 887 memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_presp, 888 csa->n_counter_offsets_presp * 889 sizeof(new->cntdwn_counter_offsets[0])); 890 else if (cca) 891 new->cntdwn_counter_offsets[0] = cca->counter_offset_presp; 892 893 rcu_assign_pointer(link->u.ap.probe_resp, new); 894 if (old) 895 kfree_rcu(old, rcu_head); 896 897 return 0; 898 } 899 900 static int ieee80211_set_fils_discovery(struct ieee80211_sub_if_data *sdata, 901 struct cfg80211_fils_discovery *params, 902 struct ieee80211_link_data *link, 903 struct ieee80211_bss_conf *link_conf) 904 { 905 struct fils_discovery_data *new, *old = NULL; 906 struct ieee80211_fils_discovery *fd; 907 908 if (!params->tmpl || !params->tmpl_len) 909 return -EINVAL; 910 911 fd = &link_conf->fils_discovery; 912 fd->min_interval = params->min_interval; 913 fd->max_interval = params->max_interval; 914 915 old = sdata_dereference(link->u.ap.fils_discovery, sdata); 916 new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL); 917 if (!new) 918 return -ENOMEM; 919 new->len = params->tmpl_len; 920 memcpy(new->data, params->tmpl, params->tmpl_len); 921 rcu_assign_pointer(link->u.ap.fils_discovery, new); 922 923 if (old) 924 kfree_rcu(old, rcu_head); 925 926 return 0; 927 } 928 929 static int 930 ieee80211_set_unsol_bcast_probe_resp(struct ieee80211_sub_if_data *sdata, 931 struct cfg80211_unsol_bcast_probe_resp *params, 932 struct ieee80211_link_data *link, 933 struct ieee80211_bss_conf *link_conf) 934 { 935 struct unsol_bcast_probe_resp_data *new, *old = NULL; 936 937 if (!params->tmpl || !params->tmpl_len) 938 return -EINVAL; 939 940 old = sdata_dereference(link->u.ap.unsol_bcast_probe_resp, sdata); 941 new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL); 942 if (!new) 943 return -ENOMEM; 944 new->len = params->tmpl_len; 945 memcpy(new->data, params->tmpl, params->tmpl_len); 946 rcu_assign_pointer(link->u.ap.unsol_bcast_probe_resp, new); 947 948 if (old) 949 kfree_rcu(old, rcu_head); 950 951 link_conf->unsol_bcast_probe_resp_interval = params->interval; 952 953 return 0; 954 } 955 956 static int ieee80211_set_ftm_responder_params( 957 struct ieee80211_sub_if_data *sdata, 958 const u8 *lci, size_t lci_len, 959 const u8 *civicloc, size_t civicloc_len, 960 struct ieee80211_bss_conf *link_conf) 961 { 962 struct ieee80211_ftm_responder_params *new, *old; 963 u8 *pos; 964 int len; 965 966 if (!lci_len && !civicloc_len) 967 return 0; 968 969 old = link_conf->ftmr_params; 970 len = lci_len + civicloc_len; 971 972 new = kzalloc(sizeof(*new) + len, GFP_KERNEL); 973 if (!new) 974 return -ENOMEM; 975 976 pos = (u8 *)(new + 1); 977 if (lci_len) { 978 new->lci_len = lci_len; 979 new->lci = pos; 980 memcpy(pos, lci, lci_len); 981 pos += lci_len; 982 } 983 984 if (civicloc_len) { 985 new->civicloc_len = civicloc_len; 986 new->civicloc = pos; 987 memcpy(pos, civicloc, civicloc_len); 988 pos += civicloc_len; 989 } 990 991 link_conf->ftmr_params = new; 992 kfree(old); 993 994 return 0; 995 } 996 997 static int 998 ieee80211_copy_mbssid_beacon(u8 *pos, struct cfg80211_mbssid_elems *dst, 999 struct cfg80211_mbssid_elems *src) 1000 { 1001 int i, offset = 0; 1002 1003 for (i = 0; i < src->cnt; i++) { 1004 memcpy(pos + offset, src->elem[i].data, src->elem[i].len); 1005 dst->elem[i].len = src->elem[i].len; 1006 dst->elem[i].data = pos + offset; 1007 offset += dst->elem[i].len; 1008 } 1009 dst->cnt = src->cnt; 1010 1011 return offset; 1012 } 1013 1014 static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata, 1015 struct ieee80211_link_data *link, 1016 struct cfg80211_beacon_data *params, 1017 const struct ieee80211_csa_settings *csa, 1018 const struct ieee80211_color_change_settings *cca) 1019 { 1020 struct cfg80211_mbssid_elems *mbssid = NULL; 1021 struct beacon_data *new, *old; 1022 int new_head_len, new_tail_len; 1023 int size, err; 1024 u32 changed = BSS_CHANGED_BEACON; 1025 struct ieee80211_bss_conf *link_conf = link->conf; 1026 1027 old = sdata_dereference(link->u.ap.beacon, sdata); 1028 1029 /* Need to have a beacon head if we don't have one yet */ 1030 if (!params->head && !old) 1031 return -EINVAL; 1032 1033 /* new or old head? */ 1034 if (params->head) 1035 new_head_len = params->head_len; 1036 else 1037 new_head_len = old->head_len; 1038 1039 /* new or old tail? */ 1040 if (params->tail || !old) 1041 /* params->tail_len will be zero for !params->tail */ 1042 new_tail_len = params->tail_len; 1043 else 1044 new_tail_len = old->tail_len; 1045 1046 size = sizeof(*new) + new_head_len + new_tail_len; 1047 1048 /* new or old multiple BSSID elements? */ 1049 if (params->mbssid_ies) { 1050 mbssid = params->mbssid_ies; 1051 size += struct_size(new->mbssid_ies, elem, mbssid->cnt); 1052 size += ieee80211_get_mbssid_beacon_len(mbssid); 1053 } else if (old && old->mbssid_ies) { 1054 mbssid = old->mbssid_ies; 1055 size += struct_size(new->mbssid_ies, elem, mbssid->cnt); 1056 size += ieee80211_get_mbssid_beacon_len(mbssid); 1057 } 1058 1059 new = kzalloc(size, GFP_KERNEL); 1060 if (!new) 1061 return -ENOMEM; 1062 1063 /* start filling the new info now */ 1064 1065 /* 1066 * pointers go into the block we allocated, 1067 * memory is | beacon_data | head | tail | mbssid_ies 1068 */ 1069 new->head = ((u8 *) new) + sizeof(*new); 1070 new->tail = new->head + new_head_len; 1071 new->head_len = new_head_len; 1072 new->tail_len = new_tail_len; 1073 /* copy in optional mbssid_ies */ 1074 if (mbssid) { 1075 u8 *pos = new->tail + new->tail_len; 1076 1077 new->mbssid_ies = (void *)pos; 1078 pos += struct_size(new->mbssid_ies, elem, mbssid->cnt); 1079 ieee80211_copy_mbssid_beacon(pos, new->mbssid_ies, mbssid); 1080 /* update bssid_indicator */ 1081 link_conf->bssid_indicator = 1082 ilog2(__roundup_pow_of_two(mbssid->cnt + 1)); 1083 } 1084 1085 if (csa) { 1086 new->cntdwn_current_counter = csa->count; 1087 memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_beacon, 1088 csa->n_counter_offsets_beacon * 1089 sizeof(new->cntdwn_counter_offsets[0])); 1090 } else if (cca) { 1091 new->cntdwn_current_counter = cca->count; 1092 new->cntdwn_counter_offsets[0] = cca->counter_offset_beacon; 1093 } 1094 1095 /* copy in head */ 1096 if (params->head) 1097 memcpy(new->head, params->head, new_head_len); 1098 else 1099 memcpy(new->head, old->head, new_head_len); 1100 1101 /* copy in optional tail */ 1102 if (params->tail) 1103 memcpy(new->tail, params->tail, new_tail_len); 1104 else 1105 if (old) 1106 memcpy(new->tail, old->tail, new_tail_len); 1107 1108 err = ieee80211_set_probe_resp(sdata, params->probe_resp, 1109 params->probe_resp_len, csa, cca, link); 1110 if (err < 0) { 1111 kfree(new); 1112 return err; 1113 } 1114 if (err == 0) 1115 changed |= BSS_CHANGED_AP_PROBE_RESP; 1116 1117 if (params->ftm_responder != -1) { 1118 link_conf->ftm_responder = params->ftm_responder; 1119 err = ieee80211_set_ftm_responder_params(sdata, 1120 params->lci, 1121 params->lci_len, 1122 params->civicloc, 1123 params->civicloc_len, 1124 link_conf); 1125 1126 if (err < 0) { 1127 kfree(new); 1128 return err; 1129 } 1130 1131 changed |= BSS_CHANGED_FTM_RESPONDER; 1132 } 1133 1134 rcu_assign_pointer(link->u.ap.beacon, new); 1135 sdata->u.ap.active = true; 1136 1137 if (old) 1138 kfree_rcu(old, rcu_head); 1139 1140 return changed; 1141 } 1142 1143 static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev, 1144 struct cfg80211_ap_settings *params) 1145 { 1146 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1147 struct ieee80211_local *local = sdata->local; 1148 struct beacon_data *old; 1149 struct ieee80211_sub_if_data *vlan; 1150 u32 changed = BSS_CHANGED_BEACON_INT | 1151 BSS_CHANGED_BEACON_ENABLED | 1152 BSS_CHANGED_BEACON | 1153 BSS_CHANGED_P2P_PS | 1154 BSS_CHANGED_TXPOWER | 1155 BSS_CHANGED_TWT; 1156 int i, err; 1157 int prev_beacon_int; 1158 unsigned int link_id = params->beacon.link_id; 1159 struct ieee80211_link_data *link; 1160 struct ieee80211_bss_conf *link_conf; 1161 1162 link = sdata_dereference(sdata->link[link_id], sdata); 1163 if (!link) 1164 return -ENOLINK; 1165 1166 link_conf = link->conf; 1167 1168 old = sdata_dereference(link->u.ap.beacon, sdata); 1169 if (old) 1170 return -EALREADY; 1171 1172 if (params->smps_mode != NL80211_SMPS_OFF) 1173 return -ENOTSUPP; 1174 1175 link->smps_mode = IEEE80211_SMPS_OFF; 1176 1177 link->needed_rx_chains = sdata->local->rx_chains; 1178 1179 prev_beacon_int = link_conf->beacon_int; 1180 link_conf->beacon_int = params->beacon_interval; 1181 1182 if (params->he_cap && params->he_oper) { 1183 link_conf->he_support = true; 1184 link_conf->htc_trig_based_pkt_ext = 1185 le32_get_bits(params->he_oper->he_oper_params, 1186 IEEE80211_HE_OPERATION_DFLT_PE_DURATION_MASK); 1187 link_conf->frame_time_rts_th = 1188 le32_get_bits(params->he_oper->he_oper_params, 1189 IEEE80211_HE_OPERATION_RTS_THRESHOLD_MASK); 1190 changed |= BSS_CHANGED_HE_OBSS_PD; 1191 1192 if (params->beacon.he_bss_color.enabled) 1193 changed |= BSS_CHANGED_HE_BSS_COLOR; 1194 } 1195 1196 if (sdata->vif.type == NL80211_IFTYPE_AP && 1197 params->mbssid_config.tx_wdev) { 1198 err = ieee80211_set_ap_mbssid_options(sdata, 1199 params->mbssid_config, 1200 link_conf); 1201 if (err) 1202 return err; 1203 } 1204 1205 mutex_lock(&local->mtx); 1206 err = ieee80211_link_use_channel(link, ¶ms->chandef, 1207 IEEE80211_CHANCTX_SHARED); 1208 if (!err) 1209 ieee80211_link_copy_chanctx_to_vlans(link, false); 1210 mutex_unlock(&local->mtx); 1211 if (err) { 1212 link_conf->beacon_int = prev_beacon_int; 1213 return err; 1214 } 1215 1216 /* 1217 * Apply control port protocol, this allows us to 1218 * not encrypt dynamic WEP control frames. 1219 */ 1220 sdata->control_port_protocol = params->crypto.control_port_ethertype; 1221 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt; 1222 sdata->control_port_over_nl80211 = 1223 params->crypto.control_port_over_nl80211; 1224 sdata->control_port_no_preauth = 1225 params->crypto.control_port_no_preauth; 1226 1227 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) { 1228 vlan->control_port_protocol = 1229 params->crypto.control_port_ethertype; 1230 vlan->control_port_no_encrypt = 1231 params->crypto.control_port_no_encrypt; 1232 vlan->control_port_over_nl80211 = 1233 params->crypto.control_port_over_nl80211; 1234 vlan->control_port_no_preauth = 1235 params->crypto.control_port_no_preauth; 1236 } 1237 1238 link_conf->dtim_period = params->dtim_period; 1239 link_conf->enable_beacon = true; 1240 link_conf->allow_p2p_go_ps = sdata->vif.p2p; 1241 link_conf->twt_responder = params->twt_responder; 1242 link_conf->he_obss_pd = params->he_obss_pd; 1243 link_conf->he_bss_color = params->beacon.he_bss_color; 1244 sdata->vif.cfg.s1g = params->chandef.chan->band == 1245 NL80211_BAND_S1GHZ; 1246 1247 sdata->vif.cfg.ssid_len = params->ssid_len; 1248 if (params->ssid_len) 1249 memcpy(sdata->vif.cfg.ssid, params->ssid, 1250 params->ssid_len); 1251 link_conf->hidden_ssid = 1252 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE); 1253 1254 memset(&link_conf->p2p_noa_attr, 0, 1255 sizeof(link_conf->p2p_noa_attr)); 1256 link_conf->p2p_noa_attr.oppps_ctwindow = 1257 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK; 1258 if (params->p2p_opp_ps) 1259 link_conf->p2p_noa_attr.oppps_ctwindow |= 1260 IEEE80211_P2P_OPPPS_ENABLE_BIT; 1261 1262 sdata->beacon_rate_set = false; 1263 if (wiphy_ext_feature_isset(local->hw.wiphy, 1264 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) { 1265 for (i = 0; i < NUM_NL80211_BANDS; i++) { 1266 sdata->beacon_rateidx_mask[i] = 1267 params->beacon_rate.control[i].legacy; 1268 if (sdata->beacon_rateidx_mask[i]) 1269 sdata->beacon_rate_set = true; 1270 } 1271 } 1272 1273 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) 1274 link_conf->beacon_tx_rate = params->beacon_rate; 1275 1276 err = ieee80211_assign_beacon(sdata, link, ¶ms->beacon, NULL, NULL); 1277 if (err < 0) 1278 goto error; 1279 changed |= err; 1280 1281 if (params->fils_discovery.max_interval) { 1282 err = ieee80211_set_fils_discovery(sdata, 1283 ¶ms->fils_discovery, 1284 link, link_conf); 1285 if (err < 0) 1286 goto error; 1287 changed |= BSS_CHANGED_FILS_DISCOVERY; 1288 } 1289 1290 if (params->unsol_bcast_probe_resp.interval) { 1291 err = ieee80211_set_unsol_bcast_probe_resp(sdata, 1292 ¶ms->unsol_bcast_probe_resp, 1293 link, link_conf); 1294 if (err < 0) 1295 goto error; 1296 changed |= BSS_CHANGED_UNSOL_BCAST_PROBE_RESP; 1297 } 1298 1299 err = drv_start_ap(sdata->local, sdata, link_conf); 1300 if (err) { 1301 old = sdata_dereference(link->u.ap.beacon, sdata); 1302 1303 if (old) 1304 kfree_rcu(old, rcu_head); 1305 RCU_INIT_POINTER(link->u.ap.beacon, NULL); 1306 sdata->u.ap.active = false; 1307 goto error; 1308 } 1309 1310 ieee80211_recalc_dtim(local, sdata); 1311 ieee80211_vif_cfg_change_notify(sdata, BSS_CHANGED_SSID); 1312 ieee80211_link_info_change_notify(sdata, link, changed); 1313 1314 netif_carrier_on(dev); 1315 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) 1316 netif_carrier_on(vlan->dev); 1317 1318 return 0; 1319 1320 error: 1321 mutex_lock(&local->mtx); 1322 ieee80211_link_release_channel(link); 1323 mutex_unlock(&local->mtx); 1324 1325 return err; 1326 } 1327 1328 static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev, 1329 struct cfg80211_beacon_data *params) 1330 { 1331 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1332 struct ieee80211_link_data *link; 1333 struct beacon_data *old; 1334 int err; 1335 struct ieee80211_bss_conf *link_conf; 1336 1337 sdata_assert_lock(sdata); 1338 1339 link = sdata_dereference(sdata->link[params->link_id], sdata); 1340 if (!link) 1341 return -ENOLINK; 1342 1343 link_conf = link->conf; 1344 1345 /* don't allow changing the beacon while a countdown is in place - offset 1346 * of channel switch counter may change 1347 */ 1348 if (link_conf->csa_active || link_conf->color_change_active) 1349 return -EBUSY; 1350 1351 old = sdata_dereference(link->u.ap.beacon, sdata); 1352 if (!old) 1353 return -ENOENT; 1354 1355 err = ieee80211_assign_beacon(sdata, link, params, NULL, NULL); 1356 if (err < 0) 1357 return err; 1358 1359 if (params->he_bss_color_valid && 1360 params->he_bss_color.enabled != link_conf->he_bss_color.enabled) { 1361 link_conf->he_bss_color.enabled = params->he_bss_color.enabled; 1362 err |= BSS_CHANGED_HE_BSS_COLOR; 1363 } 1364 1365 ieee80211_link_info_change_notify(sdata, link, err); 1366 return 0; 1367 } 1368 1369 static void ieee80211_free_next_beacon(struct ieee80211_link_data *link) 1370 { 1371 if (!link->u.ap.next_beacon) 1372 return; 1373 1374 kfree(link->u.ap.next_beacon->mbssid_ies); 1375 kfree(link->u.ap.next_beacon); 1376 link->u.ap.next_beacon = NULL; 1377 } 1378 1379 static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev, 1380 unsigned int link_id) 1381 { 1382 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1383 struct ieee80211_sub_if_data *vlan; 1384 struct ieee80211_local *local = sdata->local; 1385 struct beacon_data *old_beacon; 1386 struct probe_resp *old_probe_resp; 1387 struct fils_discovery_data *old_fils_discovery; 1388 struct unsol_bcast_probe_resp_data *old_unsol_bcast_probe_resp; 1389 struct cfg80211_chan_def chandef; 1390 struct ieee80211_link_data *link = 1391 sdata_dereference(sdata->link[link_id], sdata); 1392 struct ieee80211_bss_conf *link_conf = link->conf; 1393 1394 sdata_assert_lock(sdata); 1395 1396 old_beacon = sdata_dereference(link->u.ap.beacon, sdata); 1397 if (!old_beacon) 1398 return -ENOENT; 1399 old_probe_resp = sdata_dereference(link->u.ap.probe_resp, 1400 sdata); 1401 old_fils_discovery = sdata_dereference(link->u.ap.fils_discovery, 1402 sdata); 1403 old_unsol_bcast_probe_resp = 1404 sdata_dereference(link->u.ap.unsol_bcast_probe_resp, 1405 sdata); 1406 1407 /* abort any running channel switch */ 1408 mutex_lock(&local->mtx); 1409 link_conf->csa_active = false; 1410 if (link->csa_block_tx) { 1411 ieee80211_wake_vif_queues(local, sdata, 1412 IEEE80211_QUEUE_STOP_REASON_CSA); 1413 link->csa_block_tx = false; 1414 } 1415 1416 mutex_unlock(&local->mtx); 1417 1418 ieee80211_free_next_beacon(link); 1419 1420 /* turn off carrier for this interface and dependent VLANs */ 1421 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) 1422 netif_carrier_off(vlan->dev); 1423 netif_carrier_off(dev); 1424 1425 /* remove beacon and probe response */ 1426 sdata->u.ap.active = false; 1427 RCU_INIT_POINTER(link->u.ap.beacon, NULL); 1428 RCU_INIT_POINTER(link->u.ap.probe_resp, NULL); 1429 RCU_INIT_POINTER(link->u.ap.fils_discovery, NULL); 1430 RCU_INIT_POINTER(link->u.ap.unsol_bcast_probe_resp, NULL); 1431 kfree_rcu(old_beacon, rcu_head); 1432 if (old_probe_resp) 1433 kfree_rcu(old_probe_resp, rcu_head); 1434 if (old_fils_discovery) 1435 kfree_rcu(old_fils_discovery, rcu_head); 1436 if (old_unsol_bcast_probe_resp) 1437 kfree_rcu(old_unsol_bcast_probe_resp, rcu_head); 1438 1439 kfree(link_conf->ftmr_params); 1440 link_conf->ftmr_params = NULL; 1441 1442 __sta_info_flush(sdata, true); 1443 ieee80211_free_keys(sdata, true); 1444 1445 link_conf->enable_beacon = false; 1446 sdata->beacon_rate_set = false; 1447 sdata->vif.cfg.ssid_len = 0; 1448 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state); 1449 ieee80211_link_info_change_notify(sdata, link, 1450 BSS_CHANGED_BEACON_ENABLED); 1451 1452 if (sdata->wdev.cac_started) { 1453 chandef = link_conf->chandef; 1454 cancel_delayed_work_sync(&link->dfs_cac_timer_work); 1455 cfg80211_cac_event(sdata->dev, &chandef, 1456 NL80211_RADAR_CAC_ABORTED, 1457 GFP_KERNEL); 1458 } 1459 1460 drv_stop_ap(sdata->local, sdata, link_conf); 1461 1462 /* free all potentially still buffered bcast frames */ 1463 local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf); 1464 ieee80211_purge_tx_queue(&local->hw, &sdata->u.ap.ps.bc_buf); 1465 1466 mutex_lock(&local->mtx); 1467 ieee80211_link_copy_chanctx_to_vlans(link, true); 1468 ieee80211_link_release_channel(link); 1469 mutex_unlock(&local->mtx); 1470 1471 return 0; 1472 } 1473 1474 static int sta_apply_auth_flags(struct ieee80211_local *local, 1475 struct sta_info *sta, 1476 u32 mask, u32 set) 1477 { 1478 int ret; 1479 1480 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) && 1481 set & BIT(NL80211_STA_FLAG_AUTHENTICATED) && 1482 !test_sta_flag(sta, WLAN_STA_AUTH)) { 1483 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH); 1484 if (ret) 1485 return ret; 1486 } 1487 1488 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) && 1489 set & BIT(NL80211_STA_FLAG_ASSOCIATED) && 1490 !test_sta_flag(sta, WLAN_STA_ASSOC)) { 1491 /* 1492 * When peer becomes associated, init rate control as 1493 * well. Some drivers require rate control initialized 1494 * before drv_sta_state() is called. 1495 */ 1496 if (!test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) 1497 rate_control_rate_init(sta); 1498 1499 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC); 1500 if (ret) 1501 return ret; 1502 } 1503 1504 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) { 1505 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) 1506 ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); 1507 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) 1508 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC); 1509 else 1510 ret = 0; 1511 if (ret) 1512 return ret; 1513 } 1514 1515 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) && 1516 !(set & BIT(NL80211_STA_FLAG_ASSOCIATED)) && 1517 test_sta_flag(sta, WLAN_STA_ASSOC)) { 1518 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH); 1519 if (ret) 1520 return ret; 1521 } 1522 1523 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) && 1524 !(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) && 1525 test_sta_flag(sta, WLAN_STA_AUTH)) { 1526 ret = sta_info_move_state(sta, IEEE80211_STA_NONE); 1527 if (ret) 1528 return ret; 1529 } 1530 1531 return 0; 1532 } 1533 1534 static void sta_apply_mesh_params(struct ieee80211_local *local, 1535 struct sta_info *sta, 1536 struct station_parameters *params) 1537 { 1538 #ifdef CONFIG_MAC80211_MESH 1539 struct ieee80211_sub_if_data *sdata = sta->sdata; 1540 u32 changed = 0; 1541 1542 if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) { 1543 switch (params->plink_state) { 1544 case NL80211_PLINK_ESTAB: 1545 if (sta->mesh->plink_state != NL80211_PLINK_ESTAB) 1546 changed = mesh_plink_inc_estab_count(sdata); 1547 sta->mesh->plink_state = params->plink_state; 1548 sta->mesh->aid = params->peer_aid; 1549 1550 ieee80211_mps_sta_status_update(sta); 1551 changed |= ieee80211_mps_set_sta_local_pm(sta, 1552 sdata->u.mesh.mshcfg.power_mode); 1553 1554 ewma_mesh_tx_rate_avg_init(&sta->mesh->tx_rate_avg); 1555 /* init at low value */ 1556 ewma_mesh_tx_rate_avg_add(&sta->mesh->tx_rate_avg, 10); 1557 1558 break; 1559 case NL80211_PLINK_LISTEN: 1560 case NL80211_PLINK_BLOCKED: 1561 case NL80211_PLINK_OPN_SNT: 1562 case NL80211_PLINK_OPN_RCVD: 1563 case NL80211_PLINK_CNF_RCVD: 1564 case NL80211_PLINK_HOLDING: 1565 if (sta->mesh->plink_state == NL80211_PLINK_ESTAB) 1566 changed = mesh_plink_dec_estab_count(sdata); 1567 sta->mesh->plink_state = params->plink_state; 1568 1569 ieee80211_mps_sta_status_update(sta); 1570 changed |= ieee80211_mps_set_sta_local_pm(sta, 1571 NL80211_MESH_POWER_UNKNOWN); 1572 break; 1573 default: 1574 /* nothing */ 1575 break; 1576 } 1577 } 1578 1579 switch (params->plink_action) { 1580 case NL80211_PLINK_ACTION_NO_ACTION: 1581 /* nothing */ 1582 break; 1583 case NL80211_PLINK_ACTION_OPEN: 1584 changed |= mesh_plink_open(sta); 1585 break; 1586 case NL80211_PLINK_ACTION_BLOCK: 1587 changed |= mesh_plink_block(sta); 1588 break; 1589 } 1590 1591 if (params->local_pm) 1592 changed |= ieee80211_mps_set_sta_local_pm(sta, 1593 params->local_pm); 1594 1595 ieee80211_mbss_info_change_notify(sdata, changed); 1596 #endif 1597 } 1598 1599 static int sta_link_apply_parameters(struct ieee80211_local *local, 1600 struct sta_info *sta, bool new_link, 1601 struct link_station_parameters *params) 1602 { 1603 int ret = 0; 1604 struct ieee80211_supported_band *sband; 1605 struct ieee80211_sub_if_data *sdata = sta->sdata; 1606 u32 link_id = params->link_id < 0 ? 0 : params->link_id; 1607 struct ieee80211_link_data *link = 1608 sdata_dereference(sdata->link[link_id], sdata); 1609 struct link_sta_info *link_sta = 1610 rcu_dereference_protected(sta->link[link_id], 1611 lockdep_is_held(&local->sta_mtx)); 1612 1613 if (!link || !link_sta) 1614 return -EINVAL; 1615 1616 sband = ieee80211_get_link_sband(link); 1617 if (!sband) 1618 return -EINVAL; 1619 1620 if (params->link_mac) { 1621 if (new_link) { 1622 memcpy(link_sta->addr, params->link_mac, ETH_ALEN); 1623 memcpy(link_sta->pub->addr, params->link_mac, ETH_ALEN); 1624 } else if (!ether_addr_equal(link_sta->addr, 1625 params->link_mac)) { 1626 return -EINVAL; 1627 } 1628 } 1629 1630 if (params->txpwr_set) { 1631 link_sta->pub->txpwr.type = params->txpwr.type; 1632 if (params->txpwr.type == NL80211_TX_POWER_LIMITED) 1633 link_sta->pub->txpwr.power = params->txpwr.power; 1634 ret = drv_sta_set_txpwr(local, sdata, sta); 1635 if (ret) 1636 return ret; 1637 } 1638 1639 if (params->supported_rates && 1640 params->supported_rates_len) { 1641 ieee80211_parse_bitrates(link->conf->chandef.width, 1642 sband, params->supported_rates, 1643 params->supported_rates_len, 1644 &link_sta->pub->supp_rates[sband->band]); 1645 } 1646 1647 if (params->ht_capa) 1648 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband, 1649 params->ht_capa, link_sta); 1650 1651 /* VHT can override some HT caps such as the A-MSDU max length */ 1652 if (params->vht_capa) 1653 ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband, 1654 params->vht_capa, link_sta); 1655 1656 if (params->he_capa) 1657 ieee80211_he_cap_ie_to_sta_he_cap(sdata, sband, 1658 (void *)params->he_capa, 1659 params->he_capa_len, 1660 (void *)params->he_6ghz_capa, 1661 link_sta); 1662 1663 if (params->eht_capa) 1664 ieee80211_eht_cap_ie_to_sta_eht_cap(sdata, sband, 1665 (u8 *)params->he_capa, 1666 params->he_capa_len, 1667 params->eht_capa, 1668 params->eht_capa_len, 1669 link_sta); 1670 1671 if (params->opmode_notif_used) { 1672 /* returned value is only needed for rc update, but the 1673 * rc isn't initialized here yet, so ignore it 1674 */ 1675 __ieee80211_vht_handle_opmode(sdata, link_sta, 1676 params->opmode_notif, 1677 sband->band); 1678 } 1679 1680 return ret; 1681 } 1682 1683 static int sta_apply_parameters(struct ieee80211_local *local, 1684 struct sta_info *sta, 1685 struct station_parameters *params) 1686 { 1687 struct ieee80211_sub_if_data *sdata = sta->sdata; 1688 u32 mask, set; 1689 int ret = 0; 1690 1691 mask = params->sta_flags_mask; 1692 set = params->sta_flags_set; 1693 1694 if (ieee80211_vif_is_mesh(&sdata->vif)) { 1695 /* 1696 * In mesh mode, ASSOCIATED isn't part of the nl80211 1697 * API but must follow AUTHENTICATED for driver state. 1698 */ 1699 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) 1700 mask |= BIT(NL80211_STA_FLAG_ASSOCIATED); 1701 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) 1702 set |= BIT(NL80211_STA_FLAG_ASSOCIATED); 1703 } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) { 1704 /* 1705 * TDLS -- everything follows authorized, but 1706 * only becoming authorized is possible, not 1707 * going back 1708 */ 1709 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) { 1710 set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) | 1711 BIT(NL80211_STA_FLAG_ASSOCIATED); 1712 mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) | 1713 BIT(NL80211_STA_FLAG_ASSOCIATED); 1714 } 1715 } 1716 1717 if (mask & BIT(NL80211_STA_FLAG_WME) && 1718 local->hw.queues >= IEEE80211_NUM_ACS) 1719 sta->sta.wme = set & BIT(NL80211_STA_FLAG_WME); 1720 1721 /* auth flags will be set later for TDLS, 1722 * and for unassociated stations that move to associated */ 1723 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) && 1724 !((mask & BIT(NL80211_STA_FLAG_ASSOCIATED)) && 1725 (set & BIT(NL80211_STA_FLAG_ASSOCIATED)))) { 1726 ret = sta_apply_auth_flags(local, sta, mask, set); 1727 if (ret) 1728 return ret; 1729 } 1730 1731 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) { 1732 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) 1733 set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE); 1734 else 1735 clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE); 1736 } 1737 1738 if (mask & BIT(NL80211_STA_FLAG_MFP)) { 1739 sta->sta.mfp = !!(set & BIT(NL80211_STA_FLAG_MFP)); 1740 if (set & BIT(NL80211_STA_FLAG_MFP)) 1741 set_sta_flag(sta, WLAN_STA_MFP); 1742 else 1743 clear_sta_flag(sta, WLAN_STA_MFP); 1744 } 1745 1746 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { 1747 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) 1748 set_sta_flag(sta, WLAN_STA_TDLS_PEER); 1749 else 1750 clear_sta_flag(sta, WLAN_STA_TDLS_PEER); 1751 } 1752 1753 /* mark TDLS channel switch support, if the AP allows it */ 1754 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && 1755 !sdata->deflink.u.mgd.tdls_chan_switch_prohibited && 1756 params->ext_capab_len >= 4 && 1757 params->ext_capab[3] & WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH) 1758 set_sta_flag(sta, WLAN_STA_TDLS_CHAN_SWITCH); 1759 1760 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && 1761 !sdata->u.mgd.tdls_wider_bw_prohibited && 1762 ieee80211_hw_check(&local->hw, TDLS_WIDER_BW) && 1763 params->ext_capab_len >= 8 && 1764 params->ext_capab[7] & WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED) 1765 set_sta_flag(sta, WLAN_STA_TDLS_WIDER_BW); 1766 1767 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) { 1768 sta->sta.uapsd_queues = params->uapsd_queues; 1769 sta->sta.max_sp = params->max_sp; 1770 } 1771 1772 ieee80211_sta_set_max_amsdu_subframes(sta, params->ext_capab, 1773 params->ext_capab_len); 1774 1775 /* 1776 * cfg80211 validates this (1-2007) and allows setting the AID 1777 * only when creating a new station entry 1778 */ 1779 if (params->aid) 1780 sta->sta.aid = params->aid; 1781 1782 /* 1783 * Some of the following updates would be racy if called on an 1784 * existing station, via ieee80211_change_station(). However, 1785 * all such changes are rejected by cfg80211 except for updates 1786 * changing the supported rates on an existing but not yet used 1787 * TDLS peer. 1788 */ 1789 1790 if (params->listen_interval >= 0) 1791 sta->listen_interval = params->listen_interval; 1792 1793 ret = sta_link_apply_parameters(local, sta, false, 1794 ¶ms->link_sta_params); 1795 if (ret) 1796 return ret; 1797 1798 if (params->support_p2p_ps >= 0) 1799 sta->sta.support_p2p_ps = params->support_p2p_ps; 1800 1801 if (ieee80211_vif_is_mesh(&sdata->vif)) 1802 sta_apply_mesh_params(local, sta, params); 1803 1804 if (params->airtime_weight) 1805 sta->airtime_weight = params->airtime_weight; 1806 1807 /* set the STA state after all sta info from usermode has been set */ 1808 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) || 1809 set & BIT(NL80211_STA_FLAG_ASSOCIATED)) { 1810 ret = sta_apply_auth_flags(local, sta, mask, set); 1811 if (ret) 1812 return ret; 1813 } 1814 1815 /* Mark the STA as MLO if MLD MAC address is available */ 1816 if (params->link_sta_params.mld_mac) 1817 sta->sta.mlo = true; 1818 1819 return 0; 1820 } 1821 1822 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, 1823 const u8 *mac, 1824 struct station_parameters *params) 1825 { 1826 struct ieee80211_local *local = wiphy_priv(wiphy); 1827 struct sta_info *sta; 1828 struct ieee80211_sub_if_data *sdata; 1829 int err; 1830 1831 if (params->vlan) { 1832 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); 1833 1834 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && 1835 sdata->vif.type != NL80211_IFTYPE_AP) 1836 return -EINVAL; 1837 } else 1838 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1839 1840 if (ether_addr_equal(mac, sdata->vif.addr)) 1841 return -EINVAL; 1842 1843 if (!is_valid_ether_addr(mac)) 1844 return -EINVAL; 1845 1846 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER) && 1847 sdata->vif.type == NL80211_IFTYPE_STATION && 1848 !sdata->u.mgd.associated) 1849 return -EINVAL; 1850 1851 /* 1852 * If we have a link ID, it can be a non-MLO station on an AP MLD, 1853 * but we need to have a link_mac in that case as well, so use the 1854 * STA's MAC address in that case. 1855 */ 1856 if (params->link_sta_params.link_id >= 0) 1857 sta = sta_info_alloc_with_link(sdata, mac, 1858 params->link_sta_params.link_id, 1859 params->link_sta_params.link_mac ?: mac, 1860 GFP_KERNEL); 1861 else 1862 sta = sta_info_alloc(sdata, mac, GFP_KERNEL); 1863 1864 if (!sta) 1865 return -ENOMEM; 1866 1867 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) 1868 sta->sta.tdls = true; 1869 1870 /* Though the mutex is not needed here (since the station is not 1871 * visible yet), sta_apply_parameters (and inner functions) require 1872 * the mutex due to other paths. 1873 */ 1874 mutex_lock(&local->sta_mtx); 1875 err = sta_apply_parameters(local, sta, params); 1876 mutex_unlock(&local->sta_mtx); 1877 if (err) { 1878 sta_info_free(local, sta); 1879 return err; 1880 } 1881 1882 /* 1883 * for TDLS and for unassociated station, rate control should be 1884 * initialized only when rates are known and station is marked 1885 * authorized/associated 1886 */ 1887 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) && 1888 test_sta_flag(sta, WLAN_STA_ASSOC)) 1889 rate_control_rate_init(sta); 1890 1891 return sta_info_insert(sta); 1892 } 1893 1894 static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, 1895 struct station_del_parameters *params) 1896 { 1897 struct ieee80211_sub_if_data *sdata; 1898 1899 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1900 1901 if (params->mac) 1902 return sta_info_destroy_addr_bss(sdata, params->mac); 1903 1904 sta_info_flush(sdata); 1905 return 0; 1906 } 1907 1908 static int ieee80211_change_station(struct wiphy *wiphy, 1909 struct net_device *dev, const u8 *mac, 1910 struct station_parameters *params) 1911 { 1912 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1913 struct ieee80211_local *local = wiphy_priv(wiphy); 1914 struct sta_info *sta; 1915 struct ieee80211_sub_if_data *vlansdata; 1916 enum cfg80211_station_type statype; 1917 int err; 1918 1919 mutex_lock(&local->sta_mtx); 1920 1921 sta = sta_info_get_bss(sdata, mac); 1922 if (!sta) { 1923 err = -ENOENT; 1924 goto out_err; 1925 } 1926 1927 switch (sdata->vif.type) { 1928 case NL80211_IFTYPE_MESH_POINT: 1929 if (sdata->u.mesh.user_mpm) 1930 statype = CFG80211_STA_MESH_PEER_USER; 1931 else 1932 statype = CFG80211_STA_MESH_PEER_KERNEL; 1933 break; 1934 case NL80211_IFTYPE_ADHOC: 1935 statype = CFG80211_STA_IBSS; 1936 break; 1937 case NL80211_IFTYPE_STATION: 1938 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) { 1939 statype = CFG80211_STA_AP_STA; 1940 break; 1941 } 1942 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) 1943 statype = CFG80211_STA_TDLS_PEER_ACTIVE; 1944 else 1945 statype = CFG80211_STA_TDLS_PEER_SETUP; 1946 break; 1947 case NL80211_IFTYPE_AP: 1948 case NL80211_IFTYPE_AP_VLAN: 1949 if (test_sta_flag(sta, WLAN_STA_ASSOC)) 1950 statype = CFG80211_STA_AP_CLIENT; 1951 else 1952 statype = CFG80211_STA_AP_CLIENT_UNASSOC; 1953 break; 1954 default: 1955 err = -EOPNOTSUPP; 1956 goto out_err; 1957 } 1958 1959 err = cfg80211_check_station_change(wiphy, params, statype); 1960 if (err) 1961 goto out_err; 1962 1963 if (params->vlan && params->vlan != sta->sdata->dev) { 1964 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); 1965 1966 if (params->vlan->ieee80211_ptr->use_4addr) { 1967 if (vlansdata->u.vlan.sta) { 1968 err = -EBUSY; 1969 goto out_err; 1970 } 1971 1972 rcu_assign_pointer(vlansdata->u.vlan.sta, sta); 1973 __ieee80211_check_fast_rx_iface(vlansdata); 1974 drv_sta_set_4addr(local, sta->sdata, &sta->sta, true); 1975 } 1976 1977 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && 1978 sta->sdata->u.vlan.sta) { 1979 ieee80211_clear_fast_rx(sta); 1980 RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL); 1981 } 1982 1983 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) 1984 ieee80211_vif_dec_num_mcast(sta->sdata); 1985 1986 sta->sdata = vlansdata; 1987 ieee80211_check_fast_xmit(sta); 1988 1989 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) { 1990 ieee80211_vif_inc_num_mcast(sta->sdata); 1991 cfg80211_send_layer2_update(sta->sdata->dev, 1992 sta->sta.addr); 1993 } 1994 } 1995 1996 /* we use sta_info_get_bss() so this might be different */ 1997 if (sdata != sta->sdata) { 1998 mutex_lock_nested(&sta->sdata->wdev.mtx, 1); 1999 err = sta_apply_parameters(local, sta, params); 2000 mutex_unlock(&sta->sdata->wdev.mtx); 2001 } else { 2002 err = sta_apply_parameters(local, sta, params); 2003 } 2004 if (err) 2005 goto out_err; 2006 2007 mutex_unlock(&local->sta_mtx); 2008 2009 if (sdata->vif.type == NL80211_IFTYPE_STATION && 2010 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) { 2011 ieee80211_recalc_ps(local); 2012 ieee80211_recalc_ps_vif(sdata); 2013 } 2014 2015 return 0; 2016 out_err: 2017 mutex_unlock(&local->sta_mtx); 2018 return err; 2019 } 2020 2021 #ifdef CONFIG_MAC80211_MESH 2022 static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, 2023 const u8 *dst, const u8 *next_hop) 2024 { 2025 struct ieee80211_sub_if_data *sdata; 2026 struct mesh_path *mpath; 2027 struct sta_info *sta; 2028 2029 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2030 2031 rcu_read_lock(); 2032 sta = sta_info_get(sdata, next_hop); 2033 if (!sta) { 2034 rcu_read_unlock(); 2035 return -ENOENT; 2036 } 2037 2038 mpath = mesh_path_add(sdata, dst); 2039 if (IS_ERR(mpath)) { 2040 rcu_read_unlock(); 2041 return PTR_ERR(mpath); 2042 } 2043 2044 mesh_path_fix_nexthop(mpath, sta); 2045 2046 rcu_read_unlock(); 2047 return 0; 2048 } 2049 2050 static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev, 2051 const u8 *dst) 2052 { 2053 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2054 2055 if (dst) 2056 return mesh_path_del(sdata, dst); 2057 2058 mesh_path_flush_by_iface(sdata); 2059 return 0; 2060 } 2061 2062 static int ieee80211_change_mpath(struct wiphy *wiphy, struct net_device *dev, 2063 const u8 *dst, const u8 *next_hop) 2064 { 2065 struct ieee80211_sub_if_data *sdata; 2066 struct mesh_path *mpath; 2067 struct sta_info *sta; 2068 2069 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2070 2071 rcu_read_lock(); 2072 2073 sta = sta_info_get(sdata, next_hop); 2074 if (!sta) { 2075 rcu_read_unlock(); 2076 return -ENOENT; 2077 } 2078 2079 mpath = mesh_path_lookup(sdata, dst); 2080 if (!mpath) { 2081 rcu_read_unlock(); 2082 return -ENOENT; 2083 } 2084 2085 mesh_path_fix_nexthop(mpath, sta); 2086 2087 rcu_read_unlock(); 2088 return 0; 2089 } 2090 2091 static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop, 2092 struct mpath_info *pinfo) 2093 { 2094 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop); 2095 2096 if (next_hop_sta) 2097 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN); 2098 else 2099 eth_zero_addr(next_hop); 2100 2101 memset(pinfo, 0, sizeof(*pinfo)); 2102 2103 pinfo->generation = mpath->sdata->u.mesh.mesh_paths_generation; 2104 2105 pinfo->filled = MPATH_INFO_FRAME_QLEN | 2106 MPATH_INFO_SN | 2107 MPATH_INFO_METRIC | 2108 MPATH_INFO_EXPTIME | 2109 MPATH_INFO_DISCOVERY_TIMEOUT | 2110 MPATH_INFO_DISCOVERY_RETRIES | 2111 MPATH_INFO_FLAGS | 2112 MPATH_INFO_HOP_COUNT | 2113 MPATH_INFO_PATH_CHANGE; 2114 2115 pinfo->frame_qlen = mpath->frame_queue.qlen; 2116 pinfo->sn = mpath->sn; 2117 pinfo->metric = mpath->metric; 2118 if (time_before(jiffies, mpath->exp_time)) 2119 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies); 2120 pinfo->discovery_timeout = 2121 jiffies_to_msecs(mpath->discovery_timeout); 2122 pinfo->discovery_retries = mpath->discovery_retries; 2123 if (mpath->flags & MESH_PATH_ACTIVE) 2124 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE; 2125 if (mpath->flags & MESH_PATH_RESOLVING) 2126 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING; 2127 if (mpath->flags & MESH_PATH_SN_VALID) 2128 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID; 2129 if (mpath->flags & MESH_PATH_FIXED) 2130 pinfo->flags |= NL80211_MPATH_FLAG_FIXED; 2131 if (mpath->flags & MESH_PATH_RESOLVED) 2132 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED; 2133 pinfo->hop_count = mpath->hop_count; 2134 pinfo->path_change_count = mpath->path_change_count; 2135 } 2136 2137 static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev, 2138 u8 *dst, u8 *next_hop, struct mpath_info *pinfo) 2139 2140 { 2141 struct ieee80211_sub_if_data *sdata; 2142 struct mesh_path *mpath; 2143 2144 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2145 2146 rcu_read_lock(); 2147 mpath = mesh_path_lookup(sdata, dst); 2148 if (!mpath) { 2149 rcu_read_unlock(); 2150 return -ENOENT; 2151 } 2152 memcpy(dst, mpath->dst, ETH_ALEN); 2153 mpath_set_pinfo(mpath, next_hop, pinfo); 2154 rcu_read_unlock(); 2155 return 0; 2156 } 2157 2158 static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, 2159 int idx, u8 *dst, u8 *next_hop, 2160 struct mpath_info *pinfo) 2161 { 2162 struct ieee80211_sub_if_data *sdata; 2163 struct mesh_path *mpath; 2164 2165 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2166 2167 rcu_read_lock(); 2168 mpath = mesh_path_lookup_by_idx(sdata, idx); 2169 if (!mpath) { 2170 rcu_read_unlock(); 2171 return -ENOENT; 2172 } 2173 memcpy(dst, mpath->dst, ETH_ALEN); 2174 mpath_set_pinfo(mpath, next_hop, pinfo); 2175 rcu_read_unlock(); 2176 return 0; 2177 } 2178 2179 static void mpp_set_pinfo(struct mesh_path *mpath, u8 *mpp, 2180 struct mpath_info *pinfo) 2181 { 2182 memset(pinfo, 0, sizeof(*pinfo)); 2183 memcpy(mpp, mpath->mpp, ETH_ALEN); 2184 2185 pinfo->generation = mpath->sdata->u.mesh.mpp_paths_generation; 2186 } 2187 2188 static int ieee80211_get_mpp(struct wiphy *wiphy, struct net_device *dev, 2189 u8 *dst, u8 *mpp, struct mpath_info *pinfo) 2190 2191 { 2192 struct ieee80211_sub_if_data *sdata; 2193 struct mesh_path *mpath; 2194 2195 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2196 2197 rcu_read_lock(); 2198 mpath = mpp_path_lookup(sdata, dst); 2199 if (!mpath) { 2200 rcu_read_unlock(); 2201 return -ENOENT; 2202 } 2203 memcpy(dst, mpath->dst, ETH_ALEN); 2204 mpp_set_pinfo(mpath, mpp, pinfo); 2205 rcu_read_unlock(); 2206 return 0; 2207 } 2208 2209 static int ieee80211_dump_mpp(struct wiphy *wiphy, struct net_device *dev, 2210 int idx, u8 *dst, u8 *mpp, 2211 struct mpath_info *pinfo) 2212 { 2213 struct ieee80211_sub_if_data *sdata; 2214 struct mesh_path *mpath; 2215 2216 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2217 2218 rcu_read_lock(); 2219 mpath = mpp_path_lookup_by_idx(sdata, idx); 2220 if (!mpath) { 2221 rcu_read_unlock(); 2222 return -ENOENT; 2223 } 2224 memcpy(dst, mpath->dst, ETH_ALEN); 2225 mpp_set_pinfo(mpath, mpp, pinfo); 2226 rcu_read_unlock(); 2227 return 0; 2228 } 2229 2230 static int ieee80211_get_mesh_config(struct wiphy *wiphy, 2231 struct net_device *dev, 2232 struct mesh_config *conf) 2233 { 2234 struct ieee80211_sub_if_data *sdata; 2235 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2236 2237 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config)); 2238 return 0; 2239 } 2240 2241 static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask) 2242 { 2243 return (mask >> (parm-1)) & 0x1; 2244 } 2245 2246 static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh, 2247 const struct mesh_setup *setup) 2248 { 2249 u8 *new_ie; 2250 struct ieee80211_sub_if_data *sdata = container_of(ifmsh, 2251 struct ieee80211_sub_if_data, u.mesh); 2252 int i; 2253 2254 /* allocate information elements */ 2255 new_ie = NULL; 2256 2257 if (setup->ie_len) { 2258 new_ie = kmemdup(setup->ie, setup->ie_len, 2259 GFP_KERNEL); 2260 if (!new_ie) 2261 return -ENOMEM; 2262 } 2263 ifmsh->ie_len = setup->ie_len; 2264 ifmsh->ie = new_ie; 2265 2266 /* now copy the rest of the setup parameters */ 2267 ifmsh->mesh_id_len = setup->mesh_id_len; 2268 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len); 2269 ifmsh->mesh_sp_id = setup->sync_method; 2270 ifmsh->mesh_pp_id = setup->path_sel_proto; 2271 ifmsh->mesh_pm_id = setup->path_metric; 2272 ifmsh->user_mpm = setup->user_mpm; 2273 ifmsh->mesh_auth_id = setup->auth_id; 2274 ifmsh->security = IEEE80211_MESH_SEC_NONE; 2275 ifmsh->userspace_handles_dfs = setup->userspace_handles_dfs; 2276 if (setup->is_authenticated) 2277 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED; 2278 if (setup->is_secure) 2279 ifmsh->security |= IEEE80211_MESH_SEC_SECURED; 2280 2281 /* mcast rate setting in Mesh Node */ 2282 memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate, 2283 sizeof(setup->mcast_rate)); 2284 sdata->vif.bss_conf.basic_rates = setup->basic_rates; 2285 2286 sdata->vif.bss_conf.beacon_int = setup->beacon_interval; 2287 sdata->vif.bss_conf.dtim_period = setup->dtim_period; 2288 2289 sdata->beacon_rate_set = false; 2290 if (wiphy_ext_feature_isset(sdata->local->hw.wiphy, 2291 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) { 2292 for (i = 0; i < NUM_NL80211_BANDS; i++) { 2293 sdata->beacon_rateidx_mask[i] = 2294 setup->beacon_rate.control[i].legacy; 2295 if (sdata->beacon_rateidx_mask[i]) 2296 sdata->beacon_rate_set = true; 2297 } 2298 } 2299 2300 return 0; 2301 } 2302 2303 static int ieee80211_update_mesh_config(struct wiphy *wiphy, 2304 struct net_device *dev, u32 mask, 2305 const struct mesh_config *nconf) 2306 { 2307 struct mesh_config *conf; 2308 struct ieee80211_sub_if_data *sdata; 2309 struct ieee80211_if_mesh *ifmsh; 2310 2311 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2312 ifmsh = &sdata->u.mesh; 2313 2314 /* Set the config options which we are interested in setting */ 2315 conf = &(sdata->u.mesh.mshcfg); 2316 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask)) 2317 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout; 2318 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask)) 2319 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout; 2320 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask)) 2321 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout; 2322 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask)) 2323 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks; 2324 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask)) 2325 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries; 2326 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask)) 2327 conf->dot11MeshTTL = nconf->dot11MeshTTL; 2328 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask)) 2329 conf->element_ttl = nconf->element_ttl; 2330 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) { 2331 if (ifmsh->user_mpm) 2332 return -EBUSY; 2333 conf->auto_open_plinks = nconf->auto_open_plinks; 2334 } 2335 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask)) 2336 conf->dot11MeshNbrOffsetMaxNeighbor = 2337 nconf->dot11MeshNbrOffsetMaxNeighbor; 2338 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask)) 2339 conf->dot11MeshHWMPmaxPREQretries = 2340 nconf->dot11MeshHWMPmaxPREQretries; 2341 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask)) 2342 conf->path_refresh_time = nconf->path_refresh_time; 2343 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask)) 2344 conf->min_discovery_timeout = nconf->min_discovery_timeout; 2345 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask)) 2346 conf->dot11MeshHWMPactivePathTimeout = 2347 nconf->dot11MeshHWMPactivePathTimeout; 2348 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask)) 2349 conf->dot11MeshHWMPpreqMinInterval = 2350 nconf->dot11MeshHWMPpreqMinInterval; 2351 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask)) 2352 conf->dot11MeshHWMPperrMinInterval = 2353 nconf->dot11MeshHWMPperrMinInterval; 2354 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME, 2355 mask)) 2356 conf->dot11MeshHWMPnetDiameterTraversalTime = 2357 nconf->dot11MeshHWMPnetDiameterTraversalTime; 2358 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) { 2359 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode; 2360 ieee80211_mesh_root_setup(ifmsh); 2361 } 2362 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) { 2363 /* our current gate announcement implementation rides on root 2364 * announcements, so require this ifmsh to also be a root node 2365 * */ 2366 if (nconf->dot11MeshGateAnnouncementProtocol && 2367 !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) { 2368 conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN; 2369 ieee80211_mesh_root_setup(ifmsh); 2370 } 2371 conf->dot11MeshGateAnnouncementProtocol = 2372 nconf->dot11MeshGateAnnouncementProtocol; 2373 } 2374 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask)) 2375 conf->dot11MeshHWMPRannInterval = 2376 nconf->dot11MeshHWMPRannInterval; 2377 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask)) 2378 conf->dot11MeshForwarding = nconf->dot11MeshForwarding; 2379 if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) { 2380 /* our RSSI threshold implementation is supported only for 2381 * devices that report signal in dBm. 2382 */ 2383 if (!ieee80211_hw_check(&sdata->local->hw, SIGNAL_DBM)) 2384 return -ENOTSUPP; 2385 conf->rssi_threshold = nconf->rssi_threshold; 2386 } 2387 if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) { 2388 conf->ht_opmode = nconf->ht_opmode; 2389 sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode; 2390 ieee80211_link_info_change_notify(sdata, &sdata->deflink, 2391 BSS_CHANGED_HT); 2392 } 2393 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask)) 2394 conf->dot11MeshHWMPactivePathToRootTimeout = 2395 nconf->dot11MeshHWMPactivePathToRootTimeout; 2396 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask)) 2397 conf->dot11MeshHWMProotInterval = 2398 nconf->dot11MeshHWMProotInterval; 2399 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask)) 2400 conf->dot11MeshHWMPconfirmationInterval = 2401 nconf->dot11MeshHWMPconfirmationInterval; 2402 if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE, mask)) { 2403 conf->power_mode = nconf->power_mode; 2404 ieee80211_mps_local_status_update(sdata); 2405 } 2406 if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW, mask)) 2407 conf->dot11MeshAwakeWindowDuration = 2408 nconf->dot11MeshAwakeWindowDuration; 2409 if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT, mask)) 2410 conf->plink_timeout = nconf->plink_timeout; 2411 if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_GATE, mask)) 2412 conf->dot11MeshConnectedToMeshGate = 2413 nconf->dot11MeshConnectedToMeshGate; 2414 if (_chg_mesh_attr(NL80211_MESHCONF_NOLEARN, mask)) 2415 conf->dot11MeshNolearn = nconf->dot11MeshNolearn; 2416 if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_AS, mask)) 2417 conf->dot11MeshConnectedToAuthServer = 2418 nconf->dot11MeshConnectedToAuthServer; 2419 ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON); 2420 return 0; 2421 } 2422 2423 static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev, 2424 const struct mesh_config *conf, 2425 const struct mesh_setup *setup) 2426 { 2427 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2428 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 2429 int err; 2430 2431 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config)); 2432 err = copy_mesh_setup(ifmsh, setup); 2433 if (err) 2434 return err; 2435 2436 sdata->control_port_over_nl80211 = setup->control_port_over_nl80211; 2437 2438 /* can mesh use other SMPS modes? */ 2439 sdata->deflink.smps_mode = IEEE80211_SMPS_OFF; 2440 sdata->deflink.needed_rx_chains = sdata->local->rx_chains; 2441 2442 mutex_lock(&sdata->local->mtx); 2443 err = ieee80211_link_use_channel(&sdata->deflink, &setup->chandef, 2444 IEEE80211_CHANCTX_SHARED); 2445 mutex_unlock(&sdata->local->mtx); 2446 if (err) 2447 return err; 2448 2449 return ieee80211_start_mesh(sdata); 2450 } 2451 2452 static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev) 2453 { 2454 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2455 2456 ieee80211_stop_mesh(sdata); 2457 mutex_lock(&sdata->local->mtx); 2458 ieee80211_link_release_channel(&sdata->deflink); 2459 kfree(sdata->u.mesh.ie); 2460 mutex_unlock(&sdata->local->mtx); 2461 2462 return 0; 2463 } 2464 #endif 2465 2466 static int ieee80211_change_bss(struct wiphy *wiphy, 2467 struct net_device *dev, 2468 struct bss_parameters *params) 2469 { 2470 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2471 struct ieee80211_supported_band *sband; 2472 u32 changed = 0; 2473 2474 if (!sdata_dereference(sdata->deflink.u.ap.beacon, sdata)) 2475 return -ENOENT; 2476 2477 sband = ieee80211_get_sband(sdata); 2478 if (!sband) 2479 return -EINVAL; 2480 2481 if (params->use_cts_prot >= 0) { 2482 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot; 2483 changed |= BSS_CHANGED_ERP_CTS_PROT; 2484 } 2485 if (params->use_short_preamble >= 0) { 2486 sdata->vif.bss_conf.use_short_preamble = 2487 params->use_short_preamble; 2488 changed |= BSS_CHANGED_ERP_PREAMBLE; 2489 } 2490 2491 if (!sdata->vif.bss_conf.use_short_slot && 2492 (sband->band == NL80211_BAND_5GHZ || 2493 sband->band == NL80211_BAND_6GHZ)) { 2494 sdata->vif.bss_conf.use_short_slot = true; 2495 changed |= BSS_CHANGED_ERP_SLOT; 2496 } 2497 2498 if (params->use_short_slot_time >= 0) { 2499 sdata->vif.bss_conf.use_short_slot = 2500 params->use_short_slot_time; 2501 changed |= BSS_CHANGED_ERP_SLOT; 2502 } 2503 2504 if (params->basic_rates) { 2505 ieee80211_parse_bitrates(sdata->vif.bss_conf.chandef.width, 2506 wiphy->bands[sband->band], 2507 params->basic_rates, 2508 params->basic_rates_len, 2509 &sdata->vif.bss_conf.basic_rates); 2510 changed |= BSS_CHANGED_BASIC_RATES; 2511 ieee80211_check_rate_mask(&sdata->deflink); 2512 } 2513 2514 if (params->ap_isolate >= 0) { 2515 if (params->ap_isolate) 2516 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS; 2517 else 2518 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS; 2519 ieee80211_check_fast_rx_iface(sdata); 2520 } 2521 2522 if (params->ht_opmode >= 0) { 2523 sdata->vif.bss_conf.ht_operation_mode = 2524 (u16) params->ht_opmode; 2525 changed |= BSS_CHANGED_HT; 2526 } 2527 2528 if (params->p2p_ctwindow >= 0) { 2529 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &= 2530 ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK; 2531 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |= 2532 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK; 2533 changed |= BSS_CHANGED_P2P_PS; 2534 } 2535 2536 if (params->p2p_opp_ps > 0) { 2537 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |= 2538 IEEE80211_P2P_OPPPS_ENABLE_BIT; 2539 changed |= BSS_CHANGED_P2P_PS; 2540 } else if (params->p2p_opp_ps == 0) { 2541 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &= 2542 ~IEEE80211_P2P_OPPPS_ENABLE_BIT; 2543 changed |= BSS_CHANGED_P2P_PS; 2544 } 2545 2546 ieee80211_link_info_change_notify(sdata, &sdata->deflink, changed); 2547 2548 return 0; 2549 } 2550 2551 static int ieee80211_set_txq_params(struct wiphy *wiphy, 2552 struct net_device *dev, 2553 struct ieee80211_txq_params *params) 2554 { 2555 struct ieee80211_local *local = wiphy_priv(wiphy); 2556 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2557 struct ieee80211_link_data *link = &sdata->deflink; 2558 struct ieee80211_tx_queue_params p; 2559 2560 if (!local->ops->conf_tx) 2561 return -EOPNOTSUPP; 2562 2563 if (local->hw.queues < IEEE80211_NUM_ACS) 2564 return -EOPNOTSUPP; 2565 2566 memset(&p, 0, sizeof(p)); 2567 p.aifs = params->aifs; 2568 p.cw_max = params->cwmax; 2569 p.cw_min = params->cwmin; 2570 p.txop = params->txop; 2571 2572 /* 2573 * Setting tx queue params disables u-apsd because it's only 2574 * called in master mode. 2575 */ 2576 p.uapsd = false; 2577 2578 ieee80211_regulatory_limit_wmm_params(sdata, &p, params->ac); 2579 2580 link->tx_conf[params->ac] = p; 2581 if (drv_conf_tx(local, link, params->ac, &p)) { 2582 wiphy_debug(local->hw.wiphy, 2583 "failed to set TX queue parameters for AC %d\n", 2584 params->ac); 2585 return -EINVAL; 2586 } 2587 2588 ieee80211_link_info_change_notify(sdata, link, 2589 BSS_CHANGED_QOS); 2590 2591 return 0; 2592 } 2593 2594 #ifdef CONFIG_PM 2595 static int ieee80211_suspend(struct wiphy *wiphy, 2596 struct cfg80211_wowlan *wowlan) 2597 { 2598 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan); 2599 } 2600 2601 static int ieee80211_resume(struct wiphy *wiphy) 2602 { 2603 return __ieee80211_resume(wiphy_priv(wiphy)); 2604 } 2605 #else 2606 #define ieee80211_suspend NULL 2607 #define ieee80211_resume NULL 2608 #endif 2609 2610 static int ieee80211_scan(struct wiphy *wiphy, 2611 struct cfg80211_scan_request *req) 2612 { 2613 struct ieee80211_sub_if_data *sdata; 2614 2615 sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev); 2616 2617 switch (ieee80211_vif_type_p2p(&sdata->vif)) { 2618 case NL80211_IFTYPE_STATION: 2619 case NL80211_IFTYPE_ADHOC: 2620 case NL80211_IFTYPE_MESH_POINT: 2621 case NL80211_IFTYPE_P2P_CLIENT: 2622 case NL80211_IFTYPE_P2P_DEVICE: 2623 break; 2624 case NL80211_IFTYPE_P2P_GO: 2625 if (sdata->local->ops->hw_scan) 2626 break; 2627 /* 2628 * FIXME: implement NoA while scanning in software, 2629 * for now fall through to allow scanning only when 2630 * beaconing hasn't been configured yet 2631 */ 2632 fallthrough; 2633 case NL80211_IFTYPE_AP: 2634 /* 2635 * If the scan has been forced (and the driver supports 2636 * forcing), don't care about being beaconing already. 2637 * This will create problems to the attached stations (e.g. all 2638 * the frames sent while scanning on other channel will be 2639 * lost) 2640 */ 2641 if (sdata->deflink.u.ap.beacon && 2642 (!(wiphy->features & NL80211_FEATURE_AP_SCAN) || 2643 !(req->flags & NL80211_SCAN_FLAG_AP))) 2644 return -EOPNOTSUPP; 2645 break; 2646 case NL80211_IFTYPE_NAN: 2647 default: 2648 return -EOPNOTSUPP; 2649 } 2650 2651 return ieee80211_request_scan(sdata, req); 2652 } 2653 2654 static void ieee80211_abort_scan(struct wiphy *wiphy, struct wireless_dev *wdev) 2655 { 2656 ieee80211_scan_cancel(wiphy_priv(wiphy)); 2657 } 2658 2659 static int 2660 ieee80211_sched_scan_start(struct wiphy *wiphy, 2661 struct net_device *dev, 2662 struct cfg80211_sched_scan_request *req) 2663 { 2664 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2665 2666 if (!sdata->local->ops->sched_scan_start) 2667 return -EOPNOTSUPP; 2668 2669 return ieee80211_request_sched_scan_start(sdata, req); 2670 } 2671 2672 static int 2673 ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev, 2674 u64 reqid) 2675 { 2676 struct ieee80211_local *local = wiphy_priv(wiphy); 2677 2678 if (!local->ops->sched_scan_stop) 2679 return -EOPNOTSUPP; 2680 2681 return ieee80211_request_sched_scan_stop(local); 2682 } 2683 2684 static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev, 2685 struct cfg80211_auth_request *req) 2686 { 2687 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req); 2688 } 2689 2690 static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev, 2691 struct cfg80211_assoc_request *req) 2692 { 2693 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req); 2694 } 2695 2696 static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev, 2697 struct cfg80211_deauth_request *req) 2698 { 2699 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req); 2700 } 2701 2702 static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev, 2703 struct cfg80211_disassoc_request *req) 2704 { 2705 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req); 2706 } 2707 2708 static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, 2709 struct cfg80211_ibss_params *params) 2710 { 2711 return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params); 2712 } 2713 2714 static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) 2715 { 2716 return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev)); 2717 } 2718 2719 static int ieee80211_join_ocb(struct wiphy *wiphy, struct net_device *dev, 2720 struct ocb_setup *setup) 2721 { 2722 return ieee80211_ocb_join(IEEE80211_DEV_TO_SUB_IF(dev), setup); 2723 } 2724 2725 static int ieee80211_leave_ocb(struct wiphy *wiphy, struct net_device *dev) 2726 { 2727 return ieee80211_ocb_leave(IEEE80211_DEV_TO_SUB_IF(dev)); 2728 } 2729 2730 static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev, 2731 int rate[NUM_NL80211_BANDS]) 2732 { 2733 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2734 2735 memcpy(sdata->vif.bss_conf.mcast_rate, rate, 2736 sizeof(int) * NUM_NL80211_BANDS); 2737 2738 ieee80211_link_info_change_notify(sdata, &sdata->deflink, 2739 BSS_CHANGED_MCAST_RATE); 2740 2741 return 0; 2742 } 2743 2744 static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) 2745 { 2746 struct ieee80211_local *local = wiphy_priv(wiphy); 2747 int err; 2748 2749 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { 2750 ieee80211_check_fast_xmit_all(local); 2751 2752 err = drv_set_frag_threshold(local, wiphy->frag_threshold); 2753 2754 if (err) { 2755 ieee80211_check_fast_xmit_all(local); 2756 return err; 2757 } 2758 } 2759 2760 if ((changed & WIPHY_PARAM_COVERAGE_CLASS) || 2761 (changed & WIPHY_PARAM_DYN_ACK)) { 2762 s16 coverage_class; 2763 2764 coverage_class = changed & WIPHY_PARAM_COVERAGE_CLASS ? 2765 wiphy->coverage_class : -1; 2766 err = drv_set_coverage_class(local, coverage_class); 2767 2768 if (err) 2769 return err; 2770 } 2771 2772 if (changed & WIPHY_PARAM_RTS_THRESHOLD) { 2773 err = drv_set_rts_threshold(local, wiphy->rts_threshold); 2774 2775 if (err) 2776 return err; 2777 } 2778 2779 if (changed & WIPHY_PARAM_RETRY_SHORT) { 2780 if (wiphy->retry_short > IEEE80211_MAX_TX_RETRY) 2781 return -EINVAL; 2782 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; 2783 } 2784 if (changed & WIPHY_PARAM_RETRY_LONG) { 2785 if (wiphy->retry_long > IEEE80211_MAX_TX_RETRY) 2786 return -EINVAL; 2787 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; 2788 } 2789 if (changed & 2790 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG)) 2791 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS); 2792 2793 if (changed & (WIPHY_PARAM_TXQ_LIMIT | 2794 WIPHY_PARAM_TXQ_MEMORY_LIMIT | 2795 WIPHY_PARAM_TXQ_QUANTUM)) 2796 ieee80211_txq_set_params(local); 2797 2798 return 0; 2799 } 2800 2801 static int ieee80211_set_tx_power(struct wiphy *wiphy, 2802 struct wireless_dev *wdev, 2803 enum nl80211_tx_power_setting type, int mbm) 2804 { 2805 struct ieee80211_local *local = wiphy_priv(wiphy); 2806 struct ieee80211_sub_if_data *sdata; 2807 enum nl80211_tx_power_setting txp_type = type; 2808 bool update_txp_type = false; 2809 bool has_monitor = false; 2810 2811 if (wdev) { 2812 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 2813 2814 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) { 2815 sdata = wiphy_dereference(local->hw.wiphy, 2816 local->monitor_sdata); 2817 if (!sdata) 2818 return -EOPNOTSUPP; 2819 } 2820 2821 switch (type) { 2822 case NL80211_TX_POWER_AUTOMATIC: 2823 sdata->deflink.user_power_level = 2824 IEEE80211_UNSET_POWER_LEVEL; 2825 txp_type = NL80211_TX_POWER_LIMITED; 2826 break; 2827 case NL80211_TX_POWER_LIMITED: 2828 case NL80211_TX_POWER_FIXED: 2829 if (mbm < 0 || (mbm % 100)) 2830 return -EOPNOTSUPP; 2831 sdata->deflink.user_power_level = MBM_TO_DBM(mbm); 2832 break; 2833 } 2834 2835 if (txp_type != sdata->vif.bss_conf.txpower_type) { 2836 update_txp_type = true; 2837 sdata->vif.bss_conf.txpower_type = txp_type; 2838 } 2839 2840 ieee80211_recalc_txpower(sdata, update_txp_type); 2841 2842 return 0; 2843 } 2844 2845 switch (type) { 2846 case NL80211_TX_POWER_AUTOMATIC: 2847 local->user_power_level = IEEE80211_UNSET_POWER_LEVEL; 2848 txp_type = NL80211_TX_POWER_LIMITED; 2849 break; 2850 case NL80211_TX_POWER_LIMITED: 2851 case NL80211_TX_POWER_FIXED: 2852 if (mbm < 0 || (mbm % 100)) 2853 return -EOPNOTSUPP; 2854 local->user_power_level = MBM_TO_DBM(mbm); 2855 break; 2856 } 2857 2858 mutex_lock(&local->iflist_mtx); 2859 list_for_each_entry(sdata, &local->interfaces, list) { 2860 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) { 2861 has_monitor = true; 2862 continue; 2863 } 2864 sdata->deflink.user_power_level = local->user_power_level; 2865 if (txp_type != sdata->vif.bss_conf.txpower_type) 2866 update_txp_type = true; 2867 sdata->vif.bss_conf.txpower_type = txp_type; 2868 } 2869 list_for_each_entry(sdata, &local->interfaces, list) { 2870 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) 2871 continue; 2872 ieee80211_recalc_txpower(sdata, update_txp_type); 2873 } 2874 mutex_unlock(&local->iflist_mtx); 2875 2876 if (has_monitor) { 2877 sdata = wiphy_dereference(local->hw.wiphy, 2878 local->monitor_sdata); 2879 if (sdata) { 2880 sdata->deflink.user_power_level = local->user_power_level; 2881 if (txp_type != sdata->vif.bss_conf.txpower_type) 2882 update_txp_type = true; 2883 sdata->vif.bss_conf.txpower_type = txp_type; 2884 2885 ieee80211_recalc_txpower(sdata, update_txp_type); 2886 } 2887 } 2888 2889 return 0; 2890 } 2891 2892 static int ieee80211_get_tx_power(struct wiphy *wiphy, 2893 struct wireless_dev *wdev, 2894 int *dbm) 2895 { 2896 struct ieee80211_local *local = wiphy_priv(wiphy); 2897 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 2898 2899 if (local->ops->get_txpower) 2900 return drv_get_txpower(local, sdata, dbm); 2901 2902 if (!local->use_chanctx) 2903 *dbm = local->hw.conf.power_level; 2904 else 2905 *dbm = sdata->vif.bss_conf.txpower; 2906 2907 return 0; 2908 } 2909 2910 static void ieee80211_rfkill_poll(struct wiphy *wiphy) 2911 { 2912 struct ieee80211_local *local = wiphy_priv(wiphy); 2913 2914 drv_rfkill_poll(local); 2915 } 2916 2917 #ifdef CONFIG_NL80211_TESTMODE 2918 static int ieee80211_testmode_cmd(struct wiphy *wiphy, 2919 struct wireless_dev *wdev, 2920 void *data, int len) 2921 { 2922 struct ieee80211_local *local = wiphy_priv(wiphy); 2923 struct ieee80211_vif *vif = NULL; 2924 2925 if (!local->ops->testmode_cmd) 2926 return -EOPNOTSUPP; 2927 2928 if (wdev) { 2929 struct ieee80211_sub_if_data *sdata; 2930 2931 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 2932 if (sdata->flags & IEEE80211_SDATA_IN_DRIVER) 2933 vif = &sdata->vif; 2934 } 2935 2936 return local->ops->testmode_cmd(&local->hw, vif, data, len); 2937 } 2938 2939 static int ieee80211_testmode_dump(struct wiphy *wiphy, 2940 struct sk_buff *skb, 2941 struct netlink_callback *cb, 2942 void *data, int len) 2943 { 2944 struct ieee80211_local *local = wiphy_priv(wiphy); 2945 2946 if (!local->ops->testmode_dump) 2947 return -EOPNOTSUPP; 2948 2949 return local->ops->testmode_dump(&local->hw, skb, cb, data, len); 2950 } 2951 #endif 2952 2953 int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata, 2954 struct ieee80211_link_data *link, 2955 enum ieee80211_smps_mode smps_mode) 2956 { 2957 const u8 *ap; 2958 enum ieee80211_smps_mode old_req; 2959 int err; 2960 struct sta_info *sta; 2961 bool tdls_peer_found = false; 2962 2963 lockdep_assert_held(&sdata->wdev.mtx); 2964 2965 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION)) 2966 return -EINVAL; 2967 2968 old_req = link->u.mgd.req_smps; 2969 link->u.mgd.req_smps = smps_mode; 2970 2971 if (old_req == smps_mode && 2972 smps_mode != IEEE80211_SMPS_AUTOMATIC) 2973 return 0; 2974 2975 /* 2976 * If not associated, or current association is not an HT 2977 * association, there's no need to do anything, just store 2978 * the new value until we associate. 2979 */ 2980 if (!sdata->u.mgd.associated || 2981 link->conf->chandef.width == NL80211_CHAN_WIDTH_20_NOHT) 2982 return 0; 2983 2984 ap = link->u.mgd.bssid; 2985 2986 rcu_read_lock(); 2987 list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) { 2988 if (!sta->sta.tdls || sta->sdata != sdata || !sta->uploaded || 2989 !test_sta_flag(sta, WLAN_STA_AUTHORIZED)) 2990 continue; 2991 2992 tdls_peer_found = true; 2993 break; 2994 } 2995 rcu_read_unlock(); 2996 2997 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) { 2998 if (tdls_peer_found || !sdata->u.mgd.powersave) 2999 smps_mode = IEEE80211_SMPS_OFF; 3000 else 3001 smps_mode = IEEE80211_SMPS_DYNAMIC; 3002 } 3003 3004 /* send SM PS frame to AP */ 3005 err = ieee80211_send_smps_action(sdata, smps_mode, 3006 ap, ap); 3007 if (err) 3008 link->u.mgd.req_smps = old_req; 3009 else if (smps_mode != IEEE80211_SMPS_OFF && tdls_peer_found) 3010 ieee80211_teardown_tdls_peers(sdata); 3011 3012 return err; 3013 } 3014 3015 static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, 3016 bool enabled, int timeout) 3017 { 3018 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 3019 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 3020 unsigned int link_id; 3021 3022 if (sdata->vif.type != NL80211_IFTYPE_STATION) 3023 return -EOPNOTSUPP; 3024 3025 if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS)) 3026 return -EOPNOTSUPP; 3027 3028 if (enabled == sdata->u.mgd.powersave && 3029 timeout == local->dynamic_ps_forced_timeout) 3030 return 0; 3031 3032 sdata->u.mgd.powersave = enabled; 3033 local->dynamic_ps_forced_timeout = timeout; 3034 3035 /* no change, but if automatic follow powersave */ 3036 sdata_lock(sdata); 3037 for (link_id = 0; link_id < ARRAY_SIZE(sdata->link); link_id++) { 3038 struct ieee80211_link_data *link; 3039 3040 link = sdata_dereference(sdata->link[link_id], sdata); 3041 3042 if (!link) 3043 continue; 3044 __ieee80211_request_smps_mgd(sdata, link, 3045 link->u.mgd.req_smps); 3046 } 3047 sdata_unlock(sdata); 3048 3049 if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS)) 3050 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); 3051 3052 ieee80211_recalc_ps(local); 3053 ieee80211_recalc_ps_vif(sdata); 3054 ieee80211_check_fast_rx_iface(sdata); 3055 3056 return 0; 3057 } 3058 3059 static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy, 3060 struct net_device *dev, 3061 s32 rssi_thold, u32 rssi_hyst) 3062 { 3063 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 3064 struct ieee80211_vif *vif = &sdata->vif; 3065 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; 3066 3067 if (rssi_thold == bss_conf->cqm_rssi_thold && 3068 rssi_hyst == bss_conf->cqm_rssi_hyst) 3069 return 0; 3070 3071 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER && 3072 !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)) 3073 return -EOPNOTSUPP; 3074 3075 bss_conf->cqm_rssi_thold = rssi_thold; 3076 bss_conf->cqm_rssi_hyst = rssi_hyst; 3077 bss_conf->cqm_rssi_low = 0; 3078 bss_conf->cqm_rssi_high = 0; 3079 sdata->deflink.u.mgd.last_cqm_event_signal = 0; 3080 3081 /* tell the driver upon association, unless already associated */ 3082 if (sdata->u.mgd.associated && 3083 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI) 3084 ieee80211_link_info_change_notify(sdata, &sdata->deflink, 3085 BSS_CHANGED_CQM); 3086 3087 return 0; 3088 } 3089 3090 static int ieee80211_set_cqm_rssi_range_config(struct wiphy *wiphy, 3091 struct net_device *dev, 3092 s32 rssi_low, s32 rssi_high) 3093 { 3094 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 3095 struct ieee80211_vif *vif = &sdata->vif; 3096 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; 3097 3098 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER) 3099 return -EOPNOTSUPP; 3100 3101 bss_conf->cqm_rssi_low = rssi_low; 3102 bss_conf->cqm_rssi_high = rssi_high; 3103 bss_conf->cqm_rssi_thold = 0; 3104 bss_conf->cqm_rssi_hyst = 0; 3105 sdata->deflink.u.mgd.last_cqm_event_signal = 0; 3106 3107 /* tell the driver upon association, unless already associated */ 3108 if (sdata->u.mgd.associated && 3109 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI) 3110 ieee80211_link_info_change_notify(sdata, &sdata->deflink, 3111 BSS_CHANGED_CQM); 3112 3113 return 0; 3114 } 3115 3116 static int ieee80211_set_bitrate_mask(struct wiphy *wiphy, 3117 struct net_device *dev, 3118 unsigned int link_id, 3119 const u8 *addr, 3120 const struct cfg80211_bitrate_mask *mask) 3121 { 3122 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 3123 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 3124 int i, ret; 3125 3126 if (!ieee80211_sdata_running(sdata)) 3127 return -ENETDOWN; 3128 3129 /* 3130 * If active validate the setting and reject it if it doesn't leave 3131 * at least one basic rate usable, since we really have to be able 3132 * to send something, and if we're an AP we have to be able to do 3133 * so at a basic rate so that all clients can receive it. 3134 */ 3135 if (rcu_access_pointer(sdata->vif.bss_conf.chanctx_conf) && 3136 sdata->vif.bss_conf.chandef.chan) { 3137 u32 basic_rates = sdata->vif.bss_conf.basic_rates; 3138 enum nl80211_band band = sdata->vif.bss_conf.chandef.chan->band; 3139 3140 if (!(mask->control[band].legacy & basic_rates)) 3141 return -EINVAL; 3142 } 3143 3144 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) { 3145 ret = drv_set_bitrate_mask(local, sdata, mask); 3146 if (ret) 3147 return ret; 3148 } 3149 3150 for (i = 0; i < NUM_NL80211_BANDS; i++) { 3151 struct ieee80211_supported_band *sband = wiphy->bands[i]; 3152 int j; 3153 3154 sdata->rc_rateidx_mask[i] = mask->control[i].legacy; 3155 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].ht_mcs, 3156 sizeof(mask->control[i].ht_mcs)); 3157 memcpy(sdata->rc_rateidx_vht_mcs_mask[i], 3158 mask->control[i].vht_mcs, 3159 sizeof(mask->control[i].vht_mcs)); 3160 3161 sdata->rc_has_mcs_mask[i] = false; 3162 sdata->rc_has_vht_mcs_mask[i] = false; 3163 if (!sband) 3164 continue; 3165 3166 for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) { 3167 if (sdata->rc_rateidx_mcs_mask[i][j] != 0xff) { 3168 sdata->rc_has_mcs_mask[i] = true; 3169 break; 3170 } 3171 } 3172 3173 for (j = 0; j < NL80211_VHT_NSS_MAX; j++) { 3174 if (sdata->rc_rateidx_vht_mcs_mask[i][j] != 0xffff) { 3175 sdata->rc_has_vht_mcs_mask[i] = true; 3176 break; 3177 } 3178 } 3179 } 3180 3181 return 0; 3182 } 3183 3184 static int ieee80211_start_radar_detection(struct wiphy *wiphy, 3185 struct net_device *dev, 3186 struct cfg80211_chan_def *chandef, 3187 u32 cac_time_ms) 3188 { 3189 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 3190 struct ieee80211_local *local = sdata->local; 3191 int err; 3192 3193 mutex_lock(&local->mtx); 3194 if (!list_empty(&local->roc_list) || local->scanning) { 3195 err = -EBUSY; 3196 goto out_unlock; 3197 } 3198 3199 /* whatever, but channel contexts should not complain about that one */ 3200 sdata->deflink.smps_mode = IEEE80211_SMPS_OFF; 3201 sdata->deflink.needed_rx_chains = local->rx_chains; 3202 3203 err = ieee80211_link_use_channel(&sdata->deflink, chandef, 3204 IEEE80211_CHANCTX_SHARED); 3205 if (err) 3206 goto out_unlock; 3207 3208 ieee80211_queue_delayed_work(&sdata->local->hw, 3209 &sdata->deflink.dfs_cac_timer_work, 3210 msecs_to_jiffies(cac_time_ms)); 3211 3212 out_unlock: 3213 mutex_unlock(&local->mtx); 3214 return err; 3215 } 3216 3217 static void ieee80211_end_cac(struct wiphy *wiphy, 3218 struct net_device *dev) 3219 { 3220 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 3221 struct ieee80211_local *local = sdata->local; 3222 3223 mutex_lock(&local->mtx); 3224 list_for_each_entry(sdata, &local->interfaces, list) { 3225 /* it might be waiting for the local->mtx, but then 3226 * by the time it gets it, sdata->wdev.cac_started 3227 * will no longer be true 3228 */ 3229 cancel_delayed_work(&sdata->deflink.dfs_cac_timer_work); 3230 3231 if (sdata->wdev.cac_started) { 3232 ieee80211_link_release_channel(&sdata->deflink); 3233 sdata->wdev.cac_started = false; 3234 } 3235 } 3236 mutex_unlock(&local->mtx); 3237 } 3238 3239 static struct cfg80211_beacon_data * 3240 cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon) 3241 { 3242 struct cfg80211_beacon_data *new_beacon; 3243 u8 *pos; 3244 int len; 3245 3246 len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len + 3247 beacon->proberesp_ies_len + beacon->assocresp_ies_len + 3248 beacon->probe_resp_len + beacon->lci_len + beacon->civicloc_len + 3249 ieee80211_get_mbssid_beacon_len(beacon->mbssid_ies); 3250 3251 new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL); 3252 if (!new_beacon) 3253 return NULL; 3254 3255 if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) { 3256 new_beacon->mbssid_ies = 3257 kzalloc(struct_size(new_beacon->mbssid_ies, 3258 elem, beacon->mbssid_ies->cnt), 3259 GFP_KERNEL); 3260 if (!new_beacon->mbssid_ies) { 3261 kfree(new_beacon); 3262 return NULL; 3263 } 3264 } 3265 3266 pos = (u8 *)(new_beacon + 1); 3267 if (beacon->head_len) { 3268 new_beacon->head_len = beacon->head_len; 3269 new_beacon->head = pos; 3270 memcpy(pos, beacon->head, beacon->head_len); 3271 pos += beacon->head_len; 3272 } 3273 if (beacon->tail_len) { 3274 new_beacon->tail_len = beacon->tail_len; 3275 new_beacon->tail = pos; 3276 memcpy(pos, beacon->tail, beacon->tail_len); 3277 pos += beacon->tail_len; 3278 } 3279 if (beacon->beacon_ies_len) { 3280 new_beacon->beacon_ies_len = beacon->beacon_ies_len; 3281 new_beacon->beacon_ies = pos; 3282 memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len); 3283 pos += beacon->beacon_ies_len; 3284 } 3285 if (beacon->proberesp_ies_len) { 3286 new_beacon->proberesp_ies_len = beacon->proberesp_ies_len; 3287 new_beacon->proberesp_ies = pos; 3288 memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len); 3289 pos += beacon->proberesp_ies_len; 3290 } 3291 if (beacon->assocresp_ies_len) { 3292 new_beacon->assocresp_ies_len = beacon->assocresp_ies_len; 3293 new_beacon->assocresp_ies = pos; 3294 memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len); 3295 pos += beacon->assocresp_ies_len; 3296 } 3297 if (beacon->probe_resp_len) { 3298 new_beacon->probe_resp_len = beacon->probe_resp_len; 3299 new_beacon->probe_resp = pos; 3300 memcpy(pos, beacon->probe_resp, beacon->probe_resp_len); 3301 pos += beacon->probe_resp_len; 3302 } 3303 if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) 3304 pos += ieee80211_copy_mbssid_beacon(pos, 3305 new_beacon->mbssid_ies, 3306 beacon->mbssid_ies); 3307 3308 /* might copy -1, meaning no changes requested */ 3309 new_beacon->ftm_responder = beacon->ftm_responder; 3310 if (beacon->lci) { 3311 new_beacon->lci_len = beacon->lci_len; 3312 new_beacon->lci = pos; 3313 memcpy(pos, beacon->lci, beacon->lci_len); 3314 pos += beacon->lci_len; 3315 } 3316 if (beacon->civicloc) { 3317 new_beacon->civicloc_len = beacon->civicloc_len; 3318 new_beacon->civicloc = pos; 3319 memcpy(pos, beacon->civicloc, beacon->civicloc_len); 3320 pos += beacon->civicloc_len; 3321 } 3322 3323 return new_beacon; 3324 } 3325 3326 void ieee80211_csa_finish(struct ieee80211_vif *vif) 3327 { 3328 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); 3329 struct ieee80211_local *local = sdata->local; 3330 3331 rcu_read_lock(); 3332 3333 if (vif->mbssid_tx_vif == vif) { 3334 /* Trigger ieee80211_csa_finish() on the non-transmitting 3335 * interfaces when channel switch is received on 3336 * transmitting interface 3337 */ 3338 struct ieee80211_sub_if_data *iter; 3339 3340 list_for_each_entry_rcu(iter, &local->interfaces, list) { 3341 if (!ieee80211_sdata_running(iter)) 3342 continue; 3343 3344 if (iter == sdata || iter->vif.mbssid_tx_vif != vif) 3345 continue; 3346 3347 ieee80211_queue_work(&iter->local->hw, 3348 &iter->deflink.csa_finalize_work); 3349 } 3350 } 3351 ieee80211_queue_work(&local->hw, &sdata->deflink.csa_finalize_work); 3352 3353 rcu_read_unlock(); 3354 } 3355 EXPORT_SYMBOL(ieee80211_csa_finish); 3356 3357 void ieee80211_channel_switch_disconnect(struct ieee80211_vif *vif, bool block_tx) 3358 { 3359 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); 3360 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 3361 struct ieee80211_local *local = sdata->local; 3362 3363 sdata->deflink.csa_block_tx = block_tx; 3364 sdata_info(sdata, "channel switch failed, disconnecting\n"); 3365 ieee80211_queue_work(&local->hw, &ifmgd->csa_connection_drop_work); 3366 } 3367 EXPORT_SYMBOL(ieee80211_channel_switch_disconnect); 3368 3369 static int ieee80211_set_after_csa_beacon(struct ieee80211_sub_if_data *sdata, 3370 u32 *changed) 3371 { 3372 int err; 3373 3374 switch (sdata->vif.type) { 3375 case NL80211_IFTYPE_AP: 3376 if (!sdata->deflink.u.ap.next_beacon) 3377 return -EINVAL; 3378 3379 err = ieee80211_assign_beacon(sdata, &sdata->deflink, 3380 sdata->deflink.u.ap.next_beacon, 3381 NULL, NULL); 3382 ieee80211_free_next_beacon(&sdata->deflink); 3383 3384 if (err < 0) 3385 return err; 3386 *changed |= err; 3387 break; 3388 case NL80211_IFTYPE_ADHOC: 3389 err = ieee80211_ibss_finish_csa(sdata); 3390 if (err < 0) 3391 return err; 3392 *changed |= err; 3393 break; 3394 #ifdef CONFIG_MAC80211_MESH 3395 case NL80211_IFTYPE_MESH_POINT: 3396 err = ieee80211_mesh_finish_csa(sdata); 3397 if (err < 0) 3398 return err; 3399 *changed |= err; 3400 break; 3401 #endif 3402 default: 3403 WARN_ON(1); 3404 return -EINVAL; 3405 } 3406 3407 return 0; 3408 } 3409 3410 static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata) 3411 { 3412 struct ieee80211_local *local = sdata->local; 3413 u32 changed = 0; 3414 int err; 3415 3416 sdata_assert_lock(sdata); 3417 lockdep_assert_held(&local->mtx); 3418 lockdep_assert_held(&local->chanctx_mtx); 3419 3420 /* 3421 * using reservation isn't immediate as it may be deferred until later 3422 * with multi-vif. once reservation is complete it will re-schedule the 3423 * work with no reserved_chanctx so verify chandef to check if it 3424 * completed successfully 3425 */ 3426 3427 if (sdata->deflink.reserved_chanctx) { 3428 /* 3429 * with multi-vif csa driver may call ieee80211_csa_finish() 3430 * many times while waiting for other interfaces to use their 3431 * reservations 3432 */ 3433 if (sdata->deflink.reserved_ready) 3434 return 0; 3435 3436 return ieee80211_link_use_reserved_context(&sdata->deflink); 3437 } 3438 3439 if (!cfg80211_chandef_identical(&sdata->vif.bss_conf.chandef, 3440 &sdata->deflink.csa_chandef)) 3441 return -EINVAL; 3442 3443 sdata->vif.bss_conf.csa_active = false; 3444 3445 err = ieee80211_set_after_csa_beacon(sdata, &changed); 3446 if (err) 3447 return err; 3448 3449 ieee80211_link_info_change_notify(sdata, &sdata->deflink, changed); 3450 3451 if (sdata->deflink.csa_block_tx) { 3452 ieee80211_wake_vif_queues(local, sdata, 3453 IEEE80211_QUEUE_STOP_REASON_CSA); 3454 sdata->deflink.csa_block_tx = false; 3455 } 3456 3457 err = drv_post_channel_switch(sdata); 3458 if (err) 3459 return err; 3460 3461 cfg80211_ch_switch_notify(sdata->dev, &sdata->deflink.csa_chandef, 0); 3462 3463 return 0; 3464 } 3465 3466 static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata) 3467 { 3468 if (__ieee80211_csa_finalize(sdata)) { 3469 sdata_info(sdata, "failed to finalize CSA, disconnecting\n"); 3470 cfg80211_stop_iface(sdata->local->hw.wiphy, &sdata->wdev, 3471 GFP_KERNEL); 3472 } 3473 } 3474 3475 void ieee80211_csa_finalize_work(struct work_struct *work) 3476 { 3477 struct ieee80211_sub_if_data *sdata = 3478 container_of(work, struct ieee80211_sub_if_data, 3479 deflink.csa_finalize_work); 3480 struct ieee80211_local *local = sdata->local; 3481 3482 sdata_lock(sdata); 3483 mutex_lock(&local->mtx); 3484 mutex_lock(&local->chanctx_mtx); 3485 3486 /* AP might have been stopped while waiting for the lock. */ 3487 if (!sdata->vif.bss_conf.csa_active) 3488 goto unlock; 3489 3490 if (!ieee80211_sdata_running(sdata)) 3491 goto unlock; 3492 3493 ieee80211_csa_finalize(sdata); 3494 3495 unlock: 3496 mutex_unlock(&local->chanctx_mtx); 3497 mutex_unlock(&local->mtx); 3498 sdata_unlock(sdata); 3499 } 3500 3501 static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata, 3502 struct cfg80211_csa_settings *params, 3503 u32 *changed) 3504 { 3505 struct ieee80211_csa_settings csa = {}; 3506 int err; 3507 3508 switch (sdata->vif.type) { 3509 case NL80211_IFTYPE_AP: 3510 sdata->deflink.u.ap.next_beacon = 3511 cfg80211_beacon_dup(¶ms->beacon_after); 3512 if (!sdata->deflink.u.ap.next_beacon) 3513 return -ENOMEM; 3514 3515 /* 3516 * With a count of 0, we don't have to wait for any 3517 * TBTT before switching, so complete the CSA 3518 * immediately. In theory, with a count == 1 we 3519 * should delay the switch until just before the next 3520 * TBTT, but that would complicate things so we switch 3521 * immediately too. If we would delay the switch 3522 * until the next TBTT, we would have to set the probe 3523 * response here. 3524 * 3525 * TODO: A channel switch with count <= 1 without 3526 * sending a CSA action frame is kind of useless, 3527 * because the clients won't know we're changing 3528 * channels. The action frame must be implemented 3529 * either here or in the userspace. 3530 */ 3531 if (params->count <= 1) 3532 break; 3533 3534 if ((params->n_counter_offsets_beacon > 3535 IEEE80211_MAX_CNTDWN_COUNTERS_NUM) || 3536 (params->n_counter_offsets_presp > 3537 IEEE80211_MAX_CNTDWN_COUNTERS_NUM)) { 3538 ieee80211_free_next_beacon(&sdata->deflink); 3539 return -EINVAL; 3540 } 3541 3542 csa.counter_offsets_beacon = params->counter_offsets_beacon; 3543 csa.counter_offsets_presp = params->counter_offsets_presp; 3544 csa.n_counter_offsets_beacon = params->n_counter_offsets_beacon; 3545 csa.n_counter_offsets_presp = params->n_counter_offsets_presp; 3546 csa.count = params->count; 3547 3548 err = ieee80211_assign_beacon(sdata, &sdata->deflink, 3549 ¶ms->beacon_csa, &csa, 3550 NULL); 3551 if (err < 0) { 3552 ieee80211_free_next_beacon(&sdata->deflink); 3553 return err; 3554 } 3555 *changed |= err; 3556 3557 break; 3558 case NL80211_IFTYPE_ADHOC: 3559 if (!sdata->vif.cfg.ibss_joined) 3560 return -EINVAL; 3561 3562 if (params->chandef.width != sdata->u.ibss.chandef.width) 3563 return -EINVAL; 3564 3565 switch (params->chandef.width) { 3566 case NL80211_CHAN_WIDTH_40: 3567 if (cfg80211_get_chandef_type(¶ms->chandef) != 3568 cfg80211_get_chandef_type(&sdata->u.ibss.chandef)) 3569 return -EINVAL; 3570 break; 3571 case NL80211_CHAN_WIDTH_5: 3572 case NL80211_CHAN_WIDTH_10: 3573 case NL80211_CHAN_WIDTH_20_NOHT: 3574 case NL80211_CHAN_WIDTH_20: 3575 break; 3576 default: 3577 return -EINVAL; 3578 } 3579 3580 /* changes into another band are not supported */ 3581 if (sdata->u.ibss.chandef.chan->band != 3582 params->chandef.chan->band) 3583 return -EINVAL; 3584 3585 /* see comments in the NL80211_IFTYPE_AP block */ 3586 if (params->count > 1) { 3587 err = ieee80211_ibss_csa_beacon(sdata, params); 3588 if (err < 0) 3589 return err; 3590 *changed |= err; 3591 } 3592 3593 ieee80211_send_action_csa(sdata, params); 3594 3595 break; 3596 #ifdef CONFIG_MAC80211_MESH 3597 case NL80211_IFTYPE_MESH_POINT: { 3598 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 3599 3600 if (params->chandef.width != sdata->vif.bss_conf.chandef.width) 3601 return -EINVAL; 3602 3603 /* changes into another band are not supported */ 3604 if (sdata->vif.bss_conf.chandef.chan->band != 3605 params->chandef.chan->band) 3606 return -EINVAL; 3607 3608 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_NONE) { 3609 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_INIT; 3610 if (!ifmsh->pre_value) 3611 ifmsh->pre_value = 1; 3612 else 3613 ifmsh->pre_value++; 3614 } 3615 3616 /* see comments in the NL80211_IFTYPE_AP block */ 3617 if (params->count > 1) { 3618 err = ieee80211_mesh_csa_beacon(sdata, params); 3619 if (err < 0) { 3620 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE; 3621 return err; 3622 } 3623 *changed |= err; 3624 } 3625 3626 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_INIT) 3627 ieee80211_send_action_csa(sdata, params); 3628 3629 break; 3630 } 3631 #endif 3632 default: 3633 return -EOPNOTSUPP; 3634 } 3635 3636 return 0; 3637 } 3638 3639 static void ieee80211_color_change_abort(struct ieee80211_sub_if_data *sdata) 3640 { 3641 sdata->vif.bss_conf.color_change_active = false; 3642 3643 ieee80211_free_next_beacon(&sdata->deflink); 3644 3645 cfg80211_color_change_aborted_notify(sdata->dev); 3646 } 3647 3648 static int 3649 __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, 3650 struct cfg80211_csa_settings *params) 3651 { 3652 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 3653 struct ieee80211_local *local = sdata->local; 3654 struct ieee80211_channel_switch ch_switch; 3655 struct ieee80211_chanctx_conf *conf; 3656 struct ieee80211_chanctx *chanctx; 3657 u32 changed = 0; 3658 int err; 3659 3660 sdata_assert_lock(sdata); 3661 lockdep_assert_held(&local->mtx); 3662 3663 if (!list_empty(&local->roc_list) || local->scanning) 3664 return -EBUSY; 3665 3666 if (sdata->wdev.cac_started) 3667 return -EBUSY; 3668 3669 if (cfg80211_chandef_identical(¶ms->chandef, 3670 &sdata->vif.bss_conf.chandef)) 3671 return -EINVAL; 3672 3673 /* don't allow another channel switch if one is already active. */ 3674 if (sdata->vif.bss_conf.csa_active) 3675 return -EBUSY; 3676 3677 mutex_lock(&local->chanctx_mtx); 3678 conf = rcu_dereference_protected(sdata->vif.bss_conf.chanctx_conf, 3679 lockdep_is_held(&local->chanctx_mtx)); 3680 if (!conf) { 3681 err = -EBUSY; 3682 goto out; 3683 } 3684 3685 if (params->chandef.chan->freq_offset) { 3686 /* this may work, but is untested */ 3687 err = -EOPNOTSUPP; 3688 goto out; 3689 } 3690 3691 chanctx = container_of(conf, struct ieee80211_chanctx, conf); 3692 3693 ch_switch.timestamp = 0; 3694 ch_switch.device_timestamp = 0; 3695 ch_switch.block_tx = params->block_tx; 3696 ch_switch.chandef = params->chandef; 3697 ch_switch.count = params->count; 3698 3699 err = drv_pre_channel_switch(sdata, &ch_switch); 3700 if (err) 3701 goto out; 3702 3703 err = ieee80211_link_reserve_chanctx(&sdata->deflink, ¶ms->chandef, 3704 chanctx->mode, 3705 params->radar_required); 3706 if (err) 3707 goto out; 3708 3709 /* if reservation is invalid then this will fail */ 3710 err = ieee80211_check_combinations(sdata, NULL, chanctx->mode, 0); 3711 if (err) { 3712 ieee80211_link_unreserve_chanctx(&sdata->deflink); 3713 goto out; 3714 } 3715 3716 /* if there is a color change in progress, abort it */ 3717 if (sdata->vif.bss_conf.color_change_active) 3718 ieee80211_color_change_abort(sdata); 3719 3720 err = ieee80211_set_csa_beacon(sdata, params, &changed); 3721 if (err) { 3722 ieee80211_link_unreserve_chanctx(&sdata->deflink); 3723 goto out; 3724 } 3725 3726 sdata->deflink.csa_chandef = params->chandef; 3727 sdata->deflink.csa_block_tx = params->block_tx; 3728 sdata->vif.bss_conf.csa_active = true; 3729 3730 if (sdata->deflink.csa_block_tx) 3731 ieee80211_stop_vif_queues(local, sdata, 3732 IEEE80211_QUEUE_STOP_REASON_CSA); 3733 3734 cfg80211_ch_switch_started_notify(sdata->dev, 3735 &sdata->deflink.csa_chandef, 3736 params->count, params->block_tx); 3737 3738 if (changed) { 3739 ieee80211_link_info_change_notify(sdata, &sdata->deflink, 3740 changed); 3741 drv_channel_switch_beacon(sdata, ¶ms->chandef); 3742 } else { 3743 /* if the beacon didn't change, we can finalize immediately */ 3744 ieee80211_csa_finalize(sdata); 3745 } 3746 3747 out: 3748 mutex_unlock(&local->chanctx_mtx); 3749 return err; 3750 } 3751 3752 int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, 3753 struct cfg80211_csa_settings *params) 3754 { 3755 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 3756 struct ieee80211_local *local = sdata->local; 3757 int err; 3758 3759 mutex_lock(&local->mtx); 3760 err = __ieee80211_channel_switch(wiphy, dev, params); 3761 mutex_unlock(&local->mtx); 3762 3763 return err; 3764 } 3765 3766 u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local) 3767 { 3768 lockdep_assert_held(&local->mtx); 3769 3770 local->roc_cookie_counter++; 3771 3772 /* wow, you wrapped 64 bits ... more likely a bug */ 3773 if (WARN_ON(local->roc_cookie_counter == 0)) 3774 local->roc_cookie_counter++; 3775 3776 return local->roc_cookie_counter; 3777 } 3778 3779 int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff *skb, 3780 u64 *cookie, gfp_t gfp) 3781 { 3782 unsigned long spin_flags; 3783 struct sk_buff *ack_skb; 3784 int id; 3785 3786 ack_skb = skb_copy(skb, gfp); 3787 if (!ack_skb) 3788 return -ENOMEM; 3789 3790 spin_lock_irqsave(&local->ack_status_lock, spin_flags); 3791 id = idr_alloc(&local->ack_status_frames, ack_skb, 3792 1, 0x2000, GFP_ATOMIC); 3793 spin_unlock_irqrestore(&local->ack_status_lock, spin_flags); 3794 3795 if (id < 0) { 3796 kfree_skb(ack_skb); 3797 return -ENOMEM; 3798 } 3799 3800 IEEE80211_SKB_CB(skb)->ack_frame_id = id; 3801 3802 *cookie = ieee80211_mgmt_tx_cookie(local); 3803 IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie; 3804 3805 return 0; 3806 } 3807 3808 static void 3809 ieee80211_update_mgmt_frame_registrations(struct wiphy *wiphy, 3810 struct wireless_dev *wdev, 3811 struct mgmt_frame_regs *upd) 3812 { 3813 struct ieee80211_local *local = wiphy_priv(wiphy); 3814 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 3815 u32 preq_mask = BIT(IEEE80211_STYPE_PROBE_REQ >> 4); 3816 u32 action_mask = BIT(IEEE80211_STYPE_ACTION >> 4); 3817 bool global_change, intf_change; 3818 3819 global_change = 3820 (local->probe_req_reg != !!(upd->global_stypes & preq_mask)) || 3821 (local->rx_mcast_action_reg != 3822 !!(upd->global_mcast_stypes & action_mask)); 3823 local->probe_req_reg = upd->global_stypes & preq_mask; 3824 local->rx_mcast_action_reg = upd->global_mcast_stypes & action_mask; 3825 3826 intf_change = (sdata->vif.probe_req_reg != 3827 !!(upd->interface_stypes & preq_mask)) || 3828 (sdata->vif.rx_mcast_action_reg != 3829 !!(upd->interface_mcast_stypes & action_mask)); 3830 sdata->vif.probe_req_reg = upd->interface_stypes & preq_mask; 3831 sdata->vif.rx_mcast_action_reg = 3832 upd->interface_mcast_stypes & action_mask; 3833 3834 if (!local->open_count) 3835 return; 3836 3837 if (intf_change && ieee80211_sdata_running(sdata)) 3838 drv_config_iface_filter(local, sdata, 3839 sdata->vif.probe_req_reg ? 3840 FIF_PROBE_REQ : 0, 3841 FIF_PROBE_REQ); 3842 3843 if (global_change) 3844 ieee80211_configure_filter(local); 3845 } 3846 3847 static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant) 3848 { 3849 struct ieee80211_local *local = wiphy_priv(wiphy); 3850 3851 if (local->started) 3852 return -EOPNOTSUPP; 3853 3854 return drv_set_antenna(local, tx_ant, rx_ant); 3855 } 3856 3857 static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant) 3858 { 3859 struct ieee80211_local *local = wiphy_priv(wiphy); 3860 3861 return drv_get_antenna(local, tx_ant, rx_ant); 3862 } 3863 3864 static int ieee80211_set_rekey_data(struct wiphy *wiphy, 3865 struct net_device *dev, 3866 struct cfg80211_gtk_rekey_data *data) 3867 { 3868 struct ieee80211_local *local = wiphy_priv(wiphy); 3869 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 3870 3871 if (!local->ops->set_rekey_data) 3872 return -EOPNOTSUPP; 3873 3874 drv_set_rekey_data(local, sdata, data); 3875 3876 return 0; 3877 } 3878 3879 static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev, 3880 const u8 *peer, u64 *cookie) 3881 { 3882 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 3883 struct ieee80211_local *local = sdata->local; 3884 struct ieee80211_qos_hdr *nullfunc; 3885 struct sk_buff *skb; 3886 int size = sizeof(*nullfunc); 3887 __le16 fc; 3888 bool qos; 3889 struct ieee80211_tx_info *info; 3890 struct sta_info *sta; 3891 struct ieee80211_chanctx_conf *chanctx_conf; 3892 enum nl80211_band band; 3893 int ret; 3894 3895 /* the lock is needed to assign the cookie later */ 3896 mutex_lock(&local->mtx); 3897 3898 rcu_read_lock(); 3899 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); 3900 if (WARN_ON(!chanctx_conf)) { 3901 ret = -EINVAL; 3902 goto unlock; 3903 } 3904 band = chanctx_conf->def.chan->band; 3905 sta = sta_info_get_bss(sdata, peer); 3906 if (sta) { 3907 qos = sta->sta.wme; 3908 } else { 3909 ret = -ENOLINK; 3910 goto unlock; 3911 } 3912 3913 if (qos) { 3914 fc = cpu_to_le16(IEEE80211_FTYPE_DATA | 3915 IEEE80211_STYPE_QOS_NULLFUNC | 3916 IEEE80211_FCTL_FROMDS); 3917 } else { 3918 size -= 2; 3919 fc = cpu_to_le16(IEEE80211_FTYPE_DATA | 3920 IEEE80211_STYPE_NULLFUNC | 3921 IEEE80211_FCTL_FROMDS); 3922 } 3923 3924 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size); 3925 if (!skb) { 3926 ret = -ENOMEM; 3927 goto unlock; 3928 } 3929 3930 skb->dev = dev; 3931 3932 skb_reserve(skb, local->hw.extra_tx_headroom); 3933 3934 nullfunc = skb_put(skb, size); 3935 nullfunc->frame_control = fc; 3936 nullfunc->duration_id = 0; 3937 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN); 3938 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); 3939 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN); 3940 nullfunc->seq_ctrl = 0; 3941 3942 info = IEEE80211_SKB_CB(skb); 3943 3944 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS | 3945 IEEE80211_TX_INTFL_NL80211_FRAME_TX; 3946 info->band = band; 3947 3948 skb_set_queue_mapping(skb, IEEE80211_AC_VO); 3949 skb->priority = 7; 3950 if (qos) 3951 nullfunc->qos_ctrl = cpu_to_le16(7); 3952 3953 ret = ieee80211_attach_ack_skb(local, skb, cookie, GFP_ATOMIC); 3954 if (ret) { 3955 kfree_skb(skb); 3956 goto unlock; 3957 } 3958 3959 local_bh_disable(); 3960 ieee80211_xmit(sdata, sta, skb); 3961 local_bh_enable(); 3962 3963 ret = 0; 3964 unlock: 3965 rcu_read_unlock(); 3966 mutex_unlock(&local->mtx); 3967 3968 return ret; 3969 } 3970 3971 static int ieee80211_cfg_get_channel(struct wiphy *wiphy, 3972 struct wireless_dev *wdev, 3973 unsigned int link_id, 3974 struct cfg80211_chan_def *chandef) 3975 { 3976 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 3977 struct ieee80211_local *local = wiphy_priv(wiphy); 3978 struct ieee80211_chanctx_conf *chanctx_conf; 3979 struct ieee80211_link_data *link; 3980 int ret = -ENODATA; 3981 3982 rcu_read_lock(); 3983 link = rcu_dereference(sdata->link[link_id]); 3984 if (!link) { 3985 ret = -ENOLINK; 3986 goto out; 3987 } 3988 3989 chanctx_conf = rcu_dereference(link->conf->chanctx_conf); 3990 if (chanctx_conf) { 3991 *chandef = link->conf->chandef; 3992 ret = 0; 3993 } else if (local->open_count > 0 && 3994 local->open_count == local->monitors && 3995 sdata->vif.type == NL80211_IFTYPE_MONITOR) { 3996 if (local->use_chanctx) 3997 *chandef = local->monitor_chandef; 3998 else 3999 *chandef = local->_oper_chandef; 4000 ret = 0; 4001 } 4002 out: 4003 rcu_read_unlock(); 4004 4005 return ret; 4006 } 4007 4008 #ifdef CONFIG_PM 4009 static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled) 4010 { 4011 drv_set_wakeup(wiphy_priv(wiphy), enabled); 4012 } 4013 #endif 4014 4015 static int ieee80211_set_qos_map(struct wiphy *wiphy, 4016 struct net_device *dev, 4017 struct cfg80211_qos_map *qos_map) 4018 { 4019 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4020 struct mac80211_qos_map *new_qos_map, *old_qos_map; 4021 4022 if (qos_map) { 4023 new_qos_map = kzalloc(sizeof(*new_qos_map), GFP_KERNEL); 4024 if (!new_qos_map) 4025 return -ENOMEM; 4026 memcpy(&new_qos_map->qos_map, qos_map, sizeof(*qos_map)); 4027 } else { 4028 /* A NULL qos_map was passed to disable QoS mapping */ 4029 new_qos_map = NULL; 4030 } 4031 4032 old_qos_map = sdata_dereference(sdata->qos_map, sdata); 4033 rcu_assign_pointer(sdata->qos_map, new_qos_map); 4034 if (old_qos_map) 4035 kfree_rcu(old_qos_map, rcu_head); 4036 4037 return 0; 4038 } 4039 4040 static int ieee80211_set_ap_chanwidth(struct wiphy *wiphy, 4041 struct net_device *dev, 4042 unsigned int link_id, 4043 struct cfg80211_chan_def *chandef) 4044 { 4045 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4046 struct ieee80211_link_data *link; 4047 int ret; 4048 u32 changed = 0; 4049 4050 link = sdata_dereference(sdata->link[link_id], sdata); 4051 4052 ret = ieee80211_link_change_bandwidth(link, chandef, &changed); 4053 if (ret == 0) 4054 ieee80211_link_info_change_notify(sdata, link, changed); 4055 4056 return ret; 4057 } 4058 4059 static int ieee80211_add_tx_ts(struct wiphy *wiphy, struct net_device *dev, 4060 u8 tsid, const u8 *peer, u8 up, 4061 u16 admitted_time) 4062 { 4063 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4064 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 4065 int ac = ieee802_1d_to_ac[up]; 4066 4067 if (sdata->vif.type != NL80211_IFTYPE_STATION) 4068 return -EOPNOTSUPP; 4069 4070 if (!(sdata->wmm_acm & BIT(up))) 4071 return -EINVAL; 4072 4073 if (ifmgd->tx_tspec[ac].admitted_time) 4074 return -EBUSY; 4075 4076 if (admitted_time) { 4077 ifmgd->tx_tspec[ac].admitted_time = 32 * admitted_time; 4078 ifmgd->tx_tspec[ac].tsid = tsid; 4079 ifmgd->tx_tspec[ac].up = up; 4080 } 4081 4082 return 0; 4083 } 4084 4085 static int ieee80211_del_tx_ts(struct wiphy *wiphy, struct net_device *dev, 4086 u8 tsid, const u8 *peer) 4087 { 4088 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4089 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 4090 struct ieee80211_local *local = wiphy_priv(wiphy); 4091 int ac; 4092 4093 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { 4094 struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac]; 4095 4096 /* skip unused entries */ 4097 if (!tx_tspec->admitted_time) 4098 continue; 4099 4100 if (tx_tspec->tsid != tsid) 4101 continue; 4102 4103 /* due to this new packets will be reassigned to non-ACM ACs */ 4104 tx_tspec->up = -1; 4105 4106 /* Make sure that all packets have been sent to avoid to 4107 * restore the QoS params on packets that are still on the 4108 * queues. 4109 */ 4110 synchronize_net(); 4111 ieee80211_flush_queues(local, sdata, false); 4112 4113 /* restore the normal QoS parameters 4114 * (unconditionally to avoid races) 4115 */ 4116 tx_tspec->action = TX_TSPEC_ACTION_STOP_DOWNGRADE; 4117 tx_tspec->downgraded = false; 4118 ieee80211_sta_handle_tspec_ac_params(sdata); 4119 4120 /* finally clear all the data */ 4121 memset(tx_tspec, 0, sizeof(*tx_tspec)); 4122 4123 return 0; 4124 } 4125 4126 return -ENOENT; 4127 } 4128 4129 void ieee80211_nan_func_terminated(struct ieee80211_vif *vif, 4130 u8 inst_id, 4131 enum nl80211_nan_func_term_reason reason, 4132 gfp_t gfp) 4133 { 4134 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); 4135 struct cfg80211_nan_func *func; 4136 u64 cookie; 4137 4138 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN)) 4139 return; 4140 4141 spin_lock_bh(&sdata->u.nan.func_lock); 4142 4143 func = idr_find(&sdata->u.nan.function_inst_ids, inst_id); 4144 if (WARN_ON(!func)) { 4145 spin_unlock_bh(&sdata->u.nan.func_lock); 4146 return; 4147 } 4148 4149 cookie = func->cookie; 4150 idr_remove(&sdata->u.nan.function_inst_ids, inst_id); 4151 4152 spin_unlock_bh(&sdata->u.nan.func_lock); 4153 4154 cfg80211_free_nan_func(func); 4155 4156 cfg80211_nan_func_terminated(ieee80211_vif_to_wdev(vif), inst_id, 4157 reason, cookie, gfp); 4158 } 4159 EXPORT_SYMBOL(ieee80211_nan_func_terminated); 4160 4161 void ieee80211_nan_func_match(struct ieee80211_vif *vif, 4162 struct cfg80211_nan_match_params *match, 4163 gfp_t gfp) 4164 { 4165 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); 4166 struct cfg80211_nan_func *func; 4167 4168 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN)) 4169 return; 4170 4171 spin_lock_bh(&sdata->u.nan.func_lock); 4172 4173 func = idr_find(&sdata->u.nan.function_inst_ids, match->inst_id); 4174 if (WARN_ON(!func)) { 4175 spin_unlock_bh(&sdata->u.nan.func_lock); 4176 return; 4177 } 4178 match->cookie = func->cookie; 4179 4180 spin_unlock_bh(&sdata->u.nan.func_lock); 4181 4182 cfg80211_nan_match(ieee80211_vif_to_wdev(vif), match, gfp); 4183 } 4184 EXPORT_SYMBOL(ieee80211_nan_func_match); 4185 4186 static int ieee80211_set_multicast_to_unicast(struct wiphy *wiphy, 4187 struct net_device *dev, 4188 const bool enabled) 4189 { 4190 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4191 4192 sdata->u.ap.multicast_to_unicast = enabled; 4193 4194 return 0; 4195 } 4196 4197 void ieee80211_fill_txq_stats(struct cfg80211_txq_stats *txqstats, 4198 struct txq_info *txqi) 4199 { 4200 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_BYTES))) { 4201 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_BYTES); 4202 txqstats->backlog_bytes = txqi->tin.backlog_bytes; 4203 } 4204 4205 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS))) { 4206 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS); 4207 txqstats->backlog_packets = txqi->tin.backlog_packets; 4208 } 4209 4210 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_FLOWS))) { 4211 txqstats->filled |= BIT(NL80211_TXQ_STATS_FLOWS); 4212 txqstats->flows = txqi->tin.flows; 4213 } 4214 4215 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_DROPS))) { 4216 txqstats->filled |= BIT(NL80211_TXQ_STATS_DROPS); 4217 txqstats->drops = txqi->cstats.drop_count; 4218 } 4219 4220 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_ECN_MARKS))) { 4221 txqstats->filled |= BIT(NL80211_TXQ_STATS_ECN_MARKS); 4222 txqstats->ecn_marks = txqi->cstats.ecn_mark; 4223 } 4224 4225 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_OVERLIMIT))) { 4226 txqstats->filled |= BIT(NL80211_TXQ_STATS_OVERLIMIT); 4227 txqstats->overlimit = txqi->tin.overlimit; 4228 } 4229 4230 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_COLLISIONS))) { 4231 txqstats->filled |= BIT(NL80211_TXQ_STATS_COLLISIONS); 4232 txqstats->collisions = txqi->tin.collisions; 4233 } 4234 4235 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_BYTES))) { 4236 txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_BYTES); 4237 txqstats->tx_bytes = txqi->tin.tx_bytes; 4238 } 4239 4240 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_PACKETS))) { 4241 txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_PACKETS); 4242 txqstats->tx_packets = txqi->tin.tx_packets; 4243 } 4244 } 4245 4246 static int ieee80211_get_txq_stats(struct wiphy *wiphy, 4247 struct wireless_dev *wdev, 4248 struct cfg80211_txq_stats *txqstats) 4249 { 4250 struct ieee80211_local *local = wiphy_priv(wiphy); 4251 struct ieee80211_sub_if_data *sdata; 4252 int ret = 0; 4253 4254 if (!local->ops->wake_tx_queue) 4255 return 1; 4256 4257 spin_lock_bh(&local->fq.lock); 4258 rcu_read_lock(); 4259 4260 if (wdev) { 4261 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 4262 if (!sdata->vif.txq) { 4263 ret = 1; 4264 goto out; 4265 } 4266 ieee80211_fill_txq_stats(txqstats, to_txq_info(sdata->vif.txq)); 4267 } else { 4268 /* phy stats */ 4269 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS) | 4270 BIT(NL80211_TXQ_STATS_BACKLOG_BYTES) | 4271 BIT(NL80211_TXQ_STATS_OVERLIMIT) | 4272 BIT(NL80211_TXQ_STATS_OVERMEMORY) | 4273 BIT(NL80211_TXQ_STATS_COLLISIONS) | 4274 BIT(NL80211_TXQ_STATS_MAX_FLOWS); 4275 txqstats->backlog_packets = local->fq.backlog; 4276 txqstats->backlog_bytes = local->fq.memory_usage; 4277 txqstats->overlimit = local->fq.overlimit; 4278 txqstats->overmemory = local->fq.overmemory; 4279 txqstats->collisions = local->fq.collisions; 4280 txqstats->max_flows = local->fq.flows_cnt; 4281 } 4282 4283 out: 4284 rcu_read_unlock(); 4285 spin_unlock_bh(&local->fq.lock); 4286 4287 return ret; 4288 } 4289 4290 static int 4291 ieee80211_get_ftm_responder_stats(struct wiphy *wiphy, 4292 struct net_device *dev, 4293 struct cfg80211_ftm_responder_stats *ftm_stats) 4294 { 4295 struct ieee80211_local *local = wiphy_priv(wiphy); 4296 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4297 4298 return drv_get_ftm_responder_stats(local, sdata, ftm_stats); 4299 } 4300 4301 static int 4302 ieee80211_start_pmsr(struct wiphy *wiphy, struct wireless_dev *dev, 4303 struct cfg80211_pmsr_request *request) 4304 { 4305 struct ieee80211_local *local = wiphy_priv(wiphy); 4306 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev); 4307 4308 return drv_start_pmsr(local, sdata, request); 4309 } 4310 4311 static void 4312 ieee80211_abort_pmsr(struct wiphy *wiphy, struct wireless_dev *dev, 4313 struct cfg80211_pmsr_request *request) 4314 { 4315 struct ieee80211_local *local = wiphy_priv(wiphy); 4316 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev); 4317 4318 return drv_abort_pmsr(local, sdata, request); 4319 } 4320 4321 static int ieee80211_set_tid_config(struct wiphy *wiphy, 4322 struct net_device *dev, 4323 struct cfg80211_tid_config *tid_conf) 4324 { 4325 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4326 struct sta_info *sta; 4327 int ret; 4328 4329 if (!sdata->local->ops->set_tid_config) 4330 return -EOPNOTSUPP; 4331 4332 if (!tid_conf->peer) 4333 return drv_set_tid_config(sdata->local, sdata, NULL, tid_conf); 4334 4335 mutex_lock(&sdata->local->sta_mtx); 4336 sta = sta_info_get_bss(sdata, tid_conf->peer); 4337 if (!sta) { 4338 mutex_unlock(&sdata->local->sta_mtx); 4339 return -ENOENT; 4340 } 4341 4342 ret = drv_set_tid_config(sdata->local, sdata, &sta->sta, tid_conf); 4343 mutex_unlock(&sdata->local->sta_mtx); 4344 4345 return ret; 4346 } 4347 4348 static int ieee80211_reset_tid_config(struct wiphy *wiphy, 4349 struct net_device *dev, 4350 const u8 *peer, u8 tids) 4351 { 4352 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4353 struct sta_info *sta; 4354 int ret; 4355 4356 if (!sdata->local->ops->reset_tid_config) 4357 return -EOPNOTSUPP; 4358 4359 if (!peer) 4360 return drv_reset_tid_config(sdata->local, sdata, NULL, tids); 4361 4362 mutex_lock(&sdata->local->sta_mtx); 4363 sta = sta_info_get_bss(sdata, peer); 4364 if (!sta) { 4365 mutex_unlock(&sdata->local->sta_mtx); 4366 return -ENOENT; 4367 } 4368 4369 ret = drv_reset_tid_config(sdata->local, sdata, &sta->sta, tids); 4370 mutex_unlock(&sdata->local->sta_mtx); 4371 4372 return ret; 4373 } 4374 4375 static int ieee80211_set_sar_specs(struct wiphy *wiphy, 4376 struct cfg80211_sar_specs *sar) 4377 { 4378 struct ieee80211_local *local = wiphy_priv(wiphy); 4379 4380 if (!local->ops->set_sar_specs) 4381 return -EOPNOTSUPP; 4382 4383 return local->ops->set_sar_specs(&local->hw, sar); 4384 } 4385 4386 static int 4387 ieee80211_set_after_color_change_beacon(struct ieee80211_sub_if_data *sdata, 4388 u32 *changed) 4389 { 4390 switch (sdata->vif.type) { 4391 case NL80211_IFTYPE_AP: { 4392 int ret; 4393 4394 if (!sdata->deflink.u.ap.next_beacon) 4395 return -EINVAL; 4396 4397 ret = ieee80211_assign_beacon(sdata, &sdata->deflink, 4398 sdata->deflink.u.ap.next_beacon, 4399 NULL, NULL); 4400 ieee80211_free_next_beacon(&sdata->deflink); 4401 4402 if (ret < 0) 4403 return ret; 4404 4405 *changed |= ret; 4406 break; 4407 } 4408 default: 4409 WARN_ON_ONCE(1); 4410 return -EINVAL; 4411 } 4412 4413 return 0; 4414 } 4415 4416 static int 4417 ieee80211_set_color_change_beacon(struct ieee80211_sub_if_data *sdata, 4418 struct cfg80211_color_change_settings *params, 4419 u32 *changed) 4420 { 4421 struct ieee80211_color_change_settings color_change = {}; 4422 int err; 4423 4424 switch (sdata->vif.type) { 4425 case NL80211_IFTYPE_AP: 4426 sdata->deflink.u.ap.next_beacon = 4427 cfg80211_beacon_dup(¶ms->beacon_next); 4428 if (!sdata->deflink.u.ap.next_beacon) 4429 return -ENOMEM; 4430 4431 if (params->count <= 1) 4432 break; 4433 4434 color_change.counter_offset_beacon = 4435 params->counter_offset_beacon; 4436 color_change.counter_offset_presp = 4437 params->counter_offset_presp; 4438 color_change.count = params->count; 4439 4440 err = ieee80211_assign_beacon(sdata, &sdata->deflink, 4441 ¶ms->beacon_color_change, 4442 NULL, &color_change); 4443 if (err < 0) { 4444 ieee80211_free_next_beacon(&sdata->deflink); 4445 return err; 4446 } 4447 *changed |= err; 4448 break; 4449 default: 4450 return -EOPNOTSUPP; 4451 } 4452 4453 return 0; 4454 } 4455 4456 static void 4457 ieee80211_color_change_bss_config_notify(struct ieee80211_sub_if_data *sdata, 4458 u8 color, int enable, u32 changed) 4459 { 4460 sdata->vif.bss_conf.he_bss_color.color = color; 4461 sdata->vif.bss_conf.he_bss_color.enabled = enable; 4462 changed |= BSS_CHANGED_HE_BSS_COLOR; 4463 4464 ieee80211_link_info_change_notify(sdata, &sdata->deflink, changed); 4465 4466 if (!sdata->vif.bss_conf.nontransmitted && sdata->vif.mbssid_tx_vif) { 4467 struct ieee80211_sub_if_data *child; 4468 4469 mutex_lock(&sdata->local->iflist_mtx); 4470 list_for_each_entry(child, &sdata->local->interfaces, list) { 4471 if (child != sdata && child->vif.mbssid_tx_vif == &sdata->vif) { 4472 child->vif.bss_conf.he_bss_color.color = color; 4473 child->vif.bss_conf.he_bss_color.enabled = enable; 4474 ieee80211_link_info_change_notify(child, 4475 &child->deflink, 4476 BSS_CHANGED_HE_BSS_COLOR); 4477 } 4478 } 4479 mutex_unlock(&sdata->local->iflist_mtx); 4480 } 4481 } 4482 4483 static int ieee80211_color_change_finalize(struct ieee80211_sub_if_data *sdata) 4484 { 4485 struct ieee80211_local *local = sdata->local; 4486 u32 changed = 0; 4487 int err; 4488 4489 sdata_assert_lock(sdata); 4490 lockdep_assert_held(&local->mtx); 4491 4492 sdata->vif.bss_conf.color_change_active = false; 4493 4494 err = ieee80211_set_after_color_change_beacon(sdata, &changed); 4495 if (err) { 4496 cfg80211_color_change_aborted_notify(sdata->dev); 4497 return err; 4498 } 4499 4500 ieee80211_color_change_bss_config_notify(sdata, 4501 sdata->vif.bss_conf.color_change_color, 4502 1, changed); 4503 cfg80211_color_change_notify(sdata->dev); 4504 4505 return 0; 4506 } 4507 4508 void ieee80211_color_change_finalize_work(struct work_struct *work) 4509 { 4510 struct ieee80211_sub_if_data *sdata = 4511 container_of(work, struct ieee80211_sub_if_data, 4512 deflink.color_change_finalize_work); 4513 struct ieee80211_local *local = sdata->local; 4514 4515 sdata_lock(sdata); 4516 mutex_lock(&local->mtx); 4517 4518 /* AP might have been stopped while waiting for the lock. */ 4519 if (!sdata->vif.bss_conf.color_change_active) 4520 goto unlock; 4521 4522 if (!ieee80211_sdata_running(sdata)) 4523 goto unlock; 4524 4525 ieee80211_color_change_finalize(sdata); 4526 4527 unlock: 4528 mutex_unlock(&local->mtx); 4529 sdata_unlock(sdata); 4530 } 4531 4532 void ieee80211_color_change_finish(struct ieee80211_vif *vif) 4533 { 4534 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); 4535 4536 ieee80211_queue_work(&sdata->local->hw, 4537 &sdata->deflink.color_change_finalize_work); 4538 } 4539 EXPORT_SYMBOL_GPL(ieee80211_color_change_finish); 4540 4541 void 4542 ieeee80211_obss_color_collision_notify(struct ieee80211_vif *vif, 4543 u64 color_bitmap, gfp_t gfp) 4544 { 4545 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); 4546 4547 if (sdata->vif.bss_conf.color_change_active || sdata->vif.bss_conf.csa_active) 4548 return; 4549 4550 cfg80211_obss_color_collision_notify(sdata->dev, color_bitmap, gfp); 4551 } 4552 EXPORT_SYMBOL_GPL(ieeee80211_obss_color_collision_notify); 4553 4554 static int 4555 ieee80211_color_change(struct wiphy *wiphy, struct net_device *dev, 4556 struct cfg80211_color_change_settings *params) 4557 { 4558 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4559 struct ieee80211_local *local = sdata->local; 4560 u32 changed = 0; 4561 int err; 4562 4563 sdata_assert_lock(sdata); 4564 4565 if (sdata->vif.bss_conf.nontransmitted) 4566 return -EINVAL; 4567 4568 mutex_lock(&local->mtx); 4569 4570 /* don't allow another color change if one is already active or if csa 4571 * is active 4572 */ 4573 if (sdata->vif.bss_conf.color_change_active || sdata->vif.bss_conf.csa_active) { 4574 err = -EBUSY; 4575 goto out; 4576 } 4577 4578 err = ieee80211_set_color_change_beacon(sdata, params, &changed); 4579 if (err) 4580 goto out; 4581 4582 sdata->vif.bss_conf.color_change_active = true; 4583 sdata->vif.bss_conf.color_change_color = params->color; 4584 4585 cfg80211_color_change_started_notify(sdata->dev, params->count); 4586 4587 if (changed) 4588 ieee80211_color_change_bss_config_notify(sdata, 0, 0, changed); 4589 else 4590 /* if the beacon didn't change, we can finalize immediately */ 4591 ieee80211_color_change_finalize(sdata); 4592 4593 out: 4594 mutex_unlock(&local->mtx); 4595 4596 return err; 4597 } 4598 4599 static int 4600 ieee80211_set_radar_background(struct wiphy *wiphy, 4601 struct cfg80211_chan_def *chandef) 4602 { 4603 struct ieee80211_local *local = wiphy_priv(wiphy); 4604 4605 if (!local->ops->set_radar_background) 4606 return -EOPNOTSUPP; 4607 4608 return local->ops->set_radar_background(&local->hw, chandef); 4609 } 4610 4611 static int ieee80211_add_intf_link(struct wiphy *wiphy, 4612 struct wireless_dev *wdev, 4613 unsigned int link_id) 4614 { 4615 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 4616 4617 return ieee80211_vif_set_links(sdata, wdev->valid_links); 4618 } 4619 4620 static void ieee80211_del_intf_link(struct wiphy *wiphy, 4621 struct wireless_dev *wdev, 4622 unsigned int link_id) 4623 { 4624 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 4625 4626 ieee80211_vif_set_links(sdata, wdev->valid_links); 4627 } 4628 4629 static int sta_add_link_station(struct ieee80211_local *local, 4630 struct ieee80211_sub_if_data *sdata, 4631 struct link_station_parameters *params) 4632 { 4633 struct sta_info *sta; 4634 int ret; 4635 4636 sta = sta_info_get_bss(sdata, params->mld_mac); 4637 if (!sta) 4638 return -ENOENT; 4639 4640 if (!sta->sta.valid_links) 4641 return -EINVAL; 4642 4643 if (sta->sta.valid_links & BIT(params->link_id)) 4644 return -EALREADY; 4645 4646 ret = ieee80211_sta_allocate_link(sta, params->link_id); 4647 if (ret) 4648 return ret; 4649 4650 ret = sta_link_apply_parameters(local, sta, true, params); 4651 if (ret) { 4652 ieee80211_sta_free_link(sta, params->link_id); 4653 return ret; 4654 } 4655 4656 /* ieee80211_sta_activate_link frees the link upon failure */ 4657 return ieee80211_sta_activate_link(sta, params->link_id); 4658 } 4659 4660 static int 4661 ieee80211_add_link_station(struct wiphy *wiphy, struct net_device *dev, 4662 struct link_station_parameters *params) 4663 { 4664 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4665 struct ieee80211_local *local = wiphy_priv(wiphy); 4666 int ret; 4667 4668 mutex_lock(&sdata->local->sta_mtx); 4669 ret = sta_add_link_station(local, sdata, params); 4670 mutex_unlock(&sdata->local->sta_mtx); 4671 4672 return ret; 4673 } 4674 4675 static int sta_mod_link_station(struct ieee80211_local *local, 4676 struct ieee80211_sub_if_data *sdata, 4677 struct link_station_parameters *params) 4678 { 4679 struct sta_info *sta; 4680 4681 sta = sta_info_get_bss(sdata, params->mld_mac); 4682 if (!sta) 4683 return -ENOENT; 4684 4685 if (!(sta->sta.valid_links & BIT(params->link_id))) 4686 return -EINVAL; 4687 4688 return sta_link_apply_parameters(local, sta, false, params); 4689 } 4690 4691 static int 4692 ieee80211_mod_link_station(struct wiphy *wiphy, struct net_device *dev, 4693 struct link_station_parameters *params) 4694 { 4695 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4696 struct ieee80211_local *local = wiphy_priv(wiphy); 4697 int ret; 4698 4699 mutex_lock(&sdata->local->sta_mtx); 4700 ret = sta_mod_link_station(local, sdata, params); 4701 mutex_unlock(&sdata->local->sta_mtx); 4702 4703 return ret; 4704 } 4705 4706 static int sta_del_link_station(struct ieee80211_sub_if_data *sdata, 4707 struct link_station_del_parameters *params) 4708 { 4709 struct sta_info *sta; 4710 4711 sta = sta_info_get_bss(sdata, params->mld_mac); 4712 if (!sta) 4713 return -ENOENT; 4714 4715 if (!(sta->sta.valid_links & BIT(params->link_id))) 4716 return -EINVAL; 4717 4718 /* must not create a STA without links */ 4719 if (sta->sta.valid_links == BIT(params->link_id)) 4720 return -EINVAL; 4721 4722 ieee80211_sta_remove_link(sta, params->link_id); 4723 4724 return 0; 4725 } 4726 4727 static int 4728 ieee80211_del_link_station(struct wiphy *wiphy, struct net_device *dev, 4729 struct link_station_del_parameters *params) 4730 { 4731 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 4732 int ret; 4733 4734 mutex_lock(&sdata->local->sta_mtx); 4735 ret = sta_del_link_station(sdata, params); 4736 mutex_unlock(&sdata->local->sta_mtx); 4737 4738 return ret; 4739 } 4740 4741 const struct cfg80211_ops mac80211_config_ops = { 4742 .add_virtual_intf = ieee80211_add_iface, 4743 .del_virtual_intf = ieee80211_del_iface, 4744 .change_virtual_intf = ieee80211_change_iface, 4745 .start_p2p_device = ieee80211_start_p2p_device, 4746 .stop_p2p_device = ieee80211_stop_p2p_device, 4747 .add_key = ieee80211_add_key, 4748 .del_key = ieee80211_del_key, 4749 .get_key = ieee80211_get_key, 4750 .set_default_key = ieee80211_config_default_key, 4751 .set_default_mgmt_key = ieee80211_config_default_mgmt_key, 4752 .set_default_beacon_key = ieee80211_config_default_beacon_key, 4753 .start_ap = ieee80211_start_ap, 4754 .change_beacon = ieee80211_change_beacon, 4755 .stop_ap = ieee80211_stop_ap, 4756 .add_station = ieee80211_add_station, 4757 .del_station = ieee80211_del_station, 4758 .change_station = ieee80211_change_station, 4759 .get_station = ieee80211_get_station, 4760 .dump_station = ieee80211_dump_station, 4761 .dump_survey = ieee80211_dump_survey, 4762 #ifdef CONFIG_MAC80211_MESH 4763 .add_mpath = ieee80211_add_mpath, 4764 .del_mpath = ieee80211_del_mpath, 4765 .change_mpath = ieee80211_change_mpath, 4766 .get_mpath = ieee80211_get_mpath, 4767 .dump_mpath = ieee80211_dump_mpath, 4768 .get_mpp = ieee80211_get_mpp, 4769 .dump_mpp = ieee80211_dump_mpp, 4770 .update_mesh_config = ieee80211_update_mesh_config, 4771 .get_mesh_config = ieee80211_get_mesh_config, 4772 .join_mesh = ieee80211_join_mesh, 4773 .leave_mesh = ieee80211_leave_mesh, 4774 #endif 4775 .join_ocb = ieee80211_join_ocb, 4776 .leave_ocb = ieee80211_leave_ocb, 4777 .change_bss = ieee80211_change_bss, 4778 .set_txq_params = ieee80211_set_txq_params, 4779 .set_monitor_channel = ieee80211_set_monitor_channel, 4780 .suspend = ieee80211_suspend, 4781 .resume = ieee80211_resume, 4782 .scan = ieee80211_scan, 4783 .abort_scan = ieee80211_abort_scan, 4784 .sched_scan_start = ieee80211_sched_scan_start, 4785 .sched_scan_stop = ieee80211_sched_scan_stop, 4786 .auth = ieee80211_auth, 4787 .assoc = ieee80211_assoc, 4788 .deauth = ieee80211_deauth, 4789 .disassoc = ieee80211_disassoc, 4790 .join_ibss = ieee80211_join_ibss, 4791 .leave_ibss = ieee80211_leave_ibss, 4792 .set_mcast_rate = ieee80211_set_mcast_rate, 4793 .set_wiphy_params = ieee80211_set_wiphy_params, 4794 .set_tx_power = ieee80211_set_tx_power, 4795 .get_tx_power = ieee80211_get_tx_power, 4796 .rfkill_poll = ieee80211_rfkill_poll, 4797 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd) 4798 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump) 4799 .set_power_mgmt = ieee80211_set_power_mgmt, 4800 .set_bitrate_mask = ieee80211_set_bitrate_mask, 4801 .remain_on_channel = ieee80211_remain_on_channel, 4802 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel, 4803 .mgmt_tx = ieee80211_mgmt_tx, 4804 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait, 4805 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config, 4806 .set_cqm_rssi_range_config = ieee80211_set_cqm_rssi_range_config, 4807 .update_mgmt_frame_registrations = 4808 ieee80211_update_mgmt_frame_registrations, 4809 .set_antenna = ieee80211_set_antenna, 4810 .get_antenna = ieee80211_get_antenna, 4811 .set_rekey_data = ieee80211_set_rekey_data, 4812 .tdls_oper = ieee80211_tdls_oper, 4813 .tdls_mgmt = ieee80211_tdls_mgmt, 4814 .tdls_channel_switch = ieee80211_tdls_channel_switch, 4815 .tdls_cancel_channel_switch = ieee80211_tdls_cancel_channel_switch, 4816 .probe_client = ieee80211_probe_client, 4817 .set_noack_map = ieee80211_set_noack_map, 4818 #ifdef CONFIG_PM 4819 .set_wakeup = ieee80211_set_wakeup, 4820 #endif 4821 .get_channel = ieee80211_cfg_get_channel, 4822 .start_radar_detection = ieee80211_start_radar_detection, 4823 .end_cac = ieee80211_end_cac, 4824 .channel_switch = ieee80211_channel_switch, 4825 .set_qos_map = ieee80211_set_qos_map, 4826 .set_ap_chanwidth = ieee80211_set_ap_chanwidth, 4827 .add_tx_ts = ieee80211_add_tx_ts, 4828 .del_tx_ts = ieee80211_del_tx_ts, 4829 .start_nan = ieee80211_start_nan, 4830 .stop_nan = ieee80211_stop_nan, 4831 .nan_change_conf = ieee80211_nan_change_conf, 4832 .add_nan_func = ieee80211_add_nan_func, 4833 .del_nan_func = ieee80211_del_nan_func, 4834 .set_multicast_to_unicast = ieee80211_set_multicast_to_unicast, 4835 .tx_control_port = ieee80211_tx_control_port, 4836 .get_txq_stats = ieee80211_get_txq_stats, 4837 .get_ftm_responder_stats = ieee80211_get_ftm_responder_stats, 4838 .start_pmsr = ieee80211_start_pmsr, 4839 .abort_pmsr = ieee80211_abort_pmsr, 4840 .probe_mesh_link = ieee80211_probe_mesh_link, 4841 .set_tid_config = ieee80211_set_tid_config, 4842 .reset_tid_config = ieee80211_reset_tid_config, 4843 .set_sar_specs = ieee80211_set_sar_specs, 4844 .color_change = ieee80211_color_change, 4845 .set_radar_background = ieee80211_set_radar_background, 4846 .add_intf_link = ieee80211_add_intf_link, 4847 .del_intf_link = ieee80211_del_intf_link, 4848 .add_link_station = ieee80211_add_link_station, 4849 .mod_link_station = ieee80211_mod_link_station, 4850 .del_link_station = ieee80211_del_link_station, 4851 }; 4852