hal_api_mon.h 40 KB

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