dp_rx_mon_feature.c 20 KB

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