blob: fc689f5d971e259381f0a26e13079f1a727fe704 [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 &&
Felix Fietkau31eba5b2013-05-28 13:01:53 +0200149 !(local->hw.flags & IEEE80211_HW_WANT_MONITOR_VIF) &&
150 !(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE))))
Johannes Berg7b7eab62011-11-03 14:41:13 +0100151 return -EINVAL;
152
153 trace_drv_add_interface(local, sdata);
154 ret = local->ops->add_interface(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200155 trace_drv_return_int(local, ret);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100156
157 if (ret == 0)
158 sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
159
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200160 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200161}
162
Johannes Berg34d4bc42010-08-27 12:35:58 +0200163static inline int drv_change_interface(struct ieee80211_local *local,
164 struct ieee80211_sub_if_data *sdata,
Johannes Berg2ca27bc2010-09-16 14:58:23 +0200165 enum nl80211_iftype type, bool p2p)
Johannes Berg34d4bc42010-08-27 12:35:58 +0200166{
167 int ret;
168
169 might_sleep();
170
Johannes Berg7b7eab62011-11-03 14:41:13 +0100171 check_sdata_in_driver(sdata);
172
Johannes Berg2ca27bc2010-09-16 14:58:23 +0200173 trace_drv_change_interface(local, sdata, type, p2p);
174 ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
Johannes Berg34d4bc42010-08-27 12:35:58 +0200175 trace_drv_return_int(local, ret);
176 return ret;
177}
178
Johannes Berg24487982009-04-23 18:52:52 +0200179static inline void drv_remove_interface(struct ieee80211_local *local,
Johannes Berg7b7eab62011-11-03 14:41:13 +0100180 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200181{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100182 might_sleep();
183
Johannes Berg7b7eab62011-11-03 14:41:13 +0100184 check_sdata_in_driver(sdata);
185
186 trace_drv_remove_interface(local, sdata);
187 local->ops->remove_interface(&local->hw, &sdata->vif);
188 sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER;
Johannes Berg4efc76b2010-06-10 10:56:20 +0200189 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200190}
191
192static inline int drv_config(struct ieee80211_local *local, u32 changed)
193{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100194 int ret;
195
196 might_sleep();
197
Johannes Berg4efc76b2010-06-10 10:56:20 +0200198 trace_drv_config(local, changed);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100199 ret = local->ops->config(&local->hw, changed);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200200 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200201 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200202}
203
204static inline void drv_bss_info_changed(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100205 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200206 struct ieee80211_bss_conf *info,
207 u32 changed)
208{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100209 might_sleep();
210
Johannes Berg5bbe754d2013-02-13 13:50:51 +0100211 if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
212 BSS_CHANGED_BEACON_ENABLED) &&
213 sdata->vif.type != NL80211_IFTYPE_AP &&
214 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
215 sdata->vif.type != NL80211_IFTYPE_MESH_POINT))
216 return;
217
218 if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
219 sdata->vif.type == NL80211_IFTYPE_MONITOR))
220 return;
Johannes Bergb8dc1a32012-12-14 14:22:10 +0100221
Johannes Berg7b7eab62011-11-03 14:41:13 +0100222 check_sdata_in_driver(sdata);
223
Johannes Berg4efc76b2010-06-10 10:56:20 +0200224 trace_drv_bss_info_changed(local, sdata, info, changed);
Johannes Berg24487982009-04-23 18:52:52 +0200225 if (local->ops->bss_info_changed)
Johannes Berg12375ef2009-11-25 20:30:31 +0100226 local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200227 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200228}
229
Johannes Berg3ac64be2009-08-17 16:16:53 +0200230static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
Jiri Pirko22bedad32010-04-01 21:22:57 +0000231 struct netdev_hw_addr_list *mc_list)
Johannes Berg24487982009-04-23 18:52:52 +0200232{
Johannes Berg3ac64be2009-08-17 16:16:53 +0200233 u64 ret = 0;
234
Johannes Berg4efc76b2010-06-10 10:56:20 +0200235 trace_drv_prepare_multicast(local, mc_list->count);
236
Johannes Berg3ac64be2009-08-17 16:16:53 +0200237 if (local->ops->prepare_multicast)
Jiri Pirko22bedad32010-04-01 21:22:57 +0000238 ret = local->ops->prepare_multicast(&local->hw, mc_list);
Johannes Berg3ac64be2009-08-17 16:16:53 +0200239
Johannes Berg4efc76b2010-06-10 10:56:20 +0200240 trace_drv_return_u64(local, ret);
Johannes Berg3ac64be2009-08-17 16:16:53 +0200241
242 return ret;
243}
244
245static inline void drv_configure_filter(struct ieee80211_local *local,
246 unsigned int changed_flags,
247 unsigned int *total_flags,
248 u64 multicast)
249{
250 might_sleep();
251
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200252 trace_drv_configure_filter(local, changed_flags, total_flags,
Johannes Berg3ac64be2009-08-17 16:16:53 +0200253 multicast);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200254 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
255 multicast);
256 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200257}
258
259static inline int drv_set_tim(struct ieee80211_local *local,
260 struct ieee80211_sta *sta, bool set)
261{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200262 int ret = 0;
Johannes Berg4efc76b2010-06-10 10:56:20 +0200263 trace_drv_set_tim(local, sta, set);
Johannes Berg24487982009-04-23 18:52:52 +0200264 if (local->ops->set_tim)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200265 ret = local->ops->set_tim(&local->hw, sta, set);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200266 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200267 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200268}
269
270static inline int drv_set_key(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100271 enum set_key_cmd cmd,
272 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200273 struct ieee80211_sta *sta,
274 struct ieee80211_key_conf *key)
275{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100276 int ret;
277
278 might_sleep();
279
Johannes Berg077f4932012-01-20 13:55:18 +0100280 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100281 check_sdata_in_driver(sdata);
282
Johannes Berg4efc76b2010-06-10 10:56:20 +0200283 trace_drv_set_key(local, cmd, sdata, sta, key);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100284 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200285 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200286 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200287}
288
289static inline void drv_update_tkip_key(struct ieee80211_local *local,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100290 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200291 struct ieee80211_key_conf *conf,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100292 struct sta_info *sta, u32 iv32,
Johannes Berg24487982009-04-23 18:52:52 +0200293 u16 *phase1key)
294{
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100295 struct ieee80211_sta *ista = NULL;
296
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100297 if (sta)
298 ista = &sta->sta;
299
Johannes Berg077f4932012-01-20 13:55:18 +0100300 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100301 check_sdata_in_driver(sdata);
302
Johannes Berg4efc76b2010-06-10 10:56:20 +0200303 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
Johannes Berg24487982009-04-23 18:52:52 +0200304 if (local->ops->update_tkip_key)
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100305 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
306 ista, iv32, phase1key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200307 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200308}
309
310static inline int drv_hw_scan(struct ieee80211_local *local,
Johannes Berga060bbf2010-04-27 11:59:34 +0200311 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200312 struct cfg80211_scan_request *req)
313{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100314 int ret;
315
316 might_sleep();
317
Johannes Berg7b7eab62011-11-03 14:41:13 +0100318 check_sdata_in_driver(sdata);
319
Luciano Coelho79f460c2011-05-11 17:09:36 +0300320 trace_drv_hw_scan(local, sdata);
Johannes Berga060bbf2010-04-27 11:59:34 +0200321 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200322 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200323 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200324}
325
Eliad Pellerb8564392011-06-13 12:47:30 +0300326static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
327 struct ieee80211_sub_if_data *sdata)
328{
329 might_sleep();
330
Johannes Berg7b7eab62011-11-03 14:41:13 +0100331 check_sdata_in_driver(sdata);
332
Eliad Pellerb8564392011-06-13 12:47:30 +0300333 trace_drv_cancel_hw_scan(local, sdata);
334 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
335 trace_drv_return_void(local);
336}
337
Luciano Coelho79f460c2011-05-11 17:09:36 +0300338static inline int
339drv_sched_scan_start(struct ieee80211_local *local,
340 struct ieee80211_sub_if_data *sdata,
341 struct cfg80211_sched_scan_request *req,
342 struct ieee80211_sched_scan_ies *ies)
343{
344 int ret;
345
346 might_sleep();
347
Johannes Berg7b7eab62011-11-03 14:41:13 +0100348 check_sdata_in_driver(sdata);
349
Luciano Coelho79f460c2011-05-11 17:09:36 +0300350 trace_drv_sched_scan_start(local, sdata);
351 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
352 req, ies);
353 trace_drv_return_int(local, ret);
354 return ret;
355}
356
Johannes Berg37e33082014-02-17 10:48:17 +0100357static inline int drv_sched_scan_stop(struct ieee80211_local *local,
358 struct ieee80211_sub_if_data *sdata)
Luciano Coelho79f460c2011-05-11 17:09:36 +0300359{
Johannes Berg37e33082014-02-17 10:48:17 +0100360 int ret;
361
Luciano Coelho79f460c2011-05-11 17:09:36 +0300362 might_sleep();
363
Johannes Berg7b7eab62011-11-03 14:41:13 +0100364 check_sdata_in_driver(sdata);
365
Luciano Coelho79f460c2011-05-11 17:09:36 +0300366 trace_drv_sched_scan_stop(local, sdata);
Johannes Berg37e33082014-02-17 10:48:17 +0100367 ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
368 trace_drv_return_int(local, ret);
369
370 return ret;
Luciano Coelho79f460c2011-05-11 17:09:36 +0300371}
372
Johannes Berg24487982009-04-23 18:52:52 +0200373static inline void drv_sw_scan_start(struct ieee80211_local *local)
374{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100375 might_sleep();
376
Johannes Berg4efc76b2010-06-10 10:56:20 +0200377 trace_drv_sw_scan_start(local);
Johannes Berg24487982009-04-23 18:52:52 +0200378 if (local->ops->sw_scan_start)
379 local->ops->sw_scan_start(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200380 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200381}
382
383static inline void drv_sw_scan_complete(struct ieee80211_local *local)
384{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100385 might_sleep();
386
Johannes Berg4efc76b2010-06-10 10:56:20 +0200387 trace_drv_sw_scan_complete(local);
Johannes Berg24487982009-04-23 18:52:52 +0200388 if (local->ops->sw_scan_complete)
389 local->ops->sw_scan_complete(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200390 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200391}
392
393static inline int drv_get_stats(struct ieee80211_local *local,
394 struct ieee80211_low_level_stats *stats)
395{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200396 int ret = -EOPNOTSUPP;
397
Kalle Valoe1781ed2009-12-23 13:15:47 +0100398 might_sleep();
399
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200400 if (local->ops->get_stats)
401 ret = local->ops->get_stats(&local->hw, stats);
402 trace_drv_get_stats(local, stats, ret);
403
404 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200405}
406
407static inline void drv_get_tkip_seq(struct ieee80211_local *local,
408 u8 hw_key_idx, u32 *iv32, u16 *iv16)
409{
410 if (local->ops->get_tkip_seq)
411 local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200412 trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
Johannes Berg24487982009-04-23 18:52:52 +0200413}
414
Arik Nemtsovf23a4782010-11-08 11:51:06 +0200415static inline int drv_set_frag_threshold(struct ieee80211_local *local,
416 u32 value)
417{
418 int ret = 0;
419
420 might_sleep();
421
422 trace_drv_set_frag_threshold(local, value);
423 if (local->ops->set_frag_threshold)
424 ret = local->ops->set_frag_threshold(&local->hw, value);
425 trace_drv_return_int(local, ret);
426 return ret;
427}
428
Johannes Berg24487982009-04-23 18:52:52 +0200429static inline int drv_set_rts_threshold(struct ieee80211_local *local,
430 u32 value)
431{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200432 int ret = 0;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100433
434 might_sleep();
435
Johannes Berg4efc76b2010-06-10 10:56:20 +0200436 trace_drv_set_rts_threshold(local, value);
Johannes Berg24487982009-04-23 18:52:52 +0200437 if (local->ops->set_rts_threshold)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200438 ret = local->ops->set_rts_threshold(&local->hw, value);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200439 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200440 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200441}
442
Lukáš Turek310bc672009-12-21 22:50:48 +0100443static inline int drv_set_coverage_class(struct ieee80211_local *local,
444 u8 value)
445{
446 int ret = 0;
447 might_sleep();
448
Johannes Berg4efc76b2010-06-10 10:56:20 +0200449 trace_drv_set_coverage_class(local, value);
Lukáš Turek310bc672009-12-21 22:50:48 +0100450 if (local->ops->set_coverage_class)
451 local->ops->set_coverage_class(&local->hw, value);
452 else
453 ret = -EOPNOTSUPP;
454
Johannes Berg4efc76b2010-06-10 10:56:20 +0200455 trace_drv_return_int(local, ret);
Lukáš Turek310bc672009-12-21 22:50:48 +0100456 return ret;
457}
458
Johannes Berg24487982009-04-23 18:52:52 +0200459static inline void drv_sta_notify(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100460 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200461 enum sta_notify_cmd cmd,
462 struct ieee80211_sta *sta)
463{
Felix Fietkaubc192f82011-11-23 21:09:49 +0700464 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100465 check_sdata_in_driver(sdata);
466
Johannes Berg4efc76b2010-06-10 10:56:20 +0200467 trace_drv_sta_notify(local, sdata, cmd, sta);
Johannes Berg24487982009-04-23 18:52:52 +0200468 if (local->ops->sta_notify)
Johannes Berg12375ef2009-11-25 20:30:31 +0100469 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200470 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200471}
472
Johannes Berg34e89502010-02-03 13:59:58 +0100473static inline int drv_sta_add(struct ieee80211_local *local,
474 struct ieee80211_sub_if_data *sdata,
475 struct ieee80211_sta *sta)
476{
477 int ret = 0;
478
479 might_sleep();
480
Felix Fietkaubc192f82011-11-23 21:09:49 +0700481 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100482 check_sdata_in_driver(sdata);
483
Johannes Berg4efc76b2010-06-10 10:56:20 +0200484 trace_drv_sta_add(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100485 if (local->ops->sta_add)
486 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100487
Johannes Berg4efc76b2010-06-10 10:56:20 +0200488 trace_drv_return_int(local, ret);
Johannes Berg34e89502010-02-03 13:59:58 +0100489
490 return ret;
491}
492
493static inline void drv_sta_remove(struct ieee80211_local *local,
494 struct ieee80211_sub_if_data *sdata,
495 struct ieee80211_sta *sta)
496{
497 might_sleep();
498
Felix Fietkaubc192f82011-11-23 21:09:49 +0700499 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100500 check_sdata_in_driver(sdata);
501
Johannes Berg4efc76b2010-06-10 10:56:20 +0200502 trace_drv_sta_remove(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100503 if (local->ops->sta_remove)
504 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100505
Johannes Berg4efc76b2010-06-10 10:56:20 +0200506 trace_drv_return_void(local);
Johannes Berg34e89502010-02-03 13:59:58 +0100507}
508
Sujith Manoharan77d2ece2012-11-20 08:46:02 +0530509#ifdef CONFIG_MAC80211_DEBUGFS
510static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
511 struct ieee80211_sub_if_data *sdata,
512 struct ieee80211_sta *sta,
513 struct dentry *dir)
514{
515 might_sleep();
516
517 sdata = get_bss_sdata(sdata);
518 check_sdata_in_driver(sdata);
519
520 if (local->ops->sta_add_debugfs)
521 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
522 sta, dir);
523}
524
525static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
526 struct ieee80211_sub_if_data *sdata,
527 struct ieee80211_sta *sta,
528 struct dentry *dir)
529{
530 might_sleep();
531
532 sdata = get_bss_sdata(sdata);
533 check_sdata_in_driver(sdata);
534
535 if (local->ops->sta_remove_debugfs)
536 local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
537 sta, dir);
538}
539#endif
540
Johannes Berg6a9d1b92013-12-04 22:39:17 +0100541static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
542 struct ieee80211_sub_if_data *sdata,
543 struct sta_info *sta)
544{
545 might_sleep();
546
547 sdata = get_bss_sdata(sdata);
548 check_sdata_in_driver(sdata);
549
550 trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
551 if (local->ops->sta_pre_rcu_remove)
552 local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
553 &sta->sta);
554 trace_drv_return_void(local);
555}
556
Johannes Bergf09603a2012-01-20 13:55:21 +0100557static inline __must_check
558int drv_sta_state(struct ieee80211_local *local,
559 struct ieee80211_sub_if_data *sdata,
560 struct sta_info *sta,
561 enum ieee80211_sta_state old_state,
562 enum ieee80211_sta_state new_state)
563{
564 int ret = 0;
565
566 might_sleep();
567
568 sdata = get_bss_sdata(sdata);
569 check_sdata_in_driver(sdata);
570
571 trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
Johannes Berga4ec45a2012-01-20 13:55:22 +0100572 if (local->ops->sta_state) {
Johannes Bergf09603a2012-01-20 13:55:21 +0100573 ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta,
574 old_state, new_state);
Johannes Berga4ec45a2012-01-20 13:55:22 +0100575 } else if (old_state == IEEE80211_STA_AUTH &&
576 new_state == IEEE80211_STA_ASSOC) {
577 ret = drv_sta_add(local, sdata, &sta->sta);
578 if (ret == 0)
579 sta->uploaded = true;
580 } else if (old_state == IEEE80211_STA_ASSOC &&
581 new_state == IEEE80211_STA_AUTH) {
582 drv_sta_remove(local, sdata, &sta->sta);
583 }
Johannes Bergf09603a2012-01-20 13:55:21 +0100584 trace_drv_return_int(local, ret);
585 return ret;
586}
587
Johannes Berg8f727ef2012-03-30 08:43:32 +0200588static inline void drv_sta_rc_update(struct ieee80211_local *local,
589 struct ieee80211_sub_if_data *sdata,
590 struct ieee80211_sta *sta, u32 changed)
591{
592 sdata = get_bss_sdata(sdata);
593 check_sdata_in_driver(sdata);
594
Antonio Quartullie687f612012-08-12 18:24:55 +0200595 WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED &&
Thomas Pedersenf68d7762013-01-23 12:18:13 -0800596 (sdata->vif.type != NL80211_IFTYPE_ADHOC &&
597 sdata->vif.type != NL80211_IFTYPE_MESH_POINT));
Antonio Quartullie687f612012-08-12 18:24:55 +0200598
Johannes Berg8f727ef2012-03-30 08:43:32 +0200599 trace_drv_sta_rc_update(local, sdata, sta, changed);
600 if (local->ops->sta_rc_update)
601 local->ops->sta_rc_update(&local->hw, &sdata->vif,
602 sta, changed);
603
604 trace_drv_return_void(local);
605}
606
Eliad Pellerf6f3def2011-09-25 20:06:54 +0300607static inline int drv_conf_tx(struct ieee80211_local *local,
Johannes Berga3304b02012-03-28 11:04:24 +0200608 struct ieee80211_sub_if_data *sdata, u16 ac,
Johannes Berg24487982009-04-23 18:52:52 +0200609 const struct ieee80211_tx_queue_params *params)
610{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200611 int ret = -EOPNOTSUPP;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100612
613 might_sleep();
614
Johannes Berg7b7eab62011-11-03 14:41:13 +0100615 check_sdata_in_driver(sdata);
616
Johannes Berga3304b02012-03-28 11:04:24 +0200617 trace_drv_conf_tx(local, sdata, ac, params);
Johannes Berg24487982009-04-23 18:52:52 +0200618 if (local->ops->conf_tx)
Eliad Peller8a3a3c82011-10-02 10:15:52 +0200619 ret = local->ops->conf_tx(&local->hw, &sdata->vif,
Johannes Berga3304b02012-03-28 11:04:24 +0200620 ac, params);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200621 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200622 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200623}
624
Eliad Peller37a41b42011-09-21 14:06:11 +0300625static inline u64 drv_get_tsf(struct ieee80211_local *local,
626 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200627{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200628 u64 ret = -1ULL;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100629
630 might_sleep();
631
Johannes Berg7b7eab62011-11-03 14:41:13 +0100632 check_sdata_in_driver(sdata);
633
Eliad Peller37a41b42011-09-21 14:06:11 +0300634 trace_drv_get_tsf(local, sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200635 if (local->ops->get_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300636 ret = local->ops->get_tsf(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200637 trace_drv_return_u64(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200638 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200639}
640
Eliad Peller37a41b42011-09-21 14:06:11 +0300641static inline void drv_set_tsf(struct ieee80211_local *local,
642 struct ieee80211_sub_if_data *sdata,
643 u64 tsf)
Johannes Berg24487982009-04-23 18:52:52 +0200644{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100645 might_sleep();
646
Johannes Berg7b7eab62011-11-03 14:41:13 +0100647 check_sdata_in_driver(sdata);
648
Eliad Peller37a41b42011-09-21 14:06:11 +0300649 trace_drv_set_tsf(local, sdata, tsf);
Johannes Berg24487982009-04-23 18:52:52 +0200650 if (local->ops->set_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300651 local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200652 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200653}
654
Eliad Peller37a41b42011-09-21 14:06:11 +0300655static inline void drv_reset_tsf(struct ieee80211_local *local,
656 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200657{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100658 might_sleep();
659
Johannes Berg7b7eab62011-11-03 14:41:13 +0100660 check_sdata_in_driver(sdata);
661
Eliad Peller37a41b42011-09-21 14:06:11 +0300662 trace_drv_reset_tsf(local, sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200663 if (local->ops->reset_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300664 local->ops->reset_tsf(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200665 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200666}
667
668static inline int drv_tx_last_beacon(struct ieee80211_local *local)
669{
Masanari Iida02582e92012-08-22 19:11:26 +0900670 int ret = 0; /* default unsupported op for less congestion */
Kalle Valoe1781ed2009-12-23 13:15:47 +0100671
672 might_sleep();
673
Johannes Berg4efc76b2010-06-10 10:56:20 +0200674 trace_drv_tx_last_beacon(local);
Johannes Berg24487982009-04-23 18:52:52 +0200675 if (local->ops->tx_last_beacon)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200676 ret = local->ops->tx_last_beacon(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200677 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200678 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200679}
680
681static inline int drv_ampdu_action(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100682 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200683 enum ieee80211_ampdu_mlme_action action,
684 struct ieee80211_sta *sta, u16 tid,
Johannes Berg0b01f032011-01-18 13:51:05 +0100685 u16 *ssn, u8 buf_size)
Johannes Berg24487982009-04-23 18:52:52 +0200686{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200687 int ret = -EOPNOTSUPP;
Johannes Bergcfcdbde2010-06-10 10:21:48 +0200688
689 might_sleep();
690
Felix Fietkaubc192f82011-11-23 21:09:49 +0700691 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100692 check_sdata_in_driver(sdata);
693
Johannes Berg0b01f032011-01-18 13:51:05 +0100694 trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200695
Johannes Berg24487982009-04-23 18:52:52 +0200696 if (local->ops->ampdu_action)
Johannes Berg12375ef2009-11-25 20:30:31 +0100697 ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
Johannes Berg0b01f032011-01-18 13:51:05 +0100698 sta, tid, ssn, buf_size);
Johannes Berg85ad1812010-06-10 10:21:49 +0200699
Johannes Berg4efc76b2010-06-10 10:56:20 +0200700 trace_drv_return_int(local, ret);
701
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200702 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200703}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200704
Holger Schurig12897232010-04-19 10:23:57 +0200705static inline int drv_get_survey(struct ieee80211_local *local, int idx,
706 struct survey_info *survey)
707{
708 int ret = -EOPNOTSUPP;
John W. Linvillec466d4e2010-06-29 14:51:23 -0400709
710 trace_drv_get_survey(local, idx, survey);
711
Holger Schurig35dd0502010-06-07 16:33:49 +0200712 if (local->ops->get_survey)
Holger Schurig12897232010-04-19 10:23:57 +0200713 ret = local->ops->get_survey(&local->hw, idx, survey);
John W. Linvillec466d4e2010-06-29 14:51:23 -0400714
715 trace_drv_return_int(local, ret);
716
Holger Schurig12897232010-04-19 10:23:57 +0200717 return ret;
718}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200719
720static inline void drv_rfkill_poll(struct ieee80211_local *local)
721{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100722 might_sleep();
723
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200724 if (local->ops->rfkill_poll)
725 local->ops->rfkill_poll(&local->hw);
726}
Johannes Berga80f7c02009-12-23 13:15:32 +0100727
Johannes Berg39ecc012013-02-13 12:11:00 +0100728static inline void drv_flush(struct ieee80211_local *local,
729 u32 queues, bool drop)
Johannes Berga80f7c02009-12-23 13:15:32 +0100730{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100731 might_sleep();
732
Johannes Berg39ecc012013-02-13 12:11:00 +0100733 trace_drv_flush(local, queues, drop);
Johannes Berga80f7c02009-12-23 13:15:32 +0100734 if (local->ops->flush)
Johannes Berg39ecc012013-02-13 12:11:00 +0100735 local->ops->flush(&local->hw, queues, drop);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200736 trace_drv_return_void(local);
Johannes Berga80f7c02009-12-23 13:15:32 +0100737}
Johannes Berg5ce6e432010-05-11 16:20:57 +0200738
739static inline void drv_channel_switch(struct ieee80211_local *local,
740 struct ieee80211_channel_switch *ch_switch)
741{
742 might_sleep();
743
Johannes Berg5ce6e432010-05-11 16:20:57 +0200744 trace_drv_channel_switch(local, ch_switch);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200745 local->ops->channel_switch(&local->hw, ch_switch);
746 trace_drv_return_void(local);
Johannes Berg5ce6e432010-05-11 16:20:57 +0200747}
748
Bruno Randolf15d96752010-11-10 12:50:56 +0900749
750static inline int drv_set_antenna(struct ieee80211_local *local,
751 u32 tx_ant, u32 rx_ant)
752{
753 int ret = -EOPNOTSUPP;
754 might_sleep();
755 if (local->ops->set_antenna)
756 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
757 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
758 return ret;
759}
760
761static inline int drv_get_antenna(struct ieee80211_local *local,
762 u32 *tx_ant, u32 *rx_ant)
763{
764 int ret = -EOPNOTSUPP;
765 might_sleep();
766 if (local->ops->get_antenna)
767 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
768 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
769 return ret;
770}
771
Johannes Berg21f83582010-12-18 17:20:47 +0100772static inline int drv_remain_on_channel(struct ieee80211_local *local,
Eliad Peller49884562012-11-19 17:05:09 +0200773 struct ieee80211_sub_if_data *sdata,
Johannes Berg21f83582010-12-18 17:20:47 +0100774 struct ieee80211_channel *chan,
Ilan Peerd339d5c2013-02-12 09:34:13 +0200775 unsigned int duration,
776 enum ieee80211_roc_type type)
Johannes Berg21f83582010-12-18 17:20:47 +0100777{
778 int ret;
779
780 might_sleep();
781
Ilan Peerd339d5c2013-02-12 09:34:13 +0200782 trace_drv_remain_on_channel(local, sdata, chan, duration, type);
Eliad Peller49884562012-11-19 17:05:09 +0200783 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
Ilan Peerd339d5c2013-02-12 09:34:13 +0200784 chan, duration, type);
Johannes Berg21f83582010-12-18 17:20:47 +0100785 trace_drv_return_int(local, ret);
786
787 return ret;
788}
789
790static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
791{
792 int ret;
793
794 might_sleep();
795
796 trace_drv_cancel_remain_on_channel(local);
797 ret = local->ops->cancel_remain_on_channel(&local->hw);
798 trace_drv_return_int(local, ret);
799
800 return ret;
801}
802
John W. Linville38c09152011-03-07 16:19:18 -0500803static inline int drv_set_ringparam(struct ieee80211_local *local,
804 u32 tx, u32 rx)
805{
806 int ret = -ENOTSUPP;
807
808 might_sleep();
809
810 trace_drv_set_ringparam(local, tx, rx);
811 if (local->ops->set_ringparam)
812 ret = local->ops->set_ringparam(&local->hw, tx, rx);
813 trace_drv_return_int(local, ret);
814
815 return ret;
816}
817
818static inline void drv_get_ringparam(struct ieee80211_local *local,
819 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
820{
821 might_sleep();
822
823 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
824 if (local->ops->get_ringparam)
825 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
826 trace_drv_return_void(local);
827}
828
Vivek Natarajane8306f92011-04-06 11:41:10 +0530829static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
830{
831 bool ret = false;
832
833 might_sleep();
834
835 trace_drv_tx_frames_pending(local);
836 if (local->ops->tx_frames_pending)
837 ret = local->ops->tx_frames_pending(&local->hw);
838 trace_drv_return_bool(local, ret);
839
840 return ret;
841}
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530842
843static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
844 struct ieee80211_sub_if_data *sdata,
845 const struct cfg80211_bitrate_mask *mask)
846{
847 int ret = -EOPNOTSUPP;
848
849 might_sleep();
850
Johannes Berg7b7eab62011-11-03 14:41:13 +0100851 check_sdata_in_driver(sdata);
852
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530853 trace_drv_set_bitrate_mask(local, sdata, mask);
854 if (local->ops->set_bitrate_mask)
855 ret = local->ops->set_bitrate_mask(&local->hw,
856 &sdata->vif, mask);
857 trace_drv_return_int(local, ret);
858
859 return ret;
860}
861
Johannes Bergc68f4b82011-07-05 16:35:41 +0200862static inline void drv_set_rekey_data(struct ieee80211_local *local,
863 struct ieee80211_sub_if_data *sdata,
864 struct cfg80211_gtk_rekey_data *data)
865{
Johannes Berg7b7eab62011-11-03 14:41:13 +0100866 check_sdata_in_driver(sdata);
867
Johannes Bergc68f4b82011-07-05 16:35:41 +0200868 trace_drv_set_rekey_data(local, sdata, data);
869 if (local->ops->set_rekey_data)
870 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
871 trace_drv_return_void(local);
872}
873
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700874static inline void drv_rssi_callback(struct ieee80211_local *local,
Emmanuel Grumbach887da912013-01-20 17:32:41 +0200875 struct ieee80211_sub_if_data *sdata,
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700876 const enum ieee80211_rssi_event event)
877{
Emmanuel Grumbach887da912013-01-20 17:32:41 +0200878 trace_drv_rssi_callback(local, sdata, event);
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700879 if (local->ops->rssi_callback)
Emmanuel Grumbach887da912013-01-20 17:32:41 +0200880 local->ops->rssi_callback(&local->hw, &sdata->vif, event);
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700881 trace_drv_return_void(local);
882}
Johannes Berg4049e092011-09-29 16:04:32 +0200883
884static inline void
885drv_release_buffered_frames(struct ieee80211_local *local,
886 struct sta_info *sta, u16 tids, int num_frames,
887 enum ieee80211_frame_release_type reason,
888 bool more_data)
889{
890 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
891 reason, more_data);
892 if (local->ops->release_buffered_frames)
893 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
894 num_frames, reason,
895 more_data);
896 trace_drv_return_void(local);
897}
Johannes Berg40b96402011-09-29 16:04:38 +0200898
899static inline void
900drv_allow_buffered_frames(struct ieee80211_local *local,
901 struct sta_info *sta, u16 tids, int num_frames,
902 enum ieee80211_frame_release_type reason,
903 bool more_data)
904{
905 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
906 reason, more_data);
907 if (local->ops->allow_buffered_frames)
908 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
909 tids, num_frames, reason,
910 more_data);
911 trace_drv_return_void(local);
912}
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300913
914static inline int drv_get_rssi(struct ieee80211_local *local,
915 struct ieee80211_sub_if_data *sdata,
916 struct ieee80211_sta *sta,
917 s8 *rssi_dbm)
918{
919 int ret;
920
921 might_sleep();
922
923 ret = local->ops->get_rssi(&local->hw, &sdata->vif, sta, rssi_dbm);
924 trace_drv_get_rssi(local, sta, *rssi_dbm, ret);
925
926 return ret;
927}
Johannes Berga1845fc2012-06-27 13:18:36 +0200928
929static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
930 struct ieee80211_sub_if_data *sdata)
931{
932 might_sleep();
933
934 check_sdata_in_driver(sdata);
935 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
936
937 trace_drv_mgd_prepare_tx(local, sdata);
938 if (local->ops->mgd_prepare_tx)
939 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
940 trace_drv_return_void(local);
941}
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200942
943static inline int drv_add_chanctx(struct ieee80211_local *local,
944 struct ieee80211_chanctx *ctx)
945{
946 int ret = -EOPNOTSUPP;
947
948 trace_drv_add_chanctx(local, ctx);
949 if (local->ops->add_chanctx)
950 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
951 trace_drv_return_int(local, ret);
Johannes Berg8a61af62012-12-13 17:42:30 +0100952 if (!ret)
953 ctx->driver_present = true;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200954
955 return ret;
956}
957
958static inline void drv_remove_chanctx(struct ieee80211_local *local,
959 struct ieee80211_chanctx *ctx)
960{
961 trace_drv_remove_chanctx(local, ctx);
962 if (local->ops->remove_chanctx)
963 local->ops->remove_chanctx(&local->hw, &ctx->conf);
964 trace_drv_return_void(local);
Johannes Berg8a61af62012-12-13 17:42:30 +0100965 ctx->driver_present = false;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200966}
967
968static inline void drv_change_chanctx(struct ieee80211_local *local,
969 struct ieee80211_chanctx *ctx,
970 u32 changed)
971{
972 trace_drv_change_chanctx(local, ctx, changed);
Johannes Berg8a61af62012-12-13 17:42:30 +0100973 if (local->ops->change_chanctx) {
974 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200975 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
Johannes Berg8a61af62012-12-13 17:42:30 +0100976 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200977 trace_drv_return_void(local);
978}
979
980static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
981 struct ieee80211_sub_if_data *sdata,
982 struct ieee80211_chanctx *ctx)
983{
984 int ret = 0;
985
986 check_sdata_in_driver(sdata);
987
988 trace_drv_assign_vif_chanctx(local, sdata, ctx);
Johannes Berg8a61af62012-12-13 17:42:30 +0100989 if (local->ops->assign_vif_chanctx) {
990 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200991 ret = local->ops->assign_vif_chanctx(&local->hw,
992 &sdata->vif,
993 &ctx->conf);
Johannes Berg8a61af62012-12-13 17:42:30 +0100994 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200995 trace_drv_return_int(local, ret);
996
997 return ret;
998}
999
1000static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
1001 struct ieee80211_sub_if_data *sdata,
1002 struct ieee80211_chanctx *ctx)
1003{
1004 check_sdata_in_driver(sdata);
1005
1006 trace_drv_unassign_vif_chanctx(local, sdata, ctx);
Johannes Berg8a61af62012-12-13 17:42:30 +01001007 if (local->ops->unassign_vif_chanctx) {
1008 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +02001009 local->ops->unassign_vif_chanctx(&local->hw,
1010 &sdata->vif,
1011 &ctx->conf);
Johannes Berg8a61af62012-12-13 17:42:30 +01001012 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +02001013 trace_drv_return_void(local);
1014}
1015
Johannes Berg10416382012-10-19 15:44:42 +02001016static inline int drv_start_ap(struct ieee80211_local *local,
1017 struct ieee80211_sub_if_data *sdata)
1018{
1019 int ret = 0;
1020
1021 check_sdata_in_driver(sdata);
1022
1023 trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
1024 if (local->ops->start_ap)
1025 ret = local->ops->start_ap(&local->hw, &sdata->vif);
1026 trace_drv_return_int(local, ret);
1027 return ret;
1028}
1029
1030static inline void drv_stop_ap(struct ieee80211_local *local,
1031 struct ieee80211_sub_if_data *sdata)
1032{
1033 check_sdata_in_driver(sdata);
1034
1035 trace_drv_stop_ap(local, sdata);
1036 if (local->ops->stop_ap)
1037 local->ops->stop_ap(&local->hw, &sdata->vif);
1038 trace_drv_return_void(local);
1039}
1040
Johannes Berg9214ad72012-11-06 19:18:13 +01001041static inline void drv_restart_complete(struct ieee80211_local *local)
1042{
1043 might_sleep();
1044
1045 trace_drv_restart_complete(local);
1046 if (local->ops->restart_complete)
1047 local->ops->restart_complete(&local->hw);
1048 trace_drv_return_void(local);
1049}
1050
Yoni Divinskyde5fad82012-05-30 11:36:39 +03001051static inline void
1052drv_set_default_unicast_key(struct ieee80211_local *local,
1053 struct ieee80211_sub_if_data *sdata,
1054 int key_idx)
1055{
1056 check_sdata_in_driver(sdata);
1057
1058 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1059
1060 trace_drv_set_default_unicast_key(local, sdata, key_idx);
1061 if (local->ops->set_default_unicast_key)
1062 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1063 key_idx);
1064 trace_drv_return_void(local);
1065}
1066
Johannes Berga65240c2013-01-14 15:14:34 +01001067#if IS_ENABLED(CONFIG_IPV6)
1068static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1069 struct ieee80211_sub_if_data *sdata,
1070 struct inet6_dev *idev)
1071{
1072 trace_drv_ipv6_addr_change(local, sdata);
1073 if (local->ops->ipv6_addr_change)
1074 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1075 trace_drv_return_void(local);
1076}
1077#endif
1078
Simon Wunderlich73da7d52013-07-11 16:09:06 +02001079static inline void
1080drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1081 struct cfg80211_chan_def *chandef)
1082{
1083 struct ieee80211_local *local = sdata->local;
1084
1085 if (local->ops->channel_switch_beacon) {
1086 trace_drv_channel_switch_beacon(local, sdata, chandef);
1087 local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1088 chandef);
1089 }
1090}
1091
Johannes Berg55fff502013-08-19 18:48:41 +02001092static inline int drv_join_ibss(struct ieee80211_local *local,
1093 struct ieee80211_sub_if_data *sdata)
1094{
1095 int ret = 0;
1096
1097 might_sleep();
1098 check_sdata_in_driver(sdata);
1099
1100 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1101 if (local->ops->join_ibss)
1102 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1103 trace_drv_return_int(local, ret);
1104 return ret;
1105}
1106
1107static inline void drv_leave_ibss(struct ieee80211_local *local,
1108 struct ieee80211_sub_if_data *sdata)
1109{
1110 might_sleep();
1111 check_sdata_in_driver(sdata);
1112
1113 trace_drv_leave_ibss(local, sdata);
1114 if (local->ops->leave_ibss)
1115 local->ops->leave_ibss(&local->hw, &sdata->vif);
1116 trace_drv_return_void(local);
1117}
1118
Johannes Berg24487982009-04-23 18:52:52 +02001119#endif /* __MAC80211_DRIVER_OPS */