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
))
220 if (WARN_ON_ONCE(sdata
->vif
.type
== NL80211_IFTYPE_P2P_DEVICE
||
221 sdata
->vif
.type
== NL80211_IFTYPE_MONITOR
))
224 if (!check_sdata_in_driver(sdata
))
227 trace_drv_bss_info_changed(local
, sdata
, info
, changed
);
228 if (local
->ops
->bss_info_changed
)
229 local
->ops
->bss_info_changed(&local
->hw
, &sdata
->vif
, info
, changed
);
230 trace_drv_return_void(local
);
233 static inline u64
drv_prepare_multicast(struct ieee80211_local
*local
,
234 struct netdev_hw_addr_list
*mc_list
)
238 trace_drv_prepare_multicast(local
, mc_list
->count
);
240 if (local
->ops
->prepare_multicast
)
241 ret
= local
->ops
->prepare_multicast(&local
->hw
, mc_list
);
243 trace_drv_return_u64(local
, ret
);
248 static inline void drv_configure_filter(struct ieee80211_local
*local
,
249 unsigned int changed_flags
,
250 unsigned int *total_flags
,
255 trace_drv_configure_filter(local
, changed_flags
, total_flags
,
257 local
->ops
->configure_filter(&local
->hw
, changed_flags
, total_flags
,
259 trace_drv_return_void(local
);
262 static inline int drv_set_tim(struct ieee80211_local
*local
,
263 struct ieee80211_sta
*sta
, bool set
)
266 trace_drv_set_tim(local
, sta
, set
);
267 if (local
->ops
->set_tim
)
268 ret
= local
->ops
->set_tim(&local
->hw
, sta
, set
);
269 trace_drv_return_int(local
, ret
);
273 static inline int drv_set_key(struct ieee80211_local
*local
,
274 enum set_key_cmd cmd
,
275 struct ieee80211_sub_if_data
*sdata
,
276 struct ieee80211_sta
*sta
,
277 struct ieee80211_key_conf
*key
)
283 sdata
= get_bss_sdata(sdata
);
284 if (!check_sdata_in_driver(sdata
))
287 trace_drv_set_key(local
, cmd
, sdata
, sta
, key
);
288 ret
= local
->ops
->set_key(&local
->hw
, cmd
, &sdata
->vif
, sta
, key
);
289 trace_drv_return_int(local
, ret
);
293 static inline void drv_update_tkip_key(struct ieee80211_local
*local
,
294 struct ieee80211_sub_if_data
*sdata
,
295 struct ieee80211_key_conf
*conf
,
296 struct sta_info
*sta
, u32 iv32
,
299 struct ieee80211_sta
*ista
= NULL
;
304 sdata
= get_bss_sdata(sdata
);
305 if (!check_sdata_in_driver(sdata
))
308 trace_drv_update_tkip_key(local
, sdata
, conf
, ista
, iv32
);
309 if (local
->ops
->update_tkip_key
)
310 local
->ops
->update_tkip_key(&local
->hw
, &sdata
->vif
, conf
,
311 ista
, iv32
, phase1key
);
312 trace_drv_return_void(local
);
315 static inline int drv_hw_scan(struct ieee80211_local
*local
,
316 struct ieee80211_sub_if_data
*sdata
,
317 struct ieee80211_scan_request
*req
)
323 if (!check_sdata_in_driver(sdata
))
326 trace_drv_hw_scan(local
, sdata
);
327 ret
= local
->ops
->hw_scan(&local
->hw
, &sdata
->vif
, req
);
328 trace_drv_return_int(local
, ret
);
332 static inline void drv_cancel_hw_scan(struct ieee80211_local
*local
,
333 struct ieee80211_sub_if_data
*sdata
)
337 if (!check_sdata_in_driver(sdata
))
340 trace_drv_cancel_hw_scan(local
, sdata
);
341 local
->ops
->cancel_hw_scan(&local
->hw
, &sdata
->vif
);
342 trace_drv_return_void(local
);
346 drv_sched_scan_start(struct ieee80211_local
*local
,
347 struct ieee80211_sub_if_data
*sdata
,
348 struct cfg80211_sched_scan_request
*req
,
349 struct ieee80211_scan_ies
*ies
)
355 if (!check_sdata_in_driver(sdata
))
358 trace_drv_sched_scan_start(local
, sdata
);
359 ret
= local
->ops
->sched_scan_start(&local
->hw
, &sdata
->vif
,
361 trace_drv_return_int(local
, ret
);
365 static inline int drv_sched_scan_stop(struct ieee80211_local
*local
,
366 struct ieee80211_sub_if_data
*sdata
)
372 if (!check_sdata_in_driver(sdata
))
375 trace_drv_sched_scan_stop(local
, sdata
);
376 ret
= local
->ops
->sched_scan_stop(&local
->hw
, &sdata
->vif
);
377 trace_drv_return_int(local
, ret
);
382 static inline void drv_sw_scan_start(struct ieee80211_local
*local
)
386 trace_drv_sw_scan_start(local
);
387 if (local
->ops
->sw_scan_start
)
388 local
->ops
->sw_scan_start(&local
->hw
);
389 trace_drv_return_void(local
);
392 static inline void drv_sw_scan_complete(struct ieee80211_local
*local
)
396 trace_drv_sw_scan_complete(local
);
397 if (local
->ops
->sw_scan_complete
)
398 local
->ops
->sw_scan_complete(&local
->hw
);
399 trace_drv_return_void(local
);
402 static inline int drv_get_stats(struct ieee80211_local
*local
,
403 struct ieee80211_low_level_stats
*stats
)
405 int ret
= -EOPNOTSUPP
;
409 if (local
->ops
->get_stats
)
410 ret
= local
->ops
->get_stats(&local
->hw
, stats
);
411 trace_drv_get_stats(local
, stats
, ret
);
416 static inline void drv_get_tkip_seq(struct ieee80211_local
*local
,
417 u8 hw_key_idx
, u32
*iv32
, u16
*iv16
)
419 if (local
->ops
->get_tkip_seq
)
420 local
->ops
->get_tkip_seq(&local
->hw
, hw_key_idx
, iv32
, iv16
);
421 trace_drv_get_tkip_seq(local
, hw_key_idx
, iv32
, iv16
);
424 static inline int drv_set_frag_threshold(struct ieee80211_local
*local
,
431 trace_drv_set_frag_threshold(local
, value
);
432 if (local
->ops
->set_frag_threshold
)
433 ret
= local
->ops
->set_frag_threshold(&local
->hw
, value
);
434 trace_drv_return_int(local
, ret
);
438 static inline int drv_set_rts_threshold(struct ieee80211_local
*local
,
445 trace_drv_set_rts_threshold(local
, value
);
446 if (local
->ops
->set_rts_threshold
)
447 ret
= local
->ops
->set_rts_threshold(&local
->hw
, value
);
448 trace_drv_return_int(local
, ret
);
452 static inline int drv_set_coverage_class(struct ieee80211_local
*local
,
458 trace_drv_set_coverage_class(local
, value
);
459 if (local
->ops
->set_coverage_class
)
460 local
->ops
->set_coverage_class(&local
->hw
, value
);
464 trace_drv_return_int(local
, ret
);
468 static inline void drv_sta_notify(struct ieee80211_local
*local
,
469 struct ieee80211_sub_if_data
*sdata
,
470 enum sta_notify_cmd cmd
,
471 struct ieee80211_sta
*sta
)
473 sdata
= get_bss_sdata(sdata
);
474 if (!check_sdata_in_driver(sdata
))
477 trace_drv_sta_notify(local
, sdata
, cmd
, sta
);
478 if (local
->ops
->sta_notify
)
479 local
->ops
->sta_notify(&local
->hw
, &sdata
->vif
, cmd
, sta
);
480 trace_drv_return_void(local
);
483 static inline int drv_sta_add(struct ieee80211_local
*local
,
484 struct ieee80211_sub_if_data
*sdata
,
485 struct ieee80211_sta
*sta
)
491 sdata
= get_bss_sdata(sdata
);
492 if (!check_sdata_in_driver(sdata
))
495 trace_drv_sta_add(local
, sdata
, sta
);
496 if (local
->ops
->sta_add
)
497 ret
= local
->ops
->sta_add(&local
->hw
, &sdata
->vif
, sta
);
499 trace_drv_return_int(local
, ret
);
504 static inline void drv_sta_remove(struct ieee80211_local
*local
,
505 struct ieee80211_sub_if_data
*sdata
,
506 struct ieee80211_sta
*sta
)
510 sdata
= get_bss_sdata(sdata
);
511 if (!check_sdata_in_driver(sdata
))
514 trace_drv_sta_remove(local
, sdata
, sta
);
515 if (local
->ops
->sta_remove
)
516 local
->ops
->sta_remove(&local
->hw
, &sdata
->vif
, sta
);
518 trace_drv_return_void(local
);
521 #ifdef CONFIG_MAC80211_DEBUGFS
522 static inline void drv_sta_add_debugfs(struct ieee80211_local
*local
,
523 struct ieee80211_sub_if_data
*sdata
,
524 struct ieee80211_sta
*sta
,
529 sdata
= get_bss_sdata(sdata
);
530 if (!check_sdata_in_driver(sdata
))
533 if (local
->ops
->sta_add_debugfs
)
534 local
->ops
->sta_add_debugfs(&local
->hw
, &sdata
->vif
,
538 static inline void drv_sta_remove_debugfs(struct ieee80211_local
*local
,
539 struct ieee80211_sub_if_data
*sdata
,
540 struct ieee80211_sta
*sta
,
545 sdata
= get_bss_sdata(sdata
);
546 check_sdata_in_driver(sdata
);
548 if (local
->ops
->sta_remove_debugfs
)
549 local
->ops
->sta_remove_debugfs(&local
->hw
, &sdata
->vif
,
554 static inline void drv_sta_pre_rcu_remove(struct ieee80211_local
*local
,
555 struct ieee80211_sub_if_data
*sdata
,
556 struct sta_info
*sta
)
560 sdata
= get_bss_sdata(sdata
);
561 if (!check_sdata_in_driver(sdata
))
564 trace_drv_sta_pre_rcu_remove(local
, sdata
, &sta
->sta
);
565 if (local
->ops
->sta_pre_rcu_remove
)
566 local
->ops
->sta_pre_rcu_remove(&local
->hw
, &sdata
->vif
,
568 trace_drv_return_void(local
);
571 static inline __must_check
572 int drv_sta_state(struct ieee80211_local
*local
,
573 struct ieee80211_sub_if_data
*sdata
,
574 struct sta_info
*sta
,
575 enum ieee80211_sta_state old_state
,
576 enum ieee80211_sta_state new_state
)
582 sdata
= get_bss_sdata(sdata
);
583 if (!check_sdata_in_driver(sdata
))
586 trace_drv_sta_state(local
, sdata
, &sta
->sta
, old_state
, new_state
);
587 if (local
->ops
->sta_state
) {
588 ret
= local
->ops
->sta_state(&local
->hw
, &sdata
->vif
, &sta
->sta
,
589 old_state
, new_state
);
590 } else if (old_state
== IEEE80211_STA_AUTH
&&
591 new_state
== IEEE80211_STA_ASSOC
) {
592 ret
= drv_sta_add(local
, sdata
, &sta
->sta
);
594 sta
->uploaded
= true;
595 } else if (old_state
== IEEE80211_STA_ASSOC
&&
596 new_state
== IEEE80211_STA_AUTH
) {
597 drv_sta_remove(local
, sdata
, &sta
->sta
);
599 trace_drv_return_int(local
, ret
);
603 static inline void drv_sta_rc_update(struct ieee80211_local
*local
,
604 struct ieee80211_sub_if_data
*sdata
,
605 struct ieee80211_sta
*sta
, u32 changed
)
607 sdata
= get_bss_sdata(sdata
);
608 if (!check_sdata_in_driver(sdata
))
611 WARN_ON(changed
& IEEE80211_RC_SUPP_RATES_CHANGED
&&
612 (sdata
->vif
.type
!= NL80211_IFTYPE_ADHOC
&&
613 sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
));
615 trace_drv_sta_rc_update(local
, sdata
, sta
, changed
);
616 if (local
->ops
->sta_rc_update
)
617 local
->ops
->sta_rc_update(&local
->hw
, &sdata
->vif
,
620 trace_drv_return_void(local
);
623 static inline int drv_conf_tx(struct ieee80211_local
*local
,
624 struct ieee80211_sub_if_data
*sdata
, u16 ac
,
625 const struct ieee80211_tx_queue_params
*params
)
627 int ret
= -EOPNOTSUPP
;
631 if (!check_sdata_in_driver(sdata
))
634 if (WARN_ONCE(params
->cw_min
== 0 ||
635 params
->cw_min
> params
->cw_max
,
636 "%s: invalid CW_min/CW_max: %d/%d\n",
637 sdata
->name
, params
->cw_min
, params
->cw_max
))
640 trace_drv_conf_tx(local
, sdata
, ac
, params
);
641 if (local
->ops
->conf_tx
)
642 ret
= local
->ops
->conf_tx(&local
->hw
, &sdata
->vif
,
644 trace_drv_return_int(local
, ret
);
648 static inline u64
drv_get_tsf(struct ieee80211_local
*local
,
649 struct ieee80211_sub_if_data
*sdata
)
655 if (!check_sdata_in_driver(sdata
))
658 trace_drv_get_tsf(local
, sdata
);
659 if (local
->ops
->get_tsf
)
660 ret
= local
->ops
->get_tsf(&local
->hw
, &sdata
->vif
);
661 trace_drv_return_u64(local
, ret
);
665 static inline void drv_set_tsf(struct ieee80211_local
*local
,
666 struct ieee80211_sub_if_data
*sdata
,
671 if (!check_sdata_in_driver(sdata
))
674 trace_drv_set_tsf(local
, sdata
, tsf
);
675 if (local
->ops
->set_tsf
)
676 local
->ops
->set_tsf(&local
->hw
, &sdata
->vif
, tsf
);
677 trace_drv_return_void(local
);
680 static inline void drv_reset_tsf(struct ieee80211_local
*local
,
681 struct ieee80211_sub_if_data
*sdata
)
685 if (!check_sdata_in_driver(sdata
))
688 trace_drv_reset_tsf(local
, sdata
);
689 if (local
->ops
->reset_tsf
)
690 local
->ops
->reset_tsf(&local
->hw
, &sdata
->vif
);
691 trace_drv_return_void(local
);
694 static inline int drv_tx_last_beacon(struct ieee80211_local
*local
)
696 int ret
= 0; /* default unsupported op for less congestion */
700 trace_drv_tx_last_beacon(local
);
701 if (local
->ops
->tx_last_beacon
)
702 ret
= local
->ops
->tx_last_beacon(&local
->hw
);
703 trace_drv_return_int(local
, ret
);
707 static inline int drv_ampdu_action(struct ieee80211_local
*local
,
708 struct ieee80211_sub_if_data
*sdata
,
709 enum ieee80211_ampdu_mlme_action action
,
710 struct ieee80211_sta
*sta
, u16 tid
,
711 u16
*ssn
, u8 buf_size
)
713 int ret
= -EOPNOTSUPP
;
717 sdata
= get_bss_sdata(sdata
);
718 if (!check_sdata_in_driver(sdata
))
721 trace_drv_ampdu_action(local
, sdata
, action
, sta
, tid
, ssn
, buf_size
);
723 if (local
->ops
->ampdu_action
)
724 ret
= local
->ops
->ampdu_action(&local
->hw
, &sdata
->vif
, action
,
725 sta
, tid
, ssn
, buf_size
);
727 trace_drv_return_int(local
, ret
);
732 static inline int drv_get_survey(struct ieee80211_local
*local
, int idx
,
733 struct survey_info
*survey
)
735 int ret
= -EOPNOTSUPP
;
737 trace_drv_get_survey(local
, idx
, survey
);
739 if (local
->ops
->get_survey
)
740 ret
= local
->ops
->get_survey(&local
->hw
, idx
, survey
);
742 trace_drv_return_int(local
, ret
);
747 static inline void drv_rfkill_poll(struct ieee80211_local
*local
)
751 if (local
->ops
->rfkill_poll
)
752 local
->ops
->rfkill_poll(&local
->hw
);
755 static inline void drv_flush(struct ieee80211_local
*local
,
756 struct ieee80211_sub_if_data
*sdata
,
757 u32 queues
, bool drop
)
759 struct ieee80211_vif
*vif
= sdata
? &sdata
->vif
: NULL
;
763 if (sdata
&& !check_sdata_in_driver(sdata
))
766 trace_drv_flush(local
, queues
, drop
);
767 if (local
->ops
->flush
)
768 local
->ops
->flush(&local
->hw
, vif
, queues
, drop
);
769 trace_drv_return_void(local
);
772 static inline void drv_channel_switch(struct ieee80211_local
*local
,
773 struct ieee80211_sub_if_data
*sdata
,
774 struct ieee80211_channel_switch
*ch_switch
)
778 trace_drv_channel_switch(local
, sdata
, ch_switch
);
779 local
->ops
->channel_switch(&local
->hw
, &sdata
->vif
, ch_switch
);
780 trace_drv_return_void(local
);
784 static inline int drv_set_antenna(struct ieee80211_local
*local
,
785 u32 tx_ant
, u32 rx_ant
)
787 int ret
= -EOPNOTSUPP
;
789 if (local
->ops
->set_antenna
)
790 ret
= local
->ops
->set_antenna(&local
->hw
, tx_ant
, rx_ant
);
791 trace_drv_set_antenna(local
, tx_ant
, rx_ant
, ret
);
795 static inline int drv_get_antenna(struct ieee80211_local
*local
,
796 u32
*tx_ant
, u32
*rx_ant
)
798 int ret
= -EOPNOTSUPP
;
800 if (local
->ops
->get_antenna
)
801 ret
= local
->ops
->get_antenna(&local
->hw
, tx_ant
, rx_ant
);
802 trace_drv_get_antenna(local
, *tx_ant
, *rx_ant
, ret
);
806 static inline int drv_remain_on_channel(struct ieee80211_local
*local
,
807 struct ieee80211_sub_if_data
*sdata
,
808 struct ieee80211_channel
*chan
,
809 unsigned int duration
,
810 enum ieee80211_roc_type type
)
816 trace_drv_remain_on_channel(local
, sdata
, chan
, duration
, type
);
817 ret
= local
->ops
->remain_on_channel(&local
->hw
, &sdata
->vif
,
818 chan
, duration
, type
);
819 trace_drv_return_int(local
, ret
);
824 static inline int drv_cancel_remain_on_channel(struct ieee80211_local
*local
)
830 trace_drv_cancel_remain_on_channel(local
);
831 ret
= local
->ops
->cancel_remain_on_channel(&local
->hw
);
832 trace_drv_return_int(local
, ret
);
837 static inline int drv_set_ringparam(struct ieee80211_local
*local
,
844 trace_drv_set_ringparam(local
, tx
, rx
);
845 if (local
->ops
->set_ringparam
)
846 ret
= local
->ops
->set_ringparam(&local
->hw
, tx
, rx
);
847 trace_drv_return_int(local
, ret
);
852 static inline void drv_get_ringparam(struct ieee80211_local
*local
,
853 u32
*tx
, u32
*tx_max
, u32
*rx
, u32
*rx_max
)
857 trace_drv_get_ringparam(local
, tx
, tx_max
, rx
, rx_max
);
858 if (local
->ops
->get_ringparam
)
859 local
->ops
->get_ringparam(&local
->hw
, tx
, tx_max
, rx
, rx_max
);
860 trace_drv_return_void(local
);
863 static inline bool drv_tx_frames_pending(struct ieee80211_local
*local
)
869 trace_drv_tx_frames_pending(local
);
870 if (local
->ops
->tx_frames_pending
)
871 ret
= local
->ops
->tx_frames_pending(&local
->hw
);
872 trace_drv_return_bool(local
, ret
);
877 static inline int drv_set_bitrate_mask(struct ieee80211_local
*local
,
878 struct ieee80211_sub_if_data
*sdata
,
879 const struct cfg80211_bitrate_mask
*mask
)
881 int ret
= -EOPNOTSUPP
;
885 if (!check_sdata_in_driver(sdata
))
888 trace_drv_set_bitrate_mask(local
, sdata
, mask
);
889 if (local
->ops
->set_bitrate_mask
)
890 ret
= local
->ops
->set_bitrate_mask(&local
->hw
,
892 trace_drv_return_int(local
, ret
);
897 static inline void drv_set_rekey_data(struct ieee80211_local
*local
,
898 struct ieee80211_sub_if_data
*sdata
,
899 struct cfg80211_gtk_rekey_data
*data
)
901 if (!check_sdata_in_driver(sdata
))
904 trace_drv_set_rekey_data(local
, sdata
, data
);
905 if (local
->ops
->set_rekey_data
)
906 local
->ops
->set_rekey_data(&local
->hw
, &sdata
->vif
, data
);
907 trace_drv_return_void(local
);
910 static inline void drv_rssi_callback(struct ieee80211_local
*local
,
911 struct ieee80211_sub_if_data
*sdata
,
912 const enum ieee80211_rssi_event event
)
914 trace_drv_rssi_callback(local
, sdata
, event
);
915 if (local
->ops
->rssi_callback
)
916 local
->ops
->rssi_callback(&local
->hw
, &sdata
->vif
, event
);
917 trace_drv_return_void(local
);
921 drv_release_buffered_frames(struct ieee80211_local
*local
,
922 struct sta_info
*sta
, u16 tids
, int num_frames
,
923 enum ieee80211_frame_release_type reason
,
926 trace_drv_release_buffered_frames(local
, &sta
->sta
, tids
, num_frames
,
928 if (local
->ops
->release_buffered_frames
)
929 local
->ops
->release_buffered_frames(&local
->hw
, &sta
->sta
, tids
,
932 trace_drv_return_void(local
);
936 drv_allow_buffered_frames(struct ieee80211_local
*local
,
937 struct sta_info
*sta
, u16 tids
, int num_frames
,
938 enum ieee80211_frame_release_type reason
,
941 trace_drv_allow_buffered_frames(local
, &sta
->sta
, tids
, num_frames
,
943 if (local
->ops
->allow_buffered_frames
)
944 local
->ops
->allow_buffered_frames(&local
->hw
, &sta
->sta
,
945 tids
, num_frames
, reason
,
947 trace_drv_return_void(local
);
950 static inline int drv_get_rssi(struct ieee80211_local
*local
,
951 struct ieee80211_sub_if_data
*sdata
,
952 struct ieee80211_sta
*sta
,
959 ret
= local
->ops
->get_rssi(&local
->hw
, &sdata
->vif
, sta
, rssi_dbm
);
960 trace_drv_get_rssi(local
, sta
, *rssi_dbm
, ret
);
965 static inline void drv_mgd_prepare_tx(struct ieee80211_local
*local
,
966 struct ieee80211_sub_if_data
*sdata
)
970 if (!check_sdata_in_driver(sdata
))
972 WARN_ON_ONCE(sdata
->vif
.type
!= NL80211_IFTYPE_STATION
);
974 trace_drv_mgd_prepare_tx(local
, sdata
);
975 if (local
->ops
->mgd_prepare_tx
)
976 local
->ops
->mgd_prepare_tx(&local
->hw
, &sdata
->vif
);
977 trace_drv_return_void(local
);
981 drv_mgd_protect_tdls_discover(struct ieee80211_local
*local
,
982 struct ieee80211_sub_if_data
*sdata
)
986 if (!check_sdata_in_driver(sdata
))
988 WARN_ON_ONCE(sdata
->vif
.type
!= NL80211_IFTYPE_STATION
);
990 trace_drv_mgd_protect_tdls_discover(local
, sdata
);
991 if (local
->ops
->mgd_protect_tdls_discover
)
992 local
->ops
->mgd_protect_tdls_discover(&local
->hw
, &sdata
->vif
);
993 trace_drv_return_void(local
);
996 static inline int drv_add_chanctx(struct ieee80211_local
*local
,
997 struct ieee80211_chanctx
*ctx
)
999 int ret
= -EOPNOTSUPP
;
1001 trace_drv_add_chanctx(local
, ctx
);
1002 if (local
->ops
->add_chanctx
)
1003 ret
= local
->ops
->add_chanctx(&local
->hw
, &ctx
->conf
);
1004 trace_drv_return_int(local
, ret
);
1006 ctx
->driver_present
= true;
1011 static inline void drv_remove_chanctx(struct ieee80211_local
*local
,
1012 struct ieee80211_chanctx
*ctx
)
1014 if (WARN_ON(!ctx
->driver_present
))
1017 trace_drv_remove_chanctx(local
, ctx
);
1018 if (local
->ops
->remove_chanctx
)
1019 local
->ops
->remove_chanctx(&local
->hw
, &ctx
->conf
);
1020 trace_drv_return_void(local
);
1021 ctx
->driver_present
= false;
1024 static inline void drv_change_chanctx(struct ieee80211_local
*local
,
1025 struct ieee80211_chanctx
*ctx
,
1028 trace_drv_change_chanctx(local
, ctx
, changed
);
1029 if (local
->ops
->change_chanctx
) {
1030 WARN_ON_ONCE(!ctx
->driver_present
);
1031 local
->ops
->change_chanctx(&local
->hw
, &ctx
->conf
, changed
);
1033 trace_drv_return_void(local
);
1036 static inline int drv_assign_vif_chanctx(struct ieee80211_local
*local
,
1037 struct ieee80211_sub_if_data
*sdata
,
1038 struct ieee80211_chanctx
*ctx
)
1042 if (!check_sdata_in_driver(sdata
))
1045 trace_drv_assign_vif_chanctx(local
, sdata
, ctx
);
1046 if (local
->ops
->assign_vif_chanctx
) {
1047 WARN_ON_ONCE(!ctx
->driver_present
);
1048 ret
= local
->ops
->assign_vif_chanctx(&local
->hw
,
1052 trace_drv_return_int(local
, ret
);
1057 static inline void drv_unassign_vif_chanctx(struct ieee80211_local
*local
,
1058 struct ieee80211_sub_if_data
*sdata
,
1059 struct ieee80211_chanctx
*ctx
)
1061 if (!check_sdata_in_driver(sdata
))
1064 trace_drv_unassign_vif_chanctx(local
, sdata
, ctx
);
1065 if (local
->ops
->unassign_vif_chanctx
) {
1066 WARN_ON_ONCE(!ctx
->driver_present
);
1067 local
->ops
->unassign_vif_chanctx(&local
->hw
,
1071 trace_drv_return_void(local
);
1075 drv_switch_vif_chanctx(struct ieee80211_local
*local
,
1076 struct ieee80211_vif_chanctx_switch
*vifs
,
1078 enum ieee80211_chanctx_switch_mode mode
)
1083 if (!local
->ops
->switch_vif_chanctx
)
1086 for (i
= 0; i
< n_vifs
; i
++) {
1087 struct ieee80211_chanctx
*new_ctx
=
1088 container_of(vifs
[i
].new_ctx
,
1089 struct ieee80211_chanctx
,
1091 struct ieee80211_chanctx
*old_ctx
=
1092 container_of(vifs
[i
].old_ctx
,
1093 struct ieee80211_chanctx
,
1096 WARN_ON_ONCE(!old_ctx
->driver_present
);
1097 WARN_ON_ONCE((mode
== CHANCTX_SWMODE_SWAP_CONTEXTS
&&
1098 new_ctx
->driver_present
) ||
1099 (mode
== CHANCTX_SWMODE_REASSIGN_VIF
&&
1100 !new_ctx
->driver_present
));
1103 trace_drv_switch_vif_chanctx(local
, vifs
, n_vifs
, mode
);
1104 ret
= local
->ops
->switch_vif_chanctx(&local
->hw
,
1105 vifs
, n_vifs
, mode
);
1106 trace_drv_return_int(local
, ret
);
1108 if (!ret
&& mode
== CHANCTX_SWMODE_SWAP_CONTEXTS
) {
1109 for (i
= 0; i
< n_vifs
; i
++) {
1110 struct ieee80211_chanctx
*new_ctx
=
1111 container_of(vifs
[i
].new_ctx
,
1112 struct ieee80211_chanctx
,
1114 struct ieee80211_chanctx
*old_ctx
=
1115 container_of(vifs
[i
].old_ctx
,
1116 struct ieee80211_chanctx
,
1119 new_ctx
->driver_present
= true;
1120 old_ctx
->driver_present
= false;
1127 static inline int drv_start_ap(struct ieee80211_local
*local
,
1128 struct ieee80211_sub_if_data
*sdata
)
1132 if (!check_sdata_in_driver(sdata
))
1135 trace_drv_start_ap(local
, sdata
, &sdata
->vif
.bss_conf
);
1136 if (local
->ops
->start_ap
)
1137 ret
= local
->ops
->start_ap(&local
->hw
, &sdata
->vif
);
1138 trace_drv_return_int(local
, ret
);
1142 static inline void drv_stop_ap(struct ieee80211_local
*local
,
1143 struct ieee80211_sub_if_data
*sdata
)
1145 if (!check_sdata_in_driver(sdata
))
1148 trace_drv_stop_ap(local
, sdata
);
1149 if (local
->ops
->stop_ap
)
1150 local
->ops
->stop_ap(&local
->hw
, &sdata
->vif
);
1151 trace_drv_return_void(local
);
1154 static inline void drv_restart_complete(struct ieee80211_local
*local
)
1158 trace_drv_restart_complete(local
);
1159 if (local
->ops
->restart_complete
)
1160 local
->ops
->restart_complete(&local
->hw
);
1161 trace_drv_return_void(local
);
1165 drv_set_default_unicast_key(struct ieee80211_local
*local
,
1166 struct ieee80211_sub_if_data
*sdata
,
1169 if (!check_sdata_in_driver(sdata
))
1172 WARN_ON_ONCE(key_idx
< -1 || key_idx
> 3);
1174 trace_drv_set_default_unicast_key(local
, sdata
, key_idx
);
1175 if (local
->ops
->set_default_unicast_key
)
1176 local
->ops
->set_default_unicast_key(&local
->hw
, &sdata
->vif
,
1178 trace_drv_return_void(local
);
1181 #if IS_ENABLED(CONFIG_IPV6)
1182 static inline void drv_ipv6_addr_change(struct ieee80211_local
*local
,
1183 struct ieee80211_sub_if_data
*sdata
,
1184 struct inet6_dev
*idev
)
1186 trace_drv_ipv6_addr_change(local
, sdata
);
1187 if (local
->ops
->ipv6_addr_change
)
1188 local
->ops
->ipv6_addr_change(&local
->hw
, &sdata
->vif
, idev
);
1189 trace_drv_return_void(local
);
1194 drv_channel_switch_beacon(struct ieee80211_sub_if_data
*sdata
,
1195 struct cfg80211_chan_def
*chandef
)
1197 struct ieee80211_local
*local
= sdata
->local
;
1199 if (local
->ops
->channel_switch_beacon
) {
1200 trace_drv_channel_switch_beacon(local
, sdata
, chandef
);
1201 local
->ops
->channel_switch_beacon(&local
->hw
, &sdata
->vif
,
1207 drv_pre_channel_switch(struct ieee80211_sub_if_data
*sdata
,
1208 struct ieee80211_channel_switch
*ch_switch
)
1210 struct ieee80211_local
*local
= sdata
->local
;
1213 if (!check_sdata_in_driver(sdata
))
1216 trace_drv_pre_channel_switch(local
, sdata
, ch_switch
);
1217 if (local
->ops
->pre_channel_switch
)
1218 ret
= local
->ops
->pre_channel_switch(&local
->hw
, &sdata
->vif
,
1220 trace_drv_return_int(local
, ret
);
1225 drv_post_channel_switch(struct ieee80211_sub_if_data
*sdata
)
1227 struct ieee80211_local
*local
= sdata
->local
;
1230 if (!check_sdata_in_driver(sdata
))
1233 trace_drv_post_channel_switch(local
, sdata
);
1234 if (local
->ops
->post_channel_switch
)
1235 ret
= local
->ops
->post_channel_switch(&local
->hw
, &sdata
->vif
);
1236 trace_drv_return_int(local
, ret
);
1240 static inline int drv_join_ibss(struct ieee80211_local
*local
,
1241 struct ieee80211_sub_if_data
*sdata
)
1246 if (!check_sdata_in_driver(sdata
))
1249 trace_drv_join_ibss(local
, sdata
, &sdata
->vif
.bss_conf
);
1250 if (local
->ops
->join_ibss
)
1251 ret
= local
->ops
->join_ibss(&local
->hw
, &sdata
->vif
);
1252 trace_drv_return_int(local
, ret
);
1256 static inline void drv_leave_ibss(struct ieee80211_local
*local
,
1257 struct ieee80211_sub_if_data
*sdata
)
1260 if (!check_sdata_in_driver(sdata
))
1263 trace_drv_leave_ibss(local
, sdata
);
1264 if (local
->ops
->leave_ibss
)
1265 local
->ops
->leave_ibss(&local
->hw
, &sdata
->vif
);
1266 trace_drv_return_void(local
);
1269 static inline u32
drv_get_expected_throughput(struct ieee80211_local
*local
,
1270 struct ieee80211_sta
*sta
)
1274 trace_drv_get_expected_throughput(sta
);
1275 if (local
->ops
->get_expected_throughput
)
1276 ret
= local
->ops
->get_expected_throughput(sta
);
1277 trace_drv_return_u32(local
, ret
);
1282 #endif /* __MAC80211_DRIVER_OPS */