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