dp_rx_mon_status.c 30 KB

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