blob: af4691fed6457e4df103d3e27332a01b9b304f66 [file] [log] [blame]
Johannes Berg24487982009-04-23 18:52:52 +02001#ifndef __MAC80211_DRIVER_OPS
2#define __MAC80211_DRIVER_OPS
3
4#include <net/mac80211.h>
5#include "ieee80211_i.h"
Johannes Berg0a2b8bb2009-07-07 13:46:22 +02006#include "driver-trace.h"
Johannes Berg24487982009-04-23 18:52:52 +02007
Johannes Berg7b7eab62011-11-03 14:41:13 +01008static inline void check_sdata_in_driver(struct ieee80211_sub_if_data *sdata)
9{
10 WARN_ON(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER));
11}
12
Felix Fietkaubc192f82011-11-23 21:09:49 +070013static inline struct ieee80211_sub_if_data *
14get_bss_sdata(struct ieee80211_sub_if_data *sdata)
15{
16 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
17 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
18 u.ap);
19
20 return sdata;
21}
22
Johannes Berg7bb45682011-02-24 14:42:06 +010023static inline void drv_tx(struct ieee80211_local *local, struct sk_buff *skb)
Johannes Berg24487982009-04-23 18:52:52 +020024{
Johannes Berg7bb45682011-02-24 14:42:06 +010025 local->ops->tx(&local->hw, skb);
Johannes Berg24487982009-04-23 18:52:52 +020026}
27
Johannes Berg11127e92011-11-16 16:02:47 +010028static inline void drv_tx_frags(struct ieee80211_local *local,
29 struct ieee80211_vif *vif,
30 struct ieee80211_sta *sta,
31 struct sk_buff_head *skbs)
32{
33 local->ops->tx_frags(&local->hw, vif, sta, skbs);
34}
35
Johannes Berg24487982009-04-23 18:52:52 +020036static inline int drv_start(struct ieee80211_local *local)
37{
Johannes Bergea77f122009-08-21 14:44:45 +020038 int ret;
39
Kalle Valoe1781ed2009-12-23 13:15:47 +010040 might_sleep();
41
Johannes Berg4efc76b2010-06-10 10:56:20 +020042 trace_drv_start(local);
Johannes Bergea77f122009-08-21 14:44:45 +020043 local->started = true;
44 smp_mb();
45 ret = local->ops->start(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +020046 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +020047 return ret;
Johannes Berg24487982009-04-23 18:52:52 +020048}
49
50static inline void drv_stop(struct ieee80211_local *local)
51{
Kalle Valoe1781ed2009-12-23 13:15:47 +010052 might_sleep();
53
Johannes Berg0a2b8bb2009-07-07 13:46:22 +020054 trace_drv_stop(local);
Johannes Berg4efc76b2010-06-10 10:56:20 +020055 local->ops->stop(&local->hw);
56 trace_drv_return_void(local);
Johannes Bergea77f122009-08-21 14:44:45 +020057
58 /* sync away all work on the tasklet before clearing started */
59 tasklet_disable(&local->tasklet);
60 tasklet_enable(&local->tasklet);
61
62 barrier();
63
64 local->started = false;
Johannes Berg24487982009-04-23 18:52:52 +020065}
66
Johannes Bergeecc4802011-05-04 15:37:29 +020067#ifdef CONFIG_PM
68static inline int drv_suspend(struct ieee80211_local *local,
69 struct cfg80211_wowlan *wowlan)
70{
71 int ret;
72
73 might_sleep();
74
75 trace_drv_suspend(local);
76 ret = local->ops->suspend(&local->hw, wowlan);
77 trace_drv_return_int(local, ret);
78 return ret;
79}
80
81static inline int drv_resume(struct ieee80211_local *local)
82{
83 int ret;
84
85 might_sleep();
86
87 trace_drv_resume(local);
88 ret = local->ops->resume(&local->hw);
89 trace_drv_return_int(local, ret);
90 return ret;
91}
92#endif
93
Johannes Berg24487982009-04-23 18:52:52 +020094static inline int drv_add_interface(struct ieee80211_local *local,
Johannes Berg7b7eab62011-11-03 14:41:13 +010095 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +020096{
Kalle Valoe1781ed2009-12-23 13:15:47 +010097 int ret;
98
99 might_sleep();
100
Johannes Berg7b7eab62011-11-03 14:41:13 +0100101 if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
102 sdata->vif.type == NL80211_IFTYPE_MONITOR))
103 return -EINVAL;
104
105 trace_drv_add_interface(local, sdata);
106 ret = local->ops->add_interface(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200107 trace_drv_return_int(local, ret);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100108
109 if (ret == 0)
110 sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
111
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200112 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200113}
114
Johannes Berg34d4bc42010-08-27 12:35:58 +0200115static inline int drv_change_interface(struct ieee80211_local *local,
116 struct ieee80211_sub_if_data *sdata,
Johannes Berg2ca27bc2010-09-16 14:58:23 +0200117 enum nl80211_iftype type, bool p2p)
Johannes Berg34d4bc42010-08-27 12:35:58 +0200118{
119 int ret;
120
121 might_sleep();
122
Johannes Berg7b7eab62011-11-03 14:41:13 +0100123 check_sdata_in_driver(sdata);
124
Johannes Berg2ca27bc2010-09-16 14:58:23 +0200125 trace_drv_change_interface(local, sdata, type, p2p);
126 ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
Johannes Berg34d4bc42010-08-27 12:35:58 +0200127 trace_drv_return_int(local, ret);
128 return ret;
129}
130
Johannes Berg24487982009-04-23 18:52:52 +0200131static inline void drv_remove_interface(struct ieee80211_local *local,
Johannes Berg7b7eab62011-11-03 14:41:13 +0100132 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200133{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100134 might_sleep();
135
Johannes Berg7b7eab62011-11-03 14:41:13 +0100136 check_sdata_in_driver(sdata);
137
138 trace_drv_remove_interface(local, sdata);
139 local->ops->remove_interface(&local->hw, &sdata->vif);
140 sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER;
Johannes Berg4efc76b2010-06-10 10:56:20 +0200141 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200142}
143
144static inline int drv_config(struct ieee80211_local *local, u32 changed)
145{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100146 int ret;
147
148 might_sleep();
149
Johannes Berg4efc76b2010-06-10 10:56:20 +0200150 trace_drv_config(local, changed);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100151 ret = local->ops->config(&local->hw, changed);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200152 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200153 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200154}
155
156static inline void drv_bss_info_changed(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100157 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200158 struct ieee80211_bss_conf *info,
159 u32 changed)
160{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100161 might_sleep();
162
Johannes Berg7b7eab62011-11-03 14:41:13 +0100163 check_sdata_in_driver(sdata);
164
Johannes Berg4efc76b2010-06-10 10:56:20 +0200165 trace_drv_bss_info_changed(local, sdata, info, changed);
Johannes Berg24487982009-04-23 18:52:52 +0200166 if (local->ops->bss_info_changed)
Johannes Berg12375ef2009-11-25 20:30:31 +0100167 local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200168 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200169}
170
Johannes Berg3ac64be2009-08-17 16:16:53 +0200171static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
Jiri Pirko22bedad2010-04-01 21:22:57 +0000172 struct netdev_hw_addr_list *mc_list)
Johannes Berg24487982009-04-23 18:52:52 +0200173{
Johannes Berg3ac64be2009-08-17 16:16:53 +0200174 u64 ret = 0;
175
Johannes Berg4efc76b2010-06-10 10:56:20 +0200176 trace_drv_prepare_multicast(local, mc_list->count);
177
Johannes Berg3ac64be2009-08-17 16:16:53 +0200178 if (local->ops->prepare_multicast)
Jiri Pirko22bedad2010-04-01 21:22:57 +0000179 ret = local->ops->prepare_multicast(&local->hw, mc_list);
Johannes Berg3ac64be2009-08-17 16:16:53 +0200180
Johannes Berg4efc76b2010-06-10 10:56:20 +0200181 trace_drv_return_u64(local, ret);
Johannes Berg3ac64be2009-08-17 16:16:53 +0200182
183 return ret;
184}
185
186static inline void drv_configure_filter(struct ieee80211_local *local,
187 unsigned int changed_flags,
188 unsigned int *total_flags,
189 u64 multicast)
190{
191 might_sleep();
192
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200193 trace_drv_configure_filter(local, changed_flags, total_flags,
Johannes Berg3ac64be2009-08-17 16:16:53 +0200194 multicast);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200195 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
196 multicast);
197 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200198}
199
200static inline int drv_set_tim(struct ieee80211_local *local,
201 struct ieee80211_sta *sta, bool set)
202{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200203 int ret = 0;
Johannes Berg4efc76b2010-06-10 10:56:20 +0200204 trace_drv_set_tim(local, sta, set);
Johannes Berg24487982009-04-23 18:52:52 +0200205 if (local->ops->set_tim)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200206 ret = local->ops->set_tim(&local->hw, sta, set);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200207 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200208 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200209}
210
211static inline int drv_set_key(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100212 enum set_key_cmd cmd,
213 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200214 struct ieee80211_sta *sta,
215 struct ieee80211_key_conf *key)
216{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100217 int ret;
218
219 might_sleep();
220
Johannes Berg077f4932012-01-20 13:55:18 +0100221 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100222 check_sdata_in_driver(sdata);
223
Johannes Berg4efc76b2010-06-10 10:56:20 +0200224 trace_drv_set_key(local, cmd, sdata, sta, key);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100225 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200226 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200227 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200228}
229
230static inline void drv_update_tkip_key(struct ieee80211_local *local,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100231 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200232 struct ieee80211_key_conf *conf,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100233 struct sta_info *sta, u32 iv32,
Johannes Berg24487982009-04-23 18:52:52 +0200234 u16 *phase1key)
235{
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100236 struct ieee80211_sta *ista = NULL;
237
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100238 if (sta)
239 ista = &sta->sta;
240
Johannes Berg077f4932012-01-20 13:55:18 +0100241 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100242 check_sdata_in_driver(sdata);
243
Johannes Berg4efc76b2010-06-10 10:56:20 +0200244 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
Johannes Berg24487982009-04-23 18:52:52 +0200245 if (local->ops->update_tkip_key)
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100246 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
247 ista, iv32, phase1key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200248 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200249}
250
251static inline int drv_hw_scan(struct ieee80211_local *local,
Johannes Berga060bbf2010-04-27 11:59:34 +0200252 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200253 struct cfg80211_scan_request *req)
254{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100255 int ret;
256
257 might_sleep();
258
Johannes Berg7b7eab62011-11-03 14:41:13 +0100259 check_sdata_in_driver(sdata);
260
Luciano Coelho79f460c2011-05-11 17:09:36 +0300261 trace_drv_hw_scan(local, sdata);
Johannes Berga060bbf2010-04-27 11:59:34 +0200262 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200263 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200264 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200265}
266
Eliad Pellerb8564392011-06-13 12:47:30 +0300267static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
268 struct ieee80211_sub_if_data *sdata)
269{
270 might_sleep();
271
Johannes Berg7b7eab62011-11-03 14:41:13 +0100272 check_sdata_in_driver(sdata);
273
Eliad Pellerb8564392011-06-13 12:47:30 +0300274 trace_drv_cancel_hw_scan(local, sdata);
275 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
276 trace_drv_return_void(local);
277}
278
Luciano Coelho79f460c2011-05-11 17:09:36 +0300279static inline int
280drv_sched_scan_start(struct ieee80211_local *local,
281 struct ieee80211_sub_if_data *sdata,
282 struct cfg80211_sched_scan_request *req,
283 struct ieee80211_sched_scan_ies *ies)
284{
285 int ret;
286
287 might_sleep();
288
Johannes Berg7b7eab62011-11-03 14:41:13 +0100289 check_sdata_in_driver(sdata);
290
Luciano Coelho79f460c2011-05-11 17:09:36 +0300291 trace_drv_sched_scan_start(local, sdata);
292 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
293 req, ies);
294 trace_drv_return_int(local, ret);
295 return ret;
296}
297
298static inline void drv_sched_scan_stop(struct ieee80211_local *local,
299 struct ieee80211_sub_if_data *sdata)
300{
301 might_sleep();
302
Johannes Berg7b7eab62011-11-03 14:41:13 +0100303 check_sdata_in_driver(sdata);
304
Luciano Coelho79f460c2011-05-11 17:09:36 +0300305 trace_drv_sched_scan_stop(local, sdata);
306 local->ops->sched_scan_stop(&local->hw, &sdata->vif);
307 trace_drv_return_void(local);
308}
309
Johannes Berg24487982009-04-23 18:52:52 +0200310static inline void drv_sw_scan_start(struct ieee80211_local *local)
311{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100312 might_sleep();
313
Johannes Berg4efc76b2010-06-10 10:56:20 +0200314 trace_drv_sw_scan_start(local);
Johannes Berg24487982009-04-23 18:52:52 +0200315 if (local->ops->sw_scan_start)
316 local->ops->sw_scan_start(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200317 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200318}
319
320static inline void drv_sw_scan_complete(struct ieee80211_local *local)
321{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100322 might_sleep();
323
Johannes Berg4efc76b2010-06-10 10:56:20 +0200324 trace_drv_sw_scan_complete(local);
Johannes Berg24487982009-04-23 18:52:52 +0200325 if (local->ops->sw_scan_complete)
326 local->ops->sw_scan_complete(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200327 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200328}
329
330static inline int drv_get_stats(struct ieee80211_local *local,
331 struct ieee80211_low_level_stats *stats)
332{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200333 int ret = -EOPNOTSUPP;
334
Kalle Valoe1781ed2009-12-23 13:15:47 +0100335 might_sleep();
336
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200337 if (local->ops->get_stats)
338 ret = local->ops->get_stats(&local->hw, stats);
339 trace_drv_get_stats(local, stats, ret);
340
341 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200342}
343
344static inline void drv_get_tkip_seq(struct ieee80211_local *local,
345 u8 hw_key_idx, u32 *iv32, u16 *iv16)
346{
347 if (local->ops->get_tkip_seq)
348 local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200349 trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
Johannes Berg24487982009-04-23 18:52:52 +0200350}
351
Arik Nemtsovf23a4782010-11-08 11:51:06 +0200352static inline int drv_set_frag_threshold(struct ieee80211_local *local,
353 u32 value)
354{
355 int ret = 0;
356
357 might_sleep();
358
359 trace_drv_set_frag_threshold(local, value);
360 if (local->ops->set_frag_threshold)
361 ret = local->ops->set_frag_threshold(&local->hw, value);
362 trace_drv_return_int(local, ret);
363 return ret;
364}
365
Johannes Berg24487982009-04-23 18:52:52 +0200366static inline int drv_set_rts_threshold(struct ieee80211_local *local,
367 u32 value)
368{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200369 int ret = 0;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100370
371 might_sleep();
372
Johannes Berg4efc76b2010-06-10 10:56:20 +0200373 trace_drv_set_rts_threshold(local, value);
Johannes Berg24487982009-04-23 18:52:52 +0200374 if (local->ops->set_rts_threshold)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200375 ret = local->ops->set_rts_threshold(&local->hw, value);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200376 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200377 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200378}
379
Lukáš Turek310bc672009-12-21 22:50:48 +0100380static inline int drv_set_coverage_class(struct ieee80211_local *local,
381 u8 value)
382{
383 int ret = 0;
384 might_sleep();
385
Johannes Berg4efc76b2010-06-10 10:56:20 +0200386 trace_drv_set_coverage_class(local, value);
Lukáš Turek310bc672009-12-21 22:50:48 +0100387 if (local->ops->set_coverage_class)
388 local->ops->set_coverage_class(&local->hw, value);
389 else
390 ret = -EOPNOTSUPP;
391
Johannes Berg4efc76b2010-06-10 10:56:20 +0200392 trace_drv_return_int(local, ret);
Lukáš Turek310bc672009-12-21 22:50:48 +0100393 return ret;
394}
395
Johannes Berg24487982009-04-23 18:52:52 +0200396static inline void drv_sta_notify(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100397 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200398 enum sta_notify_cmd cmd,
399 struct ieee80211_sta *sta)
400{
Felix Fietkaubc192f82011-11-23 21:09:49 +0700401 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100402 check_sdata_in_driver(sdata);
403
Johannes Berg4efc76b2010-06-10 10:56:20 +0200404 trace_drv_sta_notify(local, sdata, cmd, sta);
Johannes Berg24487982009-04-23 18:52:52 +0200405 if (local->ops->sta_notify)
Johannes Berg12375ef2009-11-25 20:30:31 +0100406 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200407 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200408}
409
Johannes Berg34e89502010-02-03 13:59:58 +0100410static inline int drv_sta_add(struct ieee80211_local *local,
411 struct ieee80211_sub_if_data *sdata,
412 struct ieee80211_sta *sta)
413{
414 int ret = 0;
415
416 might_sleep();
417
Felix Fietkaubc192f82011-11-23 21:09:49 +0700418 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100419 check_sdata_in_driver(sdata);
420
Johannes Berg4efc76b2010-06-10 10:56:20 +0200421 trace_drv_sta_add(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100422 if (local->ops->sta_add)
423 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100424
Johannes Berg4efc76b2010-06-10 10:56:20 +0200425 trace_drv_return_int(local, ret);
Johannes Berg34e89502010-02-03 13:59:58 +0100426
427 return ret;
428}
429
430static inline void drv_sta_remove(struct ieee80211_local *local,
431 struct ieee80211_sub_if_data *sdata,
432 struct ieee80211_sta *sta)
433{
434 might_sleep();
435
Felix Fietkaubc192f82011-11-23 21:09:49 +0700436 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100437 check_sdata_in_driver(sdata);
438
Johannes Berg4efc76b2010-06-10 10:56:20 +0200439 trace_drv_sta_remove(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100440 if (local->ops->sta_remove)
441 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100442
Johannes Berg4efc76b2010-06-10 10:56:20 +0200443 trace_drv_return_void(local);
Johannes Berg34e89502010-02-03 13:59:58 +0100444}
445
Johannes Bergf09603a2012-01-20 13:55:21 +0100446static inline __must_check
447int drv_sta_state(struct ieee80211_local *local,
448 struct ieee80211_sub_if_data *sdata,
449 struct sta_info *sta,
450 enum ieee80211_sta_state old_state,
451 enum ieee80211_sta_state new_state)
452{
453 int ret = 0;
454
455 might_sleep();
456
457 sdata = get_bss_sdata(sdata);
458 check_sdata_in_driver(sdata);
459
460 trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
Johannes Berga4ec45a2012-01-20 13:55:22 +0100461 if (local->ops->sta_state) {
Johannes Bergf09603a2012-01-20 13:55:21 +0100462 ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta,
463 old_state, new_state);
Johannes Berga4ec45a2012-01-20 13:55:22 +0100464 } else if (old_state == IEEE80211_STA_AUTH &&
465 new_state == IEEE80211_STA_ASSOC) {
466 ret = drv_sta_add(local, sdata, &sta->sta);
467 if (ret == 0)
468 sta->uploaded = true;
469 } else if (old_state == IEEE80211_STA_ASSOC &&
470 new_state == IEEE80211_STA_AUTH) {
471 drv_sta_remove(local, sdata, &sta->sta);
472 }
Johannes Bergf09603a2012-01-20 13:55:21 +0100473 trace_drv_return_int(local, ret);
474 return ret;
475}
476
Eliad Pellerf6f3def2011-09-25 20:06:54 +0300477static inline int drv_conf_tx(struct ieee80211_local *local,
478 struct ieee80211_sub_if_data *sdata, u16 queue,
Johannes Berg24487982009-04-23 18:52:52 +0200479 const struct ieee80211_tx_queue_params *params)
480{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200481 int ret = -EOPNOTSUPP;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100482
483 might_sleep();
484
Johannes Berg7b7eab62011-11-03 14:41:13 +0100485 check_sdata_in_driver(sdata);
486
Eliad Pellerf6f3def2011-09-25 20:06:54 +0300487 trace_drv_conf_tx(local, sdata, queue, params);
Johannes Berg24487982009-04-23 18:52:52 +0200488 if (local->ops->conf_tx)
Eliad Peller8a3a3c82011-10-02 10:15:52 +0200489 ret = local->ops->conf_tx(&local->hw, &sdata->vif,
490 queue, params);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200491 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200492 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200493}
494
Eliad Peller37a41b42011-09-21 14:06:11 +0300495static inline u64 drv_get_tsf(struct ieee80211_local *local,
496 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200497{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200498 u64 ret = -1ULL;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100499
500 might_sleep();
501
Johannes Berg7b7eab62011-11-03 14:41:13 +0100502 check_sdata_in_driver(sdata);
503
Eliad Peller37a41b42011-09-21 14:06:11 +0300504 trace_drv_get_tsf(local, sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200505 if (local->ops->get_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300506 ret = local->ops->get_tsf(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200507 trace_drv_return_u64(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200508 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200509}
510
Eliad Peller37a41b42011-09-21 14:06:11 +0300511static inline void drv_set_tsf(struct ieee80211_local *local,
512 struct ieee80211_sub_if_data *sdata,
513 u64 tsf)
Johannes Berg24487982009-04-23 18:52:52 +0200514{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100515 might_sleep();
516
Johannes Berg7b7eab62011-11-03 14:41:13 +0100517 check_sdata_in_driver(sdata);
518
Eliad Peller37a41b42011-09-21 14:06:11 +0300519 trace_drv_set_tsf(local, sdata, tsf);
Johannes Berg24487982009-04-23 18:52:52 +0200520 if (local->ops->set_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300521 local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200522 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200523}
524
Eliad Peller37a41b42011-09-21 14:06:11 +0300525static inline void drv_reset_tsf(struct ieee80211_local *local,
526 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200527{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100528 might_sleep();
529
Johannes Berg7b7eab62011-11-03 14:41:13 +0100530 check_sdata_in_driver(sdata);
531
Eliad Peller37a41b42011-09-21 14:06:11 +0300532 trace_drv_reset_tsf(local, sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200533 if (local->ops->reset_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300534 local->ops->reset_tsf(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200535 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200536}
537
538static inline int drv_tx_last_beacon(struct ieee80211_local *local)
539{
Tim Harvey91f44b02010-12-09 13:15:45 -0800540 int ret = 0; /* default unsuported op for less congestion */
Kalle Valoe1781ed2009-12-23 13:15:47 +0100541
542 might_sleep();
543
Johannes Berg4efc76b2010-06-10 10:56:20 +0200544 trace_drv_tx_last_beacon(local);
Johannes Berg24487982009-04-23 18:52:52 +0200545 if (local->ops->tx_last_beacon)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200546 ret = local->ops->tx_last_beacon(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200547 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200548 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200549}
550
551static inline int drv_ampdu_action(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100552 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200553 enum ieee80211_ampdu_mlme_action action,
554 struct ieee80211_sta *sta, u16 tid,
Johannes Berg0b01f032011-01-18 13:51:05 +0100555 u16 *ssn, u8 buf_size)
Johannes Berg24487982009-04-23 18:52:52 +0200556{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200557 int ret = -EOPNOTSUPP;
Johannes Bergcfcdbde2010-06-10 10:21:48 +0200558
559 might_sleep();
560
Felix Fietkaubc192f82011-11-23 21:09:49 +0700561 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100562 check_sdata_in_driver(sdata);
563
Johannes Berg0b01f032011-01-18 13:51:05 +0100564 trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200565
Johannes Berg24487982009-04-23 18:52:52 +0200566 if (local->ops->ampdu_action)
Johannes Berg12375ef2009-11-25 20:30:31 +0100567 ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
Johannes Berg0b01f032011-01-18 13:51:05 +0100568 sta, tid, ssn, buf_size);
Johannes Berg85ad1812010-06-10 10:21:49 +0200569
Johannes Berg4efc76b2010-06-10 10:56:20 +0200570 trace_drv_return_int(local, ret);
571
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200572 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200573}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200574
Holger Schurig12897232010-04-19 10:23:57 +0200575static inline int drv_get_survey(struct ieee80211_local *local, int idx,
576 struct survey_info *survey)
577{
578 int ret = -EOPNOTSUPP;
John W. Linvillec466d4e2010-06-29 14:51:23 -0400579
580 trace_drv_get_survey(local, idx, survey);
581
Holger Schurig35dd0502010-06-07 16:33:49 +0200582 if (local->ops->get_survey)
Holger Schurig12897232010-04-19 10:23:57 +0200583 ret = local->ops->get_survey(&local->hw, idx, survey);
John W. Linvillec466d4e2010-06-29 14:51:23 -0400584
585 trace_drv_return_int(local, ret);
586
Holger Schurig12897232010-04-19 10:23:57 +0200587 return ret;
588}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200589
590static inline void drv_rfkill_poll(struct ieee80211_local *local)
591{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100592 might_sleep();
593
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200594 if (local->ops->rfkill_poll)
595 local->ops->rfkill_poll(&local->hw);
596}
Johannes Berga80f7c02009-12-23 13:15:32 +0100597
598static inline void drv_flush(struct ieee80211_local *local, bool drop)
599{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100600 might_sleep();
601
Johannes Berga80f7c02009-12-23 13:15:32 +0100602 trace_drv_flush(local, drop);
603 if (local->ops->flush)
604 local->ops->flush(&local->hw, drop);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200605 trace_drv_return_void(local);
Johannes Berga80f7c02009-12-23 13:15:32 +0100606}
Johannes Berg5ce6e432010-05-11 16:20:57 +0200607
608static inline void drv_channel_switch(struct ieee80211_local *local,
609 struct ieee80211_channel_switch *ch_switch)
610{
611 might_sleep();
612
Johannes Berg5ce6e432010-05-11 16:20:57 +0200613 trace_drv_channel_switch(local, ch_switch);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200614 local->ops->channel_switch(&local->hw, ch_switch);
615 trace_drv_return_void(local);
Johannes Berg5ce6e432010-05-11 16:20:57 +0200616}
617
Bruno Randolf15d96752010-11-10 12:50:56 +0900618
619static inline int drv_set_antenna(struct ieee80211_local *local,
620 u32 tx_ant, u32 rx_ant)
621{
622 int ret = -EOPNOTSUPP;
623 might_sleep();
624 if (local->ops->set_antenna)
625 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
626 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
627 return ret;
628}
629
630static inline int drv_get_antenna(struct ieee80211_local *local,
631 u32 *tx_ant, u32 *rx_ant)
632{
633 int ret = -EOPNOTSUPP;
634 might_sleep();
635 if (local->ops->get_antenna)
636 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
637 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
638 return ret;
639}
640
Johannes Berg21f83582010-12-18 17:20:47 +0100641static inline int drv_remain_on_channel(struct ieee80211_local *local,
642 struct ieee80211_channel *chan,
643 enum nl80211_channel_type chantype,
644 unsigned int duration)
645{
646 int ret;
647
648 might_sleep();
649
650 trace_drv_remain_on_channel(local, chan, chantype, duration);
651 ret = local->ops->remain_on_channel(&local->hw, chan, chantype,
652 duration);
653 trace_drv_return_int(local, ret);
654
655 return ret;
656}
657
658static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
659{
660 int ret;
661
662 might_sleep();
663
664 trace_drv_cancel_remain_on_channel(local);
665 ret = local->ops->cancel_remain_on_channel(&local->hw);
666 trace_drv_return_int(local, ret);
667
668 return ret;
669}
670
John W. Linville38c09152011-03-07 16:19:18 -0500671static inline int drv_set_ringparam(struct ieee80211_local *local,
672 u32 tx, u32 rx)
673{
674 int ret = -ENOTSUPP;
675
676 might_sleep();
677
678 trace_drv_set_ringparam(local, tx, rx);
679 if (local->ops->set_ringparam)
680 ret = local->ops->set_ringparam(&local->hw, tx, rx);
681 trace_drv_return_int(local, ret);
682
683 return ret;
684}
685
686static inline void drv_get_ringparam(struct ieee80211_local *local,
687 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
688{
689 might_sleep();
690
691 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
692 if (local->ops->get_ringparam)
693 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
694 trace_drv_return_void(local);
695}
696
Vivek Natarajane8306f92011-04-06 11:41:10 +0530697static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
698{
699 bool ret = false;
700
701 might_sleep();
702
703 trace_drv_tx_frames_pending(local);
704 if (local->ops->tx_frames_pending)
705 ret = local->ops->tx_frames_pending(&local->hw);
706 trace_drv_return_bool(local, ret);
707
708 return ret;
709}
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530710
711static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
712 struct ieee80211_sub_if_data *sdata,
713 const struct cfg80211_bitrate_mask *mask)
714{
715 int ret = -EOPNOTSUPP;
716
717 might_sleep();
718
Johannes Berg7b7eab62011-11-03 14:41:13 +0100719 check_sdata_in_driver(sdata);
720
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530721 trace_drv_set_bitrate_mask(local, sdata, mask);
722 if (local->ops->set_bitrate_mask)
723 ret = local->ops->set_bitrate_mask(&local->hw,
724 &sdata->vif, mask);
725 trace_drv_return_int(local, ret);
726
727 return ret;
728}
729
Johannes Bergc68f4b82011-07-05 16:35:41 +0200730static inline void drv_set_rekey_data(struct ieee80211_local *local,
731 struct ieee80211_sub_if_data *sdata,
732 struct cfg80211_gtk_rekey_data *data)
733{
Johannes Berg7b7eab62011-11-03 14:41:13 +0100734 check_sdata_in_driver(sdata);
735
Johannes Bergc68f4b82011-07-05 16:35:41 +0200736 trace_drv_set_rekey_data(local, sdata, data);
737 if (local->ops->set_rekey_data)
738 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
739 trace_drv_return_void(local);
740}
741
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700742static inline void drv_rssi_callback(struct ieee80211_local *local,
743 const enum ieee80211_rssi_event event)
744{
745 trace_drv_rssi_callback(local, event);
746 if (local->ops->rssi_callback)
747 local->ops->rssi_callback(&local->hw, event);
748 trace_drv_return_void(local);
749}
Johannes Berg4049e092011-09-29 16:04:32 +0200750
751static inline void
752drv_release_buffered_frames(struct ieee80211_local *local,
753 struct sta_info *sta, u16 tids, int num_frames,
754 enum ieee80211_frame_release_type reason,
755 bool more_data)
756{
757 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
758 reason, more_data);
759 if (local->ops->release_buffered_frames)
760 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
761 num_frames, reason,
762 more_data);
763 trace_drv_return_void(local);
764}
Johannes Berg40b96402011-09-29 16:04:38 +0200765
766static inline void
767drv_allow_buffered_frames(struct ieee80211_local *local,
768 struct sta_info *sta, u16 tids, int num_frames,
769 enum ieee80211_frame_release_type reason,
770 bool more_data)
771{
772 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
773 reason, more_data);
774 if (local->ops->allow_buffered_frames)
775 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
776 tids, num_frames, reason,
777 more_data);
778 trace_drv_return_void(local);
779}
Johannes Berg24487982009-04-23 18:52:52 +0200780#endif /* __MAC80211_DRIVER_OPS */