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 | 7bb4568 | 2011-02-24 14:42:06 +0100 | [diff] [blame] | 8 | 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] | 9 | { |
Johannes Berg | 7bb4568 | 2011-02-24 14:42:06 +0100 | [diff] [blame] | 10 | local->ops->tx(&local->hw, skb); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 11 | } |
| 12 | |
| 13 | static inline int drv_start(struct ieee80211_local *local) |
| 14 | { |
Johannes Berg | ea77f12 | 2009-08-21 14:44:45 +0200 | [diff] [blame] | 15 | int ret; |
| 16 | |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 17 | might_sleep(); |
| 18 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 19 | trace_drv_start(local); |
Johannes Berg | ea77f12 | 2009-08-21 14:44:45 +0200 | [diff] [blame] | 20 | local->started = true; |
| 21 | smp_mb(); |
| 22 | ret = local->ops->start(&local->hw); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 23 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 24 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | static inline void drv_stop(struct ieee80211_local *local) |
| 28 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 29 | might_sleep(); |
| 30 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 31 | trace_drv_stop(local); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 32 | local->ops->stop(&local->hw); |
| 33 | trace_drv_return_void(local); |
Johannes Berg | ea77f12 | 2009-08-21 14:44:45 +0200 | [diff] [blame] | 34 | |
| 35 | /* sync away all work on the tasklet before clearing started */ |
| 36 | tasklet_disable(&local->tasklet); |
| 37 | tasklet_enable(&local->tasklet); |
| 38 | |
| 39 | barrier(); |
| 40 | |
| 41 | local->started = false; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 42 | } |
| 43 | |
Johannes Berg | eecc480 | 2011-05-04 15:37:29 +0200 | [diff] [blame^] | 44 | #ifdef CONFIG_PM |
| 45 | static inline int drv_suspend(struct ieee80211_local *local, |
| 46 | struct cfg80211_wowlan *wowlan) |
| 47 | { |
| 48 | int ret; |
| 49 | |
| 50 | might_sleep(); |
| 51 | |
| 52 | trace_drv_suspend(local); |
| 53 | ret = local->ops->suspend(&local->hw, wowlan); |
| 54 | trace_drv_return_int(local, ret); |
| 55 | return ret; |
| 56 | } |
| 57 | |
| 58 | static inline int drv_resume(struct ieee80211_local *local) |
| 59 | { |
| 60 | int ret; |
| 61 | |
| 62 | might_sleep(); |
| 63 | |
| 64 | trace_drv_resume(local); |
| 65 | ret = local->ops->resume(&local->hw); |
| 66 | trace_drv_return_int(local, ret); |
| 67 | return ret; |
| 68 | } |
| 69 | #endif |
| 70 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 71 | static inline int drv_add_interface(struct ieee80211_local *local, |
Johannes Berg | 1ed32e4 | 2009-12-23 13:15:45 +0100 | [diff] [blame] | 72 | struct ieee80211_vif *vif) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 73 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 74 | int ret; |
| 75 | |
| 76 | might_sleep(); |
| 77 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 78 | trace_drv_add_interface(local, vif_to_sdata(vif)); |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 79 | ret = local->ops->add_interface(&local->hw, vif); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 80 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 81 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 82 | } |
| 83 | |
Johannes Berg | 34d4bc4 | 2010-08-27 12:35:58 +0200 | [diff] [blame] | 84 | static inline int drv_change_interface(struct ieee80211_local *local, |
| 85 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2ca27bc | 2010-09-16 14:58:23 +0200 | [diff] [blame] | 86 | enum nl80211_iftype type, bool p2p) |
Johannes Berg | 34d4bc4 | 2010-08-27 12:35:58 +0200 | [diff] [blame] | 87 | { |
| 88 | int ret; |
| 89 | |
| 90 | might_sleep(); |
| 91 | |
Johannes Berg | 2ca27bc | 2010-09-16 14:58:23 +0200 | [diff] [blame] | 92 | trace_drv_change_interface(local, sdata, type, p2p); |
| 93 | ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p); |
Johannes Berg | 34d4bc4 | 2010-08-27 12:35:58 +0200 | [diff] [blame] | 94 | trace_drv_return_int(local, ret); |
| 95 | return ret; |
| 96 | } |
| 97 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 98 | static inline void drv_remove_interface(struct ieee80211_local *local, |
Johannes Berg | 1ed32e4 | 2009-12-23 13:15:45 +0100 | [diff] [blame] | 99 | struct ieee80211_vif *vif) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 100 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 101 | might_sleep(); |
| 102 | |
Johannes Berg | 1ed32e4 | 2009-12-23 13:15:45 +0100 | [diff] [blame] | 103 | trace_drv_remove_interface(local, vif_to_sdata(vif)); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 104 | local->ops->remove_interface(&local->hw, vif); |
| 105 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | static inline int drv_config(struct ieee80211_local *local, u32 changed) |
| 109 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 110 | int ret; |
| 111 | |
| 112 | might_sleep(); |
| 113 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 114 | trace_drv_config(local, changed); |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 115 | ret = local->ops->config(&local->hw, changed); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 116 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 117 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | static inline void drv_bss_info_changed(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 121 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 122 | struct ieee80211_bss_conf *info, |
| 123 | u32 changed) |
| 124 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 125 | might_sleep(); |
| 126 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 127 | trace_drv_bss_info_changed(local, sdata, info, changed); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 128 | if (local->ops->bss_info_changed) |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 129 | local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 130 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 131 | } |
| 132 | |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 133 | static inline u64 drv_prepare_multicast(struct ieee80211_local *local, |
Jiri Pirko | 22bedad3 | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 134 | struct netdev_hw_addr_list *mc_list) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 135 | { |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 136 | u64 ret = 0; |
| 137 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 138 | trace_drv_prepare_multicast(local, mc_list->count); |
| 139 | |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 140 | if (local->ops->prepare_multicast) |
Jiri Pirko | 22bedad3 | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 141 | ret = local->ops->prepare_multicast(&local->hw, mc_list); |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 142 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 143 | trace_drv_return_u64(local, ret); |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 144 | |
| 145 | return ret; |
| 146 | } |
| 147 | |
| 148 | static inline void drv_configure_filter(struct ieee80211_local *local, |
| 149 | unsigned int changed_flags, |
| 150 | unsigned int *total_flags, |
| 151 | u64 multicast) |
| 152 | { |
| 153 | might_sleep(); |
| 154 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 155 | trace_drv_configure_filter(local, changed_flags, total_flags, |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 156 | multicast); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 157 | local->ops->configure_filter(&local->hw, changed_flags, total_flags, |
| 158 | multicast); |
| 159 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | static inline int drv_set_tim(struct ieee80211_local *local, |
| 163 | struct ieee80211_sta *sta, bool set) |
| 164 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 165 | int ret = 0; |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 166 | trace_drv_set_tim(local, sta, set); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 167 | if (local->ops->set_tim) |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 168 | ret = local->ops->set_tim(&local->hw, sta, set); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 169 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 170 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | static inline int drv_set_key(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 174 | enum set_key_cmd cmd, |
| 175 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 176 | struct ieee80211_sta *sta, |
| 177 | struct ieee80211_key_conf *key) |
| 178 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 179 | int ret; |
| 180 | |
| 181 | might_sleep(); |
| 182 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 183 | trace_drv_set_key(local, cmd, sdata, sta, key); |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 184 | ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 185 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 186 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | static inline void drv_update_tkip_key(struct ieee80211_local *local, |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 190 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 191 | struct ieee80211_key_conf *conf, |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 192 | struct sta_info *sta, u32 iv32, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 193 | u16 *phase1key) |
| 194 | { |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 195 | struct ieee80211_sta *ista = NULL; |
| 196 | |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 197 | if (sta) |
| 198 | ista = &sta->sta; |
| 199 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 200 | trace_drv_update_tkip_key(local, sdata, conf, ista, iv32); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 201 | if (local->ops->update_tkip_key) |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 202 | local->ops->update_tkip_key(&local->hw, &sdata->vif, conf, |
| 203 | ista, iv32, phase1key); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 204 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | static inline int drv_hw_scan(struct ieee80211_local *local, |
Johannes Berg | a060bbf | 2010-04-27 11:59:34 +0200 | [diff] [blame] | 208 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 209 | struct cfg80211_scan_request *req) |
| 210 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 211 | int ret; |
| 212 | |
| 213 | might_sleep(); |
| 214 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 215 | trace_drv_hw_scan(local, sdata, req); |
Johannes Berg | a060bbf | 2010-04-27 11:59:34 +0200 | [diff] [blame] | 216 | ret = local->ops->hw_scan(&local->hw, &sdata->vif, req); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 217 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 218 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | static inline void drv_sw_scan_start(struct ieee80211_local *local) |
| 222 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 223 | might_sleep(); |
| 224 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 225 | trace_drv_sw_scan_start(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 226 | if (local->ops->sw_scan_start) |
| 227 | local->ops->sw_scan_start(&local->hw); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 228 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | static inline void drv_sw_scan_complete(struct ieee80211_local *local) |
| 232 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 233 | might_sleep(); |
| 234 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 235 | trace_drv_sw_scan_complete(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 236 | if (local->ops->sw_scan_complete) |
| 237 | local->ops->sw_scan_complete(&local->hw); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 238 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | static inline int drv_get_stats(struct ieee80211_local *local, |
| 242 | struct ieee80211_low_level_stats *stats) |
| 243 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 244 | int ret = -EOPNOTSUPP; |
| 245 | |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 246 | might_sleep(); |
| 247 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 248 | if (local->ops->get_stats) |
| 249 | ret = local->ops->get_stats(&local->hw, stats); |
| 250 | trace_drv_get_stats(local, stats, ret); |
| 251 | |
| 252 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | static inline void drv_get_tkip_seq(struct ieee80211_local *local, |
| 256 | u8 hw_key_idx, u32 *iv32, u16 *iv16) |
| 257 | { |
| 258 | if (local->ops->get_tkip_seq) |
| 259 | local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 260 | trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 261 | } |
| 262 | |
Arik Nemtsov | f23a478 | 2010-11-08 11:51:06 +0200 | [diff] [blame] | 263 | static inline int drv_set_frag_threshold(struct ieee80211_local *local, |
| 264 | u32 value) |
| 265 | { |
| 266 | int ret = 0; |
| 267 | |
| 268 | might_sleep(); |
| 269 | |
| 270 | trace_drv_set_frag_threshold(local, value); |
| 271 | if (local->ops->set_frag_threshold) |
| 272 | ret = local->ops->set_frag_threshold(&local->hw, value); |
| 273 | trace_drv_return_int(local, ret); |
| 274 | return ret; |
| 275 | } |
| 276 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 277 | static inline int drv_set_rts_threshold(struct ieee80211_local *local, |
| 278 | u32 value) |
| 279 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 280 | int ret = 0; |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 281 | |
| 282 | might_sleep(); |
| 283 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 284 | trace_drv_set_rts_threshold(local, value); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 285 | if (local->ops->set_rts_threshold) |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 286 | ret = local->ops->set_rts_threshold(&local->hw, value); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 287 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 288 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 289 | } |
| 290 | |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 291 | static inline int drv_set_coverage_class(struct ieee80211_local *local, |
| 292 | u8 value) |
| 293 | { |
| 294 | int ret = 0; |
| 295 | might_sleep(); |
| 296 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 297 | trace_drv_set_coverage_class(local, value); |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 298 | if (local->ops->set_coverage_class) |
| 299 | local->ops->set_coverage_class(&local->hw, value); |
| 300 | else |
| 301 | ret = -EOPNOTSUPP; |
| 302 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 303 | trace_drv_return_int(local, ret); |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 304 | return ret; |
| 305 | } |
| 306 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 307 | static inline void drv_sta_notify(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 308 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 309 | enum sta_notify_cmd cmd, |
| 310 | struct ieee80211_sta *sta) |
| 311 | { |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 312 | trace_drv_sta_notify(local, sdata, cmd, sta); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 313 | if (local->ops->sta_notify) |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 314 | local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 315 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 316 | } |
| 317 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 318 | static inline int drv_sta_add(struct ieee80211_local *local, |
| 319 | struct ieee80211_sub_if_data *sdata, |
| 320 | struct ieee80211_sta *sta) |
| 321 | { |
| 322 | int ret = 0; |
| 323 | |
| 324 | might_sleep(); |
| 325 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 326 | trace_drv_sta_add(local, sdata, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 327 | if (local->ops->sta_add) |
| 328 | ret = local->ops->sta_add(&local->hw, &sdata->vif, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 329 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 330 | trace_drv_return_int(local, ret); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 331 | |
| 332 | return ret; |
| 333 | } |
| 334 | |
| 335 | static inline void drv_sta_remove(struct ieee80211_local *local, |
| 336 | struct ieee80211_sub_if_data *sdata, |
| 337 | struct ieee80211_sta *sta) |
| 338 | { |
| 339 | might_sleep(); |
| 340 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 341 | trace_drv_sta_remove(local, sdata, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 342 | if (local->ops->sta_remove) |
| 343 | local->ops->sta_remove(&local->hw, &sdata->vif, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 344 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 345 | trace_drv_return_void(local); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 346 | } |
| 347 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 348 | static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue, |
| 349 | const struct ieee80211_tx_queue_params *params) |
| 350 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 351 | int ret = -EOPNOTSUPP; |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 352 | |
| 353 | might_sleep(); |
| 354 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 355 | trace_drv_conf_tx(local, queue, params); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 356 | if (local->ops->conf_tx) |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 357 | ret = local->ops->conf_tx(&local->hw, queue, params); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 358 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 359 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 360 | } |
| 361 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 362 | static inline u64 drv_get_tsf(struct ieee80211_local *local) |
| 363 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 364 | u64 ret = -1ULL; |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 365 | |
| 366 | might_sleep(); |
| 367 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 368 | trace_drv_get_tsf(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 369 | if (local->ops->get_tsf) |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 370 | ret = local->ops->get_tsf(&local->hw); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 371 | trace_drv_return_u64(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 372 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf) |
| 376 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 377 | might_sleep(); |
| 378 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 379 | trace_drv_set_tsf(local, tsf); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 380 | if (local->ops->set_tsf) |
| 381 | local->ops->set_tsf(&local->hw, tsf); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 382 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | static inline void drv_reset_tsf(struct ieee80211_local *local) |
| 386 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 387 | might_sleep(); |
| 388 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 389 | trace_drv_reset_tsf(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 390 | if (local->ops->reset_tsf) |
| 391 | local->ops->reset_tsf(&local->hw); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 392 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | static inline int drv_tx_last_beacon(struct ieee80211_local *local) |
| 396 | { |
Tim Harvey | 91f44b0 | 2010-12-09 13:15:45 -0800 | [diff] [blame] | 397 | int ret = 0; /* default unsuported op for less congestion */ |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 398 | |
| 399 | might_sleep(); |
| 400 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 401 | trace_drv_tx_last_beacon(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 402 | if (local->ops->tx_last_beacon) |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 403 | ret = local->ops->tx_last_beacon(&local->hw); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 404 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 405 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | static inline int drv_ampdu_action(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 409 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 410 | enum ieee80211_ampdu_mlme_action action, |
| 411 | struct ieee80211_sta *sta, u16 tid, |
Johannes Berg | 0b01f03 | 2011-01-18 13:51:05 +0100 | [diff] [blame] | 412 | u16 *ssn, u8 buf_size) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 413 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 414 | int ret = -EOPNOTSUPP; |
Johannes Berg | cfcdbde | 2010-06-10 10:21:48 +0200 | [diff] [blame] | 415 | |
| 416 | might_sleep(); |
| 417 | |
Johannes Berg | 0b01f03 | 2011-01-18 13:51:05 +0100 | [diff] [blame] | 418 | trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 419 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 420 | if (local->ops->ampdu_action) |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 421 | ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action, |
Johannes Berg | 0b01f03 | 2011-01-18 13:51:05 +0100 | [diff] [blame] | 422 | sta, tid, ssn, buf_size); |
Johannes Berg | 85ad181 | 2010-06-10 10:21:49 +0200 | [diff] [blame] | 423 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 424 | trace_drv_return_int(local, ret); |
| 425 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 426 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 427 | } |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 428 | |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 429 | static inline int drv_get_survey(struct ieee80211_local *local, int idx, |
| 430 | struct survey_info *survey) |
| 431 | { |
| 432 | int ret = -EOPNOTSUPP; |
John W. Linville | c466d4e | 2010-06-29 14:51:23 -0400 | [diff] [blame] | 433 | |
| 434 | trace_drv_get_survey(local, idx, survey); |
| 435 | |
Holger Schurig | 35dd050 | 2010-06-07 16:33:49 +0200 | [diff] [blame] | 436 | if (local->ops->get_survey) |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 437 | ret = local->ops->get_survey(&local->hw, idx, survey); |
John W. Linville | c466d4e | 2010-06-29 14:51:23 -0400 | [diff] [blame] | 438 | |
| 439 | trace_drv_return_int(local, ret); |
| 440 | |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 441 | return ret; |
| 442 | } |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 443 | |
| 444 | static inline void drv_rfkill_poll(struct ieee80211_local *local) |
| 445 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 446 | might_sleep(); |
| 447 | |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 448 | if (local->ops->rfkill_poll) |
| 449 | local->ops->rfkill_poll(&local->hw); |
| 450 | } |
Johannes Berg | a80f7c0 | 2009-12-23 13:15:32 +0100 | [diff] [blame] | 451 | |
| 452 | static inline void drv_flush(struct ieee80211_local *local, bool drop) |
| 453 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 454 | might_sleep(); |
| 455 | |
Johannes Berg | a80f7c0 | 2009-12-23 13:15:32 +0100 | [diff] [blame] | 456 | trace_drv_flush(local, drop); |
| 457 | if (local->ops->flush) |
| 458 | local->ops->flush(&local->hw, drop); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 459 | trace_drv_return_void(local); |
Johannes Berg | a80f7c0 | 2009-12-23 13:15:32 +0100 | [diff] [blame] | 460 | } |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 461 | |
| 462 | static inline void drv_channel_switch(struct ieee80211_local *local, |
| 463 | struct ieee80211_channel_switch *ch_switch) |
| 464 | { |
| 465 | might_sleep(); |
| 466 | |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 467 | trace_drv_channel_switch(local, ch_switch); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 468 | local->ops->channel_switch(&local->hw, ch_switch); |
| 469 | trace_drv_return_void(local); |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 470 | } |
| 471 | |
Bruno Randolf | 15d9675 | 2010-11-10 12:50:56 +0900 | [diff] [blame] | 472 | |
| 473 | static inline int drv_set_antenna(struct ieee80211_local *local, |
| 474 | u32 tx_ant, u32 rx_ant) |
| 475 | { |
| 476 | int ret = -EOPNOTSUPP; |
| 477 | might_sleep(); |
| 478 | if (local->ops->set_antenna) |
| 479 | ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant); |
| 480 | trace_drv_set_antenna(local, tx_ant, rx_ant, ret); |
| 481 | return ret; |
| 482 | } |
| 483 | |
| 484 | static inline int drv_get_antenna(struct ieee80211_local *local, |
| 485 | u32 *tx_ant, u32 *rx_ant) |
| 486 | { |
| 487 | int ret = -EOPNOTSUPP; |
| 488 | might_sleep(); |
| 489 | if (local->ops->get_antenna) |
| 490 | ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant); |
| 491 | trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret); |
| 492 | return ret; |
| 493 | } |
| 494 | |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 495 | static inline int drv_remain_on_channel(struct ieee80211_local *local, |
| 496 | struct ieee80211_channel *chan, |
| 497 | enum nl80211_channel_type chantype, |
| 498 | unsigned int duration) |
| 499 | { |
| 500 | int ret; |
| 501 | |
| 502 | might_sleep(); |
| 503 | |
| 504 | trace_drv_remain_on_channel(local, chan, chantype, duration); |
| 505 | ret = local->ops->remain_on_channel(&local->hw, chan, chantype, |
| 506 | duration); |
| 507 | trace_drv_return_int(local, ret); |
| 508 | |
| 509 | return ret; |
| 510 | } |
| 511 | |
| 512 | static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local) |
| 513 | { |
| 514 | int ret; |
| 515 | |
| 516 | might_sleep(); |
| 517 | |
| 518 | trace_drv_cancel_remain_on_channel(local); |
| 519 | ret = local->ops->cancel_remain_on_channel(&local->hw); |
| 520 | trace_drv_return_int(local, ret); |
| 521 | |
| 522 | return ret; |
| 523 | } |
| 524 | |
Johannes Berg | 5f16a43 | 2011-02-25 15:36:57 +0100 | [diff] [blame] | 525 | static inline int drv_offchannel_tx(struct ieee80211_local *local, |
| 526 | struct sk_buff *skb, |
| 527 | struct ieee80211_channel *chan, |
| 528 | enum nl80211_channel_type channel_type, |
| 529 | unsigned int wait) |
| 530 | { |
| 531 | int ret; |
| 532 | |
| 533 | might_sleep(); |
| 534 | |
| 535 | trace_drv_offchannel_tx(local, skb, chan, channel_type, wait); |
| 536 | ret = local->ops->offchannel_tx(&local->hw, skb, chan, |
| 537 | channel_type, wait); |
| 538 | trace_drv_return_int(local, ret); |
| 539 | |
| 540 | return ret; |
| 541 | } |
| 542 | |
| 543 | static inline int drv_offchannel_tx_cancel_wait(struct ieee80211_local *local) |
| 544 | { |
| 545 | int ret; |
| 546 | |
| 547 | might_sleep(); |
| 548 | |
| 549 | trace_drv_offchannel_tx_cancel_wait(local); |
| 550 | ret = local->ops->offchannel_tx_cancel_wait(&local->hw); |
| 551 | trace_drv_return_int(local, ret); |
| 552 | |
| 553 | return ret; |
| 554 | } |
| 555 | |
John W. Linville | 38c0915 | 2011-03-07 16:19:18 -0500 | [diff] [blame] | 556 | static inline int drv_set_ringparam(struct ieee80211_local *local, |
| 557 | u32 tx, u32 rx) |
| 558 | { |
| 559 | int ret = -ENOTSUPP; |
| 560 | |
| 561 | might_sleep(); |
| 562 | |
| 563 | trace_drv_set_ringparam(local, tx, rx); |
| 564 | if (local->ops->set_ringparam) |
| 565 | ret = local->ops->set_ringparam(&local->hw, tx, rx); |
| 566 | trace_drv_return_int(local, ret); |
| 567 | |
| 568 | return ret; |
| 569 | } |
| 570 | |
| 571 | static inline void drv_get_ringparam(struct ieee80211_local *local, |
| 572 | u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max) |
| 573 | { |
| 574 | might_sleep(); |
| 575 | |
| 576 | trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max); |
| 577 | if (local->ops->get_ringparam) |
| 578 | local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max); |
| 579 | trace_drv_return_void(local); |
| 580 | } |
| 581 | |
Vivek Natarajan | e8306f9 | 2011-04-06 11:41:10 +0530 | [diff] [blame] | 582 | static inline bool drv_tx_frames_pending(struct ieee80211_local *local) |
| 583 | { |
| 584 | bool ret = false; |
| 585 | |
| 586 | might_sleep(); |
| 587 | |
| 588 | trace_drv_tx_frames_pending(local); |
| 589 | if (local->ops->tx_frames_pending) |
| 590 | ret = local->ops->tx_frames_pending(&local->hw); |
| 591 | trace_drv_return_bool(local, ret); |
| 592 | |
| 593 | return ret; |
| 594 | } |
Sujith Manoharan | bdbfd6b | 2011-04-27 16:56:51 +0530 | [diff] [blame] | 595 | |
| 596 | static inline int drv_set_bitrate_mask(struct ieee80211_local *local, |
| 597 | struct ieee80211_sub_if_data *sdata, |
| 598 | const struct cfg80211_bitrate_mask *mask) |
| 599 | { |
| 600 | int ret = -EOPNOTSUPP; |
| 601 | |
| 602 | might_sleep(); |
| 603 | |
| 604 | trace_drv_set_bitrate_mask(local, sdata, mask); |
| 605 | if (local->ops->set_bitrate_mask) |
| 606 | ret = local->ops->set_bitrate_mask(&local->hw, |
| 607 | &sdata->vif, mask); |
| 608 | trace_drv_return_int(local, ret); |
| 609 | |
| 610 | return ret; |
| 611 | } |
| 612 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 613 | #endif /* __MAC80211_DRIVER_OPS */ |