hal_6290_rx.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. /*
  2. * Copyright (c) 2016-2019 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. #include "qdf_util.h"
  19. #include "qdf_types.h"
  20. #include "qdf_lock.h"
  21. #include "qdf_mem.h"
  22. #include "qdf_nbuf.h"
  23. #include "tcl_data_cmd.h"
  24. #include "mac_tcl_reg_seq_hwioreg.h"
  25. #include "phyrx_rssi_legacy.h"
  26. #include "rx_msdu_start.h"
  27. #include "tlv_tag_def.h"
  28. #include "hal_hw_headers.h"
  29. #include "hal_internal.h"
  30. #include "cdp_txrx_mon_struct.h"
  31. #include "qdf_trace.h"
  32. #include "hal_rx.h"
  33. #include "hal_tx.h"
  34. #include "dp_types.h"
  35. #include "hal_api_mon.h"
  36. #include "phyrx_other_receive_info_ru_details.h"
  37. #if defined(QCA_WIFI_QCA6290_11AX)
  38. #define HAL_RX_MSDU_START_MIMO_SS_BITMAP(_rx_msdu_start)\
  39. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start),\
  40. RX_MSDU_START_5_MIMO_SS_BITMAP_OFFSET)), \
  41. RX_MSDU_START_5_MIMO_SS_BITMAP_MASK, \
  42. RX_MSDU_START_5_MIMO_SS_BITMAP_LSB))
  43. /*
  44. * hal_rx_msdu_start_nss_get_6290(): API to get the NSS
  45. * Interval from rx_msdu_start
  46. *
  47. * @buf: pointer to the start of RX PKT TLV header
  48. * Return: uint32_t(nss)
  49. */
  50. static uint32_t
  51. hal_rx_msdu_start_nss_get_6290(uint8_t *buf)
  52. {
  53. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  54. struct rx_msdu_start *msdu_start =
  55. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  56. uint8_t mimo_ss_bitmap;
  57. mimo_ss_bitmap = HAL_RX_MSDU_START_MIMO_SS_BITMAP(msdu_start);
  58. return qdf_get_hweight8(mimo_ss_bitmap);
  59. }
  60. #else
  61. static uint32_t
  62. hal_rx_msdu_start_nss_get_6290(uint8_t *buf)
  63. {
  64. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  65. struct rx_msdu_start *msdu_start =
  66. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  67. uint32_t nss;
  68. nss = HAL_RX_MSDU_START_NSS_GET(msdu_start);
  69. return nss;
  70. }
  71. #endif
  72. /**
  73. * hal_rx_mon_hw_desc_get_mpdu_status_6290(): Retrieve MPDU status
  74. *
  75. * @ hw_desc_addr: Start address of Rx HW TLVs
  76. * @ rs: Status for monitor mode
  77. *
  78. * Return: void
  79. */
  80. static void hal_rx_mon_hw_desc_get_mpdu_status_6290(void *hw_desc_addr,
  81. struct mon_rx_status *rs)
  82. {
  83. struct rx_msdu_start *rx_msdu_start;
  84. struct rx_pkt_tlvs *rx_desc = (struct rx_pkt_tlvs *)hw_desc_addr;
  85. uint32_t reg_value;
  86. const uint32_t sgi_hw_to_cdp[] = {
  87. CDP_SGI_0_8_US,
  88. CDP_SGI_0_4_US,
  89. CDP_SGI_1_6_US,
  90. CDP_SGI_3_2_US,
  91. };
  92. rx_msdu_start = &rx_desc->msdu_start_tlv.rx_msdu_start;
  93. HAL_RX_GET_MSDU_AGGREGATION(rx_desc, rs);
  94. rs->ant_signal_db = HAL_RX_GET(rx_msdu_start,
  95. RX_MSDU_START_5, USER_RSSI);
  96. rs->is_stbc = HAL_RX_GET(rx_msdu_start, RX_MSDU_START_5, STBC);
  97. reg_value = HAL_RX_GET(rx_msdu_start, RX_MSDU_START_5, SGI);
  98. rs->sgi = sgi_hw_to_cdp[reg_value];
  99. #if !defined(QCA_WIFI_QCA6290_11AX)
  100. rs->nr_ant = HAL_RX_GET(rx_msdu_start, RX_MSDU_START_5, NSS);
  101. #endif
  102. reg_value = HAL_RX_GET(rx_msdu_start, RX_MSDU_START_5, RECEPTION_TYPE);
  103. rs->beamformed = (reg_value == HAL_RX_RECEPTION_TYPE_MU_MIMO) ? 1 : 0;
  104. /* TODO: rs->beamformed should be set for SU beamforming also */
  105. }
  106. #define LINK_DESC_SIZE (NUM_OF_DWORDS_RX_MSDU_LINK << 2)
  107. static uint32_t hal_get_link_desc_size_6290(void)
  108. {
  109. return LINK_DESC_SIZE;
  110. }
  111. #ifdef QCA_WIFI_QCA6290_11AX
  112. /*
  113. * hal_rx_get_tlv_6290(): API to get the tlv
  114. *
  115. * @rx_tlv: TLV data extracted from the rx packet
  116. * Return: uint8_t
  117. */
  118. static uint8_t hal_rx_get_tlv_6290(void *rx_tlv)
  119. {
  120. return HAL_RX_GET(rx_tlv, PHYRX_RSSI_LEGACY_0, RECEIVE_BANDWIDTH);
  121. }
  122. #else
  123. static uint8_t hal_rx_get_tlv_6290(void *rx_tlv)
  124. {
  125. return HAL_RX_GET(rx_tlv, PHYRX_RSSI_LEGACY_35, RECEIVE_BANDWIDTH);
  126. }
  127. #endif
  128. #ifdef QCA_WIFI_QCA6290_11AX
  129. /**
  130. * hal_rx_proc_phyrx_other_receive_info_tlv_6290()
  131. * - process other receive info TLV
  132. * @rx_tlv_hdr: pointer to TLV header
  133. * @ppdu_info: pointer to ppdu_info
  134. *
  135. * Return: None
  136. */
  137. static
  138. void hal_rx_proc_phyrx_other_receive_info_tlv_6290(void *rx_tlv_hdr,
  139. void *ppdu_info_handle)
  140. {
  141. uint32_t tlv_tag, tlv_len;
  142. uint32_t temp_len, other_tlv_len, other_tlv_tag;
  143. void *rx_tlv = (uint8_t *)rx_tlv_hdr + HAL_RX_TLV32_HDR_SIZE;
  144. void *other_tlv_hdr = NULL;
  145. void *other_tlv = NULL;
  146. uint32_t ru_details_channel_0;
  147. struct hal_rx_ppdu_info *ppdu_info =
  148. (struct hal_rx_ppdu_info *)ppdu_info_handle;
  149. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(rx_tlv_hdr);
  150. tlv_len = HAL_RX_GET_USER_TLV32_LEN(rx_tlv_hdr);
  151. temp_len = 0;
  152. other_tlv_hdr = rx_tlv + HAL_RX_TLV32_HDR_SIZE;
  153. other_tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(other_tlv_hdr);
  154. other_tlv_len = HAL_RX_GET_USER_TLV32_LEN(other_tlv_hdr);
  155. temp_len += other_tlv_len;
  156. other_tlv = other_tlv_hdr + HAL_RX_TLV32_HDR_SIZE;
  157. switch (other_tlv_tag) {
  158. case WIFIPHYRX_OTHER_RECEIVE_INFO_RU_DETAILS_E:
  159. ru_details_channel_0 =
  160. HAL_RX_GET(other_tlv,
  161. PHYRX_OTHER_RECEIVE_INFO_RU_DETAILS_0,
  162. RU_DETAILS_CHANNEL_0);
  163. qdf_mem_copy(ppdu_info->rx_status.he_RU,
  164. &ru_details_channel_0,
  165. sizeof(ppdu_info->rx_status.he_RU));
  166. if (ppdu_info->rx_status.bw >= HAL_FULL_RX_BW_20) {
  167. ppdu_info->rx_status.he_sig_b_common_known |=
  168. QDF_MON_STATUS_HE_SIG_B_COMMON_KNOWN_RU0;
  169. }
  170. if (ppdu_info->rx_status.bw >= HAL_FULL_RX_BW_40) {
  171. ppdu_info->rx_status.he_sig_b_common_known |=
  172. QDF_MON_STATUS_HE_SIG_B_COMMON_KNOWN_RU1;
  173. }
  174. if (ppdu_info->rx_status.bw >= HAL_FULL_RX_BW_80) {
  175. ppdu_info->rx_status.he_sig_b_common_known |=
  176. QDF_MON_STATUS_HE_SIG_B_COMMON_KNOWN_RU2;
  177. }
  178. if (ppdu_info->rx_status.bw >= HAL_FULL_RX_BW_160) {
  179. ppdu_info->rx_status.he_sig_b_common_known |=
  180. QDF_MON_STATUS_HE_SIG_B_COMMON_KNOWN_RU3;
  181. }
  182. break;
  183. default:
  184. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  185. "%s unhandled TLV type: %d, TLV len:%d",
  186. __func__, other_tlv_tag, other_tlv_len);
  187. break;
  188. }
  189. }
  190. #else
  191. static
  192. void hal_rx_proc_phyrx_other_receive_info_tlv_6290(void *rx_tlv_hdr,
  193. void *ppdu_info_handle)
  194. {
  195. }
  196. #endif /* QCA_WIFI_QCA6290_11AX */
  197. /**
  198. * hal_rx_dump_msdu_start_tlv_6290() : dump RX msdu_start TLV in structured
  199. * human readable format.
  200. * @ msdu_start: pointer the msdu_start TLV in pkt.
  201. * @ dbg_level: log level.
  202. *
  203. * Return: void
  204. */
  205. static void hal_rx_dump_msdu_start_tlv_6290(void *msdustart,
  206. uint8_t dbg_level)
  207. {
  208. struct rx_msdu_start *msdu_start = (struct rx_msdu_start *)msdustart;
  209. QDF_TRACE(QDF_MODULE_ID_DP, dbg_level,
  210. "rx_msdu_start tlv - "
  211. "rxpcu_mpdu_filter_in_category: %d "
  212. "sw_frame_group_id: %d "
  213. "phy_ppdu_id: %d "
  214. "msdu_length: %d "
  215. "ipsec_esp: %d "
  216. "l3_offset: %d "
  217. "ipsec_ah: %d "
  218. "l4_offset: %d "
  219. "msdu_number: %d "
  220. "decap_format: %d "
  221. "ipv4_proto: %d "
  222. "ipv6_proto: %d "
  223. "tcp_proto: %d "
  224. "udp_proto: %d "
  225. "ip_frag: %d "
  226. "tcp_only_ack: %d "
  227. "da_is_bcast_mcast: %d "
  228. "ip4_protocol_ip6_next_header: %d "
  229. "toeplitz_hash_2_or_4: %d "
  230. "flow_id_toeplitz: %d "
  231. "user_rssi: %d "
  232. "pkt_type: %d "
  233. "stbc: %d "
  234. "sgi: %d "
  235. "rate_mcs: %d "
  236. "receive_bandwidth: %d "
  237. "reception_type: %d "
  238. #if !defined(QCA_WIFI_QCA6290_11AX)
  239. "toeplitz_hash: %d "
  240. "nss: %d "
  241. #endif
  242. "ppdu_start_timestamp: %d "
  243. "sw_phy_meta_data: %d ",
  244. msdu_start->rxpcu_mpdu_filter_in_category,
  245. msdu_start->sw_frame_group_id,
  246. msdu_start->phy_ppdu_id,
  247. msdu_start->msdu_length,
  248. msdu_start->ipsec_esp,
  249. msdu_start->l3_offset,
  250. msdu_start->ipsec_ah,
  251. msdu_start->l4_offset,
  252. msdu_start->msdu_number,
  253. msdu_start->decap_format,
  254. msdu_start->ipv4_proto,
  255. msdu_start->ipv6_proto,
  256. msdu_start->tcp_proto,
  257. msdu_start->udp_proto,
  258. msdu_start->ip_frag,
  259. msdu_start->tcp_only_ack,
  260. msdu_start->da_is_bcast_mcast,
  261. msdu_start->ip4_protocol_ip6_next_header,
  262. msdu_start->toeplitz_hash_2_or_4,
  263. msdu_start->flow_id_toeplitz,
  264. msdu_start->user_rssi,
  265. msdu_start->pkt_type,
  266. msdu_start->stbc,
  267. msdu_start->sgi,
  268. msdu_start->rate_mcs,
  269. msdu_start->receive_bandwidth,
  270. msdu_start->reception_type,
  271. #if !defined(QCA_WIFI_QCA6290_11AX)
  272. msdu_start->toeplitz_hash,
  273. msdu_start->nss,
  274. #endif
  275. msdu_start->ppdu_start_timestamp,
  276. msdu_start->sw_phy_meta_data);
  277. }
  278. /**
  279. * hal_rx_dump_msdu_end_tlv_6290: dump RX msdu_end TLV in structured
  280. * human readable format.
  281. * @ msdu_end: pointer the msdu_end TLV in pkt.
  282. * @ dbg_level: log level.
  283. *
  284. * Return: void
  285. */
  286. static void hal_rx_dump_msdu_end_tlv_6290(void *msduend,
  287. uint8_t dbg_level)
  288. {
  289. struct rx_msdu_end *msdu_end = (struct rx_msdu_end *)msduend;
  290. QDF_TRACE(QDF_MODULE_ID_DP, dbg_level,
  291. "rx_msdu_end tlv - "
  292. "rxpcu_mpdu_filter_in_category: %d "
  293. "sw_frame_group_id: %d "
  294. "phy_ppdu_id: %d "
  295. "ip_hdr_chksum: %d "
  296. "tcp_udp_chksum: %d "
  297. "key_id_octet: %d "
  298. "cce_super_rule: %d "
  299. "cce_classify_not_done_truncat: %d "
  300. "cce_classify_not_done_cce_dis: %d "
  301. "ext_wapi_pn_63_48: %d "
  302. "ext_wapi_pn_95_64: %d "
  303. "ext_wapi_pn_127_96: %d "
  304. "reported_mpdu_length: %d "
  305. "first_msdu: %d "
  306. "last_msdu: %d "
  307. "sa_idx_timeout: %d "
  308. "da_idx_timeout: %d "
  309. "msdu_limit_error: %d "
  310. "flow_idx_timeout: %d "
  311. "flow_idx_invalid: %d "
  312. "wifi_parser_error: %d "
  313. "amsdu_parser_error: %d "
  314. "sa_is_valid: %d "
  315. "da_is_valid: %d "
  316. "da_is_mcbc: %d "
  317. "l3_header_padding: %d "
  318. "ipv6_options_crc: %d "
  319. "tcp_seq_number: %d "
  320. "tcp_ack_number: %d "
  321. "tcp_flag: %d "
  322. "lro_eligible: %d "
  323. "window_size: %d "
  324. "da_offset: %d "
  325. "sa_offset: %d "
  326. "da_offset_valid: %d "
  327. "sa_offset_valid: %d "
  328. "rule_indication_31_0: %d "
  329. "rule_indication_63_32: %d "
  330. "sa_idx: %d "
  331. "da_idx: %d "
  332. "msdu_drop: %d "
  333. "reo_destination_indication: %d "
  334. "flow_idx: %d "
  335. "fse_metadata: %d "
  336. "cce_metadata: %d "
  337. "sa_sw_peer_id: %d ",
  338. msdu_end->rxpcu_mpdu_filter_in_category,
  339. msdu_end->sw_frame_group_id,
  340. msdu_end->phy_ppdu_id,
  341. msdu_end->ip_hdr_chksum,
  342. msdu_end->tcp_udp_chksum,
  343. msdu_end->key_id_octet,
  344. msdu_end->cce_super_rule,
  345. msdu_end->cce_classify_not_done_truncate,
  346. msdu_end->cce_classify_not_done_cce_dis,
  347. msdu_end->ext_wapi_pn_63_48,
  348. msdu_end->ext_wapi_pn_95_64,
  349. msdu_end->ext_wapi_pn_127_96,
  350. msdu_end->reported_mpdu_length,
  351. msdu_end->first_msdu,
  352. msdu_end->last_msdu,
  353. msdu_end->sa_idx_timeout,
  354. msdu_end->da_idx_timeout,
  355. msdu_end->msdu_limit_error,
  356. msdu_end->flow_idx_timeout,
  357. msdu_end->flow_idx_invalid,
  358. msdu_end->wifi_parser_error,
  359. msdu_end->amsdu_parser_error,
  360. msdu_end->sa_is_valid,
  361. msdu_end->da_is_valid,
  362. msdu_end->da_is_mcbc,
  363. msdu_end->l3_header_padding,
  364. msdu_end->ipv6_options_crc,
  365. msdu_end->tcp_seq_number,
  366. msdu_end->tcp_ack_number,
  367. msdu_end->tcp_flag,
  368. msdu_end->lro_eligible,
  369. msdu_end->window_size,
  370. msdu_end->da_offset,
  371. msdu_end->sa_offset,
  372. msdu_end->da_offset_valid,
  373. msdu_end->sa_offset_valid,
  374. msdu_end->rule_indication_31_0,
  375. msdu_end->rule_indication_63_32,
  376. msdu_end->sa_idx,
  377. msdu_end->da_idx,
  378. msdu_end->msdu_drop,
  379. msdu_end->reo_destination_indication,
  380. msdu_end->flow_idx,
  381. msdu_end->fse_metadata,
  382. msdu_end->cce_metadata,
  383. msdu_end->sa_sw_peer_id);
  384. }
  385. /*
  386. * Get tid from RX_MPDU_START
  387. */
  388. #define HAL_RX_MPDU_INFO_TID_GET(_rx_mpdu_info) \
  389. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_mpdu_info), \
  390. RX_MPDU_INFO_3_TID_OFFSET)), \
  391. RX_MPDU_INFO_3_TID_MASK, \
  392. RX_MPDU_INFO_3_TID_LSB))
  393. static uint32_t hal_rx_mpdu_start_tid_get_6290(uint8_t *buf)
  394. {
  395. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  396. struct rx_mpdu_start *mpdu_start =
  397. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  398. uint32_t tid;
  399. tid = HAL_RX_MPDU_INFO_TID_GET(&mpdu_start->rx_mpdu_info_details);
  400. return tid;
  401. }
  402. #define HAL_RX_MSDU_START_RECEPTION_TYPE_GET(_rx_msdu_start) \
  403. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start), \
  404. RX_MSDU_START_5_RECEPTION_TYPE_OFFSET)), \
  405. RX_MSDU_START_5_RECEPTION_TYPE_MASK, \
  406. RX_MSDU_START_5_RECEPTION_TYPE_LSB))
  407. /*
  408. * hal_rx_msdu_start_reception_type_get(): API to get the reception type
  409. * Interval from rx_msdu_start
  410. *
  411. * @buf: pointer to the start of RX PKT TLV header
  412. * Return: uint32_t(reception_type)
  413. */
  414. static uint32_t hal_rx_msdu_start_reception_type_get_6290(uint8_t *buf)
  415. {
  416. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  417. struct rx_msdu_start *msdu_start =
  418. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  419. uint32_t reception_type;
  420. reception_type = HAL_RX_MSDU_START_RECEPTION_TYPE_GET(msdu_start);
  421. return reception_type;
  422. }
  423. #define HAL_RX_MSDU_END_DA_IDX_GET(_rx_msdu_end) \
  424. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  425. RX_MSDU_END_13_DA_IDX_OFFSET)), \
  426. RX_MSDU_END_13_DA_IDX_MASK, \
  427. RX_MSDU_END_13_DA_IDX_LSB))
  428. /**
  429. * hal_rx_msdu_end_da_idx_get_6290: API to get da_idx
  430. * from rx_msdu_end TLV
  431. *
  432. * @ buf: pointer to the start of RX PKT TLV headers
  433. * Return: da index
  434. */
  435. static uint16_t hal_rx_msdu_end_da_idx_get_6290(uint8_t *buf)
  436. {
  437. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  438. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  439. uint16_t da_idx;
  440. da_idx = HAL_RX_MSDU_END_DA_IDX_GET(msdu_end);
  441. return da_idx;
  442. }