blob: edd2dd79c9be36020870bcee014d09f9ee241e25 [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 Berg7bb45682011-02-24 14:42:06 +01008static inline void drv_tx(struct ieee80211_local *local, struct sk_buff *skb)
Johannes Berg24487982009-04-23 18:52:52 +02009{
Johannes Berg7bb45682011-02-24 14:42:06 +010010 local->ops->tx(&local->hw, skb);
Johannes Berg24487982009-04-23 18:52:52 +020011}
12
13static inline int drv_start(struct ieee80211_local *local)
14{
Johannes Bergea77f122009-08-21 14:44:45 +020015 int ret;
16
Kalle Valoe1781ed2009-12-23 13:15:47 +010017 might_sleep();
18
Johannes Berg4efc76b2010-06-10 10:56:20 +020019 trace_drv_start(local);
Johannes Bergea77f122009-08-21 14:44:45 +020020 local->started = true;
21 smp_mb();
22 ret = local->ops->start(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +020023 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +020024 return ret;
Johannes Berg24487982009-04-23 18:52:52 +020025}
26
27static inline void drv_stop(struct ieee80211_local *local)
28{
Kalle Valoe1781ed2009-12-23 13:15:47 +010029 might_sleep();
30
Johannes Berg0a2b8bb2009-07-07 13:46:22 +020031 trace_drv_stop(local);
Johannes Berg4efc76b2010-06-10 10:56:20 +020032 local->ops->stop(&local->hw);
33 trace_drv_return_void(local);
Johannes Bergea77f122009-08-21 14:44:45 +020034
35 /* sync away all work on the tasklet before clearing started */
36 tasklet_disable(&local->tasklet);
37 tasklet_enable(&local->tasklet);
38
39 barrier();
40
41 local->started = false;
Johannes Berg24487982009-04-23 18:52:52 +020042}
43
Johannes Bergeecc4802011-05-04 15:37:29 +020044#ifdef CONFIG_PM
45static inline int drv_suspend(struct ieee80211_local *local,
46 struct cfg80211_wowlan *wowlan)
47{
48 int ret;
49
50 might_sleep();
51
52 trace_drv_suspend(local);
53 ret = local->ops->suspend(&local->hw, wowlan);
54 trace_drv_return_int(local, ret);
55 return ret;
56}
57
58static inline int drv_resume(struct ieee80211_local *local)
59{
60 int ret;
61
62 might_sleep();
63
64 trace_drv_resume(local);
65 ret = local->ops->resume(&local->hw);
66 trace_drv_return_int(local, ret);
67 return ret;
68}
69#endif
70
Johannes Berg24487982009-04-23 18:52:52 +020071static inline int drv_add_interface(struct ieee80211_local *local,
Johannes Berg1ed32e42009-12-23 13:15:45 +010072 struct ieee80211_vif *vif)
Johannes Berg24487982009-04-23 18:52:52 +020073{
Kalle Valoe1781ed2009-12-23 13:15:47 +010074 int ret;
75
76 might_sleep();
77
Johannes Berg4efc76b2010-06-10 10:56:20 +020078 trace_drv_add_interface(local, vif_to_sdata(vif));
Kalle Valoe1781ed2009-12-23 13:15:47 +010079 ret = local->ops->add_interface(&local->hw, vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +020080 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +020081 return ret;
Johannes Berg24487982009-04-23 18:52:52 +020082}
83
Johannes Berg34d4bc42010-08-27 12:35:58 +020084static inline int drv_change_interface(struct ieee80211_local *local,
85 struct ieee80211_sub_if_data *sdata,
Johannes Berg2ca27bc2010-09-16 14:58:23 +020086 enum nl80211_iftype type, bool p2p)
Johannes Berg34d4bc42010-08-27 12:35:58 +020087{
88 int ret;
89
90 might_sleep();
91
Johannes Berg2ca27bc2010-09-16 14:58:23 +020092 trace_drv_change_interface(local, sdata, type, p2p);
93 ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
Johannes Berg34d4bc42010-08-27 12:35:58 +020094 trace_drv_return_int(local, ret);
95 return ret;
96}
97
Johannes Berg24487982009-04-23 18:52:52 +020098static inline void drv_remove_interface(struct ieee80211_local *local,
Johannes Berg1ed32e42009-12-23 13:15:45 +010099 struct ieee80211_vif *vif)
Johannes Berg24487982009-04-23 18:52:52 +0200100{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100101 might_sleep();
102
Johannes Berg1ed32e42009-12-23 13:15:45 +0100103 trace_drv_remove_interface(local, vif_to_sdata(vif));
Johannes Berg4efc76b2010-06-10 10:56:20 +0200104 local->ops->remove_interface(&local->hw, vif);
105 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200106}
107
108static inline int drv_config(struct ieee80211_local *local, u32 changed)
109{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100110 int ret;
111
112 might_sleep();
113
Johannes Berg4efc76b2010-06-10 10:56:20 +0200114 trace_drv_config(local, changed);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100115 ret = local->ops->config(&local->hw, changed);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200116 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200117 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200118}
119
120static inline void drv_bss_info_changed(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100121 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200122 struct ieee80211_bss_conf *info,
123 u32 changed)
124{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100125 might_sleep();
126
Johannes Berg4efc76b2010-06-10 10:56:20 +0200127 trace_drv_bss_info_changed(local, sdata, info, changed);
Johannes Berg24487982009-04-23 18:52:52 +0200128 if (local->ops->bss_info_changed)
Johannes Berg12375ef2009-11-25 20:30:31 +0100129 local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200130 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200131}
132
Johannes Berg3ac64be2009-08-17 16:16:53 +0200133static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
Jiri Pirko22bedad2010-04-01 21:22:57 +0000134 struct netdev_hw_addr_list *mc_list)
Johannes Berg24487982009-04-23 18:52:52 +0200135{
Johannes Berg3ac64be2009-08-17 16:16:53 +0200136 u64 ret = 0;
137
Johannes Berg4efc76b2010-06-10 10:56:20 +0200138 trace_drv_prepare_multicast(local, mc_list->count);
139
Johannes Berg3ac64be2009-08-17 16:16:53 +0200140 if (local->ops->prepare_multicast)
Jiri Pirko22bedad2010-04-01 21:22:57 +0000141 ret = local->ops->prepare_multicast(&local->hw, mc_list);
Johannes Berg3ac64be2009-08-17 16:16:53 +0200142
Johannes Berg4efc76b2010-06-10 10:56:20 +0200143 trace_drv_return_u64(local, ret);
Johannes Berg3ac64be2009-08-17 16:16:53 +0200144
145 return ret;
146}
147
148static inline void drv_configure_filter(struct ieee80211_local *local,
149 unsigned int changed_flags,
150 unsigned int *total_flags,
151 u64 multicast)
152{
153 might_sleep();
154
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200155 trace_drv_configure_filter(local, changed_flags, total_flags,
Johannes Berg3ac64be2009-08-17 16:16:53 +0200156 multicast);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200157 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
158 multicast);
159 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200160}
161
162static inline int drv_set_tim(struct ieee80211_local *local,
163 struct ieee80211_sta *sta, bool set)
164{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200165 int ret = 0;
Johannes Berg4efc76b2010-06-10 10:56:20 +0200166 trace_drv_set_tim(local, sta, set);
Johannes Berg24487982009-04-23 18:52:52 +0200167 if (local->ops->set_tim)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200168 ret = local->ops->set_tim(&local->hw, sta, set);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200169 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200170 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200171}
172
173static inline int drv_set_key(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100174 enum set_key_cmd cmd,
175 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200176 struct ieee80211_sta *sta,
177 struct ieee80211_key_conf *key)
178{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100179 int ret;
180
181 might_sleep();
182
Johannes Berg4efc76b2010-06-10 10:56:20 +0200183 trace_drv_set_key(local, cmd, sdata, sta, key);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100184 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200185 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200186 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200187}
188
189static inline void drv_update_tkip_key(struct ieee80211_local *local,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100190 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200191 struct ieee80211_key_conf *conf,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100192 struct sta_info *sta, u32 iv32,
Johannes Berg24487982009-04-23 18:52:52 +0200193 u16 *phase1key)
194{
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100195 struct ieee80211_sta *ista = NULL;
196
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100197 if (sta)
198 ista = &sta->sta;
199
Johannes Berg4efc76b2010-06-10 10:56:20 +0200200 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
Johannes Berg24487982009-04-23 18:52:52 +0200201 if (local->ops->update_tkip_key)
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100202 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
203 ista, iv32, phase1key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200204 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200205}
206
207static inline int drv_hw_scan(struct ieee80211_local *local,
Johannes Berga060bbf2010-04-27 11:59:34 +0200208 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200209 struct cfg80211_scan_request *req)
210{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100211 int ret;
212
213 might_sleep();
214
Luciano Coelho79f460c2011-05-11 17:09:36 +0300215 trace_drv_hw_scan(local, sdata);
Johannes Berga060bbf2010-04-27 11:59:34 +0200216 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200217 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200218 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200219}
220
Eliad Pellerb8564392011-06-13 12:47:30 +0300221static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
222 struct ieee80211_sub_if_data *sdata)
223{
224 might_sleep();
225
226 trace_drv_cancel_hw_scan(local, sdata);
227 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
228 trace_drv_return_void(local);
229}
230
Luciano Coelho79f460c2011-05-11 17:09:36 +0300231static inline int
232drv_sched_scan_start(struct ieee80211_local *local,
233 struct ieee80211_sub_if_data *sdata,
234 struct cfg80211_sched_scan_request *req,
235 struct ieee80211_sched_scan_ies *ies)
236{
237 int ret;
238
239 might_sleep();
240
241 trace_drv_sched_scan_start(local, sdata);
242 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
243 req, ies);
244 trace_drv_return_int(local, ret);
245 return ret;
246}
247
248static inline void drv_sched_scan_stop(struct ieee80211_local *local,
249 struct ieee80211_sub_if_data *sdata)
250{
251 might_sleep();
252
253 trace_drv_sched_scan_stop(local, sdata);
254 local->ops->sched_scan_stop(&local->hw, &sdata->vif);
255 trace_drv_return_void(local);
256}
257
Johannes Berg24487982009-04-23 18:52:52 +0200258static inline void drv_sw_scan_start(struct ieee80211_local *local)
259{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100260 might_sleep();
261
Johannes Berg4efc76b2010-06-10 10:56:20 +0200262 trace_drv_sw_scan_start(local);
Johannes Berg24487982009-04-23 18:52:52 +0200263 if (local->ops->sw_scan_start)
264 local->ops->sw_scan_start(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200265 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200266}
267
268static inline void drv_sw_scan_complete(struct ieee80211_local *local)
269{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100270 might_sleep();
271
Johannes Berg4efc76b2010-06-10 10:56:20 +0200272 trace_drv_sw_scan_complete(local);
Johannes Berg24487982009-04-23 18:52:52 +0200273 if (local->ops->sw_scan_complete)
274 local->ops->sw_scan_complete(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200275 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200276}
277
278static inline int drv_get_stats(struct ieee80211_local *local,
279 struct ieee80211_low_level_stats *stats)
280{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200281 int ret = -EOPNOTSUPP;
282
Kalle Valoe1781ed2009-12-23 13:15:47 +0100283 might_sleep();
284
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200285 if (local->ops->get_stats)
286 ret = local->ops->get_stats(&local->hw, stats);
287 trace_drv_get_stats(local, stats, ret);
288
289 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200290}
291
292static inline void drv_get_tkip_seq(struct ieee80211_local *local,
293 u8 hw_key_idx, u32 *iv32, u16 *iv16)
294{
295 if (local->ops->get_tkip_seq)
296 local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200297 trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
Johannes Berg24487982009-04-23 18:52:52 +0200298}
299
Arik Nemtsovf23a4782010-11-08 11:51:06 +0200300static inline int drv_set_frag_threshold(struct ieee80211_local *local,
301 u32 value)
302{
303 int ret = 0;
304
305 might_sleep();
306
307 trace_drv_set_frag_threshold(local, value);
308 if (local->ops->set_frag_threshold)
309 ret = local->ops->set_frag_threshold(&local->hw, value);
310 trace_drv_return_int(local, ret);
311 return ret;
312}
313
Johannes Berg24487982009-04-23 18:52:52 +0200314static inline int drv_set_rts_threshold(struct ieee80211_local *local,
315 u32 value)
316{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200317 int ret = 0;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100318
319 might_sleep();
320
Johannes Berg4efc76b2010-06-10 10:56:20 +0200321 trace_drv_set_rts_threshold(local, value);
Johannes Berg24487982009-04-23 18:52:52 +0200322 if (local->ops->set_rts_threshold)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200323 ret = local->ops->set_rts_threshold(&local->hw, value);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200324 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200325 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200326}
327
Lukáš Turek310bc672009-12-21 22:50:48 +0100328static inline int drv_set_coverage_class(struct ieee80211_local *local,
329 u8 value)
330{
331 int ret = 0;
332 might_sleep();
333
Johannes Berg4efc76b2010-06-10 10:56:20 +0200334 trace_drv_set_coverage_class(local, value);
Lukáš Turek310bc672009-12-21 22:50:48 +0100335 if (local->ops->set_coverage_class)
336 local->ops->set_coverage_class(&local->hw, value);
337 else
338 ret = -EOPNOTSUPP;
339
Johannes Berg4efc76b2010-06-10 10:56:20 +0200340 trace_drv_return_int(local, ret);
Lukáš Turek310bc672009-12-21 22:50:48 +0100341 return ret;
342}
343
Johannes Berg24487982009-04-23 18:52:52 +0200344static inline void drv_sta_notify(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100345 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200346 enum sta_notify_cmd cmd,
347 struct ieee80211_sta *sta)
348{
Johannes Berg4efc76b2010-06-10 10:56:20 +0200349 trace_drv_sta_notify(local, sdata, cmd, sta);
Johannes Berg24487982009-04-23 18:52:52 +0200350 if (local->ops->sta_notify)
Johannes Berg12375ef2009-11-25 20:30:31 +0100351 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200352 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200353}
354
Johannes Berg34e89502010-02-03 13:59:58 +0100355static inline int drv_sta_add(struct ieee80211_local *local,
356 struct ieee80211_sub_if_data *sdata,
357 struct ieee80211_sta *sta)
358{
359 int ret = 0;
360
361 might_sleep();
362
Johannes Berg4efc76b2010-06-10 10:56:20 +0200363 trace_drv_sta_add(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100364 if (local->ops->sta_add)
365 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100366
Johannes Berg4efc76b2010-06-10 10:56:20 +0200367 trace_drv_return_int(local, ret);
Johannes Berg34e89502010-02-03 13:59:58 +0100368
369 return ret;
370}
371
372static inline void drv_sta_remove(struct ieee80211_local *local,
373 struct ieee80211_sub_if_data *sdata,
374 struct ieee80211_sta *sta)
375{
376 might_sleep();
377
Johannes Berg4efc76b2010-06-10 10:56:20 +0200378 trace_drv_sta_remove(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100379 if (local->ops->sta_remove)
380 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100381
Johannes Berg4efc76b2010-06-10 10:56:20 +0200382 trace_drv_return_void(local);
Johannes Berg34e89502010-02-03 13:59:58 +0100383}
384
Johannes Berg24487982009-04-23 18:52:52 +0200385static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue,
386 const struct ieee80211_tx_queue_params *params)
387{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200388 int ret = -EOPNOTSUPP;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100389
390 might_sleep();
391
Johannes Berg4efc76b2010-06-10 10:56:20 +0200392 trace_drv_conf_tx(local, queue, params);
Johannes Berg24487982009-04-23 18:52:52 +0200393 if (local->ops->conf_tx)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200394 ret = local->ops->conf_tx(&local->hw, queue, params);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200395 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200396 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200397}
398
Johannes Berg24487982009-04-23 18:52:52 +0200399static inline u64 drv_get_tsf(struct ieee80211_local *local)
400{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200401 u64 ret = -1ULL;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100402
403 might_sleep();
404
Johannes Berg4efc76b2010-06-10 10:56:20 +0200405 trace_drv_get_tsf(local);
Johannes Berg24487982009-04-23 18:52:52 +0200406 if (local->ops->get_tsf)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200407 ret = local->ops->get_tsf(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200408 trace_drv_return_u64(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200409 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200410}
411
412static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf)
413{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100414 might_sleep();
415
Johannes Berg4efc76b2010-06-10 10:56:20 +0200416 trace_drv_set_tsf(local, tsf);
Johannes Berg24487982009-04-23 18:52:52 +0200417 if (local->ops->set_tsf)
418 local->ops->set_tsf(&local->hw, tsf);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200419 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200420}
421
422static inline void drv_reset_tsf(struct ieee80211_local *local)
423{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100424 might_sleep();
425
Johannes Berg4efc76b2010-06-10 10:56:20 +0200426 trace_drv_reset_tsf(local);
Johannes Berg24487982009-04-23 18:52:52 +0200427 if (local->ops->reset_tsf)
428 local->ops->reset_tsf(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200429 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200430}
431
432static inline int drv_tx_last_beacon(struct ieee80211_local *local)
433{
Tim Harvey91f44b02010-12-09 13:15:45 -0800434 int ret = 0; /* default unsuported op for less congestion */
Kalle Valoe1781ed2009-12-23 13:15:47 +0100435
436 might_sleep();
437
Johannes Berg4efc76b2010-06-10 10:56:20 +0200438 trace_drv_tx_last_beacon(local);
Johannes Berg24487982009-04-23 18:52:52 +0200439 if (local->ops->tx_last_beacon)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200440 ret = local->ops->tx_last_beacon(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200441 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200442 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200443}
444
445static inline int drv_ampdu_action(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100446 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200447 enum ieee80211_ampdu_mlme_action action,
448 struct ieee80211_sta *sta, u16 tid,
Johannes Berg0b01f032011-01-18 13:51:05 +0100449 u16 *ssn, u8 buf_size)
Johannes Berg24487982009-04-23 18:52:52 +0200450{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200451 int ret = -EOPNOTSUPP;
Johannes Bergcfcdbde2010-06-10 10:21:48 +0200452
453 might_sleep();
454
Johannes Berg0b01f032011-01-18 13:51:05 +0100455 trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200456
Johannes Berg24487982009-04-23 18:52:52 +0200457 if (local->ops->ampdu_action)
Johannes Berg12375ef2009-11-25 20:30:31 +0100458 ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
Johannes Berg0b01f032011-01-18 13:51:05 +0100459 sta, tid, ssn, buf_size);
Johannes Berg85ad1812010-06-10 10:21:49 +0200460
Johannes Berg4efc76b2010-06-10 10:56:20 +0200461 trace_drv_return_int(local, ret);
462
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200463 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200464}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200465
Holger Schurig12897232010-04-19 10:23:57 +0200466static inline int drv_get_survey(struct ieee80211_local *local, int idx,
467 struct survey_info *survey)
468{
469 int ret = -EOPNOTSUPP;
John W. Linvillec466d4e2010-06-29 14:51:23 -0400470
471 trace_drv_get_survey(local, idx, survey);
472
Holger Schurig35dd0502010-06-07 16:33:49 +0200473 if (local->ops->get_survey)
Holger Schurig12897232010-04-19 10:23:57 +0200474 ret = local->ops->get_survey(&local->hw, idx, survey);
John W. Linvillec466d4e2010-06-29 14:51:23 -0400475
476 trace_drv_return_int(local, ret);
477
Holger Schurig12897232010-04-19 10:23:57 +0200478 return ret;
479}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200480
481static inline void drv_rfkill_poll(struct ieee80211_local *local)
482{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100483 might_sleep();
484
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200485 if (local->ops->rfkill_poll)
486 local->ops->rfkill_poll(&local->hw);
487}
Johannes Berga80f7c02009-12-23 13:15:32 +0100488
489static inline void drv_flush(struct ieee80211_local *local, bool drop)
490{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100491 might_sleep();
492
Johannes Berga80f7c02009-12-23 13:15:32 +0100493 trace_drv_flush(local, drop);
494 if (local->ops->flush)
495 local->ops->flush(&local->hw, drop);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200496 trace_drv_return_void(local);
Johannes Berga80f7c02009-12-23 13:15:32 +0100497}
Johannes Berg5ce6e432010-05-11 16:20:57 +0200498
499static inline void drv_channel_switch(struct ieee80211_local *local,
500 struct ieee80211_channel_switch *ch_switch)
501{
502 might_sleep();
503
Johannes Berg5ce6e432010-05-11 16:20:57 +0200504 trace_drv_channel_switch(local, ch_switch);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200505 local->ops->channel_switch(&local->hw, ch_switch);
506 trace_drv_return_void(local);
Johannes Berg5ce6e432010-05-11 16:20:57 +0200507}
508
Bruno Randolf15d96752010-11-10 12:50:56 +0900509
510static inline int drv_set_antenna(struct ieee80211_local *local,
511 u32 tx_ant, u32 rx_ant)
512{
513 int ret = -EOPNOTSUPP;
514 might_sleep();
515 if (local->ops->set_antenna)
516 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
517 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
518 return ret;
519}
520
521static inline int drv_get_antenna(struct ieee80211_local *local,
522 u32 *tx_ant, u32 *rx_ant)
523{
524 int ret = -EOPNOTSUPP;
525 might_sleep();
526 if (local->ops->get_antenna)
527 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
528 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
529 return ret;
530}
531
Johannes Berg21f83582010-12-18 17:20:47 +0100532static inline int drv_remain_on_channel(struct ieee80211_local *local,
533 struct ieee80211_channel *chan,
534 enum nl80211_channel_type chantype,
535 unsigned int duration)
536{
537 int ret;
538
539 might_sleep();
540
541 trace_drv_remain_on_channel(local, chan, chantype, duration);
542 ret = local->ops->remain_on_channel(&local->hw, chan, chantype,
543 duration);
544 trace_drv_return_int(local, ret);
545
546 return ret;
547}
548
549static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
550{
551 int ret;
552
553 might_sleep();
554
555 trace_drv_cancel_remain_on_channel(local);
556 ret = local->ops->cancel_remain_on_channel(&local->hw);
557 trace_drv_return_int(local, ret);
558
559 return ret;
560}
561
Johannes Berg5f16a432011-02-25 15:36:57 +0100562static inline int drv_offchannel_tx(struct ieee80211_local *local,
563 struct sk_buff *skb,
564 struct ieee80211_channel *chan,
565 enum nl80211_channel_type channel_type,
566 unsigned int wait)
567{
568 int ret;
569
570 might_sleep();
571
572 trace_drv_offchannel_tx(local, skb, chan, channel_type, wait);
573 ret = local->ops->offchannel_tx(&local->hw, skb, chan,
574 channel_type, wait);
575 trace_drv_return_int(local, ret);
576
577 return ret;
578}
579
580static inline int drv_offchannel_tx_cancel_wait(struct ieee80211_local *local)
581{
582 int ret;
583
584 might_sleep();
585
586 trace_drv_offchannel_tx_cancel_wait(local);
587 ret = local->ops->offchannel_tx_cancel_wait(&local->hw);
588 trace_drv_return_int(local, ret);
589
590 return ret;
591}
592
John W. Linville38c09152011-03-07 16:19:18 -0500593static inline int drv_set_ringparam(struct ieee80211_local *local,
594 u32 tx, u32 rx)
595{
596 int ret = -ENOTSUPP;
597
598 might_sleep();
599
600 trace_drv_set_ringparam(local, tx, rx);
601 if (local->ops->set_ringparam)
602 ret = local->ops->set_ringparam(&local->hw, tx, rx);
603 trace_drv_return_int(local, ret);
604
605 return ret;
606}
607
608static inline void drv_get_ringparam(struct ieee80211_local *local,
609 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
610{
611 might_sleep();
612
613 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
614 if (local->ops->get_ringparam)
615 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
616 trace_drv_return_void(local);
617}
618
Vivek Natarajane8306f92011-04-06 11:41:10 +0530619static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
620{
621 bool ret = false;
622
623 might_sleep();
624
625 trace_drv_tx_frames_pending(local);
626 if (local->ops->tx_frames_pending)
627 ret = local->ops->tx_frames_pending(&local->hw);
628 trace_drv_return_bool(local, ret);
629
630 return ret;
631}
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530632
633static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
634 struct ieee80211_sub_if_data *sdata,
635 const struct cfg80211_bitrate_mask *mask)
636{
637 int ret = -EOPNOTSUPP;
638
639 might_sleep();
640
641 trace_drv_set_bitrate_mask(local, sdata, mask);
642 if (local->ops->set_bitrate_mask)
643 ret = local->ops->set_bitrate_mask(&local->hw,
644 &sdata->vif, mask);
645 trace_drv_return_int(local, ret);
646
647 return ret;
648}
649
Johannes Bergc68f4b82011-07-05 16:35:41 +0200650static inline void drv_set_rekey_data(struct ieee80211_local *local,
651 struct ieee80211_sub_if_data *sdata,
652 struct cfg80211_gtk_rekey_data *data)
653{
654 trace_drv_set_rekey_data(local, sdata, data);
655 if (local->ops->set_rekey_data)
656 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
657 trace_drv_return_void(local);
658}
659
Johannes Berg24487982009-04-23 18:52:52 +0200660#endif /* __MAC80211_DRIVER_OPS */