hal_api_mon.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. /*
  2. * Copyright (c) 2017-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 _HAL_API_MON_H_
  19. #define _HAL_API_MON_H_
  20. #include "qdf_types.h"
  21. #include "hal_internal.h"
  22. #include <target_type.h>
  23. #define HAL_RX_PHY_DATA_RADAR 0x01
  24. #define HAL_SU_MU_CODING_LDPC 0x01
  25. #define HAL_RX_FCS_LEN (4)
  26. #define KEY_EXTIV 0x20
  27. #define HAL_RX_USER_TLV32_TYPE_OFFSET 0x00000000
  28. #define HAL_RX_USER_TLV32_TYPE_LSB 1
  29. #define HAL_RX_USER_TLV32_TYPE_MASK 0x000003FE
  30. #define HAL_RX_USER_TLV32_LEN_OFFSET 0x00000000
  31. #define HAL_RX_USER_TLV32_LEN_LSB 10
  32. #define HAL_RX_USER_TLV32_LEN_MASK 0x003FFC00
  33. #define HAL_RX_USER_TLV32_USERID_OFFSET 0x00000000
  34. #define HAL_RX_USER_TLV32_USERID_LSB 26
  35. #define HAL_RX_USER_TLV32_USERID_MASK 0xFC000000
  36. #define HAL_ALIGN(x, a) HAL_ALIGN_MASK(x, (a)-1)
  37. #define HAL_ALIGN_MASK(x, mask) (typeof(x))(((uint32)(x) + (mask)) & ~(mask))
  38. #define HAL_RX_TLV32_HDR_SIZE 4
  39. #define HAL_RX_GET_USER_TLV32_TYPE(rx_status_tlv_ptr) \
  40. ((*((uint32_t *)(rx_status_tlv_ptr)) & \
  41. HAL_RX_USER_TLV32_TYPE_MASK) >> \
  42. HAL_RX_USER_TLV32_TYPE_LSB)
  43. #define HAL_RX_GET_USER_TLV32_LEN(rx_status_tlv_ptr) \
  44. ((*((uint32_t *)(rx_status_tlv_ptr)) & \
  45. HAL_RX_USER_TLV32_LEN_MASK) >> \
  46. HAL_RX_USER_TLV32_LEN_LSB)
  47. #define HAL_RX_GET_USER_TLV32_USERID(rx_status_tlv_ptr) \
  48. ((*((uint32_t *)(rx_status_tlv_ptr)) & \
  49. HAL_RX_USER_TLV32_USERID_MASK) >> \
  50. HAL_RX_USER_TLV32_USERID_LSB)
  51. #define HAL_TLV_STATUS_PPDU_NOT_DONE 0
  52. #define HAL_TLV_STATUS_PPDU_DONE 1
  53. #define HAL_TLV_STATUS_BUF_DONE 2
  54. #define HAL_TLV_STATUS_PPDU_NON_STD_DONE 3
  55. #define HAL_TLV_STATUS_PPDU_START 4
  56. #define HAL_TLV_STATUS_HEADER 5
  57. #define HAL_TLV_STATUS_MPDU_END 6
  58. #define HAL_TLV_STATUS_MSDU_START 7
  59. #define HAL_TLV_STATUS_MSDU_END 8
  60. #define HAL_MAX_UL_MU_USERS 37
  61. #define HAL_RX_PKT_TYPE_11A 0
  62. #define HAL_RX_PKT_TYPE_11B 1
  63. #define HAL_RX_PKT_TYPE_11N 2
  64. #define HAL_RX_PKT_TYPE_11AC 3
  65. #define HAL_RX_PKT_TYPE_11AX 4
  66. #define HAL_RX_RECEPTION_TYPE_SU 0
  67. #define HAL_RX_RECEPTION_TYPE_MU_MIMO 1
  68. #define HAL_RX_RECEPTION_TYPE_OFDMA 2
  69. #define HAL_RX_RECEPTION_TYPE_MU_OFDMA 3
  70. /* Multiply rate by 2 to avoid float point
  71. * and get rate in units of 500kbps
  72. */
  73. #define HAL_11B_RATE_0MCS 11*2
  74. #define HAL_11B_RATE_1MCS 5.5*2
  75. #define HAL_11B_RATE_2MCS 2*2
  76. #define HAL_11B_RATE_3MCS 1*2
  77. #define HAL_11B_RATE_4MCS 11*2
  78. #define HAL_11B_RATE_5MCS 5.5*2
  79. #define HAL_11B_RATE_6MCS 2*2
  80. #define HAL_11A_RATE_0MCS 48*2
  81. #define HAL_11A_RATE_1MCS 24*2
  82. #define HAL_11A_RATE_2MCS 12*2
  83. #define HAL_11A_RATE_3MCS 6*2
  84. #define HAL_11A_RATE_4MCS 54*2
  85. #define HAL_11A_RATE_5MCS 36*2
  86. #define HAL_11A_RATE_6MCS 18*2
  87. #define HAL_11A_RATE_7MCS 9*2
  88. #define HAL_LEGACY_MCS0 0
  89. #define HAL_LEGACY_MCS1 1
  90. #define HAL_LEGACY_MCS2 2
  91. #define HAL_LEGACY_MCS3 3
  92. #define HAL_LEGACY_MCS4 4
  93. #define HAL_LEGACY_MCS5 5
  94. #define HAL_LEGACY_MCS6 6
  95. #define HAL_LEGACY_MCS7 7
  96. #define HE_GI_0_8 0
  97. #define HE_GI_0_4 1
  98. #define HE_GI_1_6 2
  99. #define HE_GI_3_2 3
  100. #define HE_GI_RADIOTAP_0_8 0
  101. #define HE_GI_RADIOTAP_1_6 1
  102. #define HE_GI_RADIOTAP_3_2 2
  103. #define HE_GI_RADIOTAP_RESERVED 3
  104. #define HE_LTF_RADIOTAP_UNKNOWN 0
  105. #define HE_LTF_RADIOTAP_1_X 1
  106. #define HE_LTF_RADIOTAP_2_X 2
  107. #define HE_LTF_RADIOTAP_4_X 3
  108. #define HT_SGI_PRESENT 0x80
  109. #define HE_LTF_1_X 0
  110. #define HE_LTF_2_X 1
  111. #define HE_LTF_4_X 2
  112. #define HE_LTF_UNKNOWN 3
  113. #define VHT_SIG_SU_NSS_MASK 0x7
  114. #define HT_SIG_SU_NSS_SHIFT 0x3
  115. #define HAL_TID_INVALID 31
  116. #define HAL_AST_IDX_INVALID 0xFFFF
  117. #ifdef GET_MSDU_AGGREGATION
  118. #define HAL_RX_GET_MSDU_AGGREGATION(rx_desc, rs)\
  119. {\
  120. struct rx_msdu_end *rx_msdu_end;\
  121. bool first_msdu, last_msdu; \
  122. rx_msdu_end = &rx_desc->msdu_end_tlv.rx_msdu_end;\
  123. first_msdu = HAL_RX_GET(rx_msdu_end, RX_MSDU_END_5, FIRST_MSDU);\
  124. last_msdu = HAL_RX_GET(rx_msdu_end, RX_MSDU_END_5, LAST_MSDU);\
  125. if (first_msdu && last_msdu)\
  126. rs->rs_flags &= (~IEEE80211_AMSDU_FLAG);\
  127. else\
  128. rs->rs_flags |= (IEEE80211_AMSDU_FLAG); \
  129. } \
  130. #define HAL_RX_SET_MSDU_AGGREGATION((rs_mpdu), (rs_ppdu))\
  131. {\
  132. if (rs_mpdu->rs_flags & IEEE80211_AMSDU_FLAG)\
  133. rs_ppdu->rs_flags |= IEEE80211_AMSDU_FLAG;\
  134. } \
  135. #else
  136. #define HAL_RX_GET_MSDU_AGGREGATION(rx_desc, rs)
  137. #define HAL_RX_SET_MSDU_AGGREGATION(rs_mpdu, rs_ppdu)
  138. #endif
  139. /* Max MPDUs per status buffer */
  140. #define HAL_RX_MAX_MPDU 256
  141. #define HAL_RX_NUM_WORDS_PER_PPDU_BITMAP (HAL_RX_MAX_MPDU >> 5)
  142. #define HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER 16
  143. /* Max pilot count */
  144. #define HAL_RX_MAX_SU_EVM_COUNT 32
  145. /**
  146. * struct hal_rx_mon_desc_info () - HAL Rx Monitor descriptor info
  147. *
  148. * @ppdu_id: PHY ppdu id
  149. * @status_ppdu_id: status PHY ppdu id
  150. * @status_buf_count: number of status buffer count
  151. * @rxdma_push_reason: rxdma push reason
  152. * @rxdma_error_code: rxdma error code
  153. * @msdu_cnt: msdu count
  154. * @end_of_ppdu: end of ppdu
  155. * @link_desc: msdu link descriptor address
  156. * @status_buf: for a PPDU, status buffers can span acrosss
  157. * multiple buffers, status_buf points to first
  158. * status buffer address of PPDU
  159. * @drop_ppdu: flag to indicate current destination
  160. * ring ppdu drop
  161. */
  162. struct hal_rx_mon_desc_info {
  163. uint16_t ppdu_id;
  164. uint16_t status_ppdu_id;
  165. uint8_t status_buf_count;
  166. uint8_t rxdma_push_reason;
  167. uint8_t rxdma_error_code;
  168. uint8_t msdu_count;
  169. uint8_t end_of_ppdu;
  170. struct hal_buf_info link_desc;
  171. struct hal_buf_info status_buf;
  172. bool drop_ppdu;
  173. };
  174. /*
  175. * Struct hal_rx_su_evm_info - SU evm info
  176. * @number_of_symbols: number of symbols
  177. * @nss_count: nss count
  178. * @pilot_count: pilot count
  179. * @pilot_evm: Array of pilot evm values
  180. */
  181. struct hal_rx_su_evm_info {
  182. uint32_t number_of_symbols;
  183. uint8_t nss_count;
  184. uint8_t pilot_count;
  185. uint32_t pilot_evm[HAL_RX_MAX_SU_EVM_COUNT];
  186. };
  187. enum {
  188. DP_PPDU_STATUS_START,
  189. DP_PPDU_STATUS_DONE,
  190. };
  191. static inline
  192. uint8_t *HAL_RX_MON_DEST_GET_DESC(uint8_t *data)
  193. {
  194. return data;
  195. }
  196. static inline
  197. uint32_t HAL_RX_DESC_GET_MPDU_LENGTH_ERR(void *hw_desc_addr)
  198. {
  199. struct rx_attention *rx_attn;
  200. struct rx_mon_pkt_tlvs *rx_desc =
  201. (struct rx_mon_pkt_tlvs *)hw_desc_addr;
  202. rx_attn = &rx_desc->attn_tlv.rx_attn;
  203. return HAL_RX_GET(rx_attn, RX_ATTENTION_1, MPDU_LENGTH_ERR);
  204. }
  205. static inline
  206. uint32_t HAL_RX_DESC_GET_MPDU_FCS_ERR(void *hw_desc_addr)
  207. {
  208. struct rx_attention *rx_attn;
  209. struct rx_mon_pkt_tlvs *rx_desc =
  210. (struct rx_mon_pkt_tlvs *)hw_desc_addr;
  211. rx_attn = &rx_desc->attn_tlv.rx_attn;
  212. return HAL_RX_GET(rx_attn, RX_ATTENTION_1, FCS_ERR);
  213. }
  214. /*
  215. * HAL_RX_HW_DESC_MPDU_VALID() - check MPDU start TLV tag in MPDU
  216. * start TLV of Hardware TLV descriptor
  217. * @hw_desc_addr: Hardware desciptor address
  218. *
  219. * Return: bool: if TLV tag match
  220. */
  221. static inline
  222. bool HAL_RX_HW_DESC_MPDU_VALID(void *hw_desc_addr)
  223. {
  224. struct rx_mon_pkt_tlvs *rx_desc =
  225. (struct rx_mon_pkt_tlvs *)hw_desc_addr;
  226. uint32_t tlv_tag;
  227. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(
  228. &rx_desc->mpdu_start_tlv);
  229. return tlv_tag == WIFIRX_MPDU_START_E ? true : false;
  230. }
  231. /*
  232. * HAL_RX_HW_DESC_MPDU_VALID() - check MPDU start TLV user id in MPDU
  233. * start TLV of Hardware TLV descriptor
  234. * @hw_desc_addr: Hardware desciptor address
  235. *
  236. * Return: unit32_t: user id
  237. */
  238. static inline
  239. uint32_t HAL_RX_HW_DESC_MPDU_USER_ID(void *hw_desc_addr)
  240. {
  241. struct rx_mon_pkt_tlvs *rx_desc =
  242. (struct rx_mon_pkt_tlvs *)hw_desc_addr;
  243. uint32_t user_id;
  244. user_id = HAL_RX_GET_USER_TLV32_USERID(
  245. &rx_desc->mpdu_start_tlv);
  246. return user_id;
  247. }
  248. /* TODO: Move all Rx descriptor functions to hal_rx.h to avoid duplication */
  249. #define HAL_RX_BUFFER_ADDR_31_0_GET(buff_addr_info) \
  250. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  251. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_OFFSET)), \
  252. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_MASK, \
  253. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_LSB))
  254. #define HAL_RX_REO_ENT_BUFFER_ADDR_39_32_GET(reo_ent_desc) \
  255. (HAL_RX_BUFFER_ADDR_39_32_GET(& \
  256. (((struct reo_entrance_ring *)reo_ent_desc) \
  257. ->reo_level_mpdu_frame_info.msdu_link_desc_addr_info)))
  258. #define HAL_RX_REO_ENT_BUFFER_ADDR_31_0_GET(reo_ent_desc) \
  259. (HAL_RX_BUFFER_ADDR_31_0_GET(& \
  260. (((struct reo_entrance_ring *)reo_ent_desc) \
  261. ->reo_level_mpdu_frame_info.msdu_link_desc_addr_info)))
  262. #define HAL_RX_REO_ENT_BUF_COOKIE_GET(reo_ent_desc) \
  263. (HAL_RX_BUF_COOKIE_GET(& \
  264. (((struct reo_entrance_ring *)reo_ent_desc) \
  265. ->reo_level_mpdu_frame_info.msdu_link_desc_addr_info)))
  266. /**
  267. * hal_rx_reo_ent_buf_paddr_get: Gets the physical address and
  268. * cookie from the REO entrance ring element
  269. *
  270. * @ hal_rx_desc_cookie: Opaque cookie pointer used by HAL to get to
  271. * the current descriptor
  272. * @ buf_info: structure to return the buffer information
  273. * @ msdu_cnt: pointer to msdu count in MPDU
  274. * Return: void
  275. */
  276. static inline
  277. void hal_rx_reo_ent_buf_paddr_get(hal_rxdma_desc_t rx_desc,
  278. struct hal_buf_info *buf_info,
  279. uint32_t *msdu_cnt
  280. )
  281. {
  282. struct reo_entrance_ring *reo_ent_ring =
  283. (struct reo_entrance_ring *)rx_desc;
  284. struct buffer_addr_info *buf_addr_info;
  285. struct rx_mpdu_desc_info *rx_mpdu_desc_info_details;
  286. uint32_t loop_cnt;
  287. rx_mpdu_desc_info_details =
  288. &reo_ent_ring->reo_level_mpdu_frame_info.rx_mpdu_desc_info_details;
  289. *msdu_cnt = HAL_RX_GET(rx_mpdu_desc_info_details,
  290. RX_MPDU_DESC_INFO_0, MSDU_COUNT);
  291. loop_cnt = HAL_RX_GET(reo_ent_ring, REO_ENTRANCE_RING_7, LOOPING_COUNT);
  292. buf_addr_info =
  293. &reo_ent_ring->reo_level_mpdu_frame_info.msdu_link_desc_addr_info;
  294. buf_info->paddr =
  295. (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) |
  296. ((uint64_t)
  297. (HAL_RX_BUFFER_ADDR_39_32_GET(buf_addr_info)) << 32));
  298. buf_info->sw_cookie = HAL_RX_BUF_COOKIE_GET(buf_addr_info);
  299. buf_info->rbm = HAL_RX_BUF_RBM_GET(buf_addr_info);
  300. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  301. "[%s][%d] ReoAddr=%pK, addrInfo=%pK, paddr=0x%llx, loopcnt=%d",
  302. __func__, __LINE__, reo_ent_ring, buf_addr_info,
  303. (unsigned long long)buf_info->paddr, loop_cnt);
  304. }
  305. static inline
  306. void hal_rx_mon_next_link_desc_get(void *rx_msdu_link_desc,
  307. struct hal_buf_info *buf_info)
  308. {
  309. struct rx_msdu_link *msdu_link =
  310. (struct rx_msdu_link *)rx_msdu_link_desc;
  311. struct buffer_addr_info *buf_addr_info;
  312. buf_addr_info = &msdu_link->next_msdu_link_desc_addr_info;
  313. buf_info->paddr =
  314. (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) |
  315. ((uint64_t)
  316. (HAL_RX_BUFFER_ADDR_39_32_GET(buf_addr_info)) << 32));
  317. buf_info->sw_cookie = HAL_RX_BUF_COOKIE_GET(buf_addr_info);
  318. buf_info->rbm = HAL_RX_BUF_RBM_GET(buf_addr_info);
  319. }
  320. /**
  321. * hal_rx_msdu_link_desc_set: Retrieves MSDU Link Descriptor to WBM
  322. *
  323. * @ soc : HAL version of the SOC pointer
  324. * @ src_srng_desc : void pointer to the WBM Release Ring descriptor
  325. * @ buf_addr_info : void pointer to the buffer_addr_info
  326. *
  327. * Return: void
  328. */
  329. static inline
  330. void hal_rx_mon_msdu_link_desc_set(hal_soc_handle_t hal_soc_hdl,
  331. void *src_srng_desc,
  332. hal_buff_addrinfo_t buf_addr_info)
  333. {
  334. struct buffer_addr_info *wbm_srng_buffer_addr_info =
  335. (struct buffer_addr_info *)src_srng_desc;
  336. uint64_t paddr;
  337. struct buffer_addr_info *p_buffer_addr_info =
  338. (struct buffer_addr_info *)buf_addr_info;
  339. paddr =
  340. (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) |
  341. ((uint64_t)
  342. (HAL_RX_BUFFER_ADDR_39_32_GET(buf_addr_info)) << 32));
  343. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  344. "[%s][%d] src_srng_desc=%pK, buf_addr=0x%llx, cookie=0x%llx",
  345. __func__, __LINE__, src_srng_desc, (unsigned long long)paddr,
  346. (unsigned long long)p_buffer_addr_info->sw_buffer_cookie);
  347. /* Structure copy !!! */
  348. *wbm_srng_buffer_addr_info =
  349. *((struct buffer_addr_info *)buf_addr_info);
  350. }
  351. static inline
  352. uint32 hal_get_rx_msdu_link_desc_size(void)
  353. {
  354. return sizeof(struct rx_msdu_link);
  355. }
  356. enum {
  357. HAL_PKT_TYPE_OFDM = 0,
  358. HAL_PKT_TYPE_CCK,
  359. HAL_PKT_TYPE_HT,
  360. HAL_PKT_TYPE_VHT,
  361. HAL_PKT_TYPE_HE,
  362. };
  363. enum {
  364. HAL_SGI_0_8_US,
  365. HAL_SGI_0_4_US,
  366. HAL_SGI_1_6_US,
  367. HAL_SGI_3_2_US,
  368. };
  369. enum {
  370. HAL_FULL_RX_BW_20,
  371. HAL_FULL_RX_BW_40,
  372. HAL_FULL_RX_BW_80,
  373. HAL_FULL_RX_BW_160,
  374. };
  375. enum {
  376. HAL_RX_TYPE_SU,
  377. HAL_RX_TYPE_MU_MIMO,
  378. HAL_RX_TYPE_MU_OFDMA,
  379. HAL_RX_TYPE_MU_OFDMA_MIMO,
  380. };
  381. /**
  382. * enum
  383. * @HAL_RX_MON_PPDU_START: PPDU start TLV is decoded in HAL
  384. * @HAL_RX_MON_PPDU_END: PPDU end TLV is decoded in HAL
  385. * @HAL_RX_MON_PPDU_RESET: Not PPDU start and end TLV
  386. */
  387. enum {
  388. HAL_RX_MON_PPDU_START = 0,
  389. HAL_RX_MON_PPDU_END,
  390. HAL_RX_MON_PPDU_RESET,
  391. };
  392. /* struct hal_rx_ppdu_common_info - common ppdu info
  393. * @ppdu_id - ppdu id number
  394. * @ppdu_timestamp - timestamp at ppdu received
  395. * @mpdu_cnt_fcs_ok - mpdu count in ppdu with fcs ok
  396. * @mpdu_cnt_fcs_err - mpdu count in ppdu with fcs err
  397. * @mpdu_fcs_ok_bitmap - fcs ok mpdu count in ppdu bitmap
  398. * @last_ppdu_id - last received ppdu id
  399. * @mpdu_cnt - total mpdu count
  400. * @num_users - num users
  401. */
  402. struct hal_rx_ppdu_common_info {
  403. uint32_t ppdu_id;
  404. uint32_t ppdu_timestamp;
  405. uint32_t mpdu_cnt_fcs_ok;
  406. uint32_t mpdu_cnt_fcs_err;
  407. uint32_t mpdu_fcs_ok_bitmap[HAL_RX_NUM_WORDS_PER_PPDU_BITMAP];
  408. uint32_t last_ppdu_id;
  409. uint32_t mpdu_cnt;
  410. uint8_t num_users;
  411. };
  412. /**
  413. * struct hal_rx_msdu_payload_info - msdu payload info
  414. * @first_msdu_payload: pointer to first msdu payload
  415. * @payload_len: payload len
  416. */
  417. struct hal_rx_msdu_payload_info {
  418. uint8_t *first_msdu_payload;
  419. uint32_t payload_len;
  420. };
  421. /**
  422. * struct hal_rx_nac_info - struct for neighbour info
  423. * @fc_valid: flag indicate if it has valid frame control information
  424. * @frame_control: frame control from each MPDU
  425. * @to_ds_flag: flag indicate to_ds bit
  426. * @mac_addr2_valid: flag indicate if mac_addr2 is valid
  427. * @mac_addr2: mac address2 in wh
  428. * @mcast_bcast: multicast/broadcast
  429. */
  430. struct hal_rx_nac_info {
  431. uint8_t fc_valid;
  432. uint16_t frame_control;
  433. uint8_t to_ds_flag;
  434. uint8_t mac_addr2_valid;
  435. uint8_t mac_addr2[QDF_MAC_ADDR_SIZE];
  436. uint8_t mcast_bcast;
  437. };
  438. /**
  439. * struct hal_rx_ppdu_msdu_info - struct for msdu info from HW TLVs
  440. * @cce_metadata: cached CCE metadata value received in the MSDU_END TLV
  441. * @is_flow_idx_timeout: flag to indicate if flow search timeout occurred
  442. * @is_flow_idx_invalid: flag to indicate if flow idx is valid or not
  443. * @fse_metadata: cached FSE metadata value received in the MSDU END TLV
  444. * @flow_idx: flow idx matched in FSE received in the MSDU END TLV
  445. */
  446. struct hal_rx_ppdu_msdu_info {
  447. uint16_t cce_metadata;
  448. bool is_flow_idx_timeout;
  449. bool is_flow_idx_invalid;
  450. uint32_t fse_metadata;
  451. uint32_t flow_idx;
  452. };
  453. #if defined(WLAN_CFR_ENABLE) && defined(WLAN_ENH_CFR_ENABLE)
  454. /**
  455. * struct hal_rx_ppdu_cfr_user_info - struct for storing peer info extracted
  456. * from HW TLVs, this will be used for correlating CFR data with multiple peers
  457. * in MU PPDUs
  458. *
  459. * @peer_macaddr: macaddr of the peer
  460. * @ast_index: AST index of the peer
  461. */
  462. struct hal_rx_ppdu_cfr_user_info {
  463. uint8_t peer_macaddr[QDF_MAC_ADDR_SIZE];
  464. uint32_t ast_index;
  465. };
  466. /**
  467. * struct hal_rx_ppdu_cfr_info - struct for storing ppdu info extracted from HW
  468. * TLVs, this will be used for CFR correlation
  469. *
  470. * @bb_captured_channel : Set by RXPCU when MACRX_FREEZE_CAPTURE_CHANNEL TLV is
  471. * sent to PHY, SW checks it to correlate current PPDU TLVs with uploaded
  472. * channel information.
  473. *
  474. * @bb_captured_timeout : Set by RxPCU to indicate channel capture condition is
  475. * met, but MACRX_FREEZE_CAPTURE_CHANNEL is not sent to PHY due to AST delay,
  476. * which means the rx_frame_falling edge to FREEZE TLV ready time exceeds
  477. * the threshold time defined by RXPCU register FREEZE_TLV_DELAY_CNT_THRESH.
  478. * Bb_captured_reason is still valid in this case.
  479. *
  480. * @rx_location_info_valid: Indicates whether CFR DMA address in the PPDU TLV
  481. * is valid
  482. * <enum 0 rx_location_info_is_not_valid>
  483. * <enum 1 rx_location_info_is_valid>
  484. * <legal all>
  485. *
  486. * @bb_captured_reason : Copy capture_reason of MACRX_FREEZE_CAPTURE_CHANNEL
  487. * TLV to here for FW usage. Valid when bb_captured_channel or
  488. * bb_captured_timeout is set.
  489. * <enum 0 freeze_reason_TM>
  490. * <enum 1 freeze_reason_FTM>
  491. * <enum 2 freeze_reason_ACK_resp_to_TM_FTM>
  492. * <enum 3 freeze_reason_TA_RA_TYPE_FILTER>
  493. * <enum 4 freeze_reason_NDPA_NDP>
  494. * <enum 5 freeze_reason_ALL_PACKET>
  495. * <legal 0-5>
  496. *
  497. * @rtt_che_buffer_pointer_low32 : The low 32 bits of the 40 bits pointer to
  498. * external RTT channel information buffer
  499. *
  500. * @rtt_che_buffer_pointer_high8 : The high 8 bits of the 40 bits pointer to
  501. * external RTT channel information buffer
  502. *
  503. * @chan_capture_status : capture status reported by ucode
  504. * a. CAPTURE_IDLE: FW has disabled "REPETITIVE_CHE_CAPTURE_CTRL"
  505. * b. CAPTURE_BUSY: previous PPDU’s channel capture upload DMA ongoing. (Note
  506. * that this upload is triggered after receiving freeze_channel_capture TLV
  507. * after last PPDU is rx)
  508. * c. CAPTURE_ACTIVE: channel capture is enabled and no previous channel
  509. * capture ongoing
  510. * d. CAPTURE_NO_BUFFER: next buffer in IPC ring not available
  511. *
  512. * @cfr_user_info: Peer mac for upto 4 MU users
  513. */
  514. struct hal_rx_ppdu_cfr_info {
  515. bool bb_captured_channel;
  516. bool bb_captured_timeout;
  517. uint8_t bb_captured_reason;
  518. bool rx_location_info_valid;
  519. uint8_t chan_capture_status;
  520. uint8_t rtt_che_buffer_pointer_high8;
  521. uint32_t rtt_che_buffer_pointer_low32;
  522. struct hal_rx_ppdu_cfr_user_info cfr_user_info[HAL_MAX_UL_MU_USERS];
  523. int16_t rtt_cfo_measurement;
  524. uint32_t agc_gain_info0;
  525. uint32_t agc_gain_info1;
  526. uint32_t agc_gain_info2;
  527. uint32_t agc_gain_info3;
  528. uint32_t rx_start_ts;
  529. };
  530. #else
  531. struct hal_rx_ppdu_cfr_info {};
  532. #endif
  533. struct mon_rx_info {
  534. uint8_t qos_control_info_valid;
  535. uint16_t qos_control;
  536. uint8_t mac_addr1_valid;
  537. uint8_t mac_addr1[QDF_MAC_ADDR_SIZE];
  538. uint32_t user_id;
  539. };
  540. struct mon_rx_user_info {
  541. uint16_t qos_control;
  542. uint8_t qos_control_info_valid;
  543. };
  544. struct hal_rx_ppdu_info {
  545. struct hal_rx_ppdu_common_info com_info;
  546. struct mon_rx_status rx_status;
  547. struct mon_rx_user_status rx_user_status[HAL_MAX_UL_MU_USERS];
  548. struct mon_rx_info rx_info;
  549. struct mon_rx_user_info rx_user_info[HAL_MAX_UL_MU_USERS];
  550. struct hal_rx_msdu_payload_info msdu_info;
  551. struct hal_rx_msdu_payload_info fcs_ok_msdu_info;
  552. struct hal_rx_nac_info nac_info;
  553. /* status ring PPDU start and end state */
  554. uint32_t rx_state;
  555. /* MU user id for status ring TLV */
  556. uint32_t user_id;
  557. /* MPDU/MSDU truncated to 128 bytes header start addr in status skb */
  558. unsigned char *data;
  559. /* MPDU/MSDU truncated to 128 bytes header real length */
  560. uint32_t hdr_len;
  561. /* MPDU FCS error */
  562. bool fcs_err;
  563. /* Id to indicate how to process mpdu */
  564. uint8_t sw_frame_group_id;
  565. struct hal_rx_ppdu_msdu_info rx_msdu_info[HAL_MAX_UL_MU_USERS];
  566. /* fcs passed mpdu count in rx monitor status buffer */
  567. uint8_t fcs_ok_cnt;
  568. /* fcs error mpdu count in rx monitor status buffer */
  569. uint8_t fcs_err_cnt;
  570. /* MPDU FCS passed */
  571. bool is_fcs_passed;
  572. /* first msdu payload for all mpdus in rx monitor status buffer */
  573. struct hal_rx_msdu_payload_info ppdu_msdu_info[HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER];
  574. /* evm info */
  575. struct hal_rx_su_evm_info evm_info;
  576. /**
  577. * Will be used to store ppdu info extracted from HW TLVs,
  578. * and for CFR correlation as well
  579. */
  580. struct hal_rx_ppdu_cfr_info cfr_info;
  581. };
  582. static inline uint32_t
  583. hal_get_rx_status_buf_size(void) {
  584. /* RX status buffer size is hard coded for now */
  585. return 2048;
  586. }
  587. static inline uint8_t*
  588. hal_rx_status_get_next_tlv(uint8_t *rx_tlv) {
  589. uint32_t tlv_len, tlv_tag;
  590. tlv_len = HAL_RX_GET_USER_TLV32_LEN(rx_tlv);
  591. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(rx_tlv);
  592. /* The actual length of PPDU_END is the combined length of many PHY
  593. * TLVs that follow. Skip the TLV header and
  594. * rx_rxpcu_classification_overview that follows the header to get to
  595. * next TLV.
  596. */
  597. if (tlv_tag == WIFIRX_PPDU_END_E)
  598. tlv_len = sizeof(struct rx_rxpcu_classification_overview);
  599. return (uint8_t *)(((unsigned long)(rx_tlv + tlv_len +
  600. HAL_RX_TLV32_HDR_SIZE + 3)) & (~((unsigned long)3)));
  601. }
  602. /**
  603. * hal_rx_proc_phyrx_other_receive_info_tlv()
  604. * - process other receive info TLV
  605. * @rx_tlv_hdr: pointer to TLV header
  606. * @ppdu_info: pointer to ppdu_info
  607. *
  608. * Return: None
  609. */
  610. static inline void hal_rx_proc_phyrx_other_receive_info_tlv(struct hal_soc *hal_soc,
  611. void *rx_tlv_hdr,
  612. struct hal_rx_ppdu_info
  613. *ppdu_info)
  614. {
  615. hal_soc->ops->hal_rx_proc_phyrx_other_receive_info_tlv(rx_tlv_hdr,
  616. (void *)ppdu_info);
  617. }
  618. /**
  619. * hal_rx_status_get_tlv_info() - process receive info TLV
  620. * @rx_tlv_hdr: pointer to TLV header
  621. * @ppdu_info: pointer to ppdu_info
  622. * @hal_soc: HAL soc handle
  623. * @nbuf: PPDU status netowrk buffer
  624. *
  625. * Return: HAL_TLV_STATUS_PPDU_NOT_DONE or HAL_TLV_STATUS_PPDU_DONE from tlv
  626. */
  627. static inline uint32_t
  628. hal_rx_status_get_tlv_info(void *rx_tlv_hdr, void *ppdu_info,
  629. hal_soc_handle_t hal_soc_hdl,
  630. qdf_nbuf_t nbuf)
  631. {
  632. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  633. return hal_soc->ops->hal_rx_status_get_tlv_info(
  634. rx_tlv_hdr,
  635. ppdu_info,
  636. hal_soc_hdl,
  637. nbuf);
  638. }
  639. static inline
  640. uint32_t hal_get_rx_status_done_tlv_size(hal_soc_handle_t hal_soc_hdl)
  641. {
  642. return HAL_RX_TLV32_HDR_SIZE;
  643. }
  644. static inline QDF_STATUS
  645. hal_get_rx_status_done(uint8_t *rx_tlv)
  646. {
  647. uint32_t tlv_tag;
  648. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(rx_tlv);
  649. if (tlv_tag == WIFIRX_STATUS_BUFFER_DONE_E)
  650. return QDF_STATUS_SUCCESS;
  651. else
  652. return QDF_STATUS_E_EMPTY;
  653. }
  654. static inline QDF_STATUS
  655. hal_clear_rx_status_done(uint8_t *rx_tlv)
  656. {
  657. *(uint32_t *)rx_tlv = 0;
  658. return QDF_STATUS_SUCCESS;
  659. }
  660. #endif