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