dp_rx_mon_status.c 62 KB

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