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 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->flags & IEEE80211_SDATA_IN_DRIVER), \
17 "%s: Failed check-sdata-in-driver check, flags: 0x%x\n", \
18 sdata->dev ? sdata->dev->name : sdata->name, sdata->flags); \
21 static inline struct ieee80211_sub_if_data *
22 get_bss_sdata(struct ieee80211_sub_if_data *sdata)
24 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
25 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
31 static inline void drv_tx(struct ieee80211_local *local,
32 struct ieee80211_tx_control *control,
35 local->ops->tx(&local->hw, control, skb);
38 static inline void drv_sync_rx_queues(struct ieee80211_local *local,
41 if (local->ops->sync_rx_queues) {
42 trace_drv_sync_rx_queues(local, sta->sdata, &sta->sta);
43 local->ops->sync_rx_queues(&local->hw);
44 trace_drv_return_void(local);
48 static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata,
51 struct ieee80211_local *local = sdata->local;
52 if (local->ops->get_et_strings) {
53 trace_drv_get_et_strings(local, sset);
54 local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data);
55 trace_drv_return_void(local);
59 static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata,
60 struct ethtool_stats *stats,
63 struct ieee80211_local *local = sdata->local;
64 if (local->ops->get_et_stats) {
65 trace_drv_get_et_stats(local);
66 local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data);
67 trace_drv_return_void(local);
71 static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata,
74 struct ieee80211_local *local = sdata->local;
76 if (local->ops->get_et_sset_count) {
77 trace_drv_get_et_sset_count(local, sset);
78 rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif,
80 trace_drv_return_int(local, rv);
85 int drv_start(struct ieee80211_local *local);
86 void drv_stop(struct ieee80211_local *local);
89 static inline int drv_suspend(struct ieee80211_local *local,
90 struct cfg80211_wowlan *wowlan)
96 trace_drv_suspend(local);
97 ret = local->ops->suspend(&local->hw, wowlan);
98 trace_drv_return_int(local, ret);
102 static inline int drv_resume(struct ieee80211_local *local)
108 trace_drv_resume(local);
109 ret = local->ops->resume(&local->hw);
110 trace_drv_return_int(local, ret);
114 static inline void drv_set_wakeup(struct ieee80211_local *local,
119 if (!local->ops->set_wakeup)
122 trace_drv_set_wakeup(local, enabled);
123 local->ops->set_wakeup(&local->hw, enabled);
124 trace_drv_return_void(local);
128 int drv_add_interface(struct ieee80211_local *local,
129 struct ieee80211_sub_if_data *sdata);
131 int drv_change_interface(struct ieee80211_local *local,
132 struct ieee80211_sub_if_data *sdata,
133 enum nl80211_iftype type, bool p2p);
135 void drv_remove_interface(struct ieee80211_local *local,
136 struct ieee80211_sub_if_data *sdata);
138 static inline int drv_config(struct ieee80211_local *local, u32 changed)
144 trace_drv_config(local, changed);
145 ret = local->ops->config(&local->hw, changed);
146 trace_drv_return_int(local, ret);
150 static inline void drv_vif_cfg_changed(struct ieee80211_local *local,
151 struct ieee80211_sub_if_data *sdata,
156 if (!check_sdata_in_driver(sdata))
159 trace_drv_vif_cfg_changed(local, sdata, changed);
160 if (local->ops->vif_cfg_changed)
161 local->ops->vif_cfg_changed(&local->hw, &sdata->vif, changed);
162 else if (local->ops->bss_info_changed)
163 local->ops->bss_info_changed(&local->hw, &sdata->vif,
164 &sdata->vif.bss_conf, changed);
165 trace_drv_return_void(local);
168 static inline void drv_link_info_changed(struct ieee80211_local *local,
169 struct ieee80211_sub_if_data *sdata,
170 int link_id, u64 changed)
174 if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
175 BSS_CHANGED_BEACON_ENABLED) &&
176 sdata->vif.type != NL80211_IFTYPE_AP &&
177 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
178 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
179 sdata->vif.type != NL80211_IFTYPE_OCB))
182 if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
183 sdata->vif.type == NL80211_IFTYPE_NAN ||
184 (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
185 !sdata->vif.bss_conf.mu_mimo_owner &&
186 !(changed & BSS_CHANGED_TXPOWER))))
189 if (!check_sdata_in_driver(sdata))
192 trace_drv_link_info_changed(local, sdata, link_id, changed);
193 if (local->ops->link_info_changed)
194 local->ops->link_info_changed(&local->hw, &sdata->vif,
196 else if (local->ops->bss_info_changed)
197 local->ops->bss_info_changed(&local->hw, &sdata->vif,
198 &sdata->vif.bss_conf, changed);
199 trace_drv_return_void(local);
202 static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
203 struct netdev_hw_addr_list *mc_list)
207 trace_drv_prepare_multicast(local, mc_list->count);
209 if (local->ops->prepare_multicast)
210 ret = local->ops->prepare_multicast(&local->hw, mc_list);
212 trace_drv_return_u64(local, ret);
217 static inline void drv_configure_filter(struct ieee80211_local *local,
218 unsigned int changed_flags,
219 unsigned int *total_flags,
224 trace_drv_configure_filter(local, changed_flags, total_flags,
226 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
228 trace_drv_return_void(local);
231 static inline void drv_config_iface_filter(struct ieee80211_local *local,
232 struct ieee80211_sub_if_data *sdata,
233 unsigned int filter_flags,
234 unsigned int changed_flags)
238 trace_drv_config_iface_filter(local, sdata, filter_flags,
240 if (local->ops->config_iface_filter)
241 local->ops->config_iface_filter(&local->hw, &sdata->vif,
244 trace_drv_return_void(local);
247 static inline int drv_set_tim(struct ieee80211_local *local,
248 struct ieee80211_sta *sta, bool set)
251 trace_drv_set_tim(local, sta, set);
252 if (local->ops->set_tim)
253 ret = local->ops->set_tim(&local->hw, sta, set);
254 trace_drv_return_int(local, ret);
258 static inline int drv_set_key(struct ieee80211_local *local,
259 enum set_key_cmd cmd,
260 struct ieee80211_sub_if_data *sdata,
261 struct ieee80211_sta *sta,
262 struct ieee80211_key_conf *key)
268 sdata = get_bss_sdata(sdata);
269 if (!check_sdata_in_driver(sdata))
272 trace_drv_set_key(local, cmd, sdata, sta, key);
273 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
274 trace_drv_return_int(local, ret);
278 static inline void drv_update_tkip_key(struct ieee80211_local *local,
279 struct ieee80211_sub_if_data *sdata,
280 struct ieee80211_key_conf *conf,
281 struct sta_info *sta, u32 iv32,
284 struct ieee80211_sta *ista = NULL;
289 sdata = get_bss_sdata(sdata);
290 if (!check_sdata_in_driver(sdata))
293 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
294 if (local->ops->update_tkip_key)
295 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
296 ista, iv32, phase1key);
297 trace_drv_return_void(local);
300 static inline int drv_hw_scan(struct ieee80211_local *local,
301 struct ieee80211_sub_if_data *sdata,
302 struct ieee80211_scan_request *req)
308 if (!check_sdata_in_driver(sdata))
311 trace_drv_hw_scan(local, sdata);
312 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
313 trace_drv_return_int(local, ret);
317 static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
318 struct ieee80211_sub_if_data *sdata)
322 if (!check_sdata_in_driver(sdata))
325 trace_drv_cancel_hw_scan(local, sdata);
326 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
327 trace_drv_return_void(local);
331 drv_sched_scan_start(struct ieee80211_local *local,
332 struct ieee80211_sub_if_data *sdata,
333 struct cfg80211_sched_scan_request *req,
334 struct ieee80211_scan_ies *ies)
340 if (!check_sdata_in_driver(sdata))
343 trace_drv_sched_scan_start(local, sdata);
344 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
346 trace_drv_return_int(local, ret);
350 static inline int drv_sched_scan_stop(struct ieee80211_local *local,
351 struct ieee80211_sub_if_data *sdata)
357 if (!check_sdata_in_driver(sdata))
360 trace_drv_sched_scan_stop(local, sdata);
361 ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
362 trace_drv_return_int(local, ret);
367 static inline void drv_sw_scan_start(struct ieee80211_local *local,
368 struct ieee80211_sub_if_data *sdata,
373 trace_drv_sw_scan_start(local, sdata, mac_addr);
374 if (local->ops->sw_scan_start)
375 local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
376 trace_drv_return_void(local);
379 static inline void drv_sw_scan_complete(struct ieee80211_local *local,
380 struct ieee80211_sub_if_data *sdata)
384 trace_drv_sw_scan_complete(local, sdata);
385 if (local->ops->sw_scan_complete)
386 local->ops->sw_scan_complete(&local->hw, &sdata->vif);
387 trace_drv_return_void(local);
390 static inline int drv_get_stats(struct ieee80211_local *local,
391 struct ieee80211_low_level_stats *stats)
393 int ret = -EOPNOTSUPP;
397 if (local->ops->get_stats)
398 ret = local->ops->get_stats(&local->hw, stats);
399 trace_drv_get_stats(local, stats, ret);
404 static inline void drv_get_key_seq(struct ieee80211_local *local,
405 struct ieee80211_key *key,
406 struct ieee80211_key_seq *seq)
408 if (local->ops->get_key_seq)
409 local->ops->get_key_seq(&local->hw, &key->conf, seq);
410 trace_drv_get_key_seq(local, &key->conf);
413 static inline int drv_set_frag_threshold(struct ieee80211_local *local,
420 trace_drv_set_frag_threshold(local, value);
421 if (local->ops->set_frag_threshold)
422 ret = local->ops->set_frag_threshold(&local->hw, value);
423 trace_drv_return_int(local, ret);
427 static inline int drv_set_rts_threshold(struct ieee80211_local *local,
434 trace_drv_set_rts_threshold(local, value);
435 if (local->ops->set_rts_threshold)
436 ret = local->ops->set_rts_threshold(&local->hw, value);
437 trace_drv_return_int(local, ret);
441 static inline int drv_set_coverage_class(struct ieee80211_local *local,
447 trace_drv_set_coverage_class(local, value);
448 if (local->ops->set_coverage_class)
449 local->ops->set_coverage_class(&local->hw, value);
453 trace_drv_return_int(local, ret);
457 static inline void drv_sta_notify(struct ieee80211_local *local,
458 struct ieee80211_sub_if_data *sdata,
459 enum sta_notify_cmd cmd,
460 struct ieee80211_sta *sta)
462 sdata = get_bss_sdata(sdata);
463 if (!check_sdata_in_driver(sdata))
466 trace_drv_sta_notify(local, sdata, cmd, sta);
467 if (local->ops->sta_notify)
468 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
469 trace_drv_return_void(local);
472 static inline int drv_sta_add(struct ieee80211_local *local,
473 struct ieee80211_sub_if_data *sdata,
474 struct ieee80211_sta *sta)
480 sdata = get_bss_sdata(sdata);
481 if (!check_sdata_in_driver(sdata))
484 trace_drv_sta_add(local, sdata, sta);
485 if (local->ops->sta_add)
486 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
488 trace_drv_return_int(local, ret);
493 static inline void drv_sta_remove(struct ieee80211_local *local,
494 struct ieee80211_sub_if_data *sdata,
495 struct ieee80211_sta *sta)
499 sdata = get_bss_sdata(sdata);
500 if (!check_sdata_in_driver(sdata))
503 trace_drv_sta_remove(local, sdata, sta);
504 if (local->ops->sta_remove)
505 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
507 trace_drv_return_void(local);
510 #ifdef CONFIG_MAC80211_DEBUGFS
511 static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
512 struct ieee80211_sub_if_data *sdata,
513 struct ieee80211_sta *sta,
518 sdata = get_bss_sdata(sdata);
519 if (!check_sdata_in_driver(sdata))
522 if (local->ops->sta_add_debugfs)
523 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
528 static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
529 struct ieee80211_sub_if_data *sdata,
530 struct sta_info *sta)
534 sdata = get_bss_sdata(sdata);
535 if (!check_sdata_in_driver(sdata))
538 trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
539 if (local->ops->sta_pre_rcu_remove)
540 local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
542 trace_drv_return_void(local);
546 int drv_sta_state(struct ieee80211_local *local,
547 struct ieee80211_sub_if_data *sdata,
548 struct sta_info *sta,
549 enum ieee80211_sta_state old_state,
550 enum ieee80211_sta_state new_state);
553 int drv_sta_set_txpwr(struct ieee80211_local *local,
554 struct ieee80211_sub_if_data *sdata,
555 struct sta_info *sta);
557 void drv_sta_rc_update(struct ieee80211_local *local,
558 struct ieee80211_sub_if_data *sdata,
559 struct ieee80211_sta *sta, u32 changed);
561 static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
562 struct ieee80211_sub_if_data *sdata,
563 struct ieee80211_sta *sta)
565 sdata = get_bss_sdata(sdata);
566 if (!check_sdata_in_driver(sdata))
569 trace_drv_sta_rate_tbl_update(local, sdata, sta);
570 if (local->ops->sta_rate_tbl_update)
571 local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
573 trace_drv_return_void(local);
576 static inline void drv_sta_statistics(struct ieee80211_local *local,
577 struct ieee80211_sub_if_data *sdata,
578 struct ieee80211_sta *sta,
579 struct station_info *sinfo)
581 sdata = get_bss_sdata(sdata);
582 if (!check_sdata_in_driver(sdata))
585 trace_drv_sta_statistics(local, sdata, sta);
586 if (local->ops->sta_statistics)
587 local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
588 trace_drv_return_void(local);
591 int drv_conf_tx(struct ieee80211_local *local,
592 struct ieee80211_sub_if_data *sdata, u16 ac,
593 const struct ieee80211_tx_queue_params *params);
595 u64 drv_get_tsf(struct ieee80211_local *local,
596 struct ieee80211_sub_if_data *sdata);
597 void drv_set_tsf(struct ieee80211_local *local,
598 struct ieee80211_sub_if_data *sdata,
600 void drv_offset_tsf(struct ieee80211_local *local,
601 struct ieee80211_sub_if_data *sdata,
603 void drv_reset_tsf(struct ieee80211_local *local,
604 struct ieee80211_sub_if_data *sdata);
606 static inline int drv_tx_last_beacon(struct ieee80211_local *local)
608 int ret = 0; /* default unsupported op for less congestion */
612 trace_drv_tx_last_beacon(local);
613 if (local->ops->tx_last_beacon)
614 ret = local->ops->tx_last_beacon(&local->hw);
615 trace_drv_return_int(local, ret);
619 int drv_ampdu_action(struct ieee80211_local *local,
620 struct ieee80211_sub_if_data *sdata,
621 struct ieee80211_ampdu_params *params);
623 static inline int drv_get_survey(struct ieee80211_local *local, int idx,
624 struct survey_info *survey)
626 int ret = -EOPNOTSUPP;
628 trace_drv_get_survey(local, idx, survey);
630 if (local->ops->get_survey)
631 ret = local->ops->get_survey(&local->hw, idx, survey);
633 trace_drv_return_int(local, ret);
638 static inline void drv_rfkill_poll(struct ieee80211_local *local)
642 if (local->ops->rfkill_poll)
643 local->ops->rfkill_poll(&local->hw);
646 static inline void drv_flush(struct ieee80211_local *local,
647 struct ieee80211_sub_if_data *sdata,
648 u32 queues, bool drop)
650 struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
654 if (sdata && !check_sdata_in_driver(sdata))
657 trace_drv_flush(local, queues, drop);
658 if (local->ops->flush)
659 local->ops->flush(&local->hw, vif, queues, drop);
660 trace_drv_return_void(local);
663 static inline void drv_channel_switch(struct ieee80211_local *local,
664 struct ieee80211_sub_if_data *sdata,
665 struct ieee80211_channel_switch *ch_switch)
669 trace_drv_channel_switch(local, sdata, ch_switch);
670 local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
671 trace_drv_return_void(local);
675 static inline int drv_set_antenna(struct ieee80211_local *local,
676 u32 tx_ant, u32 rx_ant)
678 int ret = -EOPNOTSUPP;
680 if (local->ops->set_antenna)
681 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
682 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
686 static inline int drv_get_antenna(struct ieee80211_local *local,
687 u32 *tx_ant, u32 *rx_ant)
689 int ret = -EOPNOTSUPP;
691 if (local->ops->get_antenna)
692 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
693 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
697 static inline int drv_remain_on_channel(struct ieee80211_local *local,
698 struct ieee80211_sub_if_data *sdata,
699 struct ieee80211_channel *chan,
700 unsigned int duration,
701 enum ieee80211_roc_type type)
707 trace_drv_remain_on_channel(local, sdata, chan, duration, type);
708 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
709 chan, duration, type);
710 trace_drv_return_int(local, ret);
716 drv_cancel_remain_on_channel(struct ieee80211_local *local,
717 struct ieee80211_sub_if_data *sdata)
723 trace_drv_cancel_remain_on_channel(local, sdata);
724 ret = local->ops->cancel_remain_on_channel(&local->hw, &sdata->vif);
725 trace_drv_return_int(local, ret);
730 static inline int drv_set_ringparam(struct ieee80211_local *local,
737 trace_drv_set_ringparam(local, tx, rx);
738 if (local->ops->set_ringparam)
739 ret = local->ops->set_ringparam(&local->hw, tx, rx);
740 trace_drv_return_int(local, ret);
745 static inline void drv_get_ringparam(struct ieee80211_local *local,
746 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
750 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
751 if (local->ops->get_ringparam)
752 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
753 trace_drv_return_void(local);
756 static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
762 trace_drv_tx_frames_pending(local);
763 if (local->ops->tx_frames_pending)
764 ret = local->ops->tx_frames_pending(&local->hw);
765 trace_drv_return_bool(local, ret);
770 static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
771 struct ieee80211_sub_if_data *sdata,
772 const struct cfg80211_bitrate_mask *mask)
774 int ret = -EOPNOTSUPP;
778 if (!check_sdata_in_driver(sdata))
781 trace_drv_set_bitrate_mask(local, sdata, mask);
782 if (local->ops->set_bitrate_mask)
783 ret = local->ops->set_bitrate_mask(&local->hw,
785 trace_drv_return_int(local, ret);
790 static inline void drv_set_rekey_data(struct ieee80211_local *local,
791 struct ieee80211_sub_if_data *sdata,
792 struct cfg80211_gtk_rekey_data *data)
794 if (!check_sdata_in_driver(sdata))
797 trace_drv_set_rekey_data(local, sdata, data);
798 if (local->ops->set_rekey_data)
799 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
800 trace_drv_return_void(local);
803 static inline void drv_event_callback(struct ieee80211_local *local,
804 struct ieee80211_sub_if_data *sdata,
805 const struct ieee80211_event *event)
807 trace_drv_event_callback(local, sdata, event);
808 if (local->ops->event_callback)
809 local->ops->event_callback(&local->hw, &sdata->vif, event);
810 trace_drv_return_void(local);
814 drv_release_buffered_frames(struct ieee80211_local *local,
815 struct sta_info *sta, u16 tids, int num_frames,
816 enum ieee80211_frame_release_type reason,
819 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
821 if (local->ops->release_buffered_frames)
822 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
825 trace_drv_return_void(local);
829 drv_allow_buffered_frames(struct ieee80211_local *local,
830 struct sta_info *sta, u16 tids, int num_frames,
831 enum ieee80211_frame_release_type reason,
834 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
836 if (local->ops->allow_buffered_frames)
837 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
838 tids, num_frames, reason,
840 trace_drv_return_void(local);
843 static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
844 struct ieee80211_sub_if_data *sdata,
845 struct ieee80211_prep_tx_info *info)
849 if (!check_sdata_in_driver(sdata))
851 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
853 trace_drv_mgd_prepare_tx(local, sdata, info->duration,
854 info->subtype, info->success);
855 if (local->ops->mgd_prepare_tx)
856 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif, info);
857 trace_drv_return_void(local);
860 static inline void drv_mgd_complete_tx(struct ieee80211_local *local,
861 struct ieee80211_sub_if_data *sdata,
862 struct ieee80211_prep_tx_info *info)
866 if (!check_sdata_in_driver(sdata))
868 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
870 trace_drv_mgd_complete_tx(local, sdata, info->duration,
871 info->subtype, info->success);
872 if (local->ops->mgd_complete_tx)
873 local->ops->mgd_complete_tx(&local->hw, &sdata->vif, info);
874 trace_drv_return_void(local);
878 drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
879 struct ieee80211_sub_if_data *sdata)
883 if (!check_sdata_in_driver(sdata))
885 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
887 trace_drv_mgd_protect_tdls_discover(local, sdata);
888 if (local->ops->mgd_protect_tdls_discover)
889 local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
890 trace_drv_return_void(local);
893 static inline int drv_add_chanctx(struct ieee80211_local *local,
894 struct ieee80211_chanctx *ctx)
896 int ret = -EOPNOTSUPP;
900 trace_drv_add_chanctx(local, ctx);
901 if (local->ops->add_chanctx)
902 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
903 trace_drv_return_int(local, ret);
905 ctx->driver_present = true;
910 static inline void drv_remove_chanctx(struct ieee80211_local *local,
911 struct ieee80211_chanctx *ctx)
915 if (WARN_ON(!ctx->driver_present))
918 trace_drv_remove_chanctx(local, ctx);
919 if (local->ops->remove_chanctx)
920 local->ops->remove_chanctx(&local->hw, &ctx->conf);
921 trace_drv_return_void(local);
922 ctx->driver_present = false;
925 static inline void drv_change_chanctx(struct ieee80211_local *local,
926 struct ieee80211_chanctx *ctx,
931 trace_drv_change_chanctx(local, ctx, changed);
932 if (local->ops->change_chanctx) {
933 WARN_ON_ONCE(!ctx->driver_present);
934 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
936 trace_drv_return_void(local);
939 static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
940 struct ieee80211_sub_if_data *sdata,
941 unsigned int link_id,
942 struct ieee80211_chanctx *ctx)
946 if (!check_sdata_in_driver(sdata))
949 trace_drv_assign_vif_chanctx(local, sdata, link_id, ctx);
950 if (local->ops->assign_vif_chanctx) {
951 WARN_ON_ONCE(!ctx->driver_present);
952 ret = local->ops->assign_vif_chanctx(&local->hw,
957 trace_drv_return_int(local, ret);
962 static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
963 struct ieee80211_sub_if_data *sdata,
964 unsigned int link_id,
965 struct ieee80211_chanctx *ctx)
969 if (!check_sdata_in_driver(sdata))
972 trace_drv_unassign_vif_chanctx(local, sdata, link_id, ctx);
973 if (local->ops->unassign_vif_chanctx) {
974 WARN_ON_ONCE(!ctx->driver_present);
975 local->ops->unassign_vif_chanctx(&local->hw,
980 trace_drv_return_void(local);
983 int drv_switch_vif_chanctx(struct ieee80211_local *local,
984 struct ieee80211_vif_chanctx_switch *vifs,
985 int n_vifs, enum ieee80211_chanctx_switch_mode mode);
987 static inline int drv_start_ap(struct ieee80211_local *local,
988 struct ieee80211_sub_if_data *sdata,
989 unsigned int link_id)
995 if (!check_sdata_in_driver(sdata))
998 trace_drv_start_ap(local, sdata, sdata->vif.link_conf[link_id],
1000 if (local->ops->start_ap)
1001 ret = local->ops->start_ap(&local->hw, &sdata->vif, link_id);
1002 trace_drv_return_int(local, ret);
1006 static inline void drv_stop_ap(struct ieee80211_local *local,
1007 struct ieee80211_sub_if_data *sdata,
1008 unsigned int link_id)
1010 if (!check_sdata_in_driver(sdata))
1013 trace_drv_stop_ap(local, sdata, link_id);
1014 if (local->ops->stop_ap)
1015 local->ops->stop_ap(&local->hw, &sdata->vif, link_id);
1016 trace_drv_return_void(local);
1020 drv_reconfig_complete(struct ieee80211_local *local,
1021 enum ieee80211_reconfig_type reconfig_type)
1025 trace_drv_reconfig_complete(local, reconfig_type);
1026 if (local->ops->reconfig_complete)
1027 local->ops->reconfig_complete(&local->hw, reconfig_type);
1028 trace_drv_return_void(local);
1032 drv_set_default_unicast_key(struct ieee80211_local *local,
1033 struct ieee80211_sub_if_data *sdata,
1036 if (!check_sdata_in_driver(sdata))
1039 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1041 trace_drv_set_default_unicast_key(local, sdata, key_idx);
1042 if (local->ops->set_default_unicast_key)
1043 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1045 trace_drv_return_void(local);
1048 #if IS_ENABLED(CONFIG_IPV6)
1049 static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1050 struct ieee80211_sub_if_data *sdata,
1051 struct inet6_dev *idev)
1053 trace_drv_ipv6_addr_change(local, sdata);
1054 if (local->ops->ipv6_addr_change)
1055 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1056 trace_drv_return_void(local);
1061 drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1062 struct cfg80211_chan_def *chandef)
1064 struct ieee80211_local *local = sdata->local;
1066 if (local->ops->channel_switch_beacon) {
1067 trace_drv_channel_switch_beacon(local, sdata, chandef);
1068 local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1074 drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
1075 struct ieee80211_channel_switch *ch_switch)
1077 struct ieee80211_local *local = sdata->local;
1080 if (!check_sdata_in_driver(sdata))
1083 trace_drv_pre_channel_switch(local, sdata, ch_switch);
1084 if (local->ops->pre_channel_switch)
1085 ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
1087 trace_drv_return_int(local, ret);
1092 drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1094 struct ieee80211_local *local = sdata->local;
1097 if (!check_sdata_in_driver(sdata))
1100 trace_drv_post_channel_switch(local, sdata);
1101 if (local->ops->post_channel_switch)
1102 ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1103 trace_drv_return_int(local, ret);
1108 drv_abort_channel_switch(struct ieee80211_sub_if_data *sdata)
1110 struct ieee80211_local *local = sdata->local;
1112 if (!check_sdata_in_driver(sdata))
1115 trace_drv_abort_channel_switch(local, sdata);
1117 if (local->ops->abort_channel_switch)
1118 local->ops->abort_channel_switch(&local->hw, &sdata->vif);
1122 drv_channel_switch_rx_beacon(struct ieee80211_sub_if_data *sdata,
1123 struct ieee80211_channel_switch *ch_switch)
1125 struct ieee80211_local *local = sdata->local;
1127 if (!check_sdata_in_driver(sdata))
1130 trace_drv_channel_switch_rx_beacon(local, sdata, ch_switch);
1131 if (local->ops->channel_switch_rx_beacon)
1132 local->ops->channel_switch_rx_beacon(&local->hw, &sdata->vif,
1136 static inline int drv_join_ibss(struct ieee80211_local *local,
1137 struct ieee80211_sub_if_data *sdata)
1142 if (!check_sdata_in_driver(sdata))
1145 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1146 if (local->ops->join_ibss)
1147 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1148 trace_drv_return_int(local, ret);
1152 static inline void drv_leave_ibss(struct ieee80211_local *local,
1153 struct ieee80211_sub_if_data *sdata)
1156 if (!check_sdata_in_driver(sdata))
1159 trace_drv_leave_ibss(local, sdata);
1160 if (local->ops->leave_ibss)
1161 local->ops->leave_ibss(&local->hw, &sdata->vif);
1162 trace_drv_return_void(local);
1165 static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
1166 struct sta_info *sta)
1170 trace_drv_get_expected_throughput(&sta->sta);
1171 if (local->ops->get_expected_throughput && sta->uploaded)
1172 ret = local->ops->get_expected_throughput(&local->hw, &sta->sta);
1173 trace_drv_return_u32(local, ret);
1178 static inline int drv_get_txpower(struct ieee80211_local *local,
1179 struct ieee80211_sub_if_data *sdata, int *dbm)
1183 if (!local->ops->get_txpower)
1186 ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
1187 trace_drv_get_txpower(local, sdata, *dbm, ret);
1193 drv_tdls_channel_switch(struct ieee80211_local *local,
1194 struct ieee80211_sub_if_data *sdata,
1195 struct ieee80211_sta *sta, u8 oper_class,
1196 struct cfg80211_chan_def *chandef,
1197 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
1202 if (!check_sdata_in_driver(sdata))
1205 if (!local->ops->tdls_channel_switch)
1208 trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
1209 ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
1210 oper_class, chandef, tmpl_skb,
1212 trace_drv_return_int(local, ret);
1217 drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
1218 struct ieee80211_sub_if_data *sdata,
1219 struct ieee80211_sta *sta)
1222 if (!check_sdata_in_driver(sdata))
1225 if (!local->ops->tdls_cancel_channel_switch)
1228 trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
1229 local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
1230 trace_drv_return_void(local);
1234 drv_tdls_recv_channel_switch(struct ieee80211_local *local,
1235 struct ieee80211_sub_if_data *sdata,
1236 struct ieee80211_tdls_ch_sw_params *params)
1238 trace_drv_tdls_recv_channel_switch(local, sdata, params);
1239 if (local->ops->tdls_recv_channel_switch)
1240 local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
1242 trace_drv_return_void(local);
1245 static inline void drv_wake_tx_queue(struct ieee80211_local *local,
1246 struct txq_info *txq)
1248 struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
1250 /* In reconfig don't transmit now, but mark for waking later */
1251 if (local->in_reconfig) {
1252 set_bit(IEEE80211_TXQ_STOP_NETIF_TX, &txq->flags);
1256 if (!check_sdata_in_driver(sdata))
1259 trace_drv_wake_tx_queue(local, sdata, txq);
1260 local->ops->wake_tx_queue(&local->hw, &txq->txq);
1263 static inline void schedule_and_wake_txq(struct ieee80211_local *local,
1264 struct txq_info *txqi)
1266 ieee80211_schedule_txq(&local->hw, &txqi->txq);
1267 drv_wake_tx_queue(local, txqi);
1270 static inline int drv_can_aggregate_in_amsdu(struct ieee80211_local *local,
1271 struct sk_buff *head,
1272 struct sk_buff *skb)
1274 if (!local->ops->can_aggregate_in_amsdu)
1277 return local->ops->can_aggregate_in_amsdu(&local->hw, head, skb);
1281 drv_get_ftm_responder_stats(struct ieee80211_local *local,
1282 struct ieee80211_sub_if_data *sdata,
1283 struct cfg80211_ftm_responder_stats *ftm_stats)
1285 u32 ret = -EOPNOTSUPP;
1287 if (local->ops->get_ftm_responder_stats)
1288 ret = local->ops->get_ftm_responder_stats(&local->hw,
1291 trace_drv_get_ftm_responder_stats(local, sdata, ftm_stats);
1296 static inline int drv_start_pmsr(struct ieee80211_local *local,
1297 struct ieee80211_sub_if_data *sdata,
1298 struct cfg80211_pmsr_request *request)
1300 int ret = -EOPNOTSUPP;
1303 if (!check_sdata_in_driver(sdata))
1306 trace_drv_start_pmsr(local, sdata);
1308 if (local->ops->start_pmsr)
1309 ret = local->ops->start_pmsr(&local->hw, &sdata->vif, request);
1310 trace_drv_return_int(local, ret);
1315 static inline void drv_abort_pmsr(struct ieee80211_local *local,
1316 struct ieee80211_sub_if_data *sdata,
1317 struct cfg80211_pmsr_request *request)
1319 trace_drv_abort_pmsr(local, sdata);
1322 if (!check_sdata_in_driver(sdata))
1325 if (local->ops->abort_pmsr)
1326 local->ops->abort_pmsr(&local->hw, &sdata->vif, request);
1327 trace_drv_return_void(local);
1330 static inline int drv_start_nan(struct ieee80211_local *local,
1331 struct ieee80211_sub_if_data *sdata,
1332 struct cfg80211_nan_conf *conf)
1337 check_sdata_in_driver(sdata);
1339 trace_drv_start_nan(local, sdata, conf);
1340 ret = local->ops->start_nan(&local->hw, &sdata->vif, conf);
1341 trace_drv_return_int(local, ret);
1345 static inline void drv_stop_nan(struct ieee80211_local *local,
1346 struct ieee80211_sub_if_data *sdata)
1349 check_sdata_in_driver(sdata);
1351 trace_drv_stop_nan(local, sdata);
1352 local->ops->stop_nan(&local->hw, &sdata->vif);
1353 trace_drv_return_void(local);
1356 static inline int drv_nan_change_conf(struct ieee80211_local *local,
1357 struct ieee80211_sub_if_data *sdata,
1358 struct cfg80211_nan_conf *conf,
1364 check_sdata_in_driver(sdata);
1366 if (!local->ops->nan_change_conf)
1369 trace_drv_nan_change_conf(local, sdata, conf, changes);
1370 ret = local->ops->nan_change_conf(&local->hw, &sdata->vif, conf,
1372 trace_drv_return_int(local, ret);
1377 static inline int drv_add_nan_func(struct ieee80211_local *local,
1378 struct ieee80211_sub_if_data *sdata,
1379 const struct cfg80211_nan_func *nan_func)
1384 check_sdata_in_driver(sdata);
1386 if (!local->ops->add_nan_func)
1389 trace_drv_add_nan_func(local, sdata, nan_func);
1390 ret = local->ops->add_nan_func(&local->hw, &sdata->vif, nan_func);
1391 trace_drv_return_int(local, ret);
1396 static inline void drv_del_nan_func(struct ieee80211_local *local,
1397 struct ieee80211_sub_if_data *sdata,
1401 check_sdata_in_driver(sdata);
1403 trace_drv_del_nan_func(local, sdata, instance_id);
1404 if (local->ops->del_nan_func)
1405 local->ops->del_nan_func(&local->hw, &sdata->vif, instance_id);
1406 trace_drv_return_void(local);
1409 static inline int drv_set_tid_config(struct ieee80211_local *local,
1410 struct ieee80211_sub_if_data *sdata,
1411 struct ieee80211_sta *sta,
1412 struct cfg80211_tid_config *tid_conf)
1417 ret = local->ops->set_tid_config(&local->hw, &sdata->vif, sta,
1419 trace_drv_return_int(local, ret);
1424 static inline int drv_reset_tid_config(struct ieee80211_local *local,
1425 struct ieee80211_sub_if_data *sdata,
1426 struct ieee80211_sta *sta, u8 tids)
1431 ret = local->ops->reset_tid_config(&local->hw, &sdata->vif, sta, tids);
1432 trace_drv_return_int(local, ret);
1437 static inline void drv_update_vif_offload(struct ieee80211_local *local,
1438 struct ieee80211_sub_if_data *sdata)
1441 check_sdata_in_driver(sdata);
1443 if (!local->ops->update_vif_offload)
1446 trace_drv_update_vif_offload(local, sdata);
1447 local->ops->update_vif_offload(&local->hw, &sdata->vif);
1448 trace_drv_return_void(local);
1451 static inline void drv_sta_set_4addr(struct ieee80211_local *local,
1452 struct ieee80211_sub_if_data *sdata,
1453 struct ieee80211_sta *sta, bool enabled)
1455 sdata = get_bss_sdata(sdata);
1456 if (!check_sdata_in_driver(sdata))
1459 trace_drv_sta_set_4addr(local, sdata, sta, enabled);
1460 if (local->ops->sta_set_4addr)
1461 local->ops->sta_set_4addr(&local->hw, &sdata->vif, sta, enabled);
1462 trace_drv_return_void(local);
1465 static inline void drv_sta_set_decap_offload(struct ieee80211_local *local,
1466 struct ieee80211_sub_if_data *sdata,
1467 struct ieee80211_sta *sta,
1470 sdata = get_bss_sdata(sdata);
1471 if (!check_sdata_in_driver(sdata))
1474 trace_drv_sta_set_decap_offload(local, sdata, sta, enabled);
1475 if (local->ops->sta_set_decap_offload)
1476 local->ops->sta_set_decap_offload(&local->hw, &sdata->vif, sta,
1478 trace_drv_return_void(local);
1481 static inline void drv_add_twt_setup(struct ieee80211_local *local,
1482 struct ieee80211_sub_if_data *sdata,
1483 struct ieee80211_sta *sta,
1484 struct ieee80211_twt_setup *twt)
1486 struct ieee80211_twt_params *twt_agrt;
1490 if (!check_sdata_in_driver(sdata))
1493 twt_agrt = (void *)twt->params;
1495 trace_drv_add_twt_setup(local, sta, twt, twt_agrt);
1496 local->ops->add_twt_setup(&local->hw, sta, twt);
1497 trace_drv_return_void(local);
1500 static inline void drv_twt_teardown_request(struct ieee80211_local *local,
1501 struct ieee80211_sub_if_data *sdata,
1502 struct ieee80211_sta *sta,
1506 if (!check_sdata_in_driver(sdata))
1509 if (!local->ops->twt_teardown_request)
1512 trace_drv_twt_teardown_request(local, sta, flowid);
1513 local->ops->twt_teardown_request(&local->hw, sta, flowid);
1514 trace_drv_return_void(local);
1517 static inline int drv_net_fill_forward_path(struct ieee80211_local *local,
1518 struct ieee80211_sub_if_data *sdata,
1519 struct ieee80211_sta *sta,
1520 struct net_device_path_ctx *ctx,
1521 struct net_device_path *path)
1523 int ret = -EOPNOTSUPP;
1525 sdata = get_bss_sdata(sdata);
1526 if (!check_sdata_in_driver(sdata))
1529 trace_drv_net_fill_forward_path(local, sdata, sta);
1530 if (local->ops->net_fill_forward_path)
1531 ret = local->ops->net_fill_forward_path(&local->hw,
1534 trace_drv_return_int(local, ret);
1539 static inline 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])
1544 int ret = -EOPNOTSUPP;
1548 if (!check_sdata_in_driver(sdata))
1551 trace_drv_change_vif_links(local, sdata, old_links, new_links);
1552 if (local->ops->change_vif_links)
1553 ret = local->ops->change_vif_links(&local->hw, &sdata->vif,
1554 old_links, new_links, old);
1555 trace_drv_return_int(local, ret);
1560 static inline int drv_change_sta_links(struct ieee80211_local *local,
1561 struct ieee80211_sub_if_data *sdata,
1562 struct ieee80211_sta *sta,
1563 u16 old_links, u16 new_links)
1565 int ret = -EOPNOTSUPP;
1569 if (!check_sdata_in_driver(sdata))
1572 trace_drv_change_sta_links(local, sdata, sta, old_links, new_links);
1573 if (local->ops->change_sta_links)
1574 ret = local->ops->change_sta_links(&local->hw, &sdata->vif, sta,
1575 old_links, new_links);
1576 trace_drv_return_int(local, ret);
1581 #endif /* __MAC80211_DRIVER_OPS */