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" | |
0a2b8bb2 | 6 | #include "driver-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", | |
12 | sdata->dev->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 | ||
7bb45683 | 25 | static inline void drv_tx(struct ieee80211_local *local, struct sk_buff *skb) |
24487981 | 26 | { |
7bb45683 | 27 | local->ops->tx(&local->hw, skb); |
24487981 JB |
28 | } |
29 | ||
11127e91 JB |
30 | static inline void drv_tx_frags(struct ieee80211_local *local, |
31 | struct ieee80211_vif *vif, | |
32 | struct ieee80211_sta *sta, | |
33 | struct sk_buff_head *skbs) | |
34 | { | |
35 | local->ops->tx_frags(&local->hw, vif, sta, skbs); | |
36 | } | |
37 | ||
24487981 JB |
38 | static inline int drv_start(struct ieee80211_local *local) |
39 | { | |
ea77f12f JB |
40 | int ret; |
41 | ||
e1781ed3 KV |
42 | might_sleep(); |
43 | ||
4efc76bd | 44 | trace_drv_start(local); |
ea77f12f JB |
45 | local->started = true; |
46 | smp_mb(); | |
47 | ret = local->ops->start(&local->hw); | |
4efc76bd | 48 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 49 | return ret; |
24487981 JB |
50 | } |
51 | ||
52 | static inline void drv_stop(struct ieee80211_local *local) | |
53 | { | |
e1781ed3 KV |
54 | might_sleep(); |
55 | ||
0a2b8bb2 | 56 | trace_drv_stop(local); |
4efc76bd JB |
57 | local->ops->stop(&local->hw); |
58 | trace_drv_return_void(local); | |
ea77f12f JB |
59 | |
60 | /* sync away all work on the tasklet before clearing started */ | |
61 | tasklet_disable(&local->tasklet); | |
62 | tasklet_enable(&local->tasklet); | |
63 | ||
64 | barrier(); | |
65 | ||
66 | local->started = false; | |
24487981 JB |
67 | } |
68 | ||
eecc4800 JB |
69 | #ifdef CONFIG_PM |
70 | static inline int drv_suspend(struct ieee80211_local *local, | |
71 | struct cfg80211_wowlan *wowlan) | |
72 | { | |
73 | int ret; | |
74 | ||
75 | might_sleep(); | |
76 | ||
77 | trace_drv_suspend(local); | |
78 | ret = local->ops->suspend(&local->hw, wowlan); | |
79 | trace_drv_return_int(local, ret); | |
80 | return ret; | |
81 | } | |
82 | ||
83 | static inline int drv_resume(struct ieee80211_local *local) | |
84 | { | |
85 | int ret; | |
86 | ||
87 | might_sleep(); | |
88 | ||
89 | trace_drv_resume(local); | |
90 | ret = local->ops->resume(&local->hw); | |
91 | trace_drv_return_int(local, ret); | |
92 | return ret; | |
93 | } | |
94 | #endif | |
95 | ||
24487981 | 96 | static inline int drv_add_interface(struct ieee80211_local *local, |
7b7eab6f | 97 | struct ieee80211_sub_if_data *sdata) |
24487981 | 98 | { |
e1781ed3 KV |
99 | int ret; |
100 | ||
101 | might_sleep(); | |
102 | ||
7b7eab6f JB |
103 | if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN || |
104 | sdata->vif.type == NL80211_IFTYPE_MONITOR)) | |
105 | return -EINVAL; | |
106 | ||
107 | trace_drv_add_interface(local, sdata); | |
108 | ret = local->ops->add_interface(&local->hw, &sdata->vif); | |
4efc76bd | 109 | trace_drv_return_int(local, ret); |
7b7eab6f JB |
110 | |
111 | if (ret == 0) | |
112 | sdata->flags |= IEEE80211_SDATA_IN_DRIVER; | |
113 | ||
0a2b8bb2 | 114 | return ret; |
24487981 JB |
115 | } |
116 | ||
34d4bc4d JB |
117 | static inline int drv_change_interface(struct ieee80211_local *local, |
118 | struct ieee80211_sub_if_data *sdata, | |
2ca27bcf | 119 | enum nl80211_iftype type, bool p2p) |
34d4bc4d JB |
120 | { |
121 | int ret; | |
122 | ||
123 | might_sleep(); | |
124 | ||
7b7eab6f JB |
125 | check_sdata_in_driver(sdata); |
126 | ||
2ca27bcf JB |
127 | trace_drv_change_interface(local, sdata, type, p2p); |
128 | ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p); | |
34d4bc4d JB |
129 | trace_drv_return_int(local, ret); |
130 | return ret; | |
131 | } | |
132 | ||
24487981 | 133 | static inline void drv_remove_interface(struct ieee80211_local *local, |
7b7eab6f | 134 | struct ieee80211_sub_if_data *sdata) |
24487981 | 135 | { |
e1781ed3 KV |
136 | might_sleep(); |
137 | ||
7b7eab6f JB |
138 | check_sdata_in_driver(sdata); |
139 | ||
140 | trace_drv_remove_interface(local, sdata); | |
141 | local->ops->remove_interface(&local->hw, &sdata->vif); | |
142 | sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER; | |
4efc76bd | 143 | trace_drv_return_void(local); |
24487981 JB |
144 | } |
145 | ||
146 | static inline int drv_config(struct ieee80211_local *local, u32 changed) | |
147 | { | |
e1781ed3 KV |
148 | int ret; |
149 | ||
150 | might_sleep(); | |
151 | ||
4efc76bd | 152 | trace_drv_config(local, changed); |
e1781ed3 | 153 | ret = local->ops->config(&local->hw, changed); |
4efc76bd | 154 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 155 | return ret; |
24487981 JB |
156 | } |
157 | ||
158 | static inline void drv_bss_info_changed(struct ieee80211_local *local, | |
12375ef9 | 159 | struct ieee80211_sub_if_data *sdata, |
24487981 JB |
160 | struct ieee80211_bss_conf *info, |
161 | u32 changed) | |
162 | { | |
e1781ed3 KV |
163 | might_sleep(); |
164 | ||
7b7eab6f JB |
165 | check_sdata_in_driver(sdata); |
166 | ||
4efc76bd | 167 | trace_drv_bss_info_changed(local, sdata, info, changed); |
24487981 | 168 | if (local->ops->bss_info_changed) |
12375ef9 | 169 | local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed); |
4efc76bd | 170 | trace_drv_return_void(local); |
24487981 JB |
171 | } |
172 | ||
3ac64bee | 173 | static inline u64 drv_prepare_multicast(struct ieee80211_local *local, |
22bedad3 | 174 | struct netdev_hw_addr_list *mc_list) |
3ac64bee JB |
175 | { |
176 | u64 ret = 0; | |
177 | ||
4efc76bd JB |
178 | trace_drv_prepare_multicast(local, mc_list->count); |
179 | ||
3ac64bee | 180 | if (local->ops->prepare_multicast) |
22bedad3 | 181 | ret = local->ops->prepare_multicast(&local->hw, mc_list); |
3ac64bee | 182 | |
4efc76bd | 183 | trace_drv_return_u64(local, ret); |
3ac64bee JB |
184 | |
185 | return ret; | |
186 | } | |
187 | ||
24487981 JB |
188 | static inline void drv_configure_filter(struct ieee80211_local *local, |
189 | unsigned int changed_flags, | |
190 | unsigned int *total_flags, | |
3ac64bee | 191 | u64 multicast) |
24487981 | 192 | { |
3ac64bee JB |
193 | might_sleep(); |
194 | ||
0a2b8bb2 | 195 | trace_drv_configure_filter(local, changed_flags, total_flags, |
3ac64bee | 196 | multicast); |
4efc76bd JB |
197 | local->ops->configure_filter(&local->hw, changed_flags, total_flags, |
198 | multicast); | |
199 | trace_drv_return_void(local); | |
24487981 JB |
200 | } |
201 | ||
202 | static inline int drv_set_tim(struct ieee80211_local *local, | |
203 | struct ieee80211_sta *sta, bool set) | |
204 | { | |
0a2b8bb2 | 205 | int ret = 0; |
4efc76bd | 206 | trace_drv_set_tim(local, sta, set); |
24487981 | 207 | if (local->ops->set_tim) |
0a2b8bb2 | 208 | ret = local->ops->set_tim(&local->hw, sta, set); |
4efc76bd | 209 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 210 | return ret; |
24487981 JB |
211 | } |
212 | ||
213 | static inline int drv_set_key(struct ieee80211_local *local, | |
12375ef9 JB |
214 | enum set_key_cmd cmd, |
215 | struct ieee80211_sub_if_data *sdata, | |
24487981 JB |
216 | struct ieee80211_sta *sta, |
217 | struct ieee80211_key_conf *key) | |
218 | { | |
e1781ed3 KV |
219 | int ret; |
220 | ||
221 | might_sleep(); | |
222 | ||
077f4939 | 223 | sdata = get_bss_sdata(sdata); |
7b7eab6f JB |
224 | check_sdata_in_driver(sdata); |
225 | ||
4efc76bd | 226 | trace_drv_set_key(local, cmd, sdata, sta, key); |
e1781ed3 | 227 | ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key); |
4efc76bd | 228 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 229 | return ret; |
24487981 JB |
230 | } |
231 | ||
232 | static inline void drv_update_tkip_key(struct ieee80211_local *local, | |
b3fbdcf4 | 233 | struct ieee80211_sub_if_data *sdata, |
24487981 | 234 | struct ieee80211_key_conf *conf, |
b3fbdcf4 | 235 | struct sta_info *sta, u32 iv32, |
24487981 JB |
236 | u16 *phase1key) |
237 | { | |
b3fbdcf4 JB |
238 | struct ieee80211_sta *ista = NULL; |
239 | ||
b3fbdcf4 JB |
240 | if (sta) |
241 | ista = &sta->sta; | |
242 | ||
077f4939 | 243 | sdata = get_bss_sdata(sdata); |
7b7eab6f JB |
244 | check_sdata_in_driver(sdata); |
245 | ||
4efc76bd | 246 | trace_drv_update_tkip_key(local, sdata, conf, ista, iv32); |
24487981 | 247 | if (local->ops->update_tkip_key) |
b3fbdcf4 JB |
248 | local->ops->update_tkip_key(&local->hw, &sdata->vif, conf, |
249 | ista, iv32, phase1key); | |
4efc76bd | 250 | trace_drv_return_void(local); |
24487981 JB |
251 | } |
252 | ||
253 | static inline int drv_hw_scan(struct ieee80211_local *local, | |
a060bbfe | 254 | struct ieee80211_sub_if_data *sdata, |
24487981 JB |
255 | struct cfg80211_scan_request *req) |
256 | { | |
e1781ed3 KV |
257 | int ret; |
258 | ||
259 | might_sleep(); | |
260 | ||
7b7eab6f JB |
261 | check_sdata_in_driver(sdata); |
262 | ||
79f460ca | 263 | trace_drv_hw_scan(local, sdata); |
a060bbfe | 264 | ret = local->ops->hw_scan(&local->hw, &sdata->vif, req); |
4efc76bd | 265 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 266 | return ret; |
24487981 JB |
267 | } |
268 | ||
b856439b EP |
269 | static inline void drv_cancel_hw_scan(struct ieee80211_local *local, |
270 | struct ieee80211_sub_if_data *sdata) | |
271 | { | |
272 | might_sleep(); | |
273 | ||
7b7eab6f JB |
274 | check_sdata_in_driver(sdata); |
275 | ||
b856439b EP |
276 | trace_drv_cancel_hw_scan(local, sdata); |
277 | local->ops->cancel_hw_scan(&local->hw, &sdata->vif); | |
278 | trace_drv_return_void(local); | |
279 | } | |
280 | ||
79f460ca LC |
281 | static inline int |
282 | drv_sched_scan_start(struct ieee80211_local *local, | |
283 | struct ieee80211_sub_if_data *sdata, | |
284 | struct cfg80211_sched_scan_request *req, | |
285 | struct ieee80211_sched_scan_ies *ies) | |
286 | { | |
287 | int ret; | |
288 | ||
289 | might_sleep(); | |
290 | ||
7b7eab6f JB |
291 | check_sdata_in_driver(sdata); |
292 | ||
79f460ca LC |
293 | trace_drv_sched_scan_start(local, sdata); |
294 | ret = local->ops->sched_scan_start(&local->hw, &sdata->vif, | |
295 | req, ies); | |
296 | trace_drv_return_int(local, ret); | |
297 | return ret; | |
298 | } | |
299 | ||
300 | static inline void drv_sched_scan_stop(struct ieee80211_local *local, | |
301 | struct ieee80211_sub_if_data *sdata) | |
302 | { | |
303 | might_sleep(); | |
304 | ||
7b7eab6f JB |
305 | check_sdata_in_driver(sdata); |
306 | ||
79f460ca LC |
307 | trace_drv_sched_scan_stop(local, sdata); |
308 | local->ops->sched_scan_stop(&local->hw, &sdata->vif); | |
309 | trace_drv_return_void(local); | |
310 | } | |
311 | ||
24487981 JB |
312 | static inline void drv_sw_scan_start(struct ieee80211_local *local) |
313 | { | |
e1781ed3 KV |
314 | might_sleep(); |
315 | ||
4efc76bd | 316 | trace_drv_sw_scan_start(local); |
24487981 JB |
317 | if (local->ops->sw_scan_start) |
318 | local->ops->sw_scan_start(&local->hw); | |
4efc76bd | 319 | trace_drv_return_void(local); |
24487981 JB |
320 | } |
321 | ||
322 | static inline void drv_sw_scan_complete(struct ieee80211_local *local) | |
323 | { | |
e1781ed3 KV |
324 | might_sleep(); |
325 | ||
4efc76bd | 326 | trace_drv_sw_scan_complete(local); |
24487981 JB |
327 | if (local->ops->sw_scan_complete) |
328 | local->ops->sw_scan_complete(&local->hw); | |
4efc76bd | 329 | trace_drv_return_void(local); |
24487981 JB |
330 | } |
331 | ||
332 | static inline int drv_get_stats(struct ieee80211_local *local, | |
333 | struct ieee80211_low_level_stats *stats) | |
334 | { | |
0a2b8bb2 JB |
335 | int ret = -EOPNOTSUPP; |
336 | ||
e1781ed3 KV |
337 | might_sleep(); |
338 | ||
0a2b8bb2 JB |
339 | if (local->ops->get_stats) |
340 | ret = local->ops->get_stats(&local->hw, stats); | |
341 | trace_drv_get_stats(local, stats, ret); | |
342 | ||
343 | return ret; | |
24487981 JB |
344 | } |
345 | ||
346 | static inline void drv_get_tkip_seq(struct ieee80211_local *local, | |
347 | u8 hw_key_idx, u32 *iv32, u16 *iv16) | |
348 | { | |
349 | if (local->ops->get_tkip_seq) | |
350 | local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16); | |
0a2b8bb2 | 351 | trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16); |
24487981 JB |
352 | } |
353 | ||
f23a4780 AN |
354 | static inline int drv_set_frag_threshold(struct ieee80211_local *local, |
355 | u32 value) | |
356 | { | |
357 | int ret = 0; | |
358 | ||
359 | might_sleep(); | |
360 | ||
361 | trace_drv_set_frag_threshold(local, value); | |
362 | if (local->ops->set_frag_threshold) | |
363 | ret = local->ops->set_frag_threshold(&local->hw, value); | |
364 | trace_drv_return_int(local, ret); | |
365 | return ret; | |
366 | } | |
367 | ||
24487981 JB |
368 | static inline int drv_set_rts_threshold(struct ieee80211_local *local, |
369 | u32 value) | |
370 | { | |
0a2b8bb2 | 371 | int ret = 0; |
e1781ed3 KV |
372 | |
373 | might_sleep(); | |
374 | ||
4efc76bd | 375 | trace_drv_set_rts_threshold(local, value); |
24487981 | 376 | if (local->ops->set_rts_threshold) |
0a2b8bb2 | 377 | ret = local->ops->set_rts_threshold(&local->hw, value); |
4efc76bd | 378 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 379 | return ret; |
24487981 JB |
380 | } |
381 | ||
310bc676 LT |
382 | static inline int drv_set_coverage_class(struct ieee80211_local *local, |
383 | u8 value) | |
384 | { | |
385 | int ret = 0; | |
386 | might_sleep(); | |
387 | ||
4efc76bd | 388 | trace_drv_set_coverage_class(local, value); |
310bc676 LT |
389 | if (local->ops->set_coverage_class) |
390 | local->ops->set_coverage_class(&local->hw, value); | |
391 | else | |
392 | ret = -EOPNOTSUPP; | |
393 | ||
4efc76bd | 394 | trace_drv_return_int(local, ret); |
310bc676 LT |
395 | return ret; |
396 | } | |
397 | ||
24487981 | 398 | static inline void drv_sta_notify(struct ieee80211_local *local, |
12375ef9 | 399 | struct ieee80211_sub_if_data *sdata, |
24487981 JB |
400 | enum sta_notify_cmd cmd, |
401 | struct ieee80211_sta *sta) | |
402 | { | |
bc192f89 | 403 | sdata = get_bss_sdata(sdata); |
7b7eab6f JB |
404 | check_sdata_in_driver(sdata); |
405 | ||
4efc76bd | 406 | trace_drv_sta_notify(local, sdata, cmd, sta); |
24487981 | 407 | if (local->ops->sta_notify) |
12375ef9 | 408 | local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta); |
4efc76bd | 409 | trace_drv_return_void(local); |
24487981 JB |
410 | } |
411 | ||
34e89507 JB |
412 | static inline int drv_sta_add(struct ieee80211_local *local, |
413 | struct ieee80211_sub_if_data *sdata, | |
414 | struct ieee80211_sta *sta) | |
415 | { | |
416 | int ret = 0; | |
417 | ||
418 | might_sleep(); | |
419 | ||
bc192f89 | 420 | sdata = get_bss_sdata(sdata); |
7b7eab6f JB |
421 | check_sdata_in_driver(sdata); |
422 | ||
4efc76bd | 423 | trace_drv_sta_add(local, sdata, sta); |
34e89507 JB |
424 | if (local->ops->sta_add) |
425 | ret = local->ops->sta_add(&local->hw, &sdata->vif, sta); | |
34e89507 | 426 | |
4efc76bd | 427 | trace_drv_return_int(local, ret); |
34e89507 JB |
428 | |
429 | return ret; | |
430 | } | |
431 | ||
432 | static inline void drv_sta_remove(struct ieee80211_local *local, | |
433 | struct ieee80211_sub_if_data *sdata, | |
434 | struct ieee80211_sta *sta) | |
435 | { | |
436 | might_sleep(); | |
437 | ||
bc192f89 | 438 | sdata = get_bss_sdata(sdata); |
7b7eab6f JB |
439 | check_sdata_in_driver(sdata); |
440 | ||
4efc76bd | 441 | trace_drv_sta_remove(local, sdata, sta); |
34e89507 JB |
442 | if (local->ops->sta_remove) |
443 | local->ops->sta_remove(&local->hw, &sdata->vif, sta); | |
34e89507 | 444 | |
4efc76bd | 445 | trace_drv_return_void(local); |
34e89507 JB |
446 | } |
447 | ||
f09603a2 JB |
448 | static inline __must_check |
449 | int drv_sta_state(struct ieee80211_local *local, | |
450 | struct ieee80211_sub_if_data *sdata, | |
451 | struct sta_info *sta, | |
452 | enum ieee80211_sta_state old_state, | |
453 | enum ieee80211_sta_state new_state) | |
454 | { | |
455 | int ret = 0; | |
456 | ||
457 | might_sleep(); | |
458 | ||
459 | sdata = get_bss_sdata(sdata); | |
460 | check_sdata_in_driver(sdata); | |
461 | ||
462 | trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state); | |
a4ec45a4 | 463 | if (local->ops->sta_state) { |
f09603a2 JB |
464 | ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta, |
465 | old_state, new_state); | |
a4ec45a4 JB |
466 | } else if (old_state == IEEE80211_STA_AUTH && |
467 | new_state == IEEE80211_STA_ASSOC) { | |
468 | ret = drv_sta_add(local, sdata, &sta->sta); | |
469 | if (ret == 0) | |
470 | sta->uploaded = true; | |
471 | } else if (old_state == IEEE80211_STA_ASSOC && | |
472 | new_state == IEEE80211_STA_AUTH) { | |
473 | drv_sta_remove(local, sdata, &sta->sta); | |
474 | } | |
f09603a2 JB |
475 | trace_drv_return_int(local, ret); |
476 | return ret; | |
477 | } | |
478 | ||
8f727ef3 JB |
479 | static inline void drv_sta_rc_update(struct ieee80211_local *local, |
480 | struct ieee80211_sub_if_data *sdata, | |
481 | struct ieee80211_sta *sta, u32 changed) | |
482 | { | |
483 | sdata = get_bss_sdata(sdata); | |
484 | check_sdata_in_driver(sdata); | |
485 | ||
486 | trace_drv_sta_rc_update(local, sdata, sta, changed); | |
487 | if (local->ops->sta_rc_update) | |
488 | local->ops->sta_rc_update(&local->hw, &sdata->vif, | |
489 | sta, changed); | |
490 | ||
491 | trace_drv_return_void(local); | |
492 | } | |
493 | ||
f6f3def3 | 494 | static inline int drv_conf_tx(struct ieee80211_local *local, |
a3304b0a | 495 | struct ieee80211_sub_if_data *sdata, u16 ac, |
24487981 JB |
496 | const struct ieee80211_tx_queue_params *params) |
497 | { | |
0a2b8bb2 | 498 | int ret = -EOPNOTSUPP; |
e1781ed3 KV |
499 | |
500 | might_sleep(); | |
501 | ||
7b7eab6f JB |
502 | check_sdata_in_driver(sdata); |
503 | ||
a3304b0a | 504 | trace_drv_conf_tx(local, sdata, ac, params); |
24487981 | 505 | if (local->ops->conf_tx) |
8a3a3c85 | 506 | ret = local->ops->conf_tx(&local->hw, &sdata->vif, |
a3304b0a | 507 | ac, params); |
4efc76bd | 508 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 509 | return ret; |
24487981 JB |
510 | } |
511 | ||
37a41b4a EP |
512 | static inline u64 drv_get_tsf(struct ieee80211_local *local, |
513 | struct ieee80211_sub_if_data *sdata) | |
24487981 | 514 | { |
0a2b8bb2 | 515 | u64 ret = -1ULL; |
e1781ed3 KV |
516 | |
517 | might_sleep(); | |
518 | ||
7b7eab6f JB |
519 | check_sdata_in_driver(sdata); |
520 | ||
37a41b4a | 521 | trace_drv_get_tsf(local, sdata); |
24487981 | 522 | if (local->ops->get_tsf) |
37a41b4a | 523 | ret = local->ops->get_tsf(&local->hw, &sdata->vif); |
4efc76bd | 524 | trace_drv_return_u64(local, ret); |
0a2b8bb2 | 525 | return ret; |
24487981 JB |
526 | } |
527 | ||
37a41b4a EP |
528 | static inline void drv_set_tsf(struct ieee80211_local *local, |
529 | struct ieee80211_sub_if_data *sdata, | |
530 | u64 tsf) | |
24487981 | 531 | { |
e1781ed3 KV |
532 | might_sleep(); |
533 | ||
7b7eab6f JB |
534 | check_sdata_in_driver(sdata); |
535 | ||
37a41b4a | 536 | trace_drv_set_tsf(local, sdata, tsf); |
24487981 | 537 | if (local->ops->set_tsf) |
37a41b4a | 538 | local->ops->set_tsf(&local->hw, &sdata->vif, tsf); |
4efc76bd | 539 | trace_drv_return_void(local); |
24487981 JB |
540 | } |
541 | ||
37a41b4a EP |
542 | static inline void drv_reset_tsf(struct ieee80211_local *local, |
543 | struct ieee80211_sub_if_data *sdata) | |
24487981 | 544 | { |
e1781ed3 KV |
545 | might_sleep(); |
546 | ||
7b7eab6f JB |
547 | check_sdata_in_driver(sdata); |
548 | ||
37a41b4a | 549 | trace_drv_reset_tsf(local, sdata); |
24487981 | 550 | if (local->ops->reset_tsf) |
37a41b4a | 551 | local->ops->reset_tsf(&local->hw, &sdata->vif); |
4efc76bd | 552 | trace_drv_return_void(local); |
24487981 JB |
553 | } |
554 | ||
555 | static inline int drv_tx_last_beacon(struct ieee80211_local *local) | |
556 | { | |
91f44b02 | 557 | int ret = 0; /* default unsuported op for less congestion */ |
e1781ed3 KV |
558 | |
559 | might_sleep(); | |
560 | ||
4efc76bd | 561 | trace_drv_tx_last_beacon(local); |
24487981 | 562 | if (local->ops->tx_last_beacon) |
0a2b8bb2 | 563 | ret = local->ops->tx_last_beacon(&local->hw); |
4efc76bd | 564 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 565 | return ret; |
24487981 JB |
566 | } |
567 | ||
568 | static inline int drv_ampdu_action(struct ieee80211_local *local, | |
12375ef9 | 569 | struct ieee80211_sub_if_data *sdata, |
24487981 JB |
570 | enum ieee80211_ampdu_mlme_action action, |
571 | struct ieee80211_sta *sta, u16 tid, | |
0b01f030 | 572 | u16 *ssn, u8 buf_size) |
24487981 | 573 | { |
0a2b8bb2 | 574 | int ret = -EOPNOTSUPP; |
cfcdbde3 JB |
575 | |
576 | might_sleep(); | |
577 | ||
bc192f89 | 578 | sdata = get_bss_sdata(sdata); |
7b7eab6f JB |
579 | check_sdata_in_driver(sdata); |
580 | ||
0b01f030 | 581 | trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size); |
4efc76bd | 582 | |
24487981 | 583 | if (local->ops->ampdu_action) |
12375ef9 | 584 | ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action, |
0b01f030 | 585 | sta, tid, ssn, buf_size); |
85ad181e | 586 | |
4efc76bd JB |
587 | trace_drv_return_int(local, ret); |
588 | ||
0a2b8bb2 | 589 | return ret; |
24487981 | 590 | } |
1f87f7d3 | 591 | |
1289723e HS |
592 | static inline int drv_get_survey(struct ieee80211_local *local, int idx, |
593 | struct survey_info *survey) | |
594 | { | |
595 | int ret = -EOPNOTSUPP; | |
c466d4ef JL |
596 | |
597 | trace_drv_get_survey(local, idx, survey); | |
598 | ||
35dd0509 | 599 | if (local->ops->get_survey) |
1289723e | 600 | ret = local->ops->get_survey(&local->hw, idx, survey); |
c466d4ef JL |
601 | |
602 | trace_drv_return_int(local, ret); | |
603 | ||
1289723e HS |
604 | return ret; |
605 | } | |
1f87f7d3 JB |
606 | |
607 | static inline void drv_rfkill_poll(struct ieee80211_local *local) | |
608 | { | |
e1781ed3 KV |
609 | might_sleep(); |
610 | ||
1f87f7d3 JB |
611 | if (local->ops->rfkill_poll) |
612 | local->ops->rfkill_poll(&local->hw); | |
613 | } | |
a80f7c0b JB |
614 | |
615 | static inline void drv_flush(struct ieee80211_local *local, bool drop) | |
616 | { | |
e1781ed3 KV |
617 | might_sleep(); |
618 | ||
a80f7c0b JB |
619 | trace_drv_flush(local, drop); |
620 | if (local->ops->flush) | |
621 | local->ops->flush(&local->hw, drop); | |
4efc76bd | 622 | trace_drv_return_void(local); |
a80f7c0b | 623 | } |
5ce6e438 JB |
624 | |
625 | static inline void drv_channel_switch(struct ieee80211_local *local, | |
626 | struct ieee80211_channel_switch *ch_switch) | |
627 | { | |
628 | might_sleep(); | |
629 | ||
5ce6e438 | 630 | trace_drv_channel_switch(local, ch_switch); |
4efc76bd JB |
631 | local->ops->channel_switch(&local->hw, ch_switch); |
632 | trace_drv_return_void(local); | |
5ce6e438 JB |
633 | } |
634 | ||
15d96753 BR |
635 | |
636 | static inline int drv_set_antenna(struct ieee80211_local *local, | |
637 | u32 tx_ant, u32 rx_ant) | |
638 | { | |
639 | int ret = -EOPNOTSUPP; | |
640 | might_sleep(); | |
641 | if (local->ops->set_antenna) | |
642 | ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant); | |
643 | trace_drv_set_antenna(local, tx_ant, rx_ant, ret); | |
644 | return ret; | |
645 | } | |
646 | ||
647 | static inline int drv_get_antenna(struct ieee80211_local *local, | |
648 | u32 *tx_ant, u32 *rx_ant) | |
649 | { | |
650 | int ret = -EOPNOTSUPP; | |
651 | might_sleep(); | |
652 | if (local->ops->get_antenna) | |
653 | ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant); | |
654 | trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret); | |
655 | return ret; | |
656 | } | |
657 | ||
21f83589 JB |
658 | static inline int drv_remain_on_channel(struct ieee80211_local *local, |
659 | struct ieee80211_channel *chan, | |
660 | enum nl80211_channel_type chantype, | |
661 | unsigned int duration) | |
662 | { | |
663 | int ret; | |
664 | ||
665 | might_sleep(); | |
666 | ||
667 | trace_drv_remain_on_channel(local, chan, chantype, duration); | |
668 | ret = local->ops->remain_on_channel(&local->hw, chan, chantype, | |
669 | duration); | |
670 | trace_drv_return_int(local, ret); | |
671 | ||
672 | return ret; | |
673 | } | |
674 | ||
675 | static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local) | |
676 | { | |
677 | int ret; | |
678 | ||
679 | might_sleep(); | |
680 | ||
681 | trace_drv_cancel_remain_on_channel(local); | |
682 | ret = local->ops->cancel_remain_on_channel(&local->hw); | |
683 | trace_drv_return_int(local, ret); | |
5f16a436 JB |
684 | |
685 | return ret; | |
686 | } | |
687 | ||
38c09159 JL |
688 | static inline int drv_set_ringparam(struct ieee80211_local *local, |
689 | u32 tx, u32 rx) | |
690 | { | |
691 | int ret = -ENOTSUPP; | |
692 | ||
693 | might_sleep(); | |
694 | ||
695 | trace_drv_set_ringparam(local, tx, rx); | |
696 | if (local->ops->set_ringparam) | |
697 | ret = local->ops->set_ringparam(&local->hw, tx, rx); | |
698 | trace_drv_return_int(local, ret); | |
699 | ||
700 | return ret; | |
701 | } | |
702 | ||
703 | static inline void drv_get_ringparam(struct ieee80211_local *local, | |
704 | u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max) | |
705 | { | |
706 | might_sleep(); | |
707 | ||
708 | trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max); | |
709 | if (local->ops->get_ringparam) | |
710 | local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max); | |
711 | trace_drv_return_void(local); | |
712 | } | |
713 | ||
e8306f98 VN |
714 | static inline bool drv_tx_frames_pending(struct ieee80211_local *local) |
715 | { | |
716 | bool ret = false; | |
717 | ||
718 | might_sleep(); | |
719 | ||
720 | trace_drv_tx_frames_pending(local); | |
721 | if (local->ops->tx_frames_pending) | |
722 | ret = local->ops->tx_frames_pending(&local->hw); | |
723 | trace_drv_return_bool(local, ret); | |
724 | ||
725 | return ret; | |
726 | } | |
bdbfd6b5 SM |
727 | |
728 | static inline int drv_set_bitrate_mask(struct ieee80211_local *local, | |
729 | struct ieee80211_sub_if_data *sdata, | |
730 | const struct cfg80211_bitrate_mask *mask) | |
731 | { | |
732 | int ret = -EOPNOTSUPP; | |
733 | ||
734 | might_sleep(); | |
735 | ||
7b7eab6f JB |
736 | check_sdata_in_driver(sdata); |
737 | ||
bdbfd6b5 SM |
738 | trace_drv_set_bitrate_mask(local, sdata, mask); |
739 | if (local->ops->set_bitrate_mask) | |
740 | ret = local->ops->set_bitrate_mask(&local->hw, | |
741 | &sdata->vif, mask); | |
742 | trace_drv_return_int(local, ret); | |
743 | ||
744 | return ret; | |
745 | } | |
746 | ||
c68f4b89 JB |
747 | static inline void drv_set_rekey_data(struct ieee80211_local *local, |
748 | struct ieee80211_sub_if_data *sdata, | |
749 | struct cfg80211_gtk_rekey_data *data) | |
750 | { | |
7b7eab6f JB |
751 | check_sdata_in_driver(sdata); |
752 | ||
c68f4b89 JB |
753 | trace_drv_set_rekey_data(local, sdata, data); |
754 | if (local->ops->set_rekey_data) | |
755 | local->ops->set_rekey_data(&local->hw, &sdata->vif, data); | |
756 | trace_drv_return_void(local); | |
757 | } | |
758 | ||
615f7b9b MV |
759 | static inline void drv_rssi_callback(struct ieee80211_local *local, |
760 | const enum ieee80211_rssi_event event) | |
761 | { | |
762 | trace_drv_rssi_callback(local, event); | |
763 | if (local->ops->rssi_callback) | |
764 | local->ops->rssi_callback(&local->hw, event); | |
765 | trace_drv_return_void(local); | |
766 | } | |
4049e09a JB |
767 | |
768 | static inline void | |
769 | drv_release_buffered_frames(struct ieee80211_local *local, | |
770 | struct sta_info *sta, u16 tids, int num_frames, | |
771 | enum ieee80211_frame_release_type reason, | |
772 | bool more_data) | |
773 | { | |
774 | trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames, | |
775 | reason, more_data); | |
776 | if (local->ops->release_buffered_frames) | |
777 | local->ops->release_buffered_frames(&local->hw, &sta->sta, tids, | |
778 | num_frames, reason, | |
779 | more_data); | |
780 | trace_drv_return_void(local); | |
781 | } | |
40b96408 JB |
782 | |
783 | static inline void | |
784 | drv_allow_buffered_frames(struct ieee80211_local *local, | |
785 | struct sta_info *sta, u16 tids, int num_frames, | |
786 | enum ieee80211_frame_release_type reason, | |
787 | bool more_data) | |
788 | { | |
789 | trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames, | |
790 | reason, more_data); | |
791 | if (local->ops->allow_buffered_frames) | |
792 | local->ops->allow_buffered_frames(&local->hw, &sta->sta, | |
793 | tids, num_frames, reason, | |
794 | more_data); | |
795 | trace_drv_return_void(local); | |
796 | } | |
24487981 | 797 | #endif /* __MAC80211_DRIVER_OPS */ |