hal_8074v1_rx.h 10 KB

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