Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* |
| 3 | * Portions of this file |
| 4 | * Copyright(c) 2016 Intel Deutschland GmbH |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 5 | * Copyright (C) 2018 - 2019 Intel Corporation |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 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 | static inline bool check_sdata_in_driver(struct ieee80211_sub_if_data *sdata) |
| 16 | { |
| 17 | return !WARN(!(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 | } |
| 21 | |
| 22 | static inline struct ieee80211_sub_if_data * |
| 23 | get_bss_sdata(struct ieee80211_sub_if_data *sdata) |
| 24 | { |
| 25 | if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) |
| 26 | sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, |
| 27 | u.ap); |
| 28 | |
| 29 | return sdata; |
| 30 | } |
| 31 | |
| 32 | static inline void drv_tx(struct ieee80211_local *local, |
| 33 | struct ieee80211_tx_control *control, |
| 34 | struct sk_buff *skb) |
| 35 | { |
| 36 | local->ops->tx(&local->hw, control, skb); |
| 37 | } |
| 38 | |
| 39 | static inline void drv_sync_rx_queues(struct ieee80211_local *local, |
| 40 | struct sta_info *sta) |
| 41 | { |
| 42 | if (local->ops->sync_rx_queues) { |
| 43 | trace_drv_sync_rx_queues(local, sta->sdata, &sta->sta); |
| 44 | local->ops->sync_rx_queues(&local->hw); |
| 45 | trace_drv_return_void(local); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata, |
| 50 | u32 sset, u8 *data) |
| 51 | { |
| 52 | struct ieee80211_local *local = sdata->local; |
| 53 | if (local->ops->get_et_strings) { |
| 54 | trace_drv_get_et_strings(local, sset); |
| 55 | local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data); |
| 56 | trace_drv_return_void(local); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata, |
| 61 | struct ethtool_stats *stats, |
| 62 | u64 *data) |
| 63 | { |
| 64 | struct ieee80211_local *local = sdata->local; |
| 65 | if (local->ops->get_et_stats) { |
| 66 | trace_drv_get_et_stats(local); |
| 67 | local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data); |
| 68 | trace_drv_return_void(local); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata, |
| 73 | int sset) |
| 74 | { |
| 75 | struct ieee80211_local *local = sdata->local; |
| 76 | int rv = 0; |
| 77 | if (local->ops->get_et_sset_count) { |
| 78 | trace_drv_get_et_sset_count(local, sset); |
| 79 | rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif, |
| 80 | sset); |
| 81 | trace_drv_return_int(local, rv); |
| 82 | } |
| 83 | return rv; |
| 84 | } |
| 85 | |
| 86 | int drv_start(struct ieee80211_local *local); |
| 87 | void drv_stop(struct ieee80211_local *local); |
| 88 | |
| 89 | #ifdef CONFIG_PM |
| 90 | static inline int drv_suspend(struct ieee80211_local *local, |
| 91 | struct cfg80211_wowlan *wowlan) |
| 92 | { |
| 93 | int ret; |
| 94 | |
| 95 | might_sleep(); |
| 96 | |
| 97 | trace_drv_suspend(local); |
| 98 | ret = local->ops->suspend(&local->hw, wowlan); |
| 99 | trace_drv_return_int(local, ret); |
| 100 | return ret; |
| 101 | } |
| 102 | |
| 103 | static inline int drv_resume(struct ieee80211_local *local) |
| 104 | { |
| 105 | int ret; |
| 106 | |
| 107 | might_sleep(); |
| 108 | |
| 109 | trace_drv_resume(local); |
| 110 | ret = local->ops->resume(&local->hw); |
| 111 | trace_drv_return_int(local, ret); |
| 112 | return ret; |
| 113 | } |
| 114 | |
| 115 | static inline void drv_set_wakeup(struct ieee80211_local *local, |
| 116 | bool enabled) |
| 117 | { |
| 118 | might_sleep(); |
| 119 | |
| 120 | if (!local->ops->set_wakeup) |
| 121 | return; |
| 122 | |
| 123 | trace_drv_set_wakeup(local, enabled); |
| 124 | local->ops->set_wakeup(&local->hw, enabled); |
| 125 | trace_drv_return_void(local); |
| 126 | } |
| 127 | #endif |
| 128 | |
| 129 | int drv_add_interface(struct ieee80211_local *local, |
| 130 | struct ieee80211_sub_if_data *sdata); |
| 131 | |
| 132 | int drv_change_interface(struct ieee80211_local *local, |
| 133 | struct ieee80211_sub_if_data *sdata, |
| 134 | enum nl80211_iftype type, bool p2p); |
| 135 | |
| 136 | void drv_remove_interface(struct ieee80211_local *local, |
| 137 | struct ieee80211_sub_if_data *sdata); |
| 138 | |
| 139 | static inline int drv_config(struct ieee80211_local *local, u32 changed) |
| 140 | { |
| 141 | int ret; |
| 142 | |
| 143 | might_sleep(); |
| 144 | |
| 145 | trace_drv_config(local, changed); |
| 146 | ret = local->ops->config(&local->hw, changed); |
| 147 | trace_drv_return_int(local, ret); |
| 148 | return ret; |
| 149 | } |
| 150 | |
| 151 | static inline void drv_bss_info_changed(struct ieee80211_local *local, |
| 152 | struct ieee80211_sub_if_data *sdata, |
| 153 | struct ieee80211_bss_conf *info, |
| 154 | u32 changed) |
| 155 | { |
| 156 | might_sleep(); |
| 157 | |
| 158 | if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON | |
| 159 | BSS_CHANGED_BEACON_ENABLED) && |
| 160 | sdata->vif.type != NL80211_IFTYPE_AP && |
| 161 | sdata->vif.type != NL80211_IFTYPE_ADHOC && |
| 162 | sdata->vif.type != NL80211_IFTYPE_MESH_POINT && |
| 163 | sdata->vif.type != NL80211_IFTYPE_OCB)) |
| 164 | return; |
| 165 | |
| 166 | if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE || |
| 167 | sdata->vif.type == NL80211_IFTYPE_NAN || |
| 168 | (sdata->vif.type == NL80211_IFTYPE_MONITOR && |
| 169 | !sdata->vif.mu_mimo_owner && |
| 170 | !(changed & BSS_CHANGED_TXPOWER)))) |
| 171 | return; |
| 172 | |
| 173 | if (!check_sdata_in_driver(sdata)) |
| 174 | return; |
| 175 | |
| 176 | trace_drv_bss_info_changed(local, sdata, info, changed); |
| 177 | if (local->ops->bss_info_changed) |
| 178 | local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed); |
| 179 | trace_drv_return_void(local); |
| 180 | } |
| 181 | |
| 182 | static inline u64 drv_prepare_multicast(struct ieee80211_local *local, |
| 183 | struct netdev_hw_addr_list *mc_list) |
| 184 | { |
| 185 | u64 ret = 0; |
| 186 | |
| 187 | trace_drv_prepare_multicast(local, mc_list->count); |
| 188 | |
| 189 | if (local->ops->prepare_multicast) |
| 190 | ret = local->ops->prepare_multicast(&local->hw, mc_list); |
| 191 | |
| 192 | trace_drv_return_u64(local, ret); |
| 193 | |
| 194 | return ret; |
| 195 | } |
| 196 | |
| 197 | static inline void drv_configure_filter(struct ieee80211_local *local, |
| 198 | unsigned int changed_flags, |
| 199 | unsigned int *total_flags, |
| 200 | u64 multicast) |
| 201 | { |
| 202 | might_sleep(); |
| 203 | |
| 204 | trace_drv_configure_filter(local, changed_flags, total_flags, |
| 205 | multicast); |
| 206 | local->ops->configure_filter(&local->hw, changed_flags, total_flags, |
| 207 | multicast); |
| 208 | trace_drv_return_void(local); |
| 209 | } |
| 210 | |
| 211 | static inline void drv_config_iface_filter(struct ieee80211_local *local, |
| 212 | struct ieee80211_sub_if_data *sdata, |
| 213 | unsigned int filter_flags, |
| 214 | unsigned int changed_flags) |
| 215 | { |
| 216 | might_sleep(); |
| 217 | |
| 218 | trace_drv_config_iface_filter(local, sdata, filter_flags, |
| 219 | changed_flags); |
| 220 | if (local->ops->config_iface_filter) |
| 221 | local->ops->config_iface_filter(&local->hw, &sdata->vif, |
| 222 | filter_flags, |
| 223 | changed_flags); |
| 224 | trace_drv_return_void(local); |
| 225 | } |
| 226 | |
| 227 | static inline int drv_set_tim(struct ieee80211_local *local, |
| 228 | struct ieee80211_sta *sta, bool set) |
| 229 | { |
| 230 | int ret = 0; |
| 231 | trace_drv_set_tim(local, sta, set); |
| 232 | if (local->ops->set_tim) |
| 233 | ret = local->ops->set_tim(&local->hw, sta, set); |
| 234 | trace_drv_return_int(local, ret); |
| 235 | return ret; |
| 236 | } |
| 237 | |
| 238 | static inline int drv_set_key(struct ieee80211_local *local, |
| 239 | enum set_key_cmd cmd, |
| 240 | struct ieee80211_sub_if_data *sdata, |
| 241 | struct ieee80211_sta *sta, |
| 242 | struct ieee80211_key_conf *key) |
| 243 | { |
| 244 | int ret; |
| 245 | |
| 246 | might_sleep(); |
| 247 | |
| 248 | sdata = get_bss_sdata(sdata); |
| 249 | if (!check_sdata_in_driver(sdata)) |
| 250 | return -EIO; |
| 251 | |
| 252 | trace_drv_set_key(local, cmd, sdata, sta, key); |
| 253 | ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key); |
| 254 | trace_drv_return_int(local, ret); |
| 255 | return ret; |
| 256 | } |
| 257 | |
| 258 | static inline void drv_update_tkip_key(struct ieee80211_local *local, |
| 259 | struct ieee80211_sub_if_data *sdata, |
| 260 | struct ieee80211_key_conf *conf, |
| 261 | struct sta_info *sta, u32 iv32, |
| 262 | u16 *phase1key) |
| 263 | { |
| 264 | struct ieee80211_sta *ista = NULL; |
| 265 | |
| 266 | if (sta) |
| 267 | ista = &sta->sta; |
| 268 | |
| 269 | sdata = get_bss_sdata(sdata); |
| 270 | if (!check_sdata_in_driver(sdata)) |
| 271 | return; |
| 272 | |
| 273 | trace_drv_update_tkip_key(local, sdata, conf, ista, iv32); |
| 274 | if (local->ops->update_tkip_key) |
| 275 | local->ops->update_tkip_key(&local->hw, &sdata->vif, conf, |
| 276 | ista, iv32, phase1key); |
| 277 | trace_drv_return_void(local); |
| 278 | } |
| 279 | |
| 280 | static inline int drv_hw_scan(struct ieee80211_local *local, |
| 281 | struct ieee80211_sub_if_data *sdata, |
| 282 | struct ieee80211_scan_request *req) |
| 283 | { |
| 284 | int ret; |
| 285 | |
| 286 | might_sleep(); |
| 287 | |
| 288 | if (!check_sdata_in_driver(sdata)) |
| 289 | return -EIO; |
| 290 | |
| 291 | trace_drv_hw_scan(local, sdata); |
| 292 | ret = local->ops->hw_scan(&local->hw, &sdata->vif, req); |
| 293 | trace_drv_return_int(local, ret); |
| 294 | return ret; |
| 295 | } |
| 296 | |
| 297 | static inline void drv_cancel_hw_scan(struct ieee80211_local *local, |
| 298 | struct ieee80211_sub_if_data *sdata) |
| 299 | { |
| 300 | might_sleep(); |
| 301 | |
| 302 | if (!check_sdata_in_driver(sdata)) |
| 303 | return; |
| 304 | |
| 305 | trace_drv_cancel_hw_scan(local, sdata); |
| 306 | local->ops->cancel_hw_scan(&local->hw, &sdata->vif); |
| 307 | trace_drv_return_void(local); |
| 308 | } |
| 309 | |
| 310 | static inline int |
| 311 | drv_sched_scan_start(struct ieee80211_local *local, |
| 312 | struct ieee80211_sub_if_data *sdata, |
| 313 | struct cfg80211_sched_scan_request *req, |
| 314 | struct ieee80211_scan_ies *ies) |
| 315 | { |
| 316 | int ret; |
| 317 | |
| 318 | might_sleep(); |
| 319 | |
| 320 | if (!check_sdata_in_driver(sdata)) |
| 321 | return -EIO; |
| 322 | |
| 323 | trace_drv_sched_scan_start(local, sdata); |
| 324 | ret = local->ops->sched_scan_start(&local->hw, &sdata->vif, |
| 325 | req, ies); |
| 326 | trace_drv_return_int(local, ret); |
| 327 | return ret; |
| 328 | } |
| 329 | |
| 330 | static inline int drv_sched_scan_stop(struct ieee80211_local *local, |
| 331 | struct ieee80211_sub_if_data *sdata) |
| 332 | { |
| 333 | int ret; |
| 334 | |
| 335 | might_sleep(); |
| 336 | |
| 337 | if (!check_sdata_in_driver(sdata)) |
| 338 | return -EIO; |
| 339 | |
| 340 | trace_drv_sched_scan_stop(local, sdata); |
| 341 | ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif); |
| 342 | trace_drv_return_int(local, ret); |
| 343 | |
| 344 | return ret; |
| 345 | } |
| 346 | |
| 347 | static inline void drv_sw_scan_start(struct ieee80211_local *local, |
| 348 | struct ieee80211_sub_if_data *sdata, |
| 349 | const u8 *mac_addr) |
| 350 | { |
| 351 | might_sleep(); |
| 352 | |
| 353 | trace_drv_sw_scan_start(local, sdata, mac_addr); |
| 354 | if (local->ops->sw_scan_start) |
| 355 | local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr); |
| 356 | trace_drv_return_void(local); |
| 357 | } |
| 358 | |
| 359 | static inline void drv_sw_scan_complete(struct ieee80211_local *local, |
| 360 | struct ieee80211_sub_if_data *sdata) |
| 361 | { |
| 362 | might_sleep(); |
| 363 | |
| 364 | trace_drv_sw_scan_complete(local, sdata); |
| 365 | if (local->ops->sw_scan_complete) |
| 366 | local->ops->sw_scan_complete(&local->hw, &sdata->vif); |
| 367 | trace_drv_return_void(local); |
| 368 | } |
| 369 | |
| 370 | static inline int drv_get_stats(struct ieee80211_local *local, |
| 371 | struct ieee80211_low_level_stats *stats) |
| 372 | { |
| 373 | int ret = -EOPNOTSUPP; |
| 374 | |
| 375 | might_sleep(); |
| 376 | |
| 377 | if (local->ops->get_stats) |
| 378 | ret = local->ops->get_stats(&local->hw, stats); |
| 379 | trace_drv_get_stats(local, stats, ret); |
| 380 | |
| 381 | return ret; |
| 382 | } |
| 383 | |
| 384 | static inline void drv_get_key_seq(struct ieee80211_local *local, |
| 385 | struct ieee80211_key *key, |
| 386 | struct ieee80211_key_seq *seq) |
| 387 | { |
| 388 | if (local->ops->get_key_seq) |
| 389 | local->ops->get_key_seq(&local->hw, &key->conf, seq); |
| 390 | trace_drv_get_key_seq(local, &key->conf); |
| 391 | } |
| 392 | |
| 393 | static inline int drv_set_frag_threshold(struct ieee80211_local *local, |
| 394 | u32 value) |
| 395 | { |
| 396 | int ret = 0; |
| 397 | |
| 398 | might_sleep(); |
| 399 | |
| 400 | trace_drv_set_frag_threshold(local, value); |
| 401 | if (local->ops->set_frag_threshold) |
| 402 | ret = local->ops->set_frag_threshold(&local->hw, value); |
| 403 | trace_drv_return_int(local, ret); |
| 404 | return ret; |
| 405 | } |
| 406 | |
| 407 | static inline int drv_set_rts_threshold(struct ieee80211_local *local, |
| 408 | u32 value) |
| 409 | { |
| 410 | int ret = 0; |
| 411 | |
| 412 | might_sleep(); |
| 413 | |
| 414 | trace_drv_set_rts_threshold(local, value); |
| 415 | if (local->ops->set_rts_threshold) |
| 416 | ret = local->ops->set_rts_threshold(&local->hw, value); |
| 417 | trace_drv_return_int(local, ret); |
| 418 | return ret; |
| 419 | } |
| 420 | |
| 421 | static inline int drv_set_coverage_class(struct ieee80211_local *local, |
| 422 | s16 value) |
| 423 | { |
| 424 | int ret = 0; |
| 425 | might_sleep(); |
| 426 | |
| 427 | trace_drv_set_coverage_class(local, value); |
| 428 | if (local->ops->set_coverage_class) |
| 429 | local->ops->set_coverage_class(&local->hw, value); |
| 430 | else |
| 431 | ret = -EOPNOTSUPP; |
| 432 | |
| 433 | trace_drv_return_int(local, ret); |
| 434 | return ret; |
| 435 | } |
| 436 | |
| 437 | static inline void drv_sta_notify(struct ieee80211_local *local, |
| 438 | struct ieee80211_sub_if_data *sdata, |
| 439 | enum sta_notify_cmd cmd, |
| 440 | struct ieee80211_sta *sta) |
| 441 | { |
| 442 | sdata = get_bss_sdata(sdata); |
| 443 | if (!check_sdata_in_driver(sdata)) |
| 444 | return; |
| 445 | |
| 446 | trace_drv_sta_notify(local, sdata, cmd, sta); |
| 447 | if (local->ops->sta_notify) |
| 448 | local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta); |
| 449 | trace_drv_return_void(local); |
| 450 | } |
| 451 | |
| 452 | static inline int drv_sta_add(struct ieee80211_local *local, |
| 453 | struct ieee80211_sub_if_data *sdata, |
| 454 | struct ieee80211_sta *sta) |
| 455 | { |
| 456 | int ret = 0; |
| 457 | |
| 458 | might_sleep(); |
| 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 | |
| 479 | sdata = get_bss_sdata(sdata); |
| 480 | if (!check_sdata_in_driver(sdata)) |
| 481 | return; |
| 482 | |
| 483 | trace_drv_sta_remove(local, sdata, sta); |
| 484 | if (local->ops->sta_remove) |
| 485 | local->ops->sta_remove(&local->hw, &sdata->vif, sta); |
| 486 | |
| 487 | trace_drv_return_void(local); |
| 488 | } |
| 489 | |
| 490 | #ifdef CONFIG_MAC80211_DEBUGFS |
| 491 | static inline void drv_sta_add_debugfs(struct ieee80211_local *local, |
| 492 | struct ieee80211_sub_if_data *sdata, |
| 493 | struct ieee80211_sta *sta, |
| 494 | struct dentry *dir) |
| 495 | { |
| 496 | might_sleep(); |
| 497 | |
| 498 | sdata = get_bss_sdata(sdata); |
| 499 | if (!check_sdata_in_driver(sdata)) |
| 500 | return; |
| 501 | |
| 502 | if (local->ops->sta_add_debugfs) |
| 503 | local->ops->sta_add_debugfs(&local->hw, &sdata->vif, |
| 504 | sta, dir); |
| 505 | } |
| 506 | #endif |
| 507 | |
| 508 | static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local, |
| 509 | struct ieee80211_sub_if_data *sdata, |
| 510 | struct sta_info *sta) |
| 511 | { |
| 512 | might_sleep(); |
| 513 | |
| 514 | sdata = get_bss_sdata(sdata); |
| 515 | if (!check_sdata_in_driver(sdata)) |
| 516 | return; |
| 517 | |
| 518 | trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta); |
| 519 | if (local->ops->sta_pre_rcu_remove) |
| 520 | local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif, |
| 521 | &sta->sta); |
| 522 | trace_drv_return_void(local); |
| 523 | } |
| 524 | |
| 525 | __must_check |
| 526 | int drv_sta_state(struct ieee80211_local *local, |
| 527 | struct ieee80211_sub_if_data *sdata, |
| 528 | struct sta_info *sta, |
| 529 | enum ieee80211_sta_state old_state, |
| 530 | enum ieee80211_sta_state new_state); |
| 531 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 532 | __must_check |
| 533 | int drv_sta_set_txpwr(struct ieee80211_local *local, |
| 534 | struct ieee80211_sub_if_data *sdata, |
| 535 | struct sta_info *sta); |
| 536 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 537 | void drv_sta_rc_update(struct ieee80211_local *local, |
| 538 | struct ieee80211_sub_if_data *sdata, |
| 539 | struct ieee80211_sta *sta, u32 changed); |
| 540 | |
| 541 | static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local, |
| 542 | struct ieee80211_sub_if_data *sdata, |
| 543 | struct ieee80211_sta *sta) |
| 544 | { |
| 545 | sdata = get_bss_sdata(sdata); |
| 546 | if (!check_sdata_in_driver(sdata)) |
| 547 | return; |
| 548 | |
| 549 | trace_drv_sta_rate_tbl_update(local, sdata, sta); |
| 550 | if (local->ops->sta_rate_tbl_update) |
| 551 | local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta); |
| 552 | |
| 553 | trace_drv_return_void(local); |
| 554 | } |
| 555 | |
| 556 | static inline void drv_sta_statistics(struct ieee80211_local *local, |
| 557 | struct ieee80211_sub_if_data *sdata, |
| 558 | struct ieee80211_sta *sta, |
| 559 | struct station_info *sinfo) |
| 560 | { |
| 561 | sdata = get_bss_sdata(sdata); |
| 562 | if (!check_sdata_in_driver(sdata)) |
| 563 | return; |
| 564 | |
| 565 | trace_drv_sta_statistics(local, sdata, sta); |
| 566 | if (local->ops->sta_statistics) |
| 567 | local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo); |
| 568 | trace_drv_return_void(local); |
| 569 | } |
| 570 | |
| 571 | int drv_conf_tx(struct ieee80211_local *local, |
| 572 | struct ieee80211_sub_if_data *sdata, u16 ac, |
| 573 | const struct ieee80211_tx_queue_params *params); |
| 574 | |
| 575 | u64 drv_get_tsf(struct ieee80211_local *local, |
| 576 | struct ieee80211_sub_if_data *sdata); |
| 577 | void drv_set_tsf(struct ieee80211_local *local, |
| 578 | struct ieee80211_sub_if_data *sdata, |
| 579 | u64 tsf); |
| 580 | void drv_offset_tsf(struct ieee80211_local *local, |
| 581 | struct ieee80211_sub_if_data *sdata, |
| 582 | s64 offset); |
| 583 | void drv_reset_tsf(struct ieee80211_local *local, |
| 584 | struct ieee80211_sub_if_data *sdata); |
| 585 | |
| 586 | static inline int drv_tx_last_beacon(struct ieee80211_local *local) |
| 587 | { |
| 588 | int ret = 0; /* default unsupported op for less congestion */ |
| 589 | |
| 590 | might_sleep(); |
| 591 | |
| 592 | trace_drv_tx_last_beacon(local); |
| 593 | if (local->ops->tx_last_beacon) |
| 594 | ret = local->ops->tx_last_beacon(&local->hw); |
| 595 | trace_drv_return_int(local, ret); |
| 596 | return ret; |
| 597 | } |
| 598 | |
| 599 | int drv_ampdu_action(struct ieee80211_local *local, |
| 600 | struct ieee80211_sub_if_data *sdata, |
| 601 | struct ieee80211_ampdu_params *params); |
| 602 | |
| 603 | static inline int drv_get_survey(struct ieee80211_local *local, int idx, |
| 604 | struct survey_info *survey) |
| 605 | { |
| 606 | int ret = -EOPNOTSUPP; |
| 607 | |
| 608 | trace_drv_get_survey(local, idx, survey); |
| 609 | |
| 610 | if (local->ops->get_survey) |
| 611 | ret = local->ops->get_survey(&local->hw, idx, survey); |
| 612 | |
| 613 | trace_drv_return_int(local, ret); |
| 614 | |
| 615 | return ret; |
| 616 | } |
| 617 | |
| 618 | static inline void drv_rfkill_poll(struct ieee80211_local *local) |
| 619 | { |
| 620 | might_sleep(); |
| 621 | |
| 622 | if (local->ops->rfkill_poll) |
| 623 | local->ops->rfkill_poll(&local->hw); |
| 624 | } |
| 625 | |
| 626 | static inline void drv_flush(struct ieee80211_local *local, |
| 627 | struct ieee80211_sub_if_data *sdata, |
| 628 | u32 queues, bool drop) |
| 629 | { |
| 630 | struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL; |
| 631 | |
| 632 | might_sleep(); |
| 633 | |
| 634 | if (sdata && !check_sdata_in_driver(sdata)) |
| 635 | return; |
| 636 | |
| 637 | trace_drv_flush(local, queues, drop); |
| 638 | if (local->ops->flush) |
| 639 | local->ops->flush(&local->hw, vif, queues, drop); |
| 640 | trace_drv_return_void(local); |
| 641 | } |
| 642 | |
| 643 | static inline void drv_channel_switch(struct ieee80211_local *local, |
| 644 | struct ieee80211_sub_if_data *sdata, |
| 645 | struct ieee80211_channel_switch *ch_switch) |
| 646 | { |
| 647 | might_sleep(); |
| 648 | |
| 649 | trace_drv_channel_switch(local, sdata, ch_switch); |
| 650 | local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch); |
| 651 | trace_drv_return_void(local); |
| 652 | } |
| 653 | |
| 654 | |
| 655 | static inline int drv_set_antenna(struct ieee80211_local *local, |
| 656 | u32 tx_ant, u32 rx_ant) |
| 657 | { |
| 658 | int ret = -EOPNOTSUPP; |
| 659 | might_sleep(); |
| 660 | if (local->ops->set_antenna) |
| 661 | ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant); |
| 662 | trace_drv_set_antenna(local, tx_ant, rx_ant, ret); |
| 663 | return ret; |
| 664 | } |
| 665 | |
| 666 | static inline int drv_get_antenna(struct ieee80211_local *local, |
| 667 | u32 *tx_ant, u32 *rx_ant) |
| 668 | { |
| 669 | int ret = -EOPNOTSUPP; |
| 670 | might_sleep(); |
| 671 | if (local->ops->get_antenna) |
| 672 | ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant); |
| 673 | trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret); |
| 674 | return ret; |
| 675 | } |
| 676 | |
| 677 | static inline int drv_remain_on_channel(struct ieee80211_local *local, |
| 678 | struct ieee80211_sub_if_data *sdata, |
| 679 | struct ieee80211_channel *chan, |
| 680 | unsigned int duration, |
| 681 | enum ieee80211_roc_type type) |
| 682 | { |
| 683 | int ret; |
| 684 | |
| 685 | might_sleep(); |
| 686 | |
| 687 | trace_drv_remain_on_channel(local, sdata, chan, duration, type); |
| 688 | ret = local->ops->remain_on_channel(&local->hw, &sdata->vif, |
| 689 | chan, duration, type); |
| 690 | trace_drv_return_int(local, ret); |
| 691 | |
| 692 | return ret; |
| 693 | } |
| 694 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 695 | static inline int |
| 696 | drv_cancel_remain_on_channel(struct ieee80211_local *local, |
| 697 | struct ieee80211_sub_if_data *sdata) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 698 | { |
| 699 | int ret; |
| 700 | |
| 701 | might_sleep(); |
| 702 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 703 | trace_drv_cancel_remain_on_channel(local, sdata); |
| 704 | ret = local->ops->cancel_remain_on_channel(&local->hw, &sdata->vif); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 705 | trace_drv_return_int(local, ret); |
| 706 | |
| 707 | return ret; |
| 708 | } |
| 709 | |
| 710 | static inline int drv_set_ringparam(struct ieee80211_local *local, |
| 711 | u32 tx, u32 rx) |
| 712 | { |
| 713 | int ret = -ENOTSUPP; |
| 714 | |
| 715 | might_sleep(); |
| 716 | |
| 717 | trace_drv_set_ringparam(local, tx, rx); |
| 718 | if (local->ops->set_ringparam) |
| 719 | ret = local->ops->set_ringparam(&local->hw, tx, rx); |
| 720 | trace_drv_return_int(local, ret); |
| 721 | |
| 722 | return ret; |
| 723 | } |
| 724 | |
| 725 | static inline void drv_get_ringparam(struct ieee80211_local *local, |
| 726 | u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max) |
| 727 | { |
| 728 | might_sleep(); |
| 729 | |
| 730 | trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max); |
| 731 | if (local->ops->get_ringparam) |
| 732 | local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max); |
| 733 | trace_drv_return_void(local); |
| 734 | } |
| 735 | |
| 736 | static inline bool drv_tx_frames_pending(struct ieee80211_local *local) |
| 737 | { |
| 738 | bool ret = false; |
| 739 | |
| 740 | might_sleep(); |
| 741 | |
| 742 | trace_drv_tx_frames_pending(local); |
| 743 | if (local->ops->tx_frames_pending) |
| 744 | ret = local->ops->tx_frames_pending(&local->hw); |
| 745 | trace_drv_return_bool(local, ret); |
| 746 | |
| 747 | return ret; |
| 748 | } |
| 749 | |
| 750 | static inline int drv_set_bitrate_mask(struct ieee80211_local *local, |
| 751 | struct ieee80211_sub_if_data *sdata, |
| 752 | const struct cfg80211_bitrate_mask *mask) |
| 753 | { |
| 754 | int ret = -EOPNOTSUPP; |
| 755 | |
| 756 | might_sleep(); |
| 757 | |
| 758 | if (!check_sdata_in_driver(sdata)) |
| 759 | return -EIO; |
| 760 | |
| 761 | trace_drv_set_bitrate_mask(local, sdata, mask); |
| 762 | if (local->ops->set_bitrate_mask) |
| 763 | ret = local->ops->set_bitrate_mask(&local->hw, |
| 764 | &sdata->vif, mask); |
| 765 | trace_drv_return_int(local, ret); |
| 766 | |
| 767 | return ret; |
| 768 | } |
| 769 | |
| 770 | static inline void drv_set_rekey_data(struct ieee80211_local *local, |
| 771 | struct ieee80211_sub_if_data *sdata, |
| 772 | struct cfg80211_gtk_rekey_data *data) |
| 773 | { |
| 774 | if (!check_sdata_in_driver(sdata)) |
| 775 | return; |
| 776 | |
| 777 | trace_drv_set_rekey_data(local, sdata, data); |
| 778 | if (local->ops->set_rekey_data) |
| 779 | local->ops->set_rekey_data(&local->hw, &sdata->vif, data); |
| 780 | trace_drv_return_void(local); |
| 781 | } |
| 782 | |
| 783 | static inline void drv_event_callback(struct ieee80211_local *local, |
| 784 | struct ieee80211_sub_if_data *sdata, |
| 785 | const struct ieee80211_event *event) |
| 786 | { |
| 787 | trace_drv_event_callback(local, sdata, event); |
| 788 | if (local->ops->event_callback) |
| 789 | local->ops->event_callback(&local->hw, &sdata->vif, event); |
| 790 | trace_drv_return_void(local); |
| 791 | } |
| 792 | |
| 793 | static inline void |
| 794 | drv_release_buffered_frames(struct ieee80211_local *local, |
| 795 | struct sta_info *sta, u16 tids, int num_frames, |
| 796 | enum ieee80211_frame_release_type reason, |
| 797 | bool more_data) |
| 798 | { |
| 799 | trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames, |
| 800 | reason, more_data); |
| 801 | if (local->ops->release_buffered_frames) |
| 802 | local->ops->release_buffered_frames(&local->hw, &sta->sta, tids, |
| 803 | num_frames, reason, |
| 804 | more_data); |
| 805 | trace_drv_return_void(local); |
| 806 | } |
| 807 | |
| 808 | static inline void |
| 809 | drv_allow_buffered_frames(struct ieee80211_local *local, |
| 810 | struct sta_info *sta, u16 tids, int num_frames, |
| 811 | enum ieee80211_frame_release_type reason, |
| 812 | bool more_data) |
| 813 | { |
| 814 | trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames, |
| 815 | reason, more_data); |
| 816 | if (local->ops->allow_buffered_frames) |
| 817 | local->ops->allow_buffered_frames(&local->hw, &sta->sta, |
| 818 | tids, num_frames, reason, |
| 819 | more_data); |
| 820 | trace_drv_return_void(local); |
| 821 | } |
| 822 | |
| 823 | static inline void drv_mgd_prepare_tx(struct ieee80211_local *local, |
| 824 | struct ieee80211_sub_if_data *sdata, |
| 825 | u16 duration) |
| 826 | { |
| 827 | might_sleep(); |
| 828 | |
| 829 | if (!check_sdata_in_driver(sdata)) |
| 830 | return; |
| 831 | WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION); |
| 832 | |
| 833 | trace_drv_mgd_prepare_tx(local, sdata, duration); |
| 834 | if (local->ops->mgd_prepare_tx) |
| 835 | local->ops->mgd_prepare_tx(&local->hw, &sdata->vif, duration); |
| 836 | trace_drv_return_void(local); |
| 837 | } |
| 838 | |
| 839 | static inline void |
| 840 | drv_mgd_protect_tdls_discover(struct ieee80211_local *local, |
| 841 | struct ieee80211_sub_if_data *sdata) |
| 842 | { |
| 843 | might_sleep(); |
| 844 | |
| 845 | if (!check_sdata_in_driver(sdata)) |
| 846 | return; |
| 847 | WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION); |
| 848 | |
| 849 | trace_drv_mgd_protect_tdls_discover(local, sdata); |
| 850 | if (local->ops->mgd_protect_tdls_discover) |
| 851 | local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif); |
| 852 | trace_drv_return_void(local); |
| 853 | } |
| 854 | |
| 855 | static inline int drv_add_chanctx(struct ieee80211_local *local, |
| 856 | struct ieee80211_chanctx *ctx) |
| 857 | { |
| 858 | int ret = -EOPNOTSUPP; |
| 859 | |
| 860 | might_sleep(); |
| 861 | |
| 862 | trace_drv_add_chanctx(local, ctx); |
| 863 | if (local->ops->add_chanctx) |
| 864 | ret = local->ops->add_chanctx(&local->hw, &ctx->conf); |
| 865 | trace_drv_return_int(local, ret); |
| 866 | if (!ret) |
| 867 | ctx->driver_present = true; |
| 868 | |
| 869 | return ret; |
| 870 | } |
| 871 | |
| 872 | static inline void drv_remove_chanctx(struct ieee80211_local *local, |
| 873 | struct ieee80211_chanctx *ctx) |
| 874 | { |
| 875 | might_sleep(); |
| 876 | |
| 877 | if (WARN_ON(!ctx->driver_present)) |
| 878 | return; |
| 879 | |
| 880 | trace_drv_remove_chanctx(local, ctx); |
| 881 | if (local->ops->remove_chanctx) |
| 882 | local->ops->remove_chanctx(&local->hw, &ctx->conf); |
| 883 | trace_drv_return_void(local); |
| 884 | ctx->driver_present = false; |
| 885 | } |
| 886 | |
| 887 | static inline void drv_change_chanctx(struct ieee80211_local *local, |
| 888 | struct ieee80211_chanctx *ctx, |
| 889 | u32 changed) |
| 890 | { |
| 891 | might_sleep(); |
| 892 | |
| 893 | trace_drv_change_chanctx(local, ctx, changed); |
| 894 | if (local->ops->change_chanctx) { |
| 895 | WARN_ON_ONCE(!ctx->driver_present); |
| 896 | local->ops->change_chanctx(&local->hw, &ctx->conf, changed); |
| 897 | } |
| 898 | trace_drv_return_void(local); |
| 899 | } |
| 900 | |
| 901 | static inline int drv_assign_vif_chanctx(struct ieee80211_local *local, |
| 902 | struct ieee80211_sub_if_data *sdata, |
| 903 | struct ieee80211_chanctx *ctx) |
| 904 | { |
| 905 | int ret = 0; |
| 906 | |
| 907 | if (!check_sdata_in_driver(sdata)) |
| 908 | return -EIO; |
| 909 | |
| 910 | trace_drv_assign_vif_chanctx(local, sdata, ctx); |
| 911 | if (local->ops->assign_vif_chanctx) { |
| 912 | WARN_ON_ONCE(!ctx->driver_present); |
| 913 | ret = local->ops->assign_vif_chanctx(&local->hw, |
| 914 | &sdata->vif, |
| 915 | &ctx->conf); |
| 916 | } |
| 917 | trace_drv_return_int(local, ret); |
| 918 | |
| 919 | return ret; |
| 920 | } |
| 921 | |
| 922 | static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local, |
| 923 | struct ieee80211_sub_if_data *sdata, |
| 924 | struct ieee80211_chanctx *ctx) |
| 925 | { |
| 926 | might_sleep(); |
| 927 | |
| 928 | if (!check_sdata_in_driver(sdata)) |
| 929 | return; |
| 930 | |
| 931 | trace_drv_unassign_vif_chanctx(local, sdata, ctx); |
| 932 | if (local->ops->unassign_vif_chanctx) { |
| 933 | WARN_ON_ONCE(!ctx->driver_present); |
| 934 | local->ops->unassign_vif_chanctx(&local->hw, |
| 935 | &sdata->vif, |
| 936 | &ctx->conf); |
| 937 | } |
| 938 | trace_drv_return_void(local); |
| 939 | } |
| 940 | |
| 941 | int drv_switch_vif_chanctx(struct ieee80211_local *local, |
| 942 | struct ieee80211_vif_chanctx_switch *vifs, |
| 943 | int n_vifs, enum ieee80211_chanctx_switch_mode mode); |
| 944 | |
| 945 | static inline int drv_start_ap(struct ieee80211_local *local, |
| 946 | struct ieee80211_sub_if_data *sdata) |
| 947 | { |
| 948 | int ret = 0; |
| 949 | |
| 950 | might_sleep(); |
| 951 | |
| 952 | if (!check_sdata_in_driver(sdata)) |
| 953 | return -EIO; |
| 954 | |
| 955 | trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf); |
| 956 | if (local->ops->start_ap) |
| 957 | ret = local->ops->start_ap(&local->hw, &sdata->vif); |
| 958 | trace_drv_return_int(local, ret); |
| 959 | return ret; |
| 960 | } |
| 961 | |
| 962 | static inline void drv_stop_ap(struct ieee80211_local *local, |
| 963 | struct ieee80211_sub_if_data *sdata) |
| 964 | { |
| 965 | if (!check_sdata_in_driver(sdata)) |
| 966 | return; |
| 967 | |
| 968 | trace_drv_stop_ap(local, sdata); |
| 969 | if (local->ops->stop_ap) |
| 970 | local->ops->stop_ap(&local->hw, &sdata->vif); |
| 971 | trace_drv_return_void(local); |
| 972 | } |
| 973 | |
| 974 | static inline void |
| 975 | drv_reconfig_complete(struct ieee80211_local *local, |
| 976 | enum ieee80211_reconfig_type reconfig_type) |
| 977 | { |
| 978 | might_sleep(); |
| 979 | |
| 980 | trace_drv_reconfig_complete(local, reconfig_type); |
| 981 | if (local->ops->reconfig_complete) |
| 982 | local->ops->reconfig_complete(&local->hw, reconfig_type); |
| 983 | trace_drv_return_void(local); |
| 984 | } |
| 985 | |
| 986 | static inline void |
| 987 | drv_set_default_unicast_key(struct ieee80211_local *local, |
| 988 | struct ieee80211_sub_if_data *sdata, |
| 989 | int key_idx) |
| 990 | { |
| 991 | if (!check_sdata_in_driver(sdata)) |
| 992 | return; |
| 993 | |
| 994 | WARN_ON_ONCE(key_idx < -1 || key_idx > 3); |
| 995 | |
| 996 | trace_drv_set_default_unicast_key(local, sdata, key_idx); |
| 997 | if (local->ops->set_default_unicast_key) |
| 998 | local->ops->set_default_unicast_key(&local->hw, &sdata->vif, |
| 999 | key_idx); |
| 1000 | trace_drv_return_void(local); |
| 1001 | } |
| 1002 | |
| 1003 | #if IS_ENABLED(CONFIG_IPV6) |
| 1004 | static inline void drv_ipv6_addr_change(struct ieee80211_local *local, |
| 1005 | struct ieee80211_sub_if_data *sdata, |
| 1006 | struct inet6_dev *idev) |
| 1007 | { |
| 1008 | trace_drv_ipv6_addr_change(local, sdata); |
| 1009 | if (local->ops->ipv6_addr_change) |
| 1010 | local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev); |
| 1011 | trace_drv_return_void(local); |
| 1012 | } |
| 1013 | #endif |
| 1014 | |
| 1015 | static inline void |
| 1016 | drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata, |
| 1017 | struct cfg80211_chan_def *chandef) |
| 1018 | { |
| 1019 | struct ieee80211_local *local = sdata->local; |
| 1020 | |
| 1021 | if (local->ops->channel_switch_beacon) { |
| 1022 | trace_drv_channel_switch_beacon(local, sdata, chandef); |
| 1023 | local->ops->channel_switch_beacon(&local->hw, &sdata->vif, |
| 1024 | chandef); |
| 1025 | } |
| 1026 | } |
| 1027 | |
| 1028 | static inline int |
| 1029 | drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata, |
| 1030 | struct ieee80211_channel_switch *ch_switch) |
| 1031 | { |
| 1032 | struct ieee80211_local *local = sdata->local; |
| 1033 | int ret = 0; |
| 1034 | |
| 1035 | if (!check_sdata_in_driver(sdata)) |
| 1036 | return -EIO; |
| 1037 | |
| 1038 | trace_drv_pre_channel_switch(local, sdata, ch_switch); |
| 1039 | if (local->ops->pre_channel_switch) |
| 1040 | ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif, |
| 1041 | ch_switch); |
| 1042 | trace_drv_return_int(local, ret); |
| 1043 | return ret; |
| 1044 | } |
| 1045 | |
| 1046 | static inline int |
| 1047 | drv_post_channel_switch(struct ieee80211_sub_if_data *sdata) |
| 1048 | { |
| 1049 | struct ieee80211_local *local = sdata->local; |
| 1050 | int ret = 0; |
| 1051 | |
| 1052 | if (!check_sdata_in_driver(sdata)) |
| 1053 | return -EIO; |
| 1054 | |
| 1055 | trace_drv_post_channel_switch(local, sdata); |
| 1056 | if (local->ops->post_channel_switch) |
| 1057 | ret = local->ops->post_channel_switch(&local->hw, &sdata->vif); |
| 1058 | trace_drv_return_int(local, ret); |
| 1059 | return ret; |
| 1060 | } |
| 1061 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 1062 | static inline void |
| 1063 | drv_abort_channel_switch(struct ieee80211_sub_if_data *sdata) |
| 1064 | { |
| 1065 | struct ieee80211_local *local = sdata->local; |
| 1066 | |
| 1067 | if (!check_sdata_in_driver(sdata)) |
| 1068 | return; |
| 1069 | |
| 1070 | trace_drv_abort_channel_switch(local, sdata); |
| 1071 | |
| 1072 | if (local->ops->abort_channel_switch) |
| 1073 | local->ops->abort_channel_switch(&local->hw, &sdata->vif); |
| 1074 | } |
| 1075 | |
| 1076 | static inline void |
| 1077 | drv_channel_switch_rx_beacon(struct ieee80211_sub_if_data *sdata, |
| 1078 | struct ieee80211_channel_switch *ch_switch) |
| 1079 | { |
| 1080 | struct ieee80211_local *local = sdata->local; |
| 1081 | |
| 1082 | if (!check_sdata_in_driver(sdata)) |
| 1083 | return; |
| 1084 | |
| 1085 | trace_drv_channel_switch_rx_beacon(local, sdata, ch_switch); |
| 1086 | if (local->ops->channel_switch_rx_beacon) |
| 1087 | local->ops->channel_switch_rx_beacon(&local->hw, &sdata->vif, |
| 1088 | ch_switch); |
| 1089 | } |
| 1090 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1091 | static inline int drv_join_ibss(struct ieee80211_local *local, |
| 1092 | struct ieee80211_sub_if_data *sdata) |
| 1093 | { |
| 1094 | int ret = 0; |
| 1095 | |
| 1096 | might_sleep(); |
| 1097 | if (!check_sdata_in_driver(sdata)) |
| 1098 | return -EIO; |
| 1099 | |
| 1100 | trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf); |
| 1101 | if (local->ops->join_ibss) |
| 1102 | ret = local->ops->join_ibss(&local->hw, &sdata->vif); |
| 1103 | trace_drv_return_int(local, ret); |
| 1104 | return ret; |
| 1105 | } |
| 1106 | |
| 1107 | static inline void drv_leave_ibss(struct ieee80211_local *local, |
| 1108 | struct ieee80211_sub_if_data *sdata) |
| 1109 | { |
| 1110 | might_sleep(); |
| 1111 | if (!check_sdata_in_driver(sdata)) |
| 1112 | return; |
| 1113 | |
| 1114 | trace_drv_leave_ibss(local, sdata); |
| 1115 | if (local->ops->leave_ibss) |
| 1116 | local->ops->leave_ibss(&local->hw, &sdata->vif); |
| 1117 | trace_drv_return_void(local); |
| 1118 | } |
| 1119 | |
| 1120 | static inline u32 drv_get_expected_throughput(struct ieee80211_local *local, |
| 1121 | struct sta_info *sta) |
| 1122 | { |
| 1123 | u32 ret = 0; |
| 1124 | |
| 1125 | trace_drv_get_expected_throughput(&sta->sta); |
| 1126 | if (local->ops->get_expected_throughput && sta->uploaded) |
| 1127 | ret = local->ops->get_expected_throughput(&local->hw, &sta->sta); |
| 1128 | trace_drv_return_u32(local, ret); |
| 1129 | |
| 1130 | return ret; |
| 1131 | } |
| 1132 | |
| 1133 | static inline int drv_get_txpower(struct ieee80211_local *local, |
| 1134 | struct ieee80211_sub_if_data *sdata, int *dbm) |
| 1135 | { |
| 1136 | int ret; |
| 1137 | |
| 1138 | if (!local->ops->get_txpower) |
| 1139 | return -EOPNOTSUPP; |
| 1140 | |
| 1141 | ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm); |
| 1142 | trace_drv_get_txpower(local, sdata, *dbm, ret); |
| 1143 | |
| 1144 | return ret; |
| 1145 | } |
| 1146 | |
| 1147 | static inline int |
| 1148 | drv_tdls_channel_switch(struct ieee80211_local *local, |
| 1149 | struct ieee80211_sub_if_data *sdata, |
| 1150 | struct ieee80211_sta *sta, u8 oper_class, |
| 1151 | struct cfg80211_chan_def *chandef, |
| 1152 | struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie) |
| 1153 | { |
| 1154 | int ret; |
| 1155 | |
| 1156 | might_sleep(); |
| 1157 | if (!check_sdata_in_driver(sdata)) |
| 1158 | return -EIO; |
| 1159 | |
| 1160 | if (!local->ops->tdls_channel_switch) |
| 1161 | return -EOPNOTSUPP; |
| 1162 | |
| 1163 | trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef); |
| 1164 | ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta, |
| 1165 | oper_class, chandef, tmpl_skb, |
| 1166 | ch_sw_tm_ie); |
| 1167 | trace_drv_return_int(local, ret); |
| 1168 | return ret; |
| 1169 | } |
| 1170 | |
| 1171 | static inline void |
| 1172 | drv_tdls_cancel_channel_switch(struct ieee80211_local *local, |
| 1173 | struct ieee80211_sub_if_data *sdata, |
| 1174 | struct ieee80211_sta *sta) |
| 1175 | { |
| 1176 | might_sleep(); |
| 1177 | if (!check_sdata_in_driver(sdata)) |
| 1178 | return; |
| 1179 | |
| 1180 | if (!local->ops->tdls_cancel_channel_switch) |
| 1181 | return; |
| 1182 | |
| 1183 | trace_drv_tdls_cancel_channel_switch(local, sdata, sta); |
| 1184 | local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta); |
| 1185 | trace_drv_return_void(local); |
| 1186 | } |
| 1187 | |
| 1188 | static inline void |
| 1189 | drv_tdls_recv_channel_switch(struct ieee80211_local *local, |
| 1190 | struct ieee80211_sub_if_data *sdata, |
| 1191 | struct ieee80211_tdls_ch_sw_params *params) |
| 1192 | { |
| 1193 | trace_drv_tdls_recv_channel_switch(local, sdata, params); |
| 1194 | if (local->ops->tdls_recv_channel_switch) |
| 1195 | local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif, |
| 1196 | params); |
| 1197 | trace_drv_return_void(local); |
| 1198 | } |
| 1199 | |
| 1200 | static inline void drv_wake_tx_queue(struct ieee80211_local *local, |
| 1201 | struct txq_info *txq) |
| 1202 | { |
| 1203 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif); |
| 1204 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 1205 | if (local->in_reconfig) |
| 1206 | return; |
| 1207 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1208 | if (!check_sdata_in_driver(sdata)) |
| 1209 | return; |
| 1210 | |
| 1211 | trace_drv_wake_tx_queue(local, sdata, txq); |
| 1212 | local->ops->wake_tx_queue(&local->hw, &txq->txq); |
| 1213 | } |
| 1214 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 1215 | static inline void schedule_and_wake_txq(struct ieee80211_local *local, |
| 1216 | struct txq_info *txqi) |
| 1217 | { |
| 1218 | ieee80211_schedule_txq(&local->hw, &txqi->txq); |
| 1219 | drv_wake_tx_queue(local, txqi); |
| 1220 | } |
| 1221 | |
| 1222 | static inline int drv_can_aggregate_in_amsdu(struct ieee80211_local *local, |
| 1223 | struct sk_buff *head, |
| 1224 | struct sk_buff *skb) |
| 1225 | { |
| 1226 | if (!local->ops->can_aggregate_in_amsdu) |
| 1227 | return true; |
| 1228 | |
| 1229 | return local->ops->can_aggregate_in_amsdu(&local->hw, head, skb); |
| 1230 | } |
| 1231 | |
| 1232 | static inline int |
| 1233 | drv_get_ftm_responder_stats(struct ieee80211_local *local, |
| 1234 | struct ieee80211_sub_if_data *sdata, |
| 1235 | struct cfg80211_ftm_responder_stats *ftm_stats) |
| 1236 | { |
| 1237 | u32 ret = -EOPNOTSUPP; |
| 1238 | |
| 1239 | if (local->ops->get_ftm_responder_stats) |
| 1240 | ret = local->ops->get_ftm_responder_stats(&local->hw, |
| 1241 | &sdata->vif, |
| 1242 | ftm_stats); |
| 1243 | trace_drv_get_ftm_responder_stats(local, sdata, ftm_stats); |
| 1244 | |
| 1245 | return ret; |
| 1246 | } |
| 1247 | |
| 1248 | static inline int drv_start_pmsr(struct ieee80211_local *local, |
| 1249 | struct ieee80211_sub_if_data *sdata, |
| 1250 | struct cfg80211_pmsr_request *request) |
| 1251 | { |
| 1252 | int ret = -EOPNOTSUPP; |
| 1253 | |
| 1254 | might_sleep(); |
| 1255 | if (!check_sdata_in_driver(sdata)) |
| 1256 | return -EIO; |
| 1257 | |
| 1258 | trace_drv_start_pmsr(local, sdata); |
| 1259 | |
| 1260 | if (local->ops->start_pmsr) |
| 1261 | ret = local->ops->start_pmsr(&local->hw, &sdata->vif, request); |
| 1262 | trace_drv_return_int(local, ret); |
| 1263 | |
| 1264 | return ret; |
| 1265 | } |
| 1266 | |
| 1267 | static inline void drv_abort_pmsr(struct ieee80211_local *local, |
| 1268 | struct ieee80211_sub_if_data *sdata, |
| 1269 | struct cfg80211_pmsr_request *request) |
| 1270 | { |
| 1271 | trace_drv_abort_pmsr(local, sdata); |
| 1272 | |
| 1273 | might_sleep(); |
| 1274 | if (!check_sdata_in_driver(sdata)) |
| 1275 | return; |
| 1276 | |
| 1277 | if (local->ops->abort_pmsr) |
| 1278 | local->ops->abort_pmsr(&local->hw, &sdata->vif, request); |
| 1279 | trace_drv_return_void(local); |
| 1280 | } |
| 1281 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1282 | static inline int drv_start_nan(struct ieee80211_local *local, |
| 1283 | struct ieee80211_sub_if_data *sdata, |
| 1284 | struct cfg80211_nan_conf *conf) |
| 1285 | { |
| 1286 | int ret; |
| 1287 | |
| 1288 | might_sleep(); |
| 1289 | check_sdata_in_driver(sdata); |
| 1290 | |
| 1291 | trace_drv_start_nan(local, sdata, conf); |
| 1292 | ret = local->ops->start_nan(&local->hw, &sdata->vif, conf); |
| 1293 | trace_drv_return_int(local, ret); |
| 1294 | return ret; |
| 1295 | } |
| 1296 | |
| 1297 | static inline void drv_stop_nan(struct ieee80211_local *local, |
| 1298 | struct ieee80211_sub_if_data *sdata) |
| 1299 | { |
| 1300 | might_sleep(); |
| 1301 | check_sdata_in_driver(sdata); |
| 1302 | |
| 1303 | trace_drv_stop_nan(local, sdata); |
| 1304 | local->ops->stop_nan(&local->hw, &sdata->vif); |
| 1305 | trace_drv_return_void(local); |
| 1306 | } |
| 1307 | |
| 1308 | static inline int drv_nan_change_conf(struct ieee80211_local *local, |
| 1309 | struct ieee80211_sub_if_data *sdata, |
| 1310 | struct cfg80211_nan_conf *conf, |
| 1311 | u32 changes) |
| 1312 | { |
| 1313 | int ret; |
| 1314 | |
| 1315 | might_sleep(); |
| 1316 | check_sdata_in_driver(sdata); |
| 1317 | |
| 1318 | if (!local->ops->nan_change_conf) |
| 1319 | return -EOPNOTSUPP; |
| 1320 | |
| 1321 | trace_drv_nan_change_conf(local, sdata, conf, changes); |
| 1322 | ret = local->ops->nan_change_conf(&local->hw, &sdata->vif, conf, |
| 1323 | changes); |
| 1324 | trace_drv_return_int(local, ret); |
| 1325 | |
| 1326 | return ret; |
| 1327 | } |
| 1328 | |
| 1329 | static inline int drv_add_nan_func(struct ieee80211_local *local, |
| 1330 | struct ieee80211_sub_if_data *sdata, |
| 1331 | const struct cfg80211_nan_func *nan_func) |
| 1332 | { |
| 1333 | int ret; |
| 1334 | |
| 1335 | might_sleep(); |
| 1336 | check_sdata_in_driver(sdata); |
| 1337 | |
| 1338 | if (!local->ops->add_nan_func) |
| 1339 | return -EOPNOTSUPP; |
| 1340 | |
| 1341 | trace_drv_add_nan_func(local, sdata, nan_func); |
| 1342 | ret = local->ops->add_nan_func(&local->hw, &sdata->vif, nan_func); |
| 1343 | trace_drv_return_int(local, ret); |
| 1344 | |
| 1345 | return ret; |
| 1346 | } |
| 1347 | |
| 1348 | static inline void drv_del_nan_func(struct ieee80211_local *local, |
| 1349 | struct ieee80211_sub_if_data *sdata, |
| 1350 | u8 instance_id) |
| 1351 | { |
| 1352 | might_sleep(); |
| 1353 | check_sdata_in_driver(sdata); |
| 1354 | |
| 1355 | trace_drv_del_nan_func(local, sdata, instance_id); |
| 1356 | if (local->ops->del_nan_func) |
| 1357 | local->ops->del_nan_func(&local->hw, &sdata->vif, instance_id); |
| 1358 | trace_drv_return_void(local); |
| 1359 | } |
| 1360 | |
| 1361 | #endif /* __MAC80211_DRIVER_OPS */ |