Merge tag 'for-6.6-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
[linux-block.git] / net / mac80211 / driver-ops.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
f59374eb
SS
2/*
3* Portions of this file
4* Copyright(c) 2016 Intel Deutschland GmbH
c4fdb081 5* Copyright (C) 2018 - 2019, 2021 - 2023 Intel Corporation
f59374eb
SS
6*/
7
24487981
JB
8#ifndef __MAC80211_DRIVER_OPS
9#define __MAC80211_DRIVER_OPS
10
11#include <net/mac80211.h>
12#include "ieee80211_i.h"
011ad0e9 13#include "trace.h"
24487981 14
c8ad0106 15#define check_sdata_in_driver(sdata) ({ \
c4fdb081
JB
16 WARN_ONCE(!sdata->local->reconfig_failure && \
17 !(sdata->flags & IEEE80211_SDATA_IN_DRIVER), \
18 "%s: Failed check-sdata-in-driver check, flags: 0x%x\n", \
19 sdata->dev ? sdata->dev->name : sdata->name, sdata->flags); \
20 !!(sdata->flags & IEEE80211_SDATA_IN_DRIVER); \
c8ad0106 21})
7b7eab6f 22
bc192f89
FF
23static inline struct ieee80211_sub_if_data *
24get_bss_sdata(struct ieee80211_sub_if_data *sdata)
25{
26 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
27 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
28 u.ap);
29
30 return sdata;
31}
32
36323f81
TH
33static inline void drv_tx(struct ieee80211_local *local,
34 struct ieee80211_tx_control *control,
35 struct sk_buff *skb)
24487981 36{
36323f81 37 local->ops->tx(&local->hw, control, skb);
24487981
JB
38}
39
f59374eb
SS
40static inline void drv_sync_rx_queues(struct ieee80211_local *local,
41 struct sta_info *sta)
42{
43 if (local->ops->sync_rx_queues) {
44 trace_drv_sync_rx_queues(local, sta->sdata, &sta->sta);
45 local->ops->sync_rx_queues(&local->hw);
46 trace_drv_return_void(local);
47 }
48}
49
e352114f
BG
50static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata,
51 u32 sset, u8 *data)
52{
53 struct ieee80211_local *local = sdata->local;
54 if (local->ops->get_et_strings) {
55 trace_drv_get_et_strings(local, sset);
56 local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data);
57 trace_drv_return_void(local);
58 }
59}
60
61static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata,
62 struct ethtool_stats *stats,
63 u64 *data)
64{
65 struct ieee80211_local *local = sdata->local;
66 if (local->ops->get_et_stats) {
67 trace_drv_get_et_stats(local);
68 local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data);
69 trace_drv_return_void(local);
70 }
71}
72
73static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata,
74 int sset)
75{
76 struct ieee80211_local *local = sdata->local;
77 int rv = 0;
78 if (local->ops->get_et_sset_count) {
79 trace_drv_get_et_sset_count(local, sset);
80 rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif,
81 sset);
82 trace_drv_return_int(local, rv);
83 }
84 return rv;
85}
86
968a76ce
EP
87int drv_start(struct ieee80211_local *local);
88void drv_stop(struct ieee80211_local *local);
24487981 89
eecc4800
JB
90#ifdef CONFIG_PM
91static inline int drv_suspend(struct ieee80211_local *local,
92 struct cfg80211_wowlan *wowlan)
93{
94 int ret;
95
96 might_sleep();
97
98 trace_drv_suspend(local);
99 ret = local->ops->suspend(&local->hw, wowlan);
100 trace_drv_return_int(local, ret);
101 return ret;
102}
103
104static inline int drv_resume(struct ieee80211_local *local)
105{
106 int ret;
107
108 might_sleep();
109
110 trace_drv_resume(local);
111 ret = local->ops->resume(&local->hw);
112 trace_drv_return_int(local, ret);
113 return ret;
114}
6d52563f
JB
115
116static inline void drv_set_wakeup(struct ieee80211_local *local,
117 bool enabled)
118{
119 might_sleep();
120
121 if (!local->ops->set_wakeup)
122 return;
123
124 trace_drv_set_wakeup(local, enabled);
125 local->ops->set_wakeup(&local->hw, enabled);
126 trace_drv_return_void(local);
127}
eecc4800
JB
128#endif
129
9aae296a
DV
130int drv_add_interface(struct ieee80211_local *local,
131 struct ieee80211_sub_if_data *sdata);
7b7eab6f 132
9aae296a
DV
133int drv_change_interface(struct ieee80211_local *local,
134 struct ieee80211_sub_if_data *sdata,
135 enum nl80211_iftype type, bool p2p);
7b7eab6f 136
9aae296a
DV
137void drv_remove_interface(struct ieee80211_local *local,
138 struct ieee80211_sub_if_data *sdata);
24487981
JB
139
140static inline int drv_config(struct ieee80211_local *local, u32 changed)
141{
e1781ed3
KV
142 int ret;
143
144 might_sleep();
145
4efc76bd 146 trace_drv_config(local, changed);
e1781ed3 147 ret = local->ops->config(&local->hw, changed);
4efc76bd 148 trace_drv_return_int(local, ret);
0a2b8bb2 149 return ret;
24487981
JB
150}
151
7b7090b4
JB
152static inline void drv_vif_cfg_changed(struct ieee80211_local *local,
153 struct ieee80211_sub_if_data *sdata,
154 u64 changed)
155{
156 might_sleep();
157
158 if (!check_sdata_in_driver(sdata))
159 return;
160
161 trace_drv_vif_cfg_changed(local, sdata, changed);
162 if (local->ops->vif_cfg_changed)
163 local->ops->vif_cfg_changed(&local->hw, &sdata->vif, changed);
164 else if (local->ops->bss_info_changed)
165 local->ops->bss_info_changed(&local->hw, &sdata->vif,
166 &sdata->vif.bss_conf, changed);
167 trace_drv_return_void(local);
168}
169
efe9c2bf
JB
170void drv_link_info_changed(struct ieee80211_local *local,
171 struct ieee80211_sub_if_data *sdata,
172 struct ieee80211_bss_conf *info,
173 int link_id, u64 changed);
24487981 174
3ac64bee 175static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
22bedad3 176 struct netdev_hw_addr_list *mc_list)
3ac64bee
JB
177{
178 u64 ret = 0;
179
4efc76bd
JB
180 trace_drv_prepare_multicast(local, mc_list->count);
181
3ac64bee 182 if (local->ops->prepare_multicast)
22bedad3 183 ret = local->ops->prepare_multicast(&local->hw, mc_list);
3ac64bee 184
4efc76bd 185 trace_drv_return_u64(local, ret);
3ac64bee
JB
186
187 return ret;
188}
189
24487981
JB
190static inline void drv_configure_filter(struct ieee80211_local *local,
191 unsigned int changed_flags,
192 unsigned int *total_flags,
3ac64bee 193 u64 multicast)
24487981 194{
3ac64bee
JB
195 might_sleep();
196
0a2b8bb2 197 trace_drv_configure_filter(local, changed_flags, total_flags,
3ac64bee 198 multicast);
4efc76bd
JB
199 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
200 multicast);
201 trace_drv_return_void(local);
24487981
JB
202}
203
1b09b556
AO
204static inline void drv_config_iface_filter(struct ieee80211_local *local,
205 struct ieee80211_sub_if_data *sdata,
206 unsigned int filter_flags,
207 unsigned int changed_flags)
208{
209 might_sleep();
210
211 trace_drv_config_iface_filter(local, sdata, filter_flags,
212 changed_flags);
213 if (local->ops->config_iface_filter)
214 local->ops->config_iface_filter(&local->hw, &sdata->vif,
215 filter_flags,
216 changed_flags);
217 trace_drv_return_void(local);
218}
219
24487981
JB
220static inline int drv_set_tim(struct ieee80211_local *local,
221 struct ieee80211_sta *sta, bool set)
222{
0a2b8bb2 223 int ret = 0;
4efc76bd 224 trace_drv_set_tim(local, sta, set);
24487981 225 if (local->ops->set_tim)
0a2b8bb2 226 ret = local->ops->set_tim(&local->hw, sta, set);
4efc76bd 227 trace_drv_return_int(local, ret);
0a2b8bb2 228 return ret;
24487981
JB
229}
230
efe9c2bf
JB
231int drv_set_key(struct ieee80211_local *local,
232 enum set_key_cmd cmd,
233 struct ieee80211_sub_if_data *sdata,
234 struct ieee80211_sta *sta,
235 struct ieee80211_key_conf *key);
24487981
JB
236
237static inline void drv_update_tkip_key(struct ieee80211_local *local,
b3fbdcf4 238 struct ieee80211_sub_if_data *sdata,
24487981 239 struct ieee80211_key_conf *conf,
b3fbdcf4 240 struct sta_info *sta, u32 iv32,
24487981
JB
241 u16 *phase1key)
242{
b3fbdcf4
JB
243 struct ieee80211_sta *ista = NULL;
244
b3fbdcf4
JB
245 if (sta)
246 ista = &sta->sta;
247
077f4939 248 sdata = get_bss_sdata(sdata);
f6837ba8
JB
249 if (!check_sdata_in_driver(sdata))
250 return;
7b7eab6f 251
4efc76bd 252 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
24487981 253 if (local->ops->update_tkip_key)
b3fbdcf4
JB
254 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
255 ista, iv32, phase1key);
4efc76bd 256 trace_drv_return_void(local);
24487981
JB
257}
258
259static inline int drv_hw_scan(struct ieee80211_local *local,
a060bbfe 260 struct ieee80211_sub_if_data *sdata,
c56ef672 261 struct ieee80211_scan_request *req)
24487981 262{
e1781ed3
KV
263 int ret;
264
265 might_sleep();
266
f6837ba8
JB
267 if (!check_sdata_in_driver(sdata))
268 return -EIO;
7b7eab6f 269
79f460ca 270 trace_drv_hw_scan(local, sdata);
a060bbfe 271 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
4efc76bd 272 trace_drv_return_int(local, ret);
0a2b8bb2 273 return ret;
24487981
JB
274}
275
b856439b
EP
276static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
277 struct ieee80211_sub_if_data *sdata)
278{
279 might_sleep();
280
f6837ba8
JB
281 if (!check_sdata_in_driver(sdata))
282 return;
7b7eab6f 283
b856439b
EP
284 trace_drv_cancel_hw_scan(local, sdata);
285 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
286 trace_drv_return_void(local);
287}
288
79f460ca
LC
289static inline int
290drv_sched_scan_start(struct ieee80211_local *local,
291 struct ieee80211_sub_if_data *sdata,
292 struct cfg80211_sched_scan_request *req,
633e2713 293 struct ieee80211_scan_ies *ies)
79f460ca
LC
294{
295 int ret;
296
297 might_sleep();
298
f6837ba8
JB
299 if (!check_sdata_in_driver(sdata))
300 return -EIO;
7b7eab6f 301
79f460ca
LC
302 trace_drv_sched_scan_start(local, sdata);
303 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
304 req, ies);
305 trace_drv_return_int(local, ret);
306 return ret;
307}
308
37e3308c
JB
309static inline int drv_sched_scan_stop(struct ieee80211_local *local,
310 struct ieee80211_sub_if_data *sdata)
79f460ca 311{
37e3308c
JB
312 int ret;
313
79f460ca
LC
314 might_sleep();
315
f6837ba8
JB
316 if (!check_sdata_in_driver(sdata))
317 return -EIO;
7b7eab6f 318
79f460ca 319 trace_drv_sched_scan_stop(local, sdata);
37e3308c
JB
320 ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
321 trace_drv_return_int(local, ret);
322
323 return ret;
79f460ca
LC
324}
325
a344d677
JB
326static inline void drv_sw_scan_start(struct ieee80211_local *local,
327 struct ieee80211_sub_if_data *sdata,
328 const u8 *mac_addr)
24487981 329{
e1781ed3
KV
330 might_sleep();
331
a344d677 332 trace_drv_sw_scan_start(local, sdata, mac_addr);
24487981 333 if (local->ops->sw_scan_start)
a344d677 334 local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
4efc76bd 335 trace_drv_return_void(local);
24487981
JB
336}
337
a344d677
JB
338static inline void drv_sw_scan_complete(struct ieee80211_local *local,
339 struct ieee80211_sub_if_data *sdata)
24487981 340{
e1781ed3
KV
341 might_sleep();
342
a344d677 343 trace_drv_sw_scan_complete(local, sdata);
24487981 344 if (local->ops->sw_scan_complete)
a344d677 345 local->ops->sw_scan_complete(&local->hw, &sdata->vif);
4efc76bd 346 trace_drv_return_void(local);
24487981
JB
347}
348
349static inline int drv_get_stats(struct ieee80211_local *local,
350 struct ieee80211_low_level_stats *stats)
351{
0a2b8bb2
JB
352 int ret = -EOPNOTSUPP;
353
e1781ed3
KV
354 might_sleep();
355
0a2b8bb2
JB
356 if (local->ops->get_stats)
357 ret = local->ops->get_stats(&local->hw, stats);
358 trace_drv_get_stats(local, stats, ret);
359
360 return ret;
24487981
JB
361}
362
9352c19f
JB
363static inline void drv_get_key_seq(struct ieee80211_local *local,
364 struct ieee80211_key *key,
365 struct ieee80211_key_seq *seq)
24487981 366{
9352c19f
JB
367 if (local->ops->get_key_seq)
368 local->ops->get_key_seq(&local->hw, &key->conf, seq);
369 trace_drv_get_key_seq(local, &key->conf);
24487981
JB
370}
371
f23a4780
AN
372static inline int drv_set_frag_threshold(struct ieee80211_local *local,
373 u32 value)
374{
375 int ret = 0;
376
377 might_sleep();
378
379 trace_drv_set_frag_threshold(local, value);
380 if (local->ops->set_frag_threshold)
381 ret = local->ops->set_frag_threshold(&local->hw, value);
382 trace_drv_return_int(local, ret);
383 return ret;
384}
385
24487981
JB
386static inline int drv_set_rts_threshold(struct ieee80211_local *local,
387 u32 value)
388{
0a2b8bb2 389 int ret = 0;
e1781ed3
KV
390
391 might_sleep();
392
4efc76bd 393 trace_drv_set_rts_threshold(local, value);
24487981 394 if (local->ops->set_rts_threshold)
0a2b8bb2 395 ret = local->ops->set_rts_threshold(&local->hw, value);
4efc76bd 396 trace_drv_return_int(local, ret);
0a2b8bb2 397 return ret;
24487981
JB
398}
399
310bc676 400static inline int drv_set_coverage_class(struct ieee80211_local *local,
a4bcaf55 401 s16 value)
310bc676
LT
402{
403 int ret = 0;
404 might_sleep();
405
4efc76bd 406 trace_drv_set_coverage_class(local, value);
310bc676
LT
407 if (local->ops->set_coverage_class)
408 local->ops->set_coverage_class(&local->hw, value);
409 else
410 ret = -EOPNOTSUPP;
411
4efc76bd 412 trace_drv_return_int(local, ret);
310bc676
LT
413 return ret;
414}
415
24487981 416static inline void drv_sta_notify(struct ieee80211_local *local,
12375ef9 417 struct ieee80211_sub_if_data *sdata,
24487981
JB
418 enum sta_notify_cmd cmd,
419 struct ieee80211_sta *sta)
420{
bc192f89 421 sdata = get_bss_sdata(sdata);
f6837ba8
JB
422 if (!check_sdata_in_driver(sdata))
423 return;
7b7eab6f 424
4efc76bd 425 trace_drv_sta_notify(local, sdata, cmd, sta);
24487981 426 if (local->ops->sta_notify)
12375ef9 427 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
4efc76bd 428 trace_drv_return_void(local);
24487981
JB
429}
430
34e89507
JB
431static inline int drv_sta_add(struct ieee80211_local *local,
432 struct ieee80211_sub_if_data *sdata,
433 struct ieee80211_sta *sta)
434{
435 int ret = 0;
436
437 might_sleep();
438
bc192f89 439 sdata = get_bss_sdata(sdata);
f6837ba8
JB
440 if (!check_sdata_in_driver(sdata))
441 return -EIO;
7b7eab6f 442
4efc76bd 443 trace_drv_sta_add(local, sdata, sta);
34e89507
JB
444 if (local->ops->sta_add)
445 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
34e89507 446
4efc76bd 447 trace_drv_return_int(local, ret);
34e89507
JB
448
449 return ret;
450}
451
452static inline void drv_sta_remove(struct ieee80211_local *local,
453 struct ieee80211_sub_if_data *sdata,
454 struct ieee80211_sta *sta)
455{
456 might_sleep();
457
bc192f89 458 sdata = get_bss_sdata(sdata);
f6837ba8
JB
459 if (!check_sdata_in_driver(sdata))
460 return;
7b7eab6f 461
4efc76bd 462 trace_drv_sta_remove(local, sdata, sta);
34e89507
JB
463 if (local->ops->sta_remove)
464 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
34e89507 465
4efc76bd 466 trace_drv_return_void(local);
34e89507
JB
467}
468
77d2ece6 469#ifdef CONFIG_MAC80211_DEBUGFS
170cd6a6
BB
470static inline void drv_link_add_debugfs(struct ieee80211_local *local,
471 struct ieee80211_sub_if_data *sdata,
472 struct ieee80211_bss_conf *link_conf,
473 struct dentry *dir)
474{
475 might_sleep();
476
477 sdata = get_bss_sdata(sdata);
478 if (!check_sdata_in_driver(sdata))
479 return;
480
481 if (local->ops->link_add_debugfs)
482 local->ops->link_add_debugfs(&local->hw, &sdata->vif,
483 link_conf, dir);
484}
485
77d2ece6
SM
486static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
487 struct ieee80211_sub_if_data *sdata,
488 struct ieee80211_sta *sta,
489 struct dentry *dir)
490{
491 might_sleep();
492
493 sdata = get_bss_sdata(sdata);
f6837ba8
JB
494 if (!check_sdata_in_driver(sdata))
495 return;
77d2ece6
SM
496
497 if (local->ops->sta_add_debugfs)
498 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
499 sta, dir);
500}
d2caad52
BB
501
502static inline void drv_link_sta_add_debugfs(struct ieee80211_local *local,
503 struct ieee80211_sub_if_data *sdata,
504 struct ieee80211_link_sta *link_sta,
505 struct dentry *dir)
506{
507 might_sleep();
508
509 sdata = get_bss_sdata(sdata);
510 if (!check_sdata_in_driver(sdata))
511 return;
512
513 if (local->ops->link_sta_add_debugfs)
514 local->ops->link_sta_add_debugfs(&local->hw, &sdata->vif,
515 link_sta, dir);
516}
77d2ece6
SM
517#endif
518
6a9d1b91
JB
519static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
520 struct ieee80211_sub_if_data *sdata,
521 struct sta_info *sta)
522{
523 might_sleep();
524
525 sdata = get_bss_sdata(sdata);
f6837ba8
JB
526 if (!check_sdata_in_driver(sdata))
527 return;
6a9d1b91
JB
528
529 trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
530 if (local->ops->sta_pre_rcu_remove)
531 local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
532 &sta->sta);
533 trace_drv_return_void(local);
534}
535
727da60b 536__must_check
f09603a2
JB
537int drv_sta_state(struct ieee80211_local *local,
538 struct ieee80211_sub_if_data *sdata,
539 struct sta_info *sta,
540 enum ieee80211_sta_state old_state,
727da60b 541 enum ieee80211_sta_state new_state);
f09603a2 542
ba905bf4
ARN
543__must_check
544int drv_sta_set_txpwr(struct ieee80211_local *local,
545 struct ieee80211_sub_if_data *sdata,
546 struct sta_info *sta);
547
4fbd572c
DV
548void drv_sta_rc_update(struct ieee80211_local *local,
549 struct ieee80211_sub_if_data *sdata,
550 struct ieee80211_sta *sta, u32 changed);
8f727ef3 551
f815e2b3
JB
552static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
553 struct ieee80211_sub_if_data *sdata,
554 struct ieee80211_sta *sta)
555{
556 sdata = get_bss_sdata(sdata);
557 if (!check_sdata_in_driver(sdata))
558 return;
559
560 trace_drv_sta_rate_tbl_update(local, sdata, sta);
561 if (local->ops->sta_rate_tbl_update)
562 local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
563
564 trace_drv_return_void(local);
565}
566
2b9a7e1b
JB
567static inline void drv_sta_statistics(struct ieee80211_local *local,
568 struct ieee80211_sub_if_data *sdata,
569 struct ieee80211_sta *sta,
570 struct station_info *sinfo)
571{
572 sdata = get_bss_sdata(sdata);
573 if (!check_sdata_in_driver(sdata))
574 return;
575
576 trace_drv_sta_statistics(local, sdata, sta);
577 if (local->ops->sta_statistics)
578 local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
579 trace_drv_return_void(local);
580}
581
b23dcd4a 582int drv_conf_tx(struct ieee80211_local *local,
b3e2130b 583 struct ieee80211_link_data *link, u16 ac,
b23dcd4a 584 const struct ieee80211_tx_queue_params *params);
24487981 585
416eb9fc
DV
586u64 drv_get_tsf(struct ieee80211_local *local,
587 struct ieee80211_sub_if_data *sdata);
588void drv_set_tsf(struct ieee80211_local *local,
589 struct ieee80211_sub_if_data *sdata,
590 u64 tsf);
354d381b
PT
591void drv_offset_tsf(struct ieee80211_local *local,
592 struct ieee80211_sub_if_data *sdata,
593 s64 offset);
416eb9fc
DV
594void drv_reset_tsf(struct ieee80211_local *local,
595 struct ieee80211_sub_if_data *sdata);
24487981
JB
596
597static inline int drv_tx_last_beacon(struct ieee80211_local *local)
598{
02582e9b 599 int ret = 0; /* default unsupported op for less congestion */
e1781ed3
KV
600
601 might_sleep();
602
4efc76bd 603 trace_drv_tx_last_beacon(local);
24487981 604 if (local->ops->tx_last_beacon)
0a2b8bb2 605 ret = local->ops->tx_last_beacon(&local->hw);
4efc76bd 606 trace_drv_return_int(local, ret);
0a2b8bb2 607 return ret;
24487981
JB
608}
609
6db96838
DV
610int drv_ampdu_action(struct ieee80211_local *local,
611 struct ieee80211_sub_if_data *sdata,
50ea05ef 612 struct ieee80211_ampdu_params *params);
1f87f7d3 613
1289723e
HS
614static inline int drv_get_survey(struct ieee80211_local *local, int idx,
615 struct survey_info *survey)
616{
617 int ret = -EOPNOTSUPP;
c466d4ef
JL
618
619 trace_drv_get_survey(local, idx, survey);
620
35dd0509 621 if (local->ops->get_survey)
1289723e 622 ret = local->ops->get_survey(&local->hw, idx, survey);
c466d4ef
JL
623
624 trace_drv_return_int(local, ret);
625
1289723e
HS
626 return ret;
627}
1f87f7d3
JB
628
629static inline void drv_rfkill_poll(struct ieee80211_local *local)
630{
e1781ed3
KV
631 might_sleep();
632
1f87f7d3
JB
633 if (local->ops->rfkill_poll)
634 local->ops->rfkill_poll(&local->hw);
635}
a80f7c0b 636
39ecc01d 637static inline void drv_flush(struct ieee80211_local *local,
77be2c54 638 struct ieee80211_sub_if_data *sdata,
39ecc01d 639 u32 queues, bool drop)
a80f7c0b 640{
77be2c54
EG
641 struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
642
e1781ed3
KV
643 might_sleep();
644
f6837ba8
JB
645 if (sdata && !check_sdata_in_driver(sdata))
646 return;
77be2c54 647
39ecc01d 648 trace_drv_flush(local, queues, drop);
a80f7c0b 649 if (local->ops->flush)
77be2c54 650 local->ops->flush(&local->hw, vif, queues, drop);
4efc76bd 651 trace_drv_return_void(local);
a80f7c0b 652}
5ce6e438 653
d00800a2
JB
654static inline void drv_flush_sta(struct ieee80211_local *local,
655 struct ieee80211_sub_if_data *sdata,
656 struct sta_info *sta)
657{
658 might_sleep();
659
660 if (sdata && !check_sdata_in_driver(sdata))
661 return;
662
663 trace_drv_flush_sta(local, sdata, &sta->sta);
664 if (local->ops->flush_sta)
665 local->ops->flush_sta(&local->hw, &sdata->vif, &sta->sta);
666 trace_drv_return_void(local);
667}
668
5ce6e438 669static inline void drv_channel_switch(struct ieee80211_local *local,
0f791eb4
LC
670 struct ieee80211_sub_if_data *sdata,
671 struct ieee80211_channel_switch *ch_switch)
5ce6e438
JB
672{
673 might_sleep();
674
0f791eb4
LC
675 trace_drv_channel_switch(local, sdata, ch_switch);
676 local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
4efc76bd 677 trace_drv_return_void(local);
5ce6e438
JB
678}
679
15d96753
BR
680
681static inline int drv_set_antenna(struct ieee80211_local *local,
682 u32 tx_ant, u32 rx_ant)
683{
684 int ret = -EOPNOTSUPP;
685 might_sleep();
686 if (local->ops->set_antenna)
687 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
688 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
689 return ret;
690}
691
692static inline int drv_get_antenna(struct ieee80211_local *local,
693 u32 *tx_ant, u32 *rx_ant)
694{
695 int ret = -EOPNOTSUPP;
696 might_sleep();
697 if (local->ops->get_antenna)
698 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
699 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
700 return ret;
701}
702
21f83589 703static inline int drv_remain_on_channel(struct ieee80211_local *local,
49884568 704 struct ieee80211_sub_if_data *sdata,
21f83589 705 struct ieee80211_channel *chan,
d339d5ca
IP
706 unsigned int duration,
707 enum ieee80211_roc_type type)
21f83589
JB
708{
709 int ret;
710
711 might_sleep();
712
d339d5ca 713 trace_drv_remain_on_channel(local, sdata, chan, duration, type);
49884568 714 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
d339d5ca 715 chan, duration, type);
21f83589
JB
716 trace_drv_return_int(local, ret);
717
718 return ret;
719}
720
5db4c4b9
EG
721static inline int
722drv_cancel_remain_on_channel(struct ieee80211_local *local,
723 struct ieee80211_sub_if_data *sdata)
21f83589
JB
724{
725 int ret;
726
727 might_sleep();
728
5db4c4b9
EG
729 trace_drv_cancel_remain_on_channel(local, sdata);
730 ret = local->ops->cancel_remain_on_channel(&local->hw, &sdata->vif);
21f83589 731 trace_drv_return_int(local, ret);
5f16a436
JB
732
733 return ret;
734}
735
38c09159
JL
736static inline int drv_set_ringparam(struct ieee80211_local *local,
737 u32 tx, u32 rx)
738{
739 int ret = -ENOTSUPP;
740
741 might_sleep();
742
743 trace_drv_set_ringparam(local, tx, rx);
744 if (local->ops->set_ringparam)
745 ret = local->ops->set_ringparam(&local->hw, tx, rx);
746 trace_drv_return_int(local, ret);
747
748 return ret;
749}
750
751static inline void drv_get_ringparam(struct ieee80211_local *local,
752 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
753{
754 might_sleep();
755
756 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
757 if (local->ops->get_ringparam)
758 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
759 trace_drv_return_void(local);
760}
761
e8306f98
VN
762static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
763{
764 bool ret = false;
765
766 might_sleep();
767
768 trace_drv_tx_frames_pending(local);
769 if (local->ops->tx_frames_pending)
770 ret = local->ops->tx_frames_pending(&local->hw);
771 trace_drv_return_bool(local, ret);
772
773 return ret;
774}
bdbfd6b5
SM
775
776static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
777 struct ieee80211_sub_if_data *sdata,
778 const struct cfg80211_bitrate_mask *mask)
779{
780 int ret = -EOPNOTSUPP;
781
782 might_sleep();
783
f6837ba8
JB
784 if (!check_sdata_in_driver(sdata))
785 return -EIO;
7b7eab6f 786
bdbfd6b5
SM
787 trace_drv_set_bitrate_mask(local, sdata, mask);
788 if (local->ops->set_bitrate_mask)
789 ret = local->ops->set_bitrate_mask(&local->hw,
790 &sdata->vif, mask);
791 trace_drv_return_int(local, ret);
792
793 return ret;
794}
795
c68f4b89
JB
796static inline void drv_set_rekey_data(struct ieee80211_local *local,
797 struct ieee80211_sub_if_data *sdata,
798 struct cfg80211_gtk_rekey_data *data)
799{
f6837ba8
JB
800 if (!check_sdata_in_driver(sdata))
801 return;
7b7eab6f 802
c68f4b89
JB
803 trace_drv_set_rekey_data(local, sdata, data);
804 if (local->ops->set_rekey_data)
805 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
806 trace_drv_return_void(local);
807}
808
a8182929
EG
809static inline void drv_event_callback(struct ieee80211_local *local,
810 struct ieee80211_sub_if_data *sdata,
811 const struct ieee80211_event *event)
615f7b9b 812{
a8182929
EG
813 trace_drv_event_callback(local, sdata, event);
814 if (local->ops->event_callback)
815 local->ops->event_callback(&local->hw, &sdata->vif, event);
615f7b9b
MV
816 trace_drv_return_void(local);
817}
4049e09a
JB
818
819static inline void
820drv_release_buffered_frames(struct ieee80211_local *local,
821 struct sta_info *sta, u16 tids, int num_frames,
822 enum ieee80211_frame_release_type reason,
823 bool more_data)
824{
825 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
826 reason, more_data);
827 if (local->ops->release_buffered_frames)
828 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
829 num_frames, reason,
830 more_data);
831 trace_drv_return_void(local);
832}
40b96408
JB
833
834static inline void
835drv_allow_buffered_frames(struct ieee80211_local *local,
836 struct sta_info *sta, u16 tids, int num_frames,
837 enum ieee80211_frame_release_type reason,
838 bool more_data)
839{
840 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
841 reason, more_data);
842 if (local->ops->allow_buffered_frames)
843 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
844 tids, num_frames, reason,
845 more_data);
846 trace_drv_return_void(local);
847}
66572cfc 848
a1845fc7 849static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
d4e36e55 850 struct ieee80211_sub_if_data *sdata,
15fae341 851 struct ieee80211_prep_tx_info *info)
a1845fc7
JB
852{
853 might_sleep();
854
f6837ba8
JB
855 if (!check_sdata_in_driver(sdata))
856 return;
a1845fc7
JB
857 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
858
15fae341
JB
859 trace_drv_mgd_prepare_tx(local, sdata, info->duration,
860 info->subtype, info->success);
a1845fc7 861 if (local->ops->mgd_prepare_tx)
15fae341
JB
862 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif, info);
863 trace_drv_return_void(local);
864}
865
866static inline void drv_mgd_complete_tx(struct ieee80211_local *local,
867 struct ieee80211_sub_if_data *sdata,
868 struct ieee80211_prep_tx_info *info)
869{
870 might_sleep();
871
872 if (!check_sdata_in_driver(sdata))
873 return;
874 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
875
876 trace_drv_mgd_complete_tx(local, sdata, info->duration,
877 info->subtype, info->success);
878 if (local->ops->mgd_complete_tx)
879 local->ops->mgd_complete_tx(&local->hw, &sdata->vif, info);
a1845fc7
JB
880 trace_drv_return_void(local);
881}
c3645eac 882
ee10f2c7
AN
883static inline void
884drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
885 struct ieee80211_sub_if_data *sdata)
886{
887 might_sleep();
888
889 if (!check_sdata_in_driver(sdata))
890 return;
891 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
892
893 trace_drv_mgd_protect_tdls_discover(local, sdata);
894 if (local->ops->mgd_protect_tdls_discover)
895 local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
896 trace_drv_return_void(local);
897}
898
c3645eac
MK
899static inline int drv_add_chanctx(struct ieee80211_local *local,
900 struct ieee80211_chanctx *ctx)
901{
902 int ret = -EOPNOTSUPP;
903
dcae9e02
C
904 might_sleep();
905
c3645eac
MK
906 trace_drv_add_chanctx(local, ctx);
907 if (local->ops->add_chanctx)
908 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
909 trace_drv_return_int(local, ret);
8a61af65
JB
910 if (!ret)
911 ctx->driver_present = true;
c3645eac
MK
912
913 return ret;
914}
915
916static inline void drv_remove_chanctx(struct ieee80211_local *local,
917 struct ieee80211_chanctx *ctx)
918{
dcae9e02
C
919 might_sleep();
920
f6837ba8
JB
921 if (WARN_ON(!ctx->driver_present))
922 return;
923
c3645eac
MK
924 trace_drv_remove_chanctx(local, ctx);
925 if (local->ops->remove_chanctx)
926 local->ops->remove_chanctx(&local->hw, &ctx->conf);
927 trace_drv_return_void(local);
8a61af65 928 ctx->driver_present = false;
c3645eac
MK
929}
930
931static inline void drv_change_chanctx(struct ieee80211_local *local,
932 struct ieee80211_chanctx *ctx,
933 u32 changed)
934{
dcae9e02
C
935 might_sleep();
936
c3645eac 937 trace_drv_change_chanctx(local, ctx, changed);
8a61af65
JB
938 if (local->ops->change_chanctx) {
939 WARN_ON_ONCE(!ctx->driver_present);
c3645eac 940 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
8a61af65 941 }
c3645eac
MK
942 trace_drv_return_void(local);
943}
944
727eff4d
GG
945static inline void drv_verify_link_exists(struct ieee80211_sub_if_data *sdata,
946 struct ieee80211_bss_conf *link_conf)
947{
948 /* deflink always exists, so need to check only for other links */
949 if (sdata->deflink.conf != link_conf)
950 sdata_assert_lock(sdata);
951}
952
efe9c2bf
JB
953int drv_assign_vif_chanctx(struct ieee80211_local *local,
954 struct ieee80211_sub_if_data *sdata,
955 struct ieee80211_bss_conf *link_conf,
956 struct ieee80211_chanctx *ctx);
957void drv_unassign_vif_chanctx(struct ieee80211_local *local,
958 struct ieee80211_sub_if_data *sdata,
959 struct ieee80211_bss_conf *link_conf,
960 struct ieee80211_chanctx *ctx);
42677ed3
DV
961int drv_switch_vif_chanctx(struct ieee80211_local *local,
962 struct ieee80211_vif_chanctx_switch *vifs,
963 int n_vifs, enum ieee80211_chanctx_switch_mode mode);
1a5f0c13 964
1041638f 965static inline int drv_start_ap(struct ieee80211_local *local,
ae7ba17b 966 struct ieee80211_sub_if_data *sdata,
b327c84c 967 struct ieee80211_bss_conf *link_conf)
1041638f
JB
968{
969 int ret = 0;
970
b327c84c 971 /* make sure link_conf is protected */
727eff4d 972 drv_verify_link_exists(sdata, link_conf);
b327c84c 973
dcae9e02
C
974 might_sleep();
975
f6837ba8
JB
976 if (!check_sdata_in_driver(sdata))
977 return -EIO;
1041638f 978
b327c84c 979 trace_drv_start_ap(local, sdata, link_conf);
1041638f 980 if (local->ops->start_ap)
b327c84c 981 ret = local->ops->start_ap(&local->hw, &sdata->vif, link_conf);
1041638f
JB
982 trace_drv_return_int(local, ret);
983 return ret;
984}
985
986static inline void drv_stop_ap(struct ieee80211_local *local,
ae7ba17b 987 struct ieee80211_sub_if_data *sdata,
b327c84c 988 struct ieee80211_bss_conf *link_conf)
1041638f 989{
b327c84c 990 /* make sure link_conf is protected */
727eff4d 991 drv_verify_link_exists(sdata, link_conf);
b327c84c 992
f6837ba8
JB
993 if (!check_sdata_in_driver(sdata))
994 return;
1041638f 995
b327c84c 996 trace_drv_stop_ap(local, sdata, link_conf);
1041638f 997 if (local->ops->stop_ap)
b327c84c 998 local->ops->stop_ap(&local->hw, &sdata->vif, link_conf);
1041638f
JB
999 trace_drv_return_void(local);
1000}
1001
cf2c92d8
EP
1002static inline void
1003drv_reconfig_complete(struct ieee80211_local *local,
1004 enum ieee80211_reconfig_type reconfig_type)
9214ad7f
JB
1005{
1006 might_sleep();
1007
cf2c92d8
EP
1008 trace_drv_reconfig_complete(local, reconfig_type);
1009 if (local->ops->reconfig_complete)
1010 local->ops->reconfig_complete(&local->hw, reconfig_type);
9214ad7f
JB
1011 trace_drv_return_void(local);
1012}
1013
de5fad81
YD
1014static inline void
1015drv_set_default_unicast_key(struct ieee80211_local *local,
1016 struct ieee80211_sub_if_data *sdata,
1017 int key_idx)
1018{
f6837ba8
JB
1019 if (!check_sdata_in_driver(sdata))
1020 return;
de5fad81
YD
1021
1022 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1023
1024 trace_drv_set_default_unicast_key(local, sdata, key_idx);
1025 if (local->ops->set_default_unicast_key)
1026 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1027 key_idx);
1028 trace_drv_return_void(local);
1029}
1030
a65240c1
JB
1031#if IS_ENABLED(CONFIG_IPV6)
1032static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1033 struct ieee80211_sub_if_data *sdata,
1034 struct inet6_dev *idev)
1035{
1036 trace_drv_ipv6_addr_change(local, sdata);
1037 if (local->ops->ipv6_addr_change)
1038 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1039 trace_drv_return_void(local);
1040}
1041#endif
1042
73da7d5b
SW
1043static inline void
1044drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1045 struct cfg80211_chan_def *chandef)
1046{
1047 struct ieee80211_local *local = sdata->local;
1048
1049 if (local->ops->channel_switch_beacon) {
1050 trace_drv_channel_switch_beacon(local, sdata, chandef);
1051 local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1052 chandef);
1053 }
1054}
1055
6d027bcc
LC
1056static inline int
1057drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
1058 struct ieee80211_channel_switch *ch_switch)
1059{
1060 struct ieee80211_local *local = sdata->local;
1061 int ret = 0;
1062
1063 if (!check_sdata_in_driver(sdata))
1064 return -EIO;
1065
1066 trace_drv_pre_channel_switch(local, sdata, ch_switch);
1067 if (local->ops->pre_channel_switch)
1068 ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
1069 ch_switch);
1070 trace_drv_return_int(local, ret);
1071 return ret;
1072}
1073
f1d65583
LC
1074static inline int
1075drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1076{
1077 struct ieee80211_local *local = sdata->local;
1078 int ret = 0;
1079
1080 if (!check_sdata_in_driver(sdata))
1081 return -EIO;
1082
1083 trace_drv_post_channel_switch(local, sdata);
1084 if (local->ops->post_channel_switch)
1085 ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1086 trace_drv_return_int(local, ret);
1087 return ret;
1088}
1089
b9cc81d8
SS
1090static inline void
1091drv_abort_channel_switch(struct ieee80211_sub_if_data *sdata)
1092{
1093 struct ieee80211_local *local = sdata->local;
1094
1095 if (!check_sdata_in_driver(sdata))
1096 return;
1097
1098 trace_drv_abort_channel_switch(local, sdata);
1099
1100 if (local->ops->abort_channel_switch)
1101 local->ops->abort_channel_switch(&local->hw, &sdata->vif);
1102}
1103
fafd2bce
SS
1104static inline void
1105drv_channel_switch_rx_beacon(struct ieee80211_sub_if_data *sdata,
1106 struct ieee80211_channel_switch *ch_switch)
1107{
1108 struct ieee80211_local *local = sdata->local;
1109
1110 if (!check_sdata_in_driver(sdata))
1111 return;
1112
1113 trace_drv_channel_switch_rx_beacon(local, sdata, ch_switch);
1114 if (local->ops->channel_switch_rx_beacon)
1115 local->ops->channel_switch_rx_beacon(&local->hw, &sdata->vif,
1116 ch_switch);
1117}
1118
55fff501
JB
1119static inline int drv_join_ibss(struct ieee80211_local *local,
1120 struct ieee80211_sub_if_data *sdata)
1121{
1122 int ret = 0;
1123
1124 might_sleep();
f6837ba8
JB
1125 if (!check_sdata_in_driver(sdata))
1126 return -EIO;
55fff501
JB
1127
1128 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1129 if (local->ops->join_ibss)
1130 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1131 trace_drv_return_int(local, ret);
1132 return ret;
1133}
1134
1135static inline void drv_leave_ibss(struct ieee80211_local *local,
1136 struct ieee80211_sub_if_data *sdata)
1137{
1138 might_sleep();
f6837ba8
JB
1139 if (!check_sdata_in_driver(sdata))
1140 return;
55fff501
JB
1141
1142 trace_drv_leave_ibss(local, sdata);
1143 if (local->ops->leave_ibss)
1144 local->ops->leave_ibss(&local->hw, &sdata->vif);
1145 trace_drv_return_void(local);
1146}
1147
cca674d4 1148static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
4fdbc67a 1149 struct sta_info *sta)
cca674d4
AQ
1150{
1151 u32 ret = 0;
1152
4fdbc67a
MA
1153 trace_drv_get_expected_throughput(&sta->sta);
1154 if (local->ops->get_expected_throughput && sta->uploaded)
1155 ret = local->ops->get_expected_throughput(&local->hw, &sta->sta);
cca674d4
AQ
1156 trace_drv_return_u32(local, ret);
1157
1158 return ret;
1159}
1160
5b3dc42b
FF
1161static inline int drv_get_txpower(struct ieee80211_local *local,
1162 struct ieee80211_sub_if_data *sdata, int *dbm)
1163{
1164 int ret;
1165
1166 if (!local->ops->get_txpower)
1167 return -EOPNOTSUPP;
1168
1169 ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
1170 trace_drv_get_txpower(local, sdata, *dbm, ret);
1171
1172 return ret;
1173}
1174
a7a6bdd0
AN
1175static inline int
1176drv_tdls_channel_switch(struct ieee80211_local *local,
1177 struct ieee80211_sub_if_data *sdata,
1178 struct ieee80211_sta *sta, u8 oper_class,
1179 struct cfg80211_chan_def *chandef,
1180 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
1181{
1182 int ret;
1183
1184 might_sleep();
1185 if (!check_sdata_in_driver(sdata))
1186 return -EIO;
1187
1188 if (!local->ops->tdls_channel_switch)
1189 return -EOPNOTSUPP;
1190
1191 trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
1192 ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
1193 oper_class, chandef, tmpl_skb,
1194 ch_sw_tm_ie);
1195 trace_drv_return_int(local, ret);
1196 return ret;
1197}
1198
1199static inline void
1200drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
1201 struct ieee80211_sub_if_data *sdata,
1202 struct ieee80211_sta *sta)
1203{
1204 might_sleep();
1205 if (!check_sdata_in_driver(sdata))
1206 return;
1207
1208 if (!local->ops->tdls_cancel_channel_switch)
1209 return;
1210
1211 trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
1212 local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
1213 trace_drv_return_void(local);
1214}
1215
8a4d32f3
AN
1216static inline void
1217drv_tdls_recv_channel_switch(struct ieee80211_local *local,
1218 struct ieee80211_sub_if_data *sdata,
1219 struct ieee80211_tdls_ch_sw_params *params)
1220{
1221 trace_drv_tdls_recv_channel_switch(local, sdata, params);
1222 if (local->ops->tdls_recv_channel_switch)
1223 local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
1224 params);
1225 trace_drv_return_void(local);
1226}
1227
e7881bd5
JB
1228static inline void drv_wake_tx_queue(struct ieee80211_local *local,
1229 struct txq_info *txq)
ba8c3d6f 1230{
e7881bd5
JB
1231 struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
1232
db7205af
JB
1233 /* In reconfig don't transmit now, but mark for waking later */
1234 if (local->in_reconfig) {
4444bc21 1235 set_bit(IEEE80211_TXQ_DIRTY, &txq->flags);
4856bfd2 1236 return;
db7205af 1237 }
4856bfd2 1238
e7881bd5
JB
1239 if (!check_sdata_in_driver(sdata))
1240 return;
1241
1242 trace_drv_wake_tx_queue(local, sdata, txq);
1243 local->ops->wake_tx_queue(&local->hw, &txq->txq);
ba8c3d6f
FF
1244}
1245
18667600
THJ
1246static inline void schedule_and_wake_txq(struct ieee80211_local *local,
1247 struct txq_info *txqi)
1248{
390298e8 1249 ieee80211_schedule_txq(&local->hw, &txqi->txq);
18667600
THJ
1250 drv_wake_tx_queue(local, txqi);
1251}
1252
9739fe29
SS
1253static inline int drv_can_aggregate_in_amsdu(struct ieee80211_local *local,
1254 struct sk_buff *head,
1255 struct sk_buff *skb)
1256{
1257 if (!local->ops->can_aggregate_in_amsdu)
1258 return true;
1259
1260 return local->ops->can_aggregate_in_amsdu(&local->hw, head, skb);
1261}
1262
bc847970
PKC
1263static inline int
1264drv_get_ftm_responder_stats(struct ieee80211_local *local,
1265 struct ieee80211_sub_if_data *sdata,
1266 struct cfg80211_ftm_responder_stats *ftm_stats)
1267{
1268 u32 ret = -EOPNOTSUPP;
1269
1270 if (local->ops->get_ftm_responder_stats)
1271 ret = local->ops->get_ftm_responder_stats(&local->hw,
1272 &sdata->vif,
1273 ftm_stats);
1274 trace_drv_get_ftm_responder_stats(local, sdata, ftm_stats);
1275
1276 return ret;
1277}
1278
cee7013b
JB
1279static inline int drv_start_pmsr(struct ieee80211_local *local,
1280 struct ieee80211_sub_if_data *sdata,
1281 struct cfg80211_pmsr_request *request)
1282{
1283 int ret = -EOPNOTSUPP;
1284
1285 might_sleep();
1286 if (!check_sdata_in_driver(sdata))
1287 return -EIO;
1288
1289 trace_drv_start_pmsr(local, sdata);
1290
1291 if (local->ops->start_pmsr)
1292 ret = local->ops->start_pmsr(&local->hw, &sdata->vif, request);
1293 trace_drv_return_int(local, ret);
1294
1295 return ret;
1296}
1297
1298static inline void drv_abort_pmsr(struct ieee80211_local *local,
1299 struct ieee80211_sub_if_data *sdata,
1300 struct cfg80211_pmsr_request *request)
1301{
1302 trace_drv_abort_pmsr(local, sdata);
1303
1304 might_sleep();
1305 if (!check_sdata_in_driver(sdata))
1306 return;
1307
1308 if (local->ops->abort_pmsr)
1309 local->ops->abort_pmsr(&local->hw, &sdata->vif, request);
1310 trace_drv_return_void(local);
1311}
1312
708d50ed
AB
1313static inline int drv_start_nan(struct ieee80211_local *local,
1314 struct ieee80211_sub_if_data *sdata,
1315 struct cfg80211_nan_conf *conf)
1316{
1317 int ret;
1318
1319 might_sleep();
1320 check_sdata_in_driver(sdata);
1321
1322 trace_drv_start_nan(local, sdata, conf);
1323 ret = local->ops->start_nan(&local->hw, &sdata->vif, conf);
1324 trace_drv_return_int(local, ret);
1325 return ret;
1326}
1327
1328static inline void drv_stop_nan(struct ieee80211_local *local,
1329 struct ieee80211_sub_if_data *sdata)
1330{
1331 might_sleep();
1332 check_sdata_in_driver(sdata);
1333
1334 trace_drv_stop_nan(local, sdata);
1335 local->ops->stop_nan(&local->hw, &sdata->vif);
1336 trace_drv_return_void(local);
1337}
1338
5953ff6d
AB
1339static inline int drv_nan_change_conf(struct ieee80211_local *local,
1340 struct ieee80211_sub_if_data *sdata,
1341 struct cfg80211_nan_conf *conf,
1342 u32 changes)
1343{
1344 int ret;
1345
1346 might_sleep();
1347 check_sdata_in_driver(sdata);
1348
1349 if (!local->ops->nan_change_conf)
1350 return -EOPNOTSUPP;
1351
1352 trace_drv_nan_change_conf(local, sdata, conf, changes);
1353 ret = local->ops->nan_change_conf(&local->hw, &sdata->vif, conf,
1354 changes);
1355 trace_drv_return_int(local, ret);
1356
1357 return ret;
1358}
1359
167e33f4
AB
1360static inline int drv_add_nan_func(struct ieee80211_local *local,
1361 struct ieee80211_sub_if_data *sdata,
1362 const struct cfg80211_nan_func *nan_func)
1363{
1364 int ret;
1365
1366 might_sleep();
1367 check_sdata_in_driver(sdata);
1368
1369 if (!local->ops->add_nan_func)
1370 return -EOPNOTSUPP;
1371
1372 trace_drv_add_nan_func(local, sdata, nan_func);
1373 ret = local->ops->add_nan_func(&local->hw, &sdata->vif, nan_func);
1374 trace_drv_return_int(local, ret);
1375
1376 return ret;
1377}
1378
1379static inline void drv_del_nan_func(struct ieee80211_local *local,
1380 struct ieee80211_sub_if_data *sdata,
1381 u8 instance_id)
1382{
1383 might_sleep();
1384 check_sdata_in_driver(sdata);
1385
1386 trace_drv_del_nan_func(local, sdata, instance_id);
1387 if (local->ops->del_nan_func)
1388 local->ops->del_nan_func(&local->hw, &sdata->vif, instance_id);
1389 trace_drv_return_void(local);
1390}
1391
370f51d5
T
1392static inline int drv_set_tid_config(struct ieee80211_local *local,
1393 struct ieee80211_sub_if_data *sdata,
1394 struct ieee80211_sta *sta,
1395 struct cfg80211_tid_config *tid_conf)
1396{
1397 int ret;
1398
1399 might_sleep();
1400 ret = local->ops->set_tid_config(&local->hw, &sdata->vif, sta,
1401 tid_conf);
1402 trace_drv_return_int(local, ret);
1403
1404 return ret;
1405}
1406
1407static inline int drv_reset_tid_config(struct ieee80211_local *local,
1408 struct ieee80211_sub_if_data *sdata,
60c2ef0e 1409 struct ieee80211_sta *sta, u8 tids)
370f51d5
T
1410{
1411 int ret;
1412
1413 might_sleep();
60c2ef0e 1414 ret = local->ops->reset_tid_config(&local->hw, &sdata->vif, sta, tids);
370f51d5
T
1415 trace_drv_return_int(local, ret);
1416
1417 return ret;
1418}
6aea26ce
FF
1419
1420static inline void drv_update_vif_offload(struct ieee80211_local *local,
1421 struct ieee80211_sub_if_data *sdata)
1422{
1423 might_sleep();
1424 check_sdata_in_driver(sdata);
1425
1426 if (!local->ops->update_vif_offload)
1427 return;
1428
1429 trace_drv_update_vif_offload(local, sdata);
1430 local->ops->update_vif_offload(&local->hw, &sdata->vif);
1431 trace_drv_return_void(local);
1432}
1433
1ff4e8f2
FF
1434static inline void drv_sta_set_4addr(struct ieee80211_local *local,
1435 struct ieee80211_sub_if_data *sdata,
1436 struct ieee80211_sta *sta, bool enabled)
1437{
1438 sdata = get_bss_sdata(sdata);
1439 if (!check_sdata_in_driver(sdata))
1440 return;
1441
1442 trace_drv_sta_set_4addr(local, sdata, sta, enabled);
1443 if (local->ops->sta_set_4addr)
1444 local->ops->sta_set_4addr(&local->hw, &sdata->vif, sta, enabled);
1445 trace_drv_return_void(local);
1446}
1447
80a915ec
FF
1448static inline void drv_sta_set_decap_offload(struct ieee80211_local *local,
1449 struct ieee80211_sub_if_data *sdata,
1450 struct ieee80211_sta *sta,
1451 bool enabled)
1452{
1453 sdata = get_bss_sdata(sdata);
1454 if (!check_sdata_in_driver(sdata))
1455 return;
1456
1457 trace_drv_sta_set_decap_offload(local, sdata, sta, enabled);
1458 if (local->ops->sta_set_decap_offload)
1459 local->ops->sta_set_decap_offload(&local->hw, &sdata->vif, sta,
1460 enabled);
1461 trace_drv_return_void(local);
1462}
1463
f5a4c24e
LB
1464static inline void drv_add_twt_setup(struct ieee80211_local *local,
1465 struct ieee80211_sub_if_data *sdata,
1466 struct ieee80211_sta *sta,
1467 struct ieee80211_twt_setup *twt)
1468{
1469 struct ieee80211_twt_params *twt_agrt;
1470
1471 might_sleep();
1472
1473 if (!check_sdata_in_driver(sdata))
1474 return;
1475
1476 twt_agrt = (void *)twt->params;
1477
1478 trace_drv_add_twt_setup(local, sta, twt, twt_agrt);
1479 local->ops->add_twt_setup(&local->hw, sta, twt);
1480 trace_drv_return_void(local);
1481}
1482
1483static inline void drv_twt_teardown_request(struct ieee80211_local *local,
1484 struct ieee80211_sub_if_data *sdata,
1485 struct ieee80211_sta *sta,
1486 u8 flowid)
1487{
1488 might_sleep();
1489 if (!check_sdata_in_driver(sdata))
1490 return;
1491
1492 if (!local->ops->twt_teardown_request)
1493 return;
1494
1495 trace_drv_twt_teardown_request(local, sta, flowid);
1496 local->ops->twt_teardown_request(&local->hw, sta, flowid);
1497 trace_drv_return_void(local);
1498}
1499
d787a3e3
FF
1500static inline int drv_net_fill_forward_path(struct ieee80211_local *local,
1501 struct ieee80211_sub_if_data *sdata,
1502 struct ieee80211_sta *sta,
1503 struct net_device_path_ctx *ctx,
1504 struct net_device_path *path)
1505{
1506 int ret = -EOPNOTSUPP;
1507
1508 sdata = get_bss_sdata(sdata);
1509 if (!check_sdata_in_driver(sdata))
1510 return -EIO;
1511
1512 trace_drv_net_fill_forward_path(local, sdata, sta);
1513 if (local->ops->net_fill_forward_path)
1514 ret = local->ops->net_fill_forward_path(&local->hw,
1515 &sdata->vif, sta,
1516 ctx, path);
1517 trace_drv_return_int(local, ret);
1518
1519 return ret;
1520}
1521
61587f15
FF
1522static inline int drv_net_setup_tc(struct ieee80211_local *local,
1523 struct ieee80211_sub_if_data *sdata,
1524 struct net_device *dev,
1525 enum tc_setup_type type, void *type_data)
1526{
1527 int ret = -EOPNOTSUPP;
1528
1529 sdata = get_bss_sdata(sdata);
1530 trace_drv_net_setup_tc(local, sdata, type);
1531 if (local->ops->net_setup_tc)
1532 ret = local->ops->net_setup_tc(&local->hw, &sdata->vif, dev,
1533 type, type_data);
1534 trace_drv_return_int(local, ret);
1535
1536 return ret;
1537}
1538
efe9c2bf
JB
1539int drv_change_vif_links(struct ieee80211_local *local,
1540 struct ieee80211_sub_if_data *sdata,
1541 u16 old_links, u16 new_links,
1542 struct ieee80211_bss_conf *old[IEEE80211_MLD_MAX_NUM_LINKS]);
1543int drv_change_sta_links(struct ieee80211_local *local,
1544 struct ieee80211_sub_if_data *sdata,
1545 struct ieee80211_sta *sta,
1546 u16 old_links, u16 new_links);
cb71f1d1 1547
24487981 1548#endif /* __MAC80211_DRIVER_OPS */