blob: 1a169de60192e8be5dfedb74adc23a294a471457 [file] [log] [blame]
Sara Sharonf59374e2016-03-02 23:46:14 +02001/*
2* Portions of this file
3* Copyright(c) 2016 Intel Deutschland GmbH
4*/
5
Johannes Berg24487982009-04-23 18:52:52 +02006#ifndef __MAC80211_DRIVER_OPS
7#define __MAC80211_DRIVER_OPS
8
9#include <net/mac80211.h>
10#include "ieee80211_i.h"
Johannes Berg011ad0e2012-06-22 12:55:52 +020011#include "trace.h"
Johannes Berg24487982009-04-23 18:52:52 +020012
Johannes Bergf6837ba2014-04-30 14:19:04 +020013static inline bool check_sdata_in_driver(struct ieee80211_sub_if_data *sdata)
Johannes Berg7b7eab62011-11-03 14:41:13 +010014{
Johannes Bergf6837ba2014-04-30 14:19:04 +020015 return !WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER),
16 "%s: Failed check-sdata-in-driver check, flags: 0x%x\n",
17 sdata->dev ? sdata->dev->name : sdata->name, sdata->flags);
Johannes Berg7b7eab62011-11-03 14:41:13 +010018}
19
Felix Fietkaubc192f82011-11-23 21:09:49 +070020static inline struct ieee80211_sub_if_data *
21get_bss_sdata(struct ieee80211_sub_if_data *sdata)
22{
23 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
24 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
25 u.ap);
26
27 return sdata;
28}
29
Thomas Huehn36323f82012-07-23 21:33:42 +020030static inline void drv_tx(struct ieee80211_local *local,
31 struct ieee80211_tx_control *control,
32 struct sk_buff *skb)
Johannes Berg24487982009-04-23 18:52:52 +020033{
Thomas Huehn36323f82012-07-23 21:33:42 +020034 local->ops->tx(&local->hw, control, skb);
Johannes Berg24487982009-04-23 18:52:52 +020035}
36
Sara Sharonf59374e2016-03-02 23:46:14 +020037static inline void drv_sync_rx_queues(struct ieee80211_local *local,
38 struct sta_info *sta)
39{
40 if (local->ops->sync_rx_queues) {
41 trace_drv_sync_rx_queues(local, sta->sdata, &sta->sta);
42 local->ops->sync_rx_queues(&local->hw);
43 trace_drv_return_void(local);
44 }
45}
46
Ben Greeare3521142012-04-23 12:50:31 -070047static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata,
48 u32 sset, u8 *data)
49{
50 struct ieee80211_local *local = sdata->local;
51 if (local->ops->get_et_strings) {
52 trace_drv_get_et_strings(local, sset);
53 local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data);
54 trace_drv_return_void(local);
55 }
56}
57
58static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata,
59 struct ethtool_stats *stats,
60 u64 *data)
61{
62 struct ieee80211_local *local = sdata->local;
63 if (local->ops->get_et_stats) {
64 trace_drv_get_et_stats(local);
65 local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data);
66 trace_drv_return_void(local);
67 }
68}
69
70static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata,
71 int sset)
72{
73 struct ieee80211_local *local = sdata->local;
74 int rv = 0;
75 if (local->ops->get_et_sset_count) {
76 trace_drv_get_et_sset_count(local, sset);
77 rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif,
78 sset);
79 trace_drv_return_int(local, rv);
80 }
81 return rv;
82}
83
Eliad Peller968a76c2015-10-25 10:59:36 +020084int drv_start(struct ieee80211_local *local);
85void drv_stop(struct ieee80211_local *local);
Johannes Berg24487982009-04-23 18:52:52 +020086
Johannes Bergeecc4802011-05-04 15:37:29 +020087#ifdef CONFIG_PM
88static inline int drv_suspend(struct ieee80211_local *local,
89 struct cfg80211_wowlan *wowlan)
90{
91 int ret;
92
93 might_sleep();
94
95 trace_drv_suspend(local);
96 ret = local->ops->suspend(&local->hw, wowlan);
97 trace_drv_return_int(local, ret);
98 return ret;
99}
100
101static inline int drv_resume(struct ieee80211_local *local)
102{
103 int ret;
104
105 might_sleep();
106
107 trace_drv_resume(local);
108 ret = local->ops->resume(&local->hw);
109 trace_drv_return_int(local, ret);
110 return ret;
111}
Johannes Berg6d525632012-04-04 15:05:25 +0200112
113static inline void drv_set_wakeup(struct ieee80211_local *local,
114 bool enabled)
115{
116 might_sleep();
117
118 if (!local->ops->set_wakeup)
119 return;
120
121 trace_drv_set_wakeup(local, enabled);
122 local->ops->set_wakeup(&local->hw, enabled);
123 trace_drv_return_void(local);
124}
Johannes Bergeecc4802011-05-04 15:37:29 +0200125#endif
126
Denys Vlasenko9aae2962015-09-18 15:19:38 +0200127int drv_add_interface(struct ieee80211_local *local,
128 struct ieee80211_sub_if_data *sdata);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100129
Denys Vlasenko9aae2962015-09-18 15:19:38 +0200130int drv_change_interface(struct ieee80211_local *local,
131 struct ieee80211_sub_if_data *sdata,
132 enum nl80211_iftype type, bool p2p);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100133
Denys Vlasenko9aae2962015-09-18 15:19:38 +0200134void drv_remove_interface(struct ieee80211_local *local,
135 struct ieee80211_sub_if_data *sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200136
137static inline int drv_config(struct ieee80211_local *local, u32 changed)
138{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100139 int ret;
140
141 might_sleep();
142
Johannes Berg4efc76b2010-06-10 10:56:20 +0200143 trace_drv_config(local, changed);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100144 ret = local->ops->config(&local->hw, changed);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200145 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200146 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200147}
148
149static inline void drv_bss_info_changed(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100150 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200151 struct ieee80211_bss_conf *info,
152 u32 changed)
153{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100154 might_sleep();
155
Johannes Berg5bbe754d2013-02-13 13:50:51 +0100156 if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
157 BSS_CHANGED_BEACON_ENABLED) &&
158 sdata->vif.type != NL80211_IFTYPE_AP &&
159 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
Rostislav Lisovy239281f2014-11-03 10:33:19 +0100160 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
161 sdata->vif.type != NL80211_IFTYPE_OCB))
Johannes Berg5bbe754d2013-02-13 13:50:51 +0100162 return;
163
164 if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
Ayala Beker708d50e2016-09-20 17:31:14 +0300165 sdata->vif.type == NL80211_IFTYPE_NAN ||
Aviya Erenfeld42bd20d2016-08-29 23:25:16 +0300166 (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
Peter Großec6f78282017-12-13 18:29:46 +0100167 !sdata->vif.mu_mimo_owner &&
168 !(changed & BSS_CHANGED_TXPOWER))))
Johannes Berg5bbe754d2013-02-13 13:50:51 +0100169 return;
Johannes Bergb8dc1a32012-12-14 14:22:10 +0100170
Johannes Bergf6837ba2014-04-30 14:19:04 +0200171 if (!check_sdata_in_driver(sdata))
172 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100173
Johannes Berg4efc76b2010-06-10 10:56:20 +0200174 trace_drv_bss_info_changed(local, sdata, info, changed);
Johannes Berg24487982009-04-23 18:52:52 +0200175 if (local->ops->bss_info_changed)
Johannes Berg12375ef2009-11-25 20:30:31 +0100176 local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200177 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200178}
179
Johannes Berg3ac64be2009-08-17 16:16:53 +0200180static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
Jiri Pirko22bedad32010-04-01 21:22:57 +0000181 struct netdev_hw_addr_list *mc_list)
Johannes Berg24487982009-04-23 18:52:52 +0200182{
Johannes Berg3ac64be2009-08-17 16:16:53 +0200183 u64 ret = 0;
184
Johannes Berg4efc76b2010-06-10 10:56:20 +0200185 trace_drv_prepare_multicast(local, mc_list->count);
186
Johannes Berg3ac64be2009-08-17 16:16:53 +0200187 if (local->ops->prepare_multicast)
Jiri Pirko22bedad32010-04-01 21:22:57 +0000188 ret = local->ops->prepare_multicast(&local->hw, mc_list);
Johannes Berg3ac64be2009-08-17 16:16:53 +0200189
Johannes Berg4efc76b2010-06-10 10:56:20 +0200190 trace_drv_return_u64(local, ret);
Johannes Berg3ac64be2009-08-17 16:16:53 +0200191
192 return ret;
193}
194
195static inline void drv_configure_filter(struct ieee80211_local *local,
196 unsigned int changed_flags,
197 unsigned int *total_flags,
198 u64 multicast)
199{
200 might_sleep();
201
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200202 trace_drv_configure_filter(local, changed_flags, total_flags,
Johannes Berg3ac64be2009-08-17 16:16:53 +0200203 multicast);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200204 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
205 multicast);
206 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200207}
208
Andrei Otcheretianski1b09b552015-08-15 22:39:50 +0300209static inline void drv_config_iface_filter(struct ieee80211_local *local,
210 struct ieee80211_sub_if_data *sdata,
211 unsigned int filter_flags,
212 unsigned int changed_flags)
213{
214 might_sleep();
215
216 trace_drv_config_iface_filter(local, sdata, filter_flags,
217 changed_flags);
218 if (local->ops->config_iface_filter)
219 local->ops->config_iface_filter(&local->hw, &sdata->vif,
220 filter_flags,
221 changed_flags);
222 trace_drv_return_void(local);
223}
224
Johannes Berg24487982009-04-23 18:52:52 +0200225static inline int drv_set_tim(struct ieee80211_local *local,
226 struct ieee80211_sta *sta, bool set)
227{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200228 int ret = 0;
Johannes Berg4efc76b2010-06-10 10:56:20 +0200229 trace_drv_set_tim(local, sta, set);
Johannes Berg24487982009-04-23 18:52:52 +0200230 if (local->ops->set_tim)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200231 ret = local->ops->set_tim(&local->hw, sta, set);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200232 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200233 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200234}
235
236static inline int drv_set_key(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100237 enum set_key_cmd cmd,
238 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200239 struct ieee80211_sta *sta,
240 struct ieee80211_key_conf *key)
241{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100242 int ret;
243
244 might_sleep();
245
Johannes Berg077f4932012-01-20 13:55:18 +0100246 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba2014-04-30 14:19:04 +0200247 if (!check_sdata_in_driver(sdata))
248 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100249
Johannes Berg4efc76b2010-06-10 10:56:20 +0200250 trace_drv_set_key(local, cmd, sdata, sta, key);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100251 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200252 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200253 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200254}
255
256static inline void drv_update_tkip_key(struct ieee80211_local *local,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100257 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200258 struct ieee80211_key_conf *conf,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100259 struct sta_info *sta, u32 iv32,
Johannes Berg24487982009-04-23 18:52:52 +0200260 u16 *phase1key)
261{
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100262 struct ieee80211_sta *ista = NULL;
263
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100264 if (sta)
265 ista = &sta->sta;
266
Johannes Berg077f4932012-01-20 13:55:18 +0100267 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba2014-04-30 14:19:04 +0200268 if (!check_sdata_in_driver(sdata))
269 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100270
Johannes Berg4efc76b2010-06-10 10:56:20 +0200271 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
Johannes Berg24487982009-04-23 18:52:52 +0200272 if (local->ops->update_tkip_key)
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100273 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
274 ista, iv32, phase1key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200275 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200276}
277
278static inline int drv_hw_scan(struct ieee80211_local *local,
Johannes Berga060bbf2010-04-27 11:59:34 +0200279 struct ieee80211_sub_if_data *sdata,
David Spinadelc56ef672014-02-05 15:21:13 +0200280 struct ieee80211_scan_request *req)
Johannes Berg24487982009-04-23 18:52:52 +0200281{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100282 int ret;
283
284 might_sleep();
285
Johannes Bergf6837ba2014-04-30 14:19:04 +0200286 if (!check_sdata_in_driver(sdata))
287 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100288
Luciano Coelho79f460c2011-05-11 17:09:36 +0300289 trace_drv_hw_scan(local, sdata);
Johannes Berga060bbf2010-04-27 11:59:34 +0200290 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200291 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200292 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200293}
294
Eliad Pellerb8564392011-06-13 12:47:30 +0300295static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
296 struct ieee80211_sub_if_data *sdata)
297{
298 might_sleep();
299
Johannes Bergf6837ba2014-04-30 14:19:04 +0200300 if (!check_sdata_in_driver(sdata))
301 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100302
Eliad Pellerb8564392011-06-13 12:47:30 +0300303 trace_drv_cancel_hw_scan(local, sdata);
304 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
305 trace_drv_return_void(local);
306}
307
Luciano Coelho79f460c2011-05-11 17:09:36 +0300308static inline int
309drv_sched_scan_start(struct ieee80211_local *local,
310 struct ieee80211_sub_if_data *sdata,
311 struct cfg80211_sched_scan_request *req,
David Spinadel633e2712014-02-06 16:15:23 +0200312 struct ieee80211_scan_ies *ies)
Luciano Coelho79f460c2011-05-11 17:09:36 +0300313{
314 int ret;
315
316 might_sleep();
317
Johannes Bergf6837ba2014-04-30 14:19:04 +0200318 if (!check_sdata_in_driver(sdata))
319 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100320
Luciano Coelho79f460c2011-05-11 17:09:36 +0300321 trace_drv_sched_scan_start(local, sdata);
322 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
323 req, ies);
324 trace_drv_return_int(local, ret);
325 return ret;
326}
327
Johannes Berg37e33082014-02-17 10:48:17 +0100328static inline int drv_sched_scan_stop(struct ieee80211_local *local,
329 struct ieee80211_sub_if_data *sdata)
Luciano Coelho79f460c2011-05-11 17:09:36 +0300330{
Johannes Berg37e33082014-02-17 10:48:17 +0100331 int ret;
332
Luciano Coelho79f460c2011-05-11 17:09:36 +0300333 might_sleep();
334
Johannes Bergf6837ba2014-04-30 14:19:04 +0200335 if (!check_sdata_in_driver(sdata))
336 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100337
Luciano Coelho79f460c2011-05-11 17:09:36 +0300338 trace_drv_sched_scan_stop(local, sdata);
Johannes Berg37e33082014-02-17 10:48:17 +0100339 ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
340 trace_drv_return_int(local, ret);
341
342 return ret;
Luciano Coelho79f460c2011-05-11 17:09:36 +0300343}
344
Johannes Berga344d672014-06-12 22:24:31 +0200345static inline void drv_sw_scan_start(struct ieee80211_local *local,
346 struct ieee80211_sub_if_data *sdata,
347 const u8 *mac_addr)
Johannes Berg24487982009-04-23 18:52:52 +0200348{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100349 might_sleep();
350
Johannes Berga344d672014-06-12 22:24:31 +0200351 trace_drv_sw_scan_start(local, sdata, mac_addr);
Johannes Berg24487982009-04-23 18:52:52 +0200352 if (local->ops->sw_scan_start)
Johannes Berga344d672014-06-12 22:24:31 +0200353 local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200354 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200355}
356
Johannes Berga344d672014-06-12 22:24:31 +0200357static inline void drv_sw_scan_complete(struct ieee80211_local *local,
358 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200359{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100360 might_sleep();
361
Johannes Berga344d672014-06-12 22:24:31 +0200362 trace_drv_sw_scan_complete(local, sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200363 if (local->ops->sw_scan_complete)
Johannes Berga344d672014-06-12 22:24:31 +0200364 local->ops->sw_scan_complete(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200365 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200366}
367
368static inline int drv_get_stats(struct ieee80211_local *local,
369 struct ieee80211_low_level_stats *stats)
370{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200371 int ret = -EOPNOTSUPP;
372
Kalle Valoe1781ed2009-12-23 13:15:47 +0100373 might_sleep();
374
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200375 if (local->ops->get_stats)
376 ret = local->ops->get_stats(&local->hw, stats);
377 trace_drv_get_stats(local, stats, ret);
378
379 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200380}
381
Johannes Berg9352c192015-04-20 18:12:41 +0200382static inline void drv_get_key_seq(struct ieee80211_local *local,
383 struct ieee80211_key *key,
384 struct ieee80211_key_seq *seq)
Johannes Berg24487982009-04-23 18:52:52 +0200385{
Johannes Berg9352c192015-04-20 18:12:41 +0200386 if (local->ops->get_key_seq)
387 local->ops->get_key_seq(&local->hw, &key->conf, seq);
388 trace_drv_get_key_seq(local, &key->conf);
Johannes Berg24487982009-04-23 18:52:52 +0200389}
390
Arik Nemtsovf23a4782010-11-08 11:51:06 +0200391static inline int drv_set_frag_threshold(struct ieee80211_local *local,
392 u32 value)
393{
394 int ret = 0;
395
396 might_sleep();
397
398 trace_drv_set_frag_threshold(local, value);
399 if (local->ops->set_frag_threshold)
400 ret = local->ops->set_frag_threshold(&local->hw, value);
401 trace_drv_return_int(local, ret);
402 return ret;
403}
404
Johannes Berg24487982009-04-23 18:52:52 +0200405static inline int drv_set_rts_threshold(struct ieee80211_local *local,
406 u32 value)
407{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200408 int ret = 0;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100409
410 might_sleep();
411
Johannes Berg4efc76b2010-06-10 10:56:20 +0200412 trace_drv_set_rts_threshold(local, value);
Johannes Berg24487982009-04-23 18:52:52 +0200413 if (local->ops->set_rts_threshold)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200414 ret = local->ops->set_rts_threshold(&local->hw, value);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200415 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200416 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200417}
418
Lukáš Turek310bc672009-12-21 22:50:48 +0100419static inline int drv_set_coverage_class(struct ieee80211_local *local,
Lorenzo Bianconia4bcaf52014-09-04 23:57:41 +0200420 s16 value)
Lukáš Turek310bc672009-12-21 22:50:48 +0100421{
422 int ret = 0;
423 might_sleep();
424
Johannes Berg4efc76b2010-06-10 10:56:20 +0200425 trace_drv_set_coverage_class(local, value);
Lukáš Turek310bc672009-12-21 22:50:48 +0100426 if (local->ops->set_coverage_class)
427 local->ops->set_coverage_class(&local->hw, value);
428 else
429 ret = -EOPNOTSUPP;
430
Johannes Berg4efc76b2010-06-10 10:56:20 +0200431 trace_drv_return_int(local, ret);
Lukáš Turek310bc672009-12-21 22:50:48 +0100432 return ret;
433}
434
Johannes Berg24487982009-04-23 18:52:52 +0200435static inline void drv_sta_notify(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100436 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200437 enum sta_notify_cmd cmd,
438 struct ieee80211_sta *sta)
439{
Felix Fietkaubc192f82011-11-23 21:09:49 +0700440 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba2014-04-30 14:19:04 +0200441 if (!check_sdata_in_driver(sdata))
442 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100443
Johannes Berg4efc76b2010-06-10 10:56:20 +0200444 trace_drv_sta_notify(local, sdata, cmd, sta);
Johannes Berg24487982009-04-23 18:52:52 +0200445 if (local->ops->sta_notify)
Johannes Berg12375ef2009-11-25 20:30:31 +0100446 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200447 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200448}
449
Johannes Berg34e89502010-02-03 13:59:58 +0100450static inline int drv_sta_add(struct ieee80211_local *local,
451 struct ieee80211_sub_if_data *sdata,
452 struct ieee80211_sta *sta)
453{
454 int ret = 0;
455
456 might_sleep();
457
Felix Fietkaubc192f82011-11-23 21:09:49 +0700458 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba2014-04-30 14:19:04 +0200459 if (!check_sdata_in_driver(sdata))
460 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100461
Johannes Berg4efc76b2010-06-10 10:56:20 +0200462 trace_drv_sta_add(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100463 if (local->ops->sta_add)
464 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100465
Johannes Berg4efc76b2010-06-10 10:56:20 +0200466 trace_drv_return_int(local, ret);
Johannes Berg34e89502010-02-03 13:59:58 +0100467
468 return ret;
469}
470
471static inline void drv_sta_remove(struct ieee80211_local *local,
472 struct ieee80211_sub_if_data *sdata,
473 struct ieee80211_sta *sta)
474{
475 might_sleep();
476
Felix Fietkaubc192f82011-11-23 21:09:49 +0700477 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba2014-04-30 14:19:04 +0200478 if (!check_sdata_in_driver(sdata))
479 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100480
Johannes Berg4efc76b2010-06-10 10:56:20 +0200481 trace_drv_sta_remove(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100482 if (local->ops->sta_remove)
483 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100484
Johannes Berg4efc76b2010-06-10 10:56:20 +0200485 trace_drv_return_void(local);
Johannes Berg34e89502010-02-03 13:59:58 +0100486}
487
Sujith Manoharan77d2ece2012-11-20 08:46:02 +0530488#ifdef CONFIG_MAC80211_DEBUGFS
489static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
490 struct ieee80211_sub_if_data *sdata,
491 struct ieee80211_sta *sta,
492 struct dentry *dir)
493{
494 might_sleep();
495
496 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba2014-04-30 14:19:04 +0200497 if (!check_sdata_in_driver(sdata))
498 return;
Sujith Manoharan77d2ece2012-11-20 08:46:02 +0530499
500 if (local->ops->sta_add_debugfs)
501 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
502 sta, dir);
503}
Sujith Manoharan77d2ece2012-11-20 08:46:02 +0530504#endif
505
Johannes Berg6a9d1b92013-12-04 22:39:17 +0100506static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
507 struct ieee80211_sub_if_data *sdata,
508 struct sta_info *sta)
509{
510 might_sleep();
511
512 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba2014-04-30 14:19:04 +0200513 if (!check_sdata_in_driver(sdata))
514 return;
Johannes Berg6a9d1b92013-12-04 22:39:17 +0100515
516 trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
517 if (local->ops->sta_pre_rcu_remove)
518 local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
519 &sta->sta);
520 trace_drv_return_void(local);
521}
522
Denys Vlasenko727da602015-07-15 14:56:05 +0200523__must_check
Johannes Bergf09603a2012-01-20 13:55:21 +0100524int drv_sta_state(struct ieee80211_local *local,
525 struct ieee80211_sub_if_data *sdata,
526 struct sta_info *sta,
527 enum ieee80211_sta_state old_state,
Denys Vlasenko727da602015-07-15 14:56:05 +0200528 enum ieee80211_sta_state new_state);
Johannes Bergf09603a2012-01-20 13:55:21 +0100529
Denys Vlasenko4fbd5722015-09-18 15:19:35 +0200530void drv_sta_rc_update(struct ieee80211_local *local,
531 struct ieee80211_sub_if_data *sdata,
532 struct ieee80211_sta *sta, u32 changed);
Johannes Berg8f727ef2012-03-30 08:43:32 +0200533
Johannes Bergf815e2b2014-11-19 00:10:42 +0100534static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
535 struct ieee80211_sub_if_data *sdata,
536 struct ieee80211_sta *sta)
537{
538 sdata = get_bss_sdata(sdata);
539 if (!check_sdata_in_driver(sdata))
540 return;
541
542 trace_drv_sta_rate_tbl_update(local, sdata, sta);
543 if (local->ops->sta_rate_tbl_update)
544 local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
545
546 trace_drv_return_void(local);
547}
548
Johannes Berg2b9a7e12014-11-17 11:35:23 +0100549static inline void drv_sta_statistics(struct ieee80211_local *local,
550 struct ieee80211_sub_if_data *sdata,
551 struct ieee80211_sta *sta,
552 struct station_info *sinfo)
553{
554 sdata = get_bss_sdata(sdata);
555 if (!check_sdata_in_driver(sdata))
556 return;
557
558 trace_drv_sta_statistics(local, sdata, sta);
559 if (local->ops->sta_statistics)
560 local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
561 trace_drv_return_void(local);
562}
563
Denys Vlasenkob23dcd42015-09-18 15:19:34 +0200564int drv_conf_tx(struct ieee80211_local *local,
565 struct ieee80211_sub_if_data *sdata, u16 ac,
566 const struct ieee80211_tx_queue_params *params);
Johannes Berg24487982009-04-23 18:52:52 +0200567
Denys Vlasenko416eb9f2015-09-23 14:18:36 +0200568u64 drv_get_tsf(struct ieee80211_local *local,
569 struct ieee80211_sub_if_data *sdata);
570void drv_set_tsf(struct ieee80211_local *local,
571 struct ieee80211_sub_if_data *sdata,
572 u64 tsf);
Pedersen, Thomas354d3812016-09-28 16:56:28 -0700573void drv_offset_tsf(struct ieee80211_local *local,
574 struct ieee80211_sub_if_data *sdata,
575 s64 offset);
Denys Vlasenko416eb9f2015-09-23 14:18:36 +0200576void drv_reset_tsf(struct ieee80211_local *local,
577 struct ieee80211_sub_if_data *sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200578
579static inline int drv_tx_last_beacon(struct ieee80211_local *local)
580{
Masanari Iida02582e92012-08-22 19:11:26 +0900581 int ret = 0; /* default unsupported op for less congestion */
Kalle Valoe1781ed2009-12-23 13:15:47 +0100582
583 might_sleep();
584
Johannes Berg4efc76b2010-06-10 10:56:20 +0200585 trace_drv_tx_last_beacon(local);
Johannes Berg24487982009-04-23 18:52:52 +0200586 if (local->ops->tx_last_beacon)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200587 ret = local->ops->tx_last_beacon(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200588 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200589 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200590}
591
Denys Vlasenko6db96832015-09-23 14:18:35 +0200592int drv_ampdu_action(struct ieee80211_local *local,
593 struct ieee80211_sub_if_data *sdata,
Sara Sharon50ea05e2015-12-30 16:06:04 +0200594 struct ieee80211_ampdu_params *params);
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200595
Holger Schurig12897232010-04-19 10:23:57 +0200596static inline int drv_get_survey(struct ieee80211_local *local, int idx,
597 struct survey_info *survey)
598{
599 int ret = -EOPNOTSUPP;
John W. Linvillec466d4e2010-06-29 14:51:23 -0400600
601 trace_drv_get_survey(local, idx, survey);
602
Holger Schurig35dd0502010-06-07 16:33:49 +0200603 if (local->ops->get_survey)
Holger Schurig12897232010-04-19 10:23:57 +0200604 ret = local->ops->get_survey(&local->hw, idx, survey);
John W. Linvillec466d4e2010-06-29 14:51:23 -0400605
606 trace_drv_return_int(local, ret);
607
Holger Schurig12897232010-04-19 10:23:57 +0200608 return ret;
609}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200610
611static inline void drv_rfkill_poll(struct ieee80211_local *local)
612{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100613 might_sleep();
614
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200615 if (local->ops->rfkill_poll)
616 local->ops->rfkill_poll(&local->hw);
617}
Johannes Berga80f7c02009-12-23 13:15:32 +0100618
Johannes Berg39ecc012013-02-13 12:11:00 +0100619static inline void drv_flush(struct ieee80211_local *local,
Emmanuel Grumbach77be2c52014-03-27 11:30:29 +0200620 struct ieee80211_sub_if_data *sdata,
Johannes Berg39ecc012013-02-13 12:11:00 +0100621 u32 queues, bool drop)
Johannes Berga80f7c02009-12-23 13:15:32 +0100622{
Emmanuel Grumbach77be2c52014-03-27 11:30:29 +0200623 struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
624
Kalle Valoe1781ed2009-12-23 13:15:47 +0100625 might_sleep();
626
Johannes Bergf6837ba2014-04-30 14:19:04 +0200627 if (sdata && !check_sdata_in_driver(sdata))
628 return;
Emmanuel Grumbach77be2c52014-03-27 11:30:29 +0200629
Johannes Berg39ecc012013-02-13 12:11:00 +0100630 trace_drv_flush(local, queues, drop);
Johannes Berga80f7c02009-12-23 13:15:32 +0100631 if (local->ops->flush)
Emmanuel Grumbach77be2c52014-03-27 11:30:29 +0200632 local->ops->flush(&local->hw, vif, queues, drop);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200633 trace_drv_return_void(local);
Johannes Berga80f7c02009-12-23 13:15:32 +0100634}
Johannes Berg5ce6e432010-05-11 16:20:57 +0200635
636static inline void drv_channel_switch(struct ieee80211_local *local,
Luciano Coelho0f791eb42014-10-08 09:48:40 +0300637 struct ieee80211_sub_if_data *sdata,
638 struct ieee80211_channel_switch *ch_switch)
Johannes Berg5ce6e432010-05-11 16:20:57 +0200639{
640 might_sleep();
641
Luciano Coelho0f791eb42014-10-08 09:48:40 +0300642 trace_drv_channel_switch(local, sdata, ch_switch);
643 local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200644 trace_drv_return_void(local);
Johannes Berg5ce6e432010-05-11 16:20:57 +0200645}
646
Bruno Randolf15d96752010-11-10 12:50:56 +0900647
648static inline int drv_set_antenna(struct ieee80211_local *local,
649 u32 tx_ant, u32 rx_ant)
650{
651 int ret = -EOPNOTSUPP;
652 might_sleep();
653 if (local->ops->set_antenna)
654 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
655 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
656 return ret;
657}
658
659static inline int drv_get_antenna(struct ieee80211_local *local,
660 u32 *tx_ant, u32 *rx_ant)
661{
662 int ret = -EOPNOTSUPP;
663 might_sleep();
664 if (local->ops->get_antenna)
665 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
666 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
667 return ret;
668}
669
Johannes Berg21f83582010-12-18 17:20:47 +0100670static inline int drv_remain_on_channel(struct ieee80211_local *local,
Eliad Peller49884562012-11-19 17:05:09 +0200671 struct ieee80211_sub_if_data *sdata,
Johannes Berg21f83582010-12-18 17:20:47 +0100672 struct ieee80211_channel *chan,
Ilan Peerd339d5c2013-02-12 09:34:13 +0200673 unsigned int duration,
674 enum ieee80211_roc_type type)
Johannes Berg21f83582010-12-18 17:20:47 +0100675{
676 int ret;
677
678 might_sleep();
679
Ilan Peerd339d5c2013-02-12 09:34:13 +0200680 trace_drv_remain_on_channel(local, sdata, chan, duration, type);
Eliad Peller49884562012-11-19 17:05:09 +0200681 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
Ilan Peerd339d5c2013-02-12 09:34:13 +0200682 chan, duration, type);
Johannes Berg21f83582010-12-18 17:20:47 +0100683 trace_drv_return_int(local, ret);
684
685 return ret;
686}
687
688static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
689{
690 int ret;
691
692 might_sleep();
693
694 trace_drv_cancel_remain_on_channel(local);
695 ret = local->ops->cancel_remain_on_channel(&local->hw);
696 trace_drv_return_int(local, ret);
697
698 return ret;
699}
700
John W. Linville38c09152011-03-07 16:19:18 -0500701static inline int drv_set_ringparam(struct ieee80211_local *local,
702 u32 tx, u32 rx)
703{
704 int ret = -ENOTSUPP;
705
706 might_sleep();
707
708 trace_drv_set_ringparam(local, tx, rx);
709 if (local->ops->set_ringparam)
710 ret = local->ops->set_ringparam(&local->hw, tx, rx);
711 trace_drv_return_int(local, ret);
712
713 return ret;
714}
715
716static inline void drv_get_ringparam(struct ieee80211_local *local,
717 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
718{
719 might_sleep();
720
721 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
722 if (local->ops->get_ringparam)
723 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
724 trace_drv_return_void(local);
725}
726
Vivek Natarajane8306f92011-04-06 11:41:10 +0530727static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
728{
729 bool ret = false;
730
731 might_sleep();
732
733 trace_drv_tx_frames_pending(local);
734 if (local->ops->tx_frames_pending)
735 ret = local->ops->tx_frames_pending(&local->hw);
736 trace_drv_return_bool(local, ret);
737
738 return ret;
739}
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530740
741static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
742 struct ieee80211_sub_if_data *sdata,
743 const struct cfg80211_bitrate_mask *mask)
744{
745 int ret = -EOPNOTSUPP;
746
747 might_sleep();
748
Johannes Bergf6837ba2014-04-30 14:19:04 +0200749 if (!check_sdata_in_driver(sdata))
750 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100751
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530752 trace_drv_set_bitrate_mask(local, sdata, mask);
753 if (local->ops->set_bitrate_mask)
754 ret = local->ops->set_bitrate_mask(&local->hw,
755 &sdata->vif, mask);
756 trace_drv_return_int(local, ret);
757
758 return ret;
759}
760
Johannes Bergc68f4b82011-07-05 16:35:41 +0200761static inline void drv_set_rekey_data(struct ieee80211_local *local,
762 struct ieee80211_sub_if_data *sdata,
763 struct cfg80211_gtk_rekey_data *data)
764{
Johannes Bergf6837ba2014-04-30 14:19:04 +0200765 if (!check_sdata_in_driver(sdata))
766 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100767
Johannes Bergc68f4b82011-07-05 16:35:41 +0200768 trace_drv_set_rekey_data(local, sdata, data);
769 if (local->ops->set_rekey_data)
770 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
771 trace_drv_return_void(local);
772}
773
Emmanuel Grumbacha8182922015-03-16 23:23:34 +0200774static inline void drv_event_callback(struct ieee80211_local *local,
775 struct ieee80211_sub_if_data *sdata,
776 const struct ieee80211_event *event)
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700777{
Emmanuel Grumbacha8182922015-03-16 23:23:34 +0200778 trace_drv_event_callback(local, sdata, event);
779 if (local->ops->event_callback)
780 local->ops->event_callback(&local->hw, &sdata->vif, event);
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700781 trace_drv_return_void(local);
782}
Johannes Berg4049e092011-09-29 16:04:32 +0200783
784static inline void
785drv_release_buffered_frames(struct ieee80211_local *local,
786 struct sta_info *sta, u16 tids, int num_frames,
787 enum ieee80211_frame_release_type reason,
788 bool more_data)
789{
790 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
791 reason, more_data);
792 if (local->ops->release_buffered_frames)
793 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
794 num_frames, reason,
795 more_data);
796 trace_drv_return_void(local);
797}
Johannes Berg40b96402011-09-29 16:04:38 +0200798
799static inline void
800drv_allow_buffered_frames(struct ieee80211_local *local,
801 struct sta_info *sta, u16 tids, int num_frames,
802 enum ieee80211_frame_release_type reason,
803 bool more_data)
804{
805 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
806 reason, more_data);
807 if (local->ops->allow_buffered_frames)
808 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
809 tids, num_frames, reason,
810 more_data);
811 trace_drv_return_void(local);
812}
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300813
Johannes Berga1845fc2012-06-27 13:18:36 +0200814static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
815 struct ieee80211_sub_if_data *sdata)
816{
817 might_sleep();
818
Johannes Bergf6837ba2014-04-30 14:19:04 +0200819 if (!check_sdata_in_driver(sdata))
820 return;
Johannes Berga1845fc2012-06-27 13:18:36 +0200821 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
822
823 trace_drv_mgd_prepare_tx(local, sdata);
824 if (local->ops->mgd_prepare_tx)
825 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
826 trace_drv_return_void(local);
827}
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200828
Arik Nemtsovee10f2c2014-06-11 17:18:27 +0300829static inline void
830drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
831 struct ieee80211_sub_if_data *sdata)
832{
833 might_sleep();
834
835 if (!check_sdata_in_driver(sdata))
836 return;
837 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
838
839 trace_drv_mgd_protect_tdls_discover(local, sdata);
840 if (local->ops->mgd_protect_tdls_discover)
841 local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
842 trace_drv_return_void(local);
843}
844
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200845static inline int drv_add_chanctx(struct ieee80211_local *local,
846 struct ieee80211_chanctx *ctx)
847{
848 int ret = -EOPNOTSUPP;
849
Chaitanya T Kdcae9e02015-10-30 23:16:15 +0530850 might_sleep();
851
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200852 trace_drv_add_chanctx(local, ctx);
853 if (local->ops->add_chanctx)
854 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
855 trace_drv_return_int(local, ret);
Johannes Berg8a61af62012-12-13 17:42:30 +0100856 if (!ret)
857 ctx->driver_present = true;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200858
859 return ret;
860}
861
862static inline void drv_remove_chanctx(struct ieee80211_local *local,
863 struct ieee80211_chanctx *ctx)
864{
Chaitanya T Kdcae9e02015-10-30 23:16:15 +0530865 might_sleep();
866
Johannes Bergf6837ba2014-04-30 14:19:04 +0200867 if (WARN_ON(!ctx->driver_present))
868 return;
869
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200870 trace_drv_remove_chanctx(local, ctx);
871 if (local->ops->remove_chanctx)
872 local->ops->remove_chanctx(&local->hw, &ctx->conf);
873 trace_drv_return_void(local);
Johannes Berg8a61af62012-12-13 17:42:30 +0100874 ctx->driver_present = false;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200875}
876
877static inline void drv_change_chanctx(struct ieee80211_local *local,
878 struct ieee80211_chanctx *ctx,
879 u32 changed)
880{
Chaitanya T Kdcae9e02015-10-30 23:16:15 +0530881 might_sleep();
882
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200883 trace_drv_change_chanctx(local, ctx, changed);
Johannes Berg8a61af62012-12-13 17:42:30 +0100884 if (local->ops->change_chanctx) {
885 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200886 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
Johannes Berg8a61af62012-12-13 17:42:30 +0100887 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200888 trace_drv_return_void(local);
889}
890
891static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
892 struct ieee80211_sub_if_data *sdata,
893 struct ieee80211_chanctx *ctx)
894{
895 int ret = 0;
896
Johannes Bergf6837ba2014-04-30 14:19:04 +0200897 if (!check_sdata_in_driver(sdata))
898 return -EIO;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200899
900 trace_drv_assign_vif_chanctx(local, sdata, ctx);
Johannes Berg8a61af62012-12-13 17:42:30 +0100901 if (local->ops->assign_vif_chanctx) {
902 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200903 ret = local->ops->assign_vif_chanctx(&local->hw,
904 &sdata->vif,
905 &ctx->conf);
Johannes Berg8a61af62012-12-13 17:42:30 +0100906 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200907 trace_drv_return_int(local, ret);
908
909 return ret;
910}
911
912static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
913 struct ieee80211_sub_if_data *sdata,
914 struct ieee80211_chanctx *ctx)
915{
Chaitanya T Kdcae9e02015-10-30 23:16:15 +0530916 might_sleep();
917
Johannes Bergf6837ba2014-04-30 14:19:04 +0200918 if (!check_sdata_in_driver(sdata))
919 return;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200920
921 trace_drv_unassign_vif_chanctx(local, sdata, ctx);
Johannes Berg8a61af62012-12-13 17:42:30 +0100922 if (local->ops->unassign_vif_chanctx) {
923 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200924 local->ops->unassign_vif_chanctx(&local->hw,
925 &sdata->vif,
926 &ctx->conf);
Johannes Berg8a61af62012-12-13 17:42:30 +0100927 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200928 trace_drv_return_void(local);
929}
930
Denys Vlasenko42677ed2015-09-23 14:18:34 +0200931int drv_switch_vif_chanctx(struct ieee80211_local *local,
932 struct ieee80211_vif_chanctx_switch *vifs,
933 int n_vifs, enum ieee80211_chanctx_switch_mode mode);
Luciano Coelho1a5f0c12014-05-23 14:33:12 +0300934
Johannes Berg10416382012-10-19 15:44:42 +0200935static inline int drv_start_ap(struct ieee80211_local *local,
936 struct ieee80211_sub_if_data *sdata)
937{
938 int ret = 0;
939
Chaitanya T Kdcae9e02015-10-30 23:16:15 +0530940 might_sleep();
941
Johannes Bergf6837ba2014-04-30 14:19:04 +0200942 if (!check_sdata_in_driver(sdata))
943 return -EIO;
Johannes Berg10416382012-10-19 15:44:42 +0200944
945 trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
946 if (local->ops->start_ap)
947 ret = local->ops->start_ap(&local->hw, &sdata->vif);
948 trace_drv_return_int(local, ret);
949 return ret;
950}
951
952static inline void drv_stop_ap(struct ieee80211_local *local,
953 struct ieee80211_sub_if_data *sdata)
954{
Johannes Bergf6837ba2014-04-30 14:19:04 +0200955 if (!check_sdata_in_driver(sdata))
956 return;
Johannes Berg10416382012-10-19 15:44:42 +0200957
958 trace_drv_stop_ap(local, sdata);
959 if (local->ops->stop_ap)
960 local->ops->stop_ap(&local->hw, &sdata->vif);
961 trace_drv_return_void(local);
962}
963
Eliad Pellercf2c92d2014-11-04 11:43:54 +0200964static inline void
965drv_reconfig_complete(struct ieee80211_local *local,
966 enum ieee80211_reconfig_type reconfig_type)
Johannes Berg9214ad72012-11-06 19:18:13 +0100967{
968 might_sleep();
969
Eliad Pellercf2c92d2014-11-04 11:43:54 +0200970 trace_drv_reconfig_complete(local, reconfig_type);
971 if (local->ops->reconfig_complete)
972 local->ops->reconfig_complete(&local->hw, reconfig_type);
Johannes Berg9214ad72012-11-06 19:18:13 +0100973 trace_drv_return_void(local);
974}
975
Yoni Divinskyde5fad82012-05-30 11:36:39 +0300976static inline void
977drv_set_default_unicast_key(struct ieee80211_local *local,
978 struct ieee80211_sub_if_data *sdata,
979 int key_idx)
980{
Johannes Bergf6837ba2014-04-30 14:19:04 +0200981 if (!check_sdata_in_driver(sdata))
982 return;
Yoni Divinskyde5fad82012-05-30 11:36:39 +0300983
984 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
985
986 trace_drv_set_default_unicast_key(local, sdata, key_idx);
987 if (local->ops->set_default_unicast_key)
988 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
989 key_idx);
990 trace_drv_return_void(local);
991}
992
Johannes Berga65240c2013-01-14 15:14:34 +0100993#if IS_ENABLED(CONFIG_IPV6)
994static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
995 struct ieee80211_sub_if_data *sdata,
996 struct inet6_dev *idev)
997{
998 trace_drv_ipv6_addr_change(local, sdata);
999 if (local->ops->ipv6_addr_change)
1000 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1001 trace_drv_return_void(local);
1002}
1003#endif
1004
Simon Wunderlich73da7d52013-07-11 16:09:06 +02001005static inline void
1006drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1007 struct cfg80211_chan_def *chandef)
1008{
1009 struct ieee80211_local *local = sdata->local;
1010
1011 if (local->ops->channel_switch_beacon) {
1012 trace_drv_channel_switch_beacon(local, sdata, chandef);
1013 local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1014 chandef);
1015 }
1016}
1017
Luciano Coelho6d027bc2014-10-08 09:48:37 +03001018static inline int
1019drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
1020 struct ieee80211_channel_switch *ch_switch)
1021{
1022 struct ieee80211_local *local = sdata->local;
1023 int ret = 0;
1024
1025 if (!check_sdata_in_driver(sdata))
1026 return -EIO;
1027
1028 trace_drv_pre_channel_switch(local, sdata, ch_switch);
1029 if (local->ops->pre_channel_switch)
1030 ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
1031 ch_switch);
1032 trace_drv_return_int(local, ret);
1033 return ret;
1034}
1035
Luciano Coelhof1d65582014-10-08 09:48:38 +03001036static inline int
1037drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1038{
1039 struct ieee80211_local *local = sdata->local;
1040 int ret = 0;
1041
1042 if (!check_sdata_in_driver(sdata))
1043 return -EIO;
1044
1045 trace_drv_post_channel_switch(local, sdata);
1046 if (local->ops->post_channel_switch)
1047 ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1048 trace_drv_return_int(local, ret);
1049 return ret;
1050}
1051
Johannes Berg55fff502013-08-19 18:48:41 +02001052static inline int drv_join_ibss(struct ieee80211_local *local,
1053 struct ieee80211_sub_if_data *sdata)
1054{
1055 int ret = 0;
1056
1057 might_sleep();
Johannes Bergf6837ba2014-04-30 14:19:04 +02001058 if (!check_sdata_in_driver(sdata))
1059 return -EIO;
Johannes Berg55fff502013-08-19 18:48:41 +02001060
1061 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1062 if (local->ops->join_ibss)
1063 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1064 trace_drv_return_int(local, ret);
1065 return ret;
1066}
1067
1068static inline void drv_leave_ibss(struct ieee80211_local *local,
1069 struct ieee80211_sub_if_data *sdata)
1070{
1071 might_sleep();
Johannes Bergf6837ba2014-04-30 14:19:04 +02001072 if (!check_sdata_in_driver(sdata))
1073 return;
Johannes Berg55fff502013-08-19 18:48:41 +02001074
1075 trace_drv_leave_ibss(local, sdata);
1076 if (local->ops->leave_ibss)
1077 local->ops->leave_ibss(&local->hw, &sdata->vif);
1078 trace_drv_return_void(local);
1079}
1080
Antonio Quartullicca674d2014-05-19 21:53:20 +02001081static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
Maxim Altshul4fdbc67a2016-08-11 13:38:16 +03001082 struct sta_info *sta)
Antonio Quartullicca674d2014-05-19 21:53:20 +02001083{
1084 u32 ret = 0;
1085
Maxim Altshul4fdbc67a2016-08-11 13:38:16 +03001086 trace_drv_get_expected_throughput(&sta->sta);
1087 if (local->ops->get_expected_throughput && sta->uploaded)
1088 ret = local->ops->get_expected_throughput(&local->hw, &sta->sta);
Antonio Quartullicca674d2014-05-19 21:53:20 +02001089 trace_drv_return_u32(local, ret);
1090
1091 return ret;
1092}
1093
Felix Fietkau5b3dc422014-10-26 00:32:53 +02001094static inline int drv_get_txpower(struct ieee80211_local *local,
1095 struct ieee80211_sub_if_data *sdata, int *dbm)
1096{
1097 int ret;
1098
1099 if (!local->ops->get_txpower)
1100 return -EOPNOTSUPP;
1101
1102 ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
1103 trace_drv_get_txpower(local, sdata, *dbm, ret);
1104
1105 return ret;
1106}
1107
Arik Nemtsova7a6bdd2014-11-09 18:50:19 +02001108static inline int
1109drv_tdls_channel_switch(struct ieee80211_local *local,
1110 struct ieee80211_sub_if_data *sdata,
1111 struct ieee80211_sta *sta, u8 oper_class,
1112 struct cfg80211_chan_def *chandef,
1113 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
1114{
1115 int ret;
1116
1117 might_sleep();
1118 if (!check_sdata_in_driver(sdata))
1119 return -EIO;
1120
1121 if (!local->ops->tdls_channel_switch)
1122 return -EOPNOTSUPP;
1123
1124 trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
1125 ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
1126 oper_class, chandef, tmpl_skb,
1127 ch_sw_tm_ie);
1128 trace_drv_return_int(local, ret);
1129 return ret;
1130}
1131
1132static inline void
1133drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
1134 struct ieee80211_sub_if_data *sdata,
1135 struct ieee80211_sta *sta)
1136{
1137 might_sleep();
1138 if (!check_sdata_in_driver(sdata))
1139 return;
1140
1141 if (!local->ops->tdls_cancel_channel_switch)
1142 return;
1143
1144 trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
1145 local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
1146 trace_drv_return_void(local);
1147}
1148
Arik Nemtsov8a4d32f2014-11-09 18:50:20 +02001149static inline void
1150drv_tdls_recv_channel_switch(struct ieee80211_local *local,
1151 struct ieee80211_sub_if_data *sdata,
1152 struct ieee80211_tdls_ch_sw_params *params)
1153{
1154 trace_drv_tdls_recv_channel_switch(local, sdata, params);
1155 if (local->ops->tdls_recv_channel_switch)
1156 local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
1157 params);
1158 trace_drv_return_void(local);
1159}
1160
Felix Fietkauba8c3d62015-03-27 21:30:37 +01001161static inline void drv_wake_tx_queue(struct ieee80211_local *local,
1162 struct txq_info *txq)
1163{
1164 struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
1165
Felix Fietkau56e74ed2019-03-01 14:48:37 +01001166 if (local->in_reconfig)
1167 return;
1168
Felix Fietkauba8c3d62015-03-27 21:30:37 +01001169 if (!check_sdata_in_driver(sdata))
1170 return;
1171
1172 trace_drv_wake_tx_queue(local, sdata, txq);
1173 local->ops->wake_tx_queue(&local->hw, &txq->txq);
1174}
1175
Ayala Beker708d50e2016-09-20 17:31:14 +03001176static inline int drv_start_nan(struct ieee80211_local *local,
1177 struct ieee80211_sub_if_data *sdata,
1178 struct cfg80211_nan_conf *conf)
1179{
1180 int ret;
1181
1182 might_sleep();
1183 check_sdata_in_driver(sdata);
1184
1185 trace_drv_start_nan(local, sdata, conf);
1186 ret = local->ops->start_nan(&local->hw, &sdata->vif, conf);
1187 trace_drv_return_int(local, ret);
1188 return ret;
1189}
1190
1191static inline void drv_stop_nan(struct ieee80211_local *local,
1192 struct ieee80211_sub_if_data *sdata)
1193{
1194 might_sleep();
1195 check_sdata_in_driver(sdata);
1196
1197 trace_drv_stop_nan(local, sdata);
1198 local->ops->stop_nan(&local->hw, &sdata->vif);
1199 trace_drv_return_void(local);
1200}
1201
Ayala Beker5953ff62016-09-20 17:31:19 +03001202static inline int drv_nan_change_conf(struct ieee80211_local *local,
1203 struct ieee80211_sub_if_data *sdata,
1204 struct cfg80211_nan_conf *conf,
1205 u32 changes)
1206{
1207 int ret;
1208
1209 might_sleep();
1210 check_sdata_in_driver(sdata);
1211
1212 if (!local->ops->nan_change_conf)
1213 return -EOPNOTSUPP;
1214
1215 trace_drv_nan_change_conf(local, sdata, conf, changes);
1216 ret = local->ops->nan_change_conf(&local->hw, &sdata->vif, conf,
1217 changes);
1218 trace_drv_return_int(local, ret);
1219
1220 return ret;
1221}
1222
Ayala Beker167e33f2016-09-20 17:31:20 +03001223static inline int drv_add_nan_func(struct ieee80211_local *local,
1224 struct ieee80211_sub_if_data *sdata,
1225 const struct cfg80211_nan_func *nan_func)
1226{
1227 int ret;
1228
1229 might_sleep();
1230 check_sdata_in_driver(sdata);
1231
1232 if (!local->ops->add_nan_func)
1233 return -EOPNOTSUPP;
1234
1235 trace_drv_add_nan_func(local, sdata, nan_func);
1236 ret = local->ops->add_nan_func(&local->hw, &sdata->vif, nan_func);
1237 trace_drv_return_int(local, ret);
1238
1239 return ret;
1240}
1241
1242static inline void drv_del_nan_func(struct ieee80211_local *local,
1243 struct ieee80211_sub_if_data *sdata,
1244 u8 instance_id)
1245{
1246 might_sleep();
1247 check_sdata_in_driver(sdata);
1248
1249 trace_drv_del_nan_func(local, sdata, instance_id);
1250 if (local->ops->del_nan_func)
1251 local->ops->del_nan_func(&local->hw, &sdata->vif, instance_id);
1252 trace_drv_return_void(local);
1253}
1254
Johannes Berg24487982009-04-23 18:52:52 +02001255#endif /* __MAC80211_DRIVER_OPS */