dp_rx_mon_feature.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /*
  2. * Copyright (c) 2017-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 "dp_types.h"
  20. #include "dp_rx.h"
  21. #include "dp_peer.h"
  22. #include "hal_rx.h"
  23. #include "hal_api.h"
  24. #include "qdf_trace.h"
  25. #include "qdf_nbuf.h"
  26. #include "hal_api_mon.h"
  27. #include "dp_rx_mon.h"
  28. #include "dp_internal.h"
  29. #include "qdf_mem.h" /* qdf_mem_malloc,free */
  30. #ifdef WLAN_RX_PKT_CAPTURE_ENH
  31. static inline void
  32. dp_rx_free_msdu_list(struct msdu_list *msdu_list)
  33. {
  34. qdf_nbuf_list_free(msdu_list->head);
  35. msdu_list->head = NULL;
  36. msdu_list->tail = NULL;
  37. msdu_list->sum_len = 0;
  38. }
  39. /**
  40. * dp_nbuf_set_data_and_len() - set nbuf data and len
  41. * @buf: Network buf instance
  42. * @data: pointer to nbuf data
  43. * @len: nbuf data length
  44. *
  45. * Return: none
  46. */
  47. static inline void dp_nbuf_set_data_and_len(qdf_nbuf_t buf, unsigned char *data
  48. , int len)
  49. {
  50. qdf_nbuf_set_data_pointer(buf, data);
  51. qdf_nbuf_set_len(buf, len);
  52. qdf_nbuf_set_tail_pointer(buf, len);
  53. }
  54. /*
  55. * dp_rx_populate_cdp_indication_mpdu_info() - Populate cdp rx indication
  56. * MPDU info structure
  57. * @pdev: pdev ctx
  58. * @ppdu_info: ppdu info structure from monitor status ring
  59. * @cdp_mpdu_info: cdp rx indication MPDU info structure
  60. * @user: user ID
  61. *
  62. * Return: none
  63. */
  64. void
  65. dp_rx_populate_cdp_indication_mpdu_info(
  66. struct dp_pdev *pdev,
  67. struct hal_rx_ppdu_info *ppdu_info,
  68. struct cdp_rx_indication_mpdu_info *cdp_mpdu_info,
  69. uint32_t user)
  70. {
  71. int i;
  72. cdp_mpdu_info->ppdu_id = ppdu_info->com_info.ppdu_id;
  73. cdp_mpdu_info->duration = ppdu_info->rx_status.duration;
  74. cdp_mpdu_info->bw = ppdu_info->rx_status.bw;
  75. if ((ppdu_info->rx_status.sgi == VHT_SGI_NYSM) &&
  76. (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC))
  77. cdp_mpdu_info->gi = CDP_SGI_0_4_US;
  78. else
  79. cdp_mpdu_info->gi = ppdu_info->rx_status.sgi;
  80. cdp_mpdu_info->ldpc = ppdu_info->rx_status.ldpc;
  81. cdp_mpdu_info->preamble = ppdu_info->rx_status.preamble_type;
  82. cdp_mpdu_info->ppdu_type = ppdu_info->rx_status.reception_type;
  83. cdp_mpdu_info->rssi_comb = ppdu_info->rx_status.rssi_comb;
  84. cdp_mpdu_info->timestamp = ppdu_info->rx_status.tsft;
  85. cdp_mpdu_info->nss = ppdu_info->rx_user_status[user].nss;
  86. cdp_mpdu_info->mcs = ppdu_info->rx_user_status[user].mcs;
  87. for (i = 0; i < MAX_CHAIN; i++)
  88. cdp_mpdu_info->per_chain_rssi[i] = ppdu_info->rx_status.rssi[i];
  89. }
  90. /*
  91. * dp_rx_handle_enh_capture() - Deliver Rx enhanced capture data
  92. * @pdev: pdev ctx
  93. * @ppdu_info: ppdu info structure from monitor status ring
  94. *
  95. * Return: QDF status
  96. */
  97. QDF_STATUS
  98. dp_rx_handle_enh_capture(struct dp_soc *soc, struct dp_pdev *pdev,
  99. struct hal_rx_ppdu_info *ppdu_info)
  100. {
  101. qdf_nbuf_t nbuf;
  102. uint32_t user;
  103. qdf_nbuf_queue_t *mpdu_q;
  104. struct cdp_rx_indication_mpdu *mpdu_ind;
  105. struct cdp_rx_indication_mpdu_info *mpdu_info;
  106. struct msdu_list *msdu_list;
  107. user = 0;
  108. mpdu_q = &pdev->mpdu_q[user];
  109. while (!qdf_nbuf_is_queue_empty(mpdu_q)) {
  110. msdu_list = &pdev->msdu_list[user];
  111. dp_rx_free_msdu_list(msdu_list);
  112. mpdu_ind = &pdev->mpdu_ind[user];
  113. mpdu_info = &mpdu_ind->mpdu_info;
  114. dp_rx_populate_cdp_indication_mpdu_info(
  115. pdev, &pdev->ppdu_info, mpdu_info, user);
  116. while (!qdf_nbuf_is_queue_empty(mpdu_q)) {
  117. nbuf = qdf_nbuf_queue_remove(mpdu_q);
  118. mpdu_ind->nbuf = nbuf;
  119. mpdu_info->fcs_err = QDF_NBUF_CB_RX_FCS_ERR(nbuf);
  120. dp_wdi_event_handler(WDI_EVENT_RX_MPDU,
  121. soc, mpdu_ind, HTT_INVALID_PEER,
  122. WDI_NO_VAL, pdev->pdev_id);
  123. }
  124. user++;
  125. mpdu_q = &pdev->mpdu_q[user];
  126. }
  127. return QDF_STATUS_SUCCESS;
  128. }
  129. /*
  130. * dp_rx_mon_enh_capture_process() - Rx enhanced capture mode
  131. * processing.
  132. * @pdev: pdev structure
  133. * @tlv_status: processed TLV status
  134. * @status_nbuf: monitor status ring buffer
  135. * @ppdu_info: ppdu info structure from monitor status ring
  136. * @nbuf_used: nbuf need a clone
  137. * @rx_enh_capture_mode: Rx enhanced capture mode
  138. *
  139. * Return: none
  140. */
  141. void
  142. dp_rx_mon_enh_capture_process(struct dp_pdev *pdev, uint32_t tlv_status,
  143. qdf_nbuf_t status_nbuf,
  144. struct hal_rx_ppdu_info *ppdu_info,
  145. bool *nbuf_used,
  146. uint32_t rx_enh_capture_mode)
  147. {
  148. qdf_nbuf_t nbuf;
  149. struct msdu_list *msdu_list;
  150. uint32_t user_id;
  151. if (rx_enh_capture_mode == CDP_RX_ENH_CAPTURE_DISABLED)
  152. return;
  153. user_id = ppdu_info->user_id;
  154. if ((tlv_status == HAL_TLV_STATUS_HEADER) && (
  155. (rx_enh_capture_mode == CDP_RX_ENH_CAPTURE_MPDU_MSDU) ||
  156. ((rx_enh_capture_mode == CDP_RX_ENH_CAPTURE_MPDU) &&
  157. pdev->is_mpdu_hdr[user_id]))) {
  158. if (*nbuf_used) {
  159. nbuf = qdf_nbuf_clone(status_nbuf);
  160. } else {
  161. *nbuf_used = true;
  162. nbuf = status_nbuf;
  163. }
  164. dp_nbuf_set_data_and_len(nbuf, ppdu_info->data,
  165. ppdu_info->hdr_len);
  166. if (pdev->is_mpdu_hdr[user_id]) {
  167. qdf_nbuf_queue_add(&pdev->mpdu_q[user_id],
  168. nbuf);
  169. pdev->is_mpdu_hdr[user_id] = false;
  170. } else {
  171. msdu_list = &pdev->msdu_list[user_id];
  172. if (!msdu_list->head)
  173. msdu_list->head = nbuf;
  174. else
  175. msdu_list->tail->next = nbuf;
  176. msdu_list->tail = nbuf;
  177. msdu_list->sum_len += qdf_nbuf_len(nbuf);
  178. }
  179. }
  180. if (tlv_status == HAL_TLV_STATUS_MPDU_END) {
  181. msdu_list = &pdev->msdu_list[user_id];
  182. nbuf = qdf_nbuf_queue_last(&pdev->mpdu_q[user_id]);
  183. if (nbuf) {
  184. qdf_nbuf_append_ext_list(nbuf,
  185. msdu_list->head,
  186. msdu_list->sum_len);
  187. msdu_list->head = NULL;
  188. msdu_list->tail = NULL;
  189. msdu_list->sum_len = 0;
  190. QDF_NBUF_CB_RX_FCS_ERR(nbuf) = ppdu_info->fcs_err;
  191. pdev->is_mpdu_hdr[user_id] = true;
  192. } else {
  193. dp_rx_free_msdu_list(msdu_list);
  194. }
  195. }
  196. }
  197. /*
  198. * dp_config_enh_rx_capture()- API to enable/disable enhanced rx capture
  199. * @pdev_handle: DP_PDEV handle
  200. * @val: user provided value
  201. *
  202. * Return: 0 for success. nonzero for failure.
  203. */
  204. QDF_STATUS
  205. dp_config_enh_rx_capture(struct cdp_pdev *pdev_handle, int val)
  206. {
  207. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  208. if (pdev->mcopy_mode || (val < CDP_RX_ENH_CAPTURE_DISABLED) ||
  209. (val > CDP_RX_ENH_CAPTURE_MPDU_MSDU)) {
  210. dp_err("Invalid mode");
  211. return QDF_STATUS_E_INVAL;
  212. }
  213. if (pdev->rx_enh_capture_mode)
  214. dp_reset_monitor_mode(pdev_handle);
  215. pdev->rx_enh_capture_mode = val;
  216. return dp_pdev_configure_monitor_rings(pdev);
  217. }
  218. #endif