dp_rx_mon_status.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  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 FEATURE_PERPKT_INFO
  31. #include "dp_ratetable.h"
  32. #endif
  33. #ifdef WLAN_RX_PKT_CAPTURE_ENH
  34. #include "dp_rx_mon_feature.h"
  35. #else
  36. static QDF_STATUS
  37. dp_rx_handle_enh_capture(struct dp_soc *soc, struct dp_pdev *pdev,
  38. struct hal_rx_ppdu_info *ppdu_info)
  39. {
  40. return QDF_STATUS_SUCCESS;
  41. }
  42. static void
  43. dp_rx_mon_enh_capture_process(struct dp_pdev *pdev, uint32_t tlv_status,
  44. qdf_nbuf_t status_nbuf,
  45. struct hal_rx_ppdu_info *ppdu_info,
  46. bool *nbuf_used,
  47. uint32_t rx_enh_capture_mode)
  48. {
  49. }
  50. #endif
  51. /**
  52. * dp_rx_populate_cdp_indication_ppdu() - Populate cdp rx indication structure
  53. * @pdev: pdev ctx
  54. * @ppdu_info: ppdu info structure from ppdu ring
  55. * @ppdu_nbuf: qdf nbuf abstraction for linux skb
  56. *
  57. * Return: none
  58. */
  59. #ifdef FEATURE_PERPKT_INFO
  60. static inline void
  61. dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
  62. struct hal_rx_ppdu_info *ppdu_info,
  63. qdf_nbuf_t ppdu_nbuf)
  64. {
  65. struct dp_peer *peer;
  66. struct dp_soc *soc = pdev->soc;
  67. struct dp_ast_entry *ast_entry;
  68. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  69. uint32_t ast_index;
  70. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
  71. cdp_rx_ppdu->first_data_seq_ctrl =
  72. ppdu_info->rx_status.first_data_seq_ctrl;
  73. cdp_rx_ppdu->frame_ctrl =
  74. ppdu_info->rx_status.frame_control;
  75. cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
  76. cdp_rx_ppdu->length = ppdu_info->rx_status.ppdu_len;
  77. cdp_rx_ppdu->duration = ppdu_info->rx_status.duration;
  78. cdp_rx_ppdu->u.bw = ppdu_info->rx_status.bw;
  79. cdp_rx_ppdu->tcp_msdu_count = ppdu_info->rx_status.tcp_msdu_count;
  80. cdp_rx_ppdu->udp_msdu_count = ppdu_info->rx_status.udp_msdu_count;
  81. cdp_rx_ppdu->other_msdu_count = ppdu_info->rx_status.other_msdu_count;
  82. cdp_rx_ppdu->u.nss = ppdu_info->rx_status.nss;
  83. cdp_rx_ppdu->u.mcs = ppdu_info->rx_status.mcs;
  84. if ((ppdu_info->rx_status.sgi == VHT_SGI_NYSM) &&
  85. (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC))
  86. cdp_rx_ppdu->u.gi = CDP_SGI_0_4_US;
  87. else
  88. cdp_rx_ppdu->u.gi = ppdu_info->rx_status.sgi;
  89. cdp_rx_ppdu->u.ldpc = ppdu_info->rx_status.ldpc;
  90. cdp_rx_ppdu->u.preamble = ppdu_info->rx_status.preamble_type;
  91. cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
  92. cdp_rx_ppdu->u.ltf_size = (ppdu_info->rx_status.he_data5 >>
  93. QDF_MON_STATUS_HE_LTF_SIZE_SHIFT) & 0x3;
  94. cdp_rx_ppdu->num_mpdu = ppdu_info->com_info.mpdu_cnt_fcs_ok;
  95. cdp_rx_ppdu->rssi = ppdu_info->rx_status.rssi_comb;
  96. cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
  97. cdp_rx_ppdu->channel = ppdu_info->rx_status.chan_num;
  98. cdp_rx_ppdu->beamformed = ppdu_info->rx_status.beamformed;
  99. cdp_rx_ppdu->num_msdu = (cdp_rx_ppdu->tcp_msdu_count +
  100. cdp_rx_ppdu->udp_msdu_count +
  101. cdp_rx_ppdu->other_msdu_count);
  102. cdp_rx_ppdu->num_bytes = ppdu_info->rx_status.ppdu_len;
  103. cdp_rx_ppdu->retries = CDP_FC_IS_RETRY_SET(cdp_rx_ppdu->frame_ctrl) ?
  104. ppdu_info->com_info.mpdu_cnt_fcs_ok : 0;
  105. if (ppdu_info->com_info.mpdu_cnt_fcs_ok > 1)
  106. cdp_rx_ppdu->is_ampdu = 1;
  107. else
  108. cdp_rx_ppdu->is_ampdu = 0;
  109. cdp_rx_ppdu->tid = ppdu_info->rx_status.tid;
  110. cdp_rx_ppdu->lsig_a = ppdu_info->rx_status.rate;
  111. ast_index = ppdu_info->rx_status.ast_index;
  112. if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  113. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  114. return;
  115. }
  116. ast_entry = soc->ast_table[ast_index];
  117. if (!ast_entry) {
  118. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  119. return;
  120. }
  121. peer = ast_entry->peer;
  122. if (!peer || peer->peer_ids[0] == HTT_INVALID_PEER) {
  123. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  124. return;
  125. }
  126. qdf_mem_copy(cdp_rx_ppdu->mac_addr,
  127. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  128. cdp_rx_ppdu->peer_id = peer->peer_ids[0];
  129. cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
  130. cdp_rx_ppdu->u.ltf_size = ppdu_info->rx_status.ltf_size;
  131. }
  132. #else
  133. static inline void
  134. dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
  135. struct hal_rx_ppdu_info *ppdu_info,
  136. qdf_nbuf_t ppdu_nbuf)
  137. {
  138. }
  139. #endif
  140. /**
  141. * dp_rx_stats_update() - Update per-peer statistics
  142. * @soc: Datapath SOC handle
  143. * @peer: Datapath peer handle
  144. * @ppdu: PPDU Descriptor
  145. *
  146. * Return: None
  147. */
  148. #ifdef FEATURE_PERPKT_INFO
  149. static inline void dp_rx_rate_stats_update(struct dp_peer *peer,
  150. struct cdp_rx_indication_ppdu *ppdu)
  151. {
  152. uint32_t ratekbps = 0;
  153. uint32_t ppdu_rx_rate = 0;
  154. uint32_t nss = 0;
  155. uint32_t rix;
  156. if (!peer || !ppdu)
  157. return;
  158. if (ppdu->u.nss == 0)
  159. nss = 0;
  160. else
  161. nss = ppdu->u.nss - 1;
  162. ratekbps = dp_getrateindex(ppdu->u.gi,
  163. ppdu->u.mcs,
  164. nss,
  165. ppdu->u.preamble,
  166. ppdu->u.bw,
  167. &rix);
  168. if (!ratekbps)
  169. return;
  170. ppdu->rix = rix;
  171. DP_STATS_UPD(peer, rx.last_rx_rate, ratekbps);
  172. dp_ath_rate_lpf(peer->stats.rx.avg_rx_rate, ratekbps);
  173. ppdu_rx_rate = dp_ath_rate_out(peer->stats.rx.avg_rx_rate);
  174. DP_STATS_UPD(peer, rx.rnd_avg_rx_rate, ppdu_rx_rate);
  175. ppdu->rx_ratekbps = ratekbps;
  176. if (peer->vdev)
  177. peer->vdev->stats.rx.last_rx_rate = ratekbps;
  178. }
  179. static void dp_rx_stats_update(struct dp_pdev *pdev, struct dp_peer *peer,
  180. struct cdp_rx_indication_ppdu *ppdu)
  181. {
  182. struct dp_soc *soc = NULL;
  183. uint8_t mcs, preamble, ac = 0;
  184. uint16_t num_msdu;
  185. bool is_invalid_peer = false;
  186. mcs = ppdu->u.mcs;
  187. preamble = ppdu->u.preamble;
  188. num_msdu = ppdu->num_msdu;
  189. if (pdev)
  190. soc = pdev->soc;
  191. else
  192. return;
  193. if (!peer) {
  194. is_invalid_peer = true;
  195. peer = pdev->invalid_peer;
  196. }
  197. if (!soc || soc->process_rx_status)
  198. return;
  199. DP_STATS_UPD(peer, rx.rssi, ppdu->rssi);
  200. if (peer->stats.rx.avg_rssi == INVALID_RSSI)
  201. peer->stats.rx.avg_rssi = ppdu->rssi;
  202. else
  203. peer->stats.rx.avg_rssi =
  204. DP_GET_AVG_RSSI(peer->stats.rx.avg_rssi, ppdu->rssi);
  205. if ((preamble == DOT11_A) || (preamble == DOT11_B))
  206. ppdu->u.nss = 1;
  207. if (ppdu->u.nss)
  208. DP_STATS_INC(peer, rx.nss[ppdu->u.nss - 1], num_msdu);
  209. DP_STATS_INC(peer, rx.sgi_count[ppdu->u.gi], num_msdu);
  210. DP_STATS_INC(peer, rx.bw[ppdu->u.bw], num_msdu);
  211. DP_STATS_INC(peer, rx.reception_type[ppdu->u.ppdu_type], num_msdu);
  212. DP_STATS_INCC(peer, rx.ampdu_cnt, num_msdu, ppdu->is_ampdu);
  213. DP_STATS_INCC(peer, rx.non_ampdu_cnt, num_msdu, !(ppdu->is_ampdu));
  214. DP_STATS_UPD(peer, rx.rx_rate, mcs);
  215. DP_STATS_INCC(peer,
  216. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  217. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
  218. DP_STATS_INCC(peer,
  219. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  220. ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
  221. DP_STATS_INCC(peer,
  222. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  223. ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B)));
  224. DP_STATS_INCC(peer,
  225. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  226. ((mcs < MAX_MCS_11B) && (preamble == DOT11_B)));
  227. DP_STATS_INCC(peer,
  228. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  229. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N)));
  230. DP_STATS_INCC(peer,
  231. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  232. ((mcs < MAX_MCS_11A) && (preamble == DOT11_N)));
  233. DP_STATS_INCC(peer,
  234. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  235. ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC)));
  236. DP_STATS_INCC(peer,
  237. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  238. ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
  239. DP_STATS_INCC(peer,
  240. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  241. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  242. DP_STATS_INCC(peer,
  243. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  244. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  245. /*
  246. * If invalid TID, it could be a non-qos frame, hence do not update
  247. * any AC counters
  248. */
  249. ac = TID_TO_WME_AC(ppdu->tid);
  250. if (ppdu->tid != HAL_TID_INVALID)
  251. DP_STATS_INC(peer, rx.wme_ac_type[ac], num_msdu);
  252. dp_peer_stats_notify(peer);
  253. DP_STATS_UPD(peer, rx.last_rssi, ppdu->rssi);
  254. if (is_invalid_peer)
  255. return;
  256. dp_rx_rate_stats_update(peer, ppdu);
  257. #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
  258. dp_wdi_event_handler(WDI_EVENT_UPDATE_DP_STATS, pdev->soc,
  259. &peer->stats, ppdu->peer_id,
  260. UPDATE_PEER_STATS, pdev->pdev_id);
  261. #endif
  262. }
  263. #endif
  264. /**
  265. * dp_rx_handle_mcopy_mode() - Allocate and deliver first MSDU payload
  266. * @soc: core txrx main context
  267. * @pdev: pdev strcuture
  268. * @ppdu_info: structure for rx ppdu ring
  269. *
  270. * Return: QDF_STATUS_SUCCESS - If nbuf to be freed by caller
  271. * QDF_STATUS_E_ALREADY - If nbuf not to be freed by caller
  272. */
  273. #ifdef FEATURE_PERPKT_INFO
  274. static inline QDF_STATUS
  275. dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  276. struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf)
  277. {
  278. uint8_t size = 0;
  279. struct ieee80211_frame *wh;
  280. uint32_t *nbuf_data;
  281. if (!ppdu_info->msdu_info.first_msdu_payload)
  282. return QDF_STATUS_SUCCESS;
  283. if (pdev->m_copy_id.rx_ppdu_id == ppdu_info->com_info.ppdu_id)
  284. return QDF_STATUS_SUCCESS;
  285. pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
  286. wh = (struct ieee80211_frame *)(ppdu_info->msdu_info.first_msdu_payload
  287. + 4);
  288. size = (ppdu_info->msdu_info.first_msdu_payload -
  289. qdf_nbuf_data(nbuf));
  290. ppdu_info->msdu_info.first_msdu_payload = NULL;
  291. if (qdf_nbuf_pull_head(nbuf, size) == NULL)
  292. return QDF_STATUS_SUCCESS;
  293. if (((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  294. IEEE80211_FC0_TYPE_MGT) ||
  295. ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  296. IEEE80211_FC0_TYPE_CTL)) {
  297. return QDF_STATUS_SUCCESS;
  298. }
  299. nbuf_data = (uint32_t *)qdf_nbuf_data(nbuf);
  300. *nbuf_data = pdev->ppdu_info.com_info.ppdu_id;
  301. /* only retain RX MSDU payload in the skb */
  302. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
  303. ppdu_info->msdu_info.payload_len);
  304. dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
  305. nbuf, HTT_INVALID_PEER, WDI_NO_VAL, pdev->pdev_id);
  306. return QDF_STATUS_E_ALREADY;
  307. }
  308. #else
  309. static inline QDF_STATUS
  310. dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  311. struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf)
  312. {
  313. return QDF_STATUS_SUCCESS;
  314. }
  315. #endif
  316. /**
  317. * dp_rx_handle_smart_mesh_mode() - Deliver header for smart mesh
  318. * @soc: Datapath SOC handle
  319. * @pdev: Datapath PDEV handle
  320. * @ppdu_info: Structure for rx ppdu info
  321. * @nbuf: Qdf nbuf abstraction for linux skb
  322. *
  323. * Return: 0 on success, 1 on failure
  324. */
  325. static inline int
  326. dp_rx_handle_smart_mesh_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  327. struct hal_rx_ppdu_info *ppdu_info,
  328. qdf_nbuf_t nbuf)
  329. {
  330. uint8_t size = 0;
  331. if (!pdev->monitor_vdev) {
  332. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  333. "[%s]:[%d] Monitor vdev is NULL !!",
  334. __func__, __LINE__);
  335. return 1;
  336. }
  337. if (!ppdu_info->msdu_info.first_msdu_payload) {
  338. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  339. "[%s]:[%d] First msdu payload not present",
  340. __func__, __LINE__);
  341. return 1;
  342. }
  343. /* Adding 4 bytes to get to start of 802.11 frame after phy_ppdu_id */
  344. size = (ppdu_info->msdu_info.first_msdu_payload -
  345. qdf_nbuf_data(nbuf)) + 4;
  346. ppdu_info->msdu_info.first_msdu_payload = NULL;
  347. if (qdf_nbuf_pull_head(nbuf, size) == NULL) {
  348. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  349. "[%s]:[%d] No header present",
  350. __func__, __LINE__);
  351. return 1;
  352. }
  353. /* Only retain RX MSDU payload in the skb */
  354. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
  355. ppdu_info->msdu_info.payload_len);
  356. qdf_nbuf_update_radiotap(&(pdev->ppdu_info.rx_status),
  357. nbuf, sizeof(struct rx_pkt_tlvs));
  358. pdev->monitor_vdev->osif_rx_mon(pdev->monitor_vdev->osif_vdev,
  359. nbuf, NULL);
  360. pdev->ppdu_info.rx_status.monitor_direct_used = 0;
  361. return 0;
  362. }
  363. /**
  364. * dp_rx_handle_ppdu_stats() - Allocate and deliver ppdu stats to cdp layer
  365. * @soc: core txrx main context
  366. * @pdev: pdev strcuture
  367. * @ppdu_info: structure for rx ppdu ring
  368. *
  369. * Return: none
  370. */
  371. #ifdef FEATURE_PERPKT_INFO
  372. static inline void
  373. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  374. struct hal_rx_ppdu_info *ppdu_info)
  375. {
  376. qdf_nbuf_t ppdu_nbuf;
  377. struct dp_peer *peer;
  378. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  379. /*
  380. * Do not allocate if fcs error,
  381. * ast idx invalid / fctl invalid
  382. */
  383. if (ppdu_info->com_info.mpdu_cnt_fcs_ok == 0)
  384. return;
  385. if (ppdu_info->nac_info.fc_valid &&
  386. ppdu_info->nac_info.to_ds_flag &&
  387. ppdu_info->nac_info.mac_addr2_valid) {
  388. struct dp_neighbour_peer *peer = NULL;
  389. uint8_t rssi = ppdu_info->rx_status.rssi_comb;
  390. qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
  391. if (pdev->neighbour_peers_added) {
  392. TAILQ_FOREACH(peer, &pdev->neighbour_peers_list,
  393. neighbour_peer_list_elem) {
  394. if (!qdf_mem_cmp(&peer->neighbour_peers_macaddr,
  395. &ppdu_info->nac_info.mac_addr2,
  396. QDF_MAC_ADDR_SIZE)) {
  397. peer->rssi = rssi;
  398. break;
  399. }
  400. }
  401. }
  402. qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
  403. }
  404. /* need not generate wdi event when mcopy and
  405. * enhanced stats are not enabled
  406. */
  407. if (!pdev->mcopy_mode && !pdev->enhanced_stats_en)
  408. return;
  409. if (!pdev->mcopy_mode) {
  410. if (!ppdu_info->rx_status.frame_control_info_valid)
  411. return;
  412. if (ppdu_info->rx_status.ast_index == HAL_AST_IDX_INVALID)
  413. return;
  414. }
  415. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  416. sizeof(struct cdp_rx_indication_ppdu), 0, 0, FALSE);
  417. if (ppdu_nbuf) {
  418. dp_rx_populate_cdp_indication_ppdu(pdev, ppdu_info, ppdu_nbuf);
  419. qdf_nbuf_put_tail(ppdu_nbuf,
  420. sizeof(struct cdp_rx_indication_ppdu));
  421. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
  422. peer = dp_peer_find_by_id(soc, cdp_rx_ppdu->peer_id);
  423. if (peer) {
  424. cdp_rx_ppdu->cookie = (void *)peer->wlanstats_ctx;
  425. dp_rx_stats_update(pdev, peer, cdp_rx_ppdu);
  426. dp_peer_unref_del_find_by_id(peer);
  427. }
  428. if (cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) {
  429. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC,
  430. soc, ppdu_nbuf,
  431. cdp_rx_ppdu->peer_id,
  432. WDI_NO_VAL, pdev->pdev_id);
  433. } else if (pdev->mcopy_mode) {
  434. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
  435. ppdu_nbuf, HTT_INVALID_PEER,
  436. WDI_NO_VAL, pdev->pdev_id);
  437. } else {
  438. qdf_nbuf_free(ppdu_nbuf);
  439. }
  440. }
  441. }
  442. #else
  443. static inline void
  444. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  445. struct hal_rx_ppdu_info *ppdu_info)
  446. {
  447. }
  448. #endif
  449. /**
  450. * dp_rx_process_peer_based_pktlog() - Process Rx pktlog if peer based
  451. * filtering enabled
  452. * @soc: core txrx main context
  453. * @ppdu_info: Structure for rx ppdu info
  454. * @status_nbuf: Qdf nbuf abstraction for linux skb
  455. * @mac_id: mac_id/pdev_id correspondinggly for MCL and WIN
  456. *
  457. * Return: none
  458. */
  459. static inline void
  460. dp_rx_process_peer_based_pktlog(struct dp_soc *soc,
  461. struct hal_rx_ppdu_info *ppdu_info,
  462. qdf_nbuf_t status_nbuf, uint32_t mac_id)
  463. {
  464. struct dp_peer *peer;
  465. struct dp_ast_entry *ast_entry;
  466. uint32_t ast_index;
  467. ast_index = ppdu_info->rx_status.ast_index;
  468. if (ast_index < (WLAN_UMAC_PSOC_MAX_PEERS * 2)) {
  469. ast_entry = soc->ast_table[ast_index];
  470. if (ast_entry) {
  471. peer = ast_entry->peer;
  472. if (peer && (peer->peer_ids[0] != HTT_INVALID_PEER)) {
  473. if (peer->peer_based_pktlog_filter) {
  474. dp_wdi_event_handler(
  475. WDI_EVENT_RX_DESC, soc,
  476. status_nbuf,
  477. peer->peer_ids[0],
  478. WDI_NO_VAL, mac_id);
  479. }
  480. }
  481. }
  482. }
  483. }
  484. /**
  485. * dp_rx_mon_status_process_tlv() - Process status TLV in status
  486. * buffer on Rx status Queue posted by status SRNG processing.
  487. * @soc: core txrx main context
  488. * @mac_id: mac_id which is one of 3 mac_ids _ring
  489. *
  490. * Return: none
  491. */
  492. static inline void
  493. dp_rx_mon_status_process_tlv(struct dp_soc *soc, uint32_t mac_id,
  494. uint32_t quota)
  495. {
  496. struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id);
  497. struct hal_rx_ppdu_info *ppdu_info;
  498. qdf_nbuf_t status_nbuf;
  499. uint8_t *rx_tlv;
  500. uint8_t *rx_tlv_start;
  501. uint32_t tlv_status = HAL_TLV_STATUS_BUF_DONE;
  502. QDF_STATUS m_copy_status = QDF_STATUS_SUCCESS;
  503. QDF_STATUS enh_log_status = QDF_STATUS_SUCCESS;
  504. struct cdp_pdev_mon_stats *rx_mon_stats;
  505. int smart_mesh_status;
  506. enum WDI_EVENT pktlog_mode = WDI_NO_VAL;
  507. bool nbuf_used;
  508. uint32_t rx_enh_capture_mode;
  509. ppdu_info = &pdev->ppdu_info;
  510. rx_mon_stats = &pdev->rx_mon_stats;
  511. if (pdev->mon_ppdu_status != DP_PPDU_STATUS_START)
  512. return;
  513. rx_enh_capture_mode = pdev->rx_enh_capture_mode;
  514. while (!qdf_nbuf_is_queue_empty(&pdev->rx_status_q)) {
  515. status_nbuf = qdf_nbuf_queue_remove(&pdev->rx_status_q);
  516. rx_tlv = qdf_nbuf_data(status_nbuf);
  517. rx_tlv_start = rx_tlv;
  518. nbuf_used = false;
  519. if ((pdev->monitor_vdev) || (pdev->enhanced_stats_en) ||
  520. pdev->mcopy_mode ||
  521. (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED)) {
  522. do {
  523. tlv_status = hal_rx_status_get_tlv_info(rx_tlv,
  524. ppdu_info, pdev->soc->hal_soc);
  525. dp_rx_mon_update_dbg_ppdu_stats(ppdu_info,
  526. rx_mon_stats);
  527. dp_rx_mon_enh_capture_process(pdev, tlv_status,
  528. status_nbuf, ppdu_info,
  529. &nbuf_used, rx_enh_capture_mode);
  530. rx_tlv = hal_rx_status_get_next_tlv(rx_tlv);
  531. if ((rx_tlv - rx_tlv_start) >= RX_BUFFER_SIZE)
  532. break;
  533. } while ((tlv_status == HAL_TLV_STATUS_PPDU_NOT_DONE) ||
  534. (tlv_status == HAL_TLV_STATUS_HEADER) ||
  535. (tlv_status == HAL_TLV_STATUS_MPDU_END));
  536. }
  537. if (pdev->dp_peer_based_pktlog) {
  538. dp_rx_process_peer_based_pktlog(soc, ppdu_info,
  539. status_nbuf, mac_id);
  540. } else {
  541. if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_FULL)
  542. pktlog_mode = WDI_EVENT_RX_DESC;
  543. else if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_LITE)
  544. pktlog_mode = WDI_EVENT_LITE_RX;
  545. if (pktlog_mode != WDI_NO_VAL)
  546. dp_wdi_event_handler(pktlog_mode, soc,
  547. status_nbuf,
  548. HTT_INVALID_PEER,
  549. WDI_NO_VAL, mac_id);
  550. }
  551. /* smart monitor vap and m_copy cannot co-exist */
  552. if (ppdu_info->rx_status.monitor_direct_used && pdev->neighbour_peers_added
  553. && pdev->monitor_vdev) {
  554. smart_mesh_status = dp_rx_handle_smart_mesh_mode(soc,
  555. pdev, ppdu_info, status_nbuf);
  556. if (smart_mesh_status)
  557. qdf_nbuf_free(status_nbuf);
  558. } else if (pdev->mcopy_mode) {
  559. m_copy_status = dp_rx_handle_mcopy_mode(soc,
  560. pdev, ppdu_info, status_nbuf);
  561. if (m_copy_status == QDF_STATUS_SUCCESS)
  562. qdf_nbuf_free(status_nbuf);
  563. } else if (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED) {
  564. if (!nbuf_used)
  565. qdf_nbuf_free(status_nbuf);
  566. if (tlv_status == HAL_TLV_STATUS_PPDU_DONE)
  567. enh_log_status =
  568. dp_rx_handle_enh_capture(soc,
  569. pdev, ppdu_info);
  570. } else {
  571. qdf_nbuf_free(status_nbuf);
  572. }
  573. if (tlv_status == HAL_TLV_STATUS_PPDU_NON_STD_DONE) {
  574. dp_rx_mon_deliver_non_std(soc, mac_id);
  575. } else if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) {
  576. rx_mon_stats->status_ppdu_done++;
  577. if (pdev->enhanced_stats_en ||
  578. pdev->mcopy_mode || pdev->neighbour_peers_added)
  579. dp_rx_handle_ppdu_stats(soc, pdev, ppdu_info);
  580. pdev->mon_ppdu_status = DP_PPDU_STATUS_DONE;
  581. dp_rx_mon_dest_process(soc, mac_id, quota);
  582. pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  583. }
  584. }
  585. return;
  586. }
  587. /*
  588. * dp_rx_mon_status_srng_process() - Process monitor status ring
  589. * post the status ring buffer to Rx status Queue for later
  590. * processing when status ring is filled with status TLV.
  591. * Allocate a new buffer to status ring if the filled buffer
  592. * is posted.
  593. *
  594. * @soc: core txrx main context
  595. * @mac_id: mac_id which is one of 3 mac_ids
  596. * @quota: No. of ring entry that can be serviced in one shot.
  597. * Return: uint32_t: No. of ring entry that is processed.
  598. */
  599. static inline uint32_t
  600. dp_rx_mon_status_srng_process(struct dp_soc *soc, uint32_t mac_id,
  601. uint32_t quota)
  602. {
  603. struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id);
  604. void *hal_soc;
  605. void *mon_status_srng;
  606. void *rxdma_mon_status_ring_entry;
  607. QDF_STATUS status;
  608. uint32_t work_done = 0;
  609. int mac_for_pdev = dp_get_mac_id_for_mac(soc, mac_id);
  610. mon_status_srng = pdev->rxdma_mon_status_ring[mac_for_pdev].hal_srng;
  611. qdf_assert(mon_status_srng);
  612. if (!mon_status_srng || !hal_srng_initialized(mon_status_srng)) {
  613. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  614. "%s %d : HAL Monitor Status Ring Init Failed -- %pK",
  615. __func__, __LINE__, mon_status_srng);
  616. return work_done;
  617. }
  618. hal_soc = soc->hal_soc;
  619. qdf_assert(hal_soc);
  620. if (qdf_unlikely(hal_srng_access_start(hal_soc, mon_status_srng)))
  621. goto done;
  622. /* mon_status_ring_desc => WBM_BUFFER_RING STRUCT =>
  623. * BUFFER_ADDR_INFO STRUCT
  624. */
  625. while (qdf_likely((rxdma_mon_status_ring_entry =
  626. hal_srng_src_peek(hal_soc, mon_status_srng))
  627. && quota--)) {
  628. uint32_t rx_buf_cookie;
  629. qdf_nbuf_t status_nbuf;
  630. struct dp_rx_desc *rx_desc;
  631. uint8_t *status_buf;
  632. qdf_dma_addr_t paddr;
  633. uint64_t buf_addr;
  634. buf_addr =
  635. (HAL_RX_BUFFER_ADDR_31_0_GET(
  636. rxdma_mon_status_ring_entry) |
  637. ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(
  638. rxdma_mon_status_ring_entry)) << 32));
  639. if (qdf_likely(buf_addr)) {
  640. rx_buf_cookie =
  641. HAL_RX_BUF_COOKIE_GET(
  642. rxdma_mon_status_ring_entry);
  643. rx_desc = dp_rx_cookie_2_va_mon_status(soc,
  644. rx_buf_cookie);
  645. qdf_assert(rx_desc);
  646. status_nbuf = rx_desc->nbuf;
  647. qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf,
  648. QDF_DMA_FROM_DEVICE);
  649. status_buf = qdf_nbuf_data(status_nbuf);
  650. status = hal_get_rx_status_done(status_buf);
  651. if (status != QDF_STATUS_SUCCESS) {
  652. uint32_t hp, tp;
  653. hal_get_sw_hptp(hal_soc, mon_status_srng,
  654. &tp, &hp);
  655. QDF_TRACE(QDF_MODULE_ID_DP,
  656. QDF_TRACE_LEVEL_ERROR,
  657. "[%s][%d] status not done - hp:%u, tp:%u",
  658. __func__, __LINE__, hp, tp);
  659. /* WAR for missing status: Skip status entry */
  660. hal_srng_src_get_next(hal_soc, mon_status_srng);
  661. continue;
  662. }
  663. qdf_nbuf_set_pktlen(status_nbuf, RX_BUFFER_SIZE);
  664. qdf_nbuf_unmap_single(soc->osdev, status_nbuf,
  665. QDF_DMA_FROM_DEVICE);
  666. /* Put the status_nbuf to queue */
  667. qdf_nbuf_queue_add(&pdev->rx_status_q, status_nbuf);
  668. } else {
  669. union dp_rx_desc_list_elem_t *desc_list = NULL;
  670. union dp_rx_desc_list_elem_t *tail = NULL;
  671. struct rx_desc_pool *rx_desc_pool;
  672. uint32_t num_alloc_desc;
  673. rx_desc_pool = &soc->rx_desc_status[mac_id];
  674. num_alloc_desc = dp_rx_get_free_desc_list(soc, mac_id,
  675. rx_desc_pool,
  676. 1,
  677. &desc_list,
  678. &tail);
  679. /*
  680. * No free descriptors available
  681. */
  682. if (qdf_unlikely(num_alloc_desc == 0)) {
  683. work_done++;
  684. break;
  685. }
  686. rx_desc = &desc_list->rx_desc;
  687. }
  688. status_nbuf = dp_rx_nbuf_prepare(soc, pdev);
  689. /*
  690. * qdf_nbuf alloc or map failed,
  691. * free the dp rx desc to free list,
  692. * fill in NULL dma address at current HP entry,
  693. * keep HP in mon_status_ring unchanged,
  694. * wait next time dp_rx_mon_status_srng_process
  695. * to fill in buffer at current HP.
  696. */
  697. if (qdf_unlikely(!status_nbuf)) {
  698. union dp_rx_desc_list_elem_t *desc_list = NULL;
  699. union dp_rx_desc_list_elem_t *tail = NULL;
  700. struct rx_desc_pool *rx_desc_pool;
  701. rx_desc_pool = &soc->rx_desc_status[mac_id];
  702. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  703. "%s: fail to allocate or map qdf_nbuf",
  704. __func__);
  705. dp_rx_add_to_free_desc_list(&desc_list,
  706. &tail, rx_desc);
  707. dp_rx_add_desc_list_to_free_list(soc, &desc_list,
  708. &tail, mac_id, rx_desc_pool);
  709. hal_rxdma_buff_addr_info_set(
  710. rxdma_mon_status_ring_entry,
  711. 0, 0, HAL_RX_BUF_RBM_SW3_BM);
  712. work_done++;
  713. break;
  714. }
  715. paddr = qdf_nbuf_get_frag_paddr(status_nbuf, 0);
  716. rx_desc->nbuf = status_nbuf;
  717. rx_desc->in_use = 1;
  718. hal_rxdma_buff_addr_info_set(rxdma_mon_status_ring_entry,
  719. paddr, rx_desc->cookie, HAL_RX_BUF_RBM_SW3_BM);
  720. hal_srng_src_get_next(hal_soc, mon_status_srng);
  721. work_done++;
  722. }
  723. done:
  724. hal_srng_access_end(hal_soc, mon_status_srng);
  725. return work_done;
  726. }
  727. /*
  728. * dp_rx_mon_status_process() - Process monitor status ring and
  729. * TLV in status ring.
  730. *
  731. * @soc: core txrx main context
  732. * @mac_id: mac_id which is one of 3 mac_ids
  733. * @quota: No. of ring entry that can be serviced in one shot.
  734. * Return: uint32_t: No. of ring entry that is processed.
  735. */
  736. static inline uint32_t
  737. dp_rx_mon_status_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
  738. uint32_t work_done;
  739. work_done = dp_rx_mon_status_srng_process(soc, mac_id, quota);
  740. quota -= work_done;
  741. dp_rx_mon_status_process_tlv(soc, mac_id, quota);
  742. return work_done;
  743. }
  744. /**
  745. * dp_mon_process() - Main monitor mode processing roution.
  746. * This call monitor status ring process then monitor
  747. * destination ring process.
  748. * Called from the bottom half (tasklet/NET_RX_SOFTIRQ)
  749. * @soc: core txrx main context
  750. * @mac_id: mac_id which is one of 3 mac_ids
  751. * @quota: No. of status ring entry that can be serviced in one shot.
  752. * Return: uint32_t: No. of ring entry that is processed.
  753. */
  754. uint32_t
  755. dp_mon_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
  756. return dp_rx_mon_status_process(soc, mac_id, quota);
  757. }
  758. /**
  759. * dp_rx_pdev_mon_status_detach() - detach dp rx for status ring
  760. * @pdev: core txrx pdev context
  761. * @mac_id: mac_id/pdev_id correspondinggly for MCL and WIN
  762. *
  763. * This function will detach DP RX status ring from
  764. * main device context. will free DP Rx resources for
  765. * status ring
  766. *
  767. * Return: QDF_STATUS_SUCCESS: success
  768. * QDF_STATUS_E_RESOURCES: Error return
  769. */
  770. QDF_STATUS
  771. dp_rx_pdev_mon_status_detach(struct dp_pdev *pdev, int mac_id)
  772. {
  773. struct dp_soc *soc = pdev->soc;
  774. struct rx_desc_pool *rx_desc_pool;
  775. rx_desc_pool = &soc->rx_desc_status[mac_id];
  776. if (rx_desc_pool->pool_size != 0) {
  777. if (!dp_is_soc_reinit(soc))
  778. dp_rx_desc_pool_free(soc, mac_id, rx_desc_pool);
  779. else
  780. dp_rx_desc_nbuf_pool_free(soc, rx_desc_pool);
  781. }
  782. return QDF_STATUS_SUCCESS;
  783. }
  784. /*
  785. * dp_rx_buffers_replenish() - replenish monitor status ring with
  786. * rx nbufs called during dp rx
  787. * monitor status ring initialization
  788. *
  789. * @soc: core txrx main context
  790. * @mac_id: mac_id which is one of 3 mac_ids
  791. * @dp_rxdma_srng: dp monitor status circular ring
  792. * @rx_desc_pool; Pointer to Rx descriptor pool
  793. * @num_req_buffers: number of buffer to be replenished
  794. * @desc_list: list of descs if called from dp rx monitor status
  795. * process or NULL during dp rx initialization or
  796. * out of buffer interrupt
  797. * @tail: tail of descs list
  798. * @owner: who owns the nbuf (host, NSS etc...)
  799. * Return: return success or failure
  800. */
  801. static inline
  802. QDF_STATUS dp_rx_mon_status_buffers_replenish(struct dp_soc *dp_soc,
  803. uint32_t mac_id,
  804. struct dp_srng *dp_rxdma_srng,
  805. struct rx_desc_pool *rx_desc_pool,
  806. uint32_t num_req_buffers,
  807. union dp_rx_desc_list_elem_t **desc_list,
  808. union dp_rx_desc_list_elem_t **tail,
  809. uint8_t owner)
  810. {
  811. uint32_t num_alloc_desc;
  812. uint16_t num_desc_to_free = 0;
  813. uint32_t num_entries_avail;
  814. uint32_t count = 0;
  815. int sync_hw_ptr = 1;
  816. qdf_dma_addr_t paddr;
  817. qdf_nbuf_t rx_netbuf;
  818. void *rxdma_ring_entry;
  819. union dp_rx_desc_list_elem_t *next;
  820. void *rxdma_srng;
  821. struct dp_pdev *dp_pdev = dp_get_pdev_for_mac_id(dp_soc, mac_id);
  822. rxdma_srng = dp_rxdma_srng->hal_srng;
  823. qdf_assert(rxdma_srng);
  824. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  825. "[%s][%d] requested %d buffers for replenish",
  826. __func__, __LINE__, num_req_buffers);
  827. /*
  828. * if desc_list is NULL, allocate the descs from freelist
  829. */
  830. if (!(*desc_list)) {
  831. num_alloc_desc = dp_rx_get_free_desc_list(dp_soc, mac_id,
  832. rx_desc_pool,
  833. num_req_buffers,
  834. desc_list,
  835. tail);
  836. if (!num_alloc_desc) {
  837. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  838. "[%s][%d] no free rx_descs in freelist",
  839. __func__, __LINE__);
  840. return QDF_STATUS_E_NOMEM;
  841. }
  842. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  843. "[%s][%d] %d rx desc allocated", __func__, __LINE__,
  844. num_alloc_desc);
  845. num_req_buffers = num_alloc_desc;
  846. }
  847. hal_srng_access_start(dp_soc->hal_soc, rxdma_srng);
  848. num_entries_avail = hal_srng_src_num_avail(dp_soc->hal_soc,
  849. rxdma_srng, sync_hw_ptr);
  850. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  851. "[%s][%d] no of available entries in rxdma ring: %d",
  852. __func__, __LINE__, num_entries_avail);
  853. if (num_entries_avail < num_req_buffers) {
  854. num_desc_to_free = num_req_buffers - num_entries_avail;
  855. num_req_buffers = num_entries_avail;
  856. }
  857. while (count < num_req_buffers) {
  858. rx_netbuf = dp_rx_nbuf_prepare(dp_soc, dp_pdev);
  859. /*
  860. * qdf_nbuf alloc or map failed,
  861. * keep HP in mon_status_ring unchanged,
  862. * wait dp_rx_mon_status_srng_process
  863. * to fill in buffer at current HP.
  864. */
  865. if (qdf_unlikely(!rx_netbuf)) {
  866. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  867. "%s: qdf_nbuf allocate or map fail, count %d",
  868. __func__, count);
  869. break;
  870. }
  871. paddr = qdf_nbuf_get_frag_paddr(rx_netbuf, 0);
  872. next = (*desc_list)->next;
  873. rxdma_ring_entry = hal_srng_src_get_next(dp_soc->hal_soc,
  874. rxdma_srng);
  875. if (qdf_unlikely(!rxdma_ring_entry)) {
  876. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  877. "[%s][%d] rxdma_ring_entry is NULL, count - %d",
  878. __func__, __LINE__, count);
  879. qdf_nbuf_unmap_single(dp_soc->osdev, rx_netbuf,
  880. QDF_DMA_BIDIRECTIONAL);
  881. qdf_nbuf_free(rx_netbuf);
  882. break;
  883. }
  884. (*desc_list)->rx_desc.nbuf = rx_netbuf;
  885. (*desc_list)->rx_desc.in_use = 1;
  886. count++;
  887. hal_rxdma_buff_addr_info_set(rxdma_ring_entry, paddr,
  888. (*desc_list)->rx_desc.cookie, owner);
  889. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  890. "[%s][%d] rx_desc=%pK, cookie=%d, nbuf=%pK, \
  891. paddr=%pK",
  892. __func__, __LINE__, &(*desc_list)->rx_desc,
  893. (*desc_list)->rx_desc.cookie, rx_netbuf,
  894. (void *)paddr);
  895. *desc_list = next;
  896. }
  897. hal_srng_access_end(dp_soc->hal_soc, rxdma_srng);
  898. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  899. "successfully replenished %d buffers", num_req_buffers);
  900. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  901. "%d rx desc added back to free list", num_desc_to_free);
  902. /*
  903. * add any available free desc back to the free list
  904. */
  905. if (*desc_list) {
  906. dp_rx_add_desc_list_to_free_list(dp_soc, desc_list, tail,
  907. mac_id, rx_desc_pool);
  908. }
  909. return QDF_STATUS_SUCCESS;
  910. }
  911. /**
  912. * dp_rx_pdev_mon_status_attach() - attach DP RX monitor status ring
  913. * @pdev: core txrx pdev context
  914. * @ring_id: ring number
  915. * This function will attach a DP RX monitor status ring into pDEV
  916. * and replenish monitor status ring with buffer.
  917. *
  918. * Return: QDF_STATUS_SUCCESS: success
  919. * QDF_STATUS_E_RESOURCES: Error return
  920. */
  921. QDF_STATUS
  922. dp_rx_pdev_mon_status_attach(struct dp_pdev *pdev, int ring_id) {
  923. struct dp_soc *soc = pdev->soc;
  924. union dp_rx_desc_list_elem_t *desc_list = NULL;
  925. union dp_rx_desc_list_elem_t *tail = NULL;
  926. struct dp_srng *mon_status_ring;
  927. uint32_t num_entries;
  928. uint32_t i;
  929. struct rx_desc_pool *rx_desc_pool;
  930. QDF_STATUS status;
  931. int mac_for_pdev = dp_get_mac_id_for_mac(soc, ring_id);
  932. mon_status_ring = &pdev->rxdma_mon_status_ring[mac_for_pdev];
  933. num_entries = mon_status_ring->num_entries;
  934. rx_desc_pool = &soc->rx_desc_status[ring_id];
  935. dp_info("Mon RX Status Pool[%d] entries=%d",
  936. ring_id, num_entries);
  937. status = dp_rx_desc_pool_alloc(soc, ring_id, num_entries + 1,
  938. rx_desc_pool);
  939. if (!QDF_IS_STATUS_SUCCESS(status))
  940. return status;
  941. dp_debug("Mon RX Status Buffers Replenish ring_id=%d", ring_id);
  942. status = dp_rx_mon_status_buffers_replenish(soc, ring_id,
  943. mon_status_ring,
  944. rx_desc_pool,
  945. num_entries,
  946. &desc_list, &tail,
  947. HAL_RX_BUF_RBM_SW3_BM);
  948. if (!QDF_IS_STATUS_SUCCESS(status))
  949. return status;
  950. qdf_nbuf_queue_init(&pdev->rx_status_q);
  951. pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  952. qdf_mem_zero(&(pdev->ppdu_info.rx_status),
  953. sizeof(pdev->ppdu_info.rx_status));
  954. qdf_mem_zero(&pdev->rx_mon_stats,
  955. sizeof(pdev->rx_mon_stats));
  956. dp_rx_mon_init_dbg_ppdu_stats(&pdev->ppdu_info,
  957. &pdev->rx_mon_stats);
  958. for (i = 0; i < MAX_MU_USERS; i++) {
  959. qdf_nbuf_queue_init(&pdev->mpdu_q[i]);
  960. pdev->is_mpdu_hdr[i] = true;
  961. }
  962. qdf_mem_zero(pdev->msdu_list, sizeof(pdev->msdu_list[MAX_MU_USERS]));
  963. pdev->rx_enh_capture_mode = CDP_RX_ENH_CAPTURE_DISABLED;
  964. return QDF_STATUS_SUCCESS;
  965. }