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