Merge tag 'vfio-v4.2-rc5' of git://github.com/awilliam/linux-vfio
[linux-2.6-block.git] / net / mac80211 / driver-ops.h
CommitLineData
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
f6837ba8 8static inline bool check_sdata_in_driver(struct ieee80211_sub_if_data *sdata)
7b7eab6f 9{
f6837ba8
JB
10 return !WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER),
11 "%s: Failed check-sdata-in-driver check, flags: 0x%x\n",
12 sdata->dev ? sdata->dev->name : sdata->name, sdata->flags);
7b7eab6f
JB
13}
14
bc192f89
FF
15static inline struct ieee80211_sub_if_data *
16get_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
25static 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
32static 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
43static 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
55static 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
69static 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
83static 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
101static 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
114static 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
126static 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 140static 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 148 (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
30686bf7 149 !ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF) &&
31eba5bc 150 !(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE))))
7b7eab6f
JB
151 return -EINVAL;
152
153 trace_drv_add_interface(local, sdata);
154 ret = local->ops->add_interface(&local->hw, &sdata->vif);
4efc76bd 155 trace_drv_return_int(local, ret);
7b7eab6f
JB
156
157 if (ret == 0)
158 sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
159
0a2b8bb2 160 return ret;
24487981
JB
161}
162
34d4bc4d
JB
163static inline int drv_change_interface(struct ieee80211_local *local,
164 struct ieee80211_sub_if_data *sdata,
2ca27bcf 165 enum nl80211_iftype type, bool p2p)
34d4bc4d
JB
166{
167 int ret;
168
169 might_sleep();
170
f6837ba8
JB
171 if (!check_sdata_in_driver(sdata))
172 return -EIO;
7b7eab6f 173
2ca27bcf
JB
174 trace_drv_change_interface(local, sdata, type, p2p);
175 ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
34d4bc4d
JB
176 trace_drv_return_int(local, ret);
177 return ret;
178}
179
24487981 180static inline void drv_remove_interface(struct ieee80211_local *local,
7b7eab6f 181 struct ieee80211_sub_if_data *sdata)
24487981 182{
e1781ed3
KV
183 might_sleep();
184
f6837ba8
JB
185 if (!check_sdata_in_driver(sdata))
186 return;
7b7eab6f
JB
187
188 trace_drv_remove_interface(local, sdata);
189 local->ops->remove_interface(&local->hw, &sdata->vif);
190 sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER;
4efc76bd 191 trace_drv_return_void(local);
24487981
JB
192}
193
194static inline int drv_config(struct ieee80211_local *local, u32 changed)
195{
e1781ed3
KV
196 int ret;
197
198 might_sleep();
199
4efc76bd 200 trace_drv_config(local, changed);
e1781ed3 201 ret = local->ops->config(&local->hw, changed);
4efc76bd 202 trace_drv_return_int(local, ret);
0a2b8bb2 203 return ret;
24487981
JB
204}
205
206static inline void drv_bss_info_changed(struct ieee80211_local *local,
12375ef9 207 struct ieee80211_sub_if_data *sdata,
24487981
JB
208 struct ieee80211_bss_conf *info,
209 u32 changed)
210{
e1781ed3
KV
211 might_sleep();
212
5bbe754d
JB
213 if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
214 BSS_CHANGED_BEACON_ENABLED) &&
215 sdata->vif.type != NL80211_IFTYPE_AP &&
216 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
239281f8
RL
217 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
218 sdata->vif.type != NL80211_IFTYPE_OCB))
5bbe754d
JB
219 return;
220
221 if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
222 sdata->vif.type == NL80211_IFTYPE_MONITOR))
223 return;
b8dc1a35 224
f6837ba8
JB
225 if (!check_sdata_in_driver(sdata))
226 return;
7b7eab6f 227
4efc76bd 228 trace_drv_bss_info_changed(local, sdata, info, changed);
24487981 229 if (local->ops->bss_info_changed)
12375ef9 230 local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
4efc76bd 231 trace_drv_return_void(local);
24487981
JB
232}
233
3ac64bee 234static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
22bedad3 235 struct netdev_hw_addr_list *mc_list)
3ac64bee
JB
236{
237 u64 ret = 0;
238
4efc76bd
JB
239 trace_drv_prepare_multicast(local, mc_list->count);
240
3ac64bee 241 if (local->ops->prepare_multicast)
22bedad3 242 ret = local->ops->prepare_multicast(&local->hw, mc_list);
3ac64bee 243
4efc76bd 244 trace_drv_return_u64(local, ret);
3ac64bee
JB
245
246 return ret;
247}
248
24487981
JB
249static inline void drv_configure_filter(struct ieee80211_local *local,
250 unsigned int changed_flags,
251 unsigned int *total_flags,
3ac64bee 252 u64 multicast)
24487981 253{
3ac64bee
JB
254 might_sleep();
255
0a2b8bb2 256 trace_drv_configure_filter(local, changed_flags, total_flags,
3ac64bee 257 multicast);
4efc76bd
JB
258 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
259 multicast);
260 trace_drv_return_void(local);
24487981
JB
261}
262
263static inline int drv_set_tim(struct ieee80211_local *local,
264 struct ieee80211_sta *sta, bool set)
265{
0a2b8bb2 266 int ret = 0;
4efc76bd 267 trace_drv_set_tim(local, sta, set);
24487981 268 if (local->ops->set_tim)
0a2b8bb2 269 ret = local->ops->set_tim(&local->hw, sta, set);
4efc76bd 270 trace_drv_return_int(local, ret);
0a2b8bb2 271 return ret;
24487981
JB
272}
273
274static inline int drv_set_key(struct ieee80211_local *local,
12375ef9
JB
275 enum set_key_cmd cmd,
276 struct ieee80211_sub_if_data *sdata,
24487981
JB
277 struct ieee80211_sta *sta,
278 struct ieee80211_key_conf *key)
279{
e1781ed3
KV
280 int ret;
281
282 might_sleep();
283
077f4939 284 sdata = get_bss_sdata(sdata);
f6837ba8
JB
285 if (!check_sdata_in_driver(sdata))
286 return -EIO;
7b7eab6f 287
4efc76bd 288 trace_drv_set_key(local, cmd, sdata, sta, key);
e1781ed3 289 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
4efc76bd 290 trace_drv_return_int(local, ret);
0a2b8bb2 291 return ret;
24487981
JB
292}
293
294static inline void drv_update_tkip_key(struct ieee80211_local *local,
b3fbdcf4 295 struct ieee80211_sub_if_data *sdata,
24487981 296 struct ieee80211_key_conf *conf,
b3fbdcf4 297 struct sta_info *sta, u32 iv32,
24487981
JB
298 u16 *phase1key)
299{
b3fbdcf4
JB
300 struct ieee80211_sta *ista = NULL;
301
b3fbdcf4
JB
302 if (sta)
303 ista = &sta->sta;
304
077f4939 305 sdata = get_bss_sdata(sdata);
f6837ba8
JB
306 if (!check_sdata_in_driver(sdata))
307 return;
7b7eab6f 308
4efc76bd 309 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
24487981 310 if (local->ops->update_tkip_key)
b3fbdcf4
JB
311 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
312 ista, iv32, phase1key);
4efc76bd 313 trace_drv_return_void(local);
24487981
JB
314}
315
316static inline int drv_hw_scan(struct ieee80211_local *local,
a060bbfe 317 struct ieee80211_sub_if_data *sdata,
c56ef672 318 struct ieee80211_scan_request *req)
24487981 319{
e1781ed3
KV
320 int ret;
321
322 might_sleep();
323
f6837ba8
JB
324 if (!check_sdata_in_driver(sdata))
325 return -EIO;
7b7eab6f 326
79f460ca 327 trace_drv_hw_scan(local, sdata);
a060bbfe 328 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
4efc76bd 329 trace_drv_return_int(local, ret);
0a2b8bb2 330 return ret;
24487981
JB
331}
332
b856439b
EP
333static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
334 struct ieee80211_sub_if_data *sdata)
335{
336 might_sleep();
337
f6837ba8
JB
338 if (!check_sdata_in_driver(sdata))
339 return;
7b7eab6f 340
b856439b
EP
341 trace_drv_cancel_hw_scan(local, sdata);
342 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
343 trace_drv_return_void(local);
344}
345
79f460ca
LC
346static inline int
347drv_sched_scan_start(struct ieee80211_local *local,
348 struct ieee80211_sub_if_data *sdata,
349 struct cfg80211_sched_scan_request *req,
633e2713 350 struct ieee80211_scan_ies *ies)
79f460ca
LC
351{
352 int ret;
353
354 might_sleep();
355
f6837ba8
JB
356 if (!check_sdata_in_driver(sdata))
357 return -EIO;
7b7eab6f 358
79f460ca
LC
359 trace_drv_sched_scan_start(local, sdata);
360 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
361 req, ies);
362 trace_drv_return_int(local, ret);
363 return ret;
364}
365
37e3308c
JB
366static inline int drv_sched_scan_stop(struct ieee80211_local *local,
367 struct ieee80211_sub_if_data *sdata)
79f460ca 368{
37e3308c
JB
369 int ret;
370
79f460ca
LC
371 might_sleep();
372
f6837ba8
JB
373 if (!check_sdata_in_driver(sdata))
374 return -EIO;
7b7eab6f 375
79f460ca 376 trace_drv_sched_scan_stop(local, sdata);
37e3308c
JB
377 ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
378 trace_drv_return_int(local, ret);
379
380 return ret;
79f460ca
LC
381}
382
a344d677
JB
383static inline void drv_sw_scan_start(struct ieee80211_local *local,
384 struct ieee80211_sub_if_data *sdata,
385 const u8 *mac_addr)
24487981 386{
e1781ed3
KV
387 might_sleep();
388
a344d677 389 trace_drv_sw_scan_start(local, sdata, mac_addr);
24487981 390 if (local->ops->sw_scan_start)
a344d677 391 local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
4efc76bd 392 trace_drv_return_void(local);
24487981
JB
393}
394
a344d677
JB
395static inline void drv_sw_scan_complete(struct ieee80211_local *local,
396 struct ieee80211_sub_if_data *sdata)
24487981 397{
e1781ed3
KV
398 might_sleep();
399
a344d677 400 trace_drv_sw_scan_complete(local, sdata);
24487981 401 if (local->ops->sw_scan_complete)
a344d677 402 local->ops->sw_scan_complete(&local->hw, &sdata->vif);
4efc76bd 403 trace_drv_return_void(local);
24487981
JB
404}
405
406static inline int drv_get_stats(struct ieee80211_local *local,
407 struct ieee80211_low_level_stats *stats)
408{
0a2b8bb2
JB
409 int ret = -EOPNOTSUPP;
410
e1781ed3
KV
411 might_sleep();
412
0a2b8bb2
JB
413 if (local->ops->get_stats)
414 ret = local->ops->get_stats(&local->hw, stats);
415 trace_drv_get_stats(local, stats, ret);
416
417 return ret;
24487981
JB
418}
419
9352c19f
JB
420static inline void drv_get_key_seq(struct ieee80211_local *local,
421 struct ieee80211_key *key,
422 struct ieee80211_key_seq *seq)
24487981 423{
9352c19f
JB
424 if (local->ops->get_key_seq)
425 local->ops->get_key_seq(&local->hw, &key->conf, seq);
426 trace_drv_get_key_seq(local, &key->conf);
24487981
JB
427}
428
f23a4780
AN
429static inline int drv_set_frag_threshold(struct ieee80211_local *local,
430 u32 value)
431{
432 int ret = 0;
433
434 might_sleep();
435
436 trace_drv_set_frag_threshold(local, value);
437 if (local->ops->set_frag_threshold)
438 ret = local->ops->set_frag_threshold(&local->hw, value);
439 trace_drv_return_int(local, ret);
440 return ret;
441}
442
24487981
JB
443static inline int drv_set_rts_threshold(struct ieee80211_local *local,
444 u32 value)
445{
0a2b8bb2 446 int ret = 0;
e1781ed3
KV
447
448 might_sleep();
449
4efc76bd 450 trace_drv_set_rts_threshold(local, value);
24487981 451 if (local->ops->set_rts_threshold)
0a2b8bb2 452 ret = local->ops->set_rts_threshold(&local->hw, value);
4efc76bd 453 trace_drv_return_int(local, ret);
0a2b8bb2 454 return ret;
24487981
JB
455}
456
310bc676 457static inline int drv_set_coverage_class(struct ieee80211_local *local,
a4bcaf55 458 s16 value)
310bc676
LT
459{
460 int ret = 0;
461 might_sleep();
462
4efc76bd 463 trace_drv_set_coverage_class(local, value);
310bc676
LT
464 if (local->ops->set_coverage_class)
465 local->ops->set_coverage_class(&local->hw, value);
466 else
467 ret = -EOPNOTSUPP;
468
4efc76bd 469 trace_drv_return_int(local, ret);
310bc676
LT
470 return ret;
471}
472
24487981 473static inline void drv_sta_notify(struct ieee80211_local *local,
12375ef9 474 struct ieee80211_sub_if_data *sdata,
24487981
JB
475 enum sta_notify_cmd cmd,
476 struct ieee80211_sta *sta)
477{
bc192f89 478 sdata = get_bss_sdata(sdata);
f6837ba8
JB
479 if (!check_sdata_in_driver(sdata))
480 return;
7b7eab6f 481
4efc76bd 482 trace_drv_sta_notify(local, sdata, cmd, sta);
24487981 483 if (local->ops->sta_notify)
12375ef9 484 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
4efc76bd 485 trace_drv_return_void(local);
24487981
JB
486}
487
34e89507
JB
488static inline int drv_sta_add(struct ieee80211_local *local,
489 struct ieee80211_sub_if_data *sdata,
490 struct ieee80211_sta *sta)
491{
492 int ret = 0;
493
494 might_sleep();
495
bc192f89 496 sdata = get_bss_sdata(sdata);
f6837ba8
JB
497 if (!check_sdata_in_driver(sdata))
498 return -EIO;
7b7eab6f 499
4efc76bd 500 trace_drv_sta_add(local, sdata, sta);
34e89507
JB
501 if (local->ops->sta_add)
502 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
34e89507 503
4efc76bd 504 trace_drv_return_int(local, ret);
34e89507
JB
505
506 return ret;
507}
508
509static inline void drv_sta_remove(struct ieee80211_local *local,
510 struct ieee80211_sub_if_data *sdata,
511 struct ieee80211_sta *sta)
512{
513 might_sleep();
514
bc192f89 515 sdata = get_bss_sdata(sdata);
f6837ba8
JB
516 if (!check_sdata_in_driver(sdata))
517 return;
7b7eab6f 518
4efc76bd 519 trace_drv_sta_remove(local, sdata, sta);
34e89507
JB
520 if (local->ops->sta_remove)
521 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
34e89507 522
4efc76bd 523 trace_drv_return_void(local);
34e89507
JB
524}
525
77d2ece6
SM
526#ifdef CONFIG_MAC80211_DEBUGFS
527static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
528 struct ieee80211_sub_if_data *sdata,
529 struct ieee80211_sta *sta,
530 struct dentry *dir)
531{
532 might_sleep();
533
534 sdata = get_bss_sdata(sdata);
f6837ba8
JB
535 if (!check_sdata_in_driver(sdata))
536 return;
77d2ece6
SM
537
538 if (local->ops->sta_add_debugfs)
539 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
540 sta, dir);
541}
542
543static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
544 struct ieee80211_sub_if_data *sdata,
545 struct ieee80211_sta *sta,
546 struct dentry *dir)
547{
548 might_sleep();
549
550 sdata = get_bss_sdata(sdata);
551 check_sdata_in_driver(sdata);
552
553 if (local->ops->sta_remove_debugfs)
554 local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
555 sta, dir);
556}
557#endif
558
6a9d1b91
JB
559static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
560 struct ieee80211_sub_if_data *sdata,
561 struct sta_info *sta)
562{
563 might_sleep();
564
565 sdata = get_bss_sdata(sdata);
f6837ba8
JB
566 if (!check_sdata_in_driver(sdata))
567 return;
6a9d1b91
JB
568
569 trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
570 if (local->ops->sta_pre_rcu_remove)
571 local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
572 &sta->sta);
573 trace_drv_return_void(local);
574}
575
f09603a2
JB
576static inline __must_check
577int drv_sta_state(struct ieee80211_local *local,
578 struct ieee80211_sub_if_data *sdata,
579 struct sta_info *sta,
580 enum ieee80211_sta_state old_state,
581 enum ieee80211_sta_state new_state)
582{
583 int ret = 0;
584
585 might_sleep();
586
587 sdata = get_bss_sdata(sdata);
f6837ba8
JB
588 if (!check_sdata_in_driver(sdata))
589 return -EIO;
f09603a2
JB
590
591 trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
a4ec45a4 592 if (local->ops->sta_state) {
f09603a2
JB
593 ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta,
594 old_state, new_state);
a4ec45a4
JB
595 } else if (old_state == IEEE80211_STA_AUTH &&
596 new_state == IEEE80211_STA_ASSOC) {
597 ret = drv_sta_add(local, sdata, &sta->sta);
598 if (ret == 0)
599 sta->uploaded = true;
600 } else if (old_state == IEEE80211_STA_ASSOC &&
601 new_state == IEEE80211_STA_AUTH) {
602 drv_sta_remove(local, sdata, &sta->sta);
603 }
f09603a2
JB
604 trace_drv_return_int(local, ret);
605 return ret;
606}
607
8f727ef3
JB
608static inline void drv_sta_rc_update(struct ieee80211_local *local,
609 struct ieee80211_sub_if_data *sdata,
610 struct ieee80211_sta *sta, u32 changed)
611{
612 sdata = get_bss_sdata(sdata);
f6837ba8
JB
613 if (!check_sdata_in_driver(sdata))
614 return;
8f727ef3 615
e687f61e 616 WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED &&
f68d776a
TP
617 (sdata->vif.type != NL80211_IFTYPE_ADHOC &&
618 sdata->vif.type != NL80211_IFTYPE_MESH_POINT));
e687f61e 619
8f727ef3
JB
620 trace_drv_sta_rc_update(local, sdata, sta, changed);
621 if (local->ops->sta_rc_update)
622 local->ops->sta_rc_update(&local->hw, &sdata->vif,
623 sta, changed);
624
625 trace_drv_return_void(local);
626}
627
f815e2b3
JB
628static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
629 struct ieee80211_sub_if_data *sdata,
630 struct ieee80211_sta *sta)
631{
632 sdata = get_bss_sdata(sdata);
633 if (!check_sdata_in_driver(sdata))
634 return;
635
636 trace_drv_sta_rate_tbl_update(local, sdata, sta);
637 if (local->ops->sta_rate_tbl_update)
638 local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
639
640 trace_drv_return_void(local);
641}
642
2b9a7e1b
JB
643static inline void drv_sta_statistics(struct ieee80211_local *local,
644 struct ieee80211_sub_if_data *sdata,
645 struct ieee80211_sta *sta,
646 struct station_info *sinfo)
647{
648 sdata = get_bss_sdata(sdata);
649 if (!check_sdata_in_driver(sdata))
650 return;
651
652 trace_drv_sta_statistics(local, sdata, sta);
653 if (local->ops->sta_statistics)
654 local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
655 trace_drv_return_void(local);
656}
657
f6f3def3 658static inline int drv_conf_tx(struct ieee80211_local *local,
a3304b0a 659 struct ieee80211_sub_if_data *sdata, u16 ac,
24487981
JB
660 const struct ieee80211_tx_queue_params *params)
661{
0a2b8bb2 662 int ret = -EOPNOTSUPP;
e1781ed3
KV
663
664 might_sleep();
665
f6837ba8
JB
666 if (!check_sdata_in_driver(sdata))
667 return -EIO;
7b7eab6f 668
f409079b
JB
669 if (WARN_ONCE(params->cw_min == 0 ||
670 params->cw_min > params->cw_max,
671 "%s: invalid CW_min/CW_max: %d/%d\n",
672 sdata->name, params->cw_min, params->cw_max))
673 return -EINVAL;
674
a3304b0a 675 trace_drv_conf_tx(local, sdata, ac, params);
24487981 676 if (local->ops->conf_tx)
8a3a3c85 677 ret = local->ops->conf_tx(&local->hw, &sdata->vif,
a3304b0a 678 ac, params);
4efc76bd 679 trace_drv_return_int(local, ret);
0a2b8bb2 680 return ret;
24487981
JB
681}
682
37a41b4a
EP
683static inline u64 drv_get_tsf(struct ieee80211_local *local,
684 struct ieee80211_sub_if_data *sdata)
24487981 685{
0a2b8bb2 686 u64 ret = -1ULL;
e1781ed3
KV
687
688 might_sleep();
689
f6837ba8
JB
690 if (!check_sdata_in_driver(sdata))
691 return ret;
7b7eab6f 692
37a41b4a 693 trace_drv_get_tsf(local, sdata);
24487981 694 if (local->ops->get_tsf)
37a41b4a 695 ret = local->ops->get_tsf(&local->hw, &sdata->vif);
4efc76bd 696 trace_drv_return_u64(local, ret);
0a2b8bb2 697 return ret;
24487981
JB
698}
699
37a41b4a
EP
700static inline void drv_set_tsf(struct ieee80211_local *local,
701 struct ieee80211_sub_if_data *sdata,
702 u64 tsf)
24487981 703{
e1781ed3
KV
704 might_sleep();
705
f6837ba8
JB
706 if (!check_sdata_in_driver(sdata))
707 return;
7b7eab6f 708
37a41b4a 709 trace_drv_set_tsf(local, sdata, tsf);
24487981 710 if (local->ops->set_tsf)
37a41b4a 711 local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
4efc76bd 712 trace_drv_return_void(local);
24487981
JB
713}
714
37a41b4a
EP
715static inline void drv_reset_tsf(struct ieee80211_local *local,
716 struct ieee80211_sub_if_data *sdata)
24487981 717{
e1781ed3
KV
718 might_sleep();
719
f6837ba8
JB
720 if (!check_sdata_in_driver(sdata))
721 return;
7b7eab6f 722
37a41b4a 723 trace_drv_reset_tsf(local, sdata);
24487981 724 if (local->ops->reset_tsf)
37a41b4a 725 local->ops->reset_tsf(&local->hw, &sdata->vif);
4efc76bd 726 trace_drv_return_void(local);
24487981
JB
727}
728
729static inline int drv_tx_last_beacon(struct ieee80211_local *local)
730{
02582e9b 731 int ret = 0; /* default unsupported op for less congestion */
e1781ed3
KV
732
733 might_sleep();
734
4efc76bd 735 trace_drv_tx_last_beacon(local);
24487981 736 if (local->ops->tx_last_beacon)
0a2b8bb2 737 ret = local->ops->tx_last_beacon(&local->hw);
4efc76bd 738 trace_drv_return_int(local, ret);
0a2b8bb2 739 return ret;
24487981
JB
740}
741
742static inline int drv_ampdu_action(struct ieee80211_local *local,
12375ef9 743 struct ieee80211_sub_if_data *sdata,
24487981
JB
744 enum ieee80211_ampdu_mlme_action action,
745 struct ieee80211_sta *sta, u16 tid,
0b01f030 746 u16 *ssn, u8 buf_size)
24487981 747{
0a2b8bb2 748 int ret = -EOPNOTSUPP;
cfcdbde3
JB
749
750 might_sleep();
751
bc192f89 752 sdata = get_bss_sdata(sdata);
f6837ba8
JB
753 if (!check_sdata_in_driver(sdata))
754 return -EIO;
7b7eab6f 755
0b01f030 756 trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
4efc76bd 757
24487981 758 if (local->ops->ampdu_action)
12375ef9 759 ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
0b01f030 760 sta, tid, ssn, buf_size);
85ad181e 761
4efc76bd
JB
762 trace_drv_return_int(local, ret);
763
0a2b8bb2 764 return ret;
24487981 765}
1f87f7d3 766
1289723e
HS
767static inline int drv_get_survey(struct ieee80211_local *local, int idx,
768 struct survey_info *survey)
769{
770 int ret = -EOPNOTSUPP;
c466d4ef
JL
771
772 trace_drv_get_survey(local, idx, survey);
773
35dd0509 774 if (local->ops->get_survey)
1289723e 775 ret = local->ops->get_survey(&local->hw, idx, survey);
c466d4ef
JL
776
777 trace_drv_return_int(local, ret);
778
1289723e
HS
779 return ret;
780}
1f87f7d3
JB
781
782static inline void drv_rfkill_poll(struct ieee80211_local *local)
783{
e1781ed3
KV
784 might_sleep();
785
1f87f7d3
JB
786 if (local->ops->rfkill_poll)
787 local->ops->rfkill_poll(&local->hw);
788}
a80f7c0b 789
39ecc01d 790static inline void drv_flush(struct ieee80211_local *local,
77be2c54 791 struct ieee80211_sub_if_data *sdata,
39ecc01d 792 u32 queues, bool drop)
a80f7c0b 793{
77be2c54
EG
794 struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
795
e1781ed3
KV
796 might_sleep();
797
f6837ba8
JB
798 if (sdata && !check_sdata_in_driver(sdata))
799 return;
77be2c54 800
39ecc01d 801 trace_drv_flush(local, queues, drop);
a80f7c0b 802 if (local->ops->flush)
77be2c54 803 local->ops->flush(&local->hw, vif, queues, drop);
4efc76bd 804 trace_drv_return_void(local);
a80f7c0b 805}
5ce6e438
JB
806
807static inline void drv_channel_switch(struct ieee80211_local *local,
0f791eb4
LC
808 struct ieee80211_sub_if_data *sdata,
809 struct ieee80211_channel_switch *ch_switch)
5ce6e438
JB
810{
811 might_sleep();
812
0f791eb4
LC
813 trace_drv_channel_switch(local, sdata, ch_switch);
814 local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
4efc76bd 815 trace_drv_return_void(local);
5ce6e438
JB
816}
817
15d96753
BR
818
819static inline int drv_set_antenna(struct ieee80211_local *local,
820 u32 tx_ant, u32 rx_ant)
821{
822 int ret = -EOPNOTSUPP;
823 might_sleep();
824 if (local->ops->set_antenna)
825 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
826 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
827 return ret;
828}
829
830static inline int drv_get_antenna(struct ieee80211_local *local,
831 u32 *tx_ant, u32 *rx_ant)
832{
833 int ret = -EOPNOTSUPP;
834 might_sleep();
835 if (local->ops->get_antenna)
836 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
837 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
838 return ret;
839}
840
21f83589 841static inline int drv_remain_on_channel(struct ieee80211_local *local,
49884568 842 struct ieee80211_sub_if_data *sdata,
21f83589 843 struct ieee80211_channel *chan,
d339d5ca
IP
844 unsigned int duration,
845 enum ieee80211_roc_type type)
21f83589
JB
846{
847 int ret;
848
849 might_sleep();
850
d339d5ca 851 trace_drv_remain_on_channel(local, sdata, chan, duration, type);
49884568 852 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
d339d5ca 853 chan, duration, type);
21f83589
JB
854 trace_drv_return_int(local, ret);
855
856 return ret;
857}
858
859static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
860{
861 int ret;
862
863 might_sleep();
864
865 trace_drv_cancel_remain_on_channel(local);
866 ret = local->ops->cancel_remain_on_channel(&local->hw);
867 trace_drv_return_int(local, ret);
5f16a436
JB
868
869 return ret;
870}
871
38c09159
JL
872static inline int drv_set_ringparam(struct ieee80211_local *local,
873 u32 tx, u32 rx)
874{
875 int ret = -ENOTSUPP;
876
877 might_sleep();
878
879 trace_drv_set_ringparam(local, tx, rx);
880 if (local->ops->set_ringparam)
881 ret = local->ops->set_ringparam(&local->hw, tx, rx);
882 trace_drv_return_int(local, ret);
883
884 return ret;
885}
886
887static inline void drv_get_ringparam(struct ieee80211_local *local,
888 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
889{
890 might_sleep();
891
892 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
893 if (local->ops->get_ringparam)
894 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
895 trace_drv_return_void(local);
896}
897
e8306f98
VN
898static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
899{
900 bool ret = false;
901
902 might_sleep();
903
904 trace_drv_tx_frames_pending(local);
905 if (local->ops->tx_frames_pending)
906 ret = local->ops->tx_frames_pending(&local->hw);
907 trace_drv_return_bool(local, ret);
908
909 return ret;
910}
bdbfd6b5
SM
911
912static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
913 struct ieee80211_sub_if_data *sdata,
914 const struct cfg80211_bitrate_mask *mask)
915{
916 int ret = -EOPNOTSUPP;
917
918 might_sleep();
919
f6837ba8
JB
920 if (!check_sdata_in_driver(sdata))
921 return -EIO;
7b7eab6f 922
bdbfd6b5
SM
923 trace_drv_set_bitrate_mask(local, sdata, mask);
924 if (local->ops->set_bitrate_mask)
925 ret = local->ops->set_bitrate_mask(&local->hw,
926 &sdata->vif, mask);
927 trace_drv_return_int(local, ret);
928
929 return ret;
930}
931
c68f4b89
JB
932static inline void drv_set_rekey_data(struct ieee80211_local *local,
933 struct ieee80211_sub_if_data *sdata,
934 struct cfg80211_gtk_rekey_data *data)
935{
f6837ba8
JB
936 if (!check_sdata_in_driver(sdata))
937 return;
7b7eab6f 938
c68f4b89
JB
939 trace_drv_set_rekey_data(local, sdata, data);
940 if (local->ops->set_rekey_data)
941 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
942 trace_drv_return_void(local);
943}
944
a8182929
EG
945static inline void drv_event_callback(struct ieee80211_local *local,
946 struct ieee80211_sub_if_data *sdata,
947 const struct ieee80211_event *event)
615f7b9b 948{
a8182929
EG
949 trace_drv_event_callback(local, sdata, event);
950 if (local->ops->event_callback)
951 local->ops->event_callback(&local->hw, &sdata->vif, event);
615f7b9b
MV
952 trace_drv_return_void(local);
953}
4049e09a
JB
954
955static inline void
956drv_release_buffered_frames(struct ieee80211_local *local,
957 struct sta_info *sta, u16 tids, int num_frames,
958 enum ieee80211_frame_release_type reason,
959 bool more_data)
960{
961 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
962 reason, more_data);
963 if (local->ops->release_buffered_frames)
964 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
965 num_frames, reason,
966 more_data);
967 trace_drv_return_void(local);
968}
40b96408
JB
969
970static inline void
971drv_allow_buffered_frames(struct ieee80211_local *local,
972 struct sta_info *sta, u16 tids, int num_frames,
973 enum ieee80211_frame_release_type reason,
974 bool more_data)
975{
976 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
977 reason, more_data);
978 if (local->ops->allow_buffered_frames)
979 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
980 tids, num_frames, reason,
981 more_data);
982 trace_drv_return_void(local);
983}
66572cfc 984
a1845fc7
JB
985static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
986 struct ieee80211_sub_if_data *sdata)
987{
988 might_sleep();
989
f6837ba8
JB
990 if (!check_sdata_in_driver(sdata))
991 return;
a1845fc7
JB
992 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
993
994 trace_drv_mgd_prepare_tx(local, sdata);
995 if (local->ops->mgd_prepare_tx)
996 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
997 trace_drv_return_void(local);
998}
c3645eac 999
ee10f2c7
AN
1000static inline void
1001drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
1002 struct ieee80211_sub_if_data *sdata)
1003{
1004 might_sleep();
1005
1006 if (!check_sdata_in_driver(sdata))
1007 return;
1008 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
1009
1010 trace_drv_mgd_protect_tdls_discover(local, sdata);
1011 if (local->ops->mgd_protect_tdls_discover)
1012 local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
1013 trace_drv_return_void(local);
1014}
1015
c3645eac
MK
1016static inline int drv_add_chanctx(struct ieee80211_local *local,
1017 struct ieee80211_chanctx *ctx)
1018{
1019 int ret = -EOPNOTSUPP;
1020
1021 trace_drv_add_chanctx(local, ctx);
1022 if (local->ops->add_chanctx)
1023 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
1024 trace_drv_return_int(local, ret);
8a61af65
JB
1025 if (!ret)
1026 ctx->driver_present = true;
c3645eac
MK
1027
1028 return ret;
1029}
1030
1031static inline void drv_remove_chanctx(struct ieee80211_local *local,
1032 struct ieee80211_chanctx *ctx)
1033{
f6837ba8
JB
1034 if (WARN_ON(!ctx->driver_present))
1035 return;
1036
c3645eac
MK
1037 trace_drv_remove_chanctx(local, ctx);
1038 if (local->ops->remove_chanctx)
1039 local->ops->remove_chanctx(&local->hw, &ctx->conf);
1040 trace_drv_return_void(local);
8a61af65 1041 ctx->driver_present = false;
c3645eac
MK
1042}
1043
1044static inline void drv_change_chanctx(struct ieee80211_local *local,
1045 struct ieee80211_chanctx *ctx,
1046 u32 changed)
1047{
1048 trace_drv_change_chanctx(local, ctx, changed);
8a61af65
JB
1049 if (local->ops->change_chanctx) {
1050 WARN_ON_ONCE(!ctx->driver_present);
c3645eac 1051 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
8a61af65 1052 }
c3645eac
MK
1053 trace_drv_return_void(local);
1054}
1055
1056static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
1057 struct ieee80211_sub_if_data *sdata,
1058 struct ieee80211_chanctx *ctx)
1059{
1060 int ret = 0;
1061
f6837ba8
JB
1062 if (!check_sdata_in_driver(sdata))
1063 return -EIO;
c3645eac
MK
1064
1065 trace_drv_assign_vif_chanctx(local, sdata, ctx);
8a61af65
JB
1066 if (local->ops->assign_vif_chanctx) {
1067 WARN_ON_ONCE(!ctx->driver_present);
c3645eac
MK
1068 ret = local->ops->assign_vif_chanctx(&local->hw,
1069 &sdata->vif,
1070 &ctx->conf);
8a61af65 1071 }
c3645eac
MK
1072 trace_drv_return_int(local, ret);
1073
1074 return ret;
1075}
1076
1077static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
1078 struct ieee80211_sub_if_data *sdata,
1079 struct ieee80211_chanctx *ctx)
1080{
f6837ba8
JB
1081 if (!check_sdata_in_driver(sdata))
1082 return;
c3645eac
MK
1083
1084 trace_drv_unassign_vif_chanctx(local, sdata, ctx);
8a61af65
JB
1085 if (local->ops->unassign_vif_chanctx) {
1086 WARN_ON_ONCE(!ctx->driver_present);
c3645eac
MK
1087 local->ops->unassign_vif_chanctx(&local->hw,
1088 &sdata->vif,
1089 &ctx->conf);
8a61af65 1090 }
c3645eac
MK
1091 trace_drv_return_void(local);
1092}
1093
1a5f0c13
LC
1094static inline int
1095drv_switch_vif_chanctx(struct ieee80211_local *local,
1096 struct ieee80211_vif_chanctx_switch *vifs,
1097 int n_vifs,
1098 enum ieee80211_chanctx_switch_mode mode)
1099{
1100 int ret = 0;
1101 int i;
1102
1103 if (!local->ops->switch_vif_chanctx)
1104 return -EOPNOTSUPP;
1105
1106 for (i = 0; i < n_vifs; i++) {
1107 struct ieee80211_chanctx *new_ctx =
1108 container_of(vifs[i].new_ctx,
1109 struct ieee80211_chanctx,
1110 conf);
1111 struct ieee80211_chanctx *old_ctx =
1112 container_of(vifs[i].old_ctx,
1113 struct ieee80211_chanctx,
1114 conf);
1115
1116 WARN_ON_ONCE(!old_ctx->driver_present);
1117 WARN_ON_ONCE((mode == CHANCTX_SWMODE_SWAP_CONTEXTS &&
1118 new_ctx->driver_present) ||
1119 (mode == CHANCTX_SWMODE_REASSIGN_VIF &&
1120 !new_ctx->driver_present));
1121 }
1122
1123 trace_drv_switch_vif_chanctx(local, vifs, n_vifs, mode);
1124 ret = local->ops->switch_vif_chanctx(&local->hw,
1125 vifs, n_vifs, mode);
1126 trace_drv_return_int(local, ret);
1127
1128 if (!ret && mode == CHANCTX_SWMODE_SWAP_CONTEXTS) {
1129 for (i = 0; i < n_vifs; i++) {
1130 struct ieee80211_chanctx *new_ctx =
1131 container_of(vifs[i].new_ctx,
1132 struct ieee80211_chanctx,
1133 conf);
1134 struct ieee80211_chanctx *old_ctx =
1135 container_of(vifs[i].old_ctx,
1136 struct ieee80211_chanctx,
1137 conf);
1138
1139 new_ctx->driver_present = true;
1140 old_ctx->driver_present = false;
1141 }
1142 }
1143
1144 return ret;
1145}
1146
1041638f
JB
1147static inline int drv_start_ap(struct ieee80211_local *local,
1148 struct ieee80211_sub_if_data *sdata)
1149{
1150 int ret = 0;
1151
f6837ba8
JB
1152 if (!check_sdata_in_driver(sdata))
1153 return -EIO;
1041638f
JB
1154
1155 trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
1156 if (local->ops->start_ap)
1157 ret = local->ops->start_ap(&local->hw, &sdata->vif);
1158 trace_drv_return_int(local, ret);
1159 return ret;
1160}
1161
1162static inline void drv_stop_ap(struct ieee80211_local *local,
1163 struct ieee80211_sub_if_data *sdata)
1164{
f6837ba8
JB
1165 if (!check_sdata_in_driver(sdata))
1166 return;
1041638f
JB
1167
1168 trace_drv_stop_ap(local, sdata);
1169 if (local->ops->stop_ap)
1170 local->ops->stop_ap(&local->hw, &sdata->vif);
1171 trace_drv_return_void(local);
1172}
1173
cf2c92d8
EP
1174static inline void
1175drv_reconfig_complete(struct ieee80211_local *local,
1176 enum ieee80211_reconfig_type reconfig_type)
9214ad7f
JB
1177{
1178 might_sleep();
1179
cf2c92d8
EP
1180 trace_drv_reconfig_complete(local, reconfig_type);
1181 if (local->ops->reconfig_complete)
1182 local->ops->reconfig_complete(&local->hw, reconfig_type);
9214ad7f
JB
1183 trace_drv_return_void(local);
1184}
1185
de5fad81
YD
1186static inline void
1187drv_set_default_unicast_key(struct ieee80211_local *local,
1188 struct ieee80211_sub_if_data *sdata,
1189 int key_idx)
1190{
f6837ba8
JB
1191 if (!check_sdata_in_driver(sdata))
1192 return;
de5fad81
YD
1193
1194 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1195
1196 trace_drv_set_default_unicast_key(local, sdata, key_idx);
1197 if (local->ops->set_default_unicast_key)
1198 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1199 key_idx);
1200 trace_drv_return_void(local);
1201}
1202
a65240c1
JB
1203#if IS_ENABLED(CONFIG_IPV6)
1204static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1205 struct ieee80211_sub_if_data *sdata,
1206 struct inet6_dev *idev)
1207{
1208 trace_drv_ipv6_addr_change(local, sdata);
1209 if (local->ops->ipv6_addr_change)
1210 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1211 trace_drv_return_void(local);
1212}
1213#endif
1214
73da7d5b
SW
1215static inline void
1216drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1217 struct cfg80211_chan_def *chandef)
1218{
1219 struct ieee80211_local *local = sdata->local;
1220
1221 if (local->ops->channel_switch_beacon) {
1222 trace_drv_channel_switch_beacon(local, sdata, chandef);
1223 local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1224 chandef);
1225 }
1226}
1227
6d027bcc
LC
1228static inline int
1229drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
1230 struct ieee80211_channel_switch *ch_switch)
1231{
1232 struct ieee80211_local *local = sdata->local;
1233 int ret = 0;
1234
1235 if (!check_sdata_in_driver(sdata))
1236 return -EIO;
1237
1238 trace_drv_pre_channel_switch(local, sdata, ch_switch);
1239 if (local->ops->pre_channel_switch)
1240 ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
1241 ch_switch);
1242 trace_drv_return_int(local, ret);
1243 return ret;
1244}
1245
f1d65583
LC
1246static inline int
1247drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1248{
1249 struct ieee80211_local *local = sdata->local;
1250 int ret = 0;
1251
1252 if (!check_sdata_in_driver(sdata))
1253 return -EIO;
1254
1255 trace_drv_post_channel_switch(local, sdata);
1256 if (local->ops->post_channel_switch)
1257 ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1258 trace_drv_return_int(local, ret);
1259 return ret;
1260}
1261
55fff501
JB
1262static inline int drv_join_ibss(struct ieee80211_local *local,
1263 struct ieee80211_sub_if_data *sdata)
1264{
1265 int ret = 0;
1266
1267 might_sleep();
f6837ba8
JB
1268 if (!check_sdata_in_driver(sdata))
1269 return -EIO;
55fff501
JB
1270
1271 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1272 if (local->ops->join_ibss)
1273 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1274 trace_drv_return_int(local, ret);
1275 return ret;
1276}
1277
1278static inline void drv_leave_ibss(struct ieee80211_local *local,
1279 struct ieee80211_sub_if_data *sdata)
1280{
1281 might_sleep();
f6837ba8
JB
1282 if (!check_sdata_in_driver(sdata))
1283 return;
55fff501
JB
1284
1285 trace_drv_leave_ibss(local, sdata);
1286 if (local->ops->leave_ibss)
1287 local->ops->leave_ibss(&local->hw, &sdata->vif);
1288 trace_drv_return_void(local);
1289}
1290
cca674d4
AQ
1291static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
1292 struct ieee80211_sta *sta)
1293{
1294 u32 ret = 0;
1295
1296 trace_drv_get_expected_throughput(sta);
1297 if (local->ops->get_expected_throughput)
1298 ret = local->ops->get_expected_throughput(sta);
1299 trace_drv_return_u32(local, ret);
1300
1301 return ret;
1302}
1303
5b3dc42b
FF
1304static inline int drv_get_txpower(struct ieee80211_local *local,
1305 struct ieee80211_sub_if_data *sdata, int *dbm)
1306{
1307 int ret;
1308
1309 if (!local->ops->get_txpower)
1310 return -EOPNOTSUPP;
1311
1312 ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
1313 trace_drv_get_txpower(local, sdata, *dbm, ret);
1314
1315 return ret;
1316}
1317
a7a6bdd0
AN
1318static inline int
1319drv_tdls_channel_switch(struct ieee80211_local *local,
1320 struct ieee80211_sub_if_data *sdata,
1321 struct ieee80211_sta *sta, u8 oper_class,
1322 struct cfg80211_chan_def *chandef,
1323 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
1324{
1325 int ret;
1326
1327 might_sleep();
1328 if (!check_sdata_in_driver(sdata))
1329 return -EIO;
1330
1331 if (!local->ops->tdls_channel_switch)
1332 return -EOPNOTSUPP;
1333
1334 trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
1335 ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
1336 oper_class, chandef, tmpl_skb,
1337 ch_sw_tm_ie);
1338 trace_drv_return_int(local, ret);
1339 return ret;
1340}
1341
1342static inline void
1343drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
1344 struct ieee80211_sub_if_data *sdata,
1345 struct ieee80211_sta *sta)
1346{
1347 might_sleep();
1348 if (!check_sdata_in_driver(sdata))
1349 return;
1350
1351 if (!local->ops->tdls_cancel_channel_switch)
1352 return;
1353
1354 trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
1355 local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
1356 trace_drv_return_void(local);
1357}
1358
8a4d32f3
AN
1359static inline void
1360drv_tdls_recv_channel_switch(struct ieee80211_local *local,
1361 struct ieee80211_sub_if_data *sdata,
1362 struct ieee80211_tdls_ch_sw_params *params)
1363{
1364 trace_drv_tdls_recv_channel_switch(local, sdata, params);
1365 if (local->ops->tdls_recv_channel_switch)
1366 local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
1367 params);
1368 trace_drv_return_void(local);
1369}
1370
ba8c3d6f
FF
1371static inline void drv_wake_tx_queue(struct ieee80211_local *local,
1372 struct txq_info *txq)
1373{
1374 struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
1375
1376 if (!check_sdata_in_driver(sdata))
1377 return;
1378
1379 trace_drv_wake_tx_queue(local, sdata, txq);
1380 local->ops->wake_tx_queue(&local->hw, &txq->txq);
1381}
1382
24487981 1383#endif /* __MAC80211_DRIVER_OPS */