blob: eebf7a67daf73122ea7cf455e48abb8d8196c3be [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 Pirko22bedad32010-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 Pirko22bedad32010-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
Luciano Coelho79f460c2011-05-11 17:09:36 +0300221static inline int
222drv_sched_scan_start(struct ieee80211_local *local,
223 struct ieee80211_sub_if_data *sdata,
224 struct cfg80211_sched_scan_request *req,
225 struct ieee80211_sched_scan_ies *ies)
226{
227 int ret;
228
229 might_sleep();
230
231 trace_drv_sched_scan_start(local, sdata);
232 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
233 req, ies);
234 trace_drv_return_int(local, ret);
235 return ret;
236}
237
238static inline void drv_sched_scan_stop(struct ieee80211_local *local,
239 struct ieee80211_sub_if_data *sdata)
240{
241 might_sleep();
242
243 trace_drv_sched_scan_stop(local, sdata);
244 local->ops->sched_scan_stop(&local->hw, &sdata->vif);
245 trace_drv_return_void(local);
246}
247
Johannes Berg24487982009-04-23 18:52:52 +0200248static inline void drv_sw_scan_start(struct ieee80211_local *local)
249{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100250 might_sleep();
251
Johannes Berg4efc76b2010-06-10 10:56:20 +0200252 trace_drv_sw_scan_start(local);
Johannes Berg24487982009-04-23 18:52:52 +0200253 if (local->ops->sw_scan_start)
254 local->ops->sw_scan_start(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200255 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200256}
257
258static inline void drv_sw_scan_complete(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_complete(local);
Johannes Berg24487982009-04-23 18:52:52 +0200263 if (local->ops->sw_scan_complete)
264 local->ops->sw_scan_complete(&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 int drv_get_stats(struct ieee80211_local *local,
269 struct ieee80211_low_level_stats *stats)
270{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200271 int ret = -EOPNOTSUPP;
272
Kalle Valoe1781ed2009-12-23 13:15:47 +0100273 might_sleep();
274
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200275 if (local->ops->get_stats)
276 ret = local->ops->get_stats(&local->hw, stats);
277 trace_drv_get_stats(local, stats, ret);
278
279 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200280}
281
282static inline void drv_get_tkip_seq(struct ieee80211_local *local,
283 u8 hw_key_idx, u32 *iv32, u16 *iv16)
284{
285 if (local->ops->get_tkip_seq)
286 local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200287 trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
Johannes Berg24487982009-04-23 18:52:52 +0200288}
289
Arik Nemtsovf23a4782010-11-08 11:51:06 +0200290static inline int drv_set_frag_threshold(struct ieee80211_local *local,
291 u32 value)
292{
293 int ret = 0;
294
295 might_sleep();
296
297 trace_drv_set_frag_threshold(local, value);
298 if (local->ops->set_frag_threshold)
299 ret = local->ops->set_frag_threshold(&local->hw, value);
300 trace_drv_return_int(local, ret);
301 return ret;
302}
303
Johannes Berg24487982009-04-23 18:52:52 +0200304static inline int drv_set_rts_threshold(struct ieee80211_local *local,
305 u32 value)
306{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200307 int ret = 0;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100308
309 might_sleep();
310
Johannes Berg4efc76b2010-06-10 10:56:20 +0200311 trace_drv_set_rts_threshold(local, value);
Johannes Berg24487982009-04-23 18:52:52 +0200312 if (local->ops->set_rts_threshold)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200313 ret = local->ops->set_rts_threshold(&local->hw, value);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200314 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200315 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200316}
317
Lukáš Turek310bc672009-12-21 22:50:48 +0100318static inline int drv_set_coverage_class(struct ieee80211_local *local,
319 u8 value)
320{
321 int ret = 0;
322 might_sleep();
323
Johannes Berg4efc76b2010-06-10 10:56:20 +0200324 trace_drv_set_coverage_class(local, value);
Lukáš Turek310bc672009-12-21 22:50:48 +0100325 if (local->ops->set_coverage_class)
326 local->ops->set_coverage_class(&local->hw, value);
327 else
328 ret = -EOPNOTSUPP;
329
Johannes Berg4efc76b2010-06-10 10:56:20 +0200330 trace_drv_return_int(local, ret);
Lukáš Turek310bc672009-12-21 22:50:48 +0100331 return ret;
332}
333
Johannes Berg24487982009-04-23 18:52:52 +0200334static inline void drv_sta_notify(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100335 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200336 enum sta_notify_cmd cmd,
337 struct ieee80211_sta *sta)
338{
Johannes Berg4efc76b2010-06-10 10:56:20 +0200339 trace_drv_sta_notify(local, sdata, cmd, sta);
Johannes Berg24487982009-04-23 18:52:52 +0200340 if (local->ops->sta_notify)
Johannes Berg12375ef2009-11-25 20:30:31 +0100341 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200342 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200343}
344
Johannes Berg34e89502010-02-03 13:59:58 +0100345static inline int drv_sta_add(struct ieee80211_local *local,
346 struct ieee80211_sub_if_data *sdata,
347 struct ieee80211_sta *sta)
348{
349 int ret = 0;
350
351 might_sleep();
352
Johannes Berg4efc76b2010-06-10 10:56:20 +0200353 trace_drv_sta_add(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100354 if (local->ops->sta_add)
355 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100356
Johannes Berg4efc76b2010-06-10 10:56:20 +0200357 trace_drv_return_int(local, ret);
Johannes Berg34e89502010-02-03 13:59:58 +0100358
359 return ret;
360}
361
362static inline void drv_sta_remove(struct ieee80211_local *local,
363 struct ieee80211_sub_if_data *sdata,
364 struct ieee80211_sta *sta)
365{
366 might_sleep();
367
Johannes Berg4efc76b2010-06-10 10:56:20 +0200368 trace_drv_sta_remove(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100369 if (local->ops->sta_remove)
370 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100371
Johannes Berg4efc76b2010-06-10 10:56:20 +0200372 trace_drv_return_void(local);
Johannes Berg34e89502010-02-03 13:59:58 +0100373}
374
Johannes Berg24487982009-04-23 18:52:52 +0200375static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue,
376 const struct ieee80211_tx_queue_params *params)
377{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200378 int ret = -EOPNOTSUPP;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100379
380 might_sleep();
381
Johannes Berg4efc76b2010-06-10 10:56:20 +0200382 trace_drv_conf_tx(local, queue, params);
Johannes Berg24487982009-04-23 18:52:52 +0200383 if (local->ops->conf_tx)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200384 ret = local->ops->conf_tx(&local->hw, queue, params);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200385 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200386 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200387}
388
Johannes Berg24487982009-04-23 18:52:52 +0200389static inline u64 drv_get_tsf(struct ieee80211_local *local)
390{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200391 u64 ret = -1ULL;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100392
393 might_sleep();
394
Johannes Berg4efc76b2010-06-10 10:56:20 +0200395 trace_drv_get_tsf(local);
Johannes Berg24487982009-04-23 18:52:52 +0200396 if (local->ops->get_tsf)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200397 ret = local->ops->get_tsf(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200398 trace_drv_return_u64(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200399 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200400}
401
402static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf)
403{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100404 might_sleep();
405
Johannes Berg4efc76b2010-06-10 10:56:20 +0200406 trace_drv_set_tsf(local, tsf);
Johannes Berg24487982009-04-23 18:52:52 +0200407 if (local->ops->set_tsf)
408 local->ops->set_tsf(&local->hw, tsf);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200409 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200410}
411
412static inline void drv_reset_tsf(struct ieee80211_local *local)
413{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100414 might_sleep();
415
Johannes Berg4efc76b2010-06-10 10:56:20 +0200416 trace_drv_reset_tsf(local);
Johannes Berg24487982009-04-23 18:52:52 +0200417 if (local->ops->reset_tsf)
418 local->ops->reset_tsf(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200419 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200420}
421
422static inline int drv_tx_last_beacon(struct ieee80211_local *local)
423{
Tim Harvey91f44b02010-12-09 13:15:45 -0800424 int ret = 0; /* default unsuported op for less congestion */
Kalle Valoe1781ed2009-12-23 13:15:47 +0100425
426 might_sleep();
427
Johannes Berg4efc76b2010-06-10 10:56:20 +0200428 trace_drv_tx_last_beacon(local);
Johannes Berg24487982009-04-23 18:52:52 +0200429 if (local->ops->tx_last_beacon)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200430 ret = local->ops->tx_last_beacon(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200431 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200432 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200433}
434
435static inline int drv_ampdu_action(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100436 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200437 enum ieee80211_ampdu_mlme_action action,
438 struct ieee80211_sta *sta, u16 tid,
Johannes Berg0b01f032011-01-18 13:51:05 +0100439 u16 *ssn, u8 buf_size)
Johannes Berg24487982009-04-23 18:52:52 +0200440{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200441 int ret = -EOPNOTSUPP;
Johannes Bergcfcdbde2010-06-10 10:21:48 +0200442
443 might_sleep();
444
Johannes Berg0b01f032011-01-18 13:51:05 +0100445 trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200446
Johannes Berg24487982009-04-23 18:52:52 +0200447 if (local->ops->ampdu_action)
Johannes Berg12375ef2009-11-25 20:30:31 +0100448 ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
Johannes Berg0b01f032011-01-18 13:51:05 +0100449 sta, tid, ssn, buf_size);
Johannes Berg85ad1812010-06-10 10:21:49 +0200450
Johannes Berg4efc76b2010-06-10 10:56:20 +0200451 trace_drv_return_int(local, ret);
452
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200453 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200454}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200455
Holger Schurig12897232010-04-19 10:23:57 +0200456static inline int drv_get_survey(struct ieee80211_local *local, int idx,
457 struct survey_info *survey)
458{
459 int ret = -EOPNOTSUPP;
John W. Linvillec466d4e2010-06-29 14:51:23 -0400460
461 trace_drv_get_survey(local, idx, survey);
462
Holger Schurig35dd0502010-06-07 16:33:49 +0200463 if (local->ops->get_survey)
Holger Schurig12897232010-04-19 10:23:57 +0200464 ret = local->ops->get_survey(&local->hw, idx, survey);
John W. Linvillec466d4e2010-06-29 14:51:23 -0400465
466 trace_drv_return_int(local, ret);
467
Holger Schurig12897232010-04-19 10:23:57 +0200468 return ret;
469}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200470
471static inline void drv_rfkill_poll(struct ieee80211_local *local)
472{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100473 might_sleep();
474
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200475 if (local->ops->rfkill_poll)
476 local->ops->rfkill_poll(&local->hw);
477}
Johannes Berga80f7c02009-12-23 13:15:32 +0100478
479static inline void drv_flush(struct ieee80211_local *local, bool drop)
480{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100481 might_sleep();
482
Johannes Berga80f7c02009-12-23 13:15:32 +0100483 trace_drv_flush(local, drop);
484 if (local->ops->flush)
485 local->ops->flush(&local->hw, drop);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200486 trace_drv_return_void(local);
Johannes Berga80f7c02009-12-23 13:15:32 +0100487}
Johannes Berg5ce6e432010-05-11 16:20:57 +0200488
489static inline void drv_channel_switch(struct ieee80211_local *local,
490 struct ieee80211_channel_switch *ch_switch)
491{
492 might_sleep();
493
Johannes Berg5ce6e432010-05-11 16:20:57 +0200494 trace_drv_channel_switch(local, ch_switch);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200495 local->ops->channel_switch(&local->hw, ch_switch);
496 trace_drv_return_void(local);
Johannes Berg5ce6e432010-05-11 16:20:57 +0200497}
498
Bruno Randolf15d96752010-11-10 12:50:56 +0900499
500static inline int drv_set_antenna(struct ieee80211_local *local,
501 u32 tx_ant, u32 rx_ant)
502{
503 int ret = -EOPNOTSUPP;
504 might_sleep();
505 if (local->ops->set_antenna)
506 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
507 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
508 return ret;
509}
510
511static inline int drv_get_antenna(struct ieee80211_local *local,
512 u32 *tx_ant, u32 *rx_ant)
513{
514 int ret = -EOPNOTSUPP;
515 might_sleep();
516 if (local->ops->get_antenna)
517 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
518 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
519 return ret;
520}
521
Johannes Berg21f83582010-12-18 17:20:47 +0100522static inline int drv_remain_on_channel(struct ieee80211_local *local,
523 struct ieee80211_channel *chan,
524 enum nl80211_channel_type chantype,
525 unsigned int duration)
526{
527 int ret;
528
529 might_sleep();
530
531 trace_drv_remain_on_channel(local, chan, chantype, duration);
532 ret = local->ops->remain_on_channel(&local->hw, chan, chantype,
533 duration);
534 trace_drv_return_int(local, ret);
535
536 return ret;
537}
538
539static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
540{
541 int ret;
542
543 might_sleep();
544
545 trace_drv_cancel_remain_on_channel(local);
546 ret = local->ops->cancel_remain_on_channel(&local->hw);
547 trace_drv_return_int(local, ret);
548
549 return ret;
550}
551
Johannes Berg5f16a432011-02-25 15:36:57 +0100552static inline int drv_offchannel_tx(struct ieee80211_local *local,
553 struct sk_buff *skb,
554 struct ieee80211_channel *chan,
555 enum nl80211_channel_type channel_type,
556 unsigned int wait)
557{
558 int ret;
559
560 might_sleep();
561
562 trace_drv_offchannel_tx(local, skb, chan, channel_type, wait);
563 ret = local->ops->offchannel_tx(&local->hw, skb, chan,
564 channel_type, wait);
565 trace_drv_return_int(local, ret);
566
567 return ret;
568}
569
570static inline int drv_offchannel_tx_cancel_wait(struct ieee80211_local *local)
571{
572 int ret;
573
574 might_sleep();
575
576 trace_drv_offchannel_tx_cancel_wait(local);
577 ret = local->ops->offchannel_tx_cancel_wait(&local->hw);
578 trace_drv_return_int(local, ret);
579
580 return ret;
581}
582
John W. Linville38c09152011-03-07 16:19:18 -0500583static inline int drv_set_ringparam(struct ieee80211_local *local,
584 u32 tx, u32 rx)
585{
586 int ret = -ENOTSUPP;
587
588 might_sleep();
589
590 trace_drv_set_ringparam(local, tx, rx);
591 if (local->ops->set_ringparam)
592 ret = local->ops->set_ringparam(&local->hw, tx, rx);
593 trace_drv_return_int(local, ret);
594
595 return ret;
596}
597
598static inline void drv_get_ringparam(struct ieee80211_local *local,
599 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
600{
601 might_sleep();
602
603 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
604 if (local->ops->get_ringparam)
605 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
606 trace_drv_return_void(local);
607}
608
Vivek Natarajane8306f92011-04-06 11:41:10 +0530609static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
610{
611 bool ret = false;
612
613 might_sleep();
614
615 trace_drv_tx_frames_pending(local);
616 if (local->ops->tx_frames_pending)
617 ret = local->ops->tx_frames_pending(&local->hw);
618 trace_drv_return_bool(local, ret);
619
620 return ret;
621}
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530622
623static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
624 struct ieee80211_sub_if_data *sdata,
625 const struct cfg80211_bitrate_mask *mask)
626{
627 int ret = -EOPNOTSUPP;
628
629 might_sleep();
630
631 trace_drv_set_bitrate_mask(local, sdata, mask);
632 if (local->ops->set_bitrate_mask)
633 ret = local->ops->set_bitrate_mask(&local->hw,
634 &sdata->vif, mask);
635 trace_drv_return_int(local, ret);
636
637 return ret;
638}
639
Johannes Berg24487982009-04-23 18:52:52 +0200640#endif /* __MAC80211_DRIVER_OPS */