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