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