Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Sara Sharon | f59374e | 2016-03-02 23:46:14 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Portions of this file |
| 4 | * Copyright(c) 2016 Intel Deutschland GmbH |
Ilan Peer | d4e36e5 | 2018-04-20 13:49:25 +0300 | [diff] [blame] | 5 | * Copyright (C) 2018 Intel Corporation |
Sara Sharon | f59374e | 2016-03-02 23:46:14 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 8 | #ifndef __MAC80211_DRIVER_OPS |
| 9 | #define __MAC80211_DRIVER_OPS |
| 10 | |
| 11 | #include <net/mac80211.h> |
| 12 | #include "ieee80211_i.h" |
Johannes Berg | 011ad0e | 2012-06-22 12:55:52 +0200 | [diff] [blame] | 13 | #include "trace.h" |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 14 | |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 15 | static inline bool check_sdata_in_driver(struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 16 | { |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 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); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 20 | } |
| 21 | |
Felix Fietkau | bc192f8 | 2011-11-23 21:09:49 +0700 | [diff] [blame] | 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 | |
Thomas Huehn | 36323f8 | 2012-07-23 21:33:42 +0200 | [diff] [blame] | 32 | static inline void drv_tx(struct ieee80211_local *local, |
| 33 | struct ieee80211_tx_control *control, |
| 34 | struct sk_buff *skb) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 35 | { |
Thomas Huehn | 36323f8 | 2012-07-23 21:33:42 +0200 | [diff] [blame] | 36 | local->ops->tx(&local->hw, control, skb); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 37 | } |
| 38 | |
Sara Sharon | f59374e | 2016-03-02 23:46:14 +0200 | [diff] [blame] | 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 | |
Ben Greear | e352114 | 2012-04-23 12:50:31 -0700 | [diff] [blame] | 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 | |
Eliad Peller | 968a76c | 2015-10-25 10:59:36 +0200 | [diff] [blame] | 86 | int drv_start(struct ieee80211_local *local); |
| 87 | void drv_stop(struct ieee80211_local *local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 88 | |
Johannes Berg | eecc480 | 2011-05-04 15:37:29 +0200 | [diff] [blame] | 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 | } |
Johannes Berg | 6d52563 | 2012-04-04 15:05:25 +0200 | [diff] [blame] | 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 | } |
Johannes Berg | eecc480 | 2011-05-04 15:37:29 +0200 | [diff] [blame] | 127 | #endif |
| 128 | |
Denys Vlasenko | 9aae296 | 2015-09-18 15:19:38 +0200 | [diff] [blame] | 129 | int drv_add_interface(struct ieee80211_local *local, |
| 130 | struct ieee80211_sub_if_data *sdata); |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 131 | |
Denys Vlasenko | 9aae296 | 2015-09-18 15:19:38 +0200 | [diff] [blame] | 132 | int drv_change_interface(struct ieee80211_local *local, |
| 133 | struct ieee80211_sub_if_data *sdata, |
| 134 | enum nl80211_iftype type, bool p2p); |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 135 | |
Denys Vlasenko | 9aae296 | 2015-09-18 15:19:38 +0200 | [diff] [blame] | 136 | void drv_remove_interface(struct ieee80211_local *local, |
| 137 | struct ieee80211_sub_if_data *sdata); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 138 | |
| 139 | static inline int drv_config(struct ieee80211_local *local, u32 changed) |
| 140 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 141 | int ret; |
| 142 | |
| 143 | might_sleep(); |
| 144 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 145 | trace_drv_config(local, changed); |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 146 | ret = local->ops->config(&local->hw, changed); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 147 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 148 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | static inline void drv_bss_info_changed(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 152 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 153 | struct ieee80211_bss_conf *info, |
| 154 | u32 changed) |
| 155 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 156 | might_sleep(); |
| 157 | |
Johannes Berg | 5bbe754d | 2013-02-13 13:50:51 +0100 | [diff] [blame] | 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 && |
Rostislav Lisovy | 239281f | 2014-11-03 10:33:19 +0100 | [diff] [blame] | 162 | sdata->vif.type != NL80211_IFTYPE_MESH_POINT && |
| 163 | sdata->vif.type != NL80211_IFTYPE_OCB)) |
Johannes Berg | 5bbe754d | 2013-02-13 13:50:51 +0100 | [diff] [blame] | 164 | return; |
| 165 | |
| 166 | if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE || |
Ayala Beker | 708d50e | 2016-09-20 17:31:14 +0300 | [diff] [blame] | 167 | sdata->vif.type == NL80211_IFTYPE_NAN || |
Aviya Erenfeld | 42bd20d | 2016-08-29 23:25:16 +0300 | [diff] [blame] | 168 | (sdata->vif.type == NL80211_IFTYPE_MONITOR && |
Peter Große | 3a3713e | 2017-12-13 18:29:46 +0100 | [diff] [blame] | 169 | !sdata->vif.mu_mimo_owner && |
| 170 | !(changed & BSS_CHANGED_TXPOWER)))) |
Johannes Berg | 5bbe754d | 2013-02-13 13:50:51 +0100 | [diff] [blame] | 171 | return; |
Johannes Berg | b8dc1a3 | 2012-12-14 14:22:10 +0100 | [diff] [blame] | 172 | |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 173 | if (!check_sdata_in_driver(sdata)) |
| 174 | return; |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 175 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 176 | trace_drv_bss_info_changed(local, sdata, info, changed); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 177 | if (local->ops->bss_info_changed) |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 178 | local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 179 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 180 | } |
| 181 | |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 182 | static inline u64 drv_prepare_multicast(struct ieee80211_local *local, |
Jiri Pirko | 22bedad3 | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 183 | struct netdev_hw_addr_list *mc_list) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 184 | { |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 185 | u64 ret = 0; |
| 186 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 187 | trace_drv_prepare_multicast(local, mc_list->count); |
| 188 | |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 189 | if (local->ops->prepare_multicast) |
Jiri Pirko | 22bedad3 | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 190 | ret = local->ops->prepare_multicast(&local->hw, mc_list); |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 191 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 192 | trace_drv_return_u64(local, ret); |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 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 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 204 | trace_drv_configure_filter(local, changed_flags, total_flags, |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 205 | multicast); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 206 | local->ops->configure_filter(&local->hw, changed_flags, total_flags, |
| 207 | multicast); |
| 208 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 209 | } |
| 210 | |
Andrei Otcheretianski | 1b09b55 | 2015-08-15 22:39:50 +0300 | [diff] [blame] | 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 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 227 | static inline int drv_set_tim(struct ieee80211_local *local, |
| 228 | struct ieee80211_sta *sta, bool set) |
| 229 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 230 | int ret = 0; |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 231 | trace_drv_set_tim(local, sta, set); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 232 | if (local->ops->set_tim) |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 233 | ret = local->ops->set_tim(&local->hw, sta, set); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 234 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 235 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | static inline int drv_set_key(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 239 | enum set_key_cmd cmd, |
| 240 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 241 | struct ieee80211_sta *sta, |
| 242 | struct ieee80211_key_conf *key) |
| 243 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 244 | int ret; |
| 245 | |
| 246 | might_sleep(); |
| 247 | |
Johannes Berg | 077f493 | 2012-01-20 13:55:18 +0100 | [diff] [blame] | 248 | sdata = get_bss_sdata(sdata); |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 249 | if (!check_sdata_in_driver(sdata)) |
| 250 | return -EIO; |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 251 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 252 | trace_drv_set_key(local, cmd, sdata, sta, key); |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 253 | ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 254 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 255 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | static inline void drv_update_tkip_key(struct ieee80211_local *local, |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 259 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 260 | struct ieee80211_key_conf *conf, |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 261 | struct sta_info *sta, u32 iv32, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 262 | u16 *phase1key) |
| 263 | { |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 264 | struct ieee80211_sta *ista = NULL; |
| 265 | |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 266 | if (sta) |
| 267 | ista = &sta->sta; |
| 268 | |
Johannes Berg | 077f493 | 2012-01-20 13:55:18 +0100 | [diff] [blame] | 269 | sdata = get_bss_sdata(sdata); |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 270 | if (!check_sdata_in_driver(sdata)) |
| 271 | return; |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 272 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 273 | trace_drv_update_tkip_key(local, sdata, conf, ista, iv32); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 274 | if (local->ops->update_tkip_key) |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 275 | local->ops->update_tkip_key(&local->hw, &sdata->vif, conf, |
| 276 | ista, iv32, phase1key); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 277 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | static inline int drv_hw_scan(struct ieee80211_local *local, |
Johannes Berg | a060bbf | 2010-04-27 11:59:34 +0200 | [diff] [blame] | 281 | struct ieee80211_sub_if_data *sdata, |
David Spinadel | c56ef67 | 2014-02-05 15:21:13 +0200 | [diff] [blame] | 282 | struct ieee80211_scan_request *req) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 283 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 284 | int ret; |
| 285 | |
| 286 | might_sleep(); |
| 287 | |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 288 | if (!check_sdata_in_driver(sdata)) |
| 289 | return -EIO; |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 290 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 291 | trace_drv_hw_scan(local, sdata); |
Johannes Berg | a060bbf | 2010-04-27 11:59:34 +0200 | [diff] [blame] | 292 | ret = local->ops->hw_scan(&local->hw, &sdata->vif, req); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 293 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 294 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 295 | } |
| 296 | |
Eliad Peller | b856439 | 2011-06-13 12:47:30 +0300 | [diff] [blame] | 297 | static inline void drv_cancel_hw_scan(struct ieee80211_local *local, |
| 298 | struct ieee80211_sub_if_data *sdata) |
| 299 | { |
| 300 | might_sleep(); |
| 301 | |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 302 | if (!check_sdata_in_driver(sdata)) |
| 303 | return; |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 304 | |
Eliad Peller | b856439 | 2011-06-13 12:47:30 +0300 | [diff] [blame] | 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 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 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, |
David Spinadel | 633e271 | 2014-02-06 16:15:23 +0200 | [diff] [blame] | 314 | struct ieee80211_scan_ies *ies) |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 315 | { |
| 316 | int ret; |
| 317 | |
| 318 | might_sleep(); |
| 319 | |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 320 | if (!check_sdata_in_driver(sdata)) |
| 321 | return -EIO; |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 322 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 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 | |
Johannes Berg | 37e3308 | 2014-02-17 10:48:17 +0100 | [diff] [blame] | 330 | static inline int drv_sched_scan_stop(struct ieee80211_local *local, |
| 331 | struct ieee80211_sub_if_data *sdata) |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 332 | { |
Johannes Berg | 37e3308 | 2014-02-17 10:48:17 +0100 | [diff] [blame] | 333 | int ret; |
| 334 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 335 | might_sleep(); |
| 336 | |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 337 | if (!check_sdata_in_driver(sdata)) |
| 338 | return -EIO; |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 339 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 340 | trace_drv_sched_scan_stop(local, sdata); |
Johannes Berg | 37e3308 | 2014-02-17 10:48:17 +0100 | [diff] [blame] | 341 | ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif); |
| 342 | trace_drv_return_int(local, ret); |
| 343 | |
| 344 | return ret; |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 345 | } |
| 346 | |
Johannes Berg | a344d67 | 2014-06-12 22:24:31 +0200 | [diff] [blame] | 347 | static inline void drv_sw_scan_start(struct ieee80211_local *local, |
| 348 | struct ieee80211_sub_if_data *sdata, |
| 349 | const u8 *mac_addr) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 350 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 351 | might_sleep(); |
| 352 | |
Johannes Berg | a344d67 | 2014-06-12 22:24:31 +0200 | [diff] [blame] | 353 | trace_drv_sw_scan_start(local, sdata, mac_addr); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 354 | if (local->ops->sw_scan_start) |
Johannes Berg | a344d67 | 2014-06-12 22:24:31 +0200 | [diff] [blame] | 355 | local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 356 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 357 | } |
| 358 | |
Johannes Berg | a344d67 | 2014-06-12 22:24:31 +0200 | [diff] [blame] | 359 | static inline void drv_sw_scan_complete(struct ieee80211_local *local, |
| 360 | struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 361 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 362 | might_sleep(); |
| 363 | |
Johannes Berg | a344d67 | 2014-06-12 22:24:31 +0200 | [diff] [blame] | 364 | trace_drv_sw_scan_complete(local, sdata); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 365 | if (local->ops->sw_scan_complete) |
Johannes Berg | a344d67 | 2014-06-12 22:24:31 +0200 | [diff] [blame] | 366 | local->ops->sw_scan_complete(&local->hw, &sdata->vif); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 367 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | static inline int drv_get_stats(struct ieee80211_local *local, |
| 371 | struct ieee80211_low_level_stats *stats) |
| 372 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 373 | int ret = -EOPNOTSUPP; |
| 374 | |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 375 | might_sleep(); |
| 376 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 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; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 382 | } |
| 383 | |
Johannes Berg | 9352c19 | 2015-04-20 18:12:41 +0200 | [diff] [blame] | 384 | static inline void drv_get_key_seq(struct ieee80211_local *local, |
| 385 | struct ieee80211_key *key, |
| 386 | struct ieee80211_key_seq *seq) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 387 | { |
Johannes Berg | 9352c19 | 2015-04-20 18:12:41 +0200 | [diff] [blame] | 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); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 391 | } |
| 392 | |
Arik Nemtsov | f23a478 | 2010-11-08 11:51:06 +0200 | [diff] [blame] | 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 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 407 | static inline int drv_set_rts_threshold(struct ieee80211_local *local, |
| 408 | u32 value) |
| 409 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 410 | int ret = 0; |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 411 | |
| 412 | might_sleep(); |
| 413 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 414 | trace_drv_set_rts_threshold(local, value); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 415 | if (local->ops->set_rts_threshold) |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 416 | ret = local->ops->set_rts_threshold(&local->hw, value); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 417 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 418 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 419 | } |
| 420 | |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 421 | static inline int drv_set_coverage_class(struct ieee80211_local *local, |
Lorenzo Bianconi | a4bcaf5 | 2014-09-04 23:57:41 +0200 | [diff] [blame] | 422 | s16 value) |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 423 | { |
| 424 | int ret = 0; |
| 425 | might_sleep(); |
| 426 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 427 | trace_drv_set_coverage_class(local, value); |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 428 | if (local->ops->set_coverage_class) |
| 429 | local->ops->set_coverage_class(&local->hw, value); |
| 430 | else |
| 431 | ret = -EOPNOTSUPP; |
| 432 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 433 | trace_drv_return_int(local, ret); |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 434 | return ret; |
| 435 | } |
| 436 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 437 | static inline void drv_sta_notify(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 438 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 439 | enum sta_notify_cmd cmd, |
| 440 | struct ieee80211_sta *sta) |
| 441 | { |
Felix Fietkau | bc192f8 | 2011-11-23 21:09:49 +0700 | [diff] [blame] | 442 | sdata = get_bss_sdata(sdata); |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 443 | if (!check_sdata_in_driver(sdata)) |
| 444 | return; |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 445 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 446 | trace_drv_sta_notify(local, sdata, cmd, sta); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 447 | if (local->ops->sta_notify) |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 448 | local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 449 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 450 | } |
| 451 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 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 | |
Felix Fietkau | bc192f8 | 2011-11-23 21:09:49 +0700 | [diff] [blame] | 460 | sdata = get_bss_sdata(sdata); |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 461 | if (!check_sdata_in_driver(sdata)) |
| 462 | return -EIO; |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 463 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 464 | trace_drv_sta_add(local, sdata, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 465 | if (local->ops->sta_add) |
| 466 | ret = local->ops->sta_add(&local->hw, &sdata->vif, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 467 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 468 | trace_drv_return_int(local, ret); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 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 | |
Felix Fietkau | bc192f8 | 2011-11-23 21:09:49 +0700 | [diff] [blame] | 479 | sdata = get_bss_sdata(sdata); |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 480 | if (!check_sdata_in_driver(sdata)) |
| 481 | return; |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 482 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 483 | trace_drv_sta_remove(local, sdata, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 484 | if (local->ops->sta_remove) |
| 485 | local->ops->sta_remove(&local->hw, &sdata->vif, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 486 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 487 | trace_drv_return_void(local); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 488 | } |
| 489 | |
Sujith Manoharan | 77d2ece6 | 2012-11-20 08:46:02 +0530 | [diff] [blame] | 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); |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 499 | if (!check_sdata_in_driver(sdata)) |
| 500 | return; |
Sujith Manoharan | 77d2ece6 | 2012-11-20 08:46:02 +0530 | [diff] [blame] | 501 | |
| 502 | if (local->ops->sta_add_debugfs) |
| 503 | local->ops->sta_add_debugfs(&local->hw, &sdata->vif, |
| 504 | sta, dir); |
| 505 | } |
Sujith Manoharan | 77d2ece6 | 2012-11-20 08:46:02 +0530 | [diff] [blame] | 506 | #endif |
| 507 | |
Johannes Berg | 6a9d1b9 | 2013-12-04 22:39:17 +0100 | [diff] [blame] | 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); |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 515 | if (!check_sdata_in_driver(sdata)) |
| 516 | return; |
Johannes Berg | 6a9d1b9 | 2013-12-04 22:39:17 +0100 | [diff] [blame] | 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 | |
Denys Vlasenko | 727da60 | 2015-07-15 14:56:05 +0200 | [diff] [blame] | 525 | __must_check |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 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, |
Denys Vlasenko | 727da60 | 2015-07-15 14:56:05 +0200 | [diff] [blame] | 530 | enum ieee80211_sta_state new_state); |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 531 | |
Denys Vlasenko | 4fbd572 | 2015-09-18 15:19:35 +0200 | [diff] [blame] | 532 | void drv_sta_rc_update(struct ieee80211_local *local, |
| 533 | struct ieee80211_sub_if_data *sdata, |
| 534 | struct ieee80211_sta *sta, u32 changed); |
Johannes Berg | 8f727ef | 2012-03-30 08:43:32 +0200 | [diff] [blame] | 535 | |
Johannes Berg | f815e2b | 2014-11-19 00:10:42 +0100 | [diff] [blame] | 536 | static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local, |
| 537 | struct ieee80211_sub_if_data *sdata, |
| 538 | struct ieee80211_sta *sta) |
| 539 | { |
| 540 | sdata = get_bss_sdata(sdata); |
| 541 | if (!check_sdata_in_driver(sdata)) |
| 542 | return; |
| 543 | |
| 544 | trace_drv_sta_rate_tbl_update(local, sdata, sta); |
| 545 | if (local->ops->sta_rate_tbl_update) |
| 546 | local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta); |
| 547 | |
| 548 | trace_drv_return_void(local); |
| 549 | } |
| 550 | |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 551 | static inline void drv_sta_statistics(struct ieee80211_local *local, |
| 552 | struct ieee80211_sub_if_data *sdata, |
| 553 | struct ieee80211_sta *sta, |
| 554 | struct station_info *sinfo) |
| 555 | { |
| 556 | sdata = get_bss_sdata(sdata); |
| 557 | if (!check_sdata_in_driver(sdata)) |
| 558 | return; |
| 559 | |
| 560 | trace_drv_sta_statistics(local, sdata, sta); |
| 561 | if (local->ops->sta_statistics) |
| 562 | local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo); |
| 563 | trace_drv_return_void(local); |
| 564 | } |
| 565 | |
Denys Vlasenko | b23dcd4 | 2015-09-18 15:19:34 +0200 | [diff] [blame] | 566 | int drv_conf_tx(struct ieee80211_local *local, |
| 567 | struct ieee80211_sub_if_data *sdata, u16 ac, |
| 568 | const struct ieee80211_tx_queue_params *params); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 569 | |
Denys Vlasenko | 416eb9f | 2015-09-23 14:18:36 +0200 | [diff] [blame] | 570 | u64 drv_get_tsf(struct ieee80211_local *local, |
| 571 | struct ieee80211_sub_if_data *sdata); |
| 572 | void drv_set_tsf(struct ieee80211_local *local, |
| 573 | struct ieee80211_sub_if_data *sdata, |
| 574 | u64 tsf); |
Pedersen, Thomas | 354d381 | 2016-09-28 16:56:28 -0700 | [diff] [blame] | 575 | void drv_offset_tsf(struct ieee80211_local *local, |
| 576 | struct ieee80211_sub_if_data *sdata, |
| 577 | s64 offset); |
Denys Vlasenko | 416eb9f | 2015-09-23 14:18:36 +0200 | [diff] [blame] | 578 | void drv_reset_tsf(struct ieee80211_local *local, |
| 579 | struct ieee80211_sub_if_data *sdata); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 580 | |
| 581 | static inline int drv_tx_last_beacon(struct ieee80211_local *local) |
| 582 | { |
Masanari Iida | 02582e9 | 2012-08-22 19:11:26 +0900 | [diff] [blame] | 583 | int ret = 0; /* default unsupported op for less congestion */ |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 584 | |
| 585 | might_sleep(); |
| 586 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 587 | trace_drv_tx_last_beacon(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 588 | if (local->ops->tx_last_beacon) |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 589 | ret = local->ops->tx_last_beacon(&local->hw); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 590 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 591 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 592 | } |
| 593 | |
Denys Vlasenko | 6db9683 | 2015-09-23 14:18:35 +0200 | [diff] [blame] | 594 | int drv_ampdu_action(struct ieee80211_local *local, |
| 595 | struct ieee80211_sub_if_data *sdata, |
Sara Sharon | 50ea05e | 2015-12-30 16:06:04 +0200 | [diff] [blame] | 596 | struct ieee80211_ampdu_params *params); |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 597 | |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 598 | static inline int drv_get_survey(struct ieee80211_local *local, int idx, |
| 599 | struct survey_info *survey) |
| 600 | { |
| 601 | int ret = -EOPNOTSUPP; |
John W. Linville | c466d4e | 2010-06-29 14:51:23 -0400 | [diff] [blame] | 602 | |
| 603 | trace_drv_get_survey(local, idx, survey); |
| 604 | |
Holger Schurig | 35dd050 | 2010-06-07 16:33:49 +0200 | [diff] [blame] | 605 | if (local->ops->get_survey) |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 606 | ret = local->ops->get_survey(&local->hw, idx, survey); |
John W. Linville | c466d4e | 2010-06-29 14:51:23 -0400 | [diff] [blame] | 607 | |
| 608 | trace_drv_return_int(local, ret); |
| 609 | |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 610 | return ret; |
| 611 | } |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 612 | |
| 613 | static inline void drv_rfkill_poll(struct ieee80211_local *local) |
| 614 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 615 | might_sleep(); |
| 616 | |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 617 | if (local->ops->rfkill_poll) |
| 618 | local->ops->rfkill_poll(&local->hw); |
| 619 | } |
Johannes Berg | a80f7c0 | 2009-12-23 13:15:32 +0100 | [diff] [blame] | 620 | |
Johannes Berg | 39ecc01 | 2013-02-13 12:11:00 +0100 | [diff] [blame] | 621 | static inline void drv_flush(struct ieee80211_local *local, |
Emmanuel Grumbach | 77be2c5 | 2014-03-27 11:30:29 +0200 | [diff] [blame] | 622 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 39ecc01 | 2013-02-13 12:11:00 +0100 | [diff] [blame] | 623 | u32 queues, bool drop) |
Johannes Berg | a80f7c0 | 2009-12-23 13:15:32 +0100 | [diff] [blame] | 624 | { |
Emmanuel Grumbach | 77be2c5 | 2014-03-27 11:30:29 +0200 | [diff] [blame] | 625 | struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL; |
| 626 | |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 627 | might_sleep(); |
| 628 | |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 629 | if (sdata && !check_sdata_in_driver(sdata)) |
| 630 | return; |
Emmanuel Grumbach | 77be2c5 | 2014-03-27 11:30:29 +0200 | [diff] [blame] | 631 | |
Johannes Berg | 39ecc01 | 2013-02-13 12:11:00 +0100 | [diff] [blame] | 632 | trace_drv_flush(local, queues, drop); |
Johannes Berg | a80f7c0 | 2009-12-23 13:15:32 +0100 | [diff] [blame] | 633 | if (local->ops->flush) |
Emmanuel Grumbach | 77be2c5 | 2014-03-27 11:30:29 +0200 | [diff] [blame] | 634 | local->ops->flush(&local->hw, vif, queues, drop); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 635 | trace_drv_return_void(local); |
Johannes Berg | a80f7c0 | 2009-12-23 13:15:32 +0100 | [diff] [blame] | 636 | } |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 637 | |
| 638 | static inline void drv_channel_switch(struct ieee80211_local *local, |
Luciano Coelho | 0f791eb4 | 2014-10-08 09:48:40 +0300 | [diff] [blame] | 639 | struct ieee80211_sub_if_data *sdata, |
| 640 | struct ieee80211_channel_switch *ch_switch) |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 641 | { |
| 642 | might_sleep(); |
| 643 | |
Luciano Coelho | 0f791eb4 | 2014-10-08 09:48:40 +0300 | [diff] [blame] | 644 | trace_drv_channel_switch(local, sdata, ch_switch); |
| 645 | local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 646 | trace_drv_return_void(local); |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 647 | } |
| 648 | |
Bruno Randolf | 15d9675 | 2010-11-10 12:50:56 +0900 | [diff] [blame] | 649 | |
| 650 | static inline int drv_set_antenna(struct ieee80211_local *local, |
| 651 | u32 tx_ant, u32 rx_ant) |
| 652 | { |
| 653 | int ret = -EOPNOTSUPP; |
| 654 | might_sleep(); |
| 655 | if (local->ops->set_antenna) |
| 656 | ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant); |
| 657 | trace_drv_set_antenna(local, tx_ant, rx_ant, ret); |
| 658 | return ret; |
| 659 | } |
| 660 | |
| 661 | static inline int drv_get_antenna(struct ieee80211_local *local, |
| 662 | u32 *tx_ant, u32 *rx_ant) |
| 663 | { |
| 664 | int ret = -EOPNOTSUPP; |
| 665 | might_sleep(); |
| 666 | if (local->ops->get_antenna) |
| 667 | ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant); |
| 668 | trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret); |
| 669 | return ret; |
| 670 | } |
| 671 | |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 672 | static inline int drv_remain_on_channel(struct ieee80211_local *local, |
Eliad Peller | 4988456 | 2012-11-19 17:05:09 +0200 | [diff] [blame] | 673 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 674 | struct ieee80211_channel *chan, |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 675 | unsigned int duration, |
| 676 | enum ieee80211_roc_type type) |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 677 | { |
| 678 | int ret; |
| 679 | |
| 680 | might_sleep(); |
| 681 | |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 682 | trace_drv_remain_on_channel(local, sdata, chan, duration, type); |
Eliad Peller | 4988456 | 2012-11-19 17:05:09 +0200 | [diff] [blame] | 683 | ret = local->ops->remain_on_channel(&local->hw, &sdata->vif, |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 684 | chan, duration, type); |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 685 | trace_drv_return_int(local, ret); |
| 686 | |
| 687 | return ret; |
| 688 | } |
| 689 | |
| 690 | static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local) |
| 691 | { |
| 692 | int ret; |
| 693 | |
| 694 | might_sleep(); |
| 695 | |
| 696 | trace_drv_cancel_remain_on_channel(local); |
| 697 | ret = local->ops->cancel_remain_on_channel(&local->hw); |
| 698 | trace_drv_return_int(local, ret); |
| 699 | |
| 700 | return ret; |
| 701 | } |
| 702 | |
John W. Linville | 38c0915 | 2011-03-07 16:19:18 -0500 | [diff] [blame] | 703 | static inline int drv_set_ringparam(struct ieee80211_local *local, |
| 704 | u32 tx, u32 rx) |
| 705 | { |
| 706 | int ret = -ENOTSUPP; |
| 707 | |
| 708 | might_sleep(); |
| 709 | |
| 710 | trace_drv_set_ringparam(local, tx, rx); |
| 711 | if (local->ops->set_ringparam) |
| 712 | ret = local->ops->set_ringparam(&local->hw, tx, rx); |
| 713 | trace_drv_return_int(local, ret); |
| 714 | |
| 715 | return ret; |
| 716 | } |
| 717 | |
| 718 | static inline void drv_get_ringparam(struct ieee80211_local *local, |
| 719 | u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max) |
| 720 | { |
| 721 | might_sleep(); |
| 722 | |
| 723 | trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max); |
| 724 | if (local->ops->get_ringparam) |
| 725 | local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max); |
| 726 | trace_drv_return_void(local); |
| 727 | } |
| 728 | |
Vivek Natarajan | e8306f9 | 2011-04-06 11:41:10 +0530 | [diff] [blame] | 729 | static inline bool drv_tx_frames_pending(struct ieee80211_local *local) |
| 730 | { |
| 731 | bool ret = false; |
| 732 | |
| 733 | might_sleep(); |
| 734 | |
| 735 | trace_drv_tx_frames_pending(local); |
| 736 | if (local->ops->tx_frames_pending) |
| 737 | ret = local->ops->tx_frames_pending(&local->hw); |
| 738 | trace_drv_return_bool(local, ret); |
| 739 | |
| 740 | return ret; |
| 741 | } |
Sujith Manoharan | bdbfd6b | 2011-04-27 16:56:51 +0530 | [diff] [blame] | 742 | |
| 743 | static inline int drv_set_bitrate_mask(struct ieee80211_local *local, |
| 744 | struct ieee80211_sub_if_data *sdata, |
| 745 | const struct cfg80211_bitrate_mask *mask) |
| 746 | { |
| 747 | int ret = -EOPNOTSUPP; |
| 748 | |
| 749 | might_sleep(); |
| 750 | |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 751 | if (!check_sdata_in_driver(sdata)) |
| 752 | return -EIO; |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 753 | |
Sujith Manoharan | bdbfd6b | 2011-04-27 16:56:51 +0530 | [diff] [blame] | 754 | trace_drv_set_bitrate_mask(local, sdata, mask); |
| 755 | if (local->ops->set_bitrate_mask) |
| 756 | ret = local->ops->set_bitrate_mask(&local->hw, |
| 757 | &sdata->vif, mask); |
| 758 | trace_drv_return_int(local, ret); |
| 759 | |
| 760 | return ret; |
| 761 | } |
| 762 | |
Johannes Berg | c68f4b8 | 2011-07-05 16:35:41 +0200 | [diff] [blame] | 763 | static inline void drv_set_rekey_data(struct ieee80211_local *local, |
| 764 | struct ieee80211_sub_if_data *sdata, |
| 765 | struct cfg80211_gtk_rekey_data *data) |
| 766 | { |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 767 | if (!check_sdata_in_driver(sdata)) |
| 768 | return; |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 769 | |
Johannes Berg | c68f4b8 | 2011-07-05 16:35:41 +0200 | [diff] [blame] | 770 | trace_drv_set_rekey_data(local, sdata, data); |
| 771 | if (local->ops->set_rekey_data) |
| 772 | local->ops->set_rekey_data(&local->hw, &sdata->vif, data); |
| 773 | trace_drv_return_void(local); |
| 774 | } |
| 775 | |
Emmanuel Grumbach | a818292 | 2015-03-16 23:23:34 +0200 | [diff] [blame] | 776 | static inline void drv_event_callback(struct ieee80211_local *local, |
| 777 | struct ieee80211_sub_if_data *sdata, |
| 778 | const struct ieee80211_event *event) |
Meenakshi Venkataraman | 615f7b9 | 2011-07-08 08:46:22 -0700 | [diff] [blame] | 779 | { |
Emmanuel Grumbach | a818292 | 2015-03-16 23:23:34 +0200 | [diff] [blame] | 780 | trace_drv_event_callback(local, sdata, event); |
| 781 | if (local->ops->event_callback) |
| 782 | local->ops->event_callback(&local->hw, &sdata->vif, event); |
Meenakshi Venkataraman | 615f7b9 | 2011-07-08 08:46:22 -0700 | [diff] [blame] | 783 | trace_drv_return_void(local); |
| 784 | } |
Johannes Berg | 4049e09 | 2011-09-29 16:04:32 +0200 | [diff] [blame] | 785 | |
| 786 | static inline void |
| 787 | drv_release_buffered_frames(struct ieee80211_local *local, |
| 788 | struct sta_info *sta, u16 tids, int num_frames, |
| 789 | enum ieee80211_frame_release_type reason, |
| 790 | bool more_data) |
| 791 | { |
| 792 | trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames, |
| 793 | reason, more_data); |
| 794 | if (local->ops->release_buffered_frames) |
| 795 | local->ops->release_buffered_frames(&local->hw, &sta->sta, tids, |
| 796 | num_frames, reason, |
| 797 | more_data); |
| 798 | trace_drv_return_void(local); |
| 799 | } |
Johannes Berg | 40b9640 | 2011-09-29 16:04:38 +0200 | [diff] [blame] | 800 | |
| 801 | static inline void |
| 802 | drv_allow_buffered_frames(struct ieee80211_local *local, |
| 803 | struct sta_info *sta, u16 tids, int num_frames, |
| 804 | enum ieee80211_frame_release_type reason, |
| 805 | bool more_data) |
| 806 | { |
| 807 | trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames, |
| 808 | reason, more_data); |
| 809 | if (local->ops->allow_buffered_frames) |
| 810 | local->ops->allow_buffered_frames(&local->hw, &sta->sta, |
| 811 | tids, num_frames, reason, |
| 812 | more_data); |
| 813 | trace_drv_return_void(local); |
| 814 | } |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 815 | |
Johannes Berg | a1845fc | 2012-06-27 13:18:36 +0200 | [diff] [blame] | 816 | static inline void drv_mgd_prepare_tx(struct ieee80211_local *local, |
Ilan Peer | d4e36e5 | 2018-04-20 13:49:25 +0300 | [diff] [blame] | 817 | struct ieee80211_sub_if_data *sdata, |
| 818 | u16 duration) |
Johannes Berg | a1845fc | 2012-06-27 13:18:36 +0200 | [diff] [blame] | 819 | { |
| 820 | might_sleep(); |
| 821 | |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 822 | if (!check_sdata_in_driver(sdata)) |
| 823 | return; |
Johannes Berg | a1845fc | 2012-06-27 13:18:36 +0200 | [diff] [blame] | 824 | WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION); |
| 825 | |
Ilan Peer | d4e36e5 | 2018-04-20 13:49:25 +0300 | [diff] [blame] | 826 | trace_drv_mgd_prepare_tx(local, sdata, duration); |
Johannes Berg | a1845fc | 2012-06-27 13:18:36 +0200 | [diff] [blame] | 827 | if (local->ops->mgd_prepare_tx) |
Ilan Peer | d4e36e5 | 2018-04-20 13:49:25 +0300 | [diff] [blame] | 828 | local->ops->mgd_prepare_tx(&local->hw, &sdata->vif, duration); |
Johannes Berg | a1845fc | 2012-06-27 13:18:36 +0200 | [diff] [blame] | 829 | trace_drv_return_void(local); |
| 830 | } |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 831 | |
Arik Nemtsov | ee10f2c | 2014-06-11 17:18:27 +0300 | [diff] [blame] | 832 | static inline void |
| 833 | drv_mgd_protect_tdls_discover(struct ieee80211_local *local, |
| 834 | struct ieee80211_sub_if_data *sdata) |
| 835 | { |
| 836 | might_sleep(); |
| 837 | |
| 838 | if (!check_sdata_in_driver(sdata)) |
| 839 | return; |
| 840 | WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION); |
| 841 | |
| 842 | trace_drv_mgd_protect_tdls_discover(local, sdata); |
| 843 | if (local->ops->mgd_protect_tdls_discover) |
| 844 | local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif); |
| 845 | trace_drv_return_void(local); |
| 846 | } |
| 847 | |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 848 | static inline int drv_add_chanctx(struct ieee80211_local *local, |
| 849 | struct ieee80211_chanctx *ctx) |
| 850 | { |
| 851 | int ret = -EOPNOTSUPP; |
| 852 | |
Chaitanya T K | dcae9e0 | 2015-10-30 23:16:15 +0530 | [diff] [blame] | 853 | might_sleep(); |
| 854 | |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 855 | trace_drv_add_chanctx(local, ctx); |
| 856 | if (local->ops->add_chanctx) |
| 857 | ret = local->ops->add_chanctx(&local->hw, &ctx->conf); |
| 858 | trace_drv_return_int(local, ret); |
Johannes Berg | 8a61af6 | 2012-12-13 17:42:30 +0100 | [diff] [blame] | 859 | if (!ret) |
| 860 | ctx->driver_present = true; |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 861 | |
| 862 | return ret; |
| 863 | } |
| 864 | |
| 865 | static inline void drv_remove_chanctx(struct ieee80211_local *local, |
| 866 | struct ieee80211_chanctx *ctx) |
| 867 | { |
Chaitanya T K | dcae9e0 | 2015-10-30 23:16:15 +0530 | [diff] [blame] | 868 | might_sleep(); |
| 869 | |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 870 | if (WARN_ON(!ctx->driver_present)) |
| 871 | return; |
| 872 | |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 873 | trace_drv_remove_chanctx(local, ctx); |
| 874 | if (local->ops->remove_chanctx) |
| 875 | local->ops->remove_chanctx(&local->hw, &ctx->conf); |
| 876 | trace_drv_return_void(local); |
Johannes Berg | 8a61af6 | 2012-12-13 17:42:30 +0100 | [diff] [blame] | 877 | ctx->driver_present = false; |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 878 | } |
| 879 | |
| 880 | static inline void drv_change_chanctx(struct ieee80211_local *local, |
| 881 | struct ieee80211_chanctx *ctx, |
| 882 | u32 changed) |
| 883 | { |
Chaitanya T K | dcae9e0 | 2015-10-30 23:16:15 +0530 | [diff] [blame] | 884 | might_sleep(); |
| 885 | |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 886 | trace_drv_change_chanctx(local, ctx, changed); |
Johannes Berg | 8a61af6 | 2012-12-13 17:42:30 +0100 | [diff] [blame] | 887 | if (local->ops->change_chanctx) { |
| 888 | WARN_ON_ONCE(!ctx->driver_present); |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 889 | local->ops->change_chanctx(&local->hw, &ctx->conf, changed); |
Johannes Berg | 8a61af6 | 2012-12-13 17:42:30 +0100 | [diff] [blame] | 890 | } |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 891 | trace_drv_return_void(local); |
| 892 | } |
| 893 | |
| 894 | static inline int drv_assign_vif_chanctx(struct ieee80211_local *local, |
| 895 | struct ieee80211_sub_if_data *sdata, |
| 896 | struct ieee80211_chanctx *ctx) |
| 897 | { |
| 898 | int ret = 0; |
| 899 | |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 900 | if (!check_sdata_in_driver(sdata)) |
| 901 | return -EIO; |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 902 | |
| 903 | trace_drv_assign_vif_chanctx(local, sdata, ctx); |
Johannes Berg | 8a61af6 | 2012-12-13 17:42:30 +0100 | [diff] [blame] | 904 | if (local->ops->assign_vif_chanctx) { |
| 905 | WARN_ON_ONCE(!ctx->driver_present); |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 906 | ret = local->ops->assign_vif_chanctx(&local->hw, |
| 907 | &sdata->vif, |
| 908 | &ctx->conf); |
Johannes Berg | 8a61af6 | 2012-12-13 17:42:30 +0100 | [diff] [blame] | 909 | } |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 910 | trace_drv_return_int(local, ret); |
| 911 | |
| 912 | return ret; |
| 913 | } |
| 914 | |
| 915 | static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local, |
| 916 | struct ieee80211_sub_if_data *sdata, |
| 917 | struct ieee80211_chanctx *ctx) |
| 918 | { |
Chaitanya T K | dcae9e0 | 2015-10-30 23:16:15 +0530 | [diff] [blame] | 919 | might_sleep(); |
| 920 | |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 921 | if (!check_sdata_in_driver(sdata)) |
| 922 | return; |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 923 | |
| 924 | trace_drv_unassign_vif_chanctx(local, sdata, ctx); |
Johannes Berg | 8a61af6 | 2012-12-13 17:42:30 +0100 | [diff] [blame] | 925 | if (local->ops->unassign_vif_chanctx) { |
| 926 | WARN_ON_ONCE(!ctx->driver_present); |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 927 | local->ops->unassign_vif_chanctx(&local->hw, |
| 928 | &sdata->vif, |
| 929 | &ctx->conf); |
Johannes Berg | 8a61af6 | 2012-12-13 17:42:30 +0100 | [diff] [blame] | 930 | } |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 931 | trace_drv_return_void(local); |
| 932 | } |
| 933 | |
Denys Vlasenko | 42677ed | 2015-09-23 14:18:34 +0200 | [diff] [blame] | 934 | int drv_switch_vif_chanctx(struct ieee80211_local *local, |
| 935 | struct ieee80211_vif_chanctx_switch *vifs, |
| 936 | int n_vifs, enum ieee80211_chanctx_switch_mode mode); |
Luciano Coelho | 1a5f0c1 | 2014-05-23 14:33:12 +0300 | [diff] [blame] | 937 | |
Johannes Berg | 1041638 | 2012-10-19 15:44:42 +0200 | [diff] [blame] | 938 | static inline int drv_start_ap(struct ieee80211_local *local, |
| 939 | struct ieee80211_sub_if_data *sdata) |
| 940 | { |
| 941 | int ret = 0; |
| 942 | |
Chaitanya T K | dcae9e0 | 2015-10-30 23:16:15 +0530 | [diff] [blame] | 943 | might_sleep(); |
| 944 | |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 945 | if (!check_sdata_in_driver(sdata)) |
| 946 | return -EIO; |
Johannes Berg | 1041638 | 2012-10-19 15:44:42 +0200 | [diff] [blame] | 947 | |
| 948 | trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf); |
| 949 | if (local->ops->start_ap) |
| 950 | ret = local->ops->start_ap(&local->hw, &sdata->vif); |
| 951 | trace_drv_return_int(local, ret); |
| 952 | return ret; |
| 953 | } |
| 954 | |
| 955 | static inline void drv_stop_ap(struct ieee80211_local *local, |
| 956 | struct ieee80211_sub_if_data *sdata) |
| 957 | { |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 958 | if (!check_sdata_in_driver(sdata)) |
| 959 | return; |
Johannes Berg | 1041638 | 2012-10-19 15:44:42 +0200 | [diff] [blame] | 960 | |
| 961 | trace_drv_stop_ap(local, sdata); |
| 962 | if (local->ops->stop_ap) |
| 963 | local->ops->stop_ap(&local->hw, &sdata->vif); |
| 964 | trace_drv_return_void(local); |
| 965 | } |
| 966 | |
Eliad Peller | cf2c92d | 2014-11-04 11:43:54 +0200 | [diff] [blame] | 967 | static inline void |
| 968 | drv_reconfig_complete(struct ieee80211_local *local, |
| 969 | enum ieee80211_reconfig_type reconfig_type) |
Johannes Berg | 9214ad7 | 2012-11-06 19:18:13 +0100 | [diff] [blame] | 970 | { |
| 971 | might_sleep(); |
| 972 | |
Eliad Peller | cf2c92d | 2014-11-04 11:43:54 +0200 | [diff] [blame] | 973 | trace_drv_reconfig_complete(local, reconfig_type); |
| 974 | if (local->ops->reconfig_complete) |
| 975 | local->ops->reconfig_complete(&local->hw, reconfig_type); |
Johannes Berg | 9214ad7 | 2012-11-06 19:18:13 +0100 | [diff] [blame] | 976 | trace_drv_return_void(local); |
| 977 | } |
| 978 | |
Yoni Divinsky | de5fad8 | 2012-05-30 11:36:39 +0300 | [diff] [blame] | 979 | static inline void |
| 980 | drv_set_default_unicast_key(struct ieee80211_local *local, |
| 981 | struct ieee80211_sub_if_data *sdata, |
| 982 | int key_idx) |
| 983 | { |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 984 | if (!check_sdata_in_driver(sdata)) |
| 985 | return; |
Yoni Divinsky | de5fad8 | 2012-05-30 11:36:39 +0300 | [diff] [blame] | 986 | |
| 987 | WARN_ON_ONCE(key_idx < -1 || key_idx > 3); |
| 988 | |
| 989 | trace_drv_set_default_unicast_key(local, sdata, key_idx); |
| 990 | if (local->ops->set_default_unicast_key) |
| 991 | local->ops->set_default_unicast_key(&local->hw, &sdata->vif, |
| 992 | key_idx); |
| 993 | trace_drv_return_void(local); |
| 994 | } |
| 995 | |
Johannes Berg | a65240c | 2013-01-14 15:14:34 +0100 | [diff] [blame] | 996 | #if IS_ENABLED(CONFIG_IPV6) |
| 997 | static inline void drv_ipv6_addr_change(struct ieee80211_local *local, |
| 998 | struct ieee80211_sub_if_data *sdata, |
| 999 | struct inet6_dev *idev) |
| 1000 | { |
| 1001 | trace_drv_ipv6_addr_change(local, sdata); |
| 1002 | if (local->ops->ipv6_addr_change) |
| 1003 | local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev); |
| 1004 | trace_drv_return_void(local); |
| 1005 | } |
| 1006 | #endif |
| 1007 | |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 1008 | static inline void |
| 1009 | drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata, |
| 1010 | struct cfg80211_chan_def *chandef) |
| 1011 | { |
| 1012 | struct ieee80211_local *local = sdata->local; |
| 1013 | |
| 1014 | if (local->ops->channel_switch_beacon) { |
| 1015 | trace_drv_channel_switch_beacon(local, sdata, chandef); |
| 1016 | local->ops->channel_switch_beacon(&local->hw, &sdata->vif, |
| 1017 | chandef); |
| 1018 | } |
| 1019 | } |
| 1020 | |
Luciano Coelho | 6d027bc | 2014-10-08 09:48:37 +0300 | [diff] [blame] | 1021 | static inline int |
| 1022 | drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata, |
| 1023 | struct ieee80211_channel_switch *ch_switch) |
| 1024 | { |
| 1025 | struct ieee80211_local *local = sdata->local; |
| 1026 | int ret = 0; |
| 1027 | |
| 1028 | if (!check_sdata_in_driver(sdata)) |
| 1029 | return -EIO; |
| 1030 | |
| 1031 | trace_drv_pre_channel_switch(local, sdata, ch_switch); |
| 1032 | if (local->ops->pre_channel_switch) |
| 1033 | ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif, |
| 1034 | ch_switch); |
| 1035 | trace_drv_return_int(local, ret); |
| 1036 | return ret; |
| 1037 | } |
| 1038 | |
Luciano Coelho | f1d6558 | 2014-10-08 09:48:38 +0300 | [diff] [blame] | 1039 | static inline int |
| 1040 | drv_post_channel_switch(struct ieee80211_sub_if_data *sdata) |
| 1041 | { |
| 1042 | struct ieee80211_local *local = sdata->local; |
| 1043 | int ret = 0; |
| 1044 | |
| 1045 | if (!check_sdata_in_driver(sdata)) |
| 1046 | return -EIO; |
| 1047 | |
| 1048 | trace_drv_post_channel_switch(local, sdata); |
| 1049 | if (local->ops->post_channel_switch) |
| 1050 | ret = local->ops->post_channel_switch(&local->hw, &sdata->vif); |
| 1051 | trace_drv_return_int(local, ret); |
| 1052 | return ret; |
| 1053 | } |
| 1054 | |
Johannes Berg | 55fff50 | 2013-08-19 18:48:41 +0200 | [diff] [blame] | 1055 | static inline int drv_join_ibss(struct ieee80211_local *local, |
| 1056 | struct ieee80211_sub_if_data *sdata) |
| 1057 | { |
| 1058 | int ret = 0; |
| 1059 | |
| 1060 | might_sleep(); |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 1061 | if (!check_sdata_in_driver(sdata)) |
| 1062 | return -EIO; |
Johannes Berg | 55fff50 | 2013-08-19 18:48:41 +0200 | [diff] [blame] | 1063 | |
| 1064 | trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf); |
| 1065 | if (local->ops->join_ibss) |
| 1066 | ret = local->ops->join_ibss(&local->hw, &sdata->vif); |
| 1067 | trace_drv_return_int(local, ret); |
| 1068 | return ret; |
| 1069 | } |
| 1070 | |
| 1071 | static inline void drv_leave_ibss(struct ieee80211_local *local, |
| 1072 | struct ieee80211_sub_if_data *sdata) |
| 1073 | { |
| 1074 | might_sleep(); |
Johannes Berg | f6837ba8 | 2014-04-30 14:19:04 +0200 | [diff] [blame] | 1075 | if (!check_sdata_in_driver(sdata)) |
| 1076 | return; |
Johannes Berg | 55fff50 | 2013-08-19 18:48:41 +0200 | [diff] [blame] | 1077 | |
| 1078 | trace_drv_leave_ibss(local, sdata); |
| 1079 | if (local->ops->leave_ibss) |
| 1080 | local->ops->leave_ibss(&local->hw, &sdata->vif); |
| 1081 | trace_drv_return_void(local); |
| 1082 | } |
| 1083 | |
Antonio Quartulli | cca674d | 2014-05-19 21:53:20 +0200 | [diff] [blame] | 1084 | static inline u32 drv_get_expected_throughput(struct ieee80211_local *local, |
Maxim Altshul | 4fdbc67a | 2016-08-11 13:38:16 +0300 | [diff] [blame] | 1085 | struct sta_info *sta) |
Antonio Quartulli | cca674d | 2014-05-19 21:53:20 +0200 | [diff] [blame] | 1086 | { |
| 1087 | u32 ret = 0; |
| 1088 | |
Maxim Altshul | 4fdbc67a | 2016-08-11 13:38:16 +0300 | [diff] [blame] | 1089 | trace_drv_get_expected_throughput(&sta->sta); |
| 1090 | if (local->ops->get_expected_throughput && sta->uploaded) |
| 1091 | ret = local->ops->get_expected_throughput(&local->hw, &sta->sta); |
Antonio Quartulli | cca674d | 2014-05-19 21:53:20 +0200 | [diff] [blame] | 1092 | trace_drv_return_u32(local, ret); |
| 1093 | |
| 1094 | return ret; |
| 1095 | } |
| 1096 | |
Felix Fietkau | 5b3dc42 | 2014-10-26 00:32:53 +0200 | [diff] [blame] | 1097 | static inline int drv_get_txpower(struct ieee80211_local *local, |
| 1098 | struct ieee80211_sub_if_data *sdata, int *dbm) |
| 1099 | { |
| 1100 | int ret; |
| 1101 | |
| 1102 | if (!local->ops->get_txpower) |
| 1103 | return -EOPNOTSUPP; |
| 1104 | |
| 1105 | ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm); |
| 1106 | trace_drv_get_txpower(local, sdata, *dbm, ret); |
| 1107 | |
| 1108 | return ret; |
| 1109 | } |
| 1110 | |
Arik Nemtsov | a7a6bdd | 2014-11-09 18:50:19 +0200 | [diff] [blame] | 1111 | static inline int |
| 1112 | drv_tdls_channel_switch(struct ieee80211_local *local, |
| 1113 | struct ieee80211_sub_if_data *sdata, |
| 1114 | struct ieee80211_sta *sta, u8 oper_class, |
| 1115 | struct cfg80211_chan_def *chandef, |
| 1116 | struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie) |
| 1117 | { |
| 1118 | int ret; |
| 1119 | |
| 1120 | might_sleep(); |
| 1121 | if (!check_sdata_in_driver(sdata)) |
| 1122 | return -EIO; |
| 1123 | |
| 1124 | if (!local->ops->tdls_channel_switch) |
| 1125 | return -EOPNOTSUPP; |
| 1126 | |
| 1127 | trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef); |
| 1128 | ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta, |
| 1129 | oper_class, chandef, tmpl_skb, |
| 1130 | ch_sw_tm_ie); |
| 1131 | trace_drv_return_int(local, ret); |
| 1132 | return ret; |
| 1133 | } |
| 1134 | |
| 1135 | static inline void |
| 1136 | drv_tdls_cancel_channel_switch(struct ieee80211_local *local, |
| 1137 | struct ieee80211_sub_if_data *sdata, |
| 1138 | struct ieee80211_sta *sta) |
| 1139 | { |
| 1140 | might_sleep(); |
| 1141 | if (!check_sdata_in_driver(sdata)) |
| 1142 | return; |
| 1143 | |
| 1144 | if (!local->ops->tdls_cancel_channel_switch) |
| 1145 | return; |
| 1146 | |
| 1147 | trace_drv_tdls_cancel_channel_switch(local, sdata, sta); |
| 1148 | local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta); |
| 1149 | trace_drv_return_void(local); |
| 1150 | } |
| 1151 | |
Arik Nemtsov | 8a4d32f | 2014-11-09 18:50:20 +0200 | [diff] [blame] | 1152 | static inline void |
| 1153 | drv_tdls_recv_channel_switch(struct ieee80211_local *local, |
| 1154 | struct ieee80211_sub_if_data *sdata, |
| 1155 | struct ieee80211_tdls_ch_sw_params *params) |
| 1156 | { |
| 1157 | trace_drv_tdls_recv_channel_switch(local, sdata, params); |
| 1158 | if (local->ops->tdls_recv_channel_switch) |
| 1159 | local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif, |
| 1160 | params); |
| 1161 | trace_drv_return_void(local); |
| 1162 | } |
| 1163 | |
Johannes Berg | e7881bd5 | 2017-12-19 10:11:54 +0100 | [diff] [blame] | 1164 | static inline void drv_wake_tx_queue(struct ieee80211_local *local, |
| 1165 | struct txq_info *txq) |
Felix Fietkau | ba8c3d6 | 2015-03-27 21:30:37 +0100 | [diff] [blame] | 1166 | { |
Johannes Berg | e7881bd5 | 2017-12-19 10:11:54 +0100 | [diff] [blame] | 1167 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif); |
| 1168 | |
| 1169 | if (!check_sdata_in_driver(sdata)) |
| 1170 | return; |
| 1171 | |
| 1172 | trace_drv_wake_tx_queue(local, sdata, txq); |
| 1173 | local->ops->wake_tx_queue(&local->hw, &txq->txq); |
Felix Fietkau | ba8c3d6 | 2015-03-27 21:30:37 +0100 | [diff] [blame] | 1174 | } |
| 1175 | |
Ayala Beker | 708d50e | 2016-09-20 17:31:14 +0300 | [diff] [blame] | 1176 | static inline int drv_start_nan(struct ieee80211_local *local, |
| 1177 | struct ieee80211_sub_if_data *sdata, |
| 1178 | struct cfg80211_nan_conf *conf) |
| 1179 | { |
| 1180 | int ret; |
| 1181 | |
| 1182 | might_sleep(); |
| 1183 | check_sdata_in_driver(sdata); |
| 1184 | |
| 1185 | trace_drv_start_nan(local, sdata, conf); |
| 1186 | ret = local->ops->start_nan(&local->hw, &sdata->vif, conf); |
| 1187 | trace_drv_return_int(local, ret); |
| 1188 | return ret; |
| 1189 | } |
| 1190 | |
| 1191 | static inline void drv_stop_nan(struct ieee80211_local *local, |
| 1192 | struct ieee80211_sub_if_data *sdata) |
| 1193 | { |
| 1194 | might_sleep(); |
| 1195 | check_sdata_in_driver(sdata); |
| 1196 | |
| 1197 | trace_drv_stop_nan(local, sdata); |
| 1198 | local->ops->stop_nan(&local->hw, &sdata->vif); |
| 1199 | trace_drv_return_void(local); |
| 1200 | } |
| 1201 | |
Ayala Beker | 5953ff6 | 2016-09-20 17:31:19 +0300 | [diff] [blame] | 1202 | static inline int drv_nan_change_conf(struct ieee80211_local *local, |
| 1203 | struct ieee80211_sub_if_data *sdata, |
| 1204 | struct cfg80211_nan_conf *conf, |
| 1205 | u32 changes) |
| 1206 | { |
| 1207 | int ret; |
| 1208 | |
| 1209 | might_sleep(); |
| 1210 | check_sdata_in_driver(sdata); |
| 1211 | |
| 1212 | if (!local->ops->nan_change_conf) |
| 1213 | return -EOPNOTSUPP; |
| 1214 | |
| 1215 | trace_drv_nan_change_conf(local, sdata, conf, changes); |
| 1216 | ret = local->ops->nan_change_conf(&local->hw, &sdata->vif, conf, |
| 1217 | changes); |
| 1218 | trace_drv_return_int(local, ret); |
| 1219 | |
| 1220 | return ret; |
| 1221 | } |
| 1222 | |
Ayala Beker | 167e33f | 2016-09-20 17:31:20 +0300 | [diff] [blame] | 1223 | static inline int drv_add_nan_func(struct ieee80211_local *local, |
| 1224 | struct ieee80211_sub_if_data *sdata, |
| 1225 | const struct cfg80211_nan_func *nan_func) |
| 1226 | { |
| 1227 | int ret; |
| 1228 | |
| 1229 | might_sleep(); |
| 1230 | check_sdata_in_driver(sdata); |
| 1231 | |
| 1232 | if (!local->ops->add_nan_func) |
| 1233 | return -EOPNOTSUPP; |
| 1234 | |
| 1235 | trace_drv_add_nan_func(local, sdata, nan_func); |
| 1236 | ret = local->ops->add_nan_func(&local->hw, &sdata->vif, nan_func); |
| 1237 | trace_drv_return_int(local, ret); |
| 1238 | |
| 1239 | return ret; |
| 1240 | } |
| 1241 | |
| 1242 | static inline void drv_del_nan_func(struct ieee80211_local *local, |
| 1243 | struct ieee80211_sub_if_data *sdata, |
| 1244 | u8 instance_id) |
| 1245 | { |
| 1246 | might_sleep(); |
| 1247 | check_sdata_in_driver(sdata); |
| 1248 | |
| 1249 | trace_drv_del_nan_func(local, sdata, instance_id); |
| 1250 | if (local->ops->del_nan_func) |
| 1251 | local->ops->del_nan_func(&local->hw, &sdata->vif, instance_id); |
| 1252 | trace_drv_return_void(local); |
| 1253 | } |
| 1254 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 1255 | #endif /* __MAC80211_DRIVER_OPS */ |