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 !ieee80211_hw_check(&local->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 void drv_config_iface_filter(struct ieee80211_local *local,
264 struct ieee80211_sub_if_data *sdata,
265 unsigned int filter_flags,
266 unsigned int changed_flags)
270 trace_drv_config_iface_filter(local, sdata, filter_flags,
272 if (local->ops->config_iface_filter)
273 local->ops->config_iface_filter(&local->hw, &sdata->vif,
276 trace_drv_return_void(local);
279 static inline int drv_set_tim(struct ieee80211_local *local,
280 struct ieee80211_sta *sta, bool set)
283 trace_drv_set_tim(local, sta, set);
284 if (local->ops->set_tim)
285 ret = local->ops->set_tim(&local->hw, sta, set);
286 trace_drv_return_int(local, ret);
290 static inline int drv_set_key(struct ieee80211_local *local,
291 enum set_key_cmd cmd,
292 struct ieee80211_sub_if_data *sdata,
293 struct ieee80211_sta *sta,
294 struct ieee80211_key_conf *key)
300 sdata = get_bss_sdata(sdata);
301 if (!check_sdata_in_driver(sdata))
304 trace_drv_set_key(local, cmd, sdata, sta, key);
305 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
306 trace_drv_return_int(local, ret);
310 static inline void drv_update_tkip_key(struct ieee80211_local *local,
311 struct ieee80211_sub_if_data *sdata,
312 struct ieee80211_key_conf *conf,
313 struct sta_info *sta, u32 iv32,
316 struct ieee80211_sta *ista = NULL;
321 sdata = get_bss_sdata(sdata);
322 if (!check_sdata_in_driver(sdata))
325 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
326 if (local->ops->update_tkip_key)
327 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
328 ista, iv32, phase1key);
329 trace_drv_return_void(local);
332 static inline int drv_hw_scan(struct ieee80211_local *local,
333 struct ieee80211_sub_if_data *sdata,
334 struct ieee80211_scan_request *req)
340 if (!check_sdata_in_driver(sdata))
343 trace_drv_hw_scan(local, sdata);
344 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
345 trace_drv_return_int(local, ret);
349 static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
350 struct ieee80211_sub_if_data *sdata)
354 if (!check_sdata_in_driver(sdata))
357 trace_drv_cancel_hw_scan(local, sdata);
358 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
359 trace_drv_return_void(local);
363 drv_sched_scan_start(struct ieee80211_local *local,
364 struct ieee80211_sub_if_data *sdata,
365 struct cfg80211_sched_scan_request *req,
366 struct ieee80211_scan_ies *ies)
372 if (!check_sdata_in_driver(sdata))
375 trace_drv_sched_scan_start(local, sdata);
376 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
378 trace_drv_return_int(local, ret);
382 static inline int drv_sched_scan_stop(struct ieee80211_local *local,
383 struct ieee80211_sub_if_data *sdata)
389 if (!check_sdata_in_driver(sdata))
392 trace_drv_sched_scan_stop(local, sdata);
393 ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
394 trace_drv_return_int(local, ret);
399 static inline void drv_sw_scan_start(struct ieee80211_local *local,
400 struct ieee80211_sub_if_data *sdata,
405 trace_drv_sw_scan_start(local, sdata, mac_addr);
406 if (local->ops->sw_scan_start)
407 local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
408 trace_drv_return_void(local);
411 static inline void drv_sw_scan_complete(struct ieee80211_local *local,
412 struct ieee80211_sub_if_data *sdata)
416 trace_drv_sw_scan_complete(local, sdata);
417 if (local->ops->sw_scan_complete)
418 local->ops->sw_scan_complete(&local->hw, &sdata->vif);
419 trace_drv_return_void(local);
422 static inline int drv_get_stats(struct ieee80211_local *local,
423 struct ieee80211_low_level_stats *stats)
425 int ret = -EOPNOTSUPP;
429 if (local->ops->get_stats)
430 ret = local->ops->get_stats(&local->hw, stats);
431 trace_drv_get_stats(local, stats, ret);
436 static inline void drv_get_key_seq(struct ieee80211_local *local,
437 struct ieee80211_key *key,
438 struct ieee80211_key_seq *seq)
440 if (local->ops->get_key_seq)
441 local->ops->get_key_seq(&local->hw, &key->conf, seq);
442 trace_drv_get_key_seq(local, &key->conf);
445 static inline int drv_set_frag_threshold(struct ieee80211_local *local,
452 trace_drv_set_frag_threshold(local, value);
453 if (local->ops->set_frag_threshold)
454 ret = local->ops->set_frag_threshold(&local->hw, value);
455 trace_drv_return_int(local, ret);
459 static inline int drv_set_rts_threshold(struct ieee80211_local *local,
466 trace_drv_set_rts_threshold(local, value);
467 if (local->ops->set_rts_threshold)
468 ret = local->ops->set_rts_threshold(&local->hw, value);
469 trace_drv_return_int(local, ret);
473 static inline int drv_set_coverage_class(struct ieee80211_local *local,
479 trace_drv_set_coverage_class(local, value);
480 if (local->ops->set_coverage_class)
481 local->ops->set_coverage_class(&local->hw, value);
485 trace_drv_return_int(local, ret);
489 static inline void drv_sta_notify(struct ieee80211_local *local,
490 struct ieee80211_sub_if_data *sdata,
491 enum sta_notify_cmd cmd,
492 struct ieee80211_sta *sta)
494 sdata = get_bss_sdata(sdata);
495 if (!check_sdata_in_driver(sdata))
498 trace_drv_sta_notify(local, sdata, cmd, sta);
499 if (local->ops->sta_notify)
500 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
501 trace_drv_return_void(local);
504 static inline int drv_sta_add(struct ieee80211_local *local,
505 struct ieee80211_sub_if_data *sdata,
506 struct ieee80211_sta *sta)
512 sdata = get_bss_sdata(sdata);
513 if (!check_sdata_in_driver(sdata))
516 trace_drv_sta_add(local, sdata, sta);
517 if (local->ops->sta_add)
518 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
520 trace_drv_return_int(local, ret);
525 static inline void drv_sta_remove(struct ieee80211_local *local,
526 struct ieee80211_sub_if_data *sdata,
527 struct ieee80211_sta *sta)
531 sdata = get_bss_sdata(sdata);
532 if (!check_sdata_in_driver(sdata))
535 trace_drv_sta_remove(local, sdata, sta);
536 if (local->ops->sta_remove)
537 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
539 trace_drv_return_void(local);
542 #ifdef CONFIG_MAC80211_DEBUGFS
543 static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
544 struct ieee80211_sub_if_data *sdata,
545 struct ieee80211_sta *sta,
550 sdata = get_bss_sdata(sdata);
551 if (!check_sdata_in_driver(sdata))
554 if (local->ops->sta_add_debugfs)
555 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
559 static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
560 struct ieee80211_sub_if_data *sdata,
561 struct ieee80211_sta *sta,
566 sdata = get_bss_sdata(sdata);
567 check_sdata_in_driver(sdata);
569 if (local->ops->sta_remove_debugfs)
570 local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
575 static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
576 struct ieee80211_sub_if_data *sdata,
577 struct sta_info *sta)
581 sdata = get_bss_sdata(sdata);
582 if (!check_sdata_in_driver(sdata))
585 trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
586 if (local->ops->sta_pre_rcu_remove)
587 local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
589 trace_drv_return_void(local);
593 int drv_sta_state(struct ieee80211_local *local,
594 struct ieee80211_sub_if_data *sdata,
595 struct sta_info *sta,
596 enum ieee80211_sta_state old_state,
597 enum ieee80211_sta_state new_state);
599 static inline void drv_sta_rc_update(struct ieee80211_local *local,
600 struct ieee80211_sub_if_data *sdata,
601 struct ieee80211_sta *sta, u32 changed)
603 sdata = get_bss_sdata(sdata);
604 if (!check_sdata_in_driver(sdata))
607 WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED &&
608 (sdata->vif.type != NL80211_IFTYPE_ADHOC &&
609 sdata->vif.type != NL80211_IFTYPE_MESH_POINT));
611 trace_drv_sta_rc_update(local, sdata, sta, changed);
612 if (local->ops->sta_rc_update)
613 local->ops->sta_rc_update(&local->hw, &sdata->vif,
616 trace_drv_return_void(local);
619 static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
620 struct ieee80211_sub_if_data *sdata,
621 struct ieee80211_sta *sta)
623 sdata = get_bss_sdata(sdata);
624 if (!check_sdata_in_driver(sdata))
627 trace_drv_sta_rate_tbl_update(local, sdata, sta);
628 if (local->ops->sta_rate_tbl_update)
629 local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
631 trace_drv_return_void(local);
634 static inline void drv_sta_statistics(struct ieee80211_local *local,
635 struct ieee80211_sub_if_data *sdata,
636 struct ieee80211_sta *sta,
637 struct station_info *sinfo)
639 sdata = get_bss_sdata(sdata);
640 if (!check_sdata_in_driver(sdata))
643 trace_drv_sta_statistics(local, sdata, sta);
644 if (local->ops->sta_statistics)
645 local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
646 trace_drv_return_void(local);
649 int drv_conf_tx(struct ieee80211_local *local,
650 struct ieee80211_sub_if_data *sdata, u16 ac,
651 const struct ieee80211_tx_queue_params *params);
653 static inline u64 drv_get_tsf(struct ieee80211_local *local,
654 struct ieee80211_sub_if_data *sdata)
660 if (!check_sdata_in_driver(sdata))
663 trace_drv_get_tsf(local, sdata);
664 if (local->ops->get_tsf)
665 ret = local->ops->get_tsf(&local->hw, &sdata->vif);
666 trace_drv_return_u64(local, ret);
670 static inline void drv_set_tsf(struct ieee80211_local *local,
671 struct ieee80211_sub_if_data *sdata,
676 if (!check_sdata_in_driver(sdata))
679 trace_drv_set_tsf(local, sdata, tsf);
680 if (local->ops->set_tsf)
681 local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
682 trace_drv_return_void(local);
685 static inline void drv_reset_tsf(struct ieee80211_local *local,
686 struct ieee80211_sub_if_data *sdata)
690 if (!check_sdata_in_driver(sdata))
693 trace_drv_reset_tsf(local, sdata);
694 if (local->ops->reset_tsf)
695 local->ops->reset_tsf(&local->hw, &sdata->vif);
696 trace_drv_return_void(local);
699 static inline int drv_tx_last_beacon(struct ieee80211_local *local)
701 int ret = 0; /* default unsupported op for less congestion */
705 trace_drv_tx_last_beacon(local);
706 if (local->ops->tx_last_beacon)
707 ret = local->ops->tx_last_beacon(&local->hw);
708 trace_drv_return_int(local, ret);
712 static inline int drv_ampdu_action(struct ieee80211_local *local,
713 struct ieee80211_sub_if_data *sdata,
714 enum ieee80211_ampdu_mlme_action action,
715 struct ieee80211_sta *sta, u16 tid,
716 u16 *ssn, u8 buf_size, bool amsdu)
718 int ret = -EOPNOTSUPP;
722 sdata = get_bss_sdata(sdata);
723 if (!check_sdata_in_driver(sdata))
726 trace_drv_ampdu_action(local, sdata, action, sta, tid,
727 ssn, buf_size, amsdu);
729 if (local->ops->ampdu_action)
730 ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
731 sta, tid, ssn, buf_size, amsdu);
733 trace_drv_return_int(local, ret);
738 static inline int drv_get_survey(struct ieee80211_local *local, int idx,
739 struct survey_info *survey)
741 int ret = -EOPNOTSUPP;
743 trace_drv_get_survey(local, idx, survey);
745 if (local->ops->get_survey)
746 ret = local->ops->get_survey(&local->hw, idx, survey);
748 trace_drv_return_int(local, ret);
753 static inline void drv_rfkill_poll(struct ieee80211_local *local)
757 if (local->ops->rfkill_poll)
758 local->ops->rfkill_poll(&local->hw);
761 static inline void drv_flush(struct ieee80211_local *local,
762 struct ieee80211_sub_if_data *sdata,
763 u32 queues, bool drop)
765 struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
769 if (sdata && !check_sdata_in_driver(sdata))
772 trace_drv_flush(local, queues, drop);
773 if (local->ops->flush)
774 local->ops->flush(&local->hw, vif, queues, drop);
775 trace_drv_return_void(local);
778 static inline void drv_channel_switch(struct ieee80211_local *local,
779 struct ieee80211_sub_if_data *sdata,
780 struct ieee80211_channel_switch *ch_switch)
784 trace_drv_channel_switch(local, sdata, ch_switch);
785 local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
786 trace_drv_return_void(local);
790 static inline int drv_set_antenna(struct ieee80211_local *local,
791 u32 tx_ant, u32 rx_ant)
793 int ret = -EOPNOTSUPP;
795 if (local->ops->set_antenna)
796 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
797 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
801 static inline int drv_get_antenna(struct ieee80211_local *local,
802 u32 *tx_ant, u32 *rx_ant)
804 int ret = -EOPNOTSUPP;
806 if (local->ops->get_antenna)
807 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
808 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
812 static inline int drv_remain_on_channel(struct ieee80211_local *local,
813 struct ieee80211_sub_if_data *sdata,
814 struct ieee80211_channel *chan,
815 unsigned int duration,
816 enum ieee80211_roc_type type)
822 trace_drv_remain_on_channel(local, sdata, chan, duration, type);
823 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
824 chan, duration, type);
825 trace_drv_return_int(local, ret);
830 static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
836 trace_drv_cancel_remain_on_channel(local);
837 ret = local->ops->cancel_remain_on_channel(&local->hw);
838 trace_drv_return_int(local, ret);
843 static inline int drv_set_ringparam(struct ieee80211_local *local,
850 trace_drv_set_ringparam(local, tx, rx);
851 if (local->ops->set_ringparam)
852 ret = local->ops->set_ringparam(&local->hw, tx, rx);
853 trace_drv_return_int(local, ret);
858 static inline void drv_get_ringparam(struct ieee80211_local *local,
859 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
863 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
864 if (local->ops->get_ringparam)
865 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
866 trace_drv_return_void(local);
869 static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
875 trace_drv_tx_frames_pending(local);
876 if (local->ops->tx_frames_pending)
877 ret = local->ops->tx_frames_pending(&local->hw);
878 trace_drv_return_bool(local, ret);
883 static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
884 struct ieee80211_sub_if_data *sdata,
885 const struct cfg80211_bitrate_mask *mask)
887 int ret = -EOPNOTSUPP;
891 if (!check_sdata_in_driver(sdata))
894 trace_drv_set_bitrate_mask(local, sdata, mask);
895 if (local->ops->set_bitrate_mask)
896 ret = local->ops->set_bitrate_mask(&local->hw,
898 trace_drv_return_int(local, ret);
903 static inline void drv_set_rekey_data(struct ieee80211_local *local,
904 struct ieee80211_sub_if_data *sdata,
905 struct cfg80211_gtk_rekey_data *data)
907 if (!check_sdata_in_driver(sdata))
910 trace_drv_set_rekey_data(local, sdata, data);
911 if (local->ops->set_rekey_data)
912 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
913 trace_drv_return_void(local);
916 static inline void drv_event_callback(struct ieee80211_local *local,
917 struct ieee80211_sub_if_data *sdata,
918 const struct ieee80211_event *event)
920 trace_drv_event_callback(local, sdata, event);
921 if (local->ops->event_callback)
922 local->ops->event_callback(&local->hw, &sdata->vif, event);
923 trace_drv_return_void(local);
927 drv_release_buffered_frames(struct ieee80211_local *local,
928 struct sta_info *sta, u16 tids, int num_frames,
929 enum ieee80211_frame_release_type reason,
932 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
934 if (local->ops->release_buffered_frames)
935 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
938 trace_drv_return_void(local);
942 drv_allow_buffered_frames(struct ieee80211_local *local,
943 struct sta_info *sta, u16 tids, int num_frames,
944 enum ieee80211_frame_release_type reason,
947 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
949 if (local->ops->allow_buffered_frames)
950 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
951 tids, num_frames, reason,
953 trace_drv_return_void(local);
956 static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
957 struct ieee80211_sub_if_data *sdata)
961 if (!check_sdata_in_driver(sdata))
963 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
965 trace_drv_mgd_prepare_tx(local, sdata);
966 if (local->ops->mgd_prepare_tx)
967 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
968 trace_drv_return_void(local);
972 drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
973 struct ieee80211_sub_if_data *sdata)
977 if (!check_sdata_in_driver(sdata))
979 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
981 trace_drv_mgd_protect_tdls_discover(local, sdata);
982 if (local->ops->mgd_protect_tdls_discover)
983 local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
984 trace_drv_return_void(local);
987 static inline int drv_add_chanctx(struct ieee80211_local *local,
988 struct ieee80211_chanctx *ctx)
990 int ret = -EOPNOTSUPP;
992 trace_drv_add_chanctx(local, ctx);
993 if (local->ops->add_chanctx)
994 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
995 trace_drv_return_int(local, ret);
997 ctx->driver_present = true;
1002 static inline void drv_remove_chanctx(struct ieee80211_local *local,
1003 struct ieee80211_chanctx *ctx)
1005 if (WARN_ON(!ctx->driver_present))
1008 trace_drv_remove_chanctx(local, ctx);
1009 if (local->ops->remove_chanctx)
1010 local->ops->remove_chanctx(&local->hw, &ctx->conf);
1011 trace_drv_return_void(local);
1012 ctx->driver_present = false;
1015 static inline void drv_change_chanctx(struct ieee80211_local *local,
1016 struct ieee80211_chanctx *ctx,
1019 trace_drv_change_chanctx(local, ctx, changed);
1020 if (local->ops->change_chanctx) {
1021 WARN_ON_ONCE(!ctx->driver_present);
1022 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
1024 trace_drv_return_void(local);
1027 static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
1028 struct ieee80211_sub_if_data *sdata,
1029 struct ieee80211_chanctx *ctx)
1033 if (!check_sdata_in_driver(sdata))
1036 trace_drv_assign_vif_chanctx(local, sdata, ctx);
1037 if (local->ops->assign_vif_chanctx) {
1038 WARN_ON_ONCE(!ctx->driver_present);
1039 ret = local->ops->assign_vif_chanctx(&local->hw,
1043 trace_drv_return_int(local, ret);
1048 static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
1049 struct ieee80211_sub_if_data *sdata,
1050 struct ieee80211_chanctx *ctx)
1052 if (!check_sdata_in_driver(sdata))
1055 trace_drv_unassign_vif_chanctx(local, sdata, ctx);
1056 if (local->ops->unassign_vif_chanctx) {
1057 WARN_ON_ONCE(!ctx->driver_present);
1058 local->ops->unassign_vif_chanctx(&local->hw,
1062 trace_drv_return_void(local);
1066 drv_switch_vif_chanctx(struct ieee80211_local *local,
1067 struct ieee80211_vif_chanctx_switch *vifs,
1069 enum ieee80211_chanctx_switch_mode mode)
1074 if (!local->ops->switch_vif_chanctx)
1077 for (i = 0; i < n_vifs; i++) {
1078 struct ieee80211_chanctx *new_ctx =
1079 container_of(vifs[i].new_ctx,
1080 struct ieee80211_chanctx,
1082 struct ieee80211_chanctx *old_ctx =
1083 container_of(vifs[i].old_ctx,
1084 struct ieee80211_chanctx,
1087 WARN_ON_ONCE(!old_ctx->driver_present);
1088 WARN_ON_ONCE((mode == CHANCTX_SWMODE_SWAP_CONTEXTS &&
1089 new_ctx->driver_present) ||
1090 (mode == CHANCTX_SWMODE_REASSIGN_VIF &&
1091 !new_ctx->driver_present));
1094 trace_drv_switch_vif_chanctx(local, vifs, n_vifs, mode);
1095 ret = local->ops->switch_vif_chanctx(&local->hw,
1096 vifs, n_vifs, mode);
1097 trace_drv_return_int(local, ret);
1099 if (!ret && mode == CHANCTX_SWMODE_SWAP_CONTEXTS) {
1100 for (i = 0; i < n_vifs; i++) {
1101 struct ieee80211_chanctx *new_ctx =
1102 container_of(vifs[i].new_ctx,
1103 struct ieee80211_chanctx,
1105 struct ieee80211_chanctx *old_ctx =
1106 container_of(vifs[i].old_ctx,
1107 struct ieee80211_chanctx,
1110 new_ctx->driver_present = true;
1111 old_ctx->driver_present = false;
1118 static inline int drv_start_ap(struct ieee80211_local *local,
1119 struct ieee80211_sub_if_data *sdata)
1123 if (!check_sdata_in_driver(sdata))
1126 trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
1127 if (local->ops->start_ap)
1128 ret = local->ops->start_ap(&local->hw, &sdata->vif);
1129 trace_drv_return_int(local, ret);
1133 static inline void drv_stop_ap(struct ieee80211_local *local,
1134 struct ieee80211_sub_if_data *sdata)
1136 if (!check_sdata_in_driver(sdata))
1139 trace_drv_stop_ap(local, sdata);
1140 if (local->ops->stop_ap)
1141 local->ops->stop_ap(&local->hw, &sdata->vif);
1142 trace_drv_return_void(local);
1146 drv_reconfig_complete(struct ieee80211_local *local,
1147 enum ieee80211_reconfig_type reconfig_type)
1151 trace_drv_reconfig_complete(local, reconfig_type);
1152 if (local->ops->reconfig_complete)
1153 local->ops->reconfig_complete(&local->hw, reconfig_type);
1154 trace_drv_return_void(local);
1158 drv_set_default_unicast_key(struct ieee80211_local *local,
1159 struct ieee80211_sub_if_data *sdata,
1162 if (!check_sdata_in_driver(sdata))
1165 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1167 trace_drv_set_default_unicast_key(local, sdata, key_idx);
1168 if (local->ops->set_default_unicast_key)
1169 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1171 trace_drv_return_void(local);
1174 #if IS_ENABLED(CONFIG_IPV6)
1175 static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1176 struct ieee80211_sub_if_data *sdata,
1177 struct inet6_dev *idev)
1179 trace_drv_ipv6_addr_change(local, sdata);
1180 if (local->ops->ipv6_addr_change)
1181 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1182 trace_drv_return_void(local);
1187 drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1188 struct cfg80211_chan_def *chandef)
1190 struct ieee80211_local *local = sdata->local;
1192 if (local->ops->channel_switch_beacon) {
1193 trace_drv_channel_switch_beacon(local, sdata, chandef);
1194 local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1200 drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
1201 struct ieee80211_channel_switch *ch_switch)
1203 struct ieee80211_local *local = sdata->local;
1206 if (!check_sdata_in_driver(sdata))
1209 trace_drv_pre_channel_switch(local, sdata, ch_switch);
1210 if (local->ops->pre_channel_switch)
1211 ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
1213 trace_drv_return_int(local, ret);
1218 drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1220 struct ieee80211_local *local = sdata->local;
1223 if (!check_sdata_in_driver(sdata))
1226 trace_drv_post_channel_switch(local, sdata);
1227 if (local->ops->post_channel_switch)
1228 ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1229 trace_drv_return_int(local, ret);
1233 static inline int drv_join_ibss(struct ieee80211_local *local,
1234 struct ieee80211_sub_if_data *sdata)
1239 if (!check_sdata_in_driver(sdata))
1242 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1243 if (local->ops->join_ibss)
1244 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1245 trace_drv_return_int(local, ret);
1249 static inline void drv_leave_ibss(struct ieee80211_local *local,
1250 struct ieee80211_sub_if_data *sdata)
1253 if (!check_sdata_in_driver(sdata))
1256 trace_drv_leave_ibss(local, sdata);
1257 if (local->ops->leave_ibss)
1258 local->ops->leave_ibss(&local->hw, &sdata->vif);
1259 trace_drv_return_void(local);
1262 static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
1263 struct ieee80211_sta *sta)
1267 trace_drv_get_expected_throughput(sta);
1268 if (local->ops->get_expected_throughput)
1269 ret = local->ops->get_expected_throughput(sta);
1270 trace_drv_return_u32(local, ret);
1275 static inline int drv_get_txpower(struct ieee80211_local *local,
1276 struct ieee80211_sub_if_data *sdata, int *dbm)
1280 if (!local->ops->get_txpower)
1283 ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
1284 trace_drv_get_txpower(local, sdata, *dbm, ret);
1290 drv_tdls_channel_switch(struct ieee80211_local *local,
1291 struct ieee80211_sub_if_data *sdata,
1292 struct ieee80211_sta *sta, u8 oper_class,
1293 struct cfg80211_chan_def *chandef,
1294 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
1299 if (!check_sdata_in_driver(sdata))
1302 if (!local->ops->tdls_channel_switch)
1305 trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
1306 ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
1307 oper_class, chandef, tmpl_skb,
1309 trace_drv_return_int(local, ret);
1314 drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
1315 struct ieee80211_sub_if_data *sdata,
1316 struct ieee80211_sta *sta)
1319 if (!check_sdata_in_driver(sdata))
1322 if (!local->ops->tdls_cancel_channel_switch)
1325 trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
1326 local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
1327 trace_drv_return_void(local);
1331 drv_tdls_recv_channel_switch(struct ieee80211_local *local,
1332 struct ieee80211_sub_if_data *sdata,
1333 struct ieee80211_tdls_ch_sw_params *params)
1335 trace_drv_tdls_recv_channel_switch(local, sdata, params);
1336 if (local->ops->tdls_recv_channel_switch)
1337 local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
1339 trace_drv_return_void(local);
1342 static inline void drv_wake_tx_queue(struct ieee80211_local *local,
1343 struct txq_info *txq)
1345 struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
1347 if (!check_sdata_in_driver(sdata))
1350 trace_drv_wake_tx_queue(local, sdata, txq);
1351 local->ops->wake_tx_queue(&local->hw, &txq->txq);
1354 #endif /* __MAC80211_DRIVER_OPS */