1 #ifndef __MAC80211_DRIVER_OPS
2 #define __MAC80211_DRIVER_OPS
4 #include <net/mac80211.h>
5 #include "ieee80211_i.h"
8 static inline void check_sdata_in_driver(struct ieee80211_sub_if_data *sdata)
10 WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER),
11 "%s: Failed check-sdata-in-driver check, flags: 0x%x\n",
12 sdata->dev->name, sdata->flags);
15 static inline struct ieee80211_sub_if_data *
16 get_bss_sdata(struct ieee80211_sub_if_data *sdata)
18 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
19 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
25 static inline void drv_tx(struct ieee80211_local *local, struct sk_buff *skb)
27 local->ops->tx(&local->hw, skb);
30 static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata,
33 struct ieee80211_local *local = sdata->local;
34 if (local->ops->get_et_strings) {
35 trace_drv_get_et_strings(local, sset);
36 local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data);
37 trace_drv_return_void(local);
41 static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata,
42 struct ethtool_stats *stats,
45 struct ieee80211_local *local = sdata->local;
46 if (local->ops->get_et_stats) {
47 trace_drv_get_et_stats(local);
48 local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data);
49 trace_drv_return_void(local);
53 static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata,
56 struct ieee80211_local *local = sdata->local;
58 if (local->ops->get_et_sset_count) {
59 trace_drv_get_et_sset_count(local, sset);
60 rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif,
62 trace_drv_return_int(local, rv);
67 static inline int drv_start(struct ieee80211_local *local)
73 trace_drv_start(local);
74 local->started = true;
76 ret = local->ops->start(&local->hw);
77 trace_drv_return_int(local, ret);
81 static inline void drv_stop(struct ieee80211_local *local)
85 trace_drv_stop(local);
86 local->ops->stop(&local->hw);
87 trace_drv_return_void(local);
89 /* sync away all work on the tasklet before clearing started */
90 tasklet_disable(&local->tasklet);
91 tasklet_enable(&local->tasklet);
95 local->started = false;
99 static inline int drv_suspend(struct ieee80211_local *local,
100 struct cfg80211_wowlan *wowlan)
106 trace_drv_suspend(local);
107 ret = local->ops->suspend(&local->hw, wowlan);
108 trace_drv_return_int(local, ret);
112 static inline int drv_resume(struct ieee80211_local *local)
118 trace_drv_resume(local);
119 ret = local->ops->resume(&local->hw);
120 trace_drv_return_int(local, ret);
124 static inline void drv_set_wakeup(struct ieee80211_local *local,
129 if (!local->ops->set_wakeup)
132 trace_drv_set_wakeup(local, enabled);
133 local->ops->set_wakeup(&local->hw, enabled);
134 trace_drv_return_void(local);
138 static inline int drv_add_interface(struct ieee80211_local *local,
139 struct ieee80211_sub_if_data *sdata)
145 if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
146 (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
147 !(local->hw.flags & IEEE80211_HW_WANT_MONITOR_VIF))))
150 trace_drv_add_interface(local, sdata);
151 ret = local->ops->add_interface(&local->hw, &sdata->vif);
152 trace_drv_return_int(local, ret);
155 sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
160 static inline int drv_change_interface(struct ieee80211_local *local,
161 struct ieee80211_sub_if_data *sdata,
162 enum nl80211_iftype type, bool p2p)
168 check_sdata_in_driver(sdata);
170 trace_drv_change_interface(local, sdata, type, p2p);
171 ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
172 trace_drv_return_int(local, ret);
176 static inline void drv_remove_interface(struct ieee80211_local *local,
177 struct ieee80211_sub_if_data *sdata)
181 check_sdata_in_driver(sdata);
183 trace_drv_remove_interface(local, sdata);
184 local->ops->remove_interface(&local->hw, &sdata->vif);
185 sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER;
186 trace_drv_return_void(local);
189 static inline int drv_config(struct ieee80211_local *local, u32 changed)
195 trace_drv_config(local, changed);
196 ret = local->ops->config(&local->hw, changed);
197 trace_drv_return_int(local, ret);
201 static inline void drv_bss_info_changed(struct ieee80211_local *local,
202 struct ieee80211_sub_if_data *sdata,
203 struct ieee80211_bss_conf *info,
208 check_sdata_in_driver(sdata);
210 trace_drv_bss_info_changed(local, sdata, info, changed);
211 if (local->ops->bss_info_changed)
212 local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
213 trace_drv_return_void(local);
216 static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
217 struct netdev_hw_addr_list *mc_list)
221 trace_drv_prepare_multicast(local, mc_list->count);
223 if (local->ops->prepare_multicast)
224 ret = local->ops->prepare_multicast(&local->hw, mc_list);
226 trace_drv_return_u64(local, ret);
231 static inline void drv_configure_filter(struct ieee80211_local *local,
232 unsigned int changed_flags,
233 unsigned int *total_flags,
238 trace_drv_configure_filter(local, changed_flags, total_flags,
240 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
242 trace_drv_return_void(local);
245 static inline int drv_set_tim(struct ieee80211_local *local,
246 struct ieee80211_sta *sta, bool set)
249 trace_drv_set_tim(local, sta, set);
250 if (local->ops->set_tim)
251 ret = local->ops->set_tim(&local->hw, sta, set);
252 trace_drv_return_int(local, ret);
256 static inline int drv_set_key(struct ieee80211_local *local,
257 enum set_key_cmd cmd,
258 struct ieee80211_sub_if_data *sdata,
259 struct ieee80211_sta *sta,
260 struct ieee80211_key_conf *key)
266 sdata = get_bss_sdata(sdata);
267 check_sdata_in_driver(sdata);
269 trace_drv_set_key(local, cmd, sdata, sta, key);
270 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
271 trace_drv_return_int(local, ret);
275 static inline void drv_update_tkip_key(struct ieee80211_local *local,
276 struct ieee80211_sub_if_data *sdata,
277 struct ieee80211_key_conf *conf,
278 struct sta_info *sta, u32 iv32,
281 struct ieee80211_sta *ista = NULL;
286 sdata = get_bss_sdata(sdata);
287 check_sdata_in_driver(sdata);
289 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
290 if (local->ops->update_tkip_key)
291 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
292 ista, iv32, phase1key);
293 trace_drv_return_void(local);
296 static inline int drv_hw_scan(struct ieee80211_local *local,
297 struct ieee80211_sub_if_data *sdata,
298 struct cfg80211_scan_request *req)
304 check_sdata_in_driver(sdata);
306 trace_drv_hw_scan(local, sdata);
307 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
308 trace_drv_return_int(local, ret);
312 static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
313 struct ieee80211_sub_if_data *sdata)
317 check_sdata_in_driver(sdata);
319 trace_drv_cancel_hw_scan(local, sdata);
320 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
321 trace_drv_return_void(local);
325 drv_sched_scan_start(struct ieee80211_local *local,
326 struct ieee80211_sub_if_data *sdata,
327 struct cfg80211_sched_scan_request *req,
328 struct ieee80211_sched_scan_ies *ies)
334 check_sdata_in_driver(sdata);
336 trace_drv_sched_scan_start(local, sdata);
337 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
339 trace_drv_return_int(local, ret);
343 static inline void drv_sched_scan_stop(struct ieee80211_local *local,
344 struct ieee80211_sub_if_data *sdata)
348 check_sdata_in_driver(sdata);
350 trace_drv_sched_scan_stop(local, sdata);
351 local->ops->sched_scan_stop(&local->hw, &sdata->vif);
352 trace_drv_return_void(local);
355 static inline void drv_sw_scan_start(struct ieee80211_local *local)
359 trace_drv_sw_scan_start(local);
360 if (local->ops->sw_scan_start)
361 local->ops->sw_scan_start(&local->hw);
362 trace_drv_return_void(local);
365 static inline void drv_sw_scan_complete(struct ieee80211_local *local)
369 trace_drv_sw_scan_complete(local);
370 if (local->ops->sw_scan_complete)
371 local->ops->sw_scan_complete(&local->hw);
372 trace_drv_return_void(local);
375 static inline int drv_get_stats(struct ieee80211_local *local,
376 struct ieee80211_low_level_stats *stats)
378 int ret = -EOPNOTSUPP;
382 if (local->ops->get_stats)
383 ret = local->ops->get_stats(&local->hw, stats);
384 trace_drv_get_stats(local, stats, ret);
389 static inline void drv_get_tkip_seq(struct ieee80211_local *local,
390 u8 hw_key_idx, u32 *iv32, u16 *iv16)
392 if (local->ops->get_tkip_seq)
393 local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
394 trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
397 static inline int drv_set_frag_threshold(struct ieee80211_local *local,
404 trace_drv_set_frag_threshold(local, value);
405 if (local->ops->set_frag_threshold)
406 ret = local->ops->set_frag_threshold(&local->hw, value);
407 trace_drv_return_int(local, ret);
411 static inline int drv_set_rts_threshold(struct ieee80211_local *local,
418 trace_drv_set_rts_threshold(local, value);
419 if (local->ops->set_rts_threshold)
420 ret = local->ops->set_rts_threshold(&local->hw, value);
421 trace_drv_return_int(local, ret);
425 static inline int drv_set_coverage_class(struct ieee80211_local *local,
431 trace_drv_set_coverage_class(local, value);
432 if (local->ops->set_coverage_class)
433 local->ops->set_coverage_class(&local->hw, value);
437 trace_drv_return_int(local, ret);
441 static inline void drv_sta_notify(struct ieee80211_local *local,
442 struct ieee80211_sub_if_data *sdata,
443 enum sta_notify_cmd cmd,
444 struct ieee80211_sta *sta)
446 sdata = get_bss_sdata(sdata);
447 check_sdata_in_driver(sdata);
449 trace_drv_sta_notify(local, sdata, cmd, sta);
450 if (local->ops->sta_notify)
451 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
452 trace_drv_return_void(local);
455 static inline int drv_sta_add(struct ieee80211_local *local,
456 struct ieee80211_sub_if_data *sdata,
457 struct ieee80211_sta *sta)
463 sdata = get_bss_sdata(sdata);
464 check_sdata_in_driver(sdata);
466 trace_drv_sta_add(local, sdata, sta);
467 if (local->ops->sta_add)
468 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
470 trace_drv_return_int(local, ret);
475 static inline void drv_sta_remove(struct ieee80211_local *local,
476 struct ieee80211_sub_if_data *sdata,
477 struct ieee80211_sta *sta)
481 sdata = get_bss_sdata(sdata);
482 check_sdata_in_driver(sdata);
484 trace_drv_sta_remove(local, sdata, sta);
485 if (local->ops->sta_remove)
486 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
488 trace_drv_return_void(local);
491 static inline __must_check
492 int drv_sta_state(struct ieee80211_local *local,
493 struct ieee80211_sub_if_data *sdata,
494 struct sta_info *sta,
495 enum ieee80211_sta_state old_state,
496 enum ieee80211_sta_state new_state)
502 sdata = get_bss_sdata(sdata);
503 check_sdata_in_driver(sdata);
505 trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
506 if (local->ops->sta_state) {
507 ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta,
508 old_state, new_state);
509 } else if (old_state == IEEE80211_STA_AUTH &&
510 new_state == IEEE80211_STA_ASSOC) {
511 ret = drv_sta_add(local, sdata, &sta->sta);
513 sta->uploaded = true;
514 } else if (old_state == IEEE80211_STA_ASSOC &&
515 new_state == IEEE80211_STA_AUTH) {
516 drv_sta_remove(local, sdata, &sta->sta);
518 trace_drv_return_int(local, ret);
522 static inline void drv_sta_rc_update(struct ieee80211_local *local,
523 struct ieee80211_sub_if_data *sdata,
524 struct ieee80211_sta *sta, u32 changed)
526 sdata = get_bss_sdata(sdata);
527 check_sdata_in_driver(sdata);
529 trace_drv_sta_rc_update(local, sdata, sta, changed);
530 if (local->ops->sta_rc_update)
531 local->ops->sta_rc_update(&local->hw, &sdata->vif,
534 trace_drv_return_void(local);
537 static inline int drv_conf_tx(struct ieee80211_local *local,
538 struct ieee80211_sub_if_data *sdata, u16 ac,
539 const struct ieee80211_tx_queue_params *params)
541 int ret = -EOPNOTSUPP;
545 check_sdata_in_driver(sdata);
547 trace_drv_conf_tx(local, sdata, ac, params);
548 if (local->ops->conf_tx)
549 ret = local->ops->conf_tx(&local->hw, &sdata->vif,
551 trace_drv_return_int(local, ret);
555 static inline u64 drv_get_tsf(struct ieee80211_local *local,
556 struct ieee80211_sub_if_data *sdata)
562 check_sdata_in_driver(sdata);
564 trace_drv_get_tsf(local, sdata);
565 if (local->ops->get_tsf)
566 ret = local->ops->get_tsf(&local->hw, &sdata->vif);
567 trace_drv_return_u64(local, ret);
571 static inline void drv_set_tsf(struct ieee80211_local *local,
572 struct ieee80211_sub_if_data *sdata,
577 check_sdata_in_driver(sdata);
579 trace_drv_set_tsf(local, sdata, tsf);
580 if (local->ops->set_tsf)
581 local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
582 trace_drv_return_void(local);
585 static inline void drv_reset_tsf(struct ieee80211_local *local,
586 struct ieee80211_sub_if_data *sdata)
590 check_sdata_in_driver(sdata);
592 trace_drv_reset_tsf(local, sdata);
593 if (local->ops->reset_tsf)
594 local->ops->reset_tsf(&local->hw, &sdata->vif);
595 trace_drv_return_void(local);
598 static inline int drv_tx_last_beacon(struct ieee80211_local *local)
600 int ret = 0; /* default unsuported op for less congestion */
604 trace_drv_tx_last_beacon(local);
605 if (local->ops->tx_last_beacon)
606 ret = local->ops->tx_last_beacon(&local->hw);
607 trace_drv_return_int(local, ret);
611 static inline int drv_ampdu_action(struct ieee80211_local *local,
612 struct ieee80211_sub_if_data *sdata,
613 enum ieee80211_ampdu_mlme_action action,
614 struct ieee80211_sta *sta, u16 tid,
615 u16 *ssn, u8 buf_size)
617 int ret = -EOPNOTSUPP;
621 sdata = get_bss_sdata(sdata);
622 check_sdata_in_driver(sdata);
624 trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
626 if (local->ops->ampdu_action)
627 ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
628 sta, tid, ssn, buf_size);
630 trace_drv_return_int(local, ret);
635 static inline int drv_get_survey(struct ieee80211_local *local, int idx,
636 struct survey_info *survey)
638 int ret = -EOPNOTSUPP;
640 trace_drv_get_survey(local, idx, survey);
642 if (local->ops->get_survey)
643 ret = local->ops->get_survey(&local->hw, idx, survey);
645 trace_drv_return_int(local, ret);
650 static inline void drv_rfkill_poll(struct ieee80211_local *local)
654 if (local->ops->rfkill_poll)
655 local->ops->rfkill_poll(&local->hw);
658 static inline void drv_flush(struct ieee80211_local *local, bool drop)
662 trace_drv_flush(local, drop);
663 if (local->ops->flush)
664 local->ops->flush(&local->hw, drop);
665 trace_drv_return_void(local);
668 static inline void drv_channel_switch(struct ieee80211_local *local,
669 struct ieee80211_channel_switch *ch_switch)
673 trace_drv_channel_switch(local, ch_switch);
674 local->ops->channel_switch(&local->hw, ch_switch);
675 trace_drv_return_void(local);
679 static inline int drv_set_antenna(struct ieee80211_local *local,
680 u32 tx_ant, u32 rx_ant)
682 int ret = -EOPNOTSUPP;
684 if (local->ops->set_antenna)
685 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
686 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
690 static inline int drv_get_antenna(struct ieee80211_local *local,
691 u32 *tx_ant, u32 *rx_ant)
693 int ret = -EOPNOTSUPP;
695 if (local->ops->get_antenna)
696 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
697 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
701 static inline int drv_remain_on_channel(struct ieee80211_local *local,
702 struct ieee80211_channel *chan,
703 enum nl80211_channel_type chantype,
704 unsigned int duration)
710 trace_drv_remain_on_channel(local, chan, chantype, duration);
711 ret = local->ops->remain_on_channel(&local->hw, chan, chantype,
713 trace_drv_return_int(local, ret);
718 static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
724 trace_drv_cancel_remain_on_channel(local);
725 ret = local->ops->cancel_remain_on_channel(&local->hw);
726 trace_drv_return_int(local, ret);
731 static inline int drv_set_ringparam(struct ieee80211_local *local,
738 trace_drv_set_ringparam(local, tx, rx);
739 if (local->ops->set_ringparam)
740 ret = local->ops->set_ringparam(&local->hw, tx, rx);
741 trace_drv_return_int(local, ret);
746 static inline void drv_get_ringparam(struct ieee80211_local *local,
747 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
751 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
752 if (local->ops->get_ringparam)
753 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
754 trace_drv_return_void(local);
757 static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
763 trace_drv_tx_frames_pending(local);
764 if (local->ops->tx_frames_pending)
765 ret = local->ops->tx_frames_pending(&local->hw);
766 trace_drv_return_bool(local, ret);
771 static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
772 struct ieee80211_sub_if_data *sdata,
773 const struct cfg80211_bitrate_mask *mask)
775 int ret = -EOPNOTSUPP;
779 check_sdata_in_driver(sdata);
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,
785 trace_drv_return_int(local, ret);
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)
794 check_sdata_in_driver(sdata);
796 trace_drv_set_rekey_data(local, sdata, data);
797 if (local->ops->set_rekey_data)
798 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
799 trace_drv_return_void(local);
802 static inline void drv_rssi_callback(struct ieee80211_local *local,
803 const enum ieee80211_rssi_event event)
805 trace_drv_rssi_callback(local, event);
806 if (local->ops->rssi_callback)
807 local->ops->rssi_callback(&local->hw, event);
808 trace_drv_return_void(local);
812 drv_release_buffered_frames(struct ieee80211_local *local,
813 struct sta_info *sta, u16 tids, int num_frames,
814 enum ieee80211_frame_release_type reason,
817 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
819 if (local->ops->release_buffered_frames)
820 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
823 trace_drv_return_void(local);
827 drv_allow_buffered_frames(struct ieee80211_local *local,
828 struct sta_info *sta, u16 tids, int num_frames,
829 enum ieee80211_frame_release_type reason,
832 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
834 if (local->ops->allow_buffered_frames)
835 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
836 tids, num_frames, reason,
838 trace_drv_return_void(local);
841 static inline int drv_get_rssi(struct ieee80211_local *local,
842 struct ieee80211_sub_if_data *sdata,
843 struct ieee80211_sta *sta,
850 ret = local->ops->get_rssi(&local->hw, &sdata->vif, sta, rssi_dbm);
851 trace_drv_get_rssi(local, sta, *rssi_dbm, ret);
856 static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
857 struct ieee80211_sub_if_data *sdata)
861 check_sdata_in_driver(sdata);
862 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
864 trace_drv_mgd_prepare_tx(local, sdata);
865 if (local->ops->mgd_prepare_tx)
866 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
867 trace_drv_return_void(local);
869 #endif /* __MAC80211_DRIVER_OPS */