Commit | Line | Data |
---|---|---|
24487981 JB |
1 | #ifndef __MAC80211_DRIVER_OPS |
2 | #define __MAC80211_DRIVER_OPS | |
3 | ||
4 | #include <net/mac80211.h> | |
5 | #include "ieee80211_i.h" | |
011ad0e9 | 6 | #include "trace.h" |
24487981 | 7 | |
7b7eab6f JB |
8 | static inline void check_sdata_in_driver(struct ieee80211_sub_if_data *sdata) |
9 | { | |
d17087e7 BG |
10 | WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER), |
11 | "%s: Failed check-sdata-in-driver check, flags: 0x%x\n", | |
f142c6b9 | 12 | sdata->dev ? sdata->dev->name : sdata->name, sdata->flags); |
7b7eab6f JB |
13 | } |
14 | ||
bc192f89 FF |
15 | static inline struct ieee80211_sub_if_data * |
16 | get_bss_sdata(struct ieee80211_sub_if_data *sdata) | |
17 | { | |
18 | if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) | |
19 | sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, | |
20 | u.ap); | |
21 | ||
22 | return sdata; | |
23 | } | |
24 | ||
36323f81 TH |
25 | static inline void drv_tx(struct ieee80211_local *local, |
26 | struct ieee80211_tx_control *control, | |
27 | struct sk_buff *skb) | |
24487981 | 28 | { |
36323f81 | 29 | local->ops->tx(&local->hw, control, skb); |
24487981 JB |
30 | } |
31 | ||
e352114f BG |
32 | static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata, |
33 | u32 sset, u8 *data) | |
34 | { | |
35 | struct ieee80211_local *local = sdata->local; | |
36 | if (local->ops->get_et_strings) { | |
37 | trace_drv_get_et_strings(local, sset); | |
38 | local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data); | |
39 | trace_drv_return_void(local); | |
40 | } | |
41 | } | |
42 | ||
43 | static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata, | |
44 | struct ethtool_stats *stats, | |
45 | u64 *data) | |
46 | { | |
47 | struct ieee80211_local *local = sdata->local; | |
48 | if (local->ops->get_et_stats) { | |
49 | trace_drv_get_et_stats(local); | |
50 | local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data); | |
51 | trace_drv_return_void(local); | |
52 | } | |
53 | } | |
54 | ||
55 | static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata, | |
56 | int sset) | |
57 | { | |
58 | struct ieee80211_local *local = sdata->local; | |
59 | int rv = 0; | |
60 | if (local->ops->get_et_sset_count) { | |
61 | trace_drv_get_et_sset_count(local, sset); | |
62 | rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif, | |
63 | sset); | |
64 | trace_drv_return_int(local, rv); | |
65 | } | |
66 | return rv; | |
67 | } | |
68 | ||
24487981 JB |
69 | static inline int drv_start(struct ieee80211_local *local) |
70 | { | |
ea77f12f JB |
71 | int ret; |
72 | ||
e1781ed3 KV |
73 | might_sleep(); |
74 | ||
4efc76bd | 75 | trace_drv_start(local); |
ea77f12f JB |
76 | local->started = true; |
77 | smp_mb(); | |
78 | ret = local->ops->start(&local->hw); | |
4efc76bd | 79 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 80 | return ret; |
24487981 JB |
81 | } |
82 | ||
83 | static inline void drv_stop(struct ieee80211_local *local) | |
84 | { | |
e1781ed3 KV |
85 | might_sleep(); |
86 | ||
0a2b8bb2 | 87 | trace_drv_stop(local); |
4efc76bd JB |
88 | local->ops->stop(&local->hw); |
89 | trace_drv_return_void(local); | |
ea77f12f JB |
90 | |
91 | /* sync away all work on the tasklet before clearing started */ | |
92 | tasklet_disable(&local->tasklet); | |
93 | tasklet_enable(&local->tasklet); | |
94 | ||
95 | barrier(); | |
96 | ||
97 | local->started = false; | |
24487981 JB |
98 | } |
99 | ||
eecc4800 JB |
100 | #ifdef CONFIG_PM |
101 | static inline int drv_suspend(struct ieee80211_local *local, | |
102 | struct cfg80211_wowlan *wowlan) | |
103 | { | |
104 | int ret; | |
105 | ||
106 | might_sleep(); | |
107 | ||
108 | trace_drv_suspend(local); | |
109 | ret = local->ops->suspend(&local->hw, wowlan); | |
110 | trace_drv_return_int(local, ret); | |
111 | return ret; | |
112 | } | |
113 | ||
114 | static inline int drv_resume(struct ieee80211_local *local) | |
115 | { | |
116 | int ret; | |
117 | ||
118 | might_sleep(); | |
119 | ||
120 | trace_drv_resume(local); | |
121 | ret = local->ops->resume(&local->hw); | |
122 | trace_drv_return_int(local, ret); | |
123 | return ret; | |
124 | } | |
6d52563f JB |
125 | |
126 | static inline void drv_set_wakeup(struct ieee80211_local *local, | |
127 | bool enabled) | |
128 | { | |
129 | might_sleep(); | |
130 | ||
131 | if (!local->ops->set_wakeup) | |
132 | return; | |
133 | ||
134 | trace_drv_set_wakeup(local, enabled); | |
135 | local->ops->set_wakeup(&local->hw, enabled); | |
136 | trace_drv_return_void(local); | |
137 | } | |
eecc4800 JB |
138 | #endif |
139 | ||
24487981 | 140 | static inline int drv_add_interface(struct ieee80211_local *local, |
7b7eab6f | 141 | struct ieee80211_sub_if_data *sdata) |
24487981 | 142 | { |
e1781ed3 KV |
143 | int ret; |
144 | ||
145 | might_sleep(); | |
146 | ||
7b7eab6f | 147 | if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN || |
4b6f1dd6 JB |
148 | (sdata->vif.type == NL80211_IFTYPE_MONITOR && |
149 | !(local->hw.flags & IEEE80211_HW_WANT_MONITOR_VIF)))) | |
7b7eab6f JB |
150 | return -EINVAL; |
151 | ||
152 | trace_drv_add_interface(local, sdata); | |
153 | ret = local->ops->add_interface(&local->hw, &sdata->vif); | |
4efc76bd | 154 | trace_drv_return_int(local, ret); |
7b7eab6f JB |
155 | |
156 | if (ret == 0) | |
157 | sdata->flags |= IEEE80211_SDATA_IN_DRIVER; | |
158 | ||
0a2b8bb2 | 159 | return ret; |
24487981 JB |
160 | } |
161 | ||
34d4bc4d JB |
162 | static inline int drv_change_interface(struct ieee80211_local *local, |
163 | struct ieee80211_sub_if_data *sdata, | |
2ca27bcf | 164 | enum nl80211_iftype type, bool p2p) |
34d4bc4d JB |
165 | { |
166 | int ret; | |
167 | ||
168 | might_sleep(); | |
169 | ||
7b7eab6f JB |
170 | check_sdata_in_driver(sdata); |
171 | ||
2ca27bcf JB |
172 | trace_drv_change_interface(local, sdata, type, p2p); |
173 | ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p); | |
34d4bc4d JB |
174 | trace_drv_return_int(local, ret); |
175 | return ret; | |
176 | } | |
177 | ||
24487981 | 178 | static inline void drv_remove_interface(struct ieee80211_local *local, |
7b7eab6f | 179 | struct ieee80211_sub_if_data *sdata) |
24487981 | 180 | { |
e1781ed3 KV |
181 | might_sleep(); |
182 | ||
7b7eab6f JB |
183 | check_sdata_in_driver(sdata); |
184 | ||
185 | trace_drv_remove_interface(local, sdata); | |
186 | local->ops->remove_interface(&local->hw, &sdata->vif); | |
187 | sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER; | |
4efc76bd | 188 | trace_drv_return_void(local); |
24487981 JB |
189 | } |
190 | ||
191 | static inline int drv_config(struct ieee80211_local *local, u32 changed) | |
192 | { | |
e1781ed3 KV |
193 | int ret; |
194 | ||
195 | might_sleep(); | |
196 | ||
4efc76bd | 197 | trace_drv_config(local, changed); |
e1781ed3 | 198 | ret = local->ops->config(&local->hw, changed); |
4efc76bd | 199 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 200 | return ret; |
24487981 JB |
201 | } |
202 | ||
203 | static inline void drv_bss_info_changed(struct ieee80211_local *local, | |
12375ef9 | 204 | struct ieee80211_sub_if_data *sdata, |
24487981 JB |
205 | struct ieee80211_bss_conf *info, |
206 | u32 changed) | |
207 | { | |
e1781ed3 KV |
208 | might_sleep(); |
209 | ||
b8dc1a35 JB |
210 | WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON | |
211 | BSS_CHANGED_BEACON_ENABLED) && | |
212 | sdata->vif.type != NL80211_IFTYPE_AP && | |
213 | sdata->vif.type != NL80211_IFTYPE_ADHOC && | |
214 | sdata->vif.type != NL80211_IFTYPE_MESH_POINT); | |
ad2d223a JB |
215 | WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE && |
216 | changed & ~BSS_CHANGED_IDLE); | |
b8dc1a35 | 217 | |
7b7eab6f JB |
218 | check_sdata_in_driver(sdata); |
219 | ||
4efc76bd | 220 | trace_drv_bss_info_changed(local, sdata, info, changed); |
24487981 | 221 | if (local->ops->bss_info_changed) |
12375ef9 | 222 | local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed); |
4efc76bd | 223 | trace_drv_return_void(local); |
24487981 JB |
224 | } |
225 | ||
3ac64bee | 226 | static inline u64 drv_prepare_multicast(struct ieee80211_local *local, |
22bedad3 | 227 | struct netdev_hw_addr_list *mc_list) |
3ac64bee JB |
228 | { |
229 | u64 ret = 0; | |
230 | ||
4efc76bd JB |
231 | trace_drv_prepare_multicast(local, mc_list->count); |
232 | ||
3ac64bee | 233 | if (local->ops->prepare_multicast) |
22bedad3 | 234 | ret = local->ops->prepare_multicast(&local->hw, mc_list); |
3ac64bee | 235 | |
4efc76bd | 236 | trace_drv_return_u64(local, ret); |
3ac64bee JB |
237 | |
238 | return ret; | |
239 | } | |
240 | ||
24487981 JB |
241 | static inline void drv_configure_filter(struct ieee80211_local *local, |
242 | unsigned int changed_flags, | |
243 | unsigned int *total_flags, | |
3ac64bee | 244 | u64 multicast) |
24487981 | 245 | { |
3ac64bee JB |
246 | might_sleep(); |
247 | ||
0a2b8bb2 | 248 | trace_drv_configure_filter(local, changed_flags, total_flags, |
3ac64bee | 249 | multicast); |
4efc76bd JB |
250 | local->ops->configure_filter(&local->hw, changed_flags, total_flags, |
251 | multicast); | |
252 | trace_drv_return_void(local); | |
24487981 JB |
253 | } |
254 | ||
255 | static inline int drv_set_tim(struct ieee80211_local *local, | |
256 | struct ieee80211_sta *sta, bool set) | |
257 | { | |
0a2b8bb2 | 258 | int ret = 0; |
4efc76bd | 259 | trace_drv_set_tim(local, sta, set); |
24487981 | 260 | if (local->ops->set_tim) |
0a2b8bb2 | 261 | ret = local->ops->set_tim(&local->hw, sta, set); |
4efc76bd | 262 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 263 | return ret; |
24487981 JB |
264 | } |
265 | ||
266 | static inline int drv_set_key(struct ieee80211_local *local, | |
12375ef9 JB |
267 | enum set_key_cmd cmd, |
268 | struct ieee80211_sub_if_data *sdata, | |
24487981 JB |
269 | struct ieee80211_sta *sta, |
270 | struct ieee80211_key_conf *key) | |
271 | { | |
e1781ed3 KV |
272 | int ret; |
273 | ||
274 | might_sleep(); | |
275 | ||
077f4939 | 276 | sdata = get_bss_sdata(sdata); |
7b7eab6f JB |
277 | check_sdata_in_driver(sdata); |
278 | ||
4efc76bd | 279 | trace_drv_set_key(local, cmd, sdata, sta, key); |
e1781ed3 | 280 | ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key); |
4efc76bd | 281 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 282 | return ret; |
24487981 JB |
283 | } |
284 | ||
285 | static inline void drv_update_tkip_key(struct ieee80211_local *local, | |
b3fbdcf4 | 286 | struct ieee80211_sub_if_data *sdata, |
24487981 | 287 | struct ieee80211_key_conf *conf, |
b3fbdcf4 | 288 | struct sta_info *sta, u32 iv32, |
24487981 JB |
289 | u16 *phase1key) |
290 | { | |
b3fbdcf4 JB |
291 | struct ieee80211_sta *ista = NULL; |
292 | ||
b3fbdcf4 JB |
293 | if (sta) |
294 | ista = &sta->sta; | |
295 | ||
077f4939 | 296 | sdata = get_bss_sdata(sdata); |
7b7eab6f JB |
297 | check_sdata_in_driver(sdata); |
298 | ||
4efc76bd | 299 | trace_drv_update_tkip_key(local, sdata, conf, ista, iv32); |
24487981 | 300 | if (local->ops->update_tkip_key) |
b3fbdcf4 JB |
301 | local->ops->update_tkip_key(&local->hw, &sdata->vif, conf, |
302 | ista, iv32, phase1key); | |
4efc76bd | 303 | trace_drv_return_void(local); |
24487981 JB |
304 | } |
305 | ||
306 | static inline int drv_hw_scan(struct ieee80211_local *local, | |
a060bbfe | 307 | struct ieee80211_sub_if_data *sdata, |
24487981 JB |
308 | struct cfg80211_scan_request *req) |
309 | { | |
e1781ed3 KV |
310 | int ret; |
311 | ||
312 | might_sleep(); | |
313 | ||
7b7eab6f JB |
314 | check_sdata_in_driver(sdata); |
315 | ||
79f460ca | 316 | trace_drv_hw_scan(local, sdata); |
a060bbfe | 317 | ret = local->ops->hw_scan(&local->hw, &sdata->vif, req); |
4efc76bd | 318 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 319 | return ret; |
24487981 JB |
320 | } |
321 | ||
b856439b EP |
322 | static inline void drv_cancel_hw_scan(struct ieee80211_local *local, |
323 | struct ieee80211_sub_if_data *sdata) | |
324 | { | |
325 | might_sleep(); | |
326 | ||
7b7eab6f JB |
327 | check_sdata_in_driver(sdata); |
328 | ||
b856439b EP |
329 | trace_drv_cancel_hw_scan(local, sdata); |
330 | local->ops->cancel_hw_scan(&local->hw, &sdata->vif); | |
331 | trace_drv_return_void(local); | |
332 | } | |
333 | ||
79f460ca LC |
334 | static inline int |
335 | drv_sched_scan_start(struct ieee80211_local *local, | |
336 | struct ieee80211_sub_if_data *sdata, | |
337 | struct cfg80211_sched_scan_request *req, | |
338 | struct ieee80211_sched_scan_ies *ies) | |
339 | { | |
340 | int ret; | |
341 | ||
342 | might_sleep(); | |
343 | ||
7b7eab6f JB |
344 | check_sdata_in_driver(sdata); |
345 | ||
79f460ca LC |
346 | trace_drv_sched_scan_start(local, sdata); |
347 | ret = local->ops->sched_scan_start(&local->hw, &sdata->vif, | |
348 | req, ies); | |
349 | trace_drv_return_int(local, ret); | |
350 | return ret; | |
351 | } | |
352 | ||
353 | static inline void drv_sched_scan_stop(struct ieee80211_local *local, | |
354 | struct ieee80211_sub_if_data *sdata) | |
355 | { | |
356 | might_sleep(); | |
357 | ||
7b7eab6f JB |
358 | check_sdata_in_driver(sdata); |
359 | ||
79f460ca LC |
360 | trace_drv_sched_scan_stop(local, sdata); |
361 | local->ops->sched_scan_stop(&local->hw, &sdata->vif); | |
362 | trace_drv_return_void(local); | |
363 | } | |
364 | ||
24487981 JB |
365 | static inline void drv_sw_scan_start(struct ieee80211_local *local) |
366 | { | |
e1781ed3 KV |
367 | might_sleep(); |
368 | ||
4efc76bd | 369 | trace_drv_sw_scan_start(local); |
24487981 JB |
370 | if (local->ops->sw_scan_start) |
371 | local->ops->sw_scan_start(&local->hw); | |
4efc76bd | 372 | trace_drv_return_void(local); |
24487981 JB |
373 | } |
374 | ||
375 | static inline void drv_sw_scan_complete(struct ieee80211_local *local) | |
376 | { | |
e1781ed3 KV |
377 | might_sleep(); |
378 | ||
4efc76bd | 379 | trace_drv_sw_scan_complete(local); |
24487981 JB |
380 | if (local->ops->sw_scan_complete) |
381 | local->ops->sw_scan_complete(&local->hw); | |
4efc76bd | 382 | trace_drv_return_void(local); |
24487981 JB |
383 | } |
384 | ||
385 | static inline int drv_get_stats(struct ieee80211_local *local, | |
386 | struct ieee80211_low_level_stats *stats) | |
387 | { | |
0a2b8bb2 JB |
388 | int ret = -EOPNOTSUPP; |
389 | ||
e1781ed3 KV |
390 | might_sleep(); |
391 | ||
0a2b8bb2 JB |
392 | if (local->ops->get_stats) |
393 | ret = local->ops->get_stats(&local->hw, stats); | |
394 | trace_drv_get_stats(local, stats, ret); | |
395 | ||
396 | return ret; | |
24487981 JB |
397 | } |
398 | ||
399 | static inline void drv_get_tkip_seq(struct ieee80211_local *local, | |
400 | u8 hw_key_idx, u32 *iv32, u16 *iv16) | |
401 | { | |
402 | if (local->ops->get_tkip_seq) | |
403 | local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16); | |
0a2b8bb2 | 404 | trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16); |
24487981 JB |
405 | } |
406 | ||
f23a4780 AN |
407 | static inline int drv_set_frag_threshold(struct ieee80211_local *local, |
408 | u32 value) | |
409 | { | |
410 | int ret = 0; | |
411 | ||
412 | might_sleep(); | |
413 | ||
414 | trace_drv_set_frag_threshold(local, value); | |
415 | if (local->ops->set_frag_threshold) | |
416 | ret = local->ops->set_frag_threshold(&local->hw, value); | |
417 | trace_drv_return_int(local, ret); | |
418 | return ret; | |
419 | } | |
420 | ||
24487981 JB |
421 | static inline int drv_set_rts_threshold(struct ieee80211_local *local, |
422 | u32 value) | |
423 | { | |
0a2b8bb2 | 424 | int ret = 0; |
e1781ed3 KV |
425 | |
426 | might_sleep(); | |
427 | ||
4efc76bd | 428 | trace_drv_set_rts_threshold(local, value); |
24487981 | 429 | if (local->ops->set_rts_threshold) |
0a2b8bb2 | 430 | ret = local->ops->set_rts_threshold(&local->hw, value); |
4efc76bd | 431 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 432 | return ret; |
24487981 JB |
433 | } |
434 | ||
310bc676 LT |
435 | static inline int drv_set_coverage_class(struct ieee80211_local *local, |
436 | u8 value) | |
437 | { | |
438 | int ret = 0; | |
439 | might_sleep(); | |
440 | ||
4efc76bd | 441 | trace_drv_set_coverage_class(local, value); |
310bc676 LT |
442 | if (local->ops->set_coverage_class) |
443 | local->ops->set_coverage_class(&local->hw, value); | |
444 | else | |
445 | ret = -EOPNOTSUPP; | |
446 | ||
4efc76bd | 447 | trace_drv_return_int(local, ret); |
310bc676 LT |
448 | return ret; |
449 | } | |
450 | ||
24487981 | 451 | static inline void drv_sta_notify(struct ieee80211_local *local, |
12375ef9 | 452 | struct ieee80211_sub_if_data *sdata, |
24487981 JB |
453 | enum sta_notify_cmd cmd, |
454 | struct ieee80211_sta *sta) | |
455 | { | |
bc192f89 | 456 | sdata = get_bss_sdata(sdata); |
7b7eab6f JB |
457 | check_sdata_in_driver(sdata); |
458 | ||
4efc76bd | 459 | trace_drv_sta_notify(local, sdata, cmd, sta); |
24487981 | 460 | if (local->ops->sta_notify) |
12375ef9 | 461 | local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta); |
4efc76bd | 462 | trace_drv_return_void(local); |
24487981 JB |
463 | } |
464 | ||
34e89507 JB |
465 | static inline int drv_sta_add(struct ieee80211_local *local, |
466 | struct ieee80211_sub_if_data *sdata, | |
467 | struct ieee80211_sta *sta) | |
468 | { | |
469 | int ret = 0; | |
470 | ||
471 | might_sleep(); | |
472 | ||
bc192f89 | 473 | sdata = get_bss_sdata(sdata); |
7b7eab6f JB |
474 | check_sdata_in_driver(sdata); |
475 | ||
4efc76bd | 476 | trace_drv_sta_add(local, sdata, sta); |
34e89507 JB |
477 | if (local->ops->sta_add) |
478 | ret = local->ops->sta_add(&local->hw, &sdata->vif, sta); | |
34e89507 | 479 | |
4efc76bd | 480 | trace_drv_return_int(local, ret); |
34e89507 JB |
481 | |
482 | return ret; | |
483 | } | |
484 | ||
485 | static inline void drv_sta_remove(struct ieee80211_local *local, | |
486 | struct ieee80211_sub_if_data *sdata, | |
487 | struct ieee80211_sta *sta) | |
488 | { | |
489 | might_sleep(); | |
490 | ||
bc192f89 | 491 | sdata = get_bss_sdata(sdata); |
7b7eab6f JB |
492 | check_sdata_in_driver(sdata); |
493 | ||
4efc76bd | 494 | trace_drv_sta_remove(local, sdata, sta); |
34e89507 JB |
495 | if (local->ops->sta_remove) |
496 | local->ops->sta_remove(&local->hw, &sdata->vif, sta); | |
34e89507 | 497 | |
4efc76bd | 498 | trace_drv_return_void(local); |
34e89507 JB |
499 | } |
500 | ||
77d2ece6 SM |
501 | #ifdef CONFIG_MAC80211_DEBUGFS |
502 | static inline void drv_sta_add_debugfs(struct ieee80211_local *local, | |
503 | struct ieee80211_sub_if_data *sdata, | |
504 | struct ieee80211_sta *sta, | |
505 | struct dentry *dir) | |
506 | { | |
507 | might_sleep(); | |
508 | ||
509 | sdata = get_bss_sdata(sdata); | |
510 | check_sdata_in_driver(sdata); | |
511 | ||
512 | if (local->ops->sta_add_debugfs) | |
513 | local->ops->sta_add_debugfs(&local->hw, &sdata->vif, | |
514 | sta, dir); | |
515 | } | |
516 | ||
517 | static inline void drv_sta_remove_debugfs(struct ieee80211_local *local, | |
518 | struct ieee80211_sub_if_data *sdata, | |
519 | struct ieee80211_sta *sta, | |
520 | struct dentry *dir) | |
521 | { | |
522 | might_sleep(); | |
523 | ||
524 | sdata = get_bss_sdata(sdata); | |
525 | check_sdata_in_driver(sdata); | |
526 | ||
527 | if (local->ops->sta_remove_debugfs) | |
528 | local->ops->sta_remove_debugfs(&local->hw, &sdata->vif, | |
529 | sta, dir); | |
530 | } | |
531 | #endif | |
532 | ||
f09603a2 JB |
533 | static inline __must_check |
534 | int drv_sta_state(struct ieee80211_local *local, | |
535 | struct ieee80211_sub_if_data *sdata, | |
536 | struct sta_info *sta, | |
537 | enum ieee80211_sta_state old_state, | |
538 | enum ieee80211_sta_state new_state) | |
539 | { | |
540 | int ret = 0; | |
541 | ||
542 | might_sleep(); | |
543 | ||
544 | sdata = get_bss_sdata(sdata); | |
545 | check_sdata_in_driver(sdata); | |
546 | ||
547 | trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state); | |
a4ec45a4 | 548 | if (local->ops->sta_state) { |
f09603a2 JB |
549 | ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta, |
550 | old_state, new_state); | |
a4ec45a4 JB |
551 | } else if (old_state == IEEE80211_STA_AUTH && |
552 | new_state == IEEE80211_STA_ASSOC) { | |
553 | ret = drv_sta_add(local, sdata, &sta->sta); | |
554 | if (ret == 0) | |
555 | sta->uploaded = true; | |
556 | } else if (old_state == IEEE80211_STA_ASSOC && | |
557 | new_state == IEEE80211_STA_AUTH) { | |
558 | drv_sta_remove(local, sdata, &sta->sta); | |
559 | } | |
f09603a2 JB |
560 | trace_drv_return_int(local, ret); |
561 | return ret; | |
562 | } | |
563 | ||
8f727ef3 JB |
564 | static inline void drv_sta_rc_update(struct ieee80211_local *local, |
565 | struct ieee80211_sub_if_data *sdata, | |
566 | struct ieee80211_sta *sta, u32 changed) | |
567 | { | |
568 | sdata = get_bss_sdata(sdata); | |
569 | check_sdata_in_driver(sdata); | |
570 | ||
e687f61e AQ |
571 | WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED && |
572 | sdata->vif.type != NL80211_IFTYPE_ADHOC); | |
573 | ||
8f727ef3 JB |
574 | trace_drv_sta_rc_update(local, sdata, sta, changed); |
575 | if (local->ops->sta_rc_update) | |
576 | local->ops->sta_rc_update(&local->hw, &sdata->vif, | |
577 | sta, changed); | |
578 | ||
579 | trace_drv_return_void(local); | |
580 | } | |
581 | ||
f6f3def3 | 582 | static inline int drv_conf_tx(struct ieee80211_local *local, |
a3304b0a | 583 | struct ieee80211_sub_if_data *sdata, u16 ac, |
24487981 JB |
584 | const struct ieee80211_tx_queue_params *params) |
585 | { | |
0a2b8bb2 | 586 | int ret = -EOPNOTSUPP; |
e1781ed3 KV |
587 | |
588 | might_sleep(); | |
589 | ||
7b7eab6f JB |
590 | check_sdata_in_driver(sdata); |
591 | ||
a3304b0a | 592 | trace_drv_conf_tx(local, sdata, ac, params); |
24487981 | 593 | if (local->ops->conf_tx) |
8a3a3c85 | 594 | ret = local->ops->conf_tx(&local->hw, &sdata->vif, |
a3304b0a | 595 | ac, params); |
4efc76bd | 596 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 597 | return ret; |
24487981 JB |
598 | } |
599 | ||
37a41b4a EP |
600 | static inline u64 drv_get_tsf(struct ieee80211_local *local, |
601 | struct ieee80211_sub_if_data *sdata) | |
24487981 | 602 | { |
0a2b8bb2 | 603 | u64 ret = -1ULL; |
e1781ed3 KV |
604 | |
605 | might_sleep(); | |
606 | ||
7b7eab6f JB |
607 | check_sdata_in_driver(sdata); |
608 | ||
37a41b4a | 609 | trace_drv_get_tsf(local, sdata); |
24487981 | 610 | if (local->ops->get_tsf) |
37a41b4a | 611 | ret = local->ops->get_tsf(&local->hw, &sdata->vif); |
4efc76bd | 612 | trace_drv_return_u64(local, ret); |
0a2b8bb2 | 613 | return ret; |
24487981 JB |
614 | } |
615 | ||
37a41b4a EP |
616 | static inline void drv_set_tsf(struct ieee80211_local *local, |
617 | struct ieee80211_sub_if_data *sdata, | |
618 | u64 tsf) | |
24487981 | 619 | { |
e1781ed3 KV |
620 | might_sleep(); |
621 | ||
7b7eab6f JB |
622 | check_sdata_in_driver(sdata); |
623 | ||
37a41b4a | 624 | trace_drv_set_tsf(local, sdata, tsf); |
24487981 | 625 | if (local->ops->set_tsf) |
37a41b4a | 626 | local->ops->set_tsf(&local->hw, &sdata->vif, tsf); |
4efc76bd | 627 | trace_drv_return_void(local); |
24487981 JB |
628 | } |
629 | ||
37a41b4a EP |
630 | static inline void drv_reset_tsf(struct ieee80211_local *local, |
631 | struct ieee80211_sub_if_data *sdata) | |
24487981 | 632 | { |
e1781ed3 KV |
633 | might_sleep(); |
634 | ||
7b7eab6f JB |
635 | check_sdata_in_driver(sdata); |
636 | ||
37a41b4a | 637 | trace_drv_reset_tsf(local, sdata); |
24487981 | 638 | if (local->ops->reset_tsf) |
37a41b4a | 639 | local->ops->reset_tsf(&local->hw, &sdata->vif); |
4efc76bd | 640 | trace_drv_return_void(local); |
24487981 JB |
641 | } |
642 | ||
643 | static inline int drv_tx_last_beacon(struct ieee80211_local *local) | |
644 | { | |
02582e9b | 645 | int ret = 0; /* default unsupported op for less congestion */ |
e1781ed3 KV |
646 | |
647 | might_sleep(); | |
648 | ||
4efc76bd | 649 | trace_drv_tx_last_beacon(local); |
24487981 | 650 | if (local->ops->tx_last_beacon) |
0a2b8bb2 | 651 | ret = local->ops->tx_last_beacon(&local->hw); |
4efc76bd | 652 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 653 | return ret; |
24487981 JB |
654 | } |
655 | ||
656 | static inline int drv_ampdu_action(struct ieee80211_local *local, | |
12375ef9 | 657 | struct ieee80211_sub_if_data *sdata, |
24487981 JB |
658 | enum ieee80211_ampdu_mlme_action action, |
659 | struct ieee80211_sta *sta, u16 tid, | |
0b01f030 | 660 | u16 *ssn, u8 buf_size) |
24487981 | 661 | { |
0a2b8bb2 | 662 | int ret = -EOPNOTSUPP; |
cfcdbde3 JB |
663 | |
664 | might_sleep(); | |
665 | ||
bc192f89 | 666 | sdata = get_bss_sdata(sdata); |
7b7eab6f JB |
667 | check_sdata_in_driver(sdata); |
668 | ||
0b01f030 | 669 | trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size); |
4efc76bd | 670 | |
24487981 | 671 | if (local->ops->ampdu_action) |
12375ef9 | 672 | ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action, |
0b01f030 | 673 | sta, tid, ssn, buf_size); |
85ad181e | 674 | |
4efc76bd JB |
675 | trace_drv_return_int(local, ret); |
676 | ||
0a2b8bb2 | 677 | return ret; |
24487981 | 678 | } |
1f87f7d3 | 679 | |
1289723e HS |
680 | static inline int drv_get_survey(struct ieee80211_local *local, int idx, |
681 | struct survey_info *survey) | |
682 | { | |
683 | int ret = -EOPNOTSUPP; | |
c466d4ef JL |
684 | |
685 | trace_drv_get_survey(local, idx, survey); | |
686 | ||
35dd0509 | 687 | if (local->ops->get_survey) |
1289723e | 688 | ret = local->ops->get_survey(&local->hw, idx, survey); |
c466d4ef JL |
689 | |
690 | trace_drv_return_int(local, ret); | |
691 | ||
1289723e HS |
692 | return ret; |
693 | } | |
1f87f7d3 JB |
694 | |
695 | static inline void drv_rfkill_poll(struct ieee80211_local *local) | |
696 | { | |
e1781ed3 KV |
697 | might_sleep(); |
698 | ||
1f87f7d3 JB |
699 | if (local->ops->rfkill_poll) |
700 | local->ops->rfkill_poll(&local->hw); | |
701 | } | |
a80f7c0b JB |
702 | |
703 | static inline void drv_flush(struct ieee80211_local *local, bool drop) | |
704 | { | |
e1781ed3 KV |
705 | might_sleep(); |
706 | ||
a80f7c0b JB |
707 | trace_drv_flush(local, drop); |
708 | if (local->ops->flush) | |
709 | local->ops->flush(&local->hw, drop); | |
4efc76bd | 710 | trace_drv_return_void(local); |
a80f7c0b | 711 | } |
5ce6e438 JB |
712 | |
713 | static inline void drv_channel_switch(struct ieee80211_local *local, | |
714 | struct ieee80211_channel_switch *ch_switch) | |
715 | { | |
716 | might_sleep(); | |
717 | ||
5ce6e438 | 718 | trace_drv_channel_switch(local, ch_switch); |
4efc76bd JB |
719 | local->ops->channel_switch(&local->hw, ch_switch); |
720 | trace_drv_return_void(local); | |
5ce6e438 JB |
721 | } |
722 | ||
15d96753 BR |
723 | |
724 | static inline int drv_set_antenna(struct ieee80211_local *local, | |
725 | u32 tx_ant, u32 rx_ant) | |
726 | { | |
727 | int ret = -EOPNOTSUPP; | |
728 | might_sleep(); | |
729 | if (local->ops->set_antenna) | |
730 | ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant); | |
731 | trace_drv_set_antenna(local, tx_ant, rx_ant, ret); | |
732 | return ret; | |
733 | } | |
734 | ||
735 | static inline int drv_get_antenna(struct ieee80211_local *local, | |
736 | u32 *tx_ant, u32 *rx_ant) | |
737 | { | |
738 | int ret = -EOPNOTSUPP; | |
739 | might_sleep(); | |
740 | if (local->ops->get_antenna) | |
741 | ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant); | |
742 | trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret); | |
743 | return ret; | |
744 | } | |
745 | ||
21f83589 | 746 | static inline int drv_remain_on_channel(struct ieee80211_local *local, |
49884568 | 747 | struct ieee80211_sub_if_data *sdata, |
21f83589 | 748 | struct ieee80211_channel *chan, |
21f83589 JB |
749 | unsigned int duration) |
750 | { | |
751 | int ret; | |
752 | ||
753 | might_sleep(); | |
754 | ||
42d97a59 | 755 | trace_drv_remain_on_channel(local, sdata, chan, duration); |
49884568 | 756 | ret = local->ops->remain_on_channel(&local->hw, &sdata->vif, |
42d97a59 | 757 | chan, duration); |
21f83589 JB |
758 | trace_drv_return_int(local, ret); |
759 | ||
760 | return ret; | |
761 | } | |
762 | ||
763 | static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local) | |
764 | { | |
765 | int ret; | |
766 | ||
767 | might_sleep(); | |
768 | ||
769 | trace_drv_cancel_remain_on_channel(local); | |
770 | ret = local->ops->cancel_remain_on_channel(&local->hw); | |
771 | trace_drv_return_int(local, ret); | |
5f16a436 JB |
772 | |
773 | return ret; | |
774 | } | |
775 | ||
38c09159 JL |
776 | static inline int drv_set_ringparam(struct ieee80211_local *local, |
777 | u32 tx, u32 rx) | |
778 | { | |
779 | int ret = -ENOTSUPP; | |
780 | ||
781 | might_sleep(); | |
782 | ||
783 | trace_drv_set_ringparam(local, tx, rx); | |
784 | if (local->ops->set_ringparam) | |
785 | ret = local->ops->set_ringparam(&local->hw, tx, rx); | |
786 | trace_drv_return_int(local, ret); | |
787 | ||
788 | return ret; | |
789 | } | |
790 | ||
791 | static inline void drv_get_ringparam(struct ieee80211_local *local, | |
792 | u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max) | |
793 | { | |
794 | might_sleep(); | |
795 | ||
796 | trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max); | |
797 | if (local->ops->get_ringparam) | |
798 | local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max); | |
799 | trace_drv_return_void(local); | |
800 | } | |
801 | ||
e8306f98 VN |
802 | static inline bool drv_tx_frames_pending(struct ieee80211_local *local) |
803 | { | |
804 | bool ret = false; | |
805 | ||
806 | might_sleep(); | |
807 | ||
808 | trace_drv_tx_frames_pending(local); | |
809 | if (local->ops->tx_frames_pending) | |
810 | ret = local->ops->tx_frames_pending(&local->hw); | |
811 | trace_drv_return_bool(local, ret); | |
812 | ||
813 | return ret; | |
814 | } | |
bdbfd6b5 SM |
815 | |
816 | static inline int drv_set_bitrate_mask(struct ieee80211_local *local, | |
817 | struct ieee80211_sub_if_data *sdata, | |
818 | const struct cfg80211_bitrate_mask *mask) | |
819 | { | |
820 | int ret = -EOPNOTSUPP; | |
821 | ||
822 | might_sleep(); | |
823 | ||
7b7eab6f JB |
824 | check_sdata_in_driver(sdata); |
825 | ||
bdbfd6b5 SM |
826 | trace_drv_set_bitrate_mask(local, sdata, mask); |
827 | if (local->ops->set_bitrate_mask) | |
828 | ret = local->ops->set_bitrate_mask(&local->hw, | |
829 | &sdata->vif, mask); | |
830 | trace_drv_return_int(local, ret); | |
831 | ||
832 | return ret; | |
833 | } | |
834 | ||
c68f4b89 JB |
835 | static inline void drv_set_rekey_data(struct ieee80211_local *local, |
836 | struct ieee80211_sub_if_data *sdata, | |
837 | struct cfg80211_gtk_rekey_data *data) | |
838 | { | |
7b7eab6f JB |
839 | check_sdata_in_driver(sdata); |
840 | ||
c68f4b89 JB |
841 | trace_drv_set_rekey_data(local, sdata, data); |
842 | if (local->ops->set_rekey_data) | |
843 | local->ops->set_rekey_data(&local->hw, &sdata->vif, data); | |
844 | trace_drv_return_void(local); | |
845 | } | |
846 | ||
615f7b9b MV |
847 | static inline void drv_rssi_callback(struct ieee80211_local *local, |
848 | const enum ieee80211_rssi_event event) | |
849 | { | |
850 | trace_drv_rssi_callback(local, event); | |
851 | if (local->ops->rssi_callback) | |
852 | local->ops->rssi_callback(&local->hw, event); | |
853 | trace_drv_return_void(local); | |
854 | } | |
4049e09a JB |
855 | |
856 | static inline void | |
857 | drv_release_buffered_frames(struct ieee80211_local *local, | |
858 | struct sta_info *sta, u16 tids, int num_frames, | |
859 | enum ieee80211_frame_release_type reason, | |
860 | bool more_data) | |
861 | { | |
862 | trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames, | |
863 | reason, more_data); | |
864 | if (local->ops->release_buffered_frames) | |
865 | local->ops->release_buffered_frames(&local->hw, &sta->sta, tids, | |
866 | num_frames, reason, | |
867 | more_data); | |
868 | trace_drv_return_void(local); | |
869 | } | |
40b96408 JB |
870 | |
871 | static inline void | |
872 | drv_allow_buffered_frames(struct ieee80211_local *local, | |
873 | struct sta_info *sta, u16 tids, int num_frames, | |
874 | enum ieee80211_frame_release_type reason, | |
875 | bool more_data) | |
876 | { | |
877 | trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames, | |
878 | reason, more_data); | |
879 | if (local->ops->allow_buffered_frames) | |
880 | local->ops->allow_buffered_frames(&local->hw, &sta->sta, | |
881 | tids, num_frames, reason, | |
882 | more_data); | |
883 | trace_drv_return_void(local); | |
884 | } | |
66572cfc VG |
885 | |
886 | static inline int drv_get_rssi(struct ieee80211_local *local, | |
887 | struct ieee80211_sub_if_data *sdata, | |
888 | struct ieee80211_sta *sta, | |
889 | s8 *rssi_dbm) | |
890 | { | |
891 | int ret; | |
892 | ||
893 | might_sleep(); | |
894 | ||
895 | ret = local->ops->get_rssi(&local->hw, &sdata->vif, sta, rssi_dbm); | |
896 | trace_drv_get_rssi(local, sta, *rssi_dbm, ret); | |
897 | ||
898 | return ret; | |
899 | } | |
a1845fc7 JB |
900 | |
901 | static inline void drv_mgd_prepare_tx(struct ieee80211_local *local, | |
902 | struct ieee80211_sub_if_data *sdata) | |
903 | { | |
904 | might_sleep(); | |
905 | ||
906 | check_sdata_in_driver(sdata); | |
907 | WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION); | |
908 | ||
909 | trace_drv_mgd_prepare_tx(local, sdata); | |
910 | if (local->ops->mgd_prepare_tx) | |
911 | local->ops->mgd_prepare_tx(&local->hw, &sdata->vif); | |
912 | trace_drv_return_void(local); | |
913 | } | |
c3645eac MK |
914 | |
915 | static inline int drv_add_chanctx(struct ieee80211_local *local, | |
916 | struct ieee80211_chanctx *ctx) | |
917 | { | |
918 | int ret = -EOPNOTSUPP; | |
919 | ||
920 | trace_drv_add_chanctx(local, ctx); | |
921 | if (local->ops->add_chanctx) | |
922 | ret = local->ops->add_chanctx(&local->hw, &ctx->conf); | |
923 | trace_drv_return_int(local, ret); | |
8a61af65 JB |
924 | if (!ret) |
925 | ctx->driver_present = true; | |
c3645eac MK |
926 | |
927 | return ret; | |
928 | } | |
929 | ||
930 | static inline void drv_remove_chanctx(struct ieee80211_local *local, | |
931 | struct ieee80211_chanctx *ctx) | |
932 | { | |
933 | trace_drv_remove_chanctx(local, ctx); | |
934 | if (local->ops->remove_chanctx) | |
935 | local->ops->remove_chanctx(&local->hw, &ctx->conf); | |
936 | trace_drv_return_void(local); | |
8a61af65 | 937 | ctx->driver_present = false; |
c3645eac MK |
938 | } |
939 | ||
940 | static inline void drv_change_chanctx(struct ieee80211_local *local, | |
941 | struct ieee80211_chanctx *ctx, | |
942 | u32 changed) | |
943 | { | |
944 | trace_drv_change_chanctx(local, ctx, changed); | |
8a61af65 JB |
945 | if (local->ops->change_chanctx) { |
946 | WARN_ON_ONCE(!ctx->driver_present); | |
c3645eac | 947 | local->ops->change_chanctx(&local->hw, &ctx->conf, changed); |
8a61af65 | 948 | } |
c3645eac MK |
949 | trace_drv_return_void(local); |
950 | } | |
951 | ||
952 | static inline int drv_assign_vif_chanctx(struct ieee80211_local *local, | |
953 | struct ieee80211_sub_if_data *sdata, | |
954 | struct ieee80211_chanctx *ctx) | |
955 | { | |
956 | int ret = 0; | |
957 | ||
958 | check_sdata_in_driver(sdata); | |
959 | ||
960 | trace_drv_assign_vif_chanctx(local, sdata, ctx); | |
8a61af65 JB |
961 | if (local->ops->assign_vif_chanctx) { |
962 | WARN_ON_ONCE(!ctx->driver_present); | |
c3645eac MK |
963 | ret = local->ops->assign_vif_chanctx(&local->hw, |
964 | &sdata->vif, | |
965 | &ctx->conf); | |
8a61af65 | 966 | } |
c3645eac MK |
967 | trace_drv_return_int(local, ret); |
968 | ||
969 | return ret; | |
970 | } | |
971 | ||
972 | static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local, | |
973 | struct ieee80211_sub_if_data *sdata, | |
974 | struct ieee80211_chanctx *ctx) | |
975 | { | |
976 | check_sdata_in_driver(sdata); | |
977 | ||
978 | trace_drv_unassign_vif_chanctx(local, sdata, ctx); | |
8a61af65 JB |
979 | if (local->ops->unassign_vif_chanctx) { |
980 | WARN_ON_ONCE(!ctx->driver_present); | |
c3645eac MK |
981 | local->ops->unassign_vif_chanctx(&local->hw, |
982 | &sdata->vif, | |
983 | &ctx->conf); | |
8a61af65 | 984 | } |
c3645eac MK |
985 | trace_drv_return_void(local); |
986 | } | |
987 | ||
1041638f JB |
988 | static inline int drv_start_ap(struct ieee80211_local *local, |
989 | struct ieee80211_sub_if_data *sdata) | |
990 | { | |
991 | int ret = 0; | |
992 | ||
993 | check_sdata_in_driver(sdata); | |
994 | ||
995 | trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf); | |
996 | if (local->ops->start_ap) | |
997 | ret = local->ops->start_ap(&local->hw, &sdata->vif); | |
998 | trace_drv_return_int(local, ret); | |
999 | return ret; | |
1000 | } | |
1001 | ||
1002 | static inline void drv_stop_ap(struct ieee80211_local *local, | |
1003 | struct ieee80211_sub_if_data *sdata) | |
1004 | { | |
1005 | check_sdata_in_driver(sdata); | |
1006 | ||
1007 | trace_drv_stop_ap(local, sdata); | |
1008 | if (local->ops->stop_ap) | |
1009 | local->ops->stop_ap(&local->hw, &sdata->vif); | |
1010 | trace_drv_return_void(local); | |
1011 | } | |
1012 | ||
9214ad7f JB |
1013 | static inline void drv_restart_complete(struct ieee80211_local *local) |
1014 | { | |
1015 | might_sleep(); | |
1016 | ||
1017 | trace_drv_restart_complete(local); | |
1018 | if (local->ops->restart_complete) | |
1019 | local->ops->restart_complete(&local->hw); | |
1020 | trace_drv_return_void(local); | |
1021 | } | |
1022 | ||
de5fad81 YD |
1023 | static inline void |
1024 | drv_set_default_unicast_key(struct ieee80211_local *local, | |
1025 | struct ieee80211_sub_if_data *sdata, | |
1026 | int key_idx) | |
1027 | { | |
1028 | check_sdata_in_driver(sdata); | |
1029 | ||
1030 | WARN_ON_ONCE(key_idx < -1 || key_idx > 3); | |
1031 | ||
1032 | trace_drv_set_default_unicast_key(local, sdata, key_idx); | |
1033 | if (local->ops->set_default_unicast_key) | |
1034 | local->ops->set_default_unicast_key(&local->hw, &sdata->vif, | |
1035 | key_idx); | |
1036 | trace_drv_return_void(local); | |
1037 | } | |
1038 | ||
24487981 | 1039 | #endif /* __MAC80211_DRIVER_OPS */ |