Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[deliverable/linux.git] / net / mac80211 / driver-ops.h
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 !(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE))))
151 return -EINVAL;
152
153 trace_drv_add_interface(local, sdata);
154 ret = local->ops->add_interface(&local->hw, &sdata->vif);
155 trace_drv_return_int(local, ret);
156
157 if (ret == 0)
158 sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
159
160 return ret;
161 }
162
163 static inline int drv_change_interface(struct ieee80211_local *local,
164 struct ieee80211_sub_if_data *sdata,
165 enum nl80211_iftype type, bool p2p)
166 {
167 int ret;
168
169 might_sleep();
170
171 check_sdata_in_driver(sdata);
172
173 trace_drv_change_interface(local, sdata, type, p2p);
174 ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
175 trace_drv_return_int(local, ret);
176 return ret;
177 }
178
179 static inline void drv_remove_interface(struct ieee80211_local *local,
180 struct ieee80211_sub_if_data *sdata)
181 {
182 might_sleep();
183
184 check_sdata_in_driver(sdata);
185
186 trace_drv_remove_interface(local, sdata);
187 local->ops->remove_interface(&local->hw, &sdata->vif);
188 sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER;
189 trace_drv_return_void(local);
190 }
191
192 static inline int drv_config(struct ieee80211_local *local, u32 changed)
193 {
194 int ret;
195
196 might_sleep();
197
198 trace_drv_config(local, changed);
199 ret = local->ops->config(&local->hw, changed);
200 trace_drv_return_int(local, ret);
201 return ret;
202 }
203
204 static inline void drv_bss_info_changed(struct ieee80211_local *local,
205 struct ieee80211_sub_if_data *sdata,
206 struct ieee80211_bss_conf *info,
207 u32 changed)
208 {
209 might_sleep();
210
211 if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
212 BSS_CHANGED_BEACON_ENABLED) &&
213 sdata->vif.type != NL80211_IFTYPE_AP &&
214 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
215 sdata->vif.type != NL80211_IFTYPE_MESH_POINT))
216 return;
217
218 if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
219 sdata->vif.type == NL80211_IFTYPE_MONITOR))
220 return;
221
222 check_sdata_in_driver(sdata);
223
224 trace_drv_bss_info_changed(local, sdata, info, changed);
225 if (local->ops->bss_info_changed)
226 local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
227 trace_drv_return_void(local);
228 }
229
230 static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
231 struct netdev_hw_addr_list *mc_list)
232 {
233 u64 ret = 0;
234
235 trace_drv_prepare_multicast(local, mc_list->count);
236
237 if (local->ops->prepare_multicast)
238 ret = local->ops->prepare_multicast(&local->hw, mc_list);
239
240 trace_drv_return_u64(local, ret);
241
242 return ret;
243 }
244
245 static inline void drv_configure_filter(struct ieee80211_local *local,
246 unsigned int changed_flags,
247 unsigned int *total_flags,
248 u64 multicast)
249 {
250 might_sleep();
251
252 trace_drv_configure_filter(local, changed_flags, total_flags,
253 multicast);
254 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
255 multicast);
256 trace_drv_return_void(local);
257 }
258
259 static inline int drv_set_tim(struct ieee80211_local *local,
260 struct ieee80211_sta *sta, bool set)
261 {
262 int ret = 0;
263 trace_drv_set_tim(local, sta, set);
264 if (local->ops->set_tim)
265 ret = local->ops->set_tim(&local->hw, sta, set);
266 trace_drv_return_int(local, ret);
267 return ret;
268 }
269
270 static inline int drv_set_key(struct ieee80211_local *local,
271 enum set_key_cmd cmd,
272 struct ieee80211_sub_if_data *sdata,
273 struct ieee80211_sta *sta,
274 struct ieee80211_key_conf *key)
275 {
276 int ret;
277
278 might_sleep();
279
280 sdata = get_bss_sdata(sdata);
281 check_sdata_in_driver(sdata);
282
283 trace_drv_set_key(local, cmd, sdata, sta, key);
284 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
285 trace_drv_return_int(local, ret);
286 return ret;
287 }
288
289 static inline void drv_update_tkip_key(struct ieee80211_local *local,
290 struct ieee80211_sub_if_data *sdata,
291 struct ieee80211_key_conf *conf,
292 struct sta_info *sta, u32 iv32,
293 u16 *phase1key)
294 {
295 struct ieee80211_sta *ista = NULL;
296
297 if (sta)
298 ista = &sta->sta;
299
300 sdata = get_bss_sdata(sdata);
301 check_sdata_in_driver(sdata);
302
303 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
304 if (local->ops->update_tkip_key)
305 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
306 ista, iv32, phase1key);
307 trace_drv_return_void(local);
308 }
309
310 static inline int drv_hw_scan(struct ieee80211_local *local,
311 struct ieee80211_sub_if_data *sdata,
312 struct cfg80211_scan_request *req)
313 {
314 int ret;
315
316 might_sleep();
317
318 check_sdata_in_driver(sdata);
319
320 trace_drv_hw_scan(local, sdata);
321 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
322 trace_drv_return_int(local, ret);
323 return ret;
324 }
325
326 static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
327 struct ieee80211_sub_if_data *sdata)
328 {
329 might_sleep();
330
331 check_sdata_in_driver(sdata);
332
333 trace_drv_cancel_hw_scan(local, sdata);
334 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
335 trace_drv_return_void(local);
336 }
337
338 static inline int
339 drv_sched_scan_start(struct ieee80211_local *local,
340 struct ieee80211_sub_if_data *sdata,
341 struct cfg80211_sched_scan_request *req,
342 struct ieee80211_sched_scan_ies *ies)
343 {
344 int ret;
345
346 might_sleep();
347
348 check_sdata_in_driver(sdata);
349
350 trace_drv_sched_scan_start(local, sdata);
351 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
352 req, ies);
353 trace_drv_return_int(local, ret);
354 return ret;
355 }
356
357 static inline int drv_sched_scan_stop(struct ieee80211_local *local,
358 struct ieee80211_sub_if_data *sdata)
359 {
360 int ret;
361
362 might_sleep();
363
364 check_sdata_in_driver(sdata);
365
366 trace_drv_sched_scan_stop(local, sdata);
367 ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
368 trace_drv_return_int(local, ret);
369
370 return ret;
371 }
372
373 static inline void drv_sw_scan_start(struct ieee80211_local *local)
374 {
375 might_sleep();
376
377 trace_drv_sw_scan_start(local);
378 if (local->ops->sw_scan_start)
379 local->ops->sw_scan_start(&local->hw);
380 trace_drv_return_void(local);
381 }
382
383 static inline void drv_sw_scan_complete(struct ieee80211_local *local)
384 {
385 might_sleep();
386
387 trace_drv_sw_scan_complete(local);
388 if (local->ops->sw_scan_complete)
389 local->ops->sw_scan_complete(&local->hw);
390 trace_drv_return_void(local);
391 }
392
393 static inline int drv_get_stats(struct ieee80211_local *local,
394 struct ieee80211_low_level_stats *stats)
395 {
396 int ret = -EOPNOTSUPP;
397
398 might_sleep();
399
400 if (local->ops->get_stats)
401 ret = local->ops->get_stats(&local->hw, stats);
402 trace_drv_get_stats(local, stats, ret);
403
404 return ret;
405 }
406
407 static inline void drv_get_tkip_seq(struct ieee80211_local *local,
408 u8 hw_key_idx, u32 *iv32, u16 *iv16)
409 {
410 if (local->ops->get_tkip_seq)
411 local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
412 trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
413 }
414
415 static inline int drv_set_frag_threshold(struct ieee80211_local *local,
416 u32 value)
417 {
418 int ret = 0;
419
420 might_sleep();
421
422 trace_drv_set_frag_threshold(local, value);
423 if (local->ops->set_frag_threshold)
424 ret = local->ops->set_frag_threshold(&local->hw, value);
425 trace_drv_return_int(local, ret);
426 return ret;
427 }
428
429 static inline int drv_set_rts_threshold(struct ieee80211_local *local,
430 u32 value)
431 {
432 int ret = 0;
433
434 might_sleep();
435
436 trace_drv_set_rts_threshold(local, value);
437 if (local->ops->set_rts_threshold)
438 ret = local->ops->set_rts_threshold(&local->hw, value);
439 trace_drv_return_int(local, ret);
440 return ret;
441 }
442
443 static inline int drv_set_coverage_class(struct ieee80211_local *local,
444 u8 value)
445 {
446 int ret = 0;
447 might_sleep();
448
449 trace_drv_set_coverage_class(local, value);
450 if (local->ops->set_coverage_class)
451 local->ops->set_coverage_class(&local->hw, value);
452 else
453 ret = -EOPNOTSUPP;
454
455 trace_drv_return_int(local, ret);
456 return ret;
457 }
458
459 static inline void drv_sta_notify(struct ieee80211_local *local,
460 struct ieee80211_sub_if_data *sdata,
461 enum sta_notify_cmd cmd,
462 struct ieee80211_sta *sta)
463 {
464 sdata = get_bss_sdata(sdata);
465 check_sdata_in_driver(sdata);
466
467 trace_drv_sta_notify(local, sdata, cmd, sta);
468 if (local->ops->sta_notify)
469 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
470 trace_drv_return_void(local);
471 }
472
473 static inline int drv_sta_add(struct ieee80211_local *local,
474 struct ieee80211_sub_if_data *sdata,
475 struct ieee80211_sta *sta)
476 {
477 int ret = 0;
478
479 might_sleep();
480
481 sdata = get_bss_sdata(sdata);
482 check_sdata_in_driver(sdata);
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 check_sdata_in_driver(sdata);
501
502 trace_drv_sta_remove(local, sdata, sta);
503 if (local->ops->sta_remove)
504 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
505
506 trace_drv_return_void(local);
507 }
508
509 #ifdef CONFIG_MAC80211_DEBUGFS
510 static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
511 struct ieee80211_sub_if_data *sdata,
512 struct ieee80211_sta *sta,
513 struct dentry *dir)
514 {
515 might_sleep();
516
517 sdata = get_bss_sdata(sdata);
518 check_sdata_in_driver(sdata);
519
520 if (local->ops->sta_add_debugfs)
521 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
522 sta, dir);
523 }
524
525 static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
526 struct ieee80211_sub_if_data *sdata,
527 struct ieee80211_sta *sta,
528 struct dentry *dir)
529 {
530 might_sleep();
531
532 sdata = get_bss_sdata(sdata);
533 check_sdata_in_driver(sdata);
534
535 if (local->ops->sta_remove_debugfs)
536 local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
537 sta, dir);
538 }
539 #endif
540
541 static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
542 struct ieee80211_sub_if_data *sdata,
543 struct sta_info *sta)
544 {
545 might_sleep();
546
547 sdata = get_bss_sdata(sdata);
548 check_sdata_in_driver(sdata);
549
550 trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
551 if (local->ops->sta_pre_rcu_remove)
552 local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
553 &sta->sta);
554 trace_drv_return_void(local);
555 }
556
557 static inline __must_check
558 int drv_sta_state(struct ieee80211_local *local,
559 struct ieee80211_sub_if_data *sdata,
560 struct sta_info *sta,
561 enum ieee80211_sta_state old_state,
562 enum ieee80211_sta_state new_state)
563 {
564 int ret = 0;
565
566 might_sleep();
567
568 sdata = get_bss_sdata(sdata);
569 check_sdata_in_driver(sdata);
570
571 trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
572 if (local->ops->sta_state) {
573 ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta,
574 old_state, new_state);
575 } else if (old_state == IEEE80211_STA_AUTH &&
576 new_state == IEEE80211_STA_ASSOC) {
577 ret = drv_sta_add(local, sdata, &sta->sta);
578 if (ret == 0)
579 sta->uploaded = true;
580 } else if (old_state == IEEE80211_STA_ASSOC &&
581 new_state == IEEE80211_STA_AUTH) {
582 drv_sta_remove(local, sdata, &sta->sta);
583 }
584 trace_drv_return_int(local, ret);
585 return ret;
586 }
587
588 static inline void drv_sta_rc_update(struct ieee80211_local *local,
589 struct ieee80211_sub_if_data *sdata,
590 struct ieee80211_sta *sta, u32 changed)
591 {
592 sdata = get_bss_sdata(sdata);
593 check_sdata_in_driver(sdata);
594
595 WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED &&
596 (sdata->vif.type != NL80211_IFTYPE_ADHOC &&
597 sdata->vif.type != NL80211_IFTYPE_MESH_POINT));
598
599 trace_drv_sta_rc_update(local, sdata, sta, changed);
600 if (local->ops->sta_rc_update)
601 local->ops->sta_rc_update(&local->hw, &sdata->vif,
602 sta, changed);
603
604 trace_drv_return_void(local);
605 }
606
607 static inline int drv_conf_tx(struct ieee80211_local *local,
608 struct ieee80211_sub_if_data *sdata, u16 ac,
609 const struct ieee80211_tx_queue_params *params)
610 {
611 int ret = -EOPNOTSUPP;
612
613 might_sleep();
614
615 check_sdata_in_driver(sdata);
616
617 trace_drv_conf_tx(local, sdata, ac, params);
618 if (local->ops->conf_tx)
619 ret = local->ops->conf_tx(&local->hw, &sdata->vif,
620 ac, params);
621 trace_drv_return_int(local, ret);
622 return ret;
623 }
624
625 static inline u64 drv_get_tsf(struct ieee80211_local *local,
626 struct ieee80211_sub_if_data *sdata)
627 {
628 u64 ret = -1ULL;
629
630 might_sleep();
631
632 check_sdata_in_driver(sdata);
633
634 trace_drv_get_tsf(local, sdata);
635 if (local->ops->get_tsf)
636 ret = local->ops->get_tsf(&local->hw, &sdata->vif);
637 trace_drv_return_u64(local, ret);
638 return ret;
639 }
640
641 static inline void drv_set_tsf(struct ieee80211_local *local,
642 struct ieee80211_sub_if_data *sdata,
643 u64 tsf)
644 {
645 might_sleep();
646
647 check_sdata_in_driver(sdata);
648
649 trace_drv_set_tsf(local, sdata, tsf);
650 if (local->ops->set_tsf)
651 local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
652 trace_drv_return_void(local);
653 }
654
655 static inline void drv_reset_tsf(struct ieee80211_local *local,
656 struct ieee80211_sub_if_data *sdata)
657 {
658 might_sleep();
659
660 check_sdata_in_driver(sdata);
661
662 trace_drv_reset_tsf(local, sdata);
663 if (local->ops->reset_tsf)
664 local->ops->reset_tsf(&local->hw, &sdata->vif);
665 trace_drv_return_void(local);
666 }
667
668 static inline int drv_tx_last_beacon(struct ieee80211_local *local)
669 {
670 int ret = 0; /* default unsupported op for less congestion */
671
672 might_sleep();
673
674 trace_drv_tx_last_beacon(local);
675 if (local->ops->tx_last_beacon)
676 ret = local->ops->tx_last_beacon(&local->hw);
677 trace_drv_return_int(local, ret);
678 return ret;
679 }
680
681 static inline int drv_ampdu_action(struct ieee80211_local *local,
682 struct ieee80211_sub_if_data *sdata,
683 enum ieee80211_ampdu_mlme_action action,
684 struct ieee80211_sta *sta, u16 tid,
685 u16 *ssn, u8 buf_size)
686 {
687 int ret = -EOPNOTSUPP;
688
689 might_sleep();
690
691 sdata = get_bss_sdata(sdata);
692 check_sdata_in_driver(sdata);
693
694 trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
695
696 if (local->ops->ampdu_action)
697 ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
698 sta, tid, ssn, buf_size);
699
700 trace_drv_return_int(local, ret);
701
702 return ret;
703 }
704
705 static inline int drv_get_survey(struct ieee80211_local *local, int idx,
706 struct survey_info *survey)
707 {
708 int ret = -EOPNOTSUPP;
709
710 trace_drv_get_survey(local, idx, survey);
711
712 if (local->ops->get_survey)
713 ret = local->ops->get_survey(&local->hw, idx, survey);
714
715 trace_drv_return_int(local, ret);
716
717 return ret;
718 }
719
720 static inline void drv_rfkill_poll(struct ieee80211_local *local)
721 {
722 might_sleep();
723
724 if (local->ops->rfkill_poll)
725 local->ops->rfkill_poll(&local->hw);
726 }
727
728 static inline void drv_flush(struct ieee80211_local *local,
729 struct ieee80211_sub_if_data *sdata,
730 u32 queues, bool drop)
731 {
732 struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
733
734 might_sleep();
735
736 if (sdata)
737 check_sdata_in_driver(sdata);
738
739 trace_drv_flush(local, queues, drop);
740 if (local->ops->flush)
741 local->ops->flush(&local->hw, vif, queues, drop);
742 trace_drv_return_void(local);
743 }
744
745 static inline void drv_channel_switch(struct ieee80211_local *local,
746 struct ieee80211_channel_switch *ch_switch)
747 {
748 might_sleep();
749
750 trace_drv_channel_switch(local, ch_switch);
751 local->ops->channel_switch(&local->hw, ch_switch);
752 trace_drv_return_void(local);
753 }
754
755
756 static inline int drv_set_antenna(struct ieee80211_local *local,
757 u32 tx_ant, u32 rx_ant)
758 {
759 int ret = -EOPNOTSUPP;
760 might_sleep();
761 if (local->ops->set_antenna)
762 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
763 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
764 return ret;
765 }
766
767 static inline int drv_get_antenna(struct ieee80211_local *local,
768 u32 *tx_ant, u32 *rx_ant)
769 {
770 int ret = -EOPNOTSUPP;
771 might_sleep();
772 if (local->ops->get_antenna)
773 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
774 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
775 return ret;
776 }
777
778 static inline int drv_remain_on_channel(struct ieee80211_local *local,
779 struct ieee80211_sub_if_data *sdata,
780 struct ieee80211_channel *chan,
781 unsigned int duration,
782 enum ieee80211_roc_type type)
783 {
784 int ret;
785
786 might_sleep();
787
788 trace_drv_remain_on_channel(local, sdata, chan, duration, type);
789 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
790 chan, duration, type);
791 trace_drv_return_int(local, ret);
792
793 return ret;
794 }
795
796 static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
797 {
798 int ret;
799
800 might_sleep();
801
802 trace_drv_cancel_remain_on_channel(local);
803 ret = local->ops->cancel_remain_on_channel(&local->hw);
804 trace_drv_return_int(local, ret);
805
806 return ret;
807 }
808
809 static inline int drv_set_ringparam(struct ieee80211_local *local,
810 u32 tx, u32 rx)
811 {
812 int ret = -ENOTSUPP;
813
814 might_sleep();
815
816 trace_drv_set_ringparam(local, tx, rx);
817 if (local->ops->set_ringparam)
818 ret = local->ops->set_ringparam(&local->hw, tx, rx);
819 trace_drv_return_int(local, ret);
820
821 return ret;
822 }
823
824 static inline void drv_get_ringparam(struct ieee80211_local *local,
825 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
826 {
827 might_sleep();
828
829 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
830 if (local->ops->get_ringparam)
831 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
832 trace_drv_return_void(local);
833 }
834
835 static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
836 {
837 bool ret = false;
838
839 might_sleep();
840
841 trace_drv_tx_frames_pending(local);
842 if (local->ops->tx_frames_pending)
843 ret = local->ops->tx_frames_pending(&local->hw);
844 trace_drv_return_bool(local, ret);
845
846 return ret;
847 }
848
849 static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
850 struct ieee80211_sub_if_data *sdata,
851 const struct cfg80211_bitrate_mask *mask)
852 {
853 int ret = -EOPNOTSUPP;
854
855 might_sleep();
856
857 check_sdata_in_driver(sdata);
858
859 trace_drv_set_bitrate_mask(local, sdata, mask);
860 if (local->ops->set_bitrate_mask)
861 ret = local->ops->set_bitrate_mask(&local->hw,
862 &sdata->vif, mask);
863 trace_drv_return_int(local, ret);
864
865 return ret;
866 }
867
868 static inline void drv_set_rekey_data(struct ieee80211_local *local,
869 struct ieee80211_sub_if_data *sdata,
870 struct cfg80211_gtk_rekey_data *data)
871 {
872 check_sdata_in_driver(sdata);
873
874 trace_drv_set_rekey_data(local, sdata, data);
875 if (local->ops->set_rekey_data)
876 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
877 trace_drv_return_void(local);
878 }
879
880 static inline void drv_rssi_callback(struct ieee80211_local *local,
881 struct ieee80211_sub_if_data *sdata,
882 const enum ieee80211_rssi_event event)
883 {
884 trace_drv_rssi_callback(local, sdata, event);
885 if (local->ops->rssi_callback)
886 local->ops->rssi_callback(&local->hw, &sdata->vif, event);
887 trace_drv_return_void(local);
888 }
889
890 static inline void
891 drv_release_buffered_frames(struct ieee80211_local *local,
892 struct sta_info *sta, u16 tids, int num_frames,
893 enum ieee80211_frame_release_type reason,
894 bool more_data)
895 {
896 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
897 reason, more_data);
898 if (local->ops->release_buffered_frames)
899 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
900 num_frames, reason,
901 more_data);
902 trace_drv_return_void(local);
903 }
904
905 static inline void
906 drv_allow_buffered_frames(struct ieee80211_local *local,
907 struct sta_info *sta, u16 tids, int num_frames,
908 enum ieee80211_frame_release_type reason,
909 bool more_data)
910 {
911 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
912 reason, more_data);
913 if (local->ops->allow_buffered_frames)
914 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
915 tids, num_frames, reason,
916 more_data);
917 trace_drv_return_void(local);
918 }
919
920 static inline int drv_get_rssi(struct ieee80211_local *local,
921 struct ieee80211_sub_if_data *sdata,
922 struct ieee80211_sta *sta,
923 s8 *rssi_dbm)
924 {
925 int ret;
926
927 might_sleep();
928
929 ret = local->ops->get_rssi(&local->hw, &sdata->vif, sta, rssi_dbm);
930 trace_drv_get_rssi(local, sta, *rssi_dbm, ret);
931
932 return ret;
933 }
934
935 static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
936 struct ieee80211_sub_if_data *sdata)
937 {
938 might_sleep();
939
940 check_sdata_in_driver(sdata);
941 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
942
943 trace_drv_mgd_prepare_tx(local, sdata);
944 if (local->ops->mgd_prepare_tx)
945 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
946 trace_drv_return_void(local);
947 }
948
949 static inline int drv_add_chanctx(struct ieee80211_local *local,
950 struct ieee80211_chanctx *ctx)
951 {
952 int ret = -EOPNOTSUPP;
953
954 trace_drv_add_chanctx(local, ctx);
955 if (local->ops->add_chanctx)
956 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
957 trace_drv_return_int(local, ret);
958 if (!ret)
959 ctx->driver_present = true;
960
961 return ret;
962 }
963
964 static inline void drv_remove_chanctx(struct ieee80211_local *local,
965 struct ieee80211_chanctx *ctx)
966 {
967 trace_drv_remove_chanctx(local, ctx);
968 if (local->ops->remove_chanctx)
969 local->ops->remove_chanctx(&local->hw, &ctx->conf);
970 trace_drv_return_void(local);
971 ctx->driver_present = false;
972 }
973
974 static inline void drv_change_chanctx(struct ieee80211_local *local,
975 struct ieee80211_chanctx *ctx,
976 u32 changed)
977 {
978 trace_drv_change_chanctx(local, ctx, changed);
979 if (local->ops->change_chanctx) {
980 WARN_ON_ONCE(!ctx->driver_present);
981 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
982 }
983 trace_drv_return_void(local);
984 }
985
986 static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
987 struct ieee80211_sub_if_data *sdata,
988 struct ieee80211_chanctx *ctx)
989 {
990 int ret = 0;
991
992 check_sdata_in_driver(sdata);
993
994 trace_drv_assign_vif_chanctx(local, sdata, ctx);
995 if (local->ops->assign_vif_chanctx) {
996 WARN_ON_ONCE(!ctx->driver_present);
997 ret = local->ops->assign_vif_chanctx(&local->hw,
998 &sdata->vif,
999 &ctx->conf);
1000 }
1001 trace_drv_return_int(local, ret);
1002
1003 return ret;
1004 }
1005
1006 static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
1007 struct ieee80211_sub_if_data *sdata,
1008 struct ieee80211_chanctx *ctx)
1009 {
1010 check_sdata_in_driver(sdata);
1011
1012 trace_drv_unassign_vif_chanctx(local, sdata, ctx);
1013 if (local->ops->unassign_vif_chanctx) {
1014 WARN_ON_ONCE(!ctx->driver_present);
1015 local->ops->unassign_vif_chanctx(&local->hw,
1016 &sdata->vif,
1017 &ctx->conf);
1018 }
1019 trace_drv_return_void(local);
1020 }
1021
1022 static inline int drv_start_ap(struct ieee80211_local *local,
1023 struct ieee80211_sub_if_data *sdata)
1024 {
1025 int ret = 0;
1026
1027 check_sdata_in_driver(sdata);
1028
1029 trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
1030 if (local->ops->start_ap)
1031 ret = local->ops->start_ap(&local->hw, &sdata->vif);
1032 trace_drv_return_int(local, ret);
1033 return ret;
1034 }
1035
1036 static inline void drv_stop_ap(struct ieee80211_local *local,
1037 struct ieee80211_sub_if_data *sdata)
1038 {
1039 check_sdata_in_driver(sdata);
1040
1041 trace_drv_stop_ap(local, sdata);
1042 if (local->ops->stop_ap)
1043 local->ops->stop_ap(&local->hw, &sdata->vif);
1044 trace_drv_return_void(local);
1045 }
1046
1047 static inline void drv_restart_complete(struct ieee80211_local *local)
1048 {
1049 might_sleep();
1050
1051 trace_drv_restart_complete(local);
1052 if (local->ops->restart_complete)
1053 local->ops->restart_complete(&local->hw);
1054 trace_drv_return_void(local);
1055 }
1056
1057 static inline void
1058 drv_set_default_unicast_key(struct ieee80211_local *local,
1059 struct ieee80211_sub_if_data *sdata,
1060 int key_idx)
1061 {
1062 check_sdata_in_driver(sdata);
1063
1064 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1065
1066 trace_drv_set_default_unicast_key(local, sdata, key_idx);
1067 if (local->ops->set_default_unicast_key)
1068 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1069 key_idx);
1070 trace_drv_return_void(local);
1071 }
1072
1073 #if IS_ENABLED(CONFIG_IPV6)
1074 static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1075 struct ieee80211_sub_if_data *sdata,
1076 struct inet6_dev *idev)
1077 {
1078 trace_drv_ipv6_addr_change(local, sdata);
1079 if (local->ops->ipv6_addr_change)
1080 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1081 trace_drv_return_void(local);
1082 }
1083 #endif
1084
1085 static inline void
1086 drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1087 struct cfg80211_chan_def *chandef)
1088 {
1089 struct ieee80211_local *local = sdata->local;
1090
1091 if (local->ops->channel_switch_beacon) {
1092 trace_drv_channel_switch_beacon(local, sdata, chandef);
1093 local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1094 chandef);
1095 }
1096 }
1097
1098 static inline int drv_join_ibss(struct ieee80211_local *local,
1099 struct ieee80211_sub_if_data *sdata)
1100 {
1101 int ret = 0;
1102
1103 might_sleep();
1104 check_sdata_in_driver(sdata);
1105
1106 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1107 if (local->ops->join_ibss)
1108 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1109 trace_drv_return_int(local, ret);
1110 return ret;
1111 }
1112
1113 static inline void drv_leave_ibss(struct ieee80211_local *local,
1114 struct ieee80211_sub_if_data *sdata)
1115 {
1116 might_sleep();
1117 check_sdata_in_driver(sdata);
1118
1119 trace_drv_leave_ibss(local, sdata);
1120 if (local->ops->leave_ibss)
1121 local->ops->leave_ibss(&local->hw, &sdata->vif);
1122 trace_drv_return_void(local);
1123 }
1124
1125 #endif /* __MAC80211_DRIVER_OPS */
This page took 0.061001 seconds and 6 git commands to generate.