1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Portions of this file 4 * Copyright(c) 2016 Intel Deutschland GmbH 5 * Copyright (C) 2018 - 2019, 2021 - 2023 Intel Corporation 6 */ 7 8 #ifndef __MAC80211_DRIVER_OPS 9 #define __MAC80211_DRIVER_OPS 10 11 #include <net/mac80211.h> 12 #include "ieee80211_i.h" 13 #include "trace.h" 14 15 #define check_sdata_in_driver(sdata) ({ \ 16 WARN_ONCE(!sdata->local->reconfig_failure && \ 17 !(sdata->flags & IEEE80211_SDATA_IN_DRIVER), \ 18 "%s: Failed check-sdata-in-driver check, flags: 0x%x\n", \ 19 sdata->dev ? sdata->dev->name : sdata->name, sdata->flags); \ 20 !!(sdata->flags & IEEE80211_SDATA_IN_DRIVER); \ 21 }) 22 23 static inline struct ieee80211_sub_if_data * 24 get_bss_sdata(struct ieee80211_sub_if_data *sdata) 25 { 26 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 27 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, 28 u.ap); 29 30 return sdata; 31 } 32 33 static inline void drv_tx(struct ieee80211_local *local, 34 struct ieee80211_tx_control *control, 35 struct sk_buff *skb) 36 { 37 local->ops->tx(&local->hw, control, skb); 38 } 39 40 static inline void drv_sync_rx_queues(struct ieee80211_local *local, 41 struct sta_info *sta) 42 { 43 might_sleep(); 44 lockdep_assert_wiphy(local->hw.wiphy); 45 46 if (local->ops->sync_rx_queues) { 47 trace_drv_sync_rx_queues(local, sta->sdata, &sta->sta); 48 local->ops->sync_rx_queues(&local->hw); 49 trace_drv_return_void(local); 50 } 51 } 52 53 static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata, 54 u32 sset, u8 *data) 55 { 56 struct ieee80211_local *local = sdata->local; 57 if (local->ops->get_et_strings) { 58 trace_drv_get_et_strings(local, sset); 59 local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data); 60 trace_drv_return_void(local); 61 } 62 } 63 64 static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata, 65 struct ethtool_stats *stats, 66 u64 *data) 67 { 68 struct ieee80211_local *local = sdata->local; 69 if (local->ops->get_et_stats) { 70 trace_drv_get_et_stats(local); 71 local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data); 72 trace_drv_return_void(local); 73 } 74 } 75 76 static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata, 77 int sset) 78 { 79 struct ieee80211_local *local = sdata->local; 80 int rv = 0; 81 if (local->ops->get_et_sset_count) { 82 trace_drv_get_et_sset_count(local, sset); 83 rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif, 84 sset); 85 trace_drv_return_int(local, rv); 86 } 87 return rv; 88 } 89 90 int drv_start(struct ieee80211_local *local); 91 void drv_stop(struct ieee80211_local *local); 92 93 #ifdef CONFIG_PM 94 static inline int drv_suspend(struct ieee80211_local *local, 95 struct cfg80211_wowlan *wowlan) 96 { 97 int ret; 98 99 might_sleep(); 100 lockdep_assert_wiphy(local->hw.wiphy); 101 102 trace_drv_suspend(local); 103 ret = local->ops->suspend(&local->hw, wowlan); 104 trace_drv_return_int(local, ret); 105 return ret; 106 } 107 108 static inline int drv_resume(struct ieee80211_local *local) 109 { 110 int ret; 111 112 might_sleep(); 113 lockdep_assert_wiphy(local->hw.wiphy); 114 115 trace_drv_resume(local); 116 ret = local->ops->resume(&local->hw); 117 trace_drv_return_int(local, ret); 118 return ret; 119 } 120 121 static inline void drv_set_wakeup(struct ieee80211_local *local, 122 bool enabled) 123 { 124 might_sleep(); 125 lockdep_assert_wiphy(local->hw.wiphy); 126 127 if (!local->ops->set_wakeup) 128 return; 129 130 trace_drv_set_wakeup(local, enabled); 131 local->ops->set_wakeup(&local->hw, enabled); 132 trace_drv_return_void(local); 133 } 134 #endif 135 136 int drv_add_interface(struct ieee80211_local *local, 137 struct ieee80211_sub_if_data *sdata); 138 139 int drv_change_interface(struct ieee80211_local *local, 140 struct ieee80211_sub_if_data *sdata, 141 enum nl80211_iftype type, bool p2p); 142 143 void drv_remove_interface(struct ieee80211_local *local, 144 struct ieee80211_sub_if_data *sdata); 145 146 static inline int drv_config(struct ieee80211_local *local, u32 changed) 147 { 148 int ret; 149 150 might_sleep(); 151 lockdep_assert_wiphy(local->hw.wiphy); 152 153 trace_drv_config(local, changed); 154 ret = local->ops->config(&local->hw, changed); 155 trace_drv_return_int(local, ret); 156 return ret; 157 } 158 159 static inline void drv_vif_cfg_changed(struct ieee80211_local *local, 160 struct ieee80211_sub_if_data *sdata, 161 u64 changed) 162 { 163 might_sleep(); 164 lockdep_assert_wiphy(local->hw.wiphy); 165 166 if (!check_sdata_in_driver(sdata)) 167 return; 168 169 trace_drv_vif_cfg_changed(local, sdata, changed); 170 if (local->ops->vif_cfg_changed) 171 local->ops->vif_cfg_changed(&local->hw, &sdata->vif, changed); 172 else if (local->ops->bss_info_changed) 173 local->ops->bss_info_changed(&local->hw, &sdata->vif, 174 &sdata->vif.bss_conf, changed); 175 trace_drv_return_void(local); 176 } 177 178 void drv_link_info_changed(struct ieee80211_local *local, 179 struct ieee80211_sub_if_data *sdata, 180 struct ieee80211_bss_conf *info, 181 int link_id, u64 changed); 182 183 static inline u64 drv_prepare_multicast(struct ieee80211_local *local, 184 struct netdev_hw_addr_list *mc_list) 185 { 186 u64 ret = 0; 187 188 trace_drv_prepare_multicast(local, mc_list->count); 189 190 if (local->ops->prepare_multicast) 191 ret = local->ops->prepare_multicast(&local->hw, mc_list); 192 193 trace_drv_return_u64(local, ret); 194 195 return ret; 196 } 197 198 static inline void drv_configure_filter(struct ieee80211_local *local, 199 unsigned int changed_flags, 200 unsigned int *total_flags, 201 u64 multicast) 202 { 203 might_sleep(); 204 lockdep_assert_wiphy(local->hw.wiphy); 205 206 trace_drv_configure_filter(local, changed_flags, total_flags, 207 multicast); 208 local->ops->configure_filter(&local->hw, changed_flags, total_flags, 209 multicast); 210 trace_drv_return_void(local); 211 } 212 213 static inline void drv_config_iface_filter(struct ieee80211_local *local, 214 struct ieee80211_sub_if_data *sdata, 215 unsigned int filter_flags, 216 unsigned int changed_flags) 217 { 218 might_sleep(); 219 lockdep_assert_wiphy(local->hw.wiphy); 220 221 trace_drv_config_iface_filter(local, sdata, filter_flags, 222 changed_flags); 223 if (local->ops->config_iface_filter) 224 local->ops->config_iface_filter(&local->hw, &sdata->vif, 225 filter_flags, 226 changed_flags); 227 trace_drv_return_void(local); 228 } 229 230 static inline int drv_set_tim(struct ieee80211_local *local, 231 struct ieee80211_sta *sta, bool set) 232 { 233 int ret = 0; 234 trace_drv_set_tim(local, sta, set); 235 if (local->ops->set_tim) 236 ret = local->ops->set_tim(&local->hw, sta, set); 237 trace_drv_return_int(local, ret); 238 return ret; 239 } 240 241 int drv_set_key(struct ieee80211_local *local, 242 enum set_key_cmd cmd, 243 struct ieee80211_sub_if_data *sdata, 244 struct ieee80211_sta *sta, 245 struct ieee80211_key_conf *key); 246 247 static inline void drv_update_tkip_key(struct ieee80211_local *local, 248 struct ieee80211_sub_if_data *sdata, 249 struct ieee80211_key_conf *conf, 250 struct sta_info *sta, u32 iv32, 251 u16 *phase1key) 252 { 253 struct ieee80211_sta *ista = NULL; 254 255 if (sta) 256 ista = &sta->sta; 257 258 sdata = get_bss_sdata(sdata); 259 if (!check_sdata_in_driver(sdata)) 260 return; 261 262 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32); 263 if (local->ops->update_tkip_key) 264 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf, 265 ista, iv32, phase1key); 266 trace_drv_return_void(local); 267 } 268 269 static inline int drv_hw_scan(struct ieee80211_local *local, 270 struct ieee80211_sub_if_data *sdata, 271 struct ieee80211_scan_request *req) 272 { 273 int ret; 274 275 might_sleep(); 276 lockdep_assert_wiphy(local->hw.wiphy); 277 278 if (!check_sdata_in_driver(sdata)) 279 return -EIO; 280 281 trace_drv_hw_scan(local, sdata); 282 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req); 283 trace_drv_return_int(local, ret); 284 return ret; 285 } 286 287 static inline void drv_cancel_hw_scan(struct ieee80211_local *local, 288 struct ieee80211_sub_if_data *sdata) 289 { 290 might_sleep(); 291 lockdep_assert_wiphy(local->hw.wiphy); 292 293 if (!check_sdata_in_driver(sdata)) 294 return; 295 296 trace_drv_cancel_hw_scan(local, sdata); 297 local->ops->cancel_hw_scan(&local->hw, &sdata->vif); 298 trace_drv_return_void(local); 299 } 300 301 static inline int 302 drv_sched_scan_start(struct ieee80211_local *local, 303 struct ieee80211_sub_if_data *sdata, 304 struct cfg80211_sched_scan_request *req, 305 struct ieee80211_scan_ies *ies) 306 { 307 int ret; 308 309 might_sleep(); 310 lockdep_assert_wiphy(local->hw.wiphy); 311 312 if (!check_sdata_in_driver(sdata)) 313 return -EIO; 314 315 trace_drv_sched_scan_start(local, sdata); 316 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif, 317 req, ies); 318 trace_drv_return_int(local, ret); 319 return ret; 320 } 321 322 static inline int drv_sched_scan_stop(struct ieee80211_local *local, 323 struct ieee80211_sub_if_data *sdata) 324 { 325 int ret; 326 327 might_sleep(); 328 lockdep_assert_wiphy(local->hw.wiphy); 329 330 if (!check_sdata_in_driver(sdata)) 331 return -EIO; 332 333 trace_drv_sched_scan_stop(local, sdata); 334 ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif); 335 trace_drv_return_int(local, ret); 336 337 return ret; 338 } 339 340 static inline void drv_sw_scan_start(struct ieee80211_local *local, 341 struct ieee80211_sub_if_data *sdata, 342 const u8 *mac_addr) 343 { 344 might_sleep(); 345 lockdep_assert_wiphy(local->hw.wiphy); 346 347 trace_drv_sw_scan_start(local, sdata, mac_addr); 348 if (local->ops->sw_scan_start) 349 local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr); 350 trace_drv_return_void(local); 351 } 352 353 static inline void drv_sw_scan_complete(struct ieee80211_local *local, 354 struct ieee80211_sub_if_data *sdata) 355 { 356 might_sleep(); 357 lockdep_assert_wiphy(local->hw.wiphy); 358 359 trace_drv_sw_scan_complete(local, sdata); 360 if (local->ops->sw_scan_complete) 361 local->ops->sw_scan_complete(&local->hw, &sdata->vif); 362 trace_drv_return_void(local); 363 } 364 365 static inline int drv_get_stats(struct ieee80211_local *local, 366 struct ieee80211_low_level_stats *stats) 367 { 368 int ret = -EOPNOTSUPP; 369 370 might_sleep(); 371 lockdep_assert_wiphy(local->hw.wiphy); 372 373 if (local->ops->get_stats) 374 ret = local->ops->get_stats(&local->hw, stats); 375 trace_drv_get_stats(local, stats, ret); 376 377 return ret; 378 } 379 380 static inline void drv_get_key_seq(struct ieee80211_local *local, 381 struct ieee80211_key *key, 382 struct ieee80211_key_seq *seq) 383 { 384 if (local->ops->get_key_seq) 385 local->ops->get_key_seq(&local->hw, &key->conf, seq); 386 trace_drv_get_key_seq(local, &key->conf); 387 } 388 389 static inline int drv_set_frag_threshold(struct ieee80211_local *local, 390 u32 value) 391 { 392 int ret = 0; 393 394 might_sleep(); 395 lockdep_assert_wiphy(local->hw.wiphy); 396 397 trace_drv_set_frag_threshold(local, value); 398 if (local->ops->set_frag_threshold) 399 ret = local->ops->set_frag_threshold(&local->hw, value); 400 trace_drv_return_int(local, ret); 401 return ret; 402 } 403 404 static inline int drv_set_rts_threshold(struct ieee80211_local *local, 405 u32 value) 406 { 407 int ret = 0; 408 409 might_sleep(); 410 lockdep_assert_wiphy(local->hw.wiphy); 411 412 trace_drv_set_rts_threshold(local, value); 413 if (local->ops->set_rts_threshold) 414 ret = local->ops->set_rts_threshold(&local->hw, value); 415 trace_drv_return_int(local, ret); 416 return ret; 417 } 418 419 static inline int drv_set_coverage_class(struct ieee80211_local *local, 420 s16 value) 421 { 422 int ret = 0; 423 might_sleep(); 424 lockdep_assert_wiphy(local->hw.wiphy); 425 426 trace_drv_set_coverage_class(local, value); 427 if (local->ops->set_coverage_class) 428 local->ops->set_coverage_class(&local->hw, value); 429 else 430 ret = -EOPNOTSUPP; 431 432 trace_drv_return_int(local, ret); 433 return ret; 434 } 435 436 static inline void drv_sta_notify(struct ieee80211_local *local, 437 struct ieee80211_sub_if_data *sdata, 438 enum sta_notify_cmd cmd, 439 struct ieee80211_sta *sta) 440 { 441 sdata = get_bss_sdata(sdata); 442 if (!check_sdata_in_driver(sdata)) 443 return; 444 445 trace_drv_sta_notify(local, sdata, cmd, sta); 446 if (local->ops->sta_notify) 447 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta); 448 trace_drv_return_void(local); 449 } 450 451 static inline int drv_sta_add(struct ieee80211_local *local, 452 struct ieee80211_sub_if_data *sdata, 453 struct ieee80211_sta *sta) 454 { 455 int ret = 0; 456 457 might_sleep(); 458 lockdep_assert_wiphy(local->hw.wiphy); 459 460 sdata = get_bss_sdata(sdata); 461 if (!check_sdata_in_driver(sdata)) 462 return -EIO; 463 464 trace_drv_sta_add(local, sdata, sta); 465 if (local->ops->sta_add) 466 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta); 467 468 trace_drv_return_int(local, ret); 469 470 return ret; 471 } 472 473 static inline void drv_sta_remove(struct ieee80211_local *local, 474 struct ieee80211_sub_if_data *sdata, 475 struct ieee80211_sta *sta) 476 { 477 might_sleep(); 478 lockdep_assert_wiphy(local->hw.wiphy); 479 480 sdata = get_bss_sdata(sdata); 481 if (!check_sdata_in_driver(sdata)) 482 return; 483 484 trace_drv_sta_remove(local, sdata, sta); 485 if (local->ops->sta_remove) 486 local->ops->sta_remove(&local->hw, &sdata->vif, sta); 487 488 trace_drv_return_void(local); 489 } 490 491 #ifdef CONFIG_MAC80211_DEBUGFS 492 static inline void drv_vif_add_debugfs(struct ieee80211_local *local, 493 struct ieee80211_sub_if_data *sdata) 494 { 495 might_sleep(); 496 497 if (sdata->vif.type == NL80211_IFTYPE_MONITOR || 498 WARN_ON(!sdata->vif.debugfs_dir)) 499 return; 500 501 sdata = get_bss_sdata(sdata); 502 if (!check_sdata_in_driver(sdata)) 503 return; 504 505 if (local->ops->vif_add_debugfs) 506 local->ops->vif_add_debugfs(&local->hw, &sdata->vif); 507 } 508 509 static inline void drv_link_add_debugfs(struct ieee80211_local *local, 510 struct ieee80211_sub_if_data *sdata, 511 struct ieee80211_bss_conf *link_conf, 512 struct dentry *dir) 513 { 514 might_sleep(); 515 lockdep_assert_wiphy(local->hw.wiphy); 516 517 sdata = get_bss_sdata(sdata); 518 if (!check_sdata_in_driver(sdata)) 519 return; 520 521 if (local->ops->link_add_debugfs) 522 local->ops->link_add_debugfs(&local->hw, &sdata->vif, 523 link_conf, dir); 524 } 525 526 static inline void drv_sta_add_debugfs(struct ieee80211_local *local, 527 struct ieee80211_sub_if_data *sdata, 528 struct ieee80211_sta *sta, 529 struct dentry *dir) 530 { 531 might_sleep(); 532 lockdep_assert_wiphy(local->hw.wiphy); 533 534 sdata = get_bss_sdata(sdata); 535 if (!check_sdata_in_driver(sdata)) 536 return; 537 538 if (local->ops->sta_add_debugfs) 539 local->ops->sta_add_debugfs(&local->hw, &sdata->vif, 540 sta, dir); 541 } 542 543 static inline void drv_link_sta_add_debugfs(struct ieee80211_local *local, 544 struct ieee80211_sub_if_data *sdata, 545 struct ieee80211_link_sta *link_sta, 546 struct dentry *dir) 547 { 548 might_sleep(); 549 lockdep_assert_wiphy(local->hw.wiphy); 550 551 sdata = get_bss_sdata(sdata); 552 if (!check_sdata_in_driver(sdata)) 553 return; 554 555 if (local->ops->link_sta_add_debugfs) 556 local->ops->link_sta_add_debugfs(&local->hw, &sdata->vif, 557 link_sta, dir); 558 } 559 #else 560 static inline void drv_vif_add_debugfs(struct ieee80211_local *local, 561 struct ieee80211_sub_if_data *sdata) 562 { 563 might_sleep(); 564 } 565 #endif 566 567 static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local, 568 struct ieee80211_sub_if_data *sdata, 569 struct sta_info *sta) 570 { 571 might_sleep(); 572 lockdep_assert_wiphy(local->hw.wiphy); 573 574 sdata = get_bss_sdata(sdata); 575 if (!check_sdata_in_driver(sdata)) 576 return; 577 578 trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta); 579 if (local->ops->sta_pre_rcu_remove) 580 local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif, 581 &sta->sta); 582 trace_drv_return_void(local); 583 } 584 585 __must_check 586 int drv_sta_state(struct ieee80211_local *local, 587 struct ieee80211_sub_if_data *sdata, 588 struct sta_info *sta, 589 enum ieee80211_sta_state old_state, 590 enum ieee80211_sta_state new_state); 591 592 __must_check 593 int drv_sta_set_txpwr(struct ieee80211_local *local, 594 struct ieee80211_sub_if_data *sdata, 595 struct sta_info *sta); 596 597 void drv_sta_rc_update(struct ieee80211_local *local, 598 struct ieee80211_sub_if_data *sdata, 599 struct ieee80211_sta *sta, u32 changed); 600 601 static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local, 602 struct ieee80211_sub_if_data *sdata, 603 struct ieee80211_sta *sta) 604 { 605 sdata = get_bss_sdata(sdata); 606 if (!check_sdata_in_driver(sdata)) 607 return; 608 609 trace_drv_sta_rate_tbl_update(local, sdata, sta); 610 if (local->ops->sta_rate_tbl_update) 611 local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta); 612 613 trace_drv_return_void(local); 614 } 615 616 static inline void drv_sta_statistics(struct ieee80211_local *local, 617 struct ieee80211_sub_if_data *sdata, 618 struct ieee80211_sta *sta, 619 struct station_info *sinfo) 620 { 621 might_sleep(); 622 lockdep_assert_wiphy(local->hw.wiphy); 623 624 sdata = get_bss_sdata(sdata); 625 if (!check_sdata_in_driver(sdata)) 626 return; 627 628 trace_drv_sta_statistics(local, sdata, sta); 629 if (local->ops->sta_statistics) 630 local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo); 631 trace_drv_return_void(local); 632 } 633 634 int drv_conf_tx(struct ieee80211_local *local, 635 struct ieee80211_link_data *link, u16 ac, 636 const struct ieee80211_tx_queue_params *params); 637 638 u64 drv_get_tsf(struct ieee80211_local *local, 639 struct ieee80211_sub_if_data *sdata); 640 void drv_set_tsf(struct ieee80211_local *local, 641 struct ieee80211_sub_if_data *sdata, 642 u64 tsf); 643 void drv_offset_tsf(struct ieee80211_local *local, 644 struct ieee80211_sub_if_data *sdata, 645 s64 offset); 646 void drv_reset_tsf(struct ieee80211_local *local, 647 struct ieee80211_sub_if_data *sdata); 648 649 static inline int drv_tx_last_beacon(struct ieee80211_local *local) 650 { 651 int ret = 0; /* default unsupported op for less congestion */ 652 653 might_sleep(); 654 lockdep_assert_wiphy(local->hw.wiphy); 655 656 trace_drv_tx_last_beacon(local); 657 if (local->ops->tx_last_beacon) 658 ret = local->ops->tx_last_beacon(&local->hw); 659 trace_drv_return_int(local, ret); 660 return ret; 661 } 662 663 int drv_ampdu_action(struct ieee80211_local *local, 664 struct ieee80211_sub_if_data *sdata, 665 struct ieee80211_ampdu_params *params); 666 667 static inline int drv_get_survey(struct ieee80211_local *local, int idx, 668 struct survey_info *survey) 669 { 670 int ret = -EOPNOTSUPP; 671 672 might_sleep(); 673 lockdep_assert_wiphy(local->hw.wiphy); 674 675 trace_drv_get_survey(local, idx, survey); 676 677 if (local->ops->get_survey) 678 ret = local->ops->get_survey(&local->hw, idx, survey); 679 680 trace_drv_return_int(local, ret); 681 682 return ret; 683 } 684 685 static inline void drv_rfkill_poll(struct ieee80211_local *local) 686 { 687 might_sleep(); 688 lockdep_assert_wiphy(local->hw.wiphy); 689 690 if (local->ops->rfkill_poll) 691 local->ops->rfkill_poll(&local->hw); 692 } 693 694 static inline void drv_flush(struct ieee80211_local *local, 695 struct ieee80211_sub_if_data *sdata, 696 u32 queues, bool drop) 697 { 698 struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL; 699 700 might_sleep(); 701 lockdep_assert_wiphy(local->hw.wiphy); 702 703 if (sdata && !check_sdata_in_driver(sdata)) 704 return; 705 706 trace_drv_flush(local, queues, drop); 707 if (local->ops->flush) 708 local->ops->flush(&local->hw, vif, queues, drop); 709 trace_drv_return_void(local); 710 } 711 712 static inline void drv_flush_sta(struct ieee80211_local *local, 713 struct ieee80211_sub_if_data *sdata, 714 struct sta_info *sta) 715 { 716 might_sleep(); 717 lockdep_assert_wiphy(local->hw.wiphy); 718 719 if (sdata && !check_sdata_in_driver(sdata)) 720 return; 721 722 trace_drv_flush_sta(local, sdata, &sta->sta); 723 if (local->ops->flush_sta) 724 local->ops->flush_sta(&local->hw, &sdata->vif, &sta->sta); 725 trace_drv_return_void(local); 726 } 727 728 static inline void drv_channel_switch(struct ieee80211_local *local, 729 struct ieee80211_sub_if_data *sdata, 730 struct ieee80211_channel_switch *ch_switch) 731 { 732 might_sleep(); 733 lockdep_assert_wiphy(local->hw.wiphy); 734 735 trace_drv_channel_switch(local, sdata, ch_switch); 736 local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch); 737 trace_drv_return_void(local); 738 } 739 740 741 static inline int drv_set_antenna(struct ieee80211_local *local, 742 u32 tx_ant, u32 rx_ant) 743 { 744 int ret = -EOPNOTSUPP; 745 might_sleep(); 746 lockdep_assert_wiphy(local->hw.wiphy); 747 if (local->ops->set_antenna) 748 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant); 749 trace_drv_set_antenna(local, tx_ant, rx_ant, ret); 750 return ret; 751 } 752 753 static inline int drv_get_antenna(struct ieee80211_local *local, 754 u32 *tx_ant, u32 *rx_ant) 755 { 756 int ret = -EOPNOTSUPP; 757 might_sleep(); 758 lockdep_assert_wiphy(local->hw.wiphy); 759 if (local->ops->get_antenna) 760 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant); 761 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret); 762 return ret; 763 } 764 765 static inline int drv_remain_on_channel(struct ieee80211_local *local, 766 struct ieee80211_sub_if_data *sdata, 767 struct ieee80211_channel *chan, 768 unsigned int duration, 769 enum ieee80211_roc_type type) 770 { 771 int ret; 772 773 might_sleep(); 774 lockdep_assert_wiphy(local->hw.wiphy); 775 776 trace_drv_remain_on_channel(local, sdata, chan, duration, type); 777 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif, 778 chan, duration, type); 779 trace_drv_return_int(local, ret); 780 781 return ret; 782 } 783 784 static inline int 785 drv_cancel_remain_on_channel(struct ieee80211_local *local, 786 struct ieee80211_sub_if_data *sdata) 787 { 788 int ret; 789 790 might_sleep(); 791 lockdep_assert_wiphy(local->hw.wiphy); 792 793 trace_drv_cancel_remain_on_channel(local, sdata); 794 ret = local->ops->cancel_remain_on_channel(&local->hw, &sdata->vif); 795 trace_drv_return_int(local, ret); 796 797 return ret; 798 } 799 800 static inline int drv_set_ringparam(struct ieee80211_local *local, 801 u32 tx, u32 rx) 802 { 803 int ret = -ENOTSUPP; 804 805 might_sleep(); 806 lockdep_assert_wiphy(local->hw.wiphy); 807 808 trace_drv_set_ringparam(local, tx, rx); 809 if (local->ops->set_ringparam) 810 ret = local->ops->set_ringparam(&local->hw, tx, rx); 811 trace_drv_return_int(local, ret); 812 813 return ret; 814 } 815 816 static inline void drv_get_ringparam(struct ieee80211_local *local, 817 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max) 818 { 819 might_sleep(); 820 lockdep_assert_wiphy(local->hw.wiphy); 821 822 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max); 823 if (local->ops->get_ringparam) 824 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max); 825 trace_drv_return_void(local); 826 } 827 828 static inline bool drv_tx_frames_pending(struct ieee80211_local *local) 829 { 830 bool ret = false; 831 832 might_sleep(); 833 lockdep_assert_wiphy(local->hw.wiphy); 834 835 trace_drv_tx_frames_pending(local); 836 if (local->ops->tx_frames_pending) 837 ret = local->ops->tx_frames_pending(&local->hw); 838 trace_drv_return_bool(local, ret); 839 840 return ret; 841 } 842 843 static inline int drv_set_bitrate_mask(struct ieee80211_local *local, 844 struct ieee80211_sub_if_data *sdata, 845 const struct cfg80211_bitrate_mask *mask) 846 { 847 int ret = -EOPNOTSUPP; 848 849 might_sleep(); 850 lockdep_assert_wiphy(local->hw.wiphy); 851 852 if (!check_sdata_in_driver(sdata)) 853 return -EIO; 854 855 trace_drv_set_bitrate_mask(local, sdata, mask); 856 if (local->ops->set_bitrate_mask) 857 ret = local->ops->set_bitrate_mask(&local->hw, 858 &sdata->vif, mask); 859 trace_drv_return_int(local, ret); 860 861 return ret; 862 } 863 864 static inline void drv_set_rekey_data(struct ieee80211_local *local, 865 struct ieee80211_sub_if_data *sdata, 866 struct cfg80211_gtk_rekey_data *data) 867 { 868 might_sleep(); 869 lockdep_assert_wiphy(local->hw.wiphy); 870 871 if (!check_sdata_in_driver(sdata)) 872 return; 873 874 trace_drv_set_rekey_data(local, sdata, data); 875 if (local->ops->set_rekey_data) 876 local->ops->set_rekey_data(&local->hw, &sdata->vif, data); 877 trace_drv_return_void(local); 878 } 879 880 static inline void drv_event_callback(struct ieee80211_local *local, 881 struct ieee80211_sub_if_data *sdata, 882 const struct ieee80211_event *event) 883 { 884 trace_drv_event_callback(local, sdata, event); 885 if (local->ops->event_callback) 886 local->ops->event_callback(&local->hw, &sdata->vif, event); 887 trace_drv_return_void(local); 888 } 889 890 static inline void 891 drv_release_buffered_frames(struct ieee80211_local *local, 892 struct sta_info *sta, u16 tids, int num_frames, 893 enum ieee80211_frame_release_type reason, 894 bool more_data) 895 { 896 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames, 897 reason, more_data); 898 if (local->ops->release_buffered_frames) 899 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids, 900 num_frames, reason, 901 more_data); 902 trace_drv_return_void(local); 903 } 904 905 static inline void 906 drv_allow_buffered_frames(struct ieee80211_local *local, 907 struct sta_info *sta, u16 tids, int num_frames, 908 enum ieee80211_frame_release_type reason, 909 bool more_data) 910 { 911 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames, 912 reason, more_data); 913 if (local->ops->allow_buffered_frames) 914 local->ops->allow_buffered_frames(&local->hw, &sta->sta, 915 tids, num_frames, reason, 916 more_data); 917 trace_drv_return_void(local); 918 } 919 920 static inline void drv_mgd_prepare_tx(struct ieee80211_local *local, 921 struct ieee80211_sub_if_data *sdata, 922 struct ieee80211_prep_tx_info *info) 923 { 924 might_sleep(); 925 lockdep_assert_wiphy(local->hw.wiphy); 926 927 if (!check_sdata_in_driver(sdata)) 928 return; 929 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION); 930 931 info->link_id = info->link_id < 0 ? 0 : info->link_id; 932 trace_drv_mgd_prepare_tx(local, sdata, info->duration, 933 info->subtype, info->success); 934 if (local->ops->mgd_prepare_tx) 935 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif, info); 936 trace_drv_return_void(local); 937 } 938 939 static inline void drv_mgd_complete_tx(struct ieee80211_local *local, 940 struct ieee80211_sub_if_data *sdata, 941 struct ieee80211_prep_tx_info *info) 942 { 943 might_sleep(); 944 lockdep_assert_wiphy(local->hw.wiphy); 945 946 if (!check_sdata_in_driver(sdata)) 947 return; 948 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION); 949 950 trace_drv_mgd_complete_tx(local, sdata, info->duration, 951 info->subtype, info->success); 952 if (local->ops->mgd_complete_tx) 953 local->ops->mgd_complete_tx(&local->hw, &sdata->vif, info); 954 trace_drv_return_void(local); 955 } 956 957 static inline void 958 drv_mgd_protect_tdls_discover(struct ieee80211_local *local, 959 struct ieee80211_sub_if_data *sdata, 960 int link_id) 961 { 962 might_sleep(); 963 lockdep_assert_wiphy(local->hw.wiphy); 964 965 if (!check_sdata_in_driver(sdata)) 966 return; 967 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION); 968 969 link_id = link_id > 0 ? link_id : 0; 970 971 trace_drv_mgd_protect_tdls_discover(local, sdata); 972 if (local->ops->mgd_protect_tdls_discover) 973 local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif, 974 link_id); 975 trace_drv_return_void(local); 976 } 977 978 static inline int drv_add_chanctx(struct ieee80211_local *local, 979 struct ieee80211_chanctx *ctx) 980 { 981 int ret = -EOPNOTSUPP; 982 983 might_sleep(); 984 lockdep_assert_wiphy(local->hw.wiphy); 985 986 trace_drv_add_chanctx(local, ctx); 987 if (local->ops->add_chanctx) 988 ret = local->ops->add_chanctx(&local->hw, &ctx->conf); 989 trace_drv_return_int(local, ret); 990 if (!ret) 991 ctx->driver_present = true; 992 993 return ret; 994 } 995 996 static inline void drv_remove_chanctx(struct ieee80211_local *local, 997 struct ieee80211_chanctx *ctx) 998 { 999 might_sleep(); 1000 lockdep_assert_wiphy(local->hw.wiphy); 1001 1002 if (WARN_ON(!ctx->driver_present)) 1003 return; 1004 1005 trace_drv_remove_chanctx(local, ctx); 1006 if (local->ops->remove_chanctx) 1007 local->ops->remove_chanctx(&local->hw, &ctx->conf); 1008 trace_drv_return_void(local); 1009 ctx->driver_present = false; 1010 } 1011 1012 static inline void drv_change_chanctx(struct ieee80211_local *local, 1013 struct ieee80211_chanctx *ctx, 1014 u32 changed) 1015 { 1016 might_sleep(); 1017 lockdep_assert_wiphy(local->hw.wiphy); 1018 1019 trace_drv_change_chanctx(local, ctx, changed); 1020 if (local->ops->change_chanctx) { 1021 WARN_ON_ONCE(!ctx->driver_present); 1022 local->ops->change_chanctx(&local->hw, &ctx->conf, changed); 1023 } 1024 trace_drv_return_void(local); 1025 } 1026 1027 int drv_assign_vif_chanctx(struct ieee80211_local *local, 1028 struct ieee80211_sub_if_data *sdata, 1029 struct ieee80211_bss_conf *link_conf, 1030 struct ieee80211_chanctx *ctx); 1031 void drv_unassign_vif_chanctx(struct ieee80211_local *local, 1032 struct ieee80211_sub_if_data *sdata, 1033 struct ieee80211_bss_conf *link_conf, 1034 struct ieee80211_chanctx *ctx); 1035 int drv_switch_vif_chanctx(struct ieee80211_local *local, 1036 struct ieee80211_vif_chanctx_switch *vifs, 1037 int n_vifs, enum ieee80211_chanctx_switch_mode mode); 1038 1039 static inline int drv_start_ap(struct ieee80211_local *local, 1040 struct ieee80211_sub_if_data *sdata, 1041 struct ieee80211_bss_conf *link_conf) 1042 { 1043 int ret = 0; 1044 1045 might_sleep(); 1046 lockdep_assert_wiphy(local->hw.wiphy); 1047 1048 if (!check_sdata_in_driver(sdata)) 1049 return -EIO; 1050 1051 trace_drv_start_ap(local, sdata, link_conf); 1052 if (local->ops->start_ap) 1053 ret = local->ops->start_ap(&local->hw, &sdata->vif, link_conf); 1054 trace_drv_return_int(local, ret); 1055 return ret; 1056 } 1057 1058 static inline void drv_stop_ap(struct ieee80211_local *local, 1059 struct ieee80211_sub_if_data *sdata, 1060 struct ieee80211_bss_conf *link_conf) 1061 { 1062 might_sleep(); 1063 lockdep_assert_wiphy(local->hw.wiphy); 1064 1065 if (!check_sdata_in_driver(sdata)) 1066 return; 1067 1068 trace_drv_stop_ap(local, sdata, link_conf); 1069 if (local->ops->stop_ap) 1070 local->ops->stop_ap(&local->hw, &sdata->vif, link_conf); 1071 trace_drv_return_void(local); 1072 } 1073 1074 static inline void 1075 drv_reconfig_complete(struct ieee80211_local *local, 1076 enum ieee80211_reconfig_type reconfig_type) 1077 { 1078 might_sleep(); 1079 lockdep_assert_wiphy(local->hw.wiphy); 1080 1081 trace_drv_reconfig_complete(local, reconfig_type); 1082 if (local->ops->reconfig_complete) 1083 local->ops->reconfig_complete(&local->hw, reconfig_type); 1084 trace_drv_return_void(local); 1085 } 1086 1087 static inline void 1088 drv_set_default_unicast_key(struct ieee80211_local *local, 1089 struct ieee80211_sub_if_data *sdata, 1090 int key_idx) 1091 { 1092 might_sleep(); 1093 lockdep_assert_wiphy(local->hw.wiphy); 1094 1095 if (!check_sdata_in_driver(sdata)) 1096 return; 1097 1098 WARN_ON_ONCE(key_idx < -1 || key_idx > 3); 1099 1100 trace_drv_set_default_unicast_key(local, sdata, key_idx); 1101 if (local->ops->set_default_unicast_key) 1102 local->ops->set_default_unicast_key(&local->hw, &sdata->vif, 1103 key_idx); 1104 trace_drv_return_void(local); 1105 } 1106 1107 #if IS_ENABLED(CONFIG_IPV6) 1108 static inline void drv_ipv6_addr_change(struct ieee80211_local *local, 1109 struct ieee80211_sub_if_data *sdata, 1110 struct inet6_dev *idev) 1111 { 1112 trace_drv_ipv6_addr_change(local, sdata); 1113 if (local->ops->ipv6_addr_change) 1114 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev); 1115 trace_drv_return_void(local); 1116 } 1117 #endif 1118 1119 static inline void 1120 drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata, 1121 struct cfg80211_chan_def *chandef) 1122 { 1123 struct ieee80211_local *local = sdata->local; 1124 1125 might_sleep(); 1126 lockdep_assert_wiphy(local->hw.wiphy); 1127 1128 if (local->ops->channel_switch_beacon) { 1129 trace_drv_channel_switch_beacon(local, sdata, chandef); 1130 local->ops->channel_switch_beacon(&local->hw, &sdata->vif, 1131 chandef); 1132 } 1133 } 1134 1135 static inline int 1136 drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata, 1137 struct ieee80211_channel_switch *ch_switch) 1138 { 1139 struct ieee80211_local *local = sdata->local; 1140 int ret = 0; 1141 1142 might_sleep(); 1143 lockdep_assert_wiphy(local->hw.wiphy); 1144 1145 if (!check_sdata_in_driver(sdata)) 1146 return -EIO; 1147 1148 trace_drv_pre_channel_switch(local, sdata, ch_switch); 1149 if (local->ops->pre_channel_switch) 1150 ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif, 1151 ch_switch); 1152 trace_drv_return_int(local, ret); 1153 return ret; 1154 } 1155 1156 static inline int 1157 drv_post_channel_switch(struct ieee80211_link_data *link) 1158 { 1159 struct ieee80211_sub_if_data *sdata = link->sdata; 1160 struct ieee80211_local *local = sdata->local; 1161 int ret = 0; 1162 1163 might_sleep(); 1164 lockdep_assert_wiphy(local->hw.wiphy); 1165 1166 if (!check_sdata_in_driver(sdata)) 1167 return -EIO; 1168 1169 trace_drv_post_channel_switch(local, sdata); 1170 if (local->ops->post_channel_switch) 1171 ret = local->ops->post_channel_switch(&local->hw, &sdata->vif, 1172 link->conf); 1173 trace_drv_return_int(local, ret); 1174 return ret; 1175 } 1176 1177 static inline void 1178 drv_abort_channel_switch(struct ieee80211_sub_if_data *sdata) 1179 { 1180 struct ieee80211_local *local = sdata->local; 1181 1182 might_sleep(); 1183 lockdep_assert_wiphy(local->hw.wiphy); 1184 1185 if (!check_sdata_in_driver(sdata)) 1186 return; 1187 1188 trace_drv_abort_channel_switch(local, sdata); 1189 1190 if (local->ops->abort_channel_switch) 1191 local->ops->abort_channel_switch(&local->hw, &sdata->vif); 1192 } 1193 1194 static inline void 1195 drv_channel_switch_rx_beacon(struct ieee80211_sub_if_data *sdata, 1196 struct ieee80211_channel_switch *ch_switch) 1197 { 1198 struct ieee80211_local *local = sdata->local; 1199 1200 might_sleep(); 1201 lockdep_assert_wiphy(local->hw.wiphy); 1202 1203 if (!check_sdata_in_driver(sdata)) 1204 return; 1205 1206 trace_drv_channel_switch_rx_beacon(local, sdata, ch_switch); 1207 if (local->ops->channel_switch_rx_beacon) 1208 local->ops->channel_switch_rx_beacon(&local->hw, &sdata->vif, 1209 ch_switch); 1210 } 1211 1212 static inline int drv_join_ibss(struct ieee80211_local *local, 1213 struct ieee80211_sub_if_data *sdata) 1214 { 1215 int ret = 0; 1216 1217 might_sleep(); 1218 lockdep_assert_wiphy(local->hw.wiphy); 1219 if (!check_sdata_in_driver(sdata)) 1220 return -EIO; 1221 1222 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf); 1223 if (local->ops->join_ibss) 1224 ret = local->ops->join_ibss(&local->hw, &sdata->vif); 1225 trace_drv_return_int(local, ret); 1226 return ret; 1227 } 1228 1229 static inline void drv_leave_ibss(struct ieee80211_local *local, 1230 struct ieee80211_sub_if_data *sdata) 1231 { 1232 might_sleep(); 1233 lockdep_assert_wiphy(local->hw.wiphy); 1234 if (!check_sdata_in_driver(sdata)) 1235 return; 1236 1237 trace_drv_leave_ibss(local, sdata); 1238 if (local->ops->leave_ibss) 1239 local->ops->leave_ibss(&local->hw, &sdata->vif); 1240 trace_drv_return_void(local); 1241 } 1242 1243 static inline u32 drv_get_expected_throughput(struct ieee80211_local *local, 1244 struct sta_info *sta) 1245 { 1246 u32 ret = 0; 1247 1248 trace_drv_get_expected_throughput(&sta->sta); 1249 if (local->ops->get_expected_throughput && sta->uploaded) 1250 ret = local->ops->get_expected_throughput(&local->hw, &sta->sta); 1251 trace_drv_return_u32(local, ret); 1252 1253 return ret; 1254 } 1255 1256 static inline int drv_get_txpower(struct ieee80211_local *local, 1257 struct ieee80211_sub_if_data *sdata, int *dbm) 1258 { 1259 int ret; 1260 1261 might_sleep(); 1262 lockdep_assert_wiphy(local->hw.wiphy); 1263 1264 if (!local->ops->get_txpower) 1265 return -EOPNOTSUPP; 1266 1267 ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm); 1268 trace_drv_get_txpower(local, sdata, *dbm, ret); 1269 1270 return ret; 1271 } 1272 1273 static inline int 1274 drv_tdls_channel_switch(struct ieee80211_local *local, 1275 struct ieee80211_sub_if_data *sdata, 1276 struct ieee80211_sta *sta, u8 oper_class, 1277 struct cfg80211_chan_def *chandef, 1278 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie) 1279 { 1280 int ret; 1281 1282 might_sleep(); 1283 lockdep_assert_wiphy(local->hw.wiphy); 1284 if (!check_sdata_in_driver(sdata)) 1285 return -EIO; 1286 1287 if (!local->ops->tdls_channel_switch) 1288 return -EOPNOTSUPP; 1289 1290 trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef); 1291 ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta, 1292 oper_class, chandef, tmpl_skb, 1293 ch_sw_tm_ie); 1294 trace_drv_return_int(local, ret); 1295 return ret; 1296 } 1297 1298 static inline void 1299 drv_tdls_cancel_channel_switch(struct ieee80211_local *local, 1300 struct ieee80211_sub_if_data *sdata, 1301 struct ieee80211_sta *sta) 1302 { 1303 might_sleep(); 1304 lockdep_assert_wiphy(local->hw.wiphy); 1305 if (!check_sdata_in_driver(sdata)) 1306 return; 1307 1308 if (!local->ops->tdls_cancel_channel_switch) 1309 return; 1310 1311 trace_drv_tdls_cancel_channel_switch(local, sdata, sta); 1312 local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta); 1313 trace_drv_return_void(local); 1314 } 1315 1316 static inline void 1317 drv_tdls_recv_channel_switch(struct ieee80211_local *local, 1318 struct ieee80211_sub_if_data *sdata, 1319 struct ieee80211_tdls_ch_sw_params *params) 1320 { 1321 trace_drv_tdls_recv_channel_switch(local, sdata, params); 1322 if (local->ops->tdls_recv_channel_switch) 1323 local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif, 1324 params); 1325 trace_drv_return_void(local); 1326 } 1327 1328 static inline void drv_wake_tx_queue(struct ieee80211_local *local, 1329 struct txq_info *txq) 1330 { 1331 struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif); 1332 1333 /* In reconfig don't transmit now, but mark for waking later */ 1334 if (local->in_reconfig) { 1335 set_bit(IEEE80211_TXQ_DIRTY, &txq->flags); 1336 return; 1337 } 1338 1339 if (!check_sdata_in_driver(sdata)) 1340 return; 1341 1342 trace_drv_wake_tx_queue(local, sdata, txq); 1343 local->ops->wake_tx_queue(&local->hw, &txq->txq); 1344 } 1345 1346 static inline void schedule_and_wake_txq(struct ieee80211_local *local, 1347 struct txq_info *txqi) 1348 { 1349 ieee80211_schedule_txq(&local->hw, &txqi->txq); 1350 drv_wake_tx_queue(local, txqi); 1351 } 1352 1353 static inline int drv_can_aggregate_in_amsdu(struct ieee80211_local *local, 1354 struct sk_buff *head, 1355 struct sk_buff *skb) 1356 { 1357 if (!local->ops->can_aggregate_in_amsdu) 1358 return true; 1359 1360 return local->ops->can_aggregate_in_amsdu(&local->hw, head, skb); 1361 } 1362 1363 static inline int 1364 drv_get_ftm_responder_stats(struct ieee80211_local *local, 1365 struct ieee80211_sub_if_data *sdata, 1366 struct cfg80211_ftm_responder_stats *ftm_stats) 1367 { 1368 u32 ret = -EOPNOTSUPP; 1369 1370 might_sleep(); 1371 lockdep_assert_wiphy(local->hw.wiphy); 1372 if (!check_sdata_in_driver(sdata)) 1373 return -EIO; 1374 1375 if (local->ops->get_ftm_responder_stats) 1376 ret = local->ops->get_ftm_responder_stats(&local->hw, 1377 &sdata->vif, 1378 ftm_stats); 1379 trace_drv_get_ftm_responder_stats(local, sdata, ftm_stats); 1380 1381 return ret; 1382 } 1383 1384 static inline int drv_start_pmsr(struct ieee80211_local *local, 1385 struct ieee80211_sub_if_data *sdata, 1386 struct cfg80211_pmsr_request *request) 1387 { 1388 int ret = -EOPNOTSUPP; 1389 1390 might_sleep(); 1391 lockdep_assert_wiphy(local->hw.wiphy); 1392 if (!check_sdata_in_driver(sdata)) 1393 return -EIO; 1394 1395 trace_drv_start_pmsr(local, sdata); 1396 1397 if (local->ops->start_pmsr) 1398 ret = local->ops->start_pmsr(&local->hw, &sdata->vif, request); 1399 trace_drv_return_int(local, ret); 1400 1401 return ret; 1402 } 1403 1404 static inline void drv_abort_pmsr(struct ieee80211_local *local, 1405 struct ieee80211_sub_if_data *sdata, 1406 struct cfg80211_pmsr_request *request) 1407 { 1408 trace_drv_abort_pmsr(local, sdata); 1409 1410 might_sleep(); 1411 lockdep_assert_wiphy(local->hw.wiphy); 1412 if (!check_sdata_in_driver(sdata)) 1413 return; 1414 1415 if (local->ops->abort_pmsr) 1416 local->ops->abort_pmsr(&local->hw, &sdata->vif, request); 1417 trace_drv_return_void(local); 1418 } 1419 1420 static inline int drv_start_nan(struct ieee80211_local *local, 1421 struct ieee80211_sub_if_data *sdata, 1422 struct cfg80211_nan_conf *conf) 1423 { 1424 int ret; 1425 1426 might_sleep(); 1427 lockdep_assert_wiphy(local->hw.wiphy); 1428 check_sdata_in_driver(sdata); 1429 1430 trace_drv_start_nan(local, sdata, conf); 1431 ret = local->ops->start_nan(&local->hw, &sdata->vif, conf); 1432 trace_drv_return_int(local, ret); 1433 return ret; 1434 } 1435 1436 static inline void drv_stop_nan(struct ieee80211_local *local, 1437 struct ieee80211_sub_if_data *sdata) 1438 { 1439 might_sleep(); 1440 lockdep_assert_wiphy(local->hw.wiphy); 1441 check_sdata_in_driver(sdata); 1442 1443 trace_drv_stop_nan(local, sdata); 1444 local->ops->stop_nan(&local->hw, &sdata->vif); 1445 trace_drv_return_void(local); 1446 } 1447 1448 static inline int drv_nan_change_conf(struct ieee80211_local *local, 1449 struct ieee80211_sub_if_data *sdata, 1450 struct cfg80211_nan_conf *conf, 1451 u32 changes) 1452 { 1453 int ret; 1454 1455 might_sleep(); 1456 lockdep_assert_wiphy(local->hw.wiphy); 1457 check_sdata_in_driver(sdata); 1458 1459 if (!local->ops->nan_change_conf) 1460 return -EOPNOTSUPP; 1461 1462 trace_drv_nan_change_conf(local, sdata, conf, changes); 1463 ret = local->ops->nan_change_conf(&local->hw, &sdata->vif, conf, 1464 changes); 1465 trace_drv_return_int(local, ret); 1466 1467 return ret; 1468 } 1469 1470 static inline int drv_add_nan_func(struct ieee80211_local *local, 1471 struct ieee80211_sub_if_data *sdata, 1472 const struct cfg80211_nan_func *nan_func) 1473 { 1474 int ret; 1475 1476 might_sleep(); 1477 lockdep_assert_wiphy(local->hw.wiphy); 1478 check_sdata_in_driver(sdata); 1479 1480 if (!local->ops->add_nan_func) 1481 return -EOPNOTSUPP; 1482 1483 trace_drv_add_nan_func(local, sdata, nan_func); 1484 ret = local->ops->add_nan_func(&local->hw, &sdata->vif, nan_func); 1485 trace_drv_return_int(local, ret); 1486 1487 return ret; 1488 } 1489 1490 static inline void drv_del_nan_func(struct ieee80211_local *local, 1491 struct ieee80211_sub_if_data *sdata, 1492 u8 instance_id) 1493 { 1494 might_sleep(); 1495 lockdep_assert_wiphy(local->hw.wiphy); 1496 check_sdata_in_driver(sdata); 1497 1498 trace_drv_del_nan_func(local, sdata, instance_id); 1499 if (local->ops->del_nan_func) 1500 local->ops->del_nan_func(&local->hw, &sdata->vif, instance_id); 1501 trace_drv_return_void(local); 1502 } 1503 1504 static inline int drv_set_tid_config(struct ieee80211_local *local, 1505 struct ieee80211_sub_if_data *sdata, 1506 struct ieee80211_sta *sta, 1507 struct cfg80211_tid_config *tid_conf) 1508 { 1509 int ret; 1510 1511 might_sleep(); 1512 lockdep_assert_wiphy(local->hw.wiphy); 1513 ret = local->ops->set_tid_config(&local->hw, &sdata->vif, sta, 1514 tid_conf); 1515 trace_drv_return_int(local, ret); 1516 1517 return ret; 1518 } 1519 1520 static inline int drv_reset_tid_config(struct ieee80211_local *local, 1521 struct ieee80211_sub_if_data *sdata, 1522 struct ieee80211_sta *sta, u8 tids) 1523 { 1524 int ret; 1525 1526 might_sleep(); 1527 lockdep_assert_wiphy(local->hw.wiphy); 1528 ret = local->ops->reset_tid_config(&local->hw, &sdata->vif, sta, tids); 1529 trace_drv_return_int(local, ret); 1530 1531 return ret; 1532 } 1533 1534 static inline void drv_update_vif_offload(struct ieee80211_local *local, 1535 struct ieee80211_sub_if_data *sdata) 1536 { 1537 might_sleep(); 1538 lockdep_assert_wiphy(local->hw.wiphy); 1539 check_sdata_in_driver(sdata); 1540 1541 if (!local->ops->update_vif_offload) 1542 return; 1543 1544 trace_drv_update_vif_offload(local, sdata); 1545 local->ops->update_vif_offload(&local->hw, &sdata->vif); 1546 trace_drv_return_void(local); 1547 } 1548 1549 static inline void drv_sta_set_4addr(struct ieee80211_local *local, 1550 struct ieee80211_sub_if_data *sdata, 1551 struct ieee80211_sta *sta, bool enabled) 1552 { 1553 sdata = get_bss_sdata(sdata); 1554 1555 might_sleep(); 1556 lockdep_assert_wiphy(local->hw.wiphy); 1557 if (!check_sdata_in_driver(sdata)) 1558 return; 1559 1560 trace_drv_sta_set_4addr(local, sdata, sta, enabled); 1561 if (local->ops->sta_set_4addr) 1562 local->ops->sta_set_4addr(&local->hw, &sdata->vif, sta, enabled); 1563 trace_drv_return_void(local); 1564 } 1565 1566 static inline void drv_sta_set_decap_offload(struct ieee80211_local *local, 1567 struct ieee80211_sub_if_data *sdata, 1568 struct ieee80211_sta *sta, 1569 bool enabled) 1570 { 1571 sdata = get_bss_sdata(sdata); 1572 1573 might_sleep(); 1574 lockdep_assert_wiphy(local->hw.wiphy); 1575 if (!check_sdata_in_driver(sdata)) 1576 return; 1577 1578 trace_drv_sta_set_decap_offload(local, sdata, sta, enabled); 1579 if (local->ops->sta_set_decap_offload) 1580 local->ops->sta_set_decap_offload(&local->hw, &sdata->vif, sta, 1581 enabled); 1582 trace_drv_return_void(local); 1583 } 1584 1585 static inline void drv_add_twt_setup(struct ieee80211_local *local, 1586 struct ieee80211_sub_if_data *sdata, 1587 struct ieee80211_sta *sta, 1588 struct ieee80211_twt_setup *twt) 1589 { 1590 struct ieee80211_twt_params *twt_agrt; 1591 1592 might_sleep(); 1593 lockdep_assert_wiphy(local->hw.wiphy); 1594 1595 if (!check_sdata_in_driver(sdata)) 1596 return; 1597 1598 twt_agrt = (void *)twt->params; 1599 1600 trace_drv_add_twt_setup(local, sta, twt, twt_agrt); 1601 local->ops->add_twt_setup(&local->hw, sta, twt); 1602 trace_drv_return_void(local); 1603 } 1604 1605 static inline void drv_twt_teardown_request(struct ieee80211_local *local, 1606 struct ieee80211_sub_if_data *sdata, 1607 struct ieee80211_sta *sta, 1608 u8 flowid) 1609 { 1610 might_sleep(); 1611 lockdep_assert_wiphy(local->hw.wiphy); 1612 if (!check_sdata_in_driver(sdata)) 1613 return; 1614 1615 if (!local->ops->twt_teardown_request) 1616 return; 1617 1618 trace_drv_twt_teardown_request(local, sta, flowid); 1619 local->ops->twt_teardown_request(&local->hw, sta, flowid); 1620 trace_drv_return_void(local); 1621 } 1622 1623 static inline int drv_net_fill_forward_path(struct ieee80211_local *local, 1624 struct ieee80211_sub_if_data *sdata, 1625 struct ieee80211_sta *sta, 1626 struct net_device_path_ctx *ctx, 1627 struct net_device_path *path) 1628 { 1629 int ret = -EOPNOTSUPP; 1630 1631 sdata = get_bss_sdata(sdata); 1632 if (!check_sdata_in_driver(sdata)) 1633 return -EIO; 1634 1635 trace_drv_net_fill_forward_path(local, sdata, sta); 1636 if (local->ops->net_fill_forward_path) 1637 ret = local->ops->net_fill_forward_path(&local->hw, 1638 &sdata->vif, sta, 1639 ctx, path); 1640 trace_drv_return_int(local, ret); 1641 1642 return ret; 1643 } 1644 1645 static inline int drv_net_setup_tc(struct ieee80211_local *local, 1646 struct ieee80211_sub_if_data *sdata, 1647 struct net_device *dev, 1648 enum tc_setup_type type, void *type_data) 1649 { 1650 int ret = -EOPNOTSUPP; 1651 1652 might_sleep(); 1653 1654 sdata = get_bss_sdata(sdata); 1655 trace_drv_net_setup_tc(local, sdata, type); 1656 if (local->ops->net_setup_tc) 1657 ret = local->ops->net_setup_tc(&local->hw, &sdata->vif, dev, 1658 type, type_data); 1659 trace_drv_return_int(local, ret); 1660 1661 return ret; 1662 } 1663 1664 int drv_change_vif_links(struct ieee80211_local *local, 1665 struct ieee80211_sub_if_data *sdata, 1666 u16 old_links, u16 new_links, 1667 struct ieee80211_bss_conf *old[IEEE80211_MLD_MAX_NUM_LINKS]); 1668 int drv_change_sta_links(struct ieee80211_local *local, 1669 struct ieee80211_sub_if_data *sdata, 1670 struct ieee80211_sta *sta, 1671 u16 old_links, u16 new_links); 1672 1673 #endif /* __MAC80211_DRIVER_OPS */ 1674