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 | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 6 | #include "driver-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", |
| 12 | sdata->dev->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 | |
Johannes Berg | 7bb4568 | 2011-02-24 14:42:06 +0100 | [diff] [blame] | 25 | static inline void drv_tx(struct ieee80211_local *local, struct sk_buff *skb) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 26 | { |
Johannes Berg | 7bb4568 | 2011-02-24 14:42:06 +0100 | [diff] [blame] | 27 | local->ops->tx(&local->hw, skb); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 28 | } |
| 29 | |
Johannes Berg | 11127e9 | 2011-11-16 16:02:47 +0100 | [diff] [blame] | 30 | static inline void drv_tx_frags(struct ieee80211_local *local, |
| 31 | struct ieee80211_vif *vif, |
| 32 | struct ieee80211_sta *sta, |
| 33 | struct sk_buff_head *skbs) |
| 34 | { |
| 35 | local->ops->tx_frags(&local->hw, vif, sta, skbs); |
| 36 | } |
| 37 | |
Ben Greear | e352114 | 2012-04-23 12:50:31 -0700 | [diff] [blame] | 38 | static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata, |
| 39 | u32 sset, u8 *data) |
| 40 | { |
| 41 | struct ieee80211_local *local = sdata->local; |
| 42 | if (local->ops->get_et_strings) { |
| 43 | trace_drv_get_et_strings(local, sset); |
| 44 | local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data); |
| 45 | trace_drv_return_void(local); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata, |
| 50 | struct ethtool_stats *stats, |
| 51 | u64 *data) |
| 52 | { |
| 53 | struct ieee80211_local *local = sdata->local; |
| 54 | if (local->ops->get_et_stats) { |
| 55 | trace_drv_get_et_stats(local); |
| 56 | local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data); |
| 57 | trace_drv_return_void(local); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata, |
| 62 | int sset) |
| 63 | { |
| 64 | struct ieee80211_local *local = sdata->local; |
| 65 | int rv = 0; |
| 66 | if (local->ops->get_et_sset_count) { |
| 67 | trace_drv_get_et_sset_count(local, sset); |
| 68 | rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif, |
| 69 | sset); |
| 70 | trace_drv_return_int(local, rv); |
| 71 | } |
| 72 | return rv; |
| 73 | } |
| 74 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 75 | static inline int drv_start(struct ieee80211_local *local) |
| 76 | { |
Johannes Berg | ea77f12 | 2009-08-21 14:44:45 +0200 | [diff] [blame] | 77 | int ret; |
| 78 | |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 79 | might_sleep(); |
| 80 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 81 | trace_drv_start(local); |
Johannes Berg | ea77f12 | 2009-08-21 14:44:45 +0200 | [diff] [blame] | 82 | local->started = true; |
| 83 | smp_mb(); |
| 84 | ret = local->ops->start(&local->hw); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 85 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 86 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | static inline void drv_stop(struct ieee80211_local *local) |
| 90 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 91 | might_sleep(); |
| 92 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 93 | trace_drv_stop(local); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 94 | local->ops->stop(&local->hw); |
| 95 | trace_drv_return_void(local); |
Johannes Berg | ea77f12 | 2009-08-21 14:44:45 +0200 | [diff] [blame] | 96 | |
| 97 | /* sync away all work on the tasklet before clearing started */ |
| 98 | tasklet_disable(&local->tasklet); |
| 99 | tasklet_enable(&local->tasklet); |
| 100 | |
| 101 | barrier(); |
| 102 | |
| 103 | local->started = false; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 104 | } |
| 105 | |
Johannes Berg | eecc480 | 2011-05-04 15:37:29 +0200 | [diff] [blame] | 106 | #ifdef CONFIG_PM |
| 107 | static inline int drv_suspend(struct ieee80211_local *local, |
| 108 | struct cfg80211_wowlan *wowlan) |
| 109 | { |
| 110 | int ret; |
| 111 | |
| 112 | might_sleep(); |
| 113 | |
| 114 | trace_drv_suspend(local); |
| 115 | ret = local->ops->suspend(&local->hw, wowlan); |
| 116 | trace_drv_return_int(local, ret); |
| 117 | return ret; |
| 118 | } |
| 119 | |
| 120 | static inline int drv_resume(struct ieee80211_local *local) |
| 121 | { |
| 122 | int ret; |
| 123 | |
| 124 | might_sleep(); |
| 125 | |
| 126 | trace_drv_resume(local); |
| 127 | ret = local->ops->resume(&local->hw); |
| 128 | trace_drv_return_int(local, ret); |
| 129 | return ret; |
| 130 | } |
Johannes Berg | 6d52563 | 2012-04-04 15:05:25 +0200 | [diff] [blame] | 131 | |
| 132 | static inline void drv_set_wakeup(struct ieee80211_local *local, |
| 133 | bool enabled) |
| 134 | { |
| 135 | might_sleep(); |
| 136 | |
| 137 | if (!local->ops->set_wakeup) |
| 138 | return; |
| 139 | |
| 140 | trace_drv_set_wakeup(local, enabled); |
| 141 | local->ops->set_wakeup(&local->hw, enabled); |
| 142 | trace_drv_return_void(local); |
| 143 | } |
Johannes Berg | eecc480 | 2011-05-04 15:37:29 +0200 | [diff] [blame] | 144 | #endif |
| 145 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 146 | static inline int drv_add_interface(struct ieee80211_local *local, |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 147 | struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 148 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 149 | int ret; |
| 150 | |
| 151 | might_sleep(); |
| 152 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 153 | if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN || |
Johannes Berg | 4b6f1dd | 2012-04-03 14:35:57 +0200 | [diff] [blame] | 154 | (sdata->vif.type == NL80211_IFTYPE_MONITOR && |
| 155 | !(local->hw.flags & IEEE80211_HW_WANT_MONITOR_VIF)))) |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 156 | return -EINVAL; |
| 157 | |
| 158 | trace_drv_add_interface(local, sdata); |
| 159 | ret = local->ops->add_interface(&local->hw, &sdata->vif); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 160 | trace_drv_return_int(local, ret); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 161 | |
| 162 | if (ret == 0) |
| 163 | sdata->flags |= IEEE80211_SDATA_IN_DRIVER; |
| 164 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 165 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 166 | } |
| 167 | |
Johannes Berg | 34d4bc4 | 2010-08-27 12:35:58 +0200 | [diff] [blame] | 168 | static inline int drv_change_interface(struct ieee80211_local *local, |
| 169 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2ca27bc | 2010-09-16 14:58:23 +0200 | [diff] [blame] | 170 | enum nl80211_iftype type, bool p2p) |
Johannes Berg | 34d4bc4 | 2010-08-27 12:35:58 +0200 | [diff] [blame] | 171 | { |
| 172 | int ret; |
| 173 | |
| 174 | might_sleep(); |
| 175 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 176 | check_sdata_in_driver(sdata); |
| 177 | |
Johannes Berg | 2ca27bc | 2010-09-16 14:58:23 +0200 | [diff] [blame] | 178 | trace_drv_change_interface(local, sdata, type, p2p); |
| 179 | ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p); |
Johannes Berg | 34d4bc4 | 2010-08-27 12:35:58 +0200 | [diff] [blame] | 180 | trace_drv_return_int(local, ret); |
| 181 | return ret; |
| 182 | } |
| 183 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 184 | static inline void drv_remove_interface(struct ieee80211_local *local, |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 185 | struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 186 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 187 | might_sleep(); |
| 188 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 189 | check_sdata_in_driver(sdata); |
| 190 | |
| 191 | trace_drv_remove_interface(local, sdata); |
| 192 | local->ops->remove_interface(&local->hw, &sdata->vif); |
| 193 | sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER; |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 194 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | static inline int drv_config(struct ieee80211_local *local, u32 changed) |
| 198 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 199 | int ret; |
| 200 | |
| 201 | might_sleep(); |
| 202 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 203 | trace_drv_config(local, changed); |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 204 | ret = local->ops->config(&local->hw, changed); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 205 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 206 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | static inline void drv_bss_info_changed(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 210 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 211 | struct ieee80211_bss_conf *info, |
| 212 | u32 changed) |
| 213 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 214 | might_sleep(); |
| 215 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 216 | check_sdata_in_driver(sdata); |
| 217 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 218 | trace_drv_bss_info_changed(local, sdata, info, changed); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 219 | if (local->ops->bss_info_changed) |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 220 | local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 221 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 222 | } |
| 223 | |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 224 | static inline u64 drv_prepare_multicast(struct ieee80211_local *local, |
Jiri Pirko | 22bedad3 | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 225 | struct netdev_hw_addr_list *mc_list) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 226 | { |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 227 | u64 ret = 0; |
| 228 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 229 | trace_drv_prepare_multicast(local, mc_list->count); |
| 230 | |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 231 | if (local->ops->prepare_multicast) |
Jiri Pirko | 22bedad3 | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 232 | ret = local->ops->prepare_multicast(&local->hw, mc_list); |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 233 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 234 | trace_drv_return_u64(local, ret); |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 235 | |
| 236 | return ret; |
| 237 | } |
| 238 | |
| 239 | static inline void drv_configure_filter(struct ieee80211_local *local, |
| 240 | unsigned int changed_flags, |
| 241 | unsigned int *total_flags, |
| 242 | u64 multicast) |
| 243 | { |
| 244 | might_sleep(); |
| 245 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 246 | trace_drv_configure_filter(local, changed_flags, total_flags, |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 247 | multicast); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 248 | local->ops->configure_filter(&local->hw, changed_flags, total_flags, |
| 249 | multicast); |
| 250 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | static inline int drv_set_tim(struct ieee80211_local *local, |
| 254 | struct ieee80211_sta *sta, bool set) |
| 255 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 256 | int ret = 0; |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 257 | trace_drv_set_tim(local, sta, set); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 258 | if (local->ops->set_tim) |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 259 | ret = local->ops->set_tim(&local->hw, sta, set); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 260 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 261 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | static inline int drv_set_key(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 265 | enum set_key_cmd cmd, |
| 266 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 267 | struct ieee80211_sta *sta, |
| 268 | struct ieee80211_key_conf *key) |
| 269 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 270 | int ret; |
| 271 | |
| 272 | might_sleep(); |
| 273 | |
Johannes Berg | 077f493 | 2012-01-20 13:55:18 +0100 | [diff] [blame] | 274 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 275 | check_sdata_in_driver(sdata); |
| 276 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 277 | trace_drv_set_key(local, cmd, sdata, sta, key); |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 278 | ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 279 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 280 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | static inline void drv_update_tkip_key(struct ieee80211_local *local, |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 284 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 285 | struct ieee80211_key_conf *conf, |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 286 | struct sta_info *sta, u32 iv32, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 287 | u16 *phase1key) |
| 288 | { |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 289 | struct ieee80211_sta *ista = NULL; |
| 290 | |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 291 | if (sta) |
| 292 | ista = &sta->sta; |
| 293 | |
Johannes Berg | 077f493 | 2012-01-20 13:55:18 +0100 | [diff] [blame] | 294 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 295 | check_sdata_in_driver(sdata); |
| 296 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 297 | trace_drv_update_tkip_key(local, sdata, conf, ista, iv32); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 298 | if (local->ops->update_tkip_key) |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 299 | local->ops->update_tkip_key(&local->hw, &sdata->vif, conf, |
| 300 | ista, iv32, phase1key); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 301 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | static inline int drv_hw_scan(struct ieee80211_local *local, |
Johannes Berg | a060bbf | 2010-04-27 11:59:34 +0200 | [diff] [blame] | 305 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 306 | struct cfg80211_scan_request *req) |
| 307 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 308 | int ret; |
| 309 | |
| 310 | might_sleep(); |
| 311 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 312 | check_sdata_in_driver(sdata); |
| 313 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 314 | trace_drv_hw_scan(local, sdata); |
Johannes Berg | a060bbf | 2010-04-27 11:59:34 +0200 | [diff] [blame] | 315 | ret = local->ops->hw_scan(&local->hw, &sdata->vif, req); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 316 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 317 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 318 | } |
| 319 | |
Eliad Peller | b856439 | 2011-06-13 12:47:30 +0300 | [diff] [blame] | 320 | static inline void drv_cancel_hw_scan(struct ieee80211_local *local, |
| 321 | struct ieee80211_sub_if_data *sdata) |
| 322 | { |
| 323 | might_sleep(); |
| 324 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 325 | check_sdata_in_driver(sdata); |
| 326 | |
Eliad Peller | b856439 | 2011-06-13 12:47:30 +0300 | [diff] [blame] | 327 | trace_drv_cancel_hw_scan(local, sdata); |
| 328 | local->ops->cancel_hw_scan(&local->hw, &sdata->vif); |
| 329 | trace_drv_return_void(local); |
| 330 | } |
| 331 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 332 | static inline int |
| 333 | drv_sched_scan_start(struct ieee80211_local *local, |
| 334 | struct ieee80211_sub_if_data *sdata, |
| 335 | struct cfg80211_sched_scan_request *req, |
| 336 | struct ieee80211_sched_scan_ies *ies) |
| 337 | { |
| 338 | int ret; |
| 339 | |
| 340 | might_sleep(); |
| 341 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 342 | check_sdata_in_driver(sdata); |
| 343 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 344 | trace_drv_sched_scan_start(local, sdata); |
| 345 | ret = local->ops->sched_scan_start(&local->hw, &sdata->vif, |
| 346 | req, ies); |
| 347 | trace_drv_return_int(local, ret); |
| 348 | return ret; |
| 349 | } |
| 350 | |
| 351 | static inline void drv_sched_scan_stop(struct ieee80211_local *local, |
| 352 | struct ieee80211_sub_if_data *sdata) |
| 353 | { |
| 354 | might_sleep(); |
| 355 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 356 | check_sdata_in_driver(sdata); |
| 357 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 358 | trace_drv_sched_scan_stop(local, sdata); |
| 359 | local->ops->sched_scan_stop(&local->hw, &sdata->vif); |
| 360 | trace_drv_return_void(local); |
| 361 | } |
| 362 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 363 | static inline void drv_sw_scan_start(struct ieee80211_local *local) |
| 364 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 365 | might_sleep(); |
| 366 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 367 | trace_drv_sw_scan_start(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 368 | if (local->ops->sw_scan_start) |
| 369 | local->ops->sw_scan_start(&local->hw); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 370 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | static inline void drv_sw_scan_complete(struct ieee80211_local *local) |
| 374 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 375 | might_sleep(); |
| 376 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 377 | trace_drv_sw_scan_complete(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 378 | if (local->ops->sw_scan_complete) |
| 379 | local->ops->sw_scan_complete(&local->hw); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 380 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | static inline int drv_get_stats(struct ieee80211_local *local, |
| 384 | struct ieee80211_low_level_stats *stats) |
| 385 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 386 | int ret = -EOPNOTSUPP; |
| 387 | |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 388 | might_sleep(); |
| 389 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 390 | if (local->ops->get_stats) |
| 391 | ret = local->ops->get_stats(&local->hw, stats); |
| 392 | trace_drv_get_stats(local, stats, ret); |
| 393 | |
| 394 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 395 | } |
| 396 | |
| 397 | static inline void drv_get_tkip_seq(struct ieee80211_local *local, |
| 398 | u8 hw_key_idx, u32 *iv32, u16 *iv16) |
| 399 | { |
| 400 | if (local->ops->get_tkip_seq) |
| 401 | local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 402 | trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 403 | } |
| 404 | |
Arik Nemtsov | f23a478 | 2010-11-08 11:51:06 +0200 | [diff] [blame] | 405 | static inline int drv_set_frag_threshold(struct ieee80211_local *local, |
| 406 | u32 value) |
| 407 | { |
| 408 | int ret = 0; |
| 409 | |
| 410 | might_sleep(); |
| 411 | |
| 412 | trace_drv_set_frag_threshold(local, value); |
| 413 | if (local->ops->set_frag_threshold) |
| 414 | ret = local->ops->set_frag_threshold(&local->hw, value); |
| 415 | trace_drv_return_int(local, ret); |
| 416 | return ret; |
| 417 | } |
| 418 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 419 | static inline int drv_set_rts_threshold(struct ieee80211_local *local, |
| 420 | u32 value) |
| 421 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 422 | int ret = 0; |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 423 | |
| 424 | might_sleep(); |
| 425 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 426 | trace_drv_set_rts_threshold(local, value); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 427 | if (local->ops->set_rts_threshold) |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 428 | ret = local->ops->set_rts_threshold(&local->hw, value); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 429 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 430 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 431 | } |
| 432 | |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 433 | static inline int drv_set_coverage_class(struct ieee80211_local *local, |
| 434 | u8 value) |
| 435 | { |
| 436 | int ret = 0; |
| 437 | might_sleep(); |
| 438 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 439 | trace_drv_set_coverage_class(local, value); |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 440 | if (local->ops->set_coverage_class) |
| 441 | local->ops->set_coverage_class(&local->hw, value); |
| 442 | else |
| 443 | ret = -EOPNOTSUPP; |
| 444 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 445 | trace_drv_return_int(local, ret); |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 446 | return ret; |
| 447 | } |
| 448 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 449 | static inline void drv_sta_notify(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 450 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 451 | enum sta_notify_cmd cmd, |
| 452 | struct ieee80211_sta *sta) |
| 453 | { |
Felix Fietkau | bc192f8 | 2011-11-23 21:09:49 +0700 | [diff] [blame] | 454 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 455 | check_sdata_in_driver(sdata); |
| 456 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 457 | trace_drv_sta_notify(local, sdata, cmd, sta); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 458 | if (local->ops->sta_notify) |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 459 | local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 460 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 461 | } |
| 462 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 463 | static inline int drv_sta_add(struct ieee80211_local *local, |
| 464 | struct ieee80211_sub_if_data *sdata, |
| 465 | struct ieee80211_sta *sta) |
| 466 | { |
| 467 | int ret = 0; |
| 468 | |
| 469 | might_sleep(); |
| 470 | |
Felix Fietkau | bc192f8 | 2011-11-23 21:09:49 +0700 | [diff] [blame] | 471 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 472 | check_sdata_in_driver(sdata); |
| 473 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 474 | trace_drv_sta_add(local, sdata, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 475 | if (local->ops->sta_add) |
| 476 | ret = local->ops->sta_add(&local->hw, &sdata->vif, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 477 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 478 | trace_drv_return_int(local, ret); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 479 | |
| 480 | return ret; |
| 481 | } |
| 482 | |
| 483 | static inline void drv_sta_remove(struct ieee80211_local *local, |
| 484 | struct ieee80211_sub_if_data *sdata, |
| 485 | struct ieee80211_sta *sta) |
| 486 | { |
| 487 | might_sleep(); |
| 488 | |
Felix Fietkau | bc192f8 | 2011-11-23 21:09:49 +0700 | [diff] [blame] | 489 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 490 | check_sdata_in_driver(sdata); |
| 491 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 492 | trace_drv_sta_remove(local, sdata, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 493 | if (local->ops->sta_remove) |
| 494 | local->ops->sta_remove(&local->hw, &sdata->vif, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 495 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 496 | trace_drv_return_void(local); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 497 | } |
| 498 | |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 499 | static inline __must_check |
| 500 | int drv_sta_state(struct ieee80211_local *local, |
| 501 | struct ieee80211_sub_if_data *sdata, |
| 502 | struct sta_info *sta, |
| 503 | enum ieee80211_sta_state old_state, |
| 504 | enum ieee80211_sta_state new_state) |
| 505 | { |
| 506 | int ret = 0; |
| 507 | |
| 508 | might_sleep(); |
| 509 | |
| 510 | sdata = get_bss_sdata(sdata); |
| 511 | check_sdata_in_driver(sdata); |
| 512 | |
| 513 | trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state); |
Johannes Berg | a4ec45a | 2012-01-20 13:55:22 +0100 | [diff] [blame] | 514 | if (local->ops->sta_state) { |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 515 | ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta, |
| 516 | old_state, new_state); |
Johannes Berg | a4ec45a | 2012-01-20 13:55:22 +0100 | [diff] [blame] | 517 | } else if (old_state == IEEE80211_STA_AUTH && |
| 518 | new_state == IEEE80211_STA_ASSOC) { |
| 519 | ret = drv_sta_add(local, sdata, &sta->sta); |
| 520 | if (ret == 0) |
| 521 | sta->uploaded = true; |
| 522 | } else if (old_state == IEEE80211_STA_ASSOC && |
| 523 | new_state == IEEE80211_STA_AUTH) { |
| 524 | drv_sta_remove(local, sdata, &sta->sta); |
| 525 | } |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 526 | trace_drv_return_int(local, ret); |
| 527 | return ret; |
| 528 | } |
| 529 | |
Johannes Berg | 8f727ef | 2012-03-30 08:43:32 +0200 | [diff] [blame] | 530 | static inline void drv_sta_rc_update(struct ieee80211_local *local, |
| 531 | struct ieee80211_sub_if_data *sdata, |
| 532 | struct ieee80211_sta *sta, u32 changed) |
| 533 | { |
| 534 | sdata = get_bss_sdata(sdata); |
| 535 | check_sdata_in_driver(sdata); |
| 536 | |
| 537 | trace_drv_sta_rc_update(local, sdata, sta, changed); |
| 538 | if (local->ops->sta_rc_update) |
| 539 | local->ops->sta_rc_update(&local->hw, &sdata->vif, |
| 540 | sta, changed); |
| 541 | |
| 542 | trace_drv_return_void(local); |
| 543 | } |
| 544 | |
Eliad Peller | f6f3def | 2011-09-25 20:06:54 +0300 | [diff] [blame] | 545 | static inline int drv_conf_tx(struct ieee80211_local *local, |
Johannes Berg | a3304b0 | 2012-03-28 11:04:24 +0200 | [diff] [blame] | 546 | struct ieee80211_sub_if_data *sdata, u16 ac, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 547 | const struct ieee80211_tx_queue_params *params) |
| 548 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 549 | int ret = -EOPNOTSUPP; |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 550 | |
| 551 | might_sleep(); |
| 552 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 553 | check_sdata_in_driver(sdata); |
| 554 | |
Johannes Berg | a3304b0 | 2012-03-28 11:04:24 +0200 | [diff] [blame] | 555 | trace_drv_conf_tx(local, sdata, ac, params); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 556 | if (local->ops->conf_tx) |
Eliad Peller | 8a3a3c8 | 2011-10-02 10:15:52 +0200 | [diff] [blame] | 557 | ret = local->ops->conf_tx(&local->hw, &sdata->vif, |
Johannes Berg | a3304b0 | 2012-03-28 11:04:24 +0200 | [diff] [blame] | 558 | ac, params); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 559 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 560 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 561 | } |
| 562 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 563 | static inline u64 drv_get_tsf(struct ieee80211_local *local, |
| 564 | struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 565 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 566 | u64 ret = -1ULL; |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 567 | |
| 568 | might_sleep(); |
| 569 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 570 | check_sdata_in_driver(sdata); |
| 571 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 572 | trace_drv_get_tsf(local, sdata); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 573 | if (local->ops->get_tsf) |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 574 | ret = local->ops->get_tsf(&local->hw, &sdata->vif); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 575 | trace_drv_return_u64(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 576 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 577 | } |
| 578 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 579 | static inline void drv_set_tsf(struct ieee80211_local *local, |
| 580 | struct ieee80211_sub_if_data *sdata, |
| 581 | u64 tsf) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 582 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 583 | might_sleep(); |
| 584 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 585 | check_sdata_in_driver(sdata); |
| 586 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 587 | trace_drv_set_tsf(local, sdata, tsf); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 588 | if (local->ops->set_tsf) |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 589 | local->ops->set_tsf(&local->hw, &sdata->vif, tsf); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 590 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 591 | } |
| 592 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 593 | static inline void drv_reset_tsf(struct ieee80211_local *local, |
| 594 | struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 595 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 596 | might_sleep(); |
| 597 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 598 | check_sdata_in_driver(sdata); |
| 599 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 600 | trace_drv_reset_tsf(local, sdata); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 601 | if (local->ops->reset_tsf) |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 602 | local->ops->reset_tsf(&local->hw, &sdata->vif); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 603 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | static inline int drv_tx_last_beacon(struct ieee80211_local *local) |
| 607 | { |
Tim Harvey | 91f44b0 | 2010-12-09 13:15:45 -0800 | [diff] [blame] | 608 | int ret = 0; /* default unsuported op for less congestion */ |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 609 | |
| 610 | might_sleep(); |
| 611 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 612 | trace_drv_tx_last_beacon(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 613 | if (local->ops->tx_last_beacon) |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 614 | ret = local->ops->tx_last_beacon(&local->hw); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 615 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 616 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 617 | } |
| 618 | |
| 619 | static inline int drv_ampdu_action(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 620 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 621 | enum ieee80211_ampdu_mlme_action action, |
| 622 | struct ieee80211_sta *sta, u16 tid, |
Johannes Berg | 0b01f03 | 2011-01-18 13:51:05 +0100 | [diff] [blame] | 623 | u16 *ssn, u8 buf_size) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 624 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 625 | int ret = -EOPNOTSUPP; |
Johannes Berg | cfcdbde | 2010-06-10 10:21:48 +0200 | [diff] [blame] | 626 | |
| 627 | might_sleep(); |
| 628 | |
Felix Fietkau | bc192f8 | 2011-11-23 21:09:49 +0700 | [diff] [blame] | 629 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 630 | check_sdata_in_driver(sdata); |
| 631 | |
Johannes Berg | 0b01f03 | 2011-01-18 13:51:05 +0100 | [diff] [blame] | 632 | trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 633 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 634 | if (local->ops->ampdu_action) |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 635 | ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action, |
Johannes Berg | 0b01f03 | 2011-01-18 13:51:05 +0100 | [diff] [blame] | 636 | sta, tid, ssn, buf_size); |
Johannes Berg | 85ad181 | 2010-06-10 10:21:49 +0200 | [diff] [blame] | 637 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 638 | trace_drv_return_int(local, ret); |
| 639 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 640 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 641 | } |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 642 | |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 643 | static inline int drv_get_survey(struct ieee80211_local *local, int idx, |
| 644 | struct survey_info *survey) |
| 645 | { |
| 646 | int ret = -EOPNOTSUPP; |
John W. Linville | c466d4e | 2010-06-29 14:51:23 -0400 | [diff] [blame] | 647 | |
| 648 | trace_drv_get_survey(local, idx, survey); |
| 649 | |
Holger Schurig | 35dd050 | 2010-06-07 16:33:49 +0200 | [diff] [blame] | 650 | if (local->ops->get_survey) |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 651 | ret = local->ops->get_survey(&local->hw, idx, survey); |
John W. Linville | c466d4e | 2010-06-29 14:51:23 -0400 | [diff] [blame] | 652 | |
| 653 | trace_drv_return_int(local, ret); |
| 654 | |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 655 | return ret; |
| 656 | } |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 657 | |
| 658 | static inline void drv_rfkill_poll(struct ieee80211_local *local) |
| 659 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 660 | might_sleep(); |
| 661 | |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 662 | if (local->ops->rfkill_poll) |
| 663 | local->ops->rfkill_poll(&local->hw); |
| 664 | } |
Johannes Berg | a80f7c0 | 2009-12-23 13:15:32 +0100 | [diff] [blame] | 665 | |
| 666 | static inline void drv_flush(struct ieee80211_local *local, bool drop) |
| 667 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 668 | might_sleep(); |
| 669 | |
Johannes Berg | a80f7c0 | 2009-12-23 13:15:32 +0100 | [diff] [blame] | 670 | trace_drv_flush(local, drop); |
| 671 | if (local->ops->flush) |
| 672 | local->ops->flush(&local->hw, drop); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 673 | trace_drv_return_void(local); |
Johannes Berg | a80f7c0 | 2009-12-23 13:15:32 +0100 | [diff] [blame] | 674 | } |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 675 | |
| 676 | static inline void drv_channel_switch(struct ieee80211_local *local, |
| 677 | struct ieee80211_channel_switch *ch_switch) |
| 678 | { |
| 679 | might_sleep(); |
| 680 | |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 681 | trace_drv_channel_switch(local, ch_switch); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 682 | local->ops->channel_switch(&local->hw, ch_switch); |
| 683 | trace_drv_return_void(local); |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 684 | } |
| 685 | |
Bruno Randolf | 15d9675 | 2010-11-10 12:50:56 +0900 | [diff] [blame] | 686 | |
| 687 | static inline int drv_set_antenna(struct ieee80211_local *local, |
| 688 | u32 tx_ant, u32 rx_ant) |
| 689 | { |
| 690 | int ret = -EOPNOTSUPP; |
| 691 | might_sleep(); |
| 692 | if (local->ops->set_antenna) |
| 693 | ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant); |
| 694 | trace_drv_set_antenna(local, tx_ant, rx_ant, ret); |
| 695 | return ret; |
| 696 | } |
| 697 | |
| 698 | static inline int drv_get_antenna(struct ieee80211_local *local, |
| 699 | u32 *tx_ant, u32 *rx_ant) |
| 700 | { |
| 701 | int ret = -EOPNOTSUPP; |
| 702 | might_sleep(); |
| 703 | if (local->ops->get_antenna) |
| 704 | ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant); |
| 705 | trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret); |
| 706 | return ret; |
| 707 | } |
| 708 | |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 709 | static inline int drv_remain_on_channel(struct ieee80211_local *local, |
| 710 | struct ieee80211_channel *chan, |
| 711 | enum nl80211_channel_type chantype, |
| 712 | unsigned int duration) |
| 713 | { |
| 714 | int ret; |
| 715 | |
| 716 | might_sleep(); |
| 717 | |
| 718 | trace_drv_remain_on_channel(local, chan, chantype, duration); |
| 719 | ret = local->ops->remain_on_channel(&local->hw, chan, chantype, |
| 720 | duration); |
| 721 | trace_drv_return_int(local, ret); |
| 722 | |
| 723 | return ret; |
| 724 | } |
| 725 | |
| 726 | static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local) |
| 727 | { |
| 728 | int ret; |
| 729 | |
| 730 | might_sleep(); |
| 731 | |
| 732 | trace_drv_cancel_remain_on_channel(local); |
| 733 | ret = local->ops->cancel_remain_on_channel(&local->hw); |
| 734 | trace_drv_return_int(local, ret); |
| 735 | |
| 736 | return ret; |
| 737 | } |
| 738 | |
John W. Linville | 38c0915 | 2011-03-07 16:19:18 -0500 | [diff] [blame] | 739 | static inline int drv_set_ringparam(struct ieee80211_local *local, |
| 740 | u32 tx, u32 rx) |
| 741 | { |
| 742 | int ret = -ENOTSUPP; |
| 743 | |
| 744 | might_sleep(); |
| 745 | |
| 746 | trace_drv_set_ringparam(local, tx, rx); |
| 747 | if (local->ops->set_ringparam) |
| 748 | ret = local->ops->set_ringparam(&local->hw, tx, rx); |
| 749 | trace_drv_return_int(local, ret); |
| 750 | |
| 751 | return ret; |
| 752 | } |
| 753 | |
| 754 | static inline void drv_get_ringparam(struct ieee80211_local *local, |
| 755 | u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max) |
| 756 | { |
| 757 | might_sleep(); |
| 758 | |
| 759 | trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max); |
| 760 | if (local->ops->get_ringparam) |
| 761 | local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max); |
| 762 | trace_drv_return_void(local); |
| 763 | } |
| 764 | |
Vivek Natarajan | e8306f9 | 2011-04-06 11:41:10 +0530 | [diff] [blame] | 765 | static inline bool drv_tx_frames_pending(struct ieee80211_local *local) |
| 766 | { |
| 767 | bool ret = false; |
| 768 | |
| 769 | might_sleep(); |
| 770 | |
| 771 | trace_drv_tx_frames_pending(local); |
| 772 | if (local->ops->tx_frames_pending) |
| 773 | ret = local->ops->tx_frames_pending(&local->hw); |
| 774 | trace_drv_return_bool(local, ret); |
| 775 | |
| 776 | return ret; |
| 777 | } |
Sujith Manoharan | bdbfd6b | 2011-04-27 16:56:51 +0530 | [diff] [blame] | 778 | |
| 779 | static inline int drv_set_bitrate_mask(struct ieee80211_local *local, |
| 780 | struct ieee80211_sub_if_data *sdata, |
| 781 | const struct cfg80211_bitrate_mask *mask) |
| 782 | { |
| 783 | int ret = -EOPNOTSUPP; |
| 784 | |
| 785 | might_sleep(); |
| 786 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 787 | check_sdata_in_driver(sdata); |
| 788 | |
Sujith Manoharan | bdbfd6b | 2011-04-27 16:56:51 +0530 | [diff] [blame] | 789 | trace_drv_set_bitrate_mask(local, sdata, mask); |
| 790 | if (local->ops->set_bitrate_mask) |
| 791 | ret = local->ops->set_bitrate_mask(&local->hw, |
| 792 | &sdata->vif, mask); |
| 793 | trace_drv_return_int(local, ret); |
| 794 | |
| 795 | return ret; |
| 796 | } |
| 797 | |
Johannes Berg | c68f4b8 | 2011-07-05 16:35:41 +0200 | [diff] [blame] | 798 | static inline void drv_set_rekey_data(struct ieee80211_local *local, |
| 799 | struct ieee80211_sub_if_data *sdata, |
| 800 | struct cfg80211_gtk_rekey_data *data) |
| 801 | { |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 802 | check_sdata_in_driver(sdata); |
| 803 | |
Johannes Berg | c68f4b8 | 2011-07-05 16:35:41 +0200 | [diff] [blame] | 804 | trace_drv_set_rekey_data(local, sdata, data); |
| 805 | if (local->ops->set_rekey_data) |
| 806 | local->ops->set_rekey_data(&local->hw, &sdata->vif, data); |
| 807 | trace_drv_return_void(local); |
| 808 | } |
| 809 | |
Meenakshi Venkataraman | 615f7b9 | 2011-07-08 08:46:22 -0700 | [diff] [blame] | 810 | static inline void drv_rssi_callback(struct ieee80211_local *local, |
| 811 | const enum ieee80211_rssi_event event) |
| 812 | { |
| 813 | trace_drv_rssi_callback(local, event); |
| 814 | if (local->ops->rssi_callback) |
| 815 | local->ops->rssi_callback(&local->hw, event); |
| 816 | trace_drv_return_void(local); |
| 817 | } |
Johannes Berg | 4049e09 | 2011-09-29 16:04:32 +0200 | [diff] [blame] | 818 | |
| 819 | static inline void |
| 820 | drv_release_buffered_frames(struct ieee80211_local *local, |
| 821 | struct sta_info *sta, u16 tids, int num_frames, |
| 822 | enum ieee80211_frame_release_type reason, |
| 823 | bool more_data) |
| 824 | { |
| 825 | trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames, |
| 826 | reason, more_data); |
| 827 | if (local->ops->release_buffered_frames) |
| 828 | local->ops->release_buffered_frames(&local->hw, &sta->sta, tids, |
| 829 | num_frames, reason, |
| 830 | more_data); |
| 831 | trace_drv_return_void(local); |
| 832 | } |
Johannes Berg | 40b9640 | 2011-09-29 16:04:38 +0200 | [diff] [blame] | 833 | |
| 834 | static inline void |
| 835 | drv_allow_buffered_frames(struct ieee80211_local *local, |
| 836 | struct sta_info *sta, u16 tids, int num_frames, |
| 837 | enum ieee80211_frame_release_type reason, |
| 838 | bool more_data) |
| 839 | { |
| 840 | trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames, |
| 841 | reason, more_data); |
| 842 | if (local->ops->allow_buffered_frames) |
| 843 | local->ops->allow_buffered_frames(&local->hw, &sta->sta, |
| 844 | tids, num_frames, reason, |
| 845 | more_data); |
| 846 | trace_drv_return_void(local); |
| 847 | } |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 848 | #endif /* __MAC80211_DRIVER_OPS */ |