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