hal_api_mon.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  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. /**
  138. * struct hal_rx_mon_desc_info () - HAL Rx Monitor descriptor info
  139. *
  140. * @ppdu_id: PHY ppdu id
  141. * @status_ppdu_id: status PHY ppdu id
  142. * @status_buf_count: number of status buffer count
  143. * @rxdma_push_reason: rxdma push reason
  144. * @rxdma_error_code: rxdma error code
  145. * @msdu_cnt: msdu count
  146. * @end_of_ppdu: end of ppdu
  147. * @link_desc: msdu link descriptor address
  148. * @status_buf: for a PPDU, status buffers can span acrosss
  149. * multiple buffers, status_buf points to first
  150. * status buffer address of PPDU
  151. * @drop_ppdu: flag to indicate current destination
  152. * ring ppdu drop
  153. */
  154. struct hal_rx_mon_desc_info {
  155. uint16_t ppdu_id;
  156. uint16_t status_ppdu_id;
  157. uint8_t status_buf_count;
  158. uint8_t rxdma_push_reason;
  159. uint8_t rxdma_error_code;
  160. uint8_t msdu_count;
  161. uint8_t end_of_ppdu;
  162. struct hal_buf_info link_desc;
  163. struct hal_buf_info status_buf;
  164. bool drop_ppdu;
  165. };
  166. /*
  167. * Struct hal_rx_su_evm_info - SU evm info
  168. * @number_of_symbols: number of symbols
  169. * @nss_count: nss count
  170. * @pilot_count: pilot count
  171. * @pilot_evm: Array of pilot evm values
  172. */
  173. struct hal_rx_su_evm_info {
  174. uint32_t number_of_symbols;
  175. uint8_t nss_count;
  176. uint8_t pilot_count;
  177. uint32_t pilot_evm[HAL_RX_MAX_SU_EVM_COUNT];
  178. };
  179. enum {
  180. DP_PPDU_STATUS_START,
  181. DP_PPDU_STATUS_DONE,
  182. };
  183. /**
  184. * hal_rx_reo_ent_buf_paddr_get: Gets the physical address and
  185. * cookie from the REO entrance ring element
  186. * @hal_rx_desc_cookie: Opaque cookie pointer used by HAL to get to
  187. * the current descriptor
  188. * @ buf_info: structure to return the buffer information
  189. * @ msdu_cnt: pointer to msdu count in MPDU
  190. *
  191. * CAUTION: This API calls a hal_soc ops, so be careful before calling this in
  192. * per packet path
  193. *
  194. * Return: void
  195. */
  196. static inline
  197. void hal_rx_reo_ent_buf_paddr_get(hal_soc_handle_t hal_soc_hdl,
  198. hal_rxdma_desc_t rx_desc,
  199. struct hal_buf_info *buf_info,
  200. uint32_t *msdu_cnt)
  201. {
  202. struct reo_entrance_ring *reo_ent_ring =
  203. (struct reo_entrance_ring *)rx_desc;
  204. struct buffer_addr_info *buf_addr_info;
  205. struct rx_mpdu_desc_info *rx_mpdu_desc_info_details;
  206. uint32_t loop_cnt;
  207. rx_mpdu_desc_info_details =
  208. &reo_ent_ring->reo_level_mpdu_frame_info.rx_mpdu_desc_info_details;
  209. *msdu_cnt = HAL_RX_GET(rx_mpdu_desc_info_details,
  210. HAL_RX_MPDU_DESC_INFO, MSDU_COUNT);
  211. loop_cnt = HAL_RX_GET(reo_ent_ring, HAL_REO_ENTRANCE_RING,
  212. LOOPING_COUNT);
  213. buf_addr_info =
  214. &reo_ent_ring->reo_level_mpdu_frame_info.msdu_link_desc_addr_info;
  215. hal_rx_buf_cookie_rbm_get(hal_soc_hdl, (uint32_t *)buf_addr_info,
  216. buf_info);
  217. buf_info->paddr =
  218. (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) |
  219. ((uint64_t)
  220. (HAL_RX_BUFFER_ADDR_39_32_GET(buf_addr_info)) << 32));
  221. dp_nofl_debug("[%s][%d] ReoAddr=%pK, addrInfo=%pK, paddr=0x%llx, loopcnt=%d",
  222. __func__, __LINE__, reo_ent_ring, buf_addr_info,
  223. (unsigned long long)buf_info->paddr, loop_cnt);
  224. }
  225. static inline
  226. void hal_rx_mon_next_link_desc_get(hal_soc_handle_t hal_soc_hdl,
  227. void *rx_msdu_link_desc,
  228. struct hal_buf_info *buf_info)
  229. {
  230. struct rx_msdu_link *msdu_link =
  231. (struct rx_msdu_link *)rx_msdu_link_desc;
  232. struct buffer_addr_info *buf_addr_info;
  233. buf_addr_info = &msdu_link->next_msdu_link_desc_addr_info;
  234. hal_rx_buf_cookie_rbm_get(hal_soc_hdl, (uint32_t *)buf_addr_info,
  235. buf_info);
  236. buf_info->paddr =
  237. (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) |
  238. ((uint64_t)
  239. (HAL_RX_BUFFER_ADDR_39_32_GET(buf_addr_info)) << 32));
  240. }
  241. static inline
  242. uint8_t *HAL_RX_MON_DEST_GET_DESC(uint8_t *data)
  243. {
  244. return data;
  245. }
  246. static inline uint32_t
  247. hal_rx_tlv_mpdu_len_err_get(hal_soc_handle_t hal_soc_hdl, void *hw_desc_addr)
  248. {
  249. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  250. if (!hal_soc || !hal_soc->ops) {
  251. hal_err("hal handle is NULL");
  252. QDF_BUG(0);
  253. return 0;
  254. }
  255. if (hal_soc->ops->hal_rx_tlv_mpdu_len_err_get)
  256. return hal_soc->ops->hal_rx_tlv_mpdu_len_err_get(hw_desc_addr);
  257. return 0;
  258. }
  259. static inline uint32_t
  260. hal_rx_tlv_mpdu_fcs_err_get(hal_soc_handle_t hal_soc_hdl, void *hw_desc_addr)
  261. {
  262. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  263. if (!hal_soc || !hal_soc->ops) {
  264. hal_err("hal handle is NULL");
  265. QDF_BUG(0);
  266. return 0;
  267. }
  268. if (hal_soc->ops->hal_rx_tlv_mpdu_fcs_err_get)
  269. return hal_soc->ops->hal_rx_tlv_mpdu_fcs_err_get(hw_desc_addr);
  270. return 0;
  271. }
  272. #ifdef notyet
  273. /*
  274. * HAL_RX_HW_DESC_MPDU_VALID() - check MPDU start TLV tag in MPDU
  275. * start TLV of Hardware TLV descriptor
  276. * @hw_desc_addr: Hardware descriptor address
  277. *
  278. * Return: bool: if TLV tag match
  279. */
  280. static inline
  281. bool HAL_RX_HW_DESC_MPDU_VALID(void *hw_desc_addr)
  282. {
  283. struct rx_mon_pkt_tlvs *rx_desc =
  284. (struct rx_mon_pkt_tlvs *)hw_desc_addr;
  285. uint32_t tlv_tag;
  286. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(&rx_desc->mpdu_start_tlv);
  287. return tlv_tag == WIFIRX_MPDU_START_E ? true : false;
  288. }
  289. #endif
  290. /*
  291. * HAL_RX_HW_DESC_MPDU_VALID() - check MPDU start TLV user id in MPDU
  292. * start TLV of Hardware TLV descriptor
  293. * @hw_desc_addr: Hardware descriptor address
  294. *
  295. * Return: unit32_t: user id
  296. */
  297. static inline uint32_t
  298. hal_rx_hw_desc_mpdu_user_id(hal_soc_handle_t hal_soc_hdl,
  299. void *hw_desc_addr)
  300. {
  301. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  302. if (!hal_soc || !hal_soc->ops) {
  303. hal_err("hal handle is NULL");
  304. QDF_BUG(0);
  305. return 0;
  306. }
  307. if (hal_soc->ops->hal_rx_hw_desc_mpdu_user_id)
  308. return hal_soc->ops->hal_rx_hw_desc_mpdu_user_id(hw_desc_addr);
  309. return 0;
  310. }
  311. /* TODO: Move all Rx descriptor functions to hal_rx.h to avoid duplication */
  312. /**
  313. * hal_rx_msdu_link_desc_set: Retrieves MSDU Link Descriptor to WBM
  314. *
  315. * @ soc : HAL version of the SOC pointer
  316. * @ src_srng_desc : void pointer to the WBM Release Ring descriptor
  317. * @ buf_addr_info : void pointer to the buffer_addr_info
  318. *
  319. * Return: void
  320. */
  321. static inline
  322. void hal_rx_mon_msdu_link_desc_set(hal_soc_handle_t hal_soc_hdl,
  323. void *src_srng_desc,
  324. hal_buff_addrinfo_t buf_addr_info)
  325. {
  326. struct buffer_addr_info *wbm_srng_buffer_addr_info =
  327. (struct buffer_addr_info *)src_srng_desc;
  328. uint64_t paddr;
  329. struct buffer_addr_info *p_buffer_addr_info =
  330. (struct buffer_addr_info *)buf_addr_info;
  331. paddr =
  332. (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) |
  333. ((uint64_t)
  334. (HAL_RX_BUFFER_ADDR_39_32_GET(buf_addr_info)) << 32));
  335. dp_nofl_debug("[%s][%d] src_srng_desc=%pK, buf_addr=0x%llx, cookie=0x%llx",
  336. __func__, __LINE__, src_srng_desc, (unsigned long long)paddr,
  337. (unsigned long long)p_buffer_addr_info->sw_buffer_cookie);
  338. /* Structure copy !!! */
  339. *wbm_srng_buffer_addr_info =
  340. *((struct buffer_addr_info *)buf_addr_info);
  341. }
  342. /**
  343. * hal_get_rx_msdu_link_desc_size() - Get msdu link descriptor size
  344. *
  345. * Return: size of rx_msdu_link
  346. */
  347. static inline
  348. uint32_t hal_get_rx_msdu_link_desc_size(void)
  349. {
  350. return sizeof(struct rx_msdu_link);
  351. }
  352. enum {
  353. HAL_PKT_TYPE_OFDM = 0,
  354. HAL_PKT_TYPE_CCK,
  355. HAL_PKT_TYPE_HT,
  356. HAL_PKT_TYPE_VHT,
  357. HAL_PKT_TYPE_HE,
  358. };
  359. enum {
  360. HAL_SGI_0_8_US,
  361. HAL_SGI_0_4_US,
  362. HAL_SGI_1_6_US,
  363. HAL_SGI_3_2_US,
  364. };
  365. enum {
  366. HAL_FULL_RX_BW_20,
  367. HAL_FULL_RX_BW_40,
  368. HAL_FULL_RX_BW_80,
  369. HAL_FULL_RX_BW_160,
  370. };
  371. enum {
  372. HAL_RX_TYPE_SU,
  373. HAL_RX_TYPE_MU_MIMO,
  374. HAL_RX_TYPE_MU_OFDMA,
  375. HAL_RX_TYPE_MU_OFDMA_MIMO,
  376. };
  377. /**
  378. * enum
  379. * @HAL_RX_MON_PPDU_START: PPDU start TLV is decoded in HAL
  380. * @HAL_RX_MON_PPDU_END: PPDU end TLV is decoded in HAL
  381. * @HAL_RX_MON_PPDU_RESET: Not PPDU start and end TLV
  382. */
  383. enum {
  384. HAL_RX_MON_PPDU_START = 0,
  385. HAL_RX_MON_PPDU_END,
  386. HAL_RX_MON_PPDU_RESET,
  387. };
  388. /* struct hal_rx_ppdu_common_info - common ppdu info
  389. * @ppdu_id - ppdu id number
  390. * @ppdu_timestamp - timestamp at ppdu received
  391. * @mpdu_cnt_fcs_ok - mpdu count in ppdu with fcs ok
  392. * @mpdu_cnt_fcs_err - mpdu count in ppdu with fcs err
  393. * @mpdu_fcs_ok_bitmap - fcs ok mpdu count in ppdu bitmap
  394. * @last_ppdu_id - last received ppdu id
  395. * @mpdu_cnt - total mpdu count
  396. * @num_users - num users
  397. */
  398. struct hal_rx_ppdu_common_info {
  399. uint32_t ppdu_id;
  400. uint32_t ppdu_timestamp;
  401. uint32_t mpdu_cnt_fcs_ok;
  402. uint32_t mpdu_cnt_fcs_err;
  403. uint32_t mpdu_fcs_ok_bitmap[HAL_RX_NUM_WORDS_PER_PPDU_BITMAP];
  404. uint32_t last_ppdu_id;
  405. uint32_t mpdu_cnt;
  406. uint8_t num_users;
  407. };
  408. /**
  409. * struct hal_rx_msdu_payload_info - msdu payload info
  410. * @first_msdu_payload: pointer to first msdu payload
  411. * @payload_len: payload len
  412. */
  413. struct hal_rx_msdu_payload_info {
  414. uint8_t *first_msdu_payload;
  415. uint32_t payload_len;
  416. };
  417. /**
  418. * struct hal_rx_nac_info - struct for neighbour info
  419. * @fc_valid: flag indicate if it has valid frame control information
  420. * @frame_control: frame control from each MPDU
  421. * @to_ds_flag: flag indicate to_ds bit
  422. * @mac_addr2_valid: flag indicate if mac_addr2 is valid
  423. * @mac_addr2: mac address2 in wh
  424. * @mcast_bcast: multicast/broadcast
  425. */
  426. struct hal_rx_nac_info {
  427. uint8_t fc_valid;
  428. uint16_t frame_control;
  429. uint8_t to_ds_flag;
  430. uint8_t mac_addr2_valid;
  431. uint8_t mac_addr2[QDF_MAC_ADDR_SIZE];
  432. uint8_t mcast_bcast;
  433. };
  434. /**
  435. * struct hal_rx_ppdu_msdu_info - struct for msdu info from HW TLVs
  436. * @cce_metadata: cached CCE metadata value received in the MSDU_END TLV
  437. * @is_flow_idx_timeout: flag to indicate if flow search timeout occurred
  438. * @is_flow_idx_invalid: flag to indicate if flow idx is valid or not
  439. * @fse_metadata: cached FSE metadata value received in the MSDU END TLV
  440. * @flow_idx: flow idx matched in FSE received in the MSDU END TLV
  441. */
  442. struct hal_rx_ppdu_msdu_info {
  443. uint16_t cce_metadata;
  444. bool is_flow_idx_timeout;
  445. bool is_flow_idx_invalid;
  446. uint32_t fse_metadata;
  447. uint32_t flow_idx;
  448. };
  449. #if defined(WLAN_CFR_ENABLE) && defined(WLAN_ENH_CFR_ENABLE)
  450. /**
  451. * struct hal_rx_ppdu_cfr_user_info - struct for storing peer info extracted
  452. * from HW TLVs, this will be used for correlating CFR data with multiple peers
  453. * in MU PPDUs
  454. *
  455. * @peer_macaddr: macaddr of the peer
  456. * @ast_index: AST index of the peer
  457. */
  458. struct hal_rx_ppdu_cfr_user_info {
  459. uint8_t peer_macaddr[QDF_MAC_ADDR_SIZE];
  460. uint32_t ast_index;
  461. };
  462. /**
  463. * struct hal_rx_ppdu_cfr_info - struct for storing ppdu info extracted from HW
  464. * TLVs, this will be used for CFR correlation
  465. *
  466. * @bb_captured_channel : Set by RXPCU when MACRX_FREEZE_CAPTURE_CHANNEL TLV is
  467. * sent to PHY, SW checks it to correlate current PPDU TLVs with uploaded
  468. * channel information.
  469. *
  470. * @bb_captured_timeout : Set by RxPCU to indicate channel capture condition is
  471. * met, but MACRX_FREEZE_CAPTURE_CHANNEL is not sent to PHY due to AST delay,
  472. * which means the rx_frame_falling edge to FREEZE TLV ready time exceeds
  473. * the threshold time defined by RXPCU register FREEZE_TLV_DELAY_CNT_THRESH.
  474. * Bb_captured_reason is still valid in this case.
  475. *
  476. * @rx_location_info_valid: Indicates whether CFR DMA address in the PPDU TLV
  477. * is valid
  478. * <enum 0 rx_location_info_is_not_valid>
  479. * <enum 1 rx_location_info_is_valid>
  480. * <legal all>
  481. *
  482. * @bb_captured_reason : Copy capture_reason of MACRX_FREEZE_CAPTURE_CHANNEL
  483. * TLV to here for FW usage. Valid when bb_captured_channel or
  484. * bb_captured_timeout is set.
  485. * <enum 0 freeze_reason_TM>
  486. * <enum 1 freeze_reason_FTM>
  487. * <enum 2 freeze_reason_ACK_resp_to_TM_FTM>
  488. * <enum 3 freeze_reason_TA_RA_TYPE_FILTER>
  489. * <enum 4 freeze_reason_NDPA_NDP>
  490. * <enum 5 freeze_reason_ALL_PACKET>
  491. * <legal 0-5>
  492. *
  493. * @rtt_che_buffer_pointer_low32 : The low 32 bits of the 40 bits pointer to
  494. * external RTT channel information buffer
  495. *
  496. * @rtt_che_buffer_pointer_high8 : The high 8 bits of the 40 bits pointer to
  497. * external RTT channel information buffer
  498. *
  499. * @chan_capture_status : capture status reported by ucode
  500. * a. CAPTURE_IDLE: FW has disabled "REPETITIVE_CHE_CAPTURE_CTRL"
  501. * b. CAPTURE_BUSY: previous PPDU’s channel capture upload DMA ongoing. (Note
  502. * that this upload is triggered after receiving freeze_channel_capture TLV
  503. * after last PPDU is rx)
  504. * c. CAPTURE_ACTIVE: channel capture is enabled and no previous channel
  505. * capture ongoing
  506. * d. CAPTURE_NO_BUFFER: next buffer in IPC ring not available
  507. *
  508. * @cfr_user_info: Peer mac for upto 4 MU users
  509. *
  510. * @rtt_cfo_measurement : raw cfo data extracted from hardware, which is 14 bit
  511. * signed number. The first bit used for sign representation and 13 bits for
  512. * fractional part.
  513. *
  514. * @agc_gain_info0: Chain 0 & chain 1 agc gain information reported by PHY
  515. *
  516. * @agc_gain_info1: Chain 2 & chain 3 agc gain information reported by PHY
  517. *
  518. * @agc_gain_info2: Chain 4 & chain 5 agc gain information reported by PHY
  519. *
  520. * @agc_gain_info3: Chain 6 & chain 7 agc gain information reported by PHY
  521. *
  522. * @rx_start_ts: Rx packet timestamp, the time the first L-STF ADC sample
  523. * arrived at Rx antenna.
  524. *
  525. * @mcs_rate: Indicates the mcs/rate in which packet is received.
  526. * If HT,
  527. * 0-7: MCS0-MCS7
  528. * If VHT,
  529. * 0-9: MCS0 to MCS9
  530. * If HE,
  531. * 0-11: MCS0 to MCS11,
  532. * 12-13: 4096QAM,
  533. * 14-15: reserved
  534. * If Legacy,
  535. * 0: 48 Mbps
  536. * 1: 24 Mbps
  537. * 2: 12 Mbps
  538. * 3: 6 Mbps
  539. * 4: 54 Mbps
  540. * 5: 36 Mbps
  541. * 6: 18 Mbps
  542. * 7: 9 Mbps
  543. *
  544. * @gi_type: Indicates the gaurd interval.
  545. * 0: 0.8 us
  546. * 1: 0.4 us
  547. * 2: 1.6 us
  548. * 3: 3.2 us
  549. */
  550. struct hal_rx_ppdu_cfr_info {
  551. bool bb_captured_channel;
  552. bool bb_captured_timeout;
  553. uint8_t bb_captured_reason;
  554. bool rx_location_info_valid;
  555. uint8_t chan_capture_status;
  556. uint8_t rtt_che_buffer_pointer_high8;
  557. uint32_t rtt_che_buffer_pointer_low32;
  558. struct hal_rx_ppdu_cfr_user_info cfr_user_info[HAL_MAX_UL_MU_USERS];
  559. int16_t rtt_cfo_measurement;
  560. uint32_t agc_gain_info0;
  561. uint32_t agc_gain_info1;
  562. uint32_t agc_gain_info2;
  563. uint32_t agc_gain_info3;
  564. uint32_t rx_start_ts;
  565. uint32_t mcs_rate;
  566. uint32_t gi_type;
  567. };
  568. #else
  569. struct hal_rx_ppdu_cfr_info {};
  570. #endif
  571. struct mon_rx_info {
  572. uint8_t qos_control_info_valid;
  573. uint16_t qos_control;
  574. uint8_t mac_addr1_valid;
  575. uint8_t mac_addr1[QDF_MAC_ADDR_SIZE];
  576. uint32_t user_id;
  577. };
  578. struct mon_rx_user_info {
  579. uint16_t qos_control;
  580. uint8_t qos_control_info_valid;
  581. };
  582. struct hal_rx_ppdu_info {
  583. struct hal_rx_ppdu_common_info com_info;
  584. struct mon_rx_status rx_status;
  585. struct mon_rx_user_status rx_user_status[HAL_MAX_UL_MU_USERS];
  586. struct mon_rx_info rx_info;
  587. struct mon_rx_user_info rx_user_info[HAL_MAX_UL_MU_USERS];
  588. struct hal_rx_msdu_payload_info msdu_info;
  589. struct hal_rx_msdu_payload_info fcs_ok_msdu_info;
  590. struct hal_rx_nac_info nac_info;
  591. /* status ring PPDU start and end state */
  592. uint32_t rx_state;
  593. /* MU user id for status ring TLV */
  594. uint32_t user_id;
  595. /* MPDU/MSDU truncated to 128 bytes header start addr in status skb */
  596. unsigned char *data;
  597. /* MPDU/MSDU truncated to 128 bytes header real length */
  598. uint32_t hdr_len;
  599. /* MPDU FCS error */
  600. bool fcs_err;
  601. /* Id to indicate how to process mpdu */
  602. uint8_t sw_frame_group_id;
  603. struct hal_rx_ppdu_msdu_info rx_msdu_info[HAL_MAX_UL_MU_USERS];
  604. /* fcs passed mpdu count in rx monitor status buffer */
  605. uint8_t fcs_ok_cnt;
  606. /* fcs error mpdu count in rx monitor status buffer */
  607. uint8_t fcs_err_cnt;
  608. /* MPDU FCS passed */
  609. bool is_fcs_passed;
  610. /* first msdu payload for all mpdus in rx monitor status buffer */
  611. struct hal_rx_msdu_payload_info ppdu_msdu_info[HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER];
  612. /* evm info */
  613. struct hal_rx_su_evm_info evm_info;
  614. /**
  615. * Will be used to store ppdu info extracted from HW TLVs,
  616. * and for CFR correlation as well
  617. */
  618. struct hal_rx_ppdu_cfr_info cfr_info;
  619. };
  620. static inline uint32_t
  621. hal_get_rx_status_buf_size(void) {
  622. /* RX status buffer size is hard coded for now */
  623. return 2048;
  624. }
  625. static inline uint8_t*
  626. hal_rx_status_get_next_tlv(uint8_t *rx_tlv) {
  627. uint32_t tlv_len, tlv_tag;
  628. tlv_len = HAL_RX_GET_USER_TLV32_LEN(rx_tlv);
  629. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(rx_tlv);
  630. /* The actual length of PPDU_END is the combined length of many PHY
  631. * TLVs that follow. Skip the TLV header and
  632. * rx_rxpcu_classification_overview that follows the header to get to
  633. * next TLV.
  634. */
  635. if (tlv_tag == WIFIRX_PPDU_END_E)
  636. tlv_len = sizeof(struct rx_rxpcu_classification_overview);
  637. return (uint8_t *)(((unsigned long)(rx_tlv + tlv_len +
  638. HAL_RX_TLV32_HDR_SIZE + 3)) & (~((unsigned long)3)));
  639. }
  640. /**
  641. * hal_rx_proc_phyrx_other_receive_info_tlv()
  642. * - process other receive info TLV
  643. * @rx_tlv_hdr: pointer to TLV header
  644. * @ppdu_info: pointer to ppdu_info
  645. *
  646. * Return: None
  647. */
  648. static inline void hal_rx_proc_phyrx_other_receive_info_tlv(struct hal_soc *hal_soc,
  649. void *rx_tlv_hdr,
  650. struct hal_rx_ppdu_info
  651. *ppdu_info)
  652. {
  653. hal_soc->ops->hal_rx_proc_phyrx_other_receive_info_tlv(rx_tlv_hdr,
  654. (void *)ppdu_info);
  655. }
  656. /**
  657. * hal_rx_status_get_tlv_info() - process receive info TLV
  658. * @rx_tlv_hdr: pointer to TLV header
  659. * @ppdu_info: pointer to ppdu_info
  660. * @hal_soc: HAL soc handle
  661. * @nbuf: PPDU status netowrk buffer
  662. *
  663. * Return: HAL_TLV_STATUS_PPDU_NOT_DONE or HAL_TLV_STATUS_PPDU_DONE from tlv
  664. */
  665. static inline uint32_t
  666. hal_rx_status_get_tlv_info(void *rx_tlv_hdr, void *ppdu_info,
  667. hal_soc_handle_t hal_soc_hdl,
  668. qdf_nbuf_t nbuf)
  669. {
  670. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  671. return hal_soc->ops->hal_rx_status_get_tlv_info(
  672. rx_tlv_hdr,
  673. ppdu_info,
  674. hal_soc_hdl,
  675. nbuf);
  676. }
  677. static inline
  678. uint32_t hal_get_rx_status_done_tlv_size(hal_soc_handle_t hal_soc_hdl)
  679. {
  680. return HAL_RX_TLV32_HDR_SIZE;
  681. }
  682. static inline QDF_STATUS
  683. hal_get_rx_status_done(uint8_t *rx_tlv)
  684. {
  685. uint32_t tlv_tag;
  686. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(rx_tlv);
  687. if (tlv_tag == WIFIRX_STATUS_BUFFER_DONE_E)
  688. return QDF_STATUS_SUCCESS;
  689. else
  690. return QDF_STATUS_E_EMPTY;
  691. }
  692. static inline QDF_STATUS
  693. hal_clear_rx_status_done(uint8_t *rx_tlv)
  694. {
  695. *(uint32_t *)rx_tlv = 0;
  696. return QDF_STATUS_SUCCESS;
  697. }
  698. #endif