hal_8074v1_rx.h 10 KB

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