hal_api_mon.h 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219
  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. struct hal_mon_usig_cmn {
  612. uint32_t phy_version : 3,
  613. bw : 3,
  614. ul_dl : 1,
  615. bss_color : 6,
  616. txop : 7,
  617. disregard : 5,
  618. validate_0 : 1,
  619. reserved : 6;
  620. };
  621. struct hal_mon_usig_tb {
  622. uint32_t ppdu_type_comp_mode : 2,
  623. validate_1 : 1,
  624. spatial_reuse_1 : 4,
  625. spatial_reuse_2 : 4,
  626. disregard_1 : 5,
  627. crc : 4,
  628. tail : 6,
  629. reserved : 5,
  630. rx_integrity_check_passed : 1;
  631. };
  632. struct hal_mon_usig_mu {
  633. uint32_t ppdu_type_comp_mode : 2,
  634. validate_1 : 1,
  635. punc_ch_info : 5,
  636. validate_2 : 1,
  637. eht_sig_mcs : 2,
  638. num_eht_sig_sym : 5,
  639. crc : 4,
  640. tail : 6,
  641. reserved : 5,
  642. rx_integrity_check_passed : 1;
  643. };
  644. /**
  645. * union hal_mon_usig_non_cmn: Version dependent USIG fields
  646. * @tb: trigger based frame USIG header
  647. * @mu: MU frame USIG header
  648. */
  649. union hal_mon_usig_non_cmn {
  650. struct hal_mon_usig_tb tb;
  651. struct hal_mon_usig_mu mu;
  652. };
  653. /**
  654. * struct hal_mon_usig_hdr: U-SIG header for EHT (and subsequent) frames
  655. * @usig_1: USIG common header fields
  656. * @usig_2: USIG version dependent fields
  657. */
  658. struct hal_mon_usig_hdr {
  659. struct hal_mon_usig_cmn usig_1;
  660. union hal_mon_usig_non_cmn usig_2;
  661. };
  662. #define HAL_RX_MON_USIG_PPDU_TYPE_N_COMP_MODE_MASK 0x0000000300000000
  663. #define HAL_RX_MON_USIG_PPDU_TYPE_N_COMP_MODE_LSB 32
  664. #define HAL_RX_MON_USIG_GET_PPDU_TYPE_N_COMP_MODE(usig_tlv_ptr) \
  665. ((*((uint64_t *)(usig_tlv_ptr)) & \
  666. HAL_RX_MON_USIG_PPDU_TYPE_N_COMP_MODE_MASK) >> \
  667. HAL_RX_MON_USIG_PPDU_TYPE_N_COMP_MODE_LSB)
  668. #define HAL_RX_MON_USIG_RX_INTEGRITY_CHECK_PASSED_MASK 0x8000000000000000
  669. #define HAL_RX_MON_USIG_RX_INTEGRITY_CHECK_PASSED_LSB 63
  670. #define HAL_RX_MON_USIG_GET_RX_INTEGRITY_CHECK_PASSED(usig_tlv_ptr) \
  671. ((*((uint64_t *)(usig_tlv_ptr)) & \
  672. HAL_RX_MON_USIG_RX_INTEGRITY_CHECK_PASSED_MASK) >> \
  673. HAL_RX_MON_USIG_RX_INTEGRITY_CHECK_PASSED_LSB)
  674. /**
  675. * enum hal_eht_bw: Reception bandwidth
  676. * @HAL_EHT_BW_20: 20Mhz
  677. * @HAL_EHT_BW_40: 40Mhz
  678. * @HAL_EHT_BW_80: 80Mhz
  679. * @HAL_EHT_BW_160: 160Mhz
  680. * @HAL_EHT_BW_320_1: 320_1 band
  681. * @HAL_EHT_BW_320_2: 320_2 band
  682. */
  683. enum hal_eht_bw {
  684. HAL_EHT_BW_20 = 0,
  685. HAL_EHT_BW_40,
  686. HAL_EHT_BW_80,
  687. HAL_EHT_BW_160,
  688. HAL_EHT_BW_320_1,
  689. HAL_EHT_BW_320_2,
  690. };
  691. struct hal_eht_sig_mu_mimo_user_info {
  692. uint32_t sta_id : 11,
  693. mcs : 4,
  694. coding : 1,
  695. spatial_coding : 6,
  696. crc : 4;
  697. };
  698. struct hal_eht_sig_non_mu_mimo_user_info {
  699. uint32_t sta_id : 11,
  700. mcs : 4,
  701. validate : 1,
  702. nss : 4,
  703. beamformed : 1,
  704. coding : 1,
  705. crc : 4;
  706. };
  707. /**
  708. * union hal_eht_sig_user_field: User field in EHTSIG
  709. * @mu_mimo_usr: MU-MIMO user field information in EHTSIG
  710. * @non_mu_mimo_usr: Non MU-MIMO user field information in EHTSIG
  711. */
  712. union hal_eht_sig_user_field {
  713. struct hal_eht_sig_mu_mimo_user_info mu_mimo_usr;
  714. struct hal_eht_sig_non_mu_mimo_user_info non_mu_mimo_usr;
  715. };
  716. struct hal_eht_sig_ofdma_cmn_eb1 {
  717. uint64_t spatial_reuse : 4,
  718. gi_ltf : 2,
  719. num_ltf_sym : 3,
  720. ldpc_extra_sym : 1,
  721. pre_fec_pad_factor : 2,
  722. pe_disambiguity : 1,
  723. disregard : 4,
  724. ru_allocation1_1 : 9,
  725. ru_allocation1_2 : 9,
  726. crc : 4;
  727. };
  728. struct hal_eht_sig_ofdma_cmn_eb2 {
  729. uint64_t ru_allocation2_1 : 9,
  730. ru_allocation2_2 : 9,
  731. ru_allocation2_3 : 9,
  732. ru_allocation2_4 : 9,
  733. ru_allocation2_5 : 9,
  734. ru_allocation2_6 : 9,
  735. crc : 4;
  736. };
  737. struct hal_eht_sig_cc_usig_overflow {
  738. uint32_t spatial_reuse : 4,
  739. gi_ltf : 2,
  740. num_ltf_sym : 3,
  741. ldpc_extra_sym : 1,
  742. pre_fec_pad_factor : 2,
  743. pe_disambiguity : 1,
  744. disregard : 4;
  745. };
  746. struct hal_eht_sig_non_ofdma_cmn_eb {
  747. uint32_t spatial_reuse : 4,
  748. gi_ltf : 2,
  749. num_ltf_sym : 3,
  750. ldpc_extra_sym : 1,
  751. pre_fec_pad_factor : 2,
  752. pe_disambiguity : 1,
  753. disregard : 4,
  754. num_users : 3;
  755. union hal_eht_sig_user_field user_field;
  756. };
  757. struct hal_eht_sig_ndp_cmn_eb {
  758. uint32_t spatial_reuse : 4,
  759. gi_ltf : 2,
  760. num_ltf_sym : 3,
  761. nss : 4,
  762. beamformed : 1,
  763. disregard : 2,
  764. crc : 4;
  765. };
  766. /* Different allowed RU in 11BE */
  767. #define HAL_EHT_RU_26 0ULL
  768. #define HAL_EHT_RU_52 1ULL
  769. #define HAL_EHT_RU_78 2ULL
  770. #define HAL_EHT_RU_106 3ULL
  771. #define HAL_EHT_RU_132 4ULL
  772. #define HAL_EHT_RU_242 5ULL
  773. #define HAL_EHT_RU_484 6ULL
  774. #define HAL_EHT_RU_726 7ULL
  775. #define HAL_EHT_RU_996 8ULL
  776. #define HAL_EHT_RU_996x2 9ULL
  777. #define HAL_EHT_RU_996x3 10ULL
  778. #define HAL_EHT_RU_996x4 11ULL
  779. #define HAL_EHT_RU_NONE 15ULL
  780. #define HAL_EHT_RU_INVALID 31ULL
  781. /*
  782. * MRUs spanning above 80Mhz
  783. * HAL_EHT_RU_996_484 = HAL_EHT_RU_484 + HAL_EHT_RU_996 + 4 (reserved)
  784. */
  785. #define HAL_EHT_RU_996_484 18ULL
  786. #define HAL_EHT_RU_996x2_484 28ULL
  787. #define HAL_EHT_RU_996x3_484 40ULL
  788. #define HAL_EHT_RU_996_484_242 23ULL
  789. /**
  790. * enum ieee80211_eht_ru_size: RU type id in EHTSIG radiotap header
  791. * @IEEE80211_EHT_RU_26: RU26
  792. * @IEEE80211_EHT_RU_52: RU52
  793. * @IEEE80211_EHT_RU_106: RU106
  794. * @IEEE80211_EHT_RU_242: RU242
  795. * @IEEE80211_EHT_RU_484: RU484
  796. * @IEEE80211_EHT_RU_996: RU996
  797. * @IEEE80211_EHT_RU_996x2: RU996x2
  798. * @IEEE80211_EHT_RU_996x4: RU996x4
  799. * @IEEE80211_EHT_RU_52_26: RU52+RU26
  800. * @IEEE80211_EHT_RU_106_26: RU106+RU26
  801. * @IEEE80211_EHT_RU_484_242: RU484+RU242
  802. * @IEEE80211_EHT_RU_996_484: RU996+RU484
  803. * @IEEE80211_EHT_RU_996_484_242: RU996+RU484+RU242
  804. * @IEEE80211_EHT_RU_996x2_484: RU996x2 + RU484
  805. * @IEEE80211_EHT_RU_996x3: RU996x3
  806. * @IEEE80211_EHT_RU_996x3_484: RU996x3 + RU484
  807. * @IEEE80211_EHT_RU_INVALID: Invalid/Max RU
  808. */
  809. enum ieee80211_eht_ru_size {
  810. IEEE80211_EHT_RU_26,
  811. IEEE80211_EHT_RU_52,
  812. IEEE80211_EHT_RU_106,
  813. IEEE80211_EHT_RU_242,
  814. IEEE80211_EHT_RU_484,
  815. IEEE80211_EHT_RU_996,
  816. IEEE80211_EHT_RU_996x2,
  817. IEEE80211_EHT_RU_996x4,
  818. IEEE80211_EHT_RU_52_26,
  819. IEEE80211_EHT_RU_106_26,
  820. IEEE80211_EHT_RU_484_242,
  821. IEEE80211_EHT_RU_996_484,
  822. IEEE80211_EHT_RU_996_484_242,
  823. IEEE80211_EHT_RU_996x2_484,
  824. IEEE80211_EHT_RU_996x3,
  825. IEEE80211_EHT_RU_996x3_484,
  826. IEEE80211_EHT_RU_INVALID,
  827. };
  828. #define NUM_RU_BITS_PER80 16
  829. #define NUM_RU_BITS_PER20 4
  830. /* Different per_80Mhz band in 320Mhz bandwidth */
  831. #define HAL_80_0 0
  832. #define HAL_80_1 1
  833. #define HAL_80_2 2
  834. #define HAL_80_3 3
  835. #define HAL_RU_SHIFT(num_80mhz_band, ru_index_per_80) \
  836. ((NUM_RU_BITS_PER80 * (num_80mhz_band)) + \
  837. (NUM_RU_BITS_PER20 * (ru_index_per_80)))
  838. /* MRU-996+484 */
  839. #define HAL_EHT_RU_996_484_0 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_0, 1)) | \
  840. (HAL_EHT_RU_996 << HAL_RU_SHIFT(HAL_80_1, 0)))
  841. #define HAL_EHT_RU_996_484_1 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  842. (HAL_EHT_RU_996 << HAL_RU_SHIFT(HAL_80_1, 0)))
  843. #define HAL_EHT_RU_996_484_2 ((HAL_EHT_RU_996 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  844. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_1, 1)))
  845. #define HAL_EHT_RU_996_484_3 ((HAL_EHT_RU_996 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  846. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_1, 0)))
  847. #define HAL_EHT_RU_996_484_4 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_2, 1)) | \
  848. (HAL_EHT_RU_996 << HAL_RU_SHIFT(HAL_80_3, 0)))
  849. #define HAL_EHT_RU_996_484_5 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  850. (HAL_EHT_RU_996 << HAL_RU_SHIFT(HAL_80_3, 0)))
  851. #define HAL_EHT_RU_996_484_6 ((HAL_EHT_RU_996 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  852. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_3, 1)))
  853. #define HAL_EHT_RU_996_484_7 ((HAL_EHT_RU_996 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  854. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_3, 0)))
  855. /* MRU-996x2+484 */
  856. #define HAL_EHT_RU_996x2_484_0 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_0, 1)) | \
  857. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  858. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_2, 0)))
  859. #define HAL_EHT_RU_996x2_484_1 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  860. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  861. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_2, 0)))
  862. #define HAL_EHT_RU_996x2_484_2 ((HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  863. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_1, 1)) | \
  864. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_2, 0)))
  865. #define HAL_EHT_RU_996x2_484_3 ((HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  866. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  867. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_2, 0)))
  868. #define HAL_EHT_RU_996x2_484_4 ((HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  869. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  870. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_2, 1)))
  871. #define HAL_EHT_RU_996x2_484_5 ((HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  872. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  873. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_2, 0)))
  874. #define HAL_EHT_RU_996x2_484_6 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_1, 1)) | \
  875. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  876. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_3, 0)))
  877. #define HAL_EHT_RU_996x2_484_7 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  878. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  879. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_3, 0)))
  880. #define HAL_EHT_RU_996x2_484_8 ((HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  881. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_2, 1)) | \
  882. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_3, 0)))
  883. #define HAL_EHT_RU_996x2_484_9 ((HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  884. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  885. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_3, 0)))
  886. #define HAL_EHT_RU_996x2_484_10 ((HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  887. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  888. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_3, 1)))
  889. #define HAL_EHT_RU_996x2_484_11 ((HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  890. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  891. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_3, 0)))
  892. /* MRU-996x3+484 */
  893. #define HAL_EHT_RU_996x3_484_0 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_0, 1)) | \
  894. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  895. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  896. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_3, 0)))
  897. #define HAL_EHT_RU_996x3_484_1 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  898. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  899. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  900. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_3, 0)))
  901. #define HAL_EHT_RU_996x3_484_2 ((HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  902. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_1, 1)) | \
  903. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  904. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_3, 0)))
  905. #define HAL_EHT_RU_996x3_484_3 ((HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  906. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  907. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  908. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_3, 0)))
  909. #define HAL_EHT_RU_996x3_484_4 ((HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  910. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  911. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_2, 1)) | \
  912. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_3, 0)))
  913. #define HAL_EHT_RU_996x3_484_5 ((HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  914. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  915. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  916. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_3, 0)))
  917. #define HAL_EHT_RU_996x3_484_6 ((HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  918. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  919. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  920. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_3, 1)))
  921. #define HAL_EHT_RU_996x3_484_7 ((HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  922. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  923. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  924. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_3, 0)))
  925. /* EHT Reception Type */
  926. #define HAL_RX_TYPE_MU_MIMO 1
  927. #define HAL_RX_TYPE_MU_OFDMA 2
  928. #define HAL_RX_TYPE_MU_OFMDA_MIMO 3
  929. #define HAL_RX_MON_MAX_AGGR_SIZE 128
  930. /**
  931. * struct hal_rx_tlv_aggr_info - Data structure to hold
  932. * metadata for aggregatng repeated TLVs
  933. * @in_progress: Flag to indicate if TLV aggregation is in progress
  934. * @cur_len: Total length of currently aggregated TLV
  935. * @tlv_tag: TLV tag which is currently being aggregated
  936. * @buf: Buffer containing aggregated TLV data
  937. */
  938. struct hal_rx_tlv_aggr_info {
  939. uint8_t in_progress;
  940. uint16_t cur_len;
  941. uint32_t tlv_tag;
  942. uint8_t buf[HAL_RX_MON_MAX_AGGR_SIZE];
  943. };
  944. /* struct hal_rx_u_sig_info - Certain fields from U-SIG header which are used
  945. * for other header field parsing.
  946. * @ul_dl: UL or DL
  947. * @bw: EHT BW
  948. * @ppdu_type_comp_mode: PPDU TYPE
  949. * @eht_sig_mcs: EHT SIG MCS
  950. * @num_eht_sig_sym: Number of EHT SIG symbols
  951. */
  952. struct hal_rx_u_sig_info {
  953. uint32_t ul_dl : 1,
  954. bw : 3,
  955. ppdu_type_comp_mode : 2,
  956. eht_sig_mcs : 2,
  957. num_eht_sig_sym : 5;
  958. };
  959. struct hal_rx_ppdu_info {
  960. struct hal_rx_ppdu_common_info com_info;
  961. struct hal_rx_u_sig_info u_sig_info;
  962. struct mon_rx_status rx_status;
  963. struct mon_rx_user_status rx_user_status[HAL_MAX_UL_MU_USERS];
  964. struct mon_rx_info rx_info;
  965. struct mon_rx_user_info rx_user_info[HAL_MAX_UL_MU_USERS];
  966. struct hal_rx_msdu_payload_info msdu_info;
  967. struct hal_rx_msdu_payload_info fcs_ok_msdu_info;
  968. struct hal_rx_nac_info nac_info;
  969. /* status ring PPDU start and end state */
  970. uint32_t rx_state;
  971. /* MU user id for status ring TLV */
  972. uint32_t user_id;
  973. /* MPDU/MSDU truncated to 128 bytes header start addr in status skb */
  974. unsigned char *data;
  975. /* MPDU/MSDU truncated to 128 bytes header real length */
  976. uint32_t hdr_len;
  977. /* MPDU FCS error */
  978. bool fcs_err;
  979. /* Id to indicate how to process mpdu */
  980. uint8_t sw_frame_group_id;
  981. struct hal_rx_ppdu_msdu_info rx_msdu_info[HAL_MAX_UL_MU_USERS];
  982. /* fcs passed mpdu count in rx monitor status buffer */
  983. uint8_t fcs_ok_cnt;
  984. /* fcs error mpdu count in rx monitor status buffer */
  985. uint8_t fcs_err_cnt;
  986. /* MPDU FCS passed */
  987. bool is_fcs_passed;
  988. /* first msdu payload for all mpdus in rx monitor status buffer */
  989. struct hal_rx_msdu_payload_info ppdu_msdu_info[HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER];
  990. /* evm info */
  991. struct hal_rx_su_evm_info evm_info;
  992. /**
  993. * Will be used to store ppdu info extracted from HW TLVs,
  994. * and for CFR correlation as well
  995. */
  996. struct hal_rx_ppdu_cfr_info cfr_info;
  997. /* per frame type counts */
  998. struct hal_rx_frm_type_info frm_type_info;
  999. /* TLV aggregation metadata context */
  1000. struct hal_rx_tlv_aggr_info tlv_aggr;
  1001. /* EHT SIG user info */
  1002. uint32_t eht_sig_user_info;
  1003. };
  1004. static inline uint32_t
  1005. hal_get_rx_status_buf_size(void) {
  1006. /* RX status buffer size is hard coded for now */
  1007. return 2048;
  1008. }
  1009. static inline uint8_t*
  1010. hal_rx_status_get_next_tlv(uint8_t *rx_tlv, bool is_tlv_hdr_64_bit) {
  1011. uint32_t tlv_len, tlv_tag, tlv_hdr_size;
  1012. if (is_tlv_hdr_64_bit) {
  1013. tlv_len = HAL_RX_GET_USER_TLV32_LEN(rx_tlv);
  1014. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(rx_tlv);
  1015. tlv_hdr_size = HAL_RX_TLV64_HDR_SIZE;
  1016. } else {
  1017. tlv_len = HAL_RX_GET_USER_TLV32_LEN(rx_tlv);
  1018. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(rx_tlv);
  1019. tlv_hdr_size = HAL_RX_TLV32_HDR_SIZE;
  1020. }
  1021. /* The actual length of PPDU_END is the combined length of many PHY
  1022. * TLVs that follow. Skip the TLV header and
  1023. * rx_rxpcu_classification_overview that follows the header to get to
  1024. * next TLV.
  1025. */
  1026. if (tlv_tag == WIFIRX_PPDU_END_E)
  1027. tlv_len = sizeof(struct rx_rxpcu_classification_overview);
  1028. return (uint8_t *)(uintptr_t)qdf_align((uint64_t)((uintptr_t)rx_tlv +
  1029. tlv_len +
  1030. tlv_hdr_size),
  1031. tlv_hdr_size);
  1032. }
  1033. /**
  1034. * hal_rx_proc_phyrx_other_receive_info_tlv()
  1035. * - process other receive info TLV
  1036. * @rx_tlv_hdr: pointer to TLV header
  1037. * @ppdu_info: pointer to ppdu_info
  1038. *
  1039. * Return: None
  1040. */
  1041. static inline void hal_rx_proc_phyrx_other_receive_info_tlv(struct hal_soc *hal_soc,
  1042. void *rx_tlv_hdr,
  1043. struct hal_rx_ppdu_info
  1044. *ppdu_info)
  1045. {
  1046. hal_soc->ops->hal_rx_proc_phyrx_other_receive_info_tlv(rx_tlv_hdr,
  1047. (void *)ppdu_info);
  1048. }
  1049. /**
  1050. * hal_rx_status_get_tlv_info() - process receive info TLV
  1051. * @rx_tlv_hdr: pointer to TLV header
  1052. * @ppdu_info: pointer to ppdu_info
  1053. * @hal_soc: HAL soc handle
  1054. * @nbuf: PPDU status netowrk buffer
  1055. *
  1056. * Return: HAL_TLV_STATUS_PPDU_NOT_DONE or HAL_TLV_STATUS_PPDU_DONE from tlv
  1057. */
  1058. static inline uint32_t
  1059. hal_rx_status_get_tlv_info(void *rx_tlv_hdr, void *ppdu_info,
  1060. hal_soc_handle_t hal_soc_hdl,
  1061. qdf_nbuf_t nbuf)
  1062. {
  1063. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1064. return hal_soc->ops->hal_rx_status_get_tlv_info(
  1065. rx_tlv_hdr,
  1066. ppdu_info,
  1067. hal_soc_hdl,
  1068. nbuf);
  1069. }
  1070. static inline
  1071. uint32_t hal_get_rx_status_done_tlv_size(hal_soc_handle_t hal_soc_hdl)
  1072. {
  1073. return HAL_RX_TLV32_HDR_SIZE;
  1074. }
  1075. static inline QDF_STATUS
  1076. hal_get_rx_status_done(uint8_t *rx_tlv)
  1077. {
  1078. uint32_t tlv_tag;
  1079. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(rx_tlv);
  1080. if (tlv_tag == WIFIRX_STATUS_BUFFER_DONE_E)
  1081. return QDF_STATUS_SUCCESS;
  1082. else
  1083. return QDF_STATUS_E_EMPTY;
  1084. }
  1085. static inline QDF_STATUS
  1086. hal_clear_rx_status_done(uint8_t *rx_tlv)
  1087. {
  1088. *(uint32_t *)rx_tlv = 0;
  1089. return QDF_STATUS_SUCCESS;
  1090. }
  1091. #endif