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