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 | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 8 | static inline void check_sdata_in_driver(struct ieee80211_sub_if_data *sdata) |
| 9 | { |
Ben Greear | d17087e | 2012-03-15 16:22:05 -0700 | [diff] [blame] | 10 | WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER), |
| 11 | "%s: Failed check-sdata-in-driver check, flags: 0x%x\n", |
Johannes Berg | f142c6b | 2012-06-18 20:07:15 +0200 | [diff] [blame] | 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 && |
| 149 | !(local->hw.flags & IEEE80211_HW_WANT_MONITOR_VIF)))) |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 150 | return -EINVAL; |
| 151 | |
| 152 | trace_drv_add_interface(local, sdata); |
| 153 | ret = local->ops->add_interface(&local->hw, &sdata->vif); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 154 | trace_drv_return_int(local, ret); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 155 | |
| 156 | if (ret == 0) |
| 157 | sdata->flags |= IEEE80211_SDATA_IN_DRIVER; |
| 158 | |
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 | |
Johannes Berg | 34d4bc4 | 2010-08-27 12:35:58 +0200 | [diff] [blame] | 162 | static inline int drv_change_interface(struct ieee80211_local *local, |
| 163 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2ca27bc | 2010-09-16 14:58:23 +0200 | [diff] [blame] | 164 | enum nl80211_iftype type, bool p2p) |
Johannes Berg | 34d4bc4 | 2010-08-27 12:35:58 +0200 | [diff] [blame] | 165 | { |
| 166 | int ret; |
| 167 | |
| 168 | might_sleep(); |
| 169 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 170 | check_sdata_in_driver(sdata); |
| 171 | |
Johannes Berg | 2ca27bc | 2010-09-16 14:58:23 +0200 | [diff] [blame] | 172 | trace_drv_change_interface(local, sdata, type, p2p); |
| 173 | ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p); |
Johannes Berg | 34d4bc4 | 2010-08-27 12:35:58 +0200 | [diff] [blame] | 174 | trace_drv_return_int(local, ret); |
| 175 | return ret; |
| 176 | } |
| 177 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 178 | static inline void drv_remove_interface(struct ieee80211_local *local, |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 179 | struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 180 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 181 | might_sleep(); |
| 182 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 183 | check_sdata_in_driver(sdata); |
| 184 | |
| 185 | trace_drv_remove_interface(local, sdata); |
| 186 | local->ops->remove_interface(&local->hw, &sdata->vif); |
| 187 | sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER; |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 188 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | static inline int drv_config(struct ieee80211_local *local, u32 changed) |
| 192 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 193 | int ret; |
| 194 | |
| 195 | might_sleep(); |
| 196 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 197 | trace_drv_config(local, changed); |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 198 | ret = local->ops->config(&local->hw, changed); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 199 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 200 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | static inline void drv_bss_info_changed(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 204 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 205 | struct ieee80211_bss_conf *info, |
| 206 | u32 changed) |
| 207 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 208 | might_sleep(); |
| 209 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 210 | check_sdata_in_driver(sdata); |
| 211 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 212 | trace_drv_bss_info_changed(local, sdata, info, changed); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 213 | if (local->ops->bss_info_changed) |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 214 | local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 215 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 216 | } |
| 217 | |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 218 | static inline u64 drv_prepare_multicast(struct ieee80211_local *local, |
Jiri Pirko | 22bedad3 | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 219 | struct netdev_hw_addr_list *mc_list) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 220 | { |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 221 | u64 ret = 0; |
| 222 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 223 | trace_drv_prepare_multicast(local, mc_list->count); |
| 224 | |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 225 | if (local->ops->prepare_multicast) |
Jiri Pirko | 22bedad3 | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 226 | ret = local->ops->prepare_multicast(&local->hw, mc_list); |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 227 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 228 | trace_drv_return_u64(local, ret); |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 229 | |
| 230 | return ret; |
| 231 | } |
| 232 | |
| 233 | static inline void drv_configure_filter(struct ieee80211_local *local, |
| 234 | unsigned int changed_flags, |
| 235 | unsigned int *total_flags, |
| 236 | u64 multicast) |
| 237 | { |
| 238 | might_sleep(); |
| 239 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 240 | trace_drv_configure_filter(local, changed_flags, total_flags, |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 241 | multicast); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 242 | local->ops->configure_filter(&local->hw, changed_flags, total_flags, |
| 243 | multicast); |
| 244 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | static inline int drv_set_tim(struct ieee80211_local *local, |
| 248 | struct ieee80211_sta *sta, bool set) |
| 249 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 250 | int ret = 0; |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 251 | trace_drv_set_tim(local, sta, set); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 252 | if (local->ops->set_tim) |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 253 | ret = local->ops->set_tim(&local->hw, sta, set); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 254 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 255 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | static inline int drv_set_key(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 259 | enum set_key_cmd cmd, |
| 260 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 261 | struct ieee80211_sta *sta, |
| 262 | struct ieee80211_key_conf *key) |
| 263 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 264 | int ret; |
| 265 | |
| 266 | might_sleep(); |
| 267 | |
Johannes Berg | 077f493 | 2012-01-20 13:55:18 +0100 | [diff] [blame] | 268 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 269 | check_sdata_in_driver(sdata); |
| 270 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 271 | trace_drv_set_key(local, cmd, sdata, sta, key); |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 272 | ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 273 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 274 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | static inline void drv_update_tkip_key(struct ieee80211_local *local, |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 278 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 279 | struct ieee80211_key_conf *conf, |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 280 | struct sta_info *sta, u32 iv32, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 281 | u16 *phase1key) |
| 282 | { |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 283 | struct ieee80211_sta *ista = NULL; |
| 284 | |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 285 | if (sta) |
| 286 | ista = &sta->sta; |
| 287 | |
Johannes Berg | 077f493 | 2012-01-20 13:55:18 +0100 | [diff] [blame] | 288 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 289 | check_sdata_in_driver(sdata); |
| 290 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 291 | trace_drv_update_tkip_key(local, sdata, conf, ista, iv32); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 292 | if (local->ops->update_tkip_key) |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 293 | local->ops->update_tkip_key(&local->hw, &sdata->vif, conf, |
| 294 | ista, iv32, phase1key); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 295 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | static inline int drv_hw_scan(struct ieee80211_local *local, |
Johannes Berg | a060bbf | 2010-04-27 11:59:34 +0200 | [diff] [blame] | 299 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 300 | struct cfg80211_scan_request *req) |
| 301 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 302 | int ret; |
| 303 | |
| 304 | might_sleep(); |
| 305 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 306 | check_sdata_in_driver(sdata); |
| 307 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 308 | trace_drv_hw_scan(local, sdata); |
Johannes Berg | a060bbf | 2010-04-27 11:59:34 +0200 | [diff] [blame] | 309 | ret = local->ops->hw_scan(&local->hw, &sdata->vif, req); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 310 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 311 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 312 | } |
| 313 | |
Eliad Peller | b856439 | 2011-06-13 12:47:30 +0300 | [diff] [blame] | 314 | static inline void drv_cancel_hw_scan(struct ieee80211_local *local, |
| 315 | struct ieee80211_sub_if_data *sdata) |
| 316 | { |
| 317 | might_sleep(); |
| 318 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 319 | check_sdata_in_driver(sdata); |
| 320 | |
Eliad Peller | b856439 | 2011-06-13 12:47:30 +0300 | [diff] [blame] | 321 | trace_drv_cancel_hw_scan(local, sdata); |
| 322 | local->ops->cancel_hw_scan(&local->hw, &sdata->vif); |
| 323 | trace_drv_return_void(local); |
| 324 | } |
| 325 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 326 | static inline int |
| 327 | drv_sched_scan_start(struct ieee80211_local *local, |
| 328 | struct ieee80211_sub_if_data *sdata, |
| 329 | struct cfg80211_sched_scan_request *req, |
| 330 | struct ieee80211_sched_scan_ies *ies) |
| 331 | { |
| 332 | int ret; |
| 333 | |
| 334 | might_sleep(); |
| 335 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 336 | check_sdata_in_driver(sdata); |
| 337 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 338 | trace_drv_sched_scan_start(local, sdata); |
| 339 | ret = local->ops->sched_scan_start(&local->hw, &sdata->vif, |
| 340 | req, ies); |
| 341 | trace_drv_return_int(local, ret); |
| 342 | return ret; |
| 343 | } |
| 344 | |
| 345 | static inline void drv_sched_scan_stop(struct ieee80211_local *local, |
| 346 | struct ieee80211_sub_if_data *sdata) |
| 347 | { |
| 348 | might_sleep(); |
| 349 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 350 | check_sdata_in_driver(sdata); |
| 351 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 352 | trace_drv_sched_scan_stop(local, sdata); |
| 353 | local->ops->sched_scan_stop(&local->hw, &sdata->vif); |
| 354 | trace_drv_return_void(local); |
| 355 | } |
| 356 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 357 | static inline void drv_sw_scan_start(struct ieee80211_local *local) |
| 358 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 359 | might_sleep(); |
| 360 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 361 | trace_drv_sw_scan_start(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 362 | if (local->ops->sw_scan_start) |
| 363 | local->ops->sw_scan_start(&local->hw); |
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 | |
| 367 | static inline void drv_sw_scan_complete(struct ieee80211_local *local) |
| 368 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 369 | might_sleep(); |
| 370 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 371 | trace_drv_sw_scan_complete(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 372 | if (local->ops->sw_scan_complete) |
| 373 | local->ops->sw_scan_complete(&local->hw); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 374 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | static inline int drv_get_stats(struct ieee80211_local *local, |
| 378 | struct ieee80211_low_level_stats *stats) |
| 379 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 380 | int ret = -EOPNOTSUPP; |
| 381 | |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 382 | might_sleep(); |
| 383 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 384 | if (local->ops->get_stats) |
| 385 | ret = local->ops->get_stats(&local->hw, stats); |
| 386 | trace_drv_get_stats(local, stats, ret); |
| 387 | |
| 388 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | static inline void drv_get_tkip_seq(struct ieee80211_local *local, |
| 392 | u8 hw_key_idx, u32 *iv32, u16 *iv16) |
| 393 | { |
| 394 | if (local->ops->get_tkip_seq) |
| 395 | local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 396 | trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 397 | } |
| 398 | |
Arik Nemtsov | f23a478 | 2010-11-08 11:51:06 +0200 | [diff] [blame] | 399 | static inline int drv_set_frag_threshold(struct ieee80211_local *local, |
| 400 | u32 value) |
| 401 | { |
| 402 | int ret = 0; |
| 403 | |
| 404 | might_sleep(); |
| 405 | |
| 406 | trace_drv_set_frag_threshold(local, value); |
| 407 | if (local->ops->set_frag_threshold) |
| 408 | ret = local->ops->set_frag_threshold(&local->hw, value); |
| 409 | trace_drv_return_int(local, ret); |
| 410 | return ret; |
| 411 | } |
| 412 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 413 | static inline int drv_set_rts_threshold(struct ieee80211_local *local, |
| 414 | u32 value) |
| 415 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 416 | int ret = 0; |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 417 | |
| 418 | might_sleep(); |
| 419 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 420 | trace_drv_set_rts_threshold(local, value); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 421 | if (local->ops->set_rts_threshold) |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 422 | ret = local->ops->set_rts_threshold(&local->hw, value); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 423 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 424 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 425 | } |
| 426 | |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 427 | static inline int drv_set_coverage_class(struct ieee80211_local *local, |
| 428 | u8 value) |
| 429 | { |
| 430 | int ret = 0; |
| 431 | might_sleep(); |
| 432 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 433 | trace_drv_set_coverage_class(local, value); |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 434 | if (local->ops->set_coverage_class) |
| 435 | local->ops->set_coverage_class(&local->hw, value); |
| 436 | else |
| 437 | ret = -EOPNOTSUPP; |
| 438 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 439 | trace_drv_return_int(local, ret); |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 440 | return ret; |
| 441 | } |
| 442 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 443 | static inline void drv_sta_notify(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 444 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 445 | enum sta_notify_cmd cmd, |
| 446 | struct ieee80211_sta *sta) |
| 447 | { |
Felix Fietkau | bc192f8 | 2011-11-23 21:09:49 +0700 | [diff] [blame] | 448 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 449 | check_sdata_in_driver(sdata); |
| 450 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 451 | trace_drv_sta_notify(local, sdata, cmd, sta); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 452 | if (local->ops->sta_notify) |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 453 | local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 454 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 455 | } |
| 456 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 457 | static inline int drv_sta_add(struct ieee80211_local *local, |
| 458 | struct ieee80211_sub_if_data *sdata, |
| 459 | struct ieee80211_sta *sta) |
| 460 | { |
| 461 | int ret = 0; |
| 462 | |
| 463 | might_sleep(); |
| 464 | |
Felix Fietkau | bc192f8 | 2011-11-23 21:09:49 +0700 | [diff] [blame] | 465 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 466 | check_sdata_in_driver(sdata); |
| 467 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 468 | trace_drv_sta_add(local, sdata, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 469 | if (local->ops->sta_add) |
| 470 | ret = local->ops->sta_add(&local->hw, &sdata->vif, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 471 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 472 | trace_drv_return_int(local, ret); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 473 | |
| 474 | return ret; |
| 475 | } |
| 476 | |
| 477 | static inline void drv_sta_remove(struct ieee80211_local *local, |
| 478 | struct ieee80211_sub_if_data *sdata, |
| 479 | struct ieee80211_sta *sta) |
| 480 | { |
| 481 | might_sleep(); |
| 482 | |
Felix Fietkau | bc192f8 | 2011-11-23 21:09:49 +0700 | [diff] [blame] | 483 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 484 | check_sdata_in_driver(sdata); |
| 485 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 486 | trace_drv_sta_remove(local, sdata, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 487 | if (local->ops->sta_remove) |
| 488 | local->ops->sta_remove(&local->hw, &sdata->vif, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 489 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 490 | trace_drv_return_void(local); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 491 | } |
| 492 | |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 493 | static inline __must_check |
| 494 | int drv_sta_state(struct ieee80211_local *local, |
| 495 | struct ieee80211_sub_if_data *sdata, |
| 496 | struct sta_info *sta, |
| 497 | enum ieee80211_sta_state old_state, |
| 498 | enum ieee80211_sta_state new_state) |
| 499 | { |
| 500 | int ret = 0; |
| 501 | |
| 502 | might_sleep(); |
| 503 | |
| 504 | sdata = get_bss_sdata(sdata); |
| 505 | check_sdata_in_driver(sdata); |
| 506 | |
| 507 | trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state); |
Johannes Berg | a4ec45a | 2012-01-20 13:55:22 +0100 | [diff] [blame] | 508 | if (local->ops->sta_state) { |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 509 | ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta, |
| 510 | old_state, new_state); |
Johannes Berg | a4ec45a | 2012-01-20 13:55:22 +0100 | [diff] [blame] | 511 | } else if (old_state == IEEE80211_STA_AUTH && |
| 512 | new_state == IEEE80211_STA_ASSOC) { |
| 513 | ret = drv_sta_add(local, sdata, &sta->sta); |
| 514 | if (ret == 0) |
| 515 | sta->uploaded = true; |
| 516 | } else if (old_state == IEEE80211_STA_ASSOC && |
| 517 | new_state == IEEE80211_STA_AUTH) { |
| 518 | drv_sta_remove(local, sdata, &sta->sta); |
| 519 | } |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 520 | trace_drv_return_int(local, ret); |
| 521 | return ret; |
| 522 | } |
| 523 | |
Johannes Berg | 8f727ef | 2012-03-30 08:43:32 +0200 | [diff] [blame] | 524 | static inline void drv_sta_rc_update(struct ieee80211_local *local, |
| 525 | struct ieee80211_sub_if_data *sdata, |
| 526 | struct ieee80211_sta *sta, u32 changed) |
| 527 | { |
| 528 | sdata = get_bss_sdata(sdata); |
| 529 | check_sdata_in_driver(sdata); |
| 530 | |
Antonio Quartulli | e687f61 | 2012-08-12 18:24:55 +0200 | [diff] [blame] | 531 | WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED && |
| 532 | sdata->vif.type != NL80211_IFTYPE_ADHOC); |
| 533 | |
Johannes Berg | 8f727ef | 2012-03-30 08:43:32 +0200 | [diff] [blame] | 534 | trace_drv_sta_rc_update(local, sdata, sta, changed); |
| 535 | if (local->ops->sta_rc_update) |
| 536 | local->ops->sta_rc_update(&local->hw, &sdata->vif, |
| 537 | sta, changed); |
| 538 | |
| 539 | trace_drv_return_void(local); |
| 540 | } |
| 541 | |
Eliad Peller | f6f3def | 2011-09-25 20:06:54 +0300 | [diff] [blame] | 542 | static inline int drv_conf_tx(struct ieee80211_local *local, |
Johannes Berg | a3304b0 | 2012-03-28 11:04:24 +0200 | [diff] [blame] | 543 | struct ieee80211_sub_if_data *sdata, u16 ac, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 544 | const struct ieee80211_tx_queue_params *params) |
| 545 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 546 | int ret = -EOPNOTSUPP; |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 547 | |
| 548 | might_sleep(); |
| 549 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 550 | check_sdata_in_driver(sdata); |
| 551 | |
Johannes Berg | a3304b0 | 2012-03-28 11:04:24 +0200 | [diff] [blame] | 552 | trace_drv_conf_tx(local, sdata, ac, params); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 553 | if (local->ops->conf_tx) |
Eliad Peller | 8a3a3c8 | 2011-10-02 10:15:52 +0200 | [diff] [blame] | 554 | ret = local->ops->conf_tx(&local->hw, &sdata->vif, |
Johannes Berg | a3304b0 | 2012-03-28 11:04:24 +0200 | [diff] [blame] | 555 | ac, params); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 556 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 557 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 558 | } |
| 559 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 560 | static inline u64 drv_get_tsf(struct ieee80211_local *local, |
| 561 | struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 562 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 563 | u64 ret = -1ULL; |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 564 | |
| 565 | might_sleep(); |
| 566 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 567 | check_sdata_in_driver(sdata); |
| 568 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 569 | trace_drv_get_tsf(local, sdata); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 570 | if (local->ops->get_tsf) |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 571 | ret = local->ops->get_tsf(&local->hw, &sdata->vif); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 572 | trace_drv_return_u64(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 573 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 574 | } |
| 575 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 576 | static inline void drv_set_tsf(struct ieee80211_local *local, |
| 577 | struct ieee80211_sub_if_data *sdata, |
| 578 | u64 tsf) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 579 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 580 | might_sleep(); |
| 581 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 582 | check_sdata_in_driver(sdata); |
| 583 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 584 | trace_drv_set_tsf(local, sdata, tsf); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 585 | if (local->ops->set_tsf) |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 586 | local->ops->set_tsf(&local->hw, &sdata->vif, tsf); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 587 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 588 | } |
| 589 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 590 | static inline void drv_reset_tsf(struct ieee80211_local *local, |
| 591 | struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 592 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 593 | might_sleep(); |
| 594 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 595 | check_sdata_in_driver(sdata); |
| 596 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 597 | trace_drv_reset_tsf(local, sdata); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 598 | if (local->ops->reset_tsf) |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 599 | local->ops->reset_tsf(&local->hw, &sdata->vif); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 600 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 601 | } |
| 602 | |
| 603 | static inline int drv_tx_last_beacon(struct ieee80211_local *local) |
| 604 | { |
Tim Harvey | 91f44b0 | 2010-12-09 13:15:45 -0800 | [diff] [blame] | 605 | int ret = 0; /* default unsuported op for less congestion */ |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 606 | |
| 607 | might_sleep(); |
| 608 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 609 | trace_drv_tx_last_beacon(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 610 | if (local->ops->tx_last_beacon) |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 611 | ret = local->ops->tx_last_beacon(&local->hw); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 612 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 613 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | static inline int drv_ampdu_action(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 617 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 618 | enum ieee80211_ampdu_mlme_action action, |
| 619 | struct ieee80211_sta *sta, u16 tid, |
Johannes Berg | 0b01f03 | 2011-01-18 13:51:05 +0100 | [diff] [blame] | 620 | u16 *ssn, u8 buf_size) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 621 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 622 | int ret = -EOPNOTSUPP; |
Johannes Berg | cfcdbde | 2010-06-10 10:21:48 +0200 | [diff] [blame] | 623 | |
| 624 | might_sleep(); |
| 625 | |
Felix Fietkau | bc192f8 | 2011-11-23 21:09:49 +0700 | [diff] [blame] | 626 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 627 | check_sdata_in_driver(sdata); |
| 628 | |
Johannes Berg | 0b01f03 | 2011-01-18 13:51:05 +0100 | [diff] [blame] | 629 | trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 630 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 631 | if (local->ops->ampdu_action) |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 632 | ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action, |
Johannes Berg | 0b01f03 | 2011-01-18 13:51:05 +0100 | [diff] [blame] | 633 | sta, tid, ssn, buf_size); |
Johannes Berg | 85ad181 | 2010-06-10 10:21:49 +0200 | [diff] [blame] | 634 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 635 | trace_drv_return_int(local, ret); |
| 636 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 637 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 638 | } |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 639 | |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 640 | static inline int drv_get_survey(struct ieee80211_local *local, int idx, |
| 641 | struct survey_info *survey) |
| 642 | { |
| 643 | int ret = -EOPNOTSUPP; |
John W. Linville | c466d4e | 2010-06-29 14:51:23 -0400 | [diff] [blame] | 644 | |
| 645 | trace_drv_get_survey(local, idx, survey); |
| 646 | |
Holger Schurig | 35dd050 | 2010-06-07 16:33:49 +0200 | [diff] [blame] | 647 | if (local->ops->get_survey) |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 648 | ret = local->ops->get_survey(&local->hw, idx, survey); |
John W. Linville | c466d4e | 2010-06-29 14:51:23 -0400 | [diff] [blame] | 649 | |
| 650 | trace_drv_return_int(local, ret); |
| 651 | |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 652 | return ret; |
| 653 | } |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 654 | |
| 655 | static inline void drv_rfkill_poll(struct ieee80211_local *local) |
| 656 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 657 | might_sleep(); |
| 658 | |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 659 | if (local->ops->rfkill_poll) |
| 660 | local->ops->rfkill_poll(&local->hw); |
| 661 | } |
Johannes Berg | a80f7c0 | 2009-12-23 13:15:32 +0100 | [diff] [blame] | 662 | |
| 663 | static inline void drv_flush(struct ieee80211_local *local, bool drop) |
| 664 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 665 | might_sleep(); |
| 666 | |
Johannes Berg | a80f7c0 | 2009-12-23 13:15:32 +0100 | [diff] [blame] | 667 | trace_drv_flush(local, drop); |
| 668 | if (local->ops->flush) |
| 669 | local->ops->flush(&local->hw, drop); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 670 | trace_drv_return_void(local); |
Johannes Berg | a80f7c0 | 2009-12-23 13:15:32 +0100 | [diff] [blame] | 671 | } |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 672 | |
| 673 | static inline void drv_channel_switch(struct ieee80211_local *local, |
| 674 | struct ieee80211_channel_switch *ch_switch) |
| 675 | { |
| 676 | might_sleep(); |
| 677 | |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 678 | trace_drv_channel_switch(local, ch_switch); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 679 | local->ops->channel_switch(&local->hw, ch_switch); |
| 680 | trace_drv_return_void(local); |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 681 | } |
| 682 | |
Bruno Randolf | 15d9675 | 2010-11-10 12:50:56 +0900 | [diff] [blame] | 683 | |
| 684 | static inline int drv_set_antenna(struct ieee80211_local *local, |
| 685 | u32 tx_ant, u32 rx_ant) |
| 686 | { |
| 687 | int ret = -EOPNOTSUPP; |
| 688 | might_sleep(); |
| 689 | if (local->ops->set_antenna) |
| 690 | ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant); |
| 691 | trace_drv_set_antenna(local, tx_ant, rx_ant, ret); |
| 692 | return ret; |
| 693 | } |
| 694 | |
| 695 | static inline int drv_get_antenna(struct ieee80211_local *local, |
| 696 | u32 *tx_ant, u32 *rx_ant) |
| 697 | { |
| 698 | int ret = -EOPNOTSUPP; |
| 699 | might_sleep(); |
| 700 | if (local->ops->get_antenna) |
| 701 | ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant); |
| 702 | trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret); |
| 703 | return ret; |
| 704 | } |
| 705 | |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 706 | static inline int drv_remain_on_channel(struct ieee80211_local *local, |
| 707 | struct ieee80211_channel *chan, |
| 708 | enum nl80211_channel_type chantype, |
| 709 | unsigned int duration) |
| 710 | { |
| 711 | int ret; |
| 712 | |
| 713 | might_sleep(); |
| 714 | |
| 715 | trace_drv_remain_on_channel(local, chan, chantype, duration); |
| 716 | ret = local->ops->remain_on_channel(&local->hw, chan, chantype, |
| 717 | duration); |
| 718 | trace_drv_return_int(local, ret); |
| 719 | |
| 720 | return ret; |
| 721 | } |
| 722 | |
| 723 | static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local) |
| 724 | { |
| 725 | int ret; |
| 726 | |
| 727 | might_sleep(); |
| 728 | |
| 729 | trace_drv_cancel_remain_on_channel(local); |
| 730 | ret = local->ops->cancel_remain_on_channel(&local->hw); |
| 731 | trace_drv_return_int(local, ret); |
| 732 | |
| 733 | return ret; |
| 734 | } |
| 735 | |
John W. Linville | 38c0915 | 2011-03-07 16:19:18 -0500 | [diff] [blame] | 736 | static inline int drv_set_ringparam(struct ieee80211_local *local, |
| 737 | u32 tx, u32 rx) |
| 738 | { |
| 739 | int ret = -ENOTSUPP; |
| 740 | |
| 741 | might_sleep(); |
| 742 | |
| 743 | trace_drv_set_ringparam(local, tx, rx); |
| 744 | if (local->ops->set_ringparam) |
| 745 | ret = local->ops->set_ringparam(&local->hw, tx, rx); |
| 746 | trace_drv_return_int(local, ret); |
| 747 | |
| 748 | return ret; |
| 749 | } |
| 750 | |
| 751 | static inline void drv_get_ringparam(struct ieee80211_local *local, |
| 752 | u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max) |
| 753 | { |
| 754 | might_sleep(); |
| 755 | |
| 756 | trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max); |
| 757 | if (local->ops->get_ringparam) |
| 758 | local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max); |
| 759 | trace_drv_return_void(local); |
| 760 | } |
| 761 | |
Vivek Natarajan | e8306f9 | 2011-04-06 11:41:10 +0530 | [diff] [blame] | 762 | static inline bool drv_tx_frames_pending(struct ieee80211_local *local) |
| 763 | { |
| 764 | bool ret = false; |
| 765 | |
| 766 | might_sleep(); |
| 767 | |
| 768 | trace_drv_tx_frames_pending(local); |
| 769 | if (local->ops->tx_frames_pending) |
| 770 | ret = local->ops->tx_frames_pending(&local->hw); |
| 771 | trace_drv_return_bool(local, ret); |
| 772 | |
| 773 | return ret; |
| 774 | } |
Sujith Manoharan | bdbfd6b | 2011-04-27 16:56:51 +0530 | [diff] [blame] | 775 | |
| 776 | static inline int drv_set_bitrate_mask(struct ieee80211_local *local, |
| 777 | struct ieee80211_sub_if_data *sdata, |
| 778 | const struct cfg80211_bitrate_mask *mask) |
| 779 | { |
| 780 | int ret = -EOPNOTSUPP; |
| 781 | |
| 782 | might_sleep(); |
| 783 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 784 | check_sdata_in_driver(sdata); |
| 785 | |
Sujith Manoharan | bdbfd6b | 2011-04-27 16:56:51 +0530 | [diff] [blame] | 786 | trace_drv_set_bitrate_mask(local, sdata, mask); |
| 787 | if (local->ops->set_bitrate_mask) |
| 788 | ret = local->ops->set_bitrate_mask(&local->hw, |
| 789 | &sdata->vif, mask); |
| 790 | trace_drv_return_int(local, ret); |
| 791 | |
| 792 | return ret; |
| 793 | } |
| 794 | |
Johannes Berg | c68f4b8 | 2011-07-05 16:35:41 +0200 | [diff] [blame] | 795 | static inline void drv_set_rekey_data(struct ieee80211_local *local, |
| 796 | struct ieee80211_sub_if_data *sdata, |
| 797 | struct cfg80211_gtk_rekey_data *data) |
| 798 | { |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 799 | check_sdata_in_driver(sdata); |
| 800 | |
Johannes Berg | c68f4b8 | 2011-07-05 16:35:41 +0200 | [diff] [blame] | 801 | trace_drv_set_rekey_data(local, sdata, data); |
| 802 | if (local->ops->set_rekey_data) |
| 803 | local->ops->set_rekey_data(&local->hw, &sdata->vif, data); |
| 804 | trace_drv_return_void(local); |
| 805 | } |
| 806 | |
Meenakshi Venkataraman | 615f7b9 | 2011-07-08 08:46:22 -0700 | [diff] [blame] | 807 | static inline void drv_rssi_callback(struct ieee80211_local *local, |
| 808 | const enum ieee80211_rssi_event event) |
| 809 | { |
| 810 | trace_drv_rssi_callback(local, event); |
| 811 | if (local->ops->rssi_callback) |
| 812 | local->ops->rssi_callback(&local->hw, event); |
| 813 | trace_drv_return_void(local); |
| 814 | } |
Johannes Berg | 4049e09 | 2011-09-29 16:04:32 +0200 | [diff] [blame] | 815 | |
| 816 | static inline void |
| 817 | drv_release_buffered_frames(struct ieee80211_local *local, |
| 818 | struct sta_info *sta, u16 tids, int num_frames, |
| 819 | enum ieee80211_frame_release_type reason, |
| 820 | bool more_data) |
| 821 | { |
| 822 | trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames, |
| 823 | reason, more_data); |
| 824 | if (local->ops->release_buffered_frames) |
| 825 | local->ops->release_buffered_frames(&local->hw, &sta->sta, tids, |
| 826 | num_frames, reason, |
| 827 | more_data); |
| 828 | trace_drv_return_void(local); |
| 829 | } |
Johannes Berg | 40b9640 | 2011-09-29 16:04:38 +0200 | [diff] [blame] | 830 | |
| 831 | static inline void |
| 832 | drv_allow_buffered_frames(struct ieee80211_local *local, |
| 833 | struct sta_info *sta, u16 tids, int num_frames, |
| 834 | enum ieee80211_frame_release_type reason, |
| 835 | bool more_data) |
| 836 | { |
| 837 | trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames, |
| 838 | reason, more_data); |
| 839 | if (local->ops->allow_buffered_frames) |
| 840 | local->ops->allow_buffered_frames(&local->hw, &sta->sta, |
| 841 | tids, num_frames, reason, |
| 842 | more_data); |
| 843 | trace_drv_return_void(local); |
| 844 | } |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 845 | |
| 846 | static inline int drv_get_rssi(struct ieee80211_local *local, |
| 847 | struct ieee80211_sub_if_data *sdata, |
| 848 | struct ieee80211_sta *sta, |
| 849 | s8 *rssi_dbm) |
| 850 | { |
| 851 | int ret; |
| 852 | |
| 853 | might_sleep(); |
| 854 | |
| 855 | ret = local->ops->get_rssi(&local->hw, &sdata->vif, sta, rssi_dbm); |
| 856 | trace_drv_get_rssi(local, sta, *rssi_dbm, ret); |
| 857 | |
| 858 | return ret; |
| 859 | } |
Johannes Berg | a1845fc | 2012-06-27 13:18:36 +0200 | [diff] [blame] | 860 | |
| 861 | static inline void drv_mgd_prepare_tx(struct ieee80211_local *local, |
| 862 | struct ieee80211_sub_if_data *sdata) |
| 863 | { |
| 864 | might_sleep(); |
| 865 | |
| 866 | check_sdata_in_driver(sdata); |
| 867 | WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION); |
| 868 | |
| 869 | trace_drv_mgd_prepare_tx(local, sdata); |
| 870 | if (local->ops->mgd_prepare_tx) |
| 871 | local->ops->mgd_prepare_tx(&local->hw, &sdata->vif); |
| 872 | trace_drv_return_void(local); |
| 873 | } |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 874 | |
| 875 | static inline int drv_add_chanctx(struct ieee80211_local *local, |
| 876 | struct ieee80211_chanctx *ctx) |
| 877 | { |
| 878 | int ret = -EOPNOTSUPP; |
| 879 | |
| 880 | trace_drv_add_chanctx(local, ctx); |
| 881 | if (local->ops->add_chanctx) |
| 882 | ret = local->ops->add_chanctx(&local->hw, &ctx->conf); |
| 883 | trace_drv_return_int(local, ret); |
| 884 | |
| 885 | return ret; |
| 886 | } |
| 887 | |
| 888 | static inline void drv_remove_chanctx(struct ieee80211_local *local, |
| 889 | struct ieee80211_chanctx *ctx) |
| 890 | { |
| 891 | trace_drv_remove_chanctx(local, ctx); |
| 892 | if (local->ops->remove_chanctx) |
| 893 | local->ops->remove_chanctx(&local->hw, &ctx->conf); |
| 894 | trace_drv_return_void(local); |
| 895 | } |
| 896 | |
| 897 | static inline void drv_change_chanctx(struct ieee80211_local *local, |
| 898 | struct ieee80211_chanctx *ctx, |
| 899 | u32 changed) |
| 900 | { |
| 901 | trace_drv_change_chanctx(local, ctx, changed); |
| 902 | if (local->ops->change_chanctx) |
| 903 | local->ops->change_chanctx(&local->hw, &ctx->conf, changed); |
| 904 | trace_drv_return_void(local); |
| 905 | } |
| 906 | |
| 907 | static inline int drv_assign_vif_chanctx(struct ieee80211_local *local, |
| 908 | struct ieee80211_sub_if_data *sdata, |
| 909 | struct ieee80211_chanctx *ctx) |
| 910 | { |
| 911 | int ret = 0; |
| 912 | |
| 913 | check_sdata_in_driver(sdata); |
| 914 | |
| 915 | trace_drv_assign_vif_chanctx(local, sdata, ctx); |
| 916 | if (local->ops->assign_vif_chanctx) |
| 917 | ret = local->ops->assign_vif_chanctx(&local->hw, |
| 918 | &sdata->vif, |
| 919 | &ctx->conf); |
| 920 | trace_drv_return_int(local, ret); |
| 921 | |
| 922 | return ret; |
| 923 | } |
| 924 | |
| 925 | static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local, |
| 926 | struct ieee80211_sub_if_data *sdata, |
| 927 | struct ieee80211_chanctx *ctx) |
| 928 | { |
| 929 | check_sdata_in_driver(sdata); |
| 930 | |
| 931 | trace_drv_unassign_vif_chanctx(local, sdata, ctx); |
| 932 | if (local->ops->unassign_vif_chanctx) |
| 933 | local->ops->unassign_vif_chanctx(&local->hw, |
| 934 | &sdata->vif, |
| 935 | &ctx->conf); |
| 936 | trace_drv_return_void(local); |
| 937 | } |
| 938 | |
Johannes Berg | 1041638 | 2012-10-19 15:44:42 +0200 | [diff] [blame] | 939 | static inline int drv_start_ap(struct ieee80211_local *local, |
| 940 | struct ieee80211_sub_if_data *sdata) |
| 941 | { |
| 942 | int ret = 0; |
| 943 | |
| 944 | check_sdata_in_driver(sdata); |
| 945 | |
| 946 | trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf); |
| 947 | if (local->ops->start_ap) |
| 948 | ret = local->ops->start_ap(&local->hw, &sdata->vif); |
| 949 | trace_drv_return_int(local, ret); |
| 950 | return ret; |
| 951 | } |
| 952 | |
| 953 | static inline void drv_stop_ap(struct ieee80211_local *local, |
| 954 | struct ieee80211_sub_if_data *sdata) |
| 955 | { |
| 956 | check_sdata_in_driver(sdata); |
| 957 | |
| 958 | trace_drv_stop_ap(local, sdata); |
| 959 | if (local->ops->stop_ap) |
| 960 | local->ops->stop_ap(&local->hw, &sdata->vif); |
| 961 | trace_drv_return_void(local); |
| 962 | } |
| 963 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 964 | #endif /* __MAC80211_DRIVER_OPS */ |