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