1 #ifndef __MAC80211_DRIVER_OPS
2 #define __MAC80211_DRIVER_OPS
4 #include <net/mac80211.h>
5 #include "ieee80211_i.h"
6 #include "driver-trace.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_tx_frags(struct ieee80211_local *local,
31 struct ieee80211_vif *vif,
32 struct ieee80211_sta *sta,
33 struct sk_buff_head *skbs)
35 local->ops->tx_frags(&local->hw, vif, sta, skbs);
38 static inline int drv_start(struct ieee80211_local *local)
44 trace_drv_start(local);
45 local->started = true;
47 ret = local->ops->start(&local->hw);
48 trace_drv_return_int(local, ret);
52 static inline void drv_stop(struct ieee80211_local *local)
56 trace_drv_stop(local);
57 local->ops->stop(&local->hw);
58 trace_drv_return_void(local);
60 /* sync away all work on the tasklet before clearing started */
61 tasklet_disable(&local->tasklet);
62 tasklet_enable(&local->tasklet);
66 local->started = false;
70 static inline int drv_suspend(struct ieee80211_local *local,
71 struct cfg80211_wowlan *wowlan)
77 trace_drv_suspend(local);
78 ret = local->ops->suspend(&local->hw, wowlan);
79 trace_drv_return_int(local, ret);
83 static inline int drv_resume(struct ieee80211_local *local)
89 trace_drv_resume(local);
90 ret = local->ops->resume(&local->hw);
91 trace_drv_return_int(local, ret);
96 static inline int drv_add_interface(struct ieee80211_local *local,
97 struct ieee80211_sub_if_data *sdata)
103 if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
104 sdata->vif.type == NL80211_IFTYPE_MONITOR))
107 trace_drv_add_interface(local, sdata);
108 ret = local->ops->add_interface(&local->hw, &sdata->vif);
109 trace_drv_return_int(local, ret);
112 sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
117 static inline int drv_change_interface(struct ieee80211_local *local,
118 struct ieee80211_sub_if_data *sdata,
119 enum nl80211_iftype type, bool p2p)
125 check_sdata_in_driver(sdata);
127 trace_drv_change_interface(local, sdata, type, p2p);
128 ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
129 trace_drv_return_int(local, ret);
133 static inline void drv_remove_interface(struct ieee80211_local *local,
134 struct ieee80211_sub_if_data *sdata)
138 check_sdata_in_driver(sdata);
140 trace_drv_remove_interface(local, sdata);
141 local->ops->remove_interface(&local->hw, &sdata->vif);
142 sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER;
143 trace_drv_return_void(local);
146 static inline int drv_config(struct ieee80211_local *local, u32 changed)
152 trace_drv_config(local, changed);
153 ret = local->ops->config(&local->hw, changed);
154 trace_drv_return_int(local, ret);
158 static inline void drv_bss_info_changed(struct ieee80211_local *local,
159 struct ieee80211_sub_if_data *sdata,
160 struct ieee80211_bss_conf *info,
165 check_sdata_in_driver(sdata);
167 trace_drv_bss_info_changed(local, sdata, info, changed);
168 if (local->ops->bss_info_changed)
169 local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
170 trace_drv_return_void(local);
173 static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
174 struct netdev_hw_addr_list *mc_list)
178 trace_drv_prepare_multicast(local, mc_list->count);
180 if (local->ops->prepare_multicast)
181 ret = local->ops->prepare_multicast(&local->hw, mc_list);
183 trace_drv_return_u64(local, ret);
188 static inline void drv_configure_filter(struct ieee80211_local *local,
189 unsigned int changed_flags,
190 unsigned int *total_flags,
195 trace_drv_configure_filter(local, changed_flags, total_flags,
197 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
199 trace_drv_return_void(local);
202 static inline int drv_set_tim(struct ieee80211_local *local,
203 struct ieee80211_sta *sta, bool set)
206 trace_drv_set_tim(local, sta, set);
207 if (local->ops->set_tim)
208 ret = local->ops->set_tim(&local->hw, sta, set);
209 trace_drv_return_int(local, ret);
213 static inline int drv_set_key(struct ieee80211_local *local,
214 enum set_key_cmd cmd,
215 struct ieee80211_sub_if_data *sdata,
216 struct ieee80211_sta *sta,
217 struct ieee80211_key_conf *key)
223 sdata = get_bss_sdata(sdata);
224 check_sdata_in_driver(sdata);
226 trace_drv_set_key(local, cmd, sdata, sta, key);
227 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
228 trace_drv_return_int(local, ret);
232 static inline void drv_update_tkip_key(struct ieee80211_local *local,
233 struct ieee80211_sub_if_data *sdata,
234 struct ieee80211_key_conf *conf,
235 struct sta_info *sta, u32 iv32,
238 struct ieee80211_sta *ista = NULL;
243 sdata = get_bss_sdata(sdata);
244 check_sdata_in_driver(sdata);
246 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
247 if (local->ops->update_tkip_key)
248 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
249 ista, iv32, phase1key);
250 trace_drv_return_void(local);
253 static inline int drv_hw_scan(struct ieee80211_local *local,
254 struct ieee80211_sub_if_data *sdata,
255 struct cfg80211_scan_request *req)
261 check_sdata_in_driver(sdata);
263 trace_drv_hw_scan(local, sdata);
264 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
265 trace_drv_return_int(local, ret);
269 static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
270 struct ieee80211_sub_if_data *sdata)
274 check_sdata_in_driver(sdata);
276 trace_drv_cancel_hw_scan(local, sdata);
277 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
278 trace_drv_return_void(local);
282 drv_sched_scan_start(struct ieee80211_local *local,
283 struct ieee80211_sub_if_data *sdata,
284 struct cfg80211_sched_scan_request *req,
285 struct ieee80211_sched_scan_ies *ies)
291 check_sdata_in_driver(sdata);
293 trace_drv_sched_scan_start(local, sdata);
294 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
296 trace_drv_return_int(local, ret);
300 static inline void drv_sched_scan_stop(struct ieee80211_local *local,
301 struct ieee80211_sub_if_data *sdata)
305 check_sdata_in_driver(sdata);
307 trace_drv_sched_scan_stop(local, sdata);
308 local->ops->sched_scan_stop(&local->hw, &sdata->vif);
309 trace_drv_return_void(local);
312 static inline void drv_sw_scan_start(struct ieee80211_local *local)
316 trace_drv_sw_scan_start(local);
317 if (local->ops->sw_scan_start)
318 local->ops->sw_scan_start(&local->hw);
319 trace_drv_return_void(local);
322 static inline void drv_sw_scan_complete(struct ieee80211_local *local)
326 trace_drv_sw_scan_complete(local);
327 if (local->ops->sw_scan_complete)
328 local->ops->sw_scan_complete(&local->hw);
329 trace_drv_return_void(local);
332 static inline int drv_get_stats(struct ieee80211_local *local,
333 struct ieee80211_low_level_stats *stats)
335 int ret = -EOPNOTSUPP;
339 if (local->ops->get_stats)
340 ret = local->ops->get_stats(&local->hw, stats);
341 trace_drv_get_stats(local, stats, ret);
346 static inline void drv_get_tkip_seq(struct ieee80211_local *local,
347 u8 hw_key_idx, u32 *iv32, u16 *iv16)
349 if (local->ops->get_tkip_seq)
350 local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
351 trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
354 static inline int drv_set_frag_threshold(struct ieee80211_local *local,
361 trace_drv_set_frag_threshold(local, value);
362 if (local->ops->set_frag_threshold)
363 ret = local->ops->set_frag_threshold(&local->hw, value);
364 trace_drv_return_int(local, ret);
368 static inline int drv_set_rts_threshold(struct ieee80211_local *local,
375 trace_drv_set_rts_threshold(local, value);
376 if (local->ops->set_rts_threshold)
377 ret = local->ops->set_rts_threshold(&local->hw, value);
378 trace_drv_return_int(local, ret);
382 static inline int drv_set_coverage_class(struct ieee80211_local *local,
388 trace_drv_set_coverage_class(local, value);
389 if (local->ops->set_coverage_class)
390 local->ops->set_coverage_class(&local->hw, value);
394 trace_drv_return_int(local, ret);
398 static inline void drv_sta_notify(struct ieee80211_local *local,
399 struct ieee80211_sub_if_data *sdata,
400 enum sta_notify_cmd cmd,
401 struct ieee80211_sta *sta)
403 sdata = get_bss_sdata(sdata);
404 check_sdata_in_driver(sdata);
406 trace_drv_sta_notify(local, sdata, cmd, sta);
407 if (local->ops->sta_notify)
408 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
409 trace_drv_return_void(local);
412 static inline int drv_sta_add(struct ieee80211_local *local,
413 struct ieee80211_sub_if_data *sdata,
414 struct ieee80211_sta *sta)
420 sdata = get_bss_sdata(sdata);
421 check_sdata_in_driver(sdata);
423 trace_drv_sta_add(local, sdata, sta);
424 if (local->ops->sta_add)
425 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
427 trace_drv_return_int(local, ret);
432 static inline void drv_sta_remove(struct ieee80211_local *local,
433 struct ieee80211_sub_if_data *sdata,
434 struct ieee80211_sta *sta)
438 sdata = get_bss_sdata(sdata);
439 check_sdata_in_driver(sdata);
441 trace_drv_sta_remove(local, sdata, sta);
442 if (local->ops->sta_remove)
443 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
445 trace_drv_return_void(local);
448 static inline __must_check
449 int drv_sta_state(struct ieee80211_local *local,
450 struct ieee80211_sub_if_data *sdata,
451 struct sta_info *sta,
452 enum ieee80211_sta_state old_state,
453 enum ieee80211_sta_state new_state)
459 sdata = get_bss_sdata(sdata);
460 check_sdata_in_driver(sdata);
462 trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
463 if (local->ops->sta_state) {
464 ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta,
465 old_state, new_state);
466 } else if (old_state == IEEE80211_STA_AUTH &&
467 new_state == IEEE80211_STA_ASSOC) {
468 ret = drv_sta_add(local, sdata, &sta->sta);
470 sta->uploaded = true;
471 } else if (old_state == IEEE80211_STA_ASSOC &&
472 new_state == IEEE80211_STA_AUTH) {
473 drv_sta_remove(local, sdata, &sta->sta);
475 trace_drv_return_int(local, ret);
479 static inline void drv_sta_rc_update(struct ieee80211_local *local,
480 struct ieee80211_sub_if_data *sdata,
481 struct ieee80211_sta *sta, u32 changed)
483 sdata = get_bss_sdata(sdata);
484 check_sdata_in_driver(sdata);
486 trace_drv_sta_rc_update(local, sdata, sta, changed);
487 if (local->ops->sta_rc_update)
488 local->ops->sta_rc_update(&local->hw, &sdata->vif,
491 trace_drv_return_void(local);
494 static inline int drv_conf_tx(struct ieee80211_local *local,
495 struct ieee80211_sub_if_data *sdata, u16 ac,
496 const struct ieee80211_tx_queue_params *params)
498 int ret = -EOPNOTSUPP;
502 check_sdata_in_driver(sdata);
504 trace_drv_conf_tx(local, sdata, ac, params);
505 if (local->ops->conf_tx)
506 ret = local->ops->conf_tx(&local->hw, &sdata->vif,
508 trace_drv_return_int(local, ret);
512 static inline u64 drv_get_tsf(struct ieee80211_local *local,
513 struct ieee80211_sub_if_data *sdata)
519 check_sdata_in_driver(sdata);
521 trace_drv_get_tsf(local, sdata);
522 if (local->ops->get_tsf)
523 ret = local->ops->get_tsf(&local->hw, &sdata->vif);
524 trace_drv_return_u64(local, ret);
528 static inline void drv_set_tsf(struct ieee80211_local *local,
529 struct ieee80211_sub_if_data *sdata,
534 check_sdata_in_driver(sdata);
536 trace_drv_set_tsf(local, sdata, tsf);
537 if (local->ops->set_tsf)
538 local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
539 trace_drv_return_void(local);
542 static inline void drv_reset_tsf(struct ieee80211_local *local,
543 struct ieee80211_sub_if_data *sdata)
547 check_sdata_in_driver(sdata);
549 trace_drv_reset_tsf(local, sdata);
550 if (local->ops->reset_tsf)
551 local->ops->reset_tsf(&local->hw, &sdata->vif);
552 trace_drv_return_void(local);
555 static inline int drv_tx_last_beacon(struct ieee80211_local *local)
557 int ret = 0; /* default unsuported op for less congestion */
561 trace_drv_tx_last_beacon(local);
562 if (local->ops->tx_last_beacon)
563 ret = local->ops->tx_last_beacon(&local->hw);
564 trace_drv_return_int(local, ret);
568 static inline int drv_ampdu_action(struct ieee80211_local *local,
569 struct ieee80211_sub_if_data *sdata,
570 enum ieee80211_ampdu_mlme_action action,
571 struct ieee80211_sta *sta, u16 tid,
572 u16 *ssn, u8 buf_size)
574 int ret = -EOPNOTSUPP;
578 sdata = get_bss_sdata(sdata);
579 check_sdata_in_driver(sdata);
581 trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
583 if (local->ops->ampdu_action)
584 ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
585 sta, tid, ssn, buf_size);
587 trace_drv_return_int(local, ret);
592 static inline int drv_get_survey(struct ieee80211_local *local, int idx,
593 struct survey_info *survey)
595 int ret = -EOPNOTSUPP;
597 trace_drv_get_survey(local, idx, survey);
599 if (local->ops->get_survey)
600 ret = local->ops->get_survey(&local->hw, idx, survey);
602 trace_drv_return_int(local, ret);
607 static inline void drv_rfkill_poll(struct ieee80211_local *local)
611 if (local->ops->rfkill_poll)
612 local->ops->rfkill_poll(&local->hw);
615 static inline void drv_flush(struct ieee80211_local *local, bool drop)
619 trace_drv_flush(local, drop);
620 if (local->ops->flush)
621 local->ops->flush(&local->hw, drop);
622 trace_drv_return_void(local);
625 static inline void drv_channel_switch(struct ieee80211_local *local,
626 struct ieee80211_channel_switch *ch_switch)
630 trace_drv_channel_switch(local, ch_switch);
631 local->ops->channel_switch(&local->hw, ch_switch);
632 trace_drv_return_void(local);
636 static inline int drv_set_antenna(struct ieee80211_local *local,
637 u32 tx_ant, u32 rx_ant)
639 int ret = -EOPNOTSUPP;
641 if (local->ops->set_antenna)
642 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
643 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
647 static inline int drv_get_antenna(struct ieee80211_local *local,
648 u32 *tx_ant, u32 *rx_ant)
650 int ret = -EOPNOTSUPP;
652 if (local->ops->get_antenna)
653 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
654 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
658 static inline int drv_remain_on_channel(struct ieee80211_local *local,
659 struct ieee80211_channel *chan,
660 enum nl80211_channel_type chantype,
661 unsigned int duration)
667 trace_drv_remain_on_channel(local, chan, chantype, duration);
668 ret = local->ops->remain_on_channel(&local->hw, chan, chantype,
670 trace_drv_return_int(local, ret);
675 static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
681 trace_drv_cancel_remain_on_channel(local);
682 ret = local->ops->cancel_remain_on_channel(&local->hw);
683 trace_drv_return_int(local, ret);
688 static inline int drv_set_ringparam(struct ieee80211_local *local,
695 trace_drv_set_ringparam(local, tx, rx);
696 if (local->ops->set_ringparam)
697 ret = local->ops->set_ringparam(&local->hw, tx, rx);
698 trace_drv_return_int(local, ret);
703 static inline void drv_get_ringparam(struct ieee80211_local *local,
704 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
708 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
709 if (local->ops->get_ringparam)
710 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
711 trace_drv_return_void(local);
714 static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
720 trace_drv_tx_frames_pending(local);
721 if (local->ops->tx_frames_pending)
722 ret = local->ops->tx_frames_pending(&local->hw);
723 trace_drv_return_bool(local, ret);
728 static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
729 struct ieee80211_sub_if_data *sdata,
730 const struct cfg80211_bitrate_mask *mask)
732 int ret = -EOPNOTSUPP;
736 check_sdata_in_driver(sdata);
738 trace_drv_set_bitrate_mask(local, sdata, mask);
739 if (local->ops->set_bitrate_mask)
740 ret = local->ops->set_bitrate_mask(&local->hw,
742 trace_drv_return_int(local, ret);
747 static inline void drv_set_rekey_data(struct ieee80211_local *local,
748 struct ieee80211_sub_if_data *sdata,
749 struct cfg80211_gtk_rekey_data *data)
751 check_sdata_in_driver(sdata);
753 trace_drv_set_rekey_data(local, sdata, data);
754 if (local->ops->set_rekey_data)
755 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
756 trace_drv_return_void(local);
759 static inline void drv_rssi_callback(struct ieee80211_local *local,
760 const enum ieee80211_rssi_event event)
762 trace_drv_rssi_callback(local, event);
763 if (local->ops->rssi_callback)
764 local->ops->rssi_callback(&local->hw, event);
765 trace_drv_return_void(local);
769 drv_release_buffered_frames(struct ieee80211_local *local,
770 struct sta_info *sta, u16 tids, int num_frames,
771 enum ieee80211_frame_release_type reason,
774 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
776 if (local->ops->release_buffered_frames)
777 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
780 trace_drv_return_void(local);
784 drv_allow_buffered_frames(struct ieee80211_local *local,
785 struct sta_info *sta, u16 tids, int num_frames,
786 enum ieee80211_frame_release_type reason,
789 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
791 if (local->ops->allow_buffered_frames)
792 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
793 tids, num_frames, reason,
795 trace_drv_return_void(local);
797 #endif /* __MAC80211_DRIVER_OPS */