Revert "mac80211: add driver callback for per-interface multicast filter"
[platform/adaptation/renesas_rcar/renesas_kernel.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 void drv_sched_scan_stop(struct ieee80211_local *local,
358                                        struct ieee80211_sub_if_data *sdata)
359 {
360         might_sleep();
361
362         check_sdata_in_driver(sdata);
363
364         trace_drv_sched_scan_stop(local, sdata);
365         local->ops->sched_scan_stop(&local->hw, &sdata->vif);
366         trace_drv_return_void(local);
367 }
368
369 static inline void drv_sw_scan_start(struct ieee80211_local *local)
370 {
371         might_sleep();
372
373         trace_drv_sw_scan_start(local);
374         if (local->ops->sw_scan_start)
375                 local->ops->sw_scan_start(&local->hw);
376         trace_drv_return_void(local);
377 }
378
379 static inline void drv_sw_scan_complete(struct ieee80211_local *local)
380 {
381         might_sleep();
382
383         trace_drv_sw_scan_complete(local);
384         if (local->ops->sw_scan_complete)
385                 local->ops->sw_scan_complete(&local->hw);
386         trace_drv_return_void(local);
387 }
388
389 static inline int drv_get_stats(struct ieee80211_local *local,
390                                 struct ieee80211_low_level_stats *stats)
391 {
392         int ret = -EOPNOTSUPP;
393
394         might_sleep();
395
396         if (local->ops->get_stats)
397                 ret = local->ops->get_stats(&local->hw, stats);
398         trace_drv_get_stats(local, stats, ret);
399
400         return ret;
401 }
402
403 static inline void drv_get_tkip_seq(struct ieee80211_local *local,
404                                     u8 hw_key_idx, u32 *iv32, u16 *iv16)
405 {
406         if (local->ops->get_tkip_seq)
407                 local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
408         trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
409 }
410
411 static inline int drv_set_frag_threshold(struct ieee80211_local *local,
412                                         u32 value)
413 {
414         int ret = 0;
415
416         might_sleep();
417
418         trace_drv_set_frag_threshold(local, value);
419         if (local->ops->set_frag_threshold)
420                 ret = local->ops->set_frag_threshold(&local->hw, value);
421         trace_drv_return_int(local, ret);
422         return ret;
423 }
424
425 static inline int drv_set_rts_threshold(struct ieee80211_local *local,
426                                         u32 value)
427 {
428         int ret = 0;
429
430         might_sleep();
431
432         trace_drv_set_rts_threshold(local, value);
433         if (local->ops->set_rts_threshold)
434                 ret = local->ops->set_rts_threshold(&local->hw, value);
435         trace_drv_return_int(local, ret);
436         return ret;
437 }
438
439 static inline int drv_set_coverage_class(struct ieee80211_local *local,
440                                          u8 value)
441 {
442         int ret = 0;
443         might_sleep();
444
445         trace_drv_set_coverage_class(local, value);
446         if (local->ops->set_coverage_class)
447                 local->ops->set_coverage_class(&local->hw, value);
448         else
449                 ret = -EOPNOTSUPP;
450
451         trace_drv_return_int(local, ret);
452         return ret;
453 }
454
455 static inline void drv_sta_notify(struct ieee80211_local *local,
456                                   struct ieee80211_sub_if_data *sdata,
457                                   enum sta_notify_cmd cmd,
458                                   struct ieee80211_sta *sta)
459 {
460         sdata = get_bss_sdata(sdata);
461         check_sdata_in_driver(sdata);
462
463         trace_drv_sta_notify(local, sdata, cmd, sta);
464         if (local->ops->sta_notify)
465                 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
466         trace_drv_return_void(local);
467 }
468
469 static inline int drv_sta_add(struct ieee80211_local *local,
470                               struct ieee80211_sub_if_data *sdata,
471                               struct ieee80211_sta *sta)
472 {
473         int ret = 0;
474
475         might_sleep();
476
477         sdata = get_bss_sdata(sdata);
478         check_sdata_in_driver(sdata);
479
480         trace_drv_sta_add(local, sdata, sta);
481         if (local->ops->sta_add)
482                 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
483
484         trace_drv_return_int(local, ret);
485
486         return ret;
487 }
488
489 static inline void drv_sta_remove(struct ieee80211_local *local,
490                                   struct ieee80211_sub_if_data *sdata,
491                                   struct ieee80211_sta *sta)
492 {
493         might_sleep();
494
495         sdata = get_bss_sdata(sdata);
496         check_sdata_in_driver(sdata);
497
498         trace_drv_sta_remove(local, sdata, sta);
499         if (local->ops->sta_remove)
500                 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
501
502         trace_drv_return_void(local);
503 }
504
505 #ifdef CONFIG_MAC80211_DEBUGFS
506 static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
507                                        struct ieee80211_sub_if_data *sdata,
508                                        struct ieee80211_sta *sta,
509                                        struct dentry *dir)
510 {
511         might_sleep();
512
513         sdata = get_bss_sdata(sdata);
514         check_sdata_in_driver(sdata);
515
516         if (local->ops->sta_add_debugfs)
517                 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
518                                             sta, dir);
519 }
520
521 static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
522                                           struct ieee80211_sub_if_data *sdata,
523                                           struct ieee80211_sta *sta,
524                                           struct dentry *dir)
525 {
526         might_sleep();
527
528         sdata = get_bss_sdata(sdata);
529         check_sdata_in_driver(sdata);
530
531         if (local->ops->sta_remove_debugfs)
532                 local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
533                                                sta, dir);
534 }
535 #endif
536
537 static inline __must_check
538 int drv_sta_state(struct ieee80211_local *local,
539                   struct ieee80211_sub_if_data *sdata,
540                   struct sta_info *sta,
541                   enum ieee80211_sta_state old_state,
542                   enum ieee80211_sta_state new_state)
543 {
544         int ret = 0;
545
546         might_sleep();
547
548         sdata = get_bss_sdata(sdata);
549         check_sdata_in_driver(sdata);
550
551         trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
552         if (local->ops->sta_state) {
553                 ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta,
554                                             old_state, new_state);
555         } else if (old_state == IEEE80211_STA_AUTH &&
556                    new_state == IEEE80211_STA_ASSOC) {
557                 ret = drv_sta_add(local, sdata, &sta->sta);
558                 if (ret == 0)
559                         sta->uploaded = true;
560         } else if (old_state == IEEE80211_STA_ASSOC &&
561                    new_state == IEEE80211_STA_AUTH) {
562                 drv_sta_remove(local, sdata, &sta->sta);
563         }
564         trace_drv_return_int(local, ret);
565         return ret;
566 }
567
568 static inline void drv_sta_rc_update(struct ieee80211_local *local,
569                                      struct ieee80211_sub_if_data *sdata,
570                                      struct ieee80211_sta *sta, u32 changed)
571 {
572         sdata = get_bss_sdata(sdata);
573         check_sdata_in_driver(sdata);
574
575         WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED &&
576                 (sdata->vif.type != NL80211_IFTYPE_ADHOC &&
577                  sdata->vif.type != NL80211_IFTYPE_MESH_POINT));
578
579         trace_drv_sta_rc_update(local, sdata, sta, changed);
580         if (local->ops->sta_rc_update)
581                 local->ops->sta_rc_update(&local->hw, &sdata->vif,
582                                           sta, changed);
583
584         trace_drv_return_void(local);
585 }
586
587 static inline int drv_conf_tx(struct ieee80211_local *local,
588                               struct ieee80211_sub_if_data *sdata, u16 ac,
589                               const struct ieee80211_tx_queue_params *params)
590 {
591         int ret = -EOPNOTSUPP;
592
593         might_sleep();
594
595         check_sdata_in_driver(sdata);
596
597         trace_drv_conf_tx(local, sdata, ac, params);
598         if (local->ops->conf_tx)
599                 ret = local->ops->conf_tx(&local->hw, &sdata->vif,
600                                           ac, params);
601         trace_drv_return_int(local, ret);
602         return ret;
603 }
604
605 static inline u64 drv_get_tsf(struct ieee80211_local *local,
606                               struct ieee80211_sub_if_data *sdata)
607 {
608         u64 ret = -1ULL;
609
610         might_sleep();
611
612         check_sdata_in_driver(sdata);
613
614         trace_drv_get_tsf(local, sdata);
615         if (local->ops->get_tsf)
616                 ret = local->ops->get_tsf(&local->hw, &sdata->vif);
617         trace_drv_return_u64(local, ret);
618         return ret;
619 }
620
621 static inline void drv_set_tsf(struct ieee80211_local *local,
622                                struct ieee80211_sub_if_data *sdata,
623                                u64 tsf)
624 {
625         might_sleep();
626
627         check_sdata_in_driver(sdata);
628
629         trace_drv_set_tsf(local, sdata, tsf);
630         if (local->ops->set_tsf)
631                 local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
632         trace_drv_return_void(local);
633 }
634
635 static inline void drv_reset_tsf(struct ieee80211_local *local,
636                                  struct ieee80211_sub_if_data *sdata)
637 {
638         might_sleep();
639
640         check_sdata_in_driver(sdata);
641
642         trace_drv_reset_tsf(local, sdata);
643         if (local->ops->reset_tsf)
644                 local->ops->reset_tsf(&local->hw, &sdata->vif);
645         trace_drv_return_void(local);
646 }
647
648 static inline int drv_tx_last_beacon(struct ieee80211_local *local)
649 {
650         int ret = 0; /* default unsupported op for less congestion */
651
652         might_sleep();
653
654         trace_drv_tx_last_beacon(local);
655         if (local->ops->tx_last_beacon)
656                 ret = local->ops->tx_last_beacon(&local->hw);
657         trace_drv_return_int(local, ret);
658         return ret;
659 }
660
661 static inline int drv_ampdu_action(struct ieee80211_local *local,
662                                    struct ieee80211_sub_if_data *sdata,
663                                    enum ieee80211_ampdu_mlme_action action,
664                                    struct ieee80211_sta *sta, u16 tid,
665                                    u16 *ssn, u8 buf_size)
666 {
667         int ret = -EOPNOTSUPP;
668
669         might_sleep();
670
671         sdata = get_bss_sdata(sdata);
672         check_sdata_in_driver(sdata);
673
674         trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
675
676         if (local->ops->ampdu_action)
677                 ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
678                                                sta, tid, ssn, buf_size);
679
680         trace_drv_return_int(local, ret);
681
682         return ret;
683 }
684
685 static inline int drv_get_survey(struct ieee80211_local *local, int idx,
686                                 struct survey_info *survey)
687 {
688         int ret = -EOPNOTSUPP;
689
690         trace_drv_get_survey(local, idx, survey);
691
692         if (local->ops->get_survey)
693                 ret = local->ops->get_survey(&local->hw, idx, survey);
694
695         trace_drv_return_int(local, ret);
696
697         return ret;
698 }
699
700 static inline void drv_rfkill_poll(struct ieee80211_local *local)
701 {
702         might_sleep();
703
704         if (local->ops->rfkill_poll)
705                 local->ops->rfkill_poll(&local->hw);
706 }
707
708 static inline void drv_flush(struct ieee80211_local *local,
709                              u32 queues, bool drop)
710 {
711         might_sleep();
712
713         trace_drv_flush(local, queues, drop);
714         if (local->ops->flush)
715                 local->ops->flush(&local->hw, queues, drop);
716         trace_drv_return_void(local);
717 }
718
719 static inline void drv_channel_switch(struct ieee80211_local *local,
720                                      struct ieee80211_channel_switch *ch_switch)
721 {
722         might_sleep();
723
724         trace_drv_channel_switch(local, ch_switch);
725         local->ops->channel_switch(&local->hw, ch_switch);
726         trace_drv_return_void(local);
727 }
728
729
730 static inline int drv_set_antenna(struct ieee80211_local *local,
731                                   u32 tx_ant, u32 rx_ant)
732 {
733         int ret = -EOPNOTSUPP;
734         might_sleep();
735         if (local->ops->set_antenna)
736                 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
737         trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
738         return ret;
739 }
740
741 static inline int drv_get_antenna(struct ieee80211_local *local,
742                                   u32 *tx_ant, u32 *rx_ant)
743 {
744         int ret = -EOPNOTSUPP;
745         might_sleep();
746         if (local->ops->get_antenna)
747                 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
748         trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
749         return ret;
750 }
751
752 static inline int drv_remain_on_channel(struct ieee80211_local *local,
753                                         struct ieee80211_sub_if_data *sdata,
754                                         struct ieee80211_channel *chan,
755                                         unsigned int duration,
756                                         enum ieee80211_roc_type type)
757 {
758         int ret;
759
760         might_sleep();
761
762         trace_drv_remain_on_channel(local, sdata, chan, duration, type);
763         ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
764                                             chan, duration, type);
765         trace_drv_return_int(local, ret);
766
767         return ret;
768 }
769
770 static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
771 {
772         int ret;
773
774         might_sleep();
775
776         trace_drv_cancel_remain_on_channel(local);
777         ret = local->ops->cancel_remain_on_channel(&local->hw);
778         trace_drv_return_int(local, ret);
779
780         return ret;
781 }
782
783 static inline int drv_set_ringparam(struct ieee80211_local *local,
784                                     u32 tx, u32 rx)
785 {
786         int ret = -ENOTSUPP;
787
788         might_sleep();
789
790         trace_drv_set_ringparam(local, tx, rx);
791         if (local->ops->set_ringparam)
792                 ret = local->ops->set_ringparam(&local->hw, tx, rx);
793         trace_drv_return_int(local, ret);
794
795         return ret;
796 }
797
798 static inline void drv_get_ringparam(struct ieee80211_local *local,
799                                      u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
800 {
801         might_sleep();
802
803         trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
804         if (local->ops->get_ringparam)
805                 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
806         trace_drv_return_void(local);
807 }
808
809 static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
810 {
811         bool ret = false;
812
813         might_sleep();
814
815         trace_drv_tx_frames_pending(local);
816         if (local->ops->tx_frames_pending)
817                 ret = local->ops->tx_frames_pending(&local->hw);
818         trace_drv_return_bool(local, ret);
819
820         return ret;
821 }
822
823 static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
824                                        struct ieee80211_sub_if_data *sdata,
825                                        const struct cfg80211_bitrate_mask *mask)
826 {
827         int ret = -EOPNOTSUPP;
828
829         might_sleep();
830
831         check_sdata_in_driver(sdata);
832
833         trace_drv_set_bitrate_mask(local, sdata, mask);
834         if (local->ops->set_bitrate_mask)
835                 ret = local->ops->set_bitrate_mask(&local->hw,
836                                                    &sdata->vif, mask);
837         trace_drv_return_int(local, ret);
838
839         return ret;
840 }
841
842 static inline void drv_set_rekey_data(struct ieee80211_local *local,
843                                       struct ieee80211_sub_if_data *sdata,
844                                       struct cfg80211_gtk_rekey_data *data)
845 {
846         check_sdata_in_driver(sdata);
847
848         trace_drv_set_rekey_data(local, sdata, data);
849         if (local->ops->set_rekey_data)
850                 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
851         trace_drv_return_void(local);
852 }
853
854 static inline void drv_rssi_callback(struct ieee80211_local *local,
855                                      struct ieee80211_sub_if_data *sdata,
856                                      const enum ieee80211_rssi_event event)
857 {
858         trace_drv_rssi_callback(local, sdata, event);
859         if (local->ops->rssi_callback)
860                 local->ops->rssi_callback(&local->hw, &sdata->vif, event);
861         trace_drv_return_void(local);
862 }
863
864 static inline void
865 drv_release_buffered_frames(struct ieee80211_local *local,
866                             struct sta_info *sta, u16 tids, int num_frames,
867                             enum ieee80211_frame_release_type reason,
868                             bool more_data)
869 {
870         trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
871                                           reason, more_data);
872         if (local->ops->release_buffered_frames)
873                 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
874                                                     num_frames, reason,
875                                                     more_data);
876         trace_drv_return_void(local);
877 }
878
879 static inline void
880 drv_allow_buffered_frames(struct ieee80211_local *local,
881                           struct sta_info *sta, u16 tids, int num_frames,
882                           enum ieee80211_frame_release_type reason,
883                           bool more_data)
884 {
885         trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
886                                         reason, more_data);
887         if (local->ops->allow_buffered_frames)
888                 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
889                                                   tids, num_frames, reason,
890                                                   more_data);
891         trace_drv_return_void(local);
892 }
893
894 static inline int drv_get_rssi(struct ieee80211_local *local,
895                                 struct ieee80211_sub_if_data *sdata,
896                                 struct ieee80211_sta *sta,
897                                 s8 *rssi_dbm)
898 {
899         int ret;
900
901         might_sleep();
902
903         ret = local->ops->get_rssi(&local->hw, &sdata->vif, sta, rssi_dbm);
904         trace_drv_get_rssi(local, sta, *rssi_dbm, ret);
905
906         return ret;
907 }
908
909 static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
910                                       struct ieee80211_sub_if_data *sdata)
911 {
912         might_sleep();
913
914         check_sdata_in_driver(sdata);
915         WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
916
917         trace_drv_mgd_prepare_tx(local, sdata);
918         if (local->ops->mgd_prepare_tx)
919                 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
920         trace_drv_return_void(local);
921 }
922
923 static inline int drv_add_chanctx(struct ieee80211_local *local,
924                                   struct ieee80211_chanctx *ctx)
925 {
926         int ret = -EOPNOTSUPP;
927
928         trace_drv_add_chanctx(local, ctx);
929         if (local->ops->add_chanctx)
930                 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
931         trace_drv_return_int(local, ret);
932         if (!ret)
933                 ctx->driver_present = true;
934
935         return ret;
936 }
937
938 static inline void drv_remove_chanctx(struct ieee80211_local *local,
939                                       struct ieee80211_chanctx *ctx)
940 {
941         trace_drv_remove_chanctx(local, ctx);
942         if (local->ops->remove_chanctx)
943                 local->ops->remove_chanctx(&local->hw, &ctx->conf);
944         trace_drv_return_void(local);
945         ctx->driver_present = false;
946 }
947
948 static inline void drv_change_chanctx(struct ieee80211_local *local,
949                                       struct ieee80211_chanctx *ctx,
950                                       u32 changed)
951 {
952         trace_drv_change_chanctx(local, ctx, changed);
953         if (local->ops->change_chanctx) {
954                 WARN_ON_ONCE(!ctx->driver_present);
955                 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
956         }
957         trace_drv_return_void(local);
958 }
959
960 static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
961                                          struct ieee80211_sub_if_data *sdata,
962                                          struct ieee80211_chanctx *ctx)
963 {
964         int ret = 0;
965
966         check_sdata_in_driver(sdata);
967
968         trace_drv_assign_vif_chanctx(local, sdata, ctx);
969         if (local->ops->assign_vif_chanctx) {
970                 WARN_ON_ONCE(!ctx->driver_present);
971                 ret = local->ops->assign_vif_chanctx(&local->hw,
972                                                      &sdata->vif,
973                                                      &ctx->conf);
974         }
975         trace_drv_return_int(local, ret);
976
977         return ret;
978 }
979
980 static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
981                                             struct ieee80211_sub_if_data *sdata,
982                                             struct ieee80211_chanctx *ctx)
983 {
984         check_sdata_in_driver(sdata);
985
986         trace_drv_unassign_vif_chanctx(local, sdata, ctx);
987         if (local->ops->unassign_vif_chanctx) {
988                 WARN_ON_ONCE(!ctx->driver_present);
989                 local->ops->unassign_vif_chanctx(&local->hw,
990                                                  &sdata->vif,
991                                                  &ctx->conf);
992         }
993         trace_drv_return_void(local);
994 }
995
996 static inline int drv_start_ap(struct ieee80211_local *local,
997                                struct ieee80211_sub_if_data *sdata)
998 {
999         int ret = 0;
1000
1001         check_sdata_in_driver(sdata);
1002
1003         trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
1004         if (local->ops->start_ap)
1005                 ret = local->ops->start_ap(&local->hw, &sdata->vif);
1006         trace_drv_return_int(local, ret);
1007         return ret;
1008 }
1009
1010 static inline void drv_stop_ap(struct ieee80211_local *local,
1011                                struct ieee80211_sub_if_data *sdata)
1012 {
1013         check_sdata_in_driver(sdata);
1014
1015         trace_drv_stop_ap(local, sdata);
1016         if (local->ops->stop_ap)
1017                 local->ops->stop_ap(&local->hw, &sdata->vif);
1018         trace_drv_return_void(local);
1019 }
1020
1021 static inline void drv_restart_complete(struct ieee80211_local *local)
1022 {
1023         might_sleep();
1024
1025         trace_drv_restart_complete(local);
1026         if (local->ops->restart_complete)
1027                 local->ops->restart_complete(&local->hw);
1028         trace_drv_return_void(local);
1029 }
1030
1031 static inline void
1032 drv_set_default_unicast_key(struct ieee80211_local *local,
1033                             struct ieee80211_sub_if_data *sdata,
1034                             int key_idx)
1035 {
1036         check_sdata_in_driver(sdata);
1037
1038         WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1039
1040         trace_drv_set_default_unicast_key(local, sdata, key_idx);
1041         if (local->ops->set_default_unicast_key)
1042                 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1043                                                     key_idx);
1044         trace_drv_return_void(local);
1045 }
1046
1047 #if IS_ENABLED(CONFIG_IPV6)
1048 static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1049                                         struct ieee80211_sub_if_data *sdata,
1050                                         struct inet6_dev *idev)
1051 {
1052         trace_drv_ipv6_addr_change(local, sdata);
1053         if (local->ops->ipv6_addr_change)
1054                 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1055         trace_drv_return_void(local);
1056 }
1057 #endif
1058
1059 static inline void
1060 drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1061                           struct cfg80211_chan_def *chandef)
1062 {
1063         struct ieee80211_local *local = sdata->local;
1064
1065         if (local->ops->channel_switch_beacon) {
1066                 trace_drv_channel_switch_beacon(local, sdata, chandef);
1067                 local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1068                                                   chandef);
1069         }
1070 }
1071
1072 static inline int drv_join_ibss(struct ieee80211_local *local,
1073                                 struct ieee80211_sub_if_data *sdata)
1074 {
1075         int ret = 0;
1076
1077         might_sleep();
1078         check_sdata_in_driver(sdata);
1079
1080         trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1081         if (local->ops->join_ibss)
1082                 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1083         trace_drv_return_int(local, ret);
1084         return ret;
1085 }
1086
1087 static inline void drv_leave_ibss(struct ieee80211_local *local,
1088                                   struct ieee80211_sub_if_data *sdata)
1089 {
1090         might_sleep();
1091         check_sdata_in_driver(sdata);
1092
1093         trace_drv_leave_ibss(local, sdata);
1094         if (local->ops->leave_ibss)
1095                 local->ops->leave_ibss(&local->hw, &sdata->vif);
1096         trace_drv_return_void(local);
1097 }
1098
1099 #endif /* __MAC80211_DRIVER_OPS */