xref: /openbmc/linux/net/mac80211/driver-ops.h (revision d0b73b48)
1 #ifndef __MAC80211_DRIVER_OPS
2 #define __MAC80211_DRIVER_OPS
3 
4 #include <net/mac80211.h>
5 #include "ieee80211_i.h"
6 #include "trace.h"
7 
8 static inline void check_sdata_in_driver(struct ieee80211_sub_if_data *sdata)
9 {
10 	WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER),
11 	     "%s:  Failed check-sdata-in-driver check, flags: 0x%x\n",
12 	     sdata->dev ? sdata->dev->name : sdata->name, sdata->flags);
13 }
14 
15 static inline struct ieee80211_sub_if_data *
16 get_bss_sdata(struct ieee80211_sub_if_data *sdata)
17 {
18 	if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
19 		sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
20 				     u.ap);
21 
22 	return sdata;
23 }
24 
25 static inline void drv_tx(struct ieee80211_local *local,
26 			  struct ieee80211_tx_control *control,
27 			  struct sk_buff *skb)
28 {
29 	local->ops->tx(&local->hw, control, skb);
30 }
31 
32 static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata,
33 				      u32 sset, u8 *data)
34 {
35 	struct ieee80211_local *local = sdata->local;
36 	if (local->ops->get_et_strings) {
37 		trace_drv_get_et_strings(local, sset);
38 		local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data);
39 		trace_drv_return_void(local);
40 	}
41 }
42 
43 static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata,
44 				    struct ethtool_stats *stats,
45 				    u64 *data)
46 {
47 	struct ieee80211_local *local = sdata->local;
48 	if (local->ops->get_et_stats) {
49 		trace_drv_get_et_stats(local);
50 		local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data);
51 		trace_drv_return_void(local);
52 	}
53 }
54 
55 static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata,
56 					int sset)
57 {
58 	struct ieee80211_local *local = sdata->local;
59 	int rv = 0;
60 	if (local->ops->get_et_sset_count) {
61 		trace_drv_get_et_sset_count(local, sset);
62 		rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif,
63 						   sset);
64 		trace_drv_return_int(local, rv);
65 	}
66 	return rv;
67 }
68 
69 static inline int drv_start(struct ieee80211_local *local)
70 {
71 	int ret;
72 
73 	might_sleep();
74 
75 	trace_drv_start(local);
76 	local->started = true;
77 	smp_mb();
78 	ret = local->ops->start(&local->hw);
79 	trace_drv_return_int(local, ret);
80 	return ret;
81 }
82 
83 static inline void drv_stop(struct ieee80211_local *local)
84 {
85 	might_sleep();
86 
87 	trace_drv_stop(local);
88 	local->ops->stop(&local->hw);
89 	trace_drv_return_void(local);
90 
91 	/* sync away all work on the tasklet before clearing started */
92 	tasklet_disable(&local->tasklet);
93 	tasklet_enable(&local->tasklet);
94 
95 	barrier();
96 
97 	local->started = false;
98 }
99 
100 #ifdef CONFIG_PM
101 static inline int drv_suspend(struct ieee80211_local *local,
102 			      struct cfg80211_wowlan *wowlan)
103 {
104 	int ret;
105 
106 	might_sleep();
107 
108 	trace_drv_suspend(local);
109 	ret = local->ops->suspend(&local->hw, wowlan);
110 	trace_drv_return_int(local, ret);
111 	return ret;
112 }
113 
114 static inline int drv_resume(struct ieee80211_local *local)
115 {
116 	int ret;
117 
118 	might_sleep();
119 
120 	trace_drv_resume(local);
121 	ret = local->ops->resume(&local->hw);
122 	trace_drv_return_int(local, ret);
123 	return ret;
124 }
125 
126 static inline void drv_set_wakeup(struct ieee80211_local *local,
127 				  bool enabled)
128 {
129 	might_sleep();
130 
131 	if (!local->ops->set_wakeup)
132 		return;
133 
134 	trace_drv_set_wakeup(local, enabled);
135 	local->ops->set_wakeup(&local->hw, enabled);
136 	trace_drv_return_void(local);
137 }
138 #endif
139 
140 static inline int drv_add_interface(struct ieee80211_local *local,
141 				    struct ieee80211_sub_if_data *sdata)
142 {
143 	int ret;
144 
145 	might_sleep();
146 
147 	if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
148 		    (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
149 		     !(local->hw.flags & IEEE80211_HW_WANT_MONITOR_VIF))))
150 		return -EINVAL;
151 
152 	trace_drv_add_interface(local, sdata);
153 	ret = local->ops->add_interface(&local->hw, &sdata->vif);
154 	trace_drv_return_int(local, ret);
155 
156 	if (ret == 0)
157 		sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
158 
159 	return ret;
160 }
161 
162 static inline int drv_change_interface(struct ieee80211_local *local,
163 				       struct ieee80211_sub_if_data *sdata,
164 				       enum nl80211_iftype type, bool p2p)
165 {
166 	int ret;
167 
168 	might_sleep();
169 
170 	check_sdata_in_driver(sdata);
171 
172 	trace_drv_change_interface(local, sdata, type, p2p);
173 	ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
174 	trace_drv_return_int(local, ret);
175 	return ret;
176 }
177 
178 static inline void drv_remove_interface(struct ieee80211_local *local,
179 					struct ieee80211_sub_if_data *sdata)
180 {
181 	might_sleep();
182 
183 	check_sdata_in_driver(sdata);
184 
185 	trace_drv_remove_interface(local, sdata);
186 	local->ops->remove_interface(&local->hw, &sdata->vif);
187 	sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER;
188 	trace_drv_return_void(local);
189 }
190 
191 static inline int drv_config(struct ieee80211_local *local, u32 changed)
192 {
193 	int ret;
194 
195 	might_sleep();
196 
197 	trace_drv_config(local, changed);
198 	ret = local->ops->config(&local->hw, changed);
199 	trace_drv_return_int(local, ret);
200 	return ret;
201 }
202 
203 static inline void drv_bss_info_changed(struct ieee80211_local *local,
204 					struct ieee80211_sub_if_data *sdata,
205 					struct ieee80211_bss_conf *info,
206 					u32 changed)
207 {
208 	might_sleep();
209 
210 	check_sdata_in_driver(sdata);
211 
212 	trace_drv_bss_info_changed(local, sdata, info, changed);
213 	if (local->ops->bss_info_changed)
214 		local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
215 	trace_drv_return_void(local);
216 }
217 
218 static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
219 					struct netdev_hw_addr_list *mc_list)
220 {
221 	u64 ret = 0;
222 
223 	trace_drv_prepare_multicast(local, mc_list->count);
224 
225 	if (local->ops->prepare_multicast)
226 		ret = local->ops->prepare_multicast(&local->hw, mc_list);
227 
228 	trace_drv_return_u64(local, ret);
229 
230 	return ret;
231 }
232 
233 static inline void drv_configure_filter(struct ieee80211_local *local,
234 					unsigned int changed_flags,
235 					unsigned int *total_flags,
236 					u64 multicast)
237 {
238 	might_sleep();
239 
240 	trace_drv_configure_filter(local, changed_flags, total_flags,
241 				   multicast);
242 	local->ops->configure_filter(&local->hw, changed_flags, total_flags,
243 				     multicast);
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 	check_sdata_in_driver(sdata);
270 
271 	trace_drv_set_key(local, cmd, sdata, sta, key);
272 	ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
273 	trace_drv_return_int(local, ret);
274 	return ret;
275 }
276 
277 static inline void drv_update_tkip_key(struct ieee80211_local *local,
278 				       struct ieee80211_sub_if_data *sdata,
279 				       struct ieee80211_key_conf *conf,
280 				       struct sta_info *sta, u32 iv32,
281 				       u16 *phase1key)
282 {
283 	struct ieee80211_sta *ista = NULL;
284 
285 	if (sta)
286 		ista = &sta->sta;
287 
288 	sdata = get_bss_sdata(sdata);
289 	check_sdata_in_driver(sdata);
290 
291 	trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
292 	if (local->ops->update_tkip_key)
293 		local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
294 					    ista, iv32, phase1key);
295 	trace_drv_return_void(local);
296 }
297 
298 static inline int drv_hw_scan(struct ieee80211_local *local,
299 			      struct ieee80211_sub_if_data *sdata,
300 			      struct cfg80211_scan_request *req)
301 {
302 	int ret;
303 
304 	might_sleep();
305 
306 	check_sdata_in_driver(sdata);
307 
308 	trace_drv_hw_scan(local, sdata);
309 	ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
310 	trace_drv_return_int(local, ret);
311 	return ret;
312 }
313 
314 static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
315 				      struct ieee80211_sub_if_data *sdata)
316 {
317 	might_sleep();
318 
319 	check_sdata_in_driver(sdata);
320 
321 	trace_drv_cancel_hw_scan(local, sdata);
322 	local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
323 	trace_drv_return_void(local);
324 }
325 
326 static inline int
327 drv_sched_scan_start(struct ieee80211_local *local,
328 		     struct ieee80211_sub_if_data *sdata,
329 		     struct cfg80211_sched_scan_request *req,
330 		     struct ieee80211_sched_scan_ies *ies)
331 {
332 	int ret;
333 
334 	might_sleep();
335 
336 	check_sdata_in_driver(sdata);
337 
338 	trace_drv_sched_scan_start(local, sdata);
339 	ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
340 					      req, ies);
341 	trace_drv_return_int(local, ret);
342 	return ret;
343 }
344 
345 static inline void drv_sched_scan_stop(struct ieee80211_local *local,
346 				       struct ieee80211_sub_if_data *sdata)
347 {
348 	might_sleep();
349 
350 	check_sdata_in_driver(sdata);
351 
352 	trace_drv_sched_scan_stop(local, sdata);
353 	local->ops->sched_scan_stop(&local->hw, &sdata->vif);
354 	trace_drv_return_void(local);
355 }
356 
357 static inline void drv_sw_scan_start(struct ieee80211_local *local)
358 {
359 	might_sleep();
360 
361 	trace_drv_sw_scan_start(local);
362 	if (local->ops->sw_scan_start)
363 		local->ops->sw_scan_start(&local->hw);
364 	trace_drv_return_void(local);
365 }
366 
367 static inline void drv_sw_scan_complete(struct ieee80211_local *local)
368 {
369 	might_sleep();
370 
371 	trace_drv_sw_scan_complete(local);
372 	if (local->ops->sw_scan_complete)
373 		local->ops->sw_scan_complete(&local->hw);
374 	trace_drv_return_void(local);
375 }
376 
377 static inline int drv_get_stats(struct ieee80211_local *local,
378 				struct ieee80211_low_level_stats *stats)
379 {
380 	int ret = -EOPNOTSUPP;
381 
382 	might_sleep();
383 
384 	if (local->ops->get_stats)
385 		ret = local->ops->get_stats(&local->hw, stats);
386 	trace_drv_get_stats(local, stats, ret);
387 
388 	return ret;
389 }
390 
391 static inline void drv_get_tkip_seq(struct ieee80211_local *local,
392 				    u8 hw_key_idx, u32 *iv32, u16 *iv16)
393 {
394 	if (local->ops->get_tkip_seq)
395 		local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
396 	trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
397 }
398 
399 static inline int drv_set_frag_threshold(struct ieee80211_local *local,
400 					u32 value)
401 {
402 	int ret = 0;
403 
404 	might_sleep();
405 
406 	trace_drv_set_frag_threshold(local, value);
407 	if (local->ops->set_frag_threshold)
408 		ret = local->ops->set_frag_threshold(&local->hw, value);
409 	trace_drv_return_int(local, ret);
410 	return ret;
411 }
412 
413 static inline int drv_set_rts_threshold(struct ieee80211_local *local,
414 					u32 value)
415 {
416 	int ret = 0;
417 
418 	might_sleep();
419 
420 	trace_drv_set_rts_threshold(local, value);
421 	if (local->ops->set_rts_threshold)
422 		ret = local->ops->set_rts_threshold(&local->hw, value);
423 	trace_drv_return_int(local, ret);
424 	return ret;
425 }
426 
427 static inline int drv_set_coverage_class(struct ieee80211_local *local,
428 					 u8 value)
429 {
430 	int ret = 0;
431 	might_sleep();
432 
433 	trace_drv_set_coverage_class(local, value);
434 	if (local->ops->set_coverage_class)
435 		local->ops->set_coverage_class(&local->hw, value);
436 	else
437 		ret = -EOPNOTSUPP;
438 
439 	trace_drv_return_int(local, ret);
440 	return ret;
441 }
442 
443 static inline void drv_sta_notify(struct ieee80211_local *local,
444 				  struct ieee80211_sub_if_data *sdata,
445 				  enum sta_notify_cmd cmd,
446 				  struct ieee80211_sta *sta)
447 {
448 	sdata = get_bss_sdata(sdata);
449 	check_sdata_in_driver(sdata);
450 
451 	trace_drv_sta_notify(local, sdata, cmd, sta);
452 	if (local->ops->sta_notify)
453 		local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
454 	trace_drv_return_void(local);
455 }
456 
457 static inline int drv_sta_add(struct ieee80211_local *local,
458 			      struct ieee80211_sub_if_data *sdata,
459 			      struct ieee80211_sta *sta)
460 {
461 	int ret = 0;
462 
463 	might_sleep();
464 
465 	sdata = get_bss_sdata(sdata);
466 	check_sdata_in_driver(sdata);
467 
468 	trace_drv_sta_add(local, sdata, sta);
469 	if (local->ops->sta_add)
470 		ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
471 
472 	trace_drv_return_int(local, ret);
473 
474 	return ret;
475 }
476 
477 static inline void drv_sta_remove(struct ieee80211_local *local,
478 				  struct ieee80211_sub_if_data *sdata,
479 				  struct ieee80211_sta *sta)
480 {
481 	might_sleep();
482 
483 	sdata = get_bss_sdata(sdata);
484 	check_sdata_in_driver(sdata);
485 
486 	trace_drv_sta_remove(local, sdata, sta);
487 	if (local->ops->sta_remove)
488 		local->ops->sta_remove(&local->hw, &sdata->vif, sta);
489 
490 	trace_drv_return_void(local);
491 }
492 
493 #ifdef CONFIG_MAC80211_DEBUGFS
494 static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
495 				       struct ieee80211_sub_if_data *sdata,
496 				       struct ieee80211_sta *sta,
497 				       struct dentry *dir)
498 {
499 	might_sleep();
500 
501 	sdata = get_bss_sdata(sdata);
502 	check_sdata_in_driver(sdata);
503 
504 	if (local->ops->sta_add_debugfs)
505 		local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
506 					    sta, dir);
507 }
508 
509 static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
510 					  struct ieee80211_sub_if_data *sdata,
511 					  struct ieee80211_sta *sta,
512 					  struct dentry *dir)
513 {
514 	might_sleep();
515 
516 	sdata = get_bss_sdata(sdata);
517 	check_sdata_in_driver(sdata);
518 
519 	if (local->ops->sta_remove_debugfs)
520 		local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
521 					       sta, dir);
522 }
523 #endif
524 
525 static inline __must_check
526 int drv_sta_state(struct ieee80211_local *local,
527 		  struct ieee80211_sub_if_data *sdata,
528 		  struct sta_info *sta,
529 		  enum ieee80211_sta_state old_state,
530 		  enum ieee80211_sta_state new_state)
531 {
532 	int ret = 0;
533 
534 	might_sleep();
535 
536 	sdata = get_bss_sdata(sdata);
537 	check_sdata_in_driver(sdata);
538 
539 	trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
540 	if (local->ops->sta_state) {
541 		ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta,
542 					    old_state, new_state);
543 	} else if (old_state == IEEE80211_STA_AUTH &&
544 		   new_state == IEEE80211_STA_ASSOC) {
545 		ret = drv_sta_add(local, sdata, &sta->sta);
546 		if (ret == 0)
547 			sta->uploaded = true;
548 	} else if (old_state == IEEE80211_STA_ASSOC &&
549 		   new_state == IEEE80211_STA_AUTH) {
550 		drv_sta_remove(local, sdata, &sta->sta);
551 	}
552 	trace_drv_return_int(local, ret);
553 	return ret;
554 }
555 
556 static inline void drv_sta_rc_update(struct ieee80211_local *local,
557 				     struct ieee80211_sub_if_data *sdata,
558 				     struct ieee80211_sta *sta, u32 changed)
559 {
560 	sdata = get_bss_sdata(sdata);
561 	check_sdata_in_driver(sdata);
562 
563 	WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED &&
564 		sdata->vif.type != NL80211_IFTYPE_ADHOC);
565 
566 	trace_drv_sta_rc_update(local, sdata, sta, changed);
567 	if (local->ops->sta_rc_update)
568 		local->ops->sta_rc_update(&local->hw, &sdata->vif,
569 					  sta, changed);
570 
571 	trace_drv_return_void(local);
572 }
573 
574 static inline int drv_conf_tx(struct ieee80211_local *local,
575 			      struct ieee80211_sub_if_data *sdata, u16 ac,
576 			      const struct ieee80211_tx_queue_params *params)
577 {
578 	int ret = -EOPNOTSUPP;
579 
580 	might_sleep();
581 
582 	check_sdata_in_driver(sdata);
583 
584 	trace_drv_conf_tx(local, sdata, ac, params);
585 	if (local->ops->conf_tx)
586 		ret = local->ops->conf_tx(&local->hw, &sdata->vif,
587 					  ac, params);
588 	trace_drv_return_int(local, ret);
589 	return ret;
590 }
591 
592 static inline u64 drv_get_tsf(struct ieee80211_local *local,
593 			      struct ieee80211_sub_if_data *sdata)
594 {
595 	u64 ret = -1ULL;
596 
597 	might_sleep();
598 
599 	check_sdata_in_driver(sdata);
600 
601 	trace_drv_get_tsf(local, sdata);
602 	if (local->ops->get_tsf)
603 		ret = local->ops->get_tsf(&local->hw, &sdata->vif);
604 	trace_drv_return_u64(local, ret);
605 	return ret;
606 }
607 
608 static inline void drv_set_tsf(struct ieee80211_local *local,
609 			       struct ieee80211_sub_if_data *sdata,
610 			       u64 tsf)
611 {
612 	might_sleep();
613 
614 	check_sdata_in_driver(sdata);
615 
616 	trace_drv_set_tsf(local, sdata, tsf);
617 	if (local->ops->set_tsf)
618 		local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
619 	trace_drv_return_void(local);
620 }
621 
622 static inline void drv_reset_tsf(struct ieee80211_local *local,
623 				 struct ieee80211_sub_if_data *sdata)
624 {
625 	might_sleep();
626 
627 	check_sdata_in_driver(sdata);
628 
629 	trace_drv_reset_tsf(local, sdata);
630 	if (local->ops->reset_tsf)
631 		local->ops->reset_tsf(&local->hw, &sdata->vif);
632 	trace_drv_return_void(local);
633 }
634 
635 static inline int drv_tx_last_beacon(struct ieee80211_local *local)
636 {
637 	int ret = 0; /* default unsupported op for less congestion */
638 
639 	might_sleep();
640 
641 	trace_drv_tx_last_beacon(local);
642 	if (local->ops->tx_last_beacon)
643 		ret = local->ops->tx_last_beacon(&local->hw);
644 	trace_drv_return_int(local, ret);
645 	return ret;
646 }
647 
648 static inline int drv_ampdu_action(struct ieee80211_local *local,
649 				   struct ieee80211_sub_if_data *sdata,
650 				   enum ieee80211_ampdu_mlme_action action,
651 				   struct ieee80211_sta *sta, u16 tid,
652 				   u16 *ssn, u8 buf_size)
653 {
654 	int ret = -EOPNOTSUPP;
655 
656 	might_sleep();
657 
658 	sdata = get_bss_sdata(sdata);
659 	check_sdata_in_driver(sdata);
660 
661 	trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
662 
663 	if (local->ops->ampdu_action)
664 		ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
665 					       sta, tid, ssn, buf_size);
666 
667 	trace_drv_return_int(local, ret);
668 
669 	return ret;
670 }
671 
672 static inline int drv_get_survey(struct ieee80211_local *local, int idx,
673 				struct survey_info *survey)
674 {
675 	int ret = -EOPNOTSUPP;
676 
677 	trace_drv_get_survey(local, idx, survey);
678 
679 	if (local->ops->get_survey)
680 		ret = local->ops->get_survey(&local->hw, idx, survey);
681 
682 	trace_drv_return_int(local, ret);
683 
684 	return ret;
685 }
686 
687 static inline void drv_rfkill_poll(struct ieee80211_local *local)
688 {
689 	might_sleep();
690 
691 	if (local->ops->rfkill_poll)
692 		local->ops->rfkill_poll(&local->hw);
693 }
694 
695 static inline void drv_flush(struct ieee80211_local *local, bool drop)
696 {
697 	might_sleep();
698 
699 	trace_drv_flush(local, drop);
700 	if (local->ops->flush)
701 		local->ops->flush(&local->hw, drop);
702 	trace_drv_return_void(local);
703 }
704 
705 static inline void drv_channel_switch(struct ieee80211_local *local,
706 				     struct ieee80211_channel_switch *ch_switch)
707 {
708 	might_sleep();
709 
710 	trace_drv_channel_switch(local, ch_switch);
711 	local->ops->channel_switch(&local->hw, ch_switch);
712 	trace_drv_return_void(local);
713 }
714 
715 
716 static inline int drv_set_antenna(struct ieee80211_local *local,
717 				  u32 tx_ant, u32 rx_ant)
718 {
719 	int ret = -EOPNOTSUPP;
720 	might_sleep();
721 	if (local->ops->set_antenna)
722 		ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
723 	trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
724 	return ret;
725 }
726 
727 static inline int drv_get_antenna(struct ieee80211_local *local,
728 				  u32 *tx_ant, u32 *rx_ant)
729 {
730 	int ret = -EOPNOTSUPP;
731 	might_sleep();
732 	if (local->ops->get_antenna)
733 		ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
734 	trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
735 	return ret;
736 }
737 
738 static inline int drv_remain_on_channel(struct ieee80211_local *local,
739 					struct ieee80211_sub_if_data *sdata,
740 					struct ieee80211_channel *chan,
741 					unsigned int duration)
742 {
743 	int ret;
744 
745 	might_sleep();
746 
747 	trace_drv_remain_on_channel(local, sdata, chan, duration);
748 	ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
749 					    chan, duration);
750 	trace_drv_return_int(local, ret);
751 
752 	return ret;
753 }
754 
755 static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
756 {
757 	int ret;
758 
759 	might_sleep();
760 
761 	trace_drv_cancel_remain_on_channel(local);
762 	ret = local->ops->cancel_remain_on_channel(&local->hw);
763 	trace_drv_return_int(local, ret);
764 
765 	return ret;
766 }
767 
768 static inline int drv_set_ringparam(struct ieee80211_local *local,
769 				    u32 tx, u32 rx)
770 {
771 	int ret = -ENOTSUPP;
772 
773 	might_sleep();
774 
775 	trace_drv_set_ringparam(local, tx, rx);
776 	if (local->ops->set_ringparam)
777 		ret = local->ops->set_ringparam(&local->hw, tx, rx);
778 	trace_drv_return_int(local, ret);
779 
780 	return ret;
781 }
782 
783 static inline void drv_get_ringparam(struct ieee80211_local *local,
784 				     u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
785 {
786 	might_sleep();
787 
788 	trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
789 	if (local->ops->get_ringparam)
790 		local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
791 	trace_drv_return_void(local);
792 }
793 
794 static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
795 {
796 	bool ret = false;
797 
798 	might_sleep();
799 
800 	trace_drv_tx_frames_pending(local);
801 	if (local->ops->tx_frames_pending)
802 		ret = local->ops->tx_frames_pending(&local->hw);
803 	trace_drv_return_bool(local, ret);
804 
805 	return ret;
806 }
807 
808 static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
809 				       struct ieee80211_sub_if_data *sdata,
810 				       const struct cfg80211_bitrate_mask *mask)
811 {
812 	int ret = -EOPNOTSUPP;
813 
814 	might_sleep();
815 
816 	check_sdata_in_driver(sdata);
817 
818 	trace_drv_set_bitrate_mask(local, sdata, mask);
819 	if (local->ops->set_bitrate_mask)
820 		ret = local->ops->set_bitrate_mask(&local->hw,
821 						   &sdata->vif, mask);
822 	trace_drv_return_int(local, ret);
823 
824 	return ret;
825 }
826 
827 static inline void drv_set_rekey_data(struct ieee80211_local *local,
828 				      struct ieee80211_sub_if_data *sdata,
829 				      struct cfg80211_gtk_rekey_data *data)
830 {
831 	check_sdata_in_driver(sdata);
832 
833 	trace_drv_set_rekey_data(local, sdata, data);
834 	if (local->ops->set_rekey_data)
835 		local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
836 	trace_drv_return_void(local);
837 }
838 
839 static inline void drv_rssi_callback(struct ieee80211_local *local,
840 				     const enum ieee80211_rssi_event event)
841 {
842 	trace_drv_rssi_callback(local, event);
843 	if (local->ops->rssi_callback)
844 		local->ops->rssi_callback(&local->hw, event);
845 	trace_drv_return_void(local);
846 }
847 
848 static inline void
849 drv_release_buffered_frames(struct ieee80211_local *local,
850 			    struct sta_info *sta, u16 tids, int num_frames,
851 			    enum ieee80211_frame_release_type reason,
852 			    bool more_data)
853 {
854 	trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
855 					  reason, more_data);
856 	if (local->ops->release_buffered_frames)
857 		local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
858 						    num_frames, reason,
859 						    more_data);
860 	trace_drv_return_void(local);
861 }
862 
863 static inline void
864 drv_allow_buffered_frames(struct ieee80211_local *local,
865 			  struct sta_info *sta, u16 tids, int num_frames,
866 			  enum ieee80211_frame_release_type reason,
867 			  bool more_data)
868 {
869 	trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
870 					reason, more_data);
871 	if (local->ops->allow_buffered_frames)
872 		local->ops->allow_buffered_frames(&local->hw, &sta->sta,
873 						  tids, num_frames, reason,
874 						  more_data);
875 	trace_drv_return_void(local);
876 }
877 
878 static inline int drv_get_rssi(struct ieee80211_local *local,
879 				struct ieee80211_sub_if_data *sdata,
880 				struct ieee80211_sta *sta,
881 				s8 *rssi_dbm)
882 {
883 	int ret;
884 
885 	might_sleep();
886 
887 	ret = local->ops->get_rssi(&local->hw, &sdata->vif, sta, rssi_dbm);
888 	trace_drv_get_rssi(local, sta, *rssi_dbm, ret);
889 
890 	return ret;
891 }
892 
893 static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
894 				      struct ieee80211_sub_if_data *sdata)
895 {
896 	might_sleep();
897 
898 	check_sdata_in_driver(sdata);
899 	WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
900 
901 	trace_drv_mgd_prepare_tx(local, sdata);
902 	if (local->ops->mgd_prepare_tx)
903 		local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
904 	trace_drv_return_void(local);
905 }
906 
907 static inline int drv_add_chanctx(struct ieee80211_local *local,
908 				  struct ieee80211_chanctx *ctx)
909 {
910 	int ret = -EOPNOTSUPP;
911 
912 	trace_drv_add_chanctx(local, ctx);
913 	if (local->ops->add_chanctx)
914 		ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
915 	trace_drv_return_int(local, ret);
916 
917 	return ret;
918 }
919 
920 static inline void drv_remove_chanctx(struct ieee80211_local *local,
921 				      struct ieee80211_chanctx *ctx)
922 {
923 	trace_drv_remove_chanctx(local, ctx);
924 	if (local->ops->remove_chanctx)
925 		local->ops->remove_chanctx(&local->hw, &ctx->conf);
926 	trace_drv_return_void(local);
927 }
928 
929 static inline void drv_change_chanctx(struct ieee80211_local *local,
930 				      struct ieee80211_chanctx *ctx,
931 				      u32 changed)
932 {
933 	trace_drv_change_chanctx(local, ctx, changed);
934 	if (local->ops->change_chanctx)
935 		local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
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 					 struct ieee80211_chanctx *ctx)
942 {
943 	int ret = 0;
944 
945 	check_sdata_in_driver(sdata);
946 
947 	trace_drv_assign_vif_chanctx(local, sdata, ctx);
948 	if (local->ops->assign_vif_chanctx)
949 		ret = local->ops->assign_vif_chanctx(&local->hw,
950 						     &sdata->vif,
951 						     &ctx->conf);
952 	trace_drv_return_int(local, ret);
953 
954 	return ret;
955 }
956 
957 static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
958 					    struct ieee80211_sub_if_data *sdata,
959 					    struct ieee80211_chanctx *ctx)
960 {
961 	check_sdata_in_driver(sdata);
962 
963 	trace_drv_unassign_vif_chanctx(local, sdata, ctx);
964 	if (local->ops->unassign_vif_chanctx)
965 		local->ops->unassign_vif_chanctx(&local->hw,
966 						 &sdata->vif,
967 						 &ctx->conf);
968 	trace_drv_return_void(local);
969 }
970 
971 static inline int drv_start_ap(struct ieee80211_local *local,
972 			       struct ieee80211_sub_if_data *sdata)
973 {
974 	int ret = 0;
975 
976 	check_sdata_in_driver(sdata);
977 
978 	trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
979 	if (local->ops->start_ap)
980 		ret = local->ops->start_ap(&local->hw, &sdata->vif);
981 	trace_drv_return_int(local, ret);
982 	return ret;
983 }
984 
985 static inline void drv_stop_ap(struct ieee80211_local *local,
986 			       struct ieee80211_sub_if_data *sdata)
987 {
988 	check_sdata_in_driver(sdata);
989 
990 	trace_drv_stop_ap(local, sdata);
991 	if (local->ops->stop_ap)
992 		local->ops->stop_ap(&local->hw, &sdata->vif);
993 	trace_drv_return_void(local);
994 }
995 
996 static inline void drv_restart_complete(struct ieee80211_local *local)
997 {
998 	might_sleep();
999 
1000 	trace_drv_restart_complete(local);
1001 	if (local->ops->restart_complete)
1002 		local->ops->restart_complete(&local->hw);
1003 	trace_drv_return_void(local);
1004 }
1005 
1006 #endif /* __MAC80211_DRIVER_OPS */
1007