dp_rx_mon_status.c 72 KB

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