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