driver-ops.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. #ifndef __MAC80211_DRIVER_OPS
  2. #define __MAC80211_DRIVER_OPS
  3. #include <net/mac80211.h>
  4. #include "ieee80211_i.h"
  5. #include "driver-trace.h"
  6. static inline int drv_tx(struct ieee80211_local *local, struct sk_buff *skb)
  7. {
  8. return local->ops->tx(&local->hw, skb);
  9. }
  10. static inline int drv_start(struct ieee80211_local *local)
  11. {
  12. int ret;
  13. local->started = true;
  14. smp_mb();
  15. ret = local->ops->start(&local->hw);
  16. trace_drv_start(local, ret);
  17. return ret;
  18. }
  19. static inline void drv_stop(struct ieee80211_local *local)
  20. {
  21. local->ops->stop(&local->hw);
  22. trace_drv_stop(local);
  23. /* sync away all work on the tasklet before clearing started */
  24. tasklet_disable(&local->tasklet);
  25. tasklet_enable(&local->tasklet);
  26. barrier();
  27. local->started = false;
  28. }
  29. static inline int drv_add_interface(struct ieee80211_local *local,
  30. struct ieee80211_if_init_conf *conf)
  31. {
  32. int ret = local->ops->add_interface(&local->hw, conf);
  33. trace_drv_add_interface(local, vif_to_sdata(conf->vif), ret);
  34. return ret;
  35. }
  36. static inline void drv_remove_interface(struct ieee80211_local *local,
  37. struct ieee80211_if_init_conf *conf)
  38. {
  39. local->ops->remove_interface(&local->hw, conf);
  40. trace_drv_remove_interface(local, vif_to_sdata(conf->vif));
  41. }
  42. static inline int drv_config(struct ieee80211_local *local, u32 changed)
  43. {
  44. int ret = local->ops->config(&local->hw, changed);
  45. trace_drv_config(local, changed, ret);
  46. return ret;
  47. }
  48. static inline void drv_bss_info_changed(struct ieee80211_local *local,
  49. struct ieee80211_sub_if_data *sdata,
  50. struct ieee80211_bss_conf *info,
  51. u32 changed)
  52. {
  53. if (local->ops->bss_info_changed)
  54. local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
  55. trace_drv_bss_info_changed(local, sdata, info, changed);
  56. }
  57. static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
  58. int mc_count,
  59. struct dev_addr_list *mc_list)
  60. {
  61. u64 ret = 0;
  62. if (local->ops->prepare_multicast)
  63. ret = local->ops->prepare_multicast(&local->hw, mc_count,
  64. mc_list);
  65. trace_drv_prepare_multicast(local, mc_count, ret);
  66. return ret;
  67. }
  68. static inline void drv_configure_filter(struct ieee80211_local *local,
  69. unsigned int changed_flags,
  70. unsigned int *total_flags,
  71. u64 multicast)
  72. {
  73. might_sleep();
  74. local->ops->configure_filter(&local->hw, changed_flags, total_flags,
  75. multicast);
  76. trace_drv_configure_filter(local, changed_flags, total_flags,
  77. multicast);
  78. }
  79. static inline int drv_set_tim(struct ieee80211_local *local,
  80. struct ieee80211_sta *sta, bool set)
  81. {
  82. int ret = 0;
  83. if (local->ops->set_tim)
  84. ret = local->ops->set_tim(&local->hw, sta, set);
  85. trace_drv_set_tim(local, sta, set, ret);
  86. return ret;
  87. }
  88. static inline int drv_set_key(struct ieee80211_local *local,
  89. enum set_key_cmd cmd,
  90. struct ieee80211_sub_if_data *sdata,
  91. struct ieee80211_sta *sta,
  92. struct ieee80211_key_conf *key)
  93. {
  94. int ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
  95. trace_drv_set_key(local, cmd, sdata, sta, key, ret);
  96. return ret;
  97. }
  98. static inline void drv_update_tkip_key(struct ieee80211_local *local,
  99. struct ieee80211_key_conf *conf,
  100. const u8 *address, u32 iv32,
  101. u16 *phase1key)
  102. {
  103. if (local->ops->update_tkip_key)
  104. local->ops->update_tkip_key(&local->hw, conf, address,
  105. iv32, phase1key);
  106. trace_drv_update_tkip_key(local, conf, address, iv32);
  107. }
  108. static inline int drv_hw_scan(struct ieee80211_local *local,
  109. struct cfg80211_scan_request *req)
  110. {
  111. int ret = local->ops->hw_scan(&local->hw, req);
  112. trace_drv_hw_scan(local, req, ret);
  113. return ret;
  114. }
  115. static inline void drv_sw_scan_start(struct ieee80211_local *local)
  116. {
  117. if (local->ops->sw_scan_start)
  118. local->ops->sw_scan_start(&local->hw);
  119. trace_drv_sw_scan_start(local);
  120. }
  121. static inline void drv_sw_scan_complete(struct ieee80211_local *local)
  122. {
  123. if (local->ops->sw_scan_complete)
  124. local->ops->sw_scan_complete(&local->hw);
  125. trace_drv_sw_scan_complete(local);
  126. }
  127. static inline int drv_get_stats(struct ieee80211_local *local,
  128. struct ieee80211_low_level_stats *stats)
  129. {
  130. int ret = -EOPNOTSUPP;
  131. if (local->ops->get_stats)
  132. ret = local->ops->get_stats(&local->hw, stats);
  133. trace_drv_get_stats(local, stats, ret);
  134. return ret;
  135. }
  136. static inline void drv_get_tkip_seq(struct ieee80211_local *local,
  137. u8 hw_key_idx, u32 *iv32, u16 *iv16)
  138. {
  139. if (local->ops->get_tkip_seq)
  140. local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
  141. trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
  142. }
  143. static inline int drv_set_rts_threshold(struct ieee80211_local *local,
  144. u32 value)
  145. {
  146. int ret = 0;
  147. if (local->ops->set_rts_threshold)
  148. ret = local->ops->set_rts_threshold(&local->hw, value);
  149. trace_drv_set_rts_threshold(local, value, ret);
  150. return ret;
  151. }
  152. static inline void drv_sta_notify(struct ieee80211_local *local,
  153. struct ieee80211_sub_if_data *sdata,
  154. enum sta_notify_cmd cmd,
  155. struct ieee80211_sta *sta)
  156. {
  157. if (local->ops->sta_notify)
  158. local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
  159. trace_drv_sta_notify(local, sdata, cmd, sta);
  160. }
  161. static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue,
  162. const struct ieee80211_tx_queue_params *params)
  163. {
  164. int ret = -EOPNOTSUPP;
  165. if (local->ops->conf_tx)
  166. ret = local->ops->conf_tx(&local->hw, queue, params);
  167. trace_drv_conf_tx(local, queue, params, ret);
  168. return ret;
  169. }
  170. static inline int drv_get_tx_stats(struct ieee80211_local *local,
  171. struct ieee80211_tx_queue_stats *stats)
  172. {
  173. int ret = local->ops->get_tx_stats(&local->hw, stats);
  174. trace_drv_get_tx_stats(local, stats, ret);
  175. return ret;
  176. }
  177. static inline u64 drv_get_tsf(struct ieee80211_local *local)
  178. {
  179. u64 ret = -1ULL;
  180. if (local->ops->get_tsf)
  181. ret = local->ops->get_tsf(&local->hw);
  182. trace_drv_get_tsf(local, ret);
  183. return ret;
  184. }
  185. static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf)
  186. {
  187. if (local->ops->set_tsf)
  188. local->ops->set_tsf(&local->hw, tsf);
  189. trace_drv_set_tsf(local, tsf);
  190. }
  191. static inline void drv_reset_tsf(struct ieee80211_local *local)
  192. {
  193. if (local->ops->reset_tsf)
  194. local->ops->reset_tsf(&local->hw);
  195. trace_drv_reset_tsf(local);
  196. }
  197. static inline int drv_tx_last_beacon(struct ieee80211_local *local)
  198. {
  199. int ret = 1;
  200. if (local->ops->tx_last_beacon)
  201. ret = local->ops->tx_last_beacon(&local->hw);
  202. trace_drv_tx_last_beacon(local, ret);
  203. return ret;
  204. }
  205. static inline int drv_ampdu_action(struct ieee80211_local *local,
  206. struct ieee80211_sub_if_data *sdata,
  207. enum ieee80211_ampdu_mlme_action action,
  208. struct ieee80211_sta *sta, u16 tid,
  209. u16 *ssn)
  210. {
  211. int ret = -EOPNOTSUPP;
  212. if (local->ops->ampdu_action)
  213. ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
  214. sta, tid, ssn);
  215. trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, ret);
  216. return ret;
  217. }
  218. static inline void drv_rfkill_poll(struct ieee80211_local *local)
  219. {
  220. if (local->ops->rfkill_poll)
  221. local->ops->rfkill_poll(&local->hw);
  222. }
  223. #endif /* __MAC80211_DRIVER_OPS */