Blame view

net/mac80211/driver-ops.h 31.5 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
f59374eb4   Sara Sharon   mac80211: synchro...
2
3
4
5
  /*
  * Portions of this file
  * Copyright(c) 2016 Intel Deutschland GmbH
  */
244879813   Johannes Berg   mac80211: add dri...
6
7
8
9
10
  #ifndef __MAC80211_DRIVER_OPS
  #define __MAC80211_DRIVER_OPS
  
  #include <net/mac80211.h>
  #include "ieee80211_i.h"
011ad0e9f   Johannes Berg   mac80211: rename ...
11
  #include "trace.h"
244879813   Johannes Berg   mac80211: add dri...
12

f6837ba8c   Johannes Berg   mac80211: handle ...
13
  static inline bool check_sdata_in_driver(struct ieee80211_sub_if_data *sdata)
7b7eab6fc   Johannes Berg   mac80211: verify ...
14
  {
f6837ba8c   Johannes Berg   mac80211: handle ...
15
16
17
18
  	return !WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER),
  		     "%s:  Failed check-sdata-in-driver check, flags: 0x%x
  ",
  		     sdata->dev ? sdata->dev->name : sdata->name, sdata->flags);
7b7eab6fc   Johannes Berg   mac80211: verify ...
19
  }
bc192f891   Felix Fietkau   mac80211: do not ...
20
21
22
23
24
25
26
27
28
  static inline struct ieee80211_sub_if_data *
  get_bss_sdata(struct ieee80211_sub_if_data *sdata)
  {
  	if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  		sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
  				     u.ap);
  
  	return sdata;
  }
36323f817   Thomas Huehn   mac80211: move TX...
29
30
31
  static inline void drv_tx(struct ieee80211_local *local,
  			  struct ieee80211_tx_control *control,
  			  struct sk_buff *skb)
244879813   Johannes Berg   mac80211: add dri...
32
  {
36323f817   Thomas Huehn   mac80211: move TX...
33
  	local->ops->tx(&local->hw, control, skb);
244879813   Johannes Berg   mac80211: add dri...
34
  }
f59374eb4   Sara Sharon   mac80211: synchro...
35
36
37
38
39
40
41
42
43
  static inline void drv_sync_rx_queues(struct ieee80211_local *local,
  				      struct sta_info *sta)
  {
  	if (local->ops->sync_rx_queues) {
  		trace_drv_sync_rx_queues(local, sta->sdata, &sta->sta);
  		local->ops->sync_rx_queues(&local->hw);
  		trace_drv_return_void(local);
  	}
  }
e352114fd   Ben Greear   mac80211: Framewo...
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata,
  				      u32 sset, u8 *data)
  {
  	struct ieee80211_local *local = sdata->local;
  	if (local->ops->get_et_strings) {
  		trace_drv_get_et_strings(local, sset);
  		local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data);
  		trace_drv_return_void(local);
  	}
  }
  
  static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata,
  				    struct ethtool_stats *stats,
  				    u64 *data)
  {
  	struct ieee80211_local *local = sdata->local;
  	if (local->ops->get_et_stats) {
  		trace_drv_get_et_stats(local);
  		local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data);
  		trace_drv_return_void(local);
  	}
  }
  
  static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata,
  					int sset)
  {
  	struct ieee80211_local *local = sdata->local;
  	int rv = 0;
  	if (local->ops->get_et_sset_count) {
  		trace_drv_get_et_sset_count(local, sset);
  		rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif,
  						   sset);
  		trace_drv_return_int(local, rv);
  	}
  	return rv;
  }
968a76cef   Eliad Peller   mac80211: call dr...
80
81
  int drv_start(struct ieee80211_local *local);
  void drv_stop(struct ieee80211_local *local);
244879813   Johannes Berg   mac80211: add dri...
82

eecc48000   Johannes Berg   mac80211: add bas...
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
  #ifdef CONFIG_PM
  static inline int drv_suspend(struct ieee80211_local *local,
  			      struct cfg80211_wowlan *wowlan)
  {
  	int ret;
  
  	might_sleep();
  
  	trace_drv_suspend(local);
  	ret = local->ops->suspend(&local->hw, wowlan);
  	trace_drv_return_int(local, ret);
  	return ret;
  }
  
  static inline int drv_resume(struct ieee80211_local *local)
  {
  	int ret;
  
  	might_sleep();
  
  	trace_drv_resume(local);
  	ret = local->ops->resume(&local->hw);
  	trace_drv_return_int(local, ret);
  	return ret;
  }
6d52563f2   Johannes Berg   cfg80211/mac80211...
108
109
110
111
112
113
114
115
116
117
118
119
120
  
  static inline void drv_set_wakeup(struct ieee80211_local *local,
  				  bool enabled)
  {
  	might_sleep();
  
  	if (!local->ops->set_wakeup)
  		return;
  
  	trace_drv_set_wakeup(local, enabled);
  	local->ops->set_wakeup(&local->hw, enabled);
  	trace_drv_return_void(local);
  }
eecc48000   Johannes Berg   mac80211: add bas...
121
  #endif
9aae296a6   Denys Vlasenko   mac80211: Deinlin...
122
123
  int drv_add_interface(struct ieee80211_local *local,
  		      struct ieee80211_sub_if_data *sdata);
7b7eab6fc   Johannes Berg   mac80211: verify ...
124

9aae296a6   Denys Vlasenko   mac80211: Deinlin...
125
126
127
  int drv_change_interface(struct ieee80211_local *local,
  			 struct ieee80211_sub_if_data *sdata,
  			 enum nl80211_iftype type, bool p2p);
7b7eab6fc   Johannes Berg   mac80211: verify ...
128

9aae296a6   Denys Vlasenko   mac80211: Deinlin...
129
130
  void drv_remove_interface(struct ieee80211_local *local,
  			  struct ieee80211_sub_if_data *sdata);
244879813   Johannes Berg   mac80211: add dri...
131
132
133
  
  static inline int drv_config(struct ieee80211_local *local, u32 changed)
  {
e1781ed33   Kalle Valo   mac80211: annotat...
134
135
136
  	int ret;
  
  	might_sleep();
4efc76bdb   Johannes Berg   mac80211: bracket...
137
  	trace_drv_config(local, changed);
e1781ed33   Kalle Valo   mac80211: annotat...
138
  	ret = local->ops->config(&local->hw, changed);
4efc76bdb   Johannes Berg   mac80211: bracket...
139
  	trace_drv_return_int(local, ret);
0a2b8bb24   Johannes Berg   mac80211: driver ...
140
  	return ret;
244879813   Johannes Berg   mac80211: add dri...
141
142
143
  }
  
  static inline void drv_bss_info_changed(struct ieee80211_local *local,
12375ef93   Johannes Berg   mac80211: trace i...
144
  					struct ieee80211_sub_if_data *sdata,
244879813   Johannes Berg   mac80211: add dri...
145
146
147
  					struct ieee80211_bss_conf *info,
  					u32 changed)
  {
e1781ed33   Kalle Valo   mac80211: annotat...
148
  	might_sleep();
5bbe754d9   Johannes Berg   mac80211: don't c...
149
150
151
152
  	if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
  				    BSS_CHANGED_BEACON_ENABLED) &&
  			 sdata->vif.type != NL80211_IFTYPE_AP &&
  			 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
239281f80   Rostislav Lisovy   mac80211: 802.11p...
153
154
  			 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
  			 sdata->vif.type != NL80211_IFTYPE_OCB))
5bbe754d9   Johannes Berg   mac80211: don't c...
155
156
157
  		return;
  
  	if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
708d50edb   Ayala Beker   mac80211: add boi...
158
  			 sdata->vif.type == NL80211_IFTYPE_NAN ||
42bd20d99   Aviya Erenfeld   mac80211: add sup...
159
  			 (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
bb23fbd8f   Peter Große   mac80211: Fix set...
160
161
  			  !sdata->vif.mu_mimo_owner &&
  			  !(changed & BSS_CHANGED_TXPOWER))))
5bbe754d9   Johannes Berg   mac80211: don't c...
162
  		return;
b8dc1a35c   Johannes Berg   mac80211: further...
163

f6837ba8c   Johannes Berg   mac80211: handle ...
164
165
  	if (!check_sdata_in_driver(sdata))
  		return;
7b7eab6fc   Johannes Berg   mac80211: verify ...
166

4efc76bdb   Johannes Berg   mac80211: bracket...
167
  	trace_drv_bss_info_changed(local, sdata, info, changed);
244879813   Johannes Berg   mac80211: add dri...
168
  	if (local->ops->bss_info_changed)
12375ef93   Johannes Berg   mac80211: trace i...
169
  		local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
4efc76bdb   Johannes Berg   mac80211: bracket...
170
  	trace_drv_return_void(local);
244879813   Johannes Berg   mac80211: add dri...
171
  }
3ac64beec   Johannes Berg   mac80211: allow c...
172
  static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
22bedad3c   Jiri Pirko   net: convert mult...
173
  					struct netdev_hw_addr_list *mc_list)
3ac64beec   Johannes Berg   mac80211: allow c...
174
175
  {
  	u64 ret = 0;
4efc76bdb   Johannes Berg   mac80211: bracket...
176
  	trace_drv_prepare_multicast(local, mc_list->count);
3ac64beec   Johannes Berg   mac80211: allow c...
177
  	if (local->ops->prepare_multicast)
22bedad3c   Jiri Pirko   net: convert mult...
178
  		ret = local->ops->prepare_multicast(&local->hw, mc_list);
3ac64beec   Johannes Berg   mac80211: allow c...
179

4efc76bdb   Johannes Berg   mac80211: bracket...
180
  	trace_drv_return_u64(local, ret);
3ac64beec   Johannes Berg   mac80211: allow c...
181
182
183
  
  	return ret;
  }
244879813   Johannes Berg   mac80211: add dri...
184
185
186
  static inline void drv_configure_filter(struct ieee80211_local *local,
  					unsigned int changed_flags,
  					unsigned int *total_flags,
3ac64beec   Johannes Berg   mac80211: allow c...
187
  					u64 multicast)
244879813   Johannes Berg   mac80211: add dri...
188
  {
3ac64beec   Johannes Berg   mac80211: allow c...
189
  	might_sleep();
0a2b8bb24   Johannes Berg   mac80211: driver ...
190
  	trace_drv_configure_filter(local, changed_flags, total_flags,
3ac64beec   Johannes Berg   mac80211: allow c...
191
  				   multicast);
4efc76bdb   Johannes Berg   mac80211: bracket...
192
193
194
  	local->ops->configure_filter(&local->hw, changed_flags, total_flags,
  				     multicast);
  	trace_drv_return_void(local);
244879813   Johannes Berg   mac80211: add dri...
195
  }
1b09b5568   Andrei Otcheretianski   mac80211: introdu...
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
  static inline void drv_config_iface_filter(struct ieee80211_local *local,
  					   struct ieee80211_sub_if_data *sdata,
  					   unsigned int filter_flags,
  					   unsigned int changed_flags)
  {
  	might_sleep();
  
  	trace_drv_config_iface_filter(local, sdata, filter_flags,
  				      changed_flags);
  	if (local->ops->config_iface_filter)
  		local->ops->config_iface_filter(&local->hw, &sdata->vif,
  						filter_flags,
  						changed_flags);
  	trace_drv_return_void(local);
  }
244879813   Johannes Berg   mac80211: add dri...
211
212
213
  static inline int drv_set_tim(struct ieee80211_local *local,
  			      struct ieee80211_sta *sta, bool set)
  {
0a2b8bb24   Johannes Berg   mac80211: driver ...
214
  	int ret = 0;
4efc76bdb   Johannes Berg   mac80211: bracket...
215
  	trace_drv_set_tim(local, sta, set);
244879813   Johannes Berg   mac80211: add dri...
216
  	if (local->ops->set_tim)
0a2b8bb24   Johannes Berg   mac80211: driver ...
217
  		ret = local->ops->set_tim(&local->hw, sta, set);
4efc76bdb   Johannes Berg   mac80211: bracket...
218
  	trace_drv_return_int(local, ret);
0a2b8bb24   Johannes Berg   mac80211: driver ...
219
  	return ret;
244879813   Johannes Berg   mac80211: add dri...
220
221
222
  }
  
  static inline int drv_set_key(struct ieee80211_local *local,
12375ef93   Johannes Berg   mac80211: trace i...
223
224
  			      enum set_key_cmd cmd,
  			      struct ieee80211_sub_if_data *sdata,
244879813   Johannes Berg   mac80211: add dri...
225
226
227
  			      struct ieee80211_sta *sta,
  			      struct ieee80211_key_conf *key)
  {
e1781ed33   Kalle Valo   mac80211: annotat...
228
229
230
  	int ret;
  
  	might_sleep();
077f49392   Johannes Berg   mac80211: simplif...
231
  	sdata = get_bss_sdata(sdata);
f6837ba8c   Johannes Berg   mac80211: handle ...
232
233
  	if (!check_sdata_in_driver(sdata))
  		return -EIO;
7b7eab6fc   Johannes Berg   mac80211: verify ...
234

4efc76bdb   Johannes Berg   mac80211: bracket...
235
  	trace_drv_set_key(local, cmd, sdata, sta, key);
e1781ed33   Kalle Valo   mac80211: annotat...
236
  	ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
4efc76bdb   Johannes Berg   mac80211: bracket...
237
  	trace_drv_return_int(local, ret);
0a2b8bb24   Johannes Berg   mac80211: driver ...
238
  	return ret;
244879813   Johannes Berg   mac80211: add dri...
239
240
241
  }
  
  static inline void drv_update_tkip_key(struct ieee80211_local *local,
b3fbdcf49   Johannes Berg   mac80211: pass vi...
242
  				       struct ieee80211_sub_if_data *sdata,
244879813   Johannes Berg   mac80211: add dri...
243
  				       struct ieee80211_key_conf *conf,
b3fbdcf49   Johannes Berg   mac80211: pass vi...
244
  				       struct sta_info *sta, u32 iv32,
244879813   Johannes Berg   mac80211: add dri...
245
246
  				       u16 *phase1key)
  {
b3fbdcf49   Johannes Berg   mac80211: pass vi...
247
  	struct ieee80211_sta *ista = NULL;
b3fbdcf49   Johannes Berg   mac80211: pass vi...
248
249
  	if (sta)
  		ista = &sta->sta;
077f49392   Johannes Berg   mac80211: simplif...
250
  	sdata = get_bss_sdata(sdata);
f6837ba8c   Johannes Berg   mac80211: handle ...
251
252
  	if (!check_sdata_in_driver(sdata))
  		return;
7b7eab6fc   Johannes Berg   mac80211: verify ...
253

4efc76bdb   Johannes Berg   mac80211: bracket...
254
  	trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
244879813   Johannes Berg   mac80211: add dri...
255
  	if (local->ops->update_tkip_key)
b3fbdcf49   Johannes Berg   mac80211: pass vi...
256
257
  		local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
  					    ista, iv32, phase1key);
4efc76bdb   Johannes Berg   mac80211: bracket...
258
  	trace_drv_return_void(local);
244879813   Johannes Berg   mac80211: add dri...
259
260
261
  }
  
  static inline int drv_hw_scan(struct ieee80211_local *local,
a060bbfe4   Johannes Berg   mac80211: give vi...
262
  			      struct ieee80211_sub_if_data *sdata,
c56ef6725   David Spinadel   mac80211: support...
263
  			      struct ieee80211_scan_request *req)
244879813   Johannes Berg   mac80211: add dri...
264
  {
e1781ed33   Kalle Valo   mac80211: annotat...
265
266
267
  	int ret;
  
  	might_sleep();
f6837ba8c   Johannes Berg   mac80211: handle ...
268
269
  	if (!check_sdata_in_driver(sdata))
  		return -EIO;
7b7eab6fc   Johannes Berg   mac80211: verify ...
270

79f460ca4   Luciano Coelho   mac80211: add sup...
271
  	trace_drv_hw_scan(local, sdata);
a060bbfe4   Johannes Berg   mac80211: give vi...
272
  	ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
4efc76bdb   Johannes Berg   mac80211: bracket...
273
  	trace_drv_return_int(local, ret);
0a2b8bb24   Johannes Berg   mac80211: driver ...
274
  	return ret;
244879813   Johannes Berg   mac80211: add dri...
275
  }
b856439b1   Eliad Peller   mac80211: add can...
276
277
278
279
  static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
  				      struct ieee80211_sub_if_data *sdata)
  {
  	might_sleep();
f6837ba8c   Johannes Berg   mac80211: handle ...
280
281
  	if (!check_sdata_in_driver(sdata))
  		return;
7b7eab6fc   Johannes Berg   mac80211: verify ...
282

b856439b1   Eliad Peller   mac80211: add can...
283
284
285
286
  	trace_drv_cancel_hw_scan(local, sdata);
  	local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
  	trace_drv_return_void(local);
  }
79f460ca4   Luciano Coelho   mac80211: add sup...
287
288
289
290
  static inline int
  drv_sched_scan_start(struct ieee80211_local *local,
  		     struct ieee80211_sub_if_data *sdata,
  		     struct cfg80211_sched_scan_request *req,
633e27132   David Spinadel   mac80211: split s...
291
  		     struct ieee80211_scan_ies *ies)
79f460ca4   Luciano Coelho   mac80211: add sup...
292
293
294
295
  {
  	int ret;
  
  	might_sleep();
f6837ba8c   Johannes Berg   mac80211: handle ...
296
297
  	if (!check_sdata_in_driver(sdata))
  		return -EIO;
7b7eab6fc   Johannes Berg   mac80211: verify ...
298

79f460ca4   Luciano Coelho   mac80211: add sup...
299
300
301
302
303
304
  	trace_drv_sched_scan_start(local, sdata);
  	ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
  					      req, ies);
  	trace_drv_return_int(local, ret);
  	return ret;
  }
37e3308cb   Johannes Berg   mac80211: allow d...
305
306
  static inline int drv_sched_scan_stop(struct ieee80211_local *local,
  				      struct ieee80211_sub_if_data *sdata)
79f460ca4   Luciano Coelho   mac80211: add sup...
307
  {
37e3308cb   Johannes Berg   mac80211: allow d...
308
  	int ret;
79f460ca4   Luciano Coelho   mac80211: add sup...
309
  	might_sleep();
f6837ba8c   Johannes Berg   mac80211: handle ...
310
311
  	if (!check_sdata_in_driver(sdata))
  		return -EIO;
7b7eab6fc   Johannes Berg   mac80211: verify ...
312

79f460ca4   Luciano Coelho   mac80211: add sup...
313
  	trace_drv_sched_scan_stop(local, sdata);
37e3308cb   Johannes Berg   mac80211: allow d...
314
315
316
317
  	ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
  	trace_drv_return_int(local, ret);
  
  	return ret;
79f460ca4   Luciano Coelho   mac80211: add sup...
318
  }
a344d6778   Johannes Berg   mac80211: allow d...
319
320
321
  static inline void drv_sw_scan_start(struct ieee80211_local *local,
  				     struct ieee80211_sub_if_data *sdata,
  				     const u8 *mac_addr)
244879813   Johannes Berg   mac80211: add dri...
322
  {
e1781ed33   Kalle Valo   mac80211: annotat...
323
  	might_sleep();
a344d6778   Johannes Berg   mac80211: allow d...
324
  	trace_drv_sw_scan_start(local, sdata, mac_addr);
244879813   Johannes Berg   mac80211: add dri...
325
  	if (local->ops->sw_scan_start)
a344d6778   Johannes Berg   mac80211: allow d...
326
  		local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
4efc76bdb   Johannes Berg   mac80211: bracket...
327
  	trace_drv_return_void(local);
244879813   Johannes Berg   mac80211: add dri...
328
  }
a344d6778   Johannes Berg   mac80211: allow d...
329
330
  static inline void drv_sw_scan_complete(struct ieee80211_local *local,
  					struct ieee80211_sub_if_data *sdata)
244879813   Johannes Berg   mac80211: add dri...
331
  {
e1781ed33   Kalle Valo   mac80211: annotat...
332
  	might_sleep();
a344d6778   Johannes Berg   mac80211: allow d...
333
  	trace_drv_sw_scan_complete(local, sdata);
244879813   Johannes Berg   mac80211: add dri...
334
  	if (local->ops->sw_scan_complete)
a344d6778   Johannes Berg   mac80211: allow d...
335
  		local->ops->sw_scan_complete(&local->hw, &sdata->vif);
4efc76bdb   Johannes Berg   mac80211: bracket...
336
  	trace_drv_return_void(local);
244879813   Johannes Berg   mac80211: add dri...
337
338
339
340
341
  }
  
  static inline int drv_get_stats(struct ieee80211_local *local,
  				struct ieee80211_low_level_stats *stats)
  {
0a2b8bb24   Johannes Berg   mac80211: driver ...
342
  	int ret = -EOPNOTSUPP;
e1781ed33   Kalle Valo   mac80211: annotat...
343
  	might_sleep();
0a2b8bb24   Johannes Berg   mac80211: driver ...
344
345
346
347
348
  	if (local->ops->get_stats)
  		ret = local->ops->get_stats(&local->hw, stats);
  	trace_drv_get_stats(local, stats, ret);
  
  	return ret;
244879813   Johannes Berg   mac80211: add dri...
349
  }
9352c19f6   Johannes Berg   mac80211: extend ...
350
351
352
  static inline void drv_get_key_seq(struct ieee80211_local *local,
  				   struct ieee80211_key *key,
  				   struct ieee80211_key_seq *seq)
244879813   Johannes Berg   mac80211: add dri...
353
  {
9352c19f6   Johannes Berg   mac80211: extend ...
354
355
356
  	if (local->ops->get_key_seq)
  		local->ops->get_key_seq(&local->hw, &key->conf, seq);
  	trace_drv_get_key_seq(local, &key->conf);
244879813   Johannes Berg   mac80211: add dri...
357
  }
f23a47807   Arik Nemtsov   mac80211: support...
358
359
360
361
362
363
364
365
366
367
368
369
370
  static inline int drv_set_frag_threshold(struct ieee80211_local *local,
  					u32 value)
  {
  	int ret = 0;
  
  	might_sleep();
  
  	trace_drv_set_frag_threshold(local, value);
  	if (local->ops->set_frag_threshold)
  		ret = local->ops->set_frag_threshold(&local->hw, value);
  	trace_drv_return_int(local, ret);
  	return ret;
  }
244879813   Johannes Berg   mac80211: add dri...
371
372
373
  static inline int drv_set_rts_threshold(struct ieee80211_local *local,
  					u32 value)
  {
0a2b8bb24   Johannes Berg   mac80211: driver ...
374
  	int ret = 0;
e1781ed33   Kalle Valo   mac80211: annotat...
375
376
  
  	might_sleep();
4efc76bdb   Johannes Berg   mac80211: bracket...
377
  	trace_drv_set_rts_threshold(local, value);
244879813   Johannes Berg   mac80211: add dri...
378
  	if (local->ops->set_rts_threshold)
0a2b8bb24   Johannes Berg   mac80211: driver ...
379
  		ret = local->ops->set_rts_threshold(&local->hw, value);
4efc76bdb   Johannes Berg   mac80211: bracket...
380
  	trace_drv_return_int(local, ret);
0a2b8bb24   Johannes Berg   mac80211: driver ...
381
  	return ret;
244879813   Johannes Berg   mac80211: add dri...
382
  }
310bc676e   Lukáš Turek   mac80211: Add new...
383
  static inline int drv_set_coverage_class(struct ieee80211_local *local,
a4bcaf555   Lorenzo Bianconi   mac80211: extend ...
384
  					 s16 value)
310bc676e   Lukáš Turek   mac80211: Add new...
385
386
387
  {
  	int ret = 0;
  	might_sleep();
4efc76bdb   Johannes Berg   mac80211: bracket...
388
  	trace_drv_set_coverage_class(local, value);
310bc676e   Lukáš Turek   mac80211: Add new...
389
390
391
392
  	if (local->ops->set_coverage_class)
  		local->ops->set_coverage_class(&local->hw, value);
  	else
  		ret = -EOPNOTSUPP;
4efc76bdb   Johannes Berg   mac80211: bracket...
393
  	trace_drv_return_int(local, ret);
310bc676e   Lukáš Turek   mac80211: Add new...
394
395
  	return ret;
  }
244879813   Johannes Berg   mac80211: add dri...
396
  static inline void drv_sta_notify(struct ieee80211_local *local,
12375ef93   Johannes Berg   mac80211: trace i...
397
  				  struct ieee80211_sub_if_data *sdata,
244879813   Johannes Berg   mac80211: add dri...
398
399
400
  				  enum sta_notify_cmd cmd,
  				  struct ieee80211_sta *sta)
  {
bc192f891   Felix Fietkau   mac80211: do not ...
401
  	sdata = get_bss_sdata(sdata);
f6837ba8c   Johannes Berg   mac80211: handle ...
402
403
  	if (!check_sdata_in_driver(sdata))
  		return;
7b7eab6fc   Johannes Berg   mac80211: verify ...
404

4efc76bdb   Johannes Berg   mac80211: bracket...
405
  	trace_drv_sta_notify(local, sdata, cmd, sta);
244879813   Johannes Berg   mac80211: add dri...
406
  	if (local->ops->sta_notify)
12375ef93   Johannes Berg   mac80211: trace i...
407
  		local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
4efc76bdb   Johannes Berg   mac80211: bracket...
408
  	trace_drv_return_void(local);
244879813   Johannes Berg   mac80211: add dri...
409
  }
34e895075   Johannes Berg   mac80211: allow s...
410
411
412
413
414
415
416
  static inline int drv_sta_add(struct ieee80211_local *local,
  			      struct ieee80211_sub_if_data *sdata,
  			      struct ieee80211_sta *sta)
  {
  	int ret = 0;
  
  	might_sleep();
bc192f891   Felix Fietkau   mac80211: do not ...
417
  	sdata = get_bss_sdata(sdata);
f6837ba8c   Johannes Berg   mac80211: handle ...
418
419
  	if (!check_sdata_in_driver(sdata))
  		return -EIO;
7b7eab6fc   Johannes Berg   mac80211: verify ...
420

4efc76bdb   Johannes Berg   mac80211: bracket...
421
  	trace_drv_sta_add(local, sdata, sta);
34e895075   Johannes Berg   mac80211: allow s...
422
423
  	if (local->ops->sta_add)
  		ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
34e895075   Johannes Berg   mac80211: allow s...
424

4efc76bdb   Johannes Berg   mac80211: bracket...
425
  	trace_drv_return_int(local, ret);
34e895075   Johannes Berg   mac80211: allow s...
426
427
428
429
430
431
432
433
434
  
  	return ret;
  }
  
  static inline void drv_sta_remove(struct ieee80211_local *local,
  				  struct ieee80211_sub_if_data *sdata,
  				  struct ieee80211_sta *sta)
  {
  	might_sleep();
bc192f891   Felix Fietkau   mac80211: do not ...
435
  	sdata = get_bss_sdata(sdata);
f6837ba8c   Johannes Berg   mac80211: handle ...
436
437
  	if (!check_sdata_in_driver(sdata))
  		return;
7b7eab6fc   Johannes Berg   mac80211: verify ...
438

4efc76bdb   Johannes Berg   mac80211: bracket...
439
  	trace_drv_sta_remove(local, sdata, sta);
34e895075   Johannes Berg   mac80211: allow s...
440
441
  	if (local->ops->sta_remove)
  		local->ops->sta_remove(&local->hw, &sdata->vif, sta);
34e895075   Johannes Berg   mac80211: allow s...
442

4efc76bdb   Johannes Berg   mac80211: bracket...
443
  	trace_drv_return_void(local);
34e895075   Johannes Berg   mac80211: allow s...
444
  }
77d2ece6f   Sujith Manoharan   mac80211: Add deb...
445
446
447
448
449
450
451
452
453
  #ifdef CONFIG_MAC80211_DEBUGFS
  static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
  				       struct ieee80211_sub_if_data *sdata,
  				       struct ieee80211_sta *sta,
  				       struct dentry *dir)
  {
  	might_sleep();
  
  	sdata = get_bss_sdata(sdata);
f6837ba8c   Johannes Berg   mac80211: handle ...
454
455
  	if (!check_sdata_in_driver(sdata))
  		return;
77d2ece6f   Sujith Manoharan   mac80211: Add deb...
456
457
458
459
460
  
  	if (local->ops->sta_add_debugfs)
  		local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
  					    sta, dir);
  }
77d2ece6f   Sujith Manoharan   mac80211: Add deb...
461
  #endif
6a9d1b91f   Johannes Berg   mac80211: add pre...
462
463
464
465
466
467
468
  static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
  					  struct ieee80211_sub_if_data *sdata,
  					  struct sta_info *sta)
  {
  	might_sleep();
  
  	sdata = get_bss_sdata(sdata);
f6837ba8c   Johannes Berg   mac80211: handle ...
469
470
  	if (!check_sdata_in_driver(sdata))
  		return;
6a9d1b91f   Johannes Berg   mac80211: add pre...
471
472
473
474
475
476
477
  
  	trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
  	if (local->ops->sta_pre_rcu_remove)
  		local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
  					       &sta->sta);
  	trace_drv_return_void(local);
  }
727da60be   Denys Vlasenko   mac80211: deinlin...
478
  __must_check
f09603a25   Johannes Berg   mac80211: add sta...
479
480
481
482
  int drv_sta_state(struct ieee80211_local *local,
  		  struct ieee80211_sub_if_data *sdata,
  		  struct sta_info *sta,
  		  enum ieee80211_sta_state old_state,
727da60be   Denys Vlasenko   mac80211: deinlin...
483
  		  enum ieee80211_sta_state new_state);
f09603a25   Johannes Berg   mac80211: add sta...
484

4fbd572c2   Denys Vlasenko   mac80211: Deinlin...
485
486
487
  void drv_sta_rc_update(struct ieee80211_local *local,
  		       struct ieee80211_sub_if_data *sdata,
  		       struct ieee80211_sta *sta, u32 changed);
8f727ef3c   Johannes Berg   mac80211: notify ...
488

f815e2b3c   Johannes Berg   mac80211: notify ...
489
490
491
492
493
494
495
496
497
498
499
500
501
502
  static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
  					   struct ieee80211_sub_if_data *sdata,
  					   struct ieee80211_sta *sta)
  {
  	sdata = get_bss_sdata(sdata);
  	if (!check_sdata_in_driver(sdata))
  		return;
  
  	trace_drv_sta_rate_tbl_update(local, sdata, sta);
  	if (local->ops->sta_rate_tbl_update)
  		local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
  
  	trace_drv_return_void(local);
  }
2b9a7e1ba   Johannes Berg   mac80211: allow d...
503
504
505
506
507
508
509
510
511
512
513
514
515
516
  static inline void drv_sta_statistics(struct ieee80211_local *local,
  				      struct ieee80211_sub_if_data *sdata,
  				      struct ieee80211_sta *sta,
  				      struct station_info *sinfo)
  {
  	sdata = get_bss_sdata(sdata);
  	if (!check_sdata_in_driver(sdata))
  		return;
  
  	trace_drv_sta_statistics(local, sdata, sta);
  	if (local->ops->sta_statistics)
  		local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
  	trace_drv_return_void(local);
  }
b23dcd4ac   Denys Vlasenko   mac80211: Deinlin...
517
518
519
  int drv_conf_tx(struct ieee80211_local *local,
  		struct ieee80211_sub_if_data *sdata, u16 ac,
  		const struct ieee80211_tx_queue_params *params);
244879813   Johannes Berg   mac80211: add dri...
520

416eb9fc2   Denys Vlasenko   mac80211: Deinlin...
521
522
523
524
525
  u64 drv_get_tsf(struct ieee80211_local *local,
  		struct ieee80211_sub_if_data *sdata);
  void drv_set_tsf(struct ieee80211_local *local,
  		 struct ieee80211_sub_if_data *sdata,
  		 u64 tsf);
354d381ba   Pedersen, Thomas   mac80211: add off...
526
527
528
  void drv_offset_tsf(struct ieee80211_local *local,
  		    struct ieee80211_sub_if_data *sdata,
  		    s64 offset);
416eb9fc2   Denys Vlasenko   mac80211: Deinlin...
529
530
  void drv_reset_tsf(struct ieee80211_local *local,
  		   struct ieee80211_sub_if_data *sdata);
244879813   Johannes Berg   mac80211: add dri...
531
532
533
  
  static inline int drv_tx_last_beacon(struct ieee80211_local *local)
  {
02582e9bc   Masanari Iida   treewide: fix typ...
534
  	int ret = 0; /* default unsupported op for less congestion */
e1781ed33   Kalle Valo   mac80211: annotat...
535
536
  
  	might_sleep();
4efc76bdb   Johannes Berg   mac80211: bracket...
537
  	trace_drv_tx_last_beacon(local);
244879813   Johannes Berg   mac80211: add dri...
538
  	if (local->ops->tx_last_beacon)
0a2b8bb24   Johannes Berg   mac80211: driver ...
539
  		ret = local->ops->tx_last_beacon(&local->hw);
4efc76bdb   Johannes Berg   mac80211: bracket...
540
  	trace_drv_return_int(local, ret);
0a2b8bb24   Johannes Berg   mac80211: driver ...
541
  	return ret;
244879813   Johannes Berg   mac80211: add dri...
542
  }
6db968389   Denys Vlasenko   mac80211: Deinlin...
543
544
  int drv_ampdu_action(struct ieee80211_local *local,
  		     struct ieee80211_sub_if_data *sdata,
50ea05efa   Sara Sharon   mac80211: pass bl...
545
  		     struct ieee80211_ampdu_params *params);
1f87f7d3a   Johannes Berg   cfg80211: add rfk...
546

1289723ef   Holger Schurig   mac80211: sample ...
547
548
549
550
  static inline int drv_get_survey(struct ieee80211_local *local, int idx,
  				struct survey_info *survey)
  {
  	int ret = -EOPNOTSUPP;
c466d4efb   John W. Linville   mac80211: add bas...
551
552
  
  	trace_drv_get_survey(local, idx, survey);
35dd0509b   Holger Schurig   mac80211: fix fun...
553
  	if (local->ops->get_survey)
1289723ef   Holger Schurig   mac80211: sample ...
554
  		ret = local->ops->get_survey(&local->hw, idx, survey);
c466d4efb   John W. Linville   mac80211: add bas...
555
556
  
  	trace_drv_return_int(local, ret);
1289723ef   Holger Schurig   mac80211: sample ...
557
558
  	return ret;
  }
1f87f7d3a   Johannes Berg   cfg80211: add rfk...
559
560
561
  
  static inline void drv_rfkill_poll(struct ieee80211_local *local)
  {
e1781ed33   Kalle Valo   mac80211: annotat...
562
  	might_sleep();
1f87f7d3a   Johannes Berg   cfg80211: add rfk...
563
564
565
  	if (local->ops->rfkill_poll)
  		local->ops->rfkill_poll(&local->hw);
  }
a80f7c0b0   Johannes Berg   mac80211: introdu...
566

39ecc01d1   Johannes Berg   mac80211: pass qu...
567
  static inline void drv_flush(struct ieee80211_local *local,
77be2c54c   Emmanuel Grumbach   mac80211: add vif...
568
  			     struct ieee80211_sub_if_data *sdata,
39ecc01d1   Johannes Berg   mac80211: pass qu...
569
  			     u32 queues, bool drop)
a80f7c0b0   Johannes Berg   mac80211: introdu...
570
  {
77be2c54c   Emmanuel Grumbach   mac80211: add vif...
571
  	struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
e1781ed33   Kalle Valo   mac80211: annotat...
572
  	might_sleep();
f6837ba8c   Johannes Berg   mac80211: handle ...
573
574
  	if (sdata && !check_sdata_in_driver(sdata))
  		return;
77be2c54c   Emmanuel Grumbach   mac80211: add vif...
575

39ecc01d1   Johannes Berg   mac80211: pass qu...
576
  	trace_drv_flush(local, queues, drop);
a80f7c0b0   Johannes Berg   mac80211: introdu...
577
  	if (local->ops->flush)
77be2c54c   Emmanuel Grumbach   mac80211: add vif...
578
  		local->ops->flush(&local->hw, vif, queues, drop);
4efc76bdb   Johannes Berg   mac80211: bracket...
579
  	trace_drv_return_void(local);
a80f7c0b0   Johannes Berg   mac80211: introdu...
580
  }
5ce6e438d   Johannes Berg   mac80211: add off...
581
582
  
  static inline void drv_channel_switch(struct ieee80211_local *local,
0f791eb47   Luciano Coelho   mac80211: allow c...
583
584
  				      struct ieee80211_sub_if_data *sdata,
  				      struct ieee80211_channel_switch *ch_switch)
5ce6e438d   Johannes Berg   mac80211: add off...
585
586
  {
  	might_sleep();
0f791eb47   Luciano Coelho   mac80211: allow c...
587
588
  	trace_drv_channel_switch(local, sdata, ch_switch);
  	local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
4efc76bdb   Johannes Berg   mac80211: bracket...
589
  	trace_drv_return_void(local);
5ce6e438d   Johannes Berg   mac80211: add off...
590
  }
15d967532   Bruno Randolf   mac80211: Add ant...
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
  
  static inline int drv_set_antenna(struct ieee80211_local *local,
  				  u32 tx_ant, u32 rx_ant)
  {
  	int ret = -EOPNOTSUPP;
  	might_sleep();
  	if (local->ops->set_antenna)
  		ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
  	trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
  	return ret;
  }
  
  static inline int drv_get_antenna(struct ieee80211_local *local,
  				  u32 *tx_ant, u32 *rx_ant)
  {
  	int ret = -EOPNOTSUPP;
  	might_sleep();
  	if (local->ops->get_antenna)
  		ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
  	trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
  	return ret;
  }
21f835896   Johannes Berg   mac80211: impleme...
613
  static inline int drv_remain_on_channel(struct ieee80211_local *local,
498845686   Eliad Peller   mac80211: make re...
614
  					struct ieee80211_sub_if_data *sdata,
21f835896   Johannes Berg   mac80211: impleme...
615
  					struct ieee80211_channel *chan,
d339d5ca8   Ilan Peer   mac80211: Allow d...
616
617
  					unsigned int duration,
  					enum ieee80211_roc_type type)
21f835896   Johannes Berg   mac80211: impleme...
618
619
620
621
  {
  	int ret;
  
  	might_sleep();
d339d5ca8   Ilan Peer   mac80211: Allow d...
622
  	trace_drv_remain_on_channel(local, sdata, chan, duration, type);
498845686   Eliad Peller   mac80211: make re...
623
  	ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
d339d5ca8   Ilan Peer   mac80211: Allow d...
624
  					    chan, duration, type);
21f835896   Johannes Berg   mac80211: impleme...
625
626
627
628
629
630
631
632
633
634
635
636
637
638
  	trace_drv_return_int(local, ret);
  
  	return ret;
  }
  
  static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
  {
  	int ret;
  
  	might_sleep();
  
  	trace_drv_cancel_remain_on_channel(local);
  	ret = local->ops->cancel_remain_on_channel(&local->hw);
  	trace_drv_return_int(local, ret);
5f16a4361   Johannes Berg   mac80211: support...
639
640
641
  
  	return ret;
  }
38c091590   John W. Linville   mac80211: impleme...
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
  static inline int drv_set_ringparam(struct ieee80211_local *local,
  				    u32 tx, u32 rx)
  {
  	int ret = -ENOTSUPP;
  
  	might_sleep();
  
  	trace_drv_set_ringparam(local, tx, rx);
  	if (local->ops->set_ringparam)
  		ret = local->ops->set_ringparam(&local->hw, tx, rx);
  	trace_drv_return_int(local, ret);
  
  	return ret;
  }
  
  static inline void drv_get_ringparam(struct ieee80211_local *local,
  				     u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
  {
  	might_sleep();
  
  	trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
  	if (local->ops->get_ringparam)
  		local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
  	trace_drv_return_void(local);
  }
e8306f989   Vivek Natarajan   mac80211: Check f...
667
668
669
670
671
672
673
674
675
676
677
678
679
  static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
  {
  	bool ret = false;
  
  	might_sleep();
  
  	trace_drv_tx_frames_pending(local);
  	if (local->ops->tx_frames_pending)
  		ret = local->ops->tx_frames_pending(&local->hw);
  	trace_drv_return_bool(local, ret);
  
  	return ret;
  }
bdbfd6b58   Sujith Manoharan   mac80211: Add new...
680
681
682
683
684
685
686
687
  
  static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
  				       struct ieee80211_sub_if_data *sdata,
  				       const struct cfg80211_bitrate_mask *mask)
  {
  	int ret = -EOPNOTSUPP;
  
  	might_sleep();
f6837ba8c   Johannes Berg   mac80211: handle ...
688
689
  	if (!check_sdata_in_driver(sdata))
  		return -EIO;
7b7eab6fc   Johannes Berg   mac80211: verify ...
690

bdbfd6b58   Sujith Manoharan   mac80211: Add new...
691
692
693
694
695
696
697
698
  	trace_drv_set_bitrate_mask(local, sdata, mask);
  	if (local->ops->set_bitrate_mask)
  		ret = local->ops->set_bitrate_mask(&local->hw,
  						   &sdata->vif, mask);
  	trace_drv_return_int(local, ret);
  
  	return ret;
  }
c68f4b892   Johannes Berg   mac80211: support...
699
700
701
702
  static inline void drv_set_rekey_data(struct ieee80211_local *local,
  				      struct ieee80211_sub_if_data *sdata,
  				      struct cfg80211_gtk_rekey_data *data)
  {
f6837ba8c   Johannes Berg   mac80211: handle ...
703
704
  	if (!check_sdata_in_driver(sdata))
  		return;
7b7eab6fc   Johannes Berg   mac80211: verify ...
705

c68f4b892   Johannes Berg   mac80211: support...
706
707
708
709
710
  	trace_drv_set_rekey_data(local, sdata, data);
  	if (local->ops->set_rekey_data)
  		local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
  	trace_drv_return_void(local);
  }
a81829295   Emmanuel Grumbach   mac80211: convert...
711
712
713
  static inline void drv_event_callback(struct ieee80211_local *local,
  				      struct ieee80211_sub_if_data *sdata,
  				      const struct ieee80211_event *event)
615f7b9bb   Meenakshi Venkataraman   mac80211: add dri...
714
  {
a81829295   Emmanuel Grumbach   mac80211: convert...
715
716
717
  	trace_drv_event_callback(local, sdata, event);
  	if (local->ops->event_callback)
  		local->ops->event_callback(&local->hw, &sdata->vif, event);
615f7b9bb   Meenakshi Venkataraman   mac80211: add dri...
718
719
  	trace_drv_return_void(local);
  }
4049e09ac   Johannes Berg   mac80211: allow r...
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
  
  static inline void
  drv_release_buffered_frames(struct ieee80211_local *local,
  			    struct sta_info *sta, u16 tids, int num_frames,
  			    enum ieee80211_frame_release_type reason,
  			    bool more_data)
  {
  	trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
  					  reason, more_data);
  	if (local->ops->release_buffered_frames)
  		local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
  						    num_frames, reason,
  						    more_data);
  	trace_drv_return_void(local);
  }
40b964088   Johannes Berg   mac80211: explici...
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
  
  static inline void
  drv_allow_buffered_frames(struct ieee80211_local *local,
  			  struct sta_info *sta, u16 tids, int num_frames,
  			  enum ieee80211_frame_release_type reason,
  			  bool more_data)
  {
  	trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
  					reason, more_data);
  	if (local->ops->allow_buffered_frames)
  		local->ops->allow_buffered_frames(&local->hw, &sta->sta,
  						  tids, num_frames, reason,
  						  more_data);
  	trace_drv_return_void(local);
  }
66572cfc3   Victor Goldenshtein   mac80211: add com...
750

a1845fc7c   Johannes Berg   mac80211: add TX ...
751
752
753
754
  static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
  				      struct ieee80211_sub_if_data *sdata)
  {
  	might_sleep();
f6837ba8c   Johannes Berg   mac80211: handle ...
755
756
  	if (!check_sdata_in_driver(sdata))
  		return;
a1845fc7c   Johannes Berg   mac80211: add TX ...
757
758
759
760
761
762
763
  	WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
  
  	trace_drv_mgd_prepare_tx(local, sdata);
  	if (local->ops->mgd_prepare_tx)
  		local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
  	trace_drv_return_void(local);
  }
c3645eac4   Michal Kazior   mac80211: introdu...
764

ee10f2c77   Arik Nemtsov   mac80211: protect...
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
  static inline void
  drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
  			      struct ieee80211_sub_if_data *sdata)
  {
  	might_sleep();
  
  	if (!check_sdata_in_driver(sdata))
  		return;
  	WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
  
  	trace_drv_mgd_protect_tdls_discover(local, sdata);
  	if (local->ops->mgd_protect_tdls_discover)
  		local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
  	trace_drv_return_void(local);
  }
c3645eac4   Michal Kazior   mac80211: introdu...
780
781
782
783
  static inline int drv_add_chanctx(struct ieee80211_local *local,
  				  struct ieee80211_chanctx *ctx)
  {
  	int ret = -EOPNOTSUPP;
dcae9e020   Chaitanya T K   mac80211: documen...
784
  	might_sleep();
c3645eac4   Michal Kazior   mac80211: introdu...
785
786
787
788
  	trace_drv_add_chanctx(local, ctx);
  	if (local->ops->add_chanctx)
  		ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
  	trace_drv_return_int(local, ret);
8a61af65c   Johannes Berg   mac80211: fix cha...
789
790
  	if (!ret)
  		ctx->driver_present = true;
c3645eac4   Michal Kazior   mac80211: introdu...
791
792
793
794
795
796
797
  
  	return ret;
  }
  
  static inline void drv_remove_chanctx(struct ieee80211_local *local,
  				      struct ieee80211_chanctx *ctx)
  {
dcae9e020   Chaitanya T K   mac80211: documen...
798
  	might_sleep();
f6837ba8c   Johannes Berg   mac80211: handle ...
799
800
  	if (WARN_ON(!ctx->driver_present))
  		return;
c3645eac4   Michal Kazior   mac80211: introdu...
801
802
803
804
  	trace_drv_remove_chanctx(local, ctx);
  	if (local->ops->remove_chanctx)
  		local->ops->remove_chanctx(&local->hw, &ctx->conf);
  	trace_drv_return_void(local);
8a61af65c   Johannes Berg   mac80211: fix cha...
805
  	ctx->driver_present = false;
c3645eac4   Michal Kazior   mac80211: introdu...
806
807
808
809
810
811
  }
  
  static inline void drv_change_chanctx(struct ieee80211_local *local,
  				      struct ieee80211_chanctx *ctx,
  				      u32 changed)
  {
dcae9e020   Chaitanya T K   mac80211: documen...
812
  	might_sleep();
c3645eac4   Michal Kazior   mac80211: introdu...
813
  	trace_drv_change_chanctx(local, ctx, changed);
8a61af65c   Johannes Berg   mac80211: fix cha...
814
815
  	if (local->ops->change_chanctx) {
  		WARN_ON_ONCE(!ctx->driver_present);
c3645eac4   Michal Kazior   mac80211: introdu...
816
  		local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
8a61af65c   Johannes Berg   mac80211: fix cha...
817
  	}
c3645eac4   Michal Kazior   mac80211: introdu...
818
819
820
821
822
823
824
825
  	trace_drv_return_void(local);
  }
  
  static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
  					 struct ieee80211_sub_if_data *sdata,
  					 struct ieee80211_chanctx *ctx)
  {
  	int ret = 0;
f6837ba8c   Johannes Berg   mac80211: handle ...
826
827
  	if (!check_sdata_in_driver(sdata))
  		return -EIO;
c3645eac4   Michal Kazior   mac80211: introdu...
828
829
  
  	trace_drv_assign_vif_chanctx(local, sdata, ctx);
8a61af65c   Johannes Berg   mac80211: fix cha...
830
831
  	if (local->ops->assign_vif_chanctx) {
  		WARN_ON_ONCE(!ctx->driver_present);
c3645eac4   Michal Kazior   mac80211: introdu...
832
833
834
  		ret = local->ops->assign_vif_chanctx(&local->hw,
  						     &sdata->vif,
  						     &ctx->conf);
8a61af65c   Johannes Berg   mac80211: fix cha...
835
  	}
c3645eac4   Michal Kazior   mac80211: introdu...
836
837
838
839
840
841
842
843
844
  	trace_drv_return_int(local, ret);
  
  	return ret;
  }
  
  static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
  					    struct ieee80211_sub_if_data *sdata,
  					    struct ieee80211_chanctx *ctx)
  {
dcae9e020   Chaitanya T K   mac80211: documen...
845
  	might_sleep();
f6837ba8c   Johannes Berg   mac80211: handle ...
846
847
  	if (!check_sdata_in_driver(sdata))
  		return;
c3645eac4   Michal Kazior   mac80211: introdu...
848
849
  
  	trace_drv_unassign_vif_chanctx(local, sdata, ctx);
8a61af65c   Johannes Berg   mac80211: fix cha...
850
851
  	if (local->ops->unassign_vif_chanctx) {
  		WARN_ON_ONCE(!ctx->driver_present);
c3645eac4   Michal Kazior   mac80211: introdu...
852
853
854
  		local->ops->unassign_vif_chanctx(&local->hw,
  						 &sdata->vif,
  						 &ctx->conf);
8a61af65c   Johannes Berg   mac80211: fix cha...
855
  	}
c3645eac4   Michal Kazior   mac80211: introdu...
856
857
  	trace_drv_return_void(local);
  }
42677ed33   Denys Vlasenko   mac80211: Deinlin...
858
859
860
  int drv_switch_vif_chanctx(struct ieee80211_local *local,
  			   struct ieee80211_vif_chanctx_switch *vifs,
  			   int n_vifs, enum ieee80211_chanctx_switch_mode mode);
1a5f0c13d   Luciano Coelho   mac80211: add a s...
861

1041638f2   Johannes Berg   mac80211: add exp...
862
863
864
865
  static inline int drv_start_ap(struct ieee80211_local *local,
  			       struct ieee80211_sub_if_data *sdata)
  {
  	int ret = 0;
dcae9e020   Chaitanya T K   mac80211: documen...
866
  	might_sleep();
f6837ba8c   Johannes Berg   mac80211: handle ...
867
868
  	if (!check_sdata_in_driver(sdata))
  		return -EIO;
1041638f2   Johannes Berg   mac80211: add exp...
869
870
871
872
873
874
875
876
877
878
879
  
  	trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
  	if (local->ops->start_ap)
  		ret = local->ops->start_ap(&local->hw, &sdata->vif);
  	trace_drv_return_int(local, ret);
  	return ret;
  }
  
  static inline void drv_stop_ap(struct ieee80211_local *local,
  			       struct ieee80211_sub_if_data *sdata)
  {
f6837ba8c   Johannes Berg   mac80211: handle ...
880
881
  	if (!check_sdata_in_driver(sdata))
  		return;
1041638f2   Johannes Berg   mac80211: add exp...
882
883
884
885
886
887
  
  	trace_drv_stop_ap(local, sdata);
  	if (local->ops->stop_ap)
  		local->ops->stop_ap(&local->hw, &sdata->vif);
  	trace_drv_return_void(local);
  }
cf2c92d84   Eliad Peller   mac80211: replace...
888
889
890
  static inline void
  drv_reconfig_complete(struct ieee80211_local *local,
  		      enum ieee80211_reconfig_type reconfig_type)
9214ad7f9   Johannes Berg   mac80211: call dr...
891
892
  {
  	might_sleep();
cf2c92d84   Eliad Peller   mac80211: replace...
893
894
895
  	trace_drv_reconfig_complete(local, reconfig_type);
  	if (local->ops->reconfig_complete)
  		local->ops->reconfig_complete(&local->hw, reconfig_type);
9214ad7f9   Johannes Berg   mac80211: call dr...
896
897
  	trace_drv_return_void(local);
  }
de5fad815   Yoni Divinsky   mac80211: add op ...
898
899
900
901
902
  static inline void
  drv_set_default_unicast_key(struct ieee80211_local *local,
  			    struct ieee80211_sub_if_data *sdata,
  			    int key_idx)
  {
f6837ba8c   Johannes Berg   mac80211: handle ...
903
904
  	if (!check_sdata_in_driver(sdata))
  		return;
de5fad815   Yoni Divinsky   mac80211: add op ...
905
906
907
908
909
910
911
912
913
  
  	WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
  
  	trace_drv_set_default_unicast_key(local, sdata, key_idx);
  	if (local->ops->set_default_unicast_key)
  		local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
  						    key_idx);
  	trace_drv_return_void(local);
  }
a65240c10   Johannes Berg   mac80211: allow d...
914
915
916
917
918
919
920
921
922
923
924
  #if IS_ENABLED(CONFIG_IPV6)
  static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
  					struct ieee80211_sub_if_data *sdata,
  					struct inet6_dev *idev)
  {
  	trace_drv_ipv6_addr_change(local, sdata);
  	if (local->ops->ipv6_addr_change)
  		local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
  	trace_drv_return_void(local);
  }
  #endif
73da7d5ba   Simon Wunderlich   mac80211: add cha...
925
926
927
928
929
930
931
932
933
934
935
936
  static inline void
  drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
  			  struct cfg80211_chan_def *chandef)
  {
  	struct ieee80211_local *local = sdata->local;
  
  	if (local->ops->channel_switch_beacon) {
  		trace_drv_channel_switch_beacon(local, sdata, chandef);
  		local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
  						  chandef);
  	}
  }
6d027bcc8   Luciano Coelho   mac80211: add pre...
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
  static inline int
  drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
  		       struct ieee80211_channel_switch *ch_switch)
  {
  	struct ieee80211_local *local = sdata->local;
  	int ret = 0;
  
  	if (!check_sdata_in_driver(sdata))
  		return -EIO;
  
  	trace_drv_pre_channel_switch(local, sdata, ch_switch);
  	if (local->ops->pre_channel_switch)
  		ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
  						     ch_switch);
  	trace_drv_return_int(local, ret);
  	return ret;
  }
f1d65583b   Luciano Coelho   mac80211: add pos...
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
  static inline int
  drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
  {
  	struct ieee80211_local *local = sdata->local;
  	int ret = 0;
  
  	if (!check_sdata_in_driver(sdata))
  		return -EIO;
  
  	trace_drv_post_channel_switch(local, sdata);
  	if (local->ops->post_channel_switch)
  		ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
  	trace_drv_return_int(local, ret);
  	return ret;
  }
55fff5011   Johannes Berg   mac80211: add exp...
969
970
971
972
973
974
  static inline int drv_join_ibss(struct ieee80211_local *local,
  				struct ieee80211_sub_if_data *sdata)
  {
  	int ret = 0;
  
  	might_sleep();
f6837ba8c   Johannes Berg   mac80211: handle ...
975
976
  	if (!check_sdata_in_driver(sdata))
  		return -EIO;
55fff5011   Johannes Berg   mac80211: add exp...
977
978
979
980
981
982
983
984
985
986
987
988
  
  	trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
  	if (local->ops->join_ibss)
  		ret = local->ops->join_ibss(&local->hw, &sdata->vif);
  	trace_drv_return_int(local, ret);
  	return ret;
  }
  
  static inline void drv_leave_ibss(struct ieee80211_local *local,
  				  struct ieee80211_sub_if_data *sdata)
  {
  	might_sleep();
f6837ba8c   Johannes Berg   mac80211: handle ...
989
990
  	if (!check_sdata_in_driver(sdata))
  		return;
55fff5011   Johannes Berg   mac80211: add exp...
991
992
993
994
995
996
  
  	trace_drv_leave_ibss(local, sdata);
  	if (local->ops->leave_ibss)
  		local->ops->leave_ibss(&local->hw, &sdata->vif);
  	trace_drv_return_void(local);
  }
cca674d47   Antonio Quartulli   mac80211: export ...
997
  static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
4fdbc67a2   Maxim Altshul   mac80211: call ge...
998
  					      struct sta_info *sta)
cca674d47   Antonio Quartulli   mac80211: export ...
999
1000
  {
  	u32 ret = 0;
4fdbc67a2   Maxim Altshul   mac80211: call ge...
1001
1002
1003
  	trace_drv_get_expected_throughput(&sta->sta);
  	if (local->ops->get_expected_throughput && sta->uploaded)
  		ret = local->ops->get_expected_throughput(&local->hw, &sta->sta);
cca674d47   Antonio Quartulli   mac80211: export ...
1004
1005
1006
1007
  	trace_drv_return_u32(local, ret);
  
  	return ret;
  }
5b3dc42b1   Felix Fietkau   mac80211: add sup...
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
  static inline int drv_get_txpower(struct ieee80211_local *local,
  				  struct ieee80211_sub_if_data *sdata, int *dbm)
  {
  	int ret;
  
  	if (!local->ops->get_txpower)
  		return -EOPNOTSUPP;
  
  	ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
  	trace_drv_get_txpower(local, sdata, *dbm, ret);
  
  	return ret;
  }
a7a6bdd06   Arik Nemtsov   mac80211: introdu...
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
  static inline int
  drv_tdls_channel_switch(struct ieee80211_local *local,
  			struct ieee80211_sub_if_data *sdata,
  			struct ieee80211_sta *sta, u8 oper_class,
  			struct cfg80211_chan_def *chandef,
  			struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
  {
  	int ret;
  
  	might_sleep();
  	if (!check_sdata_in_driver(sdata))
  		return -EIO;
  
  	if (!local->ops->tdls_channel_switch)
  		return -EOPNOTSUPP;
  
  	trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
  	ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
  					      oper_class, chandef, tmpl_skb,
  					      ch_sw_tm_ie);
  	trace_drv_return_int(local, ret);
  	return ret;
  }
  
  static inline void
  drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
  			       struct ieee80211_sub_if_data *sdata,
  			       struct ieee80211_sta *sta)
  {
  	might_sleep();
  	if (!check_sdata_in_driver(sdata))
  		return;
  
  	if (!local->ops->tdls_cancel_channel_switch)
  		return;
  
  	trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
  	local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
  	trace_drv_return_void(local);
  }
8a4d32f30   Arik Nemtsov   mac80211: add TDL...
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
  static inline void
  drv_tdls_recv_channel_switch(struct ieee80211_local *local,
  			     struct ieee80211_sub_if_data *sdata,
  			     struct ieee80211_tdls_ch_sw_params *params)
  {
  	trace_drv_tdls_recv_channel_switch(local, sdata, params);
  	if (local->ops->tdls_recv_channel_switch)
  		local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
  						     params);
  	trace_drv_return_void(local);
  }
ba8c3d6f1   Felix Fietkau   mac80211: add an ...
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
  static inline void drv_wake_tx_queue(struct ieee80211_local *local,
  				     struct txq_info *txq)
  {
  	struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
  
  	if (!check_sdata_in_driver(sdata))
  		return;
  
  	trace_drv_wake_tx_queue(local, sdata, txq);
  	local->ops->wake_tx_queue(&local->hw, &txq->txq);
  }
708d50edb   Ayala Beker   mac80211: add boi...
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
  static inline int drv_start_nan(struct ieee80211_local *local,
  				struct ieee80211_sub_if_data *sdata,
  				struct cfg80211_nan_conf *conf)
  {
  	int ret;
  
  	might_sleep();
  	check_sdata_in_driver(sdata);
  
  	trace_drv_start_nan(local, sdata, conf);
  	ret = local->ops->start_nan(&local->hw, &sdata->vif, conf);
  	trace_drv_return_int(local, ret);
  	return ret;
  }
  
  static inline void drv_stop_nan(struct ieee80211_local *local,
  				struct ieee80211_sub_if_data *sdata)
  {
  	might_sleep();
  	check_sdata_in_driver(sdata);
  
  	trace_drv_stop_nan(local, sdata);
  	local->ops->stop_nan(&local->hw, &sdata->vif);
  	trace_drv_return_void(local);
  }
5953ff6d6   Ayala Beker   mac80211: impleme...
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
  static inline int drv_nan_change_conf(struct ieee80211_local *local,
  				       struct ieee80211_sub_if_data *sdata,
  				       struct cfg80211_nan_conf *conf,
  				       u32 changes)
  {
  	int ret;
  
  	might_sleep();
  	check_sdata_in_driver(sdata);
  
  	if (!local->ops->nan_change_conf)
  		return -EOPNOTSUPP;
  
  	trace_drv_nan_change_conf(local, sdata, conf, changes);
  	ret = local->ops->nan_change_conf(&local->hw, &sdata->vif, conf,
  					  changes);
  	trace_drv_return_int(local, ret);
  
  	return ret;
  }
167e33f4f   Ayala Beker   mac80211: Impleme...
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
  static inline int drv_add_nan_func(struct ieee80211_local *local,
  				   struct ieee80211_sub_if_data *sdata,
  				   const struct cfg80211_nan_func *nan_func)
  {
  	int ret;
  
  	might_sleep();
  	check_sdata_in_driver(sdata);
  
  	if (!local->ops->add_nan_func)
  		return -EOPNOTSUPP;
  
  	trace_drv_add_nan_func(local, sdata, nan_func);
  	ret = local->ops->add_nan_func(&local->hw, &sdata->vif, nan_func);
  	trace_drv_return_int(local, ret);
  
  	return ret;
  }
  
  static inline void drv_del_nan_func(struct ieee80211_local *local,
  				   struct ieee80211_sub_if_data *sdata,
  				   u8 instance_id)
  {
  	might_sleep();
  	check_sdata_in_driver(sdata);
  
  	trace_drv_del_nan_func(local, sdata, instance_id);
  	if (local->ops->del_nan_func)
  		local->ops->del_nan_func(&local->hw, &sdata->vif, instance_id);
  	trace_drv_return_void(local);
  }
244879813   Johannes Berg   mac80211: add dri...
1159
  #endif /* __MAC80211_DRIVER_OPS */