blob: ee56d0779d8bdea4b5374ce5d0749cbbe1a88937 [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
244static inline void drv_configure_filter(struct ieee80211_local *local,
245 unsigned int changed_flags,
246 unsigned int *total_flags,
247 u64 multicast)
248{
249 might_sleep();
250
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200251 trace_drv_configure_filter(local, changed_flags, total_flags,
Johannes Berg3ac64be2009-08-17 16:16:53 +0200252 multicast);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200253 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
254 multicast);
255 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200256}
257
258static inline int drv_set_tim(struct ieee80211_local *local,
259 struct ieee80211_sta *sta, bool set)
260{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200261 int ret = 0;
Johannes Berg4efc76b2010-06-10 10:56:20 +0200262 trace_drv_set_tim(local, sta, set);
Johannes Berg24487982009-04-23 18:52:52 +0200263 if (local->ops->set_tim)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200264 ret = local->ops->set_tim(&local->hw, sta, set);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200265 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200266 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200267}
268
269static inline int drv_set_key(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100270 enum set_key_cmd cmd,
271 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200272 struct ieee80211_sta *sta,
273 struct ieee80211_key_conf *key)
274{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100275 int ret;
276
277 might_sleep();
278
Johannes Berg077f4932012-01-20 13:55:18 +0100279 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100280 check_sdata_in_driver(sdata);
281
Johannes Berg4efc76b2010-06-10 10:56:20 +0200282 trace_drv_set_key(local, cmd, sdata, sta, key);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100283 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200284 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200285 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200286}
287
288static inline void drv_update_tkip_key(struct ieee80211_local *local,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100289 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200290 struct ieee80211_key_conf *conf,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100291 struct sta_info *sta, u32 iv32,
Johannes Berg24487982009-04-23 18:52:52 +0200292 u16 *phase1key)
293{
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100294 struct ieee80211_sta *ista = NULL;
295
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100296 if (sta)
297 ista = &sta->sta;
298
Johannes Berg077f4932012-01-20 13:55:18 +0100299 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100300 check_sdata_in_driver(sdata);
301
Johannes Berg4efc76b2010-06-10 10:56:20 +0200302 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
Johannes Berg24487982009-04-23 18:52:52 +0200303 if (local->ops->update_tkip_key)
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100304 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
305 ista, iv32, phase1key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200306 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200307}
308
309static inline int drv_hw_scan(struct ieee80211_local *local,
Johannes Berga060bbf2010-04-27 11:59:34 +0200310 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200311 struct cfg80211_scan_request *req)
312{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100313 int ret;
314
315 might_sleep();
316
Johannes Berg7b7eab62011-11-03 14:41:13 +0100317 check_sdata_in_driver(sdata);
318
Luciano Coelho79f460c2011-05-11 17:09:36 +0300319 trace_drv_hw_scan(local, sdata);
Johannes Berga060bbf2010-04-27 11:59:34 +0200320 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200321 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200322 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200323}
324
Eliad Pellerb8564392011-06-13 12:47:30 +0300325static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
326 struct ieee80211_sub_if_data *sdata)
327{
328 might_sleep();
329
Johannes Berg7b7eab62011-11-03 14:41:13 +0100330 check_sdata_in_driver(sdata);
331
Eliad Pellerb8564392011-06-13 12:47:30 +0300332 trace_drv_cancel_hw_scan(local, sdata);
333 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
334 trace_drv_return_void(local);
335}
336
Luciano Coelho79f460c2011-05-11 17:09:36 +0300337static inline int
338drv_sched_scan_start(struct ieee80211_local *local,
339 struct ieee80211_sub_if_data *sdata,
340 struct cfg80211_sched_scan_request *req,
341 struct ieee80211_sched_scan_ies *ies)
342{
343 int ret;
344
345 might_sleep();
346
Johannes Berg7b7eab62011-11-03 14:41:13 +0100347 check_sdata_in_driver(sdata);
348
Luciano Coelho79f460c2011-05-11 17:09:36 +0300349 trace_drv_sched_scan_start(local, sdata);
350 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
351 req, ies);
352 trace_drv_return_int(local, ret);
353 return ret;
354}
355
356static inline void drv_sched_scan_stop(struct ieee80211_local *local,
357 struct ieee80211_sub_if_data *sdata)
358{
359 might_sleep();
360
Johannes Berg7b7eab62011-11-03 14:41:13 +0100361 check_sdata_in_driver(sdata);
362
Luciano Coelho79f460c2011-05-11 17:09:36 +0300363 trace_drv_sched_scan_stop(local, sdata);
364 local->ops->sched_scan_stop(&local->hw, &sdata->vif);
365 trace_drv_return_void(local);
366}
367
Johannes Berg24487982009-04-23 18:52:52 +0200368static inline void drv_sw_scan_start(struct ieee80211_local *local)
369{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100370 might_sleep();
371
Johannes Berg4efc76b2010-06-10 10:56:20 +0200372 trace_drv_sw_scan_start(local);
Johannes Berg24487982009-04-23 18:52:52 +0200373 if (local->ops->sw_scan_start)
374 local->ops->sw_scan_start(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200375 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200376}
377
378static inline void drv_sw_scan_complete(struct ieee80211_local *local)
379{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100380 might_sleep();
381
Johannes Berg4efc76b2010-06-10 10:56:20 +0200382 trace_drv_sw_scan_complete(local);
Johannes Berg24487982009-04-23 18:52:52 +0200383 if (local->ops->sw_scan_complete)
384 local->ops->sw_scan_complete(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200385 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200386}
387
388static inline int drv_get_stats(struct ieee80211_local *local,
389 struct ieee80211_low_level_stats *stats)
390{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200391 int ret = -EOPNOTSUPP;
392
Kalle Valoe1781ed2009-12-23 13:15:47 +0100393 might_sleep();
394
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200395 if (local->ops->get_stats)
396 ret = local->ops->get_stats(&local->hw, stats);
397 trace_drv_get_stats(local, stats, ret);
398
399 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200400}
401
402static inline void drv_get_tkip_seq(struct ieee80211_local *local,
403 u8 hw_key_idx, u32 *iv32, u16 *iv16)
404{
405 if (local->ops->get_tkip_seq)
406 local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200407 trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
Johannes Berg24487982009-04-23 18:52:52 +0200408}
409
Arik Nemtsovf23a4782010-11-08 11:51:06 +0200410static inline int drv_set_frag_threshold(struct ieee80211_local *local,
411 u32 value)
412{
413 int ret = 0;
414
415 might_sleep();
416
417 trace_drv_set_frag_threshold(local, value);
418 if (local->ops->set_frag_threshold)
419 ret = local->ops->set_frag_threshold(&local->hw, value);
420 trace_drv_return_int(local, ret);
421 return ret;
422}
423
Johannes Berg24487982009-04-23 18:52:52 +0200424static inline int drv_set_rts_threshold(struct ieee80211_local *local,
425 u32 value)
426{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200427 int ret = 0;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100428
429 might_sleep();
430
Johannes Berg4efc76b2010-06-10 10:56:20 +0200431 trace_drv_set_rts_threshold(local, value);
Johannes Berg24487982009-04-23 18:52:52 +0200432 if (local->ops->set_rts_threshold)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200433 ret = local->ops->set_rts_threshold(&local->hw, value);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200434 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200435 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200436}
437
Lukáš Turek310bc672009-12-21 22:50:48 +0100438static inline int drv_set_coverage_class(struct ieee80211_local *local,
439 u8 value)
440{
441 int ret = 0;
442 might_sleep();
443
Johannes Berg4efc76b2010-06-10 10:56:20 +0200444 trace_drv_set_coverage_class(local, value);
Lukáš Turek310bc672009-12-21 22:50:48 +0100445 if (local->ops->set_coverage_class)
446 local->ops->set_coverage_class(&local->hw, value);
447 else
448 ret = -EOPNOTSUPP;
449
Johannes Berg4efc76b2010-06-10 10:56:20 +0200450 trace_drv_return_int(local, ret);
Lukáš Turek310bc672009-12-21 22:50:48 +0100451 return ret;
452}
453
Johannes Berg24487982009-04-23 18:52:52 +0200454static inline void drv_sta_notify(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100455 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200456 enum sta_notify_cmd cmd,
457 struct ieee80211_sta *sta)
458{
Felix Fietkaubc192f82011-11-23 21:09:49 +0700459 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100460 check_sdata_in_driver(sdata);
461
Johannes Berg4efc76b2010-06-10 10:56:20 +0200462 trace_drv_sta_notify(local, sdata, cmd, sta);
Johannes Berg24487982009-04-23 18:52:52 +0200463 if (local->ops->sta_notify)
Johannes Berg12375ef2009-11-25 20:30:31 +0100464 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200465 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200466}
467
Johannes Berg34e89502010-02-03 13:59:58 +0100468static inline int drv_sta_add(struct ieee80211_local *local,
469 struct ieee80211_sub_if_data *sdata,
470 struct ieee80211_sta *sta)
471{
472 int ret = 0;
473
474 might_sleep();
475
Felix Fietkaubc192f82011-11-23 21:09:49 +0700476 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100477 check_sdata_in_driver(sdata);
478
Johannes Berg4efc76b2010-06-10 10:56:20 +0200479 trace_drv_sta_add(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100480 if (local->ops->sta_add)
481 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100482
Johannes Berg4efc76b2010-06-10 10:56:20 +0200483 trace_drv_return_int(local, ret);
Johannes Berg34e89502010-02-03 13:59:58 +0100484
485 return ret;
486}
487
488static inline void drv_sta_remove(struct ieee80211_local *local,
489 struct ieee80211_sub_if_data *sdata,
490 struct ieee80211_sta *sta)
491{
492 might_sleep();
493
Felix Fietkaubc192f82011-11-23 21:09:49 +0700494 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100495 check_sdata_in_driver(sdata);
496
Johannes Berg4efc76b2010-06-10 10:56:20 +0200497 trace_drv_sta_remove(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100498 if (local->ops->sta_remove)
499 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100500
Johannes Berg4efc76b2010-06-10 10:56:20 +0200501 trace_drv_return_void(local);
Johannes Berg34e89502010-02-03 13:59:58 +0100502}
503
Sujith Manoharan77d2ece2012-11-20 08:46:02 +0530504#ifdef CONFIG_MAC80211_DEBUGFS
505static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
506 struct ieee80211_sub_if_data *sdata,
507 struct ieee80211_sta *sta,
508 struct dentry *dir)
509{
510 might_sleep();
511
512 sdata = get_bss_sdata(sdata);
513 check_sdata_in_driver(sdata);
514
515 if (local->ops->sta_add_debugfs)
516 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
517 sta, dir);
518}
519
520static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
521 struct ieee80211_sub_if_data *sdata,
522 struct ieee80211_sta *sta,
523 struct dentry *dir)
524{
525 might_sleep();
526
527 sdata = get_bss_sdata(sdata);
528 check_sdata_in_driver(sdata);
529
530 if (local->ops->sta_remove_debugfs)
531 local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
532 sta, dir);
533}
Alexander Bondarb207cdb2012-12-22 10:43:33 +0200534
535static inline
536void drv_add_interface_debugfs(struct ieee80211_local *local,
537 struct ieee80211_sub_if_data *sdata)
538{
539 might_sleep();
540
541 check_sdata_in_driver(sdata);
542
543 if (!local->ops->add_interface_debugfs)
544 return;
545
546 local->ops->add_interface_debugfs(&local->hw, &sdata->vif,
547 sdata->debugfs.dir);
548}
549
550static inline
551void drv_remove_interface_debugfs(struct ieee80211_local *local,
552 struct ieee80211_sub_if_data *sdata)
553{
554 might_sleep();
555
556 check_sdata_in_driver(sdata);
557
558 if (!local->ops->remove_interface_debugfs)
559 return;
560
561 local->ops->remove_interface_debugfs(&local->hw, &sdata->vif,
562 sdata->debugfs.dir);
563}
564#else
565static inline
566void drv_add_interface_debugfs(struct ieee80211_local *local,
567 struct ieee80211_sub_if_data *sdata) {}
568static inline
569void drv_remove_interface_debugfs(struct ieee80211_local *local,
570 struct ieee80211_sub_if_data *sdata) {}
Sujith Manoharan77d2ece2012-11-20 08:46:02 +0530571#endif
572
Johannes Bergf09603a2012-01-20 13:55:21 +0100573static inline __must_check
574int drv_sta_state(struct ieee80211_local *local,
575 struct ieee80211_sub_if_data *sdata,
576 struct sta_info *sta,
577 enum ieee80211_sta_state old_state,
578 enum ieee80211_sta_state new_state)
579{
580 int ret = 0;
581
582 might_sleep();
583
584 sdata = get_bss_sdata(sdata);
585 check_sdata_in_driver(sdata);
586
587 trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
Johannes Berga4ec45a2012-01-20 13:55:22 +0100588 if (local->ops->sta_state) {
Johannes Bergf09603a2012-01-20 13:55:21 +0100589 ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta,
590 old_state, new_state);
Johannes Berga4ec45a2012-01-20 13:55:22 +0100591 } else if (old_state == IEEE80211_STA_AUTH &&
592 new_state == IEEE80211_STA_ASSOC) {
593 ret = drv_sta_add(local, sdata, &sta->sta);
594 if (ret == 0)
595 sta->uploaded = true;
596 } else if (old_state == IEEE80211_STA_ASSOC &&
597 new_state == IEEE80211_STA_AUTH) {
598 drv_sta_remove(local, sdata, &sta->sta);
599 }
Johannes Bergf09603a2012-01-20 13:55:21 +0100600 trace_drv_return_int(local, ret);
601 return ret;
602}
603
Johannes Berg8f727ef2012-03-30 08:43:32 +0200604static inline void drv_sta_rc_update(struct ieee80211_local *local,
605 struct ieee80211_sub_if_data *sdata,
606 struct ieee80211_sta *sta, u32 changed)
607{
608 sdata = get_bss_sdata(sdata);
609 check_sdata_in_driver(sdata);
610
Antonio Quartullie687f612012-08-12 18:24:55 +0200611 WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED &&
Thomas Pedersenf68d7762013-01-23 12:18:13 -0800612 (sdata->vif.type != NL80211_IFTYPE_ADHOC &&
613 sdata->vif.type != NL80211_IFTYPE_MESH_POINT));
Antonio Quartullie687f612012-08-12 18:24:55 +0200614
Johannes Berg8f727ef2012-03-30 08:43:32 +0200615 trace_drv_sta_rc_update(local, sdata, sta, changed);
616 if (local->ops->sta_rc_update)
617 local->ops->sta_rc_update(&local->hw, &sdata->vif,
618 sta, changed);
619
620 trace_drv_return_void(local);
621}
622
Eliad Pellerf6f3def2011-09-25 20:06:54 +0300623static inline int drv_conf_tx(struct ieee80211_local *local,
Johannes Berga3304b02012-03-28 11:04:24 +0200624 struct ieee80211_sub_if_data *sdata, u16 ac,
Johannes Berg24487982009-04-23 18:52:52 +0200625 const struct ieee80211_tx_queue_params *params)
626{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200627 int ret = -EOPNOTSUPP;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100628
629 might_sleep();
630
Johannes Berg7b7eab62011-11-03 14:41:13 +0100631 check_sdata_in_driver(sdata);
632
Johannes Berga3304b02012-03-28 11:04:24 +0200633 trace_drv_conf_tx(local, sdata, ac, params);
Johannes Berg24487982009-04-23 18:52:52 +0200634 if (local->ops->conf_tx)
Eliad Peller8a3a3c82011-10-02 10:15:52 +0200635 ret = local->ops->conf_tx(&local->hw, &sdata->vif,
Johannes Berga3304b02012-03-28 11:04:24 +0200636 ac, params);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200637 trace_drv_return_int(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 u64 drv_get_tsf(struct ieee80211_local *local,
642 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200643{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200644 u64 ret = -1ULL;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100645
646 might_sleep();
647
Johannes Berg7b7eab62011-11-03 14:41:13 +0100648 check_sdata_in_driver(sdata);
649
Eliad Peller37a41b42011-09-21 14:06:11 +0300650 trace_drv_get_tsf(local, sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200651 if (local->ops->get_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300652 ret = local->ops->get_tsf(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200653 trace_drv_return_u64(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200654 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200655}
656
Eliad Peller37a41b42011-09-21 14:06:11 +0300657static inline void drv_set_tsf(struct ieee80211_local *local,
658 struct ieee80211_sub_if_data *sdata,
659 u64 tsf)
Johannes Berg24487982009-04-23 18:52:52 +0200660{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100661 might_sleep();
662
Johannes Berg7b7eab62011-11-03 14:41:13 +0100663 check_sdata_in_driver(sdata);
664
Eliad Peller37a41b42011-09-21 14:06:11 +0300665 trace_drv_set_tsf(local, sdata, tsf);
Johannes Berg24487982009-04-23 18:52:52 +0200666 if (local->ops->set_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300667 local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200668 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200669}
670
Eliad Peller37a41b42011-09-21 14:06:11 +0300671static inline void drv_reset_tsf(struct ieee80211_local *local,
672 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200673{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100674 might_sleep();
675
Johannes Berg7b7eab62011-11-03 14:41:13 +0100676 check_sdata_in_driver(sdata);
677
Eliad Peller37a41b42011-09-21 14:06:11 +0300678 trace_drv_reset_tsf(local, sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200679 if (local->ops->reset_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300680 local->ops->reset_tsf(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200681 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200682}
683
684static inline int drv_tx_last_beacon(struct ieee80211_local *local)
685{
Masanari Iida02582e92012-08-22 19:11:26 +0900686 int ret = 0; /* default unsupported op for less congestion */
Kalle Valoe1781ed2009-12-23 13:15:47 +0100687
688 might_sleep();
689
Johannes Berg4efc76b2010-06-10 10:56:20 +0200690 trace_drv_tx_last_beacon(local);
Johannes Berg24487982009-04-23 18:52:52 +0200691 if (local->ops->tx_last_beacon)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200692 ret = local->ops->tx_last_beacon(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200693 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200694 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200695}
696
697static inline int drv_ampdu_action(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100698 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200699 enum ieee80211_ampdu_mlme_action action,
700 struct ieee80211_sta *sta, u16 tid,
Johannes Berg0b01f032011-01-18 13:51:05 +0100701 u16 *ssn, u8 buf_size)
Johannes Berg24487982009-04-23 18:52:52 +0200702{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200703 int ret = -EOPNOTSUPP;
Johannes Bergcfcdbde2010-06-10 10:21:48 +0200704
705 might_sleep();
706
Felix Fietkaubc192f82011-11-23 21:09:49 +0700707 sdata = get_bss_sdata(sdata);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100708 check_sdata_in_driver(sdata);
709
Johannes Berg0b01f032011-01-18 13:51:05 +0100710 trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200711
Johannes Berg24487982009-04-23 18:52:52 +0200712 if (local->ops->ampdu_action)
Johannes Berg12375ef2009-11-25 20:30:31 +0100713 ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
Johannes Berg0b01f032011-01-18 13:51:05 +0100714 sta, tid, ssn, buf_size);
Johannes Berg85ad1812010-06-10 10:21:49 +0200715
Johannes Berg4efc76b2010-06-10 10:56:20 +0200716 trace_drv_return_int(local, ret);
717
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200718 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200719}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200720
Holger Schurig12897232010-04-19 10:23:57 +0200721static inline int drv_get_survey(struct ieee80211_local *local, int idx,
722 struct survey_info *survey)
723{
724 int ret = -EOPNOTSUPP;
John W. Linvillec466d4e2010-06-29 14:51:23 -0400725
726 trace_drv_get_survey(local, idx, survey);
727
Holger Schurig35dd0502010-06-07 16:33:49 +0200728 if (local->ops->get_survey)
Holger Schurig12897232010-04-19 10:23:57 +0200729 ret = local->ops->get_survey(&local->hw, idx, survey);
John W. Linvillec466d4e2010-06-29 14:51:23 -0400730
731 trace_drv_return_int(local, ret);
732
Holger Schurig12897232010-04-19 10:23:57 +0200733 return ret;
734}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200735
736static inline void drv_rfkill_poll(struct ieee80211_local *local)
737{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100738 might_sleep();
739
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200740 if (local->ops->rfkill_poll)
741 local->ops->rfkill_poll(&local->hw);
742}
Johannes Berga80f7c02009-12-23 13:15:32 +0100743
744static inline void drv_flush(struct ieee80211_local *local, bool drop)
745{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100746 might_sleep();
747
Johannes Berga80f7c02009-12-23 13:15:32 +0100748 trace_drv_flush(local, drop);
749 if (local->ops->flush)
750 local->ops->flush(&local->hw, drop);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200751 trace_drv_return_void(local);
Johannes Berga80f7c02009-12-23 13:15:32 +0100752}
Johannes Berg5ce6e432010-05-11 16:20:57 +0200753
754static inline void drv_channel_switch(struct ieee80211_local *local,
755 struct ieee80211_channel_switch *ch_switch)
756{
757 might_sleep();
758
Johannes Berg5ce6e432010-05-11 16:20:57 +0200759 trace_drv_channel_switch(local, ch_switch);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200760 local->ops->channel_switch(&local->hw, ch_switch);
761 trace_drv_return_void(local);
Johannes Berg5ce6e432010-05-11 16:20:57 +0200762}
763
Bruno Randolf15d96752010-11-10 12:50:56 +0900764
765static inline int drv_set_antenna(struct ieee80211_local *local,
766 u32 tx_ant, u32 rx_ant)
767{
768 int ret = -EOPNOTSUPP;
769 might_sleep();
770 if (local->ops->set_antenna)
771 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
772 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
773 return ret;
774}
775
776static inline int drv_get_antenna(struct ieee80211_local *local,
777 u32 *tx_ant, u32 *rx_ant)
778{
779 int ret = -EOPNOTSUPP;
780 might_sleep();
781 if (local->ops->get_antenna)
782 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
783 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
784 return ret;
785}
786
Johannes Berg21f83582010-12-18 17:20:47 +0100787static inline int drv_remain_on_channel(struct ieee80211_local *local,
Eliad Peller49884562012-11-19 17:05:09 +0200788 struct ieee80211_sub_if_data *sdata,
Johannes Berg21f83582010-12-18 17:20:47 +0100789 struct ieee80211_channel *chan,
Johannes Berg21f83582010-12-18 17:20:47 +0100790 unsigned int duration)
791{
792 int ret;
793
794 might_sleep();
795
Johannes Berg42d97a52012-11-08 18:31:02 +0100796 trace_drv_remain_on_channel(local, sdata, chan, duration);
Eliad Peller49884562012-11-19 17:05:09 +0200797 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
Johannes Berg42d97a52012-11-08 18:31:02 +0100798 chan, duration);
Johannes Berg21f83582010-12-18 17:20:47 +0100799 trace_drv_return_int(local, ret);
800
801 return ret;
802}
803
804static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
805{
806 int ret;
807
808 might_sleep();
809
810 trace_drv_cancel_remain_on_channel(local);
811 ret = local->ops->cancel_remain_on_channel(&local->hw);
812 trace_drv_return_int(local, ret);
813
814 return ret;
815}
816
John W. Linville38c09152011-03-07 16:19:18 -0500817static inline int drv_set_ringparam(struct ieee80211_local *local,
818 u32 tx, u32 rx)
819{
820 int ret = -ENOTSUPP;
821
822 might_sleep();
823
824 trace_drv_set_ringparam(local, tx, rx);
825 if (local->ops->set_ringparam)
826 ret = local->ops->set_ringparam(&local->hw, tx, rx);
827 trace_drv_return_int(local, ret);
828
829 return ret;
830}
831
832static inline void drv_get_ringparam(struct ieee80211_local *local,
833 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
834{
835 might_sleep();
836
837 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
838 if (local->ops->get_ringparam)
839 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
840 trace_drv_return_void(local);
841}
842
Vivek Natarajane8306f92011-04-06 11:41:10 +0530843static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
844{
845 bool ret = false;
846
847 might_sleep();
848
849 trace_drv_tx_frames_pending(local);
850 if (local->ops->tx_frames_pending)
851 ret = local->ops->tx_frames_pending(&local->hw);
852 trace_drv_return_bool(local, ret);
853
854 return ret;
855}
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530856
857static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
858 struct ieee80211_sub_if_data *sdata,
859 const struct cfg80211_bitrate_mask *mask)
860{
861 int ret = -EOPNOTSUPP;
862
863 might_sleep();
864
Johannes Berg7b7eab62011-11-03 14:41:13 +0100865 check_sdata_in_driver(sdata);
866
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530867 trace_drv_set_bitrate_mask(local, sdata, mask);
868 if (local->ops->set_bitrate_mask)
869 ret = local->ops->set_bitrate_mask(&local->hw,
870 &sdata->vif, mask);
871 trace_drv_return_int(local, ret);
872
873 return ret;
874}
875
Johannes Bergc68f4b82011-07-05 16:35:41 +0200876static inline void drv_set_rekey_data(struct ieee80211_local *local,
877 struct ieee80211_sub_if_data *sdata,
878 struct cfg80211_gtk_rekey_data *data)
879{
Johannes Berg7b7eab62011-11-03 14:41:13 +0100880 check_sdata_in_driver(sdata);
881
Johannes Bergc68f4b82011-07-05 16:35:41 +0200882 trace_drv_set_rekey_data(local, sdata, data);
883 if (local->ops->set_rekey_data)
884 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
885 trace_drv_return_void(local);
886}
887
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700888static inline void drv_rssi_callback(struct ieee80211_local *local,
Emmanuel Grumbach887da912013-01-20 17:32:41 +0200889 struct ieee80211_sub_if_data *sdata,
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700890 const enum ieee80211_rssi_event event)
891{
Emmanuel Grumbach887da912013-01-20 17:32:41 +0200892 trace_drv_rssi_callback(local, sdata, event);
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700893 if (local->ops->rssi_callback)
Emmanuel Grumbach887da912013-01-20 17:32:41 +0200894 local->ops->rssi_callback(&local->hw, &sdata->vif, event);
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700895 trace_drv_return_void(local);
896}
Johannes Berg4049e092011-09-29 16:04:32 +0200897
898static inline void
899drv_release_buffered_frames(struct ieee80211_local *local,
900 struct sta_info *sta, u16 tids, int num_frames,
901 enum ieee80211_frame_release_type reason,
902 bool more_data)
903{
904 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
905 reason, more_data);
906 if (local->ops->release_buffered_frames)
907 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
908 num_frames, reason,
909 more_data);
910 trace_drv_return_void(local);
911}
Johannes Berg40b96402011-09-29 16:04:38 +0200912
913static inline void
914drv_allow_buffered_frames(struct ieee80211_local *local,
915 struct sta_info *sta, u16 tids, int num_frames,
916 enum ieee80211_frame_release_type reason,
917 bool more_data)
918{
919 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
920 reason, more_data);
921 if (local->ops->allow_buffered_frames)
922 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
923 tids, num_frames, reason,
924 more_data);
925 trace_drv_return_void(local);
926}
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300927
928static inline int drv_get_rssi(struct ieee80211_local *local,
929 struct ieee80211_sub_if_data *sdata,
930 struct ieee80211_sta *sta,
931 s8 *rssi_dbm)
932{
933 int ret;
934
935 might_sleep();
936
937 ret = local->ops->get_rssi(&local->hw, &sdata->vif, sta, rssi_dbm);
938 trace_drv_get_rssi(local, sta, *rssi_dbm, ret);
939
940 return ret;
941}
Johannes Berga1845fc2012-06-27 13:18:36 +0200942
943static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
944 struct ieee80211_sub_if_data *sdata)
945{
946 might_sleep();
947
948 check_sdata_in_driver(sdata);
949 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
950
951 trace_drv_mgd_prepare_tx(local, sdata);
952 if (local->ops->mgd_prepare_tx)
953 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
954 trace_drv_return_void(local);
955}
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200956
957static inline int drv_add_chanctx(struct ieee80211_local *local,
958 struct ieee80211_chanctx *ctx)
959{
960 int ret = -EOPNOTSUPP;
961
962 trace_drv_add_chanctx(local, ctx);
963 if (local->ops->add_chanctx)
964 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
965 trace_drv_return_int(local, ret);
Johannes Berg8a61af62012-12-13 17:42:30 +0100966 if (!ret)
967 ctx->driver_present = true;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200968
969 return ret;
970}
971
972static inline void drv_remove_chanctx(struct ieee80211_local *local,
973 struct ieee80211_chanctx *ctx)
974{
975 trace_drv_remove_chanctx(local, ctx);
976 if (local->ops->remove_chanctx)
977 local->ops->remove_chanctx(&local->hw, &ctx->conf);
978 trace_drv_return_void(local);
Johannes Berg8a61af62012-12-13 17:42:30 +0100979 ctx->driver_present = false;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200980}
981
982static inline void drv_change_chanctx(struct ieee80211_local *local,
983 struct ieee80211_chanctx *ctx,
984 u32 changed)
985{
986 trace_drv_change_chanctx(local, ctx, changed);
Johannes Berg8a61af62012-12-13 17:42:30 +0100987 if (local->ops->change_chanctx) {
988 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200989 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
Johannes Berg8a61af62012-12-13 17:42:30 +0100990 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200991 trace_drv_return_void(local);
992}
993
994static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
995 struct ieee80211_sub_if_data *sdata,
996 struct ieee80211_chanctx *ctx)
997{
998 int ret = 0;
999
1000 check_sdata_in_driver(sdata);
1001
1002 trace_drv_assign_vif_chanctx(local, sdata, ctx);
Johannes Berg8a61af62012-12-13 17:42:30 +01001003 if (local->ops->assign_vif_chanctx) {
1004 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +02001005 ret = local->ops->assign_vif_chanctx(&local->hw,
1006 &sdata->vif,
1007 &ctx->conf);
Johannes Berg8a61af62012-12-13 17:42:30 +01001008 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +02001009 trace_drv_return_int(local, ret);
1010
1011 return ret;
1012}
1013
1014static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
1015 struct ieee80211_sub_if_data *sdata,
1016 struct ieee80211_chanctx *ctx)
1017{
1018 check_sdata_in_driver(sdata);
1019
1020 trace_drv_unassign_vif_chanctx(local, sdata, ctx);
Johannes Berg8a61af62012-12-13 17:42:30 +01001021 if (local->ops->unassign_vif_chanctx) {
1022 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +02001023 local->ops->unassign_vif_chanctx(&local->hw,
1024 &sdata->vif,
1025 &ctx->conf);
Johannes Berg8a61af62012-12-13 17:42:30 +01001026 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +02001027 trace_drv_return_void(local);
1028}
1029
Johannes Berg10416382012-10-19 15:44:42 +02001030static inline int drv_start_ap(struct ieee80211_local *local,
1031 struct ieee80211_sub_if_data *sdata)
1032{
1033 int ret = 0;
1034
1035 check_sdata_in_driver(sdata);
1036
1037 trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
1038 if (local->ops->start_ap)
1039 ret = local->ops->start_ap(&local->hw, &sdata->vif);
1040 trace_drv_return_int(local, ret);
1041 return ret;
1042}
1043
1044static inline void drv_stop_ap(struct ieee80211_local *local,
1045 struct ieee80211_sub_if_data *sdata)
1046{
1047 check_sdata_in_driver(sdata);
1048
1049 trace_drv_stop_ap(local, sdata);
1050 if (local->ops->stop_ap)
1051 local->ops->stop_ap(&local->hw, &sdata->vif);
1052 trace_drv_return_void(local);
1053}
1054
Johannes Berg9214ad72012-11-06 19:18:13 +01001055static inline void drv_restart_complete(struct ieee80211_local *local)
1056{
1057 might_sleep();
1058
1059 trace_drv_restart_complete(local);
1060 if (local->ops->restart_complete)
1061 local->ops->restart_complete(&local->hw);
1062 trace_drv_return_void(local);
1063}
1064
Yoni Divinskyde5fad82012-05-30 11:36:39 +03001065static inline void
1066drv_set_default_unicast_key(struct ieee80211_local *local,
1067 struct ieee80211_sub_if_data *sdata,
1068 int key_idx)
1069{
1070 check_sdata_in_driver(sdata);
1071
1072 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1073
1074 trace_drv_set_default_unicast_key(local, sdata, key_idx);
1075 if (local->ops->set_default_unicast_key)
1076 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1077 key_idx);
1078 trace_drv_return_void(local);
1079}
1080
Johannes Berga65240c2013-01-14 15:14:34 +01001081#if IS_ENABLED(CONFIG_IPV6)
1082static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1083 struct ieee80211_sub_if_data *sdata,
1084 struct inet6_dev *idev)
1085{
1086 trace_drv_ipv6_addr_change(local, sdata);
1087 if (local->ops->ipv6_addr_change)
1088 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1089 trace_drv_return_void(local);
1090}
1091#endif
1092
Johannes Berg24487982009-04-23 18:52:52 +02001093#endif /* __MAC80211_DRIVER_OPS */