dp_rx_mon_feature.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  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. #include "wlan_cfg.h"
  31. #ifdef WLAN_RX_PKT_CAPTURE_ENH
  32. static inline void
  33. dp_rx_free_msdu_list(struct msdu_list *msdu_list)
  34. {
  35. qdf_nbuf_list_free(msdu_list->head);
  36. msdu_list->head = NULL;
  37. msdu_list->tail = NULL;
  38. msdu_list->sum_len = 0;
  39. }
  40. /**
  41. * dp_nbuf_set_data_and_len() - set nbuf data and len
  42. * @buf: Network buf instance
  43. * @data: pointer to nbuf data
  44. * @len: nbuf data length
  45. *
  46. * Return: none
  47. */
  48. static inline void
  49. dp_nbuf_set_data_and_len(qdf_nbuf_t buf, unsigned char *data,
  50. int len)
  51. {
  52. qdf_nbuf_set_data_pointer(buf, data);
  53. qdf_nbuf_set_len(buf, len);
  54. qdf_nbuf_set_tail_pointer(buf, len);
  55. }
  56. /*
  57. * dp_rx_populate_cdp_indication_mpdu_info() - Populate cdp rx indication
  58. * MPDU info structure
  59. * @pdev: pdev ctx
  60. * @ppdu_info: ppdu info structure from monitor status ring
  61. * @cdp_mpdu_info: cdp rx indication MPDU info structure
  62. * @user: user ID
  63. *
  64. * Return: none
  65. */
  66. void
  67. dp_rx_populate_cdp_indication_mpdu_info(
  68. struct dp_pdev *pdev,
  69. struct hal_rx_ppdu_info *ppdu_info,
  70. struct cdp_rx_indication_mpdu_info *cdp_mpdu_info,
  71. uint32_t user)
  72. {
  73. int i;
  74. struct mon_rx_user_status *rx_user_status;
  75. cdp_mpdu_info->ppdu_id = ppdu_info->com_info.ppdu_id;
  76. cdp_mpdu_info->channel = ppdu_info->rx_status.chan_num;
  77. cdp_mpdu_info->duration = ppdu_info->rx_status.duration;
  78. cdp_mpdu_info->timestamp = ppdu_info->rx_status.tsft;
  79. cdp_mpdu_info->bw = ppdu_info->rx_status.bw;
  80. if ((ppdu_info->rx_status.sgi == VHT_SGI_NYSM) &&
  81. (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC))
  82. cdp_mpdu_info->gi = CDP_SGI_0_4_US;
  83. else
  84. cdp_mpdu_info->gi = ppdu_info->rx_status.sgi;
  85. cdp_mpdu_info->ldpc = ppdu_info->rx_status.ldpc;
  86. cdp_mpdu_info->preamble = ppdu_info->rx_status.preamble_type;
  87. cdp_mpdu_info->ppdu_type = ppdu_info->rx_status.reception_type;
  88. cdp_mpdu_info->rssi_comb = ppdu_info->rx_status.rssi_comb;
  89. cdp_mpdu_info->nf = ppdu_info->rx_status.chan_noise_floor;
  90. if (ppdu_info->rx_status.reception_type == HAL_RX_TYPE_MU_OFDMA) {
  91. rx_user_status = &ppdu_info->rx_user_status[user];
  92. cdp_mpdu_info->nss = rx_user_status->nss;
  93. cdp_mpdu_info->mcs = rx_user_status->mcs;
  94. cdp_mpdu_info->ofdma_info_valid =
  95. rx_user_status->ofdma_info_valid;
  96. cdp_mpdu_info->ofdma_ru_start_index =
  97. rx_user_status->dl_ofdma_ru_start_index;
  98. cdp_mpdu_info->ofdma_ru_width =
  99. rx_user_status->dl_ofdma_ru_width;
  100. } else {
  101. cdp_mpdu_info->nss = ppdu_info->rx_status.nss;
  102. cdp_mpdu_info->mcs = ppdu_info->rx_status.mcs;
  103. }
  104. cdp_mpdu_info->rate = ppdu_info->rx_status.rate;
  105. for (i = 0; i < MAX_CHAIN; i++)
  106. cdp_mpdu_info->per_chain_rssi[i] = ppdu_info->rx_status.rssi[i];
  107. }
  108. #ifdef WLAN_SUPPORT_RX_FLOW_TAG
  109. /**
  110. * dp_rx_mon_enh_capture_set_flow_tag() - Tags the actual nbuf with
  111. * cached flow tag data read from TLV
  112. * @pdev: pdev structure
  113. * @ppdu_info: ppdu info structure from monitor status ring
  114. * @user_id: user ID on which the PPDU is received
  115. * @nbuf: packet buffer on which metadata have to be updated
  116. *
  117. * Return: None
  118. */
  119. void dp_rx_mon_enh_capture_set_flow_tag(struct dp_pdev *pdev,
  120. struct hal_rx_ppdu_info *ppdu_info,
  121. uint32_t user_id, qdf_nbuf_t nbuf)
  122. {
  123. struct dp_soc *soc = pdev->soc;
  124. uint16_t fse_metadata;
  125. if (user_id >= MAX_MU_USERS)
  126. return;
  127. if (qdf_likely(!wlan_cfg_is_rx_flow_tag_enabled(soc->wlan_cfg_ctx)))
  128. return;
  129. if (ppdu_info->rx_msdu_info[user_id].is_flow_idx_invalid)
  130. return;
  131. if (ppdu_info->rx_msdu_info[user_id].is_flow_idx_timeout)
  132. return;
  133. fse_metadata =
  134. (uint16_t)ppdu_info->rx_msdu_info[user_id].fse_metadata & 0xFFFF;
  135. /* update the skb->cb with the user-specified tag/metadata */
  136. qdf_nbuf_set_rx_flow_tag(nbuf, fse_metadata);
  137. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  138. "Setting flow tag %u for userID %u", fse_metadata, user_id);
  139. ppdu_info->rx_msdu_info[user_id].fse_metadata = 0;
  140. ppdu_info->rx_msdu_info[user_id].flow_idx = 0;
  141. ppdu_info->rx_msdu_info[user_id].is_flow_idx_timeout = false;
  142. ppdu_info->rx_msdu_info[user_id].is_flow_idx_invalid = false;
  143. }
  144. /**
  145. * dp_rx_mon_enh_capture_set_flow_tag_in_trailer - update msdu trailer
  146. * with flow tag
  147. * @nbuf: packet buffer on which metadata have to be updated
  148. * @trailer: pointer to rx monitor-lite trailer
  149. *
  150. * Return: None
  151. */
  152. static inline void dp_rx_mon_enh_capture_set_flow_tag_in_trailer(
  153. qdf_nbuf_t nbuf, void *trailer)
  154. {
  155. uint16_t flow_tag = qdf_nbuf_get_rx_flow_tag(nbuf);
  156. struct dp_rx_mon_enh_trailer_data *nbuf_trailer =
  157. (struct dp_rx_mon_enh_trailer_data *)trailer;
  158. if (!flow_tag)
  159. return;
  160. nbuf_trailer->flow_tag = flow_tag;
  161. }
  162. #else
  163. void dp_rx_mon_enh_capture_set_flow_tag(struct dp_pdev *pdev,
  164. struct hal_rx_ppdu_info *ppdu_info,
  165. uint32_t user_id, qdf_nbuf_t nbuf)
  166. {
  167. }
  168. static inline void dp_rx_mon_enh_capture_set_flow_tag_in_trailer(
  169. qdf_nbuf_t nbuf, void *trailer)
  170. {
  171. }
  172. #endif /* WLAN_SUPPORT_RX_FLOW_TAG */
  173. #ifdef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
  174. /*
  175. * dp_rx_mon_enh_capture_set_protocol_tag() - Tags the actual nbuf with
  176. * cached protocol tag data read from TLV
  177. * @pdev: pdev structure
  178. * @ppdu_info: ppdu info structure from monitor status ring
  179. * @user_id: user ID on which the PPDU is received
  180. * @nbuf: packet buffer on which metadata have to be updated
  181. *
  182. * Return: none
  183. */
  184. static void
  185. dp_rx_mon_enh_capture_set_protocol_tag(struct dp_pdev *pdev,
  186. struct hal_rx_ppdu_info *ppdu_info,
  187. uint32_t user_id,
  188. qdf_nbuf_t nbuf)
  189. {
  190. uint32_t cce_metadata = 0;
  191. uint16_t protocol_tag = 0;
  192. if (user_id >= MAX_MU_USERS)
  193. return;
  194. /**
  195. * Since skb->cb is memset to 0, we can skip setting protocol tag to 0
  196. * in all the error paths.
  197. */
  198. cce_metadata = ppdu_info->rx_msdu_info[user_id].cce_metadata;
  199. /**
  200. * Received CCE metadata should be
  201. * within the valid limits
  202. */
  203. if (qdf_unlikely((cce_metadata < RX_PROTOCOL_TAG_START_OFFSET) ||
  204. (cce_metadata >= (RX_PROTOCOL_TAG_START_OFFSET
  205. + RX_PROTOCOL_TAG_MAX))))
  206. return;
  207. /**
  208. * The CCE metadata received is just the
  209. * packet_type + RX_PROTOCOL_TAG_START_OFFSET
  210. */
  211. cce_metadata -= RX_PROTOCOL_TAG_START_OFFSET;
  212. /**
  213. * Update the QDF packet with the user specified tag/metadata
  214. * by looking up tag value for received protocol type.
  215. */
  216. protocol_tag = pdev->rx_proto_tag_map[cce_metadata].tag;
  217. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  218. "Setting ProtoID:%d Tag %u in mon nbuf",
  219. cce_metadata, protocol_tag);
  220. qdf_nbuf_set_rx_protocol_tag(nbuf, protocol_tag);
  221. }
  222. /*
  223. * dp_rx_mon_enh_capture_tag_protocol_type() - Support protocol tagging
  224. * for packets captured in enhanced capture mode
  225. * @pdev: pdev structure
  226. * @ppdu_info: ppdu info structure from monitor status ring
  227. * @user_id: user ID on which the PPDU is received
  228. * @nbuf: packet buffer on which tag should be updated
  229. *
  230. * Return: none
  231. */
  232. static void
  233. dp_rx_mon_enh_capture_tag_protocol_type(struct dp_pdev *pdev,
  234. struct hal_rx_ppdu_info *ppdu_info,
  235. uint32_t user_id, qdf_nbuf_t nbuf)
  236. {
  237. /**
  238. * Since skb->cb is memset to 0, we can skip setting protocol tag to 0
  239. * in all the error paths.
  240. */
  241. if (!pdev->is_rx_protocol_tagging_enabled)
  242. return;
  243. /**
  244. * It is assumed that we have already received RX Header/ MSDU
  245. * Start TLV for this MSDU.
  246. */
  247. dp_rx_mon_enh_capture_set_protocol_tag(pdev, ppdu_info,
  248. user_id, nbuf);
  249. /* Reset MSDU tag variables on completion of every MSDU tag */
  250. ppdu_info->rx_msdu_info[user_id].cce_metadata = 0;
  251. }
  252. /*
  253. * dp_rx_mon_enh_capture_set_protocol_tag_in_trailer - update msdu trailer
  254. * with protocol tag
  255. * @nbuf: packet buffer on which metadata have to be updated
  256. * @trailer: pointer to rx monitor-lite trailer
  257. *
  258. * Return: void
  259. */
  260. static inline
  261. void dp_rx_mon_enh_capture_set_protocol_tag_in_trailer(qdf_nbuf_t nbuf,
  262. void *trailer)
  263. {
  264. uint16_t protocol_tag = qdf_nbuf_get_rx_protocol_tag(nbuf);
  265. struct dp_rx_mon_enh_trailer_data *nbuf_trailer =
  266. (struct dp_rx_mon_enh_trailer_data *)trailer;
  267. if (protocol_tag != 0)
  268. nbuf_trailer->protocol_tag = protocol_tag;
  269. }
  270. #else
  271. static void
  272. dp_rx_mon_enh_capture_tag_protocol_type(struct dp_pdev *pdev,
  273. struct hal_rx_ppdu_info *ppdu_info,
  274. uint32_t user_id, qdf_nbuf_t nbuf)
  275. {
  276. }
  277. static void
  278. dp_rx_mon_enh_capture_set_protocol_tag(struct dp_pdev *pdev,
  279. struct hal_rx_ppdu_info *ppdu_info,
  280. uint32_t user_id, qdf_nbuf_t nbuf)
  281. {
  282. }
  283. static inline
  284. void dp_rx_mon_enh_capture_set_protocol_tag_in_trailer(qdf_nbuf_t nbuf,
  285. void *trailer)
  286. {
  287. }
  288. #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
  289. /*
  290. * dp_rx_mon_enh_capture_update_trailer() - Update trailer with custom data
  291. * @pdev: pdev structure
  292. * @nbuf: packet buffer on which metadata have to be updated
  293. *
  294. * Return: return number of bytes updated in the tail
  295. */
  296. static inline
  297. uint16_t dp_rx_mon_enh_capture_update_trailer(struct dp_pdev *pdev,
  298. qdf_nbuf_t nbuf)
  299. {
  300. uint64_t trailer;
  301. uint8_t *dest;
  302. struct dp_soc *soc = pdev->soc;
  303. struct dp_rx_mon_enh_trailer_data *nbuf_trailer =
  304. (struct dp_rx_mon_enh_trailer_data *)&trailer;
  305. if (qdf_unlikely(qdf_nbuf_len(nbuf) < sizeof(trailer)))
  306. return 0;
  307. trailer = RX_MON_CAP_ENH_TRAILER;
  308. if (wlan_cfg_is_rx_mon_protocol_flow_tag_enabled(soc->wlan_cfg_ctx)) {
  309. dp_rx_mon_enh_capture_set_protocol_tag_in_trailer(nbuf,
  310. nbuf_trailer);
  311. dp_rx_mon_enh_capture_set_flow_tag_in_trailer(nbuf,
  312. nbuf_trailer);
  313. }
  314. /**
  315. * Overwrite last 8 bytes of data with trailer. This is ok since we
  316. * do not care about the data in this debug mode.
  317. */
  318. qdf_nbuf_trim_tail(nbuf, sizeof(trailer));
  319. dest = qdf_nbuf_put_tail(nbuf, sizeof(trailer));
  320. if (qdf_likely(dest)) {
  321. qdf_mem_copy(dest, &trailer, sizeof(trailer));
  322. } else {
  323. dp_err("Unable to add tail room");
  324. return 0;
  325. }
  326. return sizeof(trailer);
  327. }
  328. /*
  329. * dp_rx_handle_enh_capture() - Deliver Rx enhanced capture data
  330. * @pdev: pdev ctx
  331. * @ppdu_info: ppdu info structure from monitor status ring
  332. *
  333. * Return: QDF status
  334. */
  335. QDF_STATUS
  336. dp_rx_handle_enh_capture(struct dp_soc *soc, struct dp_pdev *pdev,
  337. struct hal_rx_ppdu_info *ppdu_info)
  338. {
  339. qdf_nbuf_t mpdu_head;
  340. uint32_t user;
  341. qdf_nbuf_queue_t *mpdu_q;
  342. struct cdp_rx_indication_mpdu *mpdu_ind;
  343. struct cdp_rx_indication_mpdu_info *mpdu_info;
  344. struct msdu_list *msdu_list;
  345. user = 0;
  346. mpdu_q = &pdev->mpdu_q[user];
  347. while (!qdf_nbuf_is_queue_empty(mpdu_q) && user < MAX_MU_USERS) {
  348. msdu_list = &pdev->msdu_list[user];
  349. dp_rx_free_msdu_list(msdu_list);
  350. mpdu_ind = &pdev->mpdu_ind[user];
  351. mpdu_info = &mpdu_ind->mpdu_info;
  352. pdev->is_mpdu_hdr[user] = true;
  353. dp_rx_populate_cdp_indication_mpdu_info(
  354. pdev, &pdev->ppdu_info, mpdu_info, user);
  355. while ((mpdu_head = qdf_nbuf_queue_remove(mpdu_q))) {
  356. mpdu_ind->nbuf = mpdu_head;
  357. mpdu_info->fcs_err =
  358. QDF_NBUF_CB_RX_FCS_ERR(mpdu_head);
  359. dp_wdi_event_handler(WDI_EVENT_RX_MPDU,
  360. soc, mpdu_ind, HTT_INVALID_PEER,
  361. WDI_NO_VAL, pdev->pdev_id);
  362. }
  363. user++;
  364. mpdu_q = &pdev->mpdu_q[user];
  365. }
  366. return QDF_STATUS_SUCCESS;
  367. }
  368. /*
  369. * dp_rx_mon_enh_capture_process() - Rx enhanced capture mode
  370. * processing.
  371. * @pdev: pdev structure
  372. * @tlv_status: processed TLV status
  373. * @status_nbuf: monitor status ring buffer
  374. * @ppdu_info: ppdu info structure from monitor status ring
  375. * @nbuf_used: nbuf need a clone
  376. *
  377. * Return: none
  378. */
  379. void
  380. dp_rx_mon_enh_capture_process(struct dp_pdev *pdev, uint32_t tlv_status,
  381. qdf_nbuf_t status_nbuf,
  382. struct hal_rx_ppdu_info *ppdu_info,
  383. bool *nbuf_used)
  384. {
  385. qdf_nbuf_t nbuf;
  386. struct msdu_list *msdu_list;
  387. uint32_t user_id;
  388. struct dp_soc *soc;
  389. qdf_nbuf_t mpdu_head;
  390. if (pdev->rx_enh_capture_mode == CDP_RX_ENH_CAPTURE_DISABLED)
  391. return;
  392. user_id = ppdu_info->user_id;
  393. if (user_id >= MAX_MU_USERS)
  394. return;
  395. if ((tlv_status == HAL_TLV_STATUS_HEADER) && (
  396. (pdev->rx_enh_capture_mode == CDP_RX_ENH_CAPTURE_MPDU_MSDU) ||
  397. ((pdev->rx_enh_capture_mode == CDP_RX_ENH_CAPTURE_MPDU) &&
  398. pdev->is_mpdu_hdr[user_id]))) {
  399. if (*nbuf_used) {
  400. nbuf = qdf_nbuf_clone(status_nbuf);
  401. } else {
  402. *nbuf_used = true;
  403. nbuf = status_nbuf;
  404. }
  405. if (!nbuf)
  406. return;
  407. /* Truncate 4 bytes containing PPDU ID */
  408. dp_nbuf_set_data_and_len(nbuf, ppdu_info->data,
  409. ppdu_info->hdr_len - 4);
  410. if (pdev->is_mpdu_hdr[user_id]) {
  411. soc = pdev->soc;
  412. mpdu_head = qdf_nbuf_alloc(soc->osdev,
  413. RX_ENH_CB_BUF_SIZE + RX_ENH_CB_BUF_RESERVATION,
  414. RX_ENH_CB_BUF_RESERVATION,
  415. RX_ENH_CB_BUF_ALIGNMENT,
  416. FALSE);
  417. if (mpdu_head == NULL)
  418. return;
  419. qdf_nbuf_queue_add(&pdev->mpdu_q[user_id],
  420. mpdu_head);
  421. pdev->is_mpdu_hdr[user_id] = false;
  422. }
  423. msdu_list = &pdev->msdu_list[user_id];
  424. if (!msdu_list->head)
  425. msdu_list->head = nbuf;
  426. else
  427. msdu_list->tail->next = nbuf;
  428. msdu_list->tail = nbuf;
  429. msdu_list->sum_len += qdf_nbuf_len(nbuf);
  430. }
  431. if (tlv_status == HAL_TLV_STATUS_MPDU_END) {
  432. msdu_list = &pdev->msdu_list[user_id];
  433. mpdu_head = qdf_nbuf_queue_last(&pdev->mpdu_q[user_id]);
  434. if (mpdu_head) {
  435. qdf_nbuf_append_ext_list(mpdu_head,
  436. msdu_list->head,
  437. msdu_list->sum_len);
  438. msdu_list->head = NULL;
  439. msdu_list->tail = NULL;
  440. msdu_list->sum_len = 0;
  441. QDF_NBUF_CB_RX_FCS_ERR(mpdu_head)
  442. = ppdu_info->fcs_err;
  443. } else {
  444. dp_rx_free_msdu_list(msdu_list);
  445. }
  446. pdev->is_mpdu_hdr[user_id] = true;
  447. }
  448. /* Tag the MSDU/MPDU if a cce_metadata is valid */
  449. if ((tlv_status == HAL_TLV_STATUS_MSDU_END) &&
  450. (pdev->rx_enh_capture_mode == CDP_RX_ENH_CAPTURE_MPDU_MSDU)) {
  451. bool is_rx_mon_protocol_flow_tag_en;
  452. /**
  453. * Proceed only if this is a data frame.
  454. * We could also rx probes, etc.
  455. */
  456. if (!(ppdu_info->nac_info.fc_valid &&
  457. (IEEE80211_FC0_TYPE_DATA ==
  458. (ppdu_info->nac_info.frame_control &
  459. IEEE80211_FC0_TYPE_MASK))))
  460. return;
  461. msdu_list = &pdev->msdu_list[user_id];
  462. qdf_assert_always(msdu_list->head);
  463. /**
  464. * Directly move the last MSDU and fetch the same.
  465. * The earlier MSDUs should already be tagged as the
  466. * packets are tagged at the end of every RX
  467. * MSDU.
  468. */
  469. nbuf = msdu_list->tail;
  470. is_rx_mon_protocol_flow_tag_en =
  471. wlan_cfg_is_rx_mon_protocol_flow_tag_enabled(
  472. pdev->soc->wlan_cfg_ctx);
  473. if (is_rx_mon_protocol_flow_tag_en) {
  474. /* Set the protocol tag value from CCE metadata */
  475. dp_rx_mon_enh_capture_tag_protocol_type(pdev, ppdu_info,
  476. user_id, nbuf);
  477. /* Set the flow tag from FSE metadata */
  478. dp_rx_mon_enh_capture_set_flow_tag(pdev, ppdu_info,
  479. user_id, nbuf);
  480. }
  481. if (!pdev->is_rx_enh_capture_trailer_enabled)
  482. return;
  483. /**
  484. * Update necessary information in trailer (for debug purpose)
  485. */
  486. dp_rx_mon_enh_capture_update_trailer(pdev, nbuf);
  487. }
  488. }
  489. /*
  490. * dp_config_enh_rx_capture()- API to enable/disable enhanced rx capture
  491. * @pdev_handle: DP_PDEV handle
  492. * @val: user provided value
  493. *
  494. * Return: 0 for success. nonzero for failure.
  495. */
  496. QDF_STATUS
  497. dp_config_enh_rx_capture(struct cdp_pdev *pdev_handle, uint8_t val)
  498. {
  499. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  500. uint8_t rx_cap_mode = (val & RX_ENH_CAPTURE_MODE_MASK);
  501. bool is_mpdu_hdr = false;
  502. uint8_t user_id;
  503. if (pdev->mcopy_mode || (rx_cap_mode < CDP_RX_ENH_CAPTURE_DISABLED) ||
  504. (rx_cap_mode > CDP_RX_ENH_CAPTURE_MPDU_MSDU)) {
  505. dp_err("Invalid mode: %d", rx_cap_mode);
  506. return QDF_STATUS_E_INVAL;
  507. }
  508. dp_reset_monitor_mode(pdev_handle);
  509. pdev->rx_enh_capture_mode = rx_cap_mode;
  510. if (rx_cap_mode != CDP_RX_ENH_CAPTURE_DISABLED)
  511. is_mpdu_hdr = true;
  512. for (user_id = 0; user_id < MAX_MU_USERS; user_id++)
  513. pdev->is_mpdu_hdr[user_id] = is_mpdu_hdr;
  514. /* Use a bit from val to enable MSDU trailer for internal debug use */
  515. pdev->is_rx_enh_capture_trailer_enabled =
  516. (val & RX_ENH_CAPTURE_TRAILER_ENABLE_MASK) ? true : false;
  517. return dp_pdev_configure_monitor_rings(pdev);
  518. }
  519. #endif /* WLAN_RX_PKT_CAPTURE_ENH */