• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Portions of this file
4 * Copyright(c) 2016 Intel Deutschland GmbH
5 * Copyright (C) 2018 - 2019 Intel Corporation
6 */
7 
8 #ifndef __MAC80211_DRIVER_OPS
9 #define __MAC80211_DRIVER_OPS
10 
11 #include <net/mac80211.h>
12 #include "ieee80211_i.h"
13 #include "trace.h"
14 
check_sdata_in_driver(struct ieee80211_sub_if_data * sdata)15 static inline bool check_sdata_in_driver(struct ieee80211_sub_if_data *sdata)
16 {
17 	return !WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER),
18 		     "%s:  Failed check-sdata-in-driver check, flags: 0x%x\n",
19 		     sdata->dev ? sdata->dev->name : sdata->name, sdata->flags);
20 }
21 
22 static inline struct ieee80211_sub_if_data *
get_bss_sdata(struct ieee80211_sub_if_data * sdata)23 get_bss_sdata(struct ieee80211_sub_if_data *sdata)
24 {
25 	if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
26 		sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
27 				     u.ap);
28 
29 	return sdata;
30 }
31 
drv_tx(struct ieee80211_local * local,struct ieee80211_tx_control * control,struct sk_buff * skb)32 static inline void drv_tx(struct ieee80211_local *local,
33 			  struct ieee80211_tx_control *control,
34 			  struct sk_buff *skb)
35 {
36 	local->ops->tx(&local->hw, control, skb);
37 }
38 
drv_sync_rx_queues(struct ieee80211_local * local,struct sta_info * sta)39 static inline void drv_sync_rx_queues(struct ieee80211_local *local,
40 				      struct sta_info *sta)
41 {
42 	if (local->ops->sync_rx_queues) {
43 		trace_drv_sync_rx_queues(local, sta->sdata, &sta->sta);
44 		local->ops->sync_rx_queues(&local->hw);
45 		trace_drv_return_void(local);
46 	}
47 }
48 
drv_get_et_strings(struct ieee80211_sub_if_data * sdata,u32 sset,u8 * data)49 static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata,
50 				      u32 sset, u8 *data)
51 {
52 	struct ieee80211_local *local = sdata->local;
53 	if (local->ops->get_et_strings) {
54 		trace_drv_get_et_strings(local, sset);
55 		local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data);
56 		trace_drv_return_void(local);
57 	}
58 }
59 
drv_get_et_stats(struct ieee80211_sub_if_data * sdata,struct ethtool_stats * stats,u64 * data)60 static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata,
61 				    struct ethtool_stats *stats,
62 				    u64 *data)
63 {
64 	struct ieee80211_local *local = sdata->local;
65 	if (local->ops->get_et_stats) {
66 		trace_drv_get_et_stats(local);
67 		local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data);
68 		trace_drv_return_void(local);
69 	}
70 }
71 
drv_get_et_sset_count(struct ieee80211_sub_if_data * sdata,int sset)72 static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata,
73 					int sset)
74 {
75 	struct ieee80211_local *local = sdata->local;
76 	int rv = 0;
77 	if (local->ops->get_et_sset_count) {
78 		trace_drv_get_et_sset_count(local, sset);
79 		rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif,
80 						   sset);
81 		trace_drv_return_int(local, rv);
82 	}
83 	return rv;
84 }
85 
86 int drv_start(struct ieee80211_local *local);
87 void drv_stop(struct ieee80211_local *local);
88 
89 #ifdef CONFIG_PM
drv_suspend(struct ieee80211_local * local,struct cfg80211_wowlan * wowlan)90 static inline int drv_suspend(struct ieee80211_local *local,
91 			      struct cfg80211_wowlan *wowlan)
92 {
93 	int ret;
94 
95 	might_sleep();
96 
97 	trace_drv_suspend(local);
98 	ret = local->ops->suspend(&local->hw, wowlan);
99 	trace_drv_return_int(local, ret);
100 	return ret;
101 }
102 
drv_resume(struct ieee80211_local * local)103 static inline int drv_resume(struct ieee80211_local *local)
104 {
105 	int ret;
106 
107 	might_sleep();
108 
109 	trace_drv_resume(local);
110 	ret = local->ops->resume(&local->hw);
111 	trace_drv_return_int(local, ret);
112 	return ret;
113 }
114 
drv_set_wakeup(struct ieee80211_local * local,bool enabled)115 static inline void drv_set_wakeup(struct ieee80211_local *local,
116 				  bool enabled)
117 {
118 	might_sleep();
119 
120 	if (!local->ops->set_wakeup)
121 		return;
122 
123 	trace_drv_set_wakeup(local, enabled);
124 	local->ops->set_wakeup(&local->hw, enabled);
125 	trace_drv_return_void(local);
126 }
127 #endif
128 
129 int drv_add_interface(struct ieee80211_local *local,
130 		      struct ieee80211_sub_if_data *sdata);
131 
132 int drv_change_interface(struct ieee80211_local *local,
133 			 struct ieee80211_sub_if_data *sdata,
134 			 enum nl80211_iftype type, bool p2p);
135 
136 void drv_remove_interface(struct ieee80211_local *local,
137 			  struct ieee80211_sub_if_data *sdata);
138 
drv_config(struct ieee80211_local * local,u32 changed)139 static inline int drv_config(struct ieee80211_local *local, u32 changed)
140 {
141 	int ret;
142 
143 	might_sleep();
144 
145 	trace_drv_config(local, changed);
146 	ret = local->ops->config(&local->hw, changed);
147 	trace_drv_return_int(local, ret);
148 	return ret;
149 }
150 
drv_bss_info_changed(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_bss_conf * info,u32 changed)151 static inline void drv_bss_info_changed(struct ieee80211_local *local,
152 					struct ieee80211_sub_if_data *sdata,
153 					struct ieee80211_bss_conf *info,
154 					u32 changed)
155 {
156 	might_sleep();
157 
158 	if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
159 				    BSS_CHANGED_BEACON_ENABLED) &&
160 			 sdata->vif.type != NL80211_IFTYPE_AP &&
161 			 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
162 			 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
163 			 sdata->vif.type != NL80211_IFTYPE_OCB))
164 		return;
165 
166 	if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
167 			 sdata->vif.type == NL80211_IFTYPE_NAN ||
168 			 (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
169 			  !sdata->vif.mu_mimo_owner &&
170 			  !(changed & BSS_CHANGED_TXPOWER))))
171 		return;
172 
173 	if (!check_sdata_in_driver(sdata))
174 		return;
175 
176 	trace_drv_bss_info_changed(local, sdata, info, changed);
177 	if (local->ops->bss_info_changed)
178 		local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
179 	trace_drv_return_void(local);
180 }
181 
drv_prepare_multicast(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct netdev_hw_addr_list * mc_list)182 static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
183 					struct ieee80211_sub_if_data *sdata,
184 					struct netdev_hw_addr_list *mc_list)
185 {
186 	u64 ret = 0;
187 
188 	trace_drv_prepare_multicast(local, mc_list->count);
189 
190 	if (local->ops->prepare_multicast)
191 		ret = local->ops->prepare_multicast(&local->hw, &sdata->vif, mc_list);
192 
193 	trace_drv_return_u64(local, ret);
194 
195 	return ret;
196 }
197 
drv_configure_filter(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,unsigned int changed_flags,unsigned int * total_flags,u64 multicast)198 static inline void drv_configure_filter(struct ieee80211_local *local,
199 					struct ieee80211_sub_if_data *sdata,
200 					unsigned int changed_flags,
201 					unsigned int *total_flags,
202 					u64 multicast)
203 {
204 	might_sleep();
205 
206 	trace_drv_configure_filter(local, changed_flags, total_flags,
207 				   multicast);
208 	local->ops->configure_filter(&local->hw, &sdata->vif, changed_flags,
209 						total_flags, multicast);
210 	trace_drv_return_void(local);
211 }
212 
drv_config_iface_filter(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,unsigned int filter_flags,unsigned int changed_flags)213 static inline void drv_config_iface_filter(struct ieee80211_local *local,
214 					   struct ieee80211_sub_if_data *sdata,
215 					   unsigned int filter_flags,
216 					   unsigned int changed_flags)
217 {
218 	might_sleep();
219 
220 	trace_drv_config_iface_filter(local, sdata, filter_flags,
221 					changed_flags);
222 	if (local->ops->config_iface_filter)
223 		local->ops->config_iface_filter(&local->hw, &sdata->vif,
224 						filter_flags,
225 						changed_flags);
226 	trace_drv_return_void(local);
227 }
228 
drv_set_tim(struct ieee80211_local * local,struct ieee80211_sta * sta,bool set)229 static inline int drv_set_tim(struct ieee80211_local *local,
230 			      struct ieee80211_sta *sta, bool set)
231 {
232 	int ret = 0;
233 	trace_drv_set_tim(local, sta, set);
234 	if (local->ops->set_tim)
235 		ret = local->ops->set_tim(&local->hw, sta, set);
236 	trace_drv_return_int(local, ret);
237 	return ret;
238 }
239 
drv_set_key(struct ieee80211_local * local,enum set_key_cmd cmd,struct ieee80211_sub_if_data * sdata,struct ieee80211_sta * sta,struct ieee80211_key_conf * key)240 static inline int drv_set_key(struct ieee80211_local *local,
241 			      enum set_key_cmd cmd,
242 			      struct ieee80211_sub_if_data *sdata,
243 			      struct ieee80211_sta *sta,
244 			      struct ieee80211_key_conf *key)
245 {
246 	int ret;
247 
248 	might_sleep();
249 
250 	sdata = get_bss_sdata(sdata);
251 	if (!check_sdata_in_driver(sdata))
252 		return -EIO;
253 
254 	trace_drv_set_key(local, cmd, sdata, sta, key);
255 	ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
256 	trace_drv_return_int(local, ret);
257 	return ret;
258 }
259 
drv_update_tkip_key(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_key_conf * conf,struct sta_info * sta,u32 iv32,u16 * phase1key)260 static inline void drv_update_tkip_key(struct ieee80211_local *local,
261 				       struct ieee80211_sub_if_data *sdata,
262 				       struct ieee80211_key_conf *conf,
263 				       struct sta_info *sta, u32 iv32,
264 				       u16 *phase1key)
265 {
266 	struct ieee80211_sta *ista = NULL;
267 
268 	if (sta)
269 		ista = &sta->sta;
270 
271 	sdata = get_bss_sdata(sdata);
272 	if (!check_sdata_in_driver(sdata))
273 		return;
274 
275 	trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
276 	if (local->ops->update_tkip_key)
277 		local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
278 					    ista, iv32, phase1key);
279 	trace_drv_return_void(local);
280 }
281 
drv_hw_scan(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_scan_request * req)282 static inline int drv_hw_scan(struct ieee80211_local *local,
283 			      struct ieee80211_sub_if_data *sdata,
284 			      struct ieee80211_scan_request *req)
285 {
286 	int ret;
287 
288 	might_sleep();
289 
290 	if (!check_sdata_in_driver(sdata))
291 		return -EIO;
292 
293 	trace_drv_hw_scan(local, sdata);
294 	ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
295 	trace_drv_return_int(local, ret);
296 	return ret;
297 }
298 
drv_cancel_hw_scan(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata)299 static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
300 				      struct ieee80211_sub_if_data *sdata)
301 {
302 	might_sleep();
303 
304 	if (!check_sdata_in_driver(sdata))
305 		return;
306 
307 	trace_drv_cancel_hw_scan(local, sdata);
308 	local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
309 	trace_drv_return_void(local);
310 }
311 
312 static inline int
drv_sched_scan_start(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct cfg80211_sched_scan_request * req,struct ieee80211_scan_ies * ies)313 drv_sched_scan_start(struct ieee80211_local *local,
314 		     struct ieee80211_sub_if_data *sdata,
315 		     struct cfg80211_sched_scan_request *req,
316 		     struct ieee80211_scan_ies *ies)
317 {
318 	int ret;
319 
320 	might_sleep();
321 
322 	if (!check_sdata_in_driver(sdata))
323 		return -EIO;
324 
325 	trace_drv_sched_scan_start(local, sdata);
326 	ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
327 					      req, ies);
328 	trace_drv_return_int(local, ret);
329 	return ret;
330 }
331 
drv_sched_scan_stop(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata)332 static inline int drv_sched_scan_stop(struct ieee80211_local *local,
333 				      struct ieee80211_sub_if_data *sdata)
334 {
335 	int ret;
336 
337 	might_sleep();
338 
339 	if (!check_sdata_in_driver(sdata))
340 		return -EIO;
341 
342 	trace_drv_sched_scan_stop(local, sdata);
343 	ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
344 	trace_drv_return_int(local, ret);
345 
346 	return ret;
347 }
348 
drv_sw_scan_start(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,const u8 * mac_addr)349 static inline void drv_sw_scan_start(struct ieee80211_local *local,
350 				     struct ieee80211_sub_if_data *sdata,
351 				     const u8 *mac_addr)
352 {
353 	might_sleep();
354 
355 	trace_drv_sw_scan_start(local, sdata, mac_addr);
356 	if (local->ops->sw_scan_start)
357 		local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
358 	trace_drv_return_void(local);
359 }
360 
drv_sw_scan_complete(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata)361 static inline void drv_sw_scan_complete(struct ieee80211_local *local,
362 					struct ieee80211_sub_if_data *sdata)
363 {
364 	might_sleep();
365 
366 	trace_drv_sw_scan_complete(local, sdata);
367 	if (local->ops->sw_scan_complete)
368 		local->ops->sw_scan_complete(&local->hw, &sdata->vif);
369 	trace_drv_return_void(local);
370 }
371 
drv_get_stats(struct ieee80211_local * local,struct ieee80211_low_level_stats * stats)372 static inline int drv_get_stats(struct ieee80211_local *local,
373 				struct ieee80211_low_level_stats *stats)
374 {
375 	int ret = -EOPNOTSUPP;
376 
377 	might_sleep();
378 
379 	if (local->ops->get_stats)
380 		ret = local->ops->get_stats(&local->hw, stats);
381 	trace_drv_get_stats(local, stats, ret);
382 
383 	return ret;
384 }
385 
drv_get_key_seq(struct ieee80211_local * local,struct ieee80211_key * key,struct ieee80211_key_seq * seq)386 static inline void drv_get_key_seq(struct ieee80211_local *local,
387 				   struct ieee80211_key *key,
388 				   struct ieee80211_key_seq *seq)
389 {
390 	if (local->ops->get_key_seq)
391 		local->ops->get_key_seq(&local->hw, &key->conf, seq);
392 	trace_drv_get_key_seq(local, &key->conf);
393 }
394 
drv_set_frag_threshold(struct ieee80211_local * local,u32 value)395 static inline int drv_set_frag_threshold(struct ieee80211_local *local,
396 					u32 value)
397 {
398 	int ret = 0;
399 
400 	might_sleep();
401 
402 	trace_drv_set_frag_threshold(local, value);
403 	if (local->ops->set_frag_threshold)
404 		ret = local->ops->set_frag_threshold(&local->hw, value);
405 	trace_drv_return_int(local, ret);
406 	return ret;
407 }
408 
drv_set_rts_threshold(struct ieee80211_local * local,u32 value)409 static inline int drv_set_rts_threshold(struct ieee80211_local *local,
410 					u32 value)
411 {
412 	int ret = 0;
413 
414 	might_sleep();
415 
416 	trace_drv_set_rts_threshold(local, value);
417 	if (local->ops->set_rts_threshold)
418 		ret = local->ops->set_rts_threshold(&local->hw, value);
419 	trace_drv_return_int(local, ret);
420 	return ret;
421 }
422 
drv_set_coverage_class(struct ieee80211_local * local,s16 value)423 static inline int drv_set_coverage_class(struct ieee80211_local *local,
424 					 s16 value)
425 {
426 	int ret = 0;
427 	might_sleep();
428 
429 	trace_drv_set_coverage_class(local, value);
430 	if (local->ops->set_coverage_class)
431 		local->ops->set_coverage_class(&local->hw, value);
432 	else
433 		ret = -EOPNOTSUPP;
434 
435 	trace_drv_return_int(local, ret);
436 	return ret;
437 }
438 
drv_sta_notify(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,enum sta_notify_cmd cmd,struct ieee80211_sta * sta)439 static inline void drv_sta_notify(struct ieee80211_local *local,
440 				  struct ieee80211_sub_if_data *sdata,
441 				  enum sta_notify_cmd cmd,
442 				  struct ieee80211_sta *sta)
443 {
444 	sdata = get_bss_sdata(sdata);
445 	if (!check_sdata_in_driver(sdata))
446 		return;
447 
448 	trace_drv_sta_notify(local, sdata, cmd, sta);
449 	if (local->ops->sta_notify)
450 		local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
451 	trace_drv_return_void(local);
452 }
453 
drv_sta_add(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_sta * sta)454 static inline int drv_sta_add(struct ieee80211_local *local,
455 			      struct ieee80211_sub_if_data *sdata,
456 			      struct ieee80211_sta *sta)
457 {
458 	int ret = 0;
459 
460 	might_sleep();
461 
462 	sdata = get_bss_sdata(sdata);
463 	if (!check_sdata_in_driver(sdata))
464 		return -EIO;
465 
466 	trace_drv_sta_add(local, sdata, sta);
467 	if (local->ops->sta_add)
468 		ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
469 
470 	trace_drv_return_int(local, ret);
471 
472 	return ret;
473 }
474 
drv_sta_remove(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_sta * sta)475 static inline void drv_sta_remove(struct ieee80211_local *local,
476 				  struct ieee80211_sub_if_data *sdata,
477 				  struct ieee80211_sta *sta)
478 {
479 	might_sleep();
480 
481 	sdata = get_bss_sdata(sdata);
482 	if (!check_sdata_in_driver(sdata))
483 		return;
484 
485 	trace_drv_sta_remove(local, sdata, sta);
486 	if (local->ops->sta_remove)
487 		local->ops->sta_remove(&local->hw, &sdata->vif, sta);
488 
489 	trace_drv_return_void(local);
490 }
491 
492 #ifdef CONFIG_MAC80211_DEBUGFS
drv_sta_add_debugfs(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_sta * sta,struct dentry * dir)493 static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
494 				       struct ieee80211_sub_if_data *sdata,
495 				       struct ieee80211_sta *sta,
496 				       struct dentry *dir)
497 {
498 	might_sleep();
499 
500 	sdata = get_bss_sdata(sdata);
501 	if (!check_sdata_in_driver(sdata))
502 		return;
503 
504 	if (local->ops->sta_add_debugfs)
505 		local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
506 					    sta, dir);
507 }
508 #endif
509 
drv_sta_pre_rcu_remove(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct sta_info * sta)510 static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
511 					  struct ieee80211_sub_if_data *sdata,
512 					  struct sta_info *sta)
513 {
514 	might_sleep();
515 
516 	sdata = get_bss_sdata(sdata);
517 	if (!check_sdata_in_driver(sdata))
518 		return;
519 
520 	trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
521 	if (local->ops->sta_pre_rcu_remove)
522 		local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
523 					       &sta->sta);
524 	trace_drv_return_void(local);
525 }
526 
527 __must_check
528 int drv_sta_state(struct ieee80211_local *local,
529 		  struct ieee80211_sub_if_data *sdata,
530 		  struct sta_info *sta,
531 		  enum ieee80211_sta_state old_state,
532 		  enum ieee80211_sta_state new_state);
533 
534 __must_check
535 int drv_sta_set_txpwr(struct ieee80211_local *local,
536 		      struct ieee80211_sub_if_data *sdata,
537 		      struct sta_info *sta);
538 
539 void drv_sta_rc_update(struct ieee80211_local *local,
540 		       struct ieee80211_sub_if_data *sdata,
541 		       struct ieee80211_sta *sta, u32 changed);
542 
drv_sta_rate_tbl_update(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_sta * sta)543 static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
544 					   struct ieee80211_sub_if_data *sdata,
545 					   struct ieee80211_sta *sta)
546 {
547 	sdata = get_bss_sdata(sdata);
548 	if (!check_sdata_in_driver(sdata))
549 		return;
550 
551 	trace_drv_sta_rate_tbl_update(local, sdata, sta);
552 	if (local->ops->sta_rate_tbl_update)
553 		local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
554 
555 	trace_drv_return_void(local);
556 }
557 
drv_sta_statistics(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_sta * sta,struct station_info * sinfo)558 static inline void drv_sta_statistics(struct ieee80211_local *local,
559 				      struct ieee80211_sub_if_data *sdata,
560 				      struct ieee80211_sta *sta,
561 				      struct station_info *sinfo)
562 {
563 	sdata = get_bss_sdata(sdata);
564 	if (!check_sdata_in_driver(sdata))
565 		return;
566 
567 	trace_drv_sta_statistics(local, sdata, sta);
568 	if (local->ops->sta_statistics)
569 		local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
570 	trace_drv_return_void(local);
571 }
572 
573 int drv_conf_tx(struct ieee80211_local *local,
574 		struct ieee80211_sub_if_data *sdata, u16 ac,
575 		const struct ieee80211_tx_queue_params *params);
576 
577 u64 drv_get_tsf(struct ieee80211_local *local,
578 		struct ieee80211_sub_if_data *sdata);
579 void drv_set_tsf(struct ieee80211_local *local,
580 		 struct ieee80211_sub_if_data *sdata,
581 		 u64 tsf);
582 void drv_offset_tsf(struct ieee80211_local *local,
583 		    struct ieee80211_sub_if_data *sdata,
584 		    s64 offset);
585 void drv_reset_tsf(struct ieee80211_local *local,
586 		   struct ieee80211_sub_if_data *sdata);
587 
drv_tx_last_beacon(struct ieee80211_local * local)588 static inline int drv_tx_last_beacon(struct ieee80211_local *local)
589 {
590 	int ret = 0; /* default unsupported op for less congestion */
591 
592 	might_sleep();
593 
594 	trace_drv_tx_last_beacon(local);
595 	if (local->ops->tx_last_beacon)
596 		ret = local->ops->tx_last_beacon(&local->hw);
597 	trace_drv_return_int(local, ret);
598 	return ret;
599 }
600 
601 int drv_ampdu_action(struct ieee80211_local *local,
602 		     struct ieee80211_sub_if_data *sdata,
603 		     struct ieee80211_ampdu_params *params);
604 
drv_get_survey(struct ieee80211_local * local,int idx,struct survey_info * survey)605 static inline int drv_get_survey(struct ieee80211_local *local, int idx,
606 				struct survey_info *survey)
607 {
608 	int ret = -EOPNOTSUPP;
609 
610 	trace_drv_get_survey(local, idx, survey);
611 
612 	if (local->ops->get_survey)
613 		ret = local->ops->get_survey(&local->hw, idx, survey);
614 
615 	trace_drv_return_int(local, ret);
616 
617 	return ret;
618 }
619 
drv_rfkill_poll(struct ieee80211_local * local)620 static inline void drv_rfkill_poll(struct ieee80211_local *local)
621 {
622 	might_sleep();
623 
624 	if (local->ops->rfkill_poll)
625 		local->ops->rfkill_poll(&local->hw);
626 }
627 
drv_flush(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,u32 queues,bool drop)628 static inline void drv_flush(struct ieee80211_local *local,
629 			     struct ieee80211_sub_if_data *sdata,
630 			     u32 queues, bool drop)
631 {
632 	struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
633 
634 	might_sleep();
635 
636 	if (sdata && !check_sdata_in_driver(sdata))
637 		return;
638 
639 	trace_drv_flush(local, queues, drop);
640 	if (local->ops->flush)
641 		local->ops->flush(&local->hw, vif, queues, drop);
642 	trace_drv_return_void(local);
643 }
644 
drv_channel_switch(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_channel_switch * ch_switch)645 static inline void drv_channel_switch(struct ieee80211_local *local,
646 				      struct ieee80211_sub_if_data *sdata,
647 				      struct ieee80211_channel_switch *ch_switch)
648 {
649 	might_sleep();
650 
651 	trace_drv_channel_switch(local, sdata, ch_switch);
652 	local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
653 	trace_drv_return_void(local);
654 }
655 
656 
drv_set_antenna(struct ieee80211_local * local,u32 tx_ant,u32 rx_ant)657 static inline int drv_set_antenna(struct ieee80211_local *local,
658 				  u32 tx_ant, u32 rx_ant)
659 {
660 	int ret = -EOPNOTSUPP;
661 	might_sleep();
662 	if (local->ops->set_antenna)
663 		ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
664 	trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
665 	return ret;
666 }
667 
drv_get_antenna(struct ieee80211_local * local,u32 * tx_ant,u32 * rx_ant)668 static inline int drv_get_antenna(struct ieee80211_local *local,
669 				  u32 *tx_ant, u32 *rx_ant)
670 {
671 	int ret = -EOPNOTSUPP;
672 	might_sleep();
673 	if (local->ops->get_antenna)
674 		ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
675 	trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
676 	return ret;
677 }
678 
drv_remain_on_channel(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_channel * chan,unsigned int duration,enum ieee80211_roc_type type)679 static inline int drv_remain_on_channel(struct ieee80211_local *local,
680 					struct ieee80211_sub_if_data *sdata,
681 					struct ieee80211_channel *chan,
682 					unsigned int duration,
683 					enum ieee80211_roc_type type)
684 {
685 	int ret;
686 
687 	might_sleep();
688 
689 	trace_drv_remain_on_channel(local, sdata, chan, duration, type);
690 	ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
691 					    chan, duration, type);
692 	trace_drv_return_int(local, ret);
693 
694 	return ret;
695 }
696 
697 static inline int
drv_cancel_remain_on_channel(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata)698 drv_cancel_remain_on_channel(struct ieee80211_local *local,
699 			     struct ieee80211_sub_if_data *sdata)
700 {
701 	int ret;
702 
703 	might_sleep();
704 
705 	trace_drv_cancel_remain_on_channel(local, sdata);
706 	ret = local->ops->cancel_remain_on_channel(&local->hw, &sdata->vif);
707 	trace_drv_return_int(local, ret);
708 
709 	return ret;
710 }
711 
drv_set_ringparam(struct ieee80211_local * local,u32 tx,u32 rx)712 static inline int drv_set_ringparam(struct ieee80211_local *local,
713 				    u32 tx, u32 rx)
714 {
715 	int ret = -ENOTSUPP;
716 
717 	might_sleep();
718 
719 	trace_drv_set_ringparam(local, tx, rx);
720 	if (local->ops->set_ringparam)
721 		ret = local->ops->set_ringparam(&local->hw, tx, rx);
722 	trace_drv_return_int(local, ret);
723 
724 	return ret;
725 }
726 
drv_get_ringparam(struct ieee80211_local * local,u32 * tx,u32 * tx_max,u32 * rx,u32 * rx_max)727 static inline void drv_get_ringparam(struct ieee80211_local *local,
728 				     u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
729 {
730 	might_sleep();
731 
732 	trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
733 	if (local->ops->get_ringparam)
734 		local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
735 	trace_drv_return_void(local);
736 }
737 
drv_tx_frames_pending(struct ieee80211_local * local)738 static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
739 {
740 	bool ret = false;
741 
742 	might_sleep();
743 
744 	trace_drv_tx_frames_pending(local);
745 	if (local->ops->tx_frames_pending)
746 		ret = local->ops->tx_frames_pending(&local->hw);
747 	trace_drv_return_bool(local, ret);
748 
749 	return ret;
750 }
751 
drv_set_bitrate_mask(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,const struct cfg80211_bitrate_mask * mask)752 static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
753 				       struct ieee80211_sub_if_data *sdata,
754 				       const struct cfg80211_bitrate_mask *mask)
755 {
756 	int ret = -EOPNOTSUPP;
757 
758 	might_sleep();
759 
760 	if (!check_sdata_in_driver(sdata))
761 		return -EIO;
762 
763 	trace_drv_set_bitrate_mask(local, sdata, mask);
764 	if (local->ops->set_bitrate_mask)
765 		ret = local->ops->set_bitrate_mask(&local->hw,
766 						   &sdata->vif, mask);
767 	trace_drv_return_int(local, ret);
768 
769 	return ret;
770 }
771 
drv_set_rekey_data(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct cfg80211_gtk_rekey_data * data)772 static inline void drv_set_rekey_data(struct ieee80211_local *local,
773 				      struct ieee80211_sub_if_data *sdata,
774 				      struct cfg80211_gtk_rekey_data *data)
775 {
776 	if (!check_sdata_in_driver(sdata))
777 		return;
778 
779 	trace_drv_set_rekey_data(local, sdata, data);
780 	if (local->ops->set_rekey_data)
781 		local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
782 	trace_drv_return_void(local);
783 }
784 
drv_event_callback(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,const struct ieee80211_event * event)785 static inline void drv_event_callback(struct ieee80211_local *local,
786 				      struct ieee80211_sub_if_data *sdata,
787 				      const struct ieee80211_event *event)
788 {
789 	trace_drv_event_callback(local, sdata, event);
790 	if (local->ops->event_callback)
791 		local->ops->event_callback(&local->hw, &sdata->vif, event);
792 	trace_drv_return_void(local);
793 }
794 
795 static inline void
drv_release_buffered_frames(struct ieee80211_local * local,struct sta_info * sta,u16 tids,int num_frames,enum ieee80211_frame_release_type reason,bool more_data)796 drv_release_buffered_frames(struct ieee80211_local *local,
797 			    struct sta_info *sta, u16 tids, int num_frames,
798 			    enum ieee80211_frame_release_type reason,
799 			    bool more_data)
800 {
801 	trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
802 					  reason, more_data);
803 	if (local->ops->release_buffered_frames)
804 		local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
805 						    num_frames, reason,
806 						    more_data);
807 	trace_drv_return_void(local);
808 }
809 
810 static inline void
drv_allow_buffered_frames(struct ieee80211_local * local,struct sta_info * sta,u16 tids,int num_frames,enum ieee80211_frame_release_type reason,bool more_data)811 drv_allow_buffered_frames(struct ieee80211_local *local,
812 			  struct sta_info *sta, u16 tids, int num_frames,
813 			  enum ieee80211_frame_release_type reason,
814 			  bool more_data)
815 {
816 	trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
817 					reason, more_data);
818 	if (local->ops->allow_buffered_frames)
819 		local->ops->allow_buffered_frames(&local->hw, &sta->sta,
820 						  tids, num_frames, reason,
821 						  more_data);
822 	trace_drv_return_void(local);
823 }
824 
drv_mgd_prepare_tx(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,u16 duration)825 static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
826 				      struct ieee80211_sub_if_data *sdata,
827 				      u16 duration)
828 {
829 	might_sleep();
830 
831 	if (!check_sdata_in_driver(sdata))
832 		return;
833 	WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
834 
835 	trace_drv_mgd_prepare_tx(local, sdata, duration);
836 	if (local->ops->mgd_prepare_tx)
837 		local->ops->mgd_prepare_tx(&local->hw, &sdata->vif, duration);
838 	trace_drv_return_void(local);
839 }
840 
841 static inline void
drv_mgd_protect_tdls_discover(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata)842 drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
843 			      struct ieee80211_sub_if_data *sdata)
844 {
845 	might_sleep();
846 
847 	if (!check_sdata_in_driver(sdata))
848 		return;
849 	WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
850 
851 	trace_drv_mgd_protect_tdls_discover(local, sdata);
852 	if (local->ops->mgd_protect_tdls_discover)
853 		local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
854 	trace_drv_return_void(local);
855 }
856 
drv_add_chanctx(struct ieee80211_local * local,struct ieee80211_chanctx * ctx)857 static inline int drv_add_chanctx(struct ieee80211_local *local,
858 				  struct ieee80211_chanctx *ctx)
859 {
860 	int ret = -EOPNOTSUPP;
861 
862 	might_sleep();
863 
864 	trace_drv_add_chanctx(local, ctx);
865 	if (local->ops->add_chanctx)
866 		ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
867 	trace_drv_return_int(local, ret);
868 	if (!ret)
869 		ctx->driver_present = true;
870 
871 	return ret;
872 }
873 
drv_remove_chanctx(struct ieee80211_local * local,struct ieee80211_chanctx * ctx)874 static inline void drv_remove_chanctx(struct ieee80211_local *local,
875 				      struct ieee80211_chanctx *ctx)
876 {
877 	might_sleep();
878 
879 	if (WARN_ON(!ctx->driver_present))
880 		return;
881 
882 	trace_drv_remove_chanctx(local, ctx);
883 	if (local->ops->remove_chanctx)
884 		local->ops->remove_chanctx(&local->hw, &ctx->conf);
885 	trace_drv_return_void(local);
886 	ctx->driver_present = false;
887 }
888 
drv_change_chanctx(struct ieee80211_local * local,struct ieee80211_chanctx * ctx,u32 changed)889 static inline void drv_change_chanctx(struct ieee80211_local *local,
890 				      struct ieee80211_chanctx *ctx,
891 				      u32 changed)
892 {
893 	might_sleep();
894 
895 	trace_drv_change_chanctx(local, ctx, changed);
896 	if (local->ops->change_chanctx) {
897 		WARN_ON_ONCE(!ctx->driver_present);
898 		local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
899 	}
900 	trace_drv_return_void(local);
901 }
902 
drv_assign_vif_chanctx(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_chanctx * ctx)903 static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
904 					 struct ieee80211_sub_if_data *sdata,
905 					 struct ieee80211_chanctx *ctx)
906 {
907 	int ret = 0;
908 
909 	if (!check_sdata_in_driver(sdata))
910 		return -EIO;
911 
912 	trace_drv_assign_vif_chanctx(local, sdata, ctx);
913 	if (local->ops->assign_vif_chanctx) {
914 		WARN_ON_ONCE(!ctx->driver_present);
915 		ret = local->ops->assign_vif_chanctx(&local->hw,
916 						     &sdata->vif,
917 						     &ctx->conf);
918 	}
919 	trace_drv_return_int(local, ret);
920 
921 	return ret;
922 }
923 
drv_unassign_vif_chanctx(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_chanctx * ctx)924 static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
925 					    struct ieee80211_sub_if_data *sdata,
926 					    struct ieee80211_chanctx *ctx)
927 {
928 	might_sleep();
929 
930 	if (!check_sdata_in_driver(sdata))
931 		return;
932 
933 	trace_drv_unassign_vif_chanctx(local, sdata, ctx);
934 	if (local->ops->unassign_vif_chanctx) {
935 		WARN_ON_ONCE(!ctx->driver_present);
936 		local->ops->unassign_vif_chanctx(&local->hw,
937 						 &sdata->vif,
938 						 &ctx->conf);
939 	}
940 	trace_drv_return_void(local);
941 }
942 
943 int drv_switch_vif_chanctx(struct ieee80211_local *local,
944 			   struct ieee80211_vif_chanctx_switch *vifs,
945 			   int n_vifs, enum ieee80211_chanctx_switch_mode mode);
946 
drv_start_ap(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata)947 static inline int drv_start_ap(struct ieee80211_local *local,
948 			       struct ieee80211_sub_if_data *sdata)
949 {
950 	int ret = 0;
951 
952 	might_sleep();
953 
954 	if (!check_sdata_in_driver(sdata))
955 		return -EIO;
956 
957 	trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
958 	if (local->ops->start_ap)
959 		ret = local->ops->start_ap(&local->hw, &sdata->vif);
960 	trace_drv_return_int(local, ret);
961 	return ret;
962 }
963 
drv_stop_ap(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata)964 static inline void drv_stop_ap(struct ieee80211_local *local,
965 			       struct ieee80211_sub_if_data *sdata)
966 {
967 	if (!check_sdata_in_driver(sdata))
968 		return;
969 
970 	trace_drv_stop_ap(local, sdata);
971 	if (local->ops->stop_ap)
972 		local->ops->stop_ap(&local->hw, &sdata->vif);
973 	trace_drv_return_void(local);
974 }
975 
976 static inline void
drv_reconfig_complete(struct ieee80211_local * local,enum ieee80211_reconfig_type reconfig_type)977 drv_reconfig_complete(struct ieee80211_local *local,
978 		      enum ieee80211_reconfig_type reconfig_type)
979 {
980 	might_sleep();
981 
982 	trace_drv_reconfig_complete(local, reconfig_type);
983 	if (local->ops->reconfig_complete)
984 		local->ops->reconfig_complete(&local->hw, reconfig_type);
985 	trace_drv_return_void(local);
986 }
987 
988 static inline void
drv_set_default_unicast_key(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,int key_idx)989 drv_set_default_unicast_key(struct ieee80211_local *local,
990 			    struct ieee80211_sub_if_data *sdata,
991 			    int key_idx)
992 {
993 	if (!check_sdata_in_driver(sdata))
994 		return;
995 
996 	WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
997 
998 	trace_drv_set_default_unicast_key(local, sdata, key_idx);
999 	if (local->ops->set_default_unicast_key)
1000 		local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1001 						    key_idx);
1002 	trace_drv_return_void(local);
1003 }
1004 
1005 #if IS_ENABLED(CONFIG_IPV6)
drv_ipv6_addr_change(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct inet6_dev * idev)1006 static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1007 					struct ieee80211_sub_if_data *sdata,
1008 					struct inet6_dev *idev)
1009 {
1010 	trace_drv_ipv6_addr_change(local, sdata);
1011 	if (local->ops->ipv6_addr_change)
1012 		local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1013 	trace_drv_return_void(local);
1014 }
1015 #endif
1016 
1017 static inline void
drv_channel_switch_beacon(struct ieee80211_sub_if_data * sdata,struct cfg80211_chan_def * chandef)1018 drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1019 			  struct cfg80211_chan_def *chandef)
1020 {
1021 	struct ieee80211_local *local = sdata->local;
1022 
1023 	if (local->ops->channel_switch_beacon) {
1024 		trace_drv_channel_switch_beacon(local, sdata, chandef);
1025 		local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1026 						  chandef);
1027 	}
1028 }
1029 
1030 static inline int
drv_pre_channel_switch(struct ieee80211_sub_if_data * sdata,struct ieee80211_channel_switch * ch_switch)1031 drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
1032 		       struct ieee80211_channel_switch *ch_switch)
1033 {
1034 	struct ieee80211_local *local = sdata->local;
1035 	int ret = 0;
1036 
1037 	if (!check_sdata_in_driver(sdata))
1038 		return -EIO;
1039 
1040 	trace_drv_pre_channel_switch(local, sdata, ch_switch);
1041 	if (local->ops->pre_channel_switch)
1042 		ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
1043 						     ch_switch);
1044 	trace_drv_return_int(local, ret);
1045 	return ret;
1046 }
1047 
1048 static inline int
drv_post_channel_switch(struct ieee80211_sub_if_data * sdata)1049 drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1050 {
1051 	struct ieee80211_local *local = sdata->local;
1052 	int ret = 0;
1053 
1054 	if (!check_sdata_in_driver(sdata))
1055 		return -EIO;
1056 
1057 	trace_drv_post_channel_switch(local, sdata);
1058 	if (local->ops->post_channel_switch)
1059 		ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1060 	trace_drv_return_int(local, ret);
1061 	return ret;
1062 }
1063 
1064 static inline void
drv_abort_channel_switch(struct ieee80211_sub_if_data * sdata)1065 drv_abort_channel_switch(struct ieee80211_sub_if_data *sdata)
1066 {
1067 	struct ieee80211_local *local = sdata->local;
1068 
1069 	if (!check_sdata_in_driver(sdata))
1070 		return;
1071 
1072 	trace_drv_abort_channel_switch(local, sdata);
1073 
1074 	if (local->ops->abort_channel_switch)
1075 		local->ops->abort_channel_switch(&local->hw, &sdata->vif);
1076 }
1077 
1078 static inline void
drv_channel_switch_rx_beacon(struct ieee80211_sub_if_data * sdata,struct ieee80211_channel_switch * ch_switch)1079 drv_channel_switch_rx_beacon(struct ieee80211_sub_if_data *sdata,
1080 			     struct ieee80211_channel_switch *ch_switch)
1081 {
1082 	struct ieee80211_local *local = sdata->local;
1083 
1084 	if (!check_sdata_in_driver(sdata))
1085 		return;
1086 
1087 	trace_drv_channel_switch_rx_beacon(local, sdata, ch_switch);
1088 	if (local->ops->channel_switch_rx_beacon)
1089 		local->ops->channel_switch_rx_beacon(&local->hw, &sdata->vif,
1090 						     ch_switch);
1091 }
1092 
drv_join_ibss(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata)1093 static inline int drv_join_ibss(struct ieee80211_local *local,
1094 				struct ieee80211_sub_if_data *sdata)
1095 {
1096 	int ret = 0;
1097 
1098 	might_sleep();
1099 	if (!check_sdata_in_driver(sdata))
1100 		return -EIO;
1101 
1102 	trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1103 	if (local->ops->join_ibss)
1104 		ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1105 	trace_drv_return_int(local, ret);
1106 	return ret;
1107 }
1108 
drv_leave_ibss(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata)1109 static inline void drv_leave_ibss(struct ieee80211_local *local,
1110 				  struct ieee80211_sub_if_data *sdata)
1111 {
1112 	might_sleep();
1113 	if (!check_sdata_in_driver(sdata))
1114 		return;
1115 
1116 	trace_drv_leave_ibss(local, sdata);
1117 	if (local->ops->leave_ibss)
1118 		local->ops->leave_ibss(&local->hw, &sdata->vif);
1119 	trace_drv_return_void(local);
1120 }
1121 
drv_get_expected_throughput(struct ieee80211_local * local,struct sta_info * sta)1122 static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
1123 					      struct sta_info *sta)
1124 {
1125 	u32 ret = 0;
1126 
1127 	trace_drv_get_expected_throughput(&sta->sta);
1128 	if (local->ops->get_expected_throughput && sta->uploaded)
1129 		ret = local->ops->get_expected_throughput(&local->hw, &sta->sta);
1130 	trace_drv_return_u32(local, ret);
1131 
1132 	return ret;
1133 }
1134 
drv_get_txpower(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,int * dbm)1135 static inline int drv_get_txpower(struct ieee80211_local *local,
1136 				  struct ieee80211_sub_if_data *sdata, int *dbm)
1137 {
1138 	int ret;
1139 
1140 	if (!local->ops->get_txpower)
1141 		return -EOPNOTSUPP;
1142 
1143 	ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
1144 	trace_drv_get_txpower(local, sdata, *dbm, ret);
1145 
1146 	return ret;
1147 }
1148 
1149 static inline int
drv_tdls_channel_switch(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_sta * sta,u8 oper_class,struct cfg80211_chan_def * chandef,struct sk_buff * tmpl_skb,u32 ch_sw_tm_ie)1150 drv_tdls_channel_switch(struct ieee80211_local *local,
1151 			struct ieee80211_sub_if_data *sdata,
1152 			struct ieee80211_sta *sta, u8 oper_class,
1153 			struct cfg80211_chan_def *chandef,
1154 			struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
1155 {
1156 	int ret;
1157 
1158 	might_sleep();
1159 	if (!check_sdata_in_driver(sdata))
1160 		return -EIO;
1161 
1162 	if (!local->ops->tdls_channel_switch)
1163 		return -EOPNOTSUPP;
1164 
1165 	trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
1166 	ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
1167 					      oper_class, chandef, tmpl_skb,
1168 					      ch_sw_tm_ie);
1169 	trace_drv_return_int(local, ret);
1170 	return ret;
1171 }
1172 
1173 static inline void
drv_tdls_cancel_channel_switch(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_sta * sta)1174 drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
1175 			       struct ieee80211_sub_if_data *sdata,
1176 			       struct ieee80211_sta *sta)
1177 {
1178 	might_sleep();
1179 	if (!check_sdata_in_driver(sdata))
1180 		return;
1181 
1182 	if (!local->ops->tdls_cancel_channel_switch)
1183 		return;
1184 
1185 	trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
1186 	local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
1187 	trace_drv_return_void(local);
1188 }
1189 
1190 static inline void
drv_tdls_recv_channel_switch(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_tdls_ch_sw_params * params)1191 drv_tdls_recv_channel_switch(struct ieee80211_local *local,
1192 			     struct ieee80211_sub_if_data *sdata,
1193 			     struct ieee80211_tdls_ch_sw_params *params)
1194 {
1195 	trace_drv_tdls_recv_channel_switch(local, sdata, params);
1196 	if (local->ops->tdls_recv_channel_switch)
1197 		local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
1198 						     params);
1199 	trace_drv_return_void(local);
1200 }
1201 
drv_wake_tx_queue(struct ieee80211_local * local,struct txq_info * txq)1202 static inline void drv_wake_tx_queue(struct ieee80211_local *local,
1203 				     struct txq_info *txq)
1204 {
1205 	struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
1206 
1207 	if (local->in_reconfig)
1208 		return;
1209 
1210 	if (!check_sdata_in_driver(sdata))
1211 		return;
1212 
1213 	trace_drv_wake_tx_queue(local, sdata, txq);
1214 	local->ops->wake_tx_queue(&local->hw, &txq->txq);
1215 }
1216 
schedule_and_wake_txq(struct ieee80211_local * local,struct txq_info * txqi)1217 static inline void schedule_and_wake_txq(struct ieee80211_local *local,
1218 					 struct txq_info *txqi)
1219 {
1220 	ieee80211_schedule_txq(&local->hw, &txqi->txq);
1221 	drv_wake_tx_queue(local, txqi);
1222 }
1223 
drv_can_aggregate_in_amsdu(struct ieee80211_local * local,struct sk_buff * head,struct sk_buff * skb)1224 static inline int drv_can_aggregate_in_amsdu(struct ieee80211_local *local,
1225 					     struct sk_buff *head,
1226 					     struct sk_buff *skb)
1227 {
1228 	if (!local->ops->can_aggregate_in_amsdu)
1229 		return true;
1230 
1231 	return local->ops->can_aggregate_in_amsdu(&local->hw, head, skb);
1232 }
1233 
1234 static inline int
drv_get_ftm_responder_stats(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct cfg80211_ftm_responder_stats * ftm_stats)1235 drv_get_ftm_responder_stats(struct ieee80211_local *local,
1236 			    struct ieee80211_sub_if_data *sdata,
1237 			    struct cfg80211_ftm_responder_stats *ftm_stats)
1238 {
1239 	u32 ret = -EOPNOTSUPP;
1240 
1241 	if (local->ops->get_ftm_responder_stats)
1242 		ret = local->ops->get_ftm_responder_stats(&local->hw,
1243 							 &sdata->vif,
1244 							 ftm_stats);
1245 	trace_drv_get_ftm_responder_stats(local, sdata, ftm_stats);
1246 
1247 	return ret;
1248 }
1249 
drv_start_pmsr(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct cfg80211_pmsr_request * request)1250 static inline int drv_start_pmsr(struct ieee80211_local *local,
1251 				 struct ieee80211_sub_if_data *sdata,
1252 				 struct cfg80211_pmsr_request *request)
1253 {
1254 	int ret = -EOPNOTSUPP;
1255 
1256 	might_sleep();
1257 	if (!check_sdata_in_driver(sdata))
1258 		return -EIO;
1259 
1260 	trace_drv_start_pmsr(local, sdata);
1261 
1262 	if (local->ops->start_pmsr)
1263 		ret = local->ops->start_pmsr(&local->hw, &sdata->vif, request);
1264 	trace_drv_return_int(local, ret);
1265 
1266 	return ret;
1267 }
1268 
drv_abort_pmsr(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct cfg80211_pmsr_request * request)1269 static inline void drv_abort_pmsr(struct ieee80211_local *local,
1270 				  struct ieee80211_sub_if_data *sdata,
1271 				  struct cfg80211_pmsr_request *request)
1272 {
1273 	trace_drv_abort_pmsr(local, sdata);
1274 
1275 	might_sleep();
1276 	if (!check_sdata_in_driver(sdata))
1277 		return;
1278 
1279 	if (local->ops->abort_pmsr)
1280 		local->ops->abort_pmsr(&local->hw, &sdata->vif, request);
1281 	trace_drv_return_void(local);
1282 }
1283 
drv_start_nan(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct cfg80211_nan_conf * conf)1284 static inline int drv_start_nan(struct ieee80211_local *local,
1285 				struct ieee80211_sub_if_data *sdata,
1286 				struct cfg80211_nan_conf *conf)
1287 {
1288 	int ret;
1289 
1290 	might_sleep();
1291 	check_sdata_in_driver(sdata);
1292 
1293 	trace_drv_start_nan(local, sdata, conf);
1294 	ret = local->ops->start_nan(&local->hw, &sdata->vif, conf);
1295 	trace_drv_return_int(local, ret);
1296 	return ret;
1297 }
1298 
drv_stop_nan(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata)1299 static inline void drv_stop_nan(struct ieee80211_local *local,
1300 				struct ieee80211_sub_if_data *sdata)
1301 {
1302 	might_sleep();
1303 	check_sdata_in_driver(sdata);
1304 
1305 	trace_drv_stop_nan(local, sdata);
1306 	local->ops->stop_nan(&local->hw, &sdata->vif);
1307 	trace_drv_return_void(local);
1308 }
1309 
drv_nan_change_conf(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct cfg80211_nan_conf * conf,u32 changes)1310 static inline int drv_nan_change_conf(struct ieee80211_local *local,
1311 				       struct ieee80211_sub_if_data *sdata,
1312 				       struct cfg80211_nan_conf *conf,
1313 				       u32 changes)
1314 {
1315 	int ret;
1316 
1317 	might_sleep();
1318 	check_sdata_in_driver(sdata);
1319 
1320 	if (!local->ops->nan_change_conf)
1321 		return -EOPNOTSUPP;
1322 
1323 	trace_drv_nan_change_conf(local, sdata, conf, changes);
1324 	ret = local->ops->nan_change_conf(&local->hw, &sdata->vif, conf,
1325 					  changes);
1326 	trace_drv_return_int(local, ret);
1327 
1328 	return ret;
1329 }
1330 
drv_add_nan_func(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,const struct cfg80211_nan_func * nan_func)1331 static inline int drv_add_nan_func(struct ieee80211_local *local,
1332 				   struct ieee80211_sub_if_data *sdata,
1333 				   const struct cfg80211_nan_func *nan_func)
1334 {
1335 	int ret;
1336 
1337 	might_sleep();
1338 	check_sdata_in_driver(sdata);
1339 
1340 	if (!local->ops->add_nan_func)
1341 		return -EOPNOTSUPP;
1342 
1343 	trace_drv_add_nan_func(local, sdata, nan_func);
1344 	ret = local->ops->add_nan_func(&local->hw, &sdata->vif, nan_func);
1345 	trace_drv_return_int(local, ret);
1346 
1347 	return ret;
1348 }
1349 
drv_del_nan_func(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,u8 instance_id)1350 static inline void drv_del_nan_func(struct ieee80211_local *local,
1351 				   struct ieee80211_sub_if_data *sdata,
1352 				   u8 instance_id)
1353 {
1354 	might_sleep();
1355 	check_sdata_in_driver(sdata);
1356 
1357 	trace_drv_del_nan_func(local, sdata, instance_id);
1358 	if (local->ops->del_nan_func)
1359 		local->ops->del_nan_func(&local->hw, &sdata->vif, instance_id);
1360 	trace_drv_return_void(local);
1361 }
1362 
drv_change_mac(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct sockaddr * sa)1363 static inline int drv_change_mac(struct ieee80211_local *local,
1364 			   struct ieee80211_sub_if_data *sdata, struct sockaddr *sa)
1365 {
1366    int ret = 0;
1367    if (local->ops->change_mac)
1368 	   ret = local->ops->change_mac(&local->hw, &sdata->vif, sa);
1369 
1370    return ret;
1371 }
1372 
1373 #endif /* __MAC80211_DRIVER_OPS */
1374