1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Portions of this file
4 * Copyright(c) 2016 Intel Deutschland GmbH
5 * Copyright (C) 2018 - 2019, 2021 - 2023 Intel Corporation
8 #ifndef __MAC80211_DRIVER_OPS
9 #define __MAC80211_DRIVER_OPS
11 #include <net/mac80211.h>
12 #include "ieee80211_i.h"
15 #define check_sdata_in_driver(sdata) ({ \
16 WARN_ONCE(!sdata->local->reconfig_failure && \
17 !(sdata->flags & IEEE80211_SDATA_IN_DRIVER), \
18 "%s: Failed check-sdata-in-driver check, flags: 0x%x\n", \
19 sdata->dev ? sdata->dev->name : sdata->name, sdata->flags); \
20 !!(sdata->flags & IEEE80211_SDATA_IN_DRIVER); \
23 static inline struct ieee80211_sub_if_data *
24 get_bss_sdata(struct ieee80211_sub_if_data *sdata)
26 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
27 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
33 static inline void drv_tx(struct ieee80211_local *local,
34 struct ieee80211_tx_control *control,
37 local->ops->tx(&local->hw, control, skb);
40 static inline void drv_sync_rx_queues(struct ieee80211_local *local,
43 if (local->ops->sync_rx_queues) {
44 trace_drv_sync_rx_queues(local, sta->sdata, &sta->sta);
45 local->ops->sync_rx_queues(&local->hw);
46 trace_drv_return_void(local);
50 static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata,
53 struct ieee80211_local *local = sdata->local;
54 if (local->ops->get_et_strings) {
55 trace_drv_get_et_strings(local, sset);
56 local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data);
57 trace_drv_return_void(local);
61 static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata,
62 struct ethtool_stats *stats,
65 struct ieee80211_local *local = sdata->local;
66 if (local->ops->get_et_stats) {
67 trace_drv_get_et_stats(local);
68 local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data);
69 trace_drv_return_void(local);
73 static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata,
76 struct ieee80211_local *local = sdata->local;
78 if (local->ops->get_et_sset_count) {
79 trace_drv_get_et_sset_count(local, sset);
80 rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif,
82 trace_drv_return_int(local, rv);
87 int drv_start(struct ieee80211_local *local);
88 void drv_stop(struct ieee80211_local *local);
91 static inline int drv_suspend(struct ieee80211_local *local,
92 struct cfg80211_wowlan *wowlan)
98 trace_drv_suspend(local);
99 ret = local->ops->suspend(&local->hw, wowlan);
100 trace_drv_return_int(local, ret);
104 static inline int drv_resume(struct ieee80211_local *local)
110 trace_drv_resume(local);
111 ret = local->ops->resume(&local->hw);
112 trace_drv_return_int(local, ret);
116 static inline void drv_set_wakeup(struct ieee80211_local *local,
121 if (!local->ops->set_wakeup)
124 trace_drv_set_wakeup(local, enabled);
125 local->ops->set_wakeup(&local->hw, enabled);
126 trace_drv_return_void(local);
130 int drv_add_interface(struct ieee80211_local *local,
131 struct ieee80211_sub_if_data *sdata);
133 int drv_change_interface(struct ieee80211_local *local,
134 struct ieee80211_sub_if_data *sdata,
135 enum nl80211_iftype type, bool p2p);
137 void drv_remove_interface(struct ieee80211_local *local,
138 struct ieee80211_sub_if_data *sdata);
140 static inline int drv_config(struct ieee80211_local *local, u32 changed)
146 trace_drv_config(local, changed);
147 ret = local->ops->config(&local->hw, changed);
148 trace_drv_return_int(local, ret);
152 static inline void drv_vif_cfg_changed(struct ieee80211_local *local,
153 struct ieee80211_sub_if_data *sdata,
158 if (!check_sdata_in_driver(sdata))
161 trace_drv_vif_cfg_changed(local, sdata, changed);
162 if (local->ops->vif_cfg_changed)
163 local->ops->vif_cfg_changed(&local->hw, &sdata->vif, changed);
164 else if (local->ops->bss_info_changed)
165 local->ops->bss_info_changed(&local->hw, &sdata->vif,
166 &sdata->vif.bss_conf, changed);
167 trace_drv_return_void(local);
170 void drv_link_info_changed(struct ieee80211_local *local,
171 struct ieee80211_sub_if_data *sdata,
172 struct ieee80211_bss_conf *info,
173 int link_id, u64 changed);
175 static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
176 struct netdev_hw_addr_list *mc_list)
180 trace_drv_prepare_multicast(local, mc_list->count);
182 if (local->ops->prepare_multicast)
183 ret = local->ops->prepare_multicast(&local->hw, mc_list);
185 trace_drv_return_u64(local, ret);
190 static inline void drv_configure_filter(struct ieee80211_local *local,
191 unsigned int changed_flags,
192 unsigned int *total_flags,
197 trace_drv_configure_filter(local, changed_flags, total_flags,
199 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
201 trace_drv_return_void(local);
204 static inline void drv_config_iface_filter(struct ieee80211_local *local,
205 struct ieee80211_sub_if_data *sdata,
206 unsigned int filter_flags,
207 unsigned int changed_flags)
211 trace_drv_config_iface_filter(local, sdata, filter_flags,
213 if (local->ops->config_iface_filter)
214 local->ops->config_iface_filter(&local->hw, &sdata->vif,
217 trace_drv_return_void(local);
220 static inline int drv_set_tim(struct ieee80211_local *local,
221 struct ieee80211_sta *sta, bool set)
224 trace_drv_set_tim(local, sta, set);
225 if (local->ops->set_tim)
226 ret = local->ops->set_tim(&local->hw, sta, set);
227 trace_drv_return_int(local, ret);
231 int drv_set_key(struct ieee80211_local *local,
232 enum set_key_cmd cmd,
233 struct ieee80211_sub_if_data *sdata,
234 struct ieee80211_sta *sta,
235 struct ieee80211_key_conf *key);
237 static inline void drv_update_tkip_key(struct ieee80211_local *local,
238 struct ieee80211_sub_if_data *sdata,
239 struct ieee80211_key_conf *conf,
240 struct sta_info *sta, u32 iv32,
243 struct ieee80211_sta *ista = NULL;
248 sdata = get_bss_sdata(sdata);
249 if (!check_sdata_in_driver(sdata))
252 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
253 if (local->ops->update_tkip_key)
254 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
255 ista, iv32, phase1key);
256 trace_drv_return_void(local);
259 static inline int drv_hw_scan(struct ieee80211_local *local,
260 struct ieee80211_sub_if_data *sdata,
261 struct ieee80211_scan_request *req)
267 if (!check_sdata_in_driver(sdata))
270 trace_drv_hw_scan(local, sdata);
271 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
272 trace_drv_return_int(local, ret);
276 static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
277 struct ieee80211_sub_if_data *sdata)
281 if (!check_sdata_in_driver(sdata))
284 trace_drv_cancel_hw_scan(local, sdata);
285 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
286 trace_drv_return_void(local);
290 drv_sched_scan_start(struct ieee80211_local *local,
291 struct ieee80211_sub_if_data *sdata,
292 struct cfg80211_sched_scan_request *req,
293 struct ieee80211_scan_ies *ies)
299 if (!check_sdata_in_driver(sdata))
302 trace_drv_sched_scan_start(local, sdata);
303 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
305 trace_drv_return_int(local, ret);
309 static inline int drv_sched_scan_stop(struct ieee80211_local *local,
310 struct ieee80211_sub_if_data *sdata)
316 if (!check_sdata_in_driver(sdata))
319 trace_drv_sched_scan_stop(local, sdata);
320 ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
321 trace_drv_return_int(local, ret);
326 static inline void drv_sw_scan_start(struct ieee80211_local *local,
327 struct ieee80211_sub_if_data *sdata,
332 trace_drv_sw_scan_start(local, sdata, mac_addr);
333 if (local->ops->sw_scan_start)
334 local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
335 trace_drv_return_void(local);
338 static inline void drv_sw_scan_complete(struct ieee80211_local *local,
339 struct ieee80211_sub_if_data *sdata)
343 trace_drv_sw_scan_complete(local, sdata);
344 if (local->ops->sw_scan_complete)
345 local->ops->sw_scan_complete(&local->hw, &sdata->vif);
346 trace_drv_return_void(local);
349 static inline int drv_get_stats(struct ieee80211_local *local,
350 struct ieee80211_low_level_stats *stats)
352 int ret = -EOPNOTSUPP;
356 if (local->ops->get_stats)
357 ret = local->ops->get_stats(&local->hw, stats);
358 trace_drv_get_stats(local, stats, ret);
363 static inline void drv_get_key_seq(struct ieee80211_local *local,
364 struct ieee80211_key *key,
365 struct ieee80211_key_seq *seq)
367 if (local->ops->get_key_seq)
368 local->ops->get_key_seq(&local->hw, &key->conf, seq);
369 trace_drv_get_key_seq(local, &key->conf);
372 static inline int drv_set_frag_threshold(struct ieee80211_local *local,
379 trace_drv_set_frag_threshold(local, value);
380 if (local->ops->set_frag_threshold)
381 ret = local->ops->set_frag_threshold(&local->hw, value);
382 trace_drv_return_int(local, ret);
386 static inline int drv_set_rts_threshold(struct ieee80211_local *local,
393 trace_drv_set_rts_threshold(local, value);
394 if (local->ops->set_rts_threshold)
395 ret = local->ops->set_rts_threshold(&local->hw, value);
396 trace_drv_return_int(local, ret);
400 static inline int drv_set_coverage_class(struct ieee80211_local *local,
406 trace_drv_set_coverage_class(local, value);
407 if (local->ops->set_coverage_class)
408 local->ops->set_coverage_class(&local->hw, value);
412 trace_drv_return_int(local, ret);
416 static inline void drv_sta_notify(struct ieee80211_local *local,
417 struct ieee80211_sub_if_data *sdata,
418 enum sta_notify_cmd cmd,
419 struct ieee80211_sta *sta)
421 sdata = get_bss_sdata(sdata);
422 if (!check_sdata_in_driver(sdata))
425 trace_drv_sta_notify(local, sdata, cmd, sta);
426 if (local->ops->sta_notify)
427 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
428 trace_drv_return_void(local);
431 static inline int drv_sta_add(struct ieee80211_local *local,
432 struct ieee80211_sub_if_data *sdata,
433 struct ieee80211_sta *sta)
439 sdata = get_bss_sdata(sdata);
440 if (!check_sdata_in_driver(sdata))
443 trace_drv_sta_add(local, sdata, sta);
444 if (local->ops->sta_add)
445 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
447 trace_drv_return_int(local, ret);
452 static inline void drv_sta_remove(struct ieee80211_local *local,
453 struct ieee80211_sub_if_data *sdata,
454 struct ieee80211_sta *sta)
458 sdata = get_bss_sdata(sdata);
459 if (!check_sdata_in_driver(sdata))
462 trace_drv_sta_remove(local, sdata, sta);
463 if (local->ops->sta_remove)
464 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
466 trace_drv_return_void(local);
469 #ifdef CONFIG_MAC80211_DEBUGFS
470 static inline void drv_link_add_debugfs(struct ieee80211_local *local,
471 struct ieee80211_sub_if_data *sdata,
472 struct ieee80211_bss_conf *link_conf,
477 sdata = get_bss_sdata(sdata);
478 if (!check_sdata_in_driver(sdata))
481 if (local->ops->link_add_debugfs)
482 local->ops->link_add_debugfs(&local->hw, &sdata->vif,
486 static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
487 struct ieee80211_sub_if_data *sdata,
488 struct ieee80211_sta *sta,
493 sdata = get_bss_sdata(sdata);
494 if (!check_sdata_in_driver(sdata))
497 if (local->ops->sta_add_debugfs)
498 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
502 static inline void drv_link_sta_add_debugfs(struct ieee80211_local *local,
503 struct ieee80211_sub_if_data *sdata,
504 struct ieee80211_link_sta *link_sta,
509 sdata = get_bss_sdata(sdata);
510 if (!check_sdata_in_driver(sdata))
513 if (local->ops->link_sta_add_debugfs)
514 local->ops->link_sta_add_debugfs(&local->hw, &sdata->vif,
519 static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
520 struct ieee80211_sub_if_data *sdata,
521 struct sta_info *sta)
525 sdata = get_bss_sdata(sdata);
526 if (!check_sdata_in_driver(sdata))
529 trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
530 if (local->ops->sta_pre_rcu_remove)
531 local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
533 trace_drv_return_void(local);
537 int drv_sta_state(struct ieee80211_local *local,
538 struct ieee80211_sub_if_data *sdata,
539 struct sta_info *sta,
540 enum ieee80211_sta_state old_state,
541 enum ieee80211_sta_state new_state);
544 int drv_sta_set_txpwr(struct ieee80211_local *local,
545 struct ieee80211_sub_if_data *sdata,
546 struct sta_info *sta);
548 void drv_sta_rc_update(struct ieee80211_local *local,
549 struct ieee80211_sub_if_data *sdata,
550 struct ieee80211_sta *sta, u32 changed);
552 static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
553 struct ieee80211_sub_if_data *sdata,
554 struct ieee80211_sta *sta)
556 sdata = get_bss_sdata(sdata);
557 if (!check_sdata_in_driver(sdata))
560 trace_drv_sta_rate_tbl_update(local, sdata, sta);
561 if (local->ops->sta_rate_tbl_update)
562 local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
564 trace_drv_return_void(local);
567 static inline void drv_sta_statistics(struct ieee80211_local *local,
568 struct ieee80211_sub_if_data *sdata,
569 struct ieee80211_sta *sta,
570 struct station_info *sinfo)
572 sdata = get_bss_sdata(sdata);
573 if (!check_sdata_in_driver(sdata))
576 trace_drv_sta_statistics(local, sdata, sta);
577 if (local->ops->sta_statistics)
578 local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
579 trace_drv_return_void(local);
582 int drv_conf_tx(struct ieee80211_local *local,
583 struct ieee80211_link_data *link, u16 ac,
584 const struct ieee80211_tx_queue_params *params);
586 u64 drv_get_tsf(struct ieee80211_local *local,
587 struct ieee80211_sub_if_data *sdata);
588 void drv_set_tsf(struct ieee80211_local *local,
589 struct ieee80211_sub_if_data *sdata,
591 void drv_offset_tsf(struct ieee80211_local *local,
592 struct ieee80211_sub_if_data *sdata,
594 void drv_reset_tsf(struct ieee80211_local *local,
595 struct ieee80211_sub_if_data *sdata);
597 static inline int drv_tx_last_beacon(struct ieee80211_local *local)
599 int ret = 0; /* default unsupported op for less congestion */
603 trace_drv_tx_last_beacon(local);
604 if (local->ops->tx_last_beacon)
605 ret = local->ops->tx_last_beacon(&local->hw);
606 trace_drv_return_int(local, ret);
610 int drv_ampdu_action(struct ieee80211_local *local,
611 struct ieee80211_sub_if_data *sdata,
612 struct ieee80211_ampdu_params *params);
614 static inline int drv_get_survey(struct ieee80211_local *local, int idx,
615 struct survey_info *survey)
617 int ret = -EOPNOTSUPP;
619 trace_drv_get_survey(local, idx, survey);
621 if (local->ops->get_survey)
622 ret = local->ops->get_survey(&local->hw, idx, survey);
624 trace_drv_return_int(local, ret);
629 static inline void drv_rfkill_poll(struct ieee80211_local *local)
633 if (local->ops->rfkill_poll)
634 local->ops->rfkill_poll(&local->hw);
637 static inline void drv_flush(struct ieee80211_local *local,
638 struct ieee80211_sub_if_data *sdata,
639 u32 queues, bool drop)
641 struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
645 if (sdata && !check_sdata_in_driver(sdata))
648 trace_drv_flush(local, queues, drop);
649 if (local->ops->flush)
650 local->ops->flush(&local->hw, vif, queues, drop);
651 trace_drv_return_void(local);
654 static inline void drv_flush_sta(struct ieee80211_local *local,
655 struct ieee80211_sub_if_data *sdata,
656 struct sta_info *sta)
660 if (sdata && !check_sdata_in_driver(sdata))
663 trace_drv_flush_sta(local, sdata, &sta->sta);
664 if (local->ops->flush_sta)
665 local->ops->flush_sta(&local->hw, &sdata->vif, &sta->sta);
666 trace_drv_return_void(local);
669 static inline void drv_channel_switch(struct ieee80211_local *local,
670 struct ieee80211_sub_if_data *sdata,
671 struct ieee80211_channel_switch *ch_switch)
675 trace_drv_channel_switch(local, sdata, ch_switch);
676 local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
677 trace_drv_return_void(local);
681 static inline int drv_set_antenna(struct ieee80211_local *local,
682 u32 tx_ant, u32 rx_ant)
684 int ret = -EOPNOTSUPP;
686 if (local->ops->set_antenna)
687 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
688 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
692 static inline int drv_get_antenna(struct ieee80211_local *local,
693 u32 *tx_ant, u32 *rx_ant)
695 int ret = -EOPNOTSUPP;
697 if (local->ops->get_antenna)
698 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
699 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
703 static inline int drv_remain_on_channel(struct ieee80211_local *local,
704 struct ieee80211_sub_if_data *sdata,
705 struct ieee80211_channel *chan,
706 unsigned int duration,
707 enum ieee80211_roc_type type)
713 trace_drv_remain_on_channel(local, sdata, chan, duration, type);
714 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
715 chan, duration, type);
716 trace_drv_return_int(local, ret);
722 drv_cancel_remain_on_channel(struct ieee80211_local *local,
723 struct ieee80211_sub_if_data *sdata)
729 trace_drv_cancel_remain_on_channel(local, sdata);
730 ret = local->ops->cancel_remain_on_channel(&local->hw, &sdata->vif);
731 trace_drv_return_int(local, ret);
736 static inline int drv_set_ringparam(struct ieee80211_local *local,
743 trace_drv_set_ringparam(local, tx, rx);
744 if (local->ops->set_ringparam)
745 ret = local->ops->set_ringparam(&local->hw, tx, rx);
746 trace_drv_return_int(local, ret);
751 static inline void drv_get_ringparam(struct ieee80211_local *local,
752 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
756 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
757 if (local->ops->get_ringparam)
758 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
759 trace_drv_return_void(local);
762 static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
768 trace_drv_tx_frames_pending(local);
769 if (local->ops->tx_frames_pending)
770 ret = local->ops->tx_frames_pending(&local->hw);
771 trace_drv_return_bool(local, ret);
776 static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
777 struct ieee80211_sub_if_data *sdata,
778 const struct cfg80211_bitrate_mask *mask)
780 int ret = -EOPNOTSUPP;
784 if (!check_sdata_in_driver(sdata))
787 trace_drv_set_bitrate_mask(local, sdata, mask);
788 if (local->ops->set_bitrate_mask)
789 ret = local->ops->set_bitrate_mask(&local->hw,
791 trace_drv_return_int(local, ret);
796 static inline void drv_set_rekey_data(struct ieee80211_local *local,
797 struct ieee80211_sub_if_data *sdata,
798 struct cfg80211_gtk_rekey_data *data)
800 if (!check_sdata_in_driver(sdata))
803 trace_drv_set_rekey_data(local, sdata, data);
804 if (local->ops->set_rekey_data)
805 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
806 trace_drv_return_void(local);
809 static inline void drv_event_callback(struct ieee80211_local *local,
810 struct ieee80211_sub_if_data *sdata,
811 const struct ieee80211_event *event)
813 trace_drv_event_callback(local, sdata, event);
814 if (local->ops->event_callback)
815 local->ops->event_callback(&local->hw, &sdata->vif, event);
816 trace_drv_return_void(local);
820 drv_release_buffered_frames(struct ieee80211_local *local,
821 struct sta_info *sta, u16 tids, int num_frames,
822 enum ieee80211_frame_release_type reason,
825 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
827 if (local->ops->release_buffered_frames)
828 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
831 trace_drv_return_void(local);
835 drv_allow_buffered_frames(struct ieee80211_local *local,
836 struct sta_info *sta, u16 tids, int num_frames,
837 enum ieee80211_frame_release_type reason,
840 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
842 if (local->ops->allow_buffered_frames)
843 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
844 tids, num_frames, reason,
846 trace_drv_return_void(local);
849 static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
850 struct ieee80211_sub_if_data *sdata,
851 struct ieee80211_prep_tx_info *info)
855 if (!check_sdata_in_driver(sdata))
857 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
859 trace_drv_mgd_prepare_tx(local, sdata, info->duration,
860 info->subtype, info->success);
861 if (local->ops->mgd_prepare_tx)
862 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif, info);
863 trace_drv_return_void(local);
866 static inline void drv_mgd_complete_tx(struct ieee80211_local *local,
867 struct ieee80211_sub_if_data *sdata,
868 struct ieee80211_prep_tx_info *info)
872 if (!check_sdata_in_driver(sdata))
874 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
876 trace_drv_mgd_complete_tx(local, sdata, info->duration,
877 info->subtype, info->success);
878 if (local->ops->mgd_complete_tx)
879 local->ops->mgd_complete_tx(&local->hw, &sdata->vif, info);
880 trace_drv_return_void(local);
884 drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
885 struct ieee80211_sub_if_data *sdata)
889 if (!check_sdata_in_driver(sdata))
891 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
893 trace_drv_mgd_protect_tdls_discover(local, sdata);
894 if (local->ops->mgd_protect_tdls_discover)
895 local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
896 trace_drv_return_void(local);
899 static inline int drv_add_chanctx(struct ieee80211_local *local,
900 struct ieee80211_chanctx *ctx)
902 int ret = -EOPNOTSUPP;
906 trace_drv_add_chanctx(local, ctx);
907 if (local->ops->add_chanctx)
908 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
909 trace_drv_return_int(local, ret);
911 ctx->driver_present = true;
916 static inline void drv_remove_chanctx(struct ieee80211_local *local,
917 struct ieee80211_chanctx *ctx)
921 if (WARN_ON(!ctx->driver_present))
924 trace_drv_remove_chanctx(local, ctx);
925 if (local->ops->remove_chanctx)
926 local->ops->remove_chanctx(&local->hw, &ctx->conf);
927 trace_drv_return_void(local);
928 ctx->driver_present = false;
931 static inline void drv_change_chanctx(struct ieee80211_local *local,
932 struct ieee80211_chanctx *ctx,
937 trace_drv_change_chanctx(local, ctx, changed);
938 if (local->ops->change_chanctx) {
939 WARN_ON_ONCE(!ctx->driver_present);
940 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
942 trace_drv_return_void(local);
945 static inline void drv_verify_link_exists(struct ieee80211_sub_if_data *sdata,
946 struct ieee80211_bss_conf *link_conf)
948 /* deflink always exists, so need to check only for other links */
949 if (sdata->deflink.conf != link_conf)
950 sdata_assert_lock(sdata);
953 int drv_assign_vif_chanctx(struct ieee80211_local *local,
954 struct ieee80211_sub_if_data *sdata,
955 struct ieee80211_bss_conf *link_conf,
956 struct ieee80211_chanctx *ctx);
957 void drv_unassign_vif_chanctx(struct ieee80211_local *local,
958 struct ieee80211_sub_if_data *sdata,
959 struct ieee80211_bss_conf *link_conf,
960 struct ieee80211_chanctx *ctx);
961 int drv_switch_vif_chanctx(struct ieee80211_local *local,
962 struct ieee80211_vif_chanctx_switch *vifs,
963 int n_vifs, enum ieee80211_chanctx_switch_mode mode);
965 static inline int drv_start_ap(struct ieee80211_local *local,
966 struct ieee80211_sub_if_data *sdata,
967 struct ieee80211_bss_conf *link_conf)
971 /* make sure link_conf is protected */
972 drv_verify_link_exists(sdata, link_conf);
976 if (!check_sdata_in_driver(sdata))
979 trace_drv_start_ap(local, sdata, link_conf);
980 if (local->ops->start_ap)
981 ret = local->ops->start_ap(&local->hw, &sdata->vif, link_conf);
982 trace_drv_return_int(local, ret);
986 static inline void drv_stop_ap(struct ieee80211_local *local,
987 struct ieee80211_sub_if_data *sdata,
988 struct ieee80211_bss_conf *link_conf)
990 /* make sure link_conf is protected */
991 drv_verify_link_exists(sdata, link_conf);
993 if (!check_sdata_in_driver(sdata))
996 trace_drv_stop_ap(local, sdata, link_conf);
997 if (local->ops->stop_ap)
998 local->ops->stop_ap(&local->hw, &sdata->vif, link_conf);
999 trace_drv_return_void(local);
1003 drv_reconfig_complete(struct ieee80211_local *local,
1004 enum ieee80211_reconfig_type reconfig_type)
1008 trace_drv_reconfig_complete(local, reconfig_type);
1009 if (local->ops->reconfig_complete)
1010 local->ops->reconfig_complete(&local->hw, reconfig_type);
1011 trace_drv_return_void(local);
1015 drv_set_default_unicast_key(struct ieee80211_local *local,
1016 struct ieee80211_sub_if_data *sdata,
1019 if (!check_sdata_in_driver(sdata))
1022 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1024 trace_drv_set_default_unicast_key(local, sdata, key_idx);
1025 if (local->ops->set_default_unicast_key)
1026 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1028 trace_drv_return_void(local);
1031 #if IS_ENABLED(CONFIG_IPV6)
1032 static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1033 struct ieee80211_sub_if_data *sdata,
1034 struct inet6_dev *idev)
1036 trace_drv_ipv6_addr_change(local, sdata);
1037 if (local->ops->ipv6_addr_change)
1038 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1039 trace_drv_return_void(local);
1044 drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1045 struct cfg80211_chan_def *chandef)
1047 struct ieee80211_local *local = sdata->local;
1049 if (local->ops->channel_switch_beacon) {
1050 trace_drv_channel_switch_beacon(local, sdata, chandef);
1051 local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1057 drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
1058 struct ieee80211_channel_switch *ch_switch)
1060 struct ieee80211_local *local = sdata->local;
1063 if (!check_sdata_in_driver(sdata))
1066 trace_drv_pre_channel_switch(local, sdata, ch_switch);
1067 if (local->ops->pre_channel_switch)
1068 ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
1070 trace_drv_return_int(local, ret);
1075 drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1077 struct ieee80211_local *local = sdata->local;
1080 if (!check_sdata_in_driver(sdata))
1083 trace_drv_post_channel_switch(local, sdata);
1084 if (local->ops->post_channel_switch)
1085 ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1086 trace_drv_return_int(local, ret);
1091 drv_abort_channel_switch(struct ieee80211_sub_if_data *sdata)
1093 struct ieee80211_local *local = sdata->local;
1095 if (!check_sdata_in_driver(sdata))
1098 trace_drv_abort_channel_switch(local, sdata);
1100 if (local->ops->abort_channel_switch)
1101 local->ops->abort_channel_switch(&local->hw, &sdata->vif);
1105 drv_channel_switch_rx_beacon(struct ieee80211_sub_if_data *sdata,
1106 struct ieee80211_channel_switch *ch_switch)
1108 struct ieee80211_local *local = sdata->local;
1110 if (!check_sdata_in_driver(sdata))
1113 trace_drv_channel_switch_rx_beacon(local, sdata, ch_switch);
1114 if (local->ops->channel_switch_rx_beacon)
1115 local->ops->channel_switch_rx_beacon(&local->hw, &sdata->vif,
1119 static inline int drv_join_ibss(struct ieee80211_local *local,
1120 struct ieee80211_sub_if_data *sdata)
1125 if (!check_sdata_in_driver(sdata))
1128 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1129 if (local->ops->join_ibss)
1130 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1131 trace_drv_return_int(local, ret);
1135 static inline void drv_leave_ibss(struct ieee80211_local *local,
1136 struct ieee80211_sub_if_data *sdata)
1139 if (!check_sdata_in_driver(sdata))
1142 trace_drv_leave_ibss(local, sdata);
1143 if (local->ops->leave_ibss)
1144 local->ops->leave_ibss(&local->hw, &sdata->vif);
1145 trace_drv_return_void(local);
1148 static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
1149 struct sta_info *sta)
1153 trace_drv_get_expected_throughput(&sta->sta);
1154 if (local->ops->get_expected_throughput && sta->uploaded)
1155 ret = local->ops->get_expected_throughput(&local->hw, &sta->sta);
1156 trace_drv_return_u32(local, ret);
1161 static inline int drv_get_txpower(struct ieee80211_local *local,
1162 struct ieee80211_sub_if_data *sdata, int *dbm)
1166 if (!local->ops->get_txpower)
1169 ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
1170 trace_drv_get_txpower(local, sdata, *dbm, ret);
1176 drv_tdls_channel_switch(struct ieee80211_local *local,
1177 struct ieee80211_sub_if_data *sdata,
1178 struct ieee80211_sta *sta, u8 oper_class,
1179 struct cfg80211_chan_def *chandef,
1180 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
1185 if (!check_sdata_in_driver(sdata))
1188 if (!local->ops->tdls_channel_switch)
1191 trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
1192 ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
1193 oper_class, chandef, tmpl_skb,
1195 trace_drv_return_int(local, ret);
1200 drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
1201 struct ieee80211_sub_if_data *sdata,
1202 struct ieee80211_sta *sta)
1205 if (!check_sdata_in_driver(sdata))
1208 if (!local->ops->tdls_cancel_channel_switch)
1211 trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
1212 local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
1213 trace_drv_return_void(local);
1217 drv_tdls_recv_channel_switch(struct ieee80211_local *local,
1218 struct ieee80211_sub_if_data *sdata,
1219 struct ieee80211_tdls_ch_sw_params *params)
1221 trace_drv_tdls_recv_channel_switch(local, sdata, params);
1222 if (local->ops->tdls_recv_channel_switch)
1223 local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
1225 trace_drv_return_void(local);
1228 static inline void drv_wake_tx_queue(struct ieee80211_local *local,
1229 struct txq_info *txq)
1231 struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
1233 /* In reconfig don't transmit now, but mark for waking later */
1234 if (local->in_reconfig) {
1235 set_bit(IEEE80211_TXQ_DIRTY, &txq->flags);
1239 if (!check_sdata_in_driver(sdata))
1242 trace_drv_wake_tx_queue(local, sdata, txq);
1243 local->ops->wake_tx_queue(&local->hw, &txq->txq);
1246 static inline void schedule_and_wake_txq(struct ieee80211_local *local,
1247 struct txq_info *txqi)
1249 ieee80211_schedule_txq(&local->hw, &txqi->txq);
1250 drv_wake_tx_queue(local, txqi);
1253 static inline int drv_can_aggregate_in_amsdu(struct ieee80211_local *local,
1254 struct sk_buff *head,
1255 struct sk_buff *skb)
1257 if (!local->ops->can_aggregate_in_amsdu)
1260 return local->ops->can_aggregate_in_amsdu(&local->hw, head, skb);
1264 drv_get_ftm_responder_stats(struct ieee80211_local *local,
1265 struct ieee80211_sub_if_data *sdata,
1266 struct cfg80211_ftm_responder_stats *ftm_stats)
1268 u32 ret = -EOPNOTSUPP;
1270 if (local->ops->get_ftm_responder_stats)
1271 ret = local->ops->get_ftm_responder_stats(&local->hw,
1274 trace_drv_get_ftm_responder_stats(local, sdata, ftm_stats);
1279 static inline int drv_start_pmsr(struct ieee80211_local *local,
1280 struct ieee80211_sub_if_data *sdata,
1281 struct cfg80211_pmsr_request *request)
1283 int ret = -EOPNOTSUPP;
1286 if (!check_sdata_in_driver(sdata))
1289 trace_drv_start_pmsr(local, sdata);
1291 if (local->ops->start_pmsr)
1292 ret = local->ops->start_pmsr(&local->hw, &sdata->vif, request);
1293 trace_drv_return_int(local, ret);
1298 static inline void drv_abort_pmsr(struct ieee80211_local *local,
1299 struct ieee80211_sub_if_data *sdata,
1300 struct cfg80211_pmsr_request *request)
1302 trace_drv_abort_pmsr(local, sdata);
1305 if (!check_sdata_in_driver(sdata))
1308 if (local->ops->abort_pmsr)
1309 local->ops->abort_pmsr(&local->hw, &sdata->vif, request);
1310 trace_drv_return_void(local);
1313 static inline int drv_start_nan(struct ieee80211_local *local,
1314 struct ieee80211_sub_if_data *sdata,
1315 struct cfg80211_nan_conf *conf)
1320 check_sdata_in_driver(sdata);
1322 trace_drv_start_nan(local, sdata, conf);
1323 ret = local->ops->start_nan(&local->hw, &sdata->vif, conf);
1324 trace_drv_return_int(local, ret);
1328 static inline void drv_stop_nan(struct ieee80211_local *local,
1329 struct ieee80211_sub_if_data *sdata)
1332 check_sdata_in_driver(sdata);
1334 trace_drv_stop_nan(local, sdata);
1335 local->ops->stop_nan(&local->hw, &sdata->vif);
1336 trace_drv_return_void(local);
1339 static inline int drv_nan_change_conf(struct ieee80211_local *local,
1340 struct ieee80211_sub_if_data *sdata,
1341 struct cfg80211_nan_conf *conf,
1347 check_sdata_in_driver(sdata);
1349 if (!local->ops->nan_change_conf)
1352 trace_drv_nan_change_conf(local, sdata, conf, changes);
1353 ret = local->ops->nan_change_conf(&local->hw, &sdata->vif, conf,
1355 trace_drv_return_int(local, ret);
1360 static inline int drv_add_nan_func(struct ieee80211_local *local,
1361 struct ieee80211_sub_if_data *sdata,
1362 const struct cfg80211_nan_func *nan_func)
1367 check_sdata_in_driver(sdata);
1369 if (!local->ops->add_nan_func)
1372 trace_drv_add_nan_func(local, sdata, nan_func);
1373 ret = local->ops->add_nan_func(&local->hw, &sdata->vif, nan_func);
1374 trace_drv_return_int(local, ret);
1379 static inline void drv_del_nan_func(struct ieee80211_local *local,
1380 struct ieee80211_sub_if_data *sdata,
1384 check_sdata_in_driver(sdata);
1386 trace_drv_del_nan_func(local, sdata, instance_id);
1387 if (local->ops->del_nan_func)
1388 local->ops->del_nan_func(&local->hw, &sdata->vif, instance_id);
1389 trace_drv_return_void(local);
1392 static inline int drv_set_tid_config(struct ieee80211_local *local,
1393 struct ieee80211_sub_if_data *sdata,
1394 struct ieee80211_sta *sta,
1395 struct cfg80211_tid_config *tid_conf)
1400 ret = local->ops->set_tid_config(&local->hw, &sdata->vif, sta,
1402 trace_drv_return_int(local, ret);
1407 static inline int drv_reset_tid_config(struct ieee80211_local *local,
1408 struct ieee80211_sub_if_data *sdata,
1409 struct ieee80211_sta *sta, u8 tids)
1414 ret = local->ops->reset_tid_config(&local->hw, &sdata->vif, sta, tids);
1415 trace_drv_return_int(local, ret);
1420 static inline void drv_update_vif_offload(struct ieee80211_local *local,
1421 struct ieee80211_sub_if_data *sdata)
1424 check_sdata_in_driver(sdata);
1426 if (!local->ops->update_vif_offload)
1429 trace_drv_update_vif_offload(local, sdata);
1430 local->ops->update_vif_offload(&local->hw, &sdata->vif);
1431 trace_drv_return_void(local);
1434 static inline void drv_sta_set_4addr(struct ieee80211_local *local,
1435 struct ieee80211_sub_if_data *sdata,
1436 struct ieee80211_sta *sta, bool enabled)
1438 sdata = get_bss_sdata(sdata);
1439 if (!check_sdata_in_driver(sdata))
1442 trace_drv_sta_set_4addr(local, sdata, sta, enabled);
1443 if (local->ops->sta_set_4addr)
1444 local->ops->sta_set_4addr(&local->hw, &sdata->vif, sta, enabled);
1445 trace_drv_return_void(local);
1448 static inline void drv_sta_set_decap_offload(struct ieee80211_local *local,
1449 struct ieee80211_sub_if_data *sdata,
1450 struct ieee80211_sta *sta,
1453 sdata = get_bss_sdata(sdata);
1454 if (!check_sdata_in_driver(sdata))
1457 trace_drv_sta_set_decap_offload(local, sdata, sta, enabled);
1458 if (local->ops->sta_set_decap_offload)
1459 local->ops->sta_set_decap_offload(&local->hw, &sdata->vif, sta,
1461 trace_drv_return_void(local);
1464 static inline void drv_add_twt_setup(struct ieee80211_local *local,
1465 struct ieee80211_sub_if_data *sdata,
1466 struct ieee80211_sta *sta,
1467 struct ieee80211_twt_setup *twt)
1469 struct ieee80211_twt_params *twt_agrt;
1473 if (!check_sdata_in_driver(sdata))
1476 twt_agrt = (void *)twt->params;
1478 trace_drv_add_twt_setup(local, sta, twt, twt_agrt);
1479 local->ops->add_twt_setup(&local->hw, sta, twt);
1480 trace_drv_return_void(local);
1483 static inline void drv_twt_teardown_request(struct ieee80211_local *local,
1484 struct ieee80211_sub_if_data *sdata,
1485 struct ieee80211_sta *sta,
1489 if (!check_sdata_in_driver(sdata))
1492 if (!local->ops->twt_teardown_request)
1495 trace_drv_twt_teardown_request(local, sta, flowid);
1496 local->ops->twt_teardown_request(&local->hw, sta, flowid);
1497 trace_drv_return_void(local);
1500 static inline int drv_net_fill_forward_path(struct ieee80211_local *local,
1501 struct ieee80211_sub_if_data *sdata,
1502 struct ieee80211_sta *sta,
1503 struct net_device_path_ctx *ctx,
1504 struct net_device_path *path)
1506 int ret = -EOPNOTSUPP;
1508 sdata = get_bss_sdata(sdata);
1509 if (!check_sdata_in_driver(sdata))
1512 trace_drv_net_fill_forward_path(local, sdata, sta);
1513 if (local->ops->net_fill_forward_path)
1514 ret = local->ops->net_fill_forward_path(&local->hw,
1517 trace_drv_return_int(local, ret);
1522 static inline int drv_net_setup_tc(struct ieee80211_local *local,
1523 struct ieee80211_sub_if_data *sdata,
1524 struct net_device *dev,
1525 enum tc_setup_type type, void *type_data)
1527 int ret = -EOPNOTSUPP;
1529 sdata = get_bss_sdata(sdata);
1530 trace_drv_net_setup_tc(local, sdata, type);
1531 if (local->ops->net_setup_tc)
1532 ret = local->ops->net_setup_tc(&local->hw, &sdata->vif, dev,
1534 trace_drv_return_int(local, ret);
1539 int drv_change_vif_links(struct ieee80211_local *local,
1540 struct ieee80211_sub_if_data *sdata,
1541 u16 old_links, u16 new_links,
1542 struct ieee80211_bss_conf *old[IEEE80211_MLD_MAX_NUM_LINKS]);
1543 int drv_change_sta_links(struct ieee80211_local *local,
1544 struct ieee80211_sub_if_data *sdata,
1545 struct ieee80211_sta *sta,
1546 u16 old_links, u16 new_links);
1548 #endif /* __MAC80211_DRIVER_OPS */