0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __MAC80211_DRIVER_OPS
0009 #define __MAC80211_DRIVER_OPS
0010
0011 #include <net/mac80211.h>
0012 #include "ieee80211_i.h"
0013 #include "trace.h"
0014
0015 #define check_sdata_in_driver(sdata) ({ \
0016 !WARN_ONCE(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER), \
0017 "%s: Failed check-sdata-in-driver check, flags: 0x%x\n", \
0018 sdata->dev ? sdata->dev->name : sdata->name, sdata->flags); \
0019 })
0020
0021 static inline struct ieee80211_sub_if_data *
0022 get_bss_sdata(struct ieee80211_sub_if_data *sdata)
0023 {
0024 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
0025 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
0026 u.ap);
0027
0028 return sdata;
0029 }
0030
0031 static inline void drv_tx(struct ieee80211_local *local,
0032 struct ieee80211_tx_control *control,
0033 struct sk_buff *skb)
0034 {
0035 local->ops->tx(&local->hw, control, skb);
0036 }
0037
0038 static inline void drv_sync_rx_queues(struct ieee80211_local *local,
0039 struct sta_info *sta)
0040 {
0041 if (local->ops->sync_rx_queues) {
0042 trace_drv_sync_rx_queues(local, sta->sdata, &sta->sta);
0043 local->ops->sync_rx_queues(&local->hw);
0044 trace_drv_return_void(local);
0045 }
0046 }
0047
0048 static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata,
0049 u32 sset, u8 *data)
0050 {
0051 struct ieee80211_local *local = sdata->local;
0052 if (local->ops->get_et_strings) {
0053 trace_drv_get_et_strings(local, sset);
0054 local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data);
0055 trace_drv_return_void(local);
0056 }
0057 }
0058
0059 static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata,
0060 struct ethtool_stats *stats,
0061 u64 *data)
0062 {
0063 struct ieee80211_local *local = sdata->local;
0064 if (local->ops->get_et_stats) {
0065 trace_drv_get_et_stats(local);
0066 local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data);
0067 trace_drv_return_void(local);
0068 }
0069 }
0070
0071 static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata,
0072 int sset)
0073 {
0074 struct ieee80211_local *local = sdata->local;
0075 int rv = 0;
0076 if (local->ops->get_et_sset_count) {
0077 trace_drv_get_et_sset_count(local, sset);
0078 rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif,
0079 sset);
0080 trace_drv_return_int(local, rv);
0081 }
0082 return rv;
0083 }
0084
0085 int drv_start(struct ieee80211_local *local);
0086 void drv_stop(struct ieee80211_local *local);
0087
0088 #ifdef CONFIG_PM
0089 static inline int drv_suspend(struct ieee80211_local *local,
0090 struct cfg80211_wowlan *wowlan)
0091 {
0092 int ret;
0093
0094 might_sleep();
0095
0096 trace_drv_suspend(local);
0097 ret = local->ops->suspend(&local->hw, wowlan);
0098 trace_drv_return_int(local, ret);
0099 return ret;
0100 }
0101
0102 static inline int drv_resume(struct ieee80211_local *local)
0103 {
0104 int ret;
0105
0106 might_sleep();
0107
0108 trace_drv_resume(local);
0109 ret = local->ops->resume(&local->hw);
0110 trace_drv_return_int(local, ret);
0111 return ret;
0112 }
0113
0114 static inline void drv_set_wakeup(struct ieee80211_local *local,
0115 bool enabled)
0116 {
0117 might_sleep();
0118
0119 if (!local->ops->set_wakeup)
0120 return;
0121
0122 trace_drv_set_wakeup(local, enabled);
0123 local->ops->set_wakeup(&local->hw, enabled);
0124 trace_drv_return_void(local);
0125 }
0126 #endif
0127
0128 int drv_add_interface(struct ieee80211_local *local,
0129 struct ieee80211_sub_if_data *sdata);
0130
0131 int drv_change_interface(struct ieee80211_local *local,
0132 struct ieee80211_sub_if_data *sdata,
0133 enum nl80211_iftype type, bool p2p);
0134
0135 void drv_remove_interface(struct ieee80211_local *local,
0136 struct ieee80211_sub_if_data *sdata);
0137
0138 static inline int drv_config(struct ieee80211_local *local, u32 changed)
0139 {
0140 int ret;
0141
0142 might_sleep();
0143
0144 trace_drv_config(local, changed);
0145 ret = local->ops->config(&local->hw, changed);
0146 trace_drv_return_int(local, ret);
0147 return ret;
0148 }
0149
0150 static inline void drv_vif_cfg_changed(struct ieee80211_local *local,
0151 struct ieee80211_sub_if_data *sdata,
0152 u64 changed)
0153 {
0154 might_sleep();
0155
0156 if (!check_sdata_in_driver(sdata))
0157 return;
0158
0159 trace_drv_vif_cfg_changed(local, sdata, changed);
0160 if (local->ops->vif_cfg_changed)
0161 local->ops->vif_cfg_changed(&local->hw, &sdata->vif, changed);
0162 else if (local->ops->bss_info_changed)
0163 local->ops->bss_info_changed(&local->hw, &sdata->vif,
0164 &sdata->vif.bss_conf, changed);
0165 trace_drv_return_void(local);
0166 }
0167
0168 static inline void drv_link_info_changed(struct ieee80211_local *local,
0169 struct ieee80211_sub_if_data *sdata,
0170 struct ieee80211_bss_conf *info,
0171 int link_id, u64 changed)
0172 {
0173 might_sleep();
0174
0175 if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
0176 BSS_CHANGED_BEACON_ENABLED) &&
0177 sdata->vif.type != NL80211_IFTYPE_AP &&
0178 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
0179 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
0180 sdata->vif.type != NL80211_IFTYPE_OCB))
0181 return;
0182
0183 if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
0184 sdata->vif.type == NL80211_IFTYPE_NAN ||
0185 (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
0186 !sdata->vif.bss_conf.mu_mimo_owner &&
0187 !(changed & BSS_CHANGED_TXPOWER))))
0188 return;
0189
0190 if (!check_sdata_in_driver(sdata))
0191 return;
0192
0193 trace_drv_link_info_changed(local, sdata, info, changed);
0194 if (local->ops->link_info_changed)
0195 local->ops->link_info_changed(&local->hw, &sdata->vif,
0196 info, changed);
0197 else if (local->ops->bss_info_changed)
0198 local->ops->bss_info_changed(&local->hw, &sdata->vif,
0199 info, changed);
0200 trace_drv_return_void(local);
0201 }
0202
0203 static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
0204 struct netdev_hw_addr_list *mc_list)
0205 {
0206 u64 ret = 0;
0207
0208 trace_drv_prepare_multicast(local, mc_list->count);
0209
0210 if (local->ops->prepare_multicast)
0211 ret = local->ops->prepare_multicast(&local->hw, mc_list);
0212
0213 trace_drv_return_u64(local, ret);
0214
0215 return ret;
0216 }
0217
0218 static inline void drv_configure_filter(struct ieee80211_local *local,
0219 unsigned int changed_flags,
0220 unsigned int *total_flags,
0221 u64 multicast)
0222 {
0223 might_sleep();
0224
0225 trace_drv_configure_filter(local, changed_flags, total_flags,
0226 multicast);
0227 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
0228 multicast);
0229 trace_drv_return_void(local);
0230 }
0231
0232 static inline void drv_config_iface_filter(struct ieee80211_local *local,
0233 struct ieee80211_sub_if_data *sdata,
0234 unsigned int filter_flags,
0235 unsigned int changed_flags)
0236 {
0237 might_sleep();
0238
0239 trace_drv_config_iface_filter(local, sdata, filter_flags,
0240 changed_flags);
0241 if (local->ops->config_iface_filter)
0242 local->ops->config_iface_filter(&local->hw, &sdata->vif,
0243 filter_flags,
0244 changed_flags);
0245 trace_drv_return_void(local);
0246 }
0247
0248 static inline int drv_set_tim(struct ieee80211_local *local,
0249 struct ieee80211_sta *sta, bool set)
0250 {
0251 int ret = 0;
0252 trace_drv_set_tim(local, sta, set);
0253 if (local->ops->set_tim)
0254 ret = local->ops->set_tim(&local->hw, sta, set);
0255 trace_drv_return_int(local, ret);
0256 return ret;
0257 }
0258
0259 static inline int drv_set_key(struct ieee80211_local *local,
0260 enum set_key_cmd cmd,
0261 struct ieee80211_sub_if_data *sdata,
0262 struct ieee80211_sta *sta,
0263 struct ieee80211_key_conf *key)
0264 {
0265 int ret;
0266
0267 might_sleep();
0268
0269 sdata = get_bss_sdata(sdata);
0270 if (!check_sdata_in_driver(sdata))
0271 return -EIO;
0272
0273 trace_drv_set_key(local, cmd, sdata, sta, key);
0274 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
0275 trace_drv_return_int(local, ret);
0276 return ret;
0277 }
0278
0279 static inline void drv_update_tkip_key(struct ieee80211_local *local,
0280 struct ieee80211_sub_if_data *sdata,
0281 struct ieee80211_key_conf *conf,
0282 struct sta_info *sta, u32 iv32,
0283 u16 *phase1key)
0284 {
0285 struct ieee80211_sta *ista = NULL;
0286
0287 if (sta)
0288 ista = &sta->sta;
0289
0290 sdata = get_bss_sdata(sdata);
0291 if (!check_sdata_in_driver(sdata))
0292 return;
0293
0294 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
0295 if (local->ops->update_tkip_key)
0296 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
0297 ista, iv32, phase1key);
0298 trace_drv_return_void(local);
0299 }
0300
0301 static inline int drv_hw_scan(struct ieee80211_local *local,
0302 struct ieee80211_sub_if_data *sdata,
0303 struct ieee80211_scan_request *req)
0304 {
0305 int ret;
0306
0307 might_sleep();
0308
0309 if (!check_sdata_in_driver(sdata))
0310 return -EIO;
0311
0312 trace_drv_hw_scan(local, sdata);
0313 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
0314 trace_drv_return_int(local, ret);
0315 return ret;
0316 }
0317
0318 static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
0319 struct ieee80211_sub_if_data *sdata)
0320 {
0321 might_sleep();
0322
0323 if (!check_sdata_in_driver(sdata))
0324 return;
0325
0326 trace_drv_cancel_hw_scan(local, sdata);
0327 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
0328 trace_drv_return_void(local);
0329 }
0330
0331 static inline int
0332 drv_sched_scan_start(struct ieee80211_local *local,
0333 struct ieee80211_sub_if_data *sdata,
0334 struct cfg80211_sched_scan_request *req,
0335 struct ieee80211_scan_ies *ies)
0336 {
0337 int ret;
0338
0339 might_sleep();
0340
0341 if (!check_sdata_in_driver(sdata))
0342 return -EIO;
0343
0344 trace_drv_sched_scan_start(local, sdata);
0345 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
0346 req, ies);
0347 trace_drv_return_int(local, ret);
0348 return ret;
0349 }
0350
0351 static inline int drv_sched_scan_stop(struct ieee80211_local *local,
0352 struct ieee80211_sub_if_data *sdata)
0353 {
0354 int ret;
0355
0356 might_sleep();
0357
0358 if (!check_sdata_in_driver(sdata))
0359 return -EIO;
0360
0361 trace_drv_sched_scan_stop(local, sdata);
0362 ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
0363 trace_drv_return_int(local, ret);
0364
0365 return ret;
0366 }
0367
0368 static inline void drv_sw_scan_start(struct ieee80211_local *local,
0369 struct ieee80211_sub_if_data *sdata,
0370 const u8 *mac_addr)
0371 {
0372 might_sleep();
0373
0374 trace_drv_sw_scan_start(local, sdata, mac_addr);
0375 if (local->ops->sw_scan_start)
0376 local->ops->sw_scan_start(&local->hw, &sdata->vif, mac_addr);
0377 trace_drv_return_void(local);
0378 }
0379
0380 static inline void drv_sw_scan_complete(struct ieee80211_local *local,
0381 struct ieee80211_sub_if_data *sdata)
0382 {
0383 might_sleep();
0384
0385 trace_drv_sw_scan_complete(local, sdata);
0386 if (local->ops->sw_scan_complete)
0387 local->ops->sw_scan_complete(&local->hw, &sdata->vif);
0388 trace_drv_return_void(local);
0389 }
0390
0391 static inline int drv_get_stats(struct ieee80211_local *local,
0392 struct ieee80211_low_level_stats *stats)
0393 {
0394 int ret = -EOPNOTSUPP;
0395
0396 might_sleep();
0397
0398 if (local->ops->get_stats)
0399 ret = local->ops->get_stats(&local->hw, stats);
0400 trace_drv_get_stats(local, stats, ret);
0401
0402 return ret;
0403 }
0404
0405 static inline void drv_get_key_seq(struct ieee80211_local *local,
0406 struct ieee80211_key *key,
0407 struct ieee80211_key_seq *seq)
0408 {
0409 if (local->ops->get_key_seq)
0410 local->ops->get_key_seq(&local->hw, &key->conf, seq);
0411 trace_drv_get_key_seq(local, &key->conf);
0412 }
0413
0414 static inline int drv_set_frag_threshold(struct ieee80211_local *local,
0415 u32 value)
0416 {
0417 int ret = 0;
0418
0419 might_sleep();
0420
0421 trace_drv_set_frag_threshold(local, value);
0422 if (local->ops->set_frag_threshold)
0423 ret = local->ops->set_frag_threshold(&local->hw, value);
0424 trace_drv_return_int(local, ret);
0425 return ret;
0426 }
0427
0428 static inline int drv_set_rts_threshold(struct ieee80211_local *local,
0429 u32 value)
0430 {
0431 int ret = 0;
0432
0433 might_sleep();
0434
0435 trace_drv_set_rts_threshold(local, value);
0436 if (local->ops->set_rts_threshold)
0437 ret = local->ops->set_rts_threshold(&local->hw, value);
0438 trace_drv_return_int(local, ret);
0439 return ret;
0440 }
0441
0442 static inline int drv_set_coverage_class(struct ieee80211_local *local,
0443 s16 value)
0444 {
0445 int ret = 0;
0446 might_sleep();
0447
0448 trace_drv_set_coverage_class(local, value);
0449 if (local->ops->set_coverage_class)
0450 local->ops->set_coverage_class(&local->hw, value);
0451 else
0452 ret = -EOPNOTSUPP;
0453
0454 trace_drv_return_int(local, ret);
0455 return ret;
0456 }
0457
0458 static inline void drv_sta_notify(struct ieee80211_local *local,
0459 struct ieee80211_sub_if_data *sdata,
0460 enum sta_notify_cmd cmd,
0461 struct ieee80211_sta *sta)
0462 {
0463 sdata = get_bss_sdata(sdata);
0464 if (!check_sdata_in_driver(sdata))
0465 return;
0466
0467 trace_drv_sta_notify(local, sdata, cmd, sta);
0468 if (local->ops->sta_notify)
0469 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
0470 trace_drv_return_void(local);
0471 }
0472
0473 static inline int drv_sta_add(struct ieee80211_local *local,
0474 struct ieee80211_sub_if_data *sdata,
0475 struct ieee80211_sta *sta)
0476 {
0477 int ret = 0;
0478
0479 might_sleep();
0480
0481 sdata = get_bss_sdata(sdata);
0482 if (!check_sdata_in_driver(sdata))
0483 return -EIO;
0484
0485 trace_drv_sta_add(local, sdata, sta);
0486 if (local->ops->sta_add)
0487 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
0488
0489 trace_drv_return_int(local, ret);
0490
0491 return ret;
0492 }
0493
0494 static inline void drv_sta_remove(struct ieee80211_local *local,
0495 struct ieee80211_sub_if_data *sdata,
0496 struct ieee80211_sta *sta)
0497 {
0498 might_sleep();
0499
0500 sdata = get_bss_sdata(sdata);
0501 if (!check_sdata_in_driver(sdata))
0502 return;
0503
0504 trace_drv_sta_remove(local, sdata, sta);
0505 if (local->ops->sta_remove)
0506 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
0507
0508 trace_drv_return_void(local);
0509 }
0510
0511 #ifdef CONFIG_MAC80211_DEBUGFS
0512 static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
0513 struct ieee80211_sub_if_data *sdata,
0514 struct ieee80211_sta *sta,
0515 struct dentry *dir)
0516 {
0517 might_sleep();
0518
0519 sdata = get_bss_sdata(sdata);
0520 if (!check_sdata_in_driver(sdata))
0521 return;
0522
0523 if (local->ops->sta_add_debugfs)
0524 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
0525 sta, dir);
0526 }
0527 #endif
0528
0529 static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
0530 struct ieee80211_sub_if_data *sdata,
0531 struct sta_info *sta)
0532 {
0533 might_sleep();
0534
0535 sdata = get_bss_sdata(sdata);
0536 if (!check_sdata_in_driver(sdata))
0537 return;
0538
0539 trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
0540 if (local->ops->sta_pre_rcu_remove)
0541 local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif,
0542 &sta->sta);
0543 trace_drv_return_void(local);
0544 }
0545
0546 __must_check
0547 int drv_sta_state(struct ieee80211_local *local,
0548 struct ieee80211_sub_if_data *sdata,
0549 struct sta_info *sta,
0550 enum ieee80211_sta_state old_state,
0551 enum ieee80211_sta_state new_state);
0552
0553 __must_check
0554 int drv_sta_set_txpwr(struct ieee80211_local *local,
0555 struct ieee80211_sub_if_data *sdata,
0556 struct sta_info *sta);
0557
0558 void drv_sta_rc_update(struct ieee80211_local *local,
0559 struct ieee80211_sub_if_data *sdata,
0560 struct ieee80211_sta *sta, u32 changed);
0561
0562 static inline void drv_sta_rate_tbl_update(struct ieee80211_local *local,
0563 struct ieee80211_sub_if_data *sdata,
0564 struct ieee80211_sta *sta)
0565 {
0566 sdata = get_bss_sdata(sdata);
0567 if (!check_sdata_in_driver(sdata))
0568 return;
0569
0570 trace_drv_sta_rate_tbl_update(local, sdata, sta);
0571 if (local->ops->sta_rate_tbl_update)
0572 local->ops->sta_rate_tbl_update(&local->hw, &sdata->vif, sta);
0573
0574 trace_drv_return_void(local);
0575 }
0576
0577 static inline void drv_sta_statistics(struct ieee80211_local *local,
0578 struct ieee80211_sub_if_data *sdata,
0579 struct ieee80211_sta *sta,
0580 struct station_info *sinfo)
0581 {
0582 sdata = get_bss_sdata(sdata);
0583 if (!check_sdata_in_driver(sdata))
0584 return;
0585
0586 trace_drv_sta_statistics(local, sdata, sta);
0587 if (local->ops->sta_statistics)
0588 local->ops->sta_statistics(&local->hw, &sdata->vif, sta, sinfo);
0589 trace_drv_return_void(local);
0590 }
0591
0592 int drv_conf_tx(struct ieee80211_local *local,
0593 struct ieee80211_link_data *link, u16 ac,
0594 const struct ieee80211_tx_queue_params *params);
0595
0596 u64 drv_get_tsf(struct ieee80211_local *local,
0597 struct ieee80211_sub_if_data *sdata);
0598 void drv_set_tsf(struct ieee80211_local *local,
0599 struct ieee80211_sub_if_data *sdata,
0600 u64 tsf);
0601 void drv_offset_tsf(struct ieee80211_local *local,
0602 struct ieee80211_sub_if_data *sdata,
0603 s64 offset);
0604 void drv_reset_tsf(struct ieee80211_local *local,
0605 struct ieee80211_sub_if_data *sdata);
0606
0607 static inline int drv_tx_last_beacon(struct ieee80211_local *local)
0608 {
0609 int ret = 0;
0610
0611 might_sleep();
0612
0613 trace_drv_tx_last_beacon(local);
0614 if (local->ops->tx_last_beacon)
0615 ret = local->ops->tx_last_beacon(&local->hw);
0616 trace_drv_return_int(local, ret);
0617 return ret;
0618 }
0619
0620 int drv_ampdu_action(struct ieee80211_local *local,
0621 struct ieee80211_sub_if_data *sdata,
0622 struct ieee80211_ampdu_params *params);
0623
0624 static inline int drv_get_survey(struct ieee80211_local *local, int idx,
0625 struct survey_info *survey)
0626 {
0627 int ret = -EOPNOTSUPP;
0628
0629 trace_drv_get_survey(local, idx, survey);
0630
0631 if (local->ops->get_survey)
0632 ret = local->ops->get_survey(&local->hw, idx, survey);
0633
0634 trace_drv_return_int(local, ret);
0635
0636 return ret;
0637 }
0638
0639 static inline void drv_rfkill_poll(struct ieee80211_local *local)
0640 {
0641 might_sleep();
0642
0643 if (local->ops->rfkill_poll)
0644 local->ops->rfkill_poll(&local->hw);
0645 }
0646
0647 static inline void drv_flush(struct ieee80211_local *local,
0648 struct ieee80211_sub_if_data *sdata,
0649 u32 queues, bool drop)
0650 {
0651 struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL;
0652
0653 might_sleep();
0654
0655 if (sdata && !check_sdata_in_driver(sdata))
0656 return;
0657
0658 trace_drv_flush(local, queues, drop);
0659 if (local->ops->flush)
0660 local->ops->flush(&local->hw, vif, queues, drop);
0661 trace_drv_return_void(local);
0662 }
0663
0664 static inline void drv_channel_switch(struct ieee80211_local *local,
0665 struct ieee80211_sub_if_data *sdata,
0666 struct ieee80211_channel_switch *ch_switch)
0667 {
0668 might_sleep();
0669
0670 trace_drv_channel_switch(local, sdata, ch_switch);
0671 local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch);
0672 trace_drv_return_void(local);
0673 }
0674
0675
0676 static inline int drv_set_antenna(struct ieee80211_local *local,
0677 u32 tx_ant, u32 rx_ant)
0678 {
0679 int ret = -EOPNOTSUPP;
0680 might_sleep();
0681 if (local->ops->set_antenna)
0682 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
0683 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
0684 return ret;
0685 }
0686
0687 static inline int drv_get_antenna(struct ieee80211_local *local,
0688 u32 *tx_ant, u32 *rx_ant)
0689 {
0690 int ret = -EOPNOTSUPP;
0691 might_sleep();
0692 if (local->ops->get_antenna)
0693 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
0694 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
0695 return ret;
0696 }
0697
0698 static inline int drv_remain_on_channel(struct ieee80211_local *local,
0699 struct ieee80211_sub_if_data *sdata,
0700 struct ieee80211_channel *chan,
0701 unsigned int duration,
0702 enum ieee80211_roc_type type)
0703 {
0704 int ret;
0705
0706 might_sleep();
0707
0708 trace_drv_remain_on_channel(local, sdata, chan, duration, type);
0709 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif,
0710 chan, duration, type);
0711 trace_drv_return_int(local, ret);
0712
0713 return ret;
0714 }
0715
0716 static inline int
0717 drv_cancel_remain_on_channel(struct ieee80211_local *local,
0718 struct ieee80211_sub_if_data *sdata)
0719 {
0720 int ret;
0721
0722 might_sleep();
0723
0724 trace_drv_cancel_remain_on_channel(local, sdata);
0725 ret = local->ops->cancel_remain_on_channel(&local->hw, &sdata->vif);
0726 trace_drv_return_int(local, ret);
0727
0728 return ret;
0729 }
0730
0731 static inline int drv_set_ringparam(struct ieee80211_local *local,
0732 u32 tx, u32 rx)
0733 {
0734 int ret = -ENOTSUPP;
0735
0736 might_sleep();
0737
0738 trace_drv_set_ringparam(local, tx, rx);
0739 if (local->ops->set_ringparam)
0740 ret = local->ops->set_ringparam(&local->hw, tx, rx);
0741 trace_drv_return_int(local, ret);
0742
0743 return ret;
0744 }
0745
0746 static inline void drv_get_ringparam(struct ieee80211_local *local,
0747 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
0748 {
0749 might_sleep();
0750
0751 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
0752 if (local->ops->get_ringparam)
0753 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
0754 trace_drv_return_void(local);
0755 }
0756
0757 static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
0758 {
0759 bool ret = false;
0760
0761 might_sleep();
0762
0763 trace_drv_tx_frames_pending(local);
0764 if (local->ops->tx_frames_pending)
0765 ret = local->ops->tx_frames_pending(&local->hw);
0766 trace_drv_return_bool(local, ret);
0767
0768 return ret;
0769 }
0770
0771 static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
0772 struct ieee80211_sub_if_data *sdata,
0773 const struct cfg80211_bitrate_mask *mask)
0774 {
0775 int ret = -EOPNOTSUPP;
0776
0777 might_sleep();
0778
0779 if (!check_sdata_in_driver(sdata))
0780 return -EIO;
0781
0782 trace_drv_set_bitrate_mask(local, sdata, mask);
0783 if (local->ops->set_bitrate_mask)
0784 ret = local->ops->set_bitrate_mask(&local->hw,
0785 &sdata->vif, mask);
0786 trace_drv_return_int(local, ret);
0787
0788 return ret;
0789 }
0790
0791 static inline void drv_set_rekey_data(struct ieee80211_local *local,
0792 struct ieee80211_sub_if_data *sdata,
0793 struct cfg80211_gtk_rekey_data *data)
0794 {
0795 if (!check_sdata_in_driver(sdata))
0796 return;
0797
0798 trace_drv_set_rekey_data(local, sdata, data);
0799 if (local->ops->set_rekey_data)
0800 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
0801 trace_drv_return_void(local);
0802 }
0803
0804 static inline void drv_event_callback(struct ieee80211_local *local,
0805 struct ieee80211_sub_if_data *sdata,
0806 const struct ieee80211_event *event)
0807 {
0808 trace_drv_event_callback(local, sdata, event);
0809 if (local->ops->event_callback)
0810 local->ops->event_callback(&local->hw, &sdata->vif, event);
0811 trace_drv_return_void(local);
0812 }
0813
0814 static inline void
0815 drv_release_buffered_frames(struct ieee80211_local *local,
0816 struct sta_info *sta, u16 tids, int num_frames,
0817 enum ieee80211_frame_release_type reason,
0818 bool more_data)
0819 {
0820 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
0821 reason, more_data);
0822 if (local->ops->release_buffered_frames)
0823 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
0824 num_frames, reason,
0825 more_data);
0826 trace_drv_return_void(local);
0827 }
0828
0829 static inline void
0830 drv_allow_buffered_frames(struct ieee80211_local *local,
0831 struct sta_info *sta, u16 tids, int num_frames,
0832 enum ieee80211_frame_release_type reason,
0833 bool more_data)
0834 {
0835 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
0836 reason, more_data);
0837 if (local->ops->allow_buffered_frames)
0838 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
0839 tids, num_frames, reason,
0840 more_data);
0841 trace_drv_return_void(local);
0842 }
0843
0844 static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
0845 struct ieee80211_sub_if_data *sdata,
0846 struct ieee80211_prep_tx_info *info)
0847 {
0848 might_sleep();
0849
0850 if (!check_sdata_in_driver(sdata))
0851 return;
0852 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
0853
0854 trace_drv_mgd_prepare_tx(local, sdata, info->duration,
0855 info->subtype, info->success);
0856 if (local->ops->mgd_prepare_tx)
0857 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif, info);
0858 trace_drv_return_void(local);
0859 }
0860
0861 static inline void drv_mgd_complete_tx(struct ieee80211_local *local,
0862 struct ieee80211_sub_if_data *sdata,
0863 struct ieee80211_prep_tx_info *info)
0864 {
0865 might_sleep();
0866
0867 if (!check_sdata_in_driver(sdata))
0868 return;
0869 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
0870
0871 trace_drv_mgd_complete_tx(local, sdata, info->duration,
0872 info->subtype, info->success);
0873 if (local->ops->mgd_complete_tx)
0874 local->ops->mgd_complete_tx(&local->hw, &sdata->vif, info);
0875 trace_drv_return_void(local);
0876 }
0877
0878 static inline void
0879 drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
0880 struct ieee80211_sub_if_data *sdata)
0881 {
0882 might_sleep();
0883
0884 if (!check_sdata_in_driver(sdata))
0885 return;
0886 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
0887
0888 trace_drv_mgd_protect_tdls_discover(local, sdata);
0889 if (local->ops->mgd_protect_tdls_discover)
0890 local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
0891 trace_drv_return_void(local);
0892 }
0893
0894 static inline int drv_add_chanctx(struct ieee80211_local *local,
0895 struct ieee80211_chanctx *ctx)
0896 {
0897 int ret = -EOPNOTSUPP;
0898
0899 might_sleep();
0900
0901 trace_drv_add_chanctx(local, ctx);
0902 if (local->ops->add_chanctx)
0903 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
0904 trace_drv_return_int(local, ret);
0905 if (!ret)
0906 ctx->driver_present = true;
0907
0908 return ret;
0909 }
0910
0911 static inline void drv_remove_chanctx(struct ieee80211_local *local,
0912 struct ieee80211_chanctx *ctx)
0913 {
0914 might_sleep();
0915
0916 if (WARN_ON(!ctx->driver_present))
0917 return;
0918
0919 trace_drv_remove_chanctx(local, ctx);
0920 if (local->ops->remove_chanctx)
0921 local->ops->remove_chanctx(&local->hw, &ctx->conf);
0922 trace_drv_return_void(local);
0923 ctx->driver_present = false;
0924 }
0925
0926 static inline void drv_change_chanctx(struct ieee80211_local *local,
0927 struct ieee80211_chanctx *ctx,
0928 u32 changed)
0929 {
0930 might_sleep();
0931
0932 trace_drv_change_chanctx(local, ctx, changed);
0933 if (local->ops->change_chanctx) {
0934 WARN_ON_ONCE(!ctx->driver_present);
0935 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
0936 }
0937 trace_drv_return_void(local);
0938 }
0939
0940 static inline void drv_verify_link_exists(struct ieee80211_sub_if_data *sdata,
0941 struct ieee80211_bss_conf *link_conf)
0942 {
0943
0944 if (sdata->deflink.conf != link_conf)
0945 sdata_assert_lock(sdata);
0946 }
0947
0948 static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
0949 struct ieee80211_sub_if_data *sdata,
0950 struct ieee80211_bss_conf *link_conf,
0951 struct ieee80211_chanctx *ctx)
0952 {
0953 int ret = 0;
0954
0955 drv_verify_link_exists(sdata, link_conf);
0956 if (!check_sdata_in_driver(sdata))
0957 return -EIO;
0958
0959 trace_drv_assign_vif_chanctx(local, sdata, link_conf, ctx);
0960 if (local->ops->assign_vif_chanctx) {
0961 WARN_ON_ONCE(!ctx->driver_present);
0962 ret = local->ops->assign_vif_chanctx(&local->hw,
0963 &sdata->vif,
0964 link_conf,
0965 &ctx->conf);
0966 }
0967 trace_drv_return_int(local, ret);
0968
0969 return ret;
0970 }
0971
0972 static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
0973 struct ieee80211_sub_if_data *sdata,
0974 struct ieee80211_bss_conf *link_conf,
0975 struct ieee80211_chanctx *ctx)
0976 {
0977 might_sleep();
0978
0979 drv_verify_link_exists(sdata, link_conf);
0980 if (!check_sdata_in_driver(sdata))
0981 return;
0982
0983 trace_drv_unassign_vif_chanctx(local, sdata, link_conf, ctx);
0984 if (local->ops->unassign_vif_chanctx) {
0985 WARN_ON_ONCE(!ctx->driver_present);
0986 local->ops->unassign_vif_chanctx(&local->hw,
0987 &sdata->vif,
0988 link_conf,
0989 &ctx->conf);
0990 }
0991 trace_drv_return_void(local);
0992 }
0993
0994 int drv_switch_vif_chanctx(struct ieee80211_local *local,
0995 struct ieee80211_vif_chanctx_switch *vifs,
0996 int n_vifs, enum ieee80211_chanctx_switch_mode mode);
0997
0998 static inline int drv_start_ap(struct ieee80211_local *local,
0999 struct ieee80211_sub_if_data *sdata,
1000 struct ieee80211_bss_conf *link_conf)
1001 {
1002 int ret = 0;
1003
1004
1005 drv_verify_link_exists(sdata, link_conf);
1006
1007 might_sleep();
1008
1009 if (!check_sdata_in_driver(sdata))
1010 return -EIO;
1011
1012 trace_drv_start_ap(local, sdata, link_conf);
1013 if (local->ops->start_ap)
1014 ret = local->ops->start_ap(&local->hw, &sdata->vif, link_conf);
1015 trace_drv_return_int(local, ret);
1016 return ret;
1017 }
1018
1019 static inline void drv_stop_ap(struct ieee80211_local *local,
1020 struct ieee80211_sub_if_data *sdata,
1021 struct ieee80211_bss_conf *link_conf)
1022 {
1023
1024 drv_verify_link_exists(sdata, link_conf);
1025
1026 if (!check_sdata_in_driver(sdata))
1027 return;
1028
1029 trace_drv_stop_ap(local, sdata, link_conf);
1030 if (local->ops->stop_ap)
1031 local->ops->stop_ap(&local->hw, &sdata->vif, link_conf);
1032 trace_drv_return_void(local);
1033 }
1034
1035 static inline void
1036 drv_reconfig_complete(struct ieee80211_local *local,
1037 enum ieee80211_reconfig_type reconfig_type)
1038 {
1039 might_sleep();
1040
1041 trace_drv_reconfig_complete(local, reconfig_type);
1042 if (local->ops->reconfig_complete)
1043 local->ops->reconfig_complete(&local->hw, reconfig_type);
1044 trace_drv_return_void(local);
1045 }
1046
1047 static inline void
1048 drv_set_default_unicast_key(struct ieee80211_local *local,
1049 struct ieee80211_sub_if_data *sdata,
1050 int key_idx)
1051 {
1052 if (!check_sdata_in_driver(sdata))
1053 return;
1054
1055 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1056
1057 trace_drv_set_default_unicast_key(local, sdata, key_idx);
1058 if (local->ops->set_default_unicast_key)
1059 local->ops->set_default_unicast_key(&local->hw, &sdata->vif,
1060 key_idx);
1061 trace_drv_return_void(local);
1062 }
1063
1064 #if IS_ENABLED(CONFIG_IPV6)
1065 static inline void drv_ipv6_addr_change(struct ieee80211_local *local,
1066 struct ieee80211_sub_if_data *sdata,
1067 struct inet6_dev *idev)
1068 {
1069 trace_drv_ipv6_addr_change(local, sdata);
1070 if (local->ops->ipv6_addr_change)
1071 local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev);
1072 trace_drv_return_void(local);
1073 }
1074 #endif
1075
1076 static inline void
1077 drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1078 struct cfg80211_chan_def *chandef)
1079 {
1080 struct ieee80211_local *local = sdata->local;
1081
1082 if (local->ops->channel_switch_beacon) {
1083 trace_drv_channel_switch_beacon(local, sdata, chandef);
1084 local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
1085 chandef);
1086 }
1087 }
1088
1089 static inline int
1090 drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
1091 struct ieee80211_channel_switch *ch_switch)
1092 {
1093 struct ieee80211_local *local = sdata->local;
1094 int ret = 0;
1095
1096 if (!check_sdata_in_driver(sdata))
1097 return -EIO;
1098
1099 trace_drv_pre_channel_switch(local, sdata, ch_switch);
1100 if (local->ops->pre_channel_switch)
1101 ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif,
1102 ch_switch);
1103 trace_drv_return_int(local, ret);
1104 return ret;
1105 }
1106
1107 static inline int
1108 drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
1109 {
1110 struct ieee80211_local *local = sdata->local;
1111 int ret = 0;
1112
1113 if (!check_sdata_in_driver(sdata))
1114 return -EIO;
1115
1116 trace_drv_post_channel_switch(local, sdata);
1117 if (local->ops->post_channel_switch)
1118 ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
1119 trace_drv_return_int(local, ret);
1120 return ret;
1121 }
1122
1123 static inline void
1124 drv_abort_channel_switch(struct ieee80211_sub_if_data *sdata)
1125 {
1126 struct ieee80211_local *local = sdata->local;
1127
1128 if (!check_sdata_in_driver(sdata))
1129 return;
1130
1131 trace_drv_abort_channel_switch(local, sdata);
1132
1133 if (local->ops->abort_channel_switch)
1134 local->ops->abort_channel_switch(&local->hw, &sdata->vif);
1135 }
1136
1137 static inline void
1138 drv_channel_switch_rx_beacon(struct ieee80211_sub_if_data *sdata,
1139 struct ieee80211_channel_switch *ch_switch)
1140 {
1141 struct ieee80211_local *local = sdata->local;
1142
1143 if (!check_sdata_in_driver(sdata))
1144 return;
1145
1146 trace_drv_channel_switch_rx_beacon(local, sdata, ch_switch);
1147 if (local->ops->channel_switch_rx_beacon)
1148 local->ops->channel_switch_rx_beacon(&local->hw, &sdata->vif,
1149 ch_switch);
1150 }
1151
1152 static inline int drv_join_ibss(struct ieee80211_local *local,
1153 struct ieee80211_sub_if_data *sdata)
1154 {
1155 int ret = 0;
1156
1157 might_sleep();
1158 if (!check_sdata_in_driver(sdata))
1159 return -EIO;
1160
1161 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1162 if (local->ops->join_ibss)
1163 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1164 trace_drv_return_int(local, ret);
1165 return ret;
1166 }
1167
1168 static inline void drv_leave_ibss(struct ieee80211_local *local,
1169 struct ieee80211_sub_if_data *sdata)
1170 {
1171 might_sleep();
1172 if (!check_sdata_in_driver(sdata))
1173 return;
1174
1175 trace_drv_leave_ibss(local, sdata);
1176 if (local->ops->leave_ibss)
1177 local->ops->leave_ibss(&local->hw, &sdata->vif);
1178 trace_drv_return_void(local);
1179 }
1180
1181 static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
1182 struct sta_info *sta)
1183 {
1184 u32 ret = 0;
1185
1186 trace_drv_get_expected_throughput(&sta->sta);
1187 if (local->ops->get_expected_throughput && sta->uploaded)
1188 ret = local->ops->get_expected_throughput(&local->hw, &sta->sta);
1189 trace_drv_return_u32(local, ret);
1190
1191 return ret;
1192 }
1193
1194 static inline int drv_get_txpower(struct ieee80211_local *local,
1195 struct ieee80211_sub_if_data *sdata, int *dbm)
1196 {
1197 int ret;
1198
1199 if (!local->ops->get_txpower)
1200 return -EOPNOTSUPP;
1201
1202 ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
1203 trace_drv_get_txpower(local, sdata, *dbm, ret);
1204
1205 return ret;
1206 }
1207
1208 static inline int
1209 drv_tdls_channel_switch(struct ieee80211_local *local,
1210 struct ieee80211_sub_if_data *sdata,
1211 struct ieee80211_sta *sta, u8 oper_class,
1212 struct cfg80211_chan_def *chandef,
1213 struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie)
1214 {
1215 int ret;
1216
1217 might_sleep();
1218 if (!check_sdata_in_driver(sdata))
1219 return -EIO;
1220
1221 if (!local->ops->tdls_channel_switch)
1222 return -EOPNOTSUPP;
1223
1224 trace_drv_tdls_channel_switch(local, sdata, sta, oper_class, chandef);
1225 ret = local->ops->tdls_channel_switch(&local->hw, &sdata->vif, sta,
1226 oper_class, chandef, tmpl_skb,
1227 ch_sw_tm_ie);
1228 trace_drv_return_int(local, ret);
1229 return ret;
1230 }
1231
1232 static inline void
1233 drv_tdls_cancel_channel_switch(struct ieee80211_local *local,
1234 struct ieee80211_sub_if_data *sdata,
1235 struct ieee80211_sta *sta)
1236 {
1237 might_sleep();
1238 if (!check_sdata_in_driver(sdata))
1239 return;
1240
1241 if (!local->ops->tdls_cancel_channel_switch)
1242 return;
1243
1244 trace_drv_tdls_cancel_channel_switch(local, sdata, sta);
1245 local->ops->tdls_cancel_channel_switch(&local->hw, &sdata->vif, sta);
1246 trace_drv_return_void(local);
1247 }
1248
1249 static inline void
1250 drv_tdls_recv_channel_switch(struct ieee80211_local *local,
1251 struct ieee80211_sub_if_data *sdata,
1252 struct ieee80211_tdls_ch_sw_params *params)
1253 {
1254 trace_drv_tdls_recv_channel_switch(local, sdata, params);
1255 if (local->ops->tdls_recv_channel_switch)
1256 local->ops->tdls_recv_channel_switch(&local->hw, &sdata->vif,
1257 params);
1258 trace_drv_return_void(local);
1259 }
1260
1261 static inline void drv_wake_tx_queue(struct ieee80211_local *local,
1262 struct txq_info *txq)
1263 {
1264 struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
1265
1266
1267 if (local->in_reconfig) {
1268 set_bit(IEEE80211_TXQ_STOP_NETIF_TX, &txq->flags);
1269 return;
1270 }
1271
1272 if (!check_sdata_in_driver(sdata))
1273 return;
1274
1275 trace_drv_wake_tx_queue(local, sdata, txq);
1276 local->ops->wake_tx_queue(&local->hw, &txq->txq);
1277 }
1278
1279 static inline void schedule_and_wake_txq(struct ieee80211_local *local,
1280 struct txq_info *txqi)
1281 {
1282 ieee80211_schedule_txq(&local->hw, &txqi->txq);
1283 drv_wake_tx_queue(local, txqi);
1284 }
1285
1286 static inline int drv_can_aggregate_in_amsdu(struct ieee80211_local *local,
1287 struct sk_buff *head,
1288 struct sk_buff *skb)
1289 {
1290 if (!local->ops->can_aggregate_in_amsdu)
1291 return true;
1292
1293 return local->ops->can_aggregate_in_amsdu(&local->hw, head, skb);
1294 }
1295
1296 static inline int
1297 drv_get_ftm_responder_stats(struct ieee80211_local *local,
1298 struct ieee80211_sub_if_data *sdata,
1299 struct cfg80211_ftm_responder_stats *ftm_stats)
1300 {
1301 u32 ret = -EOPNOTSUPP;
1302
1303 if (local->ops->get_ftm_responder_stats)
1304 ret = local->ops->get_ftm_responder_stats(&local->hw,
1305 &sdata->vif,
1306 ftm_stats);
1307 trace_drv_get_ftm_responder_stats(local, sdata, ftm_stats);
1308
1309 return ret;
1310 }
1311
1312 static inline int drv_start_pmsr(struct ieee80211_local *local,
1313 struct ieee80211_sub_if_data *sdata,
1314 struct cfg80211_pmsr_request *request)
1315 {
1316 int ret = -EOPNOTSUPP;
1317
1318 might_sleep();
1319 if (!check_sdata_in_driver(sdata))
1320 return -EIO;
1321
1322 trace_drv_start_pmsr(local, sdata);
1323
1324 if (local->ops->start_pmsr)
1325 ret = local->ops->start_pmsr(&local->hw, &sdata->vif, request);
1326 trace_drv_return_int(local, ret);
1327
1328 return ret;
1329 }
1330
1331 static inline void drv_abort_pmsr(struct ieee80211_local *local,
1332 struct ieee80211_sub_if_data *sdata,
1333 struct cfg80211_pmsr_request *request)
1334 {
1335 trace_drv_abort_pmsr(local, sdata);
1336
1337 might_sleep();
1338 if (!check_sdata_in_driver(sdata))
1339 return;
1340
1341 if (local->ops->abort_pmsr)
1342 local->ops->abort_pmsr(&local->hw, &sdata->vif, request);
1343 trace_drv_return_void(local);
1344 }
1345
1346 static inline int drv_start_nan(struct ieee80211_local *local,
1347 struct ieee80211_sub_if_data *sdata,
1348 struct cfg80211_nan_conf *conf)
1349 {
1350 int ret;
1351
1352 might_sleep();
1353 check_sdata_in_driver(sdata);
1354
1355 trace_drv_start_nan(local, sdata, conf);
1356 ret = local->ops->start_nan(&local->hw, &sdata->vif, conf);
1357 trace_drv_return_int(local, ret);
1358 return ret;
1359 }
1360
1361 static inline void drv_stop_nan(struct ieee80211_local *local,
1362 struct ieee80211_sub_if_data *sdata)
1363 {
1364 might_sleep();
1365 check_sdata_in_driver(sdata);
1366
1367 trace_drv_stop_nan(local, sdata);
1368 local->ops->stop_nan(&local->hw, &sdata->vif);
1369 trace_drv_return_void(local);
1370 }
1371
1372 static inline int drv_nan_change_conf(struct ieee80211_local *local,
1373 struct ieee80211_sub_if_data *sdata,
1374 struct cfg80211_nan_conf *conf,
1375 u32 changes)
1376 {
1377 int ret;
1378
1379 might_sleep();
1380 check_sdata_in_driver(sdata);
1381
1382 if (!local->ops->nan_change_conf)
1383 return -EOPNOTSUPP;
1384
1385 trace_drv_nan_change_conf(local, sdata, conf, changes);
1386 ret = local->ops->nan_change_conf(&local->hw, &sdata->vif, conf,
1387 changes);
1388 trace_drv_return_int(local, ret);
1389
1390 return ret;
1391 }
1392
1393 static inline int drv_add_nan_func(struct ieee80211_local *local,
1394 struct ieee80211_sub_if_data *sdata,
1395 const struct cfg80211_nan_func *nan_func)
1396 {
1397 int ret;
1398
1399 might_sleep();
1400 check_sdata_in_driver(sdata);
1401
1402 if (!local->ops->add_nan_func)
1403 return -EOPNOTSUPP;
1404
1405 trace_drv_add_nan_func(local, sdata, nan_func);
1406 ret = local->ops->add_nan_func(&local->hw, &sdata->vif, nan_func);
1407 trace_drv_return_int(local, ret);
1408
1409 return ret;
1410 }
1411
1412 static inline void drv_del_nan_func(struct ieee80211_local *local,
1413 struct ieee80211_sub_if_data *sdata,
1414 u8 instance_id)
1415 {
1416 might_sleep();
1417 check_sdata_in_driver(sdata);
1418
1419 trace_drv_del_nan_func(local, sdata, instance_id);
1420 if (local->ops->del_nan_func)
1421 local->ops->del_nan_func(&local->hw, &sdata->vif, instance_id);
1422 trace_drv_return_void(local);
1423 }
1424
1425 static inline int drv_set_tid_config(struct ieee80211_local *local,
1426 struct ieee80211_sub_if_data *sdata,
1427 struct ieee80211_sta *sta,
1428 struct cfg80211_tid_config *tid_conf)
1429 {
1430 int ret;
1431
1432 might_sleep();
1433 ret = local->ops->set_tid_config(&local->hw, &sdata->vif, sta,
1434 tid_conf);
1435 trace_drv_return_int(local, ret);
1436
1437 return ret;
1438 }
1439
1440 static inline int drv_reset_tid_config(struct ieee80211_local *local,
1441 struct ieee80211_sub_if_data *sdata,
1442 struct ieee80211_sta *sta, u8 tids)
1443 {
1444 int ret;
1445
1446 might_sleep();
1447 ret = local->ops->reset_tid_config(&local->hw, &sdata->vif, sta, tids);
1448 trace_drv_return_int(local, ret);
1449
1450 return ret;
1451 }
1452
1453 static inline void drv_update_vif_offload(struct ieee80211_local *local,
1454 struct ieee80211_sub_if_data *sdata)
1455 {
1456 might_sleep();
1457 check_sdata_in_driver(sdata);
1458
1459 if (!local->ops->update_vif_offload)
1460 return;
1461
1462 trace_drv_update_vif_offload(local, sdata);
1463 local->ops->update_vif_offload(&local->hw, &sdata->vif);
1464 trace_drv_return_void(local);
1465 }
1466
1467 static inline void drv_sta_set_4addr(struct ieee80211_local *local,
1468 struct ieee80211_sub_if_data *sdata,
1469 struct ieee80211_sta *sta, bool enabled)
1470 {
1471 sdata = get_bss_sdata(sdata);
1472 if (!check_sdata_in_driver(sdata))
1473 return;
1474
1475 trace_drv_sta_set_4addr(local, sdata, sta, enabled);
1476 if (local->ops->sta_set_4addr)
1477 local->ops->sta_set_4addr(&local->hw, &sdata->vif, sta, enabled);
1478 trace_drv_return_void(local);
1479 }
1480
1481 static inline void drv_sta_set_decap_offload(struct ieee80211_local *local,
1482 struct ieee80211_sub_if_data *sdata,
1483 struct ieee80211_sta *sta,
1484 bool enabled)
1485 {
1486 sdata = get_bss_sdata(sdata);
1487 if (!check_sdata_in_driver(sdata))
1488 return;
1489
1490 trace_drv_sta_set_decap_offload(local, sdata, sta, enabled);
1491 if (local->ops->sta_set_decap_offload)
1492 local->ops->sta_set_decap_offload(&local->hw, &sdata->vif, sta,
1493 enabled);
1494 trace_drv_return_void(local);
1495 }
1496
1497 static inline void drv_add_twt_setup(struct ieee80211_local *local,
1498 struct ieee80211_sub_if_data *sdata,
1499 struct ieee80211_sta *sta,
1500 struct ieee80211_twt_setup *twt)
1501 {
1502 struct ieee80211_twt_params *twt_agrt;
1503
1504 might_sleep();
1505
1506 if (!check_sdata_in_driver(sdata))
1507 return;
1508
1509 twt_agrt = (void *)twt->params;
1510
1511 trace_drv_add_twt_setup(local, sta, twt, twt_agrt);
1512 local->ops->add_twt_setup(&local->hw, sta, twt);
1513 trace_drv_return_void(local);
1514 }
1515
1516 static inline void drv_twt_teardown_request(struct ieee80211_local *local,
1517 struct ieee80211_sub_if_data *sdata,
1518 struct ieee80211_sta *sta,
1519 u8 flowid)
1520 {
1521 might_sleep();
1522 if (!check_sdata_in_driver(sdata))
1523 return;
1524
1525 if (!local->ops->twt_teardown_request)
1526 return;
1527
1528 trace_drv_twt_teardown_request(local, sta, flowid);
1529 local->ops->twt_teardown_request(&local->hw, sta, flowid);
1530 trace_drv_return_void(local);
1531 }
1532
1533 static inline int drv_net_fill_forward_path(struct ieee80211_local *local,
1534 struct ieee80211_sub_if_data *sdata,
1535 struct ieee80211_sta *sta,
1536 struct net_device_path_ctx *ctx,
1537 struct net_device_path *path)
1538 {
1539 int ret = -EOPNOTSUPP;
1540
1541 sdata = get_bss_sdata(sdata);
1542 if (!check_sdata_in_driver(sdata))
1543 return -EIO;
1544
1545 trace_drv_net_fill_forward_path(local, sdata, sta);
1546 if (local->ops->net_fill_forward_path)
1547 ret = local->ops->net_fill_forward_path(&local->hw,
1548 &sdata->vif, sta,
1549 ctx, path);
1550 trace_drv_return_int(local, ret);
1551
1552 return ret;
1553 }
1554
1555 static inline int drv_change_vif_links(struct ieee80211_local *local,
1556 struct ieee80211_sub_if_data *sdata,
1557 u16 old_links, u16 new_links,
1558 struct ieee80211_bss_conf *old[IEEE80211_MLD_MAX_NUM_LINKS])
1559 {
1560 int ret = -EOPNOTSUPP;
1561
1562 might_sleep();
1563
1564 if (!check_sdata_in_driver(sdata))
1565 return -EIO;
1566
1567 trace_drv_change_vif_links(local, sdata, old_links, new_links);
1568 if (local->ops->change_vif_links)
1569 ret = local->ops->change_vif_links(&local->hw, &sdata->vif,
1570 old_links, new_links, old);
1571 trace_drv_return_int(local, ret);
1572
1573 return ret;
1574 }
1575
1576 static inline int drv_change_sta_links(struct ieee80211_local *local,
1577 struct ieee80211_sub_if_data *sdata,
1578 struct ieee80211_sta *sta,
1579 u16 old_links, u16 new_links)
1580 {
1581 int ret = -EOPNOTSUPP;
1582
1583 might_sleep();
1584
1585 if (!check_sdata_in_driver(sdata))
1586 return -EIO;
1587
1588 trace_drv_change_sta_links(local, sdata, sta, old_links, new_links);
1589 if (local->ops->change_sta_links)
1590 ret = local->ops->change_sta_links(&local->hw, &sdata->vif, sta,
1591 old_links, new_links);
1592 trace_drv_return_int(local, ret);
1593
1594 return ret;
1595 }
1596
1597 #endif