1 #ifndef __MAC80211_DRIVER_OPS
2 #define __MAC80211_DRIVER_OPS
4 #include <net/mac80211.h>
5 #include "ieee80211_i.h"
8 static inline bool check_sdata_in_driver(struct ieee80211_sub_if_data
*sdata
)
10 return !WARN(!(sdata
->flags
& IEEE80211_SDATA_IN_DRIVER
),
11 "%s: Failed check-sdata-in-driver check, flags: 0x%x\n",
12 sdata
->dev
? sdata
->dev
->name
: sdata
->name
, sdata
->flags
);
15 static inline struct ieee80211_sub_if_data
*
16 get_bss_sdata(struct ieee80211_sub_if_data
*sdata
)
18 if (sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
)
19 sdata
= container_of(sdata
->bss
, struct ieee80211_sub_if_data
,
25 static inline void drv_tx(struct ieee80211_local
*local
,
26 struct ieee80211_tx_control
*control
,
29 local
->ops
->tx(&local
->hw
, control
, skb
);
32 static inline void drv_get_et_strings(struct ieee80211_sub_if_data
*sdata
,
35 struct ieee80211_local
*local
= sdata
->local
;
36 if (local
->ops
->get_et_strings
) {
37 trace_drv_get_et_strings(local
, sset
);
38 local
->ops
->get_et_strings(&local
->hw
, &sdata
->vif
, sset
, data
);
39 trace_drv_return_void(local
);
43 static inline void drv_get_et_stats(struct ieee80211_sub_if_data
*sdata
,
44 struct ethtool_stats
*stats
,
47 struct ieee80211_local
*local
= sdata
->local
;
48 if (local
->ops
->get_et_stats
) {
49 trace_drv_get_et_stats(local
);
50 local
->ops
->get_et_stats(&local
->hw
, &sdata
->vif
, stats
, data
);
51 trace_drv_return_void(local
);
55 static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data
*sdata
,
58 struct ieee80211_local
*local
= sdata
->local
;
60 if (local
->ops
->get_et_sset_count
) {
61 trace_drv_get_et_sset_count(local
, sset
);
62 rv
= local
->ops
->get_et_sset_count(&local
->hw
, &sdata
->vif
,
64 trace_drv_return_int(local
, rv
);
69 static inline int drv_start(struct ieee80211_local
*local
)
75 trace_drv_start(local
);
76 local
->started
= true;
78 ret
= local
->ops
->start(&local
->hw
);
79 trace_drv_return_int(local
, ret
);
83 static inline void drv_stop(struct ieee80211_local
*local
)
87 trace_drv_stop(local
);
88 local
->ops
->stop(&local
->hw
);
89 trace_drv_return_void(local
);
91 /* sync away all work on the tasklet before clearing started */
92 tasklet_disable(&local
->tasklet
);
93 tasklet_enable(&local
->tasklet
);
97 local
->started
= false;
101 static inline int drv_suspend(struct ieee80211_local
*local
,
102 struct cfg80211_wowlan
*wowlan
)
108 trace_drv_suspend(local
);
109 ret
= local
->ops
->suspend(&local
->hw
, wowlan
);
110 trace_drv_return_int(local
, ret
);
114 static inline int drv_resume(struct ieee80211_local
*local
)
120 trace_drv_resume(local
);
121 ret
= local
->ops
->resume(&local
->hw
);
122 trace_drv_return_int(local
, ret
);
126 static inline void drv_set_wakeup(struct ieee80211_local
*local
,
131 if (!local
->ops
->set_wakeup
)
134 trace_drv_set_wakeup(local
, enabled
);
135 local
->ops
->set_wakeup(&local
->hw
, enabled
);
136 trace_drv_return_void(local
);
140 static inline int drv_add_interface(struct ieee80211_local
*local
,
141 struct ieee80211_sub_if_data
*sdata
)
147 if (WARN_ON(sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
||
148 (sdata
->vif
.type
== NL80211_IFTYPE_MONITOR
&&
149 !(local
->hw
.flags
& IEEE80211_HW_WANT_MONITOR_VIF
) &&
150 !(sdata
->u
.mntr_flags
& MONITOR_FLAG_ACTIVE
))))
153 trace_drv_add_interface(local
, sdata
);
154 ret
= local
->ops
->add_interface(&local
->hw
, &sdata
->vif
);
155 trace_drv_return_int(local
, ret
);
158 sdata
->flags
|= IEEE80211_SDATA_IN_DRIVER
;
163 static inline int drv_change_interface(struct ieee80211_local
*local
,
164 struct ieee80211_sub_if_data
*sdata
,
165 enum nl80211_iftype type
, bool p2p
)
171 if (!check_sdata_in_driver(sdata
))
174 trace_drv_change_interface(local
, sdata
, type
, p2p
);
175 ret
= local
->ops
->change_interface(&local
->hw
, &sdata
->vif
, type
, p2p
);
176 trace_drv_return_int(local
, ret
);
180 static inline void drv_remove_interface(struct ieee80211_local
*local
,
181 struct ieee80211_sub_if_data
*sdata
)
185 if (!check_sdata_in_driver(sdata
))
188 trace_drv_remove_interface(local
, sdata
);
189 local
->ops
->remove_interface(&local
->hw
, &sdata
->vif
);
190 sdata
->flags
&= ~IEEE80211_SDATA_IN_DRIVER
;
191 trace_drv_return_void(local
);
194 static inline int drv_config(struct ieee80211_local
*local
, u32 changed
)
200 trace_drv_config(local
, changed
);
201 ret
= local
->ops
->config(&local
->hw
, changed
);
202 trace_drv_return_int(local
, ret
);
206 static inline void drv_bss_info_changed(struct ieee80211_local
*local
,
207 struct ieee80211_sub_if_data
*sdata
,
208 struct ieee80211_bss_conf
*info
,
213 if (WARN_ON_ONCE(changed
& (BSS_CHANGED_BEACON
|
214 BSS_CHANGED_BEACON_ENABLED
) &&
215 sdata
->vif
.type
!= NL80211_IFTYPE_AP
&&
216 sdata
->vif
.type
!= NL80211_IFTYPE_ADHOC
&&
217 sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
&&
218 sdata
->vif
.type
!= NL80211_IFTYPE_OCB
))
221 if (WARN_ON_ONCE(sdata
->vif
.type
== NL80211_IFTYPE_P2P_DEVICE
||
222 sdata
->vif
.type
== NL80211_IFTYPE_MONITOR
))
225 if (!check_sdata_in_driver(sdata
))
228 trace_drv_bss_info_changed(local
, sdata
, info
, changed
);
229 if (local
->ops
->bss_info_changed
)
230 local
->ops
->bss_info_changed(&local
->hw
, &sdata
->vif
, info
, changed
);
231 trace_drv_return_void(local
);
234 static inline u64
drv_prepare_multicast(struct ieee80211_local
*local
,
235 struct netdev_hw_addr_list
*mc_list
)
239 trace_drv_prepare_multicast(local
, mc_list
->count
);
241 if (local
->ops
->prepare_multicast
)
242 ret
= local
->ops
->prepare_multicast(&local
->hw
, mc_list
);
244 trace_drv_return_u64(local
, ret
);
249 static inline void drv_configure_filter(struct ieee80211_local
*local
,
250 unsigned int changed_flags
,
251 unsigned int *total_flags
,
256 trace_drv_configure_filter(local
, changed_flags
, total_flags
,
258 local
->ops
->configure_filter(&local
->hw
, changed_flags
, total_flags
,
260 trace_drv_return_void(local
);
263 static inline int drv_set_tim(struct ieee80211_local
*local
,
264 struct ieee80211_sta
*sta
, bool set
)
267 trace_drv_set_tim(local
, sta
, set
);
268 if (local
->ops
->set_tim
)
269 ret
= local
->ops
->set_tim(&local
->hw
, sta
, set
);
270 trace_drv_return_int(local
, ret
);
274 static inline int drv_set_key(struct ieee80211_local
*local
,
275 enum set_key_cmd cmd
,
276 struct ieee80211_sub_if_data
*sdata
,
277 struct ieee80211_sta
*sta
,
278 struct ieee80211_key_conf
*key
)
284 sdata
= get_bss_sdata(sdata
);
285 if (!check_sdata_in_driver(sdata
))
288 trace_drv_set_key(local
, cmd
, sdata
, sta
, key
);
289 ret
= local
->ops
->set_key(&local
->hw
, cmd
, &sdata
->vif
, sta
, key
);
290 trace_drv_return_int(local
, ret
);
294 static inline void drv_update_tkip_key(struct ieee80211_local
*local
,
295 struct ieee80211_sub_if_data
*sdata
,
296 struct ieee80211_key_conf
*conf
,
297 struct sta_info
*sta
, u32 iv32
,
300 struct ieee80211_sta
*ista
= NULL
;
305 sdata
= get_bss_sdata(sdata
);
306 if (!check_sdata_in_driver(sdata
))
309 trace_drv_update_tkip_key(local
, sdata
, conf
, ista
, iv32
);
310 if (local
->ops
->update_tkip_key
)
311 local
->ops
->update_tkip_key(&local
->hw
, &sdata
->vif
, conf
,
312 ista
, iv32
, phase1key
);
313 trace_drv_return_void(local
);
316 static inline int drv_hw_scan(struct ieee80211_local
*local
,
317 struct ieee80211_sub_if_data
*sdata
,
318 struct ieee80211_scan_request
*req
)
324 if (!check_sdata_in_driver(sdata
))
327 trace_drv_hw_scan(local
, sdata
);
328 ret
= local
->ops
->hw_scan(&local
->hw
, &sdata
->vif
, req
);
329 trace_drv_return_int(local
, ret
);
333 static inline void drv_cancel_hw_scan(struct ieee80211_local
*local
,
334 struct ieee80211_sub_if_data
*sdata
)
338 if (!check_sdata_in_driver(sdata
))
341 trace_drv_cancel_hw_scan(local
, sdata
);
342 local
->ops
->cancel_hw_scan(&local
->hw
, &sdata
->vif
);
343 trace_drv_return_void(local
);
347 drv_sched_scan_start(struct ieee80211_local
*local
,
348 struct ieee80211_sub_if_data
*sdata
,
349 struct cfg80211_sched_scan_request
*req
,
350 struct ieee80211_scan_ies
*ies
)
356 if (!check_sdata_in_driver(sdata
))
359 trace_drv_sched_scan_start(local
, sdata
);
360 ret
= local
->ops
->sched_scan_start(&local
->hw
, &sdata
->vif
,
362 trace_drv_return_int(local
, ret
);
366 static inline int drv_sched_scan_stop(struct ieee80211_local
*local
,
367 struct ieee80211_sub_if_data
*sdata
)
373 if (!check_sdata_in_driver(sdata
))
376 trace_drv_sched_scan_stop(local
, sdata
);
377 ret
= local
->ops
->sched_scan_stop(&local
->hw
, &sdata
->vif
);
378 trace_drv_return_int(local
, ret
);
383 static inline void drv_sw_scan_start(struct ieee80211_local
*local
)
387 trace_drv_sw_scan_start(local
);
388 if (local
->ops
->sw_scan_start
)
389 local
->ops
->sw_scan_start(&local
->hw
);
390 trace_drv_return_void(local
);
393 static inline void drv_sw_scan_complete(struct ieee80211_local
*local
)
397 trace_drv_sw_scan_complete(local
);
398 if (local
->ops
->sw_scan_complete
)
399 local
->ops
->sw_scan_complete(&local
->hw
);
400 trace_drv_return_void(local
);
403 static inline int drv_get_stats(struct ieee80211_local
*local
,
404 struct ieee80211_low_level_stats
*stats
)
406 int ret
= -EOPNOTSUPP
;
410 if (local
->ops
->get_stats
)
411 ret
= local
->ops
->get_stats(&local
->hw
, stats
);
412 trace_drv_get_stats(local
, stats
, ret
);
417 static inline void drv_get_tkip_seq(struct ieee80211_local
*local
,
418 u8 hw_key_idx
, u32
*iv32
, u16
*iv16
)
420 if (local
->ops
->get_tkip_seq
)
421 local
->ops
->get_tkip_seq(&local
->hw
, hw_key_idx
, iv32
, iv16
);
422 trace_drv_get_tkip_seq(local
, hw_key_idx
, iv32
, iv16
);
425 static inline int drv_set_frag_threshold(struct ieee80211_local
*local
,
432 trace_drv_set_frag_threshold(local
, value
);
433 if (local
->ops
->set_frag_threshold
)
434 ret
= local
->ops
->set_frag_threshold(&local
->hw
, value
);
435 trace_drv_return_int(local
, ret
);
439 static inline int drv_set_rts_threshold(struct ieee80211_local
*local
,
446 trace_drv_set_rts_threshold(local
, value
);
447 if (local
->ops
->set_rts_threshold
)
448 ret
= local
->ops
->set_rts_threshold(&local
->hw
, value
);
449 trace_drv_return_int(local
, ret
);
453 static inline int drv_set_coverage_class(struct ieee80211_local
*local
,
459 trace_drv_set_coverage_class(local
, value
);
460 if (local
->ops
->set_coverage_class
)
461 local
->ops
->set_coverage_class(&local
->hw
, value
);
465 trace_drv_return_int(local
, ret
);
469 static inline void drv_sta_notify(struct ieee80211_local
*local
,
470 struct ieee80211_sub_if_data
*sdata
,
471 enum sta_notify_cmd cmd
,
472 struct ieee80211_sta
*sta
)
474 sdata
= get_bss_sdata(sdata
);
475 if (!check_sdata_in_driver(sdata
))
478 trace_drv_sta_notify(local
, sdata
, cmd
, sta
);
479 if (local
->ops
->sta_notify
)
480 local
->ops
->sta_notify(&local
->hw
, &sdata
->vif
, cmd
, sta
);
481 trace_drv_return_void(local
);
484 static inline int drv_sta_add(struct ieee80211_local
*local
,
485 struct ieee80211_sub_if_data
*sdata
,
486 struct ieee80211_sta
*sta
)
492 sdata
= get_bss_sdata(sdata
);
493 if (!check_sdata_in_driver(sdata
))
496 trace_drv_sta_add(local
, sdata
, sta
);
497 if (local
->ops
->sta_add
)
498 ret
= local
->ops
->sta_add(&local
->hw
, &sdata
->vif
, sta
);
500 trace_drv_return_int(local
, ret
);
505 static inline void drv_sta_remove(struct ieee80211_local
*local
,
506 struct ieee80211_sub_if_data
*sdata
,
507 struct ieee80211_sta
*sta
)
511 sdata
= get_bss_sdata(sdata
);
512 if (!check_sdata_in_driver(sdata
))
515 trace_drv_sta_remove(local
, sdata
, sta
);
516 if (local
->ops
->sta_remove
)
517 local
->ops
->sta_remove(&local
->hw
, &sdata
->vif
, sta
);
519 trace_drv_return_void(local
);
522 #ifdef CONFIG_MAC80211_DEBUGFS
523 static inline void drv_sta_add_debugfs(struct ieee80211_local
*local
,
524 struct ieee80211_sub_if_data
*sdata
,
525 struct ieee80211_sta
*sta
,
530 sdata
= get_bss_sdata(sdata
);
531 if (!check_sdata_in_driver(sdata
))
534 if (local
->ops
->sta_add_debugfs
)
535 local
->ops
->sta_add_debugfs(&local
->hw
, &sdata
->vif
,
539 static inline void drv_sta_remove_debugfs(struct ieee80211_local
*local
,
540 struct ieee80211_sub_if_data
*sdata
,
541 struct ieee80211_sta
*sta
,
546 sdata
= get_bss_sdata(sdata
);
547 check_sdata_in_driver(sdata
);
549 if (local
->ops
->sta_remove_debugfs
)
550 local
->ops
->sta_remove_debugfs(&local
->hw
, &sdata
->vif
,
555 static inline void drv_sta_pre_rcu_remove(struct ieee80211_local
*local
,
556 struct ieee80211_sub_if_data
*sdata
,
557 struct sta_info
*sta
)
561 sdata
= get_bss_sdata(sdata
);
562 if (!check_sdata_in_driver(sdata
))
565 trace_drv_sta_pre_rcu_remove(local
, sdata
, &sta
->sta
);
566 if (local
->ops
->sta_pre_rcu_remove
)
567 local
->ops
->sta_pre_rcu_remove(&local
->hw
, &sdata
->vif
,
569 trace_drv_return_void(local
);
572 static inline __must_check
573 int drv_sta_state(struct ieee80211_local
*local
,
574 struct ieee80211_sub_if_data
*sdata
,
575 struct sta_info
*sta
,
576 enum ieee80211_sta_state old_state
,
577 enum ieee80211_sta_state new_state
)
583 sdata
= get_bss_sdata(sdata
);
584 if (!check_sdata_in_driver(sdata
))
587 trace_drv_sta_state(local
, sdata
, &sta
->sta
, old_state
, new_state
);
588 if (local
->ops
->sta_state
) {
589 ret
= local
->ops
->sta_state(&local
->hw
, &sdata
->vif
, &sta
->sta
,
590 old_state
, new_state
);
591 } else if (old_state
== IEEE80211_STA_AUTH
&&
592 new_state
== IEEE80211_STA_ASSOC
) {
593 ret
= drv_sta_add(local
, sdata
, &sta
->sta
);
595 sta
->uploaded
= true;
596 } else if (old_state
== IEEE80211_STA_ASSOC
&&
597 new_state
== IEEE80211_STA_AUTH
) {
598 drv_sta_remove(local
, sdata
, &sta
->sta
);
600 trace_drv_return_int(local
, ret
);
604 static inline void drv_sta_rc_update(struct ieee80211_local
*local
,
605 struct ieee80211_sub_if_data
*sdata
,
606 struct ieee80211_sta
*sta
, u32 changed
)
608 sdata
= get_bss_sdata(sdata
);
609 if (!check_sdata_in_driver(sdata
))
612 WARN_ON(changed
& IEEE80211_RC_SUPP_RATES_CHANGED
&&
613 (sdata
->vif
.type
!= NL80211_IFTYPE_ADHOC
&&
614 sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
));
616 trace_drv_sta_rc_update(local
, sdata
, sta
, changed
);
617 if (local
->ops
->sta_rc_update
)
618 local
->ops
->sta_rc_update(&local
->hw
, &sdata
->vif
,
621 trace_drv_return_void(local
);
624 static inline int drv_conf_tx(struct ieee80211_local
*local
,
625 struct ieee80211_sub_if_data
*sdata
, u16 ac
,
626 const struct ieee80211_tx_queue_params
*params
)
628 int ret
= -EOPNOTSUPP
;
632 if (!check_sdata_in_driver(sdata
))
635 if (WARN_ONCE(params
->cw_min
== 0 ||
636 params
->cw_min
> params
->cw_max
,
637 "%s: invalid CW_min/CW_max: %d/%d\n",
638 sdata
->name
, params
->cw_min
, params
->cw_max
))
641 trace_drv_conf_tx(local
, sdata
, ac
, params
);
642 if (local
->ops
->conf_tx
)
643 ret
= local
->ops
->conf_tx(&local
->hw
, &sdata
->vif
,
645 trace_drv_return_int(local
, ret
);
649 static inline u64
drv_get_tsf(struct ieee80211_local
*local
,
650 struct ieee80211_sub_if_data
*sdata
)
656 if (!check_sdata_in_driver(sdata
))
659 trace_drv_get_tsf(local
, sdata
);
660 if (local
->ops
->get_tsf
)
661 ret
= local
->ops
->get_tsf(&local
->hw
, &sdata
->vif
);
662 trace_drv_return_u64(local
, ret
);
666 static inline void drv_set_tsf(struct ieee80211_local
*local
,
667 struct ieee80211_sub_if_data
*sdata
,
672 if (!check_sdata_in_driver(sdata
))
675 trace_drv_set_tsf(local
, sdata
, tsf
);
676 if (local
->ops
->set_tsf
)
677 local
->ops
->set_tsf(&local
->hw
, &sdata
->vif
, tsf
);
678 trace_drv_return_void(local
);
681 static inline void drv_reset_tsf(struct ieee80211_local
*local
,
682 struct ieee80211_sub_if_data
*sdata
)
686 if (!check_sdata_in_driver(sdata
))
689 trace_drv_reset_tsf(local
, sdata
);
690 if (local
->ops
->reset_tsf
)
691 local
->ops
->reset_tsf(&local
->hw
, &sdata
->vif
);
692 trace_drv_return_void(local
);
695 static inline int drv_tx_last_beacon(struct ieee80211_local
*local
)
697 int ret
= 0; /* default unsupported op for less congestion */
701 trace_drv_tx_last_beacon(local
);
702 if (local
->ops
->tx_last_beacon
)
703 ret
= local
->ops
->tx_last_beacon(&local
->hw
);
704 trace_drv_return_int(local
, ret
);
708 static inline int drv_ampdu_action(struct ieee80211_local
*local
,
709 struct ieee80211_sub_if_data
*sdata
,
710 enum ieee80211_ampdu_mlme_action action
,
711 struct ieee80211_sta
*sta
, u16 tid
,
712 u16
*ssn
, u8 buf_size
)
714 int ret
= -EOPNOTSUPP
;
718 sdata
= get_bss_sdata(sdata
);
719 if (!check_sdata_in_driver(sdata
))
722 trace_drv_ampdu_action(local
, sdata
, action
, sta
, tid
, ssn
, buf_size
);
724 if (local
->ops
->ampdu_action
)
725 ret
= local
->ops
->ampdu_action(&local
->hw
, &sdata
->vif
, action
,
726 sta
, tid
, ssn
, buf_size
);
728 trace_drv_return_int(local
, ret
);
733 static inline int drv_get_survey(struct ieee80211_local
*local
, int idx
,
734 struct survey_info
*survey
)
736 int ret
= -EOPNOTSUPP
;
738 trace_drv_get_survey(local
, idx
, survey
);
740 if (local
->ops
->get_survey
)
741 ret
= local
->ops
->get_survey(&local
->hw
, idx
, survey
);
743 trace_drv_return_int(local
, ret
);
748 static inline void drv_rfkill_poll(struct ieee80211_local
*local
)
752 if (local
->ops
->rfkill_poll
)
753 local
->ops
->rfkill_poll(&local
->hw
);
756 static inline void drv_flush(struct ieee80211_local
*local
,
757 struct ieee80211_sub_if_data
*sdata
,
758 u32 queues
, bool drop
)
760 struct ieee80211_vif
*vif
= sdata
? &sdata
->vif
: NULL
;
764 if (sdata
&& !check_sdata_in_driver(sdata
))
767 trace_drv_flush(local
, queues
, drop
);
768 if (local
->ops
->flush
)
769 local
->ops
->flush(&local
->hw
, vif
, queues
, drop
);
770 trace_drv_return_void(local
);
773 static inline void drv_channel_switch(struct ieee80211_local
*local
,
774 struct ieee80211_sub_if_data
*sdata
,
775 struct ieee80211_channel_switch
*ch_switch
)
779 trace_drv_channel_switch(local
, sdata
, ch_switch
);
780 local
->ops
->channel_switch(&local
->hw
, &sdata
->vif
, ch_switch
);
781 trace_drv_return_void(local
);
785 static inline int drv_set_antenna(struct ieee80211_local
*local
,
786 u32 tx_ant
, u32 rx_ant
)
788 int ret
= -EOPNOTSUPP
;
790 if (local
->ops
->set_antenna
)
791 ret
= local
->ops
->set_antenna(&local
->hw
, tx_ant
, rx_ant
);
792 trace_drv_set_antenna(local
, tx_ant
, rx_ant
, ret
);
796 static inline int drv_get_antenna(struct ieee80211_local
*local
,
797 u32
*tx_ant
, u32
*rx_ant
)
799 int ret
= -EOPNOTSUPP
;
801 if (local
->ops
->get_antenna
)
802 ret
= local
->ops
->get_antenna(&local
->hw
, tx_ant
, rx_ant
);
803 trace_drv_get_antenna(local
, *tx_ant
, *rx_ant
, ret
);
807 static inline int drv_remain_on_channel(struct ieee80211_local
*local
,
808 struct ieee80211_sub_if_data
*sdata
,
809 struct ieee80211_channel
*chan
,
810 unsigned int duration
,
811 enum ieee80211_roc_type type
)
817 trace_drv_remain_on_channel(local
, sdata
, chan
, duration
, type
);
818 ret
= local
->ops
->remain_on_channel(&local
->hw
, &sdata
->vif
,
819 chan
, duration
, type
);
820 trace_drv_return_int(local
, ret
);
825 static inline int drv_cancel_remain_on_channel(struct ieee80211_local
*local
)
831 trace_drv_cancel_remain_on_channel(local
);
832 ret
= local
->ops
->cancel_remain_on_channel(&local
->hw
);
833 trace_drv_return_int(local
, ret
);
838 static inline int drv_set_ringparam(struct ieee80211_local
*local
,
845 trace_drv_set_ringparam(local
, tx
, rx
);
846 if (local
->ops
->set_ringparam
)
847 ret
= local
->ops
->set_ringparam(&local
->hw
, tx
, rx
);
848 trace_drv_return_int(local
, ret
);
853 static inline void drv_get_ringparam(struct ieee80211_local
*local
,
854 u32
*tx
, u32
*tx_max
, u32
*rx
, u32
*rx_max
)
858 trace_drv_get_ringparam(local
, tx
, tx_max
, rx
, rx_max
);
859 if (local
->ops
->get_ringparam
)
860 local
->ops
->get_ringparam(&local
->hw
, tx
, tx_max
, rx
, rx_max
);
861 trace_drv_return_void(local
);
864 static inline bool drv_tx_frames_pending(struct ieee80211_local
*local
)
870 trace_drv_tx_frames_pending(local
);
871 if (local
->ops
->tx_frames_pending
)
872 ret
= local
->ops
->tx_frames_pending(&local
->hw
);
873 trace_drv_return_bool(local
, ret
);
878 static inline int drv_set_bitrate_mask(struct ieee80211_local
*local
,
879 struct ieee80211_sub_if_data
*sdata
,
880 const struct cfg80211_bitrate_mask
*mask
)
882 int ret
= -EOPNOTSUPP
;
886 if (!check_sdata_in_driver(sdata
))
889 trace_drv_set_bitrate_mask(local
, sdata
, mask
);
890 if (local
->ops
->set_bitrate_mask
)
891 ret
= local
->ops
->set_bitrate_mask(&local
->hw
,
893 trace_drv_return_int(local
, ret
);
898 static inline void drv_set_rekey_data(struct ieee80211_local
*local
,
899 struct ieee80211_sub_if_data
*sdata
,
900 struct cfg80211_gtk_rekey_data
*data
)
902 if (!check_sdata_in_driver(sdata
))
905 trace_drv_set_rekey_data(local
, sdata
, data
);
906 if (local
->ops
->set_rekey_data
)
907 local
->ops
->set_rekey_data(&local
->hw
, &sdata
->vif
, data
);
908 trace_drv_return_void(local
);
911 static inline void drv_rssi_callback(struct ieee80211_local
*local
,
912 struct ieee80211_sub_if_data
*sdata
,
913 const enum ieee80211_rssi_event event
)
915 trace_drv_rssi_callback(local
, sdata
, event
);
916 if (local
->ops
->rssi_callback
)
917 local
->ops
->rssi_callback(&local
->hw
, &sdata
->vif
, event
);
918 trace_drv_return_void(local
);
922 drv_release_buffered_frames(struct ieee80211_local
*local
,
923 struct sta_info
*sta
, u16 tids
, int num_frames
,
924 enum ieee80211_frame_release_type reason
,
927 trace_drv_release_buffered_frames(local
, &sta
->sta
, tids
, num_frames
,
929 if (local
->ops
->release_buffered_frames
)
930 local
->ops
->release_buffered_frames(&local
->hw
, &sta
->sta
, tids
,
933 trace_drv_return_void(local
);
937 drv_allow_buffered_frames(struct ieee80211_local
*local
,
938 struct sta_info
*sta
, u16 tids
, int num_frames
,
939 enum ieee80211_frame_release_type reason
,
942 trace_drv_allow_buffered_frames(local
, &sta
->sta
, tids
, num_frames
,
944 if (local
->ops
->allow_buffered_frames
)
945 local
->ops
->allow_buffered_frames(&local
->hw
, &sta
->sta
,
946 tids
, num_frames
, reason
,
948 trace_drv_return_void(local
);
951 static inline int drv_get_rssi(struct ieee80211_local
*local
,
952 struct ieee80211_sub_if_data
*sdata
,
953 struct ieee80211_sta
*sta
,
960 ret
= local
->ops
->get_rssi(&local
->hw
, &sdata
->vif
, sta
, rssi_dbm
);
961 trace_drv_get_rssi(local
, sta
, *rssi_dbm
, ret
);
966 static inline void drv_mgd_prepare_tx(struct ieee80211_local
*local
,
967 struct ieee80211_sub_if_data
*sdata
)
971 if (!check_sdata_in_driver(sdata
))
973 WARN_ON_ONCE(sdata
->vif
.type
!= NL80211_IFTYPE_STATION
);
975 trace_drv_mgd_prepare_tx(local
, sdata
);
976 if (local
->ops
->mgd_prepare_tx
)
977 local
->ops
->mgd_prepare_tx(&local
->hw
, &sdata
->vif
);
978 trace_drv_return_void(local
);
982 drv_mgd_protect_tdls_discover(struct ieee80211_local
*local
,
983 struct ieee80211_sub_if_data
*sdata
)
987 if (!check_sdata_in_driver(sdata
))
989 WARN_ON_ONCE(sdata
->vif
.type
!= NL80211_IFTYPE_STATION
);
991 trace_drv_mgd_protect_tdls_discover(local
, sdata
);
992 if (local
->ops
->mgd_protect_tdls_discover
)
993 local
->ops
->mgd_protect_tdls_discover(&local
->hw
, &sdata
->vif
);
994 trace_drv_return_void(local
);
997 static inline int drv_add_chanctx(struct ieee80211_local
*local
,
998 struct ieee80211_chanctx
*ctx
)
1000 int ret
= -EOPNOTSUPP
;
1002 trace_drv_add_chanctx(local
, ctx
);
1003 if (local
->ops
->add_chanctx
)
1004 ret
= local
->ops
->add_chanctx(&local
->hw
, &ctx
->conf
);
1005 trace_drv_return_int(local
, ret
);
1007 ctx
->driver_present
= true;
1012 static inline void drv_remove_chanctx(struct ieee80211_local
*local
,
1013 struct ieee80211_chanctx
*ctx
)
1015 if (WARN_ON(!ctx
->driver_present
))
1018 trace_drv_remove_chanctx(local
, ctx
);
1019 if (local
->ops
->remove_chanctx
)
1020 local
->ops
->remove_chanctx(&local
->hw
, &ctx
->conf
);
1021 trace_drv_return_void(local
);
1022 ctx
->driver_present
= false;
1025 static inline void drv_change_chanctx(struct ieee80211_local
*local
,
1026 struct ieee80211_chanctx
*ctx
,
1029 trace_drv_change_chanctx(local
, ctx
, changed
);
1030 if (local
->ops
->change_chanctx
) {
1031 WARN_ON_ONCE(!ctx
->driver_present
);
1032 local
->ops
->change_chanctx(&local
->hw
, &ctx
->conf
, changed
);
1034 trace_drv_return_void(local
);
1037 static inline int drv_assign_vif_chanctx(struct ieee80211_local
*local
,
1038 struct ieee80211_sub_if_data
*sdata
,
1039 struct ieee80211_chanctx
*ctx
)
1043 if (!check_sdata_in_driver(sdata
))
1046 trace_drv_assign_vif_chanctx(local
, sdata
, ctx
);
1047 if (local
->ops
->assign_vif_chanctx
) {
1048 WARN_ON_ONCE(!ctx
->driver_present
);
1049 ret
= local
->ops
->assign_vif_chanctx(&local
->hw
,
1053 trace_drv_return_int(local
, ret
);
1058 static inline void drv_unassign_vif_chanctx(struct ieee80211_local
*local
,
1059 struct ieee80211_sub_if_data
*sdata
,
1060 struct ieee80211_chanctx
*ctx
)
1062 if (!check_sdata_in_driver(sdata
))
1065 trace_drv_unassign_vif_chanctx(local
, sdata
, ctx
);
1066 if (local
->ops
->unassign_vif_chanctx
) {
1067 WARN_ON_ONCE(!ctx
->driver_present
);
1068 local
->ops
->unassign_vif_chanctx(&local
->hw
,
1072 trace_drv_return_void(local
);
1076 drv_switch_vif_chanctx(struct ieee80211_local
*local
,
1077 struct ieee80211_vif_chanctx_switch
*vifs
,
1079 enum ieee80211_chanctx_switch_mode mode
)
1084 if (!local
->ops
->switch_vif_chanctx
)
1087 for (i
= 0; i
< n_vifs
; i
++) {
1088 struct ieee80211_chanctx
*new_ctx
=
1089 container_of(vifs
[i
].new_ctx
,
1090 struct ieee80211_chanctx
,
1092 struct ieee80211_chanctx
*old_ctx
=
1093 container_of(vifs
[i
].old_ctx
,
1094 struct ieee80211_chanctx
,
1097 WARN_ON_ONCE(!old_ctx
->driver_present
);
1098 WARN_ON_ONCE((mode
== CHANCTX_SWMODE_SWAP_CONTEXTS
&&
1099 new_ctx
->driver_present
) ||
1100 (mode
== CHANCTX_SWMODE_REASSIGN_VIF
&&
1101 !new_ctx
->driver_present
));
1104 trace_drv_switch_vif_chanctx(local
, vifs
, n_vifs
, mode
);
1105 ret
= local
->ops
->switch_vif_chanctx(&local
->hw
,
1106 vifs
, n_vifs
, mode
);
1107 trace_drv_return_int(local
, ret
);
1109 if (!ret
&& mode
== CHANCTX_SWMODE_SWAP_CONTEXTS
) {
1110 for (i
= 0; i
< n_vifs
; i
++) {
1111 struct ieee80211_chanctx
*new_ctx
=
1112 container_of(vifs
[i
].new_ctx
,
1113 struct ieee80211_chanctx
,
1115 struct ieee80211_chanctx
*old_ctx
=
1116 container_of(vifs
[i
].old_ctx
,
1117 struct ieee80211_chanctx
,
1120 new_ctx
->driver_present
= true;
1121 old_ctx
->driver_present
= false;
1128 static inline int drv_start_ap(struct ieee80211_local
*local
,
1129 struct ieee80211_sub_if_data
*sdata
)
1133 if (!check_sdata_in_driver(sdata
))
1136 trace_drv_start_ap(local
, sdata
, &sdata
->vif
.bss_conf
);
1137 if (local
->ops
->start_ap
)
1138 ret
= local
->ops
->start_ap(&local
->hw
, &sdata
->vif
);
1139 trace_drv_return_int(local
, ret
);
1143 static inline void drv_stop_ap(struct ieee80211_local
*local
,
1144 struct ieee80211_sub_if_data
*sdata
)
1146 if (!check_sdata_in_driver(sdata
))
1149 trace_drv_stop_ap(local
, sdata
);
1150 if (local
->ops
->stop_ap
)
1151 local
->ops
->stop_ap(&local
->hw
, &sdata
->vif
);
1152 trace_drv_return_void(local
);
1155 static inline void drv_restart_complete(struct ieee80211_local
*local
)
1159 trace_drv_restart_complete(local
);
1160 if (local
->ops
->restart_complete
)
1161 local
->ops
->restart_complete(&local
->hw
);
1162 trace_drv_return_void(local
);
1166 drv_set_default_unicast_key(struct ieee80211_local
*local
,
1167 struct ieee80211_sub_if_data
*sdata
,
1170 if (!check_sdata_in_driver(sdata
))
1173 WARN_ON_ONCE(key_idx
< -1 || key_idx
> 3);
1175 trace_drv_set_default_unicast_key(local
, sdata
, key_idx
);
1176 if (local
->ops
->set_default_unicast_key
)
1177 local
->ops
->set_default_unicast_key(&local
->hw
, &sdata
->vif
,
1179 trace_drv_return_void(local
);
1182 #if IS_ENABLED(CONFIG_IPV6)
1183 static inline void drv_ipv6_addr_change(struct ieee80211_local
*local
,
1184 struct ieee80211_sub_if_data
*sdata
,
1185 struct inet6_dev
*idev
)
1187 trace_drv_ipv6_addr_change(local
, sdata
);
1188 if (local
->ops
->ipv6_addr_change
)
1189 local
->ops
->ipv6_addr_change(&local
->hw
, &sdata
->vif
, idev
);
1190 trace_drv_return_void(local
);
1195 drv_channel_switch_beacon(struct ieee80211_sub_if_data
*sdata
,
1196 struct cfg80211_chan_def
*chandef
)
1198 struct ieee80211_local
*local
= sdata
->local
;
1200 if (local
->ops
->channel_switch_beacon
) {
1201 trace_drv_channel_switch_beacon(local
, sdata
, chandef
);
1202 local
->ops
->channel_switch_beacon(&local
->hw
, &sdata
->vif
,
1208 drv_pre_channel_switch(struct ieee80211_sub_if_data
*sdata
,
1209 struct ieee80211_channel_switch
*ch_switch
)
1211 struct ieee80211_local
*local
= sdata
->local
;
1214 if (!check_sdata_in_driver(sdata
))
1217 trace_drv_pre_channel_switch(local
, sdata
, ch_switch
);
1218 if (local
->ops
->pre_channel_switch
)
1219 ret
= local
->ops
->pre_channel_switch(&local
->hw
, &sdata
->vif
,
1221 trace_drv_return_int(local
, ret
);
1226 drv_post_channel_switch(struct ieee80211_sub_if_data
*sdata
)
1228 struct ieee80211_local
*local
= sdata
->local
;
1231 if (!check_sdata_in_driver(sdata
))
1234 trace_drv_post_channel_switch(local
, sdata
);
1235 if (local
->ops
->post_channel_switch
)
1236 ret
= local
->ops
->post_channel_switch(&local
->hw
, &sdata
->vif
);
1237 trace_drv_return_int(local
, ret
);
1241 static inline int drv_join_ibss(struct ieee80211_local
*local
,
1242 struct ieee80211_sub_if_data
*sdata
)
1247 if (!check_sdata_in_driver(sdata
))
1250 trace_drv_join_ibss(local
, sdata
, &sdata
->vif
.bss_conf
);
1251 if (local
->ops
->join_ibss
)
1252 ret
= local
->ops
->join_ibss(&local
->hw
, &sdata
->vif
);
1253 trace_drv_return_int(local
, ret
);
1257 static inline void drv_leave_ibss(struct ieee80211_local
*local
,
1258 struct ieee80211_sub_if_data
*sdata
)
1261 if (!check_sdata_in_driver(sdata
))
1264 trace_drv_leave_ibss(local
, sdata
);
1265 if (local
->ops
->leave_ibss
)
1266 local
->ops
->leave_ibss(&local
->hw
, &sdata
->vif
);
1267 trace_drv_return_void(local
);
1270 static inline u32
drv_get_expected_throughput(struct ieee80211_local
*local
,
1271 struct ieee80211_sta
*sta
)
1275 trace_drv_get_expected_throughput(sta
);
1276 if (local
->ops
->get_expected_throughput
)
1277 ret
= local
->ops
->get_expected_throughput(sta
);
1278 trace_drv_return_u32(local
, ret
);
1283 static inline int drv_get_txpower(struct ieee80211_local
*local
,
1284 struct ieee80211_sub_if_data
*sdata
, int *dbm
)
1288 if (!local
->ops
->get_txpower
)
1291 ret
= local
->ops
->get_txpower(&local
->hw
, &sdata
->vif
, dbm
);
1292 trace_drv_get_txpower(local
, sdata
, *dbm
, ret
);
1297 #endif /* __MAC80211_DRIVER_OPS */