xref: /openbmc/linux/net/mac80211/driver-ops.h (revision 239281f8)
124487981SJohannes Berg #ifndef __MAC80211_DRIVER_OPS
224487981SJohannes Berg #define __MAC80211_DRIVER_OPS
324487981SJohannes Berg 
424487981SJohannes Berg #include <net/mac80211.h>
524487981SJohannes Berg #include "ieee80211_i.h"
6011ad0e9SJohannes Berg #include "trace.h"
724487981SJohannes Berg 
8f6837ba8SJohannes Berg static inline bool check_sdata_in_driver(struct ieee80211_sub_if_data *sdata)
97b7eab6fSJohannes Berg {
10f6837ba8SJohannes Berg 	return !WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER),
11d17087e7SBen Greear 		     "%s:  Failed check-sdata-in-driver check, flags: 0x%x\n",
12f142c6b9SJohannes Berg 		     sdata->dev ? sdata->dev->name : sdata->name, sdata->flags);
137b7eab6fSJohannes Berg }
147b7eab6fSJohannes Berg 
15bc192f89SFelix Fietkau static inline struct ieee80211_sub_if_data *
16bc192f89SFelix Fietkau get_bss_sdata(struct ieee80211_sub_if_data *sdata)
17bc192f89SFelix Fietkau {
18bc192f89SFelix Fietkau 	if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
19bc192f89SFelix Fietkau 		sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
20bc192f89SFelix Fietkau 				     u.ap);
21bc192f89SFelix Fietkau 
22bc192f89SFelix Fietkau 	return sdata;
23bc192f89SFelix Fietkau }
24bc192f89SFelix Fietkau 
2536323f81SThomas Huehn static inline void drv_tx(struct ieee80211_local *local,
2636323f81SThomas Huehn 			  struct ieee80211_tx_control *control,
2736323f81SThomas Huehn 			  struct sk_buff *skb)
2824487981SJohannes Berg {
2936323f81SThomas Huehn 	local->ops->tx(&local->hw, control, skb);
3024487981SJohannes Berg }
3124487981SJohannes Berg 
32e352114fSBen Greear static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata,
33e352114fSBen Greear 				      u32 sset, u8 *data)
34e352114fSBen Greear {
35e352114fSBen Greear 	struct ieee80211_local *local = sdata->local;
36e352114fSBen Greear 	if (local->ops->get_et_strings) {
37e352114fSBen Greear 		trace_drv_get_et_strings(local, sset);
38e352114fSBen Greear 		local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data);
39e352114fSBen Greear 		trace_drv_return_void(local);
40e352114fSBen Greear 	}
41e352114fSBen Greear }
42e352114fSBen Greear 
43e352114fSBen Greear static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata,
44e352114fSBen Greear 				    struct ethtool_stats *stats,
45e352114fSBen Greear 				    u64 *data)
46e352114fSBen Greear {
47e352114fSBen Greear 	struct ieee80211_local *local = sdata->local;
48e352114fSBen Greear 	if (local->ops->get_et_stats) {
49e352114fSBen Greear 		trace_drv_get_et_stats(local);
50e352114fSBen Greear 		local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data);
51e352114fSBen Greear 		trace_drv_return_void(local);
52e352114fSBen Greear 	}
53e352114fSBen Greear }
54e352114fSBen Greear 
55e352114fSBen Greear static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata,
56e352114fSBen Greear 					int sset)
57e352114fSBen Greear {
58e352114fSBen Greear 	struct ieee80211_local *local = sdata->local;
59e352114fSBen Greear 	int rv = 0;
60e352114fSBen Greear 	if (local->ops->get_et_sset_count) {
61e352114fSBen Greear 		trace_drv_get_et_sset_count(local, sset);
62e352114fSBen Greear 		rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif,
63e352114fSBen Greear 						   sset);
64e352114fSBen Greear 		trace_drv_return_int(local, rv);
65e352114fSBen Greear 	}
66e352114fSBen Greear 	return rv;
67e352114fSBen Greear }
68e352114fSBen Greear 
6924487981SJohannes Berg static inline int drv_start(struct ieee80211_local *local)
7024487981SJohannes Berg {
71ea77f12fSJohannes Berg 	int ret;
72ea77f12fSJohannes Berg 
73e1781ed3SKalle Valo 	might_sleep();
74e1781ed3SKalle Valo 
754efc76bdSJohannes Berg 	trace_drv_start(local);
76ea77f12fSJohannes Berg 	local->started = true;
77ea77f12fSJohannes Berg 	smp_mb();
78ea77f12fSJohannes Berg 	ret = local->ops->start(&local->hw);
794efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
800a2b8bb2SJohannes Berg 	return ret;
8124487981SJohannes Berg }
8224487981SJohannes Berg 
8324487981SJohannes Berg static inline void drv_stop(struct ieee80211_local *local)
8424487981SJohannes Berg {
85e1781ed3SKalle Valo 	might_sleep();
86e1781ed3SKalle Valo 
870a2b8bb2SJohannes Berg 	trace_drv_stop(local);
884efc76bdSJohannes Berg 	local->ops->stop(&local->hw);
894efc76bdSJohannes Berg 	trace_drv_return_void(local);
90ea77f12fSJohannes Berg 
91ea77f12fSJohannes Berg 	/* sync away all work on the tasklet before clearing started */
92ea77f12fSJohannes Berg 	tasklet_disable(&local->tasklet);
93ea77f12fSJohannes Berg 	tasklet_enable(&local->tasklet);
94ea77f12fSJohannes Berg 
95ea77f12fSJohannes Berg 	barrier();
96ea77f12fSJohannes Berg 
97ea77f12fSJohannes Berg 	local->started = false;
9824487981SJohannes Berg }
9924487981SJohannes Berg 
100eecc4800SJohannes Berg #ifdef CONFIG_PM
101eecc4800SJohannes Berg static inline int drv_suspend(struct ieee80211_local *local,
102eecc4800SJohannes Berg 			      struct cfg80211_wowlan *wowlan)
103eecc4800SJohannes Berg {
104eecc4800SJohannes Berg 	int ret;
105eecc4800SJohannes Berg 
106eecc4800SJohannes Berg 	might_sleep();
107eecc4800SJohannes Berg 
108eecc4800SJohannes Berg 	trace_drv_suspend(local);
109eecc4800SJohannes Berg 	ret = local->ops->suspend(&local->hw, wowlan);
110eecc4800SJohannes Berg 	trace_drv_return_int(local, ret);
111eecc4800SJohannes Berg 	return ret;
112eecc4800SJohannes Berg }
113eecc4800SJohannes Berg 
114eecc4800SJohannes Berg static inline int drv_resume(struct ieee80211_local *local)
115eecc4800SJohannes Berg {
116eecc4800SJohannes Berg 	int ret;
117eecc4800SJohannes Berg 
118eecc4800SJohannes Berg 	might_sleep();
119eecc4800SJohannes Berg 
120eecc4800SJohannes Berg 	trace_drv_resume(local);
121eecc4800SJohannes Berg 	ret = local->ops->resume(&local->hw);
122eecc4800SJohannes Berg 	trace_drv_return_int(local, ret);
123eecc4800SJohannes Berg 	return ret;
124eecc4800SJohannes Berg }
1256d52563fSJohannes Berg 
1266d52563fSJohannes Berg static inline void drv_set_wakeup(struct ieee80211_local *local,
1276d52563fSJohannes Berg 				  bool enabled)
1286d52563fSJohannes Berg {
1296d52563fSJohannes Berg 	might_sleep();
1306d52563fSJohannes Berg 
1316d52563fSJohannes Berg 	if (!local->ops->set_wakeup)
1326d52563fSJohannes Berg 		return;
1336d52563fSJohannes Berg 
1346d52563fSJohannes Berg 	trace_drv_set_wakeup(local, enabled);
1356d52563fSJohannes Berg 	local->ops->set_wakeup(&local->hw, enabled);
1366d52563fSJohannes Berg 	trace_drv_return_void(local);
1376d52563fSJohannes Berg }
138eecc4800SJohannes Berg #endif
139eecc4800SJohannes Berg 
14024487981SJohannes Berg static inline int drv_add_interface(struct ieee80211_local *local,
1417b7eab6fSJohannes Berg 				    struct ieee80211_sub_if_data *sdata)
14224487981SJohannes Berg {
143e1781ed3SKalle Valo 	int ret;
144e1781ed3SKalle Valo 
145e1781ed3SKalle Valo 	might_sleep();
146e1781ed3SKalle Valo 
1477b7eab6fSJohannes Berg 	if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
1484b6f1dd6SJohannes Berg 		    (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
14931eba5bcSFelix Fietkau 		     !(local->hw.flags & IEEE80211_HW_WANT_MONITOR_VIF) &&
15031eba5bcSFelix Fietkau 		     !(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE))))
1517b7eab6fSJohannes Berg 		return -EINVAL;
1527b7eab6fSJohannes Berg 
1537b7eab6fSJohannes Berg 	trace_drv_add_interface(local, sdata);
1547b7eab6fSJohannes Berg 	ret = local->ops->add_interface(&local->hw, &sdata->vif);
1554efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
1567b7eab6fSJohannes Berg 
1577b7eab6fSJohannes Berg 	if (ret == 0)
1587b7eab6fSJohannes Berg 		sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
1597b7eab6fSJohannes Berg 
1600a2b8bb2SJohannes Berg 	return ret;
16124487981SJohannes Berg }
16224487981SJohannes Berg 
16334d4bc4dSJohannes Berg static inline int drv_change_interface(struct ieee80211_local *local,
16434d4bc4dSJohannes Berg 				       struct ieee80211_sub_if_data *sdata,
1652ca27bcfSJohannes Berg 				       enum nl80211_iftype type, bool p2p)
16634d4bc4dSJohannes Berg {
16734d4bc4dSJohannes Berg 	int ret;
16834d4bc4dSJohannes Berg 
16934d4bc4dSJohannes Berg 	might_sleep();
17034d4bc4dSJohannes Berg 
171f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
172f6837ba8SJohannes Berg 		return -EIO;
1737b7eab6fSJohannes Berg 
1742ca27bcfSJohannes Berg 	trace_drv_change_interface(local, sdata, type, p2p);
1752ca27bcfSJohannes Berg 	ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
17634d4bc4dSJohannes Berg 	trace_drv_return_int(local, ret);
17734d4bc4dSJohannes Berg 	return ret;
17834d4bc4dSJohannes Berg }
17934d4bc4dSJohannes Berg 
18024487981SJohannes Berg static inline void drv_remove_interface(struct ieee80211_local *local,
1817b7eab6fSJohannes Berg 					struct ieee80211_sub_if_data *sdata)
18224487981SJohannes Berg {
183e1781ed3SKalle Valo 	might_sleep();
184e1781ed3SKalle Valo 
185f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
186f6837ba8SJohannes Berg 		return;
1877b7eab6fSJohannes Berg 
1887b7eab6fSJohannes Berg 	trace_drv_remove_interface(local, sdata);
1897b7eab6fSJohannes Berg 	local->ops->remove_interface(&local->hw, &sdata->vif);
1907b7eab6fSJohannes Berg 	sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER;
1914efc76bdSJohannes Berg 	trace_drv_return_void(local);
19224487981SJohannes Berg }
19324487981SJohannes Berg 
19424487981SJohannes Berg static inline int drv_config(struct ieee80211_local *local, u32 changed)
19524487981SJohannes Berg {
196e1781ed3SKalle Valo 	int ret;
197e1781ed3SKalle Valo 
198e1781ed3SKalle Valo 	might_sleep();
199e1781ed3SKalle Valo 
2004efc76bdSJohannes Berg 	trace_drv_config(local, changed);
201e1781ed3SKalle Valo 	ret = local->ops->config(&local->hw, changed);
2024efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
2030a2b8bb2SJohannes Berg 	return ret;
20424487981SJohannes Berg }
20524487981SJohannes Berg 
20624487981SJohannes Berg static inline void drv_bss_info_changed(struct ieee80211_local *local,
20712375ef9SJohannes Berg 					struct ieee80211_sub_if_data *sdata,
20824487981SJohannes Berg 					struct ieee80211_bss_conf *info,
20924487981SJohannes Berg 					u32 changed)
21024487981SJohannes Berg {
211e1781ed3SKalle Valo 	might_sleep();
212e1781ed3SKalle Valo 
2135bbe754dSJohannes Berg 	if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
214b8dc1a35SJohannes Berg 				    BSS_CHANGED_BEACON_ENABLED) &&
215b8dc1a35SJohannes Berg 			 sdata->vif.type != NL80211_IFTYPE_AP &&
216b8dc1a35SJohannes Berg 			 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
217239281f8SRostislav Lisovy 			 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
218239281f8SRostislav Lisovy 			 sdata->vif.type != NL80211_IFTYPE_OCB))
2195bbe754dSJohannes Berg 		return;
2205bbe754dSJohannes Berg 
2215bbe754dSJohannes Berg 	if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
2225bbe754dSJohannes Berg 			 sdata->vif.type == NL80211_IFTYPE_MONITOR))
2235bbe754dSJohannes Berg 		return;
224b8dc1a35SJohannes Berg 
225f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
226f6837ba8SJohannes Berg 		return;
2277b7eab6fSJohannes Berg 
2284efc76bdSJohannes Berg 	trace_drv_bss_info_changed(local, sdata, info, changed);
22924487981SJohannes Berg 	if (local->ops->bss_info_changed)
23012375ef9SJohannes Berg 		local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
2314efc76bdSJohannes Berg 	trace_drv_return_void(local);
23224487981SJohannes Berg }
23324487981SJohannes Berg 
2343ac64beeSJohannes Berg static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
23522bedad3SJiri Pirko 					struct netdev_hw_addr_list *mc_list)
23624487981SJohannes Berg {
2373ac64beeSJohannes Berg 	u64 ret = 0;
2383ac64beeSJohannes Berg 
2394efc76bdSJohannes Berg 	trace_drv_prepare_multicast(local, mc_list->count);
2404efc76bdSJohannes Berg 
2413ac64beeSJohannes Berg 	if (local->ops->prepare_multicast)
24222bedad3SJiri Pirko 		ret = local->ops->prepare_multicast(&local->hw, mc_list);
2433ac64beeSJohannes Berg 
2444efc76bdSJohannes Berg 	trace_drv_return_u64(local, ret);
2453ac64beeSJohannes Berg 
2463ac64beeSJohannes Berg 	return ret;
2473ac64beeSJohannes Berg }
2483ac64beeSJohannes Berg 
2493ac64beeSJohannes Berg static inline void drv_configure_filter(struct ieee80211_local *local,
2503ac64beeSJohannes Berg 					unsigned int changed_flags,
2513ac64beeSJohannes Berg 					unsigned int *total_flags,
2523ac64beeSJohannes Berg 					u64 multicast)
2533ac64beeSJohannes Berg {
2543ac64beeSJohannes Berg 	might_sleep();
2553ac64beeSJohannes Berg 
2560a2b8bb2SJohannes Berg 	trace_drv_configure_filter(local, changed_flags, total_flags,
2573ac64beeSJohannes Berg 				   multicast);
2584efc76bdSJohannes Berg 	local->ops->configure_filter(&local->hw, changed_flags, total_flags,
2594efc76bdSJohannes Berg 				     multicast);
2604efc76bdSJohannes Berg 	trace_drv_return_void(local);
26124487981SJohannes Berg }
26224487981SJohannes Berg 
26324487981SJohannes Berg static inline int drv_set_tim(struct ieee80211_local *local,
26424487981SJohannes Berg 			      struct ieee80211_sta *sta, bool set)
26524487981SJohannes Berg {
2660a2b8bb2SJohannes Berg 	int ret = 0;
2674efc76bdSJohannes Berg 	trace_drv_set_tim(local, sta, set);
26824487981SJohannes Berg 	if (local->ops->set_tim)
2690a2b8bb2SJohannes Berg 		ret = local->ops->set_tim(&local->hw, sta, set);
2704efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
2710a2b8bb2SJohannes Berg 	return ret;
27224487981SJohannes Berg }
27324487981SJohannes Berg 
27424487981SJohannes Berg static inline int drv_set_key(struct ieee80211_local *local,
27512375ef9SJohannes Berg 			      enum set_key_cmd cmd,
27612375ef9SJohannes Berg 			      struct ieee80211_sub_if_data *sdata,
27724487981SJohannes Berg 			      struct ieee80211_sta *sta,
27824487981SJohannes Berg 			      struct ieee80211_key_conf *key)
27924487981SJohannes Berg {
280e1781ed3SKalle Valo 	int ret;
281e1781ed3SKalle Valo 
282e1781ed3SKalle Valo 	might_sleep();
283e1781ed3SKalle Valo 
284077f4939SJohannes Berg 	sdata = get_bss_sdata(sdata);
285f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
286f6837ba8SJohannes Berg 		return -EIO;
2877b7eab6fSJohannes Berg 
2884efc76bdSJohannes Berg 	trace_drv_set_key(local, cmd, sdata, sta, key);
289e1781ed3SKalle Valo 	ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
2904efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
2910a2b8bb2SJohannes Berg 	return ret;
29224487981SJohannes Berg }
29324487981SJohannes Berg 
29424487981SJohannes Berg static inline void drv_update_tkip_key(struct ieee80211_local *local,
295b3fbdcf4SJohannes Berg 				       struct ieee80211_sub_if_data *sdata,
29624487981SJohannes Berg 				       struct ieee80211_key_conf *conf,
297b3fbdcf4SJohannes Berg 				       struct sta_info *sta, u32 iv32,
29824487981SJohannes Berg 				       u16 *phase1key)
29924487981SJohannes Berg {
300b3fbdcf4SJohannes Berg 	struct ieee80211_sta *ista = NULL;
301b3fbdcf4SJohannes Berg 
302b3fbdcf4SJohannes Berg 	if (sta)
303b3fbdcf4SJohannes Berg 		ista = &sta->sta;
304b3fbdcf4SJohannes Berg 
305077f4939SJohannes Berg 	sdata = get_bss_sdata(sdata);
306f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
307f6837ba8SJohannes Berg 		return;
3087b7eab6fSJohannes Berg 
3094efc76bdSJohannes Berg 	trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
31024487981SJohannes Berg 	if (local->ops->update_tkip_key)
311b3fbdcf4SJohannes Berg 		local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
312b3fbdcf4SJohannes Berg 					    ista, iv32, phase1key);
3134efc76bdSJohannes Berg 	trace_drv_return_void(local);
31424487981SJohannes Berg }
31524487981SJohannes Berg 
31624487981SJohannes Berg static inline int drv_hw_scan(struct ieee80211_local *local,
317a060bbfeSJohannes Berg 			      struct ieee80211_sub_if_data *sdata,
318c56ef672SDavid Spinadel 			      struct ieee80211_scan_request *req)
31924487981SJohannes Berg {
320e1781ed3SKalle Valo 	int ret;
321e1781ed3SKalle Valo 
322e1781ed3SKalle Valo 	might_sleep();
323e1781ed3SKalle Valo 
324f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
325f6837ba8SJohannes Berg 		return -EIO;
3267b7eab6fSJohannes Berg 
32779f460caSLuciano Coelho 	trace_drv_hw_scan(local, sdata);
328a060bbfeSJohannes Berg 	ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
3294efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
3300a2b8bb2SJohannes Berg 	return ret;
33124487981SJohannes Berg }
33224487981SJohannes Berg 
333b856439bSEliad Peller static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
334b856439bSEliad Peller 				      struct ieee80211_sub_if_data *sdata)
335b856439bSEliad Peller {
336b856439bSEliad Peller 	might_sleep();
337b856439bSEliad Peller 
338f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
339f6837ba8SJohannes Berg 		return;
3407b7eab6fSJohannes Berg 
341b856439bSEliad Peller 	trace_drv_cancel_hw_scan(local, sdata);
342b856439bSEliad Peller 	local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
343b856439bSEliad Peller 	trace_drv_return_void(local);
344b856439bSEliad Peller }
345b856439bSEliad Peller 
34679f460caSLuciano Coelho static inline int
34779f460caSLuciano Coelho drv_sched_scan_start(struct ieee80211_local *local,
34879f460caSLuciano Coelho 		     struct ieee80211_sub_if_data *sdata,
34979f460caSLuciano Coelho 		     struct cfg80211_sched_scan_request *req,
350633e2713SDavid Spinadel 		     struct ieee80211_scan_ies *ies)
35179f460caSLuciano Coelho {
35279f460caSLuciano Coelho 	int ret;
35379f460caSLuciano Coelho 
35479f460caSLuciano Coelho 	might_sleep();
35579f460caSLuciano Coelho 
356f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
357f6837ba8SJohannes Berg 		return -EIO;
3587b7eab6fSJohannes Berg 
35979f460caSLuciano Coelho 	trace_drv_sched_scan_start(local, sdata);
36079f460caSLuciano Coelho 	ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
36179f460caSLuciano Coelho 					      req, ies);
36279f460caSLuciano Coelho 	trace_drv_return_int(local, ret);
36379f460caSLuciano Coelho 	return ret;
36479f460caSLuciano Coelho }
36579f460caSLuciano Coelho 
36637e3308cSJohannes Berg static inline int drv_sched_scan_stop(struct ieee80211_local *local,
36779f460caSLuciano Coelho 				      struct ieee80211_sub_if_data *sdata)
36879f460caSLuciano Coelho {
36937e3308cSJohannes Berg 	int ret;
37037e3308cSJohannes Berg 
37179f460caSLuciano Coelho 	might_sleep();
37279f460caSLuciano Coelho 
373f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
374f6837ba8SJohannes Berg 		return -EIO;
3757b7eab6fSJohannes Berg 
37679f460caSLuciano Coelho 	trace_drv_sched_scan_stop(local, sdata);
37737e3308cSJohannes Berg 	ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
37837e3308cSJohannes Berg 	trace_drv_return_int(local, ret);
37937e3308cSJohannes Berg 
38037e3308cSJohannes Berg 	return ret;
38179f460caSLuciano Coelho }
38279f460caSLuciano Coelho 
38324487981SJohannes Berg static inline void drv_sw_scan_start(struct ieee80211_local *local)
38424487981SJohannes Berg {
385e1781ed3SKalle Valo 	might_sleep();
386e1781ed3SKalle Valo 
3874efc76bdSJohannes Berg 	trace_drv_sw_scan_start(local);
38824487981SJohannes Berg 	if (local->ops->sw_scan_start)
38924487981SJohannes Berg 		local->ops->sw_scan_start(&local->hw);
3904efc76bdSJohannes Berg 	trace_drv_return_void(local);
39124487981SJohannes Berg }
39224487981SJohannes Berg 
39324487981SJohannes Berg static inline void drv_sw_scan_complete(struct ieee80211_local *local)
39424487981SJohannes Berg {
395e1781ed3SKalle Valo 	might_sleep();
396e1781ed3SKalle Valo 
3974efc76bdSJohannes Berg 	trace_drv_sw_scan_complete(local);
39824487981SJohannes Berg 	if (local->ops->sw_scan_complete)
39924487981SJohannes Berg 		local->ops->sw_scan_complete(&local->hw);
4004efc76bdSJohannes Berg 	trace_drv_return_void(local);
40124487981SJohannes Berg }
40224487981SJohannes Berg 
40324487981SJohannes Berg static inline int drv_get_stats(struct ieee80211_local *local,
40424487981SJohannes Berg 				struct ieee80211_low_level_stats *stats)
40524487981SJohannes Berg {
4060a2b8bb2SJohannes Berg 	int ret = -EOPNOTSUPP;
4070a2b8bb2SJohannes Berg 
408e1781ed3SKalle Valo 	might_sleep();
409e1781ed3SKalle Valo 
4100a2b8bb2SJohannes Berg 	if (local->ops->get_stats)
4110a2b8bb2SJohannes Berg 		ret = local->ops->get_stats(&local->hw, stats);
4120a2b8bb2SJohannes Berg 	trace_drv_get_stats(local, stats, ret);
4130a2b8bb2SJohannes Berg 
4140a2b8bb2SJohannes Berg 	return ret;
41524487981SJohannes Berg }
41624487981SJohannes Berg 
41724487981SJohannes Berg static inline void drv_get_tkip_seq(struct ieee80211_local *local,
41824487981SJohannes Berg 				    u8 hw_key_idx, u32 *iv32, u16 *iv16)
41924487981SJohannes Berg {
42024487981SJohannes Berg 	if (local->ops->get_tkip_seq)
42124487981SJohannes Berg 		local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
4220a2b8bb2SJohannes Berg 	trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
42324487981SJohannes Berg }
42424487981SJohannes Berg 
425f23a4780SArik Nemtsov static inline int drv_set_frag_threshold(struct ieee80211_local *local,
426f23a4780SArik Nemtsov 					u32 value)
427f23a4780SArik Nemtsov {
428f23a4780SArik Nemtsov 	int ret = 0;
429f23a4780SArik Nemtsov 
430f23a4780SArik Nemtsov 	might_sleep();
431f23a4780SArik Nemtsov 
432f23a4780SArik Nemtsov 	trace_drv_set_frag_threshold(local, value);
433f23a4780SArik Nemtsov 	if (local->ops->set_frag_threshold)
434f23a4780SArik Nemtsov 		ret = local->ops->set_frag_threshold(&local->hw, value);
435f23a4780SArik Nemtsov 	trace_drv_return_int(local, ret);
436f23a4780SArik Nemtsov 	return ret;
437f23a4780SArik Nemtsov }
438f23a4780SArik Nemtsov 
43924487981SJohannes Berg static inline int drv_set_rts_threshold(struct ieee80211_local *local,
44024487981SJohannes Berg 					u32 value)
44124487981SJohannes Berg {
4420a2b8bb2SJohannes Berg 	int ret = 0;
443e1781ed3SKalle Valo 
444e1781ed3SKalle Valo 	might_sleep();
445e1781ed3SKalle Valo 
4464efc76bdSJohannes Berg 	trace_drv_set_rts_threshold(local, value);
44724487981SJohannes Berg 	if (local->ops->set_rts_threshold)
4480a2b8bb2SJohannes Berg 		ret = local->ops->set_rts_threshold(&local->hw, value);
4494efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
4500a2b8bb2SJohannes Berg 	return ret;
45124487981SJohannes Berg }
45224487981SJohannes Berg 
453310bc676SLukáš Turek static inline int drv_set_coverage_class(struct ieee80211_local *local,
454a4bcaf55SLorenzo Bianconi 					 s16 value)
455310bc676SLukáš Turek {
456310bc676SLukáš Turek 	int ret = 0;
457310bc676SLukáš Turek 	might_sleep();
458310bc676SLukáš Turek 
4594efc76bdSJohannes Berg 	trace_drv_set_coverage_class(local, value);
460310bc676SLukáš Turek 	if (local->ops->set_coverage_class)
461310bc676SLukáš Turek 		local->ops->set_coverage_class(&local->hw, value);
462310bc676SLukáš Turek 	else
463310bc676SLukáš Turek 		ret = -EOPNOTSUPP;
464310bc676SLukáš Turek 
4654efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
466310bc676SLukáš Turek 	return ret;
467310bc676SLukáš Turek }
468310bc676SLukáš Turek 
46924487981SJohannes Berg static inline void drv_sta_notify(struct ieee80211_local *local,
47012375ef9SJohannes Berg 				  struct ieee80211_sub_if_data *sdata,
47124487981SJohannes Berg 				  enum sta_notify_cmd cmd,
47224487981SJohannes Berg 				  struct ieee80211_sta *sta)
47324487981SJohannes Berg {
474bc192f89SFelix Fietkau 	sdata = get_bss_sdata(sdata);
475f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
476f6837ba8SJohannes Berg 		return;
4777b7eab6fSJohannes Berg 
4784efc76bdSJohannes Berg 	trace_drv_sta_notify(local, sdata, cmd, sta);
47924487981SJohannes Berg 	if (local->ops->sta_notify)
48012375ef9SJohannes Berg 		local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
4814efc76bdSJohannes Berg 	trace_drv_return_void(local);
48224487981SJohannes Berg }
48324487981SJohannes Berg 
48434e89507SJohannes Berg static inline int drv_sta_add(struct ieee80211_local *local,
48534e89507SJohannes Berg 			      struct ieee80211_sub_if_data *sdata,
48634e89507SJohannes Berg 			      struct ieee80211_sta *sta)
48734e89507SJohannes Berg {
48834e89507SJohannes Berg 	int ret = 0;
48934e89507SJohannes Berg 
49034e89507SJohannes Berg 	might_sleep();
49134e89507SJohannes Berg 
492bc192f89SFelix Fietkau 	sdata = get_bss_sdata(sdata);
493f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
494f6837ba8SJohannes Berg 		return -EIO;
4957b7eab6fSJohannes Berg 
4964efc76bdSJohannes Berg 	trace_drv_sta_add(local, sdata, sta);
49734e89507SJohannes Berg 	if (local->ops->sta_add)
49834e89507SJohannes Berg 		ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
49934e89507SJohannes Berg 
5004efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
50134e89507SJohannes Berg 
50234e89507SJohannes Berg 	return ret;
50334e89507SJohannes Berg }
50434e89507SJohannes Berg 
50534e89507SJohannes Berg static inline void drv_sta_remove(struct ieee80211_local *local,
50634e89507SJohannes Berg 				  struct ieee80211_sub_if_data *sdata,
50734e89507SJohannes Berg 				  struct ieee80211_sta *sta)
50834e89507SJohannes Berg {
50934e89507SJohannes Berg 	might_sleep();
51034e89507SJohannes Berg 
511bc192f89SFelix Fietkau 	sdata = get_bss_sdata(sdata);
512f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
513f6837ba8SJohannes Berg 		return;
5147b7eab6fSJohannes Berg 
5154efc76bdSJohannes Berg 	trace_drv_sta_remove(local, sdata, sta);
51634e89507SJohannes Berg 	if (local->ops->sta_remove)
51734e89507SJohannes Berg 		local->ops->sta_remove(&local->hw, &sdata->vif, sta);
51834e89507SJohannes Berg 
5194efc76bdSJohannes Berg 	trace_drv_return_void(local);
52034e89507SJohannes Berg }
52134e89507SJohannes Berg 
52277d2ece6SSujith Manoharan #ifdef CONFIG_MAC80211_DEBUGFS
52377d2ece6SSujith Manoharan static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
52477d2ece6SSujith Manoharan 				       struct ieee80211_sub_if_data *sdata,
52577d2ece6SSujith Manoharan 				       struct ieee80211_sta *sta,
52677d2ece6SSujith Manoharan 				       struct dentry *dir)
52777d2ece6SSujith Manoharan {
52877d2ece6SSujith Manoharan 	might_sleep();
52977d2ece6SSujith Manoharan 
53077d2ece6SSujith Manoharan 	sdata = get_bss_sdata(sdata);
531f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
532f6837ba8SJohannes Berg 		return;
53377d2ece6SSujith Manoharan 
53477d2ece6SSujith Manoharan 	if (local->ops->sta_add_debugfs)
53577d2ece6SSujith Manoharan 		local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
53677d2ece6SSujith Manoharan 					    sta, dir);
53777d2ece6SSujith Manoharan }
53877d2ece6SSujith Manoharan 
53977d2ece6SSujith Manoharan static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
54077d2ece6SSujith Manoharan 					  struct ieee80211_sub_if_data *sdata,
54177d2ece6SSujith Manoharan 					  struct ieee80211_sta *sta,
54277d2ece6SSujith Manoharan 					  struct dentry *dir)
54377d2ece6SSujith Manoharan {
54477d2ece6SSujith Manoharan 	might_sleep();
54577d2ece6SSujith Manoharan 
54677d2ece6SSujith Manoharan 	sdata = get_bss_sdata(sdata);
54777d2ece6SSujith Manoharan 	check_sdata_in_driver(sdata);
54877d2ece6SSujith Manoharan 
54977d2ece6SSujith Manoharan 	if (local->ops->sta_remove_debugfs)
55077d2ece6SSujith Manoharan 		local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
55177d2ece6SSujith Manoharan 					       sta, dir);
55277d2ece6SSujith Manoharan }
55377d2ece6SSujith Manoharan #endif
55477d2ece6SSujith Manoharan 
5556a9d1b91SJohannes Berg static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
5566a9d1b91SJohannes Berg 					  struct ieee80211_sub_if_data *sdata,
5576a9d1b91SJohannes Berg 					  struct sta_info *sta)
5586a9d1b91SJohannes Berg {
5596a9d1b91SJohannes Berg 	might_sleep();
5606a9d1b91SJohannes Berg 
5616a9d1b91SJohannes Berg 	sdata = get_bss_sdata(sdata);
562f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
563f6837ba8SJohannes Berg 		return;
5646a9d1b91SJohannes Berg 
5656a9d1b91SJohannes Berg 	trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
5666a9d1b91SJohannes Berg 	if (local->ops->sta_pre_rcu_remove)
5676a9d1b91SJohannes Berg 		local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
5686a9d1b91SJohannes Berg 					       &sta->sta);
5696a9d1b91SJohannes Berg 	trace_drv_return_void(local);
5706a9d1b91SJohannes Berg }
5716a9d1b91SJohannes Berg 
572f09603a2SJohannes Berg static inline __must_check
573f09603a2SJohannes Berg int drv_sta_state(struct ieee80211_local *local,
574f09603a2SJohannes Berg 		  struct ieee80211_sub_if_data *sdata,
575f09603a2SJohannes Berg 		  struct sta_info *sta,
576f09603a2SJohannes Berg 		  enum ieee80211_sta_state old_state,
577f09603a2SJohannes Berg 		  enum ieee80211_sta_state new_state)
578f09603a2SJohannes Berg {
579f09603a2SJohannes Berg 	int ret = 0;
580f09603a2SJohannes Berg 
581f09603a2SJohannes Berg 	might_sleep();
582f09603a2SJohannes Berg 
583f09603a2SJohannes Berg 	sdata = get_bss_sdata(sdata);
584f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
585f6837ba8SJohannes Berg 		return -EIO;
586f09603a2SJohannes Berg 
587f09603a2SJohannes Berg 	trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
588a4ec45a4SJohannes Berg 	if (local->ops->sta_state) {
589f09603a2SJohannes Berg 		ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta,
590f09603a2SJohannes Berg 					    old_state, new_state);
591a4ec45a4SJohannes Berg 	} else if (old_state == IEEE80211_STA_AUTH &&
592a4ec45a4SJohannes Berg 		   new_state == IEEE80211_STA_ASSOC) {
593a4ec45a4SJohannes Berg 		ret = drv_sta_add(local, sdata, &sta->sta);
594a4ec45a4SJohannes Berg 		if (ret == 0)
595a4ec45a4SJohannes Berg 			sta->uploaded = true;
596a4ec45a4SJohannes Berg 	} else if (old_state == IEEE80211_STA_ASSOC &&
597a4ec45a4SJohannes Berg 		   new_state == IEEE80211_STA_AUTH) {
598a4ec45a4SJohannes Berg 		drv_sta_remove(local, sdata, &sta->sta);
599a4ec45a4SJohannes Berg 	}
600f09603a2SJohannes Berg 	trace_drv_return_int(local, ret);
601f09603a2SJohannes Berg 	return ret;
602f09603a2SJohannes Berg }
603f09603a2SJohannes Berg 
6048f727ef3SJohannes Berg static inline void drv_sta_rc_update(struct ieee80211_local *local,
6058f727ef3SJohannes Berg 				     struct ieee80211_sub_if_data *sdata,
6068f727ef3SJohannes Berg 				     struct ieee80211_sta *sta, u32 changed)
6078f727ef3SJohannes Berg {
6088f727ef3SJohannes Berg 	sdata = get_bss_sdata(sdata);
609f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
610f6837ba8SJohannes Berg 		return;
6118f727ef3SJohannes Berg 
612e687f61eSAntonio Quartulli 	WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED &&
613f68d776aSThomas Pedersen 		(sdata->vif.type != NL80211_IFTYPE_ADHOC &&
614f68d776aSThomas Pedersen 		 sdata->vif.type != NL80211_IFTYPE_MESH_POINT));
615e687f61eSAntonio Quartulli 
6168f727ef3SJohannes Berg 	trace_drv_sta_rc_update(local, sdata, sta, changed);
6178f727ef3SJohannes Berg 	if (local->ops->sta_rc_update)
6188f727ef3SJohannes Berg 		local->ops->sta_rc_update(&local->hw, &sdata->vif,
6198f727ef3SJohannes Berg 					  sta, changed);
6208f727ef3SJohannes Berg 
6218f727ef3SJohannes Berg 	trace_drv_return_void(local);
6228f727ef3SJohannes Berg }
6238f727ef3SJohannes Berg 
624f6f3def3SEliad Peller static inline int drv_conf_tx(struct ieee80211_local *local,
625a3304b0aSJohannes Berg 			      struct ieee80211_sub_if_data *sdata, u16 ac,
62624487981SJohannes Berg 			      const struct ieee80211_tx_queue_params *params)
62724487981SJohannes Berg {
6280a2b8bb2SJohannes Berg 	int ret = -EOPNOTSUPP;
629e1781ed3SKalle Valo 
630e1781ed3SKalle Valo 	might_sleep();
631e1781ed3SKalle Valo 
632f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
633f6837ba8SJohannes Berg 		return -EIO;
6347b7eab6fSJohannes Berg 
635f409079bSJohannes Berg 	if (WARN_ONCE(params->cw_min == 0 ||
636f409079bSJohannes Berg 		      params->cw_min > params->cw_max,
637f409079bSJohannes Berg 		      "%s: invalid CW_min/CW_max: %d/%d\n",
638f409079bSJohannes Berg 		      sdata->name, params->cw_min, params->cw_max))
639f409079bSJohannes Berg 		return -EINVAL;
640f409079bSJohannes Berg 
641a3304b0aSJohannes Berg 	trace_drv_conf_tx(local, sdata, ac, params);
64224487981SJohannes Berg 	if (local->ops->conf_tx)
6438a3a3c85SEliad Peller 		ret = local->ops->conf_tx(&local->hw, &sdata->vif,
644a3304b0aSJohannes Berg 					  ac, params);
6454efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
6460a2b8bb2SJohannes Berg 	return ret;
64724487981SJohannes Berg }
64824487981SJohannes Berg 
64937a41b4aSEliad Peller static inline u64 drv_get_tsf(struct ieee80211_local *local,
65037a41b4aSEliad Peller 			      struct ieee80211_sub_if_data *sdata)
65124487981SJohannes Berg {
6520a2b8bb2SJohannes Berg 	u64 ret = -1ULL;
653e1781ed3SKalle Valo 
654e1781ed3SKalle Valo 	might_sleep();
655e1781ed3SKalle Valo 
656f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
657f6837ba8SJohannes Berg 		return ret;
6587b7eab6fSJohannes Berg 
65937a41b4aSEliad Peller 	trace_drv_get_tsf(local, sdata);
66024487981SJohannes Berg 	if (local->ops->get_tsf)
66137a41b4aSEliad Peller 		ret = local->ops->get_tsf(&local->hw, &sdata->vif);
6624efc76bdSJohannes Berg 	trace_drv_return_u64(local, ret);
6630a2b8bb2SJohannes Berg 	return ret;
66424487981SJohannes Berg }
66524487981SJohannes Berg 
66637a41b4aSEliad Peller static inline void drv_set_tsf(struct ieee80211_local *local,
66737a41b4aSEliad Peller 			       struct ieee80211_sub_if_data *sdata,
66837a41b4aSEliad Peller 			       u64 tsf)
66924487981SJohannes Berg {
670e1781ed3SKalle Valo 	might_sleep();
671e1781ed3SKalle Valo 
672f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
673f6837ba8SJohannes Berg 		return;
6747b7eab6fSJohannes Berg 
67537a41b4aSEliad Peller 	trace_drv_set_tsf(local, sdata, tsf);
67624487981SJohannes Berg 	if (local->ops->set_tsf)
67737a41b4aSEliad Peller 		local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
6784efc76bdSJohannes Berg 	trace_drv_return_void(local);
67924487981SJohannes Berg }
68024487981SJohannes Berg 
68137a41b4aSEliad Peller static inline void drv_reset_tsf(struct ieee80211_local *local,
68237a41b4aSEliad Peller 				 struct ieee80211_sub_if_data *sdata)
68324487981SJohannes Berg {
684e1781ed3SKalle Valo 	might_sleep();
685e1781ed3SKalle Valo 
686f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
687f6837ba8SJohannes Berg 		return;
6887b7eab6fSJohannes Berg 
68937a41b4aSEliad Peller 	trace_drv_reset_tsf(local, sdata);
69024487981SJohannes Berg 	if (local->ops->reset_tsf)
69137a41b4aSEliad Peller 		local->ops->reset_tsf(&local->hw, &sdata->vif);
6924efc76bdSJohannes Berg 	trace_drv_return_void(local);
69324487981SJohannes Berg }
69424487981SJohannes Berg 
69524487981SJohannes Berg static inline int drv_tx_last_beacon(struct ieee80211_local *local)
69624487981SJohannes Berg {
69702582e9bSMasanari Iida 	int ret = 0; /* default unsupported op for less congestion */
698e1781ed3SKalle Valo 
699e1781ed3SKalle Valo 	might_sleep();
700e1781ed3SKalle Valo 
7014efc76bdSJohannes Berg 	trace_drv_tx_last_beacon(local);
70224487981SJohannes Berg 	if (local->ops->tx_last_beacon)
7030a2b8bb2SJohannes Berg 		ret = local->ops->tx_last_beacon(&local->hw);
7044efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
7050a2b8bb2SJohannes Berg 	return ret;
70624487981SJohannes Berg }
70724487981SJohannes Berg 
70824487981SJohannes Berg static inline int drv_ampdu_action(struct ieee80211_local *local,
70912375ef9SJohannes Berg 				   struct ieee80211_sub_if_data *sdata,
71024487981SJohannes Berg 				   enum ieee80211_ampdu_mlme_action action,
71124487981SJohannes Berg 				   struct ieee80211_sta *sta, u16 tid,
7120b01f030SJohannes Berg 				   u16 *ssn, u8 buf_size)
71324487981SJohannes Berg {
7140a2b8bb2SJohannes Berg 	int ret = -EOPNOTSUPP;
715cfcdbde3SJohannes Berg 
716cfcdbde3SJohannes Berg 	might_sleep();
717cfcdbde3SJohannes Berg 
718bc192f89SFelix Fietkau 	sdata = get_bss_sdata(sdata);
719f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
720f6837ba8SJohannes Berg 		return -EIO;
7217b7eab6fSJohannes Berg 
7220b01f030SJohannes Berg 	trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
7234efc76bdSJohannes Berg 
72424487981SJohannes Berg 	if (local->ops->ampdu_action)
72512375ef9SJohannes Berg 		ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
7260b01f030SJohannes Berg 					       sta, tid, ssn, buf_size);
72785ad181eSJohannes Berg 
7284efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
7294efc76bdSJohannes Berg 
7300a2b8bb2SJohannes Berg 	return ret;
73124487981SJohannes Berg }
7321f87f7d3SJohannes Berg 
7331289723eSHolger Schurig static inline int drv_get_survey(struct ieee80211_local *local, int idx,
7341289723eSHolger Schurig 				struct survey_info *survey)
7351289723eSHolger Schurig {
7361289723eSHolger Schurig 	int ret = -EOPNOTSUPP;
737c466d4efSJohn W. Linville 
738c466d4efSJohn W. Linville 	trace_drv_get_survey(local, idx, survey);
739c466d4efSJohn W. Linville 
74035dd0509SHolger Schurig 	if (local->ops->get_survey)
7411289723eSHolger Schurig 		ret = local->ops->get_survey(&local->hw, idx, survey);
742c466d4efSJohn W. Linville 
743c466d4efSJohn W. Linville 	trace_drv_return_int(local, ret);
744c466d4efSJohn W. Linville 
7451289723eSHolger Schurig 	return ret;
7461289723eSHolger Schurig }
7471f87f7d3SJohannes Berg 
7481f87f7d3SJohannes Berg static inline void drv_rfkill_poll(struct ieee80211_local *local)
7491f87f7d3SJohannes Berg {
750e1781ed3SKalle Valo 	might_sleep();
751e1781ed3SKalle Valo 
7521f87f7d3SJohannes Berg 	if (local->ops->rfkill_poll)
7531f87f7d3SJohannes Berg 		local->ops->rfkill_poll(&local->hw);
7541f87f7d3SJohannes Berg }
755a80f7c0bSJohannes Berg 
75639ecc01dSJohannes Berg static inline void drv_flush(struct ieee80211_local *local,
75777be2c54SEmmanuel Grumbach 			     struct ieee80211_sub_if_data *sdata,
75839ecc01dSJohannes Berg 			     u32 queues, bool drop)
759a80f7c0bSJohannes Berg {
76077be2c54SEmmanuel Grumbach 	struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
76177be2c54SEmmanuel Grumbach 
762e1781ed3SKalle Valo 	might_sleep();
763e1781ed3SKalle Valo 
764f6837ba8SJohannes Berg 	if (sdata && !check_sdata_in_driver(sdata))
765f6837ba8SJohannes Berg 		return;
76677be2c54SEmmanuel Grumbach 
76739ecc01dSJohannes Berg 	trace_drv_flush(local, queues, drop);
768a80f7c0bSJohannes Berg 	if (local->ops->flush)
76977be2c54SEmmanuel Grumbach 		local->ops->flush(&local->hw, vif, queues, drop);
7704efc76bdSJohannes Berg 	trace_drv_return_void(local);
771a80f7c0bSJohannes Berg }
7725ce6e438SJohannes Berg 
7735ce6e438SJohannes Berg static inline void drv_channel_switch(struct ieee80211_local *local,
7740f791eb4SLuciano Coelho 				      struct ieee80211_sub_if_data *sdata,
7755ce6e438SJohannes Berg 				      struct ieee80211_channel_switch *ch_switch)
7765ce6e438SJohannes Berg {
7775ce6e438SJohannes Berg 	might_sleep();
7785ce6e438SJohannes Berg 
7790f791eb4SLuciano Coelho 	trace_drv_channel_switch(local, sdata, ch_switch);
7800f791eb4SLuciano Coelho 	local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
7814efc76bdSJohannes Berg 	trace_drv_return_void(local);
7825ce6e438SJohannes Berg }
7835ce6e438SJohannes Berg 
78415d96753SBruno Randolf 
78515d96753SBruno Randolf static inline int drv_set_antenna(struct ieee80211_local *local,
78615d96753SBruno Randolf 				  u32 tx_ant, u32 rx_ant)
78715d96753SBruno Randolf {
78815d96753SBruno Randolf 	int ret = -EOPNOTSUPP;
78915d96753SBruno Randolf 	might_sleep();
79015d96753SBruno Randolf 	if (local->ops->set_antenna)
79115d96753SBruno Randolf 		ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
79215d96753SBruno Randolf 	trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
79315d96753SBruno Randolf 	return ret;
79415d96753SBruno Randolf }
79515d96753SBruno Randolf 
79615d96753SBruno Randolf static inline int drv_get_antenna(struct ieee80211_local *local,
79715d96753SBruno Randolf 				  u32 *tx_ant, u32 *rx_ant)
79815d96753SBruno Randolf {
79915d96753SBruno Randolf 	int ret = -EOPNOTSUPP;
80015d96753SBruno Randolf 	might_sleep();
80115d96753SBruno Randolf 	if (local->ops->get_antenna)
80215d96753SBruno Randolf 		ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
80315d96753SBruno Randolf 	trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
80415d96753SBruno Randolf 	return ret;
80515d96753SBruno Randolf }
80615d96753SBruno Randolf 
80721f83589SJohannes Berg static inline int drv_remain_on_channel(struct ieee80211_local *local,
80849884568SEliad Peller 					struct ieee80211_sub_if_data *sdata,
80921f83589SJohannes Berg 					struct ieee80211_channel *chan,
810d339d5caSIlan Peer 					unsigned int duration,
811d339d5caSIlan Peer 					enum ieee80211_roc_type type)
81221f83589SJohannes Berg {
81321f83589SJohannes Berg 	int ret;
81421f83589SJohannes Berg 
81521f83589SJohannes Berg 	might_sleep();
81621f83589SJohannes Berg 
817d339d5caSIlan Peer 	trace_drv_remain_on_channel(local, sdata, chan, duration, type);
81849884568SEliad Peller 	ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
819d339d5caSIlan Peer 					    chan, duration, type);
82021f83589SJohannes Berg 	trace_drv_return_int(local, ret);
82121f83589SJohannes Berg 
82221f83589SJohannes Berg 	return ret;
82321f83589SJohannes Berg }
82421f83589SJohannes Berg 
82521f83589SJohannes Berg static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
82621f83589SJohannes Berg {
82721f83589SJohannes Berg 	int ret;
82821f83589SJohannes Berg 
82921f83589SJohannes Berg 	might_sleep();
83021f83589SJohannes Berg 
83121f83589SJohannes Berg 	trace_drv_cancel_remain_on_channel(local);
83221f83589SJohannes Berg 	ret = local->ops->cancel_remain_on_channel(&local->hw);
83321f83589SJohannes Berg 	trace_drv_return_int(local, ret);
83421f83589SJohannes Berg 
83521f83589SJohannes Berg 	return ret;
83621f83589SJohannes Berg }
83721f83589SJohannes Berg 
83838c09159SJohn W. Linville static inline int drv_set_ringparam(struct ieee80211_local *local,
83938c09159SJohn W. Linville 				    u32 tx, u32 rx)
84038c09159SJohn W. Linville {
84138c09159SJohn W. Linville 	int ret = -ENOTSUPP;
84238c09159SJohn W. Linville 
84338c09159SJohn W. Linville 	might_sleep();
84438c09159SJohn W. Linville 
84538c09159SJohn W. Linville 	trace_drv_set_ringparam(local, tx, rx);
84638c09159SJohn W. Linville 	if (local->ops->set_ringparam)
84738c09159SJohn W. Linville 		ret = local->ops->set_ringparam(&local->hw, tx, rx);
84838c09159SJohn W. Linville 	trace_drv_return_int(local, ret);
84938c09159SJohn W. Linville 
85038c09159SJohn W. Linville 	return ret;
85138c09159SJohn W. Linville }
85238c09159SJohn W. Linville 
85338c09159SJohn W. Linville static inline void drv_get_ringparam(struct ieee80211_local *local,
85438c09159SJohn W. Linville 				     u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
85538c09159SJohn W. Linville {
85638c09159SJohn W. Linville 	might_sleep();
85738c09159SJohn W. Linville 
85838c09159SJohn W. Linville 	trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
85938c09159SJohn W. Linville 	if (local->ops->get_ringparam)
86038c09159SJohn W. Linville 		local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
86138c09159SJohn W. Linville 	trace_drv_return_void(local);
86238c09159SJohn W. Linville }
86338c09159SJohn W. Linville 
864e8306f98SVivek Natarajan static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
865e8306f98SVivek Natarajan {
866e8306f98SVivek Natarajan 	bool ret = false;
867e8306f98SVivek Natarajan 
868e8306f98SVivek Natarajan 	might_sleep();
869e8306f98SVivek Natarajan 
870e8306f98SVivek Natarajan 	trace_drv_tx_frames_pending(local);
871e8306f98SVivek Natarajan 	if (local->ops->tx_frames_pending)
872e8306f98SVivek Natarajan 		ret = local->ops->tx_frames_pending(&local->hw);
873e8306f98SVivek Natarajan 	trace_drv_return_bool(local, ret);
874e8306f98SVivek Natarajan 
875e8306f98SVivek Natarajan 	return ret;
876e8306f98SVivek Natarajan }
877bdbfd6b5SSujith Manoharan 
878bdbfd6b5SSujith Manoharan static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
879bdbfd6b5SSujith Manoharan 				       struct ieee80211_sub_if_data *sdata,
880bdbfd6b5SSujith Manoharan 				       const struct cfg80211_bitrate_mask *mask)
881bdbfd6b5SSujith Manoharan {
882bdbfd6b5SSujith Manoharan 	int ret = -EOPNOTSUPP;
883bdbfd6b5SSujith Manoharan 
884bdbfd6b5SSujith Manoharan 	might_sleep();
885bdbfd6b5SSujith Manoharan 
886f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
887f6837ba8SJohannes Berg 		return -EIO;
8887b7eab6fSJohannes Berg 
889bdbfd6b5SSujith Manoharan 	trace_drv_set_bitrate_mask(local, sdata, mask);
890bdbfd6b5SSujith Manoharan 	if (local->ops->set_bitrate_mask)
891bdbfd6b5SSujith Manoharan 		ret = local->ops->set_bitrate_mask(&local->hw,
892bdbfd6b5SSujith Manoharan 						   &sdata->vif, mask);
893bdbfd6b5SSujith Manoharan 	trace_drv_return_int(local, ret);
894bdbfd6b5SSujith Manoharan 
895bdbfd6b5SSujith Manoharan 	return ret;
896bdbfd6b5SSujith Manoharan }
897bdbfd6b5SSujith Manoharan 
898c68f4b89SJohannes Berg static inline void drv_set_rekey_data(struct ieee80211_local *local,
899c68f4b89SJohannes Berg 				      struct ieee80211_sub_if_data *sdata,
900c68f4b89SJohannes Berg 				      struct cfg80211_gtk_rekey_data *data)
901c68f4b89SJohannes Berg {
902f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
903f6837ba8SJohannes Berg 		return;
9047b7eab6fSJohannes Berg 
905c68f4b89SJohannes Berg 	trace_drv_set_rekey_data(local, sdata, data);
906c68f4b89SJohannes Berg 	if (local->ops->set_rekey_data)
907c68f4b89SJohannes Berg 		local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
908c68f4b89SJohannes Berg 	trace_drv_return_void(local);
909c68f4b89SJohannes Berg }
910c68f4b89SJohannes Berg 
911615f7b9bSMeenakshi Venkataraman static inline void drv_rssi_callback(struct ieee80211_local *local,
912887da917SEmmanuel Grumbach 				     struct ieee80211_sub_if_data *sdata,
913615f7b9bSMeenakshi Venkataraman 				     const enum ieee80211_rssi_event event)
914615f7b9bSMeenakshi Venkataraman {
915887da917SEmmanuel Grumbach 	trace_drv_rssi_callback(local, sdata, event);
916615f7b9bSMeenakshi Venkataraman 	if (local->ops->rssi_callback)
917887da917SEmmanuel Grumbach 		local->ops->rssi_callback(&local->hw, &sdata->vif, event);
918615f7b9bSMeenakshi Venkataraman 	trace_drv_return_void(local);
919615f7b9bSMeenakshi Venkataraman }
9204049e09aSJohannes Berg 
9214049e09aSJohannes Berg static inline void
9224049e09aSJohannes Berg drv_release_buffered_frames(struct ieee80211_local *local,
9234049e09aSJohannes Berg 			    struct sta_info *sta, u16 tids, int num_frames,
9244049e09aSJohannes Berg 			    enum ieee80211_frame_release_type reason,
9254049e09aSJohannes Berg 			    bool more_data)
9264049e09aSJohannes Berg {
9274049e09aSJohannes Berg 	trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
9284049e09aSJohannes Berg 					  reason, more_data);
9294049e09aSJohannes Berg 	if (local->ops->release_buffered_frames)
9304049e09aSJohannes Berg 		local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
9314049e09aSJohannes Berg 						    num_frames, reason,
9324049e09aSJohannes Berg 						    more_data);
9334049e09aSJohannes Berg 	trace_drv_return_void(local);
9344049e09aSJohannes Berg }
93540b96408SJohannes Berg 
93640b96408SJohannes Berg static inline void
93740b96408SJohannes Berg drv_allow_buffered_frames(struct ieee80211_local *local,
93840b96408SJohannes Berg 			  struct sta_info *sta, u16 tids, int num_frames,
93940b96408SJohannes Berg 			  enum ieee80211_frame_release_type reason,
94040b96408SJohannes Berg 			  bool more_data)
94140b96408SJohannes Berg {
94240b96408SJohannes Berg 	trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
94340b96408SJohannes Berg 					reason, more_data);
94440b96408SJohannes Berg 	if (local->ops->allow_buffered_frames)
94540b96408SJohannes Berg 		local->ops->allow_buffered_frames(&local->hw, &sta->sta,
94640b96408SJohannes Berg 						  tids, num_frames, reason,
94740b96408SJohannes Berg 						  more_data);
94840b96408SJohannes Berg 	trace_drv_return_void(local);
94940b96408SJohannes Berg }
95066572cfcSVictor Goldenshtein 
95166572cfcSVictor Goldenshtein static inline int drv_get_rssi(struct ieee80211_local *local,
95266572cfcSVictor Goldenshtein 				struct ieee80211_sub_if_data *sdata,
95366572cfcSVictor Goldenshtein 				struct ieee80211_sta *sta,
95466572cfcSVictor Goldenshtein 				s8 *rssi_dbm)
95566572cfcSVictor Goldenshtein {
95666572cfcSVictor Goldenshtein 	int ret;
95766572cfcSVictor Goldenshtein 
95866572cfcSVictor Goldenshtein 	might_sleep();
95966572cfcSVictor Goldenshtein 
96066572cfcSVictor Goldenshtein 	ret = local->ops->get_rssi(&local->hw, &sdata->vif, sta, rssi_dbm);
96166572cfcSVictor Goldenshtein 	trace_drv_get_rssi(local, sta, *rssi_dbm, ret);
96266572cfcSVictor Goldenshtein 
96366572cfcSVictor Goldenshtein 	return ret;
96466572cfcSVictor Goldenshtein }
965a1845fc7SJohannes Berg 
966a1845fc7SJohannes Berg static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
967a1845fc7SJohannes Berg 				      struct ieee80211_sub_if_data *sdata)
968a1845fc7SJohannes Berg {
969a1845fc7SJohannes Berg 	might_sleep();
970a1845fc7SJohannes Berg 
971f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
972f6837ba8SJohannes Berg 		return;
973a1845fc7SJohannes Berg 	WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
974a1845fc7SJohannes Berg 
975a1845fc7SJohannes Berg 	trace_drv_mgd_prepare_tx(local, sdata);
976a1845fc7SJohannes Berg 	if (local->ops->mgd_prepare_tx)
977a1845fc7SJohannes Berg 		local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
978a1845fc7SJohannes Berg 	trace_drv_return_void(local);
979a1845fc7SJohannes Berg }
980c3645eacSMichal Kazior 
981ee10f2c7SArik Nemtsov static inline void
982ee10f2c7SArik Nemtsov drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
983ee10f2c7SArik Nemtsov 			      struct ieee80211_sub_if_data *sdata)
984ee10f2c7SArik Nemtsov {
985ee10f2c7SArik Nemtsov 	might_sleep();
986ee10f2c7SArik Nemtsov 
987ee10f2c7SArik Nemtsov 	if (!check_sdata_in_driver(sdata))
988ee10f2c7SArik Nemtsov 		return;
989ee10f2c7SArik Nemtsov 	WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
990ee10f2c7SArik Nemtsov 
991ee10f2c7SArik Nemtsov 	trace_drv_mgd_protect_tdls_discover(local, sdata);
992ee10f2c7SArik Nemtsov 	if (local->ops->mgd_protect_tdls_discover)
993ee10f2c7SArik Nemtsov 		local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
994ee10f2c7SArik Nemtsov 	trace_drv_return_void(local);
995ee10f2c7SArik Nemtsov }
996ee10f2c7SArik Nemtsov 
997c3645eacSMichal Kazior static inline int drv_add_chanctx(struct ieee80211_local *local,
998c3645eacSMichal Kazior 				  struct ieee80211_chanctx *ctx)
999c3645eacSMichal Kazior {
1000c3645eacSMichal Kazior 	int ret = -EOPNOTSUPP;
1001c3645eacSMichal Kazior 
1002c3645eacSMichal Kazior 	trace_drv_add_chanctx(local, ctx);
1003c3645eacSMichal Kazior 	if (local->ops->add_chanctx)
1004c3645eacSMichal Kazior 		ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
1005c3645eacSMichal Kazior 	trace_drv_return_int(local, ret);
10068a61af65SJohannes Berg 	if (!ret)
10078a61af65SJohannes Berg 		ctx->driver_present = true;
1008c3645eacSMichal Kazior 
1009c3645eacSMichal Kazior 	return ret;
1010c3645eacSMichal Kazior }
1011c3645eacSMichal Kazior 
1012c3645eacSMichal Kazior static inline void drv_remove_chanctx(struct ieee80211_local *local,
1013c3645eacSMichal Kazior 				      struct ieee80211_chanctx *ctx)
1014c3645eacSMichal Kazior {
1015f6837ba8SJohannes Berg 	if (WARN_ON(!ctx->driver_present))
1016f6837ba8SJohannes Berg 		return;
1017f6837ba8SJohannes Berg 
1018c3645eacSMichal Kazior 	trace_drv_remove_chanctx(local, ctx);
1019c3645eacSMichal Kazior 	if (local->ops->remove_chanctx)
1020c3645eacSMichal Kazior 		local->ops->remove_chanctx(&local->hw, &ctx->conf);
1021c3645eacSMichal Kazior 	trace_drv_return_void(local);
10228a61af65SJohannes Berg 	ctx->driver_present = false;
1023c3645eacSMichal Kazior }
1024c3645eacSMichal Kazior 
1025c3645eacSMichal Kazior static inline void drv_change_chanctx(struct ieee80211_local *local,
1026c3645eacSMichal Kazior 				      struct ieee80211_chanctx *ctx,
1027c3645eacSMichal Kazior 				      u32 changed)
1028c3645eacSMichal Kazior {
1029c3645eacSMichal Kazior 	trace_drv_change_chanctx(local, ctx, changed);
10308a61af65SJohannes Berg 	if (local->ops->change_chanctx) {
10318a61af65SJohannes Berg 		WARN_ON_ONCE(!ctx->driver_present);
1032c3645eacSMichal Kazior 		local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
10338a61af65SJohannes Berg 	}
1034c3645eacSMichal Kazior 	trace_drv_return_void(local);
1035c3645eacSMichal Kazior }
1036c3645eacSMichal Kazior 
1037c3645eacSMichal Kazior static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
1038c3645eacSMichal Kazior 					 struct ieee80211_sub_if_data *sdata,
1039c3645eacSMichal Kazior 					 struct ieee80211_chanctx *ctx)
1040c3645eacSMichal Kazior {
1041c3645eacSMichal Kazior 	int ret = 0;
1042c3645eacSMichal Kazior 
1043f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1044f6837ba8SJohannes Berg 		return -EIO;
1045c3645eacSMichal Kazior 
1046c3645eacSMichal Kazior 	trace_drv_assign_vif_chanctx(local, sdata, ctx);
10478a61af65SJohannes Berg 	if (local->ops->assign_vif_chanctx) {
10488a61af65SJohannes Berg 		WARN_ON_ONCE(!ctx->driver_present);
1049c3645eacSMichal Kazior 		ret = local->ops->assign_vif_chanctx(&local->hw,
1050c3645eacSMichal Kazior 						     &sdata->vif,
1051c3645eacSMichal Kazior 						     &ctx->conf);
10528a61af65SJohannes Berg 	}
1053c3645eacSMichal Kazior 	trace_drv_return_int(local, ret);
1054c3645eacSMichal Kazior 
1055c3645eacSMichal Kazior 	return ret;
1056c3645eacSMichal Kazior }
1057c3645eacSMichal Kazior 
1058c3645eacSMichal Kazior static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
1059c3645eacSMichal Kazior 					    struct ieee80211_sub_if_data *sdata,
1060c3645eacSMichal Kazior 					    struct ieee80211_chanctx *ctx)
1061c3645eacSMichal Kazior {
1062f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1063f6837ba8SJohannes Berg 		return;
1064c3645eacSMichal Kazior 
1065c3645eacSMichal Kazior 	trace_drv_unassign_vif_chanctx(local, sdata, ctx);
10668a61af65SJohannes Berg 	if (local->ops->unassign_vif_chanctx) {
10678a61af65SJohannes Berg 		WARN_ON_ONCE(!ctx->driver_present);
1068c3645eacSMichal Kazior 		local->ops->unassign_vif_chanctx(&local->hw,
1069c3645eacSMichal Kazior 						 &sdata->vif,
1070c3645eacSMichal Kazior 						 &ctx->conf);
10718a61af65SJohannes Berg 	}
1072c3645eacSMichal Kazior 	trace_drv_return_void(local);
1073c3645eacSMichal Kazior }
1074c3645eacSMichal Kazior 
10751a5f0c13SLuciano Coelho static inline int
10761a5f0c13SLuciano Coelho drv_switch_vif_chanctx(struct ieee80211_local *local,
10771a5f0c13SLuciano Coelho 		       struct ieee80211_vif_chanctx_switch *vifs,
10781a5f0c13SLuciano Coelho 		       int n_vifs,
10791a5f0c13SLuciano Coelho 		       enum ieee80211_chanctx_switch_mode mode)
10801a5f0c13SLuciano Coelho {
10811a5f0c13SLuciano Coelho 	int ret = 0;
10821a5f0c13SLuciano Coelho 	int i;
10831a5f0c13SLuciano Coelho 
10841a5f0c13SLuciano Coelho 	if (!local->ops->switch_vif_chanctx)
10851a5f0c13SLuciano Coelho 		return -EOPNOTSUPP;
10861a5f0c13SLuciano Coelho 
10871a5f0c13SLuciano Coelho 	for (i = 0; i < n_vifs; i++) {
10881a5f0c13SLuciano Coelho 		struct ieee80211_chanctx *new_ctx =
10891a5f0c13SLuciano Coelho 			container_of(vifs[i].new_ctx,
10901a5f0c13SLuciano Coelho 				     struct ieee80211_chanctx,
10911a5f0c13SLuciano Coelho 				     conf);
10921a5f0c13SLuciano Coelho 		struct ieee80211_chanctx *old_ctx =
10931a5f0c13SLuciano Coelho 			container_of(vifs[i].old_ctx,
10941a5f0c13SLuciano Coelho 				     struct ieee80211_chanctx,
10951a5f0c13SLuciano Coelho 				     conf);
10961a5f0c13SLuciano Coelho 
10971a5f0c13SLuciano Coelho 		WARN_ON_ONCE(!old_ctx->driver_present);
10981a5f0c13SLuciano Coelho 		WARN_ON_ONCE((mode == CHANCTX_SWMODE_SWAP_CONTEXTS &&
10991a5f0c13SLuciano Coelho 			      new_ctx->driver_present) ||
11001a5f0c13SLuciano Coelho 			     (mode == CHANCTX_SWMODE_REASSIGN_VIF &&
11011a5f0c13SLuciano Coelho 			      !new_ctx->driver_present));
11021a5f0c13SLuciano Coelho 	}
11031a5f0c13SLuciano Coelho 
11041a5f0c13SLuciano Coelho 	trace_drv_switch_vif_chanctx(local, vifs, n_vifs, mode);
11051a5f0c13SLuciano Coelho 	ret = local->ops->switch_vif_chanctx(&local->hw,
11061a5f0c13SLuciano Coelho 					     vifs, n_vifs, mode);
11071a5f0c13SLuciano Coelho 	trace_drv_return_int(local, ret);
11081a5f0c13SLuciano Coelho 
11091a5f0c13SLuciano Coelho 	if (!ret && mode == CHANCTX_SWMODE_SWAP_CONTEXTS) {
11101a5f0c13SLuciano Coelho 		for (i = 0; i < n_vifs; i++) {
11111a5f0c13SLuciano Coelho 			struct ieee80211_chanctx *new_ctx =
11121a5f0c13SLuciano Coelho 				container_of(vifs[i].new_ctx,
11131a5f0c13SLuciano Coelho 					     struct ieee80211_chanctx,
11141a5f0c13SLuciano Coelho 					     conf);
11151a5f0c13SLuciano Coelho 			struct ieee80211_chanctx *old_ctx =
11161a5f0c13SLuciano Coelho 				container_of(vifs[i].old_ctx,
11171a5f0c13SLuciano Coelho 					     struct ieee80211_chanctx,
11181a5f0c13SLuciano Coelho 					     conf);
11191a5f0c13SLuciano Coelho 
11201a5f0c13SLuciano Coelho 			new_ctx->driver_present = true;
11211a5f0c13SLuciano Coelho 			old_ctx->driver_present = false;
11221a5f0c13SLuciano Coelho 		}
11231a5f0c13SLuciano Coelho 	}
11241a5f0c13SLuciano Coelho 
11251a5f0c13SLuciano Coelho 	return ret;
11261a5f0c13SLuciano Coelho }
11271a5f0c13SLuciano Coelho 
11281041638fSJohannes Berg static inline int drv_start_ap(struct ieee80211_local *local,
11291041638fSJohannes Berg 			       struct ieee80211_sub_if_data *sdata)
11301041638fSJohannes Berg {
11311041638fSJohannes Berg 	int ret = 0;
11321041638fSJohannes Berg 
1133f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1134f6837ba8SJohannes Berg 		return -EIO;
11351041638fSJohannes Berg 
11361041638fSJohannes Berg 	trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
11371041638fSJohannes Berg 	if (local->ops->start_ap)
11381041638fSJohannes Berg 		ret = local->ops->start_ap(&local->hw, &sdata->vif);
11391041638fSJohannes Berg 	trace_drv_return_int(local, ret);
11401041638fSJohannes Berg 	return ret;
11411041638fSJohannes Berg }
11421041638fSJohannes Berg 
11431041638fSJohannes Berg static inline void drv_stop_ap(struct ieee80211_local *local,
11441041638fSJohannes Berg 			       struct ieee80211_sub_if_data *sdata)
11451041638fSJohannes Berg {
1146f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1147f6837ba8SJohannes Berg 		return;
11481041638fSJohannes Berg 
11491041638fSJohannes Berg 	trace_drv_stop_ap(local, sdata);
11501041638fSJohannes Berg 	if (local->ops->stop_ap)
11511041638fSJohannes Berg 		local->ops->stop_ap(&local->hw, &sdata->vif);
11521041638fSJohannes Berg 	trace_drv_return_void(local);
11531041638fSJohannes Berg }
11541041638fSJohannes Berg 
11559214ad7fSJohannes Berg static inline void drv_restart_complete(struct ieee80211_local *local)
11569214ad7fSJohannes Berg {
11579214ad7fSJohannes Berg 	might_sleep();
11589214ad7fSJohannes Berg 
11599214ad7fSJohannes Berg 	trace_drv_restart_complete(local);
11609214ad7fSJohannes Berg 	if (local->ops->restart_complete)
11619214ad7fSJohannes Berg 		local->ops->restart_complete(&local->hw);
11629214ad7fSJohannes Berg 	trace_drv_return_void(local);
11639214ad7fSJohannes Berg }
11649214ad7fSJohannes Berg 
1165de5fad81SYoni Divinsky static inline void
1166de5fad81SYoni Divinsky drv_set_default_unicast_key(struct ieee80211_local *local,
1167de5fad81SYoni Divinsky 			    struct ieee80211_sub_if_data *sdata,
1168de5fad81SYoni Divinsky 			    int key_idx)
1169de5fad81SYoni Divinsky {
1170f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1171f6837ba8SJohannes Berg 		return;
1172de5fad81SYoni Divinsky 
1173de5fad81SYoni Divinsky 	WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1174de5fad81SYoni Divinsky 
1175de5fad81SYoni Divinsky 	trace_drv_set_default_unicast_key(local, sdata, key_idx);
1176de5fad81SYoni Divinsky 	if (local->ops->set_default_unicast_key)
1177de5fad81SYoni Divinsky 		local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1178de5fad81SYoni Divinsky 						    key_idx);
1179de5fad81SYoni Divinsky 	trace_drv_return_void(local);
1180de5fad81SYoni Divinsky }
1181de5fad81SYoni Divinsky 
1182a65240c1SJohannes Berg #if IS_ENABLED(CONFIG_IPV6)
1183a65240c1SJohannes Berg static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1184a65240c1SJohannes Berg 					struct ieee80211_sub_if_data *sdata,
1185a65240c1SJohannes Berg 					struct inet6_dev *idev)
1186a65240c1SJohannes Berg {
1187a65240c1SJohannes Berg 	trace_drv_ipv6_addr_change(local, sdata);
1188a65240c1SJohannes Berg 	if (local->ops->ipv6_addr_change)
1189a65240c1SJohannes Berg 		local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1190a65240c1SJohannes Berg 	trace_drv_return_void(local);
1191a65240c1SJohannes Berg }
1192a65240c1SJohannes Berg #endif
1193a65240c1SJohannes Berg 
119473da7d5bSSimon Wunderlich static inline void
119573da7d5bSSimon Wunderlich drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
119673da7d5bSSimon Wunderlich 			  struct cfg80211_chan_def *chandef)
119773da7d5bSSimon Wunderlich {
119873da7d5bSSimon Wunderlich 	struct ieee80211_local *local = sdata->local;
119973da7d5bSSimon Wunderlich 
120073da7d5bSSimon Wunderlich 	if (local->ops->channel_switch_beacon) {
120173da7d5bSSimon Wunderlich 		trace_drv_channel_switch_beacon(local, sdata, chandef);
120273da7d5bSSimon Wunderlich 		local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
120373da7d5bSSimon Wunderlich 						  chandef);
120473da7d5bSSimon Wunderlich 	}
120573da7d5bSSimon Wunderlich }
120673da7d5bSSimon Wunderlich 
12076d027bccSLuciano Coelho static inline int
12086d027bccSLuciano Coelho drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
12096d027bccSLuciano Coelho 		       struct ieee80211_channel_switch *ch_switch)
12106d027bccSLuciano Coelho {
12116d027bccSLuciano Coelho 	struct ieee80211_local *local = sdata->local;
12126d027bccSLuciano Coelho 	int ret = 0;
12136d027bccSLuciano Coelho 
12146d027bccSLuciano Coelho 	if (!check_sdata_in_driver(sdata))
12156d027bccSLuciano Coelho 		return -EIO;
12166d027bccSLuciano Coelho 
12176d027bccSLuciano Coelho 	trace_drv_pre_channel_switch(local, sdata, ch_switch);
12186d027bccSLuciano Coelho 	if (local->ops->pre_channel_switch)
12196d027bccSLuciano Coelho 		ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
12206d027bccSLuciano Coelho 						     ch_switch);
12216d027bccSLuciano Coelho 	trace_drv_return_int(local, ret);
12226d027bccSLuciano Coelho 	return ret;
12236d027bccSLuciano Coelho }
12246d027bccSLuciano Coelho 
1225f1d65583SLuciano Coelho static inline int
1226f1d65583SLuciano Coelho drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1227f1d65583SLuciano Coelho {
1228f1d65583SLuciano Coelho 	struct ieee80211_local *local = sdata->local;
1229f1d65583SLuciano Coelho 	int ret = 0;
1230f1d65583SLuciano Coelho 
1231f1d65583SLuciano Coelho 	if (!check_sdata_in_driver(sdata))
1232f1d65583SLuciano Coelho 		return -EIO;
1233f1d65583SLuciano Coelho 
1234f1d65583SLuciano Coelho 	trace_drv_post_channel_switch(local, sdata);
1235f1d65583SLuciano Coelho 	if (local->ops->post_channel_switch)
1236f1d65583SLuciano Coelho 		ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1237f1d65583SLuciano Coelho 	trace_drv_return_int(local, ret);
1238f1d65583SLuciano Coelho 	return ret;
1239f1d65583SLuciano Coelho }
1240f1d65583SLuciano Coelho 
124155fff501SJohannes Berg static inline int drv_join_ibss(struct ieee80211_local *local,
124255fff501SJohannes Berg 				struct ieee80211_sub_if_data *sdata)
124355fff501SJohannes Berg {
124455fff501SJohannes Berg 	int ret = 0;
124555fff501SJohannes Berg 
124655fff501SJohannes Berg 	might_sleep();
1247f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1248f6837ba8SJohannes Berg 		return -EIO;
124955fff501SJohannes Berg 
125055fff501SJohannes Berg 	trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
125155fff501SJohannes Berg 	if (local->ops->join_ibss)
125255fff501SJohannes Berg 		ret = local->ops->join_ibss(&local->hw, &sdata->vif);
125355fff501SJohannes Berg 	trace_drv_return_int(local, ret);
125455fff501SJohannes Berg 	return ret;
125555fff501SJohannes Berg }
125655fff501SJohannes Berg 
125755fff501SJohannes Berg static inline void drv_leave_ibss(struct ieee80211_local *local,
125855fff501SJohannes Berg 				  struct ieee80211_sub_if_data *sdata)
125955fff501SJohannes Berg {
126055fff501SJohannes Berg 	might_sleep();
1261f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1262f6837ba8SJohannes Berg 		return;
126355fff501SJohannes Berg 
126455fff501SJohannes Berg 	trace_drv_leave_ibss(local, sdata);
126555fff501SJohannes Berg 	if (local->ops->leave_ibss)
126655fff501SJohannes Berg 		local->ops->leave_ibss(&local->hw, &sdata->vif);
126755fff501SJohannes Berg 	trace_drv_return_void(local);
126855fff501SJohannes Berg }
126955fff501SJohannes Berg 
1270cca674d4SAntonio Quartulli static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
1271cca674d4SAntonio Quartulli 					      struct ieee80211_sta *sta)
1272cca674d4SAntonio Quartulli {
1273cca674d4SAntonio Quartulli 	u32 ret = 0;
1274cca674d4SAntonio Quartulli 
1275cca674d4SAntonio Quartulli 	trace_drv_get_expected_throughput(sta);
1276cca674d4SAntonio Quartulli 	if (local->ops->get_expected_throughput)
1277cca674d4SAntonio Quartulli 		ret = local->ops->get_expected_throughput(sta);
1278cca674d4SAntonio Quartulli 	trace_drv_return_u32(local, ret);
1279cca674d4SAntonio Quartulli 
1280cca674d4SAntonio Quartulli 	return ret;
1281cca674d4SAntonio Quartulli }
1282cca674d4SAntonio Quartulli 
12835b3dc42bSFelix Fietkau static inline int drv_get_txpower(struct ieee80211_local *local,
12845b3dc42bSFelix Fietkau 				  struct ieee80211_sub_if_data *sdata, int *dbm)
12855b3dc42bSFelix Fietkau {
12865b3dc42bSFelix Fietkau 	int ret;
12875b3dc42bSFelix Fietkau 
12885b3dc42bSFelix Fietkau 	if (!local->ops->get_txpower)
12895b3dc42bSFelix Fietkau 		return -EOPNOTSUPP;
12905b3dc42bSFelix Fietkau 
12915b3dc42bSFelix Fietkau 	ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
12925b3dc42bSFelix Fietkau 	trace_drv_get_txpower(local, sdata, *dbm, ret);
12935b3dc42bSFelix Fietkau 
12945b3dc42bSFelix Fietkau 	return ret;
12955b3dc42bSFelix Fietkau }
12965b3dc42bSFelix Fietkau 
129724487981SJohannes Berg #endif /* __MAC80211_DRIVER_OPS */
1298