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)
994 if (!check_sdata_in_driver(sdata))
997 trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
998 if (local->ops->start_ap)
999 ret = local->ops->start_ap(&local->hw, &sdata->vif);
1000 trace_drv_return_int(local, ret);
1004 static inline void drv_stop_ap(struct ieee80211_local *local,
1005 struct ieee80211_sub_if_data *sdata)
1007 if (!check_sdata_in_driver(sdata))
1010 trace_drv_stop_ap(local, sdata);
1011 if (local->ops->stop_ap)
1012 local->ops->stop_ap(&local->hw, &sdata->vif);
1013 trace_drv_return_void(local);
1017 drv_reconfig_complete(struct ieee80211_local *local,
1018 enum ieee80211_reconfig_type reconfig_type)
1022 trace_drv_reconfig_complete(local, reconfig_type);
1023 if (local->ops->reconfig_complete)
1024 local->ops->reconfig_complete(&local->hw, reconfig_type);
1025 trace_drv_return_void(local);
1029 drv_set_default_unicast_key(struct ieee80211_local *local,
1030 struct ieee80211_sub_if_data *sdata,
1033 if (!check_sdata_in_driver(sdata))
1036 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1038 trace_drv_set_default_unicast_key(local, sdata, key_idx);
1039 if (local->ops->set_default_unicast_key)
1040 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1042 trace_drv_return_void(local);
1045 #if IS_ENABLED(CONFIG_IPV6)
1046 static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1047 struct ieee80211_sub_if_data *sdata,
1048 struct inet6_dev *idev)
1050 trace_drv_ipv6_addr_change(local, sdata);
1051 if (local->ops->ipv6_addr_change)
1052 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1053 trace_drv_return_void(local);
1058 drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1059 struct cfg80211_chan_def *chandef)
1061 struct ieee80211_local *local = sdata->local;
1063 if (local->ops->channel_switch_beacon) {
1064 trace_drv_channel_switch_beacon(local, sdata, chandef);
1065 local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1071 drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
1072 struct ieee80211_channel_switch *ch_switch)
1074 struct ieee80211_local *local = sdata->local;
1077 if (!check_sdata_in_driver(sdata))
1080 trace_drv_pre_channel_switch(local, sdata, ch_switch);
1081 if (local->ops->pre_channel_switch)
1082 ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
1084 trace_drv_return_int(local, ret);
1089 drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1091 struct ieee80211_local *local = sdata->local;
1094 if (!check_sdata_in_driver(sdata))
1097 trace_drv_post_channel_switch(local, sdata);
1098 if (local->ops->post_channel_switch)
1099 ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1100 trace_drv_return_int(local, ret);
1105 drv_abort_channel_switch(struct ieee80211_sub_if_data *sdata)
1107 struct ieee80211_local *local = sdata->local;
1109 if (!check_sdata_in_driver(sdata))
1112 trace_drv_abort_channel_switch(local, sdata);
1114 if (local->ops->abort_channel_switch)
1115 local->ops->abort_channel_switch(&local->hw, &sdata->vif);
1119 drv_channel_switch_rx_beacon(struct ieee80211_sub_if_data *sdata,
1120 struct ieee80211_channel_switch *ch_switch)
1122 struct ieee80211_local *local = sdata->local;
1124 if (!check_sdata_in_driver(sdata))
1127 trace_drv_channel_switch_rx_beacon(local, sdata, ch_switch);
1128 if (local->ops->channel_switch_rx_beacon)
1129 local->ops->channel_switch_rx_beacon(&local->hw, &sdata->vif,
1133 static inline int drv_join_ibss(struct ieee80211_local *local,
1134 struct ieee80211_sub_if_data *sdata)
1139 if (!check_sdata_in_driver(sdata))
1142 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1143 if (local->ops->join_ibss)
1144 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1145 trace_drv_return_int(local, ret);
1149 static inline void drv_leave_ibss(struct ieee80211_local *local,
1150 struct ieee80211_sub_if_data *sdata)
1153 if (!check_sdata_in_driver(sdata))
1156 trace_drv_leave_ibss(local, sdata);
1157 if (local->ops->leave_ibss)
1158 local->ops->leave_ibss(&local->hw, &sdata->vif);
1159 trace_drv_return_void(local);
1162 static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
1163 struct sta_info *sta)
1167 trace_drv_get_expected_throughput(&sta->sta);
1168 if (local->ops->get_expected_throughput && sta->uploaded)
1169 ret = local->ops->get_expected_throughput(&local->hw, &sta->sta);
1170 trace_drv_return_u32(local, ret);
1175 static inline int drv_get_txpower(struct ieee80211_local *local,
1176 struct ieee80211_sub_if_data *sdata, int *dbm)
1180 if (!local->ops->get_txpower)
1183 ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
1184 trace_drv_get_txpower(local, sdata, *dbm, ret);
1190 drv_tdls_channel_switch(struct ieee80211_local *local,
1191 struct ieee80211_sub_if_data *sdata,
1192 struct ieee80211_sta *sta, u8 oper_class,
1193 struct cfg80211_chan_def *chandef,
1194 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
1199 if (!check_sdata_in_driver(sdata))
1202 if (!local->ops->tdls_channel_switch)
1205 trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
1206 ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
1207 oper_class, chandef, tmpl_skb,
1209 trace_drv_return_int(local, ret);
1214 drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
1215 struct ieee80211_sub_if_data *sdata,
1216 struct ieee80211_sta *sta)
1219 if (!check_sdata_in_driver(sdata))
1222 if (!local->ops->tdls_cancel_channel_switch)
1225 trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
1226 local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
1227 trace_drv_return_void(local);
1231 drv_tdls_recv_channel_switch(struct ieee80211_local *local,
1232 struct ieee80211_sub_if_data *sdata,
1233 struct ieee80211_tdls_ch_sw_params *params)
1235 trace_drv_tdls_recv_channel_switch(local, sdata, params);
1236 if (local->ops->tdls_recv_channel_switch)
1237 local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
1239 trace_drv_return_void(local);
1242 static inline void drv_wake_tx_queue(struct ieee80211_local *local,
1243 struct txq_info *txq)
1245 struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
1247 /* In reconfig don't transmit now, but mark for waking later */
1248 if (local->in_reconfig) {
1249 set_bit(IEEE80211_TXQ_STOP_NETIF_TX, &txq->flags);
1253 if (!check_sdata_in_driver(sdata))
1256 trace_drv_wake_tx_queue(local, sdata, txq);
1257 local->ops->wake_tx_queue(&local->hw, &txq->txq);
1260 static inline void schedule_and_wake_txq(struct ieee80211_local *local,
1261 struct txq_info *txqi)
1263 ieee80211_schedule_txq(&local->hw, &txqi->txq);
1264 drv_wake_tx_queue(local, txqi);
1267 static inline int drv_can_aggregate_in_amsdu(struct ieee80211_local *local,
1268 struct sk_buff *head,
1269 struct sk_buff *skb)
1271 if (!local->ops->can_aggregate_in_amsdu)
1274 return local->ops->can_aggregate_in_amsdu(&local->hw, head, skb);
1278 drv_get_ftm_responder_stats(struct ieee80211_local *local,
1279 struct ieee80211_sub_if_data *sdata,
1280 struct cfg80211_ftm_responder_stats *ftm_stats)
1282 u32 ret = -EOPNOTSUPP;
1284 if (local->ops->get_ftm_responder_stats)
1285 ret = local->ops->get_ftm_responder_stats(&local->hw,
1288 trace_drv_get_ftm_responder_stats(local, sdata, ftm_stats);
1293 static inline int drv_start_pmsr(struct ieee80211_local *local,
1294 struct ieee80211_sub_if_data *sdata,
1295 struct cfg80211_pmsr_request *request)
1297 int ret = -EOPNOTSUPP;
1300 if (!check_sdata_in_driver(sdata))
1303 trace_drv_start_pmsr(local, sdata);
1305 if (local->ops->start_pmsr)
1306 ret = local->ops->start_pmsr(&local->hw, &sdata->vif, request);
1307 trace_drv_return_int(local, ret);
1312 static inline void drv_abort_pmsr(struct ieee80211_local *local,
1313 struct ieee80211_sub_if_data *sdata,
1314 struct cfg80211_pmsr_request *request)
1316 trace_drv_abort_pmsr(local, sdata);
1319 if (!check_sdata_in_driver(sdata))
1322 if (local->ops->abort_pmsr)
1323 local->ops->abort_pmsr(&local->hw, &sdata->vif, request);
1324 trace_drv_return_void(local);
1327 static inline int drv_start_nan(struct ieee80211_local *local,
1328 struct ieee80211_sub_if_data *sdata,
1329 struct cfg80211_nan_conf *conf)
1334 check_sdata_in_driver(sdata);
1336 trace_drv_start_nan(local, sdata, conf);
1337 ret = local->ops->start_nan(&local->hw, &sdata->vif, conf);
1338 trace_drv_return_int(local, ret);
1342 static inline void drv_stop_nan(struct ieee80211_local *local,
1343 struct ieee80211_sub_if_data *sdata)
1346 check_sdata_in_driver(sdata);
1348 trace_drv_stop_nan(local, sdata);
1349 local->ops->stop_nan(&local->hw, &sdata->vif);
1350 trace_drv_return_void(local);
1353 static inline int drv_nan_change_conf(struct ieee80211_local *local,
1354 struct ieee80211_sub_if_data *sdata,
1355 struct cfg80211_nan_conf *conf,
1361 check_sdata_in_driver(sdata);
1363 if (!local->ops->nan_change_conf)
1366 trace_drv_nan_change_conf(local, sdata, conf, changes);
1367 ret = local->ops->nan_change_conf(&local->hw, &sdata->vif, conf,
1369 trace_drv_return_int(local, ret);
1374 static inline int drv_add_nan_func(struct ieee80211_local *local,
1375 struct ieee80211_sub_if_data *sdata,
1376 const struct cfg80211_nan_func *nan_func)
1381 check_sdata_in_driver(sdata);
1383 if (!local->ops->add_nan_func)
1386 trace_drv_add_nan_func(local, sdata, nan_func);
1387 ret = local->ops->add_nan_func(&local->hw, &sdata->vif, nan_func);
1388 trace_drv_return_int(local, ret);
1393 static inline void drv_del_nan_func(struct ieee80211_local *local,
1394 struct ieee80211_sub_if_data *sdata,
1398 check_sdata_in_driver(sdata);
1400 trace_drv_del_nan_func(local, sdata, instance_id);
1401 if (local->ops->del_nan_func)
1402 local->ops->del_nan_func(&local->hw, &sdata->vif, instance_id);
1403 trace_drv_return_void(local);
1406 static inline int drv_set_tid_config(struct ieee80211_local *local,
1407 struct ieee80211_sub_if_data *sdata,
1408 struct ieee80211_sta *sta,
1409 struct cfg80211_tid_config *tid_conf)
1414 ret = local->ops->set_tid_config(&local->hw, &sdata->vif, sta,
1416 trace_drv_return_int(local, ret);
1421 static inline int drv_reset_tid_config(struct ieee80211_local *local,
1422 struct ieee80211_sub_if_data *sdata,
1423 struct ieee80211_sta *sta, u8 tids)
1428 ret = local->ops->reset_tid_config(&local->hw, &sdata->vif, sta, tids);
1429 trace_drv_return_int(local, ret);
1434 static inline void drv_update_vif_offload(struct ieee80211_local *local,
1435 struct ieee80211_sub_if_data *sdata)
1438 check_sdata_in_driver(sdata);
1440 if (!local->ops->update_vif_offload)
1443 trace_drv_update_vif_offload(local, sdata);
1444 local->ops->update_vif_offload(&local->hw, &sdata->vif);
1445 trace_drv_return_void(local);
1448 static inline void drv_sta_set_4addr(struct ieee80211_local *local,
1449 struct ieee80211_sub_if_data *sdata,
1450 struct ieee80211_sta *sta, bool enabled)
1452 sdata = get_bss_sdata(sdata);
1453 if (!check_sdata_in_driver(sdata))
1456 trace_drv_sta_set_4addr(local, sdata, sta, enabled);
1457 if (local->ops->sta_set_4addr)
1458 local->ops->sta_set_4addr(&local->hw, &sdata->vif, sta, enabled);
1459 trace_drv_return_void(local);
1462 static inline void drv_sta_set_decap_offload(struct ieee80211_local *local,
1463 struct ieee80211_sub_if_data *sdata,
1464 struct ieee80211_sta *sta,
1467 sdata = get_bss_sdata(sdata);
1468 if (!check_sdata_in_driver(sdata))
1471 trace_drv_sta_set_decap_offload(local, sdata, sta, enabled);
1472 if (local->ops->sta_set_decap_offload)
1473 local->ops->sta_set_decap_offload(&local->hw, &sdata->vif, sta,
1475 trace_drv_return_void(local);
1478 static inline void drv_add_twt_setup(struct ieee80211_local *local,
1479 struct ieee80211_sub_if_data *sdata,
1480 struct ieee80211_sta *sta,
1481 struct ieee80211_twt_setup *twt)
1483 struct ieee80211_twt_params *twt_agrt;
1487 if (!check_sdata_in_driver(sdata))
1490 twt_agrt = (void *)twt->params;
1492 trace_drv_add_twt_setup(local, sta, twt, twt_agrt);
1493 local->ops->add_twt_setup(&local->hw, sta, twt);
1494 trace_drv_return_void(local);
1497 static inline void drv_twt_teardown_request(struct ieee80211_local *local,
1498 struct ieee80211_sub_if_data *sdata,
1499 struct ieee80211_sta *sta,
1503 if (!check_sdata_in_driver(sdata))
1506 if (!local->ops->twt_teardown_request)
1509 trace_drv_twt_teardown_request(local, sta, flowid);
1510 local->ops->twt_teardown_request(&local->hw, sta, flowid);
1511 trace_drv_return_void(local);
1514 static inline int drv_net_fill_forward_path(struct ieee80211_local *local,
1515 struct ieee80211_sub_if_data *sdata,
1516 struct ieee80211_sta *sta,
1517 struct net_device_path_ctx *ctx,
1518 struct net_device_path *path)
1520 int ret = -EOPNOTSUPP;
1522 sdata = get_bss_sdata(sdata);
1523 if (!check_sdata_in_driver(sdata))
1526 trace_drv_net_fill_forward_path(local, sdata, sta);
1527 if (local->ops->net_fill_forward_path)
1528 ret = local->ops->net_fill_forward_path(&local->hw,
1531 trace_drv_return_int(local, ret);
1536 static inline int drv_change_vif_links(struct ieee80211_local *local,
1537 struct ieee80211_sub_if_data *sdata,
1538 u16 old_links, u16 new_links,
1539 struct ieee80211_bss_conf *old[IEEE80211_MLD_MAX_NUM_LINKS])
1541 int ret = -EOPNOTSUPP;
1545 if (!check_sdata_in_driver(sdata))
1548 trace_drv_change_vif_links(local, sdata, old_links, new_links);
1549 if (local->ops->change_vif_links)
1550 ret = local->ops->change_vif_links(&local->hw, &sdata->vif,
1551 old_links, new_links, old);
1552 trace_drv_return_int(local, ret);
1557 #endif /* __MAC80211_DRIVER_OPS */