dp_htt.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. #ifndef HTT_MAC_ADDR_LEN
  35. #define HTT_MAC_ADDR_LEN 6
  36. #endif
  37. #define DP_HTT_HTC_PKT_MISCLIST_SIZE 256
  38. #define HTT_T2H_EXT_STATS_TLV_START_OFFSET 3
  39. struct dp_htt_htc_pkt {
  40. void *soc_ctxt;
  41. qdf_dma_addr_t nbuf_paddr;
  42. HTC_PACKET htc_pkt;
  43. };
  44. struct dp_htt_htc_pkt_union {
  45. union {
  46. struct dp_htt_htc_pkt pkt;
  47. struct dp_htt_htc_pkt_union *next;
  48. } u;
  49. };
  50. struct htt_soc {
  51. void *ctrl_psoc;
  52. void *dp_soc;
  53. void *hal_soc;
  54. HTC_HANDLE htc_soc;
  55. qdf_device_t osdev;
  56. HTC_ENDPOINT_ID htc_endpoint;
  57. struct dp_htt_htc_pkt_union *htt_htc_pkt_freelist;
  58. struct dp_htt_htc_pkt_union *htt_htc_pkt_misclist;
  59. struct {
  60. u_int8_t major;
  61. u_int8_t minor;
  62. } tgt_ver;
  63. struct {
  64. u_int8_t major;
  65. u_int8_t minor;
  66. } wifi_ip_ver;
  67. struct {
  68. int htc_err_cnt;
  69. int htc_pkt_free;
  70. } stats;
  71. HTT_TX_MUTEX_TYPE htt_tx_mutex;
  72. };
  73. /**
  74. * struct htt_rx_ring_tlv_filter - Rx ring TLV filter
  75. * enable/disable.
  76. * @mpdu_start: enable/disable MPDU start TLV
  77. * @msdu_start: enable/disable MSDU start TLV
  78. * @packet: enable/disable PACKET TLV
  79. * @msdu_end: enable/disable MSDU end TLV
  80. * @mpdu_end: enable/disable MPDU end TLV
  81. * @packet_header: enable/disable PACKET header TLV
  82. * @attention: enable/disable ATTENTION TLV
  83. * @ppdu_start: enable/disable PPDU start TLV
  84. * @ppdu_end: enable/disable PPDU end TLV
  85. * @ppdu_end_user_stats: enable/disable PPDU user stats TLV
  86. * @ppdu_end_user_stats_ext: enable/disable PPDU user stats ext TLV
  87. * @ppdu_end_status_done: enable/disable PPDU end status done TLV
  88. * @enable_fp: enable/disable FP packet
  89. * @enable_md: enable/disable MD packet
  90. * @enable_mo: enable/disable MO packet
  91. * @enable_mgmt: enable/disable MGMT packet
  92. * @enable_ctrl: enable/disable CTRL packet
  93. * @enable_data: enable/disable DATA packet
  94. * @offset_valid: Flag to indicate if below offsets are valid
  95. * @rx_packet_offset: Offset of packet payload
  96. * @rx_header_offset: Offset of rx_header tlv
  97. * @rx_mpdu_end_offset: Offset of rx_mpdu_end tlv
  98. * @rx_mpdu_start_offset: Offset of rx_mpdu_start tlv
  99. * @rx_msdu_end_offset: Offset of rx_msdu_end tlv
  100. * @rx_msdu_start_offset: Offset of rx_msdu_start tlv
  101. * @rx_attn_offset: Offset of rx_attention tlv
  102. */
  103. struct htt_rx_ring_tlv_filter {
  104. u_int32_t mpdu_start:1,
  105. msdu_start:1,
  106. packet:1,
  107. msdu_end:1,
  108. mpdu_end:1,
  109. packet_header:1,
  110. attention:1,
  111. ppdu_start:1,
  112. ppdu_end:1,
  113. ppdu_end_user_stats:1,
  114. ppdu_end_user_stats_ext:1,
  115. ppdu_end_status_done:1,
  116. header_per_msdu:1,
  117. enable_fp:1,
  118. enable_md:1,
  119. enable_mo:1;
  120. u_int32_t fp_mgmt_filter:16,
  121. mo_mgmt_filter:16;
  122. u_int32_t fp_ctrl_filter:16,
  123. mo_ctrl_filter:16;
  124. u_int32_t fp_data_filter:16,
  125. mo_data_filter:16;
  126. u_int16_t md_data_filter;
  127. u_int16_t md_mgmt_filter;
  128. u_int16_t md_ctrl_filter;
  129. bool offset_valid;
  130. uint16_t rx_packet_offset;
  131. uint16_t rx_header_offset;
  132. uint16_t rx_mpdu_end_offset;
  133. uint16_t rx_mpdu_start_offset;
  134. uint16_t rx_msdu_end_offset;
  135. uint16_t rx_msdu_start_offset;
  136. uint16_t rx_attn_offset;
  137. };
  138. /*
  139. * htt_soc_initialize() - SOC level HTT initialization
  140. * @htt_soc: Opaque htt SOC handle
  141. * @ctrl_psoc: Opaque ctrl SOC handle
  142. * @htc_soc: SOC level HTC handle
  143. * @hal_soc: Opaque HAL SOC handle
  144. * @osdev: QDF device
  145. *
  146. * Return: HTT handle on success; NULL on failure
  147. */
  148. void *
  149. htt_soc_initialize(void *htt_soc, void *ctrl_psoc, HTC_HANDLE htc_soc,
  150. void *hal_soc, qdf_device_t osdev);
  151. /*
  152. * htt_soc_htc_dealloc() - HTC memory de-alloc
  153. * @htt_soc: SOC level HTT handle
  154. *
  155. * Return: None
  156. */
  157. void htt_soc_htc_dealloc(struct htt_soc *htt_handle);
  158. /*
  159. * htt_soc_htc_prealloc() - HTC memory prealloc
  160. * @htt_soc: SOC level HTT handle
  161. *
  162. * Return: QDF_STATUS_SUCCESS on success or
  163. * QDF_STATUS_E_NO_MEM on allocation failure
  164. */
  165. QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *htt_soc);
  166. void htt_soc_detach(void *soc);
  167. int htt_srng_setup(void *htt_soc, int pdev_id, void *hal_srng,
  168. int hal_ring_type);
  169. int htt_soc_attach_target(void *htt_soc);
  170. /*
  171. * htt_h2t_rx_ring_cfg() - Send SRNG packet and TLV filter
  172. * config message to target
  173. * @htt_soc: HTT SOC handle
  174. * @pdev_id: PDEV Id
  175. * @hal_srng: Opaque HAL SRNG pointer
  176. * @hal_ring_type: SRNG ring type
  177. * @ring_buf_size: SRNG buffer size
  178. * @htt_tlv_filter: Rx SRNG TLV and filter setting
  179. *
  180. * Return: 0 on success; error code on failure
  181. */
  182. int htt_h2t_rx_ring_cfg(void *htt_soc, int pdev_id, void *hal_srng,
  183. int hal_ring_type, int ring_buf_size,
  184. struct htt_rx_ring_tlv_filter *htt_tlv_filter);
  185. /*
  186. * htt_t2h_stats_handler() - target to host stats work handler
  187. * @context: context (dp soc context)
  188. *
  189. * Return: void
  190. */
  191. void htt_t2h_stats_handler(void *context);
  192. /**
  193. * struct htt_stats_context - htt stats information
  194. * @soc: Size of each descriptor in the pool
  195. * @msg: T2H Ext stats message queue
  196. * @msg_len: T2H Ext stats message length
  197. */
  198. struct htt_stats_context {
  199. struct dp_soc *soc;
  200. qdf_nbuf_queue_t msg;
  201. uint32_t msg_len;
  202. };
  203. #endif /* _DP_HTT_H_ */