xref: /openbmc/linux/net/mac80211/driver-ops.h (revision 727da60be91c9fd59f1b084ca537b5123ab97744)
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 &&
14930686bf7SJohannes Berg 		     !ieee80211_hw_check(&local->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 
383a344d677SJohannes Berg static inline void drv_sw_scan_start(struct ieee80211_local *local,
384a344d677SJohannes Berg 				     struct ieee80211_sub_if_data *sdata,
385a344d677SJohannes Berg 				     const u8 *mac_addr)
38624487981SJohannes Berg {
387e1781ed3SKalle Valo 	might_sleep();
388e1781ed3SKalle Valo 
389a344d677SJohannes Berg 	trace_drv_sw_scan_start(local, sdata, mac_addr);
39024487981SJohannes Berg 	if (local->ops->sw_scan_start)
391a344d677SJohannes Berg 		local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
3924efc76bdSJohannes Berg 	trace_drv_return_void(local);
39324487981SJohannes Berg }
39424487981SJohannes Berg 
395a344d677SJohannes Berg static inline void drv_sw_scan_complete(struct ieee80211_local *local,
396a344d677SJohannes Berg 					struct ieee80211_sub_if_data *sdata)
39724487981SJohannes Berg {
398e1781ed3SKalle Valo 	might_sleep();
399e1781ed3SKalle Valo 
400a344d677SJohannes Berg 	trace_drv_sw_scan_complete(local, sdata);
40124487981SJohannes Berg 	if (local->ops->sw_scan_complete)
402a344d677SJohannes Berg 		local->ops->sw_scan_complete(&local->hw, &sdata->vif);
4034efc76bdSJohannes Berg 	trace_drv_return_void(local);
40424487981SJohannes Berg }
40524487981SJohannes Berg 
40624487981SJohannes Berg static inline int drv_get_stats(struct ieee80211_local *local,
40724487981SJohannes Berg 				struct ieee80211_low_level_stats *stats)
40824487981SJohannes Berg {
4090a2b8bb2SJohannes Berg 	int ret = -EOPNOTSUPP;
4100a2b8bb2SJohannes Berg 
411e1781ed3SKalle Valo 	might_sleep();
412e1781ed3SKalle Valo 
4130a2b8bb2SJohannes Berg 	if (local->ops->get_stats)
4140a2b8bb2SJohannes Berg 		ret = local->ops->get_stats(&local->hw, stats);
4150a2b8bb2SJohannes Berg 	trace_drv_get_stats(local, stats, ret);
4160a2b8bb2SJohannes Berg 
4170a2b8bb2SJohannes Berg 	return ret;
41824487981SJohannes Berg }
41924487981SJohannes Berg 
4209352c19fSJohannes Berg static inline void drv_get_key_seq(struct ieee80211_local *local,
4219352c19fSJohannes Berg 				   struct ieee80211_key *key,
4229352c19fSJohannes Berg 				   struct ieee80211_key_seq *seq)
42324487981SJohannes Berg {
4249352c19fSJohannes Berg 	if (local->ops->get_key_seq)
4259352c19fSJohannes Berg 		local->ops->get_key_seq(&local->hw, &key->conf, seq);
4269352c19fSJohannes Berg 	trace_drv_get_key_seq(local, &key->conf);
42724487981SJohannes Berg }
42824487981SJohannes Berg 
429f23a4780SArik Nemtsov static inline int drv_set_frag_threshold(struct ieee80211_local *local,
430f23a4780SArik Nemtsov 					u32 value)
431f23a4780SArik Nemtsov {
432f23a4780SArik Nemtsov 	int ret = 0;
433f23a4780SArik Nemtsov 
434f23a4780SArik Nemtsov 	might_sleep();
435f23a4780SArik Nemtsov 
436f23a4780SArik Nemtsov 	trace_drv_set_frag_threshold(local, value);
437f23a4780SArik Nemtsov 	if (local->ops->set_frag_threshold)
438f23a4780SArik Nemtsov 		ret = local->ops->set_frag_threshold(&local->hw, value);
439f23a4780SArik Nemtsov 	trace_drv_return_int(local, ret);
440f23a4780SArik Nemtsov 	return ret;
441f23a4780SArik Nemtsov }
442f23a4780SArik Nemtsov 
44324487981SJohannes Berg static inline int drv_set_rts_threshold(struct ieee80211_local *local,
44424487981SJohannes Berg 					u32 value)
44524487981SJohannes Berg {
4460a2b8bb2SJohannes Berg 	int ret = 0;
447e1781ed3SKalle Valo 
448e1781ed3SKalle Valo 	might_sleep();
449e1781ed3SKalle Valo 
4504efc76bdSJohannes Berg 	trace_drv_set_rts_threshold(local, value);
45124487981SJohannes Berg 	if (local->ops->set_rts_threshold)
4520a2b8bb2SJohannes Berg 		ret = local->ops->set_rts_threshold(&local->hw, value);
4534efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
4540a2b8bb2SJohannes Berg 	return ret;
45524487981SJohannes Berg }
45624487981SJohannes Berg 
457310bc676SLukáš Turek static inline int drv_set_coverage_class(struct ieee80211_local *local,
458a4bcaf55SLorenzo Bianconi 					 s16 value)
459310bc676SLukáš Turek {
460310bc676SLukáš Turek 	int ret = 0;
461310bc676SLukáš Turek 	might_sleep();
462310bc676SLukáš Turek 
4634efc76bdSJohannes Berg 	trace_drv_set_coverage_class(local, value);
464310bc676SLukáš Turek 	if (local->ops->set_coverage_class)
465310bc676SLukáš Turek 		local->ops->set_coverage_class(&local->hw, value);
466310bc676SLukáš Turek 	else
467310bc676SLukáš Turek 		ret = -EOPNOTSUPP;
468310bc676SLukáš Turek 
4694efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
470310bc676SLukáš Turek 	return ret;
471310bc676SLukáš Turek }
472310bc676SLukáš Turek 
47324487981SJohannes Berg static inline void drv_sta_notify(struct ieee80211_local *local,
47412375ef9SJohannes Berg 				  struct ieee80211_sub_if_data *sdata,
47524487981SJohannes Berg 				  enum sta_notify_cmd cmd,
47624487981SJohannes Berg 				  struct ieee80211_sta *sta)
47724487981SJohannes Berg {
478bc192f89SFelix Fietkau 	sdata = get_bss_sdata(sdata);
479f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
480f6837ba8SJohannes Berg 		return;
4817b7eab6fSJohannes Berg 
4824efc76bdSJohannes Berg 	trace_drv_sta_notify(local, sdata, cmd, sta);
48324487981SJohannes Berg 	if (local->ops->sta_notify)
48412375ef9SJohannes Berg 		local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
4854efc76bdSJohannes Berg 	trace_drv_return_void(local);
48624487981SJohannes Berg }
48724487981SJohannes Berg 
48834e89507SJohannes Berg static inline int drv_sta_add(struct ieee80211_local *local,
48934e89507SJohannes Berg 			      struct ieee80211_sub_if_data *sdata,
49034e89507SJohannes Berg 			      struct ieee80211_sta *sta)
49134e89507SJohannes Berg {
49234e89507SJohannes Berg 	int ret = 0;
49334e89507SJohannes Berg 
49434e89507SJohannes Berg 	might_sleep();
49534e89507SJohannes Berg 
496bc192f89SFelix Fietkau 	sdata = get_bss_sdata(sdata);
497f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
498f6837ba8SJohannes Berg 		return -EIO;
4997b7eab6fSJohannes Berg 
5004efc76bdSJohannes Berg 	trace_drv_sta_add(local, sdata, sta);
50134e89507SJohannes Berg 	if (local->ops->sta_add)
50234e89507SJohannes Berg 		ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
50334e89507SJohannes Berg 
5044efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
50534e89507SJohannes Berg 
50634e89507SJohannes Berg 	return ret;
50734e89507SJohannes Berg }
50834e89507SJohannes Berg 
50934e89507SJohannes Berg static inline void drv_sta_remove(struct ieee80211_local *local,
51034e89507SJohannes Berg 				  struct ieee80211_sub_if_data *sdata,
51134e89507SJohannes Berg 				  struct ieee80211_sta *sta)
51234e89507SJohannes Berg {
51334e89507SJohannes Berg 	might_sleep();
51434e89507SJohannes Berg 
515bc192f89SFelix Fietkau 	sdata = get_bss_sdata(sdata);
516f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
517f6837ba8SJohannes Berg 		return;
5187b7eab6fSJohannes Berg 
5194efc76bdSJohannes Berg 	trace_drv_sta_remove(local, sdata, sta);
52034e89507SJohannes Berg 	if (local->ops->sta_remove)
52134e89507SJohannes Berg 		local->ops->sta_remove(&local->hw, &sdata->vif, sta);
52234e89507SJohannes Berg 
5234efc76bdSJohannes Berg 	trace_drv_return_void(local);
52434e89507SJohannes Berg }
52534e89507SJohannes Berg 
52677d2ece6SSujith Manoharan #ifdef CONFIG_MAC80211_DEBUGFS
52777d2ece6SSujith Manoharan static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
52877d2ece6SSujith Manoharan 				       struct ieee80211_sub_if_data *sdata,
52977d2ece6SSujith Manoharan 				       struct ieee80211_sta *sta,
53077d2ece6SSujith Manoharan 				       struct dentry *dir)
53177d2ece6SSujith Manoharan {
53277d2ece6SSujith Manoharan 	might_sleep();
53377d2ece6SSujith Manoharan 
53477d2ece6SSujith Manoharan 	sdata = get_bss_sdata(sdata);
535f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
536f6837ba8SJohannes Berg 		return;
53777d2ece6SSujith Manoharan 
53877d2ece6SSujith Manoharan 	if (local->ops->sta_add_debugfs)
53977d2ece6SSujith Manoharan 		local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
54077d2ece6SSujith Manoharan 					    sta, dir);
54177d2ece6SSujith Manoharan }
54277d2ece6SSujith Manoharan 
54377d2ece6SSujith Manoharan static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
54477d2ece6SSujith Manoharan 					  struct ieee80211_sub_if_data *sdata,
54577d2ece6SSujith Manoharan 					  struct ieee80211_sta *sta,
54677d2ece6SSujith Manoharan 					  struct dentry *dir)
54777d2ece6SSujith Manoharan {
54877d2ece6SSujith Manoharan 	might_sleep();
54977d2ece6SSujith Manoharan 
55077d2ece6SSujith Manoharan 	sdata = get_bss_sdata(sdata);
55177d2ece6SSujith Manoharan 	check_sdata_in_driver(sdata);
55277d2ece6SSujith Manoharan 
55377d2ece6SSujith Manoharan 	if (local->ops->sta_remove_debugfs)
55477d2ece6SSujith Manoharan 		local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
55577d2ece6SSujith Manoharan 					       sta, dir);
55677d2ece6SSujith Manoharan }
55777d2ece6SSujith Manoharan #endif
55877d2ece6SSujith Manoharan 
5596a9d1b91SJohannes Berg static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
5606a9d1b91SJohannes Berg 					  struct ieee80211_sub_if_data *sdata,
5616a9d1b91SJohannes Berg 					  struct sta_info *sta)
5626a9d1b91SJohannes Berg {
5636a9d1b91SJohannes Berg 	might_sleep();
5646a9d1b91SJohannes Berg 
5656a9d1b91SJohannes Berg 	sdata = get_bss_sdata(sdata);
566f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
567f6837ba8SJohannes Berg 		return;
5686a9d1b91SJohannes Berg 
5696a9d1b91SJohannes Berg 	trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
5706a9d1b91SJohannes Berg 	if (local->ops->sta_pre_rcu_remove)
5716a9d1b91SJohannes Berg 		local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
5726a9d1b91SJohannes Berg 					       &sta->sta);
5736a9d1b91SJohannes Berg 	trace_drv_return_void(local);
5746a9d1b91SJohannes Berg }
5756a9d1b91SJohannes Berg 
576*727da60bSDenys Vlasenko __must_check
577f09603a2SJohannes Berg int drv_sta_state(struct ieee80211_local *local,
578f09603a2SJohannes Berg 		  struct ieee80211_sub_if_data *sdata,
579f09603a2SJohannes Berg 		  struct sta_info *sta,
580f09603a2SJohannes Berg 		  enum ieee80211_sta_state old_state,
581*727da60bSDenys Vlasenko 		  enum ieee80211_sta_state new_state);
582f09603a2SJohannes Berg 
5838f727ef3SJohannes Berg static inline void drv_sta_rc_update(struct ieee80211_local *local,
5848f727ef3SJohannes Berg 				     struct ieee80211_sub_if_data *sdata,
5858f727ef3SJohannes Berg 				     struct ieee80211_sta *sta, u32 changed)
5868f727ef3SJohannes Berg {
5878f727ef3SJohannes Berg 	sdata = get_bss_sdata(sdata);
588f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
589f6837ba8SJohannes Berg 		return;
5908f727ef3SJohannes Berg 
591e687f61eSAntonio Quartulli 	WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED &&
592f68d776aSThomas Pedersen 		(sdata->vif.type != NL80211_IFTYPE_ADHOC &&
593f68d776aSThomas Pedersen 		 sdata->vif.type != NL80211_IFTYPE_MESH_POINT));
594e687f61eSAntonio Quartulli 
5958f727ef3SJohannes Berg 	trace_drv_sta_rc_update(local, sdata, sta, changed);
5968f727ef3SJohannes Berg 	if (local->ops->sta_rc_update)
5978f727ef3SJohannes Berg 		local->ops->sta_rc_update(&local->hw, &sdata->vif,
5988f727ef3SJohannes Berg 					  sta, changed);
5998f727ef3SJohannes Berg 
6008f727ef3SJohannes Berg 	trace_drv_return_void(local);
6018f727ef3SJohannes Berg }
6028f727ef3SJohannes Berg 
603f815e2b3SJohannes Berg static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
604f815e2b3SJohannes Berg 					   struct ieee80211_sub_if_data *sdata,
605f815e2b3SJohannes Berg 					   struct ieee80211_sta *sta)
606f815e2b3SJohannes Berg {
607f815e2b3SJohannes Berg 	sdata = get_bss_sdata(sdata);
608f815e2b3SJohannes Berg 	if (!check_sdata_in_driver(sdata))
609f815e2b3SJohannes Berg 		return;
610f815e2b3SJohannes Berg 
611f815e2b3SJohannes Berg 	trace_drv_sta_rate_tbl_update(local, sdata, sta);
612f815e2b3SJohannes Berg 	if (local->ops->sta_rate_tbl_update)
613f815e2b3SJohannes Berg 		local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
614f815e2b3SJohannes Berg 
615f815e2b3SJohannes Berg 	trace_drv_return_void(local);
616f815e2b3SJohannes Berg }
617f815e2b3SJohannes Berg 
6182b9a7e1bSJohannes Berg static inline void drv_sta_statistics(struct ieee80211_local *local,
6192b9a7e1bSJohannes Berg 				      struct ieee80211_sub_if_data *sdata,
6202b9a7e1bSJohannes Berg 				      struct ieee80211_sta *sta,
6212b9a7e1bSJohannes Berg 				      struct station_info *sinfo)
6222b9a7e1bSJohannes Berg {
6232b9a7e1bSJohannes Berg 	sdata = get_bss_sdata(sdata);
6242b9a7e1bSJohannes Berg 	if (!check_sdata_in_driver(sdata))
6252b9a7e1bSJohannes Berg 		return;
6262b9a7e1bSJohannes Berg 
6272b9a7e1bSJohannes Berg 	trace_drv_sta_statistics(local, sdata, sta);
6282b9a7e1bSJohannes Berg 	if (local->ops->sta_statistics)
6292b9a7e1bSJohannes Berg 		local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
6302b9a7e1bSJohannes Berg 	trace_drv_return_void(local);
6312b9a7e1bSJohannes Berg }
6322b9a7e1bSJohannes Berg 
633f6f3def3SEliad Peller static inline int drv_conf_tx(struct ieee80211_local *local,
634a3304b0aSJohannes Berg 			      struct ieee80211_sub_if_data *sdata, u16 ac,
63524487981SJohannes Berg 			      const struct ieee80211_tx_queue_params *params)
63624487981SJohannes Berg {
6370a2b8bb2SJohannes Berg 	int ret = -EOPNOTSUPP;
638e1781ed3SKalle Valo 
639e1781ed3SKalle Valo 	might_sleep();
640e1781ed3SKalle Valo 
641f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
642f6837ba8SJohannes Berg 		return -EIO;
6437b7eab6fSJohannes Berg 
644f409079bSJohannes Berg 	if (WARN_ONCE(params->cw_min == 0 ||
645f409079bSJohannes Berg 		      params->cw_min > params->cw_max,
646f409079bSJohannes Berg 		      "%s: invalid CW_min/CW_max: %d/%d\n",
647f409079bSJohannes Berg 		      sdata->name, params->cw_min, params->cw_max))
648f409079bSJohannes Berg 		return -EINVAL;
649f409079bSJohannes Berg 
650a3304b0aSJohannes Berg 	trace_drv_conf_tx(local, sdata, ac, params);
65124487981SJohannes Berg 	if (local->ops->conf_tx)
6528a3a3c85SEliad Peller 		ret = local->ops->conf_tx(&local->hw, &sdata->vif,
653a3304b0aSJohannes Berg 					  ac, params);
6544efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
6550a2b8bb2SJohannes Berg 	return ret;
65624487981SJohannes Berg }
65724487981SJohannes Berg 
65837a41b4aSEliad Peller static inline u64 drv_get_tsf(struct ieee80211_local *local,
65937a41b4aSEliad Peller 			      struct ieee80211_sub_if_data *sdata)
66024487981SJohannes Berg {
6610a2b8bb2SJohannes Berg 	u64 ret = -1ULL;
662e1781ed3SKalle Valo 
663e1781ed3SKalle Valo 	might_sleep();
664e1781ed3SKalle Valo 
665f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
666f6837ba8SJohannes Berg 		return ret;
6677b7eab6fSJohannes Berg 
66837a41b4aSEliad Peller 	trace_drv_get_tsf(local, sdata);
66924487981SJohannes Berg 	if (local->ops->get_tsf)
67037a41b4aSEliad Peller 		ret = local->ops->get_tsf(&local->hw, &sdata->vif);
6714efc76bdSJohannes Berg 	trace_drv_return_u64(local, ret);
6720a2b8bb2SJohannes Berg 	return ret;
67324487981SJohannes Berg }
67424487981SJohannes Berg 
67537a41b4aSEliad Peller static inline void drv_set_tsf(struct ieee80211_local *local,
67637a41b4aSEliad Peller 			       struct ieee80211_sub_if_data *sdata,
67737a41b4aSEliad Peller 			       u64 tsf)
67824487981SJohannes Berg {
679e1781ed3SKalle Valo 	might_sleep();
680e1781ed3SKalle Valo 
681f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
682f6837ba8SJohannes Berg 		return;
6837b7eab6fSJohannes Berg 
68437a41b4aSEliad Peller 	trace_drv_set_tsf(local, sdata, tsf);
68524487981SJohannes Berg 	if (local->ops->set_tsf)
68637a41b4aSEliad Peller 		local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
6874efc76bdSJohannes Berg 	trace_drv_return_void(local);
68824487981SJohannes Berg }
68924487981SJohannes Berg 
69037a41b4aSEliad Peller static inline void drv_reset_tsf(struct ieee80211_local *local,
69137a41b4aSEliad Peller 				 struct ieee80211_sub_if_data *sdata)
69224487981SJohannes Berg {
693e1781ed3SKalle Valo 	might_sleep();
694e1781ed3SKalle Valo 
695f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
696f6837ba8SJohannes Berg 		return;
6977b7eab6fSJohannes Berg 
69837a41b4aSEliad Peller 	trace_drv_reset_tsf(local, sdata);
69924487981SJohannes Berg 	if (local->ops->reset_tsf)
70037a41b4aSEliad Peller 		local->ops->reset_tsf(&local->hw, &sdata->vif);
7014efc76bdSJohannes Berg 	trace_drv_return_void(local);
70224487981SJohannes Berg }
70324487981SJohannes Berg 
70424487981SJohannes Berg static inline int drv_tx_last_beacon(struct ieee80211_local *local)
70524487981SJohannes Berg {
70602582e9bSMasanari Iida 	int ret = 0; /* default unsupported op for less congestion */
707e1781ed3SKalle Valo 
708e1781ed3SKalle Valo 	might_sleep();
709e1781ed3SKalle Valo 
7104efc76bdSJohannes Berg 	trace_drv_tx_last_beacon(local);
71124487981SJohannes Berg 	if (local->ops->tx_last_beacon)
7120a2b8bb2SJohannes Berg 		ret = local->ops->tx_last_beacon(&local->hw);
7134efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
7140a2b8bb2SJohannes Berg 	return ret;
71524487981SJohannes Berg }
71624487981SJohannes Berg 
71724487981SJohannes Berg static inline int drv_ampdu_action(struct ieee80211_local *local,
71812375ef9SJohannes Berg 				   struct ieee80211_sub_if_data *sdata,
71924487981SJohannes Berg 				   enum ieee80211_ampdu_mlme_action action,
72024487981SJohannes Berg 				   struct ieee80211_sta *sta, u16 tid,
7210b01f030SJohannes Berg 				   u16 *ssn, u8 buf_size)
72224487981SJohannes Berg {
7230a2b8bb2SJohannes Berg 	int ret = -EOPNOTSUPP;
724cfcdbde3SJohannes Berg 
725cfcdbde3SJohannes Berg 	might_sleep();
726cfcdbde3SJohannes Berg 
727bc192f89SFelix Fietkau 	sdata = get_bss_sdata(sdata);
728f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
729f6837ba8SJohannes Berg 		return -EIO;
7307b7eab6fSJohannes Berg 
7310b01f030SJohannes Berg 	trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
7324efc76bdSJohannes Berg 
73324487981SJohannes Berg 	if (local->ops->ampdu_action)
73412375ef9SJohannes Berg 		ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
7350b01f030SJohannes Berg 					       sta, tid, ssn, buf_size);
73685ad181eSJohannes Berg 
7374efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
7384efc76bdSJohannes Berg 
7390a2b8bb2SJohannes Berg 	return ret;
74024487981SJohannes Berg }
7411f87f7d3SJohannes Berg 
7421289723eSHolger Schurig static inline int drv_get_survey(struct ieee80211_local *local, int idx,
7431289723eSHolger Schurig 				struct survey_info *survey)
7441289723eSHolger Schurig {
7451289723eSHolger Schurig 	int ret = -EOPNOTSUPP;
746c466d4efSJohn W. Linville 
747c466d4efSJohn W. Linville 	trace_drv_get_survey(local, idx, survey);
748c466d4efSJohn W. Linville 
74935dd0509SHolger Schurig 	if (local->ops->get_survey)
7501289723eSHolger Schurig 		ret = local->ops->get_survey(&local->hw, idx, survey);
751c466d4efSJohn W. Linville 
752c466d4efSJohn W. Linville 	trace_drv_return_int(local, ret);
753c466d4efSJohn W. Linville 
7541289723eSHolger Schurig 	return ret;
7551289723eSHolger Schurig }
7561f87f7d3SJohannes Berg 
7571f87f7d3SJohannes Berg static inline void drv_rfkill_poll(struct ieee80211_local *local)
7581f87f7d3SJohannes Berg {
759e1781ed3SKalle Valo 	might_sleep();
760e1781ed3SKalle Valo 
7611f87f7d3SJohannes Berg 	if (local->ops->rfkill_poll)
7621f87f7d3SJohannes Berg 		local->ops->rfkill_poll(&local->hw);
7631f87f7d3SJohannes Berg }
764a80f7c0bSJohannes Berg 
76539ecc01dSJohannes Berg static inline void drv_flush(struct ieee80211_local *local,
76677be2c54SEmmanuel Grumbach 			     struct ieee80211_sub_if_data *sdata,
76739ecc01dSJohannes Berg 			     u32 queues, bool drop)
768a80f7c0bSJohannes Berg {
76977be2c54SEmmanuel Grumbach 	struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
77077be2c54SEmmanuel Grumbach 
771e1781ed3SKalle Valo 	might_sleep();
772e1781ed3SKalle Valo 
773f6837ba8SJohannes Berg 	if (sdata && !check_sdata_in_driver(sdata))
774f6837ba8SJohannes Berg 		return;
77577be2c54SEmmanuel Grumbach 
77639ecc01dSJohannes Berg 	trace_drv_flush(local, queues, drop);
777a80f7c0bSJohannes Berg 	if (local->ops->flush)
77877be2c54SEmmanuel Grumbach 		local->ops->flush(&local->hw, vif, queues, drop);
7794efc76bdSJohannes Berg 	trace_drv_return_void(local);
780a80f7c0bSJohannes Berg }
7815ce6e438SJohannes Berg 
7825ce6e438SJohannes Berg static inline void drv_channel_switch(struct ieee80211_local *local,
7830f791eb4SLuciano Coelho 				      struct ieee80211_sub_if_data *sdata,
7845ce6e438SJohannes Berg 				      struct ieee80211_channel_switch *ch_switch)
7855ce6e438SJohannes Berg {
7865ce6e438SJohannes Berg 	might_sleep();
7875ce6e438SJohannes Berg 
7880f791eb4SLuciano Coelho 	trace_drv_channel_switch(local, sdata, ch_switch);
7890f791eb4SLuciano Coelho 	local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
7904efc76bdSJohannes Berg 	trace_drv_return_void(local);
7915ce6e438SJohannes Berg }
7925ce6e438SJohannes Berg 
79315d96753SBruno Randolf 
79415d96753SBruno Randolf static inline int drv_set_antenna(struct ieee80211_local *local,
79515d96753SBruno Randolf 				  u32 tx_ant, u32 rx_ant)
79615d96753SBruno Randolf {
79715d96753SBruno Randolf 	int ret = -EOPNOTSUPP;
79815d96753SBruno Randolf 	might_sleep();
79915d96753SBruno Randolf 	if (local->ops->set_antenna)
80015d96753SBruno Randolf 		ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
80115d96753SBruno Randolf 	trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
80215d96753SBruno Randolf 	return ret;
80315d96753SBruno Randolf }
80415d96753SBruno Randolf 
80515d96753SBruno Randolf static inline int drv_get_antenna(struct ieee80211_local *local,
80615d96753SBruno Randolf 				  u32 *tx_ant, u32 *rx_ant)
80715d96753SBruno Randolf {
80815d96753SBruno Randolf 	int ret = -EOPNOTSUPP;
80915d96753SBruno Randolf 	might_sleep();
81015d96753SBruno Randolf 	if (local->ops->get_antenna)
81115d96753SBruno Randolf 		ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
81215d96753SBruno Randolf 	trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
81315d96753SBruno Randolf 	return ret;
81415d96753SBruno Randolf }
81515d96753SBruno Randolf 
81621f83589SJohannes Berg static inline int drv_remain_on_channel(struct ieee80211_local *local,
81749884568SEliad Peller 					struct ieee80211_sub_if_data *sdata,
81821f83589SJohannes Berg 					struct ieee80211_channel *chan,
819d339d5caSIlan Peer 					unsigned int duration,
820d339d5caSIlan Peer 					enum ieee80211_roc_type type)
82121f83589SJohannes Berg {
82221f83589SJohannes Berg 	int ret;
82321f83589SJohannes Berg 
82421f83589SJohannes Berg 	might_sleep();
82521f83589SJohannes Berg 
826d339d5caSIlan Peer 	trace_drv_remain_on_channel(local, sdata, chan, duration, type);
82749884568SEliad Peller 	ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
828d339d5caSIlan Peer 					    chan, duration, type);
82921f83589SJohannes Berg 	trace_drv_return_int(local, ret);
83021f83589SJohannes Berg 
83121f83589SJohannes Berg 	return ret;
83221f83589SJohannes Berg }
83321f83589SJohannes Berg 
83421f83589SJohannes Berg static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
83521f83589SJohannes Berg {
83621f83589SJohannes Berg 	int ret;
83721f83589SJohannes Berg 
83821f83589SJohannes Berg 	might_sleep();
83921f83589SJohannes Berg 
84021f83589SJohannes Berg 	trace_drv_cancel_remain_on_channel(local);
84121f83589SJohannes Berg 	ret = local->ops->cancel_remain_on_channel(&local->hw);
84221f83589SJohannes Berg 	trace_drv_return_int(local, ret);
84321f83589SJohannes Berg 
84421f83589SJohannes Berg 	return ret;
84521f83589SJohannes Berg }
84621f83589SJohannes Berg 
84738c09159SJohn W. Linville static inline int drv_set_ringparam(struct ieee80211_local *local,
84838c09159SJohn W. Linville 				    u32 tx, u32 rx)
84938c09159SJohn W. Linville {
85038c09159SJohn W. Linville 	int ret = -ENOTSUPP;
85138c09159SJohn W. Linville 
85238c09159SJohn W. Linville 	might_sleep();
85338c09159SJohn W. Linville 
85438c09159SJohn W. Linville 	trace_drv_set_ringparam(local, tx, rx);
85538c09159SJohn W. Linville 	if (local->ops->set_ringparam)
85638c09159SJohn W. Linville 		ret = local->ops->set_ringparam(&local->hw, tx, rx);
85738c09159SJohn W. Linville 	trace_drv_return_int(local, ret);
85838c09159SJohn W. Linville 
85938c09159SJohn W. Linville 	return ret;
86038c09159SJohn W. Linville }
86138c09159SJohn W. Linville 
86238c09159SJohn W. Linville static inline void drv_get_ringparam(struct ieee80211_local *local,
86338c09159SJohn W. Linville 				     u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
86438c09159SJohn W. Linville {
86538c09159SJohn W. Linville 	might_sleep();
86638c09159SJohn W. Linville 
86738c09159SJohn W. Linville 	trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
86838c09159SJohn W. Linville 	if (local->ops->get_ringparam)
86938c09159SJohn W. Linville 		local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
87038c09159SJohn W. Linville 	trace_drv_return_void(local);
87138c09159SJohn W. Linville }
87238c09159SJohn W. Linville 
873e8306f98SVivek Natarajan static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
874e8306f98SVivek Natarajan {
875e8306f98SVivek Natarajan 	bool ret = false;
876e8306f98SVivek Natarajan 
877e8306f98SVivek Natarajan 	might_sleep();
878e8306f98SVivek Natarajan 
879e8306f98SVivek Natarajan 	trace_drv_tx_frames_pending(local);
880e8306f98SVivek Natarajan 	if (local->ops->tx_frames_pending)
881e8306f98SVivek Natarajan 		ret = local->ops->tx_frames_pending(&local->hw);
882e8306f98SVivek Natarajan 	trace_drv_return_bool(local, ret);
883e8306f98SVivek Natarajan 
884e8306f98SVivek Natarajan 	return ret;
885e8306f98SVivek Natarajan }
886bdbfd6b5SSujith Manoharan 
887bdbfd6b5SSujith Manoharan static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
888bdbfd6b5SSujith Manoharan 				       struct ieee80211_sub_if_data *sdata,
889bdbfd6b5SSujith Manoharan 				       const struct cfg80211_bitrate_mask *mask)
890bdbfd6b5SSujith Manoharan {
891bdbfd6b5SSujith Manoharan 	int ret = -EOPNOTSUPP;
892bdbfd6b5SSujith Manoharan 
893bdbfd6b5SSujith Manoharan 	might_sleep();
894bdbfd6b5SSujith Manoharan 
895f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
896f6837ba8SJohannes Berg 		return -EIO;
8977b7eab6fSJohannes Berg 
898bdbfd6b5SSujith Manoharan 	trace_drv_set_bitrate_mask(local, sdata, mask);
899bdbfd6b5SSujith Manoharan 	if (local->ops->set_bitrate_mask)
900bdbfd6b5SSujith Manoharan 		ret = local->ops->set_bitrate_mask(&local->hw,
901bdbfd6b5SSujith Manoharan 						   &sdata->vif, mask);
902bdbfd6b5SSujith Manoharan 	trace_drv_return_int(local, ret);
903bdbfd6b5SSujith Manoharan 
904bdbfd6b5SSujith Manoharan 	return ret;
905bdbfd6b5SSujith Manoharan }
906bdbfd6b5SSujith Manoharan 
907c68f4b89SJohannes Berg static inline void drv_set_rekey_data(struct ieee80211_local *local,
908c68f4b89SJohannes Berg 				      struct ieee80211_sub_if_data *sdata,
909c68f4b89SJohannes Berg 				      struct cfg80211_gtk_rekey_data *data)
910c68f4b89SJohannes Berg {
911f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
912f6837ba8SJohannes Berg 		return;
9137b7eab6fSJohannes Berg 
914c68f4b89SJohannes Berg 	trace_drv_set_rekey_data(local, sdata, data);
915c68f4b89SJohannes Berg 	if (local->ops->set_rekey_data)
916c68f4b89SJohannes Berg 		local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
917c68f4b89SJohannes Berg 	trace_drv_return_void(local);
918c68f4b89SJohannes Berg }
919c68f4b89SJohannes Berg 
920a8182929SEmmanuel Grumbach static inline void drv_event_callback(struct ieee80211_local *local,
921887da917SEmmanuel Grumbach 				      struct ieee80211_sub_if_data *sdata,
922a8182929SEmmanuel Grumbach 				      const struct ieee80211_event *event)
923615f7b9bSMeenakshi Venkataraman {
924a8182929SEmmanuel Grumbach 	trace_drv_event_callback(local, sdata, event);
925a8182929SEmmanuel Grumbach 	if (local->ops->event_callback)
926a8182929SEmmanuel Grumbach 		local->ops->event_callback(&local->hw, &sdata->vif, event);
927615f7b9bSMeenakshi Venkataraman 	trace_drv_return_void(local);
928615f7b9bSMeenakshi Venkataraman }
9294049e09aSJohannes Berg 
9304049e09aSJohannes Berg static inline void
9314049e09aSJohannes Berg drv_release_buffered_frames(struct ieee80211_local *local,
9324049e09aSJohannes Berg 			    struct sta_info *sta, u16 tids, int num_frames,
9334049e09aSJohannes Berg 			    enum ieee80211_frame_release_type reason,
9344049e09aSJohannes Berg 			    bool more_data)
9354049e09aSJohannes Berg {
9364049e09aSJohannes Berg 	trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
9374049e09aSJohannes Berg 					  reason, more_data);
9384049e09aSJohannes Berg 	if (local->ops->release_buffered_frames)
9394049e09aSJohannes Berg 		local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
9404049e09aSJohannes Berg 						    num_frames, reason,
9414049e09aSJohannes Berg 						    more_data);
9424049e09aSJohannes Berg 	trace_drv_return_void(local);
9434049e09aSJohannes Berg }
94440b96408SJohannes Berg 
94540b96408SJohannes Berg static inline void
94640b96408SJohannes Berg drv_allow_buffered_frames(struct ieee80211_local *local,
94740b96408SJohannes Berg 			  struct sta_info *sta, u16 tids, int num_frames,
94840b96408SJohannes Berg 			  enum ieee80211_frame_release_type reason,
94940b96408SJohannes Berg 			  bool more_data)
95040b96408SJohannes Berg {
95140b96408SJohannes Berg 	trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
95240b96408SJohannes Berg 					reason, more_data);
95340b96408SJohannes Berg 	if (local->ops->allow_buffered_frames)
95440b96408SJohannes Berg 		local->ops->allow_buffered_frames(&local->hw, &sta->sta,
95540b96408SJohannes Berg 						  tids, num_frames, reason,
95640b96408SJohannes Berg 						  more_data);
95740b96408SJohannes Berg 	trace_drv_return_void(local);
95840b96408SJohannes Berg }
95966572cfcSVictor Goldenshtein 
960a1845fc7SJohannes Berg static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
961a1845fc7SJohannes Berg 				      struct ieee80211_sub_if_data *sdata)
962a1845fc7SJohannes Berg {
963a1845fc7SJohannes Berg 	might_sleep();
964a1845fc7SJohannes Berg 
965f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
966f6837ba8SJohannes Berg 		return;
967a1845fc7SJohannes Berg 	WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
968a1845fc7SJohannes Berg 
969a1845fc7SJohannes Berg 	trace_drv_mgd_prepare_tx(local, sdata);
970a1845fc7SJohannes Berg 	if (local->ops->mgd_prepare_tx)
971a1845fc7SJohannes Berg 		local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
972a1845fc7SJohannes Berg 	trace_drv_return_void(local);
973a1845fc7SJohannes Berg }
974c3645eacSMichal Kazior 
975ee10f2c7SArik Nemtsov static inline void
976ee10f2c7SArik Nemtsov drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
977ee10f2c7SArik Nemtsov 			      struct ieee80211_sub_if_data *sdata)
978ee10f2c7SArik Nemtsov {
979ee10f2c7SArik Nemtsov 	might_sleep();
980ee10f2c7SArik Nemtsov 
981ee10f2c7SArik Nemtsov 	if (!check_sdata_in_driver(sdata))
982ee10f2c7SArik Nemtsov 		return;
983ee10f2c7SArik Nemtsov 	WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
984ee10f2c7SArik Nemtsov 
985ee10f2c7SArik Nemtsov 	trace_drv_mgd_protect_tdls_discover(local, sdata);
986ee10f2c7SArik Nemtsov 	if (local->ops->mgd_protect_tdls_discover)
987ee10f2c7SArik Nemtsov 		local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
988ee10f2c7SArik Nemtsov 	trace_drv_return_void(local);
989ee10f2c7SArik Nemtsov }
990ee10f2c7SArik Nemtsov 
991c3645eacSMichal Kazior static inline int drv_add_chanctx(struct ieee80211_local *local,
992c3645eacSMichal Kazior 				  struct ieee80211_chanctx *ctx)
993c3645eacSMichal Kazior {
994c3645eacSMichal Kazior 	int ret = -EOPNOTSUPP;
995c3645eacSMichal Kazior 
996c3645eacSMichal Kazior 	trace_drv_add_chanctx(local, ctx);
997c3645eacSMichal Kazior 	if (local->ops->add_chanctx)
998c3645eacSMichal Kazior 		ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
999c3645eacSMichal Kazior 	trace_drv_return_int(local, ret);
10008a61af65SJohannes Berg 	if (!ret)
10018a61af65SJohannes Berg 		ctx->driver_present = true;
1002c3645eacSMichal Kazior 
1003c3645eacSMichal Kazior 	return ret;
1004c3645eacSMichal Kazior }
1005c3645eacSMichal Kazior 
1006c3645eacSMichal Kazior static inline void drv_remove_chanctx(struct ieee80211_local *local,
1007c3645eacSMichal Kazior 				      struct ieee80211_chanctx *ctx)
1008c3645eacSMichal Kazior {
1009f6837ba8SJohannes Berg 	if (WARN_ON(!ctx->driver_present))
1010f6837ba8SJohannes Berg 		return;
1011f6837ba8SJohannes Berg 
1012c3645eacSMichal Kazior 	trace_drv_remove_chanctx(local, ctx);
1013c3645eacSMichal Kazior 	if (local->ops->remove_chanctx)
1014c3645eacSMichal Kazior 		local->ops->remove_chanctx(&local->hw, &ctx->conf);
1015c3645eacSMichal Kazior 	trace_drv_return_void(local);
10168a61af65SJohannes Berg 	ctx->driver_present = false;
1017c3645eacSMichal Kazior }
1018c3645eacSMichal Kazior 
1019c3645eacSMichal Kazior static inline void drv_change_chanctx(struct ieee80211_local *local,
1020c3645eacSMichal Kazior 				      struct ieee80211_chanctx *ctx,
1021c3645eacSMichal Kazior 				      u32 changed)
1022c3645eacSMichal Kazior {
1023c3645eacSMichal Kazior 	trace_drv_change_chanctx(local, ctx, changed);
10248a61af65SJohannes Berg 	if (local->ops->change_chanctx) {
10258a61af65SJohannes Berg 		WARN_ON_ONCE(!ctx->driver_present);
1026c3645eacSMichal Kazior 		local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
10278a61af65SJohannes Berg 	}
1028c3645eacSMichal Kazior 	trace_drv_return_void(local);
1029c3645eacSMichal Kazior }
1030c3645eacSMichal Kazior 
1031c3645eacSMichal Kazior static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
1032c3645eacSMichal Kazior 					 struct ieee80211_sub_if_data *sdata,
1033c3645eacSMichal Kazior 					 struct ieee80211_chanctx *ctx)
1034c3645eacSMichal Kazior {
1035c3645eacSMichal Kazior 	int ret = 0;
1036c3645eacSMichal Kazior 
1037f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1038f6837ba8SJohannes Berg 		return -EIO;
1039c3645eacSMichal Kazior 
1040c3645eacSMichal Kazior 	trace_drv_assign_vif_chanctx(local, sdata, ctx);
10418a61af65SJohannes Berg 	if (local->ops->assign_vif_chanctx) {
10428a61af65SJohannes Berg 		WARN_ON_ONCE(!ctx->driver_present);
1043c3645eacSMichal Kazior 		ret = local->ops->assign_vif_chanctx(&local->hw,
1044c3645eacSMichal Kazior 						     &sdata->vif,
1045c3645eacSMichal Kazior 						     &ctx->conf);
10468a61af65SJohannes Berg 	}
1047c3645eacSMichal Kazior 	trace_drv_return_int(local, ret);
1048c3645eacSMichal Kazior 
1049c3645eacSMichal Kazior 	return ret;
1050c3645eacSMichal Kazior }
1051c3645eacSMichal Kazior 
1052c3645eacSMichal Kazior static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
1053c3645eacSMichal Kazior 					    struct ieee80211_sub_if_data *sdata,
1054c3645eacSMichal Kazior 					    struct ieee80211_chanctx *ctx)
1055c3645eacSMichal Kazior {
1056f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1057f6837ba8SJohannes Berg 		return;
1058c3645eacSMichal Kazior 
1059c3645eacSMichal Kazior 	trace_drv_unassign_vif_chanctx(local, sdata, ctx);
10608a61af65SJohannes Berg 	if (local->ops->unassign_vif_chanctx) {
10618a61af65SJohannes Berg 		WARN_ON_ONCE(!ctx->driver_present);
1062c3645eacSMichal Kazior 		local->ops->unassign_vif_chanctx(&local->hw,
1063c3645eacSMichal Kazior 						 &sdata->vif,
1064c3645eacSMichal Kazior 						 &ctx->conf);
10658a61af65SJohannes Berg 	}
1066c3645eacSMichal Kazior 	trace_drv_return_void(local);
1067c3645eacSMichal Kazior }
1068c3645eacSMichal Kazior 
10691a5f0c13SLuciano Coelho static inline int
10701a5f0c13SLuciano Coelho drv_switch_vif_chanctx(struct ieee80211_local *local,
10711a5f0c13SLuciano Coelho 		       struct ieee80211_vif_chanctx_switch *vifs,
10721a5f0c13SLuciano Coelho 		       int n_vifs,
10731a5f0c13SLuciano Coelho 		       enum ieee80211_chanctx_switch_mode mode)
10741a5f0c13SLuciano Coelho {
10751a5f0c13SLuciano Coelho 	int ret = 0;
10761a5f0c13SLuciano Coelho 	int i;
10771a5f0c13SLuciano Coelho 
10781a5f0c13SLuciano Coelho 	if (!local->ops->switch_vif_chanctx)
10791a5f0c13SLuciano Coelho 		return -EOPNOTSUPP;
10801a5f0c13SLuciano Coelho 
10811a5f0c13SLuciano Coelho 	for (i = 0; i < n_vifs; i++) {
10821a5f0c13SLuciano Coelho 		struct ieee80211_chanctx *new_ctx =
10831a5f0c13SLuciano Coelho 			container_of(vifs[i].new_ctx,
10841a5f0c13SLuciano Coelho 				     struct ieee80211_chanctx,
10851a5f0c13SLuciano Coelho 				     conf);
10861a5f0c13SLuciano Coelho 		struct ieee80211_chanctx *old_ctx =
10871a5f0c13SLuciano Coelho 			container_of(vifs[i].old_ctx,
10881a5f0c13SLuciano Coelho 				     struct ieee80211_chanctx,
10891a5f0c13SLuciano Coelho 				     conf);
10901a5f0c13SLuciano Coelho 
10911a5f0c13SLuciano Coelho 		WARN_ON_ONCE(!old_ctx->driver_present);
10921a5f0c13SLuciano Coelho 		WARN_ON_ONCE((mode == CHANCTX_SWMODE_SWAP_CONTEXTS &&
10931a5f0c13SLuciano Coelho 			      new_ctx->driver_present) ||
10941a5f0c13SLuciano Coelho 			     (mode == CHANCTX_SWMODE_REASSIGN_VIF &&
10951a5f0c13SLuciano Coelho 			      !new_ctx->driver_present));
10961a5f0c13SLuciano Coelho 	}
10971a5f0c13SLuciano Coelho 
10981a5f0c13SLuciano Coelho 	trace_drv_switch_vif_chanctx(local, vifs, n_vifs, mode);
10991a5f0c13SLuciano Coelho 	ret = local->ops->switch_vif_chanctx(&local->hw,
11001a5f0c13SLuciano Coelho 					     vifs, n_vifs, mode);
11011a5f0c13SLuciano Coelho 	trace_drv_return_int(local, ret);
11021a5f0c13SLuciano Coelho 
11031a5f0c13SLuciano Coelho 	if (!ret && mode == CHANCTX_SWMODE_SWAP_CONTEXTS) {
11041a5f0c13SLuciano Coelho 		for (i = 0; i < n_vifs; i++) {
11051a5f0c13SLuciano Coelho 			struct ieee80211_chanctx *new_ctx =
11061a5f0c13SLuciano Coelho 				container_of(vifs[i].new_ctx,
11071a5f0c13SLuciano Coelho 					     struct ieee80211_chanctx,
11081a5f0c13SLuciano Coelho 					     conf);
11091a5f0c13SLuciano Coelho 			struct ieee80211_chanctx *old_ctx =
11101a5f0c13SLuciano Coelho 				container_of(vifs[i].old_ctx,
11111a5f0c13SLuciano Coelho 					     struct ieee80211_chanctx,
11121a5f0c13SLuciano Coelho 					     conf);
11131a5f0c13SLuciano Coelho 
11141a5f0c13SLuciano Coelho 			new_ctx->driver_present = true;
11151a5f0c13SLuciano Coelho 			old_ctx->driver_present = false;
11161a5f0c13SLuciano Coelho 		}
11171a5f0c13SLuciano Coelho 	}
11181a5f0c13SLuciano Coelho 
11191a5f0c13SLuciano Coelho 	return ret;
11201a5f0c13SLuciano Coelho }
11211a5f0c13SLuciano Coelho 
11221041638fSJohannes Berg static inline int drv_start_ap(struct ieee80211_local *local,
11231041638fSJohannes Berg 			       struct ieee80211_sub_if_data *sdata)
11241041638fSJohannes Berg {
11251041638fSJohannes Berg 	int ret = 0;
11261041638fSJohannes Berg 
1127f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1128f6837ba8SJohannes Berg 		return -EIO;
11291041638fSJohannes Berg 
11301041638fSJohannes Berg 	trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
11311041638fSJohannes Berg 	if (local->ops->start_ap)
11321041638fSJohannes Berg 		ret = local->ops->start_ap(&local->hw, &sdata->vif);
11331041638fSJohannes Berg 	trace_drv_return_int(local, ret);
11341041638fSJohannes Berg 	return ret;
11351041638fSJohannes Berg }
11361041638fSJohannes Berg 
11371041638fSJohannes Berg static inline void drv_stop_ap(struct ieee80211_local *local,
11381041638fSJohannes Berg 			       struct ieee80211_sub_if_data *sdata)
11391041638fSJohannes Berg {
1140f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1141f6837ba8SJohannes Berg 		return;
11421041638fSJohannes Berg 
11431041638fSJohannes Berg 	trace_drv_stop_ap(local, sdata);
11441041638fSJohannes Berg 	if (local->ops->stop_ap)
11451041638fSJohannes Berg 		local->ops->stop_ap(&local->hw, &sdata->vif);
11461041638fSJohannes Berg 	trace_drv_return_void(local);
11471041638fSJohannes Berg }
11481041638fSJohannes Berg 
1149cf2c92d8SEliad Peller static inline void
1150cf2c92d8SEliad Peller drv_reconfig_complete(struct ieee80211_local *local,
1151cf2c92d8SEliad Peller 		      enum ieee80211_reconfig_type reconfig_type)
11529214ad7fSJohannes Berg {
11539214ad7fSJohannes Berg 	might_sleep();
11549214ad7fSJohannes Berg 
1155cf2c92d8SEliad Peller 	trace_drv_reconfig_complete(local, reconfig_type);
1156cf2c92d8SEliad Peller 	if (local->ops->reconfig_complete)
1157cf2c92d8SEliad Peller 		local->ops->reconfig_complete(&local->hw, reconfig_type);
11589214ad7fSJohannes Berg 	trace_drv_return_void(local);
11599214ad7fSJohannes Berg }
11609214ad7fSJohannes Berg 
1161de5fad81SYoni Divinsky static inline void
1162de5fad81SYoni Divinsky drv_set_default_unicast_key(struct ieee80211_local *local,
1163de5fad81SYoni Divinsky 			    struct ieee80211_sub_if_data *sdata,
1164de5fad81SYoni Divinsky 			    int key_idx)
1165de5fad81SYoni Divinsky {
1166f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1167f6837ba8SJohannes Berg 		return;
1168de5fad81SYoni Divinsky 
1169de5fad81SYoni Divinsky 	WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1170de5fad81SYoni Divinsky 
1171de5fad81SYoni Divinsky 	trace_drv_set_default_unicast_key(local, sdata, key_idx);
1172de5fad81SYoni Divinsky 	if (local->ops->set_default_unicast_key)
1173de5fad81SYoni Divinsky 		local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1174de5fad81SYoni Divinsky 						    key_idx);
1175de5fad81SYoni Divinsky 	trace_drv_return_void(local);
1176de5fad81SYoni Divinsky }
1177de5fad81SYoni Divinsky 
1178a65240c1SJohannes Berg #if IS_ENABLED(CONFIG_IPV6)
1179a65240c1SJohannes Berg static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1180a65240c1SJohannes Berg 					struct ieee80211_sub_if_data *sdata,
1181a65240c1SJohannes Berg 					struct inet6_dev *idev)
1182a65240c1SJohannes Berg {
1183a65240c1SJohannes Berg 	trace_drv_ipv6_addr_change(local, sdata);
1184a65240c1SJohannes Berg 	if (local->ops->ipv6_addr_change)
1185a65240c1SJohannes Berg 		local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1186a65240c1SJohannes Berg 	trace_drv_return_void(local);
1187a65240c1SJohannes Berg }
1188a65240c1SJohannes Berg #endif
1189a65240c1SJohannes Berg 
119073da7d5bSSimon Wunderlich static inline void
119173da7d5bSSimon Wunderlich drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
119273da7d5bSSimon Wunderlich 			  struct cfg80211_chan_def *chandef)
119373da7d5bSSimon Wunderlich {
119473da7d5bSSimon Wunderlich 	struct ieee80211_local *local = sdata->local;
119573da7d5bSSimon Wunderlich 
119673da7d5bSSimon Wunderlich 	if (local->ops->channel_switch_beacon) {
119773da7d5bSSimon Wunderlich 		trace_drv_channel_switch_beacon(local, sdata, chandef);
119873da7d5bSSimon Wunderlich 		local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
119973da7d5bSSimon Wunderlich 						  chandef);
120073da7d5bSSimon Wunderlich 	}
120173da7d5bSSimon Wunderlich }
120273da7d5bSSimon Wunderlich 
12036d027bccSLuciano Coelho static inline int
12046d027bccSLuciano Coelho drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
12056d027bccSLuciano Coelho 		       struct ieee80211_channel_switch *ch_switch)
12066d027bccSLuciano Coelho {
12076d027bccSLuciano Coelho 	struct ieee80211_local *local = sdata->local;
12086d027bccSLuciano Coelho 	int ret = 0;
12096d027bccSLuciano Coelho 
12106d027bccSLuciano Coelho 	if (!check_sdata_in_driver(sdata))
12116d027bccSLuciano Coelho 		return -EIO;
12126d027bccSLuciano Coelho 
12136d027bccSLuciano Coelho 	trace_drv_pre_channel_switch(local, sdata, ch_switch);
12146d027bccSLuciano Coelho 	if (local->ops->pre_channel_switch)
12156d027bccSLuciano Coelho 		ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
12166d027bccSLuciano Coelho 						     ch_switch);
12176d027bccSLuciano Coelho 	trace_drv_return_int(local, ret);
12186d027bccSLuciano Coelho 	return ret;
12196d027bccSLuciano Coelho }
12206d027bccSLuciano Coelho 
1221f1d65583SLuciano Coelho static inline int
1222f1d65583SLuciano Coelho drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1223f1d65583SLuciano Coelho {
1224f1d65583SLuciano Coelho 	struct ieee80211_local *local = sdata->local;
1225f1d65583SLuciano Coelho 	int ret = 0;
1226f1d65583SLuciano Coelho 
1227f1d65583SLuciano Coelho 	if (!check_sdata_in_driver(sdata))
1228f1d65583SLuciano Coelho 		return -EIO;
1229f1d65583SLuciano Coelho 
1230f1d65583SLuciano Coelho 	trace_drv_post_channel_switch(local, sdata);
1231f1d65583SLuciano Coelho 	if (local->ops->post_channel_switch)
1232f1d65583SLuciano Coelho 		ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1233f1d65583SLuciano Coelho 	trace_drv_return_int(local, ret);
1234f1d65583SLuciano Coelho 	return ret;
1235f1d65583SLuciano Coelho }
1236f1d65583SLuciano Coelho 
123755fff501SJohannes Berg static inline int drv_join_ibss(struct ieee80211_local *local,
123855fff501SJohannes Berg 				struct ieee80211_sub_if_data *sdata)
123955fff501SJohannes Berg {
124055fff501SJohannes Berg 	int ret = 0;
124155fff501SJohannes Berg 
124255fff501SJohannes Berg 	might_sleep();
1243f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1244f6837ba8SJohannes Berg 		return -EIO;
124555fff501SJohannes Berg 
124655fff501SJohannes Berg 	trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
124755fff501SJohannes Berg 	if (local->ops->join_ibss)
124855fff501SJohannes Berg 		ret = local->ops->join_ibss(&local->hw, &sdata->vif);
124955fff501SJohannes Berg 	trace_drv_return_int(local, ret);
125055fff501SJohannes Berg 	return ret;
125155fff501SJohannes Berg }
125255fff501SJohannes Berg 
125355fff501SJohannes Berg static inline void drv_leave_ibss(struct ieee80211_local *local,
125455fff501SJohannes Berg 				  struct ieee80211_sub_if_data *sdata)
125555fff501SJohannes Berg {
125655fff501SJohannes Berg 	might_sleep();
1257f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1258f6837ba8SJohannes Berg 		return;
125955fff501SJohannes Berg 
126055fff501SJohannes Berg 	trace_drv_leave_ibss(local, sdata);
126155fff501SJohannes Berg 	if (local->ops->leave_ibss)
126255fff501SJohannes Berg 		local->ops->leave_ibss(&local->hw, &sdata->vif);
126355fff501SJohannes Berg 	trace_drv_return_void(local);
126455fff501SJohannes Berg }
126555fff501SJohannes Berg 
1266cca674d4SAntonio Quartulli static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
1267cca674d4SAntonio Quartulli 					      struct ieee80211_sta *sta)
1268cca674d4SAntonio Quartulli {
1269cca674d4SAntonio Quartulli 	u32 ret = 0;
1270cca674d4SAntonio Quartulli 
1271cca674d4SAntonio Quartulli 	trace_drv_get_expected_throughput(sta);
1272cca674d4SAntonio Quartulli 	if (local->ops->get_expected_throughput)
1273cca674d4SAntonio Quartulli 		ret = local->ops->get_expected_throughput(sta);
1274cca674d4SAntonio Quartulli 	trace_drv_return_u32(local, ret);
1275cca674d4SAntonio Quartulli 
1276cca674d4SAntonio Quartulli 	return ret;
1277cca674d4SAntonio Quartulli }
1278cca674d4SAntonio Quartulli 
12795b3dc42bSFelix Fietkau static inline int drv_get_txpower(struct ieee80211_local *local,
12805b3dc42bSFelix Fietkau 				  struct ieee80211_sub_if_data *sdata, int *dbm)
12815b3dc42bSFelix Fietkau {
12825b3dc42bSFelix Fietkau 	int ret;
12835b3dc42bSFelix Fietkau 
12845b3dc42bSFelix Fietkau 	if (!local->ops->get_txpower)
12855b3dc42bSFelix Fietkau 		return -EOPNOTSUPP;
12865b3dc42bSFelix Fietkau 
12875b3dc42bSFelix Fietkau 	ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
12885b3dc42bSFelix Fietkau 	trace_drv_get_txpower(local, sdata, *dbm, ret);
12895b3dc42bSFelix Fietkau 
12905b3dc42bSFelix Fietkau 	return ret;
12915b3dc42bSFelix Fietkau }
12925b3dc42bSFelix Fietkau 
1293a7a6bdd0SArik Nemtsov static inline int
1294a7a6bdd0SArik Nemtsov drv_tdls_channel_switch(struct ieee80211_local *local,
1295a7a6bdd0SArik Nemtsov 			struct ieee80211_sub_if_data *sdata,
1296a7a6bdd0SArik Nemtsov 			struct ieee80211_sta *sta, u8 oper_class,
1297a7a6bdd0SArik Nemtsov 			struct cfg80211_chan_def *chandef,
1298a7a6bdd0SArik Nemtsov 			struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
1299a7a6bdd0SArik Nemtsov {
1300a7a6bdd0SArik Nemtsov 	int ret;
1301a7a6bdd0SArik Nemtsov 
1302a7a6bdd0SArik Nemtsov 	might_sleep();
1303a7a6bdd0SArik Nemtsov 	if (!check_sdata_in_driver(sdata))
1304a7a6bdd0SArik Nemtsov 		return -EIO;
1305a7a6bdd0SArik Nemtsov 
1306a7a6bdd0SArik Nemtsov 	if (!local->ops->tdls_channel_switch)
1307a7a6bdd0SArik Nemtsov 		return -EOPNOTSUPP;
1308a7a6bdd0SArik Nemtsov 
1309a7a6bdd0SArik Nemtsov 	trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
1310a7a6bdd0SArik Nemtsov 	ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
1311a7a6bdd0SArik Nemtsov 					      oper_class, chandef, tmpl_skb,
1312a7a6bdd0SArik Nemtsov 					      ch_sw_tm_ie);
1313a7a6bdd0SArik Nemtsov 	trace_drv_return_int(local, ret);
1314a7a6bdd0SArik Nemtsov 	return ret;
1315a7a6bdd0SArik Nemtsov }
1316a7a6bdd0SArik Nemtsov 
1317a7a6bdd0SArik Nemtsov static inline void
1318a7a6bdd0SArik Nemtsov drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
1319a7a6bdd0SArik Nemtsov 			       struct ieee80211_sub_if_data *sdata,
1320a7a6bdd0SArik Nemtsov 			       struct ieee80211_sta *sta)
1321a7a6bdd0SArik Nemtsov {
1322a7a6bdd0SArik Nemtsov 	might_sleep();
1323a7a6bdd0SArik Nemtsov 	if (!check_sdata_in_driver(sdata))
1324a7a6bdd0SArik Nemtsov 		return;
1325a7a6bdd0SArik Nemtsov 
1326a7a6bdd0SArik Nemtsov 	if (!local->ops->tdls_cancel_channel_switch)
1327a7a6bdd0SArik Nemtsov 		return;
1328a7a6bdd0SArik Nemtsov 
1329a7a6bdd0SArik Nemtsov 	trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
1330a7a6bdd0SArik Nemtsov 	local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
1331a7a6bdd0SArik Nemtsov 	trace_drv_return_void(local);
1332a7a6bdd0SArik Nemtsov }
1333a7a6bdd0SArik Nemtsov 
13348a4d32f3SArik Nemtsov static inline void
13358a4d32f3SArik Nemtsov drv_tdls_recv_channel_switch(struct ieee80211_local *local,
13368a4d32f3SArik Nemtsov 			     struct ieee80211_sub_if_data *sdata,
13378a4d32f3SArik Nemtsov 			     struct ieee80211_tdls_ch_sw_params *params)
13388a4d32f3SArik Nemtsov {
13398a4d32f3SArik Nemtsov 	trace_drv_tdls_recv_channel_switch(local, sdata, params);
13408a4d32f3SArik Nemtsov 	if (local->ops->tdls_recv_channel_switch)
13418a4d32f3SArik Nemtsov 		local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
13428a4d32f3SArik Nemtsov 						     params);
13438a4d32f3SArik Nemtsov 	trace_drv_return_void(local);
13448a4d32f3SArik Nemtsov }
13458a4d32f3SArik Nemtsov 
1346ba8c3d6fSFelix Fietkau static inline void drv_wake_tx_queue(struct ieee80211_local *local,
1347ba8c3d6fSFelix Fietkau 				     struct txq_info *txq)
1348ba8c3d6fSFelix Fietkau {
1349ba8c3d6fSFelix Fietkau 	struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
1350ba8c3d6fSFelix Fietkau 
1351ba8c3d6fSFelix Fietkau 	if (!check_sdata_in_driver(sdata))
1352ba8c3d6fSFelix Fietkau 		return;
1353ba8c3d6fSFelix Fietkau 
1354ba8c3d6fSFelix Fietkau 	trace_drv_wake_tx_queue(local, sdata, txq);
1355ba8c3d6fSFelix Fietkau 	local->ops->wake_tx_queue(&local->hw, &txq->txq);
1356ba8c3d6fSFelix Fietkau }
1357ba8c3d6fSFelix Fietkau 
135824487981SJohannes Berg #endif /* __MAC80211_DRIVER_OPS */
1359