1 #ifndef __MAC80211_DRIVER_OPS
2 #define __MAC80211_DRIVER_OPS
4 #include <net/mac80211.h>
5 #include "ieee80211_i.h"
6 #include "driver-trace.h"
8 static inline void check_sdata_in_driver(struct ieee80211_sub_if_data
*sdata
)
10 WARN(!(sdata
->flags
& IEEE80211_SDATA_IN_DRIVER
),
11 "%s: Failed check-sdata-in-driver check, flags: 0x%x\n",
12 sdata
->dev
->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
, struct sk_buff
*skb
)
27 local
->ops
->tx(&local
->hw
, skb
);
30 static inline void drv_tx_frags(struct ieee80211_local
*local
,
31 struct ieee80211_vif
*vif
,
32 struct ieee80211_sta
*sta
,
33 struct sk_buff_head
*skbs
)
35 local
->ops
->tx_frags(&local
->hw
, vif
, sta
, skbs
);
38 static inline int drv_start(struct ieee80211_local
*local
)
44 trace_drv_start(local
);
45 local
->started
= true;
47 ret
= local
->ops
->start(&local
->hw
);
48 trace_drv_return_int(local
, ret
);
52 static inline void drv_stop(struct ieee80211_local
*local
)
56 trace_drv_stop(local
);
57 local
->ops
->stop(&local
->hw
);
58 trace_drv_return_void(local
);
60 /* sync away all work on the tasklet before clearing started */
61 tasklet_disable(&local
->tasklet
);
62 tasklet_enable(&local
->tasklet
);
66 local
->started
= false;
70 static inline int drv_suspend(struct ieee80211_local
*local
,
71 struct cfg80211_wowlan
*wowlan
)
77 trace_drv_suspend(local
);
78 ret
= local
->ops
->suspend(&local
->hw
, wowlan
);
79 trace_drv_return_int(local
, ret
);
83 static inline int drv_resume(struct ieee80211_local
*local
)
89 trace_drv_resume(local
);
90 ret
= local
->ops
->resume(&local
->hw
);
91 trace_drv_return_int(local
, ret
);
96 static inline int drv_add_interface(struct ieee80211_local
*local
,
97 struct ieee80211_sub_if_data
*sdata
)
103 if (WARN_ON(sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
||
104 (sdata
->vif
.type
== NL80211_IFTYPE_MONITOR
&&
105 !(local
->hw
.flags
& IEEE80211_HW_WANT_MONITOR_VIF
))))
108 trace_drv_add_interface(local
, sdata
);
109 ret
= local
->ops
->add_interface(&local
->hw
, &sdata
->vif
);
110 trace_drv_return_int(local
, ret
);
113 sdata
->flags
|= IEEE80211_SDATA_IN_DRIVER
;
118 static inline int drv_change_interface(struct ieee80211_local
*local
,
119 struct ieee80211_sub_if_data
*sdata
,
120 enum nl80211_iftype type
, bool p2p
)
126 check_sdata_in_driver(sdata
);
128 trace_drv_change_interface(local
, sdata
, type
, p2p
);
129 ret
= local
->ops
->change_interface(&local
->hw
, &sdata
->vif
, type
, p2p
);
130 trace_drv_return_int(local
, ret
);
134 static inline void drv_remove_interface(struct ieee80211_local
*local
,
135 struct ieee80211_sub_if_data
*sdata
)
139 check_sdata_in_driver(sdata
);
141 trace_drv_remove_interface(local
, sdata
);
142 local
->ops
->remove_interface(&local
->hw
, &sdata
->vif
);
143 sdata
->flags
&= ~IEEE80211_SDATA_IN_DRIVER
;
144 trace_drv_return_void(local
);
147 static inline int drv_config(struct ieee80211_local
*local
, u32 changed
)
153 trace_drv_config(local
, changed
);
154 ret
= local
->ops
->config(&local
->hw
, changed
);
155 trace_drv_return_int(local
, ret
);
159 static inline void drv_bss_info_changed(struct ieee80211_local
*local
,
160 struct ieee80211_sub_if_data
*sdata
,
161 struct ieee80211_bss_conf
*info
,
166 check_sdata_in_driver(sdata
);
168 trace_drv_bss_info_changed(local
, sdata
, info
, changed
);
169 if (local
->ops
->bss_info_changed
)
170 local
->ops
->bss_info_changed(&local
->hw
, &sdata
->vif
, info
, changed
);
171 trace_drv_return_void(local
);
174 static inline u64
drv_prepare_multicast(struct ieee80211_local
*local
,
175 struct netdev_hw_addr_list
*mc_list
)
179 trace_drv_prepare_multicast(local
, mc_list
->count
);
181 if (local
->ops
->prepare_multicast
)
182 ret
= local
->ops
->prepare_multicast(&local
->hw
, mc_list
);
184 trace_drv_return_u64(local
, ret
);
189 static inline void drv_configure_filter(struct ieee80211_local
*local
,
190 unsigned int changed_flags
,
191 unsigned int *total_flags
,
196 trace_drv_configure_filter(local
, changed_flags
, total_flags
,
198 local
->ops
->configure_filter(&local
->hw
, changed_flags
, total_flags
,
200 trace_drv_return_void(local
);
203 static inline int drv_set_tim(struct ieee80211_local
*local
,
204 struct ieee80211_sta
*sta
, bool set
)
207 trace_drv_set_tim(local
, sta
, set
);
208 if (local
->ops
->set_tim
)
209 ret
= local
->ops
->set_tim(&local
->hw
, sta
, set
);
210 trace_drv_return_int(local
, ret
);
214 static inline int drv_set_key(struct ieee80211_local
*local
,
215 enum set_key_cmd cmd
,
216 struct ieee80211_sub_if_data
*sdata
,
217 struct ieee80211_sta
*sta
,
218 struct ieee80211_key_conf
*key
)
224 sdata
= get_bss_sdata(sdata
);
225 check_sdata_in_driver(sdata
);
227 trace_drv_set_key(local
, cmd
, sdata
, sta
, key
);
228 ret
= local
->ops
->set_key(&local
->hw
, cmd
, &sdata
->vif
, sta
, key
);
229 trace_drv_return_int(local
, ret
);
233 static inline void drv_update_tkip_key(struct ieee80211_local
*local
,
234 struct ieee80211_sub_if_data
*sdata
,
235 struct ieee80211_key_conf
*conf
,
236 struct sta_info
*sta
, u32 iv32
,
239 struct ieee80211_sta
*ista
= NULL
;
244 sdata
= get_bss_sdata(sdata
);
245 check_sdata_in_driver(sdata
);
247 trace_drv_update_tkip_key(local
, sdata
, conf
, ista
, iv32
);
248 if (local
->ops
->update_tkip_key
)
249 local
->ops
->update_tkip_key(&local
->hw
, &sdata
->vif
, conf
,
250 ista
, iv32
, phase1key
);
251 trace_drv_return_void(local
);
254 static inline int drv_hw_scan(struct ieee80211_local
*local
,
255 struct ieee80211_sub_if_data
*sdata
,
256 struct cfg80211_scan_request
*req
)
262 check_sdata_in_driver(sdata
);
264 trace_drv_hw_scan(local
, sdata
);
265 ret
= local
->ops
->hw_scan(&local
->hw
, &sdata
->vif
, req
);
266 trace_drv_return_int(local
, ret
);
270 static inline void drv_cancel_hw_scan(struct ieee80211_local
*local
,
271 struct ieee80211_sub_if_data
*sdata
)
275 check_sdata_in_driver(sdata
);
277 trace_drv_cancel_hw_scan(local
, sdata
);
278 local
->ops
->cancel_hw_scan(&local
->hw
, &sdata
->vif
);
279 trace_drv_return_void(local
);
283 drv_sched_scan_start(struct ieee80211_local
*local
,
284 struct ieee80211_sub_if_data
*sdata
,
285 struct cfg80211_sched_scan_request
*req
,
286 struct ieee80211_sched_scan_ies
*ies
)
292 check_sdata_in_driver(sdata
);
294 trace_drv_sched_scan_start(local
, sdata
);
295 ret
= local
->ops
->sched_scan_start(&local
->hw
, &sdata
->vif
,
297 trace_drv_return_int(local
, ret
);
301 static inline void drv_sched_scan_stop(struct ieee80211_local
*local
,
302 struct ieee80211_sub_if_data
*sdata
)
306 check_sdata_in_driver(sdata
);
308 trace_drv_sched_scan_stop(local
, sdata
);
309 local
->ops
->sched_scan_stop(&local
->hw
, &sdata
->vif
);
310 trace_drv_return_void(local
);
313 static inline void drv_sw_scan_start(struct ieee80211_local
*local
)
317 trace_drv_sw_scan_start(local
);
318 if (local
->ops
->sw_scan_start
)
319 local
->ops
->sw_scan_start(&local
->hw
);
320 trace_drv_return_void(local
);
323 static inline void drv_sw_scan_complete(struct ieee80211_local
*local
)
327 trace_drv_sw_scan_complete(local
);
328 if (local
->ops
->sw_scan_complete
)
329 local
->ops
->sw_scan_complete(&local
->hw
);
330 trace_drv_return_void(local
);
333 static inline int drv_get_stats(struct ieee80211_local
*local
,
334 struct ieee80211_low_level_stats
*stats
)
336 int ret
= -EOPNOTSUPP
;
340 if (local
->ops
->get_stats
)
341 ret
= local
->ops
->get_stats(&local
->hw
, stats
);
342 trace_drv_get_stats(local
, stats
, ret
);
347 static inline void drv_get_tkip_seq(struct ieee80211_local
*local
,
348 u8 hw_key_idx
, u32
*iv32
, u16
*iv16
)
350 if (local
->ops
->get_tkip_seq
)
351 local
->ops
->get_tkip_seq(&local
->hw
, hw_key_idx
, iv32
, iv16
);
352 trace_drv_get_tkip_seq(local
, hw_key_idx
, iv32
, iv16
);
355 static inline int drv_set_frag_threshold(struct ieee80211_local
*local
,
362 trace_drv_set_frag_threshold(local
, value
);
363 if (local
->ops
->set_frag_threshold
)
364 ret
= local
->ops
->set_frag_threshold(&local
->hw
, value
);
365 trace_drv_return_int(local
, ret
);
369 static inline int drv_set_rts_threshold(struct ieee80211_local
*local
,
376 trace_drv_set_rts_threshold(local
, value
);
377 if (local
->ops
->set_rts_threshold
)
378 ret
= local
->ops
->set_rts_threshold(&local
->hw
, value
);
379 trace_drv_return_int(local
, ret
);
383 static inline int drv_set_coverage_class(struct ieee80211_local
*local
,
389 trace_drv_set_coverage_class(local
, value
);
390 if (local
->ops
->set_coverage_class
)
391 local
->ops
->set_coverage_class(&local
->hw
, value
);
395 trace_drv_return_int(local
, ret
);
399 static inline void drv_sta_notify(struct ieee80211_local
*local
,
400 struct ieee80211_sub_if_data
*sdata
,
401 enum sta_notify_cmd cmd
,
402 struct ieee80211_sta
*sta
)
404 sdata
= get_bss_sdata(sdata
);
405 check_sdata_in_driver(sdata
);
407 trace_drv_sta_notify(local
, sdata
, cmd
, sta
);
408 if (local
->ops
->sta_notify
)
409 local
->ops
->sta_notify(&local
->hw
, &sdata
->vif
, cmd
, sta
);
410 trace_drv_return_void(local
);
413 static inline int drv_sta_add(struct ieee80211_local
*local
,
414 struct ieee80211_sub_if_data
*sdata
,
415 struct ieee80211_sta
*sta
)
421 sdata
= get_bss_sdata(sdata
);
422 check_sdata_in_driver(sdata
);
424 trace_drv_sta_add(local
, sdata
, sta
);
425 if (local
->ops
->sta_add
)
426 ret
= local
->ops
->sta_add(&local
->hw
, &sdata
->vif
, sta
);
428 trace_drv_return_int(local
, ret
);
433 static inline void drv_sta_remove(struct ieee80211_local
*local
,
434 struct ieee80211_sub_if_data
*sdata
,
435 struct ieee80211_sta
*sta
)
439 sdata
= get_bss_sdata(sdata
);
440 check_sdata_in_driver(sdata
);
442 trace_drv_sta_remove(local
, sdata
, sta
);
443 if (local
->ops
->sta_remove
)
444 local
->ops
->sta_remove(&local
->hw
, &sdata
->vif
, sta
);
446 trace_drv_return_void(local
);
449 static inline __must_check
450 int drv_sta_state(struct ieee80211_local
*local
,
451 struct ieee80211_sub_if_data
*sdata
,
452 struct sta_info
*sta
,
453 enum ieee80211_sta_state old_state
,
454 enum ieee80211_sta_state new_state
)
460 sdata
= get_bss_sdata(sdata
);
461 check_sdata_in_driver(sdata
);
463 trace_drv_sta_state(local
, sdata
, &sta
->sta
, old_state
, new_state
);
464 if (local
->ops
->sta_state
) {
465 ret
= local
->ops
->sta_state(&local
->hw
, &sdata
->vif
, &sta
->sta
,
466 old_state
, new_state
);
467 } else if (old_state
== IEEE80211_STA_AUTH
&&
468 new_state
== IEEE80211_STA_ASSOC
) {
469 ret
= drv_sta_add(local
, sdata
, &sta
->sta
);
471 sta
->uploaded
= true;
472 } else if (old_state
== IEEE80211_STA_ASSOC
&&
473 new_state
== IEEE80211_STA_AUTH
) {
474 drv_sta_remove(local
, sdata
, &sta
->sta
);
476 trace_drv_return_int(local
, ret
);
480 static inline void drv_sta_rc_update(struct ieee80211_local
*local
,
481 struct ieee80211_sub_if_data
*sdata
,
482 struct ieee80211_sta
*sta
, u32 changed
)
484 sdata
= get_bss_sdata(sdata
);
485 check_sdata_in_driver(sdata
);
487 trace_drv_sta_rc_update(local
, sdata
, sta
, changed
);
488 if (local
->ops
->sta_rc_update
)
489 local
->ops
->sta_rc_update(&local
->hw
, &sdata
->vif
,
492 trace_drv_return_void(local
);
495 static inline int drv_conf_tx(struct ieee80211_local
*local
,
496 struct ieee80211_sub_if_data
*sdata
, u16 ac
,
497 const struct ieee80211_tx_queue_params
*params
)
499 int ret
= -EOPNOTSUPP
;
503 check_sdata_in_driver(sdata
);
505 trace_drv_conf_tx(local
, sdata
, ac
, params
);
506 if (local
->ops
->conf_tx
)
507 ret
= local
->ops
->conf_tx(&local
->hw
, &sdata
->vif
,
509 trace_drv_return_int(local
, ret
);
513 static inline u64
drv_get_tsf(struct ieee80211_local
*local
,
514 struct ieee80211_sub_if_data
*sdata
)
520 check_sdata_in_driver(sdata
);
522 trace_drv_get_tsf(local
, sdata
);
523 if (local
->ops
->get_tsf
)
524 ret
= local
->ops
->get_tsf(&local
->hw
, &sdata
->vif
);
525 trace_drv_return_u64(local
, ret
);
529 static inline void drv_set_tsf(struct ieee80211_local
*local
,
530 struct ieee80211_sub_if_data
*sdata
,
535 check_sdata_in_driver(sdata
);
537 trace_drv_set_tsf(local
, sdata
, tsf
);
538 if (local
->ops
->set_tsf
)
539 local
->ops
->set_tsf(&local
->hw
, &sdata
->vif
, tsf
);
540 trace_drv_return_void(local
);
543 static inline void drv_reset_tsf(struct ieee80211_local
*local
,
544 struct ieee80211_sub_if_data
*sdata
)
548 check_sdata_in_driver(sdata
);
550 trace_drv_reset_tsf(local
, sdata
);
551 if (local
->ops
->reset_tsf
)
552 local
->ops
->reset_tsf(&local
->hw
, &sdata
->vif
);
553 trace_drv_return_void(local
);
556 static inline int drv_tx_last_beacon(struct ieee80211_local
*local
)
558 int ret
= 0; /* default unsuported op for less congestion */
562 trace_drv_tx_last_beacon(local
);
563 if (local
->ops
->tx_last_beacon
)
564 ret
= local
->ops
->tx_last_beacon(&local
->hw
);
565 trace_drv_return_int(local
, ret
);
569 static inline int drv_ampdu_action(struct ieee80211_local
*local
,
570 struct ieee80211_sub_if_data
*sdata
,
571 enum ieee80211_ampdu_mlme_action action
,
572 struct ieee80211_sta
*sta
, u16 tid
,
573 u16
*ssn
, u8 buf_size
)
575 int ret
= -EOPNOTSUPP
;
579 sdata
= get_bss_sdata(sdata
);
580 check_sdata_in_driver(sdata
);
582 trace_drv_ampdu_action(local
, sdata
, action
, sta
, tid
, ssn
, buf_size
);
584 if (local
->ops
->ampdu_action
)
585 ret
= local
->ops
->ampdu_action(&local
->hw
, &sdata
->vif
, action
,
586 sta
, tid
, ssn
, buf_size
);
588 trace_drv_return_int(local
, ret
);
593 static inline int drv_get_survey(struct ieee80211_local
*local
, int idx
,
594 struct survey_info
*survey
)
596 int ret
= -EOPNOTSUPP
;
598 trace_drv_get_survey(local
, idx
, survey
);
600 if (local
->ops
->get_survey
)
601 ret
= local
->ops
->get_survey(&local
->hw
, idx
, survey
);
603 trace_drv_return_int(local
, ret
);
608 static inline void drv_rfkill_poll(struct ieee80211_local
*local
)
612 if (local
->ops
->rfkill_poll
)
613 local
->ops
->rfkill_poll(&local
->hw
);
616 static inline void drv_flush(struct ieee80211_local
*local
, bool drop
)
620 trace_drv_flush(local
, drop
);
621 if (local
->ops
->flush
)
622 local
->ops
->flush(&local
->hw
, drop
);
623 trace_drv_return_void(local
);
626 static inline void drv_channel_switch(struct ieee80211_local
*local
,
627 struct ieee80211_channel_switch
*ch_switch
)
631 trace_drv_channel_switch(local
, ch_switch
);
632 local
->ops
->channel_switch(&local
->hw
, ch_switch
);
633 trace_drv_return_void(local
);
637 static inline int drv_set_antenna(struct ieee80211_local
*local
,
638 u32 tx_ant
, u32 rx_ant
)
640 int ret
= -EOPNOTSUPP
;
642 if (local
->ops
->set_antenna
)
643 ret
= local
->ops
->set_antenna(&local
->hw
, tx_ant
, rx_ant
);
644 trace_drv_set_antenna(local
, tx_ant
, rx_ant
, ret
);
648 static inline int drv_get_antenna(struct ieee80211_local
*local
,
649 u32
*tx_ant
, u32
*rx_ant
)
651 int ret
= -EOPNOTSUPP
;
653 if (local
->ops
->get_antenna
)
654 ret
= local
->ops
->get_antenna(&local
->hw
, tx_ant
, rx_ant
);
655 trace_drv_get_antenna(local
, *tx_ant
, *rx_ant
, ret
);
659 static inline int drv_remain_on_channel(struct ieee80211_local
*local
,
660 struct ieee80211_channel
*chan
,
661 enum nl80211_channel_type chantype
,
662 unsigned int duration
)
668 trace_drv_remain_on_channel(local
, chan
, chantype
, duration
);
669 ret
= local
->ops
->remain_on_channel(&local
->hw
, chan
, chantype
,
671 trace_drv_return_int(local
, ret
);
676 static inline int drv_cancel_remain_on_channel(struct ieee80211_local
*local
)
682 trace_drv_cancel_remain_on_channel(local
);
683 ret
= local
->ops
->cancel_remain_on_channel(&local
->hw
);
684 trace_drv_return_int(local
, ret
);
689 static inline int drv_set_ringparam(struct ieee80211_local
*local
,
696 trace_drv_set_ringparam(local
, tx
, rx
);
697 if (local
->ops
->set_ringparam
)
698 ret
= local
->ops
->set_ringparam(&local
->hw
, tx
, rx
);
699 trace_drv_return_int(local
, ret
);
704 static inline void drv_get_ringparam(struct ieee80211_local
*local
,
705 u32
*tx
, u32
*tx_max
, u32
*rx
, u32
*rx_max
)
709 trace_drv_get_ringparam(local
, tx
, tx_max
, rx
, rx_max
);
710 if (local
->ops
->get_ringparam
)
711 local
->ops
->get_ringparam(&local
->hw
, tx
, tx_max
, rx
, rx_max
);
712 trace_drv_return_void(local
);
715 static inline bool drv_tx_frames_pending(struct ieee80211_local
*local
)
721 trace_drv_tx_frames_pending(local
);
722 if (local
->ops
->tx_frames_pending
)
723 ret
= local
->ops
->tx_frames_pending(&local
->hw
);
724 trace_drv_return_bool(local
, ret
);
729 static inline int drv_set_bitrate_mask(struct ieee80211_local
*local
,
730 struct ieee80211_sub_if_data
*sdata
,
731 const struct cfg80211_bitrate_mask
*mask
)
733 int ret
= -EOPNOTSUPP
;
737 check_sdata_in_driver(sdata
);
739 trace_drv_set_bitrate_mask(local
, sdata
, mask
);
740 if (local
->ops
->set_bitrate_mask
)
741 ret
= local
->ops
->set_bitrate_mask(&local
->hw
,
743 trace_drv_return_int(local
, ret
);
748 static inline void drv_set_rekey_data(struct ieee80211_local
*local
,
749 struct ieee80211_sub_if_data
*sdata
,
750 struct cfg80211_gtk_rekey_data
*data
)
752 check_sdata_in_driver(sdata
);
754 trace_drv_set_rekey_data(local
, sdata
, data
);
755 if (local
->ops
->set_rekey_data
)
756 local
->ops
->set_rekey_data(&local
->hw
, &sdata
->vif
, data
);
757 trace_drv_return_void(local
);
760 static inline void drv_rssi_callback(struct ieee80211_local
*local
,
761 const enum ieee80211_rssi_event event
)
763 trace_drv_rssi_callback(local
, event
);
764 if (local
->ops
->rssi_callback
)
765 local
->ops
->rssi_callback(&local
->hw
, event
);
766 trace_drv_return_void(local
);
770 drv_release_buffered_frames(struct ieee80211_local
*local
,
771 struct sta_info
*sta
, u16 tids
, int num_frames
,
772 enum ieee80211_frame_release_type reason
,
775 trace_drv_release_buffered_frames(local
, &sta
->sta
, tids
, num_frames
,
777 if (local
->ops
->release_buffered_frames
)
778 local
->ops
->release_buffered_frames(&local
->hw
, &sta
->sta
, tids
,
781 trace_drv_return_void(local
);
785 drv_allow_buffered_frames(struct ieee80211_local
*local
,
786 struct sta_info
*sta
, u16 tids
, int num_frames
,
787 enum ieee80211_frame_release_type reason
,
790 trace_drv_allow_buffered_frames(local
, &sta
->sta
, tids
, num_frames
,
792 if (local
->ops
->allow_buffered_frames
)
793 local
->ops
->allow_buffered_frames(&local
->hw
, &sta
->sta
,
794 tids
, num_frames
, reason
,
796 trace_drv_return_void(local
);
798 #endif /* __MAC80211_DRIVER_OPS */