dp_rx_mon_status.c 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579
  1. /*
  2. * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #include "hal_hw_headers.h"
  19. #include "dp_types.h"
  20. #include "dp_rx.h"
  21. #include "dp_peer.h"
  22. #include "hal_rx.h"
  23. #include "hal_api.h"
  24. #include "qdf_trace.h"
  25. #include "qdf_nbuf.h"
  26. #include "hal_api_mon.h"
  27. #include "dp_rx_mon.h"
  28. #include "dp_internal.h"
  29. #include "qdf_mem.h" /* qdf_mem_malloc,free */
  30. #include "htt.h"
  31. #ifdef FEATURE_PERPKT_INFO
  32. #include "dp_ratetable.h"
  33. #endif
  34. static inline
  35. QDF_STATUS dp_rx_mon_status_buffers_replenish(struct dp_soc *dp_soc,
  36. uint32_t mac_id,
  37. struct dp_srng *dp_rxdma_srng,
  38. struct rx_desc_pool *rx_desc_pool,
  39. uint32_t num_req_buffers,
  40. union dp_rx_desc_list_elem_t **desc_list,
  41. union dp_rx_desc_list_elem_t **tail,
  42. uint8_t owner);
  43. static inline void
  44. dp_rx_populate_cfr_non_assoc_sta(struct dp_pdev *pdev,
  45. struct hal_rx_ppdu_info *ppdu_info,
  46. struct cdp_rx_indication_ppdu *cdp_rx_ppdu);
  47. /**
  48. * dp_rx_mon_handle_status_buf_done () - Handle status buf DMA not done
  49. *
  50. * @pdev: DP pdev handle
  51. * @mon_status_srng: Monitor status SRNG
  52. *
  53. * As per MAC team's suggestion, If HP + 2 entry's DMA done is set,
  54. * skip HP + 1 entry and start processing in next interrupt.
  55. * If HP + 2 entry's DMA done is not set, poll onto HP + 1 entry
  56. * for it's DMA done TLV to be set.
  57. *
  58. * Return: enum dp_mon_reap_status
  59. */
  60. enum dp_mon_reap_status
  61. dp_rx_mon_handle_status_buf_done(struct dp_pdev *pdev,
  62. void *mon_status_srng)
  63. {
  64. struct dp_soc *soc = pdev->soc;
  65. hal_soc_handle_t hal_soc;
  66. void *ring_entry;
  67. uint32_t rx_buf_cookie;
  68. qdf_nbuf_t status_nbuf;
  69. struct dp_rx_desc *rx_desc;
  70. void *rx_tlv;
  71. QDF_STATUS buf_status;
  72. hal_soc = soc->hal_soc;
  73. ring_entry = hal_srng_src_peek_n_get_next_next(hal_soc,
  74. mon_status_srng);
  75. if (!ring_entry) {
  76. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  77. FL("Monitor status ring entry is NULL "
  78. "for SRNG: %pK"),
  79. mon_status_srng);
  80. return DP_MON_STATUS_NO_DMA;
  81. }
  82. rx_buf_cookie = HAL_RX_BUF_COOKIE_GET(ring_entry);
  83. rx_desc = dp_rx_cookie_2_va_mon_status(soc, rx_buf_cookie);
  84. qdf_assert(rx_desc);
  85. status_nbuf = rx_desc->nbuf;
  86. qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf,
  87. QDF_DMA_FROM_DEVICE);
  88. rx_tlv = qdf_nbuf_data(status_nbuf);
  89. buf_status = hal_get_rx_status_done(rx_tlv);
  90. /* If status buffer DMA is not done,
  91. * 1. As per MAC team's suggestion, If HP + 2 entry's DMA done is set,
  92. * replenish HP + 1 entry and start processing in next interrupt.
  93. * 2. If HP + 2 entry's DMA done is not set
  94. * hold on to mon destination ring.
  95. */
  96. if (buf_status != QDF_STATUS_SUCCESS) {
  97. dp_err_rl("Monitor status ring: DMA is not done "
  98. "for nbuf: %pK", status_nbuf);
  99. pdev->rx_mon_stats.tlv_tag_status_err++;
  100. return DP_MON_STATUS_NO_DMA;
  101. }
  102. pdev->rx_mon_stats.status_buf_done_war++;
  103. return DP_MON_STATUS_REPLENISH;
  104. }
  105. #ifndef QCA_SUPPORT_FULL_MON
  106. /**
  107. * dp_rx_mon_process () - Core brain processing for monitor mode
  108. *
  109. * This API processes monitor destination ring followed by monitor status ring
  110. * Called from bottom half (tasklet/NET_RX_SOFTIRQ)
  111. *
  112. * @soc: datapath soc context
  113. * @int_ctx: interrupt context
  114. * @mac_id: mac_id on which interrupt is received
  115. * @quota: Number of status ring entry that can be serviced in one shot.
  116. *
  117. * @Return: Number of reaped status ring entries
  118. */
  119. static inline uint32_t
  120. dp_rx_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  121. uint32_t mac_id, uint32_t quota)
  122. {
  123. return quota;
  124. }
  125. #endif
  126. #ifdef WLAN_RX_PKT_CAPTURE_ENH
  127. #include "dp_rx_mon_feature.h"
  128. #else
  129. static QDF_STATUS
  130. dp_rx_handle_enh_capture(struct dp_soc *soc, struct dp_pdev *pdev,
  131. struct hal_rx_ppdu_info *ppdu_info)
  132. {
  133. return QDF_STATUS_SUCCESS;
  134. }
  135. static void
  136. dp_rx_mon_enh_capture_process(struct dp_pdev *pdev, uint32_t tlv_status,
  137. qdf_nbuf_t status_nbuf,
  138. struct hal_rx_ppdu_info *ppdu_info,
  139. bool *nbuf_used)
  140. {
  141. }
  142. #endif
  143. #ifdef WLAN_TX_PKT_CAPTURE_ENH
  144. #include "dp_rx_mon_feature.h"
  145. #else
  146. static QDF_STATUS
  147. dp_send_ack_frame_to_stack(struct dp_soc *soc,
  148. struct dp_pdev *pdev,
  149. struct hal_rx_ppdu_info *ppdu_info)
  150. {
  151. return QDF_STATUS_SUCCESS;
  152. }
  153. #endif
  154. #ifdef FEATURE_PERPKT_INFO
  155. static inline void
  156. dp_rx_populate_rx_rssi_chain(struct hal_rx_ppdu_info *ppdu_info,
  157. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  158. {
  159. uint8_t chain, bw;
  160. int8_t rssi;
  161. for (chain = 0; chain < SS_COUNT; chain++) {
  162. for (bw = 0; bw < MAX_BW; bw++) {
  163. rssi = ppdu_info->rx_status.rssi_chain[chain][bw];
  164. if (rssi != DP_RSSI_INVAL)
  165. cdp_rx_ppdu->rssi_chain[chain][bw] = rssi;
  166. else
  167. cdp_rx_ppdu->rssi_chain[chain][bw] = 0;
  168. }
  169. }
  170. }
  171. /*
  172. * dp_rx_populate_su_evm_details() - Populate su evm info
  173. * @ppdu_info: ppdu info structure from ppdu ring
  174. * @cdp_rx_ppdu: rx ppdu indication structure
  175. */
  176. static inline void
  177. dp_rx_populate_su_evm_details(struct hal_rx_ppdu_info *ppdu_info,
  178. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  179. {
  180. uint8_t pilot_evm;
  181. uint8_t nss_count;
  182. uint8_t pilot_count;
  183. nss_count = ppdu_info->evm_info.nss_count;
  184. pilot_count = ppdu_info->evm_info.pilot_count;
  185. if ((nss_count * pilot_count) > DP_RX_MAX_SU_EVM_COUNT) {
  186. qdf_err("pilot evm count is more than expected");
  187. return;
  188. }
  189. cdp_rx_ppdu->evm_info.pilot_count = pilot_count;
  190. cdp_rx_ppdu->evm_info.nss_count = nss_count;
  191. /* Populate evm for pilot_evm = nss_count*pilot_count */
  192. for (pilot_evm = 0; pilot_evm < nss_count * pilot_count; pilot_evm++) {
  193. cdp_rx_ppdu->evm_info.pilot_evm[pilot_evm] =
  194. ppdu_info->evm_info.pilot_evm[pilot_evm];
  195. }
  196. }
  197. /**
  198. * dp_rx_inc_rusize_cnt() - increment pdev stats based on RU size
  199. * @pdev: pdev ctx
  200. * @rx_user_status: mon rx user status
  201. *
  202. * Return: bool
  203. */
  204. static inline bool
  205. dp_rx_inc_rusize_cnt(struct dp_pdev *pdev,
  206. struct mon_rx_user_status *rx_user_status)
  207. {
  208. uint32_t ru_size;
  209. bool is_data;
  210. ru_size = rx_user_status->ofdma_ru_size;
  211. if (dp_is_subtype_data(rx_user_status->frame_control)) {
  212. DP_STATS_INC(pdev,
  213. ul_ofdma.data_rx_ru_size[ru_size], 1);
  214. is_data = true;
  215. } else {
  216. DP_STATS_INC(pdev,
  217. ul_ofdma.nondata_rx_ru_size[ru_size], 1);
  218. is_data = false;
  219. }
  220. return is_data;
  221. }
  222. /**
  223. * dp_rx_populate_cdp_indication_ppdu_user() - Populate per user cdp indication
  224. * @pdev: pdev ctx
  225. * @ppdu_info: ppdu info structure from ppdu ring
  226. * @cdp_rx_ppdu: Rx PPDU indication structure
  227. *
  228. * Return: none
  229. */
  230. static inline void
  231. dp_rx_populate_cdp_indication_ppdu_user(struct dp_pdev *pdev,
  232. struct hal_rx_ppdu_info *ppdu_info,
  233. struct cdp_rx_indication_ppdu
  234. *cdp_rx_ppdu)
  235. {
  236. struct dp_peer *peer;
  237. struct dp_soc *soc = pdev->soc;
  238. struct dp_ast_entry *ast_entry;
  239. uint32_t ast_index;
  240. int i;
  241. struct mon_rx_user_status *rx_user_status;
  242. struct mon_rx_user_info *rx_user_info;
  243. struct cdp_rx_stats_ppdu_user *rx_stats_peruser;
  244. int ru_size;
  245. bool is_data = false;
  246. uint32_t num_users;
  247. num_users = ppdu_info->com_info.num_users;
  248. for (i = 0; i < num_users; i++) {
  249. if (i > OFDMA_NUM_USERS)
  250. return;
  251. rx_user_status = &ppdu_info->rx_user_status[i];
  252. rx_user_info = &ppdu_info->rx_user_info[i];
  253. rx_stats_peruser = &cdp_rx_ppdu->user[i];
  254. ast_index = rx_user_status->ast_index;
  255. if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  256. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  257. continue;
  258. }
  259. ast_entry = soc->ast_table[ast_index];
  260. if (!ast_entry || ast_entry->peer_id == HTT_INVALID_PEER) {
  261. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  262. continue;
  263. }
  264. peer = dp_peer_get_ref_by_id(soc, ast_entry->peer_id,
  265. DP_MOD_ID_RX_PPDU_STATS);
  266. if (!peer) {
  267. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  268. continue;
  269. }
  270. rx_stats_peruser->is_bss_peer = peer->bss_peer;
  271. rx_stats_peruser->first_data_seq_ctrl =
  272. rx_user_status->first_data_seq_ctrl;
  273. rx_stats_peruser->frame_control_info_valid =
  274. rx_user_status->frame_control_info_valid;
  275. rx_stats_peruser->frame_control =
  276. rx_user_status->frame_control;
  277. rx_stats_peruser->qos_control_info_valid =
  278. rx_user_info->qos_control_info_valid;
  279. rx_stats_peruser->qos_control =
  280. rx_user_info->qos_control;
  281. rx_stats_peruser->tcp_msdu_count =
  282. rx_user_status->tcp_msdu_count;
  283. rx_stats_peruser->udp_msdu_count =
  284. rx_user_status->udp_msdu_count;
  285. rx_stats_peruser->other_msdu_count =
  286. rx_user_status->other_msdu_count;
  287. rx_stats_peruser->num_msdu =
  288. rx_stats_peruser->tcp_msdu_count +
  289. rx_stats_peruser->udp_msdu_count +
  290. rx_stats_peruser->other_msdu_count;
  291. rx_stats_peruser->preamble_type =
  292. rx_user_status->preamble_type;
  293. rx_stats_peruser->mpdu_cnt_fcs_ok =
  294. rx_user_status->mpdu_cnt_fcs_ok;
  295. rx_stats_peruser->mpdu_cnt_fcs_err =
  296. rx_user_status->mpdu_cnt_fcs_err;
  297. qdf_mem_copy(&rx_stats_peruser->mpdu_fcs_ok_bitmap,
  298. &rx_user_status->mpdu_fcs_ok_bitmap,
  299. HAL_RX_NUM_WORDS_PER_PPDU_BITMAP *
  300. sizeof(rx_user_status->mpdu_fcs_ok_bitmap[0]));
  301. rx_stats_peruser->mpdu_ok_byte_count =
  302. rx_user_status->mpdu_ok_byte_count;
  303. rx_stats_peruser->mpdu_err_byte_count =
  304. rx_user_status->mpdu_err_byte_count;
  305. cdp_rx_ppdu->num_mpdu += rx_user_status->mpdu_cnt_fcs_ok;
  306. cdp_rx_ppdu->num_msdu += rx_stats_peruser->num_msdu;
  307. rx_stats_peruser->retries =
  308. CDP_FC_IS_RETRY_SET(rx_stats_peruser->frame_control) ?
  309. rx_stats_peruser->mpdu_cnt_fcs_ok : 0;
  310. if (rx_stats_peruser->mpdu_cnt_fcs_ok > 1)
  311. rx_stats_peruser->is_ampdu = 1;
  312. else
  313. rx_stats_peruser->is_ampdu = 0;
  314. rx_stats_peruser->tid = ppdu_info->rx_status.tid;
  315. qdf_mem_copy(rx_stats_peruser->mac_addr,
  316. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  317. rx_stats_peruser->peer_id = peer->peer_id;
  318. cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
  319. rx_stats_peruser->vdev_id = peer->vdev->vdev_id;
  320. rx_stats_peruser->mu_ul_info_valid = 0;
  321. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  322. if (cdp_rx_ppdu->u.ppdu_type == HAL_RX_TYPE_MU_OFDMA ||
  323. cdp_rx_ppdu->u.ppdu_type == HAL_RX_TYPE_MU_MIMO) {
  324. if (rx_user_status->mu_ul_info_valid) {
  325. rx_stats_peruser->nss = rx_user_status->nss;
  326. rx_stats_peruser->mcs = rx_user_status->mcs;
  327. rx_stats_peruser->mu_ul_info_valid =
  328. rx_user_status->mu_ul_info_valid;
  329. rx_stats_peruser->ofdma_ru_start_index =
  330. rx_user_status->ofdma_ru_start_index;
  331. rx_stats_peruser->ofdma_ru_width =
  332. rx_user_status->ofdma_ru_width;
  333. rx_stats_peruser->user_index = i;
  334. ru_size = rx_user_status->ofdma_ru_size;
  335. /*
  336. * max RU size will be equal to
  337. * HTT_UL_OFDMA_V0_RU_SIZE_RU_996x2
  338. */
  339. if (ru_size >= OFDMA_NUM_RU_SIZE) {
  340. dp_err("invalid ru_size %d\n",
  341. ru_size);
  342. return;
  343. }
  344. is_data = dp_rx_inc_rusize_cnt(pdev,
  345. rx_user_status);
  346. }
  347. if (is_data) {
  348. /* counter to get number of MU OFDMA */
  349. pdev->stats.ul_ofdma.data_rx_ppdu++;
  350. pdev->stats.ul_ofdma.data_users[num_users]++;
  351. }
  352. }
  353. }
  354. }
  355. /**
  356. * dp_rx_populate_cdp_indication_ppdu() - Populate cdp rx indication structure
  357. * @pdev: pdev ctx
  358. * @ppdu_info: ppdu info structure from ppdu ring
  359. * @cdp_rx_ppdu: Rx PPDU indication structure
  360. *
  361. * Return: none
  362. */
  363. static inline void
  364. dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
  365. struct hal_rx_ppdu_info *ppdu_info,
  366. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  367. {
  368. struct dp_peer *peer;
  369. struct dp_soc *soc = pdev->soc;
  370. struct dp_ast_entry *ast_entry;
  371. uint32_t ast_index;
  372. uint32_t i;
  373. cdp_rx_ppdu->first_data_seq_ctrl =
  374. ppdu_info->rx_status.first_data_seq_ctrl;
  375. cdp_rx_ppdu->frame_ctrl =
  376. ppdu_info->rx_status.frame_control;
  377. cdp_rx_ppdu->tcp_msdu_count = ppdu_info->rx_status.tcp_msdu_count;
  378. cdp_rx_ppdu->udp_msdu_count = ppdu_info->rx_status.udp_msdu_count;
  379. cdp_rx_ppdu->other_msdu_count = ppdu_info->rx_status.other_msdu_count;
  380. cdp_rx_ppdu->u.preamble = ppdu_info->rx_status.preamble_type;
  381. /* num mpdu is consolidated and added together in num user loop */
  382. cdp_rx_ppdu->num_mpdu = ppdu_info->com_info.mpdu_cnt_fcs_ok;
  383. /* num msdu is consolidated and added together in num user loop */
  384. cdp_rx_ppdu->num_msdu = (cdp_rx_ppdu->tcp_msdu_count +
  385. cdp_rx_ppdu->udp_msdu_count +
  386. cdp_rx_ppdu->other_msdu_count);
  387. cdp_rx_ppdu->retries = CDP_FC_IS_RETRY_SET(cdp_rx_ppdu->frame_ctrl) ?
  388. ppdu_info->com_info.mpdu_cnt_fcs_ok : 0;
  389. if (ppdu_info->com_info.mpdu_cnt_fcs_ok > 1)
  390. cdp_rx_ppdu->is_ampdu = 1;
  391. else
  392. cdp_rx_ppdu->is_ampdu = 0;
  393. cdp_rx_ppdu->tid = ppdu_info->rx_status.tid;
  394. ast_index = ppdu_info->rx_status.ast_index;
  395. if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  396. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  397. cdp_rx_ppdu->num_users = 0;
  398. goto end;
  399. }
  400. ast_entry = soc->ast_table[ast_index];
  401. if (!ast_entry || ast_entry->peer_id == HTT_INVALID_PEER) {
  402. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  403. cdp_rx_ppdu->num_users = 0;
  404. goto end;
  405. }
  406. peer = dp_peer_get_ref_by_id(soc, ast_entry->peer_id,
  407. DP_MOD_ID_RX_PPDU_STATS);
  408. if (!peer) {
  409. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  410. cdp_rx_ppdu->num_users = 0;
  411. goto end;
  412. }
  413. qdf_mem_copy(cdp_rx_ppdu->mac_addr,
  414. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  415. cdp_rx_ppdu->peer_id = peer->peer_id;
  416. cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
  417. cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
  418. cdp_rx_ppdu->length = ppdu_info->rx_status.ppdu_len;
  419. cdp_rx_ppdu->duration = ppdu_info->rx_status.duration;
  420. cdp_rx_ppdu->u.bw = ppdu_info->rx_status.bw;
  421. cdp_rx_ppdu->u.nss = ppdu_info->rx_status.nss;
  422. cdp_rx_ppdu->u.mcs = ppdu_info->rx_status.mcs;
  423. if ((ppdu_info->rx_status.sgi == VHT_SGI_NYSM) &&
  424. (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC))
  425. cdp_rx_ppdu->u.gi = CDP_SGI_0_4_US;
  426. else
  427. cdp_rx_ppdu->u.gi = ppdu_info->rx_status.sgi;
  428. cdp_rx_ppdu->u.ldpc = ppdu_info->rx_status.ldpc;
  429. cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
  430. cdp_rx_ppdu->u.ltf_size = (ppdu_info->rx_status.he_data5 >>
  431. QDF_MON_STATUS_HE_LTF_SIZE_SHIFT) & 0x3;
  432. cdp_rx_ppdu->rssi = ppdu_info->rx_status.rssi_comb;
  433. cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
  434. cdp_rx_ppdu->channel = ppdu_info->rx_status.chan_num;
  435. cdp_rx_ppdu->beamformed = ppdu_info->rx_status.beamformed;
  436. cdp_rx_ppdu->num_bytes = ppdu_info->rx_status.ppdu_len;
  437. cdp_rx_ppdu->lsig_a = ppdu_info->rx_status.rate;
  438. cdp_rx_ppdu->u.ltf_size = ppdu_info->rx_status.ltf_size;
  439. dp_rx_populate_rx_rssi_chain(ppdu_info, cdp_rx_ppdu);
  440. dp_rx_populate_su_evm_details(ppdu_info, cdp_rx_ppdu);
  441. cdp_rx_ppdu->rx_antenna = ppdu_info->rx_status.rx_antenna;
  442. cdp_rx_ppdu->nf = ppdu_info->rx_status.chan_noise_floor;
  443. for (i = 0; i < MAX_CHAIN; i++)
  444. cdp_rx_ppdu->per_chain_rssi[i] = ppdu_info->rx_status.rssi[i];
  445. cdp_rx_ppdu->is_mcast_bcast = ppdu_info->nac_info.mcast_bcast;
  446. cdp_rx_ppdu->num_users = ppdu_info->com_info.num_users;
  447. cdp_rx_ppdu->num_mpdu = 0;
  448. cdp_rx_ppdu->num_msdu = 0;
  449. dp_rx_populate_cdp_indication_ppdu_user(pdev, ppdu_info, cdp_rx_ppdu);
  450. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  451. return;
  452. end:
  453. dp_rx_populate_cfr_non_assoc_sta(pdev, ppdu_info, cdp_rx_ppdu);
  454. }
  455. #else
  456. static inline void
  457. dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
  458. struct hal_rx_ppdu_info *ppdu_info,
  459. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  460. {
  461. }
  462. #endif
  463. /**
  464. * dp_rx_stats_update() - Update per-peer statistics
  465. * @soc: Datapath SOC handle
  466. * @peer: Datapath peer handle
  467. * @ppdu: PPDU Descriptor
  468. *
  469. * Return: None
  470. */
  471. #ifdef FEATURE_PERPKT_INFO
  472. static inline void dp_rx_rate_stats_update(struct dp_peer *peer,
  473. struct cdp_rx_indication_ppdu *ppdu,
  474. uint32_t user)
  475. {
  476. uint32_t ratekbps = 0;
  477. uint32_t ppdu_rx_rate = 0;
  478. uint32_t nss = 0;
  479. uint8_t mcs = 0;
  480. uint32_t rix;
  481. uint16_t ratecode;
  482. struct cdp_rx_stats_ppdu_user *ppdu_user = NULL;
  483. if (!peer || !ppdu)
  484. return;
  485. if (ppdu->u.ppdu_type != HAL_RX_TYPE_SU) {
  486. ppdu_user = &ppdu->user[user];
  487. if (ppdu_user->nss == 0)
  488. nss = 0;
  489. else
  490. nss = ppdu_user->nss - 1;
  491. mcs = ppdu_user->mcs;
  492. } else {
  493. if (ppdu->u.nss == 0)
  494. nss = 0;
  495. else
  496. nss = ppdu->u.nss - 1;
  497. mcs = ppdu->u.mcs;
  498. }
  499. ratekbps = dp_getrateindex(ppdu->u.gi,
  500. mcs,
  501. nss,
  502. ppdu->u.preamble,
  503. ppdu->u.bw,
  504. &rix,
  505. &ratecode);
  506. if (!ratekbps)
  507. return;
  508. ppdu->rix = rix;
  509. DP_STATS_UPD(peer, rx.last_rx_rate, ratekbps);
  510. dp_ath_rate_lpf(peer->stats.rx.avg_rx_rate, ratekbps);
  511. ppdu_rx_rate = dp_ath_rate_out(peer->stats.rx.avg_rx_rate);
  512. DP_STATS_UPD(peer, rx.rnd_avg_rx_rate, ppdu_rx_rate);
  513. ppdu->rx_ratekbps = ratekbps;
  514. ppdu->rx_ratecode = ratecode;
  515. if (ppdu->u.ppdu_type != HAL_RX_TYPE_SU)
  516. ppdu_user->rx_ratekbps = ratekbps;
  517. if (peer->vdev)
  518. peer->vdev->stats.rx.last_rx_rate = ratekbps;
  519. }
  520. static void dp_rx_stats_update(struct dp_pdev *pdev,
  521. struct cdp_rx_indication_ppdu *ppdu)
  522. {
  523. struct dp_soc *soc = NULL;
  524. uint8_t mcs, preamble, ac = 0, nss, ppdu_type;
  525. uint16_t num_msdu;
  526. uint8_t pkt_bw_offset;
  527. struct dp_peer *peer;
  528. struct cdp_rx_stats_ppdu_user *ppdu_user;
  529. uint32_t i;
  530. enum cdp_mu_packet_type mu_pkt_type;
  531. if (pdev)
  532. soc = pdev->soc;
  533. else
  534. return;
  535. if (!soc || soc->process_rx_status)
  536. return;
  537. preamble = ppdu->u.preamble;
  538. ppdu_type = ppdu->u.ppdu_type;
  539. for (i = 0; i < ppdu->num_users && i < CDP_MU_MAX_USERS; i++) {
  540. peer = NULL;
  541. ppdu_user = &ppdu->user[i];
  542. peer = dp_peer_get_ref_by_id(soc, ppdu_user->peer_id,
  543. DP_MOD_ID_RX_PPDU_STATS);
  544. if (!peer)
  545. peer = pdev->invalid_peer;
  546. if (ppdu_type == HAL_RX_TYPE_SU) {
  547. mcs = ppdu->u.mcs;
  548. nss = ppdu->u.nss;
  549. } else {
  550. mcs = ppdu_user->mcs;
  551. nss = ppdu_user->nss;
  552. }
  553. num_msdu = ppdu_user->num_msdu;
  554. switch (ppdu->u.bw) {
  555. case CMN_BW_20MHZ:
  556. pkt_bw_offset = PKT_BW_GAIN_20MHZ;
  557. break;
  558. case CMN_BW_40MHZ:
  559. pkt_bw_offset = PKT_BW_GAIN_40MHZ;
  560. break;
  561. case CMN_BW_80MHZ:
  562. pkt_bw_offset = PKT_BW_GAIN_80MHZ;
  563. break;
  564. case CMN_BW_160MHZ:
  565. pkt_bw_offset = PKT_BW_GAIN_160MHZ;
  566. break;
  567. default:
  568. pkt_bw_offset = 0;
  569. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  570. "Invalid BW index = %d", ppdu->u.bw);
  571. }
  572. DP_STATS_UPD(peer, rx.rssi, (ppdu->rssi + pkt_bw_offset));
  573. if (peer->stats.rx.avg_rssi == INVALID_RSSI)
  574. peer->stats.rx.avg_rssi =
  575. CDP_RSSI_IN(peer->stats.rx.rssi);
  576. else
  577. CDP_RSSI_UPDATE_AVG(peer->stats.rx.avg_rssi,
  578. peer->stats.rx.rssi);
  579. if ((preamble == DOT11_A) || (preamble == DOT11_B))
  580. nss = 1;
  581. if (ppdu_type == HAL_RX_TYPE_SU) {
  582. if (nss) {
  583. DP_STATS_INC(peer, rx.nss[nss - 1], num_msdu);
  584. DP_STATS_INC(peer, rx.ppdu_nss[nss - 1], 1);
  585. }
  586. DP_STATS_INC(peer, rx.mpdu_cnt_fcs_ok,
  587. ppdu_user->mpdu_cnt_fcs_ok);
  588. DP_STATS_INC(peer, rx.mpdu_cnt_fcs_err,
  589. ppdu_user->mpdu_cnt_fcs_err);
  590. }
  591. if (ppdu_type >= HAL_RX_TYPE_MU_MIMO &&
  592. ppdu_type <= HAL_RX_TYPE_MU_OFDMA) {
  593. if (ppdu_type == HAL_RX_TYPE_MU_MIMO)
  594. mu_pkt_type = RX_TYPE_MU_MIMO;
  595. else
  596. mu_pkt_type = RX_TYPE_MU_OFDMA;
  597. if (nss) {
  598. DP_STATS_INC(peer, rx.nss[nss - 1], num_msdu);
  599. DP_STATS_INC(peer,
  600. rx.rx_mu[mu_pkt_type].ppdu_nss[nss - 1],
  601. 1);
  602. }
  603. DP_STATS_INC(peer,
  604. rx.rx_mu[mu_pkt_type].mpdu_cnt_fcs_ok,
  605. ppdu_user->mpdu_cnt_fcs_ok);
  606. DP_STATS_INC(peer,
  607. rx.rx_mu[mu_pkt_type].mpdu_cnt_fcs_err,
  608. ppdu_user->mpdu_cnt_fcs_err);
  609. }
  610. DP_STATS_INC(peer, rx.sgi_count[ppdu->u.gi], num_msdu);
  611. DP_STATS_INC(peer, rx.bw[ppdu->u.bw], num_msdu);
  612. DP_STATS_INC(peer, rx.reception_type[ppdu->u.ppdu_type],
  613. num_msdu);
  614. DP_STATS_INC(peer, rx.ppdu_cnt[ppdu->u.ppdu_type], 1);
  615. DP_STATS_INCC(peer, rx.ampdu_cnt, num_msdu,
  616. ppdu_user->is_ampdu);
  617. DP_STATS_INCC(peer, rx.non_ampdu_cnt, num_msdu,
  618. !(ppdu_user->is_ampdu));
  619. DP_STATS_UPD(peer, rx.rx_rate, mcs);
  620. DP_STATS_INCC(peer,
  621. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  622. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
  623. DP_STATS_INCC(peer,
  624. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  625. ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
  626. DP_STATS_INCC(peer,
  627. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  628. ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B)));
  629. DP_STATS_INCC(peer,
  630. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  631. ((mcs < MAX_MCS_11B) && (preamble == DOT11_B)));
  632. DP_STATS_INCC(peer,
  633. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  634. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N)));
  635. DP_STATS_INCC(peer,
  636. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  637. ((mcs < MAX_MCS_11A) && (preamble == DOT11_N)));
  638. DP_STATS_INCC(peer,
  639. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  640. ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC)));
  641. DP_STATS_INCC(peer,
  642. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  643. ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
  644. DP_STATS_INCC(peer,
  645. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  646. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  647. DP_STATS_INCC(peer,
  648. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  649. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  650. DP_STATS_INCC(peer,
  651. rx.su_ax_ppdu_cnt.mcs_count[MAX_MCS - 1], 1,
  652. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX) &&
  653. (ppdu_type == HAL_RX_TYPE_SU)));
  654. DP_STATS_INCC(peer,
  655. rx.su_ax_ppdu_cnt.mcs_count[mcs], 1,
  656. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX) &&
  657. (ppdu_type == HAL_RX_TYPE_SU)));
  658. DP_STATS_INCC(peer,
  659. rx.rx_mu[RX_TYPE_MU_OFDMA].ppdu.mcs_count[MAX_MCS - 1],
  660. 1, ((mcs >= (MAX_MCS - 1)) &&
  661. (preamble == DOT11_AX) &&
  662. (ppdu_type == HAL_RX_TYPE_MU_OFDMA)));
  663. DP_STATS_INCC(peer,
  664. rx.rx_mu[RX_TYPE_MU_OFDMA].ppdu.mcs_count[mcs],
  665. 1, ((mcs < (MAX_MCS - 1)) &&
  666. (preamble == DOT11_AX) &&
  667. (ppdu_type == HAL_RX_TYPE_MU_OFDMA)));
  668. DP_STATS_INCC(peer,
  669. rx.rx_mu[RX_TYPE_MU_MIMO].ppdu.mcs_count[MAX_MCS - 1],
  670. 1, ((mcs >= (MAX_MCS - 1)) &&
  671. (preamble == DOT11_AX) &&
  672. (ppdu_type == HAL_RX_TYPE_MU_MIMO)));
  673. DP_STATS_INCC(peer,
  674. rx.rx_mu[RX_TYPE_MU_MIMO].ppdu.mcs_count[mcs],
  675. 1, ((mcs < (MAX_MCS - 1)) &&
  676. (preamble == DOT11_AX) &&
  677. (ppdu_type == HAL_RX_TYPE_MU_MIMO)));
  678. /*
  679. * If invalid TID, it could be a non-qos frame, hence do not
  680. * update any AC counters
  681. */
  682. ac = TID_TO_WME_AC(ppdu_user->tid);
  683. if (ppdu->tid != HAL_TID_INVALID)
  684. DP_STATS_INC(peer, rx.wme_ac_type[ac], num_msdu);
  685. dp_peer_stats_notify(pdev, peer);
  686. DP_STATS_UPD(peer, rx.last_rssi, ppdu->rssi);
  687. dp_peer_qos_stats_notify(pdev, ppdu_user);
  688. if (peer == pdev->invalid_peer)
  689. continue;
  690. if (dp_is_subtype_data(ppdu->frame_ctrl))
  691. dp_rx_rate_stats_update(peer, ppdu, i);
  692. #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
  693. dp_wdi_event_handler(WDI_EVENT_UPDATE_DP_STATS, pdev->soc,
  694. &peer->stats, ppdu->peer_id,
  695. UPDATE_PEER_STATS, pdev->pdev_id);
  696. #endif
  697. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  698. }
  699. }
  700. #endif
  701. /**
  702. * dp_rx_handle_mcopy_mode() - Allocate and deliver first MSDU payload
  703. * @soc: core txrx main context
  704. * @pdev: pdev structure
  705. * @ppdu_info: structure for rx ppdu ring
  706. * @nbuf: QDF nbuf
  707. * @fcs_ok_mpdu_cnt: fcs passsed mpdu index
  708. * @deliver_frame: flag to deliver wdi event
  709. *
  710. * Return: QDF_STATUS_SUCCESS - If nbuf to be freed by caller
  711. * QDF_STATUS_E_ALREADY - If nbuf not to be freed by caller
  712. */
  713. #ifdef FEATURE_PERPKT_INFO
  714. static inline QDF_STATUS
  715. dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  716. struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf,
  717. uint8_t fcs_ok_mpdu_cnt, bool deliver_frame)
  718. {
  719. uint16_t size = 0;
  720. struct ieee80211_frame *wh;
  721. uint32_t *nbuf_data;
  722. if (!ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload)
  723. return QDF_STATUS_SUCCESS;
  724. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  725. if (pdev->mcopy_mode == M_COPY) {
  726. if (pdev->m_copy_id.rx_ppdu_id == ppdu_info->com_info.ppdu_id)
  727. return QDF_STATUS_SUCCESS;
  728. }
  729. wh = (struct ieee80211_frame *)(ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload + 4);
  730. size = (ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload -
  731. qdf_nbuf_data(nbuf));
  732. if (qdf_nbuf_pull_head(nbuf, size) == NULL)
  733. return QDF_STATUS_SUCCESS;
  734. if (((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  735. IEEE80211_FC0_TYPE_MGT) ||
  736. ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  737. IEEE80211_FC0_TYPE_CTL)) {
  738. return QDF_STATUS_SUCCESS;
  739. }
  740. nbuf_data = (uint32_t *)qdf_nbuf_data(nbuf);
  741. *nbuf_data = pdev->ppdu_info.com_info.ppdu_id;
  742. /* only retain RX MSDU payload in the skb */
  743. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) - ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].payload_len);
  744. if (deliver_frame) {
  745. pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
  746. dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
  747. nbuf, HTT_INVALID_PEER,
  748. WDI_NO_VAL, pdev->pdev_id);
  749. }
  750. return QDF_STATUS_E_ALREADY;
  751. }
  752. #else
  753. static inline QDF_STATUS
  754. dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  755. struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf,
  756. uint8_t fcs_ok_cnt, bool deliver_frame)
  757. {
  758. return QDF_STATUS_SUCCESS;
  759. }
  760. #endif
  761. /**
  762. * dp_rx_mcopy_handle_last_mpdu() - cache and delive last MPDU header in a
  763. * status buffer if MPDU end tlv is received in different buffer
  764. * @soc: core txrx main context
  765. * @pdev: pdev structure
  766. * @ppdu_info: structure for rx ppdu ring
  767. * @status_nbuf: QDF nbuf
  768. *
  769. * Return: void
  770. */
  771. #ifdef FEATURE_PERPKT_INFO
  772. static inline void
  773. dp_rx_mcopy_handle_last_mpdu(struct dp_soc *soc, struct dp_pdev *pdev,
  774. struct hal_rx_ppdu_info *ppdu_info,
  775. qdf_nbuf_t status_nbuf)
  776. {
  777. QDF_STATUS mcopy_status;
  778. qdf_nbuf_t nbuf_clone = NULL;
  779. /* If the MPDU end tlv and RX header are received in different buffers,
  780. * process the RX header based on fcs status.
  781. */
  782. if (pdev->mcopy_status_nbuf) {
  783. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  784. if (pdev->mcopy_mode == M_COPY) {
  785. if (pdev->m_copy_id.rx_ppdu_id ==
  786. ppdu_info->com_info.ppdu_id)
  787. goto end1;
  788. }
  789. if (ppdu_info->is_fcs_passed) {
  790. nbuf_clone = qdf_nbuf_clone(pdev->mcopy_status_nbuf);
  791. if (!nbuf_clone) {
  792. QDF_TRACE(QDF_MODULE_ID_TXRX,
  793. QDF_TRACE_LEVEL_ERROR,
  794. "Failed to clone nbuf",
  795. __func__, __LINE__);
  796. goto end1;
  797. }
  798. pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
  799. dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
  800. nbuf_clone,
  801. HTT_INVALID_PEER,
  802. WDI_NO_VAL, pdev->pdev_id);
  803. ppdu_info->is_fcs_passed = false;
  804. }
  805. end1:
  806. qdf_nbuf_free(pdev->mcopy_status_nbuf);
  807. pdev->mcopy_status_nbuf = NULL;
  808. }
  809. /* If the MPDU end tlv and RX header are received in different buffers,
  810. * preserve the RX header as the fcs status will be received in MPDU
  811. * end tlv in next buffer. So, cache the buffer to be processd in next
  812. * iteration
  813. */
  814. if ((ppdu_info->fcs_ok_cnt + ppdu_info->fcs_err_cnt) !=
  815. ppdu_info->com_info.mpdu_cnt) {
  816. pdev->mcopy_status_nbuf = qdf_nbuf_clone(status_nbuf);
  817. if (pdev->mcopy_status_nbuf) {
  818. mcopy_status = dp_rx_handle_mcopy_mode(
  819. soc, pdev,
  820. ppdu_info,
  821. pdev->mcopy_status_nbuf,
  822. ppdu_info->fcs_ok_cnt,
  823. false);
  824. if (mcopy_status == QDF_STATUS_SUCCESS) {
  825. qdf_nbuf_free(pdev->mcopy_status_nbuf);
  826. pdev->mcopy_status_nbuf = NULL;
  827. }
  828. }
  829. }
  830. }
  831. #else
  832. static inline void
  833. dp_rx_mcopy_handle_last_mpdu(struct dp_soc *soc, struct dp_pdev *pdev,
  834. struct hal_rx_ppdu_info *ppdu_info,
  835. qdf_nbuf_t status_nbuf)
  836. {
  837. }
  838. #endif
  839. /**
  840. * dp_rx_mcopy_process_ppdu_info() - update mcopy ppdu info
  841. * @ppdu_info: structure for rx ppdu ring
  842. * @tlv_status: processed TLV status
  843. *
  844. * Return: void
  845. */
  846. #ifdef FEATURE_PERPKT_INFO
  847. static inline void
  848. dp_rx_mcopy_process_ppdu_info(struct dp_pdev *pdev,
  849. struct hal_rx_ppdu_info *ppdu_info,
  850. uint32_t tlv_status)
  851. {
  852. if (!pdev->mcopy_mode)
  853. return;
  854. /* The fcs status is received in MPDU end tlv. If the RX header
  855. * and its MPDU end tlv are received in different status buffer then
  856. * to process that header ppdu_info->is_fcs_passed is used.
  857. * If end tlv is received in next status buffer then com_info.mpdu_cnt
  858. * will be 0 at the time of receiving MPDU end tlv and we update the
  859. * is_fcs_passed flag based on ppdu_info->fcs_err.
  860. */
  861. if (tlv_status != HAL_TLV_STATUS_MPDU_END)
  862. return;
  863. if (!ppdu_info->fcs_err) {
  864. if (ppdu_info->fcs_ok_cnt >
  865. HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER) {
  866. dp_err("No. of MPDUs(%d) per status buff exceeded",
  867. ppdu_info->fcs_ok_cnt);
  868. return;
  869. }
  870. if (ppdu_info->com_info.mpdu_cnt)
  871. ppdu_info->fcs_ok_cnt++;
  872. else
  873. ppdu_info->is_fcs_passed = true;
  874. } else {
  875. if (ppdu_info->com_info.mpdu_cnt)
  876. ppdu_info->fcs_err_cnt++;
  877. else
  878. ppdu_info->is_fcs_passed = false;
  879. }
  880. }
  881. #else
  882. static inline void
  883. dp_rx_mcopy_process_ppdu_info(struct dp_pdev *pdev,
  884. struct hal_rx_ppdu_info *ppdu_info,
  885. uint32_t tlv_status)
  886. {
  887. }
  888. #endif
  889. #ifdef FEATURE_PERPKT_INFO
  890. static inline void
  891. dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  892. struct hal_rx_ppdu_info *ppdu_info,
  893. uint32_t tlv_status,
  894. qdf_nbuf_t status_nbuf)
  895. {
  896. QDF_STATUS mcopy_status;
  897. qdf_nbuf_t nbuf_clone = NULL;
  898. uint8_t fcs_ok_mpdu_cnt = 0;
  899. dp_rx_mcopy_handle_last_mpdu(soc, pdev, ppdu_info, status_nbuf);
  900. if (qdf_unlikely(!ppdu_info->com_info.mpdu_cnt))
  901. goto end;
  902. if (qdf_unlikely(!ppdu_info->fcs_ok_cnt))
  903. goto end;
  904. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  905. if (pdev->mcopy_mode == M_COPY)
  906. ppdu_info->fcs_ok_cnt = 1;
  907. while (fcs_ok_mpdu_cnt < ppdu_info->fcs_ok_cnt) {
  908. nbuf_clone = qdf_nbuf_clone(status_nbuf);
  909. if (!nbuf_clone) {
  910. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  911. "Failed to clone nbuf",
  912. __func__, __LINE__);
  913. goto end;
  914. }
  915. mcopy_status = dp_rx_handle_mcopy_mode(soc, pdev,
  916. ppdu_info,
  917. nbuf_clone,
  918. fcs_ok_mpdu_cnt,
  919. true);
  920. if (mcopy_status == QDF_STATUS_SUCCESS)
  921. qdf_nbuf_free(nbuf_clone);
  922. fcs_ok_mpdu_cnt++;
  923. }
  924. end:
  925. qdf_nbuf_free(status_nbuf);
  926. ppdu_info->fcs_ok_cnt = 0;
  927. ppdu_info->fcs_err_cnt = 0;
  928. ppdu_info->com_info.mpdu_cnt = 0;
  929. qdf_mem_zero(&ppdu_info->ppdu_msdu_info,
  930. HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER
  931. * sizeof(struct hal_rx_msdu_payload_info));
  932. }
  933. #else
  934. static inline void
  935. dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  936. struct hal_rx_ppdu_info *ppdu_info,
  937. uint32_t tlv_status,
  938. qdf_nbuf_t status_nbuf)
  939. {
  940. }
  941. #endif
  942. /**
  943. * dp_rx_handle_smart_mesh_mode() - Deliver header for smart mesh
  944. * @soc: Datapath SOC handle
  945. * @pdev: Datapath PDEV handle
  946. * @ppdu_info: Structure for rx ppdu info
  947. * @nbuf: Qdf nbuf abstraction for linux skb
  948. *
  949. * Return: 0 on success, 1 on failure
  950. */
  951. static inline int
  952. dp_rx_handle_smart_mesh_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  953. struct hal_rx_ppdu_info *ppdu_info,
  954. qdf_nbuf_t nbuf)
  955. {
  956. uint8_t size = 0;
  957. if (!pdev->monitor_vdev) {
  958. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  959. "[%s]:[%d] Monitor vdev is NULL !!",
  960. __func__, __LINE__);
  961. return 1;
  962. }
  963. if (!ppdu_info->msdu_info.first_msdu_payload) {
  964. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  965. "[%s]:[%d] First msdu payload not present",
  966. __func__, __LINE__);
  967. return 1;
  968. }
  969. /* Adding 4 bytes to get to start of 802.11 frame after phy_ppdu_id */
  970. size = (ppdu_info->msdu_info.first_msdu_payload -
  971. qdf_nbuf_data(nbuf)) + 4;
  972. ppdu_info->msdu_info.first_msdu_payload = NULL;
  973. if (qdf_nbuf_pull_head(nbuf, size) == NULL) {
  974. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  975. "[%s]:[%d] No header present",
  976. __func__, __LINE__);
  977. return 1;
  978. }
  979. /* Only retain RX MSDU payload in the skb */
  980. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
  981. ppdu_info->msdu_info.payload_len);
  982. if (!qdf_nbuf_update_radiotap(&pdev->ppdu_info.rx_status, nbuf,
  983. qdf_nbuf_headroom(nbuf))) {
  984. DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
  985. return 1;
  986. }
  987. pdev->monitor_vdev->osif_rx_mon(pdev->monitor_vdev->osif_vdev,
  988. nbuf, NULL);
  989. pdev->ppdu_info.rx_status.monitor_direct_used = 0;
  990. return 0;
  991. }
  992. #if defined(WLAN_CFR_ENABLE) && defined(WLAN_ENH_CFR_ENABLE)
  993. /*
  994. * dp_rx_mon_handle_cfr_mu_info() - Gather macaddr and ast_index of peer(s) in
  995. * the PPDU received, this will be used for correlation of CFR data captured
  996. * for an UL-MU-PPDU
  997. * @pdev: pdev ctx
  998. * @ppdu_info: pointer to ppdu info structure populated from ppdu status TLVs
  999. * @cdp_rx_ppdu: Rx PPDU indication structure
  1000. *
  1001. * Return: none
  1002. */
  1003. static inline void
  1004. dp_rx_mon_handle_cfr_mu_info(struct dp_pdev *pdev,
  1005. struct hal_rx_ppdu_info *ppdu_info,
  1006. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1007. {
  1008. struct dp_peer *peer;
  1009. struct dp_soc *soc = pdev->soc;
  1010. struct dp_ast_entry *ast_entry;
  1011. struct mon_rx_user_status *rx_user_status;
  1012. struct cdp_rx_stats_ppdu_user *rx_stats_peruser;
  1013. uint32_t num_users;
  1014. int user_id;
  1015. uint32_t ast_index;
  1016. qdf_spin_lock_bh(&soc->ast_lock);
  1017. num_users = ppdu_info->com_info.num_users;
  1018. for (user_id = 0; user_id < num_users; user_id++) {
  1019. if (user_id > OFDMA_NUM_USERS) {
  1020. qdf_spin_unlock_bh(&soc->ast_lock);
  1021. return;
  1022. }
  1023. rx_user_status = &ppdu_info->rx_user_status[user_id];
  1024. rx_stats_peruser = &cdp_rx_ppdu->user[user_id];
  1025. ast_index = rx_user_status->ast_index;
  1026. if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  1027. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  1028. continue;
  1029. }
  1030. ast_entry = soc->ast_table[ast_index];
  1031. if (!ast_entry || ast_entry->peer_id == HTT_INVALID_PEER) {
  1032. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  1033. continue;
  1034. }
  1035. peer = dp_peer_get_ref_by_id(soc, ast_entry->peer_id,
  1036. DP_MOD_ID_RX_PPDU_STATS);
  1037. if (!peer) {
  1038. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  1039. continue;
  1040. }
  1041. qdf_mem_copy(rx_stats_peruser->mac_addr,
  1042. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  1043. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  1044. }
  1045. qdf_spin_unlock_bh(&soc->ast_lock);
  1046. }
  1047. /*
  1048. * dp_rx_mon_populate_cfr_ppdu_info() - Populate cdp ppdu info from hal ppdu
  1049. * info
  1050. * @pdev: pdev ctx
  1051. * @ppdu_info: ppdu info structure from ppdu ring
  1052. * @cdp_rx_ppdu : Rx PPDU indication structure
  1053. *
  1054. * Return: none
  1055. */
  1056. static inline void
  1057. dp_rx_mon_populate_cfr_ppdu_info(struct dp_pdev *pdev,
  1058. struct hal_rx_ppdu_info *ppdu_info,
  1059. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1060. {
  1061. int chain;
  1062. cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
  1063. cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
  1064. cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
  1065. cdp_rx_ppdu->num_users = ppdu_info->com_info.num_users;
  1066. for (chain = 0; chain < MAX_CHAIN; chain++)
  1067. cdp_rx_ppdu->per_chain_rssi[chain] =
  1068. ppdu_info->rx_status.rssi[chain];
  1069. dp_rx_mon_handle_cfr_mu_info(pdev, ppdu_info, cdp_rx_ppdu);
  1070. }
  1071. /**
  1072. * dp_cfr_rcc_mode_status() - Return status of cfr rcc mode
  1073. * @pdev: pdev ctx
  1074. *
  1075. * Return: True or False
  1076. */
  1077. static inline bool
  1078. dp_cfr_rcc_mode_status(struct dp_pdev *pdev)
  1079. {
  1080. return pdev->cfr_rcc_mode;
  1081. }
  1082. /*
  1083. * dp_rx_mon_populate_cfr_info() - Populate cdp ppdu info from hal cfr info
  1084. * @pdev: pdev ctx
  1085. * @ppdu_info: ppdu info structure from ppdu ring
  1086. * @cdp_rx_ppdu: Rx PPDU indication structure
  1087. *
  1088. * Return: none
  1089. */
  1090. static inline void
  1091. dp_rx_mon_populate_cfr_info(struct dp_pdev *pdev,
  1092. struct hal_rx_ppdu_info *ppdu_info,
  1093. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1094. {
  1095. struct cdp_rx_ppdu_cfr_info *cfr_info;
  1096. if (!dp_cfr_rcc_mode_status(pdev))
  1097. return;
  1098. cfr_info = &cdp_rx_ppdu->cfr_info;
  1099. cfr_info->bb_captured_channel
  1100. = ppdu_info->cfr_info.bb_captured_channel;
  1101. cfr_info->bb_captured_timeout
  1102. = ppdu_info->cfr_info.bb_captured_timeout;
  1103. cfr_info->bb_captured_reason
  1104. = ppdu_info->cfr_info.bb_captured_reason;
  1105. cfr_info->rx_location_info_valid
  1106. = ppdu_info->cfr_info.rx_location_info_valid;
  1107. cfr_info->chan_capture_status
  1108. = ppdu_info->cfr_info.chan_capture_status;
  1109. cfr_info->rtt_che_buffer_pointer_high8
  1110. = ppdu_info->cfr_info.rtt_che_buffer_pointer_high8;
  1111. cfr_info->rtt_che_buffer_pointer_low32
  1112. = ppdu_info->cfr_info.rtt_che_buffer_pointer_low32;
  1113. }
  1114. /**
  1115. * dp_update_cfr_dbg_stats() - Increment RCC debug statistics
  1116. * @pdev: pdev structure
  1117. * @ppdu_info: structure for rx ppdu ring
  1118. *
  1119. * Return: none
  1120. */
  1121. static inline void
  1122. dp_update_cfr_dbg_stats(struct dp_pdev *pdev,
  1123. struct hal_rx_ppdu_info *ppdu_info)
  1124. {
  1125. struct hal_rx_ppdu_cfr_info *cfr = &ppdu_info->cfr_info;
  1126. DP_STATS_INC(pdev,
  1127. rcc.chan_capture_status[cfr->chan_capture_status], 1);
  1128. if (cfr->rx_location_info_valid) {
  1129. DP_STATS_INC(pdev, rcc.rx_loc_info_valid_cnt, 1);
  1130. if (cfr->bb_captured_channel) {
  1131. DP_STATS_INC(pdev, rcc.bb_captured_channel_cnt, 1);
  1132. DP_STATS_INC(pdev,
  1133. rcc.reason_cnt[cfr->bb_captured_reason],
  1134. 1);
  1135. } else if (cfr->bb_captured_timeout) {
  1136. DP_STATS_INC(pdev, rcc.bb_captured_timeout_cnt, 1);
  1137. DP_STATS_INC(pdev,
  1138. rcc.reason_cnt[cfr->bb_captured_reason],
  1139. 1);
  1140. }
  1141. }
  1142. }
  1143. /*
  1144. * dp_rx_handle_cfr() - Gather cfr info from hal ppdu info
  1145. * @soc: core txrx main context
  1146. * @pdev: pdev ctx
  1147. * @ppdu_info: ppdu info structure from ppdu ring
  1148. *
  1149. * Return: none
  1150. */
  1151. static inline void
  1152. dp_rx_handle_cfr(struct dp_soc *soc, struct dp_pdev *pdev,
  1153. struct hal_rx_ppdu_info *ppdu_info)
  1154. {
  1155. qdf_nbuf_t ppdu_nbuf;
  1156. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  1157. dp_update_cfr_dbg_stats(pdev, ppdu_info);
  1158. if (!ppdu_info->cfr_info.bb_captured_channel)
  1159. return;
  1160. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  1161. sizeof(struct cdp_rx_indication_ppdu),
  1162. 0,
  1163. 0,
  1164. FALSE);
  1165. if (ppdu_nbuf) {
  1166. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
  1167. dp_rx_mon_populate_cfr_info(pdev, ppdu_info, cdp_rx_ppdu);
  1168. dp_rx_mon_populate_cfr_ppdu_info(pdev, ppdu_info, cdp_rx_ppdu);
  1169. qdf_nbuf_put_tail(ppdu_nbuf,
  1170. sizeof(struct cdp_rx_indication_ppdu));
  1171. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
  1172. ppdu_nbuf, HTT_INVALID_PEER,
  1173. WDI_NO_VAL, pdev->pdev_id);
  1174. }
  1175. }
  1176. /**
  1177. * dp_rx_populate_cfr_non_assoc_sta() - Populate cfr ppdu info for PPDUs from
  1178. * non-associated stations
  1179. * @pdev: pdev ctx
  1180. * @ppdu_info: ppdu info structure from ppdu ring
  1181. * @cdp_rx_ppdu: Rx PPDU indication structure
  1182. *
  1183. * Return: none
  1184. */
  1185. static inline void
  1186. dp_rx_populate_cfr_non_assoc_sta(struct dp_pdev *pdev,
  1187. struct hal_rx_ppdu_info *ppdu_info,
  1188. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1189. {
  1190. if (!dp_cfr_rcc_mode_status(pdev))
  1191. return;
  1192. if (ppdu_info->cfr_info.bb_captured_channel)
  1193. dp_rx_mon_populate_cfr_ppdu_info(pdev, ppdu_info, cdp_rx_ppdu);
  1194. }
  1195. /**
  1196. * dp_bb_captured_chan_status() - Get the bb_captured_channel status
  1197. * @ppdu_info: structure for rx ppdu ring
  1198. *
  1199. * Return: Success/ Failure
  1200. */
  1201. static inline QDF_STATUS
  1202. dp_bb_captured_chan_status(struct dp_pdev *pdev,
  1203. struct hal_rx_ppdu_info *ppdu_info)
  1204. {
  1205. QDF_STATUS status = QDF_STATUS_E_FAILURE;
  1206. struct hal_rx_ppdu_cfr_info *cfr = &ppdu_info->cfr_info;
  1207. if (dp_cfr_rcc_mode_status(pdev)) {
  1208. if (cfr->bb_captured_channel)
  1209. status = QDF_STATUS_SUCCESS;
  1210. }
  1211. return status;
  1212. }
  1213. #else
  1214. static inline void
  1215. dp_rx_mon_handle_cfr_mu_info(struct dp_pdev *pdev,
  1216. struct hal_rx_ppdu_info *ppdu_info,
  1217. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1218. {
  1219. }
  1220. static inline void
  1221. dp_rx_mon_populate_cfr_ppdu_info(struct dp_pdev *pdev,
  1222. struct hal_rx_ppdu_info *ppdu_info,
  1223. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1224. {
  1225. }
  1226. static inline void
  1227. dp_rx_mon_populate_cfr_info(struct dp_pdev *pdev,
  1228. struct hal_rx_ppdu_info *ppdu_info,
  1229. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1230. {
  1231. }
  1232. static inline void
  1233. dp_rx_handle_cfr(struct dp_soc *soc, struct dp_pdev *pdev,
  1234. struct hal_rx_ppdu_info *ppdu_info)
  1235. {
  1236. }
  1237. static inline void
  1238. dp_rx_populate_cfr_non_assoc_sta(struct dp_pdev *pdev,
  1239. struct hal_rx_ppdu_info *ppdu_info,
  1240. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1241. {
  1242. }
  1243. static inline void
  1244. dp_update_cfr_dbg_stats(struct dp_pdev *pdev,
  1245. struct hal_rx_ppdu_info *ppdu_info)
  1246. {
  1247. }
  1248. static inline QDF_STATUS
  1249. dp_bb_captured_chan_status(struct dp_pdev *pdev,
  1250. struct hal_rx_ppdu_info *ppdu_info)
  1251. {
  1252. return QDF_STATUS_E_NOSUPPORT;
  1253. }
  1254. static inline bool
  1255. dp_cfr_rcc_mode_status(struct dp_pdev *pdev)
  1256. {
  1257. return false;
  1258. }
  1259. #endif
  1260. /**
  1261. * dp_rx_handle_ppdu_stats() - Allocate and deliver ppdu stats to cdp layer
  1262. * @soc: core txrx main context
  1263. * @pdev: pdev strcuture
  1264. * @ppdu_info: structure for rx ppdu ring
  1265. *
  1266. * Return: none
  1267. */
  1268. #ifdef FEATURE_PERPKT_INFO
  1269. static inline void
  1270. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  1271. struct hal_rx_ppdu_info *ppdu_info)
  1272. {
  1273. qdf_nbuf_t ppdu_nbuf;
  1274. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  1275. /*
  1276. * Do not allocate if fcs error,
  1277. * ast idx invalid / fctl invalid
  1278. *
  1279. * In CFR RCC mode - PPDU status TLVs of error pkts are also needed
  1280. */
  1281. if (ppdu_info->com_info.mpdu_cnt_fcs_ok == 0)
  1282. return;
  1283. if (ppdu_info->nac_info.fc_valid &&
  1284. ppdu_info->nac_info.to_ds_flag &&
  1285. ppdu_info->nac_info.mac_addr2_valid) {
  1286. struct dp_neighbour_peer *peer = NULL;
  1287. uint8_t rssi = ppdu_info->rx_status.rssi_comb;
  1288. qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
  1289. if (pdev->neighbour_peers_added) {
  1290. TAILQ_FOREACH(peer, &pdev->neighbour_peers_list,
  1291. neighbour_peer_list_elem) {
  1292. if (!qdf_mem_cmp(&peer->neighbour_peers_macaddr,
  1293. &ppdu_info->nac_info.mac_addr2,
  1294. QDF_MAC_ADDR_SIZE)) {
  1295. peer->rssi = rssi;
  1296. break;
  1297. }
  1298. }
  1299. }
  1300. qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
  1301. }
  1302. /* need not generate wdi event when mcopy, cfr rcc mode and
  1303. * enhanced stats are not enabled
  1304. */
  1305. if (!pdev->mcopy_mode && !pdev->enhanced_stats_en &&
  1306. !dp_cfr_rcc_mode_status(pdev))
  1307. return;
  1308. if (dp_cfr_rcc_mode_status(pdev))
  1309. dp_update_cfr_dbg_stats(pdev, ppdu_info);
  1310. if (!ppdu_info->rx_status.frame_control_info_valid ||
  1311. (ppdu_info->rx_status.ast_index == HAL_AST_IDX_INVALID)) {
  1312. if (!(pdev->mcopy_mode ||
  1313. (dp_bb_captured_chan_status(pdev, ppdu_info) ==
  1314. QDF_STATUS_SUCCESS)))
  1315. return;
  1316. }
  1317. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  1318. sizeof(struct cdp_rx_indication_ppdu),
  1319. 0, 0, FALSE);
  1320. if (ppdu_nbuf) {
  1321. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
  1322. dp_rx_mon_populate_cfr_info(pdev, ppdu_info, cdp_rx_ppdu);
  1323. dp_rx_populate_cdp_indication_ppdu(pdev,
  1324. ppdu_info, cdp_rx_ppdu);
  1325. if (!qdf_nbuf_put_tail(ppdu_nbuf,
  1326. sizeof(struct cdp_rx_indication_ppdu)))
  1327. return;
  1328. dp_rx_stats_update(pdev, cdp_rx_ppdu);
  1329. if (cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) {
  1330. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC,
  1331. soc, ppdu_nbuf,
  1332. cdp_rx_ppdu->peer_id,
  1333. WDI_NO_VAL, pdev->pdev_id);
  1334. } else if (pdev->mcopy_mode || dp_cfr_rcc_mode_status(pdev)) {
  1335. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
  1336. ppdu_nbuf, HTT_INVALID_PEER,
  1337. WDI_NO_VAL, pdev->pdev_id);
  1338. } else {
  1339. qdf_nbuf_free(ppdu_nbuf);
  1340. }
  1341. }
  1342. }
  1343. #else
  1344. static inline void
  1345. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  1346. struct hal_rx_ppdu_info *ppdu_info)
  1347. {
  1348. }
  1349. #endif
  1350. /**
  1351. * dp_rx_process_peer_based_pktlog() - Process Rx pktlog if peer based
  1352. * filtering enabled
  1353. * @soc: core txrx main context
  1354. * @ppdu_info: Structure for rx ppdu info
  1355. * @status_nbuf: Qdf nbuf abstraction for linux skb
  1356. * @pdev_id: mac_id/pdev_id correspondinggly for MCL and WIN
  1357. *
  1358. * Return: none
  1359. */
  1360. static inline void
  1361. dp_rx_process_peer_based_pktlog(struct dp_soc *soc,
  1362. struct hal_rx_ppdu_info *ppdu_info,
  1363. qdf_nbuf_t status_nbuf, uint32_t pdev_id)
  1364. {
  1365. struct dp_peer *peer;
  1366. struct dp_ast_entry *ast_entry;
  1367. uint32_t ast_index;
  1368. ast_index = ppdu_info->rx_status.ast_index;
  1369. if (ast_index < wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  1370. ast_entry = soc->ast_table[ast_index];
  1371. if (ast_entry) {
  1372. peer = dp_peer_get_ref_by_id(soc, ast_entry->peer_id,
  1373. DP_MOD_ID_RX_PPDU_STATS);
  1374. if (peer) {
  1375. if ((peer->peer_id != HTT_INVALID_PEER) &&
  1376. (peer->peer_based_pktlog_filter)) {
  1377. dp_wdi_event_handler(
  1378. WDI_EVENT_RX_DESC, soc,
  1379. status_nbuf,
  1380. peer->peer_id,
  1381. WDI_NO_VAL, pdev_id);
  1382. }
  1383. dp_peer_unref_delete(peer,
  1384. DP_MOD_ID_RX_PPDU_STATS);
  1385. }
  1386. }
  1387. }
  1388. }
  1389. #if defined(HTT_UL_OFDMA_USER_INFO_V0_W0_VALID_M)
  1390. static inline void
  1391. dp_rx_ul_ofdma_ru_size_to_width(
  1392. uint32_t ru_size,
  1393. uint32_t *ru_width)
  1394. {
  1395. uint32_t width;
  1396. width = 0;
  1397. switch (ru_size) {
  1398. case HTT_UL_OFDMA_V0_RU_SIZE_RU_26:
  1399. width = 1;
  1400. break;
  1401. case HTT_UL_OFDMA_V0_RU_SIZE_RU_52:
  1402. width = 2;
  1403. break;
  1404. case HTT_UL_OFDMA_V0_RU_SIZE_RU_106:
  1405. width = 4;
  1406. break;
  1407. case HTT_UL_OFDMA_V0_RU_SIZE_RU_242:
  1408. width = 9;
  1409. break;
  1410. case HTT_UL_OFDMA_V0_RU_SIZE_RU_484:
  1411. width = 18;
  1412. break;
  1413. case HTT_UL_OFDMA_V0_RU_SIZE_RU_996:
  1414. width = 37;
  1415. break;
  1416. case HTT_UL_OFDMA_V0_RU_SIZE_RU_996x2:
  1417. width = 74;
  1418. break;
  1419. default:
  1420. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1421. "RU size to width convert err");
  1422. break;
  1423. }
  1424. *ru_width = width;
  1425. }
  1426. static inline void
  1427. dp_rx_mon_handle_mu_ul_info(struct hal_rx_ppdu_info *ppdu_info)
  1428. {
  1429. struct mon_rx_user_status *mon_rx_user_status;
  1430. uint32_t num_users;
  1431. uint32_t i;
  1432. uint32_t mu_ul_user_v0_word0;
  1433. uint32_t mu_ul_user_v0_word1;
  1434. uint32_t ru_width;
  1435. uint32_t ru_size;
  1436. if (!(ppdu_info->rx_status.reception_type == HAL_RX_TYPE_MU_OFDMA ||
  1437. ppdu_info->rx_status.reception_type == HAL_RX_TYPE_MU_MIMO))
  1438. return;
  1439. num_users = ppdu_info->com_info.num_users;
  1440. if (num_users > HAL_MAX_UL_MU_USERS)
  1441. num_users = HAL_MAX_UL_MU_USERS;
  1442. for (i = 0; i < num_users; i++) {
  1443. mon_rx_user_status = &ppdu_info->rx_user_status[i];
  1444. mu_ul_user_v0_word0 =
  1445. mon_rx_user_status->mu_ul_user_v0_word0;
  1446. mu_ul_user_v0_word1 =
  1447. mon_rx_user_status->mu_ul_user_v0_word1;
  1448. if (HTT_UL_OFDMA_USER_INFO_V0_W0_VALID_GET(
  1449. mu_ul_user_v0_word0) &&
  1450. !HTT_UL_OFDMA_USER_INFO_V0_W0_VER_GET(
  1451. mu_ul_user_v0_word0)) {
  1452. mon_rx_user_status->mcs =
  1453. HTT_UL_OFDMA_USER_INFO_V0_W1_MCS_GET(
  1454. mu_ul_user_v0_word1);
  1455. mon_rx_user_status->nss =
  1456. HTT_UL_OFDMA_USER_INFO_V0_W1_NSS_GET(
  1457. mu_ul_user_v0_word1) + 1;
  1458. mon_rx_user_status->mu_ul_info_valid = 1;
  1459. mon_rx_user_status->ofdma_ru_start_index =
  1460. HTT_UL_OFDMA_USER_INFO_V0_W1_RU_START_GET(
  1461. mu_ul_user_v0_word1);
  1462. ru_size =
  1463. HTT_UL_OFDMA_USER_INFO_V0_W1_RU_SIZE_GET(
  1464. mu_ul_user_v0_word1);
  1465. dp_rx_ul_ofdma_ru_size_to_width(ru_size, &ru_width);
  1466. mon_rx_user_status->ofdma_ru_width = ru_width;
  1467. mon_rx_user_status->ofdma_ru_size = ru_size;
  1468. }
  1469. }
  1470. }
  1471. #else
  1472. static inline void
  1473. dp_rx_mon_handle_mu_ul_info(struct hal_rx_ppdu_info *ppdu_info)
  1474. {
  1475. }
  1476. #endif
  1477. /**
  1478. * dp_rx_mon_status_process_tlv() - Process status TLV in status
  1479. * buffer on Rx status Queue posted by status SRNG processing.
  1480. * @soc: core txrx main context
  1481. * @int_ctx: interrupt context
  1482. * @mac_id: mac_id which is one of 3 mac_ids _ring
  1483. * @quota: amount of work which can be done
  1484. *
  1485. * Return: none
  1486. */
  1487. static inline void
  1488. dp_rx_mon_status_process_tlv(struct dp_soc *soc, struct dp_intr *int_ctx,
  1489. uint32_t mac_id, uint32_t quota)
  1490. {
  1491. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1492. struct hal_rx_ppdu_info *ppdu_info;
  1493. qdf_nbuf_t status_nbuf;
  1494. uint8_t *rx_tlv;
  1495. uint8_t *rx_tlv_start;
  1496. uint32_t tlv_status = HAL_TLV_STATUS_BUF_DONE;
  1497. QDF_STATUS enh_log_status = QDF_STATUS_SUCCESS;
  1498. struct cdp_pdev_mon_stats *rx_mon_stats;
  1499. int smart_mesh_status;
  1500. enum WDI_EVENT pktlog_mode = WDI_NO_VAL;
  1501. bool nbuf_used;
  1502. uint32_t rx_enh_capture_mode;
  1503. if (!pdev) {
  1504. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1505. "pdev is null for mac_id = %d", mac_id);
  1506. return;
  1507. }
  1508. ppdu_info = &pdev->ppdu_info;
  1509. rx_mon_stats = &pdev->rx_mon_stats;
  1510. if (pdev->mon_ppdu_status != DP_PPDU_STATUS_START)
  1511. return;
  1512. rx_enh_capture_mode = pdev->rx_enh_capture_mode;
  1513. while (!qdf_nbuf_is_queue_empty(&pdev->rx_status_q)) {
  1514. status_nbuf = qdf_nbuf_queue_remove(&pdev->rx_status_q);
  1515. rx_tlv = qdf_nbuf_data(status_nbuf);
  1516. rx_tlv_start = rx_tlv;
  1517. nbuf_used = false;
  1518. if ((pdev->monitor_vdev) || (pdev->enhanced_stats_en) ||
  1519. (pdev->mcopy_mode) || (dp_cfr_rcc_mode_status(pdev)) ||
  1520. (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED)) {
  1521. do {
  1522. tlv_status = hal_rx_status_get_tlv_info(rx_tlv,
  1523. ppdu_info, pdev->soc->hal_soc,
  1524. status_nbuf);
  1525. dp_rx_mon_update_dbg_ppdu_stats(ppdu_info,
  1526. rx_mon_stats);
  1527. dp_rx_mon_enh_capture_process(pdev, tlv_status,
  1528. status_nbuf, ppdu_info,
  1529. &nbuf_used);
  1530. dp_rx_mcopy_process_ppdu_info(pdev,
  1531. ppdu_info,
  1532. tlv_status);
  1533. rx_tlv = hal_rx_status_get_next_tlv(rx_tlv);
  1534. if ((rx_tlv - rx_tlv_start) >=
  1535. RX_MON_STATUS_BUF_SIZE)
  1536. break;
  1537. } while ((tlv_status == HAL_TLV_STATUS_PPDU_NOT_DONE) ||
  1538. (tlv_status == HAL_TLV_STATUS_HEADER) ||
  1539. (tlv_status == HAL_TLV_STATUS_MPDU_END) ||
  1540. (tlv_status == HAL_TLV_STATUS_MSDU_END));
  1541. }
  1542. if (pdev->dp_peer_based_pktlog) {
  1543. dp_rx_process_peer_based_pktlog(soc, ppdu_info,
  1544. status_nbuf,
  1545. pdev->pdev_id);
  1546. } else {
  1547. if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_FULL)
  1548. pktlog_mode = WDI_EVENT_RX_DESC;
  1549. else if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_LITE)
  1550. pktlog_mode = WDI_EVENT_LITE_RX;
  1551. if (pktlog_mode != WDI_NO_VAL)
  1552. dp_wdi_event_handler(pktlog_mode, soc,
  1553. status_nbuf,
  1554. HTT_INVALID_PEER,
  1555. WDI_NO_VAL, pdev->pdev_id);
  1556. }
  1557. /* smart monitor vap and m_copy cannot co-exist */
  1558. if (ppdu_info->rx_status.monitor_direct_used && pdev->neighbour_peers_added
  1559. && pdev->monitor_vdev) {
  1560. smart_mesh_status = dp_rx_handle_smart_mesh_mode(soc,
  1561. pdev, ppdu_info, status_nbuf);
  1562. if (smart_mesh_status)
  1563. qdf_nbuf_free(status_nbuf);
  1564. } else if (qdf_unlikely(pdev->mcopy_mode)) {
  1565. dp_rx_process_mcopy_mode(soc, pdev,
  1566. ppdu_info, tlv_status,
  1567. status_nbuf);
  1568. } else if (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED) {
  1569. if (!nbuf_used)
  1570. qdf_nbuf_free(status_nbuf);
  1571. if (tlv_status == HAL_TLV_STATUS_PPDU_DONE)
  1572. enh_log_status =
  1573. dp_rx_handle_enh_capture(soc,
  1574. pdev, ppdu_info);
  1575. } else {
  1576. qdf_nbuf_free(status_nbuf);
  1577. }
  1578. if (tlv_status == HAL_TLV_STATUS_PPDU_NON_STD_DONE) {
  1579. dp_rx_mon_deliver_non_std(soc, mac_id);
  1580. } else if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) {
  1581. rx_mon_stats->status_ppdu_done++;
  1582. dp_rx_mon_handle_mu_ul_info(ppdu_info);
  1583. if (pdev->tx_capture_enabled
  1584. != CDP_TX_ENH_CAPTURE_DISABLED)
  1585. dp_send_ack_frame_to_stack(soc, pdev,
  1586. ppdu_info);
  1587. if (pdev->enhanced_stats_en ||
  1588. pdev->mcopy_mode || pdev->neighbour_peers_added)
  1589. dp_rx_handle_ppdu_stats(soc, pdev, ppdu_info);
  1590. else if (dp_cfr_rcc_mode_status(pdev))
  1591. dp_rx_handle_cfr(soc, pdev, ppdu_info);
  1592. pdev->mon_ppdu_status = DP_PPDU_STATUS_DONE;
  1593. /*
  1594. * if chan_num is not fetched correctly from ppdu RX TLV,
  1595. * get it from pdev saved.
  1596. */
  1597. if (qdf_unlikely(pdev->ppdu_info.rx_status.chan_num == 0))
  1598. pdev->ppdu_info.rx_status.chan_num = pdev->mon_chan_num;
  1599. /*
  1600. * if chan_freq is not fetched correctly from ppdu RX TLV,
  1601. * get it from pdev saved.
  1602. */
  1603. if (qdf_unlikely(pdev->ppdu_info.rx_status.chan_freq == 0)) {
  1604. pdev->ppdu_info.rx_status.chan_freq =
  1605. pdev->mon_chan_freq;
  1606. }
  1607. if (!soc->full_mon_mode)
  1608. dp_rx_mon_dest_process(soc, int_ctx, mac_id,
  1609. quota);
  1610. pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  1611. }
  1612. }
  1613. return;
  1614. }
  1615. /*
  1616. * dp_rx_nbuf_prepare() - prepare RX nbuf
  1617. * @soc: core txrx main context
  1618. * @pdev: core txrx pdev context
  1619. *
  1620. * This function alloc & map nbuf for RX dma usage, retry it if failed
  1621. * until retry times reaches max threshold or succeeded.
  1622. *
  1623. * Return: qdf_nbuf_t pointer if succeeded, NULL if failed.
  1624. */
  1625. static inline qdf_nbuf_t
  1626. dp_rx_nbuf_prepare(struct dp_soc *soc, struct dp_pdev *pdev)
  1627. {
  1628. uint8_t *buf;
  1629. int32_t nbuf_retry_count;
  1630. QDF_STATUS ret;
  1631. qdf_nbuf_t nbuf = NULL;
  1632. for (nbuf_retry_count = 0; nbuf_retry_count <
  1633. QDF_NBUF_ALLOC_MAP_RETRY_THRESHOLD;
  1634. nbuf_retry_count++) {
  1635. /* Allocate a new skb using alloc_skb */
  1636. nbuf = qdf_nbuf_alloc_no_recycler(RX_MON_STATUS_BUF_SIZE,
  1637. RX_MON_STATUS_BUF_RESERVATION,
  1638. RX_DATA_BUFFER_ALIGNMENT);
  1639. if (!nbuf) {
  1640. DP_STATS_INC(pdev, replenish.nbuf_alloc_fail, 1);
  1641. continue;
  1642. }
  1643. buf = qdf_nbuf_data(nbuf);
  1644. memset(buf, 0, RX_MON_STATUS_BUF_SIZE);
  1645. ret = qdf_nbuf_map_nbytes_single(soc->osdev, nbuf,
  1646. QDF_DMA_FROM_DEVICE,
  1647. RX_MON_STATUS_BUF_SIZE);
  1648. /* nbuf map failed */
  1649. if (qdf_unlikely(QDF_IS_STATUS_ERROR(ret))) {
  1650. qdf_nbuf_free(nbuf);
  1651. DP_STATS_INC(pdev, replenish.map_err, 1);
  1652. continue;
  1653. }
  1654. /* qdf_nbuf alloc and map succeeded */
  1655. break;
  1656. }
  1657. /* qdf_nbuf still alloc or map failed */
  1658. if (qdf_unlikely(nbuf_retry_count >=
  1659. QDF_NBUF_ALLOC_MAP_RETRY_THRESHOLD))
  1660. return NULL;
  1661. return nbuf;
  1662. }
  1663. /*
  1664. * dp_rx_mon_status_srng_process() - Process monitor status ring
  1665. * post the status ring buffer to Rx status Queue for later
  1666. * processing when status ring is filled with status TLV.
  1667. * Allocate a new buffer to status ring if the filled buffer
  1668. * is posted.
  1669. * @soc: core txrx main context
  1670. * @int_ctx: interrupt context
  1671. * @mac_id: mac_id which is one of 3 mac_ids
  1672. * @quota: No. of ring entry that can be serviced in one shot.
  1673. * Return: uint32_t: No. of ring entry that is processed.
  1674. */
  1675. static inline uint32_t
  1676. dp_rx_mon_status_srng_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  1677. uint32_t mac_id, uint32_t quota)
  1678. {
  1679. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1680. hal_soc_handle_t hal_soc;
  1681. void *mon_status_srng;
  1682. void *rxdma_mon_status_ring_entry;
  1683. QDF_STATUS status;
  1684. enum dp_mon_reap_status reap_status;
  1685. uint32_t work_done = 0;
  1686. if (!pdev) {
  1687. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1688. "pdev is null for mac_id = %d", mac_id);
  1689. return work_done;
  1690. }
  1691. mon_status_srng = soc->rxdma_mon_status_ring[mac_id].hal_srng;
  1692. qdf_assert(mon_status_srng);
  1693. if (!mon_status_srng || !hal_srng_initialized(mon_status_srng)) {
  1694. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1695. "%s %d : HAL Monitor Status Ring Init Failed -- %pK",
  1696. __func__, __LINE__, mon_status_srng);
  1697. return work_done;
  1698. }
  1699. hal_soc = soc->hal_soc;
  1700. qdf_assert(hal_soc);
  1701. if (qdf_unlikely(dp_srng_access_start(int_ctx, soc, mon_status_srng)))
  1702. goto done;
  1703. /* mon_status_ring_desc => WBM_BUFFER_RING STRUCT =>
  1704. * BUFFER_ADDR_INFO STRUCT
  1705. */
  1706. while (qdf_likely((rxdma_mon_status_ring_entry =
  1707. hal_srng_src_peek_n_get_next(hal_soc, mon_status_srng))
  1708. && quota--)) {
  1709. uint32_t rx_buf_cookie;
  1710. qdf_nbuf_t status_nbuf;
  1711. struct dp_rx_desc *rx_desc;
  1712. uint8_t *status_buf;
  1713. qdf_dma_addr_t paddr;
  1714. uint64_t buf_addr;
  1715. struct rx_desc_pool *rx_desc_pool;
  1716. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1717. buf_addr =
  1718. (HAL_RX_BUFFER_ADDR_31_0_GET(
  1719. rxdma_mon_status_ring_entry) |
  1720. ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(
  1721. rxdma_mon_status_ring_entry)) << 32));
  1722. if (qdf_likely(buf_addr)) {
  1723. rx_buf_cookie =
  1724. HAL_RX_BUF_COOKIE_GET(
  1725. rxdma_mon_status_ring_entry);
  1726. rx_desc = dp_rx_cookie_2_va_mon_status(soc,
  1727. rx_buf_cookie);
  1728. qdf_assert(rx_desc);
  1729. status_nbuf = rx_desc->nbuf;
  1730. qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf,
  1731. QDF_DMA_FROM_DEVICE);
  1732. status_buf = qdf_nbuf_data(status_nbuf);
  1733. status = hal_get_rx_status_done(status_buf);
  1734. if (status != QDF_STATUS_SUCCESS) {
  1735. uint32_t hp, tp;
  1736. hal_get_sw_hptp(hal_soc, mon_status_srng,
  1737. &tp, &hp);
  1738. dp_info_rl("tlv tag status error hp:%u, tp:%u",
  1739. hp, tp);
  1740. /* RxDMA status done bit might not be set even
  1741. * though tp is moved by HW.
  1742. */
  1743. /* If done status is missing:
  1744. * 1. As per MAC team's suggestion,
  1745. * when HP + 1 entry is peeked and if DMA
  1746. * is not done and if HP + 2 entry's DMA done
  1747. * is set. skip HP + 1 entry and
  1748. * start processing in next interrupt.
  1749. * 2. If HP + 2 entry's DMA done is not set,
  1750. * poll onto HP + 1 entry DMA done to be set.
  1751. * Check status for same buffer for next time
  1752. * dp_rx_mon_status_srng_process
  1753. */
  1754. reap_status = dp_rx_mon_handle_status_buf_done(pdev,
  1755. mon_status_srng);
  1756. if (reap_status == DP_MON_STATUS_NO_DMA)
  1757. continue;
  1758. else if (reap_status == DP_MON_STATUS_REPLENISH) {
  1759. qdf_nbuf_unmap_nbytes_single(
  1760. soc->osdev, status_nbuf,
  1761. QDF_DMA_FROM_DEVICE,
  1762. rx_desc_pool->buf_size);
  1763. qdf_nbuf_free(status_nbuf);
  1764. goto buf_replenish;
  1765. }
  1766. }
  1767. qdf_nbuf_set_pktlen(status_nbuf,
  1768. RX_MON_STATUS_BUF_SIZE);
  1769. qdf_nbuf_unmap_nbytes_single(soc->osdev, status_nbuf,
  1770. QDF_DMA_FROM_DEVICE,
  1771. rx_desc_pool->buf_size);
  1772. /* Put the status_nbuf to queue */
  1773. qdf_nbuf_queue_add(&pdev->rx_status_q, status_nbuf);
  1774. } else {
  1775. union dp_rx_desc_list_elem_t *desc_list = NULL;
  1776. union dp_rx_desc_list_elem_t *tail = NULL;
  1777. uint32_t num_alloc_desc;
  1778. num_alloc_desc = dp_rx_get_free_desc_list(soc, mac_id,
  1779. rx_desc_pool,
  1780. 1,
  1781. &desc_list,
  1782. &tail);
  1783. /*
  1784. * No free descriptors available
  1785. */
  1786. if (qdf_unlikely(num_alloc_desc == 0)) {
  1787. work_done++;
  1788. break;
  1789. }
  1790. rx_desc = &desc_list->rx_desc;
  1791. }
  1792. buf_replenish:
  1793. status_nbuf = dp_rx_nbuf_prepare(soc, pdev);
  1794. /*
  1795. * qdf_nbuf alloc or map failed,
  1796. * free the dp rx desc to free list,
  1797. * fill in NULL dma address at current HP entry,
  1798. * keep HP in mon_status_ring unchanged,
  1799. * wait next time dp_rx_mon_status_srng_process
  1800. * to fill in buffer at current HP.
  1801. */
  1802. if (qdf_unlikely(!status_nbuf)) {
  1803. union dp_rx_desc_list_elem_t *desc_list = NULL;
  1804. union dp_rx_desc_list_elem_t *tail = NULL;
  1805. struct rx_desc_pool *rx_desc_pool;
  1806. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1807. dp_info_rl("fail to allocate or map qdf_nbuf");
  1808. dp_rx_add_to_free_desc_list(&desc_list,
  1809. &tail, rx_desc);
  1810. dp_rx_add_desc_list_to_free_list(soc, &desc_list,
  1811. &tail, mac_id, rx_desc_pool);
  1812. hal_rxdma_buff_addr_info_set(
  1813. rxdma_mon_status_ring_entry,
  1814. 0, 0, HAL_RX_BUF_RBM_SW3_BM);
  1815. work_done++;
  1816. break;
  1817. }
  1818. paddr = qdf_nbuf_get_frag_paddr(status_nbuf, 0);
  1819. rx_desc->nbuf = status_nbuf;
  1820. rx_desc->in_use = 1;
  1821. hal_rxdma_buff_addr_info_set(rxdma_mon_status_ring_entry,
  1822. paddr, rx_desc->cookie, HAL_RX_BUF_RBM_SW3_BM);
  1823. hal_srng_src_get_next(hal_soc, mon_status_srng);
  1824. work_done++;
  1825. }
  1826. done:
  1827. dp_srng_access_end(int_ctx, soc, mon_status_srng);
  1828. return work_done;
  1829. }
  1830. uint32_t
  1831. dp_rx_mon_status_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  1832. uint32_t mac_id, uint32_t quota)
  1833. {
  1834. uint32_t work_done;
  1835. work_done = dp_rx_mon_status_srng_process(soc, int_ctx, mac_id, quota);
  1836. quota -= work_done;
  1837. dp_rx_mon_status_process_tlv(soc, int_ctx, mac_id, quota);
  1838. return work_done;
  1839. }
  1840. #ifndef DISABLE_MON_CONFIG
  1841. uint32_t
  1842. dp_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  1843. uint32_t mac_id, uint32_t quota)
  1844. {
  1845. if (qdf_unlikely(soc->full_mon_mode))
  1846. return dp_rx_mon_process(soc, int_ctx, mac_id, quota);
  1847. return dp_rx_mon_status_process(soc, int_ctx, mac_id, quota);
  1848. }
  1849. #else
  1850. uint32_t
  1851. dp_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  1852. uint32_t mac_id, uint32_t quota)
  1853. {
  1854. return 0;
  1855. }
  1856. #endif
  1857. QDF_STATUS
  1858. dp_rx_pdev_mon_status_buffers_alloc(struct dp_pdev *pdev, uint32_t mac_id)
  1859. {
  1860. uint8_t pdev_id = pdev->pdev_id;
  1861. struct dp_soc *soc = pdev->soc;
  1862. struct dp_srng *mon_status_ring;
  1863. uint32_t num_entries;
  1864. struct rx_desc_pool *rx_desc_pool;
  1865. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  1866. union dp_rx_desc_list_elem_t *desc_list = NULL;
  1867. union dp_rx_desc_list_elem_t *tail = NULL;
  1868. soc_cfg_ctx = soc->wlan_cfg_ctx;
  1869. mon_status_ring = &soc->rxdma_mon_status_ring[mac_id];
  1870. num_entries = mon_status_ring->num_entries;
  1871. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1872. dp_debug("Mon RX Desc Pool[%d] entries=%u",
  1873. pdev_id, num_entries);
  1874. return dp_rx_mon_status_buffers_replenish(soc, mac_id, mon_status_ring,
  1875. rx_desc_pool, num_entries,
  1876. &desc_list, &tail,
  1877. HAL_RX_BUF_RBM_SW3_BM);
  1878. }
  1879. QDF_STATUS
  1880. dp_rx_pdev_mon_status_desc_pool_alloc(struct dp_pdev *pdev, uint32_t mac_id)
  1881. {
  1882. uint8_t pdev_id = pdev->pdev_id;
  1883. struct dp_soc *soc = pdev->soc;
  1884. struct dp_srng *mon_status_ring;
  1885. uint32_t num_entries;
  1886. struct rx_desc_pool *rx_desc_pool;
  1887. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  1888. soc_cfg_ctx = soc->wlan_cfg_ctx;
  1889. mon_status_ring = &soc->rxdma_mon_status_ring[mac_id];
  1890. num_entries = mon_status_ring->num_entries;
  1891. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1892. dp_debug("Mon RX Desc Pool[%d] entries=%u", pdev_id, num_entries);
  1893. rx_desc_pool->desc_type = DP_RX_DESC_STATUS_TYPE;
  1894. return dp_rx_desc_pool_alloc(soc, num_entries + 1, rx_desc_pool);
  1895. }
  1896. void
  1897. dp_rx_pdev_mon_status_desc_pool_init(struct dp_pdev *pdev, uint32_t mac_id)
  1898. {
  1899. uint32_t i;
  1900. uint8_t pdev_id = pdev->pdev_id;
  1901. struct dp_soc *soc = pdev->soc;
  1902. struct dp_srng *mon_status_ring;
  1903. uint32_t num_entries;
  1904. struct rx_desc_pool *rx_desc_pool;
  1905. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  1906. soc_cfg_ctx = soc->wlan_cfg_ctx;
  1907. mon_status_ring = &soc->rxdma_mon_status_ring[mac_id];
  1908. num_entries = mon_status_ring->num_entries;
  1909. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1910. dp_debug("Mon RX Desc status Pool[%d] init entries=%u",
  1911. pdev_id, num_entries);
  1912. rx_desc_pool->owner = HAL_RX_BUF_RBM_SW3_BM;
  1913. rx_desc_pool->buf_size = RX_MON_STATUS_BUF_SIZE;
  1914. rx_desc_pool->buf_alignment = RX_DATA_BUFFER_ALIGNMENT;
  1915. /* Disable frag processing flag */
  1916. dp_rx_enable_mon_dest_frag(rx_desc_pool, false);
  1917. dp_rx_desc_pool_init(soc, mac_id, num_entries + 1, rx_desc_pool);
  1918. qdf_nbuf_queue_init(&pdev->rx_status_q);
  1919. pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  1920. qdf_mem_zero(&pdev->ppdu_info, sizeof(pdev->ppdu_info));
  1921. /*
  1922. * Set last_ppdu_id to HAL_INVALID_PPDU_ID in order to avoid ppdu_id
  1923. * match with '0' ppdu_id from monitor status ring
  1924. */
  1925. pdev->ppdu_info.com_info.last_ppdu_id = HAL_INVALID_PPDU_ID;
  1926. qdf_mem_zero(&pdev->rx_mon_stats, sizeof(pdev->rx_mon_stats));
  1927. dp_rx_mon_init_dbg_ppdu_stats(&pdev->ppdu_info,
  1928. &pdev->rx_mon_stats);
  1929. for (i = 0; i < MAX_MU_USERS; i++) {
  1930. qdf_nbuf_queue_init(&pdev->mpdu_q[i]);
  1931. pdev->is_mpdu_hdr[i] = true;
  1932. }
  1933. qdf_mem_zero(pdev->msdu_list, sizeof(pdev->msdu_list[MAX_MU_USERS]));
  1934. pdev->rx_enh_capture_mode = CDP_RX_ENH_CAPTURE_DISABLED;
  1935. }
  1936. void
  1937. dp_rx_pdev_mon_status_desc_pool_deinit(struct dp_pdev *pdev, uint32_t mac_id) {
  1938. uint8_t pdev_id = pdev->pdev_id;
  1939. struct dp_soc *soc = pdev->soc;
  1940. struct rx_desc_pool *rx_desc_pool;
  1941. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1942. dp_debug("Mon RX Desc status Pool[%d] deinit", pdev_id);
  1943. dp_rx_desc_pool_deinit(soc, rx_desc_pool);
  1944. }
  1945. void
  1946. dp_rx_pdev_mon_status_desc_pool_free(struct dp_pdev *pdev, uint32_t mac_id) {
  1947. uint8_t pdev_id = pdev->pdev_id;
  1948. struct dp_soc *soc = pdev->soc;
  1949. struct rx_desc_pool *rx_desc_pool;
  1950. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1951. dp_debug("Mon RX Status Desc Pool Free pdev[%d]", pdev_id);
  1952. dp_rx_desc_pool_free(soc, rx_desc_pool);
  1953. }
  1954. void
  1955. dp_rx_pdev_mon_status_buffers_free(struct dp_pdev *pdev, uint32_t mac_id)
  1956. {
  1957. uint8_t pdev_id = pdev->pdev_id;
  1958. struct dp_soc *soc = pdev->soc;
  1959. struct rx_desc_pool *rx_desc_pool;
  1960. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1961. dp_debug("Mon RX Status Desc Pool Free pdev[%d]", pdev_id);
  1962. dp_rx_desc_nbuf_free(soc, rx_desc_pool);
  1963. }
  1964. /*
  1965. * dp_rx_buffers_replenish() - replenish monitor status ring with
  1966. * rx nbufs called during dp rx
  1967. * monitor status ring initialization
  1968. *
  1969. * @soc: core txrx main context
  1970. * @mac_id: mac_id which is one of 3 mac_ids
  1971. * @dp_rxdma_srng: dp monitor status circular ring
  1972. * @rx_desc_pool; Pointer to Rx descriptor pool
  1973. * @num_req_buffers: number of buffer to be replenished
  1974. * @desc_list: list of descs if called from dp rx monitor status
  1975. * process or NULL during dp rx initialization or
  1976. * out of buffer interrupt
  1977. * @tail: tail of descs list
  1978. * @owner: who owns the nbuf (host, NSS etc...)
  1979. * Return: return success or failure
  1980. */
  1981. static inline
  1982. QDF_STATUS dp_rx_mon_status_buffers_replenish(struct dp_soc *dp_soc,
  1983. uint32_t mac_id,
  1984. struct dp_srng *dp_rxdma_srng,
  1985. struct rx_desc_pool *rx_desc_pool,
  1986. uint32_t num_req_buffers,
  1987. union dp_rx_desc_list_elem_t **desc_list,
  1988. union dp_rx_desc_list_elem_t **tail,
  1989. uint8_t owner)
  1990. {
  1991. uint32_t num_alloc_desc;
  1992. uint16_t num_desc_to_free = 0;
  1993. uint32_t num_entries_avail;
  1994. uint32_t count = 0;
  1995. int sync_hw_ptr = 1;
  1996. qdf_dma_addr_t paddr;
  1997. qdf_nbuf_t rx_netbuf;
  1998. void *rxdma_ring_entry;
  1999. union dp_rx_desc_list_elem_t *next;
  2000. void *rxdma_srng;
  2001. struct dp_pdev *dp_pdev = dp_get_pdev_for_lmac_id(dp_soc, mac_id);
  2002. if (!dp_pdev) {
  2003. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  2004. "pdev is null for mac_id = %d", mac_id);
  2005. return QDF_STATUS_E_FAILURE;
  2006. }
  2007. rxdma_srng = dp_rxdma_srng->hal_srng;
  2008. qdf_assert(rxdma_srng);
  2009. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  2010. "[%s][%d] requested %d buffers for replenish",
  2011. __func__, __LINE__, num_req_buffers);
  2012. /*
  2013. * if desc_list is NULL, allocate the descs from freelist
  2014. */
  2015. if (!(*desc_list)) {
  2016. num_alloc_desc = dp_rx_get_free_desc_list(dp_soc, mac_id,
  2017. rx_desc_pool,
  2018. num_req_buffers,
  2019. desc_list,
  2020. tail);
  2021. if (!num_alloc_desc) {
  2022. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2023. "[%s][%d] no free rx_descs in freelist",
  2024. __func__, __LINE__);
  2025. return QDF_STATUS_E_NOMEM;
  2026. }
  2027. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  2028. "[%s][%d] %d rx desc allocated", __func__, __LINE__,
  2029. num_alloc_desc);
  2030. num_req_buffers = num_alloc_desc;
  2031. }
  2032. hal_srng_access_start(dp_soc->hal_soc, rxdma_srng);
  2033. num_entries_avail = hal_srng_src_num_avail(dp_soc->hal_soc,
  2034. rxdma_srng, sync_hw_ptr);
  2035. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  2036. "[%s][%d] no of available entries in rxdma ring: %d",
  2037. __func__, __LINE__, num_entries_avail);
  2038. if (num_entries_avail < num_req_buffers) {
  2039. num_desc_to_free = num_req_buffers - num_entries_avail;
  2040. num_req_buffers = num_entries_avail;
  2041. }
  2042. while (count <= num_req_buffers) {
  2043. rx_netbuf = dp_rx_nbuf_prepare(dp_soc, dp_pdev);
  2044. /*
  2045. * qdf_nbuf alloc or map failed,
  2046. * keep HP in mon_status_ring unchanged,
  2047. * wait dp_rx_mon_status_srng_process
  2048. * to fill in buffer at current HP.
  2049. */
  2050. if (qdf_unlikely(!rx_netbuf)) {
  2051. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2052. "%s: qdf_nbuf allocate or map fail, count %d",
  2053. __func__, count);
  2054. break;
  2055. }
  2056. paddr = qdf_nbuf_get_frag_paddr(rx_netbuf, 0);
  2057. next = (*desc_list)->next;
  2058. rxdma_ring_entry = hal_srng_src_get_cur_hp_n_move_next(
  2059. dp_soc->hal_soc,
  2060. rxdma_srng);
  2061. if (qdf_unlikely(!rxdma_ring_entry)) {
  2062. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2063. "[%s][%d] rxdma_ring_entry is NULL, count - %d",
  2064. __func__, __LINE__, count);
  2065. qdf_nbuf_unmap_nbytes_single(dp_soc->osdev, rx_netbuf,
  2066. QDF_DMA_FROM_DEVICE,
  2067. rx_desc_pool->buf_size);
  2068. qdf_nbuf_free(rx_netbuf);
  2069. break;
  2070. }
  2071. (*desc_list)->rx_desc.nbuf = rx_netbuf;
  2072. (*desc_list)->rx_desc.in_use = 1;
  2073. count++;
  2074. hal_rxdma_buff_addr_info_set(rxdma_ring_entry, paddr,
  2075. (*desc_list)->rx_desc.cookie, owner);
  2076. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  2077. "[%s][%d] rx_desc=%pK, cookie=%d, nbuf=%pK, \
  2078. paddr=%pK",
  2079. __func__, __LINE__, &(*desc_list)->rx_desc,
  2080. (*desc_list)->rx_desc.cookie, rx_netbuf,
  2081. (void *)paddr);
  2082. *desc_list = next;
  2083. }
  2084. hal_srng_access_end(dp_soc->hal_soc, rxdma_srng);
  2085. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  2086. "successfully replenished %d buffers", num_req_buffers);
  2087. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  2088. "%d rx desc added back to free list", num_desc_to_free);
  2089. /*
  2090. * add any available free desc back to the free list
  2091. */
  2092. if (*desc_list) {
  2093. dp_rx_add_desc_list_to_free_list(dp_soc, desc_list, tail,
  2094. mac_id, rx_desc_pool);
  2095. }
  2096. return QDF_STATUS_SUCCESS;
  2097. }
  2098. #if !defined(DISABLE_MON_CONFIG) && defined(MON_ENABLE_DROP_FOR_MAC)
  2099. /**
  2100. * dp_mon_status_srng_drop_for_mac() - Drop the mon status ring packets for
  2101. * a given mac
  2102. * @pdev: DP pdev
  2103. * @mac_id: mac id
  2104. * @quota: maximum number of ring entries that can be processed
  2105. *
  2106. * Return: Number of ring entries reaped
  2107. */
  2108. static uint32_t
  2109. dp_mon_status_srng_drop_for_mac(struct dp_pdev *pdev, uint32_t mac_id,
  2110. uint32_t quota)
  2111. {
  2112. struct dp_soc *soc = pdev->soc;
  2113. void *mon_status_srng;
  2114. hal_soc_handle_t hal_soc;
  2115. void *ring_desc;
  2116. uint32_t reap_cnt = 0;
  2117. if (qdf_unlikely(!soc || !soc->hal_soc))
  2118. return reap_cnt;
  2119. mon_status_srng = soc->rxdma_mon_status_ring[mac_id].hal_srng;
  2120. if (qdf_unlikely(!mon_status_srng ||
  2121. !hal_srng_initialized(mon_status_srng)))
  2122. return reap_cnt;
  2123. hal_soc = soc->hal_soc;
  2124. if (qdf_unlikely(hal_srng_access_start(hal_soc, mon_status_srng)))
  2125. return reap_cnt;
  2126. while ((ring_desc =
  2127. hal_srng_src_peek_n_get_next(hal_soc, mon_status_srng)) &&
  2128. reap_cnt < MON_DROP_REAP_LIMIT && quota--) {
  2129. uint64_t buf_addr;
  2130. uint32_t rx_buf_cookie;
  2131. struct dp_rx_desc *rx_desc;
  2132. qdf_nbuf_t status_nbuf;
  2133. uint8_t *status_buf;
  2134. enum dp_mon_reap_status reap_status;
  2135. qdf_dma_addr_t iova;
  2136. struct rx_desc_pool *rx_desc_pool;
  2137. rx_desc_pool = &soc->rx_desc_status[mac_id];
  2138. buf_addr = (HAL_RX_BUFFER_ADDR_31_0_GET(ring_desc) |
  2139. ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(ring_desc)) << 32));
  2140. if (qdf_likely(buf_addr)) {
  2141. rx_buf_cookie = HAL_RX_BUF_COOKIE_GET(ring_desc);
  2142. rx_desc = dp_rx_cookie_2_va_mon_status(soc,
  2143. rx_buf_cookie);
  2144. qdf_assert(rx_desc);
  2145. status_nbuf = rx_desc->nbuf;
  2146. qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf,
  2147. QDF_DMA_FROM_DEVICE);
  2148. status_buf = qdf_nbuf_data(status_nbuf);
  2149. if (hal_get_rx_status_done(status_buf) !=
  2150. QDF_STATUS_SUCCESS) {
  2151. /* If done status is missing:
  2152. * 1. As per MAC team's suggestion,
  2153. * when HP + 1 entry is peeked and if DMA
  2154. * is not done and if HP + 2 entry's DMA done
  2155. * is set. skip HP + 1 entry and
  2156. * start processing in next interrupt.
  2157. * 2. If HP + 2 entry's DMA done is not set,
  2158. * poll onto HP + 1 entry DMA done to be set.
  2159. * Check status for same buffer for next time
  2160. * dp_rx_mon_status_srng_process
  2161. */
  2162. reap_status =
  2163. dp_rx_mon_handle_status_buf_done(pdev,
  2164. mon_status_srng);
  2165. if (reap_status == DP_MON_STATUS_NO_DMA)
  2166. break;
  2167. }
  2168. qdf_nbuf_unmap_nbytes_single(soc->osdev, status_nbuf,
  2169. QDF_DMA_FROM_DEVICE,
  2170. rx_desc_pool->buf_size);
  2171. qdf_nbuf_free(status_nbuf);
  2172. } else {
  2173. union dp_rx_desc_list_elem_t *rx_desc_elem;
  2174. qdf_spin_lock_bh(&rx_desc_pool->lock);
  2175. if (!rx_desc_pool->freelist) {
  2176. qdf_spin_unlock_bh(&rx_desc_pool->lock);
  2177. break;
  2178. }
  2179. rx_desc_elem = rx_desc_pool->freelist;
  2180. rx_desc_pool->freelist = rx_desc_pool->freelist->next;
  2181. qdf_spin_unlock_bh(&rx_desc_pool->lock);
  2182. rx_desc = &rx_desc_elem->rx_desc;
  2183. }
  2184. status_nbuf = dp_rx_nbuf_prepare(soc, pdev);
  2185. if (qdf_unlikely(!status_nbuf)) {
  2186. union dp_rx_desc_list_elem_t *desc_list = NULL;
  2187. union dp_rx_desc_list_elem_t *tail = NULL;
  2188. dp_info_rl("fail to allocate or map nbuf");
  2189. dp_rx_add_to_free_desc_list(&desc_list, &tail,
  2190. rx_desc);
  2191. dp_rx_add_desc_list_to_free_list(soc,
  2192. &desc_list,
  2193. &tail, mac_id,
  2194. rx_desc_pool);
  2195. hal_rxdma_buff_addr_info_set(ring_desc, 0, 0,
  2196. HAL_RX_BUF_RBM_SW3_BM);
  2197. break;
  2198. }
  2199. iova = qdf_nbuf_get_frag_paddr(status_nbuf, 0);
  2200. rx_desc->nbuf = status_nbuf;
  2201. rx_desc->in_use = 1;
  2202. hal_rxdma_buff_addr_info_set(ring_desc, iova, rx_desc->cookie,
  2203. HAL_RX_BUF_RBM_SW3_BM);
  2204. reap_cnt++;
  2205. hal_srng_src_get_next(hal_soc, mon_status_srng);
  2206. }
  2207. hal_srng_access_end(hal_soc, mon_status_srng);
  2208. return reap_cnt;
  2209. }
  2210. uint32_t dp_mon_drop_packets_for_mac(struct dp_pdev *pdev, uint32_t mac_id,
  2211. uint32_t quota)
  2212. {
  2213. uint32_t work_done;
  2214. work_done = dp_mon_status_srng_drop_for_mac(pdev, mac_id, quota);
  2215. dp_mon_dest_srng_drop_for_mac(pdev, mac_id);
  2216. return work_done;
  2217. }
  2218. #else
  2219. uint32_t dp_mon_drop_packets_for_mac(struct dp_pdev *pdev, uint32_t mac_id,
  2220. uint32_t quota)
  2221. {
  2222. return 0;
  2223. }
  2224. #endif