dp_htt.h 6.8 KB

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