blob: 169664c122e23cbe80f89016714bdcdfec24dc6e [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 Berg011ad0e2012-06-22 12:55:52 +02006#include "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{
Ben Greeard17087e2012-03-15 16:22:05 -070010 WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER),
11 "%s: Failed check-sdata-in-driver check, flags: 0x%x\n",
Johannes Bergf142c6b2012-06-18 20:07:15 +020012 sdata->dev ? sdata->dev->name : sdata->name, sdata->flags);
Johannes Berg7b7eab62011-11-03 14:41:13 +010013}
14
Felix Fietkaubc192f82011-11-23 21:09:49 +070015static inline struct ieee80211_sub_if_data *
16get_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 Huehn36323f82012-07-23 21:33:42 +020025static inline void drv_tx(struct ieee80211_local *local,
26 struct ieee80211_tx_control *control,
27 struct sk_buff *skb)
Johannes Berg24487982009-04-23 18:52:52 +020028{
Thomas Huehn36323f82012-07-23 21:33:42 +020029 local->ops->tx(&local->hw, control, skb);
Johannes Berg24487982009-04-23 18:52:52 +020030}
31
Ben Greeare3521142012-04-23 12:50:31 -070032static 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
43static 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
55static 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 Berg24487982009-04-23 18:52:52 +020069static inline int drv_start(struct ieee80211_local *local)
70{
Johannes Bergea77f122009-08-21 14:44:45 +020071 int ret;
72
Kalle Valoe1781ed2009-12-23 13:15:47 +010073 might_sleep();
74
Johannes Berg4efc76b2010-06-10 10:56:20 +020075 trace_drv_start(local);
Johannes Bergea77f122009-08-21 14:44:45 +020076 local->started = true;
77 smp_mb();
78 ret = local->ops->start(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +020079 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +020080 return ret;
Johannes Berg24487982009-04-23 18:52:52 +020081}
82
83static inline void drv_stop(struct ieee80211_local *local)
84{
Kalle Valoe1781ed2009-12-23 13:15:47 +010085 might_sleep();
86
Johannes Berg0a2b8bb2009-07-07 13:46:22 +020087 trace_drv_stop(local);
Johannes Berg4efc76b2010-06-10 10:56:20 +020088 local->ops->stop(&local->hw);
89 trace_drv_return_void(local);
Johannes Bergea77f122009-08-21 14:44:45 +020090
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 Berg24487982009-04-23 18:52:52 +020098}
99
Johannes Bergeecc4802011-05-04 15:37:29 +0200100#ifdef CONFIG_PM
101static 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
114static 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 Berg6d525632012-04-04 15:05:25 +0200125
126static 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 Bergeecc4802011-05-04 15:37:29 +0200138#endif
139
Johannes Berg24487982009-04-23 18:52:52 +0200140static inline int drv_add_interface(struct ieee80211_local *local,
Johannes Berg7b7eab62011-11-03 14:41:13 +0100141 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200142{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100143 int ret;
144
145 might_sleep();
146
Johannes Berg7b7eab62011-11-03 14:41:13 +0100147 if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
Johannes Berg4b6f1dd2012-04-03 14:35:57 +0200148 (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
149 !(local->hw.flags & IEEE80211_HW_WANT_MONITOR_VIF))))
Johannes Berg7b7eab62011-11-03 14:41:13 +0100150 return -EINVAL;
151
152 trace_drv_add_interface(local, sdata);
153 ret = local->ops->add_interface(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200154 trace_drv_return_int(local, ret);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100155
156 if (ret == 0)
157 sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
158
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200159 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200160}
161
Johannes Berg34d4bc42010-08-27 12:35:58 +0200162static inline int drv_change_interface(struct ieee80211_local *local,
163 struct ieee80211_sub_if_data *sdata,
Johannes Berg2ca27bc2010-09-16 14:58:23 +0200164 enum nl80211_iftype type, bool p2p)
Johannes Berg34d4bc42010-08-27 12:35:58 +0200165{
166 int ret;
167
168 might_sleep();
169
Johannes Berg7b7eab62011-11-03 14:41:13 +0100170 check_sdata_in_driver(sdata);
171
Johannes Berg2ca27bc2010-09-16 14:58:23 +0200172 trace_drv_change_interface(local, sdata, type, p2p);
173 ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
Johannes Berg34d4bc42010-08-27 12:35:58 +0200174 trace_drv_return_int(local, ret);
175 return ret;
176}
177
Johannes Berg24487982009-04-23 18:52:52 +0200178static inline void drv_remove_interface(struct ieee80211_local *local,
Johannes Berg7b7eab62011-11-03 14:41:13 +0100179 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200180{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100181 might_sleep();
182
Johannes Berg7b7eab62011-11-03 14:41:13 +0100183 check_sdata_in_driver(sdata);
184
185 trace_drv_remove_interface(local, sdata);
186 local->ops->remove_interface(&local->hw, &sdata->vif);
187 sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER;
Johannes Berg4efc76b2010-06-10 10:56:20 +0200188 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200189}
190
191static inline int drv_config(struct ieee80211_local *local, u32 changed)
192{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100193 int ret;
194
195 might_sleep();
196
Johannes Berg4efc76b2010-06-10 10:56:20 +0200197 trace_drv_config(local, changed);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100198 ret = local->ops->config(&local->hw, changed);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200199 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200200 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200201}
202
203static inline void drv_bss_info_changed(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100204 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200205 struct ieee80211_bss_conf *info,
206 u32 changed)
207{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100208 might_sleep();
209
Johannes Berg5bbe754d2013-02-13 13:50:51 +0100210 if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
211 BSS_CHANGED_BEACON_ENABLED) &&
212 sdata->vif.type != NL80211_IFTYPE_AP &&
213 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
214 sdata->vif.type != NL80211_IFTYPE_MESH_POINT))
215 return;
216
217 if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
218 sdata->vif.type == NL80211_IFTYPE_MONITOR))
219 return;
Johannes Bergb8dc1a32012-12-14 14:22:10 +0100220
Johannes Berg7b7eab62011-11-03 14:41:13 +0100221 check_sdata_in_driver(sdata);
222
Johannes Berg4efc76b2010-06-10 10:56:20 +0200223 trace_drv_bss_info_changed(local, sdata, info, changed);
Johannes Berg24487982009-04-23 18:52:52 +0200224 if (local->ops->bss_info_changed)
Johannes Berg12375ef2009-11-25 20:30:31 +0100225 local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200226 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200227}
228
Johannes Berg3ac64be2009-08-17 16:16:53 +0200229static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
Jiri Pirko22bedad32010-04-01 21:22:57 +0000230 struct netdev_hw_addr_list *mc_list)
Johannes Berg24487982009-04-23 18:52:52 +0200231{
Johannes Berg3ac64be2009-08-17 16:16:53 +0200232 u64 ret = 0;
233
Johannes Berg4efc76b2010-06-10 10:56:20 +0200234 trace_drv_prepare_multicast(local, mc_list->count);
235
Johannes Berg3ac64be2009-08-17 16:16:53 +0200236 if (local->ops->prepare_multicast)
Jiri Pirko22bedad32010-04-01 21:22:57 +0000237 ret = local->ops->prepare_multicast(&local->hw, mc_list);
Johannes Berg3ac64be2009-08-17 16:16:53 +0200238
Johannes Berg4efc76b2010-06-10 10:56:20 +0200239 trace_drv_return_u64(local, ret);
Johannes Berg3ac64be2009-08-17 16:16:53 +0200240
241 return ret;
242}
243
Alexander Bondar488b3662013-02-11 14:56:29 +0200244static inline void drv_set_multicast_list(struct ieee80211_local *local,
245 struct ieee80211_sub_if_data *sdata,
246 struct netdev_hw_addr_list *mc_list)
247{
248 bool allmulti = sdata->flags & IEEE80211_SDATA_ALLMULTI;
249
250 trace_drv_set_multicast_list(local, sdata, mc_list->count);
251
252 check_sdata_in_driver(sdata);
253
254 if (local->ops->set_multicast_list)
255 local->ops->set_multicast_list(&local->hw, &sdata->vif,
256 allmulti, mc_list);
257 trace_drv_return_void(local);
258}
259
Johannes Berg3ac64be2009-08-17 16:16:53 +0200260static inline void drv_configure_filter(struct ieee80211_local *local,
261 unsigned int changed_flags,
262 unsigned int *total_flags,
263 u64 multicast)
264{
265 might_sleep();
266
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200267 trace_drv_configure_filter(local, changed_flags, total_flags,
Johannes Berg3ac64be2009-08-17 16:16:53 +0200268 multicast);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200269 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
270 multicast);
271 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200272}
273
274static inline int drv_set_tim(struct ieee80211_local *local,
275 struct ieee80211_sta *sta, bool set)
276{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200277 int ret = 0;
Johannes Berg4efc76b2010-06-10 10:56:20 +0200278 trace_drv_set_tim(local, sta, set);
Johannes Berg24487982009-04-23 18:52:52 +0200279 if (local->ops->set_tim)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200280 ret = local->ops->set_tim(&local->hw, sta, set);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200281 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200282 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200283}
284
285static inline int drv_set_key(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100286 enum set_key_cmd cmd,
287 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200288 struct ieee80211_sta *sta,
289 struct ieee80211_key_conf *key)
290{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100291 int ret;
292
293 might_sleep();
294
Johannes Berg077f4932012-01-20 13:55:18 +0100295 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100296 check_sdata_in_driver(sdata);
297
Johannes Berg4efc76b2010-06-10 10:56:20 +0200298 trace_drv_set_key(local, cmd, sdata, sta, key);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100299 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200300 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200301 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200302}
303
304static inline void drv_update_tkip_key(struct ieee80211_local *local,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100305 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200306 struct ieee80211_key_conf *conf,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100307 struct sta_info *sta, u32 iv32,
Johannes Berg24487982009-04-23 18:52:52 +0200308 u16 *phase1key)
309{
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100310 struct ieee80211_sta *ista = NULL;
311
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100312 if (sta)
313 ista = &sta->sta;
314
Johannes Berg077f4932012-01-20 13:55:18 +0100315 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100316 check_sdata_in_driver(sdata);
317
Johannes Berg4efc76b2010-06-10 10:56:20 +0200318 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
Johannes Berg24487982009-04-23 18:52:52 +0200319 if (local->ops->update_tkip_key)
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100320 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
321 ista, iv32, phase1key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200322 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200323}
324
325static inline int drv_hw_scan(struct ieee80211_local *local,
Johannes Berga060bbf2010-04-27 11:59:34 +0200326 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200327 struct cfg80211_scan_request *req)
328{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100329 int ret;
330
331 might_sleep();
332
Johannes Berg7b7eab62011-11-03 14:41:13 +0100333 check_sdata_in_driver(sdata);
334
Luciano Coelho79f460c2011-05-11 17:09:36 +0300335 trace_drv_hw_scan(local, sdata);
Johannes Berga060bbf2010-04-27 11:59:34 +0200336 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200337 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200338 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200339}
340
Eliad Pellerb8564392011-06-13 12:47:30 +0300341static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
342 struct ieee80211_sub_if_data *sdata)
343{
344 might_sleep();
345
Johannes Berg7b7eab62011-11-03 14:41:13 +0100346 check_sdata_in_driver(sdata);
347
Eliad Pellerb8564392011-06-13 12:47:30 +0300348 trace_drv_cancel_hw_scan(local, sdata);
349 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
350 trace_drv_return_void(local);
351}
352
Luciano Coelho79f460c2011-05-11 17:09:36 +0300353static inline int
354drv_sched_scan_start(struct ieee80211_local *local,
355 struct ieee80211_sub_if_data *sdata,
356 struct cfg80211_sched_scan_request *req,
357 struct ieee80211_sched_scan_ies *ies)
358{
359 int ret;
360
361 might_sleep();
362
Johannes Berg7b7eab62011-11-03 14:41:13 +0100363 check_sdata_in_driver(sdata);
364
Luciano Coelho79f460c2011-05-11 17:09:36 +0300365 trace_drv_sched_scan_start(local, sdata);
366 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
367 req, ies);
368 trace_drv_return_int(local, ret);
369 return ret;
370}
371
372static inline void drv_sched_scan_stop(struct ieee80211_local *local,
373 struct ieee80211_sub_if_data *sdata)
374{
375 might_sleep();
376
Johannes Berg7b7eab62011-11-03 14:41:13 +0100377 check_sdata_in_driver(sdata);
378
Luciano Coelho79f460c2011-05-11 17:09:36 +0300379 trace_drv_sched_scan_stop(local, sdata);
380 local->ops->sched_scan_stop(&local->hw, &sdata->vif);
381 trace_drv_return_void(local);
382}
383
Johannes Berg24487982009-04-23 18:52:52 +0200384static inline void drv_sw_scan_start(struct ieee80211_local *local)
385{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100386 might_sleep();
387
Johannes Berg4efc76b2010-06-10 10:56:20 +0200388 trace_drv_sw_scan_start(local);
Johannes Berg24487982009-04-23 18:52:52 +0200389 if (local->ops->sw_scan_start)
390 local->ops->sw_scan_start(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200391 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200392}
393
394static inline void drv_sw_scan_complete(struct ieee80211_local *local)
395{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100396 might_sleep();
397
Johannes Berg4efc76b2010-06-10 10:56:20 +0200398 trace_drv_sw_scan_complete(local);
Johannes Berg24487982009-04-23 18:52:52 +0200399 if (local->ops->sw_scan_complete)
400 local->ops->sw_scan_complete(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200401 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200402}
403
404static inline int drv_get_stats(struct ieee80211_local *local,
405 struct ieee80211_low_level_stats *stats)
406{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200407 int ret = -EOPNOTSUPP;
408
Kalle Valoe1781ed2009-12-23 13:15:47 +0100409 might_sleep();
410
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200411 if (local->ops->get_stats)
412 ret = local->ops->get_stats(&local->hw, stats);
413 trace_drv_get_stats(local, stats, ret);
414
415 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200416}
417
418static inline void drv_get_tkip_seq(struct ieee80211_local *local,
419 u8 hw_key_idx, u32 *iv32, u16 *iv16)
420{
421 if (local->ops->get_tkip_seq)
422 local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200423 trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
Johannes Berg24487982009-04-23 18:52:52 +0200424}
425
Arik Nemtsovf23a4782010-11-08 11:51:06 +0200426static inline int drv_set_frag_threshold(struct ieee80211_local *local,
427 u32 value)
428{
429 int ret = 0;
430
431 might_sleep();
432
433 trace_drv_set_frag_threshold(local, value);
434 if (local->ops->set_frag_threshold)
435 ret = local->ops->set_frag_threshold(&local->hw, value);
436 trace_drv_return_int(local, ret);
437 return ret;
438}
439
Johannes Berg24487982009-04-23 18:52:52 +0200440static inline int drv_set_rts_threshold(struct ieee80211_local *local,
441 u32 value)
442{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200443 int ret = 0;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100444
445 might_sleep();
446
Johannes Berg4efc76b2010-06-10 10:56:20 +0200447 trace_drv_set_rts_threshold(local, value);
Johannes Berg24487982009-04-23 18:52:52 +0200448 if (local->ops->set_rts_threshold)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200449 ret = local->ops->set_rts_threshold(&local->hw, value);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200450 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200451 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200452}
453
Lukáš Turek310bc672009-12-21 22:50:48 +0100454static inline int drv_set_coverage_class(struct ieee80211_local *local,
455 u8 value)
456{
457 int ret = 0;
458 might_sleep();
459
Johannes Berg4efc76b2010-06-10 10:56:20 +0200460 trace_drv_set_coverage_class(local, value);
Lukáš Turek310bc672009-12-21 22:50:48 +0100461 if (local->ops->set_coverage_class)
462 local->ops->set_coverage_class(&local->hw, value);
463 else
464 ret = -EOPNOTSUPP;
465
Johannes Berg4efc76b2010-06-10 10:56:20 +0200466 trace_drv_return_int(local, ret);
Lukáš Turek310bc672009-12-21 22:50:48 +0100467 return ret;
468}
469
Johannes Berg24487982009-04-23 18:52:52 +0200470static inline void drv_sta_notify(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100471 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200472 enum sta_notify_cmd cmd,
473 struct ieee80211_sta *sta)
474{
Felix Fietkaubc192f82011-11-23 21:09:49 +0700475 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100476 check_sdata_in_driver(sdata);
477
Johannes Berg4efc76b2010-06-10 10:56:20 +0200478 trace_drv_sta_notify(local, sdata, cmd, sta);
Johannes Berg24487982009-04-23 18:52:52 +0200479 if (local->ops->sta_notify)
Johannes Berg12375ef2009-11-25 20:30:31 +0100480 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200481 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200482}
483
Johannes Berg34e89502010-02-03 13:59:58 +0100484static inline int drv_sta_add(struct ieee80211_local *local,
485 struct ieee80211_sub_if_data *sdata,
486 struct ieee80211_sta *sta)
487{
488 int ret = 0;
489
490 might_sleep();
491
Felix Fietkaubc192f82011-11-23 21:09:49 +0700492 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100493 check_sdata_in_driver(sdata);
494
Johannes Berg4efc76b2010-06-10 10:56:20 +0200495 trace_drv_sta_add(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100496 if (local->ops->sta_add)
497 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100498
Johannes Berg4efc76b2010-06-10 10:56:20 +0200499 trace_drv_return_int(local, ret);
Johannes Berg34e89502010-02-03 13:59:58 +0100500
501 return ret;
502}
503
504static inline void drv_sta_remove(struct ieee80211_local *local,
505 struct ieee80211_sub_if_data *sdata,
506 struct ieee80211_sta *sta)
507{
508 might_sleep();
509
Felix Fietkaubc192f82011-11-23 21:09:49 +0700510 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100511 check_sdata_in_driver(sdata);
512
Johannes Berg4efc76b2010-06-10 10:56:20 +0200513 trace_drv_sta_remove(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100514 if (local->ops->sta_remove)
515 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100516
Johannes Berg4efc76b2010-06-10 10:56:20 +0200517 trace_drv_return_void(local);
Johannes Berg34e89502010-02-03 13:59:58 +0100518}
519
Sujith Manoharan77d2ece2012-11-20 08:46:02 +0530520#ifdef CONFIG_MAC80211_DEBUGFS
521static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
522 struct ieee80211_sub_if_data *sdata,
523 struct ieee80211_sta *sta,
524 struct dentry *dir)
525{
526 might_sleep();
527
528 sdata = get_bss_sdata(sdata);
529 check_sdata_in_driver(sdata);
530
531 if (local->ops->sta_add_debugfs)
532 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
533 sta, dir);
534}
535
536static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
537 struct ieee80211_sub_if_data *sdata,
538 struct ieee80211_sta *sta,
539 struct dentry *dir)
540{
541 might_sleep();
542
543 sdata = get_bss_sdata(sdata);
544 check_sdata_in_driver(sdata);
545
546 if (local->ops->sta_remove_debugfs)
547 local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
548 sta, dir);
549}
550#endif
551
Johannes Bergf09603a2012-01-20 13:55:21 +0100552static inline __must_check
553int drv_sta_state(struct ieee80211_local *local,
554 struct ieee80211_sub_if_data *sdata,
555 struct sta_info *sta,
556 enum ieee80211_sta_state old_state,
557 enum ieee80211_sta_state new_state)
558{
559 int ret = 0;
560
561 might_sleep();
562
563 sdata = get_bss_sdata(sdata);
564 check_sdata_in_driver(sdata);
565
566 trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
Johannes Berga4ec45a2012-01-20 13:55:22 +0100567 if (local->ops->sta_state) {
Johannes Bergf09603a2012-01-20 13:55:21 +0100568 ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta,
569 old_state, new_state);
Johannes Berga4ec45a2012-01-20 13:55:22 +0100570 } else if (old_state == IEEE80211_STA_AUTH &&
571 new_state == IEEE80211_STA_ASSOC) {
572 ret = drv_sta_add(local, sdata, &sta->sta);
573 if (ret == 0)
574 sta->uploaded = true;
575 } else if (old_state == IEEE80211_STA_ASSOC &&
576 new_state == IEEE80211_STA_AUTH) {
577 drv_sta_remove(local, sdata, &sta->sta);
578 }
Johannes Bergf09603a2012-01-20 13:55:21 +0100579 trace_drv_return_int(local, ret);
580 return ret;
581}
582
Johannes Berg8f727ef2012-03-30 08:43:32 +0200583static inline void drv_sta_rc_update(struct ieee80211_local *local,
584 struct ieee80211_sub_if_data *sdata,
585 struct ieee80211_sta *sta, u32 changed)
586{
587 sdata = get_bss_sdata(sdata);
588 check_sdata_in_driver(sdata);
589
Antonio Quartullie687f612012-08-12 18:24:55 +0200590 WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED &&
Thomas Pedersenf68d7762013-01-23 12:18:13 -0800591 (sdata->vif.type != NL80211_IFTYPE_ADHOC &&
592 sdata->vif.type != NL80211_IFTYPE_MESH_POINT));
Antonio Quartullie687f612012-08-12 18:24:55 +0200593
Johannes Berg8f727ef2012-03-30 08:43:32 +0200594 trace_drv_sta_rc_update(local, sdata, sta, changed);
595 if (local->ops->sta_rc_update)
596 local->ops->sta_rc_update(&local->hw, &sdata->vif,
597 sta, changed);
598
599 trace_drv_return_void(local);
600}
601
Eliad Pellerf6f3def2011-09-25 20:06:54 +0300602static inline int drv_conf_tx(struct ieee80211_local *local,
Johannes Berga3304b02012-03-28 11:04:24 +0200603 struct ieee80211_sub_if_data *sdata, u16 ac,
Johannes Berg24487982009-04-23 18:52:52 +0200604 const struct ieee80211_tx_queue_params *params)
605{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200606 int ret = -EOPNOTSUPP;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100607
608 might_sleep();
609
Johannes Berg7b7eab62011-11-03 14:41:13 +0100610 check_sdata_in_driver(sdata);
611
Johannes Berga3304b02012-03-28 11:04:24 +0200612 trace_drv_conf_tx(local, sdata, ac, params);
Johannes Berg24487982009-04-23 18:52:52 +0200613 if (local->ops->conf_tx)
Eliad Peller8a3a3c82011-10-02 10:15:52 +0200614 ret = local->ops->conf_tx(&local->hw, &sdata->vif,
Johannes Berga3304b02012-03-28 11:04:24 +0200615 ac, params);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200616 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200617 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200618}
619
Eliad Peller37a41b42011-09-21 14:06:11 +0300620static inline u64 drv_get_tsf(struct ieee80211_local *local,
621 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200622{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200623 u64 ret = -1ULL;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100624
625 might_sleep();
626
Johannes Berg7b7eab62011-11-03 14:41:13 +0100627 check_sdata_in_driver(sdata);
628
Eliad Peller37a41b42011-09-21 14:06:11 +0300629 trace_drv_get_tsf(local, sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200630 if (local->ops->get_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300631 ret = local->ops->get_tsf(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200632 trace_drv_return_u64(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200633 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200634}
635
Eliad Peller37a41b42011-09-21 14:06:11 +0300636static inline void drv_set_tsf(struct ieee80211_local *local,
637 struct ieee80211_sub_if_data *sdata,
638 u64 tsf)
Johannes Berg24487982009-04-23 18:52:52 +0200639{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100640 might_sleep();
641
Johannes Berg7b7eab62011-11-03 14:41:13 +0100642 check_sdata_in_driver(sdata);
643
Eliad Peller37a41b42011-09-21 14:06:11 +0300644 trace_drv_set_tsf(local, sdata, tsf);
Johannes Berg24487982009-04-23 18:52:52 +0200645 if (local->ops->set_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300646 local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200647 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200648}
649
Eliad Peller37a41b42011-09-21 14:06:11 +0300650static inline void drv_reset_tsf(struct ieee80211_local *local,
651 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200652{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100653 might_sleep();
654
Johannes Berg7b7eab62011-11-03 14:41:13 +0100655 check_sdata_in_driver(sdata);
656
Eliad Peller37a41b42011-09-21 14:06:11 +0300657 trace_drv_reset_tsf(local, sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200658 if (local->ops->reset_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300659 local->ops->reset_tsf(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200660 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200661}
662
663static inline int drv_tx_last_beacon(struct ieee80211_local *local)
664{
Masanari Iida02582e92012-08-22 19:11:26 +0900665 int ret = 0; /* default unsupported op for less congestion */
Kalle Valoe1781ed2009-12-23 13:15:47 +0100666
667 might_sleep();
668
Johannes Berg4efc76b2010-06-10 10:56:20 +0200669 trace_drv_tx_last_beacon(local);
Johannes Berg24487982009-04-23 18:52:52 +0200670 if (local->ops->tx_last_beacon)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200671 ret = local->ops->tx_last_beacon(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200672 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200673 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200674}
675
676static inline int drv_ampdu_action(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100677 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200678 enum ieee80211_ampdu_mlme_action action,
679 struct ieee80211_sta *sta, u16 tid,
Johannes Berg0b01f032011-01-18 13:51:05 +0100680 u16 *ssn, u8 buf_size)
Johannes Berg24487982009-04-23 18:52:52 +0200681{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200682 int ret = -EOPNOTSUPP;
Johannes Bergcfcdbde2010-06-10 10:21:48 +0200683
684 might_sleep();
685
Felix Fietkaubc192f82011-11-23 21:09:49 +0700686 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100687 check_sdata_in_driver(sdata);
688
Johannes Berg0b01f032011-01-18 13:51:05 +0100689 trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200690
Johannes Berg24487982009-04-23 18:52:52 +0200691 if (local->ops->ampdu_action)
Johannes Berg12375ef2009-11-25 20:30:31 +0100692 ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
Johannes Berg0b01f032011-01-18 13:51:05 +0100693 sta, tid, ssn, buf_size);
Johannes Berg85ad1812010-06-10 10:21:49 +0200694
Johannes Berg4efc76b2010-06-10 10:56:20 +0200695 trace_drv_return_int(local, ret);
696
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200697 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200698}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200699
Holger Schurig12897232010-04-19 10:23:57 +0200700static inline int drv_get_survey(struct ieee80211_local *local, int idx,
701 struct survey_info *survey)
702{
703 int ret = -EOPNOTSUPP;
John W. Linvillec466d4e2010-06-29 14:51:23 -0400704
705 trace_drv_get_survey(local, idx, survey);
706
Holger Schurig35dd0502010-06-07 16:33:49 +0200707 if (local->ops->get_survey)
Holger Schurig12897232010-04-19 10:23:57 +0200708 ret = local->ops->get_survey(&local->hw, idx, survey);
John W. Linvillec466d4e2010-06-29 14:51:23 -0400709
710 trace_drv_return_int(local, ret);
711
Holger Schurig12897232010-04-19 10:23:57 +0200712 return ret;
713}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200714
715static inline void drv_rfkill_poll(struct ieee80211_local *local)
716{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100717 might_sleep();
718
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200719 if (local->ops->rfkill_poll)
720 local->ops->rfkill_poll(&local->hw);
721}
Johannes Berga80f7c02009-12-23 13:15:32 +0100722
Johannes Berg39ecc012013-02-13 12:11:00 +0100723static inline void drv_flush(struct ieee80211_local *local,
724 u32 queues, bool drop)
Johannes Berga80f7c02009-12-23 13:15:32 +0100725{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100726 might_sleep();
727
Johannes Berg39ecc012013-02-13 12:11:00 +0100728 trace_drv_flush(local, queues, drop);
Johannes Berga80f7c02009-12-23 13:15:32 +0100729 if (local->ops->flush)
Johannes Berg39ecc012013-02-13 12:11:00 +0100730 local->ops->flush(&local->hw, queues, drop);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200731 trace_drv_return_void(local);
Johannes Berga80f7c02009-12-23 13:15:32 +0100732}
Johannes Berg5ce6e432010-05-11 16:20:57 +0200733
734static inline void drv_channel_switch(struct ieee80211_local *local,
735 struct ieee80211_channel_switch *ch_switch)
736{
737 might_sleep();
738
Johannes Berg5ce6e432010-05-11 16:20:57 +0200739 trace_drv_channel_switch(local, ch_switch);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200740 local->ops->channel_switch(&local->hw, ch_switch);
741 trace_drv_return_void(local);
Johannes Berg5ce6e432010-05-11 16:20:57 +0200742}
743
Bruno Randolf15d96752010-11-10 12:50:56 +0900744
745static inline int drv_set_antenna(struct ieee80211_local *local,
746 u32 tx_ant, u32 rx_ant)
747{
748 int ret = -EOPNOTSUPP;
749 might_sleep();
750 if (local->ops->set_antenna)
751 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
752 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
753 return ret;
754}
755
756static inline int drv_get_antenna(struct ieee80211_local *local,
757 u32 *tx_ant, u32 *rx_ant)
758{
759 int ret = -EOPNOTSUPP;
760 might_sleep();
761 if (local->ops->get_antenna)
762 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
763 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
764 return ret;
765}
766
Johannes Berg21f83582010-12-18 17:20:47 +0100767static inline int drv_remain_on_channel(struct ieee80211_local *local,
Eliad Peller49884562012-11-19 17:05:09 +0200768 struct ieee80211_sub_if_data *sdata,
Johannes Berg21f83582010-12-18 17:20:47 +0100769 struct ieee80211_channel *chan,
Ilan Peerd339d5c2013-02-12 09:34:13 +0200770 unsigned int duration,
771 enum ieee80211_roc_type type)
Johannes Berg21f83582010-12-18 17:20:47 +0100772{
773 int ret;
774
775 might_sleep();
776
Ilan Peerd339d5c2013-02-12 09:34:13 +0200777 trace_drv_remain_on_channel(local, sdata, chan, duration, type);
Eliad Peller49884562012-11-19 17:05:09 +0200778 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
Ilan Peerd339d5c2013-02-12 09:34:13 +0200779 chan, duration, type);
Johannes Berg21f83582010-12-18 17:20:47 +0100780 trace_drv_return_int(local, ret);
781
782 return ret;
783}
784
785static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
786{
787 int ret;
788
789 might_sleep();
790
791 trace_drv_cancel_remain_on_channel(local);
792 ret = local->ops->cancel_remain_on_channel(&local->hw);
793 trace_drv_return_int(local, ret);
794
795 return ret;
796}
797
John W. Linville38c09152011-03-07 16:19:18 -0500798static inline int drv_set_ringparam(struct ieee80211_local *local,
799 u32 tx, u32 rx)
800{
801 int ret = -ENOTSUPP;
802
803 might_sleep();
804
805 trace_drv_set_ringparam(local, tx, rx);
806 if (local->ops->set_ringparam)
807 ret = local->ops->set_ringparam(&local->hw, tx, rx);
808 trace_drv_return_int(local, ret);
809
810 return ret;
811}
812
813static inline void drv_get_ringparam(struct ieee80211_local *local,
814 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
815{
816 might_sleep();
817
818 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
819 if (local->ops->get_ringparam)
820 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
821 trace_drv_return_void(local);
822}
823
Vivek Natarajane8306f92011-04-06 11:41:10 +0530824static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
825{
826 bool ret = false;
827
828 might_sleep();
829
830 trace_drv_tx_frames_pending(local);
831 if (local->ops->tx_frames_pending)
832 ret = local->ops->tx_frames_pending(&local->hw);
833 trace_drv_return_bool(local, ret);
834
835 return ret;
836}
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530837
838static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
839 struct ieee80211_sub_if_data *sdata,
840 const struct cfg80211_bitrate_mask *mask)
841{
842 int ret = -EOPNOTSUPP;
843
844 might_sleep();
845
Johannes Berg7b7eab62011-11-03 14:41:13 +0100846 check_sdata_in_driver(sdata);
847
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530848 trace_drv_set_bitrate_mask(local, sdata, mask);
849 if (local->ops->set_bitrate_mask)
850 ret = local->ops->set_bitrate_mask(&local->hw,
851 &sdata->vif, mask);
852 trace_drv_return_int(local, ret);
853
854 return ret;
855}
856
Johannes Bergc68f4b82011-07-05 16:35:41 +0200857static inline void drv_set_rekey_data(struct ieee80211_local *local,
858 struct ieee80211_sub_if_data *sdata,
859 struct cfg80211_gtk_rekey_data *data)
860{
Johannes Berg7b7eab62011-11-03 14:41:13 +0100861 check_sdata_in_driver(sdata);
862
Johannes Bergc68f4b82011-07-05 16:35:41 +0200863 trace_drv_set_rekey_data(local, sdata, data);
864 if (local->ops->set_rekey_data)
865 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
866 trace_drv_return_void(local);
867}
868
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700869static inline void drv_rssi_callback(struct ieee80211_local *local,
Emmanuel Grumbach887da912013-01-20 17:32:41 +0200870 struct ieee80211_sub_if_data *sdata,
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700871 const enum ieee80211_rssi_event event)
872{
Emmanuel Grumbach887da912013-01-20 17:32:41 +0200873 trace_drv_rssi_callback(local, sdata, event);
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700874 if (local->ops->rssi_callback)
Emmanuel Grumbach887da912013-01-20 17:32:41 +0200875 local->ops->rssi_callback(&local->hw, &sdata->vif, event);
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700876 trace_drv_return_void(local);
877}
Johannes Berg4049e092011-09-29 16:04:32 +0200878
879static inline void
880drv_release_buffered_frames(struct ieee80211_local *local,
881 struct sta_info *sta, u16 tids, int num_frames,
882 enum ieee80211_frame_release_type reason,
883 bool more_data)
884{
885 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
886 reason, more_data);
887 if (local->ops->release_buffered_frames)
888 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
889 num_frames, reason,
890 more_data);
891 trace_drv_return_void(local);
892}
Johannes Berg40b96402011-09-29 16:04:38 +0200893
894static inline void
895drv_allow_buffered_frames(struct ieee80211_local *local,
896 struct sta_info *sta, u16 tids, int num_frames,
897 enum ieee80211_frame_release_type reason,
898 bool more_data)
899{
900 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
901 reason, more_data);
902 if (local->ops->allow_buffered_frames)
903 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
904 tids, num_frames, reason,
905 more_data);
906 trace_drv_return_void(local);
907}
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300908
909static inline int drv_get_rssi(struct ieee80211_local *local,
910 struct ieee80211_sub_if_data *sdata,
911 struct ieee80211_sta *sta,
912 s8 *rssi_dbm)
913{
914 int ret;
915
916 might_sleep();
917
918 ret = local->ops->get_rssi(&local->hw, &sdata->vif, sta, rssi_dbm);
919 trace_drv_get_rssi(local, sta, *rssi_dbm, ret);
920
921 return ret;
922}
Johannes Berga1845fc2012-06-27 13:18:36 +0200923
924static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
925 struct ieee80211_sub_if_data *sdata)
926{
927 might_sleep();
928
929 check_sdata_in_driver(sdata);
930 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
931
932 trace_drv_mgd_prepare_tx(local, sdata);
933 if (local->ops->mgd_prepare_tx)
934 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
935 trace_drv_return_void(local);
936}
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200937
938static inline int drv_add_chanctx(struct ieee80211_local *local,
939 struct ieee80211_chanctx *ctx)
940{
941 int ret = -EOPNOTSUPP;
942
943 trace_drv_add_chanctx(local, ctx);
944 if (local->ops->add_chanctx)
945 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
946 trace_drv_return_int(local, ret);
Johannes Berg8a61af62012-12-13 17:42:30 +0100947 if (!ret)
948 ctx->driver_present = true;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200949
950 return ret;
951}
952
953static inline void drv_remove_chanctx(struct ieee80211_local *local,
954 struct ieee80211_chanctx *ctx)
955{
956 trace_drv_remove_chanctx(local, ctx);
957 if (local->ops->remove_chanctx)
958 local->ops->remove_chanctx(&local->hw, &ctx->conf);
959 trace_drv_return_void(local);
Johannes Berg8a61af62012-12-13 17:42:30 +0100960 ctx->driver_present = false;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200961}
962
963static inline void drv_change_chanctx(struct ieee80211_local *local,
964 struct ieee80211_chanctx *ctx,
965 u32 changed)
966{
967 trace_drv_change_chanctx(local, ctx, changed);
Johannes Berg8a61af62012-12-13 17:42:30 +0100968 if (local->ops->change_chanctx) {
969 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200970 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
Johannes Berg8a61af62012-12-13 17:42:30 +0100971 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200972 trace_drv_return_void(local);
973}
974
975static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
976 struct ieee80211_sub_if_data *sdata,
977 struct ieee80211_chanctx *ctx)
978{
979 int ret = 0;
980
981 check_sdata_in_driver(sdata);
982
983 trace_drv_assign_vif_chanctx(local, sdata, ctx);
Johannes Berg8a61af62012-12-13 17:42:30 +0100984 if (local->ops->assign_vif_chanctx) {
985 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200986 ret = local->ops->assign_vif_chanctx(&local->hw,
987 &sdata->vif,
988 &ctx->conf);
Johannes Berg8a61af62012-12-13 17:42:30 +0100989 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200990 trace_drv_return_int(local, ret);
991
992 return ret;
993}
994
995static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
996 struct ieee80211_sub_if_data *sdata,
997 struct ieee80211_chanctx *ctx)
998{
999 check_sdata_in_driver(sdata);
1000
1001 trace_drv_unassign_vif_chanctx(local, sdata, ctx);
Johannes Berg8a61af62012-12-13 17:42:30 +01001002 if (local->ops->unassign_vif_chanctx) {
1003 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +02001004 local->ops->unassign_vif_chanctx(&local->hw,
1005 &sdata->vif,
1006 &ctx->conf);
Johannes Berg8a61af62012-12-13 17:42:30 +01001007 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +02001008 trace_drv_return_void(local);
1009}
1010
Johannes Berg10416382012-10-19 15:44:42 +02001011static inline int drv_start_ap(struct ieee80211_local *local,
1012 struct ieee80211_sub_if_data *sdata)
1013{
1014 int ret = 0;
1015
1016 check_sdata_in_driver(sdata);
1017
1018 trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
1019 if (local->ops->start_ap)
1020 ret = local->ops->start_ap(&local->hw, &sdata->vif);
1021 trace_drv_return_int(local, ret);
1022 return ret;
1023}
1024
1025static inline void drv_stop_ap(struct ieee80211_local *local,
1026 struct ieee80211_sub_if_data *sdata)
1027{
1028 check_sdata_in_driver(sdata);
1029
1030 trace_drv_stop_ap(local, sdata);
1031 if (local->ops->stop_ap)
1032 local->ops->stop_ap(&local->hw, &sdata->vif);
1033 trace_drv_return_void(local);
1034}
1035
Johannes Berg9214ad72012-11-06 19:18:13 +01001036static inline void drv_restart_complete(struct ieee80211_local *local)
1037{
1038 might_sleep();
1039
1040 trace_drv_restart_complete(local);
1041 if (local->ops->restart_complete)
1042 local->ops->restart_complete(&local->hw);
1043 trace_drv_return_void(local);
1044}
1045
Yoni Divinskyde5fad82012-05-30 11:36:39 +03001046static inline void
1047drv_set_default_unicast_key(struct ieee80211_local *local,
1048 struct ieee80211_sub_if_data *sdata,
1049 int key_idx)
1050{
1051 check_sdata_in_driver(sdata);
1052
1053 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1054
1055 trace_drv_set_default_unicast_key(local, sdata, key_idx);
1056 if (local->ops->set_default_unicast_key)
1057 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1058 key_idx);
1059 trace_drv_return_void(local);
1060}
1061
Johannes Berga65240c2013-01-14 15:14:34 +01001062#if IS_ENABLED(CONFIG_IPV6)
1063static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1064 struct ieee80211_sub_if_data *sdata,
1065 struct inet6_dev *idev)
1066{
1067 trace_drv_ipv6_addr_change(local, sdata);
1068 if (local->ops->ipv6_addr_change)
1069 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1070 trace_drv_return_void(local);
1071}
1072#endif
1073
Johannes Berg24487982009-04-23 18:52:52 +02001074#endif /* __MAC80211_DRIVER_OPS */