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