driver-ops.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  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 int drv_change_interface(struct ieee80211_local *local,
  44. struct ieee80211_sub_if_data *sdata,
  45. enum nl80211_iftype type, bool p2p)
  46. {
  47. int ret;
  48. might_sleep();
  49. trace_drv_change_interface(local, sdata, type, p2p);
  50. ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
  51. trace_drv_return_int(local, ret);
  52. return ret;
  53. }
  54. static inline void drv_remove_interface(struct ieee80211_local *local,
  55. struct ieee80211_vif *vif)
  56. {
  57. might_sleep();
  58. trace_drv_remove_interface(local, vif_to_sdata(vif));
  59. local->ops->remove_interface(&local->hw, vif);
  60. trace_drv_return_void(local);
  61. }
  62. static inline int drv_config(struct ieee80211_local *local, u32 changed)
  63. {
  64. int ret;
  65. might_sleep();
  66. trace_drv_config(local, changed);
  67. ret = local->ops->config(&local->hw, changed);
  68. trace_drv_return_int(local, ret);
  69. return ret;
  70. }
  71. static inline void drv_bss_info_changed(struct ieee80211_local *local,
  72. struct ieee80211_sub_if_data *sdata,
  73. struct ieee80211_bss_conf *info,
  74. u32 changed)
  75. {
  76. might_sleep();
  77. trace_drv_bss_info_changed(local, sdata, info, changed);
  78. if (local->ops->bss_info_changed)
  79. local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
  80. trace_drv_return_void(local);
  81. }
  82. static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
  83. struct netdev_hw_addr_list *mc_list)
  84. {
  85. u64 ret = 0;
  86. trace_drv_prepare_multicast(local, mc_list->count);
  87. if (local->ops->prepare_multicast)
  88. ret = local->ops->prepare_multicast(&local->hw, mc_list);
  89. trace_drv_return_u64(local, ret);
  90. return ret;
  91. }
  92. static inline void drv_configure_filter(struct ieee80211_local *local,
  93. unsigned int changed_flags,
  94. unsigned int *total_flags,
  95. u64 multicast)
  96. {
  97. might_sleep();
  98. trace_drv_configure_filter(local, changed_flags, total_flags,
  99. multicast);
  100. local->ops->configure_filter(&local->hw, changed_flags, total_flags,
  101. multicast);
  102. trace_drv_return_void(local);
  103. }
  104. static inline int drv_set_tim(struct ieee80211_local *local,
  105. struct ieee80211_sta *sta, bool set)
  106. {
  107. int ret = 0;
  108. trace_drv_set_tim(local, sta, set);
  109. if (local->ops->set_tim)
  110. ret = local->ops->set_tim(&local->hw, sta, set);
  111. trace_drv_return_int(local, ret);
  112. return ret;
  113. }
  114. static inline int drv_set_key(struct ieee80211_local *local,
  115. enum set_key_cmd cmd,
  116. struct ieee80211_sub_if_data *sdata,
  117. struct ieee80211_sta *sta,
  118. struct ieee80211_key_conf *key)
  119. {
  120. int ret;
  121. might_sleep();
  122. trace_drv_set_key(local, cmd, sdata, sta, key);
  123. ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
  124. trace_drv_return_int(local, ret);
  125. return ret;
  126. }
  127. static inline void drv_update_tkip_key(struct ieee80211_local *local,
  128. struct ieee80211_sub_if_data *sdata,
  129. struct ieee80211_key_conf *conf,
  130. struct sta_info *sta, u32 iv32,
  131. u16 *phase1key)
  132. {
  133. struct ieee80211_sta *ista = NULL;
  134. if (sta)
  135. ista = &sta->sta;
  136. trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
  137. if (local->ops->update_tkip_key)
  138. local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
  139. ista, iv32, phase1key);
  140. trace_drv_return_void(local);
  141. }
  142. static inline int drv_hw_scan(struct ieee80211_local *local,
  143. struct ieee80211_sub_if_data *sdata,
  144. struct cfg80211_scan_request *req)
  145. {
  146. int ret;
  147. might_sleep();
  148. trace_drv_hw_scan(local, sdata, req);
  149. ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
  150. trace_drv_return_int(local, ret);
  151. return ret;
  152. }
  153. static inline void drv_sw_scan_start(struct ieee80211_local *local)
  154. {
  155. might_sleep();
  156. trace_drv_sw_scan_start(local);
  157. if (local->ops->sw_scan_start)
  158. local->ops->sw_scan_start(&local->hw);
  159. trace_drv_return_void(local);
  160. }
  161. static inline void drv_sw_scan_complete(struct ieee80211_local *local)
  162. {
  163. might_sleep();
  164. trace_drv_sw_scan_complete(local);
  165. if (local->ops->sw_scan_complete)
  166. local->ops->sw_scan_complete(&local->hw);
  167. trace_drv_return_void(local);
  168. }
  169. static inline int drv_get_stats(struct ieee80211_local *local,
  170. struct ieee80211_low_level_stats *stats)
  171. {
  172. int ret = -EOPNOTSUPP;
  173. might_sleep();
  174. if (local->ops->get_stats)
  175. ret = local->ops->get_stats(&local->hw, stats);
  176. trace_drv_get_stats(local, stats, ret);
  177. return ret;
  178. }
  179. static inline void drv_get_tkip_seq(struct ieee80211_local *local,
  180. u8 hw_key_idx, u32 *iv32, u16 *iv16)
  181. {
  182. if (local->ops->get_tkip_seq)
  183. local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
  184. trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
  185. }
  186. static inline int drv_set_frag_threshold(struct ieee80211_local *local,
  187. u32 value)
  188. {
  189. int ret = 0;
  190. might_sleep();
  191. trace_drv_set_frag_threshold(local, value);
  192. if (local->ops->set_frag_threshold)
  193. ret = local->ops->set_frag_threshold(&local->hw, value);
  194. trace_drv_return_int(local, ret);
  195. return ret;
  196. }
  197. static inline int drv_set_rts_threshold(struct ieee80211_local *local,
  198. u32 value)
  199. {
  200. int ret = 0;
  201. might_sleep();
  202. trace_drv_set_rts_threshold(local, value);
  203. if (local->ops->set_rts_threshold)
  204. ret = local->ops->set_rts_threshold(&local->hw, value);
  205. trace_drv_return_int(local, ret);
  206. return ret;
  207. }
  208. static inline int drv_set_coverage_class(struct ieee80211_local *local,
  209. u8 value)
  210. {
  211. int ret = 0;
  212. might_sleep();
  213. trace_drv_set_coverage_class(local, value);
  214. if (local->ops->set_coverage_class)
  215. local->ops->set_coverage_class(&local->hw, value);
  216. else
  217. ret = -EOPNOTSUPP;
  218. trace_drv_return_int(local, ret);
  219. return ret;
  220. }
  221. static inline void drv_sta_notify(struct ieee80211_local *local,
  222. struct ieee80211_sub_if_data *sdata,
  223. enum sta_notify_cmd cmd,
  224. struct ieee80211_sta *sta)
  225. {
  226. trace_drv_sta_notify(local, sdata, cmd, sta);
  227. if (local->ops->sta_notify)
  228. local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
  229. trace_drv_return_void(local);
  230. }
  231. static inline int drv_sta_add(struct ieee80211_local *local,
  232. struct ieee80211_sub_if_data *sdata,
  233. struct ieee80211_sta *sta)
  234. {
  235. int ret = 0;
  236. might_sleep();
  237. trace_drv_sta_add(local, sdata, sta);
  238. if (local->ops->sta_add)
  239. ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
  240. trace_drv_return_int(local, ret);
  241. return ret;
  242. }
  243. static inline void drv_sta_remove(struct ieee80211_local *local,
  244. struct ieee80211_sub_if_data *sdata,
  245. struct ieee80211_sta *sta)
  246. {
  247. might_sleep();
  248. trace_drv_sta_remove(local, sdata, sta);
  249. if (local->ops->sta_remove)
  250. local->ops->sta_remove(&local->hw, &sdata->vif, sta);
  251. trace_drv_return_void(local);
  252. }
  253. static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue,
  254. const struct ieee80211_tx_queue_params *params)
  255. {
  256. int ret = -EOPNOTSUPP;
  257. might_sleep();
  258. trace_drv_conf_tx(local, queue, params);
  259. if (local->ops->conf_tx)
  260. ret = local->ops->conf_tx(&local->hw, queue, params);
  261. trace_drv_return_int(local, ret);
  262. return ret;
  263. }
  264. static inline u64 drv_get_tsf(struct ieee80211_local *local)
  265. {
  266. u64 ret = -1ULL;
  267. might_sleep();
  268. trace_drv_get_tsf(local);
  269. if (local->ops->get_tsf)
  270. ret = local->ops->get_tsf(&local->hw);
  271. trace_drv_return_u64(local, ret);
  272. return ret;
  273. }
  274. static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf)
  275. {
  276. might_sleep();
  277. trace_drv_set_tsf(local, tsf);
  278. if (local->ops->set_tsf)
  279. local->ops->set_tsf(&local->hw, tsf);
  280. trace_drv_return_void(local);
  281. }
  282. static inline void drv_reset_tsf(struct ieee80211_local *local)
  283. {
  284. might_sleep();
  285. trace_drv_reset_tsf(local);
  286. if (local->ops->reset_tsf)
  287. local->ops->reset_tsf(&local->hw);
  288. trace_drv_return_void(local);
  289. }
  290. static inline int drv_tx_last_beacon(struct ieee80211_local *local)
  291. {
  292. int ret = 0; /* default unsuported op for less congestion */
  293. might_sleep();
  294. trace_drv_tx_last_beacon(local);
  295. if (local->ops->tx_last_beacon)
  296. ret = local->ops->tx_last_beacon(&local->hw);
  297. trace_drv_return_int(local, ret);
  298. return ret;
  299. }
  300. static inline int drv_ampdu_action(struct ieee80211_local *local,
  301. struct ieee80211_sub_if_data *sdata,
  302. enum ieee80211_ampdu_mlme_action action,
  303. struct ieee80211_sta *sta, u16 tid,
  304. u16 *ssn)
  305. {
  306. int ret = -EOPNOTSUPP;
  307. might_sleep();
  308. trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn);
  309. if (local->ops->ampdu_action)
  310. ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
  311. sta, tid, ssn);
  312. trace_drv_return_int(local, ret);
  313. return ret;
  314. }
  315. static inline int drv_get_survey(struct ieee80211_local *local, int idx,
  316. struct survey_info *survey)
  317. {
  318. int ret = -EOPNOTSUPP;
  319. trace_drv_get_survey(local, idx, survey);
  320. if (local->ops->get_survey)
  321. ret = local->ops->get_survey(&local->hw, idx, survey);
  322. trace_drv_return_int(local, ret);
  323. return ret;
  324. }
  325. static inline void drv_rfkill_poll(struct ieee80211_local *local)
  326. {
  327. might_sleep();
  328. if (local->ops->rfkill_poll)
  329. local->ops->rfkill_poll(&local->hw);
  330. }
  331. static inline void drv_flush(struct ieee80211_local *local, bool drop)
  332. {
  333. might_sleep();
  334. trace_drv_flush(local, drop);
  335. if (local->ops->flush)
  336. local->ops->flush(&local->hw, drop);
  337. trace_drv_return_void(local);
  338. }
  339. static inline void drv_channel_switch(struct ieee80211_local *local,
  340. struct ieee80211_channel_switch *ch_switch)
  341. {
  342. might_sleep();
  343. trace_drv_channel_switch(local, ch_switch);
  344. local->ops->channel_switch(&local->hw, ch_switch);
  345. trace_drv_return_void(local);
  346. }
  347. static inline int drv_set_antenna(struct ieee80211_local *local,
  348. u32 tx_ant, u32 rx_ant)
  349. {
  350. int ret = -EOPNOTSUPP;
  351. might_sleep();
  352. if (local->ops->set_antenna)
  353. ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
  354. trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
  355. return ret;
  356. }
  357. static inline int drv_get_antenna(struct ieee80211_local *local,
  358. u32 *tx_ant, u32 *rx_ant)
  359. {
  360. int ret = -EOPNOTSUPP;
  361. might_sleep();
  362. if (local->ops->get_antenna)
  363. ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
  364. trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
  365. return ret;
  366. }
  367. static inline int drv_remain_on_channel(struct ieee80211_local *local,
  368. struct ieee80211_channel *chan,
  369. enum nl80211_channel_type chantype,
  370. unsigned int duration)
  371. {
  372. int ret;
  373. might_sleep();
  374. trace_drv_remain_on_channel(local, chan, chantype, duration);
  375. ret = local->ops->remain_on_channel(&local->hw, chan, chantype,
  376. duration);
  377. trace_drv_return_int(local, ret);
  378. return ret;
  379. }
  380. static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
  381. {
  382. int ret;
  383. might_sleep();
  384. trace_drv_cancel_remain_on_channel(local);
  385. ret = local->ops->cancel_remain_on_channel(&local->hw);
  386. trace_drv_return_int(local, ret);
  387. return ret;
  388. }
  389. #endif /* __MAC80211_DRIVER_OPS */