blob: 2937bcbc32e06550e9c6ad7fb6278a2041fb9116 [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 Bergf6837ba2014-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 Bergf6837ba2014-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
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 &&
Johannes Berg30686bf2015-06-02 21:39:54 +0200149 !ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF) &&
Felix Fietkau31eba5b2013-05-28 13:01:53 +0200150 !(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE))))
Johannes Berg7b7eab62011-11-03 14:41:13 +0100151 return -EINVAL;
152
153 trace_drv_add_interface(local, sdata);
154 ret = local->ops->add_interface(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200155 trace_drv_return_int(local, ret);
Johannes Berg7b7eab62011-11-03 14:41:13 +0100156
157 if (ret == 0)
158 sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
159
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200160 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200161}
162
Johannes Berg34d4bc42010-08-27 12:35:58 +0200163static inline int drv_change_interface(struct ieee80211_local *local,
164 struct ieee80211_sub_if_data *sdata,
Johannes Berg2ca27bc2010-09-16 14:58:23 +0200165 enum nl80211_iftype type, bool p2p)
Johannes Berg34d4bc42010-08-27 12:35:58 +0200166{
167 int ret;
168
169 might_sleep();
170
Johannes Bergf6837ba2014-04-30 14:19:04 +0200171 if (!check_sdata_in_driver(sdata))
172 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100173
Johannes Berg2ca27bc2010-09-16 14:58:23 +0200174 trace_drv_change_interface(local, sdata, type, p2p);
175 ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
Johannes Berg34d4bc42010-08-27 12:35:58 +0200176 trace_drv_return_int(local, ret);
177 return ret;
178}
179
Johannes Berg24487982009-04-23 18:52:52 +0200180static inline void drv_remove_interface(struct ieee80211_local *local,
Johannes Berg7b7eab62011-11-03 14:41:13 +0100181 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200182{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100183 might_sleep();
184
Johannes Bergf6837ba2014-04-30 14:19:04 +0200185 if (!check_sdata_in_driver(sdata))
186 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100187
188 trace_drv_remove_interface(local, sdata);
189 local->ops->remove_interface(&local->hw, &sdata->vif);
190 sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER;
Johannes Berg4efc76b2010-06-10 10:56:20 +0200191 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200192}
193
194static inline int drv_config(struct ieee80211_local *local, u32 changed)
195{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100196 int ret;
197
198 might_sleep();
199
Johannes Berg4efc76b2010-06-10 10:56:20 +0200200 trace_drv_config(local, changed);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100201 ret = local->ops->config(&local->hw, changed);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200202 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200203 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200204}
205
206static inline void drv_bss_info_changed(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100207 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200208 struct ieee80211_bss_conf *info,
209 u32 changed)
210{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100211 might_sleep();
212
Johannes Berg5bbe754d2013-02-13 13:50:51 +0100213 if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
214 BSS_CHANGED_BEACON_ENABLED) &&
215 sdata->vif.type != NL80211_IFTYPE_AP &&
216 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
Rostislav Lisovy239281f2014-11-03 10:33:19 +0100217 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
218 sdata->vif.type != NL80211_IFTYPE_OCB))
Johannes Berg5bbe754d2013-02-13 13:50:51 +0100219 return;
220
221 if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
222 sdata->vif.type == NL80211_IFTYPE_MONITOR))
223 return;
Johannes Bergb8dc1a32012-12-14 14:22:10 +0100224
Johannes Bergf6837ba2014-04-30 14:19:04 +0200225 if (!check_sdata_in_driver(sdata))
226 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100227
Johannes Berg4efc76b2010-06-10 10:56:20 +0200228 trace_drv_bss_info_changed(local, sdata, info, changed);
Johannes Berg24487982009-04-23 18:52:52 +0200229 if (local->ops->bss_info_changed)
Johannes Berg12375ef2009-11-25 20:30:31 +0100230 local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200231 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200232}
233
Johannes Berg3ac64be2009-08-17 16:16:53 +0200234static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
Jiri Pirko22bedad32010-04-01 21:22:57 +0000235 struct netdev_hw_addr_list *mc_list)
Johannes Berg24487982009-04-23 18:52:52 +0200236{
Johannes Berg3ac64be2009-08-17 16:16:53 +0200237 u64 ret = 0;
238
Johannes Berg4efc76b2010-06-10 10:56:20 +0200239 trace_drv_prepare_multicast(local, mc_list->count);
240
Johannes Berg3ac64be2009-08-17 16:16:53 +0200241 if (local->ops->prepare_multicast)
Jiri Pirko22bedad32010-04-01 21:22:57 +0000242 ret = local->ops->prepare_multicast(&local->hw, mc_list);
Johannes Berg3ac64be2009-08-17 16:16:53 +0200243
Johannes Berg4efc76b2010-06-10 10:56:20 +0200244 trace_drv_return_u64(local, ret);
Johannes Berg3ac64be2009-08-17 16:16:53 +0200245
246 return ret;
247}
248
249static inline void drv_configure_filter(struct ieee80211_local *local,
250 unsigned int changed_flags,
251 unsigned int *total_flags,
252 u64 multicast)
253{
254 might_sleep();
255
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200256 trace_drv_configure_filter(local, changed_flags, total_flags,
Johannes Berg3ac64be2009-08-17 16:16:53 +0200257 multicast);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200258 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
259 multicast);
260 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200261}
262
Andrei Otcheretianski1b09b552015-08-15 22:39:50 +0300263static inline void drv_config_iface_filter(struct ieee80211_local *local,
264 struct ieee80211_sub_if_data *sdata,
265 unsigned int filter_flags,
266 unsigned int changed_flags)
267{
268 might_sleep();
269
270 trace_drv_config_iface_filter(local, sdata, filter_flags,
271 changed_flags);
272 if (local->ops->config_iface_filter)
273 local->ops->config_iface_filter(&local->hw, &sdata->vif,
274 filter_flags,
275 changed_flags);
276 trace_drv_return_void(local);
277}
278
Johannes Berg24487982009-04-23 18:52:52 +0200279static inline int drv_set_tim(struct ieee80211_local *local,
280 struct ieee80211_sta *sta, bool set)
281{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200282 int ret = 0;
Johannes Berg4efc76b2010-06-10 10:56:20 +0200283 trace_drv_set_tim(local, sta, set);
Johannes Berg24487982009-04-23 18:52:52 +0200284 if (local->ops->set_tim)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200285 ret = local->ops->set_tim(&local->hw, sta, set);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200286 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200287 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200288}
289
290static inline int drv_set_key(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100291 enum set_key_cmd cmd,
292 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200293 struct ieee80211_sta *sta,
294 struct ieee80211_key_conf *key)
295{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100296 int ret;
297
298 might_sleep();
299
Johannes Berg077f4932012-01-20 13:55:18 +0100300 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba2014-04-30 14:19:04 +0200301 if (!check_sdata_in_driver(sdata))
302 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100303
Johannes Berg4efc76b2010-06-10 10:56:20 +0200304 trace_drv_set_key(local, cmd, sdata, sta, key);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100305 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200306 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200307 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200308}
309
310static inline void drv_update_tkip_key(struct ieee80211_local *local,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100311 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200312 struct ieee80211_key_conf *conf,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100313 struct sta_info *sta, u32 iv32,
Johannes Berg24487982009-04-23 18:52:52 +0200314 u16 *phase1key)
315{
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100316 struct ieee80211_sta *ista = NULL;
317
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100318 if (sta)
319 ista = &sta->sta;
320
Johannes Berg077f4932012-01-20 13:55:18 +0100321 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba2014-04-30 14:19:04 +0200322 if (!check_sdata_in_driver(sdata))
323 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100324
Johannes Berg4efc76b2010-06-10 10:56:20 +0200325 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
Johannes Berg24487982009-04-23 18:52:52 +0200326 if (local->ops->update_tkip_key)
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100327 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
328 ista, iv32, phase1key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200329 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200330}
331
332static inline int drv_hw_scan(struct ieee80211_local *local,
Johannes Berga060bbf2010-04-27 11:59:34 +0200333 struct ieee80211_sub_if_data *sdata,
David Spinadelc56ef672014-02-05 15:21:13 +0200334 struct ieee80211_scan_request *req)
Johannes Berg24487982009-04-23 18:52:52 +0200335{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100336 int ret;
337
338 might_sleep();
339
Johannes Bergf6837ba2014-04-30 14:19:04 +0200340 if (!check_sdata_in_driver(sdata))
341 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100342
Luciano Coelho79f460c2011-05-11 17:09:36 +0300343 trace_drv_hw_scan(local, sdata);
Johannes Berga060bbf2010-04-27 11:59:34 +0200344 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200345 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200346 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200347}
348
Eliad Pellerb8564392011-06-13 12:47:30 +0300349static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
350 struct ieee80211_sub_if_data *sdata)
351{
352 might_sleep();
353
Johannes Bergf6837ba2014-04-30 14:19:04 +0200354 if (!check_sdata_in_driver(sdata))
355 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100356
Eliad Pellerb8564392011-06-13 12:47:30 +0300357 trace_drv_cancel_hw_scan(local, sdata);
358 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
359 trace_drv_return_void(local);
360}
361
Luciano Coelho79f460c2011-05-11 17:09:36 +0300362static inline int
363drv_sched_scan_start(struct ieee80211_local *local,
364 struct ieee80211_sub_if_data *sdata,
365 struct cfg80211_sched_scan_request *req,
David Spinadel633e2712014-02-06 16:15:23 +0200366 struct ieee80211_scan_ies *ies)
Luciano Coelho79f460c2011-05-11 17:09:36 +0300367{
368 int ret;
369
370 might_sleep();
371
Johannes Bergf6837ba2014-04-30 14:19:04 +0200372 if (!check_sdata_in_driver(sdata))
373 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100374
Luciano Coelho79f460c2011-05-11 17:09:36 +0300375 trace_drv_sched_scan_start(local, sdata);
376 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
377 req, ies);
378 trace_drv_return_int(local, ret);
379 return ret;
380}
381
Johannes Berg37e33082014-02-17 10:48:17 +0100382static inline int drv_sched_scan_stop(struct ieee80211_local *local,
383 struct ieee80211_sub_if_data *sdata)
Luciano Coelho79f460c2011-05-11 17:09:36 +0300384{
Johannes Berg37e33082014-02-17 10:48:17 +0100385 int ret;
386
Luciano Coelho79f460c2011-05-11 17:09:36 +0300387 might_sleep();
388
Johannes Bergf6837ba2014-04-30 14:19:04 +0200389 if (!check_sdata_in_driver(sdata))
390 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100391
Luciano Coelho79f460c2011-05-11 17:09:36 +0300392 trace_drv_sched_scan_stop(local, sdata);
Johannes Berg37e33082014-02-17 10:48:17 +0100393 ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
394 trace_drv_return_int(local, ret);
395
396 return ret;
Luciano Coelho79f460c2011-05-11 17:09:36 +0300397}
398
Johannes Berga344d672014-06-12 22:24:31 +0200399static inline void drv_sw_scan_start(struct ieee80211_local *local,
400 struct ieee80211_sub_if_data *sdata,
401 const u8 *mac_addr)
Johannes Berg24487982009-04-23 18:52:52 +0200402{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100403 might_sleep();
404
Johannes Berga344d672014-06-12 22:24:31 +0200405 trace_drv_sw_scan_start(local, sdata, mac_addr);
Johannes Berg24487982009-04-23 18:52:52 +0200406 if (local->ops->sw_scan_start)
Johannes Berga344d672014-06-12 22:24:31 +0200407 local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200408 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200409}
410
Johannes Berga344d672014-06-12 22:24:31 +0200411static inline void drv_sw_scan_complete(struct ieee80211_local *local,
412 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200413{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100414 might_sleep();
415
Johannes Berga344d672014-06-12 22:24:31 +0200416 trace_drv_sw_scan_complete(local, sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200417 if (local->ops->sw_scan_complete)
Johannes Berga344d672014-06-12 22:24:31 +0200418 local->ops->sw_scan_complete(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200419 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200420}
421
422static inline int drv_get_stats(struct ieee80211_local *local,
423 struct ieee80211_low_level_stats *stats)
424{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200425 int ret = -EOPNOTSUPP;
426
Kalle Valoe1781ed2009-12-23 13:15:47 +0100427 might_sleep();
428
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200429 if (local->ops->get_stats)
430 ret = local->ops->get_stats(&local->hw, stats);
431 trace_drv_get_stats(local, stats, ret);
432
433 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200434}
435
Johannes Berg9352c192015-04-20 18:12:41 +0200436static inline void drv_get_key_seq(struct ieee80211_local *local,
437 struct ieee80211_key *key,
438 struct ieee80211_key_seq *seq)
Johannes Berg24487982009-04-23 18:52:52 +0200439{
Johannes Berg9352c192015-04-20 18:12:41 +0200440 if (local->ops->get_key_seq)
441 local->ops->get_key_seq(&local->hw, &key->conf, seq);
442 trace_drv_get_key_seq(local, &key->conf);
Johannes Berg24487982009-04-23 18:52:52 +0200443}
444
Arik Nemtsovf23a4782010-11-08 11:51:06 +0200445static inline int drv_set_frag_threshold(struct ieee80211_local *local,
446 u32 value)
447{
448 int ret = 0;
449
450 might_sleep();
451
452 trace_drv_set_frag_threshold(local, value);
453 if (local->ops->set_frag_threshold)
454 ret = local->ops->set_frag_threshold(&local->hw, value);
455 trace_drv_return_int(local, ret);
456 return ret;
457}
458
Johannes Berg24487982009-04-23 18:52:52 +0200459static inline int drv_set_rts_threshold(struct ieee80211_local *local,
460 u32 value)
461{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200462 int ret = 0;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100463
464 might_sleep();
465
Johannes Berg4efc76b2010-06-10 10:56:20 +0200466 trace_drv_set_rts_threshold(local, value);
Johannes Berg24487982009-04-23 18:52:52 +0200467 if (local->ops->set_rts_threshold)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200468 ret = local->ops->set_rts_threshold(&local->hw, value);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200469 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200470 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200471}
472
Lukáš Turek310bc672009-12-21 22:50:48 +0100473static inline int drv_set_coverage_class(struct ieee80211_local *local,
Lorenzo Bianconia4bcaf52014-09-04 23:57:41 +0200474 s16 value)
Lukáš Turek310bc672009-12-21 22:50:48 +0100475{
476 int ret = 0;
477 might_sleep();
478
Johannes Berg4efc76b2010-06-10 10:56:20 +0200479 trace_drv_set_coverage_class(local, value);
Lukáš Turek310bc672009-12-21 22:50:48 +0100480 if (local->ops->set_coverage_class)
481 local->ops->set_coverage_class(&local->hw, value);
482 else
483 ret = -EOPNOTSUPP;
484
Johannes Berg4efc76b2010-06-10 10:56:20 +0200485 trace_drv_return_int(local, ret);
Lukáš Turek310bc672009-12-21 22:50:48 +0100486 return ret;
487}
488
Johannes Berg24487982009-04-23 18:52:52 +0200489static inline void drv_sta_notify(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100490 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200491 enum sta_notify_cmd cmd,
492 struct ieee80211_sta *sta)
493{
Felix Fietkaubc192f82011-11-23 21:09:49 +0700494 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba2014-04-30 14:19:04 +0200495 if (!check_sdata_in_driver(sdata))
496 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100497
Johannes Berg4efc76b2010-06-10 10:56:20 +0200498 trace_drv_sta_notify(local, sdata, cmd, sta);
Johannes Berg24487982009-04-23 18:52:52 +0200499 if (local->ops->sta_notify)
Johannes Berg12375ef2009-11-25 20:30:31 +0100500 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200501 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200502}
503
Johannes Berg34e89502010-02-03 13:59:58 +0100504static inline int drv_sta_add(struct ieee80211_local *local,
505 struct ieee80211_sub_if_data *sdata,
506 struct ieee80211_sta *sta)
507{
508 int ret = 0;
509
510 might_sleep();
511
Felix Fietkaubc192f82011-11-23 21:09:49 +0700512 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba2014-04-30 14:19:04 +0200513 if (!check_sdata_in_driver(sdata))
514 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100515
Johannes Berg4efc76b2010-06-10 10:56:20 +0200516 trace_drv_sta_add(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100517 if (local->ops->sta_add)
518 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100519
Johannes Berg4efc76b2010-06-10 10:56:20 +0200520 trace_drv_return_int(local, ret);
Johannes Berg34e89502010-02-03 13:59:58 +0100521
522 return ret;
523}
524
525static inline void drv_sta_remove(struct ieee80211_local *local,
526 struct ieee80211_sub_if_data *sdata,
527 struct ieee80211_sta *sta)
528{
529 might_sleep();
530
Felix Fietkaubc192f82011-11-23 21:09:49 +0700531 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba2014-04-30 14:19:04 +0200532 if (!check_sdata_in_driver(sdata))
533 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100534
Johannes Berg4efc76b2010-06-10 10:56:20 +0200535 trace_drv_sta_remove(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100536 if (local->ops->sta_remove)
537 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100538
Johannes Berg4efc76b2010-06-10 10:56:20 +0200539 trace_drv_return_void(local);
Johannes Berg34e89502010-02-03 13:59:58 +0100540}
541
Sujith Manoharan77d2ece2012-11-20 08:46:02 +0530542#ifdef CONFIG_MAC80211_DEBUGFS
543static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
544 struct ieee80211_sub_if_data *sdata,
545 struct ieee80211_sta *sta,
546 struct dentry *dir)
547{
548 might_sleep();
549
550 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba2014-04-30 14:19:04 +0200551 if (!check_sdata_in_driver(sdata))
552 return;
Sujith Manoharan77d2ece2012-11-20 08:46:02 +0530553
554 if (local->ops->sta_add_debugfs)
555 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
556 sta, dir);
557}
558
559static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
560 struct ieee80211_sub_if_data *sdata,
561 struct ieee80211_sta *sta,
562 struct dentry *dir)
563{
564 might_sleep();
565
566 sdata = get_bss_sdata(sdata);
567 check_sdata_in_driver(sdata);
568
569 if (local->ops->sta_remove_debugfs)
570 local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
571 sta, dir);
572}
573#endif
574
Johannes Berg6a9d1b92013-12-04 22:39:17 +0100575static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
576 struct ieee80211_sub_if_data *sdata,
577 struct sta_info *sta)
578{
579 might_sleep();
580
581 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba2014-04-30 14:19:04 +0200582 if (!check_sdata_in_driver(sdata))
583 return;
Johannes Berg6a9d1b92013-12-04 22:39:17 +0100584
585 trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
586 if (local->ops->sta_pre_rcu_remove)
587 local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
588 &sta->sta);
589 trace_drv_return_void(local);
590}
591
Denys Vlasenko727da602015-07-15 14:56:05 +0200592__must_check
Johannes Bergf09603a2012-01-20 13:55:21 +0100593int drv_sta_state(struct ieee80211_local *local,
594 struct ieee80211_sub_if_data *sdata,
595 struct sta_info *sta,
596 enum ieee80211_sta_state old_state,
Denys Vlasenko727da602015-07-15 14:56:05 +0200597 enum ieee80211_sta_state new_state);
Johannes Bergf09603a2012-01-20 13:55:21 +0100598
Denys Vlasenko4fbd5722015-09-18 15:19:35 +0200599void drv_sta_rc_update(struct ieee80211_local *local,
600 struct ieee80211_sub_if_data *sdata,
601 struct ieee80211_sta *sta, u32 changed);
Johannes Berg8f727ef2012-03-30 08:43:32 +0200602
Johannes Bergf815e2b2014-11-19 00:10:42 +0100603static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
604 struct ieee80211_sub_if_data *sdata,
605 struct ieee80211_sta *sta)
606{
607 sdata = get_bss_sdata(sdata);
608 if (!check_sdata_in_driver(sdata))
609 return;
610
611 trace_drv_sta_rate_tbl_update(local, sdata, sta);
612 if (local->ops->sta_rate_tbl_update)
613 local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
614
615 trace_drv_return_void(local);
616}
617
Johannes Berg2b9a7e12014-11-17 11:35:23 +0100618static inline void drv_sta_statistics(struct ieee80211_local *local,
619 struct ieee80211_sub_if_data *sdata,
620 struct ieee80211_sta *sta,
621 struct station_info *sinfo)
622{
623 sdata = get_bss_sdata(sdata);
624 if (!check_sdata_in_driver(sdata))
625 return;
626
627 trace_drv_sta_statistics(local, sdata, sta);
628 if (local->ops->sta_statistics)
629 local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
630 trace_drv_return_void(local);
631}
632
Denys Vlasenkob23dcd42015-09-18 15:19:34 +0200633int drv_conf_tx(struct ieee80211_local *local,
634 struct ieee80211_sub_if_data *sdata, u16 ac,
635 const struct ieee80211_tx_queue_params *params);
Johannes Berg24487982009-04-23 18:52:52 +0200636
Eliad Peller37a41b42011-09-21 14:06:11 +0300637static inline u64 drv_get_tsf(struct ieee80211_local *local,
638 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200639{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200640 u64 ret = -1ULL;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100641
642 might_sleep();
643
Johannes Bergf6837ba2014-04-30 14:19:04 +0200644 if (!check_sdata_in_driver(sdata))
645 return ret;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100646
Eliad Peller37a41b42011-09-21 14:06:11 +0300647 trace_drv_get_tsf(local, sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200648 if (local->ops->get_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300649 ret = local->ops->get_tsf(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200650 trace_drv_return_u64(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200651 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200652}
653
Eliad Peller37a41b42011-09-21 14:06:11 +0300654static inline void drv_set_tsf(struct ieee80211_local *local,
655 struct ieee80211_sub_if_data *sdata,
656 u64 tsf)
Johannes Berg24487982009-04-23 18:52:52 +0200657{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100658 might_sleep();
659
Johannes Bergf6837ba2014-04-30 14:19:04 +0200660 if (!check_sdata_in_driver(sdata))
661 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100662
Eliad Peller37a41b42011-09-21 14:06:11 +0300663 trace_drv_set_tsf(local, sdata, tsf);
Johannes Berg24487982009-04-23 18:52:52 +0200664 if (local->ops->set_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300665 local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200666 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200667}
668
Eliad Peller37a41b42011-09-21 14:06:11 +0300669static inline void drv_reset_tsf(struct ieee80211_local *local,
670 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200671{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100672 might_sleep();
673
Johannes Bergf6837ba2014-04-30 14:19:04 +0200674 if (!check_sdata_in_driver(sdata))
675 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100676
Eliad Peller37a41b42011-09-21 14:06:11 +0300677 trace_drv_reset_tsf(local, sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200678 if (local->ops->reset_tsf)
Eliad Peller37a41b42011-09-21 14:06:11 +0300679 local->ops->reset_tsf(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200680 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200681}
682
683static inline int drv_tx_last_beacon(struct ieee80211_local *local)
684{
Masanari Iida02582e92012-08-22 19:11:26 +0900685 int ret = 0; /* default unsupported op for less congestion */
Kalle Valoe1781ed2009-12-23 13:15:47 +0100686
687 might_sleep();
688
Johannes Berg4efc76b2010-06-10 10:56:20 +0200689 trace_drv_tx_last_beacon(local);
Johannes Berg24487982009-04-23 18:52:52 +0200690 if (local->ops->tx_last_beacon)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200691 ret = local->ops->tx_last_beacon(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200692 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200693 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200694}
695
696static inline int drv_ampdu_action(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100697 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200698 enum ieee80211_ampdu_mlme_action action,
699 struct ieee80211_sta *sta, u16 tid,
Emmanuel Grumbache3abc8f2015-08-16 11:13:22 +0300700 u16 *ssn, u8 buf_size, bool amsdu)
Johannes Berg24487982009-04-23 18:52:52 +0200701{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200702 int ret = -EOPNOTSUPP;
Johannes Bergcfcdbde2010-06-10 10:21:48 +0200703
704 might_sleep();
705
Felix Fietkaubc192f82011-11-23 21:09:49 +0700706 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba2014-04-30 14:19:04 +0200707 if (!check_sdata_in_driver(sdata))
708 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100709
Emmanuel Grumbache3abc8f2015-08-16 11:13:22 +0300710 trace_drv_ampdu_action(local, sdata, action, sta, tid,
711 ssn, buf_size, amsdu);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200712
Johannes Berg24487982009-04-23 18:52:52 +0200713 if (local->ops->ampdu_action)
Johannes Berg12375ef2009-11-25 20:30:31 +0100714 ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
Emmanuel Grumbache3abc8f2015-08-16 11:13:22 +0300715 sta, tid, ssn, buf_size, amsdu);
Johannes Berg85ad1812010-06-10 10:21:49 +0200716
Johannes Berg4efc76b2010-06-10 10:56:20 +0200717 trace_drv_return_int(local, ret);
718
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200719 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200720}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200721
Holger Schurig12897232010-04-19 10:23:57 +0200722static inline int drv_get_survey(struct ieee80211_local *local, int idx,
723 struct survey_info *survey)
724{
725 int ret = -EOPNOTSUPP;
John W. Linvillec466d4e2010-06-29 14:51:23 -0400726
727 trace_drv_get_survey(local, idx, survey);
728
Holger Schurig35dd0502010-06-07 16:33:49 +0200729 if (local->ops->get_survey)
Holger Schurig12897232010-04-19 10:23:57 +0200730 ret = local->ops->get_survey(&local->hw, idx, survey);
John W. Linvillec466d4e2010-06-29 14:51:23 -0400731
732 trace_drv_return_int(local, ret);
733
Holger Schurig12897232010-04-19 10:23:57 +0200734 return ret;
735}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200736
737static inline void drv_rfkill_poll(struct ieee80211_local *local)
738{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100739 might_sleep();
740
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200741 if (local->ops->rfkill_poll)
742 local->ops->rfkill_poll(&local->hw);
743}
Johannes Berga80f7c02009-12-23 13:15:32 +0100744
Johannes Berg39ecc012013-02-13 12:11:00 +0100745static inline void drv_flush(struct ieee80211_local *local,
Emmanuel Grumbach77be2c52014-03-27 11:30:29 +0200746 struct ieee80211_sub_if_data *sdata,
Johannes Berg39ecc012013-02-13 12:11:00 +0100747 u32 queues, bool drop)
Johannes Berga80f7c02009-12-23 13:15:32 +0100748{
Emmanuel Grumbach77be2c52014-03-27 11:30:29 +0200749 struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
750
Kalle Valoe1781ed2009-12-23 13:15:47 +0100751 might_sleep();
752
Johannes Bergf6837ba2014-04-30 14:19:04 +0200753 if (sdata && !check_sdata_in_driver(sdata))
754 return;
Emmanuel Grumbach77be2c52014-03-27 11:30:29 +0200755
Johannes Berg39ecc012013-02-13 12:11:00 +0100756 trace_drv_flush(local, queues, drop);
Johannes Berga80f7c02009-12-23 13:15:32 +0100757 if (local->ops->flush)
Emmanuel Grumbach77be2c52014-03-27 11:30:29 +0200758 local->ops->flush(&local->hw, vif, queues, drop);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200759 trace_drv_return_void(local);
Johannes Berga80f7c02009-12-23 13:15:32 +0100760}
Johannes Berg5ce6e432010-05-11 16:20:57 +0200761
762static inline void drv_channel_switch(struct ieee80211_local *local,
Luciano Coelho0f791eb42014-10-08 09:48:40 +0300763 struct ieee80211_sub_if_data *sdata,
764 struct ieee80211_channel_switch *ch_switch)
Johannes Berg5ce6e432010-05-11 16:20:57 +0200765{
766 might_sleep();
767
Luciano Coelho0f791eb42014-10-08 09:48:40 +0300768 trace_drv_channel_switch(local, sdata, ch_switch);
769 local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200770 trace_drv_return_void(local);
Johannes Berg5ce6e432010-05-11 16:20:57 +0200771}
772
Bruno Randolf15d96752010-11-10 12:50:56 +0900773
774static inline int drv_set_antenna(struct ieee80211_local *local,
775 u32 tx_ant, u32 rx_ant)
776{
777 int ret = -EOPNOTSUPP;
778 might_sleep();
779 if (local->ops->set_antenna)
780 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
781 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
782 return ret;
783}
784
785static inline int drv_get_antenna(struct ieee80211_local *local,
786 u32 *tx_ant, u32 *rx_ant)
787{
788 int ret = -EOPNOTSUPP;
789 might_sleep();
790 if (local->ops->get_antenna)
791 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
792 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
793 return ret;
794}
795
Johannes Berg21f83582010-12-18 17:20:47 +0100796static inline int drv_remain_on_channel(struct ieee80211_local *local,
Eliad Peller49884562012-11-19 17:05:09 +0200797 struct ieee80211_sub_if_data *sdata,
Johannes Berg21f83582010-12-18 17:20:47 +0100798 struct ieee80211_channel *chan,
Ilan Peerd339d5c2013-02-12 09:34:13 +0200799 unsigned int duration,
800 enum ieee80211_roc_type type)
Johannes Berg21f83582010-12-18 17:20:47 +0100801{
802 int ret;
803
804 might_sleep();
805
Ilan Peerd339d5c2013-02-12 09:34:13 +0200806 trace_drv_remain_on_channel(local, sdata, chan, duration, type);
Eliad Peller49884562012-11-19 17:05:09 +0200807 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
Ilan Peerd339d5c2013-02-12 09:34:13 +0200808 chan, duration, type);
Johannes Berg21f83582010-12-18 17:20:47 +0100809 trace_drv_return_int(local, ret);
810
811 return ret;
812}
813
814static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
815{
816 int ret;
817
818 might_sleep();
819
820 trace_drv_cancel_remain_on_channel(local);
821 ret = local->ops->cancel_remain_on_channel(&local->hw);
822 trace_drv_return_int(local, ret);
823
824 return ret;
825}
826
John W. Linville38c09152011-03-07 16:19:18 -0500827static inline int drv_set_ringparam(struct ieee80211_local *local,
828 u32 tx, u32 rx)
829{
830 int ret = -ENOTSUPP;
831
832 might_sleep();
833
834 trace_drv_set_ringparam(local, tx, rx);
835 if (local->ops->set_ringparam)
836 ret = local->ops->set_ringparam(&local->hw, tx, rx);
837 trace_drv_return_int(local, ret);
838
839 return ret;
840}
841
842static inline void drv_get_ringparam(struct ieee80211_local *local,
843 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
844{
845 might_sleep();
846
847 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
848 if (local->ops->get_ringparam)
849 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
850 trace_drv_return_void(local);
851}
852
Vivek Natarajane8306f92011-04-06 11:41:10 +0530853static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
854{
855 bool ret = false;
856
857 might_sleep();
858
859 trace_drv_tx_frames_pending(local);
860 if (local->ops->tx_frames_pending)
861 ret = local->ops->tx_frames_pending(&local->hw);
862 trace_drv_return_bool(local, ret);
863
864 return ret;
865}
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530866
867static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
868 struct ieee80211_sub_if_data *sdata,
869 const struct cfg80211_bitrate_mask *mask)
870{
871 int ret = -EOPNOTSUPP;
872
873 might_sleep();
874
Johannes Bergf6837ba2014-04-30 14:19:04 +0200875 if (!check_sdata_in_driver(sdata))
876 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100877
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530878 trace_drv_set_bitrate_mask(local, sdata, mask);
879 if (local->ops->set_bitrate_mask)
880 ret = local->ops->set_bitrate_mask(&local->hw,
881 &sdata->vif, mask);
882 trace_drv_return_int(local, ret);
883
884 return ret;
885}
886
Johannes Bergc68f4b82011-07-05 16:35:41 +0200887static inline void drv_set_rekey_data(struct ieee80211_local *local,
888 struct ieee80211_sub_if_data *sdata,
889 struct cfg80211_gtk_rekey_data *data)
890{
Johannes Bergf6837ba2014-04-30 14:19:04 +0200891 if (!check_sdata_in_driver(sdata))
892 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100893
Johannes Bergc68f4b82011-07-05 16:35:41 +0200894 trace_drv_set_rekey_data(local, sdata, data);
895 if (local->ops->set_rekey_data)
896 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
897 trace_drv_return_void(local);
898}
899
Emmanuel Grumbacha8182922015-03-16 23:23:34 +0200900static inline void drv_event_callback(struct ieee80211_local *local,
901 struct ieee80211_sub_if_data *sdata,
902 const struct ieee80211_event *event)
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700903{
Emmanuel Grumbacha8182922015-03-16 23:23:34 +0200904 trace_drv_event_callback(local, sdata, event);
905 if (local->ops->event_callback)
906 local->ops->event_callback(&local->hw, &sdata->vif, event);
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700907 trace_drv_return_void(local);
908}
Johannes Berg4049e092011-09-29 16:04:32 +0200909
910static inline void
911drv_release_buffered_frames(struct ieee80211_local *local,
912 struct sta_info *sta, u16 tids, int num_frames,
913 enum ieee80211_frame_release_type reason,
914 bool more_data)
915{
916 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
917 reason, more_data);
918 if (local->ops->release_buffered_frames)
919 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
920 num_frames, reason,
921 more_data);
922 trace_drv_return_void(local);
923}
Johannes Berg40b96402011-09-29 16:04:38 +0200924
925static inline void
926drv_allow_buffered_frames(struct ieee80211_local *local,
927 struct sta_info *sta, u16 tids, int num_frames,
928 enum ieee80211_frame_release_type reason,
929 bool more_data)
930{
931 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
932 reason, more_data);
933 if (local->ops->allow_buffered_frames)
934 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
935 tids, num_frames, reason,
936 more_data);
937 trace_drv_return_void(local);
938}
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300939
Johannes Berga1845fc2012-06-27 13:18:36 +0200940static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
941 struct ieee80211_sub_if_data *sdata)
942{
943 might_sleep();
944
Johannes Bergf6837ba2014-04-30 14:19:04 +0200945 if (!check_sdata_in_driver(sdata))
946 return;
Johannes Berga1845fc2012-06-27 13:18:36 +0200947 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
948
949 trace_drv_mgd_prepare_tx(local, sdata);
950 if (local->ops->mgd_prepare_tx)
951 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
952 trace_drv_return_void(local);
953}
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200954
Arik Nemtsovee10f2c2014-06-11 17:18:27 +0300955static inline void
956drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
957 struct ieee80211_sub_if_data *sdata)
958{
959 might_sleep();
960
961 if (!check_sdata_in_driver(sdata))
962 return;
963 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
964
965 trace_drv_mgd_protect_tdls_discover(local, sdata);
966 if (local->ops->mgd_protect_tdls_discover)
967 local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
968 trace_drv_return_void(local);
969}
970
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200971static inline int drv_add_chanctx(struct ieee80211_local *local,
972 struct ieee80211_chanctx *ctx)
973{
974 int ret = -EOPNOTSUPP;
975
976 trace_drv_add_chanctx(local, ctx);
977 if (local->ops->add_chanctx)
978 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
979 trace_drv_return_int(local, ret);
Johannes Berg8a61af62012-12-13 17:42:30 +0100980 if (!ret)
981 ctx->driver_present = true;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200982
983 return ret;
984}
985
986static inline void drv_remove_chanctx(struct ieee80211_local *local,
987 struct ieee80211_chanctx *ctx)
988{
Johannes Bergf6837ba2014-04-30 14:19:04 +0200989 if (WARN_ON(!ctx->driver_present))
990 return;
991
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200992 trace_drv_remove_chanctx(local, ctx);
993 if (local->ops->remove_chanctx)
994 local->ops->remove_chanctx(&local->hw, &ctx->conf);
995 trace_drv_return_void(local);
Johannes Berg8a61af62012-12-13 17:42:30 +0100996 ctx->driver_present = false;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200997}
998
999static inline void drv_change_chanctx(struct ieee80211_local *local,
1000 struct ieee80211_chanctx *ctx,
1001 u32 changed)
1002{
1003 trace_drv_change_chanctx(local, ctx, changed);
Johannes Berg8a61af62012-12-13 17:42:30 +01001004 if (local->ops->change_chanctx) {
1005 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +02001006 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
Johannes Berg8a61af62012-12-13 17:42:30 +01001007 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +02001008 trace_drv_return_void(local);
1009}
1010
1011static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
1012 struct ieee80211_sub_if_data *sdata,
1013 struct ieee80211_chanctx *ctx)
1014{
1015 int ret = 0;
1016
Johannes Bergf6837ba2014-04-30 14:19:04 +02001017 if (!check_sdata_in_driver(sdata))
1018 return -EIO;
Michal Kaziorc3645ea2012-06-26 14:37:17 +02001019
1020 trace_drv_assign_vif_chanctx(local, sdata, ctx);
Johannes Berg8a61af62012-12-13 17:42:30 +01001021 if (local->ops->assign_vif_chanctx) {
1022 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +02001023 ret = local->ops->assign_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_int(local, ret);
1028
1029 return ret;
1030}
1031
1032static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
1033 struct ieee80211_sub_if_data *sdata,
1034 struct ieee80211_chanctx *ctx)
1035{
Johannes Bergf6837ba2014-04-30 14:19:04 +02001036 if (!check_sdata_in_driver(sdata))
1037 return;
Michal Kaziorc3645ea2012-06-26 14:37:17 +02001038
1039 trace_drv_unassign_vif_chanctx(local, sdata, ctx);
Johannes Berg8a61af62012-12-13 17:42:30 +01001040 if (local->ops->unassign_vif_chanctx) {
1041 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +02001042 local->ops->unassign_vif_chanctx(&local->hw,
1043 &sdata->vif,
1044 &ctx->conf);
Johannes Berg8a61af62012-12-13 17:42:30 +01001045 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +02001046 trace_drv_return_void(local);
1047}
1048
Luciano Coelho1a5f0c12014-05-23 14:33:12 +03001049static inline int
1050drv_switch_vif_chanctx(struct ieee80211_local *local,
1051 struct ieee80211_vif_chanctx_switch *vifs,
1052 int n_vifs,
1053 enum ieee80211_chanctx_switch_mode mode)
1054{
1055 int ret = 0;
1056 int i;
1057
1058 if (!local->ops->switch_vif_chanctx)
1059 return -EOPNOTSUPP;
1060
1061 for (i = 0; i < n_vifs; i++) {
1062 struct ieee80211_chanctx *new_ctx =
1063 container_of(vifs[i].new_ctx,
1064 struct ieee80211_chanctx,
1065 conf);
1066 struct ieee80211_chanctx *old_ctx =
1067 container_of(vifs[i].old_ctx,
1068 struct ieee80211_chanctx,
1069 conf);
1070
1071 WARN_ON_ONCE(!old_ctx->driver_present);
1072 WARN_ON_ONCE((mode == CHANCTX_SWMODE_SWAP_CONTEXTS &&
1073 new_ctx->driver_present) ||
1074 (mode == CHANCTX_SWMODE_REASSIGN_VIF &&
1075 !new_ctx->driver_present));
1076 }
1077
1078 trace_drv_switch_vif_chanctx(local, vifs, n_vifs, mode);
1079 ret = local->ops->switch_vif_chanctx(&local->hw,
1080 vifs, n_vifs, mode);
1081 trace_drv_return_int(local, ret);
1082
1083 if (!ret && mode == CHANCTX_SWMODE_SWAP_CONTEXTS) {
1084 for (i = 0; i < n_vifs; i++) {
1085 struct ieee80211_chanctx *new_ctx =
1086 container_of(vifs[i].new_ctx,
1087 struct ieee80211_chanctx,
1088 conf);
1089 struct ieee80211_chanctx *old_ctx =
1090 container_of(vifs[i].old_ctx,
1091 struct ieee80211_chanctx,
1092 conf);
1093
1094 new_ctx->driver_present = true;
1095 old_ctx->driver_present = false;
1096 }
1097 }
1098
1099 return ret;
1100}
1101
Johannes Berg10416382012-10-19 15:44:42 +02001102static inline int drv_start_ap(struct ieee80211_local *local,
1103 struct ieee80211_sub_if_data *sdata)
1104{
1105 int ret = 0;
1106
Johannes Bergf6837ba2014-04-30 14:19:04 +02001107 if (!check_sdata_in_driver(sdata))
1108 return -EIO;
Johannes Berg10416382012-10-19 15:44:42 +02001109
1110 trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
1111 if (local->ops->start_ap)
1112 ret = local->ops->start_ap(&local->hw, &sdata->vif);
1113 trace_drv_return_int(local, ret);
1114 return ret;
1115}
1116
1117static inline void drv_stop_ap(struct ieee80211_local *local,
1118 struct ieee80211_sub_if_data *sdata)
1119{
Johannes Bergf6837ba2014-04-30 14:19:04 +02001120 if (!check_sdata_in_driver(sdata))
1121 return;
Johannes Berg10416382012-10-19 15:44:42 +02001122
1123 trace_drv_stop_ap(local, sdata);
1124 if (local->ops->stop_ap)
1125 local->ops->stop_ap(&local->hw, &sdata->vif);
1126 trace_drv_return_void(local);
1127}
1128
Eliad Pellercf2c92d2014-11-04 11:43:54 +02001129static inline void
1130drv_reconfig_complete(struct ieee80211_local *local,
1131 enum ieee80211_reconfig_type reconfig_type)
Johannes Berg9214ad72012-11-06 19:18:13 +01001132{
1133 might_sleep();
1134
Eliad Pellercf2c92d2014-11-04 11:43:54 +02001135 trace_drv_reconfig_complete(local, reconfig_type);
1136 if (local->ops->reconfig_complete)
1137 local->ops->reconfig_complete(&local->hw, reconfig_type);
Johannes Berg9214ad72012-11-06 19:18:13 +01001138 trace_drv_return_void(local);
1139}
1140
Yoni Divinskyde5fad82012-05-30 11:36:39 +03001141static inline void
1142drv_set_default_unicast_key(struct ieee80211_local *local,
1143 struct ieee80211_sub_if_data *sdata,
1144 int key_idx)
1145{
Johannes Bergf6837ba2014-04-30 14:19:04 +02001146 if (!check_sdata_in_driver(sdata))
1147 return;
Yoni Divinskyde5fad82012-05-30 11:36:39 +03001148
1149 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1150
1151 trace_drv_set_default_unicast_key(local, sdata, key_idx);
1152 if (local->ops->set_default_unicast_key)
1153 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1154 key_idx);
1155 trace_drv_return_void(local);
1156}
1157
Johannes Berga65240c2013-01-14 15:14:34 +01001158#if IS_ENABLED(CONFIG_IPV6)
1159static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1160 struct ieee80211_sub_if_data *sdata,
1161 struct inet6_dev *idev)
1162{
1163 trace_drv_ipv6_addr_change(local, sdata);
1164 if (local->ops->ipv6_addr_change)
1165 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1166 trace_drv_return_void(local);
1167}
1168#endif
1169
Simon Wunderlich73da7d52013-07-11 16:09:06 +02001170static inline void
1171drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1172 struct cfg80211_chan_def *chandef)
1173{
1174 struct ieee80211_local *local = sdata->local;
1175
1176 if (local->ops->channel_switch_beacon) {
1177 trace_drv_channel_switch_beacon(local, sdata, chandef);
1178 local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1179 chandef);
1180 }
1181}
1182
Luciano Coelho6d027bc2014-10-08 09:48:37 +03001183static inline int
1184drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
1185 struct ieee80211_channel_switch *ch_switch)
1186{
1187 struct ieee80211_local *local = sdata->local;
1188 int ret = 0;
1189
1190 if (!check_sdata_in_driver(sdata))
1191 return -EIO;
1192
1193 trace_drv_pre_channel_switch(local, sdata, ch_switch);
1194 if (local->ops->pre_channel_switch)
1195 ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
1196 ch_switch);
1197 trace_drv_return_int(local, ret);
1198 return ret;
1199}
1200
Luciano Coelhof1d65582014-10-08 09:48:38 +03001201static inline int
1202drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1203{
1204 struct ieee80211_local *local = sdata->local;
1205 int ret = 0;
1206
1207 if (!check_sdata_in_driver(sdata))
1208 return -EIO;
1209
1210 trace_drv_post_channel_switch(local, sdata);
1211 if (local->ops->post_channel_switch)
1212 ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1213 trace_drv_return_int(local, ret);
1214 return ret;
1215}
1216
Johannes Berg55fff502013-08-19 18:48:41 +02001217static inline int drv_join_ibss(struct ieee80211_local *local,
1218 struct ieee80211_sub_if_data *sdata)
1219{
1220 int ret = 0;
1221
1222 might_sleep();
Johannes Bergf6837ba2014-04-30 14:19:04 +02001223 if (!check_sdata_in_driver(sdata))
1224 return -EIO;
Johannes Berg55fff502013-08-19 18:48:41 +02001225
1226 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1227 if (local->ops->join_ibss)
1228 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1229 trace_drv_return_int(local, ret);
1230 return ret;
1231}
1232
1233static inline void drv_leave_ibss(struct ieee80211_local *local,
1234 struct ieee80211_sub_if_data *sdata)
1235{
1236 might_sleep();
Johannes Bergf6837ba2014-04-30 14:19:04 +02001237 if (!check_sdata_in_driver(sdata))
1238 return;
Johannes Berg55fff502013-08-19 18:48:41 +02001239
1240 trace_drv_leave_ibss(local, sdata);
1241 if (local->ops->leave_ibss)
1242 local->ops->leave_ibss(&local->hw, &sdata->vif);
1243 trace_drv_return_void(local);
1244}
1245
Antonio Quartullicca674d2014-05-19 21:53:20 +02001246static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
1247 struct ieee80211_sta *sta)
1248{
1249 u32 ret = 0;
1250
1251 trace_drv_get_expected_throughput(sta);
1252 if (local->ops->get_expected_throughput)
1253 ret = local->ops->get_expected_throughput(sta);
1254 trace_drv_return_u32(local, ret);
1255
1256 return ret;
1257}
1258
Felix Fietkau5b3dc422014-10-26 00:32:53 +02001259static inline int drv_get_txpower(struct ieee80211_local *local,
1260 struct ieee80211_sub_if_data *sdata, int *dbm)
1261{
1262 int ret;
1263
1264 if (!local->ops->get_txpower)
1265 return -EOPNOTSUPP;
1266
1267 ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
1268 trace_drv_get_txpower(local, sdata, *dbm, ret);
1269
1270 return ret;
1271}
1272
Arik Nemtsova7a6bdd2014-11-09 18:50:19 +02001273static inline int
1274drv_tdls_channel_switch(struct ieee80211_local *local,
1275 struct ieee80211_sub_if_data *sdata,
1276 struct ieee80211_sta *sta, u8 oper_class,
1277 struct cfg80211_chan_def *chandef,
1278 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
1279{
1280 int ret;
1281
1282 might_sleep();
1283 if (!check_sdata_in_driver(sdata))
1284 return -EIO;
1285
1286 if (!local->ops->tdls_channel_switch)
1287 return -EOPNOTSUPP;
1288
1289 trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
1290 ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
1291 oper_class, chandef, tmpl_skb,
1292 ch_sw_tm_ie);
1293 trace_drv_return_int(local, ret);
1294 return ret;
1295}
1296
1297static inline void
1298drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
1299 struct ieee80211_sub_if_data *sdata,
1300 struct ieee80211_sta *sta)
1301{
1302 might_sleep();
1303 if (!check_sdata_in_driver(sdata))
1304 return;
1305
1306 if (!local->ops->tdls_cancel_channel_switch)
1307 return;
1308
1309 trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
1310 local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
1311 trace_drv_return_void(local);
1312}
1313
Arik Nemtsov8a4d32f2014-11-09 18:50:20 +02001314static inline void
1315drv_tdls_recv_channel_switch(struct ieee80211_local *local,
1316 struct ieee80211_sub_if_data *sdata,
1317 struct ieee80211_tdls_ch_sw_params *params)
1318{
1319 trace_drv_tdls_recv_channel_switch(local, sdata, params);
1320 if (local->ops->tdls_recv_channel_switch)
1321 local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
1322 params);
1323 trace_drv_return_void(local);
1324}
1325
Felix Fietkauba8c3d62015-03-27 21:30:37 +01001326static inline void drv_wake_tx_queue(struct ieee80211_local *local,
1327 struct txq_info *txq)
1328{
1329 struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
1330
1331 if (!check_sdata_in_driver(sdata))
1332 return;
1333
1334 trace_drv_wake_tx_queue(local, sdata, txq);
1335 local->ops->wake_tx_queue(&local->hw, &txq->txq);
1336}
1337
Johannes Berg24487982009-04-23 18:52:52 +02001338#endif /* __MAC80211_DRIVER_OPS */