mac80211: remove sta_remove_debugfs driver callback
[cascardo/linux.git] / net / mac80211 / driver-ops.h
1 /*
2 * Portions of this file
3 * Copyright(c) 2016 Intel Deutschland GmbH
4 */
5
6 #ifndef __MAC80211_DRIVER_OPS
7 #define __MAC80211_DRIVER_OPS
8
9 #include <net/mac80211.h>
10 #include "ieee80211_i.h"
11 #include "trace.h"
12
13 static inline bool check_sdata_in_driver(struct ieee80211_sub_if_data *sdata)
14 {
15         return !WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER),
16                      "%s:  Failed check-sdata-in-driver check, flags: 0x%x\n",
17                      sdata->dev ? sdata->dev->name : sdata->name, sdata->flags);
18 }
19
20 static inline struct ieee80211_sub_if_data *
21 get_bss_sdata(struct ieee80211_sub_if_data *sdata)
22 {
23         if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
24                 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
25                                      u.ap);
26
27         return sdata;
28 }
29
30 static inline void drv_tx(struct ieee80211_local *local,
31                           struct ieee80211_tx_control *control,
32                           struct sk_buff *skb)
33 {
34         local->ops->tx(&local->hw, control, skb);
35 }
36
37 static inline void drv_sync_rx_queues(struct ieee80211_local *local,
38                                       struct sta_info *sta)
39 {
40         if (local->ops->sync_rx_queues) {
41                 trace_drv_sync_rx_queues(local, sta->sdata, &sta->sta);
42                 local->ops->sync_rx_queues(&local->hw);
43                 trace_drv_return_void(local);
44         }
45 }
46
47 static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata,
48                                       u32 sset, u8 *data)
49 {
50         struct ieee80211_local *local = sdata->local;
51         if (local->ops->get_et_strings) {
52                 trace_drv_get_et_strings(local, sset);
53                 local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data);
54                 trace_drv_return_void(local);
55         }
56 }
57
58 static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata,
59                                     struct ethtool_stats *stats,
60                                     u64 *data)
61 {
62         struct ieee80211_local *local = sdata->local;
63         if (local->ops->get_et_stats) {
64                 trace_drv_get_et_stats(local);
65                 local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data);
66                 trace_drv_return_void(local);
67         }
68 }
69
70 static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata,
71                                         int sset)
72 {
73         struct ieee80211_local *local = sdata->local;
74         int rv = 0;
75         if (local->ops->get_et_sset_count) {
76                 trace_drv_get_et_sset_count(local, sset);
77                 rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif,
78                                                    sset);
79                 trace_drv_return_int(local, rv);
80         }
81         return rv;
82 }
83
84 int drv_start(struct ieee80211_local *local);
85 void drv_stop(struct ieee80211_local *local);
86
87 #ifdef CONFIG_PM
88 static inline int drv_suspend(struct ieee80211_local *local,
89                               struct cfg80211_wowlan *wowlan)
90 {
91         int ret;
92
93         might_sleep();
94
95         trace_drv_suspend(local);
96         ret = local->ops->suspend(&local->hw, wowlan);
97         trace_drv_return_int(local, ret);
98         return ret;
99 }
100
101 static inline int drv_resume(struct ieee80211_local *local)
102 {
103         int ret;
104
105         might_sleep();
106
107         trace_drv_resume(local);
108         ret = local->ops->resume(&local->hw);
109         trace_drv_return_int(local, ret);
110         return ret;
111 }
112
113 static inline void drv_set_wakeup(struct ieee80211_local *local,
114                                   bool enabled)
115 {
116         might_sleep();
117
118         if (!local->ops->set_wakeup)
119                 return;
120
121         trace_drv_set_wakeup(local, enabled);
122         local->ops->set_wakeup(&local->hw, enabled);
123         trace_drv_return_void(local);
124 }
125 #endif
126
127 int drv_add_interface(struct ieee80211_local *local,
128                       struct ieee80211_sub_if_data *sdata);
129
130 int drv_change_interface(struct ieee80211_local *local,
131                          struct ieee80211_sub_if_data *sdata,
132                          enum nl80211_iftype type, bool p2p);
133
134 void drv_remove_interface(struct ieee80211_local *local,
135                           struct ieee80211_sub_if_data *sdata);
136
137 static inline int drv_config(struct ieee80211_local *local, u32 changed)
138 {
139         int ret;
140
141         might_sleep();
142
143         trace_drv_config(local, changed);
144         ret = local->ops->config(&local->hw, changed);
145         trace_drv_return_int(local, ret);
146         return ret;
147 }
148
149 static inline void drv_bss_info_changed(struct ieee80211_local *local,
150                                         struct ieee80211_sub_if_data *sdata,
151                                         struct ieee80211_bss_conf *info,
152                                         u32 changed)
153 {
154         might_sleep();
155
156         if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
157                                     BSS_CHANGED_BEACON_ENABLED) &&
158                          sdata->vif.type != NL80211_IFTYPE_AP &&
159                          sdata->vif.type != NL80211_IFTYPE_ADHOC &&
160                          sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
161                          sdata->vif.type != NL80211_IFTYPE_OCB))
162                 return;
163
164         if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
165                          (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
166                           !sdata->vif.mu_mimo_owner)))
167                 return;
168
169         if (!check_sdata_in_driver(sdata))
170                 return;
171
172         trace_drv_bss_info_changed(local, sdata, info, changed);
173         if (local->ops->bss_info_changed)
174                 local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
175         trace_drv_return_void(local);
176 }
177
178 static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
179                                         struct netdev_hw_addr_list *mc_list)
180 {
181         u64 ret = 0;
182
183         trace_drv_prepare_multicast(local, mc_list->count);
184
185         if (local->ops->prepare_multicast)
186                 ret = local->ops->prepare_multicast(&local->hw, mc_list);
187
188         trace_drv_return_u64(local, ret);
189
190         return ret;
191 }
192
193 static inline void drv_configure_filter(struct ieee80211_local *local,
194                                         unsigned int changed_flags,
195                                         unsigned int *total_flags,
196                                         u64 multicast)
197 {
198         might_sleep();
199
200         trace_drv_configure_filter(local, changed_flags, total_flags,
201                                    multicast);
202         local->ops->configure_filter(&local->hw, changed_flags, total_flags,
203                                      multicast);
204         trace_drv_return_void(local);
205 }
206
207 static inline void drv_config_iface_filter(struct ieee80211_local *local,
208                                            struct ieee80211_sub_if_data *sdata,
209                                            unsigned int filter_flags,
210                                            unsigned int changed_flags)
211 {
212         might_sleep();
213
214         trace_drv_config_iface_filter(local, sdata, filter_flags,
215                                       changed_flags);
216         if (local->ops->config_iface_filter)
217                 local->ops->config_iface_filter(&local->hw, &sdata->vif,
218                                                 filter_flags,
219                                                 changed_flags);
220         trace_drv_return_void(local);
221 }
222
223 static inline int drv_set_tim(struct ieee80211_local *local,
224                               struct ieee80211_sta *sta, bool set)
225 {
226         int ret = 0;
227         trace_drv_set_tim(local, sta, set);
228         if (local->ops->set_tim)
229                 ret = local->ops->set_tim(&local->hw, sta, set);
230         trace_drv_return_int(local, ret);
231         return ret;
232 }
233
234 static inline int drv_set_key(struct ieee80211_local *local,
235                               enum set_key_cmd cmd,
236                               struct ieee80211_sub_if_data *sdata,
237                               struct ieee80211_sta *sta,
238                               struct ieee80211_key_conf *key)
239 {
240         int ret;
241
242         might_sleep();
243
244         sdata = get_bss_sdata(sdata);
245         if (!check_sdata_in_driver(sdata))
246                 return -EIO;
247
248         trace_drv_set_key(local, cmd, sdata, sta, key);
249         ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
250         trace_drv_return_int(local, ret);
251         return ret;
252 }
253
254 static inline void drv_update_tkip_key(struct ieee80211_local *local,
255                                        struct ieee80211_sub_if_data *sdata,
256                                        struct ieee80211_key_conf *conf,
257                                        struct sta_info *sta, u32 iv32,
258                                        u16 *phase1key)
259 {
260         struct ieee80211_sta *ista = NULL;
261
262         if (sta)
263                 ista = &sta->sta;
264
265         sdata = get_bss_sdata(sdata);
266         if (!check_sdata_in_driver(sdata))
267                 return;
268
269         trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
270         if (local->ops->update_tkip_key)
271                 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
272                                             ista, iv32, phase1key);
273         trace_drv_return_void(local);
274 }
275
276 static inline int drv_hw_scan(struct ieee80211_local *local,
277                               struct ieee80211_sub_if_data *sdata,
278                               struct ieee80211_scan_request *req)
279 {
280         int ret;
281
282         might_sleep();
283
284         if (!check_sdata_in_driver(sdata))
285                 return -EIO;
286
287         trace_drv_hw_scan(local, sdata);
288         ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
289         trace_drv_return_int(local, ret);
290         return ret;
291 }
292
293 static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
294                                       struct ieee80211_sub_if_data *sdata)
295 {
296         might_sleep();
297
298         if (!check_sdata_in_driver(sdata))
299                 return;
300
301         trace_drv_cancel_hw_scan(local, sdata);
302         local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
303         trace_drv_return_void(local);
304 }
305
306 static inline int
307 drv_sched_scan_start(struct ieee80211_local *local,
308                      struct ieee80211_sub_if_data *sdata,
309                      struct cfg80211_sched_scan_request *req,
310                      struct ieee80211_scan_ies *ies)
311 {
312         int ret;
313
314         might_sleep();
315
316         if (!check_sdata_in_driver(sdata))
317                 return -EIO;
318
319         trace_drv_sched_scan_start(local, sdata);
320         ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
321                                               req, ies);
322         trace_drv_return_int(local, ret);
323         return ret;
324 }
325
326 static inline int drv_sched_scan_stop(struct ieee80211_local *local,
327                                       struct ieee80211_sub_if_data *sdata)
328 {
329         int ret;
330
331         might_sleep();
332
333         if (!check_sdata_in_driver(sdata))
334                 return -EIO;
335
336         trace_drv_sched_scan_stop(local, sdata);
337         ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
338         trace_drv_return_int(local, ret);
339
340         return ret;
341 }
342
343 static inline void drv_sw_scan_start(struct ieee80211_local *local,
344                                      struct ieee80211_sub_if_data *sdata,
345                                      const u8 *mac_addr)
346 {
347         might_sleep();
348
349         trace_drv_sw_scan_start(local, sdata, mac_addr);
350         if (local->ops->sw_scan_start)
351                 local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
352         trace_drv_return_void(local);
353 }
354
355 static inline void drv_sw_scan_complete(struct ieee80211_local *local,
356                                         struct ieee80211_sub_if_data *sdata)
357 {
358         might_sleep();
359
360         trace_drv_sw_scan_complete(local, sdata);
361         if (local->ops->sw_scan_complete)
362                 local->ops->sw_scan_complete(&local->hw, &sdata->vif);
363         trace_drv_return_void(local);
364 }
365
366 static inline int drv_get_stats(struct ieee80211_local *local,
367                                 struct ieee80211_low_level_stats *stats)
368 {
369         int ret = -EOPNOTSUPP;
370
371         might_sleep();
372
373         if (local->ops->get_stats)
374                 ret = local->ops->get_stats(&local->hw, stats);
375         trace_drv_get_stats(local, stats, ret);
376
377         return ret;
378 }
379
380 static inline void drv_get_key_seq(struct ieee80211_local *local,
381                                    struct ieee80211_key *key,
382                                    struct ieee80211_key_seq *seq)
383 {
384         if (local->ops->get_key_seq)
385                 local->ops->get_key_seq(&local->hw, &key->conf, seq);
386         trace_drv_get_key_seq(local, &key->conf);
387 }
388
389 static inline int drv_set_frag_threshold(struct ieee80211_local *local,
390                                         u32 value)
391 {
392         int ret = 0;
393
394         might_sleep();
395
396         trace_drv_set_frag_threshold(local, value);
397         if (local->ops->set_frag_threshold)
398                 ret = local->ops->set_frag_threshold(&local->hw, value);
399         trace_drv_return_int(local, ret);
400         return ret;
401 }
402
403 static inline int drv_set_rts_threshold(struct ieee80211_local *local,
404                                         u32 value)
405 {
406         int ret = 0;
407
408         might_sleep();
409
410         trace_drv_set_rts_threshold(local, value);
411         if (local->ops->set_rts_threshold)
412                 ret = local->ops->set_rts_threshold(&local->hw, value);
413         trace_drv_return_int(local, ret);
414         return ret;
415 }
416
417 static inline int drv_set_coverage_class(struct ieee80211_local *local,
418                                          s16 value)
419 {
420         int ret = 0;
421         might_sleep();
422
423         trace_drv_set_coverage_class(local, value);
424         if (local->ops->set_coverage_class)
425                 local->ops->set_coverage_class(&local->hw, value);
426         else
427                 ret = -EOPNOTSUPP;
428
429         trace_drv_return_int(local, ret);
430         return ret;
431 }
432
433 static inline void drv_sta_notify(struct ieee80211_local *local,
434                                   struct ieee80211_sub_if_data *sdata,
435                                   enum sta_notify_cmd cmd,
436                                   struct ieee80211_sta *sta)
437 {
438         sdata = get_bss_sdata(sdata);
439         if (!check_sdata_in_driver(sdata))
440                 return;
441
442         trace_drv_sta_notify(local, sdata, cmd, sta);
443         if (local->ops->sta_notify)
444                 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
445         trace_drv_return_void(local);
446 }
447
448 static inline int drv_sta_add(struct ieee80211_local *local,
449                               struct ieee80211_sub_if_data *sdata,
450                               struct ieee80211_sta *sta)
451 {
452         int ret = 0;
453
454         might_sleep();
455
456         sdata = get_bss_sdata(sdata);
457         if (!check_sdata_in_driver(sdata))
458                 return -EIO;
459
460         trace_drv_sta_add(local, sdata, sta);
461         if (local->ops->sta_add)
462                 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
463
464         trace_drv_return_int(local, ret);
465
466         return ret;
467 }
468
469 static inline void drv_sta_remove(struct ieee80211_local *local,
470                                   struct ieee80211_sub_if_data *sdata,
471                                   struct ieee80211_sta *sta)
472 {
473         might_sleep();
474
475         sdata = get_bss_sdata(sdata);
476         if (!check_sdata_in_driver(sdata))
477                 return;
478
479         trace_drv_sta_remove(local, sdata, sta);
480         if (local->ops->sta_remove)
481                 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
482
483         trace_drv_return_void(local);
484 }
485
486 #ifdef CONFIG_MAC80211_DEBUGFS
487 static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
488                                        struct ieee80211_sub_if_data *sdata,
489                                        struct ieee80211_sta *sta,
490                                        struct dentry *dir)
491 {
492         might_sleep();
493
494         sdata = get_bss_sdata(sdata);
495         if (!check_sdata_in_driver(sdata))
496                 return;
497
498         if (local->ops->sta_add_debugfs)
499                 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
500                                             sta, dir);
501 }
502 #endif
503
504 static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
505                                           struct ieee80211_sub_if_data *sdata,
506                                           struct sta_info *sta)
507 {
508         might_sleep();
509
510         sdata = get_bss_sdata(sdata);
511         if (!check_sdata_in_driver(sdata))
512                 return;
513
514         trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
515         if (local->ops->sta_pre_rcu_remove)
516                 local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
517                                                &sta->sta);
518         trace_drv_return_void(local);
519 }
520
521 __must_check
522 int drv_sta_state(struct ieee80211_local *local,
523                   struct ieee80211_sub_if_data *sdata,
524                   struct sta_info *sta,
525                   enum ieee80211_sta_state old_state,
526                   enum ieee80211_sta_state new_state);
527
528 void drv_sta_rc_update(struct ieee80211_local *local,
529                        struct ieee80211_sub_if_data *sdata,
530                        struct ieee80211_sta *sta, u32 changed);
531
532 static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
533                                            struct ieee80211_sub_if_data *sdata,
534                                            struct ieee80211_sta *sta)
535 {
536         sdata = get_bss_sdata(sdata);
537         if (!check_sdata_in_driver(sdata))
538                 return;
539
540         trace_drv_sta_rate_tbl_update(local, sdata, sta);
541         if (local->ops->sta_rate_tbl_update)
542                 local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
543
544         trace_drv_return_void(local);
545 }
546
547 static inline void drv_sta_statistics(struct ieee80211_local *local,
548                                       struct ieee80211_sub_if_data *sdata,
549                                       struct ieee80211_sta *sta,
550                                       struct station_info *sinfo)
551 {
552         sdata = get_bss_sdata(sdata);
553         if (!check_sdata_in_driver(sdata))
554                 return;
555
556         trace_drv_sta_statistics(local, sdata, sta);
557         if (local->ops->sta_statistics)
558                 local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
559         trace_drv_return_void(local);
560 }
561
562 int drv_conf_tx(struct ieee80211_local *local,
563                 struct ieee80211_sub_if_data *sdata, u16 ac,
564                 const struct ieee80211_tx_queue_params *params);
565
566 u64 drv_get_tsf(struct ieee80211_local *local,
567                 struct ieee80211_sub_if_data *sdata);
568 void drv_set_tsf(struct ieee80211_local *local,
569                  struct ieee80211_sub_if_data *sdata,
570                  u64 tsf);
571 void drv_reset_tsf(struct ieee80211_local *local,
572                    struct ieee80211_sub_if_data *sdata);
573
574 static inline int drv_tx_last_beacon(struct ieee80211_local *local)
575 {
576         int ret = 0; /* default unsupported op for less congestion */
577
578         might_sleep();
579
580         trace_drv_tx_last_beacon(local);
581         if (local->ops->tx_last_beacon)
582                 ret = local->ops->tx_last_beacon(&local->hw);
583         trace_drv_return_int(local, ret);
584         return ret;
585 }
586
587 int drv_ampdu_action(struct ieee80211_local *local,
588                      struct ieee80211_sub_if_data *sdata,
589                      struct ieee80211_ampdu_params *params);
590
591 static inline int drv_get_survey(struct ieee80211_local *local, int idx,
592                                 struct survey_info *survey)
593 {
594         int ret = -EOPNOTSUPP;
595
596         trace_drv_get_survey(local, idx, survey);
597
598         if (local->ops->get_survey)
599                 ret = local->ops->get_survey(&local->hw, idx, survey);
600
601         trace_drv_return_int(local, ret);
602
603         return ret;
604 }
605
606 static inline void drv_rfkill_poll(struct ieee80211_local *local)
607 {
608         might_sleep();
609
610         if (local->ops->rfkill_poll)
611                 local->ops->rfkill_poll(&local->hw);
612 }
613
614 static inline void drv_flush(struct ieee80211_local *local,
615                              struct ieee80211_sub_if_data *sdata,
616                              u32 queues, bool drop)
617 {
618         struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
619
620         might_sleep();
621
622         if (sdata && !check_sdata_in_driver(sdata))
623                 return;
624
625         trace_drv_flush(local, queues, drop);
626         if (local->ops->flush)
627                 local->ops->flush(&local->hw, vif, queues, drop);
628         trace_drv_return_void(local);
629 }
630
631 static inline void drv_channel_switch(struct ieee80211_local *local,
632                                       struct ieee80211_sub_if_data *sdata,
633                                       struct ieee80211_channel_switch *ch_switch)
634 {
635         might_sleep();
636
637         trace_drv_channel_switch(local, sdata, ch_switch);
638         local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
639         trace_drv_return_void(local);
640 }
641
642
643 static inline int drv_set_antenna(struct ieee80211_local *local,
644                                   u32 tx_ant, u32 rx_ant)
645 {
646         int ret = -EOPNOTSUPP;
647         might_sleep();
648         if (local->ops->set_antenna)
649                 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
650         trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
651         return ret;
652 }
653
654 static inline int drv_get_antenna(struct ieee80211_local *local,
655                                   u32 *tx_ant, u32 *rx_ant)
656 {
657         int ret = -EOPNOTSUPP;
658         might_sleep();
659         if (local->ops->get_antenna)
660                 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
661         trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
662         return ret;
663 }
664
665 static inline int drv_remain_on_channel(struct ieee80211_local *local,
666                                         struct ieee80211_sub_if_data *sdata,
667                                         struct ieee80211_channel *chan,
668                                         unsigned int duration,
669                                         enum ieee80211_roc_type type)
670 {
671         int ret;
672
673         might_sleep();
674
675         trace_drv_remain_on_channel(local, sdata, chan, duration, type);
676         ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
677                                             chan, duration, type);
678         trace_drv_return_int(local, ret);
679
680         return ret;
681 }
682
683 static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
684 {
685         int ret;
686
687         might_sleep();
688
689         trace_drv_cancel_remain_on_channel(local);
690         ret = local->ops->cancel_remain_on_channel(&local->hw);
691         trace_drv_return_int(local, ret);
692
693         return ret;
694 }
695
696 static inline int drv_set_ringparam(struct ieee80211_local *local,
697                                     u32 tx, u32 rx)
698 {
699         int ret = -ENOTSUPP;
700
701         might_sleep();
702
703         trace_drv_set_ringparam(local, tx, rx);
704         if (local->ops->set_ringparam)
705                 ret = local->ops->set_ringparam(&local->hw, tx, rx);
706         trace_drv_return_int(local, ret);
707
708         return ret;
709 }
710
711 static inline void drv_get_ringparam(struct ieee80211_local *local,
712                                      u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
713 {
714         might_sleep();
715
716         trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
717         if (local->ops->get_ringparam)
718                 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
719         trace_drv_return_void(local);
720 }
721
722 static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
723 {
724         bool ret = false;
725
726         might_sleep();
727
728         trace_drv_tx_frames_pending(local);
729         if (local->ops->tx_frames_pending)
730                 ret = local->ops->tx_frames_pending(&local->hw);
731         trace_drv_return_bool(local, ret);
732
733         return ret;
734 }
735
736 static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
737                                        struct ieee80211_sub_if_data *sdata,
738                                        const struct cfg80211_bitrate_mask *mask)
739 {
740         int ret = -EOPNOTSUPP;
741
742         might_sleep();
743
744         if (!check_sdata_in_driver(sdata))
745                 return -EIO;
746
747         trace_drv_set_bitrate_mask(local, sdata, mask);
748         if (local->ops->set_bitrate_mask)
749                 ret = local->ops->set_bitrate_mask(&local->hw,
750                                                    &sdata->vif, mask);
751         trace_drv_return_int(local, ret);
752
753         return ret;
754 }
755
756 static inline void drv_set_rekey_data(struct ieee80211_local *local,
757                                       struct ieee80211_sub_if_data *sdata,
758                                       struct cfg80211_gtk_rekey_data *data)
759 {
760         if (!check_sdata_in_driver(sdata))
761                 return;
762
763         trace_drv_set_rekey_data(local, sdata, data);
764         if (local->ops->set_rekey_data)
765                 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
766         trace_drv_return_void(local);
767 }
768
769 static inline void drv_event_callback(struct ieee80211_local *local,
770                                       struct ieee80211_sub_if_data *sdata,
771                                       const struct ieee80211_event *event)
772 {
773         trace_drv_event_callback(local, sdata, event);
774         if (local->ops->event_callback)
775                 local->ops->event_callback(&local->hw, &sdata->vif, event);
776         trace_drv_return_void(local);
777 }
778
779 static inline void
780 drv_release_buffered_frames(struct ieee80211_local *local,
781                             struct sta_info *sta, u16 tids, int num_frames,
782                             enum ieee80211_frame_release_type reason,
783                             bool more_data)
784 {
785         trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
786                                           reason, more_data);
787         if (local->ops->release_buffered_frames)
788                 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
789                                                     num_frames, reason,
790                                                     more_data);
791         trace_drv_return_void(local);
792 }
793
794 static inline void
795 drv_allow_buffered_frames(struct ieee80211_local *local,
796                           struct sta_info *sta, u16 tids, int num_frames,
797                           enum ieee80211_frame_release_type reason,
798                           bool more_data)
799 {
800         trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
801                                         reason, more_data);
802         if (local->ops->allow_buffered_frames)
803                 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
804                                                   tids, num_frames, reason,
805                                                   more_data);
806         trace_drv_return_void(local);
807 }
808
809 static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
810                                       struct ieee80211_sub_if_data *sdata)
811 {
812         might_sleep();
813
814         if (!check_sdata_in_driver(sdata))
815                 return;
816         WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
817
818         trace_drv_mgd_prepare_tx(local, sdata);
819         if (local->ops->mgd_prepare_tx)
820                 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
821         trace_drv_return_void(local);
822 }
823
824 static inline void
825 drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
826                               struct ieee80211_sub_if_data *sdata)
827 {
828         might_sleep();
829
830         if (!check_sdata_in_driver(sdata))
831                 return;
832         WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
833
834         trace_drv_mgd_protect_tdls_discover(local, sdata);
835         if (local->ops->mgd_protect_tdls_discover)
836                 local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
837         trace_drv_return_void(local);
838 }
839
840 static inline int drv_add_chanctx(struct ieee80211_local *local,
841                                   struct ieee80211_chanctx *ctx)
842 {
843         int ret = -EOPNOTSUPP;
844
845         might_sleep();
846
847         trace_drv_add_chanctx(local, ctx);
848         if (local->ops->add_chanctx)
849                 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
850         trace_drv_return_int(local, ret);
851         if (!ret)
852                 ctx->driver_present = true;
853
854         return ret;
855 }
856
857 static inline void drv_remove_chanctx(struct ieee80211_local *local,
858                                       struct ieee80211_chanctx *ctx)
859 {
860         might_sleep();
861
862         if (WARN_ON(!ctx->driver_present))
863                 return;
864
865         trace_drv_remove_chanctx(local, ctx);
866         if (local->ops->remove_chanctx)
867                 local->ops->remove_chanctx(&local->hw, &ctx->conf);
868         trace_drv_return_void(local);
869         ctx->driver_present = false;
870 }
871
872 static inline void drv_change_chanctx(struct ieee80211_local *local,
873                                       struct ieee80211_chanctx *ctx,
874                                       u32 changed)
875 {
876         might_sleep();
877
878         trace_drv_change_chanctx(local, ctx, changed);
879         if (local->ops->change_chanctx) {
880                 WARN_ON_ONCE(!ctx->driver_present);
881                 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
882         }
883         trace_drv_return_void(local);
884 }
885
886 static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
887                                          struct ieee80211_sub_if_data *sdata,
888                                          struct ieee80211_chanctx *ctx)
889 {
890         int ret = 0;
891
892         if (!check_sdata_in_driver(sdata))
893                 return -EIO;
894
895         trace_drv_assign_vif_chanctx(local, sdata, ctx);
896         if (local->ops->assign_vif_chanctx) {
897                 WARN_ON_ONCE(!ctx->driver_present);
898                 ret = local->ops->assign_vif_chanctx(&local->hw,
899                                                      &sdata->vif,
900                                                      &ctx->conf);
901         }
902         trace_drv_return_int(local, ret);
903
904         return ret;
905 }
906
907 static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
908                                             struct ieee80211_sub_if_data *sdata,
909                                             struct ieee80211_chanctx *ctx)
910 {
911         might_sleep();
912
913         if (!check_sdata_in_driver(sdata))
914                 return;
915
916         trace_drv_unassign_vif_chanctx(local, sdata, ctx);
917         if (local->ops->unassign_vif_chanctx) {
918                 WARN_ON_ONCE(!ctx->driver_present);
919                 local->ops->unassign_vif_chanctx(&local->hw,
920                                                  &sdata->vif,
921                                                  &ctx->conf);
922         }
923         trace_drv_return_void(local);
924 }
925
926 int drv_switch_vif_chanctx(struct ieee80211_local *local,
927                            struct ieee80211_vif_chanctx_switch *vifs,
928                            int n_vifs, enum ieee80211_chanctx_switch_mode mode);
929
930 static inline int drv_start_ap(struct ieee80211_local *local,
931                                struct ieee80211_sub_if_data *sdata)
932 {
933         int ret = 0;
934
935         might_sleep();
936
937         if (!check_sdata_in_driver(sdata))
938                 return -EIO;
939
940         trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
941         if (local->ops->start_ap)
942                 ret = local->ops->start_ap(&local->hw, &sdata->vif);
943         trace_drv_return_int(local, ret);
944         return ret;
945 }
946
947 static inline void drv_stop_ap(struct ieee80211_local *local,
948                                struct ieee80211_sub_if_data *sdata)
949 {
950         if (!check_sdata_in_driver(sdata))
951                 return;
952
953         trace_drv_stop_ap(local, sdata);
954         if (local->ops->stop_ap)
955                 local->ops->stop_ap(&local->hw, &sdata->vif);
956         trace_drv_return_void(local);
957 }
958
959 static inline void
960 drv_reconfig_complete(struct ieee80211_local *local,
961                       enum ieee80211_reconfig_type reconfig_type)
962 {
963         might_sleep();
964
965         trace_drv_reconfig_complete(local, reconfig_type);
966         if (local->ops->reconfig_complete)
967                 local->ops->reconfig_complete(&local->hw, reconfig_type);
968         trace_drv_return_void(local);
969 }
970
971 static inline void
972 drv_set_default_unicast_key(struct ieee80211_local *local,
973                             struct ieee80211_sub_if_data *sdata,
974                             int key_idx)
975 {
976         if (!check_sdata_in_driver(sdata))
977                 return;
978
979         WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
980
981         trace_drv_set_default_unicast_key(local, sdata, key_idx);
982         if (local->ops->set_default_unicast_key)
983                 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
984                                                     key_idx);
985         trace_drv_return_void(local);
986 }
987
988 #if IS_ENABLED(CONFIG_IPV6)
989 static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
990                                         struct ieee80211_sub_if_data *sdata,
991                                         struct inet6_dev *idev)
992 {
993         trace_drv_ipv6_addr_change(local, sdata);
994         if (local->ops->ipv6_addr_change)
995                 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
996         trace_drv_return_void(local);
997 }
998 #endif
999
1000 static inline void
1001 drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1002                           struct cfg80211_chan_def *chandef)
1003 {
1004         struct ieee80211_local *local = sdata->local;
1005
1006         if (local->ops->channel_switch_beacon) {
1007                 trace_drv_channel_switch_beacon(local, sdata, chandef);
1008                 local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1009                                                   chandef);
1010         }
1011 }
1012
1013 static inline int
1014 drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
1015                        struct ieee80211_channel_switch *ch_switch)
1016 {
1017         struct ieee80211_local *local = sdata->local;
1018         int ret = 0;
1019
1020         if (!check_sdata_in_driver(sdata))
1021                 return -EIO;
1022
1023         trace_drv_pre_channel_switch(local, sdata, ch_switch);
1024         if (local->ops->pre_channel_switch)
1025                 ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
1026                                                      ch_switch);
1027         trace_drv_return_int(local, ret);
1028         return ret;
1029 }
1030
1031 static inline int
1032 drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1033 {
1034         struct ieee80211_local *local = sdata->local;
1035         int ret = 0;
1036
1037         if (!check_sdata_in_driver(sdata))
1038                 return -EIO;
1039
1040         trace_drv_post_channel_switch(local, sdata);
1041         if (local->ops->post_channel_switch)
1042                 ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1043         trace_drv_return_int(local, ret);
1044         return ret;
1045 }
1046
1047 static inline int drv_join_ibss(struct ieee80211_local *local,
1048                                 struct ieee80211_sub_if_data *sdata)
1049 {
1050         int ret = 0;
1051
1052         might_sleep();
1053         if (!check_sdata_in_driver(sdata))
1054                 return -EIO;
1055
1056         trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1057         if (local->ops->join_ibss)
1058                 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1059         trace_drv_return_int(local, ret);
1060         return ret;
1061 }
1062
1063 static inline void drv_leave_ibss(struct ieee80211_local *local,
1064                                   struct ieee80211_sub_if_data *sdata)
1065 {
1066         might_sleep();
1067         if (!check_sdata_in_driver(sdata))
1068                 return;
1069
1070         trace_drv_leave_ibss(local, sdata);
1071         if (local->ops->leave_ibss)
1072                 local->ops->leave_ibss(&local->hw, &sdata->vif);
1073         trace_drv_return_void(local);
1074 }
1075
1076 static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
1077                                               struct sta_info *sta)
1078 {
1079         u32 ret = 0;
1080
1081         trace_drv_get_expected_throughput(&sta->sta);
1082         if (local->ops->get_expected_throughput && sta->uploaded)
1083                 ret = local->ops->get_expected_throughput(&local->hw, &sta->sta);
1084         trace_drv_return_u32(local, ret);
1085
1086         return ret;
1087 }
1088
1089 static inline int drv_get_txpower(struct ieee80211_local *local,
1090                                   struct ieee80211_sub_if_data *sdata, int *dbm)
1091 {
1092         int ret;
1093
1094         if (!local->ops->get_txpower)
1095                 return -EOPNOTSUPP;
1096
1097         ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
1098         trace_drv_get_txpower(local, sdata, *dbm, ret);
1099
1100         return ret;
1101 }
1102
1103 static inline int
1104 drv_tdls_channel_switch(struct ieee80211_local *local,
1105                         struct ieee80211_sub_if_data *sdata,
1106                         struct ieee80211_sta *sta, u8 oper_class,
1107                         struct cfg80211_chan_def *chandef,
1108                         struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
1109 {
1110         int ret;
1111
1112         might_sleep();
1113         if (!check_sdata_in_driver(sdata))
1114                 return -EIO;
1115
1116         if (!local->ops->tdls_channel_switch)
1117                 return -EOPNOTSUPP;
1118
1119         trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
1120         ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
1121                                               oper_class, chandef, tmpl_skb,
1122                                               ch_sw_tm_ie);
1123         trace_drv_return_int(local, ret);
1124         return ret;
1125 }
1126
1127 static inline void
1128 drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
1129                                struct ieee80211_sub_if_data *sdata,
1130                                struct ieee80211_sta *sta)
1131 {
1132         might_sleep();
1133         if (!check_sdata_in_driver(sdata))
1134                 return;
1135
1136         if (!local->ops->tdls_cancel_channel_switch)
1137                 return;
1138
1139         trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
1140         local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
1141         trace_drv_return_void(local);
1142 }
1143
1144 static inline void
1145 drv_tdls_recv_channel_switch(struct ieee80211_local *local,
1146                              struct ieee80211_sub_if_data *sdata,
1147                              struct ieee80211_tdls_ch_sw_params *params)
1148 {
1149         trace_drv_tdls_recv_channel_switch(local, sdata, params);
1150         if (local->ops->tdls_recv_channel_switch)
1151                 local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
1152                                                      params);
1153         trace_drv_return_void(local);
1154 }
1155
1156 static inline void drv_wake_tx_queue(struct ieee80211_local *local,
1157                                      struct txq_info *txq)
1158 {
1159         struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
1160
1161         if (!check_sdata_in_driver(sdata))
1162                 return;
1163
1164         trace_drv_wake_tx_queue(local, sdata, txq);
1165         local->ops->wake_tx_queue(&local->hw, &txq->txq);
1166 }
1167
1168 #endif /* __MAC80211_DRIVER_OPS */