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