hal_api_mon.h 39 KB

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