hal_api_mon.h 22 KB

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