1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Portions of this file
4 * Copyright(c) 2016 Intel Deutschland GmbH
5 * Copyright (C) 2018 - 2019 Intel Corporation
8 #ifndef __MAC80211_DRIVER_OPS
9 #define __MAC80211_DRIVER_OPS
11 #include <net/mac80211.h>
12 #include "ieee80211_i.h"
15 static inline bool check_sdata_in_driver(struct ieee80211_sub_if_data *sdata)
17 return !WARN(!(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);
22 static inline struct ieee80211_sub_if_data *
23 get_bss_sdata(struct ieee80211_sub_if_data *sdata)
25 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
26 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
32 static inline void drv_tx(struct ieee80211_local *local,
33 struct ieee80211_tx_control *control,
36 local->ops->tx(&local->hw, control, skb);
39 static inline void drv_sync_rx_queues(struct ieee80211_local *local,
42 if (local->ops->sync_rx_queues) {
43 trace_drv_sync_rx_queues(local, sta->sdata, &sta->sta);
44 local->ops->sync_rx_queues(&local->hw);
45 trace_drv_return_void(local);
49 static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata,
52 struct ieee80211_local *local = sdata->local;
53 if (local->ops->get_et_strings) {
54 trace_drv_get_et_strings(local, sset);
55 local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data);
56 trace_drv_return_void(local);
60 static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata,
61 struct ethtool_stats *stats,
64 struct ieee80211_local *local = sdata->local;
65 if (local->ops->get_et_stats) {
66 trace_drv_get_et_stats(local);
67 local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data);
68 trace_drv_return_void(local);
72 static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata,
75 struct ieee80211_local *local = sdata->local;
77 if (local->ops->get_et_sset_count) {
78 trace_drv_get_et_sset_count(local, sset);
79 rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif,
81 trace_drv_return_int(local, rv);
86 int drv_start(struct ieee80211_local *local);
87 void drv_stop(struct ieee80211_local *local);
90 static inline int drv_suspend(struct ieee80211_local *local,
91 struct cfg80211_wowlan *wowlan)
97 trace_drv_suspend(local);
98 ret = local->ops->suspend(&local->hw, wowlan);
99 trace_drv_return_int(local, ret);
103 static inline int drv_resume(struct ieee80211_local *local)
109 trace_drv_resume(local);
110 ret = local->ops->resume(&local->hw);
111 trace_drv_return_int(local, ret);
115 static inline void drv_set_wakeup(struct ieee80211_local *local,
120 if (!local->ops->set_wakeup)
123 trace_drv_set_wakeup(local, enabled);
124 local->ops->set_wakeup(&local->hw, enabled);
125 trace_drv_return_void(local);
129 int drv_add_interface(struct ieee80211_local *local,
130 struct ieee80211_sub_if_data *sdata);
132 int drv_change_interface(struct ieee80211_local *local,
133 struct ieee80211_sub_if_data *sdata,
134 enum nl80211_iftype type, bool p2p);
136 void drv_remove_interface(struct ieee80211_local *local,
137 struct ieee80211_sub_if_data *sdata);
139 static inline int drv_config(struct ieee80211_local *local, u32 changed)
145 trace_drv_config(local, changed);
146 ret = local->ops->config(&local->hw, changed);
147 trace_drv_return_int(local, ret);
151 static inline void drv_bss_info_changed(struct ieee80211_local *local,
152 struct ieee80211_sub_if_data *sdata,
153 struct ieee80211_bss_conf *info,
158 if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
159 BSS_CHANGED_BEACON_ENABLED) &&
160 sdata->vif.type != NL80211_IFTYPE_AP &&
161 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
162 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
163 sdata->vif.type != NL80211_IFTYPE_OCB))
166 if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
167 sdata->vif.type == NL80211_IFTYPE_NAN ||
168 (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
169 !sdata->vif.mu_mimo_owner &&
170 !(changed & BSS_CHANGED_TXPOWER))))
173 if (!check_sdata_in_driver(sdata))
176 trace_drv_bss_info_changed(local, sdata, info, changed);
177 if (local->ops->bss_info_changed)
178 local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
179 trace_drv_return_void(local);
182 static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
183 struct netdev_hw_addr_list *mc_list)
187 trace_drv_prepare_multicast(local, mc_list->count);
189 if (local->ops->prepare_multicast)
190 ret = local->ops->prepare_multicast(&local->hw, mc_list);
192 trace_drv_return_u64(local, ret);
197 static inline void drv_configure_filter(struct ieee80211_local *local,
198 unsigned int changed_flags,
199 unsigned int *total_flags,
204 trace_drv_configure_filter(local, changed_flags, total_flags,
206 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
208 trace_drv_return_void(local);
211 static inline void drv_config_iface_filter(struct ieee80211_local *local,
212 struct ieee80211_sub_if_data *sdata,
213 unsigned int filter_flags,
214 unsigned int changed_flags)
218 trace_drv_config_iface_filter(local, sdata, filter_flags,
220 if (local->ops->config_iface_filter)
221 local->ops->config_iface_filter(&local->hw, &sdata->vif,
224 trace_drv_return_void(local);
227 static inline int drv_set_tim(struct ieee80211_local *local,
228 struct ieee80211_sta *sta, bool set)
231 trace_drv_set_tim(local, sta, set);
232 if (local->ops->set_tim)
233 ret = local->ops->set_tim(&local->hw, sta, set);
234 trace_drv_return_int(local, ret);
238 static inline int drv_set_key(struct ieee80211_local *local,
239 enum set_key_cmd cmd,
240 struct ieee80211_sub_if_data *sdata,
241 struct ieee80211_sta *sta,
242 struct ieee80211_key_conf *key)
248 sdata = get_bss_sdata(sdata);
249 if (!check_sdata_in_driver(sdata))
252 trace_drv_set_key(local, cmd, sdata, sta, key);
253 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
254 trace_drv_return_int(local, ret);
258 static inline void drv_update_tkip_key(struct ieee80211_local *local,
259 struct ieee80211_sub_if_data *sdata,
260 struct ieee80211_key_conf *conf,
261 struct sta_info *sta, u32 iv32,
264 struct ieee80211_sta *ista = NULL;
269 sdata = get_bss_sdata(sdata);
270 if (!check_sdata_in_driver(sdata))
273 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
274 if (local->ops->update_tkip_key)
275 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
276 ista, iv32, phase1key);
277 trace_drv_return_void(local);
280 static inline int drv_hw_scan(struct ieee80211_local *local,
281 struct ieee80211_sub_if_data *sdata,
282 struct ieee80211_scan_request *req)
288 if (!check_sdata_in_driver(sdata))
291 trace_drv_hw_scan(local, sdata);
292 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
293 trace_drv_return_int(local, ret);
297 static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
298 struct ieee80211_sub_if_data *sdata)
302 if (!check_sdata_in_driver(sdata))
305 trace_drv_cancel_hw_scan(local, sdata);
306 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
307 trace_drv_return_void(local);
311 drv_sched_scan_start(struct ieee80211_local *local,
312 struct ieee80211_sub_if_data *sdata,
313 struct cfg80211_sched_scan_request *req,
314 struct ieee80211_scan_ies *ies)
320 if (!check_sdata_in_driver(sdata))
323 trace_drv_sched_scan_start(local, sdata);
324 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
326 trace_drv_return_int(local, ret);
330 static inline int drv_sched_scan_stop(struct ieee80211_local *local,
331 struct ieee80211_sub_if_data *sdata)
337 if (!check_sdata_in_driver(sdata))
340 trace_drv_sched_scan_stop(local, sdata);
341 ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
342 trace_drv_return_int(local, ret);
347 static inline void drv_sw_scan_start(struct ieee80211_local *local,
348 struct ieee80211_sub_if_data *sdata,
353 trace_drv_sw_scan_start(local, sdata, mac_addr);
354 if (local->ops->sw_scan_start)
355 local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
356 trace_drv_return_void(local);
359 static inline void drv_sw_scan_complete(struct ieee80211_local *local,
360 struct ieee80211_sub_if_data *sdata)
364 trace_drv_sw_scan_complete(local, sdata);
365 if (local->ops->sw_scan_complete)
366 local->ops->sw_scan_complete(&local->hw, &sdata->vif);
367 trace_drv_return_void(local);
370 static inline int drv_get_stats(struct ieee80211_local *local,
371 struct ieee80211_low_level_stats *stats)
373 int ret = -EOPNOTSUPP;
377 if (local->ops->get_stats)
378 ret = local->ops->get_stats(&local->hw, stats);
379 trace_drv_get_stats(local, stats, ret);
384 static inline void drv_get_key_seq(struct ieee80211_local *local,
385 struct ieee80211_key *key,
386 struct ieee80211_key_seq *seq)
388 if (local->ops->get_key_seq)
389 local->ops->get_key_seq(&local->hw, &key->conf, seq);
390 trace_drv_get_key_seq(local, &key->conf);
393 static inline int drv_set_frag_threshold(struct ieee80211_local *local,
400 trace_drv_set_frag_threshold(local, value);
401 if (local->ops->set_frag_threshold)
402 ret = local->ops->set_frag_threshold(&local->hw, value);
403 trace_drv_return_int(local, ret);
407 static inline int drv_set_rts_threshold(struct ieee80211_local *local,
414 trace_drv_set_rts_threshold(local, value);
415 if (local->ops->set_rts_threshold)
416 ret = local->ops->set_rts_threshold(&local->hw, value);
417 trace_drv_return_int(local, ret);
421 static inline int drv_set_coverage_class(struct ieee80211_local *local,
427 trace_drv_set_coverage_class(local, value);
428 if (local->ops->set_coverage_class)
429 local->ops->set_coverage_class(&local->hw, value);
433 trace_drv_return_int(local, ret);
437 static inline void drv_sta_notify(struct ieee80211_local *local,
438 struct ieee80211_sub_if_data *sdata,
439 enum sta_notify_cmd cmd,
440 struct ieee80211_sta *sta)
442 sdata = get_bss_sdata(sdata);
443 if (!check_sdata_in_driver(sdata))
446 trace_drv_sta_notify(local, sdata, cmd, sta);
447 if (local->ops->sta_notify)
448 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
449 trace_drv_return_void(local);
452 static inline int drv_sta_add(struct ieee80211_local *local,
453 struct ieee80211_sub_if_data *sdata,
454 struct ieee80211_sta *sta)
460 sdata = get_bss_sdata(sdata);
461 if (!check_sdata_in_driver(sdata))
464 trace_drv_sta_add(local, sdata, sta);
465 if (local->ops->sta_add)
466 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
468 trace_drv_return_int(local, ret);
473 static inline void drv_sta_remove(struct ieee80211_local *local,
474 struct ieee80211_sub_if_data *sdata,
475 struct ieee80211_sta *sta)
479 sdata = get_bss_sdata(sdata);
480 if (!check_sdata_in_driver(sdata))
483 trace_drv_sta_remove(local, sdata, sta);
484 if (local->ops->sta_remove)
485 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
487 trace_drv_return_void(local);
490 #ifdef CONFIG_MAC80211_DEBUGFS
491 static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
492 struct ieee80211_sub_if_data *sdata,
493 struct ieee80211_sta *sta,
498 sdata = get_bss_sdata(sdata);
499 if (!check_sdata_in_driver(sdata))
502 if (local->ops->sta_add_debugfs)
503 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
508 static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
509 struct ieee80211_sub_if_data *sdata,
510 struct sta_info *sta)
514 sdata = get_bss_sdata(sdata);
515 if (!check_sdata_in_driver(sdata))
518 trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
519 if (local->ops->sta_pre_rcu_remove)
520 local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
522 trace_drv_return_void(local);
526 int drv_sta_state(struct ieee80211_local *local,
527 struct ieee80211_sub_if_data *sdata,
528 struct sta_info *sta,
529 enum ieee80211_sta_state old_state,
530 enum ieee80211_sta_state new_state);
533 int drv_sta_set_txpwr(struct ieee80211_local *local,
534 struct ieee80211_sub_if_data *sdata,
535 struct sta_info *sta);
537 void drv_sta_rc_update(struct ieee80211_local *local,
538 struct ieee80211_sub_if_data *sdata,
539 struct ieee80211_sta *sta, u32 changed);
541 static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
542 struct ieee80211_sub_if_data *sdata,
543 struct ieee80211_sta *sta)
545 sdata = get_bss_sdata(sdata);
546 if (!check_sdata_in_driver(sdata))
549 trace_drv_sta_rate_tbl_update(local, sdata, sta);
550 if (local->ops->sta_rate_tbl_update)
551 local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
553 trace_drv_return_void(local);
556 static inline void drv_sta_statistics(struct ieee80211_local *local,
557 struct ieee80211_sub_if_data *sdata,
558 struct ieee80211_sta *sta,
559 struct station_info *sinfo)
561 sdata = get_bss_sdata(sdata);
562 if (!check_sdata_in_driver(sdata))
565 trace_drv_sta_statistics(local, sdata, sta);
566 if (local->ops->sta_statistics)
567 local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
568 trace_drv_return_void(local);
571 int drv_conf_tx(struct ieee80211_local *local,
572 struct ieee80211_sub_if_data *sdata, u16 ac,
573 const struct ieee80211_tx_queue_params *params);
575 u64 drv_get_tsf(struct ieee80211_local *local,
576 struct ieee80211_sub_if_data *sdata);
577 void drv_set_tsf(struct ieee80211_local *local,
578 struct ieee80211_sub_if_data *sdata,
580 void drv_offset_tsf(struct ieee80211_local *local,
581 struct ieee80211_sub_if_data *sdata,
583 void drv_reset_tsf(struct ieee80211_local *local,
584 struct ieee80211_sub_if_data *sdata);
586 static inline int drv_tx_last_beacon(struct ieee80211_local *local)
588 int ret = 0; /* default unsupported op for less congestion */
592 trace_drv_tx_last_beacon(local);
593 if (local->ops->tx_last_beacon)
594 ret = local->ops->tx_last_beacon(&local->hw);
595 trace_drv_return_int(local, ret);
599 int drv_ampdu_action(struct ieee80211_local *local,
600 struct ieee80211_sub_if_data *sdata,
601 struct ieee80211_ampdu_params *params);
603 static inline int drv_get_survey(struct ieee80211_local *local, int idx,
604 struct survey_info *survey)
606 int ret = -EOPNOTSUPP;
608 trace_drv_get_survey(local, idx, survey);
610 if (local->ops->get_survey)
611 ret = local->ops->get_survey(&local->hw, idx, survey);
613 trace_drv_return_int(local, ret);
618 static inline void drv_rfkill_poll(struct ieee80211_local *local)
622 if (local->ops->rfkill_poll)
623 local->ops->rfkill_poll(&local->hw);
626 static inline void drv_flush(struct ieee80211_local *local,
627 struct ieee80211_sub_if_data *sdata,
628 u32 queues, bool drop)
630 struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
634 if (sdata && !check_sdata_in_driver(sdata))
637 trace_drv_flush(local, queues, drop);
638 if (local->ops->flush)
639 local->ops->flush(&local->hw, vif, queues, drop);
640 trace_drv_return_void(local);
643 static inline void drv_channel_switch(struct ieee80211_local *local,
644 struct ieee80211_sub_if_data *sdata,
645 struct ieee80211_channel_switch *ch_switch)
649 trace_drv_channel_switch(local, sdata, ch_switch);
650 local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
651 trace_drv_return_void(local);
655 static inline int drv_set_antenna(struct ieee80211_local *local,
656 u32 tx_ant, u32 rx_ant)
658 int ret = -EOPNOTSUPP;
660 if (local->ops->set_antenna)
661 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
662 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
666 static inline int drv_get_antenna(struct ieee80211_local *local,
667 u32 *tx_ant, u32 *rx_ant)
669 int ret = -EOPNOTSUPP;
671 if (local->ops->get_antenna)
672 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
673 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
677 static inline int drv_remain_on_channel(struct ieee80211_local *local,
678 struct ieee80211_sub_if_data *sdata,
679 struct ieee80211_channel *chan,
680 unsigned int duration,
681 enum ieee80211_roc_type type)
687 trace_drv_remain_on_channel(local, sdata, chan, duration, type);
688 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
689 chan, duration, type);
690 trace_drv_return_int(local, ret);
695 static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
701 trace_drv_cancel_remain_on_channel(local);
702 ret = local->ops->cancel_remain_on_channel(&local->hw);
703 trace_drv_return_int(local, ret);
708 static inline int drv_set_ringparam(struct ieee80211_local *local,
715 trace_drv_set_ringparam(local, tx, rx);
716 if (local->ops->set_ringparam)
717 ret = local->ops->set_ringparam(&local->hw, tx, rx);
718 trace_drv_return_int(local, ret);
723 static inline void drv_get_ringparam(struct ieee80211_local *local,
724 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
728 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
729 if (local->ops->get_ringparam)
730 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
731 trace_drv_return_void(local);
734 static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
740 trace_drv_tx_frames_pending(local);
741 if (local->ops->tx_frames_pending)
742 ret = local->ops->tx_frames_pending(&local->hw);
743 trace_drv_return_bool(local, ret);
748 static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
749 struct ieee80211_sub_if_data *sdata,
750 const struct cfg80211_bitrate_mask *mask)
752 int ret = -EOPNOTSUPP;
756 if (!check_sdata_in_driver(sdata))
759 trace_drv_set_bitrate_mask(local, sdata, mask);
760 if (local->ops->set_bitrate_mask)
761 ret = local->ops->set_bitrate_mask(&local->hw,
763 trace_drv_return_int(local, ret);
768 static inline void drv_set_rekey_data(struct ieee80211_local *local,
769 struct ieee80211_sub_if_data *sdata,
770 struct cfg80211_gtk_rekey_data *data)
772 if (!check_sdata_in_driver(sdata))
775 trace_drv_set_rekey_data(local, sdata, data);
776 if (local->ops->set_rekey_data)
777 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
778 trace_drv_return_void(local);
781 static inline void drv_event_callback(struct ieee80211_local *local,
782 struct ieee80211_sub_if_data *sdata,
783 const struct ieee80211_event *event)
785 trace_drv_event_callback(local, sdata, event);
786 if (local->ops->event_callback)
787 local->ops->event_callback(&local->hw, &sdata->vif, event);
788 trace_drv_return_void(local);
792 drv_release_buffered_frames(struct ieee80211_local *local,
793 struct sta_info *sta, u16 tids, int num_frames,
794 enum ieee80211_frame_release_type reason,
797 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
799 if (local->ops->release_buffered_frames)
800 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
803 trace_drv_return_void(local);
807 drv_allow_buffered_frames(struct ieee80211_local *local,
808 struct sta_info *sta, u16 tids, int num_frames,
809 enum ieee80211_frame_release_type reason,
812 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
814 if (local->ops->allow_buffered_frames)
815 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
816 tids, num_frames, reason,
818 trace_drv_return_void(local);
821 static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
822 struct ieee80211_sub_if_data *sdata,
827 if (!check_sdata_in_driver(sdata))
829 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
831 trace_drv_mgd_prepare_tx(local, sdata, duration);
832 if (local->ops->mgd_prepare_tx)
833 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif, duration);
834 trace_drv_return_void(local);
838 drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
839 struct ieee80211_sub_if_data *sdata)
843 if (!check_sdata_in_driver(sdata))
845 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
847 trace_drv_mgd_protect_tdls_discover(local, sdata);
848 if (local->ops->mgd_protect_tdls_discover)
849 local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
850 trace_drv_return_void(local);
853 static inline int drv_add_chanctx(struct ieee80211_local *local,
854 struct ieee80211_chanctx *ctx)
856 int ret = -EOPNOTSUPP;
860 trace_drv_add_chanctx(local, ctx);
861 if (local->ops->add_chanctx)
862 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
863 trace_drv_return_int(local, ret);
865 ctx->driver_present = true;
870 static inline void drv_remove_chanctx(struct ieee80211_local *local,
871 struct ieee80211_chanctx *ctx)
875 if (WARN_ON(!ctx->driver_present))
878 trace_drv_remove_chanctx(local, ctx);
879 if (local->ops->remove_chanctx)
880 local->ops->remove_chanctx(&local->hw, &ctx->conf);
881 trace_drv_return_void(local);
882 ctx->driver_present = false;
885 static inline void drv_change_chanctx(struct ieee80211_local *local,
886 struct ieee80211_chanctx *ctx,
891 trace_drv_change_chanctx(local, ctx, changed);
892 if (local->ops->change_chanctx) {
893 WARN_ON_ONCE(!ctx->driver_present);
894 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
896 trace_drv_return_void(local);
899 static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
900 struct ieee80211_sub_if_data *sdata,
901 struct ieee80211_chanctx *ctx)
905 if (!check_sdata_in_driver(sdata))
908 trace_drv_assign_vif_chanctx(local, sdata, ctx);
909 if (local->ops->assign_vif_chanctx) {
910 WARN_ON_ONCE(!ctx->driver_present);
911 ret = local->ops->assign_vif_chanctx(&local->hw,
915 trace_drv_return_int(local, ret);
920 static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
921 struct ieee80211_sub_if_data *sdata,
922 struct ieee80211_chanctx *ctx)
926 if (!check_sdata_in_driver(sdata))
929 trace_drv_unassign_vif_chanctx(local, sdata, ctx);
930 if (local->ops->unassign_vif_chanctx) {
931 WARN_ON_ONCE(!ctx->driver_present);
932 local->ops->unassign_vif_chanctx(&local->hw,
936 trace_drv_return_void(local);
939 int drv_switch_vif_chanctx(struct ieee80211_local *local,
940 struct ieee80211_vif_chanctx_switch *vifs,
941 int n_vifs, enum ieee80211_chanctx_switch_mode mode);
943 static inline int drv_start_ap(struct ieee80211_local *local,
944 struct ieee80211_sub_if_data *sdata)
950 if (!check_sdata_in_driver(sdata))
953 trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
954 if (local->ops->start_ap)
955 ret = local->ops->start_ap(&local->hw, &sdata->vif);
956 trace_drv_return_int(local, ret);
960 static inline void drv_stop_ap(struct ieee80211_local *local,
961 struct ieee80211_sub_if_data *sdata)
963 if (!check_sdata_in_driver(sdata))
966 trace_drv_stop_ap(local, sdata);
967 if (local->ops->stop_ap)
968 local->ops->stop_ap(&local->hw, &sdata->vif);
969 trace_drv_return_void(local);
973 drv_reconfig_complete(struct ieee80211_local *local,
974 enum ieee80211_reconfig_type reconfig_type)
978 trace_drv_reconfig_complete(local, reconfig_type);
979 if (local->ops->reconfig_complete)
980 local->ops->reconfig_complete(&local->hw, reconfig_type);
981 trace_drv_return_void(local);
985 drv_set_default_unicast_key(struct ieee80211_local *local,
986 struct ieee80211_sub_if_data *sdata,
989 if (!check_sdata_in_driver(sdata))
992 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
994 trace_drv_set_default_unicast_key(local, sdata, key_idx);
995 if (local->ops->set_default_unicast_key)
996 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
998 trace_drv_return_void(local);
1001 #if IS_ENABLED(CONFIG_IPV6)
1002 static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1003 struct ieee80211_sub_if_data *sdata,
1004 struct inet6_dev *idev)
1006 trace_drv_ipv6_addr_change(local, sdata);
1007 if (local->ops->ipv6_addr_change)
1008 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1009 trace_drv_return_void(local);
1014 drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1015 struct cfg80211_chan_def *chandef)
1017 struct ieee80211_local *local = sdata->local;
1019 if (local->ops->channel_switch_beacon) {
1020 trace_drv_channel_switch_beacon(local, sdata, chandef);
1021 local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1027 drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
1028 struct ieee80211_channel_switch *ch_switch)
1030 struct ieee80211_local *local = sdata->local;
1033 if (!check_sdata_in_driver(sdata))
1036 trace_drv_pre_channel_switch(local, sdata, ch_switch);
1037 if (local->ops->pre_channel_switch)
1038 ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
1040 trace_drv_return_int(local, ret);
1045 drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1047 struct ieee80211_local *local = sdata->local;
1050 if (!check_sdata_in_driver(sdata))
1053 trace_drv_post_channel_switch(local, sdata);
1054 if (local->ops->post_channel_switch)
1055 ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1056 trace_drv_return_int(local, ret);
1061 drv_abort_channel_switch(struct ieee80211_sub_if_data *sdata)
1063 struct ieee80211_local *local = sdata->local;
1065 if (!check_sdata_in_driver(sdata))
1068 trace_drv_abort_channel_switch(local, sdata);
1070 if (local->ops->abort_channel_switch)
1071 local->ops->abort_channel_switch(&local->hw, &sdata->vif);
1075 drv_channel_switch_rx_beacon(struct ieee80211_sub_if_data *sdata,
1076 struct ieee80211_channel_switch *ch_switch)
1078 struct ieee80211_local *local = sdata->local;
1080 if (!check_sdata_in_driver(sdata))
1083 trace_drv_channel_switch_rx_beacon(local, sdata, ch_switch);
1084 if (local->ops->channel_switch_rx_beacon)
1085 local->ops->channel_switch_rx_beacon(&local->hw, &sdata->vif,
1089 static inline int drv_join_ibss(struct ieee80211_local *local,
1090 struct ieee80211_sub_if_data *sdata)
1095 if (!check_sdata_in_driver(sdata))
1098 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1099 if (local->ops->join_ibss)
1100 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1101 trace_drv_return_int(local, ret);
1105 static inline void drv_leave_ibss(struct ieee80211_local *local,
1106 struct ieee80211_sub_if_data *sdata)
1109 if (!check_sdata_in_driver(sdata))
1112 trace_drv_leave_ibss(local, sdata);
1113 if (local->ops->leave_ibss)
1114 local->ops->leave_ibss(&local->hw, &sdata->vif);
1115 trace_drv_return_void(local);
1118 static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
1119 struct sta_info *sta)
1123 trace_drv_get_expected_throughput(&sta->sta);
1124 if (local->ops->get_expected_throughput && sta->uploaded)
1125 ret = local->ops->get_expected_throughput(&local->hw, &sta->sta);
1126 trace_drv_return_u32(local, ret);
1131 static inline int drv_get_txpower(struct ieee80211_local *local,
1132 struct ieee80211_sub_if_data *sdata, int *dbm)
1136 if (!local->ops->get_txpower)
1139 ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
1140 trace_drv_get_txpower(local, sdata, *dbm, ret);
1146 drv_tdls_channel_switch(struct ieee80211_local *local,
1147 struct ieee80211_sub_if_data *sdata,
1148 struct ieee80211_sta *sta, u8 oper_class,
1149 struct cfg80211_chan_def *chandef,
1150 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
1155 if (!check_sdata_in_driver(sdata))
1158 if (!local->ops->tdls_channel_switch)
1161 trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
1162 ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
1163 oper_class, chandef, tmpl_skb,
1165 trace_drv_return_int(local, ret);
1170 drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
1171 struct ieee80211_sub_if_data *sdata,
1172 struct ieee80211_sta *sta)
1175 if (!check_sdata_in_driver(sdata))
1178 if (!local->ops->tdls_cancel_channel_switch)
1181 trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
1182 local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
1183 trace_drv_return_void(local);
1187 drv_tdls_recv_channel_switch(struct ieee80211_local *local,
1188 struct ieee80211_sub_if_data *sdata,
1189 struct ieee80211_tdls_ch_sw_params *params)
1191 trace_drv_tdls_recv_channel_switch(local, sdata, params);
1192 if (local->ops->tdls_recv_channel_switch)
1193 local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
1195 trace_drv_return_void(local);
1198 static inline void drv_wake_tx_queue(struct ieee80211_local *local,
1199 struct txq_info *txq)
1201 struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
1203 if (local->in_reconfig)
1206 if (!check_sdata_in_driver(sdata))
1209 trace_drv_wake_tx_queue(local, sdata, txq);
1210 local->ops->wake_tx_queue(&local->hw, &txq->txq);
1213 static inline void schedule_and_wake_txq(struct ieee80211_local *local,
1214 struct txq_info *txqi)
1216 ieee80211_schedule_txq(&local->hw, &txqi->txq);
1217 drv_wake_tx_queue(local, txqi);
1220 static inline int drv_can_aggregate_in_amsdu(struct ieee80211_local *local,
1221 struct sk_buff *head,
1222 struct sk_buff *skb)
1224 if (!local->ops->can_aggregate_in_amsdu)
1227 return local->ops->can_aggregate_in_amsdu(&local->hw, head, skb);
1231 drv_get_ftm_responder_stats(struct ieee80211_local *local,
1232 struct ieee80211_sub_if_data *sdata,
1233 struct cfg80211_ftm_responder_stats *ftm_stats)
1235 u32 ret = -EOPNOTSUPP;
1237 if (local->ops->get_ftm_responder_stats)
1238 ret = local->ops->get_ftm_responder_stats(&local->hw,
1241 trace_drv_get_ftm_responder_stats(local, sdata, ftm_stats);
1246 static inline int drv_start_pmsr(struct ieee80211_local *local,
1247 struct ieee80211_sub_if_data *sdata,
1248 struct cfg80211_pmsr_request *request)
1250 int ret = -EOPNOTSUPP;
1253 if (!check_sdata_in_driver(sdata))
1256 trace_drv_start_pmsr(local, sdata);
1258 if (local->ops->start_pmsr)
1259 ret = local->ops->start_pmsr(&local->hw, &sdata->vif, request);
1260 trace_drv_return_int(local, ret);
1265 static inline void drv_abort_pmsr(struct ieee80211_local *local,
1266 struct ieee80211_sub_if_data *sdata,
1267 struct cfg80211_pmsr_request *request)
1269 trace_drv_abort_pmsr(local, sdata);
1272 if (!check_sdata_in_driver(sdata))
1275 if (local->ops->abort_pmsr)
1276 local->ops->abort_pmsr(&local->hw, &sdata->vif, request);
1277 trace_drv_return_void(local);
1280 static inline int drv_start_nan(struct ieee80211_local *local,
1281 struct ieee80211_sub_if_data *sdata,
1282 struct cfg80211_nan_conf *conf)
1287 check_sdata_in_driver(sdata);
1289 trace_drv_start_nan(local, sdata, conf);
1290 ret = local->ops->start_nan(&local->hw, &sdata->vif, conf);
1291 trace_drv_return_int(local, ret);
1295 static inline void drv_stop_nan(struct ieee80211_local *local,
1296 struct ieee80211_sub_if_data *sdata)
1299 check_sdata_in_driver(sdata);
1301 trace_drv_stop_nan(local, sdata);
1302 local->ops->stop_nan(&local->hw, &sdata->vif);
1303 trace_drv_return_void(local);
1306 static inline int drv_nan_change_conf(struct ieee80211_local *local,
1307 struct ieee80211_sub_if_data *sdata,
1308 struct cfg80211_nan_conf *conf,
1314 check_sdata_in_driver(sdata);
1316 if (!local->ops->nan_change_conf)
1319 trace_drv_nan_change_conf(local, sdata, conf, changes);
1320 ret = local->ops->nan_change_conf(&local->hw, &sdata->vif, conf,
1322 trace_drv_return_int(local, ret);
1327 static inline int drv_add_nan_func(struct ieee80211_local *local,
1328 struct ieee80211_sub_if_data *sdata,
1329 const struct cfg80211_nan_func *nan_func)
1334 check_sdata_in_driver(sdata);
1336 if (!local->ops->add_nan_func)
1339 trace_drv_add_nan_func(local, sdata, nan_func);
1340 ret = local->ops->add_nan_func(&local->hw, &sdata->vif, nan_func);
1341 trace_drv_return_int(local, ret);
1346 static inline void drv_del_nan_func(struct ieee80211_local *local,
1347 struct ieee80211_sub_if_data *sdata,
1351 check_sdata_in_driver(sdata);
1353 trace_drv_del_nan_func(local, sdata, instance_id);
1354 if (local->ops->del_nan_func)
1355 local->ops->del_nan_func(&local->hw, &sdata->vif, instance_id);
1356 trace_drv_return_void(local);
1359 #endif /* __MAC80211_DRIVER_OPS */