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