hal_6390_rx.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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. #define HAL_RX_MSDU_START_MIMO_SS_BITMAP(_rx_msdu_start)\
  38. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start),\
  39. RX_MSDU_START_5_MIMO_SS_BITMAP_OFFSET)), \
  40. RX_MSDU_START_5_MIMO_SS_BITMAP_MASK, \
  41. RX_MSDU_START_5_MIMO_SS_BITMAP_LSB))
  42. /*
  43. * hal_rx_msdu_start_nss_get_6390(): API to get the NSS
  44. * Interval from rx_msdu_start
  45. *
  46. * @buf: pointer to the start of RX PKT TLV header
  47. * Return: uint32_t(nss)
  48. */
  49. static uint32_t
  50. hal_rx_msdu_start_nss_get_6390(uint8_t *buf)
  51. {
  52. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  53. struct rx_msdu_start *msdu_start =
  54. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  55. uint8_t mimo_ss_bitmap;
  56. mimo_ss_bitmap = HAL_RX_MSDU_START_MIMO_SS_BITMAP(msdu_start);
  57. return qdf_get_hweight8(mimo_ss_bitmap);
  58. }
  59. /**
  60. * hal_rx_mon_hw_desc_get_mpdu_status_6390(): Retrieve MPDU status
  61. *
  62. * @ hw_desc_addr: Start address of Rx HW TLVs
  63. * @ rs: Status for monitor mode
  64. *
  65. * Return: void
  66. */
  67. static void hal_rx_mon_hw_desc_get_mpdu_status_6390(void *hw_desc_addr,
  68. struct mon_rx_status *rs)
  69. {
  70. struct rx_msdu_start *rx_msdu_start;
  71. struct rx_pkt_tlvs *rx_desc = (struct rx_pkt_tlvs *)hw_desc_addr;
  72. uint32_t reg_value;
  73. const uint32_t sgi_hw_to_cdp[] = {
  74. CDP_SGI_0_8_US,
  75. CDP_SGI_0_4_US,
  76. CDP_SGI_1_6_US,
  77. CDP_SGI_3_2_US,
  78. };
  79. rx_msdu_start = &rx_desc->msdu_start_tlv.rx_msdu_start;
  80. HAL_RX_GET_MSDU_AGGREGATION(rx_desc, rs);
  81. rs->ant_signal_db = HAL_RX_GET(rx_msdu_start,
  82. RX_MSDU_START_5, USER_RSSI);
  83. rs->is_stbc = HAL_RX_GET(rx_msdu_start, RX_MSDU_START_5, STBC);
  84. reg_value = HAL_RX_GET(rx_msdu_start, RX_MSDU_START_5, SGI);
  85. rs->sgi = sgi_hw_to_cdp[reg_value];
  86. reg_value = HAL_RX_GET(rx_msdu_start, RX_MSDU_START_5, RECEPTION_TYPE);
  87. rs->beamformed = (reg_value == HAL_RX_RECEPTION_TYPE_MU_MIMO) ? 1 : 0;
  88. /* TODO: rs->beamformed should be set for SU beamforming also */
  89. }
  90. #define LINK_DESC_SIZE (NUM_OF_DWORDS_RX_MSDU_LINK << 2)
  91. static uint32_t hal_get_link_desc_size_6390(void)
  92. {
  93. return LINK_DESC_SIZE;
  94. }
  95. /*
  96. * hal_rx_get_tlv_6390(): API to get the tlv
  97. *
  98. * @rx_tlv: TLV data extracted from the rx packet
  99. * Return: uint8_t
  100. */
  101. static uint8_t hal_rx_get_tlv_6390(void *rx_tlv)
  102. {
  103. return HAL_RX_GET(rx_tlv, PHYRX_RSSI_LEGACY_0, RECEIVE_BANDWIDTH);
  104. }
  105. /**
  106. * hal_rx_proc_phyrx_other_receive_info_tlv_6390()
  107. * - process other receive info TLV
  108. * @rx_tlv_hdr: pointer to TLV header
  109. * @ppdu_info: pointer to ppdu_info
  110. *
  111. * Return: None
  112. */
  113. static
  114. void hal_rx_proc_phyrx_other_receive_info_tlv_6390(void *rx_tlv_hdr,
  115. void *ppdu_info_handle)
  116. {
  117. uint32_t tlv_tag, tlv_len;
  118. uint32_t temp_len, other_tlv_len, other_tlv_tag;
  119. void *rx_tlv = (uint8_t *)rx_tlv_hdr + HAL_RX_TLV32_HDR_SIZE;
  120. void *other_tlv_hdr = NULL;
  121. void *other_tlv = NULL;
  122. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(rx_tlv_hdr);
  123. tlv_len = HAL_RX_GET_USER_TLV32_LEN(rx_tlv_hdr);
  124. temp_len = 0;
  125. other_tlv_hdr = rx_tlv + HAL_RX_TLV32_HDR_SIZE;
  126. other_tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(other_tlv_hdr);
  127. other_tlv_len = HAL_RX_GET_USER_TLV32_LEN(other_tlv_hdr);
  128. temp_len += other_tlv_len;
  129. other_tlv = other_tlv_hdr + HAL_RX_TLV32_HDR_SIZE;
  130. switch (other_tlv_tag) {
  131. default:
  132. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  133. "%s unhandled TLV type: %d, TLV len:%d",
  134. __func__, other_tlv_tag, other_tlv_len);
  135. break;
  136. }
  137. }
  138. /**
  139. * hal_rx_dump_msdu_start_tlv_6390() : dump RX msdu_start TLV in structured
  140. * human readable format.
  141. * @ msdu_start: pointer the msdu_start TLV in pkt.
  142. * @ dbg_level: log level.
  143. *
  144. * Return: void
  145. */
  146. static void hal_rx_dump_msdu_start_tlv_6390(void *msdustart, uint8_t dbg_level)
  147. {
  148. struct rx_msdu_start *msdu_start = (struct rx_msdu_start *)msdustart;
  149. hal_verbose_debug(
  150. "rx_msdu_start tlv (1/2) - "
  151. "rxpcu_mpdu_filter_in_category: %x "
  152. "sw_frame_group_id: %x "
  153. "phy_ppdu_id: %x "
  154. "msdu_length: %x "
  155. "ipsec_esp: %x "
  156. "l3_offset: %x "
  157. "ipsec_ah: %x "
  158. "l4_offset: %x "
  159. "msdu_number: %x "
  160. "decap_format: %x "
  161. "ipv4_proto: %x "
  162. "ipv6_proto: %x "
  163. "tcp_proto: %x "
  164. "udp_proto: %x "
  165. "ip_frag: %x "
  166. "tcp_only_ack: %x "
  167. "da_is_bcast_mcast: %x "
  168. "ip4_protocol_ip6_next_header: %x "
  169. "toeplitz_hash_2_or_4: %x "
  170. "flow_id_toeplitz: %x "
  171. "user_rssi: %x "
  172. "pkt_type: %x "
  173. "stbc: %x "
  174. "sgi: %x "
  175. "rate_mcs: %x "
  176. "receive_bandwidth: %x "
  177. "reception_type: %x "
  178. "ppdu_start_timestamp: %u ",
  179. msdu_start->rxpcu_mpdu_filter_in_category,
  180. msdu_start->sw_frame_group_id,
  181. msdu_start->phy_ppdu_id,
  182. msdu_start->msdu_length,
  183. msdu_start->ipsec_esp,
  184. msdu_start->l3_offset,
  185. msdu_start->ipsec_ah,
  186. msdu_start->l4_offset,
  187. msdu_start->msdu_number,
  188. msdu_start->decap_format,
  189. msdu_start->ipv4_proto,
  190. msdu_start->ipv6_proto,
  191. msdu_start->tcp_proto,
  192. msdu_start->udp_proto,
  193. msdu_start->ip_frag,
  194. msdu_start->tcp_only_ack,
  195. msdu_start->da_is_bcast_mcast,
  196. msdu_start->ip4_protocol_ip6_next_header,
  197. msdu_start->toeplitz_hash_2_or_4,
  198. msdu_start->flow_id_toeplitz,
  199. msdu_start->user_rssi,
  200. msdu_start->pkt_type,
  201. msdu_start->stbc,
  202. msdu_start->sgi,
  203. msdu_start->rate_mcs,
  204. msdu_start->receive_bandwidth,
  205. msdu_start->reception_type,
  206. msdu_start->ppdu_start_timestamp);
  207. hal_verbose_debug(
  208. "rx_msdu_start tlv (2/2) - "
  209. "sw_phy_meta_data: %x ",
  210. msdu_start->sw_phy_meta_data);
  211. }
  212. /**
  213. * hal_rx_dump_msdu_end_tlv_6390: dump RX msdu_end TLV in structured
  214. * human readable format.
  215. * @ msdu_end: pointer the msdu_end TLV in pkt.
  216. * @ dbg_level: log level.
  217. *
  218. * Return: void
  219. */
  220. static void hal_rx_dump_msdu_end_tlv_6390(void *msduend,
  221. uint8_t dbg_level)
  222. {
  223. struct rx_msdu_end *msdu_end = (struct rx_msdu_end *)msduend;
  224. QDF_TRACE(QDF_MODULE_ID_DP, dbg_level,
  225. "rx_msdu_end tlv (1/2) - "
  226. "rxpcu_mpdu_filter_in_category: %x "
  227. "sw_frame_group_id: %x "
  228. "phy_ppdu_id: %x "
  229. "ip_hdr_chksum: %x "
  230. "tcp_udp_chksum: %x "
  231. "key_id_octet: %x "
  232. "cce_super_rule: %x "
  233. "cce_classify_not_done_truncat: %x "
  234. "cce_classify_not_done_cce_dis: %x "
  235. "ext_wapi_pn_63_48: %x "
  236. "ext_wapi_pn_95_64: %x "
  237. "ext_wapi_pn_127_96: %x "
  238. "reported_mpdu_length: %x "
  239. "first_msdu: %x "
  240. "last_msdu: %x "
  241. "sa_idx_timeout: %x "
  242. "da_idx_timeout: %x "
  243. "msdu_limit_error: %x "
  244. "flow_idx_timeout: %x "
  245. "flow_idx_invalid: %x "
  246. "wifi_parser_error: %x "
  247. "amsdu_parser_error: %x",
  248. msdu_end->rxpcu_mpdu_filter_in_category,
  249. msdu_end->sw_frame_group_id,
  250. msdu_end->phy_ppdu_id,
  251. msdu_end->ip_hdr_chksum,
  252. msdu_end->tcp_udp_chksum,
  253. msdu_end->key_id_octet,
  254. msdu_end->cce_super_rule,
  255. msdu_end->cce_classify_not_done_truncate,
  256. msdu_end->cce_classify_not_done_cce_dis,
  257. msdu_end->ext_wapi_pn_63_48,
  258. msdu_end->ext_wapi_pn_95_64,
  259. msdu_end->ext_wapi_pn_127_96,
  260. msdu_end->reported_mpdu_length,
  261. msdu_end->first_msdu,
  262. msdu_end->last_msdu,
  263. msdu_end->sa_idx_timeout,
  264. msdu_end->da_idx_timeout,
  265. msdu_end->msdu_limit_error,
  266. msdu_end->flow_idx_timeout,
  267. msdu_end->flow_idx_invalid,
  268. msdu_end->wifi_parser_error,
  269. msdu_end->amsdu_parser_error);
  270. QDF_TRACE(QDF_MODULE_ID_DP, dbg_level,
  271. "rx_msdu_end tlv (2/2)- "
  272. "sa_is_valid: %x "
  273. "da_is_valid: %x "
  274. "da_is_mcbc: %x "
  275. "l3_header_padding: %x "
  276. "ipv6_options_crc: %x "
  277. "tcp_seq_number: %x "
  278. "tcp_ack_number: %x "
  279. "tcp_flag: %x "
  280. "lro_eligible: %x "
  281. "window_size: %x "
  282. "da_offset: %x "
  283. "sa_offset: %x "
  284. "da_offset_valid: %x "
  285. "sa_offset_valid: %x "
  286. "rule_indication_31_0: %x "
  287. "rule_indication_63_32: %x "
  288. "sa_idx: %x "
  289. "da_idx: %x "
  290. "msdu_drop: %x "
  291. "reo_destination_indication: %x "
  292. "flow_idx: %x "
  293. "fse_metadata: %x "
  294. "cce_metadata: %x "
  295. "sa_sw_peer_id: %x ",
  296. msdu_end->sa_is_valid,
  297. msdu_end->da_is_valid,
  298. msdu_end->da_is_mcbc,
  299. msdu_end->l3_header_padding,
  300. msdu_end->ipv6_options_crc,
  301. msdu_end->tcp_seq_number,
  302. msdu_end->tcp_ack_number,
  303. msdu_end->tcp_flag,
  304. msdu_end->lro_eligible,
  305. msdu_end->window_size,
  306. msdu_end->da_offset,
  307. msdu_end->sa_offset,
  308. msdu_end->da_offset_valid,
  309. msdu_end->sa_offset_valid,
  310. msdu_end->rule_indication_31_0,
  311. msdu_end->rule_indication_63_32,
  312. msdu_end->sa_idx,
  313. msdu_end->da_idx_or_sw_peer_id,
  314. msdu_end->msdu_drop,
  315. msdu_end->reo_destination_indication,
  316. msdu_end->flow_idx,
  317. msdu_end->fse_metadata,
  318. msdu_end->cce_metadata,
  319. msdu_end->sa_sw_peer_id);
  320. }
  321. /*
  322. * Get tid from RX_MPDU_START
  323. */
  324. #define HAL_RX_MPDU_INFO_TID_GET(_rx_mpdu_info) \
  325. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_mpdu_info), \
  326. RX_MPDU_INFO_3_TID_OFFSET)), \
  327. RX_MPDU_INFO_3_TID_MASK, \
  328. RX_MPDU_INFO_3_TID_LSB))
  329. static uint32_t hal_rx_mpdu_start_tid_get_6390(uint8_t *buf)
  330. {
  331. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  332. struct rx_mpdu_start *mpdu_start =
  333. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  334. uint32_t tid;
  335. tid = HAL_RX_MPDU_INFO_TID_GET(&mpdu_start->rx_mpdu_info_details);
  336. return tid;
  337. }
  338. #define HAL_RX_MSDU_START_RECEPTION_TYPE_GET(_rx_msdu_start) \
  339. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start), \
  340. RX_MSDU_START_5_RECEPTION_TYPE_OFFSET)), \
  341. RX_MSDU_START_5_RECEPTION_TYPE_MASK, \
  342. RX_MSDU_START_5_RECEPTION_TYPE_LSB))
  343. /*
  344. * hal_rx_msdu_start_reception_type_get(): API to get the reception type
  345. * Interval from rx_msdu_start
  346. *
  347. * @buf: pointer to the start of RX PKT TLV header
  348. * Return: uint32_t(reception_type)
  349. */
  350. static
  351. uint32_t hal_rx_msdu_start_reception_type_get_6390(uint8_t *buf)
  352. {
  353. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  354. struct rx_msdu_start *msdu_start =
  355. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  356. uint32_t reception_type;
  357. reception_type = HAL_RX_MSDU_START_RECEPTION_TYPE_GET(msdu_start);
  358. return reception_type;
  359. }
  360. #define HAL_RX_MSDU_END_DA_IDX_GET(_rx_msdu_end) \
  361. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  362. RX_MSDU_END_13_DA_IDX_OR_SW_PEER_ID_OFFSET)), \
  363. RX_MSDU_END_13_DA_IDX_OR_SW_PEER_ID_MASK, \
  364. RX_MSDU_END_13_DA_IDX_OR_SW_PEER_ID_LSB))
  365. /**
  366. * hal_rx_msdu_end_da_idx_get_6390: API to get da_idx
  367. * from rx_msdu_end TLV
  368. *
  369. * @ buf: pointer to the start of RX PKT TLV headers
  370. * Return: da index
  371. */
  372. static uint16_t hal_rx_msdu_end_da_idx_get_6390(uint8_t *buf)
  373. {
  374. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  375. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  376. uint16_t da_idx;
  377. da_idx = HAL_RX_MSDU_END_DA_IDX_GET(msdu_end);
  378. return da_idx;
  379. }