xref: /openbmc/linux/net/mac80211/driver-ops.h (revision f409079b)
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 &&
2175bbe754dSJohannes Berg 			 sdata->vif.type != NL80211_IFTYPE_MESH_POINT))
2185bbe754dSJohannes Berg 		return;
2195bbe754dSJohannes Berg 
2205bbe754dSJohannes Berg 	if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
2215bbe754dSJohannes Berg 			 sdata->vif.type == NL80211_IFTYPE_MONITOR))
2225bbe754dSJohannes Berg 		return;
223b8dc1a35SJohannes Berg 
224f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
225f6837ba8SJohannes Berg 		return;
2267b7eab6fSJohannes Berg 
2274efc76bdSJohannes Berg 	trace_drv_bss_info_changed(local, sdata, info, changed);
22824487981SJohannes Berg 	if (local->ops->bss_info_changed)
22912375ef9SJohannes Berg 		local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
2304efc76bdSJohannes Berg 	trace_drv_return_void(local);
23124487981SJohannes Berg }
23224487981SJohannes Berg 
2333ac64beeSJohannes Berg static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
23422bedad3SJiri Pirko 					struct netdev_hw_addr_list *mc_list)
23524487981SJohannes Berg {
2363ac64beeSJohannes Berg 	u64 ret = 0;
2373ac64beeSJohannes Berg 
2384efc76bdSJohannes Berg 	trace_drv_prepare_multicast(local, mc_list->count);
2394efc76bdSJohannes Berg 
2403ac64beeSJohannes Berg 	if (local->ops->prepare_multicast)
24122bedad3SJiri Pirko 		ret = local->ops->prepare_multicast(&local->hw, mc_list);
2423ac64beeSJohannes Berg 
2434efc76bdSJohannes Berg 	trace_drv_return_u64(local, ret);
2443ac64beeSJohannes Berg 
2453ac64beeSJohannes Berg 	return ret;
2463ac64beeSJohannes Berg }
2473ac64beeSJohannes Berg 
2483ac64beeSJohannes Berg static inline void drv_configure_filter(struct ieee80211_local *local,
2493ac64beeSJohannes Berg 					unsigned int changed_flags,
2503ac64beeSJohannes Berg 					unsigned int *total_flags,
2513ac64beeSJohannes Berg 					u64 multicast)
2523ac64beeSJohannes Berg {
2533ac64beeSJohannes Berg 	might_sleep();
2543ac64beeSJohannes Berg 
2550a2b8bb2SJohannes Berg 	trace_drv_configure_filter(local, changed_flags, total_flags,
2563ac64beeSJohannes Berg 				   multicast);
2574efc76bdSJohannes Berg 	local->ops->configure_filter(&local->hw, changed_flags, total_flags,
2584efc76bdSJohannes Berg 				     multicast);
2594efc76bdSJohannes Berg 	trace_drv_return_void(local);
26024487981SJohannes Berg }
26124487981SJohannes Berg 
26224487981SJohannes Berg static inline int drv_set_tim(struct ieee80211_local *local,
26324487981SJohannes Berg 			      struct ieee80211_sta *sta, bool set)
26424487981SJohannes Berg {
2650a2b8bb2SJohannes Berg 	int ret = 0;
2664efc76bdSJohannes Berg 	trace_drv_set_tim(local, sta, set);
26724487981SJohannes Berg 	if (local->ops->set_tim)
2680a2b8bb2SJohannes Berg 		ret = local->ops->set_tim(&local->hw, sta, set);
2694efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
2700a2b8bb2SJohannes Berg 	return ret;
27124487981SJohannes Berg }
27224487981SJohannes Berg 
27324487981SJohannes Berg static inline int drv_set_key(struct ieee80211_local *local,
27412375ef9SJohannes Berg 			      enum set_key_cmd cmd,
27512375ef9SJohannes Berg 			      struct ieee80211_sub_if_data *sdata,
27624487981SJohannes Berg 			      struct ieee80211_sta *sta,
27724487981SJohannes Berg 			      struct ieee80211_key_conf *key)
27824487981SJohannes Berg {
279e1781ed3SKalle Valo 	int ret;
280e1781ed3SKalle Valo 
281e1781ed3SKalle Valo 	might_sleep();
282e1781ed3SKalle Valo 
283077f4939SJohannes Berg 	sdata = get_bss_sdata(sdata);
284f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
285f6837ba8SJohannes Berg 		return -EIO;
2867b7eab6fSJohannes Berg 
2874efc76bdSJohannes Berg 	trace_drv_set_key(local, cmd, sdata, sta, key);
288e1781ed3SKalle Valo 	ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
2894efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
2900a2b8bb2SJohannes Berg 	return ret;
29124487981SJohannes Berg }
29224487981SJohannes Berg 
29324487981SJohannes Berg static inline void drv_update_tkip_key(struct ieee80211_local *local,
294b3fbdcf4SJohannes Berg 				       struct ieee80211_sub_if_data *sdata,
29524487981SJohannes Berg 				       struct ieee80211_key_conf *conf,
296b3fbdcf4SJohannes Berg 				       struct sta_info *sta, u32 iv32,
29724487981SJohannes Berg 				       u16 *phase1key)
29824487981SJohannes Berg {
299b3fbdcf4SJohannes Berg 	struct ieee80211_sta *ista = NULL;
300b3fbdcf4SJohannes Berg 
301b3fbdcf4SJohannes Berg 	if (sta)
302b3fbdcf4SJohannes Berg 		ista = &sta->sta;
303b3fbdcf4SJohannes Berg 
304077f4939SJohannes Berg 	sdata = get_bss_sdata(sdata);
305f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
306f6837ba8SJohannes Berg 		return;
3077b7eab6fSJohannes Berg 
3084efc76bdSJohannes Berg 	trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
30924487981SJohannes Berg 	if (local->ops->update_tkip_key)
310b3fbdcf4SJohannes Berg 		local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
311b3fbdcf4SJohannes Berg 					    ista, iv32, phase1key);
3124efc76bdSJohannes Berg 	trace_drv_return_void(local);
31324487981SJohannes Berg }
31424487981SJohannes Berg 
31524487981SJohannes Berg static inline int drv_hw_scan(struct ieee80211_local *local,
316a060bbfeSJohannes Berg 			      struct ieee80211_sub_if_data *sdata,
317c56ef672SDavid Spinadel 			      struct ieee80211_scan_request *req)
31824487981SJohannes Berg {
319e1781ed3SKalle Valo 	int ret;
320e1781ed3SKalle Valo 
321e1781ed3SKalle Valo 	might_sleep();
322e1781ed3SKalle Valo 
323f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
324f6837ba8SJohannes Berg 		return -EIO;
3257b7eab6fSJohannes Berg 
32679f460caSLuciano Coelho 	trace_drv_hw_scan(local, sdata);
327a060bbfeSJohannes Berg 	ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
3284efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
3290a2b8bb2SJohannes Berg 	return ret;
33024487981SJohannes Berg }
33124487981SJohannes Berg 
332b856439bSEliad Peller static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
333b856439bSEliad Peller 				      struct ieee80211_sub_if_data *sdata)
334b856439bSEliad Peller {
335b856439bSEliad Peller 	might_sleep();
336b856439bSEliad Peller 
337f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
338f6837ba8SJohannes Berg 		return;
3397b7eab6fSJohannes Berg 
340b856439bSEliad Peller 	trace_drv_cancel_hw_scan(local, sdata);
341b856439bSEliad Peller 	local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
342b856439bSEliad Peller 	trace_drv_return_void(local);
343b856439bSEliad Peller }
344b856439bSEliad Peller 
34579f460caSLuciano Coelho static inline int
34679f460caSLuciano Coelho drv_sched_scan_start(struct ieee80211_local *local,
34779f460caSLuciano Coelho 		     struct ieee80211_sub_if_data *sdata,
34879f460caSLuciano Coelho 		     struct cfg80211_sched_scan_request *req,
349633e2713SDavid Spinadel 		     struct ieee80211_scan_ies *ies)
35079f460caSLuciano Coelho {
35179f460caSLuciano Coelho 	int ret;
35279f460caSLuciano Coelho 
35379f460caSLuciano Coelho 	might_sleep();
35479f460caSLuciano Coelho 
355f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
356f6837ba8SJohannes Berg 		return -EIO;
3577b7eab6fSJohannes Berg 
35879f460caSLuciano Coelho 	trace_drv_sched_scan_start(local, sdata);
35979f460caSLuciano Coelho 	ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
36079f460caSLuciano Coelho 					      req, ies);
36179f460caSLuciano Coelho 	trace_drv_return_int(local, ret);
36279f460caSLuciano Coelho 	return ret;
36379f460caSLuciano Coelho }
36479f460caSLuciano Coelho 
36537e3308cSJohannes Berg static inline int drv_sched_scan_stop(struct ieee80211_local *local,
36679f460caSLuciano Coelho 				      struct ieee80211_sub_if_data *sdata)
36779f460caSLuciano Coelho {
36837e3308cSJohannes Berg 	int ret;
36937e3308cSJohannes Berg 
37079f460caSLuciano Coelho 	might_sleep();
37179f460caSLuciano Coelho 
372f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
373f6837ba8SJohannes Berg 		return -EIO;
3747b7eab6fSJohannes Berg 
37579f460caSLuciano Coelho 	trace_drv_sched_scan_stop(local, sdata);
37637e3308cSJohannes Berg 	ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
37737e3308cSJohannes Berg 	trace_drv_return_int(local, ret);
37837e3308cSJohannes Berg 
37937e3308cSJohannes Berg 	return ret;
38079f460caSLuciano Coelho }
38179f460caSLuciano Coelho 
38224487981SJohannes Berg static inline void drv_sw_scan_start(struct ieee80211_local *local)
38324487981SJohannes Berg {
384e1781ed3SKalle Valo 	might_sleep();
385e1781ed3SKalle Valo 
3864efc76bdSJohannes Berg 	trace_drv_sw_scan_start(local);
38724487981SJohannes Berg 	if (local->ops->sw_scan_start)
38824487981SJohannes Berg 		local->ops->sw_scan_start(&local->hw);
3894efc76bdSJohannes Berg 	trace_drv_return_void(local);
39024487981SJohannes Berg }
39124487981SJohannes Berg 
39224487981SJohannes Berg static inline void drv_sw_scan_complete(struct ieee80211_local *local)
39324487981SJohannes Berg {
394e1781ed3SKalle Valo 	might_sleep();
395e1781ed3SKalle Valo 
3964efc76bdSJohannes Berg 	trace_drv_sw_scan_complete(local);
39724487981SJohannes Berg 	if (local->ops->sw_scan_complete)
39824487981SJohannes Berg 		local->ops->sw_scan_complete(&local->hw);
3994efc76bdSJohannes Berg 	trace_drv_return_void(local);
40024487981SJohannes Berg }
40124487981SJohannes Berg 
40224487981SJohannes Berg static inline int drv_get_stats(struct ieee80211_local *local,
40324487981SJohannes Berg 				struct ieee80211_low_level_stats *stats)
40424487981SJohannes Berg {
4050a2b8bb2SJohannes Berg 	int ret = -EOPNOTSUPP;
4060a2b8bb2SJohannes Berg 
407e1781ed3SKalle Valo 	might_sleep();
408e1781ed3SKalle Valo 
4090a2b8bb2SJohannes Berg 	if (local->ops->get_stats)
4100a2b8bb2SJohannes Berg 		ret = local->ops->get_stats(&local->hw, stats);
4110a2b8bb2SJohannes Berg 	trace_drv_get_stats(local, stats, ret);
4120a2b8bb2SJohannes Berg 
4130a2b8bb2SJohannes Berg 	return ret;
41424487981SJohannes Berg }
41524487981SJohannes Berg 
41624487981SJohannes Berg static inline void drv_get_tkip_seq(struct ieee80211_local *local,
41724487981SJohannes Berg 				    u8 hw_key_idx, u32 *iv32, u16 *iv16)
41824487981SJohannes Berg {
41924487981SJohannes Berg 	if (local->ops->get_tkip_seq)
42024487981SJohannes Berg 		local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
4210a2b8bb2SJohannes Berg 	trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
42224487981SJohannes Berg }
42324487981SJohannes Berg 
424f23a4780SArik Nemtsov static inline int drv_set_frag_threshold(struct ieee80211_local *local,
425f23a4780SArik Nemtsov 					u32 value)
426f23a4780SArik Nemtsov {
427f23a4780SArik Nemtsov 	int ret = 0;
428f23a4780SArik Nemtsov 
429f23a4780SArik Nemtsov 	might_sleep();
430f23a4780SArik Nemtsov 
431f23a4780SArik Nemtsov 	trace_drv_set_frag_threshold(local, value);
432f23a4780SArik Nemtsov 	if (local->ops->set_frag_threshold)
433f23a4780SArik Nemtsov 		ret = local->ops->set_frag_threshold(&local->hw, value);
434f23a4780SArik Nemtsov 	trace_drv_return_int(local, ret);
435f23a4780SArik Nemtsov 	return ret;
436f23a4780SArik Nemtsov }
437f23a4780SArik Nemtsov 
43824487981SJohannes Berg static inline int drv_set_rts_threshold(struct ieee80211_local *local,
43924487981SJohannes Berg 					u32 value)
44024487981SJohannes Berg {
4410a2b8bb2SJohannes Berg 	int ret = 0;
442e1781ed3SKalle Valo 
443e1781ed3SKalle Valo 	might_sleep();
444e1781ed3SKalle Valo 
4454efc76bdSJohannes Berg 	trace_drv_set_rts_threshold(local, value);
44624487981SJohannes Berg 	if (local->ops->set_rts_threshold)
4470a2b8bb2SJohannes Berg 		ret = local->ops->set_rts_threshold(&local->hw, value);
4484efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
4490a2b8bb2SJohannes Berg 	return ret;
45024487981SJohannes Berg }
45124487981SJohannes Berg 
452310bc676SLukáš Turek static inline int drv_set_coverage_class(struct ieee80211_local *local,
453a4bcaf55SLorenzo Bianconi 					 s16 value)
454310bc676SLukáš Turek {
455310bc676SLukáš Turek 	int ret = 0;
456310bc676SLukáš Turek 	might_sleep();
457310bc676SLukáš Turek 
4584efc76bdSJohannes Berg 	trace_drv_set_coverage_class(local, value);
459310bc676SLukáš Turek 	if (local->ops->set_coverage_class)
460310bc676SLukáš Turek 		local->ops->set_coverage_class(&local->hw, value);
461310bc676SLukáš Turek 	else
462310bc676SLukáš Turek 		ret = -EOPNOTSUPP;
463310bc676SLukáš Turek 
4644efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
465310bc676SLukáš Turek 	return ret;
466310bc676SLukáš Turek }
467310bc676SLukáš Turek 
46824487981SJohannes Berg static inline void drv_sta_notify(struct ieee80211_local *local,
46912375ef9SJohannes Berg 				  struct ieee80211_sub_if_data *sdata,
47024487981SJohannes Berg 				  enum sta_notify_cmd cmd,
47124487981SJohannes Berg 				  struct ieee80211_sta *sta)
47224487981SJohannes Berg {
473bc192f89SFelix Fietkau 	sdata = get_bss_sdata(sdata);
474f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
475f6837ba8SJohannes Berg 		return;
4767b7eab6fSJohannes Berg 
4774efc76bdSJohannes Berg 	trace_drv_sta_notify(local, sdata, cmd, sta);
47824487981SJohannes Berg 	if (local->ops->sta_notify)
47912375ef9SJohannes Berg 		local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
4804efc76bdSJohannes Berg 	trace_drv_return_void(local);
48124487981SJohannes Berg }
48224487981SJohannes Berg 
48334e89507SJohannes Berg static inline int drv_sta_add(struct ieee80211_local *local,
48434e89507SJohannes Berg 			      struct ieee80211_sub_if_data *sdata,
48534e89507SJohannes Berg 			      struct ieee80211_sta *sta)
48634e89507SJohannes Berg {
48734e89507SJohannes Berg 	int ret = 0;
48834e89507SJohannes Berg 
48934e89507SJohannes Berg 	might_sleep();
49034e89507SJohannes Berg 
491bc192f89SFelix Fietkau 	sdata = get_bss_sdata(sdata);
492f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
493f6837ba8SJohannes Berg 		return -EIO;
4947b7eab6fSJohannes Berg 
4954efc76bdSJohannes Berg 	trace_drv_sta_add(local, sdata, sta);
49634e89507SJohannes Berg 	if (local->ops->sta_add)
49734e89507SJohannes Berg 		ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
49834e89507SJohannes Berg 
4994efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
50034e89507SJohannes Berg 
50134e89507SJohannes Berg 	return ret;
50234e89507SJohannes Berg }
50334e89507SJohannes Berg 
50434e89507SJohannes Berg static inline void drv_sta_remove(struct ieee80211_local *local,
50534e89507SJohannes Berg 				  struct ieee80211_sub_if_data *sdata,
50634e89507SJohannes Berg 				  struct ieee80211_sta *sta)
50734e89507SJohannes Berg {
50834e89507SJohannes Berg 	might_sleep();
50934e89507SJohannes Berg 
510bc192f89SFelix Fietkau 	sdata = get_bss_sdata(sdata);
511f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
512f6837ba8SJohannes Berg 		return;
5137b7eab6fSJohannes Berg 
5144efc76bdSJohannes Berg 	trace_drv_sta_remove(local, sdata, sta);
51534e89507SJohannes Berg 	if (local->ops->sta_remove)
51634e89507SJohannes Berg 		local->ops->sta_remove(&local->hw, &sdata->vif, sta);
51734e89507SJohannes Berg 
5184efc76bdSJohannes Berg 	trace_drv_return_void(local);
51934e89507SJohannes Berg }
52034e89507SJohannes Berg 
52177d2ece6SSujith Manoharan #ifdef CONFIG_MAC80211_DEBUGFS
52277d2ece6SSujith Manoharan static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
52377d2ece6SSujith Manoharan 				       struct ieee80211_sub_if_data *sdata,
52477d2ece6SSujith Manoharan 				       struct ieee80211_sta *sta,
52577d2ece6SSujith Manoharan 				       struct dentry *dir)
52677d2ece6SSujith Manoharan {
52777d2ece6SSujith Manoharan 	might_sleep();
52877d2ece6SSujith Manoharan 
52977d2ece6SSujith Manoharan 	sdata = get_bss_sdata(sdata);
530f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
531f6837ba8SJohannes Berg 		return;
53277d2ece6SSujith Manoharan 
53377d2ece6SSujith Manoharan 	if (local->ops->sta_add_debugfs)
53477d2ece6SSujith Manoharan 		local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
53577d2ece6SSujith Manoharan 					    sta, dir);
53677d2ece6SSujith Manoharan }
53777d2ece6SSujith Manoharan 
53877d2ece6SSujith Manoharan static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
53977d2ece6SSujith Manoharan 					  struct ieee80211_sub_if_data *sdata,
54077d2ece6SSujith Manoharan 					  struct ieee80211_sta *sta,
54177d2ece6SSujith Manoharan 					  struct dentry *dir)
54277d2ece6SSujith Manoharan {
54377d2ece6SSujith Manoharan 	might_sleep();
54477d2ece6SSujith Manoharan 
54577d2ece6SSujith Manoharan 	sdata = get_bss_sdata(sdata);
54677d2ece6SSujith Manoharan 	check_sdata_in_driver(sdata);
54777d2ece6SSujith Manoharan 
54877d2ece6SSujith Manoharan 	if (local->ops->sta_remove_debugfs)
54977d2ece6SSujith Manoharan 		local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
55077d2ece6SSujith Manoharan 					       sta, dir);
55177d2ece6SSujith Manoharan }
55277d2ece6SSujith Manoharan #endif
55377d2ece6SSujith Manoharan 
5546a9d1b91SJohannes Berg static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
5556a9d1b91SJohannes Berg 					  struct ieee80211_sub_if_data *sdata,
5566a9d1b91SJohannes Berg 					  struct sta_info *sta)
5576a9d1b91SJohannes Berg {
5586a9d1b91SJohannes Berg 	might_sleep();
5596a9d1b91SJohannes Berg 
5606a9d1b91SJohannes Berg 	sdata = get_bss_sdata(sdata);
561f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
562f6837ba8SJohannes Berg 		return;
5636a9d1b91SJohannes Berg 
5646a9d1b91SJohannes Berg 	trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
5656a9d1b91SJohannes Berg 	if (local->ops->sta_pre_rcu_remove)
5666a9d1b91SJohannes Berg 		local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
5676a9d1b91SJohannes Berg 					       &sta->sta);
5686a9d1b91SJohannes Berg 	trace_drv_return_void(local);
5696a9d1b91SJohannes Berg }
5706a9d1b91SJohannes Berg 
571f09603a2SJohannes Berg static inline __must_check
572f09603a2SJohannes Berg int drv_sta_state(struct ieee80211_local *local,
573f09603a2SJohannes Berg 		  struct ieee80211_sub_if_data *sdata,
574f09603a2SJohannes Berg 		  struct sta_info *sta,
575f09603a2SJohannes Berg 		  enum ieee80211_sta_state old_state,
576f09603a2SJohannes Berg 		  enum ieee80211_sta_state new_state)
577f09603a2SJohannes Berg {
578f09603a2SJohannes Berg 	int ret = 0;
579f09603a2SJohannes Berg 
580f09603a2SJohannes Berg 	might_sleep();
581f09603a2SJohannes Berg 
582f09603a2SJohannes Berg 	sdata = get_bss_sdata(sdata);
583f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
584f6837ba8SJohannes Berg 		return -EIO;
585f09603a2SJohannes Berg 
586f09603a2SJohannes Berg 	trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
587a4ec45a4SJohannes Berg 	if (local->ops->sta_state) {
588f09603a2SJohannes Berg 		ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta,
589f09603a2SJohannes Berg 					    old_state, new_state);
590a4ec45a4SJohannes Berg 	} else if (old_state == IEEE80211_STA_AUTH &&
591a4ec45a4SJohannes Berg 		   new_state == IEEE80211_STA_ASSOC) {
592a4ec45a4SJohannes Berg 		ret = drv_sta_add(local, sdata, &sta->sta);
593a4ec45a4SJohannes Berg 		if (ret == 0)
594a4ec45a4SJohannes Berg 			sta->uploaded = true;
595a4ec45a4SJohannes Berg 	} else if (old_state == IEEE80211_STA_ASSOC &&
596a4ec45a4SJohannes Berg 		   new_state == IEEE80211_STA_AUTH) {
597a4ec45a4SJohannes Berg 		drv_sta_remove(local, sdata, &sta->sta);
598a4ec45a4SJohannes Berg 	}
599f09603a2SJohannes Berg 	trace_drv_return_int(local, ret);
600f09603a2SJohannes Berg 	return ret;
601f09603a2SJohannes Berg }
602f09603a2SJohannes Berg 
6038f727ef3SJohannes Berg static inline void drv_sta_rc_update(struct ieee80211_local *local,
6048f727ef3SJohannes Berg 				     struct ieee80211_sub_if_data *sdata,
6058f727ef3SJohannes Berg 				     struct ieee80211_sta *sta, u32 changed)
6068f727ef3SJohannes Berg {
6078f727ef3SJohannes Berg 	sdata = get_bss_sdata(sdata);
608f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
609f6837ba8SJohannes Berg 		return;
6108f727ef3SJohannes Berg 
611e687f61eSAntonio Quartulli 	WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED &&
612f68d776aSThomas Pedersen 		(sdata->vif.type != NL80211_IFTYPE_ADHOC &&
613f68d776aSThomas Pedersen 		 sdata->vif.type != NL80211_IFTYPE_MESH_POINT));
614e687f61eSAntonio Quartulli 
6158f727ef3SJohannes Berg 	trace_drv_sta_rc_update(local, sdata, sta, changed);
6168f727ef3SJohannes Berg 	if (local->ops->sta_rc_update)
6178f727ef3SJohannes Berg 		local->ops->sta_rc_update(&local->hw, &sdata->vif,
6188f727ef3SJohannes Berg 					  sta, changed);
6198f727ef3SJohannes Berg 
6208f727ef3SJohannes Berg 	trace_drv_return_void(local);
6218f727ef3SJohannes Berg }
6228f727ef3SJohannes Berg 
623f6f3def3SEliad Peller static inline int drv_conf_tx(struct ieee80211_local *local,
624a3304b0aSJohannes Berg 			      struct ieee80211_sub_if_data *sdata, u16 ac,
62524487981SJohannes Berg 			      const struct ieee80211_tx_queue_params *params)
62624487981SJohannes Berg {
6270a2b8bb2SJohannes Berg 	int ret = -EOPNOTSUPP;
628e1781ed3SKalle Valo 
629e1781ed3SKalle Valo 	might_sleep();
630e1781ed3SKalle Valo 
631f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
632f6837ba8SJohannes Berg 		return -EIO;
6337b7eab6fSJohannes Berg 
634f409079bSJohannes Berg 	if (WARN_ONCE(params->cw_min == 0 ||
635f409079bSJohannes Berg 		      params->cw_min > params->cw_max,
636f409079bSJohannes Berg 		      "%s: invalid CW_min/CW_max: %d/%d\n",
637f409079bSJohannes Berg 		      sdata->name, params->cw_min, params->cw_max))
638f409079bSJohannes Berg 		return -EINVAL;
639f409079bSJohannes Berg 
640a3304b0aSJohannes Berg 	trace_drv_conf_tx(local, sdata, ac, params);
64124487981SJohannes Berg 	if (local->ops->conf_tx)
6428a3a3c85SEliad Peller 		ret = local->ops->conf_tx(&local->hw, &sdata->vif,
643a3304b0aSJohannes Berg 					  ac, params);
6444efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
6450a2b8bb2SJohannes Berg 	return ret;
64624487981SJohannes Berg }
64724487981SJohannes Berg 
64837a41b4aSEliad Peller static inline u64 drv_get_tsf(struct ieee80211_local *local,
64937a41b4aSEliad Peller 			      struct ieee80211_sub_if_data *sdata)
65024487981SJohannes Berg {
6510a2b8bb2SJohannes Berg 	u64 ret = -1ULL;
652e1781ed3SKalle Valo 
653e1781ed3SKalle Valo 	might_sleep();
654e1781ed3SKalle Valo 
655f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
656f6837ba8SJohannes Berg 		return ret;
6577b7eab6fSJohannes Berg 
65837a41b4aSEliad Peller 	trace_drv_get_tsf(local, sdata);
65924487981SJohannes Berg 	if (local->ops->get_tsf)
66037a41b4aSEliad Peller 		ret = local->ops->get_tsf(&local->hw, &sdata->vif);
6614efc76bdSJohannes Berg 	trace_drv_return_u64(local, ret);
6620a2b8bb2SJohannes Berg 	return ret;
66324487981SJohannes Berg }
66424487981SJohannes Berg 
66537a41b4aSEliad Peller static inline void drv_set_tsf(struct ieee80211_local *local,
66637a41b4aSEliad Peller 			       struct ieee80211_sub_if_data *sdata,
66737a41b4aSEliad Peller 			       u64 tsf)
66824487981SJohannes Berg {
669e1781ed3SKalle Valo 	might_sleep();
670e1781ed3SKalle Valo 
671f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
672f6837ba8SJohannes Berg 		return;
6737b7eab6fSJohannes Berg 
67437a41b4aSEliad Peller 	trace_drv_set_tsf(local, sdata, tsf);
67524487981SJohannes Berg 	if (local->ops->set_tsf)
67637a41b4aSEliad Peller 		local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
6774efc76bdSJohannes Berg 	trace_drv_return_void(local);
67824487981SJohannes Berg }
67924487981SJohannes Berg 
68037a41b4aSEliad Peller static inline void drv_reset_tsf(struct ieee80211_local *local,
68137a41b4aSEliad Peller 				 struct ieee80211_sub_if_data *sdata)
68224487981SJohannes Berg {
683e1781ed3SKalle Valo 	might_sleep();
684e1781ed3SKalle Valo 
685f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
686f6837ba8SJohannes Berg 		return;
6877b7eab6fSJohannes Berg 
68837a41b4aSEliad Peller 	trace_drv_reset_tsf(local, sdata);
68924487981SJohannes Berg 	if (local->ops->reset_tsf)
69037a41b4aSEliad Peller 		local->ops->reset_tsf(&local->hw, &sdata->vif);
6914efc76bdSJohannes Berg 	trace_drv_return_void(local);
69224487981SJohannes Berg }
69324487981SJohannes Berg 
69424487981SJohannes Berg static inline int drv_tx_last_beacon(struct ieee80211_local *local)
69524487981SJohannes Berg {
69602582e9bSMasanari Iida 	int ret = 0; /* default unsupported op for less congestion */
697e1781ed3SKalle Valo 
698e1781ed3SKalle Valo 	might_sleep();
699e1781ed3SKalle Valo 
7004efc76bdSJohannes Berg 	trace_drv_tx_last_beacon(local);
70124487981SJohannes Berg 	if (local->ops->tx_last_beacon)
7020a2b8bb2SJohannes Berg 		ret = local->ops->tx_last_beacon(&local->hw);
7034efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
7040a2b8bb2SJohannes Berg 	return ret;
70524487981SJohannes Berg }
70624487981SJohannes Berg 
70724487981SJohannes Berg static inline int drv_ampdu_action(struct ieee80211_local *local,
70812375ef9SJohannes Berg 				   struct ieee80211_sub_if_data *sdata,
70924487981SJohannes Berg 				   enum ieee80211_ampdu_mlme_action action,
71024487981SJohannes Berg 				   struct ieee80211_sta *sta, u16 tid,
7110b01f030SJohannes Berg 				   u16 *ssn, u8 buf_size)
71224487981SJohannes Berg {
7130a2b8bb2SJohannes Berg 	int ret = -EOPNOTSUPP;
714cfcdbde3SJohannes Berg 
715cfcdbde3SJohannes Berg 	might_sleep();
716cfcdbde3SJohannes Berg 
717bc192f89SFelix Fietkau 	sdata = get_bss_sdata(sdata);
718f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
719f6837ba8SJohannes Berg 		return -EIO;
7207b7eab6fSJohannes Berg 
7210b01f030SJohannes Berg 	trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
7224efc76bdSJohannes Berg 
72324487981SJohannes Berg 	if (local->ops->ampdu_action)
72412375ef9SJohannes Berg 		ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
7250b01f030SJohannes Berg 					       sta, tid, ssn, buf_size);
72685ad181eSJohannes Berg 
7274efc76bdSJohannes Berg 	trace_drv_return_int(local, ret);
7284efc76bdSJohannes Berg 
7290a2b8bb2SJohannes Berg 	return ret;
73024487981SJohannes Berg }
7311f87f7d3SJohannes Berg 
7321289723eSHolger Schurig static inline int drv_get_survey(struct ieee80211_local *local, int idx,
7331289723eSHolger Schurig 				struct survey_info *survey)
7341289723eSHolger Schurig {
7351289723eSHolger Schurig 	int ret = -EOPNOTSUPP;
736c466d4efSJohn W. Linville 
737c466d4efSJohn W. Linville 	trace_drv_get_survey(local, idx, survey);
738c466d4efSJohn W. Linville 
73935dd0509SHolger Schurig 	if (local->ops->get_survey)
7401289723eSHolger Schurig 		ret = local->ops->get_survey(&local->hw, idx, survey);
741c466d4efSJohn W. Linville 
742c466d4efSJohn W. Linville 	trace_drv_return_int(local, ret);
743c466d4efSJohn W. Linville 
7441289723eSHolger Schurig 	return ret;
7451289723eSHolger Schurig }
7461f87f7d3SJohannes Berg 
7471f87f7d3SJohannes Berg static inline void drv_rfkill_poll(struct ieee80211_local *local)
7481f87f7d3SJohannes Berg {
749e1781ed3SKalle Valo 	might_sleep();
750e1781ed3SKalle Valo 
7511f87f7d3SJohannes Berg 	if (local->ops->rfkill_poll)
7521f87f7d3SJohannes Berg 		local->ops->rfkill_poll(&local->hw);
7531f87f7d3SJohannes Berg }
754a80f7c0bSJohannes Berg 
75539ecc01dSJohannes Berg static inline void drv_flush(struct ieee80211_local *local,
75677be2c54SEmmanuel Grumbach 			     struct ieee80211_sub_if_data *sdata,
75739ecc01dSJohannes Berg 			     u32 queues, bool drop)
758a80f7c0bSJohannes Berg {
75977be2c54SEmmanuel Grumbach 	struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
76077be2c54SEmmanuel Grumbach 
761e1781ed3SKalle Valo 	might_sleep();
762e1781ed3SKalle Valo 
763f6837ba8SJohannes Berg 	if (sdata && !check_sdata_in_driver(sdata))
764f6837ba8SJohannes Berg 		return;
76577be2c54SEmmanuel Grumbach 
76639ecc01dSJohannes Berg 	trace_drv_flush(local, queues, drop);
767a80f7c0bSJohannes Berg 	if (local->ops->flush)
76877be2c54SEmmanuel Grumbach 		local->ops->flush(&local->hw, vif, queues, drop);
7694efc76bdSJohannes Berg 	trace_drv_return_void(local);
770a80f7c0bSJohannes Berg }
7715ce6e438SJohannes Berg 
7725ce6e438SJohannes Berg static inline void drv_channel_switch(struct ieee80211_local *local,
7730f791eb4SLuciano Coelho 				      struct ieee80211_sub_if_data *sdata,
7745ce6e438SJohannes Berg 				      struct ieee80211_channel_switch *ch_switch)
7755ce6e438SJohannes Berg {
7765ce6e438SJohannes Berg 	might_sleep();
7775ce6e438SJohannes Berg 
7780f791eb4SLuciano Coelho 	trace_drv_channel_switch(local, sdata, ch_switch);
7790f791eb4SLuciano Coelho 	local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
7804efc76bdSJohannes Berg 	trace_drv_return_void(local);
7815ce6e438SJohannes Berg }
7825ce6e438SJohannes Berg 
78315d96753SBruno Randolf 
78415d96753SBruno Randolf static inline int drv_set_antenna(struct ieee80211_local *local,
78515d96753SBruno Randolf 				  u32 tx_ant, u32 rx_ant)
78615d96753SBruno Randolf {
78715d96753SBruno Randolf 	int ret = -EOPNOTSUPP;
78815d96753SBruno Randolf 	might_sleep();
78915d96753SBruno Randolf 	if (local->ops->set_antenna)
79015d96753SBruno Randolf 		ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
79115d96753SBruno Randolf 	trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
79215d96753SBruno Randolf 	return ret;
79315d96753SBruno Randolf }
79415d96753SBruno Randolf 
79515d96753SBruno Randolf static inline int drv_get_antenna(struct ieee80211_local *local,
79615d96753SBruno Randolf 				  u32 *tx_ant, u32 *rx_ant)
79715d96753SBruno Randolf {
79815d96753SBruno Randolf 	int ret = -EOPNOTSUPP;
79915d96753SBruno Randolf 	might_sleep();
80015d96753SBruno Randolf 	if (local->ops->get_antenna)
80115d96753SBruno Randolf 		ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
80215d96753SBruno Randolf 	trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
80315d96753SBruno Randolf 	return ret;
80415d96753SBruno Randolf }
80515d96753SBruno Randolf 
80621f83589SJohannes Berg static inline int drv_remain_on_channel(struct ieee80211_local *local,
80749884568SEliad Peller 					struct ieee80211_sub_if_data *sdata,
80821f83589SJohannes Berg 					struct ieee80211_channel *chan,
809d339d5caSIlan Peer 					unsigned int duration,
810d339d5caSIlan Peer 					enum ieee80211_roc_type type)
81121f83589SJohannes Berg {
81221f83589SJohannes Berg 	int ret;
81321f83589SJohannes Berg 
81421f83589SJohannes Berg 	might_sleep();
81521f83589SJohannes Berg 
816d339d5caSIlan Peer 	trace_drv_remain_on_channel(local, sdata, chan, duration, type);
81749884568SEliad Peller 	ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
818d339d5caSIlan Peer 					    chan, duration, type);
81921f83589SJohannes Berg 	trace_drv_return_int(local, ret);
82021f83589SJohannes Berg 
82121f83589SJohannes Berg 	return ret;
82221f83589SJohannes Berg }
82321f83589SJohannes Berg 
82421f83589SJohannes Berg static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
82521f83589SJohannes Berg {
82621f83589SJohannes Berg 	int ret;
82721f83589SJohannes Berg 
82821f83589SJohannes Berg 	might_sleep();
82921f83589SJohannes Berg 
83021f83589SJohannes Berg 	trace_drv_cancel_remain_on_channel(local);
83121f83589SJohannes Berg 	ret = local->ops->cancel_remain_on_channel(&local->hw);
83221f83589SJohannes Berg 	trace_drv_return_int(local, ret);
83321f83589SJohannes Berg 
83421f83589SJohannes Berg 	return ret;
83521f83589SJohannes Berg }
83621f83589SJohannes Berg 
83738c09159SJohn W. Linville static inline int drv_set_ringparam(struct ieee80211_local *local,
83838c09159SJohn W. Linville 				    u32 tx, u32 rx)
83938c09159SJohn W. Linville {
84038c09159SJohn W. Linville 	int ret = -ENOTSUPP;
84138c09159SJohn W. Linville 
84238c09159SJohn W. Linville 	might_sleep();
84338c09159SJohn W. Linville 
84438c09159SJohn W. Linville 	trace_drv_set_ringparam(local, tx, rx);
84538c09159SJohn W. Linville 	if (local->ops->set_ringparam)
84638c09159SJohn W. Linville 		ret = local->ops->set_ringparam(&local->hw, tx, rx);
84738c09159SJohn W. Linville 	trace_drv_return_int(local, ret);
84838c09159SJohn W. Linville 
84938c09159SJohn W. Linville 	return ret;
85038c09159SJohn W. Linville }
85138c09159SJohn W. Linville 
85238c09159SJohn W. Linville static inline void drv_get_ringparam(struct ieee80211_local *local,
85338c09159SJohn W. Linville 				     u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
85438c09159SJohn W. Linville {
85538c09159SJohn W. Linville 	might_sleep();
85638c09159SJohn W. Linville 
85738c09159SJohn W. Linville 	trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
85838c09159SJohn W. Linville 	if (local->ops->get_ringparam)
85938c09159SJohn W. Linville 		local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
86038c09159SJohn W. Linville 	trace_drv_return_void(local);
86138c09159SJohn W. Linville }
86238c09159SJohn W. Linville 
863e8306f98SVivek Natarajan static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
864e8306f98SVivek Natarajan {
865e8306f98SVivek Natarajan 	bool ret = false;
866e8306f98SVivek Natarajan 
867e8306f98SVivek Natarajan 	might_sleep();
868e8306f98SVivek Natarajan 
869e8306f98SVivek Natarajan 	trace_drv_tx_frames_pending(local);
870e8306f98SVivek Natarajan 	if (local->ops->tx_frames_pending)
871e8306f98SVivek Natarajan 		ret = local->ops->tx_frames_pending(&local->hw);
872e8306f98SVivek Natarajan 	trace_drv_return_bool(local, ret);
873e8306f98SVivek Natarajan 
874e8306f98SVivek Natarajan 	return ret;
875e8306f98SVivek Natarajan }
876bdbfd6b5SSujith Manoharan 
877bdbfd6b5SSujith Manoharan static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
878bdbfd6b5SSujith Manoharan 				       struct ieee80211_sub_if_data *sdata,
879bdbfd6b5SSujith Manoharan 				       const struct cfg80211_bitrate_mask *mask)
880bdbfd6b5SSujith Manoharan {
881bdbfd6b5SSujith Manoharan 	int ret = -EOPNOTSUPP;
882bdbfd6b5SSujith Manoharan 
883bdbfd6b5SSujith Manoharan 	might_sleep();
884bdbfd6b5SSujith Manoharan 
885f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
886f6837ba8SJohannes Berg 		return -EIO;
8877b7eab6fSJohannes Berg 
888bdbfd6b5SSujith Manoharan 	trace_drv_set_bitrate_mask(local, sdata, mask);
889bdbfd6b5SSujith Manoharan 	if (local->ops->set_bitrate_mask)
890bdbfd6b5SSujith Manoharan 		ret = local->ops->set_bitrate_mask(&local->hw,
891bdbfd6b5SSujith Manoharan 						   &sdata->vif, mask);
892bdbfd6b5SSujith Manoharan 	trace_drv_return_int(local, ret);
893bdbfd6b5SSujith Manoharan 
894bdbfd6b5SSujith Manoharan 	return ret;
895bdbfd6b5SSujith Manoharan }
896bdbfd6b5SSujith Manoharan 
897c68f4b89SJohannes Berg static inline void drv_set_rekey_data(struct ieee80211_local *local,
898c68f4b89SJohannes Berg 				      struct ieee80211_sub_if_data *sdata,
899c68f4b89SJohannes Berg 				      struct cfg80211_gtk_rekey_data *data)
900c68f4b89SJohannes Berg {
901f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
902f6837ba8SJohannes Berg 		return;
9037b7eab6fSJohannes Berg 
904c68f4b89SJohannes Berg 	trace_drv_set_rekey_data(local, sdata, data);
905c68f4b89SJohannes Berg 	if (local->ops->set_rekey_data)
906c68f4b89SJohannes Berg 		local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
907c68f4b89SJohannes Berg 	trace_drv_return_void(local);
908c68f4b89SJohannes Berg }
909c68f4b89SJohannes Berg 
910615f7b9bSMeenakshi Venkataraman static inline void drv_rssi_callback(struct ieee80211_local *local,
911887da917SEmmanuel Grumbach 				     struct ieee80211_sub_if_data *sdata,
912615f7b9bSMeenakshi Venkataraman 				     const enum ieee80211_rssi_event event)
913615f7b9bSMeenakshi Venkataraman {
914887da917SEmmanuel Grumbach 	trace_drv_rssi_callback(local, sdata, event);
915615f7b9bSMeenakshi Venkataraman 	if (local->ops->rssi_callback)
916887da917SEmmanuel Grumbach 		local->ops->rssi_callback(&local->hw, &sdata->vif, event);
917615f7b9bSMeenakshi Venkataraman 	trace_drv_return_void(local);
918615f7b9bSMeenakshi Venkataraman }
9194049e09aSJohannes Berg 
9204049e09aSJohannes Berg static inline void
9214049e09aSJohannes Berg drv_release_buffered_frames(struct ieee80211_local *local,
9224049e09aSJohannes Berg 			    struct sta_info *sta, u16 tids, int num_frames,
9234049e09aSJohannes Berg 			    enum ieee80211_frame_release_type reason,
9244049e09aSJohannes Berg 			    bool more_data)
9254049e09aSJohannes Berg {
9264049e09aSJohannes Berg 	trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
9274049e09aSJohannes Berg 					  reason, more_data);
9284049e09aSJohannes Berg 	if (local->ops->release_buffered_frames)
9294049e09aSJohannes Berg 		local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
9304049e09aSJohannes Berg 						    num_frames, reason,
9314049e09aSJohannes Berg 						    more_data);
9324049e09aSJohannes Berg 	trace_drv_return_void(local);
9334049e09aSJohannes Berg }
93440b96408SJohannes Berg 
93540b96408SJohannes Berg static inline void
93640b96408SJohannes Berg drv_allow_buffered_frames(struct ieee80211_local *local,
93740b96408SJohannes Berg 			  struct sta_info *sta, u16 tids, int num_frames,
93840b96408SJohannes Berg 			  enum ieee80211_frame_release_type reason,
93940b96408SJohannes Berg 			  bool more_data)
94040b96408SJohannes Berg {
94140b96408SJohannes Berg 	trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
94240b96408SJohannes Berg 					reason, more_data);
94340b96408SJohannes Berg 	if (local->ops->allow_buffered_frames)
94440b96408SJohannes Berg 		local->ops->allow_buffered_frames(&local->hw, &sta->sta,
94540b96408SJohannes Berg 						  tids, num_frames, reason,
94640b96408SJohannes Berg 						  more_data);
94740b96408SJohannes Berg 	trace_drv_return_void(local);
94840b96408SJohannes Berg }
94966572cfcSVictor Goldenshtein 
95066572cfcSVictor Goldenshtein static inline int drv_get_rssi(struct ieee80211_local *local,
95166572cfcSVictor Goldenshtein 				struct ieee80211_sub_if_data *sdata,
95266572cfcSVictor Goldenshtein 				struct ieee80211_sta *sta,
95366572cfcSVictor Goldenshtein 				s8 *rssi_dbm)
95466572cfcSVictor Goldenshtein {
95566572cfcSVictor Goldenshtein 	int ret;
95666572cfcSVictor Goldenshtein 
95766572cfcSVictor Goldenshtein 	might_sleep();
95866572cfcSVictor Goldenshtein 
95966572cfcSVictor Goldenshtein 	ret = local->ops->get_rssi(&local->hw, &sdata->vif, sta, rssi_dbm);
96066572cfcSVictor Goldenshtein 	trace_drv_get_rssi(local, sta, *rssi_dbm, ret);
96166572cfcSVictor Goldenshtein 
96266572cfcSVictor Goldenshtein 	return ret;
96366572cfcSVictor Goldenshtein }
964a1845fc7SJohannes Berg 
965a1845fc7SJohannes Berg static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
966a1845fc7SJohannes Berg 				      struct ieee80211_sub_if_data *sdata)
967a1845fc7SJohannes Berg {
968a1845fc7SJohannes Berg 	might_sleep();
969a1845fc7SJohannes Berg 
970f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
971f6837ba8SJohannes Berg 		return;
972a1845fc7SJohannes Berg 	WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
973a1845fc7SJohannes Berg 
974a1845fc7SJohannes Berg 	trace_drv_mgd_prepare_tx(local, sdata);
975a1845fc7SJohannes Berg 	if (local->ops->mgd_prepare_tx)
976a1845fc7SJohannes Berg 		local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
977a1845fc7SJohannes Berg 	trace_drv_return_void(local);
978a1845fc7SJohannes Berg }
979c3645eacSMichal Kazior 
980ee10f2c7SArik Nemtsov static inline void
981ee10f2c7SArik Nemtsov drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
982ee10f2c7SArik Nemtsov 			      struct ieee80211_sub_if_data *sdata)
983ee10f2c7SArik Nemtsov {
984ee10f2c7SArik Nemtsov 	might_sleep();
985ee10f2c7SArik Nemtsov 
986ee10f2c7SArik Nemtsov 	if (!check_sdata_in_driver(sdata))
987ee10f2c7SArik Nemtsov 		return;
988ee10f2c7SArik Nemtsov 	WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
989ee10f2c7SArik Nemtsov 
990ee10f2c7SArik Nemtsov 	trace_drv_mgd_protect_tdls_discover(local, sdata);
991ee10f2c7SArik Nemtsov 	if (local->ops->mgd_protect_tdls_discover)
992ee10f2c7SArik Nemtsov 		local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
993ee10f2c7SArik Nemtsov 	trace_drv_return_void(local);
994ee10f2c7SArik Nemtsov }
995ee10f2c7SArik Nemtsov 
996c3645eacSMichal Kazior static inline int drv_add_chanctx(struct ieee80211_local *local,
997c3645eacSMichal Kazior 				  struct ieee80211_chanctx *ctx)
998c3645eacSMichal Kazior {
999c3645eacSMichal Kazior 	int ret = -EOPNOTSUPP;
1000c3645eacSMichal Kazior 
1001c3645eacSMichal Kazior 	trace_drv_add_chanctx(local, ctx);
1002c3645eacSMichal Kazior 	if (local->ops->add_chanctx)
1003c3645eacSMichal Kazior 		ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
1004c3645eacSMichal Kazior 	trace_drv_return_int(local, ret);
10058a61af65SJohannes Berg 	if (!ret)
10068a61af65SJohannes Berg 		ctx->driver_present = true;
1007c3645eacSMichal Kazior 
1008c3645eacSMichal Kazior 	return ret;
1009c3645eacSMichal Kazior }
1010c3645eacSMichal Kazior 
1011c3645eacSMichal Kazior static inline void drv_remove_chanctx(struct ieee80211_local *local,
1012c3645eacSMichal Kazior 				      struct ieee80211_chanctx *ctx)
1013c3645eacSMichal Kazior {
1014f6837ba8SJohannes Berg 	if (WARN_ON(!ctx->driver_present))
1015f6837ba8SJohannes Berg 		return;
1016f6837ba8SJohannes Berg 
1017c3645eacSMichal Kazior 	trace_drv_remove_chanctx(local, ctx);
1018c3645eacSMichal Kazior 	if (local->ops->remove_chanctx)
1019c3645eacSMichal Kazior 		local->ops->remove_chanctx(&local->hw, &ctx->conf);
1020c3645eacSMichal Kazior 	trace_drv_return_void(local);
10218a61af65SJohannes Berg 	ctx->driver_present = false;
1022c3645eacSMichal Kazior }
1023c3645eacSMichal Kazior 
1024c3645eacSMichal Kazior static inline void drv_change_chanctx(struct ieee80211_local *local,
1025c3645eacSMichal Kazior 				      struct ieee80211_chanctx *ctx,
1026c3645eacSMichal Kazior 				      u32 changed)
1027c3645eacSMichal Kazior {
1028c3645eacSMichal Kazior 	trace_drv_change_chanctx(local, ctx, changed);
10298a61af65SJohannes Berg 	if (local->ops->change_chanctx) {
10308a61af65SJohannes Berg 		WARN_ON_ONCE(!ctx->driver_present);
1031c3645eacSMichal Kazior 		local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
10328a61af65SJohannes Berg 	}
1033c3645eacSMichal Kazior 	trace_drv_return_void(local);
1034c3645eacSMichal Kazior }
1035c3645eacSMichal Kazior 
1036c3645eacSMichal Kazior static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
1037c3645eacSMichal Kazior 					 struct ieee80211_sub_if_data *sdata,
1038c3645eacSMichal Kazior 					 struct ieee80211_chanctx *ctx)
1039c3645eacSMichal Kazior {
1040c3645eacSMichal Kazior 	int ret = 0;
1041c3645eacSMichal Kazior 
1042f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1043f6837ba8SJohannes Berg 		return -EIO;
1044c3645eacSMichal Kazior 
1045c3645eacSMichal Kazior 	trace_drv_assign_vif_chanctx(local, sdata, ctx);
10468a61af65SJohannes Berg 	if (local->ops->assign_vif_chanctx) {
10478a61af65SJohannes Berg 		WARN_ON_ONCE(!ctx->driver_present);
1048c3645eacSMichal Kazior 		ret = local->ops->assign_vif_chanctx(&local->hw,
1049c3645eacSMichal Kazior 						     &sdata->vif,
1050c3645eacSMichal Kazior 						     &ctx->conf);
10518a61af65SJohannes Berg 	}
1052c3645eacSMichal Kazior 	trace_drv_return_int(local, ret);
1053c3645eacSMichal Kazior 
1054c3645eacSMichal Kazior 	return ret;
1055c3645eacSMichal Kazior }
1056c3645eacSMichal Kazior 
1057c3645eacSMichal Kazior static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
1058c3645eacSMichal Kazior 					    struct ieee80211_sub_if_data *sdata,
1059c3645eacSMichal Kazior 					    struct ieee80211_chanctx *ctx)
1060c3645eacSMichal Kazior {
1061f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1062f6837ba8SJohannes Berg 		return;
1063c3645eacSMichal Kazior 
1064c3645eacSMichal Kazior 	trace_drv_unassign_vif_chanctx(local, sdata, ctx);
10658a61af65SJohannes Berg 	if (local->ops->unassign_vif_chanctx) {
10668a61af65SJohannes Berg 		WARN_ON_ONCE(!ctx->driver_present);
1067c3645eacSMichal Kazior 		local->ops->unassign_vif_chanctx(&local->hw,
1068c3645eacSMichal Kazior 						 &sdata->vif,
1069c3645eacSMichal Kazior 						 &ctx->conf);
10708a61af65SJohannes Berg 	}
1071c3645eacSMichal Kazior 	trace_drv_return_void(local);
1072c3645eacSMichal Kazior }
1073c3645eacSMichal Kazior 
10741a5f0c13SLuciano Coelho static inline int
10751a5f0c13SLuciano Coelho drv_switch_vif_chanctx(struct ieee80211_local *local,
10761a5f0c13SLuciano Coelho 		       struct ieee80211_vif_chanctx_switch *vifs,
10771a5f0c13SLuciano Coelho 		       int n_vifs,
10781a5f0c13SLuciano Coelho 		       enum ieee80211_chanctx_switch_mode mode)
10791a5f0c13SLuciano Coelho {
10801a5f0c13SLuciano Coelho 	int ret = 0;
10811a5f0c13SLuciano Coelho 	int i;
10821a5f0c13SLuciano Coelho 
10831a5f0c13SLuciano Coelho 	if (!local->ops->switch_vif_chanctx)
10841a5f0c13SLuciano Coelho 		return -EOPNOTSUPP;
10851a5f0c13SLuciano Coelho 
10861a5f0c13SLuciano Coelho 	for (i = 0; i < n_vifs; i++) {
10871a5f0c13SLuciano Coelho 		struct ieee80211_chanctx *new_ctx =
10881a5f0c13SLuciano Coelho 			container_of(vifs[i].new_ctx,
10891a5f0c13SLuciano Coelho 				     struct ieee80211_chanctx,
10901a5f0c13SLuciano Coelho 				     conf);
10911a5f0c13SLuciano Coelho 		struct ieee80211_chanctx *old_ctx =
10921a5f0c13SLuciano Coelho 			container_of(vifs[i].old_ctx,
10931a5f0c13SLuciano Coelho 				     struct ieee80211_chanctx,
10941a5f0c13SLuciano Coelho 				     conf);
10951a5f0c13SLuciano Coelho 
10961a5f0c13SLuciano Coelho 		WARN_ON_ONCE(!old_ctx->driver_present);
10971a5f0c13SLuciano Coelho 		WARN_ON_ONCE((mode == CHANCTX_SWMODE_SWAP_CONTEXTS &&
10981a5f0c13SLuciano Coelho 			      new_ctx->driver_present) ||
10991a5f0c13SLuciano Coelho 			     (mode == CHANCTX_SWMODE_REASSIGN_VIF &&
11001a5f0c13SLuciano Coelho 			      !new_ctx->driver_present));
11011a5f0c13SLuciano Coelho 	}
11021a5f0c13SLuciano Coelho 
11031a5f0c13SLuciano Coelho 	trace_drv_switch_vif_chanctx(local, vifs, n_vifs, mode);
11041a5f0c13SLuciano Coelho 	ret = local->ops->switch_vif_chanctx(&local->hw,
11051a5f0c13SLuciano Coelho 					     vifs, n_vifs, mode);
11061a5f0c13SLuciano Coelho 	trace_drv_return_int(local, ret);
11071a5f0c13SLuciano Coelho 
11081a5f0c13SLuciano Coelho 	if (!ret && mode == CHANCTX_SWMODE_SWAP_CONTEXTS) {
11091a5f0c13SLuciano Coelho 		for (i = 0; i < n_vifs; i++) {
11101a5f0c13SLuciano Coelho 			struct ieee80211_chanctx *new_ctx =
11111a5f0c13SLuciano Coelho 				container_of(vifs[i].new_ctx,
11121a5f0c13SLuciano Coelho 					     struct ieee80211_chanctx,
11131a5f0c13SLuciano Coelho 					     conf);
11141a5f0c13SLuciano Coelho 			struct ieee80211_chanctx *old_ctx =
11151a5f0c13SLuciano Coelho 				container_of(vifs[i].old_ctx,
11161a5f0c13SLuciano Coelho 					     struct ieee80211_chanctx,
11171a5f0c13SLuciano Coelho 					     conf);
11181a5f0c13SLuciano Coelho 
11191a5f0c13SLuciano Coelho 			new_ctx->driver_present = true;
11201a5f0c13SLuciano Coelho 			old_ctx->driver_present = false;
11211a5f0c13SLuciano Coelho 		}
11221a5f0c13SLuciano Coelho 	}
11231a5f0c13SLuciano Coelho 
11241a5f0c13SLuciano Coelho 	return ret;
11251a5f0c13SLuciano Coelho }
11261a5f0c13SLuciano Coelho 
11271041638fSJohannes Berg static inline int drv_start_ap(struct ieee80211_local *local,
11281041638fSJohannes Berg 			       struct ieee80211_sub_if_data *sdata)
11291041638fSJohannes Berg {
11301041638fSJohannes Berg 	int ret = 0;
11311041638fSJohannes Berg 
1132f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1133f6837ba8SJohannes Berg 		return -EIO;
11341041638fSJohannes Berg 
11351041638fSJohannes Berg 	trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
11361041638fSJohannes Berg 	if (local->ops->start_ap)
11371041638fSJohannes Berg 		ret = local->ops->start_ap(&local->hw, &sdata->vif);
11381041638fSJohannes Berg 	trace_drv_return_int(local, ret);
11391041638fSJohannes Berg 	return ret;
11401041638fSJohannes Berg }
11411041638fSJohannes Berg 
11421041638fSJohannes Berg static inline void drv_stop_ap(struct ieee80211_local *local,
11431041638fSJohannes Berg 			       struct ieee80211_sub_if_data *sdata)
11441041638fSJohannes Berg {
1145f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1146f6837ba8SJohannes Berg 		return;
11471041638fSJohannes Berg 
11481041638fSJohannes Berg 	trace_drv_stop_ap(local, sdata);
11491041638fSJohannes Berg 	if (local->ops->stop_ap)
11501041638fSJohannes Berg 		local->ops->stop_ap(&local->hw, &sdata->vif);
11511041638fSJohannes Berg 	trace_drv_return_void(local);
11521041638fSJohannes Berg }
11531041638fSJohannes Berg 
11549214ad7fSJohannes Berg static inline void drv_restart_complete(struct ieee80211_local *local)
11559214ad7fSJohannes Berg {
11569214ad7fSJohannes Berg 	might_sleep();
11579214ad7fSJohannes Berg 
11589214ad7fSJohannes Berg 	trace_drv_restart_complete(local);
11599214ad7fSJohannes Berg 	if (local->ops->restart_complete)
11609214ad7fSJohannes Berg 		local->ops->restart_complete(&local->hw);
11619214ad7fSJohannes Berg 	trace_drv_return_void(local);
11629214ad7fSJohannes Berg }
11639214ad7fSJohannes Berg 
1164de5fad81SYoni Divinsky static inline void
1165de5fad81SYoni Divinsky drv_set_default_unicast_key(struct ieee80211_local *local,
1166de5fad81SYoni Divinsky 			    struct ieee80211_sub_if_data *sdata,
1167de5fad81SYoni Divinsky 			    int key_idx)
1168de5fad81SYoni Divinsky {
1169f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1170f6837ba8SJohannes Berg 		return;
1171de5fad81SYoni Divinsky 
1172de5fad81SYoni Divinsky 	WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1173de5fad81SYoni Divinsky 
1174de5fad81SYoni Divinsky 	trace_drv_set_default_unicast_key(local, sdata, key_idx);
1175de5fad81SYoni Divinsky 	if (local->ops->set_default_unicast_key)
1176de5fad81SYoni Divinsky 		local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1177de5fad81SYoni Divinsky 						    key_idx);
1178de5fad81SYoni Divinsky 	trace_drv_return_void(local);
1179de5fad81SYoni Divinsky }
1180de5fad81SYoni Divinsky 
1181a65240c1SJohannes Berg #if IS_ENABLED(CONFIG_IPV6)
1182a65240c1SJohannes Berg static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1183a65240c1SJohannes Berg 					struct ieee80211_sub_if_data *sdata,
1184a65240c1SJohannes Berg 					struct inet6_dev *idev)
1185a65240c1SJohannes Berg {
1186a65240c1SJohannes Berg 	trace_drv_ipv6_addr_change(local, sdata);
1187a65240c1SJohannes Berg 	if (local->ops->ipv6_addr_change)
1188a65240c1SJohannes Berg 		local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1189a65240c1SJohannes Berg 	trace_drv_return_void(local);
1190a65240c1SJohannes Berg }
1191a65240c1SJohannes Berg #endif
1192a65240c1SJohannes Berg 
119373da7d5bSSimon Wunderlich static inline void
119473da7d5bSSimon Wunderlich drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
119573da7d5bSSimon Wunderlich 			  struct cfg80211_chan_def *chandef)
119673da7d5bSSimon Wunderlich {
119773da7d5bSSimon Wunderlich 	struct ieee80211_local *local = sdata->local;
119873da7d5bSSimon Wunderlich 
119973da7d5bSSimon Wunderlich 	if (local->ops->channel_switch_beacon) {
120073da7d5bSSimon Wunderlich 		trace_drv_channel_switch_beacon(local, sdata, chandef);
120173da7d5bSSimon Wunderlich 		local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
120273da7d5bSSimon Wunderlich 						  chandef);
120373da7d5bSSimon Wunderlich 	}
120473da7d5bSSimon Wunderlich }
120573da7d5bSSimon Wunderlich 
12066d027bccSLuciano Coelho static inline int
12076d027bccSLuciano Coelho drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
12086d027bccSLuciano Coelho 		       struct ieee80211_channel_switch *ch_switch)
12096d027bccSLuciano Coelho {
12106d027bccSLuciano Coelho 	struct ieee80211_local *local = sdata->local;
12116d027bccSLuciano Coelho 	int ret = 0;
12126d027bccSLuciano Coelho 
12136d027bccSLuciano Coelho 	if (!check_sdata_in_driver(sdata))
12146d027bccSLuciano Coelho 		return -EIO;
12156d027bccSLuciano Coelho 
12166d027bccSLuciano Coelho 	trace_drv_pre_channel_switch(local, sdata, ch_switch);
12176d027bccSLuciano Coelho 	if (local->ops->pre_channel_switch)
12186d027bccSLuciano Coelho 		ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
12196d027bccSLuciano Coelho 						     ch_switch);
12206d027bccSLuciano Coelho 	trace_drv_return_int(local, ret);
12216d027bccSLuciano Coelho 	return ret;
12226d027bccSLuciano Coelho }
12236d027bccSLuciano Coelho 
1224f1d65583SLuciano Coelho static inline int
1225f1d65583SLuciano Coelho drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1226f1d65583SLuciano Coelho {
1227f1d65583SLuciano Coelho 	struct ieee80211_local *local = sdata->local;
1228f1d65583SLuciano Coelho 	int ret = 0;
1229f1d65583SLuciano Coelho 
1230f1d65583SLuciano Coelho 	if (!check_sdata_in_driver(sdata))
1231f1d65583SLuciano Coelho 		return -EIO;
1232f1d65583SLuciano Coelho 
1233f1d65583SLuciano Coelho 	trace_drv_post_channel_switch(local, sdata);
1234f1d65583SLuciano Coelho 	if (local->ops->post_channel_switch)
1235f1d65583SLuciano Coelho 		ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1236f1d65583SLuciano Coelho 	trace_drv_return_int(local, ret);
1237f1d65583SLuciano Coelho 	return ret;
1238f1d65583SLuciano Coelho }
1239f1d65583SLuciano Coelho 
124055fff501SJohannes Berg static inline int drv_join_ibss(struct ieee80211_local *local,
124155fff501SJohannes Berg 				struct ieee80211_sub_if_data *sdata)
124255fff501SJohannes Berg {
124355fff501SJohannes Berg 	int ret = 0;
124455fff501SJohannes Berg 
124555fff501SJohannes Berg 	might_sleep();
1246f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1247f6837ba8SJohannes Berg 		return -EIO;
124855fff501SJohannes Berg 
124955fff501SJohannes Berg 	trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
125055fff501SJohannes Berg 	if (local->ops->join_ibss)
125155fff501SJohannes Berg 		ret = local->ops->join_ibss(&local->hw, &sdata->vif);
125255fff501SJohannes Berg 	trace_drv_return_int(local, ret);
125355fff501SJohannes Berg 	return ret;
125455fff501SJohannes Berg }
125555fff501SJohannes Berg 
125655fff501SJohannes Berg static inline void drv_leave_ibss(struct ieee80211_local *local,
125755fff501SJohannes Berg 				  struct ieee80211_sub_if_data *sdata)
125855fff501SJohannes Berg {
125955fff501SJohannes Berg 	might_sleep();
1260f6837ba8SJohannes Berg 	if (!check_sdata_in_driver(sdata))
1261f6837ba8SJohannes Berg 		return;
126255fff501SJohannes Berg 
126355fff501SJohannes Berg 	trace_drv_leave_ibss(local, sdata);
126455fff501SJohannes Berg 	if (local->ops->leave_ibss)
126555fff501SJohannes Berg 		local->ops->leave_ibss(&local->hw, &sdata->vif);
126655fff501SJohannes Berg 	trace_drv_return_void(local);
126755fff501SJohannes Berg }
126855fff501SJohannes Berg 
1269cca674d4SAntonio Quartulli static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
1270cca674d4SAntonio Quartulli 					      struct ieee80211_sta *sta)
1271cca674d4SAntonio Quartulli {
1272cca674d4SAntonio Quartulli 	u32 ret = 0;
1273cca674d4SAntonio Quartulli 
1274cca674d4SAntonio Quartulli 	trace_drv_get_expected_throughput(sta);
1275cca674d4SAntonio Quartulli 	if (local->ops->get_expected_throughput)
1276cca674d4SAntonio Quartulli 		ret = local->ops->get_expected_throughput(sta);
1277cca674d4SAntonio Quartulli 	trace_drv_return_u32(local, ret);
1278cca674d4SAntonio Quartulli 
1279cca674d4SAntonio Quartulli 	return ret;
1280cca674d4SAntonio Quartulli }
1281cca674d4SAntonio Quartulli 
128224487981SJohannes Berg #endif /* __MAC80211_DRIVER_OPS */
1283