xref: /linux/net/mac80211/driver-ops.h (revision ef815d2cba782e96b9aad9483523d474ed41c62a)
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 	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 
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 
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 
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
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 = sdata ? &sdata->vif : NULL;
642 
643 	might_sleep();
644 
645 	if (sdata && !check_sdata_in_driver(sdata))
646 		return;
647 
648 	trace_drv_flush(local, queues, drop);
649 	if (local->ops->flush)
650 		local->ops->flush(&local->hw, vif, queues, drop);
651 	trace_drv_return_void(local);
652 }
653 
654 static inline void drv_flush_sta(struct ieee80211_local *local,
655 				 struct ieee80211_sub_if_data *sdata,
656 				 struct sta_info *sta)
657 {
658 	might_sleep();
659 
660 	if (sdata && !check_sdata_in_driver(sdata))
661 		return;
662 
663 	trace_drv_flush_sta(local, sdata, &sta->sta);
664 	if (local->ops->flush_sta)
665 		local->ops->flush_sta(&local->hw, &sdata->vif, &sta->sta);
666 	trace_drv_return_void(local);
667 }
668 
669 static inline void drv_channel_switch(struct ieee80211_local *local,
670 				      struct ieee80211_sub_if_data *sdata,
671 				      struct ieee80211_channel_switch *ch_switch)
672 {
673 	might_sleep();
674 
675 	trace_drv_channel_switch(local, sdata, ch_switch);
676 	local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
677 	trace_drv_return_void(local);
678 }
679 
680 
681 static inline int drv_set_antenna(struct ieee80211_local *local,
682 				  u32 tx_ant, u32 rx_ant)
683 {
684 	int ret = -EOPNOTSUPP;
685 	might_sleep();
686 	if (local->ops->set_antenna)
687 		ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
688 	trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
689 	return ret;
690 }
691 
692 static inline int drv_get_antenna(struct ieee80211_local *local,
693 				  u32 *tx_ant, u32 *rx_ant)
694 {
695 	int ret = -EOPNOTSUPP;
696 	might_sleep();
697 	if (local->ops->get_antenna)
698 		ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
699 	trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
700 	return ret;
701 }
702 
703 static inline int drv_remain_on_channel(struct ieee80211_local *local,
704 					struct ieee80211_sub_if_data *sdata,
705 					struct ieee80211_channel *chan,
706 					unsigned int duration,
707 					enum ieee80211_roc_type type)
708 {
709 	int ret;
710 
711 	might_sleep();
712 
713 	trace_drv_remain_on_channel(local, sdata, chan, duration, type);
714 	ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
715 					    chan, duration, type);
716 	trace_drv_return_int(local, ret);
717 
718 	return ret;
719 }
720 
721 static inline int
722 drv_cancel_remain_on_channel(struct ieee80211_local *local,
723 			     struct ieee80211_sub_if_data *sdata)
724 {
725 	int ret;
726 
727 	might_sleep();
728 
729 	trace_drv_cancel_remain_on_channel(local, sdata);
730 	ret = local->ops->cancel_remain_on_channel(&local->hw, &sdata->vif);
731 	trace_drv_return_int(local, ret);
732 
733 	return ret;
734 }
735 
736 static inline int drv_set_ringparam(struct ieee80211_local *local,
737 				    u32 tx, u32 rx)
738 {
739 	int ret = -ENOTSUPP;
740 
741 	might_sleep();
742 
743 	trace_drv_set_ringparam(local, tx, rx);
744 	if (local->ops->set_ringparam)
745 		ret = local->ops->set_ringparam(&local->hw, tx, rx);
746 	trace_drv_return_int(local, ret);
747 
748 	return ret;
749 }
750 
751 static inline void drv_get_ringparam(struct ieee80211_local *local,
752 				     u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
753 {
754 	might_sleep();
755 
756 	trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
757 	if (local->ops->get_ringparam)
758 		local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
759 	trace_drv_return_void(local);
760 }
761 
762 static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
763 {
764 	bool ret = false;
765 
766 	might_sleep();
767 
768 	trace_drv_tx_frames_pending(local);
769 	if (local->ops->tx_frames_pending)
770 		ret = local->ops->tx_frames_pending(&local->hw);
771 	trace_drv_return_bool(local, ret);
772 
773 	return ret;
774 }
775 
776 static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
777 				       struct ieee80211_sub_if_data *sdata,
778 				       const struct cfg80211_bitrate_mask *mask)
779 {
780 	int ret = -EOPNOTSUPP;
781 
782 	might_sleep();
783 
784 	if (!check_sdata_in_driver(sdata))
785 		return -EIO;
786 
787 	trace_drv_set_bitrate_mask(local, sdata, mask);
788 	if (local->ops->set_bitrate_mask)
789 		ret = local->ops->set_bitrate_mask(&local->hw,
790 						   &sdata->vif, mask);
791 	trace_drv_return_int(local, ret);
792 
793 	return ret;
794 }
795 
796 static inline void drv_set_rekey_data(struct ieee80211_local *local,
797 				      struct ieee80211_sub_if_data *sdata,
798 				      struct cfg80211_gtk_rekey_data *data)
799 {
800 	if (!check_sdata_in_driver(sdata))
801 		return;
802 
803 	trace_drv_set_rekey_data(local, sdata, data);
804 	if (local->ops->set_rekey_data)
805 		local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
806 	trace_drv_return_void(local);
807 }
808 
809 static inline void drv_event_callback(struct ieee80211_local *local,
810 				      struct ieee80211_sub_if_data *sdata,
811 				      const struct ieee80211_event *event)
812 {
813 	trace_drv_event_callback(local, sdata, event);
814 	if (local->ops->event_callback)
815 		local->ops->event_callback(&local->hw, &sdata->vif, event);
816 	trace_drv_return_void(local);
817 }
818 
819 static inline void
820 drv_release_buffered_frames(struct ieee80211_local *local,
821 			    struct sta_info *sta, u16 tids, int num_frames,
822 			    enum ieee80211_frame_release_type reason,
823 			    bool more_data)
824 {
825 	trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
826 					  reason, more_data);
827 	if (local->ops->release_buffered_frames)
828 		local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
829 						    num_frames, reason,
830 						    more_data);
831 	trace_drv_return_void(local);
832 }
833 
834 static inline void
835 drv_allow_buffered_frames(struct ieee80211_local *local,
836 			  struct sta_info *sta, u16 tids, int num_frames,
837 			  enum ieee80211_frame_release_type reason,
838 			  bool more_data)
839 {
840 	trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
841 					reason, more_data);
842 	if (local->ops->allow_buffered_frames)
843 		local->ops->allow_buffered_frames(&local->hw, &sta->sta,
844 						  tids, num_frames, reason,
845 						  more_data);
846 	trace_drv_return_void(local);
847 }
848 
849 static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
850 				      struct ieee80211_sub_if_data *sdata,
851 				      struct ieee80211_prep_tx_info *info)
852 {
853 	might_sleep();
854 
855 	if (!check_sdata_in_driver(sdata))
856 		return;
857 	WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
858 
859 	trace_drv_mgd_prepare_tx(local, sdata, info->duration,
860 				 info->subtype, info->success);
861 	if (local->ops->mgd_prepare_tx)
862 		local->ops->mgd_prepare_tx(&local->hw, &sdata->vif, info);
863 	trace_drv_return_void(local);
864 }
865 
866 static inline void drv_mgd_complete_tx(struct ieee80211_local *local,
867 				       struct ieee80211_sub_if_data *sdata,
868 				       struct ieee80211_prep_tx_info *info)
869 {
870 	might_sleep();
871 
872 	if (!check_sdata_in_driver(sdata))
873 		return;
874 	WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
875 
876 	trace_drv_mgd_complete_tx(local, sdata, info->duration,
877 				  info->subtype, info->success);
878 	if (local->ops->mgd_complete_tx)
879 		local->ops->mgd_complete_tx(&local->hw, &sdata->vif, info);
880 	trace_drv_return_void(local);
881 }
882 
883 static inline void
884 drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
885 			      struct ieee80211_sub_if_data *sdata)
886 {
887 	might_sleep();
888 
889 	if (!check_sdata_in_driver(sdata))
890 		return;
891 	WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
892 
893 	trace_drv_mgd_protect_tdls_discover(local, sdata);
894 	if (local->ops->mgd_protect_tdls_discover)
895 		local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
896 	trace_drv_return_void(local);
897 }
898 
899 static inline int drv_add_chanctx(struct ieee80211_local *local,
900 				  struct ieee80211_chanctx *ctx)
901 {
902 	int ret = -EOPNOTSUPP;
903 
904 	might_sleep();
905 
906 	trace_drv_add_chanctx(local, ctx);
907 	if (local->ops->add_chanctx)
908 		ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
909 	trace_drv_return_int(local, ret);
910 	if (!ret)
911 		ctx->driver_present = true;
912 
913 	return ret;
914 }
915 
916 static inline void drv_remove_chanctx(struct ieee80211_local *local,
917 				      struct ieee80211_chanctx *ctx)
918 {
919 	might_sleep();
920 
921 	if (WARN_ON(!ctx->driver_present))
922 		return;
923 
924 	trace_drv_remove_chanctx(local, ctx);
925 	if (local->ops->remove_chanctx)
926 		local->ops->remove_chanctx(&local->hw, &ctx->conf);
927 	trace_drv_return_void(local);
928 	ctx->driver_present = false;
929 }
930 
931 static inline void drv_change_chanctx(struct ieee80211_local *local,
932 				      struct ieee80211_chanctx *ctx,
933 				      u32 changed)
934 {
935 	might_sleep();
936 
937 	trace_drv_change_chanctx(local, ctx, changed);
938 	if (local->ops->change_chanctx) {
939 		WARN_ON_ONCE(!ctx->driver_present);
940 		local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
941 	}
942 	trace_drv_return_void(local);
943 }
944 
945 static inline void drv_verify_link_exists(struct ieee80211_sub_if_data *sdata,
946 					  struct ieee80211_bss_conf *link_conf)
947 {
948 	/* deflink always exists, so need to check only for other links */
949 	if (sdata->deflink.conf != link_conf)
950 		sdata_assert_lock(sdata);
951 }
952 
953 int drv_assign_vif_chanctx(struct ieee80211_local *local,
954 			   struct ieee80211_sub_if_data *sdata,
955 			   struct ieee80211_bss_conf *link_conf,
956 			   struct ieee80211_chanctx *ctx);
957 void drv_unassign_vif_chanctx(struct ieee80211_local *local,
958 			      struct ieee80211_sub_if_data *sdata,
959 			      struct ieee80211_bss_conf *link_conf,
960 			      struct ieee80211_chanctx *ctx);
961 int drv_switch_vif_chanctx(struct ieee80211_local *local,
962 			   struct ieee80211_vif_chanctx_switch *vifs,
963 			   int n_vifs, enum ieee80211_chanctx_switch_mode mode);
964 
965 static inline int drv_start_ap(struct ieee80211_local *local,
966 			       struct ieee80211_sub_if_data *sdata,
967 			       struct ieee80211_bss_conf *link_conf)
968 {
969 	int ret = 0;
970 
971 	/* make sure link_conf is protected */
972 	drv_verify_link_exists(sdata, link_conf);
973 
974 	might_sleep();
975 
976 	if (!check_sdata_in_driver(sdata))
977 		return -EIO;
978 
979 	trace_drv_start_ap(local, sdata, link_conf);
980 	if (local->ops->start_ap)
981 		ret = local->ops->start_ap(&local->hw, &sdata->vif, link_conf);
982 	trace_drv_return_int(local, ret);
983 	return ret;
984 }
985 
986 static inline void drv_stop_ap(struct ieee80211_local *local,
987 			       struct ieee80211_sub_if_data *sdata,
988 			       struct ieee80211_bss_conf *link_conf)
989 {
990 	/* make sure link_conf is protected */
991 	drv_verify_link_exists(sdata, link_conf);
992 
993 	if (!check_sdata_in_driver(sdata))
994 		return;
995 
996 	trace_drv_stop_ap(local, sdata, link_conf);
997 	if (local->ops->stop_ap)
998 		local->ops->stop_ap(&local->hw, &sdata->vif, link_conf);
999 	trace_drv_return_void(local);
1000 }
1001 
1002 static inline void
1003 drv_reconfig_complete(struct ieee80211_local *local,
1004 		      enum ieee80211_reconfig_type reconfig_type)
1005 {
1006 	might_sleep();
1007 
1008 	trace_drv_reconfig_complete(local, reconfig_type);
1009 	if (local->ops->reconfig_complete)
1010 		local->ops->reconfig_complete(&local->hw, reconfig_type);
1011 	trace_drv_return_void(local);
1012 }
1013 
1014 static inline void
1015 drv_set_default_unicast_key(struct ieee80211_local *local,
1016 			    struct ieee80211_sub_if_data *sdata,
1017 			    int key_idx)
1018 {
1019 	if (!check_sdata_in_driver(sdata))
1020 		return;
1021 
1022 	WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1023 
1024 	trace_drv_set_default_unicast_key(local, sdata, key_idx);
1025 	if (local->ops->set_default_unicast_key)
1026 		local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1027 						    key_idx);
1028 	trace_drv_return_void(local);
1029 }
1030 
1031 #if IS_ENABLED(CONFIG_IPV6)
1032 static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1033 					struct ieee80211_sub_if_data *sdata,
1034 					struct inet6_dev *idev)
1035 {
1036 	trace_drv_ipv6_addr_change(local, sdata);
1037 	if (local->ops->ipv6_addr_change)
1038 		local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1039 	trace_drv_return_void(local);
1040 }
1041 #endif
1042 
1043 static inline void
1044 drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1045 			  struct cfg80211_chan_def *chandef)
1046 {
1047 	struct ieee80211_local *local = sdata->local;
1048 
1049 	if (local->ops->channel_switch_beacon) {
1050 		trace_drv_channel_switch_beacon(local, sdata, chandef);
1051 		local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1052 						  chandef);
1053 	}
1054 }
1055 
1056 static inline int
1057 drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
1058 		       struct ieee80211_channel_switch *ch_switch)
1059 {
1060 	struct ieee80211_local *local = sdata->local;
1061 	int ret = 0;
1062 
1063 	if (!check_sdata_in_driver(sdata))
1064 		return -EIO;
1065 
1066 	trace_drv_pre_channel_switch(local, sdata, ch_switch);
1067 	if (local->ops->pre_channel_switch)
1068 		ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
1069 						     ch_switch);
1070 	trace_drv_return_int(local, ret);
1071 	return ret;
1072 }
1073 
1074 static inline int
1075 drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1076 {
1077 	struct ieee80211_local *local = sdata->local;
1078 	int ret = 0;
1079 
1080 	if (!check_sdata_in_driver(sdata))
1081 		return -EIO;
1082 
1083 	trace_drv_post_channel_switch(local, sdata);
1084 	if (local->ops->post_channel_switch)
1085 		ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1086 	trace_drv_return_int(local, ret);
1087 	return ret;
1088 }
1089 
1090 static inline void
1091 drv_abort_channel_switch(struct ieee80211_sub_if_data *sdata)
1092 {
1093 	struct ieee80211_local *local = sdata->local;
1094 
1095 	if (!check_sdata_in_driver(sdata))
1096 		return;
1097 
1098 	trace_drv_abort_channel_switch(local, sdata);
1099 
1100 	if (local->ops->abort_channel_switch)
1101 		local->ops->abort_channel_switch(&local->hw, &sdata->vif);
1102 }
1103 
1104 static inline void
1105 drv_channel_switch_rx_beacon(struct ieee80211_sub_if_data *sdata,
1106 			     struct ieee80211_channel_switch *ch_switch)
1107 {
1108 	struct ieee80211_local *local = sdata->local;
1109 
1110 	if (!check_sdata_in_driver(sdata))
1111 		return;
1112 
1113 	trace_drv_channel_switch_rx_beacon(local, sdata, ch_switch);
1114 	if (local->ops->channel_switch_rx_beacon)
1115 		local->ops->channel_switch_rx_beacon(&local->hw, &sdata->vif,
1116 						     ch_switch);
1117 }
1118 
1119 static inline int drv_join_ibss(struct ieee80211_local *local,
1120 				struct ieee80211_sub_if_data *sdata)
1121 {
1122 	int ret = 0;
1123 
1124 	might_sleep();
1125 	if (!check_sdata_in_driver(sdata))
1126 		return -EIO;
1127 
1128 	trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1129 	if (local->ops->join_ibss)
1130 		ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1131 	trace_drv_return_int(local, ret);
1132 	return ret;
1133 }
1134 
1135 static inline void drv_leave_ibss(struct ieee80211_local *local,
1136 				  struct ieee80211_sub_if_data *sdata)
1137 {
1138 	might_sleep();
1139 	if (!check_sdata_in_driver(sdata))
1140 		return;
1141 
1142 	trace_drv_leave_ibss(local, sdata);
1143 	if (local->ops->leave_ibss)
1144 		local->ops->leave_ibss(&local->hw, &sdata->vif);
1145 	trace_drv_return_void(local);
1146 }
1147 
1148 static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
1149 					      struct sta_info *sta)
1150 {
1151 	u32 ret = 0;
1152 
1153 	trace_drv_get_expected_throughput(&sta->sta);
1154 	if (local->ops->get_expected_throughput && sta->uploaded)
1155 		ret = local->ops->get_expected_throughput(&local->hw, &sta->sta);
1156 	trace_drv_return_u32(local, ret);
1157 
1158 	return ret;
1159 }
1160 
1161 static inline int drv_get_txpower(struct ieee80211_local *local,
1162 				  struct ieee80211_sub_if_data *sdata, int *dbm)
1163 {
1164 	int ret;
1165 
1166 	if (!local->ops->get_txpower)
1167 		return -EOPNOTSUPP;
1168 
1169 	ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
1170 	trace_drv_get_txpower(local, sdata, *dbm, ret);
1171 
1172 	return ret;
1173 }
1174 
1175 static inline int
1176 drv_tdls_channel_switch(struct ieee80211_local *local,
1177 			struct ieee80211_sub_if_data *sdata,
1178 			struct ieee80211_sta *sta, u8 oper_class,
1179 			struct cfg80211_chan_def *chandef,
1180 			struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
1181 {
1182 	int ret;
1183 
1184 	might_sleep();
1185 	if (!check_sdata_in_driver(sdata))
1186 		return -EIO;
1187 
1188 	if (!local->ops->tdls_channel_switch)
1189 		return -EOPNOTSUPP;
1190 
1191 	trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
1192 	ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
1193 					      oper_class, chandef, tmpl_skb,
1194 					      ch_sw_tm_ie);
1195 	trace_drv_return_int(local, ret);
1196 	return ret;
1197 }
1198 
1199 static inline void
1200 drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
1201 			       struct ieee80211_sub_if_data *sdata,
1202 			       struct ieee80211_sta *sta)
1203 {
1204 	might_sleep();
1205 	if (!check_sdata_in_driver(sdata))
1206 		return;
1207 
1208 	if (!local->ops->tdls_cancel_channel_switch)
1209 		return;
1210 
1211 	trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
1212 	local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
1213 	trace_drv_return_void(local);
1214 }
1215 
1216 static inline void
1217 drv_tdls_recv_channel_switch(struct ieee80211_local *local,
1218 			     struct ieee80211_sub_if_data *sdata,
1219 			     struct ieee80211_tdls_ch_sw_params *params)
1220 {
1221 	trace_drv_tdls_recv_channel_switch(local, sdata, params);
1222 	if (local->ops->tdls_recv_channel_switch)
1223 		local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
1224 						     params);
1225 	trace_drv_return_void(local);
1226 }
1227 
1228 static inline void drv_wake_tx_queue(struct ieee80211_local *local,
1229 				     struct txq_info *txq)
1230 {
1231 	struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
1232 
1233 	/* In reconfig don't transmit now, but mark for waking later */
1234 	if (local->in_reconfig) {
1235 		set_bit(IEEE80211_TXQ_DIRTY, &txq->flags);
1236 		return;
1237 	}
1238 
1239 	if (!check_sdata_in_driver(sdata))
1240 		return;
1241 
1242 	trace_drv_wake_tx_queue(local, sdata, txq);
1243 	local->ops->wake_tx_queue(&local->hw, &txq->txq);
1244 }
1245 
1246 static inline void schedule_and_wake_txq(struct ieee80211_local *local,
1247 					 struct txq_info *txqi)
1248 {
1249 	ieee80211_schedule_txq(&local->hw, &txqi->txq);
1250 	drv_wake_tx_queue(local, txqi);
1251 }
1252 
1253 static inline int drv_can_aggregate_in_amsdu(struct ieee80211_local *local,
1254 					     struct sk_buff *head,
1255 					     struct sk_buff *skb)
1256 {
1257 	if (!local->ops->can_aggregate_in_amsdu)
1258 		return true;
1259 
1260 	return local->ops->can_aggregate_in_amsdu(&local->hw, head, skb);
1261 }
1262 
1263 static inline int
1264 drv_get_ftm_responder_stats(struct ieee80211_local *local,
1265 			    struct ieee80211_sub_if_data *sdata,
1266 			    struct cfg80211_ftm_responder_stats *ftm_stats)
1267 {
1268 	u32 ret = -EOPNOTSUPP;
1269 
1270 	if (local->ops->get_ftm_responder_stats)
1271 		ret = local->ops->get_ftm_responder_stats(&local->hw,
1272 							 &sdata->vif,
1273 							 ftm_stats);
1274 	trace_drv_get_ftm_responder_stats(local, sdata, ftm_stats);
1275 
1276 	return ret;
1277 }
1278 
1279 static inline int drv_start_pmsr(struct ieee80211_local *local,
1280 				 struct ieee80211_sub_if_data *sdata,
1281 				 struct cfg80211_pmsr_request *request)
1282 {
1283 	int ret = -EOPNOTSUPP;
1284 
1285 	might_sleep();
1286 	if (!check_sdata_in_driver(sdata))
1287 		return -EIO;
1288 
1289 	trace_drv_start_pmsr(local, sdata);
1290 
1291 	if (local->ops->start_pmsr)
1292 		ret = local->ops->start_pmsr(&local->hw, &sdata->vif, request);
1293 	trace_drv_return_int(local, ret);
1294 
1295 	return ret;
1296 }
1297 
1298 static inline void drv_abort_pmsr(struct ieee80211_local *local,
1299 				  struct ieee80211_sub_if_data *sdata,
1300 				  struct cfg80211_pmsr_request *request)
1301 {
1302 	trace_drv_abort_pmsr(local, sdata);
1303 
1304 	might_sleep();
1305 	if (!check_sdata_in_driver(sdata))
1306 		return;
1307 
1308 	if (local->ops->abort_pmsr)
1309 		local->ops->abort_pmsr(&local->hw, &sdata->vif, request);
1310 	trace_drv_return_void(local);
1311 }
1312 
1313 static inline int drv_start_nan(struct ieee80211_local *local,
1314 				struct ieee80211_sub_if_data *sdata,
1315 				struct cfg80211_nan_conf *conf)
1316 {
1317 	int ret;
1318 
1319 	might_sleep();
1320 	check_sdata_in_driver(sdata);
1321 
1322 	trace_drv_start_nan(local, sdata, conf);
1323 	ret = local->ops->start_nan(&local->hw, &sdata->vif, conf);
1324 	trace_drv_return_int(local, ret);
1325 	return ret;
1326 }
1327 
1328 static inline void drv_stop_nan(struct ieee80211_local *local,
1329 				struct ieee80211_sub_if_data *sdata)
1330 {
1331 	might_sleep();
1332 	check_sdata_in_driver(sdata);
1333 
1334 	trace_drv_stop_nan(local, sdata);
1335 	local->ops->stop_nan(&local->hw, &sdata->vif);
1336 	trace_drv_return_void(local);
1337 }
1338 
1339 static inline int drv_nan_change_conf(struct ieee80211_local *local,
1340 				       struct ieee80211_sub_if_data *sdata,
1341 				       struct cfg80211_nan_conf *conf,
1342 				       u32 changes)
1343 {
1344 	int ret;
1345 
1346 	might_sleep();
1347 	check_sdata_in_driver(sdata);
1348 
1349 	if (!local->ops->nan_change_conf)
1350 		return -EOPNOTSUPP;
1351 
1352 	trace_drv_nan_change_conf(local, sdata, conf, changes);
1353 	ret = local->ops->nan_change_conf(&local->hw, &sdata->vif, conf,
1354 					  changes);
1355 	trace_drv_return_int(local, ret);
1356 
1357 	return ret;
1358 }
1359 
1360 static inline int drv_add_nan_func(struct ieee80211_local *local,
1361 				   struct ieee80211_sub_if_data *sdata,
1362 				   const struct cfg80211_nan_func *nan_func)
1363 {
1364 	int ret;
1365 
1366 	might_sleep();
1367 	check_sdata_in_driver(sdata);
1368 
1369 	if (!local->ops->add_nan_func)
1370 		return -EOPNOTSUPP;
1371 
1372 	trace_drv_add_nan_func(local, sdata, nan_func);
1373 	ret = local->ops->add_nan_func(&local->hw, &sdata->vif, nan_func);
1374 	trace_drv_return_int(local, ret);
1375 
1376 	return ret;
1377 }
1378 
1379 static inline void drv_del_nan_func(struct ieee80211_local *local,
1380 				   struct ieee80211_sub_if_data *sdata,
1381 				   u8 instance_id)
1382 {
1383 	might_sleep();
1384 	check_sdata_in_driver(sdata);
1385 
1386 	trace_drv_del_nan_func(local, sdata, instance_id);
1387 	if (local->ops->del_nan_func)
1388 		local->ops->del_nan_func(&local->hw, &sdata->vif, instance_id);
1389 	trace_drv_return_void(local);
1390 }
1391 
1392 static inline int drv_set_tid_config(struct ieee80211_local *local,
1393 				     struct ieee80211_sub_if_data *sdata,
1394 				     struct ieee80211_sta *sta,
1395 				     struct cfg80211_tid_config *tid_conf)
1396 {
1397 	int ret;
1398 
1399 	might_sleep();
1400 	ret = local->ops->set_tid_config(&local->hw, &sdata->vif, sta,
1401 					 tid_conf);
1402 	trace_drv_return_int(local, ret);
1403 
1404 	return ret;
1405 }
1406 
1407 static inline int drv_reset_tid_config(struct ieee80211_local *local,
1408 				       struct ieee80211_sub_if_data *sdata,
1409 				       struct ieee80211_sta *sta, u8 tids)
1410 {
1411 	int ret;
1412 
1413 	might_sleep();
1414 	ret = local->ops->reset_tid_config(&local->hw, &sdata->vif, sta, tids);
1415 	trace_drv_return_int(local, ret);
1416 
1417 	return ret;
1418 }
1419 
1420 static inline void drv_update_vif_offload(struct ieee80211_local *local,
1421 					  struct ieee80211_sub_if_data *sdata)
1422 {
1423 	might_sleep();
1424 	check_sdata_in_driver(sdata);
1425 
1426 	if (!local->ops->update_vif_offload)
1427 		return;
1428 
1429 	trace_drv_update_vif_offload(local, sdata);
1430 	local->ops->update_vif_offload(&local->hw, &sdata->vif);
1431 	trace_drv_return_void(local);
1432 }
1433 
1434 static inline void drv_sta_set_4addr(struct ieee80211_local *local,
1435 				     struct ieee80211_sub_if_data *sdata,
1436 				     struct ieee80211_sta *sta, bool enabled)
1437 {
1438 	sdata = get_bss_sdata(sdata);
1439 	if (!check_sdata_in_driver(sdata))
1440 		return;
1441 
1442 	trace_drv_sta_set_4addr(local, sdata, sta, enabled);
1443 	if (local->ops->sta_set_4addr)
1444 		local->ops->sta_set_4addr(&local->hw, &sdata->vif, sta, enabled);
1445 	trace_drv_return_void(local);
1446 }
1447 
1448 static inline void drv_sta_set_decap_offload(struct ieee80211_local *local,
1449 					     struct ieee80211_sub_if_data *sdata,
1450 					     struct ieee80211_sta *sta,
1451 					     bool enabled)
1452 {
1453 	sdata = get_bss_sdata(sdata);
1454 	if (!check_sdata_in_driver(sdata))
1455 		return;
1456 
1457 	trace_drv_sta_set_decap_offload(local, sdata, sta, enabled);
1458 	if (local->ops->sta_set_decap_offload)
1459 		local->ops->sta_set_decap_offload(&local->hw, &sdata->vif, sta,
1460 						  enabled);
1461 	trace_drv_return_void(local);
1462 }
1463 
1464 static inline void drv_add_twt_setup(struct ieee80211_local *local,
1465 				     struct ieee80211_sub_if_data *sdata,
1466 				     struct ieee80211_sta *sta,
1467 				     struct ieee80211_twt_setup *twt)
1468 {
1469 	struct ieee80211_twt_params *twt_agrt;
1470 
1471 	might_sleep();
1472 
1473 	if (!check_sdata_in_driver(sdata))
1474 		return;
1475 
1476 	twt_agrt = (void *)twt->params;
1477 
1478 	trace_drv_add_twt_setup(local, sta, twt, twt_agrt);
1479 	local->ops->add_twt_setup(&local->hw, sta, twt);
1480 	trace_drv_return_void(local);
1481 }
1482 
1483 static inline void drv_twt_teardown_request(struct ieee80211_local *local,
1484 					    struct ieee80211_sub_if_data *sdata,
1485 					    struct ieee80211_sta *sta,
1486 					    u8 flowid)
1487 {
1488 	might_sleep();
1489 	if (!check_sdata_in_driver(sdata))
1490 		return;
1491 
1492 	if (!local->ops->twt_teardown_request)
1493 		return;
1494 
1495 	trace_drv_twt_teardown_request(local, sta, flowid);
1496 	local->ops->twt_teardown_request(&local->hw, sta, flowid);
1497 	trace_drv_return_void(local);
1498 }
1499 
1500 static inline int drv_net_fill_forward_path(struct ieee80211_local *local,
1501 					    struct ieee80211_sub_if_data *sdata,
1502 					    struct ieee80211_sta *sta,
1503 					    struct net_device_path_ctx *ctx,
1504 					    struct net_device_path *path)
1505 {
1506 	int ret = -EOPNOTSUPP;
1507 
1508 	sdata = get_bss_sdata(sdata);
1509 	if (!check_sdata_in_driver(sdata))
1510 		return -EIO;
1511 
1512 	trace_drv_net_fill_forward_path(local, sdata, sta);
1513 	if (local->ops->net_fill_forward_path)
1514 		ret = local->ops->net_fill_forward_path(&local->hw,
1515 							&sdata->vif, sta,
1516 							ctx, path);
1517 	trace_drv_return_int(local, ret);
1518 
1519 	return ret;
1520 }
1521 
1522 static inline int drv_net_setup_tc(struct ieee80211_local *local,
1523 				   struct ieee80211_sub_if_data *sdata,
1524 				   struct net_device *dev,
1525 				   enum tc_setup_type type, void *type_data)
1526 {
1527 	int ret = -EOPNOTSUPP;
1528 
1529 	sdata = get_bss_sdata(sdata);
1530 	trace_drv_net_setup_tc(local, sdata, type);
1531 	if (local->ops->net_setup_tc)
1532 		ret = local->ops->net_setup_tc(&local->hw, &sdata->vif, dev,
1533 					       type, type_data);
1534 	trace_drv_return_int(local, ret);
1535 
1536 	return ret;
1537 }
1538 
1539 int drv_change_vif_links(struct ieee80211_local *local,
1540 			 struct ieee80211_sub_if_data *sdata,
1541 			 u16 old_links, u16 new_links,
1542 			 struct ieee80211_bss_conf *old[IEEE80211_MLD_MAX_NUM_LINKS]);
1543 int drv_change_sta_links(struct ieee80211_local *local,
1544 			 struct ieee80211_sub_if_data *sdata,
1545 			 struct ieee80211_sta *sta,
1546 			 u16 old_links, u16 new_links);
1547 
1548 #endif /* __MAC80211_DRIVER_OPS */
1549