hw_ops.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. /*
  2. * This file is part of wlcore
  3. *
  4. * Copyright (C) 2011 Texas Instruments Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  18. * 02110-1301 USA
  19. *
  20. */
  21. #ifndef __WLCORE_HW_OPS_H__
  22. #define __WLCORE_HW_OPS_H__
  23. #include "wlcore.h"
  24. #include "rx.h"
  25. static inline u32
  26. wlcore_hw_calc_tx_blocks(struct wl1271 *wl, u32 len, u32 spare_blks)
  27. {
  28. if (!wl->ops->calc_tx_blocks)
  29. BUG_ON(1);
  30. return wl->ops->calc_tx_blocks(wl, len, spare_blks);
  31. }
  32. static inline void
  33. wlcore_hw_set_tx_desc_blocks(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc,
  34. u32 blks, u32 spare_blks)
  35. {
  36. if (!wl->ops->set_tx_desc_blocks)
  37. BUG_ON(1);
  38. return wl->ops->set_tx_desc_blocks(wl, desc, blks, spare_blks);
  39. }
  40. static inline void
  41. wlcore_hw_set_tx_desc_data_len(struct wl1271 *wl,
  42. struct wl1271_tx_hw_descr *desc,
  43. struct sk_buff *skb)
  44. {
  45. if (!wl->ops->set_tx_desc_data_len)
  46. BUG_ON(1);
  47. wl->ops->set_tx_desc_data_len(wl, desc, skb);
  48. }
  49. static inline enum wl_rx_buf_align
  50. wlcore_hw_get_rx_buf_align(struct wl1271 *wl, u32 rx_desc)
  51. {
  52. if (!wl->ops->get_rx_buf_align)
  53. BUG_ON(1);
  54. return wl->ops->get_rx_buf_align(wl, rx_desc);
  55. }
  56. static inline int
  57. wlcore_hw_prepare_read(struct wl1271 *wl, u32 rx_desc, u32 len)
  58. {
  59. if (wl->ops->prepare_read)
  60. return wl->ops->prepare_read(wl, rx_desc, len);
  61. return 0;
  62. }
  63. static inline u32
  64. wlcore_hw_get_rx_packet_len(struct wl1271 *wl, void *rx_data, u32 data_len)
  65. {
  66. if (!wl->ops->get_rx_packet_len)
  67. BUG_ON(1);
  68. return wl->ops->get_rx_packet_len(wl, rx_data, data_len);
  69. }
  70. static inline int wlcore_hw_tx_delayed_compl(struct wl1271 *wl)
  71. {
  72. if (wl->ops->tx_delayed_compl)
  73. return wl->ops->tx_delayed_compl(wl);
  74. return 0;
  75. }
  76. static inline void wlcore_hw_tx_immediate_compl(struct wl1271 *wl)
  77. {
  78. if (wl->ops->tx_immediate_compl)
  79. wl->ops->tx_immediate_compl(wl);
  80. }
  81. static inline int
  82. wlcore_hw_init_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif)
  83. {
  84. if (wl->ops->init_vif)
  85. return wl->ops->init_vif(wl, wlvif);
  86. return 0;
  87. }
  88. static inline void
  89. wlcore_hw_convert_fw_status(struct wl1271 *wl, void *raw_fw_status,
  90. struct wl_fw_status *fw_status)
  91. {
  92. BUG_ON(!wl->ops->convert_fw_status);
  93. wl->ops->convert_fw_status(wl, raw_fw_status, fw_status);
  94. }
  95. static inline u32
  96. wlcore_hw_sta_get_ap_rate_mask(struct wl1271 *wl, struct wl12xx_vif *wlvif)
  97. {
  98. if (!wl->ops->sta_get_ap_rate_mask)
  99. BUG_ON(1);
  100. return wl->ops->sta_get_ap_rate_mask(wl, wlvif);
  101. }
  102. static inline int wlcore_identify_fw(struct wl1271 *wl)
  103. {
  104. if (wl->ops->identify_fw)
  105. return wl->ops->identify_fw(wl);
  106. return 0;
  107. }
  108. static inline void
  109. wlcore_hw_set_tx_desc_csum(struct wl1271 *wl,
  110. struct wl1271_tx_hw_descr *desc,
  111. struct sk_buff *skb)
  112. {
  113. if (!wl->ops->set_tx_desc_csum)
  114. BUG_ON(1);
  115. wl->ops->set_tx_desc_csum(wl, desc, skb);
  116. }
  117. static inline void
  118. wlcore_hw_set_rx_csum(struct wl1271 *wl,
  119. struct wl1271_rx_descriptor *desc,
  120. struct sk_buff *skb)
  121. {
  122. if (wl->ops->set_rx_csum)
  123. wl->ops->set_rx_csum(wl, desc, skb);
  124. }
  125. static inline u32
  126. wlcore_hw_ap_get_mimo_wide_rate_mask(struct wl1271 *wl,
  127. struct wl12xx_vif *wlvif)
  128. {
  129. if (wl->ops->ap_get_mimo_wide_rate_mask)
  130. return wl->ops->ap_get_mimo_wide_rate_mask(wl, wlvif);
  131. return 0;
  132. }
  133. static inline int
  134. wlcore_debugfs_init(struct wl1271 *wl, struct dentry *rootdir)
  135. {
  136. if (wl->ops->debugfs_init)
  137. return wl->ops->debugfs_init(wl, rootdir);
  138. return 0;
  139. }
  140. static inline int
  141. wlcore_handle_static_data(struct wl1271 *wl, void *static_data)
  142. {
  143. if (wl->ops->handle_static_data)
  144. return wl->ops->handle_static_data(wl, static_data);
  145. return 0;
  146. }
  147. static inline int
  148. wlcore_hw_get_spare_blocks(struct wl1271 *wl, bool is_gem)
  149. {
  150. if (!wl->ops->get_spare_blocks)
  151. BUG_ON(1);
  152. return wl->ops->get_spare_blocks(wl, is_gem);
  153. }
  154. static inline int
  155. wlcore_hw_set_key(struct wl1271 *wl, enum set_key_cmd cmd,
  156. struct ieee80211_vif *vif,
  157. struct ieee80211_sta *sta,
  158. struct ieee80211_key_conf *key_conf)
  159. {
  160. if (!wl->ops->set_key)
  161. BUG_ON(1);
  162. return wl->ops->set_key(wl, cmd, vif, sta, key_conf);
  163. }
  164. static inline u32
  165. wlcore_hw_pre_pkt_send(struct wl1271 *wl, u32 buf_offset, u32 last_len)
  166. {
  167. if (wl->ops->pre_pkt_send)
  168. return wl->ops->pre_pkt_send(wl, buf_offset, last_len);
  169. return buf_offset;
  170. }
  171. static inline void
  172. wlcore_hw_sta_rc_update(struct wl1271 *wl, struct wl12xx_vif *wlvif)
  173. {
  174. if (wl->ops->sta_rc_update)
  175. wl->ops->sta_rc_update(wl, wlvif);
  176. }
  177. static inline int
  178. wlcore_hw_interrupt_notify(struct wl1271 *wl, bool action)
  179. {
  180. if (wl->ops->interrupt_notify)
  181. return wl->ops->interrupt_notify(wl, action);
  182. return 0;
  183. }
  184. static inline int
  185. wlcore_hw_rx_ba_filter(struct wl1271 *wl, bool action)
  186. {
  187. if (wl->ops->rx_ba_filter)
  188. return wl->ops->rx_ba_filter(wl, action);
  189. return 0;
  190. }
  191. static inline int
  192. wlcore_hw_ap_sleep(struct wl1271 *wl)
  193. {
  194. if (wl->ops->ap_sleep)
  195. return wl->ops->ap_sleep(wl);
  196. return 0;
  197. }
  198. static inline int
  199. wlcore_hw_set_peer_cap(struct wl1271 *wl,
  200. struct ieee80211_sta_ht_cap *ht_cap,
  201. bool allow_ht_operation,
  202. u32 rate_set, u8 hlid)
  203. {
  204. if (wl->ops->set_peer_cap)
  205. return wl->ops->set_peer_cap(wl, ht_cap, allow_ht_operation,
  206. rate_set, hlid);
  207. return 0;
  208. }
  209. static inline u32
  210. wlcore_hw_convert_hwaddr(struct wl1271 *wl, u32 hwaddr)
  211. {
  212. if (!wl->ops->convert_hwaddr)
  213. BUG_ON(1);
  214. return wl->ops->convert_hwaddr(wl, hwaddr);
  215. }
  216. static inline bool
  217. wlcore_hw_lnk_high_prio(struct wl1271 *wl, u8 hlid,
  218. struct wl1271_link *lnk)
  219. {
  220. if (!wl->ops->lnk_high_prio)
  221. BUG_ON(1);
  222. return wl->ops->lnk_high_prio(wl, hlid, lnk);
  223. }
  224. static inline bool
  225. wlcore_hw_lnk_low_prio(struct wl1271 *wl, u8 hlid,
  226. struct wl1271_link *lnk)
  227. {
  228. if (!wl->ops->lnk_low_prio)
  229. BUG_ON(1);
  230. return wl->ops->lnk_low_prio(wl, hlid, lnk);
  231. }
  232. static inline int
  233. wlcore_smart_config_start(struct wl1271 *wl, u32 group_bitmap)
  234. {
  235. if (!wl->ops->smart_config_start)
  236. return -EINVAL;
  237. return wl->ops->smart_config_start(wl, group_bitmap);
  238. }
  239. static inline int
  240. wlcore_smart_config_stop(struct wl1271 *wl)
  241. {
  242. if (!wl->ops->smart_config_stop)
  243. return -EINVAL;
  244. return wl->ops->smart_config_stop(wl);
  245. }
  246. static inline int
  247. wlcore_smart_config_set_group_key(struct wl1271 *wl, u16 group_id,
  248. u8 key_len, u8 *key)
  249. {
  250. if (!wl->ops->smart_config_set_group_key)
  251. return -EINVAL;
  252. return wl->ops->smart_config_set_group_key(wl, group_id, key_len, key);
  253. }
  254. static inline int
  255. wlcore_hw_set_cac(struct wl1271 *wl, struct wl12xx_vif *wlvif, bool start)
  256. {
  257. if (!wl->ops->set_cac)
  258. return -EINVAL;
  259. return wl->ops->set_cac(wl, wlvif, start);
  260. }
  261. static inline int
  262. wlcore_hw_dfs_master_restart(struct wl1271 *wl, struct wl12xx_vif *wlvif)
  263. {
  264. if (!wl->ops->dfs_master_restart)
  265. return -EINVAL;
  266. return wl->ops->dfs_master_restart(wl, wlvif);
  267. }
  268. #endif