dp_htt.h 14 KB

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