dp_htt.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef _DP_HTT_H_
  19. #define _DP_HTT_H_
  20. #include <qdf_types.h>
  21. #include <qdf_lock.h>
  22. #include <qdf_nbuf.h>
  23. #include <htc_api.h>
  24. #define HTT_TX_MUTEX_TYPE qdf_spinlock_t
  25. #define HTT_TX_MUTEX_INIT(_mutex) \
  26. qdf_spinlock_create(_mutex)
  27. #define HTT_TX_MUTEX_ACQUIRE(_mutex) \
  28. qdf_spin_lock_bh(_mutex)
  29. #define HTT_TX_MUTEX_RELEASE(_mutex) \
  30. qdf_spin_unlock_bh(_mutex)
  31. #define HTT_TX_MUTEX_DESTROY(_mutex) \
  32. qdf_spinlock_destroy(_mutex)
  33. #define DP_HTT_MAX_SEND_QUEUE_DEPTH 64
  34. #define DP_HTT_HTC_PKT_MISCLIST_SIZE 256
  35. #define HTT_T2H_EXT_STATS_TLV_START_OFFSET 3
  36. struct dp_htt_htc_pkt {
  37. void *soc_ctxt;
  38. qdf_dma_addr_t nbuf_paddr;
  39. HTC_PACKET htc_pkt;
  40. };
  41. struct dp_htt_htc_pkt_union {
  42. union {
  43. struct dp_htt_htc_pkt pkt;
  44. struct dp_htt_htc_pkt_union *next;
  45. } u;
  46. };
  47. struct htt_soc {
  48. void *ctrl_psoc;
  49. void *dp_soc;
  50. void *hal_soc;
  51. HTC_HANDLE htc_soc;
  52. qdf_device_t osdev;
  53. HTC_ENDPOINT_ID htc_endpoint;
  54. struct dp_htt_htc_pkt_union *htt_htc_pkt_freelist;
  55. struct dp_htt_htc_pkt_union *htt_htc_pkt_misclist;
  56. struct {
  57. u_int8_t major;
  58. u_int8_t minor;
  59. } tgt_ver;
  60. struct {
  61. u_int8_t major;
  62. u_int8_t minor;
  63. } wifi_ip_ver;
  64. struct {
  65. int htc_err_cnt;
  66. int htc_pkt_free;
  67. } stats;
  68. HTT_TX_MUTEX_TYPE htt_tx_mutex;
  69. };
  70. /**
  71. * struct htt_rx_ring_tlv_filter - Rx ring TLV filter
  72. * enable/disable.
  73. * @mpdu_start: enable/disable MPDU start TLV
  74. * @msdu_start: enable/disable MSDU start TLV
  75. * @packet: enable/disable PACKET TLV
  76. * @msdu_end: enable/disable MSDU end TLV
  77. * @mpdu_end: enable/disable MPDU end TLV
  78. * @packet_header: enable/disable PACKET header TLV
  79. * @attention: enable/disable ATTENTION TLV
  80. * @ppdu_start: enable/disable PPDU start TLV
  81. * @ppdu_end: enable/disable PPDU end TLV
  82. * @ppdu_end_user_stats: enable/disable PPDU user stats TLV
  83. * @ppdu_end_user_stats_ext: enable/disable PPDU user stats ext TLV
  84. * @ppdu_end_status_done: enable/disable PPDU end status done TLV
  85. * @enable_fp: enable/disable FP packet
  86. * @enable_md: enable/disable MD packet
  87. * @enable_mo: enable/disable MO packet
  88. * @enable_mgmt: enable/disable MGMT packet
  89. * @enable_ctrl: enable/disable CTRL packet
  90. * @enable_data: enable/disable DATA packet
  91. * @offset_valid: Flag to indicate if below offsets are valid
  92. * @rx_packet_offset: Offset of packet payload
  93. * @rx_header_offset: Offset of rx_header tlv
  94. * @rx_mpdu_end_offset: Offset of rx_mpdu_end tlv
  95. * @rx_mpdu_start_offset: Offset of rx_mpdu_start tlv
  96. * @rx_msdu_end_offset: Offset of rx_msdu_end tlv
  97. * @rx_msdu_start_offset: Offset of rx_msdu_start tlv
  98. * @rx_attn_offset: Offset of rx_attention tlv
  99. */
  100. struct htt_rx_ring_tlv_filter {
  101. u_int32_t mpdu_start:1,
  102. msdu_start:1,
  103. packet:1,
  104. msdu_end:1,
  105. mpdu_end:1,
  106. packet_header:1,
  107. attention:1,
  108. ppdu_start:1,
  109. ppdu_end:1,
  110. ppdu_end_user_stats:1,
  111. ppdu_end_user_stats_ext:1,
  112. ppdu_end_status_done:1,
  113. header_per_msdu:1,
  114. enable_fp:1,
  115. enable_md:1,
  116. enable_mo:1;
  117. u_int32_t fp_mgmt_filter:16,
  118. mo_mgmt_filter:16;
  119. u_int32_t fp_ctrl_filter:16,
  120. mo_ctrl_filter:16;
  121. u_int32_t fp_data_filter:16,
  122. mo_data_filter:16;
  123. u_int16_t md_data_filter;
  124. u_int16_t md_mgmt_filter;
  125. u_int16_t md_ctrl_filter;
  126. bool offset_valid;
  127. uint16_t rx_packet_offset;
  128. uint16_t rx_header_offset;
  129. uint16_t rx_mpdu_end_offset;
  130. uint16_t rx_mpdu_start_offset;
  131. uint16_t rx_msdu_end_offset;
  132. uint16_t rx_msdu_start_offset;
  133. uint16_t rx_attn_offset;
  134. };
  135. /*
  136. * htt_soc_initialize() - SOC level HTT initialization
  137. * @htt_soc: Opaque htt SOC handle
  138. * @ctrl_psoc: Opaque ctrl SOC handle
  139. * @htc_soc: SOC level HTC handle
  140. * @hal_soc: Opaque HAL SOC handle
  141. * @osdev: QDF device
  142. *
  143. * Return: HTT handle on success; NULL on failure
  144. */
  145. void *
  146. htt_soc_initialize(void *htt_soc, void *ctrl_psoc, HTC_HANDLE htc_soc,
  147. void *hal_soc, qdf_device_t osdev);
  148. /*
  149. * htt_soc_htc_dealloc() - HTC memory de-alloc
  150. * @htt_soc: SOC level HTT handle
  151. *
  152. * Return: None
  153. */
  154. void htt_soc_htc_dealloc(struct htt_soc *htt_handle);
  155. /*
  156. * htt_soc_htc_prealloc() - HTC memory prealloc
  157. * @htt_soc: SOC level HTT handle
  158. *
  159. * Return: QDF_STATUS_SUCCESS on success or
  160. * QDF_STATUS_E_NO_MEM on allocation failure
  161. */
  162. QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *htt_soc);
  163. void htt_soc_detach(void *soc);
  164. int htt_srng_setup(void *htt_soc, int pdev_id, void *hal_srng,
  165. int hal_ring_type);
  166. int htt_soc_attach_target(void *htt_soc);
  167. /*
  168. * htt_h2t_rx_ring_cfg() - Send SRNG packet and TLV filter
  169. * config message to target
  170. * @htt_soc: HTT SOC handle
  171. * @pdev_id: PDEV Id
  172. * @hal_srng: Opaque HAL SRNG pointer
  173. * @hal_ring_type: SRNG ring type
  174. * @ring_buf_size: SRNG buffer size
  175. * @htt_tlv_filter: Rx SRNG TLV and filter setting
  176. *
  177. * Return: 0 on success; error code on failure
  178. */
  179. int htt_h2t_rx_ring_cfg(void *htt_soc, int pdev_id, void *hal_srng,
  180. int hal_ring_type, int ring_buf_size,
  181. struct htt_rx_ring_tlv_filter *htt_tlv_filter);
  182. /*
  183. * htt_t2h_stats_handler() - target to host stats work handler
  184. * @context: context (dp soc context)
  185. *
  186. * Return: void
  187. */
  188. void htt_t2h_stats_handler(void *context);
  189. /**
  190. * struct htt_stats_context - htt stats information
  191. * @soc: Size of each descriptor in the pool
  192. * @msg: T2H Ext stats message queue
  193. * @msg_len: T2H Ext stats message length
  194. */
  195. struct htt_stats_context {
  196. struct dp_soc *soc;
  197. qdf_nbuf_queue_t msg;
  198. uint32_t msg_len;
  199. };
  200. #endif /* _DP_HTT_H_ */