Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 1 | #ifndef __MAC80211_DRIVER_OPS |
| 2 | #define __MAC80211_DRIVER_OPS |
| 3 | |
| 4 | #include <net/mac80211.h> |
| 5 | #include "ieee80211_i.h" |
Johannes Berg | 011ad0e | 2012-06-22 12:55:52 +0200 | [diff] [blame] | 6 | #include "trace.h" |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 7 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 8 | static inline void check_sdata_in_driver(struct ieee80211_sub_if_data *sdata) |
| 9 | { |
Ben Greear | d17087e | 2012-03-15 16:22:05 -0700 | [diff] [blame] | 10 | WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER), |
| 11 | "%s: Failed check-sdata-in-driver check, flags: 0x%x\n", |
Johannes Berg | f142c6b | 2012-06-18 20:07:15 +0200 | [diff] [blame] | 12 | sdata->dev ? sdata->dev->name : sdata->name, sdata->flags); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 13 | } |
| 14 | |
Felix Fietkau | bc192f8 | 2011-11-23 21:09:49 +0700 | [diff] [blame] | 15 | static inline struct ieee80211_sub_if_data * |
| 16 | get_bss_sdata(struct ieee80211_sub_if_data *sdata) |
| 17 | { |
| 18 | if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) |
| 19 | sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, |
| 20 | u.ap); |
| 21 | |
| 22 | return sdata; |
| 23 | } |
| 24 | |
Thomas Huehn | 36323f8 | 2012-07-23 21:33:42 +0200 | [diff] [blame] | 25 | static inline void drv_tx(struct ieee80211_local *local, |
| 26 | struct ieee80211_tx_control *control, |
| 27 | struct sk_buff *skb) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 28 | { |
Thomas Huehn | 36323f8 | 2012-07-23 21:33:42 +0200 | [diff] [blame] | 29 | local->ops->tx(&local->hw, control, skb); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 30 | } |
| 31 | |
Ben Greear | e352114 | 2012-04-23 12:50:31 -0700 | [diff] [blame] | 32 | static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata, |
| 33 | u32 sset, u8 *data) |
| 34 | { |
| 35 | struct ieee80211_local *local = sdata->local; |
| 36 | if (local->ops->get_et_strings) { |
| 37 | trace_drv_get_et_strings(local, sset); |
| 38 | local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data); |
| 39 | trace_drv_return_void(local); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata, |
| 44 | struct ethtool_stats *stats, |
| 45 | u64 *data) |
| 46 | { |
| 47 | struct ieee80211_local *local = sdata->local; |
| 48 | if (local->ops->get_et_stats) { |
| 49 | trace_drv_get_et_stats(local); |
| 50 | local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data); |
| 51 | trace_drv_return_void(local); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata, |
| 56 | int sset) |
| 57 | { |
| 58 | struct ieee80211_local *local = sdata->local; |
| 59 | int rv = 0; |
| 60 | if (local->ops->get_et_sset_count) { |
| 61 | trace_drv_get_et_sset_count(local, sset); |
| 62 | rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif, |
| 63 | sset); |
| 64 | trace_drv_return_int(local, rv); |
| 65 | } |
| 66 | return rv; |
| 67 | } |
| 68 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 69 | static inline int drv_start(struct ieee80211_local *local) |
| 70 | { |
Johannes Berg | ea77f12 | 2009-08-21 14:44:45 +0200 | [diff] [blame] | 71 | int ret; |
| 72 | |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 73 | might_sleep(); |
| 74 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 75 | trace_drv_start(local); |
Johannes Berg | ea77f12 | 2009-08-21 14:44:45 +0200 | [diff] [blame] | 76 | local->started = true; |
| 77 | smp_mb(); |
| 78 | ret = local->ops->start(&local->hw); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 79 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 80 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | static inline void drv_stop(struct ieee80211_local *local) |
| 84 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 85 | might_sleep(); |
| 86 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 87 | trace_drv_stop(local); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 88 | local->ops->stop(&local->hw); |
| 89 | trace_drv_return_void(local); |
Johannes Berg | ea77f12 | 2009-08-21 14:44:45 +0200 | [diff] [blame] | 90 | |
| 91 | /* sync away all work on the tasklet before clearing started */ |
| 92 | tasklet_disable(&local->tasklet); |
| 93 | tasklet_enable(&local->tasklet); |
| 94 | |
| 95 | barrier(); |
| 96 | |
| 97 | local->started = false; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 98 | } |
| 99 | |
Johannes Berg | eecc480 | 2011-05-04 15:37:29 +0200 | [diff] [blame] | 100 | #ifdef CONFIG_PM |
| 101 | static inline int drv_suspend(struct ieee80211_local *local, |
| 102 | struct cfg80211_wowlan *wowlan) |
| 103 | { |
| 104 | int ret; |
| 105 | |
| 106 | might_sleep(); |
| 107 | |
| 108 | trace_drv_suspend(local); |
| 109 | ret = local->ops->suspend(&local->hw, wowlan); |
| 110 | trace_drv_return_int(local, ret); |
| 111 | return ret; |
| 112 | } |
| 113 | |
| 114 | static inline int drv_resume(struct ieee80211_local *local) |
| 115 | { |
| 116 | int ret; |
| 117 | |
| 118 | might_sleep(); |
| 119 | |
| 120 | trace_drv_resume(local); |
| 121 | ret = local->ops->resume(&local->hw); |
| 122 | trace_drv_return_int(local, ret); |
| 123 | return ret; |
| 124 | } |
Johannes Berg | 6d52563 | 2012-04-04 15:05:25 +0200 | [diff] [blame] | 125 | |
| 126 | static inline void drv_set_wakeup(struct ieee80211_local *local, |
| 127 | bool enabled) |
| 128 | { |
| 129 | might_sleep(); |
| 130 | |
| 131 | if (!local->ops->set_wakeup) |
| 132 | return; |
| 133 | |
| 134 | trace_drv_set_wakeup(local, enabled); |
| 135 | local->ops->set_wakeup(&local->hw, enabled); |
| 136 | trace_drv_return_void(local); |
| 137 | } |
Johannes Berg | eecc480 | 2011-05-04 15:37:29 +0200 | [diff] [blame] | 138 | #endif |
| 139 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 140 | static inline int drv_add_interface(struct ieee80211_local *local, |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 141 | struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 142 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 143 | int ret; |
| 144 | |
| 145 | might_sleep(); |
| 146 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 147 | if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN || |
Johannes Berg | 4b6f1dd | 2012-04-03 14:35:57 +0200 | [diff] [blame] | 148 | (sdata->vif.type == NL80211_IFTYPE_MONITOR && |
Felix Fietkau | 31eba5b | 2013-05-28 13:01:53 +0200 | [diff] [blame] | 149 | !(local->hw.flags & IEEE80211_HW_WANT_MONITOR_VIF) && |
| 150 | !(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE)))) |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 151 | return -EINVAL; |
| 152 | |
| 153 | trace_drv_add_interface(local, sdata); |
| 154 | ret = local->ops->add_interface(&local->hw, &sdata->vif); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 155 | trace_drv_return_int(local, ret); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 156 | |
| 157 | if (ret == 0) |
| 158 | sdata->flags |= IEEE80211_SDATA_IN_DRIVER; |
| 159 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 160 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 161 | } |
| 162 | |
Johannes Berg | 34d4bc4 | 2010-08-27 12:35:58 +0200 | [diff] [blame] | 163 | static inline int drv_change_interface(struct ieee80211_local *local, |
| 164 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2ca27bc | 2010-09-16 14:58:23 +0200 | [diff] [blame] | 165 | enum nl80211_iftype type, bool p2p) |
Johannes Berg | 34d4bc4 | 2010-08-27 12:35:58 +0200 | [diff] [blame] | 166 | { |
| 167 | int ret; |
| 168 | |
| 169 | might_sleep(); |
| 170 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 171 | check_sdata_in_driver(sdata); |
| 172 | |
Johannes Berg | 2ca27bc | 2010-09-16 14:58:23 +0200 | [diff] [blame] | 173 | trace_drv_change_interface(local, sdata, type, p2p); |
| 174 | ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p); |
Johannes Berg | 34d4bc4 | 2010-08-27 12:35:58 +0200 | [diff] [blame] | 175 | trace_drv_return_int(local, ret); |
| 176 | return ret; |
| 177 | } |
| 178 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 179 | static inline void drv_remove_interface(struct ieee80211_local *local, |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 180 | struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 181 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 182 | might_sleep(); |
| 183 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 184 | check_sdata_in_driver(sdata); |
| 185 | |
| 186 | trace_drv_remove_interface(local, sdata); |
| 187 | local->ops->remove_interface(&local->hw, &sdata->vif); |
| 188 | sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER; |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 189 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | static inline int drv_config(struct ieee80211_local *local, u32 changed) |
| 193 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 194 | int ret; |
| 195 | |
| 196 | might_sleep(); |
| 197 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 198 | trace_drv_config(local, changed); |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 199 | ret = local->ops->config(&local->hw, changed); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 200 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 201 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | static inline void drv_bss_info_changed(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 205 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 206 | struct ieee80211_bss_conf *info, |
| 207 | u32 changed) |
| 208 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 209 | might_sleep(); |
| 210 | |
Johannes Berg | 5bbe754d | 2013-02-13 13:50:51 +0100 | [diff] [blame] | 211 | if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON | |
| 212 | BSS_CHANGED_BEACON_ENABLED) && |
| 213 | sdata->vif.type != NL80211_IFTYPE_AP && |
| 214 | sdata->vif.type != NL80211_IFTYPE_ADHOC && |
| 215 | sdata->vif.type != NL80211_IFTYPE_MESH_POINT)) |
| 216 | return; |
| 217 | |
| 218 | if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE || |
| 219 | sdata->vif.type == NL80211_IFTYPE_MONITOR)) |
| 220 | return; |
Johannes Berg | b8dc1a3 | 2012-12-14 14:22:10 +0100 | [diff] [blame] | 221 | |
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_bss_info_changed(local, sdata, info, changed); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 225 | if (local->ops->bss_info_changed) |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 226 | local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 227 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 228 | } |
| 229 | |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 230 | static inline u64 drv_prepare_multicast(struct ieee80211_local *local, |
Jiri Pirko | 22bedad3 | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 231 | struct netdev_hw_addr_list *mc_list) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 232 | { |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 233 | u64 ret = 0; |
| 234 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 235 | trace_drv_prepare_multicast(local, mc_list->count); |
| 236 | |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 237 | if (local->ops->prepare_multicast) |
Jiri Pirko | 22bedad3 | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 238 | ret = local->ops->prepare_multicast(&local->hw, mc_list); |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 239 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 240 | trace_drv_return_u64(local, ret); |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 241 | |
| 242 | return ret; |
| 243 | } |
| 244 | |
Alexander Bondar | 488b366 | 2013-02-11 14:56:29 +0200 | [diff] [blame] | 245 | static inline void drv_set_multicast_list(struct ieee80211_local *local, |
| 246 | struct ieee80211_sub_if_data *sdata, |
| 247 | struct netdev_hw_addr_list *mc_list) |
| 248 | { |
| 249 | bool allmulti = sdata->flags & IEEE80211_SDATA_ALLMULTI; |
| 250 | |
| 251 | trace_drv_set_multicast_list(local, sdata, mc_list->count); |
| 252 | |
| 253 | check_sdata_in_driver(sdata); |
| 254 | |
| 255 | if (local->ops->set_multicast_list) |
| 256 | local->ops->set_multicast_list(&local->hw, &sdata->vif, |
| 257 | allmulti, mc_list); |
| 258 | trace_drv_return_void(local); |
| 259 | } |
| 260 | |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 261 | static inline void drv_configure_filter(struct ieee80211_local *local, |
| 262 | unsigned int changed_flags, |
| 263 | unsigned int *total_flags, |
| 264 | u64 multicast) |
| 265 | { |
| 266 | might_sleep(); |
| 267 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 268 | trace_drv_configure_filter(local, changed_flags, total_flags, |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 269 | multicast); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 270 | local->ops->configure_filter(&local->hw, changed_flags, total_flags, |
| 271 | multicast); |
| 272 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | static inline int drv_set_tim(struct ieee80211_local *local, |
| 276 | struct ieee80211_sta *sta, bool set) |
| 277 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 278 | int ret = 0; |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 279 | trace_drv_set_tim(local, sta, set); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 280 | if (local->ops->set_tim) |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 281 | ret = local->ops->set_tim(&local->hw, sta, set); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 282 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 283 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | static inline int drv_set_key(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 287 | enum set_key_cmd cmd, |
| 288 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 289 | struct ieee80211_sta *sta, |
| 290 | struct ieee80211_key_conf *key) |
| 291 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 292 | int ret; |
| 293 | |
| 294 | might_sleep(); |
| 295 | |
Johannes Berg | 077f493 | 2012-01-20 13:55:18 +0100 | [diff] [blame] | 296 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 297 | check_sdata_in_driver(sdata); |
| 298 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 299 | trace_drv_set_key(local, cmd, sdata, sta, key); |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 300 | ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 301 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 302 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | static inline void drv_update_tkip_key(struct ieee80211_local *local, |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 306 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 307 | struct ieee80211_key_conf *conf, |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 308 | struct sta_info *sta, u32 iv32, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 309 | u16 *phase1key) |
| 310 | { |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 311 | struct ieee80211_sta *ista = NULL; |
| 312 | |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 313 | if (sta) |
| 314 | ista = &sta->sta; |
| 315 | |
Johannes Berg | 077f493 | 2012-01-20 13:55:18 +0100 | [diff] [blame] | 316 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 317 | check_sdata_in_driver(sdata); |
| 318 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 319 | trace_drv_update_tkip_key(local, sdata, conf, ista, iv32); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 320 | if (local->ops->update_tkip_key) |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 321 | local->ops->update_tkip_key(&local->hw, &sdata->vif, conf, |
| 322 | ista, iv32, phase1key); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 323 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | static inline int drv_hw_scan(struct ieee80211_local *local, |
Johannes Berg | a060bbf | 2010-04-27 11:59:34 +0200 | [diff] [blame] | 327 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 328 | struct cfg80211_scan_request *req) |
| 329 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 330 | int ret; |
| 331 | |
| 332 | might_sleep(); |
| 333 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 334 | check_sdata_in_driver(sdata); |
| 335 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 336 | trace_drv_hw_scan(local, sdata); |
Johannes Berg | a060bbf | 2010-04-27 11:59:34 +0200 | [diff] [blame] | 337 | ret = local->ops->hw_scan(&local->hw, &sdata->vif, req); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 338 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 339 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 340 | } |
| 341 | |
Eliad Peller | b856439 | 2011-06-13 12:47:30 +0300 | [diff] [blame] | 342 | static inline void drv_cancel_hw_scan(struct ieee80211_local *local, |
| 343 | struct ieee80211_sub_if_data *sdata) |
| 344 | { |
| 345 | might_sleep(); |
| 346 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 347 | check_sdata_in_driver(sdata); |
| 348 | |
Eliad Peller | b856439 | 2011-06-13 12:47:30 +0300 | [diff] [blame] | 349 | trace_drv_cancel_hw_scan(local, sdata); |
| 350 | local->ops->cancel_hw_scan(&local->hw, &sdata->vif); |
| 351 | trace_drv_return_void(local); |
| 352 | } |
| 353 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 354 | static inline int |
| 355 | drv_sched_scan_start(struct ieee80211_local *local, |
| 356 | struct ieee80211_sub_if_data *sdata, |
| 357 | struct cfg80211_sched_scan_request *req, |
| 358 | struct ieee80211_sched_scan_ies *ies) |
| 359 | { |
| 360 | int ret; |
| 361 | |
| 362 | might_sleep(); |
| 363 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 364 | check_sdata_in_driver(sdata); |
| 365 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 366 | trace_drv_sched_scan_start(local, sdata); |
| 367 | ret = local->ops->sched_scan_start(&local->hw, &sdata->vif, |
| 368 | req, ies); |
| 369 | trace_drv_return_int(local, ret); |
| 370 | return ret; |
| 371 | } |
| 372 | |
| 373 | static inline void drv_sched_scan_stop(struct ieee80211_local *local, |
| 374 | struct ieee80211_sub_if_data *sdata) |
| 375 | { |
| 376 | might_sleep(); |
| 377 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 378 | check_sdata_in_driver(sdata); |
| 379 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 380 | trace_drv_sched_scan_stop(local, sdata); |
| 381 | local->ops->sched_scan_stop(&local->hw, &sdata->vif); |
| 382 | trace_drv_return_void(local); |
| 383 | } |
| 384 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 385 | static inline void drv_sw_scan_start(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_sw_scan_start(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 390 | if (local->ops->sw_scan_start) |
| 391 | local->ops->sw_scan_start(&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 void drv_sw_scan_complete(struct ieee80211_local *local) |
| 396 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 397 | might_sleep(); |
| 398 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 399 | trace_drv_sw_scan_complete(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 400 | if (local->ops->sw_scan_complete) |
| 401 | local->ops->sw_scan_complete(&local->hw); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 402 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | static inline int drv_get_stats(struct ieee80211_local *local, |
| 406 | struct ieee80211_low_level_stats *stats) |
| 407 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 408 | int ret = -EOPNOTSUPP; |
| 409 | |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 410 | might_sleep(); |
| 411 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 412 | if (local->ops->get_stats) |
| 413 | ret = local->ops->get_stats(&local->hw, stats); |
| 414 | trace_drv_get_stats(local, stats, ret); |
| 415 | |
| 416 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | static inline void drv_get_tkip_seq(struct ieee80211_local *local, |
| 420 | u8 hw_key_idx, u32 *iv32, u16 *iv16) |
| 421 | { |
| 422 | if (local->ops->get_tkip_seq) |
| 423 | local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 424 | trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 425 | } |
| 426 | |
Arik Nemtsov | f23a478 | 2010-11-08 11:51:06 +0200 | [diff] [blame] | 427 | static inline int drv_set_frag_threshold(struct ieee80211_local *local, |
| 428 | u32 value) |
| 429 | { |
| 430 | int ret = 0; |
| 431 | |
| 432 | might_sleep(); |
| 433 | |
| 434 | trace_drv_set_frag_threshold(local, value); |
| 435 | if (local->ops->set_frag_threshold) |
| 436 | ret = local->ops->set_frag_threshold(&local->hw, value); |
| 437 | trace_drv_return_int(local, ret); |
| 438 | return ret; |
| 439 | } |
| 440 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 441 | static inline int drv_set_rts_threshold(struct ieee80211_local *local, |
| 442 | u32 value) |
| 443 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 444 | int ret = 0; |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 445 | |
| 446 | might_sleep(); |
| 447 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 448 | trace_drv_set_rts_threshold(local, value); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 449 | if (local->ops->set_rts_threshold) |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 450 | ret = local->ops->set_rts_threshold(&local->hw, value); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 451 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 452 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 453 | } |
| 454 | |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 455 | static inline int drv_set_coverage_class(struct ieee80211_local *local, |
| 456 | u8 value) |
| 457 | { |
| 458 | int ret = 0; |
| 459 | might_sleep(); |
| 460 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 461 | trace_drv_set_coverage_class(local, value); |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 462 | if (local->ops->set_coverage_class) |
| 463 | local->ops->set_coverage_class(&local->hw, value); |
| 464 | else |
| 465 | ret = -EOPNOTSUPP; |
| 466 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 467 | trace_drv_return_int(local, ret); |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 468 | return ret; |
| 469 | } |
| 470 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 471 | static inline void drv_sta_notify(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 472 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 473 | enum sta_notify_cmd cmd, |
| 474 | struct ieee80211_sta *sta) |
| 475 | { |
Felix Fietkau | bc192f8 | 2011-11-23 21:09:49 +0700 | [diff] [blame] | 476 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 477 | check_sdata_in_driver(sdata); |
| 478 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 479 | trace_drv_sta_notify(local, sdata, cmd, sta); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 480 | if (local->ops->sta_notify) |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 481 | local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 482 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 483 | } |
| 484 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 485 | static inline int drv_sta_add(struct ieee80211_local *local, |
| 486 | struct ieee80211_sub_if_data *sdata, |
| 487 | struct ieee80211_sta *sta) |
| 488 | { |
| 489 | int ret = 0; |
| 490 | |
| 491 | might_sleep(); |
| 492 | |
Felix Fietkau | bc192f8 | 2011-11-23 21:09:49 +0700 | [diff] [blame] | 493 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 494 | check_sdata_in_driver(sdata); |
| 495 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 496 | trace_drv_sta_add(local, sdata, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 497 | if (local->ops->sta_add) |
| 498 | ret = local->ops->sta_add(&local->hw, &sdata->vif, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 499 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 500 | trace_drv_return_int(local, ret); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 501 | |
| 502 | return ret; |
| 503 | } |
| 504 | |
| 505 | static inline void drv_sta_remove(struct ieee80211_local *local, |
| 506 | struct ieee80211_sub_if_data *sdata, |
| 507 | struct ieee80211_sta *sta) |
| 508 | { |
| 509 | might_sleep(); |
| 510 | |
Felix Fietkau | bc192f8 | 2011-11-23 21:09:49 +0700 | [diff] [blame] | 511 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 512 | check_sdata_in_driver(sdata); |
| 513 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 514 | trace_drv_sta_remove(local, sdata, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 515 | if (local->ops->sta_remove) |
| 516 | local->ops->sta_remove(&local->hw, &sdata->vif, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 517 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 518 | trace_drv_return_void(local); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 519 | } |
| 520 | |
Sujith Manoharan | 77d2ece | 2012-11-20 08:46:02 +0530 | [diff] [blame] | 521 | #ifdef CONFIG_MAC80211_DEBUGFS |
| 522 | static inline void drv_sta_add_debugfs(struct ieee80211_local *local, |
| 523 | struct ieee80211_sub_if_data *sdata, |
| 524 | struct ieee80211_sta *sta, |
| 525 | struct dentry *dir) |
| 526 | { |
| 527 | might_sleep(); |
| 528 | |
| 529 | sdata = get_bss_sdata(sdata); |
| 530 | check_sdata_in_driver(sdata); |
| 531 | |
| 532 | if (local->ops->sta_add_debugfs) |
| 533 | local->ops->sta_add_debugfs(&local->hw, &sdata->vif, |
| 534 | sta, dir); |
| 535 | } |
| 536 | |
| 537 | static inline void drv_sta_remove_debugfs(struct ieee80211_local *local, |
| 538 | struct ieee80211_sub_if_data *sdata, |
| 539 | struct ieee80211_sta *sta, |
| 540 | struct dentry *dir) |
| 541 | { |
| 542 | might_sleep(); |
| 543 | |
| 544 | sdata = get_bss_sdata(sdata); |
| 545 | check_sdata_in_driver(sdata); |
| 546 | |
| 547 | if (local->ops->sta_remove_debugfs) |
| 548 | local->ops->sta_remove_debugfs(&local->hw, &sdata->vif, |
| 549 | sta, dir); |
| 550 | } |
| 551 | #endif |
| 552 | |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 553 | static inline __must_check |
| 554 | int drv_sta_state(struct ieee80211_local *local, |
| 555 | struct ieee80211_sub_if_data *sdata, |
| 556 | struct sta_info *sta, |
| 557 | enum ieee80211_sta_state old_state, |
| 558 | enum ieee80211_sta_state new_state) |
| 559 | { |
| 560 | int ret = 0; |
| 561 | |
| 562 | might_sleep(); |
| 563 | |
| 564 | sdata = get_bss_sdata(sdata); |
| 565 | check_sdata_in_driver(sdata); |
| 566 | |
| 567 | trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state); |
Johannes Berg | a4ec45a | 2012-01-20 13:55:22 +0100 | [diff] [blame] | 568 | if (local->ops->sta_state) { |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 569 | ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta, |
| 570 | old_state, new_state); |
Johannes Berg | a4ec45a | 2012-01-20 13:55:22 +0100 | [diff] [blame] | 571 | } else if (old_state == IEEE80211_STA_AUTH && |
| 572 | new_state == IEEE80211_STA_ASSOC) { |
| 573 | ret = drv_sta_add(local, sdata, &sta->sta); |
| 574 | if (ret == 0) |
| 575 | sta->uploaded = true; |
| 576 | } else if (old_state == IEEE80211_STA_ASSOC && |
| 577 | new_state == IEEE80211_STA_AUTH) { |
| 578 | drv_sta_remove(local, sdata, &sta->sta); |
| 579 | } |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 580 | trace_drv_return_int(local, ret); |
| 581 | return ret; |
| 582 | } |
| 583 | |
Johannes Berg | 8f727ef | 2012-03-30 08:43:32 +0200 | [diff] [blame] | 584 | static inline void drv_sta_rc_update(struct ieee80211_local *local, |
| 585 | struct ieee80211_sub_if_data *sdata, |
| 586 | struct ieee80211_sta *sta, u32 changed) |
| 587 | { |
| 588 | sdata = get_bss_sdata(sdata); |
| 589 | check_sdata_in_driver(sdata); |
| 590 | |
Antonio Quartulli | e687f61 | 2012-08-12 18:24:55 +0200 | [diff] [blame] | 591 | WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED && |
Thomas Pedersen | f68d776 | 2013-01-23 12:18:13 -0800 | [diff] [blame] | 592 | (sdata->vif.type != NL80211_IFTYPE_ADHOC && |
| 593 | sdata->vif.type != NL80211_IFTYPE_MESH_POINT)); |
Antonio Quartulli | e687f61 | 2012-08-12 18:24:55 +0200 | [diff] [blame] | 594 | |
Johannes Berg | 8f727ef | 2012-03-30 08:43:32 +0200 | [diff] [blame] | 595 | trace_drv_sta_rc_update(local, sdata, sta, changed); |
| 596 | if (local->ops->sta_rc_update) |
| 597 | local->ops->sta_rc_update(&local->hw, &sdata->vif, |
| 598 | sta, changed); |
| 599 | |
| 600 | trace_drv_return_void(local); |
| 601 | } |
| 602 | |
Eliad Peller | f6f3def | 2011-09-25 20:06:54 +0300 | [diff] [blame] | 603 | static inline int drv_conf_tx(struct ieee80211_local *local, |
Johannes Berg | a3304b0 | 2012-03-28 11:04:24 +0200 | [diff] [blame] | 604 | struct ieee80211_sub_if_data *sdata, u16 ac, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 605 | const struct ieee80211_tx_queue_params *params) |
| 606 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 607 | int ret = -EOPNOTSUPP; |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 608 | |
| 609 | might_sleep(); |
| 610 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 611 | check_sdata_in_driver(sdata); |
| 612 | |
Johannes Berg | a3304b0 | 2012-03-28 11:04:24 +0200 | [diff] [blame] | 613 | trace_drv_conf_tx(local, sdata, ac, params); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 614 | if (local->ops->conf_tx) |
Eliad Peller | 8a3a3c8 | 2011-10-02 10:15:52 +0200 | [diff] [blame] | 615 | ret = local->ops->conf_tx(&local->hw, &sdata->vif, |
Johannes Berg | a3304b0 | 2012-03-28 11:04:24 +0200 | [diff] [blame] | 616 | ac, params); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 617 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 618 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 619 | } |
| 620 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 621 | static inline u64 drv_get_tsf(struct ieee80211_local *local, |
| 622 | struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 623 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 624 | u64 ret = -1ULL; |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 625 | |
| 626 | might_sleep(); |
| 627 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 628 | check_sdata_in_driver(sdata); |
| 629 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 630 | trace_drv_get_tsf(local, sdata); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 631 | if (local->ops->get_tsf) |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 632 | ret = local->ops->get_tsf(&local->hw, &sdata->vif); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 633 | trace_drv_return_u64(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 634 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 635 | } |
| 636 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 637 | static inline void drv_set_tsf(struct ieee80211_local *local, |
| 638 | struct ieee80211_sub_if_data *sdata, |
| 639 | u64 tsf) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 640 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 641 | might_sleep(); |
| 642 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 643 | check_sdata_in_driver(sdata); |
| 644 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 645 | trace_drv_set_tsf(local, sdata, tsf); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 646 | if (local->ops->set_tsf) |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 647 | local->ops->set_tsf(&local->hw, &sdata->vif, tsf); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 648 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 649 | } |
| 650 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 651 | static inline void drv_reset_tsf(struct ieee80211_local *local, |
| 652 | struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 653 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 654 | might_sleep(); |
| 655 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 656 | check_sdata_in_driver(sdata); |
| 657 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 658 | trace_drv_reset_tsf(local, sdata); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 659 | if (local->ops->reset_tsf) |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 660 | local->ops->reset_tsf(&local->hw, &sdata->vif); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 661 | trace_drv_return_void(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | static inline int drv_tx_last_beacon(struct ieee80211_local *local) |
| 665 | { |
Masanari Iida | 02582e9 | 2012-08-22 19:11:26 +0900 | [diff] [blame] | 666 | int ret = 0; /* default unsupported op for less congestion */ |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 667 | |
| 668 | might_sleep(); |
| 669 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 670 | trace_drv_tx_last_beacon(local); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 671 | if (local->ops->tx_last_beacon) |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 672 | ret = local->ops->tx_last_beacon(&local->hw); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 673 | trace_drv_return_int(local, ret); |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 674 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 675 | } |
| 676 | |
| 677 | static inline int drv_ampdu_action(struct ieee80211_local *local, |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 678 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 679 | enum ieee80211_ampdu_mlme_action action, |
| 680 | struct ieee80211_sta *sta, u16 tid, |
Johannes Berg | 0b01f03 | 2011-01-18 13:51:05 +0100 | [diff] [blame] | 681 | u16 *ssn, u8 buf_size) |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 682 | { |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 683 | int ret = -EOPNOTSUPP; |
Johannes Berg | cfcdbde | 2010-06-10 10:21:48 +0200 | [diff] [blame] | 684 | |
| 685 | might_sleep(); |
| 686 | |
Felix Fietkau | bc192f8 | 2011-11-23 21:09:49 +0700 | [diff] [blame] | 687 | sdata = get_bss_sdata(sdata); |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 688 | check_sdata_in_driver(sdata); |
| 689 | |
Johannes Berg | 0b01f03 | 2011-01-18 13:51:05 +0100 | [diff] [blame] | 690 | trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 691 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 692 | if (local->ops->ampdu_action) |
Johannes Berg | 12375ef | 2009-11-25 20:30:31 +0100 | [diff] [blame] | 693 | ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action, |
Johannes Berg | 0b01f03 | 2011-01-18 13:51:05 +0100 | [diff] [blame] | 694 | sta, tid, ssn, buf_size); |
Johannes Berg | 85ad181 | 2010-06-10 10:21:49 +0200 | [diff] [blame] | 695 | |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 696 | trace_drv_return_int(local, ret); |
| 697 | |
Johannes Berg | 0a2b8bb | 2009-07-07 13:46:22 +0200 | [diff] [blame] | 698 | return ret; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 699 | } |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 700 | |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 701 | static inline int drv_get_survey(struct ieee80211_local *local, int idx, |
| 702 | struct survey_info *survey) |
| 703 | { |
| 704 | int ret = -EOPNOTSUPP; |
John W. Linville | c466d4e | 2010-06-29 14:51:23 -0400 | [diff] [blame] | 705 | |
| 706 | trace_drv_get_survey(local, idx, survey); |
| 707 | |
Holger Schurig | 35dd050 | 2010-06-07 16:33:49 +0200 | [diff] [blame] | 708 | if (local->ops->get_survey) |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 709 | ret = local->ops->get_survey(&local->hw, idx, survey); |
John W. Linville | c466d4e | 2010-06-29 14:51:23 -0400 | [diff] [blame] | 710 | |
| 711 | trace_drv_return_int(local, ret); |
| 712 | |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 713 | return ret; |
| 714 | } |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 715 | |
| 716 | static inline void drv_rfkill_poll(struct ieee80211_local *local) |
| 717 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 718 | might_sleep(); |
| 719 | |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 720 | if (local->ops->rfkill_poll) |
| 721 | local->ops->rfkill_poll(&local->hw); |
| 722 | } |
Johannes Berg | a80f7c0 | 2009-12-23 13:15:32 +0100 | [diff] [blame] | 723 | |
Johannes Berg | 39ecc01 | 2013-02-13 12:11:00 +0100 | [diff] [blame] | 724 | static inline void drv_flush(struct ieee80211_local *local, |
| 725 | u32 queues, bool drop) |
Johannes Berg | a80f7c0 | 2009-12-23 13:15:32 +0100 | [diff] [blame] | 726 | { |
Kalle Valo | e1781ed | 2009-12-23 13:15:47 +0100 | [diff] [blame] | 727 | might_sleep(); |
| 728 | |
Johannes Berg | 39ecc01 | 2013-02-13 12:11:00 +0100 | [diff] [blame] | 729 | trace_drv_flush(local, queues, drop); |
Johannes Berg | a80f7c0 | 2009-12-23 13:15:32 +0100 | [diff] [blame] | 730 | if (local->ops->flush) |
Johannes Berg | 39ecc01 | 2013-02-13 12:11:00 +0100 | [diff] [blame] | 731 | local->ops->flush(&local->hw, queues, drop); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 732 | trace_drv_return_void(local); |
Johannes Berg | a80f7c0 | 2009-12-23 13:15:32 +0100 | [diff] [blame] | 733 | } |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 734 | |
| 735 | static inline void drv_channel_switch(struct ieee80211_local *local, |
| 736 | struct ieee80211_channel_switch *ch_switch) |
| 737 | { |
| 738 | might_sleep(); |
| 739 | |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 740 | trace_drv_channel_switch(local, ch_switch); |
Johannes Berg | 4efc76b | 2010-06-10 10:56:20 +0200 | [diff] [blame] | 741 | local->ops->channel_switch(&local->hw, ch_switch); |
| 742 | trace_drv_return_void(local); |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 743 | } |
| 744 | |
Bruno Randolf | 15d9675 | 2010-11-10 12:50:56 +0900 | [diff] [blame] | 745 | |
| 746 | static inline int drv_set_antenna(struct ieee80211_local *local, |
| 747 | u32 tx_ant, u32 rx_ant) |
| 748 | { |
| 749 | int ret = -EOPNOTSUPP; |
| 750 | might_sleep(); |
| 751 | if (local->ops->set_antenna) |
| 752 | ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant); |
| 753 | trace_drv_set_antenna(local, tx_ant, rx_ant, ret); |
| 754 | return ret; |
| 755 | } |
| 756 | |
| 757 | static inline int drv_get_antenna(struct ieee80211_local *local, |
| 758 | u32 *tx_ant, u32 *rx_ant) |
| 759 | { |
| 760 | int ret = -EOPNOTSUPP; |
| 761 | might_sleep(); |
| 762 | if (local->ops->get_antenna) |
| 763 | ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant); |
| 764 | trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret); |
| 765 | return ret; |
| 766 | } |
| 767 | |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 768 | static inline int drv_remain_on_channel(struct ieee80211_local *local, |
Eliad Peller | 4988456 | 2012-11-19 17:05:09 +0200 | [diff] [blame] | 769 | struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 770 | struct ieee80211_channel *chan, |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 771 | unsigned int duration, |
| 772 | enum ieee80211_roc_type type) |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 773 | { |
| 774 | int ret; |
| 775 | |
| 776 | might_sleep(); |
| 777 | |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 778 | trace_drv_remain_on_channel(local, sdata, chan, duration, type); |
Eliad Peller | 4988456 | 2012-11-19 17:05:09 +0200 | [diff] [blame] | 779 | ret = local->ops->remain_on_channel(&local->hw, &sdata->vif, |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 780 | chan, duration, type); |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 781 | trace_drv_return_int(local, ret); |
| 782 | |
| 783 | return ret; |
| 784 | } |
| 785 | |
| 786 | static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local) |
| 787 | { |
| 788 | int ret; |
| 789 | |
| 790 | might_sleep(); |
| 791 | |
| 792 | trace_drv_cancel_remain_on_channel(local); |
| 793 | ret = local->ops->cancel_remain_on_channel(&local->hw); |
| 794 | trace_drv_return_int(local, ret); |
| 795 | |
| 796 | return ret; |
| 797 | } |
| 798 | |
John W. Linville | 38c0915 | 2011-03-07 16:19:18 -0500 | [diff] [blame] | 799 | static inline int drv_set_ringparam(struct ieee80211_local *local, |
| 800 | u32 tx, u32 rx) |
| 801 | { |
| 802 | int ret = -ENOTSUPP; |
| 803 | |
| 804 | might_sleep(); |
| 805 | |
| 806 | trace_drv_set_ringparam(local, tx, rx); |
| 807 | if (local->ops->set_ringparam) |
| 808 | ret = local->ops->set_ringparam(&local->hw, tx, rx); |
| 809 | trace_drv_return_int(local, ret); |
| 810 | |
| 811 | return ret; |
| 812 | } |
| 813 | |
| 814 | static inline void drv_get_ringparam(struct ieee80211_local *local, |
| 815 | u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max) |
| 816 | { |
| 817 | might_sleep(); |
| 818 | |
| 819 | trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max); |
| 820 | if (local->ops->get_ringparam) |
| 821 | local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max); |
| 822 | trace_drv_return_void(local); |
| 823 | } |
| 824 | |
Vivek Natarajan | e8306f9 | 2011-04-06 11:41:10 +0530 | [diff] [blame] | 825 | static inline bool drv_tx_frames_pending(struct ieee80211_local *local) |
| 826 | { |
| 827 | bool ret = false; |
| 828 | |
| 829 | might_sleep(); |
| 830 | |
| 831 | trace_drv_tx_frames_pending(local); |
| 832 | if (local->ops->tx_frames_pending) |
| 833 | ret = local->ops->tx_frames_pending(&local->hw); |
| 834 | trace_drv_return_bool(local, ret); |
| 835 | |
| 836 | return ret; |
| 837 | } |
Sujith Manoharan | bdbfd6b | 2011-04-27 16:56:51 +0530 | [diff] [blame] | 838 | |
| 839 | static inline int drv_set_bitrate_mask(struct ieee80211_local *local, |
| 840 | struct ieee80211_sub_if_data *sdata, |
| 841 | const struct cfg80211_bitrate_mask *mask) |
| 842 | { |
| 843 | int ret = -EOPNOTSUPP; |
| 844 | |
| 845 | might_sleep(); |
| 846 | |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 847 | check_sdata_in_driver(sdata); |
| 848 | |
Sujith Manoharan | bdbfd6b | 2011-04-27 16:56:51 +0530 | [diff] [blame] | 849 | trace_drv_set_bitrate_mask(local, sdata, mask); |
| 850 | if (local->ops->set_bitrate_mask) |
| 851 | ret = local->ops->set_bitrate_mask(&local->hw, |
| 852 | &sdata->vif, mask); |
| 853 | trace_drv_return_int(local, ret); |
| 854 | |
| 855 | return ret; |
| 856 | } |
| 857 | |
Johannes Berg | c68f4b8 | 2011-07-05 16:35:41 +0200 | [diff] [blame] | 858 | static inline void drv_set_rekey_data(struct ieee80211_local *local, |
| 859 | struct ieee80211_sub_if_data *sdata, |
| 860 | struct cfg80211_gtk_rekey_data *data) |
| 861 | { |
Johannes Berg | 7b7eab6 | 2011-11-03 14:41:13 +0100 | [diff] [blame] | 862 | check_sdata_in_driver(sdata); |
| 863 | |
Johannes Berg | c68f4b8 | 2011-07-05 16:35:41 +0200 | [diff] [blame] | 864 | trace_drv_set_rekey_data(local, sdata, data); |
| 865 | if (local->ops->set_rekey_data) |
| 866 | local->ops->set_rekey_data(&local->hw, &sdata->vif, data); |
| 867 | trace_drv_return_void(local); |
| 868 | } |
| 869 | |
Meenakshi Venkataraman | 615f7b9 | 2011-07-08 08:46:22 -0700 | [diff] [blame] | 870 | static inline void drv_rssi_callback(struct ieee80211_local *local, |
Emmanuel Grumbach | 887da91 | 2013-01-20 17:32:41 +0200 | [diff] [blame] | 871 | struct ieee80211_sub_if_data *sdata, |
Meenakshi Venkataraman | 615f7b9 | 2011-07-08 08:46:22 -0700 | [diff] [blame] | 872 | const enum ieee80211_rssi_event event) |
| 873 | { |
Emmanuel Grumbach | 887da91 | 2013-01-20 17:32:41 +0200 | [diff] [blame] | 874 | trace_drv_rssi_callback(local, sdata, event); |
Meenakshi Venkataraman | 615f7b9 | 2011-07-08 08:46:22 -0700 | [diff] [blame] | 875 | if (local->ops->rssi_callback) |
Emmanuel Grumbach | 887da91 | 2013-01-20 17:32:41 +0200 | [diff] [blame] | 876 | local->ops->rssi_callback(&local->hw, &sdata->vif, event); |
Meenakshi Venkataraman | 615f7b9 | 2011-07-08 08:46:22 -0700 | [diff] [blame] | 877 | trace_drv_return_void(local); |
| 878 | } |
Johannes Berg | 4049e09 | 2011-09-29 16:04:32 +0200 | [diff] [blame] | 879 | |
| 880 | static inline void |
| 881 | drv_release_buffered_frames(struct ieee80211_local *local, |
| 882 | struct sta_info *sta, u16 tids, int num_frames, |
| 883 | enum ieee80211_frame_release_type reason, |
| 884 | bool more_data) |
| 885 | { |
| 886 | trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames, |
| 887 | reason, more_data); |
| 888 | if (local->ops->release_buffered_frames) |
| 889 | local->ops->release_buffered_frames(&local->hw, &sta->sta, tids, |
| 890 | num_frames, reason, |
| 891 | more_data); |
| 892 | trace_drv_return_void(local); |
| 893 | } |
Johannes Berg | 40b9640 | 2011-09-29 16:04:38 +0200 | [diff] [blame] | 894 | |
| 895 | static inline void |
| 896 | drv_allow_buffered_frames(struct ieee80211_local *local, |
| 897 | struct sta_info *sta, u16 tids, int num_frames, |
| 898 | enum ieee80211_frame_release_type reason, |
| 899 | bool more_data) |
| 900 | { |
| 901 | trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames, |
| 902 | reason, more_data); |
| 903 | if (local->ops->allow_buffered_frames) |
| 904 | local->ops->allow_buffered_frames(&local->hw, &sta->sta, |
| 905 | tids, num_frames, reason, |
| 906 | more_data); |
| 907 | trace_drv_return_void(local); |
| 908 | } |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 909 | |
| 910 | static inline int drv_get_rssi(struct ieee80211_local *local, |
| 911 | struct ieee80211_sub_if_data *sdata, |
| 912 | struct ieee80211_sta *sta, |
| 913 | s8 *rssi_dbm) |
| 914 | { |
| 915 | int ret; |
| 916 | |
| 917 | might_sleep(); |
| 918 | |
| 919 | ret = local->ops->get_rssi(&local->hw, &sdata->vif, sta, rssi_dbm); |
| 920 | trace_drv_get_rssi(local, sta, *rssi_dbm, ret); |
| 921 | |
| 922 | return ret; |
| 923 | } |
Johannes Berg | a1845fc | 2012-06-27 13:18:36 +0200 | [diff] [blame] | 924 | |
| 925 | static inline void drv_mgd_prepare_tx(struct ieee80211_local *local, |
| 926 | struct ieee80211_sub_if_data *sdata) |
| 927 | { |
| 928 | might_sleep(); |
| 929 | |
| 930 | check_sdata_in_driver(sdata); |
| 931 | WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION); |
| 932 | |
| 933 | trace_drv_mgd_prepare_tx(local, sdata); |
| 934 | if (local->ops->mgd_prepare_tx) |
| 935 | local->ops->mgd_prepare_tx(&local->hw, &sdata->vif); |
| 936 | trace_drv_return_void(local); |
| 937 | } |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 938 | |
| 939 | static inline int drv_add_chanctx(struct ieee80211_local *local, |
| 940 | struct ieee80211_chanctx *ctx) |
| 941 | { |
| 942 | int ret = -EOPNOTSUPP; |
| 943 | |
| 944 | trace_drv_add_chanctx(local, ctx); |
| 945 | if (local->ops->add_chanctx) |
| 946 | ret = local->ops->add_chanctx(&local->hw, &ctx->conf); |
| 947 | trace_drv_return_int(local, ret); |
Johannes Berg | 8a61af6 | 2012-12-13 17:42:30 +0100 | [diff] [blame] | 948 | if (!ret) |
| 949 | ctx->driver_present = true; |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 950 | |
| 951 | return ret; |
| 952 | } |
| 953 | |
| 954 | static inline void drv_remove_chanctx(struct ieee80211_local *local, |
| 955 | struct ieee80211_chanctx *ctx) |
| 956 | { |
| 957 | trace_drv_remove_chanctx(local, ctx); |
| 958 | if (local->ops->remove_chanctx) |
| 959 | local->ops->remove_chanctx(&local->hw, &ctx->conf); |
| 960 | trace_drv_return_void(local); |
Johannes Berg | 8a61af6 | 2012-12-13 17:42:30 +0100 | [diff] [blame] | 961 | ctx->driver_present = false; |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 962 | } |
| 963 | |
| 964 | static inline void drv_change_chanctx(struct ieee80211_local *local, |
| 965 | struct ieee80211_chanctx *ctx, |
| 966 | u32 changed) |
| 967 | { |
| 968 | trace_drv_change_chanctx(local, ctx, changed); |
Johannes Berg | 8a61af6 | 2012-12-13 17:42:30 +0100 | [diff] [blame] | 969 | if (local->ops->change_chanctx) { |
| 970 | WARN_ON_ONCE(!ctx->driver_present); |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 971 | local->ops->change_chanctx(&local->hw, &ctx->conf, changed); |
Johannes Berg | 8a61af6 | 2012-12-13 17:42:30 +0100 | [diff] [blame] | 972 | } |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 973 | trace_drv_return_void(local); |
| 974 | } |
| 975 | |
| 976 | static inline int drv_assign_vif_chanctx(struct ieee80211_local *local, |
| 977 | struct ieee80211_sub_if_data *sdata, |
| 978 | struct ieee80211_chanctx *ctx) |
| 979 | { |
| 980 | int ret = 0; |
| 981 | |
| 982 | check_sdata_in_driver(sdata); |
| 983 | |
| 984 | trace_drv_assign_vif_chanctx(local, sdata, ctx); |
Johannes Berg | 8a61af6 | 2012-12-13 17:42:30 +0100 | [diff] [blame] | 985 | if (local->ops->assign_vif_chanctx) { |
| 986 | WARN_ON_ONCE(!ctx->driver_present); |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 987 | ret = local->ops->assign_vif_chanctx(&local->hw, |
| 988 | &sdata->vif, |
| 989 | &ctx->conf); |
Johannes Berg | 8a61af6 | 2012-12-13 17:42:30 +0100 | [diff] [blame] | 990 | } |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 991 | trace_drv_return_int(local, ret); |
| 992 | |
| 993 | return ret; |
| 994 | } |
| 995 | |
| 996 | static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local, |
| 997 | struct ieee80211_sub_if_data *sdata, |
| 998 | struct ieee80211_chanctx *ctx) |
| 999 | { |
| 1000 | check_sdata_in_driver(sdata); |
| 1001 | |
| 1002 | trace_drv_unassign_vif_chanctx(local, sdata, ctx); |
Johannes Berg | 8a61af6 | 2012-12-13 17:42:30 +0100 | [diff] [blame] | 1003 | if (local->ops->unassign_vif_chanctx) { |
| 1004 | WARN_ON_ONCE(!ctx->driver_present); |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 1005 | local->ops->unassign_vif_chanctx(&local->hw, |
| 1006 | &sdata->vif, |
| 1007 | &ctx->conf); |
Johannes Berg | 8a61af6 | 2012-12-13 17:42:30 +0100 | [diff] [blame] | 1008 | } |
Michal Kazior | c3645ea | 2012-06-26 14:37:17 +0200 | [diff] [blame] | 1009 | trace_drv_return_void(local); |
| 1010 | } |
| 1011 | |
Johannes Berg | 1041638 | 2012-10-19 15:44:42 +0200 | [diff] [blame] | 1012 | static inline int drv_start_ap(struct ieee80211_local *local, |
| 1013 | struct ieee80211_sub_if_data *sdata) |
| 1014 | { |
| 1015 | int ret = 0; |
| 1016 | |
| 1017 | check_sdata_in_driver(sdata); |
| 1018 | |
| 1019 | trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf); |
| 1020 | if (local->ops->start_ap) |
| 1021 | ret = local->ops->start_ap(&local->hw, &sdata->vif); |
| 1022 | trace_drv_return_int(local, ret); |
| 1023 | return ret; |
| 1024 | } |
| 1025 | |
| 1026 | static inline void drv_stop_ap(struct ieee80211_local *local, |
| 1027 | struct ieee80211_sub_if_data *sdata) |
| 1028 | { |
| 1029 | check_sdata_in_driver(sdata); |
| 1030 | |
| 1031 | trace_drv_stop_ap(local, sdata); |
| 1032 | if (local->ops->stop_ap) |
| 1033 | local->ops->stop_ap(&local->hw, &sdata->vif); |
| 1034 | trace_drv_return_void(local); |
| 1035 | } |
| 1036 | |
Johannes Berg | 9214ad7 | 2012-11-06 19:18:13 +0100 | [diff] [blame] | 1037 | static inline void drv_restart_complete(struct ieee80211_local *local) |
| 1038 | { |
| 1039 | might_sleep(); |
| 1040 | |
| 1041 | trace_drv_restart_complete(local); |
| 1042 | if (local->ops->restart_complete) |
| 1043 | local->ops->restart_complete(&local->hw); |
| 1044 | trace_drv_return_void(local); |
| 1045 | } |
| 1046 | |
Yoni Divinsky | de5fad8 | 2012-05-30 11:36:39 +0300 | [diff] [blame] | 1047 | static inline void |
| 1048 | drv_set_default_unicast_key(struct ieee80211_local *local, |
| 1049 | struct ieee80211_sub_if_data *sdata, |
| 1050 | int key_idx) |
| 1051 | { |
| 1052 | check_sdata_in_driver(sdata); |
| 1053 | |
| 1054 | WARN_ON_ONCE(key_idx < -1 || key_idx > 3); |
| 1055 | |
| 1056 | trace_drv_set_default_unicast_key(local, sdata, key_idx); |
| 1057 | if (local->ops->set_default_unicast_key) |
| 1058 | local->ops->set_default_unicast_key(&local->hw, &sdata->vif, |
| 1059 | key_idx); |
| 1060 | trace_drv_return_void(local); |
| 1061 | } |
| 1062 | |
Johannes Berg | a65240c | 2013-01-14 15:14:34 +0100 | [diff] [blame] | 1063 | #if IS_ENABLED(CONFIG_IPV6) |
| 1064 | static inline void drv_ipv6_addr_change(struct ieee80211_local *local, |
| 1065 | struct ieee80211_sub_if_data *sdata, |
| 1066 | struct inet6_dev *idev) |
| 1067 | { |
| 1068 | trace_drv_ipv6_addr_change(local, sdata); |
| 1069 | if (local->ops->ipv6_addr_change) |
| 1070 | local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev); |
| 1071 | trace_drv_return_void(local); |
| 1072 | } |
| 1073 | #endif |
| 1074 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 1075 | #endif /* __MAC80211_DRIVER_OPS */ |