driver-ops.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  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. might_sleep();
  14. local->started = true;
  15. smp_mb();
  16. ret = local->ops->start(&local->hw);
  17. trace_drv_start(local, ret);
  18. return ret;
  19. }
  20. static inline void drv_stop(struct ieee80211_local *local)
  21. {
  22. might_sleep();
  23. local->ops->stop(&local->hw);
  24. trace_drv_stop(local);
  25. /* sync away all work on the tasklet before clearing started */
  26. tasklet_disable(&local->tasklet);
  27. tasklet_enable(&local->tasklet);
  28. barrier();
  29. local->started = false;
  30. }
  31. static inline int drv_add_interface(struct ieee80211_local *local,
  32. struct ieee80211_vif *vif)
  33. {
  34. int ret;
  35. might_sleep();
  36. ret = local->ops->add_interface(&local->hw, vif);
  37. trace_drv_add_interface(local, vif_to_sdata(vif), ret);
  38. return ret;
  39. }
  40. static inline void drv_remove_interface(struct ieee80211_local *local,
  41. struct ieee80211_vif *vif)
  42. {
  43. might_sleep();
  44. local->ops->remove_interface(&local->hw, vif);
  45. trace_drv_remove_interface(local, vif_to_sdata(vif));
  46. }
  47. static inline int drv_config(struct ieee80211_local *local, u32 changed)
  48. {
  49. int ret;
  50. might_sleep();
  51. ret = local->ops->config(&local->hw, changed);
  52. trace_drv_config(local, changed, ret);
  53. return ret;
  54. }
  55. static inline void drv_bss_info_changed(struct ieee80211_local *local,
  56. struct ieee80211_sub_if_data *sdata,
  57. struct ieee80211_bss_conf *info,
  58. u32 changed)
  59. {
  60. might_sleep();
  61. if (local->ops->bss_info_changed)
  62. local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
  63. trace_drv_bss_info_changed(local, sdata, info, changed);
  64. }
  65. struct in_ifaddr;
  66. static inline int drv_configure_arp_filter(struct ieee80211_local *local,
  67. struct ieee80211_vif *vif,
  68. struct in_ifaddr *ifa_list)
  69. {
  70. int ret = 0;
  71. might_sleep();
  72. if (local->ops->configure_arp_filter)
  73. ret = local->ops->configure_arp_filter(&local->hw, vif,
  74. ifa_list);
  75. trace_drv_configure_arp_filter(local, vif_to_sdata(vif), ifa_list, ret);
  76. return ret;
  77. }
  78. static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
  79. struct netdev_hw_addr_list *mc_list)
  80. {
  81. u64 ret = 0;
  82. if (local->ops->prepare_multicast)
  83. ret = local->ops->prepare_multicast(&local->hw, mc_list);
  84. trace_drv_prepare_multicast(local, mc_list->count, ret);
  85. return ret;
  86. }
  87. static inline void drv_configure_filter(struct ieee80211_local *local,
  88. unsigned int changed_flags,
  89. unsigned int *total_flags,
  90. u64 multicast)
  91. {
  92. might_sleep();
  93. local->ops->configure_filter(&local->hw, changed_flags, total_flags,
  94. multicast);
  95. trace_drv_configure_filter(local, changed_flags, total_flags,
  96. multicast);
  97. }
  98. static inline int drv_set_tim(struct ieee80211_local *local,
  99. struct ieee80211_sta *sta, bool set)
  100. {
  101. int ret = 0;
  102. if (local->ops->set_tim)
  103. ret = local->ops->set_tim(&local->hw, sta, set);
  104. trace_drv_set_tim(local, sta, set, ret);
  105. return ret;
  106. }
  107. static inline int drv_set_key(struct ieee80211_local *local,
  108. enum set_key_cmd cmd,
  109. struct ieee80211_sub_if_data *sdata,
  110. struct ieee80211_sta *sta,
  111. struct ieee80211_key_conf *key)
  112. {
  113. int ret;
  114. might_sleep();
  115. ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
  116. trace_drv_set_key(local, cmd, sdata, sta, key, ret);
  117. return ret;
  118. }
  119. static inline void drv_update_tkip_key(struct ieee80211_local *local,
  120. struct ieee80211_sub_if_data *sdata,
  121. struct ieee80211_key_conf *conf,
  122. struct sta_info *sta, u32 iv32,
  123. u16 *phase1key)
  124. {
  125. struct ieee80211_sta *ista = NULL;
  126. if (sta)
  127. ista = &sta->sta;
  128. if (local->ops->update_tkip_key)
  129. local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
  130. ista, iv32, phase1key);
  131. trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
  132. }
  133. static inline int drv_hw_scan(struct ieee80211_local *local,
  134. struct ieee80211_sub_if_data *sdata,
  135. struct cfg80211_scan_request *req)
  136. {
  137. int ret;
  138. might_sleep();
  139. ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
  140. trace_drv_hw_scan(local, sdata, req, ret);
  141. return ret;
  142. }
  143. static inline void drv_sw_scan_start(struct ieee80211_local *local)
  144. {
  145. might_sleep();
  146. if (local->ops->sw_scan_start)
  147. local->ops->sw_scan_start(&local->hw);
  148. trace_drv_sw_scan_start(local);
  149. }
  150. static inline void drv_sw_scan_complete(struct ieee80211_local *local)
  151. {
  152. might_sleep();
  153. if (local->ops->sw_scan_complete)
  154. local->ops->sw_scan_complete(&local->hw);
  155. trace_drv_sw_scan_complete(local);
  156. }
  157. static inline int drv_get_stats(struct ieee80211_local *local,
  158. struct ieee80211_low_level_stats *stats)
  159. {
  160. int ret = -EOPNOTSUPP;
  161. might_sleep();
  162. if (local->ops->get_stats)
  163. ret = local->ops->get_stats(&local->hw, stats);
  164. trace_drv_get_stats(local, stats, ret);
  165. return ret;
  166. }
  167. static inline void drv_get_tkip_seq(struct ieee80211_local *local,
  168. u8 hw_key_idx, u32 *iv32, u16 *iv16)
  169. {
  170. if (local->ops->get_tkip_seq)
  171. local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
  172. trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
  173. }
  174. static inline int drv_set_rts_threshold(struct ieee80211_local *local,
  175. u32 value)
  176. {
  177. int ret = 0;
  178. might_sleep();
  179. if (local->ops->set_rts_threshold)
  180. ret = local->ops->set_rts_threshold(&local->hw, value);
  181. trace_drv_set_rts_threshold(local, value, ret);
  182. return ret;
  183. }
  184. static inline int drv_set_coverage_class(struct ieee80211_local *local,
  185. u8 value)
  186. {
  187. int ret = 0;
  188. might_sleep();
  189. if (local->ops->set_coverage_class)
  190. local->ops->set_coverage_class(&local->hw, value);
  191. else
  192. ret = -EOPNOTSUPP;
  193. trace_drv_set_coverage_class(local, value, ret);
  194. return ret;
  195. }
  196. static inline void drv_sta_notify(struct ieee80211_local *local,
  197. struct ieee80211_sub_if_data *sdata,
  198. enum sta_notify_cmd cmd,
  199. struct ieee80211_sta *sta)
  200. {
  201. if (local->ops->sta_notify)
  202. local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
  203. trace_drv_sta_notify(local, sdata, cmd, sta);
  204. }
  205. static inline int drv_sta_add(struct ieee80211_local *local,
  206. struct ieee80211_sub_if_data *sdata,
  207. struct ieee80211_sta *sta)
  208. {
  209. int ret = 0;
  210. might_sleep();
  211. if (local->ops->sta_add)
  212. ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
  213. trace_drv_sta_add(local, sdata, sta, ret);
  214. return ret;
  215. }
  216. static inline void drv_sta_remove(struct ieee80211_local *local,
  217. struct ieee80211_sub_if_data *sdata,
  218. struct ieee80211_sta *sta)
  219. {
  220. might_sleep();
  221. if (local->ops->sta_remove)
  222. local->ops->sta_remove(&local->hw, &sdata->vif, sta);
  223. trace_drv_sta_remove(local, sdata, sta);
  224. }
  225. static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue,
  226. const struct ieee80211_tx_queue_params *params)
  227. {
  228. int ret = -EOPNOTSUPP;
  229. might_sleep();
  230. if (local->ops->conf_tx)
  231. ret = local->ops->conf_tx(&local->hw, queue, params);
  232. trace_drv_conf_tx(local, queue, params, ret);
  233. return ret;
  234. }
  235. static inline u64 drv_get_tsf(struct ieee80211_local *local)
  236. {
  237. u64 ret = -1ULL;
  238. might_sleep();
  239. if (local->ops->get_tsf)
  240. ret = local->ops->get_tsf(&local->hw);
  241. trace_drv_get_tsf(local, ret);
  242. return ret;
  243. }
  244. static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf)
  245. {
  246. might_sleep();
  247. if (local->ops->set_tsf)
  248. local->ops->set_tsf(&local->hw, tsf);
  249. trace_drv_set_tsf(local, tsf);
  250. }
  251. static inline void drv_reset_tsf(struct ieee80211_local *local)
  252. {
  253. might_sleep();
  254. if (local->ops->reset_tsf)
  255. local->ops->reset_tsf(&local->hw);
  256. trace_drv_reset_tsf(local);
  257. }
  258. static inline int drv_tx_last_beacon(struct ieee80211_local *local)
  259. {
  260. int ret = 1;
  261. might_sleep();
  262. if (local->ops->tx_last_beacon)
  263. ret = local->ops->tx_last_beacon(&local->hw);
  264. trace_drv_tx_last_beacon(local, ret);
  265. return ret;
  266. }
  267. static inline int drv_ampdu_action(struct ieee80211_local *local,
  268. struct ieee80211_sub_if_data *sdata,
  269. enum ieee80211_ampdu_mlme_action action,
  270. struct ieee80211_sta *sta, u16 tid,
  271. u16 *ssn)
  272. {
  273. int ret = -EOPNOTSUPP;
  274. if (local->ops->ampdu_action)
  275. ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
  276. sta, tid, ssn);
  277. trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, ret);
  278. return ret;
  279. }
  280. static inline int drv_get_survey(struct ieee80211_local *local, int idx,
  281. struct survey_info *survey)
  282. {
  283. int ret = -EOPNOTSUPP;
  284. if (local->ops->get_survey)
  285. ret = local->ops->get_survey(&local->hw, idx, survey);
  286. /* trace_drv_get_survey(local, idx, survey, ret); */
  287. return ret;
  288. }
  289. static inline void drv_rfkill_poll(struct ieee80211_local *local)
  290. {
  291. might_sleep();
  292. if (local->ops->rfkill_poll)
  293. local->ops->rfkill_poll(&local->hw);
  294. }
  295. static inline void drv_flush(struct ieee80211_local *local, bool drop)
  296. {
  297. might_sleep();
  298. trace_drv_flush(local, drop);
  299. if (local->ops->flush)
  300. local->ops->flush(&local->hw, drop);
  301. }
  302. static inline void drv_channel_switch(struct ieee80211_local *local,
  303. struct ieee80211_channel_switch *ch_switch)
  304. {
  305. might_sleep();
  306. local->ops->channel_switch(&local->hw, ch_switch);
  307. trace_drv_channel_switch(local, ch_switch);
  308. }
  309. #endif /* __MAC80211_DRIVER_OPS */