cdp_txrx_ipa.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. /*
  2. * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. /**
  27. * @file cdp_txrx_ipa.h
  28. * @brief Define the host data path IP Acceleraor API functions
  29. */
  30. #ifndef _CDP_TXRX_IPA_H_
  31. #define _CDP_TXRX_IPA_H_
  32. #include <cdp_txrx_mob_def.h>
  33. #include "cdp_txrx_handle.h"
  34. /**
  35. * cdp_ipa_get_resource() - Get allocated wlan resources for ipa data path
  36. * @soc - data path soc handle
  37. * @pdev - device instance pointer
  38. * @ipa_res - ipa resources pointer
  39. *
  40. * Get allocated wlan resources for ipa data path
  41. *
  42. * return none
  43. */
  44. static inline void
  45. cdp_ipa_get_resource(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  46. struct ol_txrx_ipa_resources *ipa_res)
  47. {
  48. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  49. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  50. "%s invalid instance", __func__);
  51. return;
  52. }
  53. if (soc->ops->ipa_ops->ipa_get_resource)
  54. return soc->ops->ipa_ops->ipa_get_resource(pdev, ipa_res);
  55. return;
  56. }
  57. /**
  58. * cdp_ipa_set_doorbell_paddr() - give IPA db paddr to fw
  59. * @soc - data path soc handle
  60. * @pdev - device instance pointer
  61. * @ipa_tx_uc_doorbell_paddr - tx db paddr
  62. * @ipa_rx_uc_doorbell_paddr - rx db paddr
  63. *
  64. * give IPA db paddr to fw
  65. *
  66. * return none
  67. */
  68. static inline void
  69. cdp_ipa_set_doorbell_paddr(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  70. qdf_dma_addr_t ipa_tx_uc_doorbell_paddr,
  71. qdf_dma_addr_t ipa_rx_uc_doorbell_paddr)
  72. {
  73. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  74. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  75. "%s invalid instance", __func__);
  76. return;
  77. }
  78. if (soc->ops->ipa_ops->ipa_set_doorbell_paddr)
  79. return soc->ops->ipa_ops->ipa_set_doorbell_paddr(pdev,
  80. ipa_tx_uc_doorbell_paddr, ipa_rx_uc_doorbell_paddr);
  81. return;
  82. }
  83. /**
  84. * cdp_ipa_set_active() - activate/de-ctivate wlan fw ipa data path
  85. * @soc - data path soc handle
  86. * @pdev - device instance pointer
  87. * @uc_active - activate or de-activate
  88. * @is_tx - toggle tx or rx data path
  89. *
  90. * activate/de-ctivate wlan fw ipa data path
  91. *
  92. * return none
  93. */
  94. static inline void
  95. cdp_ipa_set_active(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  96. bool uc_active, bool is_tx)
  97. {
  98. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  99. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  100. "%s invalid instance", __func__);
  101. return;
  102. }
  103. if (soc->ops->ipa_ops->ipa_set_active)
  104. return soc->ops->ipa_ops->ipa_set_active(pdev, uc_active,
  105. is_tx);
  106. return;
  107. }
  108. /**
  109. * cdp_ipa_op_response() - event handler from fw
  110. * @soc - data path soc handle
  111. * @pdev - device instance pointer
  112. * @op_msg - event contents from firmware
  113. *
  114. * event handler from fw
  115. *
  116. * return none
  117. */
  118. static inline void
  119. cdp_ipa_op_response(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  120. uint8_t *op_msg)
  121. {
  122. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  123. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  124. "%s invalid instance", __func__);
  125. return;
  126. }
  127. if (soc->ops->ipa_ops->ipa_op_response)
  128. return soc->ops->ipa_ops->ipa_op_response(pdev, op_msg);
  129. return;
  130. }
  131. /**
  132. * cdp_ipa_register_op_cb() - register event handler function pointer
  133. * @soc - data path soc handle
  134. * @pdev - device instance pointer
  135. * @op_cb - event handler callback function pointer
  136. * @osif_dev - osif instance pointer
  137. *
  138. * register event handler function pointer
  139. *
  140. * return none
  141. */
  142. static inline void
  143. cdp_ipa_register_op_cb(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  144. ipa_op_cb_type op_cb, void *osif_dev)
  145. {
  146. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  147. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  148. "%s invalid instance", __func__);
  149. return;
  150. }
  151. if (soc->ops->ipa_ops->ipa_register_op_cb)
  152. return soc->ops->ipa_ops->ipa_register_op_cb(pdev, op_cb,
  153. osif_dev);
  154. return;
  155. }
  156. /**
  157. * cdp_ipa_get_stat() - get ipa data path stats from fw
  158. * @soc - data path soc handle
  159. * @pdev - device instance pointer
  160. *
  161. * get ipa data path stats from fw async
  162. *
  163. * return none
  164. */
  165. static inline void
  166. cdp_ipa_get_stat(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
  167. {
  168. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  169. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  170. "%s invalid instance", __func__);
  171. return;
  172. }
  173. if (soc->ops->ipa_ops->ipa_get_stat)
  174. return soc->ops->ipa_ops->ipa_get_stat(pdev);
  175. return;
  176. }
  177. /**
  178. * cdp_tx_send_ipa_data_frame() - send IPA data frame
  179. * @vdev: vdev
  180. * @skb: skb
  181. *
  182. * Return: skb/ NULL is for success
  183. */
  184. static inline qdf_nbuf_t cdp_ipa_tx_send_data_frame(ol_txrx_soc_handle soc,
  185. struct cdp_vdev *vdev, qdf_nbuf_t skb)
  186. {
  187. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  188. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  189. "%s invalid instance", __func__);
  190. return skb;
  191. }
  192. if (soc->ops->ipa_ops->ipa_tx_data_frame)
  193. return soc->ops->ipa_ops->ipa_tx_data_frame(vdev, skb);
  194. return skb;
  195. }
  196. /**
  197. * cdp_ipa_set_uc_tx_partition_base() - set tx packet partition base
  198. * @pdev: physical device instance
  199. * @value: partition base value
  200. *
  201. * Return: none
  202. */
  203. static inline void cdp_ipa_set_uc_tx_partition_base(ol_txrx_soc_handle soc,
  204. struct cdp_cfg *cfg_pdev, uint32_t value)
  205. {
  206. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  207. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  208. "%s invalid instance", __func__);
  209. return;
  210. }
  211. if (soc->ops->ipa_ops->ipa_set_uc_tx_partition_base)
  212. return soc->ops->ipa_ops->ipa_set_uc_tx_partition_base(cfg_pdev,
  213. value);
  214. return;
  215. }
  216. /**
  217. * cdp_ipa_uc_get_share_stats() - get Tx/Rx byte stats from FW
  218. * @pdev: physical device instance
  219. * @value: reset stats
  220. *
  221. * Return: none
  222. */
  223. static inline void cdp_ipa_uc_get_share_stats(ol_txrx_soc_handle soc,
  224. struct cdp_pdev *pdev, uint8_t value)
  225. {
  226. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  227. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  228. "%s invalid instance", __func__);
  229. return;
  230. }
  231. if (soc->ops->ipa_ops->ipa_uc_get_share_stats)
  232. return soc->ops->ipa_ops->ipa_uc_get_share_stats(pdev,
  233. value);
  234. return;
  235. }
  236. /**
  237. * cdp_ipa_uc_set_quota() - set quota limit to FW
  238. * @pdev: physical device instance
  239. * @value: quota limit bytes
  240. *
  241. * Return: none
  242. */
  243. static inline void cdp_ipa_uc_set_quota(ol_txrx_soc_handle soc,
  244. struct cdp_pdev *pdev, uint64_t value)
  245. {
  246. if (!soc || !soc->ops || !soc->ops->ipa_ops) {
  247. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  248. "%s invalid instance", __func__);
  249. return;
  250. }
  251. if (soc->ops->ipa_ops->ipa_uc_get_share_stats)
  252. return soc->ops->ipa_ops->ipa_uc_set_quota(pdev,
  253. value);
  254. return;
  255. }
  256. #endif /* _CDP_TXRX_IPA_H_ */