dp_htt.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. /*
  2. * Copyright (c) 2016-2020 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. #ifdef HTT_LOGGER
  27. #include "dp_htt_logger.h"
  28. #else
  29. struct htt_logger;
  30. static inline
  31. void htt_interface_logging_init(struct htt_logger **htt_logger_handle)
  32. {
  33. }
  34. static inline
  35. void htt_interface_logging_deinit(struct htt_logger *htt_logger_handle)
  36. {
  37. }
  38. static inline
  39. int htt_command_record(struct htt_logger *h, uint8_t msg_type,
  40. uint8_t *msg_data)
  41. {
  42. return 0;
  43. }
  44. static inline
  45. int htt_event_record(struct htt_logger *h, uint8_t msg_type,
  46. uint8_t *msg_data)
  47. {
  48. return 0;
  49. }
  50. static inline
  51. int htt_wbm_event_record(struct htt_logger *h, uint8_t tx_status,
  52. uint8_t *msg_data)
  53. {
  54. return 0;
  55. }
  56. #endif
  57. #define HTT_TX_MUTEX_TYPE qdf_spinlock_t
  58. #define HTT_TX_MUTEX_INIT(_mutex) \
  59. qdf_spinlock_create(_mutex)
  60. #define HTT_TX_MUTEX_ACQUIRE(_mutex) \
  61. qdf_spin_lock_bh(_mutex)
  62. #define HTT_TX_MUTEX_RELEASE(_mutex) \
  63. qdf_spin_unlock_bh(_mutex)
  64. #define HTT_TX_MUTEX_DESTROY(_mutex) \
  65. qdf_spinlock_destroy(_mutex)
  66. #define DP_HTT_MAX_SEND_QUEUE_DEPTH 64
  67. #ifndef HTT_MAC_ADDR_LEN
  68. #define HTT_MAC_ADDR_LEN 6
  69. #endif
  70. #define HTT_FRAMECTRL_TYPE_MASK 0x0C
  71. #define HTT_GET_FRAME_CTRL_TYPE(_val) \
  72. (((_val) & HTT_FRAMECTRL_TYPE_MASK) >> 2)
  73. #define FRAME_CTRL_TYPE_MGMT 0x0
  74. #define FRAME_CTRL_TYPE_CTRL 0x1
  75. #define FRAME_CTRL_TYPE_DATA 0x2
  76. #define FRAME_CTRL_TYPE_RESV 0x3
  77. #define HTT_FRAMECTRL_DATATYPE 0x08
  78. #define HTT_PPDU_DESC_MAX_DEPTH 16
  79. #define DP_SCAN_PEER_ID 0xFFFF
  80. #define DP_HTT_HTC_PKT_MISCLIST_SIZE 256
  81. #define HTT_T2H_MAX_MSG_SIZE 2048
  82. #define HTT_T2H_EXT_STATS_TLV_START_OFFSET 3
  83. /*
  84. * Below offset are based on htt_ppdu_stats_common_tlv
  85. * defined in htt_ppdu_stats.h
  86. */
  87. #define HTT_PPDU_STATS_COMMON_TLV_TLV_HDR_OFFSET 0
  88. #define HTT_PPDU_STATS_COMMON_TLV_PPDU_ID_OFFSET 1
  89. #define HTT_PPDU_STATS_COMMON_TLV_RING_ID_SCH_CMD_ID_OFFSET 2
  90. #define HTT_PPDU_STATS_COMMON_TLV_QTYPE_FRM_TYPE_OFFSET 3
  91. #define HTT_PPDU_STATS_COMMON_TLV_CHAIN_MASK_OFFSET 4
  92. #define HTT_PPDU_STATS_COMMON_TLV_FES_DUR_US_OFFSET 5
  93. #define HTT_PPDU_STATS_COMMON_TLV_SCH_EVAL_START_TSTMP_L32_US_OFFSET 6
  94. #define HTT_PPDU_STATS_COMMON_TLV_SCH_END_TSTMP_US_OFFSET 7
  95. #define HTT_PPDU_STATS_COMMON_TLV_START_TSTMP_L32_US_OFFSET 8
  96. #define HTT_PPDU_STATS_COMMON_TLV_CHAN_MHZ_PHY_MODE_OFFSET 9
  97. #define HTT_PPDU_STATS_COMMON_TLV_CCA_DELTA_TIME_US_OFFSET 10
  98. #define HTT_PPDU_STATS_COMMON_TLV_RXFRM_DELTA_TIME_US_OFFSET 11
  99. #define HTT_PPDU_STATS_COMMON_TLV_TXFRM_DELTA_TIME_US_OFFSET 12
  100. #define HTT_PPDU_STATS_COMMON_TLV_RESV_NUM_UL_BEAM_OFFSET 13
  101. #define HTT_PPDU_STATS_COMMON_TLV_START_TSTMP_U32_US_OFFSET 14
  102. /* get index for field in htt_ppdu_stats_common_tlv */
  103. #define HTT_GET_STATS_CMN_INDEX(index) \
  104. HTT_PPDU_STATS_COMMON_TLV_##index##_OFFSET
  105. struct dp_htt_htc_pkt {
  106. void *soc_ctxt;
  107. qdf_dma_addr_t nbuf_paddr;
  108. HTC_PACKET htc_pkt;
  109. };
  110. struct dp_htt_htc_pkt_union {
  111. union {
  112. struct dp_htt_htc_pkt pkt;
  113. struct dp_htt_htc_pkt_union *next;
  114. } u;
  115. };
  116. struct dp_htt_timestamp {
  117. long *umac_ttt;
  118. long *lmac_ttt;
  119. };
  120. struct htt_soc {
  121. struct cdp_ctrl_objmgr_psoc *ctrl_psoc;
  122. struct dp_soc *dp_soc;
  123. hal_soc_handle_t hal_soc;
  124. struct dp_htt_timestamp pdevid_tt[MAX_PDEV_CNT];
  125. /* htt_logger handle */
  126. struct htt_logger *htt_logger_handle;
  127. HTC_HANDLE htc_soc;
  128. qdf_device_t osdev;
  129. HTC_ENDPOINT_ID htc_endpoint;
  130. struct dp_htt_htc_pkt_union *htt_htc_pkt_freelist;
  131. struct dp_htt_htc_pkt_union *htt_htc_pkt_misclist;
  132. struct {
  133. u_int8_t major;
  134. u_int8_t minor;
  135. } tgt_ver;
  136. struct {
  137. u_int8_t major;
  138. u_int8_t minor;
  139. } wifi_ip_ver;
  140. struct {
  141. int htc_err_cnt;
  142. int htc_pkt_free;
  143. } stats;
  144. HTT_TX_MUTEX_TYPE htt_tx_mutex;
  145. };
  146. /**
  147. * struct htt_rx_ring_tlv_filter - Rx ring TLV filter
  148. * enable/disable.
  149. * @mpdu_start: enable/disable MPDU start TLV
  150. * @msdu_start: enable/disable MSDU start TLV
  151. * @packet: enable/disable PACKET TLV
  152. * @msdu_end: enable/disable MSDU end TLV
  153. * @mpdu_end: enable/disable MPDU end TLV
  154. * @packet_header: enable/disable PACKET header TLV
  155. * @attention: enable/disable ATTENTION TLV
  156. * @ppdu_start: enable/disable PPDU start TLV
  157. * @ppdu_end: enable/disable PPDU end TLV
  158. * @ppdu_end_user_stats: enable/disable PPDU user stats TLV
  159. * @ppdu_end_user_stats_ext: enable/disable PPDU user stats ext TLV
  160. * @ppdu_end_status_done: enable/disable PPDU end status done TLV
  161. * @enable_fp: enable/disable FP packet
  162. * @enable_md: enable/disable MD packet
  163. * @enable_mo: enable/disable MO packet
  164. * @enable_mgmt: enable/disable MGMT packet
  165. * @enable_ctrl: enable/disable CTRL packet
  166. * @enable_data: enable/disable DATA packet
  167. * @offset_valid: Flag to indicate if below offsets are valid
  168. * @rx_packet_offset: Offset of packet payload
  169. * @rx_header_offset: Offset of rx_header tlv
  170. * @rx_mpdu_end_offset: Offset of rx_mpdu_end tlv
  171. * @rx_mpdu_start_offset: Offset of rx_mpdu_start tlv
  172. * @rx_msdu_end_offset: Offset of rx_msdu_end tlv
  173. * @rx_msdu_start_offset: Offset of rx_msdu_start tlv
  174. * @rx_attn_offset: Offset of rx_attention tlv
  175. *
  176. * NOTE: Do not change the layout of this structure
  177. */
  178. struct htt_rx_ring_tlv_filter {
  179. u_int32_t mpdu_start:1,
  180. msdu_start:1,
  181. packet:1,
  182. msdu_end:1,
  183. mpdu_end:1,
  184. packet_header:1,
  185. attention:1,
  186. ppdu_start:1,
  187. ppdu_end:1,
  188. ppdu_end_user_stats:1,
  189. ppdu_end_user_stats_ext:1,
  190. ppdu_end_status_done:1,
  191. header_per_msdu:1,
  192. enable_fp:1,
  193. enable_md:1,
  194. enable_mo:1;
  195. u_int32_t fp_mgmt_filter:16,
  196. mo_mgmt_filter:16;
  197. u_int32_t fp_ctrl_filter:16,
  198. mo_ctrl_filter:16;
  199. u_int32_t fp_data_filter:16,
  200. mo_data_filter:16;
  201. u_int16_t md_data_filter;
  202. u_int16_t md_mgmt_filter;
  203. u_int16_t md_ctrl_filter;
  204. bool offset_valid;
  205. uint16_t rx_packet_offset;
  206. uint16_t rx_header_offset;
  207. uint16_t rx_mpdu_end_offset;
  208. uint16_t rx_mpdu_start_offset;
  209. uint16_t rx_msdu_end_offset;
  210. uint16_t rx_msdu_start_offset;
  211. uint16_t rx_attn_offset;
  212. };
  213. /**
  214. * struct dp_htt_rx_flow_fst_setup - Rx FST setup message
  215. * @pdev_id: DP Pdev identifier
  216. * @max_entries: Size of Rx FST in number of entries
  217. * @max_search: Number of collisions allowed
  218. * @base_addr_lo: lower 32-bit physical address
  219. * @base_addr_hi: upper 32-bit physical address
  220. * @ip_da_sa_prefix: IPv4 prefix to map to IPv6 address scheme
  221. * @hash_key_len: Rx FST hash key size
  222. * @hash_key: Rx FST Toeplitz hash key
  223. */
  224. struct dp_htt_rx_flow_fst_setup {
  225. uint8_t pdev_id;
  226. uint32_t max_entries;
  227. uint32_t max_search;
  228. uint32_t base_addr_lo;
  229. uint32_t base_addr_hi;
  230. uint32_t ip_da_sa_prefix;
  231. uint32_t hash_key_len;
  232. uint8_t *hash_key;
  233. };
  234. /**
  235. * enum dp_htt_flow_fst_operation - FST related operations allowed
  236. * @DP_HTT_FST_CACHE_OP_NONE: Cache no-op
  237. * @DP_HTT_FST_CACHE_INVALIDATE_ENTRY: Invalidate single cache entry
  238. * @DP_HTT_FST_CACHE_INVALIDATE_FULL: Invalidate entire cache
  239. * @DP_HTT_FST_ENABLE: Bypass FST is enabled
  240. * @DP_HTT_FST_DISABLE: Disable bypass FST
  241. */
  242. enum dp_htt_flow_fst_operation {
  243. DP_HTT_FST_CACHE_OP_NONE,
  244. DP_HTT_FST_CACHE_INVALIDATE_ENTRY,
  245. DP_HTT_FST_CACHE_INVALIDATE_FULL,
  246. DP_HTT_FST_ENABLE,
  247. DP_HTT_FST_DISABLE
  248. };
  249. /**
  250. * struct dp_htt_rx_flow_fst_setup - Rx FST setup message
  251. * @pdev_id: DP Pdev identifier
  252. * @op_code: FST operation to be performed by FW/HW
  253. * @rx_flow: Rx Flow information on which operation is to be performed
  254. */
  255. struct dp_htt_rx_flow_fst_operation {
  256. uint8_t pdev_id;
  257. enum dp_htt_flow_fst_operation op_code;
  258. struct cdp_rx_flow_info *rx_flow;
  259. };
  260. /**
  261. * struct dp_htt_rx_fisa_config - Rx fisa config
  262. * @pdev_id: DP Pdev identifier
  263. * @fisa_timeout: fisa aggregation timeout
  264. */
  265. struct dp_htt_rx_fisa_cfg {
  266. uint8_t pdev_id;
  267. uint32_t fisa_timeout;
  268. };
  269. QDF_STATUS dp_htt_rx_fisa_config(struct dp_pdev *pdev,
  270. struct dp_htt_rx_fisa_cfg *fisa_config);
  271. /*
  272. * htt_soc_initialize() - SOC level HTT initialization
  273. * @htt_soc: Opaque htt SOC handle
  274. * @ctrl_psoc: Opaque ctrl SOC handle
  275. * @htc_soc: SOC level HTC handle
  276. * @hal_soc: Opaque HAL SOC handle
  277. * @osdev: QDF device
  278. *
  279. * Return: HTT handle on success; NULL on failure
  280. */
  281. void *
  282. htt_soc_initialize(struct htt_soc *htt_soc,
  283. struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
  284. HTC_HANDLE htc_soc,
  285. hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev);
  286. /*
  287. * htt_soc_attach() - attach DP and HTT SOC
  288. * @soc: DP SOC handle
  289. * @htc_hdl: HTC handle
  290. *
  291. * Return: htt_soc handle on Success, NULL on Failure
  292. */
  293. struct htt_soc *htt_soc_attach(struct dp_soc *soc, HTC_HANDLE htc_hdl);
  294. /*
  295. * htt_set_htc_handle_() - set HTC handle
  296. * @htt_hdl: HTT handle/SOC
  297. * @htc_soc: HTC handle
  298. *
  299. * Return: None
  300. */
  301. void htt_set_htc_handle(struct htt_soc *htt_hdl, HTC_HANDLE htc_soc);
  302. /*
  303. * htt_get_htc_handle_() - set HTC handle
  304. * @htt_hdl: HTT handle/SOC
  305. *
  306. * Return: HTC_HANDLE
  307. */
  308. HTC_HANDLE htt_get_htc_handle(struct htt_soc *htt_hdl);
  309. /*
  310. * htt_soc_htc_dealloc() - HTC memory de-alloc
  311. * @htt_soc: SOC level HTT handle
  312. *
  313. * Return: None
  314. */
  315. void htt_soc_htc_dealloc(struct htt_soc *htt_handle);
  316. /*
  317. * htt_soc_htc_prealloc() - HTC memory prealloc
  318. * @htt_soc: SOC level HTT handle
  319. *
  320. * Return: QDF_STATUS_SUCCESS on success or
  321. * QDF_STATUS_E_NO_MEM on allocation failure
  322. */
  323. QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *htt_soc);
  324. void htt_soc_detach(struct htt_soc *soc);
  325. int htt_srng_setup(struct htt_soc *htt_soc, int pdev_id,
  326. hal_ring_handle_t hal_ring_hdl,
  327. int hal_ring_type);
  328. int htt_soc_attach_target(struct htt_soc *htt_soc);
  329. /*
  330. * htt_h2t_rx_ring_cfg() - Send SRNG packet and TLV filter
  331. * config message to target
  332. * @htt_soc: HTT SOC handle
  333. * @pdev_id: PDEV Id
  334. * @hal_srng: Opaque HAL SRNG pointer
  335. * @hal_ring_type: SRNG ring type
  336. * @ring_buf_size: SRNG buffer size
  337. * @htt_tlv_filter: Rx SRNG TLV and filter setting
  338. *
  339. * Return: 0 on success; error code on failure
  340. */
  341. int htt_h2t_rx_ring_cfg(struct htt_soc *htt_soc, int pdev_id,
  342. hal_ring_handle_t hal_ring_hdl,
  343. int hal_ring_type, int ring_buf_size,
  344. struct htt_rx_ring_tlv_filter *htt_tlv_filter);
  345. /*
  346. * htt_t2h_stats_handler() - target to host stats work handler
  347. * @context: context (dp soc context)
  348. *
  349. * Return: void
  350. */
  351. void htt_t2h_stats_handler(void *context);
  352. /**
  353. * struct htt_stats_context - htt stats information
  354. * @soc: Size of each descriptor in the pool
  355. * @msg: T2H Ext stats message queue
  356. * @msg_len: T2H Ext stats message length
  357. */
  358. struct htt_stats_context {
  359. struct dp_soc *soc;
  360. qdf_nbuf_queue_t msg;
  361. uint32_t msg_len;
  362. };
  363. int
  364. dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(uint32_t bitmap);
  365. /**
  366. * dp_ppdu_desc_user_stats_update(): Function to update TX user stats
  367. * @pdev: DP pdev handle
  368. * @ppdu_info: per PPDU TLV descriptor
  369. *
  370. * return: void
  371. */
  372. void
  373. dp_ppdu_desc_user_stats_update(struct dp_pdev *pdev,
  374. struct ppdu_info *ppdu_info);
  375. /**
  376. * dp_htt_rx_flow_fst_setup(): Send HTT Rx FST setup message to FW
  377. * @pdev: DP pdev handle
  378. * @fse_setup_info: FST setup parameters
  379. *
  380. * Return: Success when HTT message is sent, error on failure
  381. */
  382. QDF_STATUS
  383. dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev,
  384. struct dp_htt_rx_flow_fst_setup *setup_info);
  385. /**
  386. * dp_htt_rx_flow_fse_operation(): Send HTT Flow Search Entry msg to
  387. * add/del a flow in HW
  388. * @pdev: DP pdev handle
  389. * @fse_op_info: Flow entry parameters
  390. *
  391. * Return: Success when HTT message is sent, error on failure
  392. */
  393. QDF_STATUS
  394. dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev,
  395. struct dp_htt_rx_flow_fst_operation *op_info);
  396. #endif /* _DP_HTT_H_ */