1 #ifndef __MAC80211_DRIVER_OPS
2 #define __MAC80211_DRIVER_OPS
4 #include <net/mac80211.h>
5 #include "ieee80211_i.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 ? 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 check_sdata_in_driver(sdata);
173 trace_drv_change_interface(local, sdata, type, p2p);
174 ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
175 trace_drv_return_int(local, ret);
179 static inline void drv_remove_interface(struct ieee80211_local *local,
180 struct ieee80211_sub_if_data *sdata)
184 check_sdata_in_driver(sdata);
186 trace_drv_remove_interface(local, sdata);
187 local->ops->remove_interface(&local->hw, &sdata->vif);
188 sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER;
189 trace_drv_return_void(local);
192 static inline int drv_config(struct ieee80211_local *local, u32 changed)
198 trace_drv_config(local, changed);
199 ret = local->ops->config(&local->hw, changed);
200 trace_drv_return_int(local, ret);
204 static inline void drv_bss_info_changed(struct ieee80211_local *local,
205 struct ieee80211_sub_if_data *sdata,
206 struct ieee80211_bss_conf *info,
211 if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
212 BSS_CHANGED_BEACON_ENABLED) &&
213 sdata->vif.type != NL80211_IFTYPE_AP &&
214 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
215 sdata->vif.type != NL80211_IFTYPE_MESH_POINT))
218 if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
219 sdata->vif.type == NL80211_IFTYPE_MONITOR))
222 check_sdata_in_driver(sdata);
224 trace_drv_bss_info_changed(local, sdata, info, changed);
225 if (local->ops->bss_info_changed)
226 local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
227 trace_drv_return_void(local);
230 static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
231 struct netdev_hw_addr_list *mc_list)
235 trace_drv_prepare_multicast(local, mc_list->count);
237 if (local->ops->prepare_multicast)
238 ret = local->ops->prepare_multicast(&local->hw, mc_list);
240 trace_drv_return_u64(local, ret);
245 static inline void drv_configure_filter(struct ieee80211_local *local,
246 unsigned int changed_flags,
247 unsigned int *total_flags,
252 trace_drv_configure_filter(local, changed_flags, total_flags,
254 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
256 trace_drv_return_void(local);
259 static inline int drv_set_tim(struct ieee80211_local *local,
260 struct ieee80211_sta *sta, bool set)
263 trace_drv_set_tim(local, sta, set);
264 if (local->ops->set_tim)
265 ret = local->ops->set_tim(&local->hw, sta, set);
266 trace_drv_return_int(local, ret);
270 static inline int drv_set_key(struct ieee80211_local *local,
271 enum set_key_cmd cmd,
272 struct ieee80211_sub_if_data *sdata,
273 struct ieee80211_sta *sta,
274 struct ieee80211_key_conf *key)
280 sdata = get_bss_sdata(sdata);
281 check_sdata_in_driver(sdata);
283 trace_drv_set_key(local, cmd, sdata, sta, key);
284 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
285 trace_drv_return_int(local, ret);
289 static inline void drv_update_tkip_key(struct ieee80211_local *local,
290 struct ieee80211_sub_if_data *sdata,
291 struct ieee80211_key_conf *conf,
292 struct sta_info *sta, u32 iv32,
295 struct ieee80211_sta *ista = NULL;
300 sdata = get_bss_sdata(sdata);
301 check_sdata_in_driver(sdata);
303 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
304 if (local->ops->update_tkip_key)
305 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
306 ista, iv32, phase1key);
307 trace_drv_return_void(local);
310 static inline int drv_hw_scan(struct ieee80211_local *local,
311 struct ieee80211_sub_if_data *sdata,
312 struct cfg80211_scan_request *req)
318 check_sdata_in_driver(sdata);
320 trace_drv_hw_scan(local, sdata);
321 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
322 trace_drv_return_int(local, ret);
326 static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
327 struct ieee80211_sub_if_data *sdata)
331 check_sdata_in_driver(sdata);
333 trace_drv_cancel_hw_scan(local, sdata);
334 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
335 trace_drv_return_void(local);
339 drv_sched_scan_start(struct ieee80211_local *local,
340 struct ieee80211_sub_if_data *sdata,
341 struct cfg80211_sched_scan_request *req,
342 struct ieee80211_sched_scan_ies *ies)
348 check_sdata_in_driver(sdata);
350 trace_drv_sched_scan_start(local, sdata);
351 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
353 trace_drv_return_int(local, ret);
357 static inline void drv_sched_scan_stop(struct ieee80211_local *local,
358 struct ieee80211_sub_if_data *sdata)
362 check_sdata_in_driver(sdata);
364 trace_drv_sched_scan_stop(local, sdata);
365 local->ops->sched_scan_stop(&local->hw, &sdata->vif);
366 trace_drv_return_void(local);
369 static inline void drv_sw_scan_start(struct ieee80211_local *local)
373 trace_drv_sw_scan_start(local);
374 if (local->ops->sw_scan_start)
375 local->ops->sw_scan_start(&local->hw);
376 trace_drv_return_void(local);
379 static inline void drv_sw_scan_complete(struct ieee80211_local *local)
383 trace_drv_sw_scan_complete(local);
384 if (local->ops->sw_scan_complete)
385 local->ops->sw_scan_complete(&local->hw);
386 trace_drv_return_void(local);
389 static inline int drv_get_stats(struct ieee80211_local *local,
390 struct ieee80211_low_level_stats *stats)
392 int ret = -EOPNOTSUPP;
396 if (local->ops->get_stats)
397 ret = local->ops->get_stats(&local->hw, stats);
398 trace_drv_get_stats(local, stats, ret);
403 static inline void drv_get_tkip_seq(struct ieee80211_local *local,
404 u8 hw_key_idx, u32 *iv32, u16 *iv16)
406 if (local->ops->get_tkip_seq)
407 local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
408 trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
411 static inline int drv_set_frag_threshold(struct ieee80211_local *local,
418 trace_drv_set_frag_threshold(local, value);
419 if (local->ops->set_frag_threshold)
420 ret = local->ops->set_frag_threshold(&local->hw, value);
421 trace_drv_return_int(local, ret);
425 static inline int drv_set_rts_threshold(struct ieee80211_local *local,
432 trace_drv_set_rts_threshold(local, value);
433 if (local->ops->set_rts_threshold)
434 ret = local->ops->set_rts_threshold(&local->hw, value);
435 trace_drv_return_int(local, ret);
439 static inline int drv_set_coverage_class(struct ieee80211_local *local,
445 trace_drv_set_coverage_class(local, value);
446 if (local->ops->set_coverage_class)
447 local->ops->set_coverage_class(&local->hw, value);
451 trace_drv_return_int(local, ret);
455 static inline void drv_sta_notify(struct ieee80211_local *local,
456 struct ieee80211_sub_if_data *sdata,
457 enum sta_notify_cmd cmd,
458 struct ieee80211_sta *sta)
460 sdata = get_bss_sdata(sdata);
461 check_sdata_in_driver(sdata);
463 trace_drv_sta_notify(local, sdata, cmd, sta);
464 if (local->ops->sta_notify)
465 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
466 trace_drv_return_void(local);
469 static inline int drv_sta_add(struct ieee80211_local *local,
470 struct ieee80211_sub_if_data *sdata,
471 struct ieee80211_sta *sta)
477 sdata = get_bss_sdata(sdata);
478 check_sdata_in_driver(sdata);
480 trace_drv_sta_add(local, sdata, sta);
481 if (local->ops->sta_add)
482 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
484 trace_drv_return_int(local, ret);
489 static inline void drv_sta_remove(struct ieee80211_local *local,
490 struct ieee80211_sub_if_data *sdata,
491 struct ieee80211_sta *sta)
495 sdata = get_bss_sdata(sdata);
496 check_sdata_in_driver(sdata);
498 trace_drv_sta_remove(local, sdata, sta);
499 if (local->ops->sta_remove)
500 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
502 trace_drv_return_void(local);
505 #ifdef CONFIG_MAC80211_DEBUGFS
506 static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
507 struct ieee80211_sub_if_data *sdata,
508 struct ieee80211_sta *sta,
513 sdata = get_bss_sdata(sdata);
514 check_sdata_in_driver(sdata);
516 if (local->ops->sta_add_debugfs)
517 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
521 static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
522 struct ieee80211_sub_if_data *sdata,
523 struct ieee80211_sta *sta,
528 sdata = get_bss_sdata(sdata);
529 check_sdata_in_driver(sdata);
531 if (local->ops->sta_remove_debugfs)
532 local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
537 static inline __must_check
538 int drv_sta_state(struct ieee80211_local *local,
539 struct ieee80211_sub_if_data *sdata,
540 struct sta_info *sta,
541 enum ieee80211_sta_state old_state,
542 enum ieee80211_sta_state new_state)
548 sdata = get_bss_sdata(sdata);
549 check_sdata_in_driver(sdata);
551 trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
552 if (local->ops->sta_state) {
553 ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta,
554 old_state, new_state);
555 } else if (old_state == IEEE80211_STA_AUTH &&
556 new_state == IEEE80211_STA_ASSOC) {
557 ret = drv_sta_add(local, sdata, &sta->sta);
559 sta->uploaded = true;
560 } else if (old_state == IEEE80211_STA_ASSOC &&
561 new_state == IEEE80211_STA_AUTH) {
562 drv_sta_remove(local, sdata, &sta->sta);
564 trace_drv_return_int(local, ret);
568 static inline void drv_sta_rc_update(struct ieee80211_local *local,
569 struct ieee80211_sub_if_data *sdata,
570 struct ieee80211_sta *sta, u32 changed)
572 sdata = get_bss_sdata(sdata);
573 check_sdata_in_driver(sdata);
575 WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED &&
576 (sdata->vif.type != NL80211_IFTYPE_ADHOC &&
577 sdata->vif.type != NL80211_IFTYPE_MESH_POINT));
579 trace_drv_sta_rc_update(local, sdata, sta, changed);
580 if (local->ops->sta_rc_update)
581 local->ops->sta_rc_update(&local->hw, &sdata->vif,
584 trace_drv_return_void(local);
587 static inline int drv_conf_tx(struct ieee80211_local *local,
588 struct ieee80211_sub_if_data *sdata, u16 ac,
589 const struct ieee80211_tx_queue_params *params)
591 int ret = -EOPNOTSUPP;
595 check_sdata_in_driver(sdata);
597 trace_drv_conf_tx(local, sdata, ac, params);
598 if (local->ops->conf_tx)
599 ret = local->ops->conf_tx(&local->hw, &sdata->vif,
601 trace_drv_return_int(local, ret);
605 static inline u64 drv_get_tsf(struct ieee80211_local *local,
606 struct ieee80211_sub_if_data *sdata)
612 check_sdata_in_driver(sdata);
614 trace_drv_get_tsf(local, sdata);
615 if (local->ops->get_tsf)
616 ret = local->ops->get_tsf(&local->hw, &sdata->vif);
617 trace_drv_return_u64(local, ret);
621 static inline void drv_set_tsf(struct ieee80211_local *local,
622 struct ieee80211_sub_if_data *sdata,
627 check_sdata_in_driver(sdata);
629 trace_drv_set_tsf(local, sdata, tsf);
630 if (local->ops->set_tsf)
631 local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
632 trace_drv_return_void(local);
635 static inline void drv_reset_tsf(struct ieee80211_local *local,
636 struct ieee80211_sub_if_data *sdata)
640 check_sdata_in_driver(sdata);
642 trace_drv_reset_tsf(local, sdata);
643 if (local->ops->reset_tsf)
644 local->ops->reset_tsf(&local->hw, &sdata->vif);
645 trace_drv_return_void(local);
648 static inline int drv_tx_last_beacon(struct ieee80211_local *local)
650 int ret = 0; /* default unsupported op for less congestion */
654 trace_drv_tx_last_beacon(local);
655 if (local->ops->tx_last_beacon)
656 ret = local->ops->tx_last_beacon(&local->hw);
657 trace_drv_return_int(local, ret);
661 static inline int drv_ampdu_action(struct ieee80211_local *local,
662 struct ieee80211_sub_if_data *sdata,
663 enum ieee80211_ampdu_mlme_action action,
664 struct ieee80211_sta *sta, u16 tid,
665 u16 *ssn, u8 buf_size)
667 int ret = -EOPNOTSUPP;
671 sdata = get_bss_sdata(sdata);
672 check_sdata_in_driver(sdata);
674 trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
676 if (local->ops->ampdu_action)
677 ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
678 sta, tid, ssn, buf_size);
680 trace_drv_return_int(local, ret);
685 static inline int drv_get_survey(struct ieee80211_local *local, int idx,
686 struct survey_info *survey)
688 int ret = -EOPNOTSUPP;
690 trace_drv_get_survey(local, idx, survey);
692 if (local->ops->get_survey)
693 ret = local->ops->get_survey(&local->hw, idx, survey);
695 trace_drv_return_int(local, ret);
700 static inline void drv_rfkill_poll(struct ieee80211_local *local)
704 if (local->ops->rfkill_poll)
705 local->ops->rfkill_poll(&local->hw);
708 static inline void drv_flush(struct ieee80211_local *local,
709 u32 queues, bool drop)
713 trace_drv_flush(local, queues, drop);
714 if (local->ops->flush)
715 local->ops->flush(&local->hw, queues, drop);
716 trace_drv_return_void(local);
719 static inline void drv_channel_switch(struct ieee80211_local *local,
720 struct ieee80211_channel_switch *ch_switch)
724 trace_drv_channel_switch(local, ch_switch);
725 local->ops->channel_switch(&local->hw, ch_switch);
726 trace_drv_return_void(local);
730 static inline int drv_set_antenna(struct ieee80211_local *local,
731 u32 tx_ant, u32 rx_ant)
733 int ret = -EOPNOTSUPP;
735 if (local->ops->set_antenna)
736 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
737 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
741 static inline int drv_get_antenna(struct ieee80211_local *local,
742 u32 *tx_ant, u32 *rx_ant)
744 int ret = -EOPNOTSUPP;
746 if (local->ops->get_antenna)
747 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
748 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
752 static inline int drv_remain_on_channel(struct ieee80211_local *local,
753 struct ieee80211_sub_if_data *sdata,
754 struct ieee80211_channel *chan,
755 unsigned int duration,
756 enum ieee80211_roc_type type)
762 trace_drv_remain_on_channel(local, sdata, chan, duration, type);
763 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
764 chan, duration, type);
765 trace_drv_return_int(local, ret);
770 static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
776 trace_drv_cancel_remain_on_channel(local);
777 ret = local->ops->cancel_remain_on_channel(&local->hw);
778 trace_drv_return_int(local, ret);
783 static inline int drv_set_ringparam(struct ieee80211_local *local,
790 trace_drv_set_ringparam(local, tx, rx);
791 if (local->ops->set_ringparam)
792 ret = local->ops->set_ringparam(&local->hw, tx, rx);
793 trace_drv_return_int(local, ret);
798 static inline void drv_get_ringparam(struct ieee80211_local *local,
799 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
803 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
804 if (local->ops->get_ringparam)
805 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
806 trace_drv_return_void(local);
809 static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
815 trace_drv_tx_frames_pending(local);
816 if (local->ops->tx_frames_pending)
817 ret = local->ops->tx_frames_pending(&local->hw);
818 trace_drv_return_bool(local, ret);
823 static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
824 struct ieee80211_sub_if_data *sdata,
825 const struct cfg80211_bitrate_mask *mask)
827 int ret = -EOPNOTSUPP;
831 check_sdata_in_driver(sdata);
833 trace_drv_set_bitrate_mask(local, sdata, mask);
834 if (local->ops->set_bitrate_mask)
835 ret = local->ops->set_bitrate_mask(&local->hw,
837 trace_drv_return_int(local, ret);
842 static inline void drv_set_rekey_data(struct ieee80211_local *local,
843 struct ieee80211_sub_if_data *sdata,
844 struct cfg80211_gtk_rekey_data *data)
846 check_sdata_in_driver(sdata);
848 trace_drv_set_rekey_data(local, sdata, data);
849 if (local->ops->set_rekey_data)
850 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
851 trace_drv_return_void(local);
854 static inline void drv_rssi_callback(struct ieee80211_local *local,
855 struct ieee80211_sub_if_data *sdata,
856 const enum ieee80211_rssi_event event)
858 trace_drv_rssi_callback(local, sdata, event);
859 if (local->ops->rssi_callback)
860 local->ops->rssi_callback(&local->hw, &sdata->vif, event);
861 trace_drv_return_void(local);
865 drv_release_buffered_frames(struct ieee80211_local *local,
866 struct sta_info *sta, u16 tids, int num_frames,
867 enum ieee80211_frame_release_type reason,
870 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
872 if (local->ops->release_buffered_frames)
873 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
876 trace_drv_return_void(local);
880 drv_allow_buffered_frames(struct ieee80211_local *local,
881 struct sta_info *sta, u16 tids, int num_frames,
882 enum ieee80211_frame_release_type reason,
885 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
887 if (local->ops->allow_buffered_frames)
888 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
889 tids, num_frames, reason,
891 trace_drv_return_void(local);
894 static inline int drv_get_rssi(struct ieee80211_local *local,
895 struct ieee80211_sub_if_data *sdata,
896 struct ieee80211_sta *sta,
903 ret = local->ops->get_rssi(&local->hw, &sdata->vif, sta, rssi_dbm);
904 trace_drv_get_rssi(local, sta, *rssi_dbm, ret);
909 static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
910 struct ieee80211_sub_if_data *sdata)
914 check_sdata_in_driver(sdata);
915 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
917 trace_drv_mgd_prepare_tx(local, sdata);
918 if (local->ops->mgd_prepare_tx)
919 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
920 trace_drv_return_void(local);
923 static inline int drv_add_chanctx(struct ieee80211_local *local,
924 struct ieee80211_chanctx *ctx)
926 int ret = -EOPNOTSUPP;
928 trace_drv_add_chanctx(local, ctx);
929 if (local->ops->add_chanctx)
930 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
931 trace_drv_return_int(local, ret);
933 ctx->driver_present = true;
938 static inline void drv_remove_chanctx(struct ieee80211_local *local,
939 struct ieee80211_chanctx *ctx)
941 trace_drv_remove_chanctx(local, ctx);
942 if (local->ops->remove_chanctx)
943 local->ops->remove_chanctx(&local->hw, &ctx->conf);
944 trace_drv_return_void(local);
945 ctx->driver_present = false;
948 static inline void drv_change_chanctx(struct ieee80211_local *local,
949 struct ieee80211_chanctx *ctx,
952 trace_drv_change_chanctx(local, ctx, changed);
953 if (local->ops->change_chanctx) {
954 WARN_ON_ONCE(!ctx->driver_present);
955 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
957 trace_drv_return_void(local);
960 static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
961 struct ieee80211_sub_if_data *sdata,
962 struct ieee80211_chanctx *ctx)
966 check_sdata_in_driver(sdata);
968 trace_drv_assign_vif_chanctx(local, sdata, ctx);
969 if (local->ops->assign_vif_chanctx) {
970 WARN_ON_ONCE(!ctx->driver_present);
971 ret = local->ops->assign_vif_chanctx(&local->hw,
975 trace_drv_return_int(local, ret);
980 static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
981 struct ieee80211_sub_if_data *sdata,
982 struct ieee80211_chanctx *ctx)
984 check_sdata_in_driver(sdata);
986 trace_drv_unassign_vif_chanctx(local, sdata, ctx);
987 if (local->ops->unassign_vif_chanctx) {
988 WARN_ON_ONCE(!ctx->driver_present);
989 local->ops->unassign_vif_chanctx(&local->hw,
993 trace_drv_return_void(local);
996 static inline int drv_start_ap(struct ieee80211_local *local,
997 struct ieee80211_sub_if_data *sdata)
1001 check_sdata_in_driver(sdata);
1003 trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
1004 if (local->ops->start_ap)
1005 ret = local->ops->start_ap(&local->hw, &sdata->vif);
1006 trace_drv_return_int(local, ret);
1010 static inline void drv_stop_ap(struct ieee80211_local *local,
1011 struct ieee80211_sub_if_data *sdata)
1013 check_sdata_in_driver(sdata);
1015 trace_drv_stop_ap(local, sdata);
1016 if (local->ops->stop_ap)
1017 local->ops->stop_ap(&local->hw, &sdata->vif);
1018 trace_drv_return_void(local);
1021 static inline void drv_restart_complete(struct ieee80211_local *local)
1025 trace_drv_restart_complete(local);
1026 if (local->ops->restart_complete)
1027 local->ops->restart_complete(&local->hw);
1028 trace_drv_return_void(local);
1032 drv_set_default_unicast_key(struct ieee80211_local *local,
1033 struct ieee80211_sub_if_data *sdata,
1036 check_sdata_in_driver(sdata);
1038 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1040 trace_drv_set_default_unicast_key(local, sdata, key_idx);
1041 if (local->ops->set_default_unicast_key)
1042 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1044 trace_drv_return_void(local);
1047 #if IS_ENABLED(CONFIG_IPV6)
1048 static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1049 struct ieee80211_sub_if_data *sdata,
1050 struct inet6_dev *idev)
1052 trace_drv_ipv6_addr_change(local, sdata);
1053 if (local->ops->ipv6_addr_change)
1054 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1055 trace_drv_return_void(local);
1060 drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1061 struct cfg80211_chan_def *chandef)
1063 struct ieee80211_local *local = sdata->local;
1065 if (local->ops->channel_switch_beacon) {
1066 trace_drv_channel_switch_beacon(local, sdata, chandef);
1067 local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1072 static inline int drv_join_ibss(struct ieee80211_local *local,
1073 struct ieee80211_sub_if_data *sdata)
1078 check_sdata_in_driver(sdata);
1080 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1081 if (local->ops->join_ibss)
1082 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1083 trace_drv_return_int(local, ret);
1087 static inline void drv_leave_ibss(struct ieee80211_local *local,
1088 struct ieee80211_sub_if_data *sdata)
1091 check_sdata_in_driver(sdata);
1093 trace_drv_leave_ibss(local, sdata);
1094 if (local->ops->leave_ibss)
1095 local->ops->leave_ibss(&local->hw, &sdata->vif);
1096 trace_drv_return_void(local);
1099 #endif /* __MAC80211_DRIVER_OPS */