dp_rx_mon_feature.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  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_enh_capture_is_peer_enabled() - Is peer based enh capture enabled.
  330. * @soc: core txrx main context
  331. * @ppdu_info: Structure for rx ppdu info
  332. * @user_id: user id for MU Rx packet
  333. *
  334. * Return: none
  335. */
  336. static inline bool
  337. dp_rx_enh_capture_is_peer_enabled(struct dp_soc *soc,
  338. struct hal_rx_ppdu_info *ppdu_info,
  339. uint32_t user_id)
  340. {
  341. struct dp_peer *peer;
  342. struct dp_ast_entry *ast_entry;
  343. uint32_t ast_index;
  344. ast_index = ppdu_info->rx_user_status[user_id].ast_index;
  345. if (ast_index < wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  346. ast_entry = soc->ast_table[ast_index];
  347. if (ast_entry) {
  348. peer = ast_entry->peer;
  349. if (peer && (peer->peer_ids[0] != HTT_INVALID_PEER))
  350. return peer->rx_cap_enabled;
  351. }
  352. }
  353. return false;
  354. }
  355. /*
  356. * dp_rx_handle_enh_capture() - Deliver Rx enhanced capture data
  357. * @pdev: pdev ctx
  358. * @ppdu_info: ppdu info structure from monitor status ring
  359. *
  360. * Return: QDF status
  361. */
  362. QDF_STATUS
  363. dp_rx_handle_enh_capture(struct dp_soc *soc, struct dp_pdev *pdev,
  364. struct hal_rx_ppdu_info *ppdu_info)
  365. {
  366. qdf_nbuf_t mpdu_head;
  367. uint32_t user;
  368. qdf_nbuf_queue_t *mpdu_q;
  369. struct cdp_rx_indication_mpdu *mpdu_ind;
  370. struct cdp_rx_indication_mpdu_info *mpdu_info;
  371. struct msdu_list *msdu_list;
  372. user = 0;
  373. mpdu_q = &pdev->mpdu_q[user];
  374. while (!qdf_nbuf_is_queue_empty(mpdu_q) && user < MAX_MU_USERS) {
  375. msdu_list = &pdev->msdu_list[user];
  376. dp_rx_free_msdu_list(msdu_list);
  377. pdev->is_mpdu_hdr[user] = true;
  378. if (pdev->rx_enh_capture_peer &&
  379. !dp_rx_enh_capture_is_peer_enabled(
  380. soc, ppdu_info, user)) {
  381. qdf_nbuf_queue_free(mpdu_q);
  382. } else {
  383. mpdu_ind = &pdev->mpdu_ind;
  384. mpdu_info = &mpdu_ind->mpdu_info;
  385. dp_rx_populate_cdp_indication_mpdu_info(
  386. pdev, &pdev->ppdu_info, mpdu_info, user);
  387. while ((mpdu_head = qdf_nbuf_queue_remove(mpdu_q))) {
  388. mpdu_ind->nbuf = mpdu_head;
  389. mpdu_info->fcs_err =
  390. QDF_NBUF_CB_RX_FCS_ERR(mpdu_head);
  391. dp_wdi_event_handler(WDI_EVENT_RX_MPDU,
  392. soc, mpdu_ind,
  393. HTT_INVALID_PEER,
  394. WDI_NO_VAL,
  395. pdev->pdev_id);
  396. }
  397. }
  398. user++;
  399. mpdu_q = &pdev->mpdu_q[user];
  400. }
  401. return QDF_STATUS_SUCCESS;
  402. }
  403. /*
  404. * dp_rx_mon_enh_capture_process() - Rx enhanced capture mode
  405. * processing.
  406. * @pdev: pdev structure
  407. * @tlv_status: processed TLV status
  408. * @status_nbuf: monitor status ring buffer
  409. * @ppdu_info: ppdu info structure from monitor status ring
  410. * @nbuf_used: nbuf need a clone
  411. *
  412. * Return: none
  413. */
  414. void
  415. dp_rx_mon_enh_capture_process(struct dp_pdev *pdev, uint32_t tlv_status,
  416. qdf_nbuf_t status_nbuf,
  417. struct hal_rx_ppdu_info *ppdu_info,
  418. bool *nbuf_used)
  419. {
  420. qdf_nbuf_t nbuf;
  421. struct msdu_list *msdu_list;
  422. uint32_t user_id;
  423. struct dp_soc *soc;
  424. qdf_nbuf_t mpdu_head;
  425. if (pdev->rx_enh_capture_mode == CDP_RX_ENH_CAPTURE_DISABLED)
  426. return;
  427. user_id = ppdu_info->user_id;
  428. if (user_id >= MAX_MU_USERS)
  429. return;
  430. if ((tlv_status == HAL_TLV_STATUS_HEADER) && (
  431. (pdev->rx_enh_capture_mode == CDP_RX_ENH_CAPTURE_MPDU_MSDU) ||
  432. ((pdev->rx_enh_capture_mode == CDP_RX_ENH_CAPTURE_MPDU) &&
  433. pdev->is_mpdu_hdr[user_id]))) {
  434. if (*nbuf_used) {
  435. nbuf = qdf_nbuf_clone(status_nbuf);
  436. } else {
  437. *nbuf_used = true;
  438. nbuf = status_nbuf;
  439. }
  440. if (!nbuf)
  441. return;
  442. /* Truncate 4 bytes containing PPDU ID */
  443. dp_nbuf_set_data_and_len(nbuf, ppdu_info->data,
  444. ppdu_info->hdr_len - 4);
  445. if (pdev->is_mpdu_hdr[user_id]) {
  446. soc = pdev->soc;
  447. mpdu_head = qdf_nbuf_alloc(soc->osdev,
  448. RX_ENH_CB_BUF_SIZE + RX_ENH_CB_BUF_RESERVATION,
  449. RX_ENH_CB_BUF_RESERVATION,
  450. RX_ENH_CB_BUF_ALIGNMENT,
  451. FALSE);
  452. if (mpdu_head == NULL)
  453. return;
  454. qdf_nbuf_queue_add(&pdev->mpdu_q[user_id],
  455. mpdu_head);
  456. pdev->is_mpdu_hdr[user_id] = false;
  457. }
  458. msdu_list = &pdev->msdu_list[user_id];
  459. if (!msdu_list->head)
  460. msdu_list->head = nbuf;
  461. else
  462. msdu_list->tail->next = nbuf;
  463. msdu_list->tail = nbuf;
  464. msdu_list->sum_len += qdf_nbuf_len(nbuf);
  465. }
  466. if (tlv_status == HAL_TLV_STATUS_MPDU_END) {
  467. msdu_list = &pdev->msdu_list[user_id];
  468. mpdu_head = qdf_nbuf_queue_last(&pdev->mpdu_q[user_id]);
  469. if (mpdu_head) {
  470. qdf_nbuf_append_ext_list(mpdu_head,
  471. msdu_list->head,
  472. msdu_list->sum_len);
  473. msdu_list->head = NULL;
  474. msdu_list->tail = NULL;
  475. msdu_list->sum_len = 0;
  476. QDF_NBUF_CB_RX_FCS_ERR(mpdu_head)
  477. = ppdu_info->fcs_err;
  478. } else {
  479. dp_rx_free_msdu_list(msdu_list);
  480. }
  481. pdev->is_mpdu_hdr[user_id] = true;
  482. }
  483. /* Tag the MSDU/MPDU if a cce_metadata is valid */
  484. if ((tlv_status == HAL_TLV_STATUS_MSDU_END) &&
  485. (pdev->rx_enh_capture_mode == CDP_RX_ENH_CAPTURE_MPDU_MSDU)) {
  486. bool is_rx_mon_protocol_flow_tag_en;
  487. /**
  488. * Proceed only if this is a data frame.
  489. * We could also rx probes, etc.
  490. */
  491. if (!(ppdu_info->nac_info.fc_valid &&
  492. (IEEE80211_FC0_TYPE_DATA ==
  493. (ppdu_info->nac_info.frame_control &
  494. IEEE80211_FC0_TYPE_MASK))))
  495. return;
  496. msdu_list = &pdev->msdu_list[user_id];
  497. qdf_assert_always(msdu_list->head);
  498. /**
  499. * Directly move the last MSDU and fetch the same.
  500. * The earlier MSDUs should already be tagged as the
  501. * packets are tagged at the end of every RX
  502. * MSDU.
  503. */
  504. nbuf = msdu_list->tail;
  505. is_rx_mon_protocol_flow_tag_en =
  506. wlan_cfg_is_rx_mon_protocol_flow_tag_enabled(
  507. pdev->soc->wlan_cfg_ctx);
  508. if (is_rx_mon_protocol_flow_tag_en) {
  509. /* Set the protocol tag value from CCE metadata */
  510. dp_rx_mon_enh_capture_tag_protocol_type(pdev, ppdu_info,
  511. user_id, nbuf);
  512. /* Set the flow tag from FSE metadata */
  513. dp_rx_mon_enh_capture_set_flow_tag(pdev, ppdu_info,
  514. user_id, nbuf);
  515. }
  516. if (!pdev->is_rx_enh_capture_trailer_enabled)
  517. return;
  518. /**
  519. * Update necessary information in trailer (for debug purpose)
  520. */
  521. dp_rx_mon_enh_capture_update_trailer(pdev, nbuf);
  522. }
  523. }
  524. /*
  525. * dp_config_enh_rx_capture()- API to enable/disable enhanced rx capture
  526. * @pdev_handle: DP_PDEV handle
  527. * @val: user provided value
  528. *
  529. * Return: 0 for success. nonzero for failure.
  530. */
  531. QDF_STATUS
  532. dp_config_enh_rx_capture(struct cdp_pdev *pdev_handle, uint32_t val)
  533. {
  534. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  535. uint8_t rx_cap_mode = (val & CDP_RX_ENH_CAPTURE_MODE_MASK);
  536. uint32_t rx_enh_capture_peer;
  537. bool is_mpdu_hdr = false;
  538. uint8_t user_id;
  539. rx_enh_capture_peer =
  540. (val & CDP_RX_ENH_CAPTURE_PEER_MASK)
  541. >> CDP_RX_ENH_CAPTURE_PEER_LSB;
  542. if (pdev->mcopy_mode || (rx_cap_mode < CDP_RX_ENH_CAPTURE_DISABLED) ||
  543. (rx_cap_mode > CDP_RX_ENH_CAPTURE_MPDU_MSDU)) {
  544. dp_err("Invalid mode: %d", rx_cap_mode);
  545. return QDF_STATUS_E_INVAL;
  546. }
  547. if (rx_enh_capture_peer > CDP_RX_ENH_CAPTURE_PEER_ENABLED) {
  548. dp_err("Invalid peer filter %d", rx_enh_capture_peer);
  549. return QDF_STATUS_E_INVAL;
  550. }
  551. if (pdev->rx_enh_capture_mode == CDP_RX_ENH_CAPTURE_DISABLED &&
  552. rx_cap_mode != CDP_RX_ENH_CAPTURE_DISABLED) {
  553. pdev->rx_enh_monitor_vdev = pdev->monitor_vdev;
  554. }
  555. dp_reset_monitor_mode(pdev_handle);
  556. if (pdev->rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED &&
  557. rx_cap_mode == CDP_RX_ENH_CAPTURE_DISABLED) {
  558. pdev->monitor_vdev = pdev->rx_enh_monitor_vdev;
  559. }
  560. pdev->rx_enh_capture_mode = rx_cap_mode;
  561. pdev->rx_enh_capture_peer = rx_enh_capture_peer;
  562. if (rx_cap_mode != CDP_RX_ENH_CAPTURE_DISABLED)
  563. is_mpdu_hdr = true;
  564. for (user_id = 0; user_id < MAX_MU_USERS; user_id++)
  565. pdev->is_mpdu_hdr[user_id] = is_mpdu_hdr;
  566. /* Use a bit from val to enable MSDU trailer for internal debug use */
  567. pdev->is_rx_enh_capture_trailer_enabled =
  568. (val & RX_ENH_CAPTURE_TRAILER_ENABLE_MASK) ? true : false;
  569. return dp_pdev_configure_monitor_rings(pdev);
  570. }
  571. #endif /* WLAN_RX_PKT_CAPTURE_ENH */