driver-ops.h 9.5 KB

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