dp_rx_mon_status.c 30 KB

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