blob: 0baeefdd89a01446451856b2b2e0decc8fbe3713 [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 Bergf6837ba82014-04-30 14:19:04 +02008static inline bool check_sdata_in_driver(struct ieee80211_sub_if_data *sdata)
Johannes Berg7b7eab62011-11-03 14:41:13 +01009{
Johannes Bergf6837ba82014-04-30 14:19:04 +020010 return !WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER),
11 "%s: Failed check-sdata-in-driver check, flags: 0x%x\n",
12 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
Denys Vlasenko9aae2962015-09-18 15:19:38 +0200140int drv_add_interface(struct ieee80211_local *local,
141 struct ieee80211_sub_if_data *sdata);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100142
Denys Vlasenko9aae2962015-09-18 15:19:38 +0200143int drv_change_interface(struct ieee80211_local *local,
144 struct ieee80211_sub_if_data *sdata,
145 enum nl80211_iftype type, bool p2p);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100146
Denys Vlasenko9aae2962015-09-18 15:19:38 +0200147void drv_remove_interface(struct ieee80211_local *local,
148 struct ieee80211_sub_if_data *sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200149
150static inline int drv_config(struct ieee80211_local *local, u32 changed)
151{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100152 int ret;
153
154 might_sleep();
155
Johannes Berg4efc76b2010-06-10 10:56:20 +0200156 trace_drv_config(local, changed);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100157 ret = local->ops->config(&local->hw, changed);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200158 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200159 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200160}
161
162static inline void drv_bss_info_changed(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100163 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200164 struct ieee80211_bss_conf *info,
165 u32 changed)
166{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100167 might_sleep();
168
Johannes Berg5bbe754d2013-02-13 13:50:51 +0100169 if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
170 BSS_CHANGED_BEACON_ENABLED) &&
171 sdata->vif.type != NL80211_IFTYPE_AP &&
172 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
Rostislav Lisovy239281f82014-11-03 10:33:19 +0100173 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
174 sdata->vif.type != NL80211_IFTYPE_OCB))
Johannes Berg5bbe754d2013-02-13 13:50:51 +0100175 return;
176
177 if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
178 sdata->vif.type == NL80211_IFTYPE_MONITOR))
179 return;
Johannes Bergb8dc1a32012-12-14 14:22:10 +0100180
Johannes Bergf6837ba82014-04-30 14:19:04 +0200181 if (!check_sdata_in_driver(sdata))
182 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100183
Johannes Berg4efc76b2010-06-10 10:56:20 +0200184 trace_drv_bss_info_changed(local, sdata, info, changed);
Johannes Berg24487982009-04-23 18:52:52 +0200185 if (local->ops->bss_info_changed)
Johannes Berg12375ef2009-11-25 20:30:31 +0100186 local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200187 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200188}
189
Johannes Berg3ac64be2009-08-17 16:16:53 +0200190static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
Jiri Pirko22bedad32010-04-01 21:22:57 +0000191 struct netdev_hw_addr_list *mc_list)
Johannes Berg24487982009-04-23 18:52:52 +0200192{
Johannes Berg3ac64be2009-08-17 16:16:53 +0200193 u64 ret = 0;
194
Johannes Berg4efc76b2010-06-10 10:56:20 +0200195 trace_drv_prepare_multicast(local, mc_list->count);
196
Johannes Berg3ac64be2009-08-17 16:16:53 +0200197 if (local->ops->prepare_multicast)
Jiri Pirko22bedad32010-04-01 21:22:57 +0000198 ret = local->ops->prepare_multicast(&local->hw, mc_list);
Johannes Berg3ac64be2009-08-17 16:16:53 +0200199
Johannes Berg4efc76b2010-06-10 10:56:20 +0200200 trace_drv_return_u64(local, ret);
Johannes Berg3ac64be2009-08-17 16:16:53 +0200201
202 return ret;
203}
204
205static inline void drv_configure_filter(struct ieee80211_local *local,
206 unsigned int changed_flags,
207 unsigned int *total_flags,
208 u64 multicast)
209{
210 might_sleep();
211
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200212 trace_drv_configure_filter(local, changed_flags, total_flags,
Johannes Berg3ac64be2009-08-17 16:16:53 +0200213 multicast);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200214 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
215 multicast);
216 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200217}
218
Andrei Otcheretianski1b09b552015-08-15 22:39:50 +0300219static inline void drv_config_iface_filter(struct ieee80211_local *local,
220 struct ieee80211_sub_if_data *sdata,
221 unsigned int filter_flags,
222 unsigned int changed_flags)
223{
224 might_sleep();
225
226 trace_drv_config_iface_filter(local, sdata, filter_flags,
227 changed_flags);
228 if (local->ops->config_iface_filter)
229 local->ops->config_iface_filter(&local->hw, &sdata->vif,
230 filter_flags,
231 changed_flags);
232 trace_drv_return_void(local);
233}
234
Johannes Berg24487982009-04-23 18:52:52 +0200235static inline int drv_set_tim(struct ieee80211_local *local,
236 struct ieee80211_sta *sta, bool set)
237{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200238 int ret = 0;
Johannes Berg4efc76b2010-06-10 10:56:20 +0200239 trace_drv_set_tim(local, sta, set);
Johannes Berg24487982009-04-23 18:52:52 +0200240 if (local->ops->set_tim)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200241 ret = local->ops->set_tim(&local->hw, sta, set);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200242 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200243 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200244}
245
246static inline int drv_set_key(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100247 enum set_key_cmd cmd,
248 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200249 struct ieee80211_sta *sta,
250 struct ieee80211_key_conf *key)
251{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100252 int ret;
253
254 might_sleep();
255
Johannes Berg077f4932012-01-20 13:55:18 +0100256 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba82014-04-30 14:19:04 +0200257 if (!check_sdata_in_driver(sdata))
258 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100259
Johannes Berg4efc76b2010-06-10 10:56:20 +0200260 trace_drv_set_key(local, cmd, sdata, sta, key);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100261 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200262 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200263 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200264}
265
266static inline void drv_update_tkip_key(struct ieee80211_local *local,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100267 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200268 struct ieee80211_key_conf *conf,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100269 struct sta_info *sta, u32 iv32,
Johannes Berg24487982009-04-23 18:52:52 +0200270 u16 *phase1key)
271{
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100272 struct ieee80211_sta *ista = NULL;
273
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100274 if (sta)
275 ista = &sta->sta;
276
Johannes Berg077f4932012-01-20 13:55:18 +0100277 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba82014-04-30 14:19:04 +0200278 if (!check_sdata_in_driver(sdata))
279 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100280
Johannes Berg4efc76b2010-06-10 10:56:20 +0200281 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
Johannes Berg24487982009-04-23 18:52:52 +0200282 if (local->ops->update_tkip_key)
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100283 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
284 ista, iv32, phase1key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200285 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200286}
287
288static inline int drv_hw_scan(struct ieee80211_local *local,
Johannes Berga060bbf2010-04-27 11:59:34 +0200289 struct ieee80211_sub_if_data *sdata,
David Spinadelc56ef672014-02-05 15:21:13 +0200290 struct ieee80211_scan_request *req)
Johannes Berg24487982009-04-23 18:52:52 +0200291{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100292 int ret;
293
294 might_sleep();
295
Johannes Bergf6837ba82014-04-30 14:19:04 +0200296 if (!check_sdata_in_driver(sdata))
297 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100298
Luciano Coelho79f460c2011-05-11 17:09:36 +0300299 trace_drv_hw_scan(local, sdata);
Johannes Berga060bbf2010-04-27 11:59:34 +0200300 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200301 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200302 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200303}
304
Eliad Pellerb8564392011-06-13 12:47:30 +0300305static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
306 struct ieee80211_sub_if_data *sdata)
307{
308 might_sleep();
309
Johannes Bergf6837ba82014-04-30 14:19:04 +0200310 if (!check_sdata_in_driver(sdata))
311 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100312
Eliad Pellerb8564392011-06-13 12:47:30 +0300313 trace_drv_cancel_hw_scan(local, sdata);
314 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
315 trace_drv_return_void(local);
316}
317
Luciano Coelho79f460c2011-05-11 17:09:36 +0300318static inline int
319drv_sched_scan_start(struct ieee80211_local *local,
320 struct ieee80211_sub_if_data *sdata,
321 struct cfg80211_sched_scan_request *req,
David Spinadel633e2712014-02-06 16:15:23 +0200322 struct ieee80211_scan_ies *ies)
Luciano Coelho79f460c2011-05-11 17:09:36 +0300323{
324 int ret;
325
326 might_sleep();
327
Johannes Bergf6837ba82014-04-30 14:19:04 +0200328 if (!check_sdata_in_driver(sdata))
329 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100330
Luciano Coelho79f460c2011-05-11 17:09:36 +0300331 trace_drv_sched_scan_start(local, sdata);
332 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
333 req, ies);
334 trace_drv_return_int(local, ret);
335 return ret;
336}
337
Johannes Berg37e33082014-02-17 10:48:17 +0100338static inline int drv_sched_scan_stop(struct ieee80211_local *local,
339 struct ieee80211_sub_if_data *sdata)
Luciano Coelho79f460c2011-05-11 17:09:36 +0300340{
Johannes Berg37e33082014-02-17 10:48:17 +0100341 int ret;
342
Luciano Coelho79f460c2011-05-11 17:09:36 +0300343 might_sleep();
344
Johannes Bergf6837ba82014-04-30 14:19:04 +0200345 if (!check_sdata_in_driver(sdata))
346 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100347
Luciano Coelho79f460c2011-05-11 17:09:36 +0300348 trace_drv_sched_scan_stop(local, sdata);
Johannes Berg37e33082014-02-17 10:48:17 +0100349 ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
350 trace_drv_return_int(local, ret);
351
352 return ret;
Luciano Coelho79f460c2011-05-11 17:09:36 +0300353}
354
Johannes Berga344d672014-06-12 22:24:31 +0200355static inline void drv_sw_scan_start(struct ieee80211_local *local,
356 struct ieee80211_sub_if_data *sdata,
357 const u8 *mac_addr)
Johannes Berg24487982009-04-23 18:52:52 +0200358{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100359 might_sleep();
360
Johannes Berga344d672014-06-12 22:24:31 +0200361 trace_drv_sw_scan_start(local, sdata, mac_addr);
Johannes Berg24487982009-04-23 18:52:52 +0200362 if (local->ops->sw_scan_start)
Johannes Berga344d672014-06-12 22:24:31 +0200363 local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200364 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200365}
366
Johannes Berga344d672014-06-12 22:24:31 +0200367static inline void drv_sw_scan_complete(struct ieee80211_local *local,
368 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200369{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100370 might_sleep();
371
Johannes Berga344d672014-06-12 22:24:31 +0200372 trace_drv_sw_scan_complete(local, sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200373 if (local->ops->sw_scan_complete)
Johannes Berga344d672014-06-12 22:24:31 +0200374 local->ops->sw_scan_complete(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200375 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200376}
377
378static inline int drv_get_stats(struct ieee80211_local *local,
379 struct ieee80211_low_level_stats *stats)
380{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200381 int ret = -EOPNOTSUPP;
382
Kalle Valoe1781ed2009-12-23 13:15:47 +0100383 might_sleep();
384
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200385 if (local->ops->get_stats)
386 ret = local->ops->get_stats(&local->hw, stats);
387 trace_drv_get_stats(local, stats, ret);
388
389 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200390}
391
Johannes Berg9352c192015-04-20 18:12:41 +0200392static inline void drv_get_key_seq(struct ieee80211_local *local,
393 struct ieee80211_key *key,
394 struct ieee80211_key_seq *seq)
Johannes Berg24487982009-04-23 18:52:52 +0200395{
Johannes Berg9352c192015-04-20 18:12:41 +0200396 if (local->ops->get_key_seq)
397 local->ops->get_key_seq(&local->hw, &key->conf, seq);
398 trace_drv_get_key_seq(local, &key->conf);
Johannes Berg24487982009-04-23 18:52:52 +0200399}
400
Arik Nemtsovf23a4782010-11-08 11:51:06 +0200401static inline int drv_set_frag_threshold(struct ieee80211_local *local,
402 u32 value)
403{
404 int ret = 0;
405
406 might_sleep();
407
408 trace_drv_set_frag_threshold(local, value);
409 if (local->ops->set_frag_threshold)
410 ret = local->ops->set_frag_threshold(&local->hw, value);
411 trace_drv_return_int(local, ret);
412 return ret;
413}
414
Johannes Berg24487982009-04-23 18:52:52 +0200415static inline int drv_set_rts_threshold(struct ieee80211_local *local,
416 u32 value)
417{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200418 int ret = 0;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100419
420 might_sleep();
421
Johannes Berg4efc76b2010-06-10 10:56:20 +0200422 trace_drv_set_rts_threshold(local, value);
Johannes Berg24487982009-04-23 18:52:52 +0200423 if (local->ops->set_rts_threshold)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200424 ret = local->ops->set_rts_threshold(&local->hw, value);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200425 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200426 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200427}
428
Lukáš Turek310bc672009-12-21 22:50:48 +0100429static inline int drv_set_coverage_class(struct ieee80211_local *local,
Lorenzo Bianconia4bcaf52014-09-04 23:57:41 +0200430 s16 value)
Lukáš Turek310bc672009-12-21 22:50:48 +0100431{
432 int ret = 0;
433 might_sleep();
434
Johannes Berg4efc76b2010-06-10 10:56:20 +0200435 trace_drv_set_coverage_class(local, value);
Lukáš Turek310bc672009-12-21 22:50:48 +0100436 if (local->ops->set_coverage_class)
437 local->ops->set_coverage_class(&local->hw, value);
438 else
439 ret = -EOPNOTSUPP;
440
Johannes Berg4efc76b2010-06-10 10:56:20 +0200441 trace_drv_return_int(local, ret);
Lukáš Turek310bc672009-12-21 22:50:48 +0100442 return ret;
443}
444
Johannes Berg24487982009-04-23 18:52:52 +0200445static inline void drv_sta_notify(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100446 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200447 enum sta_notify_cmd cmd,
448 struct ieee80211_sta *sta)
449{
Felix Fietkaubc192f82011-11-23 21:09:49 +0700450 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba82014-04-30 14:19:04 +0200451 if (!check_sdata_in_driver(sdata))
452 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100453
Johannes Berg4efc76b2010-06-10 10:56:20 +0200454 trace_drv_sta_notify(local, sdata, cmd, sta);
Johannes Berg24487982009-04-23 18:52:52 +0200455 if (local->ops->sta_notify)
Johannes Berg12375ef2009-11-25 20:30:31 +0100456 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200457 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200458}
459
Johannes Berg34e89502010-02-03 13:59:58 +0100460static inline int drv_sta_add(struct ieee80211_local *local,
461 struct ieee80211_sub_if_data *sdata,
462 struct ieee80211_sta *sta)
463{
464 int ret = 0;
465
466 might_sleep();
467
Felix Fietkaubc192f82011-11-23 21:09:49 +0700468 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba82014-04-30 14:19:04 +0200469 if (!check_sdata_in_driver(sdata))
470 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100471
Johannes Berg4efc76b2010-06-10 10:56:20 +0200472 trace_drv_sta_add(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100473 if (local->ops->sta_add)
474 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100475
Johannes Berg4efc76b2010-06-10 10:56:20 +0200476 trace_drv_return_int(local, ret);
Johannes Berg34e89502010-02-03 13:59:58 +0100477
478 return ret;
479}
480
481static inline void drv_sta_remove(struct ieee80211_local *local,
482 struct ieee80211_sub_if_data *sdata,
483 struct ieee80211_sta *sta)
484{
485 might_sleep();
486
Felix Fietkaubc192f82011-11-23 21:09:49 +0700487 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba82014-04-30 14:19:04 +0200488 if (!check_sdata_in_driver(sdata))
489 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100490
Johannes Berg4efc76b2010-06-10 10:56:20 +0200491 trace_drv_sta_remove(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100492 if (local->ops->sta_remove)
493 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100494
Johannes Berg4efc76b2010-06-10 10:56:20 +0200495 trace_drv_return_void(local);
Johannes Berg34e89502010-02-03 13:59:58 +0100496}
497
Sujith Manoharan77d2ece2012-11-20 08:46:02 +0530498#ifdef CONFIG_MAC80211_DEBUGFS
499static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
500 struct ieee80211_sub_if_data *sdata,
501 struct ieee80211_sta *sta,
502 struct dentry *dir)
503{
504 might_sleep();
505
506 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba82014-04-30 14:19:04 +0200507 if (!check_sdata_in_driver(sdata))
508 return;
Sujith Manoharan77d2ece2012-11-20 08:46:02 +0530509
510 if (local->ops->sta_add_debugfs)
511 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
512 sta, dir);
513}
514
515static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
516 struct ieee80211_sub_if_data *sdata,
517 struct ieee80211_sta *sta,
518 struct dentry *dir)
519{
520 might_sleep();
521
522 sdata = get_bss_sdata(sdata);
523 check_sdata_in_driver(sdata);
524
525 if (local->ops->sta_remove_debugfs)
526 local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
527 sta, dir);
528}
529#endif
530
Johannes Berg6a9d1b92013-12-04 22:39:17 +0100531static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
532 struct ieee80211_sub_if_data *sdata,
533 struct sta_info *sta)
534{
535 might_sleep();
536
537 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba82014-04-30 14:19:04 +0200538 if (!check_sdata_in_driver(sdata))
539 return;
Johannes Berg6a9d1b92013-12-04 22:39:17 +0100540
541 trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
542 if (local->ops->sta_pre_rcu_remove)
543 local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
544 &sta->sta);
545 trace_drv_return_void(local);
546}
547
Denys Vlasenko727da602015-07-15 14:56:05 +0200548__must_check
Johannes Bergf09603a2012-01-20 13:55:21 +0100549int drv_sta_state(struct ieee80211_local *local,
550 struct ieee80211_sub_if_data *sdata,
551 struct sta_info *sta,
552 enum ieee80211_sta_state old_state,
Denys Vlasenko727da602015-07-15 14:56:05 +0200553 enum ieee80211_sta_state new_state);
Johannes Bergf09603a2012-01-20 13:55:21 +0100554
Denys Vlasenko4fbd5722015-09-18 15:19:35 +0200555void drv_sta_rc_update(struct ieee80211_local *local,
556 struct ieee80211_sub_if_data *sdata,
557 struct ieee80211_sta *sta, u32 changed);
Johannes Berg8f727ef2012-03-30 08:43:32 +0200558
Johannes Bergf815e2b2014-11-19 00:10:42 +0100559static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
560 struct ieee80211_sub_if_data *sdata,
561 struct ieee80211_sta *sta)
562{
563 sdata = get_bss_sdata(sdata);
564 if (!check_sdata_in_driver(sdata))
565 return;
566
567 trace_drv_sta_rate_tbl_update(local, sdata, sta);
568 if (local->ops->sta_rate_tbl_update)
569 local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
570
571 trace_drv_return_void(local);
572}
573
Johannes Berg2b9a7e12014-11-17 11:35:23 +0100574static inline void drv_sta_statistics(struct ieee80211_local *local,
575 struct ieee80211_sub_if_data *sdata,
576 struct ieee80211_sta *sta,
577 struct station_info *sinfo)
578{
579 sdata = get_bss_sdata(sdata);
580 if (!check_sdata_in_driver(sdata))
581 return;
582
583 trace_drv_sta_statistics(local, sdata, sta);
584 if (local->ops->sta_statistics)
585 local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
586 trace_drv_return_void(local);
587}
588
Denys Vlasenkob23dcd42015-09-18 15:19:34 +0200589int drv_conf_tx(struct ieee80211_local *local,
590 struct ieee80211_sub_if_data *sdata, u16 ac,
591 const struct ieee80211_tx_queue_params *params);
Johannes Berg24487982009-04-23 18:52:52 +0200592
Eliad Peller37a41b42011-09-21 14:06:11 +0300593static inline u64 drv_get_tsf(struct ieee80211_local *local,
594 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200595{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200596 u64 ret = -1ULL;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100597
598 might_sleep();
599
Johannes Bergf6837ba82014-04-30 14:19:04 +0200600 if (!check_sdata_in_driver(sdata))
601 return ret;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100602
Eliad Peller37a41b42011-09-21 14:06:11 +0300603 trace_drv_get_tsf(local, sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200604 if (local->ops->get_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300605 ret = local->ops->get_tsf(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200606 trace_drv_return_u64(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200607 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200608}
609
Eliad Peller37a41b42011-09-21 14:06:11 +0300610static inline void drv_set_tsf(struct ieee80211_local *local,
611 struct ieee80211_sub_if_data *sdata,
612 u64 tsf)
Johannes Berg24487982009-04-23 18:52:52 +0200613{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100614 might_sleep();
615
Johannes Bergf6837ba82014-04-30 14:19:04 +0200616 if (!check_sdata_in_driver(sdata))
617 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100618
Eliad Peller37a41b42011-09-21 14:06:11 +0300619 trace_drv_set_tsf(local, sdata, tsf);
Johannes Berg24487982009-04-23 18:52:52 +0200620 if (local->ops->set_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300621 local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200622 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200623}
624
Eliad Peller37a41b42011-09-21 14:06:11 +0300625static inline void drv_reset_tsf(struct ieee80211_local *local,
626 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200627{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100628 might_sleep();
629
Johannes Bergf6837ba82014-04-30 14:19:04 +0200630 if (!check_sdata_in_driver(sdata))
631 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100632
Eliad Peller37a41b42011-09-21 14:06:11 +0300633 trace_drv_reset_tsf(local, sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200634 if (local->ops->reset_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300635 local->ops->reset_tsf(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200636 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200637}
638
639static inline int drv_tx_last_beacon(struct ieee80211_local *local)
640{
Masanari Iida02582e92012-08-22 19:11:26 +0900641 int ret = 0; /* default unsupported op for less congestion */
Kalle Valoe1781ed2009-12-23 13:15:47 +0100642
643 might_sleep();
644
Johannes Berg4efc76b2010-06-10 10:56:20 +0200645 trace_drv_tx_last_beacon(local);
Johannes Berg24487982009-04-23 18:52:52 +0200646 if (local->ops->tx_last_beacon)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200647 ret = local->ops->tx_last_beacon(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200648 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200649 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200650}
651
652static inline int drv_ampdu_action(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100653 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200654 enum ieee80211_ampdu_mlme_action action,
655 struct ieee80211_sta *sta, u16 tid,
Emmanuel Grumbache3abc8f2015-08-16 11:13:22 +0300656 u16 *ssn, u8 buf_size, bool amsdu)
Johannes Berg24487982009-04-23 18:52:52 +0200657{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200658 int ret = -EOPNOTSUPP;
Johannes Bergcfcdbde2010-06-10 10:21:48 +0200659
660 might_sleep();
661
Felix Fietkaubc192f82011-11-23 21:09:49 +0700662 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba82014-04-30 14:19:04 +0200663 if (!check_sdata_in_driver(sdata))
664 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100665
Emmanuel Grumbache3abc8f2015-08-16 11:13:22 +0300666 trace_drv_ampdu_action(local, sdata, action, sta, tid,
667 ssn, buf_size, amsdu);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200668
Johannes Berg24487982009-04-23 18:52:52 +0200669 if (local->ops->ampdu_action)
Johannes Berg12375ef2009-11-25 20:30:31 +0100670 ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
Emmanuel Grumbache3abc8f2015-08-16 11:13:22 +0300671 sta, tid, ssn, buf_size, amsdu);
Johannes Berg85ad1812010-06-10 10:21:49 +0200672
Johannes Berg4efc76b2010-06-10 10:56:20 +0200673 trace_drv_return_int(local, ret);
674
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200675 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200676}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200677
Holger Schurig12897232010-04-19 10:23:57 +0200678static inline int drv_get_survey(struct ieee80211_local *local, int idx,
679 struct survey_info *survey)
680{
681 int ret = -EOPNOTSUPP;
John W. Linvillec466d4e2010-06-29 14:51:23 -0400682
683 trace_drv_get_survey(local, idx, survey);
684
Holger Schurig35dd0502010-06-07 16:33:49 +0200685 if (local->ops->get_survey)
Holger Schurig12897232010-04-19 10:23:57 +0200686 ret = local->ops->get_survey(&local->hw, idx, survey);
John W. Linvillec466d4e2010-06-29 14:51:23 -0400687
688 trace_drv_return_int(local, ret);
689
Holger Schurig12897232010-04-19 10:23:57 +0200690 return ret;
691}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200692
693static inline void drv_rfkill_poll(struct ieee80211_local *local)
694{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100695 might_sleep();
696
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200697 if (local->ops->rfkill_poll)
698 local->ops->rfkill_poll(&local->hw);
699}
Johannes Berga80f7c02009-12-23 13:15:32 +0100700
Johannes Berg39ecc012013-02-13 12:11:00 +0100701static inline void drv_flush(struct ieee80211_local *local,
Emmanuel Grumbach77be2c52014-03-27 11:30:29 +0200702 struct ieee80211_sub_if_data *sdata,
Johannes Berg39ecc012013-02-13 12:11:00 +0100703 u32 queues, bool drop)
Johannes Berga80f7c02009-12-23 13:15:32 +0100704{
Emmanuel Grumbach77be2c52014-03-27 11:30:29 +0200705 struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
706
Kalle Valoe1781ed2009-12-23 13:15:47 +0100707 might_sleep();
708
Johannes Bergf6837ba82014-04-30 14:19:04 +0200709 if (sdata && !check_sdata_in_driver(sdata))
710 return;
Emmanuel Grumbach77be2c52014-03-27 11:30:29 +0200711
Johannes Berg39ecc012013-02-13 12:11:00 +0100712 trace_drv_flush(local, queues, drop);
Johannes Berga80f7c02009-12-23 13:15:32 +0100713 if (local->ops->flush)
Emmanuel Grumbach77be2c52014-03-27 11:30:29 +0200714 local->ops->flush(&local->hw, vif, queues, drop);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200715 trace_drv_return_void(local);
Johannes Berga80f7c02009-12-23 13:15:32 +0100716}
Johannes Berg5ce6e432010-05-11 16:20:57 +0200717
718static inline void drv_channel_switch(struct ieee80211_local *local,
Luciano Coelho0f791eb42014-10-08 09:48:40 +0300719 struct ieee80211_sub_if_data *sdata,
720 struct ieee80211_channel_switch *ch_switch)
Johannes Berg5ce6e432010-05-11 16:20:57 +0200721{
722 might_sleep();
723
Luciano Coelho0f791eb42014-10-08 09:48:40 +0300724 trace_drv_channel_switch(local, sdata, ch_switch);
725 local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200726 trace_drv_return_void(local);
Johannes Berg5ce6e432010-05-11 16:20:57 +0200727}
728
Bruno Randolf15d96752010-11-10 12:50:56 +0900729
730static inline int drv_set_antenna(struct ieee80211_local *local,
731 u32 tx_ant, u32 rx_ant)
732{
733 int ret = -EOPNOTSUPP;
734 might_sleep();
735 if (local->ops->set_antenna)
736 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
737 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
738 return ret;
739}
740
741static inline int drv_get_antenna(struct ieee80211_local *local,
742 u32 *tx_ant, u32 *rx_ant)
743{
744 int ret = -EOPNOTSUPP;
745 might_sleep();
746 if (local->ops->get_antenna)
747 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
748 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
749 return ret;
750}
751
Johannes Berg21f83582010-12-18 17:20:47 +0100752static inline int drv_remain_on_channel(struct ieee80211_local *local,
Eliad Peller49884562012-11-19 17:05:09 +0200753 struct ieee80211_sub_if_data *sdata,
Johannes Berg21f83582010-12-18 17:20:47 +0100754 struct ieee80211_channel *chan,
Ilan Peerd339d5c2013-02-12 09:34:13 +0200755 unsigned int duration,
756 enum ieee80211_roc_type type)
Johannes Berg21f83582010-12-18 17:20:47 +0100757{
758 int ret;
759
760 might_sleep();
761
Ilan Peerd339d5c2013-02-12 09:34:13 +0200762 trace_drv_remain_on_channel(local, sdata, chan, duration, type);
Eliad Peller49884562012-11-19 17:05:09 +0200763 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
Ilan Peerd339d5c2013-02-12 09:34:13 +0200764 chan, duration, type);
Johannes Berg21f83582010-12-18 17:20:47 +0100765 trace_drv_return_int(local, ret);
766
767 return ret;
768}
769
770static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
771{
772 int ret;
773
774 might_sleep();
775
776 trace_drv_cancel_remain_on_channel(local);
777 ret = local->ops->cancel_remain_on_channel(&local->hw);
778 trace_drv_return_int(local, ret);
779
780 return ret;
781}
782
John W. Linville38c09152011-03-07 16:19:18 -0500783static inline int drv_set_ringparam(struct ieee80211_local *local,
784 u32 tx, u32 rx)
785{
786 int ret = -ENOTSUPP;
787
788 might_sleep();
789
790 trace_drv_set_ringparam(local, tx, rx);
791 if (local->ops->set_ringparam)
792 ret = local->ops->set_ringparam(&local->hw, tx, rx);
793 trace_drv_return_int(local, ret);
794
795 return ret;
796}
797
798static inline void drv_get_ringparam(struct ieee80211_local *local,
799 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
800{
801 might_sleep();
802
803 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
804 if (local->ops->get_ringparam)
805 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
806 trace_drv_return_void(local);
807}
808
Vivek Natarajane8306f92011-04-06 11:41:10 +0530809static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
810{
811 bool ret = false;
812
813 might_sleep();
814
815 trace_drv_tx_frames_pending(local);
816 if (local->ops->tx_frames_pending)
817 ret = local->ops->tx_frames_pending(&local->hw);
818 trace_drv_return_bool(local, ret);
819
820 return ret;
821}
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530822
823static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
824 struct ieee80211_sub_if_data *sdata,
825 const struct cfg80211_bitrate_mask *mask)
826{
827 int ret = -EOPNOTSUPP;
828
829 might_sleep();
830
Johannes Bergf6837ba82014-04-30 14:19:04 +0200831 if (!check_sdata_in_driver(sdata))
832 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100833
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530834 trace_drv_set_bitrate_mask(local, sdata, mask);
835 if (local->ops->set_bitrate_mask)
836 ret = local->ops->set_bitrate_mask(&local->hw,
837 &sdata->vif, mask);
838 trace_drv_return_int(local, ret);
839
840 return ret;
841}
842
Johannes Bergc68f4b82011-07-05 16:35:41 +0200843static inline void drv_set_rekey_data(struct ieee80211_local *local,
844 struct ieee80211_sub_if_data *sdata,
845 struct cfg80211_gtk_rekey_data *data)
846{
Johannes Bergf6837ba82014-04-30 14:19:04 +0200847 if (!check_sdata_in_driver(sdata))
848 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100849
Johannes Bergc68f4b82011-07-05 16:35:41 +0200850 trace_drv_set_rekey_data(local, sdata, data);
851 if (local->ops->set_rekey_data)
852 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
853 trace_drv_return_void(local);
854}
855
Emmanuel Grumbacha8182922015-03-16 23:23:34 +0200856static inline void drv_event_callback(struct ieee80211_local *local,
857 struct ieee80211_sub_if_data *sdata,
858 const struct ieee80211_event *event)
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700859{
Emmanuel Grumbacha8182922015-03-16 23:23:34 +0200860 trace_drv_event_callback(local, sdata, event);
861 if (local->ops->event_callback)
862 local->ops->event_callback(&local->hw, &sdata->vif, event);
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700863 trace_drv_return_void(local);
864}
Johannes Berg4049e092011-09-29 16:04:32 +0200865
866static inline void
867drv_release_buffered_frames(struct ieee80211_local *local,
868 struct sta_info *sta, u16 tids, int num_frames,
869 enum ieee80211_frame_release_type reason,
870 bool more_data)
871{
872 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
873 reason, more_data);
874 if (local->ops->release_buffered_frames)
875 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
876 num_frames, reason,
877 more_data);
878 trace_drv_return_void(local);
879}
Johannes Berg40b96402011-09-29 16:04:38 +0200880
881static inline void
882drv_allow_buffered_frames(struct ieee80211_local *local,
883 struct sta_info *sta, u16 tids, int num_frames,
884 enum ieee80211_frame_release_type reason,
885 bool more_data)
886{
887 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
888 reason, more_data);
889 if (local->ops->allow_buffered_frames)
890 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
891 tids, num_frames, reason,
892 more_data);
893 trace_drv_return_void(local);
894}
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300895
Johannes Berga1845fc2012-06-27 13:18:36 +0200896static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
897 struct ieee80211_sub_if_data *sdata)
898{
899 might_sleep();
900
Johannes Bergf6837ba82014-04-30 14:19:04 +0200901 if (!check_sdata_in_driver(sdata))
902 return;
Johannes Berga1845fc2012-06-27 13:18:36 +0200903 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
904
905 trace_drv_mgd_prepare_tx(local, sdata);
906 if (local->ops->mgd_prepare_tx)
907 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
908 trace_drv_return_void(local);
909}
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200910
Arik Nemtsovee10f2c2014-06-11 17:18:27 +0300911static inline void
912drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
913 struct ieee80211_sub_if_data *sdata)
914{
915 might_sleep();
916
917 if (!check_sdata_in_driver(sdata))
918 return;
919 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
920
921 trace_drv_mgd_protect_tdls_discover(local, sdata);
922 if (local->ops->mgd_protect_tdls_discover)
923 local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
924 trace_drv_return_void(local);
925}
926
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200927static inline int drv_add_chanctx(struct ieee80211_local *local,
928 struct ieee80211_chanctx *ctx)
929{
930 int ret = -EOPNOTSUPP;
931
932 trace_drv_add_chanctx(local, ctx);
933 if (local->ops->add_chanctx)
934 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
935 trace_drv_return_int(local, ret);
Johannes Berg8a61af62012-12-13 17:42:30 +0100936 if (!ret)
937 ctx->driver_present = true;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200938
939 return ret;
940}
941
942static inline void drv_remove_chanctx(struct ieee80211_local *local,
943 struct ieee80211_chanctx *ctx)
944{
Johannes Bergf6837ba82014-04-30 14:19:04 +0200945 if (WARN_ON(!ctx->driver_present))
946 return;
947
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200948 trace_drv_remove_chanctx(local, ctx);
949 if (local->ops->remove_chanctx)
950 local->ops->remove_chanctx(&local->hw, &ctx->conf);
951 trace_drv_return_void(local);
Johannes Berg8a61af62012-12-13 17:42:30 +0100952 ctx->driver_present = false;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200953}
954
955static inline void drv_change_chanctx(struct ieee80211_local *local,
956 struct ieee80211_chanctx *ctx,
957 u32 changed)
958{
959 trace_drv_change_chanctx(local, ctx, changed);
Johannes Berg8a61af62012-12-13 17:42:30 +0100960 if (local->ops->change_chanctx) {
961 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200962 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
Johannes Berg8a61af62012-12-13 17:42:30 +0100963 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200964 trace_drv_return_void(local);
965}
966
967static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
968 struct ieee80211_sub_if_data *sdata,
969 struct ieee80211_chanctx *ctx)
970{
971 int ret = 0;
972
Johannes Bergf6837ba82014-04-30 14:19:04 +0200973 if (!check_sdata_in_driver(sdata))
974 return -EIO;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200975
976 trace_drv_assign_vif_chanctx(local, sdata, ctx);
Johannes Berg8a61af62012-12-13 17:42:30 +0100977 if (local->ops->assign_vif_chanctx) {
978 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200979 ret = local->ops->assign_vif_chanctx(&local->hw,
980 &sdata->vif,
981 &ctx->conf);
Johannes Berg8a61af62012-12-13 17:42:30 +0100982 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200983 trace_drv_return_int(local, ret);
984
985 return ret;
986}
987
988static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
989 struct ieee80211_sub_if_data *sdata,
990 struct ieee80211_chanctx *ctx)
991{
Johannes Bergf6837ba82014-04-30 14:19:04 +0200992 if (!check_sdata_in_driver(sdata))
993 return;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200994
995 trace_drv_unassign_vif_chanctx(local, sdata, ctx);
Johannes Berg8a61af62012-12-13 17:42:30 +0100996 if (local->ops->unassign_vif_chanctx) {
997 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200998 local->ops->unassign_vif_chanctx(&local->hw,
999 &sdata->vif,
1000 &ctx->conf);
Johannes Berg8a61af62012-12-13 17:42:30 +01001001 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +02001002 trace_drv_return_void(local);
1003}
1004
Luciano Coelho1a5f0c12014-05-23 14:33:12 +03001005static inline int
1006drv_switch_vif_chanctx(struct ieee80211_local *local,
1007 struct ieee80211_vif_chanctx_switch *vifs,
1008 int n_vifs,
1009 enum ieee80211_chanctx_switch_mode mode)
1010{
1011 int ret = 0;
1012 int i;
1013
1014 if (!local->ops->switch_vif_chanctx)
1015 return -EOPNOTSUPP;
1016
1017 for (i = 0; i < n_vifs; i++) {
1018 struct ieee80211_chanctx *new_ctx =
1019 container_of(vifs[i].new_ctx,
1020 struct ieee80211_chanctx,
1021 conf);
1022 struct ieee80211_chanctx *old_ctx =
1023 container_of(vifs[i].old_ctx,
1024 struct ieee80211_chanctx,
1025 conf);
1026
1027 WARN_ON_ONCE(!old_ctx->driver_present);
1028 WARN_ON_ONCE((mode == CHANCTX_SWMODE_SWAP_CONTEXTS &&
1029 new_ctx->driver_present) ||
1030 (mode == CHANCTX_SWMODE_REASSIGN_VIF &&
1031 !new_ctx->driver_present));
1032 }
1033
1034 trace_drv_switch_vif_chanctx(local, vifs, n_vifs, mode);
1035 ret = local->ops->switch_vif_chanctx(&local->hw,
1036 vifs, n_vifs, mode);
1037 trace_drv_return_int(local, ret);
1038
1039 if (!ret && mode == CHANCTX_SWMODE_SWAP_CONTEXTS) {
1040 for (i = 0; i < n_vifs; i++) {
1041 struct ieee80211_chanctx *new_ctx =
1042 container_of(vifs[i].new_ctx,
1043 struct ieee80211_chanctx,
1044 conf);
1045 struct ieee80211_chanctx *old_ctx =
1046 container_of(vifs[i].old_ctx,
1047 struct ieee80211_chanctx,
1048 conf);
1049
1050 new_ctx->driver_present = true;
1051 old_ctx->driver_present = false;
1052 }
1053 }
1054
1055 return ret;
1056}
1057
Johannes Berg10416382012-10-19 15:44:42 +02001058static inline int drv_start_ap(struct ieee80211_local *local,
1059 struct ieee80211_sub_if_data *sdata)
1060{
1061 int ret = 0;
1062
Johannes Bergf6837ba82014-04-30 14:19:04 +02001063 if (!check_sdata_in_driver(sdata))
1064 return -EIO;
Johannes Berg10416382012-10-19 15:44:42 +02001065
1066 trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
1067 if (local->ops->start_ap)
1068 ret = local->ops->start_ap(&local->hw, &sdata->vif);
1069 trace_drv_return_int(local, ret);
1070 return ret;
1071}
1072
1073static inline void drv_stop_ap(struct ieee80211_local *local,
1074 struct ieee80211_sub_if_data *sdata)
1075{
Johannes Bergf6837ba82014-04-30 14:19:04 +02001076 if (!check_sdata_in_driver(sdata))
1077 return;
Johannes Berg10416382012-10-19 15:44:42 +02001078
1079 trace_drv_stop_ap(local, sdata);
1080 if (local->ops->stop_ap)
1081 local->ops->stop_ap(&local->hw, &sdata->vif);
1082 trace_drv_return_void(local);
1083}
1084
Eliad Pellercf2c92d2014-11-04 11:43:54 +02001085static inline void
1086drv_reconfig_complete(struct ieee80211_local *local,
1087 enum ieee80211_reconfig_type reconfig_type)
Johannes Berg9214ad72012-11-06 19:18:13 +01001088{
1089 might_sleep();
1090
Eliad Pellercf2c92d2014-11-04 11:43:54 +02001091 trace_drv_reconfig_complete(local, reconfig_type);
1092 if (local->ops->reconfig_complete)
1093 local->ops->reconfig_complete(&local->hw, reconfig_type);
Johannes Berg9214ad72012-11-06 19:18:13 +01001094 trace_drv_return_void(local);
1095}
1096
Yoni Divinskyde5fad82012-05-30 11:36:39 +03001097static inline void
1098drv_set_default_unicast_key(struct ieee80211_local *local,
1099 struct ieee80211_sub_if_data *sdata,
1100 int key_idx)
1101{
Johannes Bergf6837ba82014-04-30 14:19:04 +02001102 if (!check_sdata_in_driver(sdata))
1103 return;
Yoni Divinskyde5fad82012-05-30 11:36:39 +03001104
1105 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1106
1107 trace_drv_set_default_unicast_key(local, sdata, key_idx);
1108 if (local->ops->set_default_unicast_key)
1109 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1110 key_idx);
1111 trace_drv_return_void(local);
1112}
1113
Johannes Berga65240c2013-01-14 15:14:34 +01001114#if IS_ENABLED(CONFIG_IPV6)
1115static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1116 struct ieee80211_sub_if_data *sdata,
1117 struct inet6_dev *idev)
1118{
1119 trace_drv_ipv6_addr_change(local, sdata);
1120 if (local->ops->ipv6_addr_change)
1121 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1122 trace_drv_return_void(local);
1123}
1124#endif
1125
Simon Wunderlich73da7d52013-07-11 16:09:06 +02001126static inline void
1127drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1128 struct cfg80211_chan_def *chandef)
1129{
1130 struct ieee80211_local *local = sdata->local;
1131
1132 if (local->ops->channel_switch_beacon) {
1133 trace_drv_channel_switch_beacon(local, sdata, chandef);
1134 local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1135 chandef);
1136 }
1137}
1138
Luciano Coelho6d027bc2014-10-08 09:48:37 +03001139static inline int
1140drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
1141 struct ieee80211_channel_switch *ch_switch)
1142{
1143 struct ieee80211_local *local = sdata->local;
1144 int ret = 0;
1145
1146 if (!check_sdata_in_driver(sdata))
1147 return -EIO;
1148
1149 trace_drv_pre_channel_switch(local, sdata, ch_switch);
1150 if (local->ops->pre_channel_switch)
1151 ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
1152 ch_switch);
1153 trace_drv_return_int(local, ret);
1154 return ret;
1155}
1156
Luciano Coelhof1d65582014-10-08 09:48:38 +03001157static inline int
1158drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1159{
1160 struct ieee80211_local *local = sdata->local;
1161 int ret = 0;
1162
1163 if (!check_sdata_in_driver(sdata))
1164 return -EIO;
1165
1166 trace_drv_post_channel_switch(local, sdata);
1167 if (local->ops->post_channel_switch)
1168 ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1169 trace_drv_return_int(local, ret);
1170 return ret;
1171}
1172
Johannes Berg55fff502013-08-19 18:48:41 +02001173static inline int drv_join_ibss(struct ieee80211_local *local,
1174 struct ieee80211_sub_if_data *sdata)
1175{
1176 int ret = 0;
1177
1178 might_sleep();
Johannes Bergf6837ba82014-04-30 14:19:04 +02001179 if (!check_sdata_in_driver(sdata))
1180 return -EIO;
Johannes Berg55fff502013-08-19 18:48:41 +02001181
1182 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1183 if (local->ops->join_ibss)
1184 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1185 trace_drv_return_int(local, ret);
1186 return ret;
1187}
1188
1189static inline void drv_leave_ibss(struct ieee80211_local *local,
1190 struct ieee80211_sub_if_data *sdata)
1191{
1192 might_sleep();
Johannes Bergf6837ba82014-04-30 14:19:04 +02001193 if (!check_sdata_in_driver(sdata))
1194 return;
Johannes Berg55fff502013-08-19 18:48:41 +02001195
1196 trace_drv_leave_ibss(local, sdata);
1197 if (local->ops->leave_ibss)
1198 local->ops->leave_ibss(&local->hw, &sdata->vif);
1199 trace_drv_return_void(local);
1200}
1201
Antonio Quartullicca674d2014-05-19 21:53:20 +02001202static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
1203 struct ieee80211_sta *sta)
1204{
1205 u32 ret = 0;
1206
1207 trace_drv_get_expected_throughput(sta);
1208 if (local->ops->get_expected_throughput)
1209 ret = local->ops->get_expected_throughput(sta);
1210 trace_drv_return_u32(local, ret);
1211
1212 return ret;
1213}
1214
Felix Fietkau5b3dc422014-10-26 00:32:53 +02001215static inline int drv_get_txpower(struct ieee80211_local *local,
1216 struct ieee80211_sub_if_data *sdata, int *dbm)
1217{
1218 int ret;
1219
1220 if (!local->ops->get_txpower)
1221 return -EOPNOTSUPP;
1222
1223 ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
1224 trace_drv_get_txpower(local, sdata, *dbm, ret);
1225
1226 return ret;
1227}
1228
Arik Nemtsova7a6bdd2014-11-09 18:50:19 +02001229static inline int
1230drv_tdls_channel_switch(struct ieee80211_local *local,
1231 struct ieee80211_sub_if_data *sdata,
1232 struct ieee80211_sta *sta, u8 oper_class,
1233 struct cfg80211_chan_def *chandef,
1234 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
1235{
1236 int ret;
1237
1238 might_sleep();
1239 if (!check_sdata_in_driver(sdata))
1240 return -EIO;
1241
1242 if (!local->ops->tdls_channel_switch)
1243 return -EOPNOTSUPP;
1244
1245 trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
1246 ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
1247 oper_class, chandef, tmpl_skb,
1248 ch_sw_tm_ie);
1249 trace_drv_return_int(local, ret);
1250 return ret;
1251}
1252
1253static inline void
1254drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
1255 struct ieee80211_sub_if_data *sdata,
1256 struct ieee80211_sta *sta)
1257{
1258 might_sleep();
1259 if (!check_sdata_in_driver(sdata))
1260 return;
1261
1262 if (!local->ops->tdls_cancel_channel_switch)
1263 return;
1264
1265 trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
1266 local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
1267 trace_drv_return_void(local);
1268}
1269
Arik Nemtsov8a4d32f2014-11-09 18:50:20 +02001270static inline void
1271drv_tdls_recv_channel_switch(struct ieee80211_local *local,
1272 struct ieee80211_sub_if_data *sdata,
1273 struct ieee80211_tdls_ch_sw_params *params)
1274{
1275 trace_drv_tdls_recv_channel_switch(local, sdata, params);
1276 if (local->ops->tdls_recv_channel_switch)
1277 local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
1278 params);
1279 trace_drv_return_void(local);
1280}
1281
Felix Fietkauba8c3d62015-03-27 21:30:37 +01001282static inline void drv_wake_tx_queue(struct ieee80211_local *local,
1283 struct txq_info *txq)
1284{
1285 struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
1286
1287 if (!check_sdata_in_driver(sdata))
1288 return;
1289
1290 trace_drv_wake_tx_queue(local, sdata, txq);
1291 local->ops->wake_tx_queue(&local->hw, &txq->txq);
1292}
1293
Johannes Berg24487982009-04-23 18:52:52 +02001294#endif /* __MAC80211_DRIVER_OPS */