blob: c2d8b5451a5ec6c52245ed306d5e0d4e607b3c67 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Sara Sharonf59374e2016-03-02 23:46:14 +02002/*
3* Portions of this file
4* Copyright(c) 2016 Intel Deutschland GmbH
Sara Sharonfafd2bc2019-02-06 13:17:15 +02005* Copyright (C) 2018 - 2019 Intel Corporation
Sara Sharonf59374e2016-03-02 23:46:14 +02006*/
7
Johannes Berg24487982009-04-23 18:52:52 +02008#ifndef __MAC80211_DRIVER_OPS
9#define __MAC80211_DRIVER_OPS
10
11#include <net/mac80211.h>
12#include "ieee80211_i.h"
Johannes Berg011ad0e2012-06-22 12:55:52 +020013#include "trace.h"
Johannes Berg24487982009-04-23 18:52:52 +020014
Johannes Bergf6837ba82014-04-30 14:19:04 +020015static inline bool check_sdata_in_driver(struct ieee80211_sub_if_data *sdata)
Johannes Berg7b7eab62011-11-03 14:41:13 +010016{
Johannes Bergf6837ba82014-04-30 14:19:04 +020017 return !WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER),
18 "%s: Failed check-sdata-in-driver check, flags: 0x%x\n",
19 sdata->dev ? sdata->dev->name : sdata->name, sdata->flags);
Johannes Berg7b7eab62011-11-03 14:41:13 +010020}
21
Felix Fietkaubc192f82011-11-23 21:09:49 +070022static inline struct ieee80211_sub_if_data *
23get_bss_sdata(struct ieee80211_sub_if_data *sdata)
24{
25 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
26 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
27 u.ap);
28
29 return sdata;
30}
31
Thomas Huehn36323f82012-07-23 21:33:42 +020032static inline void drv_tx(struct ieee80211_local *local,
33 struct ieee80211_tx_control *control,
34 struct sk_buff *skb)
Johannes Berg24487982009-04-23 18:52:52 +020035{
Thomas Huehn36323f82012-07-23 21:33:42 +020036 local->ops->tx(&local->hw, control, skb);
Johannes Berg24487982009-04-23 18:52:52 +020037}
38
Sara Sharonf59374e2016-03-02 23:46:14 +020039static inline void drv_sync_rx_queues(struct ieee80211_local *local,
40 struct sta_info *sta)
41{
42 if (local->ops->sync_rx_queues) {
43 trace_drv_sync_rx_queues(local, sta->sdata, &sta->sta);
44 local->ops->sync_rx_queues(&local->hw);
45 trace_drv_return_void(local);
46 }
47}
48
Ben Greeare3521142012-04-23 12:50:31 -070049static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata,
50 u32 sset, u8 *data)
51{
52 struct ieee80211_local *local = sdata->local;
53 if (local->ops->get_et_strings) {
54 trace_drv_get_et_strings(local, sset);
55 local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data);
56 trace_drv_return_void(local);
57 }
58}
59
60static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata,
61 struct ethtool_stats *stats,
62 u64 *data)
63{
64 struct ieee80211_local *local = sdata->local;
65 if (local->ops->get_et_stats) {
66 trace_drv_get_et_stats(local);
67 local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data);
68 trace_drv_return_void(local);
69 }
70}
71
72static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata,
73 int sset)
74{
75 struct ieee80211_local *local = sdata->local;
76 int rv = 0;
77 if (local->ops->get_et_sset_count) {
78 trace_drv_get_et_sset_count(local, sset);
79 rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif,
80 sset);
81 trace_drv_return_int(local, rv);
82 }
83 return rv;
84}
85
Eliad Peller968a76c2015-10-25 10:59:36 +020086int drv_start(struct ieee80211_local *local);
87void drv_stop(struct ieee80211_local *local);
Johannes Berg24487982009-04-23 18:52:52 +020088
Johannes Bergeecc4802011-05-04 15:37:29 +020089#ifdef CONFIG_PM
90static inline int drv_suspend(struct ieee80211_local *local,
91 struct cfg80211_wowlan *wowlan)
92{
93 int ret;
94
95 might_sleep();
96
97 trace_drv_suspend(local);
98 ret = local->ops->suspend(&local->hw, wowlan);
99 trace_drv_return_int(local, ret);
100 return ret;
101}
102
103static inline int drv_resume(struct ieee80211_local *local)
104{
105 int ret;
106
107 might_sleep();
108
109 trace_drv_resume(local);
110 ret = local->ops->resume(&local->hw);
111 trace_drv_return_int(local, ret);
112 return ret;
113}
Johannes Berg6d525632012-04-04 15:05:25 +0200114
115static inline void drv_set_wakeup(struct ieee80211_local *local,
116 bool enabled)
117{
118 might_sleep();
119
120 if (!local->ops->set_wakeup)
121 return;
122
123 trace_drv_set_wakeup(local, enabled);
124 local->ops->set_wakeup(&local->hw, enabled);
125 trace_drv_return_void(local);
126}
Johannes Bergeecc4802011-05-04 15:37:29 +0200127#endif
128
Denys Vlasenko9aae2962015-09-18 15:19:38 +0200129int drv_add_interface(struct ieee80211_local *local,
130 struct ieee80211_sub_if_data *sdata);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100131
Denys Vlasenko9aae2962015-09-18 15:19:38 +0200132int drv_change_interface(struct ieee80211_local *local,
133 struct ieee80211_sub_if_data *sdata,
134 enum nl80211_iftype type, bool p2p);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100135
Denys Vlasenko9aae2962015-09-18 15:19:38 +0200136void drv_remove_interface(struct ieee80211_local *local,
137 struct ieee80211_sub_if_data *sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200138
139static inline int drv_config(struct ieee80211_local *local, u32 changed)
140{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100141 int ret;
142
143 might_sleep();
144
Johannes Berg4efc76b2010-06-10 10:56:20 +0200145 trace_drv_config(local, changed);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100146 ret = local->ops->config(&local->hw, changed);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200147 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200148 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200149}
150
151static inline void drv_bss_info_changed(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100152 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200153 struct ieee80211_bss_conf *info,
154 u32 changed)
155{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100156 might_sleep();
157
Johannes Berg5bbe754d2013-02-13 13:50:51 +0100158 if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
159 BSS_CHANGED_BEACON_ENABLED) &&
160 sdata->vif.type != NL80211_IFTYPE_AP &&
161 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
Rostislav Lisovy239281f2014-11-03 10:33:19 +0100162 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
163 sdata->vif.type != NL80211_IFTYPE_OCB))
Johannes Berg5bbe754d2013-02-13 13:50:51 +0100164 return;
165
166 if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
Ayala Beker708d50e2016-09-20 17:31:14 +0300167 sdata->vif.type == NL80211_IFTYPE_NAN ||
Aviya Erenfeld42bd20d2016-08-29 23:25:16 +0300168 (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
Peter Große3a3713e2017-12-13 18:29:46 +0100169 !sdata->vif.mu_mimo_owner &&
170 !(changed & BSS_CHANGED_TXPOWER))))
Johannes Berg5bbe754d2013-02-13 13:50:51 +0100171 return;
Johannes Bergb8dc1a32012-12-14 14:22:10 +0100172
Johannes Bergf6837ba82014-04-30 14:19:04 +0200173 if (!check_sdata_in_driver(sdata))
174 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100175
Johannes Berg4efc76b2010-06-10 10:56:20 +0200176 trace_drv_bss_info_changed(local, sdata, info, changed);
Johannes Berg24487982009-04-23 18:52:52 +0200177 if (local->ops->bss_info_changed)
Johannes Berg12375ef2009-11-25 20:30:31 +0100178 local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200179 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200180}
181
Johannes Berg3ac64be2009-08-17 16:16:53 +0200182static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
Jiri Pirko22bedad32010-04-01 21:22:57 +0000183 struct netdev_hw_addr_list *mc_list)
Johannes Berg24487982009-04-23 18:52:52 +0200184{
Johannes Berg3ac64be2009-08-17 16:16:53 +0200185 u64 ret = 0;
186
Johannes Berg4efc76b2010-06-10 10:56:20 +0200187 trace_drv_prepare_multicast(local, mc_list->count);
188
Johannes Berg3ac64be2009-08-17 16:16:53 +0200189 if (local->ops->prepare_multicast)
Jiri Pirko22bedad32010-04-01 21:22:57 +0000190 ret = local->ops->prepare_multicast(&local->hw, mc_list);
Johannes Berg3ac64be2009-08-17 16:16:53 +0200191
Johannes Berg4efc76b2010-06-10 10:56:20 +0200192 trace_drv_return_u64(local, ret);
Johannes Berg3ac64be2009-08-17 16:16:53 +0200193
194 return ret;
195}
196
197static inline void drv_configure_filter(struct ieee80211_local *local,
198 unsigned int changed_flags,
199 unsigned int *total_flags,
200 u64 multicast)
201{
202 might_sleep();
203
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200204 trace_drv_configure_filter(local, changed_flags, total_flags,
Johannes Berg3ac64be2009-08-17 16:16:53 +0200205 multicast);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200206 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
207 multicast);
208 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200209}
210
Andrei Otcheretianski1b09b552015-08-15 22:39:50 +0300211static inline void drv_config_iface_filter(struct ieee80211_local *local,
212 struct ieee80211_sub_if_data *sdata,
213 unsigned int filter_flags,
214 unsigned int changed_flags)
215{
216 might_sleep();
217
218 trace_drv_config_iface_filter(local, sdata, filter_flags,
219 changed_flags);
220 if (local->ops->config_iface_filter)
221 local->ops->config_iface_filter(&local->hw, &sdata->vif,
222 filter_flags,
223 changed_flags);
224 trace_drv_return_void(local);
225}
226
Johannes Berg24487982009-04-23 18:52:52 +0200227static inline int drv_set_tim(struct ieee80211_local *local,
228 struct ieee80211_sta *sta, bool set)
229{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200230 int ret = 0;
Johannes Berg4efc76b2010-06-10 10:56:20 +0200231 trace_drv_set_tim(local, sta, set);
Johannes Berg24487982009-04-23 18:52:52 +0200232 if (local->ops->set_tim)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200233 ret = local->ops->set_tim(&local->hw, sta, set);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200234 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200235 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200236}
237
238static inline int drv_set_key(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100239 enum set_key_cmd cmd,
240 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200241 struct ieee80211_sta *sta,
242 struct ieee80211_key_conf *key)
243{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100244 int ret;
245
246 might_sleep();
247
Johannes Berg077f4932012-01-20 13:55:18 +0100248 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba82014-04-30 14:19:04 +0200249 if (!check_sdata_in_driver(sdata))
250 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100251
Johannes Berg4efc76b2010-06-10 10:56:20 +0200252 trace_drv_set_key(local, cmd, sdata, sta, key);
Kalle Valoe1781ed2009-12-23 13:15:47 +0100253 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200254 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200255 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200256}
257
258static inline void drv_update_tkip_key(struct ieee80211_local *local,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100259 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200260 struct ieee80211_key_conf *conf,
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100261 struct sta_info *sta, u32 iv32,
Johannes Berg24487982009-04-23 18:52:52 +0200262 u16 *phase1key)
263{
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100264 struct ieee80211_sta *ista = NULL;
265
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100266 if (sta)
267 ista = &sta->sta;
268
Johannes Berg077f4932012-01-20 13:55:18 +0100269 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba82014-04-30 14:19:04 +0200270 if (!check_sdata_in_driver(sdata))
271 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100272
Johannes Berg4efc76b2010-06-10 10:56:20 +0200273 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
Johannes Berg24487982009-04-23 18:52:52 +0200274 if (local->ops->update_tkip_key)
Johannes Bergb3fbdcf2010-01-21 11:40:47 +0100275 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
276 ista, iv32, phase1key);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200277 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200278}
279
280static inline int drv_hw_scan(struct ieee80211_local *local,
Johannes Berga060bbf2010-04-27 11:59:34 +0200281 struct ieee80211_sub_if_data *sdata,
David Spinadelc56ef672014-02-05 15:21:13 +0200282 struct ieee80211_scan_request *req)
Johannes Berg24487982009-04-23 18:52:52 +0200283{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100284 int ret;
285
286 might_sleep();
287
Johannes Bergf6837ba82014-04-30 14:19:04 +0200288 if (!check_sdata_in_driver(sdata))
289 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100290
Luciano Coelho79f460c2011-05-11 17:09:36 +0300291 trace_drv_hw_scan(local, sdata);
Johannes Berga060bbf2010-04-27 11:59:34 +0200292 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200293 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200294 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200295}
296
Eliad Pellerb8564392011-06-13 12:47:30 +0300297static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
298 struct ieee80211_sub_if_data *sdata)
299{
300 might_sleep();
301
Johannes Bergf6837ba82014-04-30 14:19:04 +0200302 if (!check_sdata_in_driver(sdata))
303 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100304
Eliad Pellerb8564392011-06-13 12:47:30 +0300305 trace_drv_cancel_hw_scan(local, sdata);
306 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
307 trace_drv_return_void(local);
308}
309
Luciano Coelho79f460c2011-05-11 17:09:36 +0300310static inline int
311drv_sched_scan_start(struct ieee80211_local *local,
312 struct ieee80211_sub_if_data *sdata,
313 struct cfg80211_sched_scan_request *req,
David Spinadel633e2712014-02-06 16:15:23 +0200314 struct ieee80211_scan_ies *ies)
Luciano Coelho79f460c2011-05-11 17:09:36 +0300315{
316 int ret;
317
318 might_sleep();
319
Johannes Bergf6837ba82014-04-30 14:19:04 +0200320 if (!check_sdata_in_driver(sdata))
321 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100322
Luciano Coelho79f460c2011-05-11 17:09:36 +0300323 trace_drv_sched_scan_start(local, sdata);
324 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
325 req, ies);
326 trace_drv_return_int(local, ret);
327 return ret;
328}
329
Johannes Berg37e33082014-02-17 10:48:17 +0100330static inline int drv_sched_scan_stop(struct ieee80211_local *local,
331 struct ieee80211_sub_if_data *sdata)
Luciano Coelho79f460c2011-05-11 17:09:36 +0300332{
Johannes Berg37e33082014-02-17 10:48:17 +0100333 int ret;
334
Luciano Coelho79f460c2011-05-11 17:09:36 +0300335 might_sleep();
336
Johannes Bergf6837ba82014-04-30 14:19:04 +0200337 if (!check_sdata_in_driver(sdata))
338 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100339
Luciano Coelho79f460c2011-05-11 17:09:36 +0300340 trace_drv_sched_scan_stop(local, sdata);
Johannes Berg37e33082014-02-17 10:48:17 +0100341 ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
342 trace_drv_return_int(local, ret);
343
344 return ret;
Luciano Coelho79f460c2011-05-11 17:09:36 +0300345}
346
Johannes Berga344d672014-06-12 22:24:31 +0200347static inline void drv_sw_scan_start(struct ieee80211_local *local,
348 struct ieee80211_sub_if_data *sdata,
349 const u8 *mac_addr)
Johannes Berg24487982009-04-23 18:52:52 +0200350{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100351 might_sleep();
352
Johannes Berga344d672014-06-12 22:24:31 +0200353 trace_drv_sw_scan_start(local, sdata, mac_addr);
Johannes Berg24487982009-04-23 18:52:52 +0200354 if (local->ops->sw_scan_start)
Johannes Berga344d672014-06-12 22:24:31 +0200355 local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200356 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200357}
358
Johannes Berga344d672014-06-12 22:24:31 +0200359static inline void drv_sw_scan_complete(struct ieee80211_local *local,
360 struct ieee80211_sub_if_data *sdata)
Johannes Berg24487982009-04-23 18:52:52 +0200361{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100362 might_sleep();
363
Johannes Berga344d672014-06-12 22:24:31 +0200364 trace_drv_sw_scan_complete(local, sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200365 if (local->ops->sw_scan_complete)
Johannes Berga344d672014-06-12 22:24:31 +0200366 local->ops->sw_scan_complete(&local->hw, &sdata->vif);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200367 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200368}
369
370static inline int drv_get_stats(struct ieee80211_local *local,
371 struct ieee80211_low_level_stats *stats)
372{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200373 int ret = -EOPNOTSUPP;
374
Kalle Valoe1781ed2009-12-23 13:15:47 +0100375 might_sleep();
376
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200377 if (local->ops->get_stats)
378 ret = local->ops->get_stats(&local->hw, stats);
379 trace_drv_get_stats(local, stats, ret);
380
381 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200382}
383
Johannes Berg9352c192015-04-20 18:12:41 +0200384static inline void drv_get_key_seq(struct ieee80211_local *local,
385 struct ieee80211_key *key,
386 struct ieee80211_key_seq *seq)
Johannes Berg24487982009-04-23 18:52:52 +0200387{
Johannes Berg9352c192015-04-20 18:12:41 +0200388 if (local->ops->get_key_seq)
389 local->ops->get_key_seq(&local->hw, &key->conf, seq);
390 trace_drv_get_key_seq(local, &key->conf);
Johannes Berg24487982009-04-23 18:52:52 +0200391}
392
Arik Nemtsovf23a4782010-11-08 11:51:06 +0200393static inline int drv_set_frag_threshold(struct ieee80211_local *local,
394 u32 value)
395{
396 int ret = 0;
397
398 might_sleep();
399
400 trace_drv_set_frag_threshold(local, value);
401 if (local->ops->set_frag_threshold)
402 ret = local->ops->set_frag_threshold(&local->hw, value);
403 trace_drv_return_int(local, ret);
404 return ret;
405}
406
Johannes Berg24487982009-04-23 18:52:52 +0200407static inline int drv_set_rts_threshold(struct ieee80211_local *local,
408 u32 value)
409{
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200410 int ret = 0;
Kalle Valoe1781ed2009-12-23 13:15:47 +0100411
412 might_sleep();
413
Johannes Berg4efc76b2010-06-10 10:56:20 +0200414 trace_drv_set_rts_threshold(local, value);
Johannes Berg24487982009-04-23 18:52:52 +0200415 if (local->ops->set_rts_threshold)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200416 ret = local->ops->set_rts_threshold(&local->hw, value);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200417 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200418 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200419}
420
Lukáš Turek310bc672009-12-21 22:50:48 +0100421static inline int drv_set_coverage_class(struct ieee80211_local *local,
Lorenzo Bianconia4bcaf52014-09-04 23:57:41 +0200422 s16 value)
Lukáš Turek310bc672009-12-21 22:50:48 +0100423{
424 int ret = 0;
425 might_sleep();
426
Johannes Berg4efc76b2010-06-10 10:56:20 +0200427 trace_drv_set_coverage_class(local, value);
Lukáš Turek310bc672009-12-21 22:50:48 +0100428 if (local->ops->set_coverage_class)
429 local->ops->set_coverage_class(&local->hw, value);
430 else
431 ret = -EOPNOTSUPP;
432
Johannes Berg4efc76b2010-06-10 10:56:20 +0200433 trace_drv_return_int(local, ret);
Lukáš Turek310bc672009-12-21 22:50:48 +0100434 return ret;
435}
436
Johannes Berg24487982009-04-23 18:52:52 +0200437static inline void drv_sta_notify(struct ieee80211_local *local,
Johannes Berg12375ef2009-11-25 20:30:31 +0100438 struct ieee80211_sub_if_data *sdata,
Johannes Berg24487982009-04-23 18:52:52 +0200439 enum sta_notify_cmd cmd,
440 struct ieee80211_sta *sta)
441{
Felix Fietkaubc192f82011-11-23 21:09:49 +0700442 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba82014-04-30 14:19:04 +0200443 if (!check_sdata_in_driver(sdata))
444 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100445
Johannes Berg4efc76b2010-06-10 10:56:20 +0200446 trace_drv_sta_notify(local, sdata, cmd, sta);
Johannes Berg24487982009-04-23 18:52:52 +0200447 if (local->ops->sta_notify)
Johannes Berg12375ef2009-11-25 20:30:31 +0100448 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200449 trace_drv_return_void(local);
Johannes Berg24487982009-04-23 18:52:52 +0200450}
451
Johannes Berg34e89502010-02-03 13:59:58 +0100452static inline int drv_sta_add(struct ieee80211_local *local,
453 struct ieee80211_sub_if_data *sdata,
454 struct ieee80211_sta *sta)
455{
456 int ret = 0;
457
458 might_sleep();
459
Felix Fietkaubc192f82011-11-23 21:09:49 +0700460 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba82014-04-30 14:19:04 +0200461 if (!check_sdata_in_driver(sdata))
462 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100463
Johannes Berg4efc76b2010-06-10 10:56:20 +0200464 trace_drv_sta_add(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100465 if (local->ops->sta_add)
466 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100467
Johannes Berg4efc76b2010-06-10 10:56:20 +0200468 trace_drv_return_int(local, ret);
Johannes Berg34e89502010-02-03 13:59:58 +0100469
470 return ret;
471}
472
473static inline void drv_sta_remove(struct ieee80211_local *local,
474 struct ieee80211_sub_if_data *sdata,
475 struct ieee80211_sta *sta)
476{
477 might_sleep();
478
Felix Fietkaubc192f82011-11-23 21:09:49 +0700479 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba82014-04-30 14:19:04 +0200480 if (!check_sdata_in_driver(sdata))
481 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100482
Johannes Berg4efc76b2010-06-10 10:56:20 +0200483 trace_drv_sta_remove(local, sdata, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100484 if (local->ops->sta_remove)
485 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
Johannes Berg34e89502010-02-03 13:59:58 +0100486
Johannes Berg4efc76b2010-06-10 10:56:20 +0200487 trace_drv_return_void(local);
Johannes Berg34e89502010-02-03 13:59:58 +0100488}
489
Sujith Manoharan77d2ece62012-11-20 08:46:02 +0530490#ifdef CONFIG_MAC80211_DEBUGFS
491static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
492 struct ieee80211_sub_if_data *sdata,
493 struct ieee80211_sta *sta,
494 struct dentry *dir)
495{
496 might_sleep();
497
498 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba82014-04-30 14:19:04 +0200499 if (!check_sdata_in_driver(sdata))
500 return;
Sujith Manoharan77d2ece62012-11-20 08:46:02 +0530501
502 if (local->ops->sta_add_debugfs)
503 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
504 sta, dir);
505}
Sujith Manoharan77d2ece62012-11-20 08:46:02 +0530506#endif
507
Johannes Berg6a9d1b92013-12-04 22:39:17 +0100508static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
509 struct ieee80211_sub_if_data *sdata,
510 struct sta_info *sta)
511{
512 might_sleep();
513
514 sdata = get_bss_sdata(sdata);
Johannes Bergf6837ba82014-04-30 14:19:04 +0200515 if (!check_sdata_in_driver(sdata))
516 return;
Johannes Berg6a9d1b92013-12-04 22:39:17 +0100517
518 trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
519 if (local->ops->sta_pre_rcu_remove)
520 local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
521 &sta->sta);
522 trace_drv_return_void(local);
523}
524
Denys Vlasenko727da602015-07-15 14:56:05 +0200525__must_check
Johannes Bergf09603a2012-01-20 13:55:21 +0100526int drv_sta_state(struct ieee80211_local *local,
527 struct ieee80211_sub_if_data *sdata,
528 struct sta_info *sta,
529 enum ieee80211_sta_state old_state,
Denys Vlasenko727da602015-07-15 14:56:05 +0200530 enum ieee80211_sta_state new_state);
Johannes Bergf09603a2012-01-20 13:55:21 +0100531
Ashok Raj Nagarajanba905bf2019-03-29 16:19:09 +0530532__must_check
533int drv_sta_set_txpwr(struct ieee80211_local *local,
534 struct ieee80211_sub_if_data *sdata,
535 struct sta_info *sta);
536
Denys Vlasenko4fbd5722015-09-18 15:19:35 +0200537void drv_sta_rc_update(struct ieee80211_local *local,
538 struct ieee80211_sub_if_data *sdata,
539 struct ieee80211_sta *sta, u32 changed);
Johannes Berg8f727ef2012-03-30 08:43:32 +0200540
Johannes Bergf815e2b2014-11-19 00:10:42 +0100541static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
542 struct ieee80211_sub_if_data *sdata,
543 struct ieee80211_sta *sta)
544{
545 sdata = get_bss_sdata(sdata);
546 if (!check_sdata_in_driver(sdata))
547 return;
548
549 trace_drv_sta_rate_tbl_update(local, sdata, sta);
550 if (local->ops->sta_rate_tbl_update)
551 local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
552
553 trace_drv_return_void(local);
554}
555
Johannes Berg2b9a7e12014-11-17 11:35:23 +0100556static inline void drv_sta_statistics(struct ieee80211_local *local,
557 struct ieee80211_sub_if_data *sdata,
558 struct ieee80211_sta *sta,
559 struct station_info *sinfo)
560{
561 sdata = get_bss_sdata(sdata);
562 if (!check_sdata_in_driver(sdata))
563 return;
564
565 trace_drv_sta_statistics(local, sdata, sta);
566 if (local->ops->sta_statistics)
567 local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
568 trace_drv_return_void(local);
569}
570
Denys Vlasenkob23dcd42015-09-18 15:19:34 +0200571int drv_conf_tx(struct ieee80211_local *local,
572 struct ieee80211_sub_if_data *sdata, u16 ac,
573 const struct ieee80211_tx_queue_params *params);
Johannes Berg24487982009-04-23 18:52:52 +0200574
Denys Vlasenko416eb9f2015-09-23 14:18:36 +0200575u64 drv_get_tsf(struct ieee80211_local *local,
576 struct ieee80211_sub_if_data *sdata);
577void drv_set_tsf(struct ieee80211_local *local,
578 struct ieee80211_sub_if_data *sdata,
579 u64 tsf);
Pedersen, Thomas354d3812016-09-28 16:56:28 -0700580void drv_offset_tsf(struct ieee80211_local *local,
581 struct ieee80211_sub_if_data *sdata,
582 s64 offset);
Denys Vlasenko416eb9f2015-09-23 14:18:36 +0200583void drv_reset_tsf(struct ieee80211_local *local,
584 struct ieee80211_sub_if_data *sdata);
Johannes Berg24487982009-04-23 18:52:52 +0200585
586static inline int drv_tx_last_beacon(struct ieee80211_local *local)
587{
Masanari Iida02582e92012-08-22 19:11:26 +0900588 int ret = 0; /* default unsupported op for less congestion */
Kalle Valoe1781ed2009-12-23 13:15:47 +0100589
590 might_sleep();
591
Johannes Berg4efc76b2010-06-10 10:56:20 +0200592 trace_drv_tx_last_beacon(local);
Johannes Berg24487982009-04-23 18:52:52 +0200593 if (local->ops->tx_last_beacon)
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200594 ret = local->ops->tx_last_beacon(&local->hw);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200595 trace_drv_return_int(local, ret);
Johannes Berg0a2b8bb2009-07-07 13:46:22 +0200596 return ret;
Johannes Berg24487982009-04-23 18:52:52 +0200597}
598
Denys Vlasenko6db96832015-09-23 14:18:35 +0200599int drv_ampdu_action(struct ieee80211_local *local,
600 struct ieee80211_sub_if_data *sdata,
Sara Sharon50ea05efa2015-12-30 16:06:04 +0200601 struct ieee80211_ampdu_params *params);
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200602
Holger Schurig12897232010-04-19 10:23:57 +0200603static inline int drv_get_survey(struct ieee80211_local *local, int idx,
604 struct survey_info *survey)
605{
606 int ret = -EOPNOTSUPP;
John W. Linvillec466d4e2010-06-29 14:51:23 -0400607
608 trace_drv_get_survey(local, idx, survey);
609
Holger Schurig35dd0502010-06-07 16:33:49 +0200610 if (local->ops->get_survey)
Holger Schurig12897232010-04-19 10:23:57 +0200611 ret = local->ops->get_survey(&local->hw, idx, survey);
John W. Linvillec466d4e2010-06-29 14:51:23 -0400612
613 trace_drv_return_int(local, ret);
614
Holger Schurig12897232010-04-19 10:23:57 +0200615 return ret;
616}
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200617
618static inline void drv_rfkill_poll(struct ieee80211_local *local)
619{
Kalle Valoe1781ed2009-12-23 13:15:47 +0100620 might_sleep();
621
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200622 if (local->ops->rfkill_poll)
623 local->ops->rfkill_poll(&local->hw);
624}
Johannes Berga80f7c02009-12-23 13:15:32 +0100625
Johannes Berg39ecc012013-02-13 12:11:00 +0100626static inline void drv_flush(struct ieee80211_local *local,
Emmanuel Grumbach77be2c52014-03-27 11:30:29 +0200627 struct ieee80211_sub_if_data *sdata,
Johannes Berg39ecc012013-02-13 12:11:00 +0100628 u32 queues, bool drop)
Johannes Berga80f7c02009-12-23 13:15:32 +0100629{
Emmanuel Grumbach77be2c52014-03-27 11:30:29 +0200630 struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
631
Kalle Valoe1781ed2009-12-23 13:15:47 +0100632 might_sleep();
633
Johannes Bergf6837ba82014-04-30 14:19:04 +0200634 if (sdata && !check_sdata_in_driver(sdata))
635 return;
Emmanuel Grumbach77be2c52014-03-27 11:30:29 +0200636
Johannes Berg39ecc012013-02-13 12:11:00 +0100637 trace_drv_flush(local, queues, drop);
Johannes Berga80f7c02009-12-23 13:15:32 +0100638 if (local->ops->flush)
Emmanuel Grumbach77be2c52014-03-27 11:30:29 +0200639 local->ops->flush(&local->hw, vif, queues, drop);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200640 trace_drv_return_void(local);
Johannes Berga80f7c02009-12-23 13:15:32 +0100641}
Johannes Berg5ce6e432010-05-11 16:20:57 +0200642
643static inline void drv_channel_switch(struct ieee80211_local *local,
Luciano Coelho0f791eb42014-10-08 09:48:40 +0300644 struct ieee80211_sub_if_data *sdata,
645 struct ieee80211_channel_switch *ch_switch)
Johannes Berg5ce6e432010-05-11 16:20:57 +0200646{
647 might_sleep();
648
Luciano Coelho0f791eb42014-10-08 09:48:40 +0300649 trace_drv_channel_switch(local, sdata, ch_switch);
650 local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
Johannes Berg4efc76b2010-06-10 10:56:20 +0200651 trace_drv_return_void(local);
Johannes Berg5ce6e432010-05-11 16:20:57 +0200652}
653
Bruno Randolf15d96752010-11-10 12:50:56 +0900654
655static inline int drv_set_antenna(struct ieee80211_local *local,
656 u32 tx_ant, u32 rx_ant)
657{
658 int ret = -EOPNOTSUPP;
659 might_sleep();
660 if (local->ops->set_antenna)
661 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
662 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
663 return ret;
664}
665
666static inline int drv_get_antenna(struct ieee80211_local *local,
667 u32 *tx_ant, u32 *rx_ant)
668{
669 int ret = -EOPNOTSUPP;
670 might_sleep();
671 if (local->ops->get_antenna)
672 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
673 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
674 return ret;
675}
676
Johannes Berg21f83582010-12-18 17:20:47 +0100677static inline int drv_remain_on_channel(struct ieee80211_local *local,
Eliad Peller49884562012-11-19 17:05:09 +0200678 struct ieee80211_sub_if_data *sdata,
Johannes Berg21f83582010-12-18 17:20:47 +0100679 struct ieee80211_channel *chan,
Ilan Peerd339d5c2013-02-12 09:34:13 +0200680 unsigned int duration,
681 enum ieee80211_roc_type type)
Johannes Berg21f83582010-12-18 17:20:47 +0100682{
683 int ret;
684
685 might_sleep();
686
Ilan Peerd339d5c2013-02-12 09:34:13 +0200687 trace_drv_remain_on_channel(local, sdata, chan, duration, type);
Eliad Peller49884562012-11-19 17:05:09 +0200688 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
Ilan Peerd339d5c2013-02-12 09:34:13 +0200689 chan, duration, type);
Johannes Berg21f83582010-12-18 17:20:47 +0100690 trace_drv_return_int(local, ret);
691
692 return ret;
693}
694
695static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
696{
697 int ret;
698
699 might_sleep();
700
701 trace_drv_cancel_remain_on_channel(local);
702 ret = local->ops->cancel_remain_on_channel(&local->hw);
703 trace_drv_return_int(local, ret);
704
705 return ret;
706}
707
John W. Linville38c09152011-03-07 16:19:18 -0500708static inline int drv_set_ringparam(struct ieee80211_local *local,
709 u32 tx, u32 rx)
710{
711 int ret = -ENOTSUPP;
712
713 might_sleep();
714
715 trace_drv_set_ringparam(local, tx, rx);
716 if (local->ops->set_ringparam)
717 ret = local->ops->set_ringparam(&local->hw, tx, rx);
718 trace_drv_return_int(local, ret);
719
720 return ret;
721}
722
723static inline void drv_get_ringparam(struct ieee80211_local *local,
724 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
725{
726 might_sleep();
727
728 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
729 if (local->ops->get_ringparam)
730 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
731 trace_drv_return_void(local);
732}
733
Vivek Natarajane8306f92011-04-06 11:41:10 +0530734static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
735{
736 bool ret = false;
737
738 might_sleep();
739
740 trace_drv_tx_frames_pending(local);
741 if (local->ops->tx_frames_pending)
742 ret = local->ops->tx_frames_pending(&local->hw);
743 trace_drv_return_bool(local, ret);
744
745 return ret;
746}
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530747
748static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
749 struct ieee80211_sub_if_data *sdata,
750 const struct cfg80211_bitrate_mask *mask)
751{
752 int ret = -EOPNOTSUPP;
753
754 might_sleep();
755
Johannes Bergf6837ba82014-04-30 14:19:04 +0200756 if (!check_sdata_in_driver(sdata))
757 return -EIO;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100758
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +0530759 trace_drv_set_bitrate_mask(local, sdata, mask);
760 if (local->ops->set_bitrate_mask)
761 ret = local->ops->set_bitrate_mask(&local->hw,
762 &sdata->vif, mask);
763 trace_drv_return_int(local, ret);
764
765 return ret;
766}
767
Johannes Bergc68f4b82011-07-05 16:35:41 +0200768static inline void drv_set_rekey_data(struct ieee80211_local *local,
769 struct ieee80211_sub_if_data *sdata,
770 struct cfg80211_gtk_rekey_data *data)
771{
Johannes Bergf6837ba82014-04-30 14:19:04 +0200772 if (!check_sdata_in_driver(sdata))
773 return;
Johannes Berg7b7eab62011-11-03 14:41:13 +0100774
Johannes Bergc68f4b82011-07-05 16:35:41 +0200775 trace_drv_set_rekey_data(local, sdata, data);
776 if (local->ops->set_rekey_data)
777 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
778 trace_drv_return_void(local);
779}
780
Emmanuel Grumbacha8182922015-03-16 23:23:34 +0200781static inline void drv_event_callback(struct ieee80211_local *local,
782 struct ieee80211_sub_if_data *sdata,
783 const struct ieee80211_event *event)
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700784{
Emmanuel Grumbacha8182922015-03-16 23:23:34 +0200785 trace_drv_event_callback(local, sdata, event);
786 if (local->ops->event_callback)
787 local->ops->event_callback(&local->hw, &sdata->vif, event);
Meenakshi Venkataraman615f7b92011-07-08 08:46:22 -0700788 trace_drv_return_void(local);
789}
Johannes Berg4049e092011-09-29 16:04:32 +0200790
791static inline void
792drv_release_buffered_frames(struct ieee80211_local *local,
793 struct sta_info *sta, u16 tids, int num_frames,
794 enum ieee80211_frame_release_type reason,
795 bool more_data)
796{
797 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
798 reason, more_data);
799 if (local->ops->release_buffered_frames)
800 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
801 num_frames, reason,
802 more_data);
803 trace_drv_return_void(local);
804}
Johannes Berg40b96402011-09-29 16:04:38 +0200805
806static inline void
807drv_allow_buffered_frames(struct ieee80211_local *local,
808 struct sta_info *sta, u16 tids, int num_frames,
809 enum ieee80211_frame_release_type reason,
810 bool more_data)
811{
812 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
813 reason, more_data);
814 if (local->ops->allow_buffered_frames)
815 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
816 tids, num_frames, reason,
817 more_data);
818 trace_drv_return_void(local);
819}
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300820
Johannes Berga1845fc2012-06-27 13:18:36 +0200821static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
Ilan Peerd4e36e52018-04-20 13:49:25 +0300822 struct ieee80211_sub_if_data *sdata,
823 u16 duration)
Johannes Berga1845fc2012-06-27 13:18:36 +0200824{
825 might_sleep();
826
Johannes Bergf6837ba82014-04-30 14:19:04 +0200827 if (!check_sdata_in_driver(sdata))
828 return;
Johannes Berga1845fc2012-06-27 13:18:36 +0200829 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
830
Ilan Peerd4e36e52018-04-20 13:49:25 +0300831 trace_drv_mgd_prepare_tx(local, sdata, duration);
Johannes Berga1845fc2012-06-27 13:18:36 +0200832 if (local->ops->mgd_prepare_tx)
Ilan Peerd4e36e52018-04-20 13:49:25 +0300833 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif, duration);
Johannes Berga1845fc2012-06-27 13:18:36 +0200834 trace_drv_return_void(local);
835}
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200836
Arik Nemtsovee10f2c2014-06-11 17:18:27 +0300837static inline void
838drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
839 struct ieee80211_sub_if_data *sdata)
840{
841 might_sleep();
842
843 if (!check_sdata_in_driver(sdata))
844 return;
845 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
846
847 trace_drv_mgd_protect_tdls_discover(local, sdata);
848 if (local->ops->mgd_protect_tdls_discover)
849 local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
850 trace_drv_return_void(local);
851}
852
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200853static inline int drv_add_chanctx(struct ieee80211_local *local,
854 struct ieee80211_chanctx *ctx)
855{
856 int ret = -EOPNOTSUPP;
857
Chaitanya T Kdcae9e02015-10-30 23:16:15 +0530858 might_sleep();
859
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200860 trace_drv_add_chanctx(local, ctx);
861 if (local->ops->add_chanctx)
862 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
863 trace_drv_return_int(local, ret);
Johannes Berg8a61af62012-12-13 17:42:30 +0100864 if (!ret)
865 ctx->driver_present = true;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200866
867 return ret;
868}
869
870static inline void drv_remove_chanctx(struct ieee80211_local *local,
871 struct ieee80211_chanctx *ctx)
872{
Chaitanya T Kdcae9e02015-10-30 23:16:15 +0530873 might_sleep();
874
Johannes Bergf6837ba82014-04-30 14:19:04 +0200875 if (WARN_ON(!ctx->driver_present))
876 return;
877
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200878 trace_drv_remove_chanctx(local, ctx);
879 if (local->ops->remove_chanctx)
880 local->ops->remove_chanctx(&local->hw, &ctx->conf);
881 trace_drv_return_void(local);
Johannes Berg8a61af62012-12-13 17:42:30 +0100882 ctx->driver_present = false;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200883}
884
885static inline void drv_change_chanctx(struct ieee80211_local *local,
886 struct ieee80211_chanctx *ctx,
887 u32 changed)
888{
Chaitanya T Kdcae9e02015-10-30 23:16:15 +0530889 might_sleep();
890
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200891 trace_drv_change_chanctx(local, ctx, changed);
Johannes Berg8a61af62012-12-13 17:42:30 +0100892 if (local->ops->change_chanctx) {
893 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200894 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
Johannes Berg8a61af62012-12-13 17:42:30 +0100895 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200896 trace_drv_return_void(local);
897}
898
899static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
900 struct ieee80211_sub_if_data *sdata,
901 struct ieee80211_chanctx *ctx)
902{
903 int ret = 0;
904
Johannes Bergf6837ba82014-04-30 14:19:04 +0200905 if (!check_sdata_in_driver(sdata))
906 return -EIO;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200907
908 trace_drv_assign_vif_chanctx(local, sdata, ctx);
Johannes Berg8a61af62012-12-13 17:42:30 +0100909 if (local->ops->assign_vif_chanctx) {
910 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200911 ret = local->ops->assign_vif_chanctx(&local->hw,
912 &sdata->vif,
913 &ctx->conf);
Johannes Berg8a61af62012-12-13 17:42:30 +0100914 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200915 trace_drv_return_int(local, ret);
916
917 return ret;
918}
919
920static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
921 struct ieee80211_sub_if_data *sdata,
922 struct ieee80211_chanctx *ctx)
923{
Chaitanya T Kdcae9e02015-10-30 23:16:15 +0530924 might_sleep();
925
Johannes Bergf6837ba82014-04-30 14:19:04 +0200926 if (!check_sdata_in_driver(sdata))
927 return;
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200928
929 trace_drv_unassign_vif_chanctx(local, sdata, ctx);
Johannes Berg8a61af62012-12-13 17:42:30 +0100930 if (local->ops->unassign_vif_chanctx) {
931 WARN_ON_ONCE(!ctx->driver_present);
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200932 local->ops->unassign_vif_chanctx(&local->hw,
933 &sdata->vif,
934 &ctx->conf);
Johannes Berg8a61af62012-12-13 17:42:30 +0100935 }
Michal Kaziorc3645ea2012-06-26 14:37:17 +0200936 trace_drv_return_void(local);
937}
938
Denys Vlasenko42677ed2015-09-23 14:18:34 +0200939int drv_switch_vif_chanctx(struct ieee80211_local *local,
940 struct ieee80211_vif_chanctx_switch *vifs,
941 int n_vifs, enum ieee80211_chanctx_switch_mode mode);
Luciano Coelho1a5f0c12014-05-23 14:33:12 +0300942
Johannes Berg10416382012-10-19 15:44:42 +0200943static inline int drv_start_ap(struct ieee80211_local *local,
944 struct ieee80211_sub_if_data *sdata)
945{
946 int ret = 0;
947
Chaitanya T Kdcae9e02015-10-30 23:16:15 +0530948 might_sleep();
949
Johannes Bergf6837ba82014-04-30 14:19:04 +0200950 if (!check_sdata_in_driver(sdata))
951 return -EIO;
Johannes Berg10416382012-10-19 15:44:42 +0200952
953 trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
954 if (local->ops->start_ap)
955 ret = local->ops->start_ap(&local->hw, &sdata->vif);
956 trace_drv_return_int(local, ret);
957 return ret;
958}
959
960static inline void drv_stop_ap(struct ieee80211_local *local,
961 struct ieee80211_sub_if_data *sdata)
962{
Johannes Bergf6837ba82014-04-30 14:19:04 +0200963 if (!check_sdata_in_driver(sdata))
964 return;
Johannes Berg10416382012-10-19 15:44:42 +0200965
966 trace_drv_stop_ap(local, sdata);
967 if (local->ops->stop_ap)
968 local->ops->stop_ap(&local->hw, &sdata->vif);
969 trace_drv_return_void(local);
970}
971
Eliad Pellercf2c92d2014-11-04 11:43:54 +0200972static inline void
973drv_reconfig_complete(struct ieee80211_local *local,
974 enum ieee80211_reconfig_type reconfig_type)
Johannes Berg9214ad72012-11-06 19:18:13 +0100975{
976 might_sleep();
977
Eliad Pellercf2c92d2014-11-04 11:43:54 +0200978 trace_drv_reconfig_complete(local, reconfig_type);
979 if (local->ops->reconfig_complete)
980 local->ops->reconfig_complete(&local->hw, reconfig_type);
Johannes Berg9214ad72012-11-06 19:18:13 +0100981 trace_drv_return_void(local);
982}
983
Yoni Divinskyde5fad82012-05-30 11:36:39 +0300984static inline void
985drv_set_default_unicast_key(struct ieee80211_local *local,
986 struct ieee80211_sub_if_data *sdata,
987 int key_idx)
988{
Johannes Bergf6837ba82014-04-30 14:19:04 +0200989 if (!check_sdata_in_driver(sdata))
990 return;
Yoni Divinskyde5fad82012-05-30 11:36:39 +0300991
992 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
993
994 trace_drv_set_default_unicast_key(local, sdata, key_idx);
995 if (local->ops->set_default_unicast_key)
996 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
997 key_idx);
998 trace_drv_return_void(local);
999}
1000
Johannes Berga65240c2013-01-14 15:14:34 +01001001#if IS_ENABLED(CONFIG_IPV6)
1002static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1003 struct ieee80211_sub_if_data *sdata,
1004 struct inet6_dev *idev)
1005{
1006 trace_drv_ipv6_addr_change(local, sdata);
1007 if (local->ops->ipv6_addr_change)
1008 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1009 trace_drv_return_void(local);
1010}
1011#endif
1012
Simon Wunderlich73da7d52013-07-11 16:09:06 +02001013static inline void
1014drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1015 struct cfg80211_chan_def *chandef)
1016{
1017 struct ieee80211_local *local = sdata->local;
1018
1019 if (local->ops->channel_switch_beacon) {
1020 trace_drv_channel_switch_beacon(local, sdata, chandef);
1021 local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1022 chandef);
1023 }
1024}
1025
Luciano Coelho6d027bc2014-10-08 09:48:37 +03001026static inline int
1027drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
1028 struct ieee80211_channel_switch *ch_switch)
1029{
1030 struct ieee80211_local *local = sdata->local;
1031 int ret = 0;
1032
1033 if (!check_sdata_in_driver(sdata))
1034 return -EIO;
1035
1036 trace_drv_pre_channel_switch(local, sdata, ch_switch);
1037 if (local->ops->pre_channel_switch)
1038 ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
1039 ch_switch);
1040 trace_drv_return_int(local, ret);
1041 return ret;
1042}
1043
Luciano Coelhof1d65582014-10-08 09:48:38 +03001044static inline int
1045drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1046{
1047 struct ieee80211_local *local = sdata->local;
1048 int ret = 0;
1049
1050 if (!check_sdata_in_driver(sdata))
1051 return -EIO;
1052
1053 trace_drv_post_channel_switch(local, sdata);
1054 if (local->ops->post_channel_switch)
1055 ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1056 trace_drv_return_int(local, ret);
1057 return ret;
1058}
1059
Sara Sharonb9cc81d2019-02-06 13:17:10 +02001060static inline void
1061drv_abort_channel_switch(struct ieee80211_sub_if_data *sdata)
1062{
1063 struct ieee80211_local *local = sdata->local;
1064
1065 if (!check_sdata_in_driver(sdata))
1066 return;
1067
1068 trace_drv_abort_channel_switch(local, sdata);
1069
1070 if (local->ops->abort_channel_switch)
1071 local->ops->abort_channel_switch(&local->hw, &sdata->vif);
1072}
1073
Sara Sharonfafd2bc2019-02-06 13:17:15 +02001074static inline void
1075drv_channel_switch_rx_beacon(struct ieee80211_sub_if_data *sdata,
1076 struct ieee80211_channel_switch *ch_switch)
1077{
1078 struct ieee80211_local *local = sdata->local;
1079
1080 if (!check_sdata_in_driver(sdata))
1081 return;
1082
1083 trace_drv_channel_switch_rx_beacon(local, sdata, ch_switch);
1084 if (local->ops->channel_switch_rx_beacon)
1085 local->ops->channel_switch_rx_beacon(&local->hw, &sdata->vif,
1086 ch_switch);
1087}
1088
Johannes Berg55fff502013-08-19 18:48:41 +02001089static inline int drv_join_ibss(struct ieee80211_local *local,
1090 struct ieee80211_sub_if_data *sdata)
1091{
1092 int ret = 0;
1093
1094 might_sleep();
Johannes Bergf6837ba82014-04-30 14:19:04 +02001095 if (!check_sdata_in_driver(sdata))
1096 return -EIO;
Johannes Berg55fff502013-08-19 18:48:41 +02001097
1098 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1099 if (local->ops->join_ibss)
1100 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1101 trace_drv_return_int(local, ret);
1102 return ret;
1103}
1104
1105static inline void drv_leave_ibss(struct ieee80211_local *local,
1106 struct ieee80211_sub_if_data *sdata)
1107{
1108 might_sleep();
Johannes Bergf6837ba82014-04-30 14:19:04 +02001109 if (!check_sdata_in_driver(sdata))
1110 return;
Johannes Berg55fff502013-08-19 18:48:41 +02001111
1112 trace_drv_leave_ibss(local, sdata);
1113 if (local->ops->leave_ibss)
1114 local->ops->leave_ibss(&local->hw, &sdata->vif);
1115 trace_drv_return_void(local);
1116}
1117
Antonio Quartullicca674d2014-05-19 21:53:20 +02001118static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
Maxim Altshul4fdbc67a2016-08-11 13:38:16 +03001119 struct sta_info *sta)
Antonio Quartullicca674d2014-05-19 21:53:20 +02001120{
1121 u32 ret = 0;
1122
Maxim Altshul4fdbc67a2016-08-11 13:38:16 +03001123 trace_drv_get_expected_throughput(&sta->sta);
1124 if (local->ops->get_expected_throughput && sta->uploaded)
1125 ret = local->ops->get_expected_throughput(&local->hw, &sta->sta);
Antonio Quartullicca674d2014-05-19 21:53:20 +02001126 trace_drv_return_u32(local, ret);
1127
1128 return ret;
1129}
1130
Felix Fietkau5b3dc422014-10-26 00:32:53 +02001131static inline int drv_get_txpower(struct ieee80211_local *local,
1132 struct ieee80211_sub_if_data *sdata, int *dbm)
1133{
1134 int ret;
1135
1136 if (!local->ops->get_txpower)
1137 return -EOPNOTSUPP;
1138
1139 ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
1140 trace_drv_get_txpower(local, sdata, *dbm, ret);
1141
1142 return ret;
1143}
1144
Arik Nemtsova7a6bdd2014-11-09 18:50:19 +02001145static inline int
1146drv_tdls_channel_switch(struct ieee80211_local *local,
1147 struct ieee80211_sub_if_data *sdata,
1148 struct ieee80211_sta *sta, u8 oper_class,
1149 struct cfg80211_chan_def *chandef,
1150 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
1151{
1152 int ret;
1153
1154 might_sleep();
1155 if (!check_sdata_in_driver(sdata))
1156 return -EIO;
1157
1158 if (!local->ops->tdls_channel_switch)
1159 return -EOPNOTSUPP;
1160
1161 trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
1162 ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
1163 oper_class, chandef, tmpl_skb,
1164 ch_sw_tm_ie);
1165 trace_drv_return_int(local, ret);
1166 return ret;
1167}
1168
1169static inline void
1170drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
1171 struct ieee80211_sub_if_data *sdata,
1172 struct ieee80211_sta *sta)
1173{
1174 might_sleep();
1175 if (!check_sdata_in_driver(sdata))
1176 return;
1177
1178 if (!local->ops->tdls_cancel_channel_switch)
1179 return;
1180
1181 trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
1182 local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
1183 trace_drv_return_void(local);
1184}
1185
Arik Nemtsov8a4d32f2014-11-09 18:50:20 +02001186static inline void
1187drv_tdls_recv_channel_switch(struct ieee80211_local *local,
1188 struct ieee80211_sub_if_data *sdata,
1189 struct ieee80211_tdls_ch_sw_params *params)
1190{
1191 trace_drv_tdls_recv_channel_switch(local, sdata, params);
1192 if (local->ops->tdls_recv_channel_switch)
1193 local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
1194 params);
1195 trace_drv_return_void(local);
1196}
1197
Johannes Berge7881bd52017-12-19 10:11:54 +01001198static inline void drv_wake_tx_queue(struct ieee80211_local *local,
1199 struct txq_info *txq)
Felix Fietkauba8c3d62015-03-27 21:30:37 +01001200{
Johannes Berge7881bd52017-12-19 10:11:54 +01001201 struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
1202
Felix Fietkau4856bfd2019-03-01 14:48:37 +01001203 if (local->in_reconfig)
1204 return;
1205
Johannes Berge7881bd52017-12-19 10:11:54 +01001206 if (!check_sdata_in_driver(sdata))
1207 return;
1208
1209 trace_drv_wake_tx_queue(local, sdata, txq);
1210 local->ops->wake_tx_queue(&local->hw, &txq->txq);
Felix Fietkauba8c3d62015-03-27 21:30:37 +01001211}
1212
Toke Høiland-Jørgensen18667602018-12-18 17:02:06 -08001213static inline void schedule_and_wake_txq(struct ieee80211_local *local,
1214 struct txq_info *txqi)
1215{
Toke Høiland-Jørgensen390298e2019-01-22 15:20:16 +01001216 ieee80211_schedule_txq(&local->hw, &txqi->txq);
Toke Høiland-Jørgensen18667602018-12-18 17:02:06 -08001217 drv_wake_tx_queue(local, txqi);
1218}
1219
Sara Sharon9739fe22018-09-05 08:06:11 +03001220static inline int drv_can_aggregate_in_amsdu(struct ieee80211_local *local,
1221 struct sk_buff *head,
1222 struct sk_buff *skb)
1223{
1224 if (!local->ops->can_aggregate_in_amsdu)
1225 return true;
1226
1227 return local->ops->can_aggregate_in_amsdu(&local->hw, head, skb);
1228}
1229
Pradeep Kumar Chitrapubc847972018-10-03 20:19:20 -07001230static inline int
1231drv_get_ftm_responder_stats(struct ieee80211_local *local,
1232 struct ieee80211_sub_if_data *sdata,
1233 struct cfg80211_ftm_responder_stats *ftm_stats)
1234{
1235 u32 ret = -EOPNOTSUPP;
1236
1237 if (local->ops->get_ftm_responder_stats)
1238 ret = local->ops->get_ftm_responder_stats(&local->hw,
1239 &sdata->vif,
1240 ftm_stats);
1241 trace_drv_get_ftm_responder_stats(local, sdata, ftm_stats);
1242
1243 return ret;
1244}
1245
Johannes Bergcee70132018-10-16 11:24:47 +02001246static inline int drv_start_pmsr(struct ieee80211_local *local,
1247 struct ieee80211_sub_if_data *sdata,
1248 struct cfg80211_pmsr_request *request)
1249{
1250 int ret = -EOPNOTSUPP;
1251
1252 might_sleep();
1253 if (!check_sdata_in_driver(sdata))
1254 return -EIO;
1255
1256 trace_drv_start_pmsr(local, sdata);
1257
1258 if (local->ops->start_pmsr)
1259 ret = local->ops->start_pmsr(&local->hw, &sdata->vif, request);
1260 trace_drv_return_int(local, ret);
1261
1262 return ret;
1263}
1264
1265static inline void drv_abort_pmsr(struct ieee80211_local *local,
1266 struct ieee80211_sub_if_data *sdata,
1267 struct cfg80211_pmsr_request *request)
1268{
1269 trace_drv_abort_pmsr(local, sdata);
1270
1271 might_sleep();
1272 if (!check_sdata_in_driver(sdata))
1273 return;
1274
1275 if (local->ops->abort_pmsr)
1276 local->ops->abort_pmsr(&local->hw, &sdata->vif, request);
1277 trace_drv_return_void(local);
1278}
1279
Ayala Beker708d50e2016-09-20 17:31:14 +03001280static inline int drv_start_nan(struct ieee80211_local *local,
1281 struct ieee80211_sub_if_data *sdata,
1282 struct cfg80211_nan_conf *conf)
1283{
1284 int ret;
1285
1286 might_sleep();
1287 check_sdata_in_driver(sdata);
1288
1289 trace_drv_start_nan(local, sdata, conf);
1290 ret = local->ops->start_nan(&local->hw, &sdata->vif, conf);
1291 trace_drv_return_int(local, ret);
1292 return ret;
1293}
1294
1295static inline void drv_stop_nan(struct ieee80211_local *local,
1296 struct ieee80211_sub_if_data *sdata)
1297{
1298 might_sleep();
1299 check_sdata_in_driver(sdata);
1300
1301 trace_drv_stop_nan(local, sdata);
1302 local->ops->stop_nan(&local->hw, &sdata->vif);
1303 trace_drv_return_void(local);
1304}
1305
Ayala Beker5953ff62016-09-20 17:31:19 +03001306static inline int drv_nan_change_conf(struct ieee80211_local *local,
1307 struct ieee80211_sub_if_data *sdata,
1308 struct cfg80211_nan_conf *conf,
1309 u32 changes)
1310{
1311 int ret;
1312
1313 might_sleep();
1314 check_sdata_in_driver(sdata);
1315
1316 if (!local->ops->nan_change_conf)
1317 return -EOPNOTSUPP;
1318
1319 trace_drv_nan_change_conf(local, sdata, conf, changes);
1320 ret = local->ops->nan_change_conf(&local->hw, &sdata->vif, conf,
1321 changes);
1322 trace_drv_return_int(local, ret);
1323
1324 return ret;
1325}
1326
Ayala Beker167e33f2016-09-20 17:31:20 +03001327static inline int drv_add_nan_func(struct ieee80211_local *local,
1328 struct ieee80211_sub_if_data *sdata,
1329 const struct cfg80211_nan_func *nan_func)
1330{
1331 int ret;
1332
1333 might_sleep();
1334 check_sdata_in_driver(sdata);
1335
1336 if (!local->ops->add_nan_func)
1337 return -EOPNOTSUPP;
1338
1339 trace_drv_add_nan_func(local, sdata, nan_func);
1340 ret = local->ops->add_nan_func(&local->hw, &sdata->vif, nan_func);
1341 trace_drv_return_int(local, ret);
1342
1343 return ret;
1344}
1345
1346static inline void drv_del_nan_func(struct ieee80211_local *local,
1347 struct ieee80211_sub_if_data *sdata,
1348 u8 instance_id)
1349{
1350 might_sleep();
1351 check_sdata_in_driver(sdata);
1352
1353 trace_drv_del_nan_func(local, sdata, instance_id);
1354 if (local->ops->del_nan_func)
1355 local->ops->del_nan_func(&local->hw, &sdata->vif, instance_id);
1356 trace_drv_return_void(local);
1357}
1358
Johannes Berg24487982009-04-23 18:52:52 +02001359#endif /* __MAC80211_DRIVER_OPS */