hal_api_mon.h 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232
  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. #ifdef WLAN_FEATURE_11BE
  73. #define HAL_RX_PKT_TYPE_11BE 6
  74. #endif
  75. #define HAL_RX_RECEPTION_TYPE_SU 0
  76. #define HAL_RX_RECEPTION_TYPE_MU_MIMO 1
  77. #define HAL_RX_RECEPTION_TYPE_OFDMA 2
  78. #define HAL_RX_RECEPTION_TYPE_MU_OFDMA 3
  79. /* Multiply rate by 2 to avoid float point
  80. * and get rate in units of 500kbps
  81. */
  82. #define HAL_11B_RATE_0MCS 11*2
  83. #define HAL_11B_RATE_1MCS 5.5*2
  84. #define HAL_11B_RATE_2MCS 2*2
  85. #define HAL_11B_RATE_3MCS 1*2
  86. #define HAL_11B_RATE_4MCS 11*2
  87. #define HAL_11B_RATE_5MCS 5.5*2
  88. #define HAL_11B_RATE_6MCS 2*2
  89. #define HAL_11A_RATE_0MCS 48*2
  90. #define HAL_11A_RATE_1MCS 24*2
  91. #define HAL_11A_RATE_2MCS 12*2
  92. #define HAL_11A_RATE_3MCS 6*2
  93. #define HAL_11A_RATE_4MCS 54*2
  94. #define HAL_11A_RATE_5MCS 36*2
  95. #define HAL_11A_RATE_6MCS 18*2
  96. #define HAL_11A_RATE_7MCS 9*2
  97. #define HAL_LEGACY_MCS0 0
  98. #define HAL_LEGACY_MCS1 1
  99. #define HAL_LEGACY_MCS2 2
  100. #define HAL_LEGACY_MCS3 3
  101. #define HAL_LEGACY_MCS4 4
  102. #define HAL_LEGACY_MCS5 5
  103. #define HAL_LEGACY_MCS6 6
  104. #define HAL_LEGACY_MCS7 7
  105. #define HE_GI_0_8 0
  106. #define HE_GI_0_4 1
  107. #define HE_GI_1_6 2
  108. #define HE_GI_3_2 3
  109. #define HE_GI_RADIOTAP_0_8 0
  110. #define HE_GI_RADIOTAP_1_6 1
  111. #define HE_GI_RADIOTAP_3_2 2
  112. #define HE_GI_RADIOTAP_RESERVED 3
  113. #define HE_LTF_RADIOTAP_UNKNOWN 0
  114. #define HE_LTF_RADIOTAP_1_X 1
  115. #define HE_LTF_RADIOTAP_2_X 2
  116. #define HE_LTF_RADIOTAP_4_X 3
  117. #define HT_SGI_PRESENT 0x80
  118. #define HE_LTF_1_X 0
  119. #define HE_LTF_2_X 1
  120. #define HE_LTF_4_X 2
  121. #define HE_LTF_UNKNOWN 3
  122. #define VHT_SIG_SU_NSS_MASK 0x7
  123. #define HT_SIG_SU_NSS_SHIFT 0x3
  124. #define HAL_TID_INVALID 31
  125. #define HAL_AST_IDX_INVALID 0xFFFF
  126. #ifdef GET_MSDU_AGGREGATION
  127. #define HAL_RX_GET_MSDU_AGGREGATION(rx_desc, rs)\
  128. {\
  129. struct rx_msdu_end *rx_msdu_end;\
  130. bool first_msdu, last_msdu; \
  131. rx_msdu_end = &rx_desc->msdu_end_tlv.rx_msdu_end;\
  132. first_msdu = HAL_RX_GET(rx_msdu_end, RX_MSDU_END_5, FIRST_MSDU);\
  133. last_msdu = HAL_RX_GET(rx_msdu_end, RX_MSDU_END_5, LAST_MSDU);\
  134. if (first_msdu && last_msdu)\
  135. rs->rs_flags &= (~IEEE80211_AMSDU_FLAG);\
  136. else\
  137. rs->rs_flags |= (IEEE80211_AMSDU_FLAG); \
  138. } \
  139. #define HAL_RX_SET_MSDU_AGGREGATION((rs_mpdu), (rs_ppdu))\
  140. {\
  141. if (rs_mpdu->rs_flags & IEEE80211_AMSDU_FLAG)\
  142. rs_ppdu->rs_flags |= IEEE80211_AMSDU_FLAG;\
  143. } \
  144. #else
  145. #define HAL_RX_GET_MSDU_AGGREGATION(rx_desc, rs)
  146. #define HAL_RX_SET_MSDU_AGGREGATION(rs_mpdu, rs_ppdu)
  147. #endif
  148. /* Max MPDUs per status buffer */
  149. #define HAL_RX_MAX_MPDU 256
  150. #define HAL_RX_NUM_WORDS_PER_PPDU_BITMAP (HAL_RX_MAX_MPDU >> 5)
  151. #define HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER 16
  152. /* Max pilot count */
  153. #define HAL_RX_MAX_SU_EVM_COUNT 32
  154. #define HAL_RX_FRAMECTRL_TYPE_MASK 0x0C
  155. #define HAL_RX_GET_FRAME_CTRL_TYPE(fc)\
  156. (((fc) & HAL_RX_FRAMECTRL_TYPE_MASK) >> 2)
  157. #define HAL_RX_FRAME_CTRL_TYPE_MGMT 0x0
  158. #define HAL_RX_FRAME_CTRL_TYPE_CTRL 0x1
  159. #define HAL_RX_FRAME_CTRL_TYPE_DATA 0x2
  160. /**
  161. * struct hal_rx_mon_desc_info () - HAL Rx Monitor descriptor info
  162. *
  163. * @ppdu_id: PHY ppdu id
  164. * @status_ppdu_id: status PHY ppdu id
  165. * @status_buf_count: number of status buffer count
  166. * @rxdma_push_reason: rxdma push reason
  167. * @rxdma_error_code: rxdma error code
  168. * @msdu_cnt: msdu count
  169. * @end_of_ppdu: end of ppdu
  170. * @link_desc: msdu link descriptor address
  171. * @status_buf: for a PPDU, status buffers can span acrosss
  172. * multiple buffers, status_buf points to first
  173. * status buffer address of PPDU
  174. * @drop_ppdu: flag to indicate current destination
  175. * ring ppdu drop
  176. */
  177. struct hal_rx_mon_desc_info {
  178. uint16_t ppdu_id;
  179. uint16_t status_ppdu_id;
  180. uint8_t status_buf_count;
  181. uint8_t rxdma_push_reason;
  182. uint8_t rxdma_error_code;
  183. uint8_t msdu_count;
  184. uint8_t end_of_ppdu;
  185. struct hal_buf_info link_desc;
  186. struct hal_buf_info status_buf;
  187. bool drop_ppdu;
  188. };
  189. /*
  190. * Struct hal_rx_su_evm_info - SU evm info
  191. * @number_of_symbols: number of symbols
  192. * @nss_count: nss count
  193. * @pilot_count: pilot count
  194. * @pilot_evm: Array of pilot evm values
  195. */
  196. struct hal_rx_su_evm_info {
  197. uint32_t number_of_symbols;
  198. uint8_t nss_count;
  199. uint8_t pilot_count;
  200. uint32_t pilot_evm[HAL_RX_MAX_SU_EVM_COUNT];
  201. };
  202. enum {
  203. DP_PPDU_STATUS_START,
  204. DP_PPDU_STATUS_DONE,
  205. };
  206. /**
  207. * hal_rx_reo_ent_buf_paddr_get: Gets the physical address and
  208. * cookie from the REO entrance ring element
  209. * @hal_rx_desc_cookie: Opaque cookie pointer used by HAL to get to
  210. * the current descriptor
  211. * @ buf_info: structure to return the buffer information
  212. * @ msdu_cnt: pointer to msdu count in MPDU
  213. *
  214. * CAUTION: This API calls a hal_soc ops, so be careful before calling this in
  215. * per packet path
  216. *
  217. * Return: void
  218. */
  219. static inline
  220. void hal_rx_reo_ent_buf_paddr_get(hal_soc_handle_t hal_soc_hdl,
  221. hal_rxdma_desc_t rx_desc,
  222. struct hal_buf_info *buf_info,
  223. uint32_t *msdu_cnt)
  224. {
  225. struct reo_entrance_ring *reo_ent_ring =
  226. (struct reo_entrance_ring *)rx_desc;
  227. struct buffer_addr_info *buf_addr_info;
  228. struct rx_mpdu_desc_info *rx_mpdu_desc_info_details;
  229. uint32_t loop_cnt;
  230. rx_mpdu_desc_info_details =
  231. &reo_ent_ring->reo_level_mpdu_frame_info.rx_mpdu_desc_info_details;
  232. *msdu_cnt = HAL_RX_GET(rx_mpdu_desc_info_details,
  233. HAL_RX_MPDU_DESC_INFO, MSDU_COUNT);
  234. loop_cnt = HAL_RX_GET(reo_ent_ring, HAL_REO_ENTRANCE_RING,
  235. LOOPING_COUNT);
  236. buf_addr_info =
  237. &reo_ent_ring->reo_level_mpdu_frame_info.msdu_link_desc_addr_info;
  238. hal_rx_buf_cookie_rbm_get(hal_soc_hdl, (uint32_t *)buf_addr_info,
  239. buf_info);
  240. buf_info->paddr =
  241. (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) |
  242. ((uint64_t)
  243. (HAL_RX_BUFFER_ADDR_39_32_GET(buf_addr_info)) << 32));
  244. dp_nofl_debug("[%s][%d] ReoAddr=%pK, addrInfo=%pK, paddr=0x%llx, loopcnt=%d",
  245. __func__, __LINE__, reo_ent_ring, buf_addr_info,
  246. (unsigned long long)buf_info->paddr, loop_cnt);
  247. }
  248. static inline
  249. void hal_rx_mon_next_link_desc_get(hal_soc_handle_t hal_soc_hdl,
  250. void *rx_msdu_link_desc,
  251. struct hal_buf_info *buf_info)
  252. {
  253. struct rx_msdu_link *msdu_link =
  254. (struct rx_msdu_link *)rx_msdu_link_desc;
  255. struct buffer_addr_info *buf_addr_info;
  256. buf_addr_info = &msdu_link->next_msdu_link_desc_addr_info;
  257. hal_rx_buf_cookie_rbm_get(hal_soc_hdl, (uint32_t *)buf_addr_info,
  258. buf_info);
  259. buf_info->paddr =
  260. (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) |
  261. ((uint64_t)
  262. (HAL_RX_BUFFER_ADDR_39_32_GET(buf_addr_info)) << 32));
  263. }
  264. static inline
  265. uint8_t *HAL_RX_MON_DEST_GET_DESC(uint8_t *data)
  266. {
  267. return data;
  268. }
  269. static inline uint32_t
  270. hal_rx_tlv_mpdu_len_err_get(hal_soc_handle_t hal_soc_hdl, void *hw_desc_addr)
  271. {
  272. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  273. if (!hal_soc || !hal_soc->ops) {
  274. hal_err("hal handle is NULL");
  275. QDF_BUG(0);
  276. return 0;
  277. }
  278. if (hal_soc->ops->hal_rx_tlv_mpdu_len_err_get)
  279. return hal_soc->ops->hal_rx_tlv_mpdu_len_err_get(hw_desc_addr);
  280. return 0;
  281. }
  282. static inline uint32_t
  283. hal_rx_tlv_mpdu_fcs_err_get(hal_soc_handle_t hal_soc_hdl, void *hw_desc_addr)
  284. {
  285. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  286. if (!hal_soc || !hal_soc->ops) {
  287. hal_err("hal handle is NULL");
  288. QDF_BUG(0);
  289. return 0;
  290. }
  291. if (hal_soc->ops->hal_rx_tlv_mpdu_fcs_err_get)
  292. return hal_soc->ops->hal_rx_tlv_mpdu_fcs_err_get(hw_desc_addr);
  293. return 0;
  294. }
  295. #ifdef notyet
  296. /*
  297. * HAL_RX_HW_DESC_MPDU_VALID() - check MPDU start TLV tag in MPDU
  298. * start TLV of Hardware TLV descriptor
  299. * @hw_desc_addr: Hardware descriptor address
  300. *
  301. * Return: bool: if TLV tag match
  302. */
  303. static inline
  304. bool HAL_RX_HW_DESC_MPDU_VALID(void *hw_desc_addr)
  305. {
  306. struct rx_mon_pkt_tlvs *rx_desc =
  307. (struct rx_mon_pkt_tlvs *)hw_desc_addr;
  308. uint32_t tlv_tag;
  309. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(&rx_desc->mpdu_start_tlv);
  310. return tlv_tag == WIFIRX_MPDU_START_E ? true : false;
  311. }
  312. #endif
  313. /*
  314. * HAL_RX_HW_DESC_MPDU_VALID() - check MPDU start TLV user id in MPDU
  315. * start TLV of Hardware TLV descriptor
  316. * @hw_desc_addr: Hardware descriptor address
  317. *
  318. * Return: unit32_t: user id
  319. */
  320. static inline uint32_t
  321. hal_rx_hw_desc_mpdu_user_id(hal_soc_handle_t hal_soc_hdl,
  322. void *hw_desc_addr)
  323. {
  324. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  325. if (!hal_soc || !hal_soc->ops) {
  326. hal_err("hal handle is NULL");
  327. QDF_BUG(0);
  328. return 0;
  329. }
  330. if (hal_soc->ops->hal_rx_hw_desc_mpdu_user_id)
  331. return hal_soc->ops->hal_rx_hw_desc_mpdu_user_id(hw_desc_addr);
  332. return 0;
  333. }
  334. /* TODO: Move all Rx descriptor functions to hal_rx.h to avoid duplication */
  335. /**
  336. * hal_rx_msdu_link_desc_set: Retrieves MSDU Link Descriptor to WBM
  337. *
  338. * @ soc : HAL version of the SOC pointer
  339. * @ src_srng_desc : void pointer to the WBM Release Ring descriptor
  340. * @ buf_addr_info : void pointer to the buffer_addr_info
  341. *
  342. * Return: void
  343. */
  344. static inline
  345. void hal_rx_mon_msdu_link_desc_set(hal_soc_handle_t hal_soc_hdl,
  346. void *src_srng_desc,
  347. hal_buff_addrinfo_t buf_addr_info)
  348. {
  349. struct buffer_addr_info *wbm_srng_buffer_addr_info =
  350. (struct buffer_addr_info *)src_srng_desc;
  351. uint64_t paddr;
  352. struct buffer_addr_info *p_buffer_addr_info =
  353. (struct buffer_addr_info *)buf_addr_info;
  354. paddr =
  355. (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) |
  356. ((uint64_t)
  357. (HAL_RX_BUFFER_ADDR_39_32_GET(buf_addr_info)) << 32));
  358. dp_nofl_debug("[%s][%d] src_srng_desc=%pK, buf_addr=0x%llx, cookie=0x%llx",
  359. __func__, __LINE__, src_srng_desc, (unsigned long long)paddr,
  360. (unsigned long long)p_buffer_addr_info->sw_buffer_cookie);
  361. /* Structure copy !!! */
  362. *wbm_srng_buffer_addr_info =
  363. *((struct buffer_addr_info *)buf_addr_info);
  364. }
  365. /**
  366. * hal_get_rx_msdu_link_desc_size() - Get msdu link descriptor size
  367. *
  368. * Return: size of rx_msdu_link
  369. */
  370. static inline
  371. uint32_t hal_get_rx_msdu_link_desc_size(void)
  372. {
  373. return sizeof(struct rx_msdu_link);
  374. }
  375. enum {
  376. HAL_PKT_TYPE_OFDM = 0,
  377. HAL_PKT_TYPE_CCK,
  378. HAL_PKT_TYPE_HT,
  379. HAL_PKT_TYPE_VHT,
  380. HAL_PKT_TYPE_HE,
  381. };
  382. enum {
  383. HAL_SGI_0_8_US,
  384. HAL_SGI_0_4_US,
  385. HAL_SGI_1_6_US,
  386. HAL_SGI_3_2_US,
  387. };
  388. #ifdef WLAN_FEATURE_11BE
  389. enum {
  390. HAL_FULL_RX_BW_20,
  391. HAL_FULL_RX_BW_40,
  392. HAL_FULL_RX_BW_80,
  393. HAL_FULL_RX_BW_160,
  394. HAL_FULL_RX_BW_320,
  395. };
  396. #else
  397. enum {
  398. HAL_FULL_RX_BW_20,
  399. HAL_FULL_RX_BW_40,
  400. HAL_FULL_RX_BW_80,
  401. HAL_FULL_RX_BW_160,
  402. };
  403. #endif
  404. enum {
  405. HAL_RX_TYPE_SU,
  406. HAL_RX_TYPE_MU_MIMO,
  407. HAL_RX_TYPE_MU_OFDMA,
  408. HAL_RX_TYPE_MU_OFDMA_MIMO,
  409. };
  410. /**
  411. * enum
  412. * @HAL_RX_MON_PPDU_START: PPDU start TLV is decoded in HAL
  413. * @HAL_RX_MON_PPDU_END: PPDU end TLV is decoded in HAL
  414. * @HAL_RX_MON_PPDU_RESET: Not PPDU start and end TLV
  415. */
  416. enum {
  417. HAL_RX_MON_PPDU_START = 0,
  418. HAL_RX_MON_PPDU_END,
  419. HAL_RX_MON_PPDU_RESET,
  420. };
  421. /* struct hal_rx_ppdu_common_info - common ppdu info
  422. * @ppdu_id - ppdu id number
  423. * @ppdu_timestamp - timestamp at ppdu received
  424. * @mpdu_cnt_fcs_ok - mpdu count in ppdu with fcs ok
  425. * @mpdu_cnt_fcs_err - mpdu count in ppdu with fcs err
  426. * @mpdu_fcs_ok_bitmap - fcs ok mpdu count in ppdu bitmap
  427. * @last_ppdu_id - last received ppdu id
  428. * @mpdu_cnt - total mpdu count
  429. * @num_users - num users
  430. */
  431. struct hal_rx_ppdu_common_info {
  432. uint32_t ppdu_id;
  433. uint32_t ppdu_timestamp;
  434. uint32_t mpdu_cnt_fcs_ok;
  435. uint32_t mpdu_cnt_fcs_err;
  436. uint32_t mpdu_fcs_ok_bitmap[HAL_RX_NUM_WORDS_PER_PPDU_BITMAP];
  437. uint32_t last_ppdu_id;
  438. uint32_t mpdu_cnt;
  439. uint8_t num_users;
  440. };
  441. /**
  442. * struct hal_rx_msdu_payload_info - msdu payload info
  443. * @first_msdu_payload: pointer to first msdu payload
  444. * @payload_len: payload len
  445. */
  446. struct hal_rx_msdu_payload_info {
  447. uint8_t *first_msdu_payload;
  448. uint32_t payload_len;
  449. };
  450. /**
  451. * struct hal_rx_nac_info - struct for neighbour info
  452. * @fc_valid: flag indicate if it has valid frame control information
  453. * @frame_control: frame control from each MPDU
  454. * @to_ds_flag: flag indicate to_ds bit
  455. * @mac_addr2_valid: flag indicate if mac_addr2 is valid
  456. * @mac_addr2: mac address2 in wh
  457. * @mcast_bcast: multicast/broadcast
  458. */
  459. struct hal_rx_nac_info {
  460. uint8_t fc_valid;
  461. uint16_t frame_control;
  462. uint8_t to_ds_flag;
  463. uint8_t mac_addr2_valid;
  464. uint8_t mac_addr2[QDF_MAC_ADDR_SIZE];
  465. uint8_t mcast_bcast;
  466. };
  467. /**
  468. * struct hal_rx_ppdu_msdu_info - struct for msdu info from HW TLVs
  469. * @cce_metadata: cached CCE metadata value received in the MSDU_END TLV
  470. * @is_flow_idx_timeout: flag to indicate if flow search timeout occurred
  471. * @is_flow_idx_invalid: flag to indicate if flow idx is valid or not
  472. * @fse_metadata: cached FSE metadata value received in the MSDU END TLV
  473. * @flow_idx: flow idx matched in FSE received in the MSDU END TLV
  474. */
  475. struct hal_rx_ppdu_msdu_info {
  476. uint16_t cce_metadata;
  477. bool is_flow_idx_timeout;
  478. bool is_flow_idx_invalid;
  479. uint32_t fse_metadata;
  480. uint32_t flow_idx;
  481. };
  482. #if defined(WLAN_CFR_ENABLE) && defined(WLAN_ENH_CFR_ENABLE)
  483. /**
  484. * struct hal_rx_ppdu_cfr_user_info - struct for storing peer info extracted
  485. * from HW TLVs, this will be used for correlating CFR data with multiple peers
  486. * in MU PPDUs
  487. *
  488. * @peer_macaddr: macaddr of the peer
  489. * @ast_index: AST index of the peer
  490. */
  491. struct hal_rx_ppdu_cfr_user_info {
  492. uint8_t peer_macaddr[QDF_MAC_ADDR_SIZE];
  493. uint32_t ast_index;
  494. };
  495. /**
  496. * struct hal_rx_ppdu_cfr_info - struct for storing ppdu info extracted from HW
  497. * TLVs, this will be used for CFR correlation
  498. *
  499. * @bb_captured_channel : Set by RXPCU when MACRX_FREEZE_CAPTURE_CHANNEL TLV is
  500. * sent to PHY, SW checks it to correlate current PPDU TLVs with uploaded
  501. * channel information.
  502. *
  503. * @bb_captured_timeout : Set by RxPCU to indicate channel capture condition is
  504. * met, but MACRX_FREEZE_CAPTURE_CHANNEL is not sent to PHY due to AST delay,
  505. * which means the rx_frame_falling edge to FREEZE TLV ready time exceeds
  506. * the threshold time defined by RXPCU register FREEZE_TLV_DELAY_CNT_THRESH.
  507. * Bb_captured_reason is still valid in this case.
  508. *
  509. * @rx_location_info_valid: Indicates whether CFR DMA address in the PPDU TLV
  510. * is valid
  511. * <enum 0 rx_location_info_is_not_valid>
  512. * <enum 1 rx_location_info_is_valid>
  513. * <legal all>
  514. *
  515. * @bb_captured_reason : Copy capture_reason of MACRX_FREEZE_CAPTURE_CHANNEL
  516. * TLV to here for FW usage. Valid when bb_captured_channel or
  517. * bb_captured_timeout is set.
  518. * <enum 0 freeze_reason_TM>
  519. * <enum 1 freeze_reason_FTM>
  520. * <enum 2 freeze_reason_ACK_resp_to_TM_FTM>
  521. * <enum 3 freeze_reason_TA_RA_TYPE_FILTER>
  522. * <enum 4 freeze_reason_NDPA_NDP>
  523. * <enum 5 freeze_reason_ALL_PACKET>
  524. * <legal 0-5>
  525. *
  526. * @rtt_che_buffer_pointer_low32 : The low 32 bits of the 40 bits pointer to
  527. * external RTT channel information buffer
  528. *
  529. * @rtt_che_buffer_pointer_high8 : The high 8 bits of the 40 bits pointer to
  530. * external RTT channel information buffer
  531. *
  532. * @chan_capture_status : capture status reported by ucode
  533. * a. CAPTURE_IDLE: FW has disabled "REPETITIVE_CHE_CAPTURE_CTRL"
  534. * b. CAPTURE_BUSY: previous PPDU’s channel capture upload DMA ongoing. (Note
  535. * that this upload is triggered after receiving freeze_channel_capture TLV
  536. * after last PPDU is rx)
  537. * c. CAPTURE_ACTIVE: channel capture is enabled and no previous channel
  538. * capture ongoing
  539. * d. CAPTURE_NO_BUFFER: next buffer in IPC ring not available
  540. *
  541. * @cfr_user_info: Peer mac for upto 4 MU users
  542. *
  543. * @rtt_cfo_measurement : raw cfo data extracted from hardware, which is 14 bit
  544. * signed number. The first bit used for sign representation and 13 bits for
  545. * fractional part.
  546. *
  547. * @agc_gain_info0: Chain 0 & chain 1 agc gain information reported by PHY
  548. *
  549. * @agc_gain_info1: Chain 2 & chain 3 agc gain information reported by PHY
  550. *
  551. * @agc_gain_info2: Chain 4 & chain 5 agc gain information reported by PHY
  552. *
  553. * @agc_gain_info3: Chain 6 & chain 7 agc gain information reported by PHY
  554. *
  555. * @rx_start_ts: Rx packet timestamp, the time the first L-STF ADC sample
  556. * arrived at Rx antenna.
  557. *
  558. * @mcs_rate: Indicates the mcs/rate in which packet is received.
  559. * If HT,
  560. * 0-7: MCS0-MCS7
  561. * If VHT,
  562. * 0-9: MCS0 to MCS9
  563. * If HE,
  564. * 0-11: MCS0 to MCS11,
  565. * 12-13: 4096QAM,
  566. * 14-15: reserved
  567. * If Legacy,
  568. * 0: 48 Mbps
  569. * 1: 24 Mbps
  570. * 2: 12 Mbps
  571. * 3: 6 Mbps
  572. * 4: 54 Mbps
  573. * 5: 36 Mbps
  574. * 6: 18 Mbps
  575. * 7: 9 Mbps
  576. *
  577. * @gi_type: Indicates the gaurd interval.
  578. * 0: 0.8 us
  579. * 1: 0.4 us
  580. * 2: 1.6 us
  581. * 3: 3.2 us
  582. */
  583. struct hal_rx_ppdu_cfr_info {
  584. bool bb_captured_channel;
  585. bool bb_captured_timeout;
  586. uint8_t bb_captured_reason;
  587. bool rx_location_info_valid;
  588. uint8_t chan_capture_status;
  589. uint8_t rtt_che_buffer_pointer_high8;
  590. uint32_t rtt_che_buffer_pointer_low32;
  591. struct hal_rx_ppdu_cfr_user_info cfr_user_info[HAL_MAX_UL_MU_USERS];
  592. int16_t rtt_cfo_measurement;
  593. uint32_t agc_gain_info0;
  594. uint32_t agc_gain_info1;
  595. uint32_t agc_gain_info2;
  596. uint32_t agc_gain_info3;
  597. uint32_t rx_start_ts;
  598. uint32_t mcs_rate;
  599. uint32_t gi_type;
  600. };
  601. #else
  602. struct hal_rx_ppdu_cfr_info {};
  603. #endif
  604. struct mon_rx_info {
  605. uint8_t qos_control_info_valid;
  606. uint16_t qos_control;
  607. uint8_t mac_addr1_valid;
  608. uint8_t mac_addr1[QDF_MAC_ADDR_SIZE];
  609. uint32_t user_id;
  610. };
  611. struct mon_rx_user_info {
  612. uint16_t qos_control;
  613. uint8_t qos_control_info_valid;
  614. };
  615. #ifdef QCA_SUPPORT_SCAN_SPCL_VAP_STATS
  616. struct hal_rx_frm_type_info {
  617. uint32_t rx_mgmt_cnt;
  618. uint32_t rx_ctrl_cnt;
  619. uint32_t rx_data_cnt;
  620. };
  621. #else
  622. struct hal_rx_frm_type_info {};
  623. #endif
  624. struct hal_mon_usig_cmn {
  625. uint32_t phy_version : 3,
  626. bw : 3,
  627. ul_dl : 1,
  628. bss_color : 6,
  629. txop : 7,
  630. disregard : 5,
  631. validate_0 : 1,
  632. reserved : 6;
  633. };
  634. struct hal_mon_usig_tb {
  635. uint32_t ppdu_type_comp_mode : 2,
  636. validate_1 : 1,
  637. spatial_reuse_1 : 4,
  638. spatial_reuse_2 : 4,
  639. disregard_1 : 5,
  640. crc : 4,
  641. tail : 6,
  642. reserved : 5,
  643. rx_integrity_check_passed : 1;
  644. };
  645. struct hal_mon_usig_mu {
  646. uint32_t ppdu_type_comp_mode : 2,
  647. validate_1 : 1,
  648. punc_ch_info : 5,
  649. validate_2 : 1,
  650. eht_sig_mcs : 2,
  651. num_eht_sig_sym : 5,
  652. crc : 4,
  653. tail : 6,
  654. reserved : 5,
  655. rx_integrity_check_passed : 1;
  656. };
  657. /**
  658. * union hal_mon_usig_non_cmn: Version dependent USIG fields
  659. * @tb: trigger based frame USIG header
  660. * @mu: MU frame USIG header
  661. */
  662. union hal_mon_usig_non_cmn {
  663. struct hal_mon_usig_tb tb;
  664. struct hal_mon_usig_mu mu;
  665. };
  666. /**
  667. * struct hal_mon_usig_hdr: U-SIG header for EHT (and subsequent) frames
  668. * @usig_1: USIG common header fields
  669. * @usig_2: USIG version dependent fields
  670. */
  671. struct hal_mon_usig_hdr {
  672. struct hal_mon_usig_cmn usig_1;
  673. union hal_mon_usig_non_cmn usig_2;
  674. };
  675. #define HAL_RX_MON_USIG_PPDU_TYPE_N_COMP_MODE_MASK 0x0000000300000000
  676. #define HAL_RX_MON_USIG_PPDU_TYPE_N_COMP_MODE_LSB 32
  677. #define HAL_RX_MON_USIG_GET_PPDU_TYPE_N_COMP_MODE(usig_tlv_ptr) \
  678. ((*((uint64_t *)(usig_tlv_ptr)) & \
  679. HAL_RX_MON_USIG_PPDU_TYPE_N_COMP_MODE_MASK) >> \
  680. HAL_RX_MON_USIG_PPDU_TYPE_N_COMP_MODE_LSB)
  681. #define HAL_RX_MON_USIG_RX_INTEGRITY_CHECK_PASSED_MASK 0x8000000000000000
  682. #define HAL_RX_MON_USIG_RX_INTEGRITY_CHECK_PASSED_LSB 63
  683. #define HAL_RX_MON_USIG_GET_RX_INTEGRITY_CHECK_PASSED(usig_tlv_ptr) \
  684. ((*((uint64_t *)(usig_tlv_ptr)) & \
  685. HAL_RX_MON_USIG_RX_INTEGRITY_CHECK_PASSED_MASK) >> \
  686. HAL_RX_MON_USIG_RX_INTEGRITY_CHECK_PASSED_LSB)
  687. /**
  688. * enum hal_eht_bw: Reception bandwidth
  689. * @HAL_EHT_BW_20: 20Mhz
  690. * @HAL_EHT_BW_40: 40Mhz
  691. * @HAL_EHT_BW_80: 80Mhz
  692. * @HAL_EHT_BW_160: 160Mhz
  693. * @HAL_EHT_BW_320_1: 320_1 band
  694. * @HAL_EHT_BW_320_2: 320_2 band
  695. */
  696. enum hal_eht_bw {
  697. HAL_EHT_BW_20 = 0,
  698. HAL_EHT_BW_40,
  699. HAL_EHT_BW_80,
  700. HAL_EHT_BW_160,
  701. HAL_EHT_BW_320_1,
  702. HAL_EHT_BW_320_2,
  703. };
  704. struct hal_eht_sig_mu_mimo_user_info {
  705. uint32_t sta_id : 11,
  706. mcs : 4,
  707. coding : 1,
  708. spatial_coding : 6,
  709. crc : 4;
  710. };
  711. struct hal_eht_sig_non_mu_mimo_user_info {
  712. uint32_t sta_id : 11,
  713. mcs : 4,
  714. validate : 1,
  715. nss : 4,
  716. beamformed : 1,
  717. coding : 1,
  718. crc : 4;
  719. };
  720. /**
  721. * union hal_eht_sig_user_field: User field in EHTSIG
  722. * @mu_mimo_usr: MU-MIMO user field information in EHTSIG
  723. * @non_mu_mimo_usr: Non MU-MIMO user field information in EHTSIG
  724. */
  725. union hal_eht_sig_user_field {
  726. struct hal_eht_sig_mu_mimo_user_info mu_mimo_usr;
  727. struct hal_eht_sig_non_mu_mimo_user_info non_mu_mimo_usr;
  728. };
  729. struct hal_eht_sig_ofdma_cmn_eb1 {
  730. uint64_t spatial_reuse : 4,
  731. gi_ltf : 2,
  732. num_ltf_sym : 3,
  733. ldpc_extra_sym : 1,
  734. pre_fec_pad_factor : 2,
  735. pe_disambiguity : 1,
  736. disregard : 4,
  737. ru_allocation1_1 : 9,
  738. ru_allocation1_2 : 9,
  739. crc : 4;
  740. };
  741. struct hal_eht_sig_ofdma_cmn_eb2 {
  742. uint64_t ru_allocation2_1 : 9,
  743. ru_allocation2_2 : 9,
  744. ru_allocation2_3 : 9,
  745. ru_allocation2_4 : 9,
  746. ru_allocation2_5 : 9,
  747. ru_allocation2_6 : 9,
  748. crc : 4;
  749. };
  750. struct hal_eht_sig_cc_usig_overflow {
  751. uint32_t spatial_reuse : 4,
  752. gi_ltf : 2,
  753. num_ltf_sym : 3,
  754. ldpc_extra_sym : 1,
  755. pre_fec_pad_factor : 2,
  756. pe_disambiguity : 1,
  757. disregard : 4;
  758. };
  759. struct hal_eht_sig_non_ofdma_cmn_eb {
  760. uint32_t spatial_reuse : 4,
  761. gi_ltf : 2,
  762. num_ltf_sym : 3,
  763. ldpc_extra_sym : 1,
  764. pre_fec_pad_factor : 2,
  765. pe_disambiguity : 1,
  766. disregard : 4,
  767. num_users : 3;
  768. union hal_eht_sig_user_field user_field;
  769. };
  770. struct hal_eht_sig_ndp_cmn_eb {
  771. uint32_t spatial_reuse : 4,
  772. gi_ltf : 2,
  773. num_ltf_sym : 3,
  774. nss : 4,
  775. beamformed : 1,
  776. disregard : 2,
  777. crc : 4;
  778. };
  779. /* Different allowed RU in 11BE */
  780. #define HAL_EHT_RU_26 0ULL
  781. #define HAL_EHT_RU_52 1ULL
  782. #define HAL_EHT_RU_78 2ULL
  783. #define HAL_EHT_RU_106 3ULL
  784. #define HAL_EHT_RU_132 4ULL
  785. #define HAL_EHT_RU_242 5ULL
  786. #define HAL_EHT_RU_484 6ULL
  787. #define HAL_EHT_RU_726 7ULL
  788. #define HAL_EHT_RU_996 8ULL
  789. #define HAL_EHT_RU_996x2 9ULL
  790. #define HAL_EHT_RU_996x3 10ULL
  791. #define HAL_EHT_RU_996x4 11ULL
  792. #define HAL_EHT_RU_NONE 15ULL
  793. #define HAL_EHT_RU_INVALID 31ULL
  794. /*
  795. * MRUs spanning above 80Mhz
  796. * HAL_EHT_RU_996_484 = HAL_EHT_RU_484 + HAL_EHT_RU_996 + 4 (reserved)
  797. */
  798. #define HAL_EHT_RU_996_484 18ULL
  799. #define HAL_EHT_RU_996x2_484 28ULL
  800. #define HAL_EHT_RU_996x3_484 40ULL
  801. #define HAL_EHT_RU_996_484_242 23ULL
  802. /**
  803. * enum ieee80211_eht_ru_size: RU type id in EHTSIG radiotap header
  804. * @IEEE80211_EHT_RU_26: RU26
  805. * @IEEE80211_EHT_RU_52: RU52
  806. * @IEEE80211_EHT_RU_106: RU106
  807. * @IEEE80211_EHT_RU_242: RU242
  808. * @IEEE80211_EHT_RU_484: RU484
  809. * @IEEE80211_EHT_RU_996: RU996
  810. * @IEEE80211_EHT_RU_996x2: RU996x2
  811. * @IEEE80211_EHT_RU_996x4: RU996x4
  812. * @IEEE80211_EHT_RU_52_26: RU52+RU26
  813. * @IEEE80211_EHT_RU_106_26: RU106+RU26
  814. * @IEEE80211_EHT_RU_484_242: RU484+RU242
  815. * @IEEE80211_EHT_RU_996_484: RU996+RU484
  816. * @IEEE80211_EHT_RU_996_484_242: RU996+RU484+RU242
  817. * @IEEE80211_EHT_RU_996x2_484: RU996x2 + RU484
  818. * @IEEE80211_EHT_RU_996x3: RU996x3
  819. * @IEEE80211_EHT_RU_996x3_484: RU996x3 + RU484
  820. * @IEEE80211_EHT_RU_INVALID: Invalid/Max RU
  821. */
  822. enum ieee80211_eht_ru_size {
  823. IEEE80211_EHT_RU_26,
  824. IEEE80211_EHT_RU_52,
  825. IEEE80211_EHT_RU_106,
  826. IEEE80211_EHT_RU_242,
  827. IEEE80211_EHT_RU_484,
  828. IEEE80211_EHT_RU_996,
  829. IEEE80211_EHT_RU_996x2,
  830. IEEE80211_EHT_RU_996x4,
  831. IEEE80211_EHT_RU_52_26,
  832. IEEE80211_EHT_RU_106_26,
  833. IEEE80211_EHT_RU_484_242,
  834. IEEE80211_EHT_RU_996_484,
  835. IEEE80211_EHT_RU_996_484_242,
  836. IEEE80211_EHT_RU_996x2_484,
  837. IEEE80211_EHT_RU_996x3,
  838. IEEE80211_EHT_RU_996x3_484,
  839. IEEE80211_EHT_RU_INVALID,
  840. };
  841. #define NUM_RU_BITS_PER80 16
  842. #define NUM_RU_BITS_PER20 4
  843. /* Different per_80Mhz band in 320Mhz bandwidth */
  844. #define HAL_80_0 0
  845. #define HAL_80_1 1
  846. #define HAL_80_2 2
  847. #define HAL_80_3 3
  848. #define HAL_RU_SHIFT(num_80mhz_band, ru_index_per_80) \
  849. ((NUM_RU_BITS_PER80 * (num_80mhz_band)) + \
  850. (NUM_RU_BITS_PER20 * (ru_index_per_80)))
  851. /* MRU-996+484 */
  852. #define HAL_EHT_RU_996_484_0 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_0, 1)) | \
  853. (HAL_EHT_RU_996 << HAL_RU_SHIFT(HAL_80_1, 0)))
  854. #define HAL_EHT_RU_996_484_1 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  855. (HAL_EHT_RU_996 << HAL_RU_SHIFT(HAL_80_1, 0)))
  856. #define HAL_EHT_RU_996_484_2 ((HAL_EHT_RU_996 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  857. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_1, 1)))
  858. #define HAL_EHT_RU_996_484_3 ((HAL_EHT_RU_996 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  859. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_1, 0)))
  860. #define HAL_EHT_RU_996_484_4 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_2, 1)) | \
  861. (HAL_EHT_RU_996 << HAL_RU_SHIFT(HAL_80_3, 0)))
  862. #define HAL_EHT_RU_996_484_5 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  863. (HAL_EHT_RU_996 << HAL_RU_SHIFT(HAL_80_3, 0)))
  864. #define HAL_EHT_RU_996_484_6 ((HAL_EHT_RU_996 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  865. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_3, 1)))
  866. #define HAL_EHT_RU_996_484_7 ((HAL_EHT_RU_996 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  867. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_3, 0)))
  868. /* MRU-996x2+484 */
  869. #define HAL_EHT_RU_996x2_484_0 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_0, 1)) | \
  870. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  871. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_2, 0)))
  872. #define HAL_EHT_RU_996x2_484_1 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  873. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  874. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_2, 0)))
  875. #define HAL_EHT_RU_996x2_484_2 ((HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  876. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_1, 1)) | \
  877. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_2, 0)))
  878. #define HAL_EHT_RU_996x2_484_3 ((HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  879. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  880. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_2, 0)))
  881. #define HAL_EHT_RU_996x2_484_4 ((HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  882. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  883. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_2, 1)))
  884. #define HAL_EHT_RU_996x2_484_5 ((HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  885. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  886. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_2, 0)))
  887. #define HAL_EHT_RU_996x2_484_6 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_1, 1)) | \
  888. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  889. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_3, 0)))
  890. #define HAL_EHT_RU_996x2_484_7 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  891. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  892. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_3, 0)))
  893. #define HAL_EHT_RU_996x2_484_8 ((HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  894. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_2, 1)) | \
  895. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_3, 0)))
  896. #define HAL_EHT_RU_996x2_484_9 ((HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  897. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  898. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_3, 0)))
  899. #define HAL_EHT_RU_996x2_484_10 ((HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  900. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  901. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_3, 1)))
  902. #define HAL_EHT_RU_996x2_484_11 ((HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  903. (HAL_EHT_RU_996x2 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  904. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_3, 0)))
  905. /* MRU-996x3+484 */
  906. #define HAL_EHT_RU_996x3_484_0 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_0, 1)) | \
  907. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  908. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  909. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_3, 0)))
  910. #define HAL_EHT_RU_996x3_484_1 ((HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  911. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  912. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  913. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_3, 0)))
  914. #define HAL_EHT_RU_996x3_484_2 ((HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  915. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_1, 1)) | \
  916. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  917. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_3, 0)))
  918. #define HAL_EHT_RU_996x3_484_3 ((HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  919. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  920. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  921. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_3, 0)))
  922. #define HAL_EHT_RU_996x3_484_4 ((HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  923. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  924. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_2, 1)) | \
  925. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_3, 0)))
  926. #define HAL_EHT_RU_996x3_484_5 ((HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  927. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  928. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  929. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_3, 0)))
  930. #define HAL_EHT_RU_996x3_484_6 ((HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  931. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  932. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  933. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_3, 1)))
  934. #define HAL_EHT_RU_996x3_484_7 ((HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_0, 0)) | \
  935. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_1, 0)) | \
  936. (HAL_EHT_RU_996x3 << HAL_RU_SHIFT(HAL_80_2, 0)) | \
  937. (HAL_EHT_RU_484 << HAL_RU_SHIFT(HAL_80_3, 0)))
  938. /* EHT Reception Type */
  939. #define HAL_RX_TYPE_MU_MIMO 1
  940. #define HAL_RX_TYPE_MU_OFDMA 2
  941. #define HAL_RX_TYPE_MU_OFMDA_MIMO 3
  942. #define HAL_RX_MON_MAX_AGGR_SIZE 128
  943. /**
  944. * struct hal_rx_tlv_aggr_info - Data structure to hold
  945. * metadata for aggregatng repeated TLVs
  946. * @in_progress: Flag to indicate if TLV aggregation is in progress
  947. * @cur_len: Total length of currently aggregated TLV
  948. * @tlv_tag: TLV tag which is currently being aggregated
  949. * @buf: Buffer containing aggregated TLV data
  950. */
  951. struct hal_rx_tlv_aggr_info {
  952. uint8_t in_progress;
  953. uint16_t cur_len;
  954. uint32_t tlv_tag;
  955. uint8_t buf[HAL_RX_MON_MAX_AGGR_SIZE];
  956. };
  957. /* struct hal_rx_u_sig_info - Certain fields from U-SIG header which are used
  958. * for other header field parsing.
  959. * @ul_dl: UL or DL
  960. * @bw: EHT BW
  961. * @ppdu_type_comp_mode: PPDU TYPE
  962. * @eht_sig_mcs: EHT SIG MCS
  963. * @num_eht_sig_sym: Number of EHT SIG symbols
  964. */
  965. struct hal_rx_u_sig_info {
  966. uint32_t ul_dl : 1,
  967. bw : 3,
  968. ppdu_type_comp_mode : 2,
  969. eht_sig_mcs : 2,
  970. num_eht_sig_sym : 5;
  971. };
  972. struct hal_rx_ppdu_info {
  973. struct hal_rx_ppdu_common_info com_info;
  974. struct hal_rx_u_sig_info u_sig_info;
  975. struct mon_rx_status rx_status;
  976. struct mon_rx_user_status rx_user_status[HAL_MAX_UL_MU_USERS];
  977. struct mon_rx_info rx_info;
  978. struct mon_rx_user_info rx_user_info[HAL_MAX_UL_MU_USERS];
  979. struct hal_rx_msdu_payload_info msdu_info;
  980. struct hal_rx_msdu_payload_info fcs_ok_msdu_info;
  981. struct hal_rx_nac_info nac_info;
  982. /* status ring PPDU start and end state */
  983. uint32_t rx_state;
  984. /* MU user id for status ring TLV */
  985. uint32_t user_id;
  986. /* MPDU/MSDU truncated to 128 bytes header start addr in status skb */
  987. unsigned char *data;
  988. /* MPDU/MSDU truncated to 128 bytes header real length */
  989. uint32_t hdr_len;
  990. /* MPDU FCS error */
  991. bool fcs_err;
  992. /* Id to indicate how to process mpdu */
  993. uint8_t sw_frame_group_id;
  994. struct hal_rx_ppdu_msdu_info rx_msdu_info[HAL_MAX_UL_MU_USERS];
  995. /* fcs passed mpdu count in rx monitor status buffer */
  996. uint8_t fcs_ok_cnt;
  997. /* fcs error mpdu count in rx monitor status buffer */
  998. uint8_t fcs_err_cnt;
  999. /* MPDU FCS passed */
  1000. bool is_fcs_passed;
  1001. /* first msdu payload for all mpdus in rx monitor status buffer */
  1002. struct hal_rx_msdu_payload_info ppdu_msdu_info[HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER];
  1003. /* evm info */
  1004. struct hal_rx_su_evm_info evm_info;
  1005. /**
  1006. * Will be used to store ppdu info extracted from HW TLVs,
  1007. * and for CFR correlation as well
  1008. */
  1009. struct hal_rx_ppdu_cfr_info cfr_info;
  1010. /* per frame type counts */
  1011. struct hal_rx_frm_type_info frm_type_info;
  1012. /* TLV aggregation metadata context */
  1013. struct hal_rx_tlv_aggr_info tlv_aggr;
  1014. /* EHT SIG user info */
  1015. uint32_t eht_sig_user_info;
  1016. };
  1017. static inline uint32_t
  1018. hal_get_rx_status_buf_size(void) {
  1019. /* RX status buffer size is hard coded for now */
  1020. return 2048;
  1021. }
  1022. static inline uint8_t*
  1023. hal_rx_status_get_next_tlv(uint8_t *rx_tlv, bool is_tlv_hdr_64_bit) {
  1024. uint32_t tlv_len, tlv_tag, tlv_hdr_size;
  1025. if (is_tlv_hdr_64_bit) {
  1026. tlv_len = HAL_RX_GET_USER_TLV32_LEN(rx_tlv);
  1027. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(rx_tlv);
  1028. tlv_hdr_size = HAL_RX_TLV64_HDR_SIZE;
  1029. } else {
  1030. tlv_len = HAL_RX_GET_USER_TLV32_LEN(rx_tlv);
  1031. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(rx_tlv);
  1032. tlv_hdr_size = HAL_RX_TLV32_HDR_SIZE;
  1033. }
  1034. /* The actual length of PPDU_END is the combined length of many PHY
  1035. * TLVs that follow. Skip the TLV header and
  1036. * rx_rxpcu_classification_overview that follows the header to get to
  1037. * next TLV.
  1038. */
  1039. if (tlv_tag == WIFIRX_PPDU_END_E)
  1040. tlv_len = sizeof(struct rx_rxpcu_classification_overview);
  1041. return (uint8_t *)(uintptr_t)qdf_align((uint64_t)((uintptr_t)rx_tlv +
  1042. tlv_len +
  1043. tlv_hdr_size),
  1044. tlv_hdr_size);
  1045. }
  1046. /**
  1047. * hal_rx_proc_phyrx_other_receive_info_tlv()
  1048. * - process other receive info TLV
  1049. * @rx_tlv_hdr: pointer to TLV header
  1050. * @ppdu_info: pointer to ppdu_info
  1051. *
  1052. * Return: None
  1053. */
  1054. static inline void hal_rx_proc_phyrx_other_receive_info_tlv(struct hal_soc *hal_soc,
  1055. void *rx_tlv_hdr,
  1056. struct hal_rx_ppdu_info
  1057. *ppdu_info)
  1058. {
  1059. hal_soc->ops->hal_rx_proc_phyrx_other_receive_info_tlv(rx_tlv_hdr,
  1060. (void *)ppdu_info);
  1061. }
  1062. /**
  1063. * hal_rx_status_get_tlv_info() - process receive info TLV
  1064. * @rx_tlv_hdr: pointer to TLV header
  1065. * @ppdu_info: pointer to ppdu_info
  1066. * @hal_soc: HAL soc handle
  1067. * @nbuf: PPDU status netowrk buffer
  1068. *
  1069. * Return: HAL_TLV_STATUS_PPDU_NOT_DONE or HAL_TLV_STATUS_PPDU_DONE from tlv
  1070. */
  1071. static inline uint32_t
  1072. hal_rx_status_get_tlv_info(void *rx_tlv_hdr, void *ppdu_info,
  1073. hal_soc_handle_t hal_soc_hdl,
  1074. qdf_nbuf_t nbuf)
  1075. {
  1076. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1077. return hal_soc->ops->hal_rx_status_get_tlv_info(
  1078. rx_tlv_hdr,
  1079. ppdu_info,
  1080. hal_soc_hdl,
  1081. nbuf);
  1082. }
  1083. static inline
  1084. uint32_t hal_get_rx_status_done_tlv_size(hal_soc_handle_t hal_soc_hdl)
  1085. {
  1086. return HAL_RX_TLV32_HDR_SIZE;
  1087. }
  1088. static inline QDF_STATUS
  1089. hal_get_rx_status_done(uint8_t *rx_tlv)
  1090. {
  1091. uint32_t tlv_tag;
  1092. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(rx_tlv);
  1093. if (tlv_tag == WIFIRX_STATUS_BUFFER_DONE_E)
  1094. return QDF_STATUS_SUCCESS;
  1095. else
  1096. return QDF_STATUS_E_EMPTY;
  1097. }
  1098. static inline QDF_STATUS
  1099. hal_clear_rx_status_done(uint8_t *rx_tlv)
  1100. {
  1101. *(uint32_t *)rx_tlv = 0;
  1102. return QDF_STATUS_SUCCESS;
  1103. }
  1104. #endif