hal_api_mon.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. /*
  2. * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #ifndef _HAL_API_MON_H_
  20. #define _HAL_API_MON_H_
  21. #include "qdf_types.h"
  22. #include "hal_internal.h"
  23. #include "hal_hw_headers.h"
  24. #include <target_type.h>
  25. #define HAL_RX_PHY_DATA_RADAR 0x01
  26. #define HAL_SU_MU_CODING_LDPC 0x01
  27. #define HAL_RX_FCS_LEN (4)
  28. #define KEY_EXTIV 0x20
  29. #define HAL_ALIGN(x, a) HAL_ALIGN_MASK(x, (a)-1)
  30. #define HAL_ALIGN_MASK(x, mask) (typeof(x))(((uint32)(x) + (mask)) & ~(mask))
  31. #define HAL_RX_TLV32_HDR_SIZE 4
  32. #define HAL_RX_GET_USER_TLV32_TYPE(rx_status_tlv_ptr) \
  33. ((*((uint32_t *)(rx_status_tlv_ptr)) & \
  34. HAL_RX_USER_TLV32_TYPE_MASK) >> \
  35. HAL_RX_USER_TLV32_TYPE_LSB)
  36. #define HAL_RX_GET_USER_TLV32_LEN(rx_status_tlv_ptr) \
  37. ((*((uint32_t *)(rx_status_tlv_ptr)) & \
  38. HAL_RX_USER_TLV32_LEN_MASK) >> \
  39. HAL_RX_USER_TLV32_LEN_LSB)
  40. #define HAL_RX_GET_USER_TLV32_USERID(rx_status_tlv_ptr) \
  41. ((*((uint32_t *)(rx_status_tlv_ptr)) & \
  42. HAL_RX_USER_TLV32_USERID_MASK) >> \
  43. HAL_RX_USER_TLV32_USERID_LSB)
  44. #define HAL_RX_TLV64_HDR_SIZE 8
  45. #define HAL_RX_GET_USER_TLV64_TYPE(rx_status_tlv_ptr) \
  46. ((*((uint64_t *)(rx_status_tlv_ptr)) & \
  47. HAL_RX_USER_TLV64_TYPE_MASK) >> \
  48. HAL_RX_USER_TLV64_TYPE_LSB)
  49. #define HAL_RX_GET_USER_TLV64_LEN(rx_status_tlv_ptr) \
  50. ((*((uint64_t *)(rx_status_tlv_ptr)) & \
  51. HAL_RX_USER_TLV64_LEN_MASK) >> \
  52. HAL_RX_USER_TLV64_LEN_LSB)
  53. #define HAL_RX_GET_USER_TLV64_USERID(rx_status_tlv_ptr) \
  54. ((*((uint64_t *)(rx_status_tlv_ptr)) & \
  55. HAL_RX_USER_TLV64_USERID_MASK) >> \
  56. HAL_RX_USER_TLV64_USERID_LSB)
  57. #define HAL_TLV_STATUS_PPDU_NOT_DONE 0
  58. #define HAL_TLV_STATUS_PPDU_DONE 1
  59. #define HAL_TLV_STATUS_BUF_DONE 2
  60. #define HAL_TLV_STATUS_PPDU_NON_STD_DONE 3
  61. #define HAL_TLV_STATUS_PPDU_START 4
  62. #define HAL_TLV_STATUS_HEADER 5
  63. #define HAL_TLV_STATUS_MPDU_END 6
  64. #define HAL_TLV_STATUS_MSDU_START 7
  65. #define HAL_TLV_STATUS_MSDU_END 8
  66. #define HAL_MAX_UL_MU_USERS 37
  67. #define HAL_RX_PKT_TYPE_11A 0
  68. #define HAL_RX_PKT_TYPE_11B 1
  69. #define HAL_RX_PKT_TYPE_11N 2
  70. #define HAL_RX_PKT_TYPE_11AC 3
  71. #define HAL_RX_PKT_TYPE_11AX 4
  72. #define HAL_RX_RECEPTION_TYPE_SU 0
  73. #define HAL_RX_RECEPTION_TYPE_MU_MIMO 1
  74. #define HAL_RX_RECEPTION_TYPE_OFDMA 2
  75. #define HAL_RX_RECEPTION_TYPE_MU_OFDMA 3
  76. /* Multiply rate by 2 to avoid float point
  77. * and get rate in units of 500kbps
  78. */
  79. #define HAL_11B_RATE_0MCS 11*2
  80. #define HAL_11B_RATE_1MCS 5.5*2
  81. #define HAL_11B_RATE_2MCS 2*2
  82. #define HAL_11B_RATE_3MCS 1*2
  83. #define HAL_11B_RATE_4MCS 11*2
  84. #define HAL_11B_RATE_5MCS 5.5*2
  85. #define HAL_11B_RATE_6MCS 2*2
  86. #define HAL_11A_RATE_0MCS 48*2
  87. #define HAL_11A_RATE_1MCS 24*2
  88. #define HAL_11A_RATE_2MCS 12*2
  89. #define HAL_11A_RATE_3MCS 6*2
  90. #define HAL_11A_RATE_4MCS 54*2
  91. #define HAL_11A_RATE_5MCS 36*2
  92. #define HAL_11A_RATE_6MCS 18*2
  93. #define HAL_11A_RATE_7MCS 9*2
  94. #define HAL_LEGACY_MCS0 0
  95. #define HAL_LEGACY_MCS1 1
  96. #define HAL_LEGACY_MCS2 2
  97. #define HAL_LEGACY_MCS3 3
  98. #define HAL_LEGACY_MCS4 4
  99. #define HAL_LEGACY_MCS5 5
  100. #define HAL_LEGACY_MCS6 6
  101. #define HAL_LEGACY_MCS7 7
  102. #define HE_GI_0_8 0
  103. #define HE_GI_0_4 1
  104. #define HE_GI_1_6 2
  105. #define HE_GI_3_2 3
  106. #define HE_GI_RADIOTAP_0_8 0
  107. #define HE_GI_RADIOTAP_1_6 1
  108. #define HE_GI_RADIOTAP_3_2 2
  109. #define HE_GI_RADIOTAP_RESERVED 3
  110. #define HE_LTF_RADIOTAP_UNKNOWN 0
  111. #define HE_LTF_RADIOTAP_1_X 1
  112. #define HE_LTF_RADIOTAP_2_X 2
  113. #define HE_LTF_RADIOTAP_4_X 3
  114. #define HT_SGI_PRESENT 0x80
  115. #define HE_LTF_1_X 0
  116. #define HE_LTF_2_X 1
  117. #define HE_LTF_4_X 2
  118. #define HE_LTF_UNKNOWN 3
  119. #define VHT_SIG_SU_NSS_MASK 0x7
  120. #define HT_SIG_SU_NSS_SHIFT 0x3
  121. #define HAL_TID_INVALID 31
  122. #define HAL_AST_IDX_INVALID 0xFFFF
  123. #ifdef GET_MSDU_AGGREGATION
  124. #define HAL_RX_GET_MSDU_AGGREGATION(rx_desc, rs)\
  125. {\
  126. struct rx_msdu_end *rx_msdu_end;\
  127. bool first_msdu, last_msdu; \
  128. rx_msdu_end = &rx_desc->msdu_end_tlv.rx_msdu_end;\
  129. first_msdu = HAL_RX_GET(rx_msdu_end, RX_MSDU_END_5, FIRST_MSDU);\
  130. last_msdu = HAL_RX_GET(rx_msdu_end, RX_MSDU_END_5, LAST_MSDU);\
  131. if (first_msdu && last_msdu)\
  132. rs->rs_flags &= (~IEEE80211_AMSDU_FLAG);\
  133. else\
  134. rs->rs_flags |= (IEEE80211_AMSDU_FLAG); \
  135. } \
  136. #define HAL_RX_SET_MSDU_AGGREGATION((rs_mpdu), (rs_ppdu))\
  137. {\
  138. if (rs_mpdu->rs_flags & IEEE80211_AMSDU_FLAG)\
  139. rs_ppdu->rs_flags |= IEEE80211_AMSDU_FLAG;\
  140. } \
  141. #else
  142. #define HAL_RX_GET_MSDU_AGGREGATION(rx_desc, rs)
  143. #define HAL_RX_SET_MSDU_AGGREGATION(rs_mpdu, rs_ppdu)
  144. #endif
  145. /* Max MPDUs per status buffer */
  146. #define HAL_RX_MAX_MPDU 256
  147. #define HAL_RX_NUM_WORDS_PER_PPDU_BITMAP (HAL_RX_MAX_MPDU >> 5)
  148. #define HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER 16
  149. /* Max pilot count */
  150. #define HAL_RX_MAX_SU_EVM_COUNT 32
  151. #define HAL_RX_FRAMECTRL_TYPE_MASK 0x0C
  152. #define HAL_RX_GET_FRAME_CTRL_TYPE(fc)\
  153. (((fc) & HAL_RX_FRAMECTRL_TYPE_MASK) >> 2)
  154. #define HAL_RX_FRAME_CTRL_TYPE_MGMT 0x0
  155. #define HAL_RX_FRAME_CTRL_TYPE_CTRL 0x1
  156. #define HAL_RX_FRAME_CTRL_TYPE_DATA 0x2
  157. /**
  158. * struct hal_rx_mon_desc_info () - HAL Rx Monitor descriptor info
  159. *
  160. * @ppdu_id: PHY ppdu id
  161. * @status_ppdu_id: status PHY ppdu id
  162. * @status_buf_count: number of status buffer count
  163. * @rxdma_push_reason: rxdma push reason
  164. * @rxdma_error_code: rxdma error code
  165. * @msdu_cnt: msdu count
  166. * @end_of_ppdu: end of ppdu
  167. * @link_desc: msdu link descriptor address
  168. * @status_buf: for a PPDU, status buffers can span acrosss
  169. * multiple buffers, status_buf points to first
  170. * status buffer address of PPDU
  171. * @drop_ppdu: flag to indicate current destination
  172. * ring ppdu drop
  173. */
  174. struct hal_rx_mon_desc_info {
  175. uint16_t ppdu_id;
  176. uint16_t status_ppdu_id;
  177. uint8_t status_buf_count;
  178. uint8_t rxdma_push_reason;
  179. uint8_t rxdma_error_code;
  180. uint8_t msdu_count;
  181. uint8_t end_of_ppdu;
  182. struct hal_buf_info link_desc;
  183. struct hal_buf_info status_buf;
  184. bool drop_ppdu;
  185. };
  186. /*
  187. * Struct hal_rx_su_evm_info - SU evm info
  188. * @number_of_symbols: number of symbols
  189. * @nss_count: nss count
  190. * @pilot_count: pilot count
  191. * @pilot_evm: Array of pilot evm values
  192. */
  193. struct hal_rx_su_evm_info {
  194. uint32_t number_of_symbols;
  195. uint8_t nss_count;
  196. uint8_t pilot_count;
  197. uint32_t pilot_evm[HAL_RX_MAX_SU_EVM_COUNT];
  198. };
  199. enum {
  200. DP_PPDU_STATUS_START,
  201. DP_PPDU_STATUS_DONE,
  202. };
  203. /**
  204. * hal_rx_reo_ent_buf_paddr_get: Gets the physical address and
  205. * cookie from the REO entrance ring element
  206. * @hal_rx_desc_cookie: Opaque cookie pointer used by HAL to get to
  207. * the current descriptor
  208. * @ buf_info: structure to return the buffer information
  209. * @ msdu_cnt: pointer to msdu count in MPDU
  210. *
  211. * CAUTION: This API calls a hal_soc ops, so be careful before calling this in
  212. * per packet path
  213. *
  214. * Return: void
  215. */
  216. static inline
  217. void hal_rx_reo_ent_buf_paddr_get(hal_soc_handle_t hal_soc_hdl,
  218. hal_rxdma_desc_t rx_desc,
  219. struct hal_buf_info *buf_info,
  220. uint32_t *msdu_cnt)
  221. {
  222. struct reo_entrance_ring *reo_ent_ring =
  223. (struct reo_entrance_ring *)rx_desc;
  224. struct buffer_addr_info *buf_addr_info;
  225. struct rx_mpdu_desc_info *rx_mpdu_desc_info_details;
  226. uint32_t loop_cnt;
  227. rx_mpdu_desc_info_details =
  228. &reo_ent_ring->reo_level_mpdu_frame_info.rx_mpdu_desc_info_details;
  229. *msdu_cnt = HAL_RX_GET(rx_mpdu_desc_info_details,
  230. HAL_RX_MPDU_DESC_INFO, MSDU_COUNT);
  231. loop_cnt = HAL_RX_GET(reo_ent_ring, HAL_REO_ENTRANCE_RING,
  232. LOOPING_COUNT);
  233. buf_addr_info =
  234. &reo_ent_ring->reo_level_mpdu_frame_info.msdu_link_desc_addr_info;
  235. hal_rx_buf_cookie_rbm_get(hal_soc_hdl, (uint32_t *)buf_addr_info,
  236. buf_info);
  237. buf_info->paddr =
  238. (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) |
  239. ((uint64_t)
  240. (HAL_RX_BUFFER_ADDR_39_32_GET(buf_addr_info)) << 32));
  241. dp_nofl_debug("[%s][%d] ReoAddr=%pK, addrInfo=%pK, paddr=0x%llx, loopcnt=%d",
  242. __func__, __LINE__, reo_ent_ring, buf_addr_info,
  243. (unsigned long long)buf_info->paddr, loop_cnt);
  244. }
  245. static inline
  246. void hal_rx_mon_next_link_desc_get(hal_soc_handle_t hal_soc_hdl,
  247. void *rx_msdu_link_desc,
  248. struct hal_buf_info *buf_info)
  249. {
  250. struct rx_msdu_link *msdu_link =
  251. (struct rx_msdu_link *)rx_msdu_link_desc;
  252. struct buffer_addr_info *buf_addr_info;
  253. buf_addr_info = &msdu_link->next_msdu_link_desc_addr_info;
  254. hal_rx_buf_cookie_rbm_get(hal_soc_hdl, (uint32_t *)buf_addr_info,
  255. buf_info);
  256. buf_info->paddr =
  257. (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) |
  258. ((uint64_t)
  259. (HAL_RX_BUFFER_ADDR_39_32_GET(buf_addr_info)) << 32));
  260. }
  261. static inline
  262. uint8_t *HAL_RX_MON_DEST_GET_DESC(uint8_t *data)
  263. {
  264. return data;
  265. }
  266. static inline uint32_t
  267. hal_rx_tlv_mpdu_len_err_get(hal_soc_handle_t hal_soc_hdl, void *hw_desc_addr)
  268. {
  269. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  270. if (!hal_soc || !hal_soc->ops) {
  271. hal_err("hal handle is NULL");
  272. QDF_BUG(0);
  273. return 0;
  274. }
  275. if (hal_soc->ops->hal_rx_tlv_mpdu_len_err_get)
  276. return hal_soc->ops->hal_rx_tlv_mpdu_len_err_get(hw_desc_addr);
  277. return 0;
  278. }
  279. static inline uint32_t
  280. hal_rx_tlv_mpdu_fcs_err_get(hal_soc_handle_t hal_soc_hdl, void *hw_desc_addr)
  281. {
  282. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  283. if (!hal_soc || !hal_soc->ops) {
  284. hal_err("hal handle is NULL");
  285. QDF_BUG(0);
  286. return 0;
  287. }
  288. if (hal_soc->ops->hal_rx_tlv_mpdu_fcs_err_get)
  289. return hal_soc->ops->hal_rx_tlv_mpdu_fcs_err_get(hw_desc_addr);
  290. return 0;
  291. }
  292. #ifdef notyet
  293. /*
  294. * HAL_RX_HW_DESC_MPDU_VALID() - check MPDU start TLV tag in MPDU
  295. * start TLV of Hardware TLV descriptor
  296. * @hw_desc_addr: Hardware descriptor address
  297. *
  298. * Return: bool: if TLV tag match
  299. */
  300. static inline
  301. bool HAL_RX_HW_DESC_MPDU_VALID(void *hw_desc_addr)
  302. {
  303. struct rx_mon_pkt_tlvs *rx_desc =
  304. (struct rx_mon_pkt_tlvs *)hw_desc_addr;
  305. uint32_t tlv_tag;
  306. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(&rx_desc->mpdu_start_tlv);
  307. return tlv_tag == WIFIRX_MPDU_START_E ? true : false;
  308. }
  309. #endif
  310. /*
  311. * HAL_RX_HW_DESC_MPDU_VALID() - check MPDU start TLV user id in MPDU
  312. * start TLV of Hardware TLV descriptor
  313. * @hw_desc_addr: Hardware descriptor address
  314. *
  315. * Return: unit32_t: user id
  316. */
  317. static inline uint32_t
  318. hal_rx_hw_desc_mpdu_user_id(hal_soc_handle_t hal_soc_hdl,
  319. void *hw_desc_addr)
  320. {
  321. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  322. if (!hal_soc || !hal_soc->ops) {
  323. hal_err("hal handle is NULL");
  324. QDF_BUG(0);
  325. return 0;
  326. }
  327. if (hal_soc->ops->hal_rx_hw_desc_mpdu_user_id)
  328. return hal_soc->ops->hal_rx_hw_desc_mpdu_user_id(hw_desc_addr);
  329. return 0;
  330. }
  331. /* TODO: Move all Rx descriptor functions to hal_rx.h to avoid duplication */
  332. /**
  333. * hal_rx_msdu_link_desc_set: Retrieves MSDU Link Descriptor to WBM
  334. *
  335. * @ soc : HAL version of the SOC pointer
  336. * @ src_srng_desc : void pointer to the WBM Release Ring descriptor
  337. * @ buf_addr_info : void pointer to the buffer_addr_info
  338. *
  339. * Return: void
  340. */
  341. static inline
  342. void hal_rx_mon_msdu_link_desc_set(hal_soc_handle_t hal_soc_hdl,
  343. void *src_srng_desc,
  344. hal_buff_addrinfo_t buf_addr_info)
  345. {
  346. struct buffer_addr_info *wbm_srng_buffer_addr_info =
  347. (struct buffer_addr_info *)src_srng_desc;
  348. uint64_t paddr;
  349. struct buffer_addr_info *p_buffer_addr_info =
  350. (struct buffer_addr_info *)buf_addr_info;
  351. paddr =
  352. (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) |
  353. ((uint64_t)
  354. (HAL_RX_BUFFER_ADDR_39_32_GET(buf_addr_info)) << 32));
  355. dp_nofl_debug("[%s][%d] src_srng_desc=%pK, buf_addr=0x%llx, cookie=0x%llx",
  356. __func__, __LINE__, src_srng_desc, (unsigned long long)paddr,
  357. (unsigned long long)p_buffer_addr_info->sw_buffer_cookie);
  358. /* Structure copy !!! */
  359. *wbm_srng_buffer_addr_info =
  360. *((struct buffer_addr_info *)buf_addr_info);
  361. }
  362. /**
  363. * hal_get_rx_msdu_link_desc_size() - Get msdu link descriptor size
  364. *
  365. * Return: size of rx_msdu_link
  366. */
  367. static inline
  368. uint32_t hal_get_rx_msdu_link_desc_size(void)
  369. {
  370. return sizeof(struct rx_msdu_link);
  371. }
  372. enum {
  373. HAL_PKT_TYPE_OFDM = 0,
  374. HAL_PKT_TYPE_CCK,
  375. HAL_PKT_TYPE_HT,
  376. HAL_PKT_TYPE_VHT,
  377. HAL_PKT_TYPE_HE,
  378. };
  379. enum {
  380. HAL_SGI_0_8_US,
  381. HAL_SGI_0_4_US,
  382. HAL_SGI_1_6_US,
  383. HAL_SGI_3_2_US,
  384. };
  385. enum {
  386. HAL_FULL_RX_BW_20,
  387. HAL_FULL_RX_BW_40,
  388. HAL_FULL_RX_BW_80,
  389. HAL_FULL_RX_BW_160,
  390. };
  391. enum {
  392. HAL_RX_TYPE_SU,
  393. HAL_RX_TYPE_MU_MIMO,
  394. HAL_RX_TYPE_MU_OFDMA,
  395. HAL_RX_TYPE_MU_OFDMA_MIMO,
  396. };
  397. /**
  398. * enum
  399. * @HAL_RX_MON_PPDU_START: PPDU start TLV is decoded in HAL
  400. * @HAL_RX_MON_PPDU_END: PPDU end TLV is decoded in HAL
  401. * @HAL_RX_MON_PPDU_RESET: Not PPDU start and end TLV
  402. */
  403. enum {
  404. HAL_RX_MON_PPDU_START = 0,
  405. HAL_RX_MON_PPDU_END,
  406. HAL_RX_MON_PPDU_RESET,
  407. };
  408. /* struct hal_rx_ppdu_common_info - common ppdu info
  409. * @ppdu_id - ppdu id number
  410. * @ppdu_timestamp - timestamp at ppdu received
  411. * @mpdu_cnt_fcs_ok - mpdu count in ppdu with fcs ok
  412. * @mpdu_cnt_fcs_err - mpdu count in ppdu with fcs err
  413. * @mpdu_fcs_ok_bitmap - fcs ok mpdu count in ppdu bitmap
  414. * @last_ppdu_id - last received ppdu id
  415. * @mpdu_cnt - total mpdu count
  416. * @num_users - num users
  417. */
  418. struct hal_rx_ppdu_common_info {
  419. uint32_t ppdu_id;
  420. uint32_t ppdu_timestamp;
  421. uint32_t mpdu_cnt_fcs_ok;
  422. uint32_t mpdu_cnt_fcs_err;
  423. uint32_t mpdu_fcs_ok_bitmap[HAL_RX_NUM_WORDS_PER_PPDU_BITMAP];
  424. uint32_t last_ppdu_id;
  425. uint32_t mpdu_cnt;
  426. uint8_t num_users;
  427. };
  428. /**
  429. * struct hal_rx_msdu_payload_info - msdu payload info
  430. * @first_msdu_payload: pointer to first msdu payload
  431. * @payload_len: payload len
  432. */
  433. struct hal_rx_msdu_payload_info {
  434. uint8_t *first_msdu_payload;
  435. uint32_t payload_len;
  436. };
  437. /**
  438. * struct hal_rx_nac_info - struct for neighbour info
  439. * @fc_valid: flag indicate if it has valid frame control information
  440. * @frame_control: frame control from each MPDU
  441. * @to_ds_flag: flag indicate to_ds bit
  442. * @mac_addr2_valid: flag indicate if mac_addr2 is valid
  443. * @mac_addr2: mac address2 in wh
  444. * @mcast_bcast: multicast/broadcast
  445. */
  446. struct hal_rx_nac_info {
  447. uint8_t fc_valid;
  448. uint16_t frame_control;
  449. uint8_t to_ds_flag;
  450. uint8_t mac_addr2_valid;
  451. uint8_t mac_addr2[QDF_MAC_ADDR_SIZE];
  452. uint8_t mcast_bcast;
  453. };
  454. /**
  455. * struct hal_rx_ppdu_msdu_info - struct for msdu info from HW TLVs
  456. * @cce_metadata: cached CCE metadata value received in the MSDU_END TLV
  457. * @is_flow_idx_timeout: flag to indicate if flow search timeout occurred
  458. * @is_flow_idx_invalid: flag to indicate if flow idx is valid or not
  459. * @fse_metadata: cached FSE metadata value received in the MSDU END TLV
  460. * @flow_idx: flow idx matched in FSE received in the MSDU END TLV
  461. */
  462. struct hal_rx_ppdu_msdu_info {
  463. uint16_t cce_metadata;
  464. bool is_flow_idx_timeout;
  465. bool is_flow_idx_invalid;
  466. uint32_t fse_metadata;
  467. uint32_t flow_idx;
  468. };
  469. #if defined(WLAN_CFR_ENABLE) && defined(WLAN_ENH_CFR_ENABLE)
  470. /**
  471. * struct hal_rx_ppdu_cfr_user_info - struct for storing peer info extracted
  472. * from HW TLVs, this will be used for correlating CFR data with multiple peers
  473. * in MU PPDUs
  474. *
  475. * @peer_macaddr: macaddr of the peer
  476. * @ast_index: AST index of the peer
  477. */
  478. struct hal_rx_ppdu_cfr_user_info {
  479. uint8_t peer_macaddr[QDF_MAC_ADDR_SIZE];
  480. uint32_t ast_index;
  481. };
  482. /**
  483. * struct hal_rx_ppdu_cfr_info - struct for storing ppdu info extracted from HW
  484. * TLVs, this will be used for CFR correlation
  485. *
  486. * @bb_captured_channel : Set by RXPCU when MACRX_FREEZE_CAPTURE_CHANNEL TLV is
  487. * sent to PHY, SW checks it to correlate current PPDU TLVs with uploaded
  488. * channel information.
  489. *
  490. * @bb_captured_timeout : Set by RxPCU to indicate channel capture condition is
  491. * met, but MACRX_FREEZE_CAPTURE_CHANNEL is not sent to PHY due to AST delay,
  492. * which means the rx_frame_falling edge to FREEZE TLV ready time exceeds
  493. * the threshold time defined by RXPCU register FREEZE_TLV_DELAY_CNT_THRESH.
  494. * Bb_captured_reason is still valid in this case.
  495. *
  496. * @rx_location_info_valid: Indicates whether CFR DMA address in the PPDU TLV
  497. * is valid
  498. * <enum 0 rx_location_info_is_not_valid>
  499. * <enum 1 rx_location_info_is_valid>
  500. * <legal all>
  501. *
  502. * @bb_captured_reason : Copy capture_reason of MACRX_FREEZE_CAPTURE_CHANNEL
  503. * TLV to here for FW usage. Valid when bb_captured_channel or
  504. * bb_captured_timeout is set.
  505. * <enum 0 freeze_reason_TM>
  506. * <enum 1 freeze_reason_FTM>
  507. * <enum 2 freeze_reason_ACK_resp_to_TM_FTM>
  508. * <enum 3 freeze_reason_TA_RA_TYPE_FILTER>
  509. * <enum 4 freeze_reason_NDPA_NDP>
  510. * <enum 5 freeze_reason_ALL_PACKET>
  511. * <legal 0-5>
  512. *
  513. * @rtt_che_buffer_pointer_low32 : The low 32 bits of the 40 bits pointer to
  514. * external RTT channel information buffer
  515. *
  516. * @rtt_che_buffer_pointer_high8 : The high 8 bits of the 40 bits pointer to
  517. * external RTT channel information buffer
  518. *
  519. * @chan_capture_status : capture status reported by ucode
  520. * a. CAPTURE_IDLE: FW has disabled "REPETITIVE_CHE_CAPTURE_CTRL"
  521. * b. CAPTURE_BUSY: previous PPDU’s channel capture upload DMA ongoing. (Note
  522. * that this upload is triggered after receiving freeze_channel_capture TLV
  523. * after last PPDU is rx)
  524. * c. CAPTURE_ACTIVE: channel capture is enabled and no previous channel
  525. * capture ongoing
  526. * d. CAPTURE_NO_BUFFER: next buffer in IPC ring not available
  527. *
  528. * @cfr_user_info: Peer mac for upto 4 MU users
  529. *
  530. * @rtt_cfo_measurement : raw cfo data extracted from hardware, which is 14 bit
  531. * signed number. The first bit used for sign representation and 13 bits for
  532. * fractional part.
  533. *
  534. * @agc_gain_info0: Chain 0 & chain 1 agc gain information reported by PHY
  535. *
  536. * @agc_gain_info1: Chain 2 & chain 3 agc gain information reported by PHY
  537. *
  538. * @agc_gain_info2: Chain 4 & chain 5 agc gain information reported by PHY
  539. *
  540. * @agc_gain_info3: Chain 6 & chain 7 agc gain information reported by PHY
  541. *
  542. * @rx_start_ts: Rx packet timestamp, the time the first L-STF ADC sample
  543. * arrived at Rx antenna.
  544. *
  545. * @mcs_rate: Indicates the mcs/rate in which packet is received.
  546. * If HT,
  547. * 0-7: MCS0-MCS7
  548. * If VHT,
  549. * 0-9: MCS0 to MCS9
  550. * If HE,
  551. * 0-11: MCS0 to MCS11,
  552. * 12-13: 4096QAM,
  553. * 14-15: reserved
  554. * If Legacy,
  555. * 0: 48 Mbps
  556. * 1: 24 Mbps
  557. * 2: 12 Mbps
  558. * 3: 6 Mbps
  559. * 4: 54 Mbps
  560. * 5: 36 Mbps
  561. * 6: 18 Mbps
  562. * 7: 9 Mbps
  563. *
  564. * @gi_type: Indicates the gaurd interval.
  565. * 0: 0.8 us
  566. * 1: 0.4 us
  567. * 2: 1.6 us
  568. * 3: 3.2 us
  569. */
  570. struct hal_rx_ppdu_cfr_info {
  571. bool bb_captured_channel;
  572. bool bb_captured_timeout;
  573. uint8_t bb_captured_reason;
  574. bool rx_location_info_valid;
  575. uint8_t chan_capture_status;
  576. uint8_t rtt_che_buffer_pointer_high8;
  577. uint32_t rtt_che_buffer_pointer_low32;
  578. struct hal_rx_ppdu_cfr_user_info cfr_user_info[HAL_MAX_UL_MU_USERS];
  579. int16_t rtt_cfo_measurement;
  580. uint32_t agc_gain_info0;
  581. uint32_t agc_gain_info1;
  582. uint32_t agc_gain_info2;
  583. uint32_t agc_gain_info3;
  584. uint32_t rx_start_ts;
  585. uint32_t mcs_rate;
  586. uint32_t gi_type;
  587. };
  588. #else
  589. struct hal_rx_ppdu_cfr_info {};
  590. #endif
  591. struct mon_rx_info {
  592. uint8_t qos_control_info_valid;
  593. uint16_t qos_control;
  594. uint8_t mac_addr1_valid;
  595. uint8_t mac_addr1[QDF_MAC_ADDR_SIZE];
  596. uint32_t user_id;
  597. };
  598. struct mon_rx_user_info {
  599. uint16_t qos_control;
  600. uint8_t qos_control_info_valid;
  601. };
  602. #ifdef QCA_SUPPORT_SCAN_SPCL_VAP_STATS
  603. struct hal_rx_frm_type_info {
  604. uint32_t rx_mgmt_cnt;
  605. uint32_t rx_ctrl_cnt;
  606. uint32_t rx_data_cnt;
  607. };
  608. #else
  609. struct hal_rx_frm_type_info {};
  610. #endif
  611. #define HAL_RX_MON_MAX_AGGR_SIZE 128
  612. /**
  613. * struct hal_rx_tlv_aggr_info - Data structure to hold
  614. * metadata for aggregatng repeated TLVs
  615. * @in_progress: Flag to indicate if TLV aggregation is in progress
  616. * @cur_len: Total length of currently aggregated TLV
  617. * @tlv_tag: TLV tag which is currently being aggregated
  618. * @buf: Buffer containing aggregated TLV data
  619. */
  620. struct hal_rx_tlv_aggr_info {
  621. uint8_t in_progress;
  622. uint16_t cur_len;
  623. uint32_t tlv_tag;
  624. uint8_t buf[HAL_RX_MON_MAX_AGGR_SIZE];
  625. };
  626. struct hal_rx_ppdu_info {
  627. struct hal_rx_ppdu_common_info com_info;
  628. struct mon_rx_status rx_status;
  629. struct mon_rx_user_status rx_user_status[HAL_MAX_UL_MU_USERS];
  630. struct mon_rx_info rx_info;
  631. struct mon_rx_user_info rx_user_info[HAL_MAX_UL_MU_USERS];
  632. struct hal_rx_msdu_payload_info msdu_info;
  633. struct hal_rx_msdu_payload_info fcs_ok_msdu_info;
  634. struct hal_rx_nac_info nac_info;
  635. /* status ring PPDU start and end state */
  636. uint32_t rx_state;
  637. /* MU user id for status ring TLV */
  638. uint32_t user_id;
  639. /* MPDU/MSDU truncated to 128 bytes header start addr in status skb */
  640. unsigned char *data;
  641. /* MPDU/MSDU truncated to 128 bytes header real length */
  642. uint32_t hdr_len;
  643. /* MPDU FCS error */
  644. bool fcs_err;
  645. /* Id to indicate how to process mpdu */
  646. uint8_t sw_frame_group_id;
  647. struct hal_rx_ppdu_msdu_info rx_msdu_info[HAL_MAX_UL_MU_USERS];
  648. /* fcs passed mpdu count in rx monitor status buffer */
  649. uint8_t fcs_ok_cnt;
  650. /* fcs error mpdu count in rx monitor status buffer */
  651. uint8_t fcs_err_cnt;
  652. /* MPDU FCS passed */
  653. bool is_fcs_passed;
  654. /* first msdu payload for all mpdus in rx monitor status buffer */
  655. struct hal_rx_msdu_payload_info ppdu_msdu_info[HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER];
  656. /* evm info */
  657. struct hal_rx_su_evm_info evm_info;
  658. /**
  659. * Will be used to store ppdu info extracted from HW TLVs,
  660. * and for CFR correlation as well
  661. */
  662. struct hal_rx_ppdu_cfr_info cfr_info;
  663. /* per frame type counts */
  664. struct hal_rx_frm_type_info frm_type_info;
  665. /* TLV aggregation metadata context */
  666. struct hal_rx_tlv_aggr_info tlv_aggr;
  667. };
  668. static inline uint32_t
  669. hal_get_rx_status_buf_size(void) {
  670. /* RX status buffer size is hard coded for now */
  671. return 2048;
  672. }
  673. static inline uint8_t*
  674. hal_rx_status_get_next_tlv(uint8_t *rx_tlv, bool is_tlv_hdr_64_bit) {
  675. uint32_t tlv_len, tlv_tag, tlv_hdr_size;
  676. if (is_tlv_hdr_64_bit) {
  677. tlv_len = HAL_RX_GET_USER_TLV32_LEN(rx_tlv);
  678. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(rx_tlv);
  679. tlv_hdr_size = HAL_RX_TLV64_HDR_SIZE;
  680. } else {
  681. tlv_len = HAL_RX_GET_USER_TLV32_LEN(rx_tlv);
  682. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(rx_tlv);
  683. tlv_hdr_size = HAL_RX_TLV32_HDR_SIZE;
  684. }
  685. /* The actual length of PPDU_END is the combined length of many PHY
  686. * TLVs that follow. Skip the TLV header and
  687. * rx_rxpcu_classification_overview that follows the header to get to
  688. * next TLV.
  689. */
  690. if (tlv_tag == WIFIRX_PPDU_END_E)
  691. tlv_len = sizeof(struct rx_rxpcu_classification_overview);
  692. return (uint8_t *)(uintptr_t)qdf_align((uint64_t)((uintptr_t)rx_tlv +
  693. tlv_len +
  694. tlv_hdr_size),
  695. tlv_hdr_size);
  696. }
  697. /**
  698. * hal_rx_proc_phyrx_other_receive_info_tlv()
  699. * - process other receive info TLV
  700. * @rx_tlv_hdr: pointer to TLV header
  701. * @ppdu_info: pointer to ppdu_info
  702. *
  703. * Return: None
  704. */
  705. static inline void hal_rx_proc_phyrx_other_receive_info_tlv(struct hal_soc *hal_soc,
  706. void *rx_tlv_hdr,
  707. struct hal_rx_ppdu_info
  708. *ppdu_info)
  709. {
  710. hal_soc->ops->hal_rx_proc_phyrx_other_receive_info_tlv(rx_tlv_hdr,
  711. (void *)ppdu_info);
  712. }
  713. /**
  714. * hal_rx_status_get_tlv_info() - process receive info TLV
  715. * @rx_tlv_hdr: pointer to TLV header
  716. * @ppdu_info: pointer to ppdu_info
  717. * @hal_soc: HAL soc handle
  718. * @nbuf: PPDU status netowrk buffer
  719. *
  720. * Return: HAL_TLV_STATUS_PPDU_NOT_DONE or HAL_TLV_STATUS_PPDU_DONE from tlv
  721. */
  722. static inline uint32_t
  723. hal_rx_status_get_tlv_info(void *rx_tlv_hdr, void *ppdu_info,
  724. hal_soc_handle_t hal_soc_hdl,
  725. qdf_nbuf_t nbuf)
  726. {
  727. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  728. return hal_soc->ops->hal_rx_status_get_tlv_info(
  729. rx_tlv_hdr,
  730. ppdu_info,
  731. hal_soc_hdl,
  732. nbuf);
  733. }
  734. static inline
  735. uint32_t hal_get_rx_status_done_tlv_size(hal_soc_handle_t hal_soc_hdl)
  736. {
  737. return HAL_RX_TLV32_HDR_SIZE;
  738. }
  739. static inline QDF_STATUS
  740. hal_get_rx_status_done(uint8_t *rx_tlv)
  741. {
  742. uint32_t tlv_tag;
  743. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(rx_tlv);
  744. if (tlv_tag == WIFIRX_STATUS_BUFFER_DONE_E)
  745. return QDF_STATUS_SUCCESS;
  746. else
  747. return QDF_STATUS_E_EMPTY;
  748. }
  749. static inline QDF_STATUS
  750. hal_clear_rx_status_done(uint8_t *rx_tlv)
  751. {
  752. *(uint32_t *)rx_tlv = 0;
  753. return QDF_STATUS_SUCCESS;
  754. }
  755. #endif