dp_rx_mon_status.c 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255
  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_ids[0] == 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_ids[0];
  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_ids[0] == 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_ids[0];
  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. mcs = ppdu->u.mcs;
  423. nss = ppdu->u.nss;
  424. }
  425. ratekbps = dp_getrateindex(ppdu->u.gi,
  426. mcs,
  427. nss,
  428. ppdu->u.preamble,
  429. ppdu->u.bw,
  430. &rix,
  431. &ratecode);
  432. if (!ratekbps)
  433. return;
  434. ppdu->rix = rix;
  435. DP_STATS_UPD(peer, rx.last_rx_rate, ratekbps);
  436. dp_ath_rate_lpf(peer->stats.rx.avg_rx_rate, ratekbps);
  437. ppdu_rx_rate = dp_ath_rate_out(peer->stats.rx.avg_rx_rate);
  438. DP_STATS_UPD(peer, rx.rnd_avg_rx_rate, ppdu_rx_rate);
  439. ppdu->rx_ratekbps = ratekbps;
  440. ppdu->rx_ratecode = ratecode;
  441. if (peer->vdev)
  442. peer->vdev->stats.rx.last_rx_rate = ratekbps;
  443. }
  444. static void dp_rx_stats_update(struct dp_pdev *pdev,
  445. struct cdp_rx_indication_ppdu *ppdu)
  446. {
  447. struct dp_soc *soc = NULL;
  448. uint8_t mcs, preamble, ac = 0, nss, ppdu_type;
  449. uint16_t num_msdu;
  450. uint8_t pkt_bw_offset;
  451. struct dp_peer *peer;
  452. struct cdp_rx_stats_ppdu_user *ppdu_user;
  453. uint32_t i;
  454. enum cdp_mu_packet_type mu_pkt_type;
  455. if (pdev)
  456. soc = pdev->soc;
  457. else
  458. return;
  459. if (!soc || soc->process_rx_status)
  460. return;
  461. preamble = ppdu->u.preamble;
  462. ppdu_type = ppdu->u.ppdu_type;
  463. for (i = 0; i < ppdu->num_users; i++) {
  464. peer = NULL;
  465. ppdu_user = &ppdu->user[i];
  466. if (ppdu_user->peer_id != HTT_INVALID_PEER)
  467. peer = dp_peer_find_hash_find(soc, ppdu_user->mac_addr,
  468. 0, ppdu_user->vdev_id);
  469. if (!peer)
  470. peer = pdev->invalid_peer;
  471. ppdu->cookie = (void *)peer->wlanstats_ctx;
  472. if (ppdu_type == HAL_RX_TYPE_SU) {
  473. mcs = ppdu->u.mcs;
  474. nss = ppdu->u.nss;
  475. } else {
  476. mcs = ppdu_user->mcs;
  477. nss = ppdu_user->nss;
  478. }
  479. num_msdu = ppdu_user->num_msdu;
  480. switch (ppdu->u.bw) {
  481. case CMN_BW_20MHZ:
  482. pkt_bw_offset = PKT_BW_GAIN_20MHZ;
  483. break;
  484. case CMN_BW_40MHZ:
  485. pkt_bw_offset = PKT_BW_GAIN_40MHZ;
  486. break;
  487. case CMN_BW_80MHZ:
  488. pkt_bw_offset = PKT_BW_GAIN_80MHZ;
  489. break;
  490. case CMN_BW_160MHZ:
  491. pkt_bw_offset = PKT_BW_GAIN_160MHZ;
  492. break;
  493. default:
  494. pkt_bw_offset = 0;
  495. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  496. "Invalid BW index = %d", ppdu->u.bw);
  497. }
  498. DP_STATS_UPD(peer, rx.rssi, (ppdu->rssi + pkt_bw_offset));
  499. if (peer->stats.rx.avg_rssi == INVALID_RSSI)
  500. peer->stats.rx.avg_rssi =
  501. CDP_RSSI_IN(peer->stats.rx.rssi);
  502. else
  503. CDP_RSSI_UPDATE_AVG(peer->stats.rx.avg_rssi,
  504. peer->stats.rx.rssi);
  505. if ((preamble == DOT11_A) || (preamble == DOT11_B))
  506. nss = 1;
  507. if (ppdu_type == HAL_RX_TYPE_SU) {
  508. if (nss) {
  509. DP_STATS_INC(peer, rx.nss[nss - 1], num_msdu);
  510. DP_STATS_INC(peer, rx.ppdu_nss[nss - 1], 1);
  511. }
  512. DP_STATS_INC(peer, rx.mpdu_cnt_fcs_ok,
  513. ppdu_user->mpdu_cnt_fcs_ok);
  514. DP_STATS_INC(peer, rx.mpdu_cnt_fcs_err,
  515. ppdu_user->mpdu_cnt_fcs_err);
  516. }
  517. if (ppdu_type >= HAL_RX_TYPE_MU_MIMO &&
  518. ppdu_type <= HAL_RX_TYPE_MU_OFDMA) {
  519. if (ppdu_type == HAL_RX_TYPE_MU_MIMO)
  520. mu_pkt_type = RX_TYPE_MU_MIMO;
  521. else
  522. mu_pkt_type = RX_TYPE_MU_OFDMA;
  523. if (nss) {
  524. DP_STATS_INC(peer, rx.nss[nss - 1], num_msdu);
  525. DP_STATS_INC(peer,
  526. rx.rx_mu[mu_pkt_type].ppdu_nss[nss - 1],
  527. 1);
  528. }
  529. DP_STATS_INC(peer,
  530. rx.rx_mu[mu_pkt_type].mpdu_cnt_fcs_ok,
  531. ppdu_user->mpdu_cnt_fcs_ok);
  532. DP_STATS_INC(peer,
  533. rx.rx_mu[mu_pkt_type].mpdu_cnt_fcs_err,
  534. ppdu_user->mpdu_cnt_fcs_err);
  535. }
  536. DP_STATS_INC(peer, rx.sgi_count[ppdu->u.gi], num_msdu);
  537. DP_STATS_INC(peer, rx.bw[ppdu->u.bw], num_msdu);
  538. DP_STATS_INC(peer, rx.reception_type[ppdu->u.ppdu_type],
  539. num_msdu);
  540. DP_STATS_INC(peer, rx.ppdu_cnt[ppdu->u.ppdu_type], 1);
  541. DP_STATS_INCC(peer, rx.ampdu_cnt, num_msdu,
  542. ppdu_user->is_ampdu);
  543. DP_STATS_INCC(peer, rx.non_ampdu_cnt, num_msdu,
  544. !(ppdu_user->is_ampdu));
  545. DP_STATS_UPD(peer, rx.rx_rate, mcs);
  546. DP_STATS_INCC(peer,
  547. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  548. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
  549. DP_STATS_INCC(peer,
  550. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  551. ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
  552. DP_STATS_INCC(peer,
  553. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  554. ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B)));
  555. DP_STATS_INCC(peer,
  556. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  557. ((mcs < MAX_MCS_11B) && (preamble == DOT11_B)));
  558. DP_STATS_INCC(peer,
  559. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  560. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N)));
  561. DP_STATS_INCC(peer,
  562. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  563. ((mcs < MAX_MCS_11A) && (preamble == DOT11_N)));
  564. DP_STATS_INCC(peer,
  565. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  566. ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC)));
  567. DP_STATS_INCC(peer,
  568. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  569. ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
  570. DP_STATS_INCC(peer,
  571. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  572. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  573. DP_STATS_INCC(peer,
  574. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  575. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  576. DP_STATS_INCC(peer,
  577. rx.su_ax_ppdu_cnt.mcs_count[MAX_MCS - 1], 1,
  578. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX) &&
  579. (ppdu_type == HAL_RX_TYPE_SU)));
  580. DP_STATS_INCC(peer,
  581. rx.su_ax_ppdu_cnt.mcs_count[mcs], 1,
  582. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX) &&
  583. (ppdu_type == HAL_RX_TYPE_SU)));
  584. DP_STATS_INCC(peer,
  585. rx.rx_mu[RX_TYPE_MU_OFDMA].ppdu.mcs_count[MAX_MCS - 1],
  586. 1, ((mcs >= (MAX_MCS - 1)) &&
  587. (preamble == DOT11_AX) &&
  588. (ppdu_type == HAL_RX_TYPE_MU_OFDMA)));
  589. DP_STATS_INCC(peer,
  590. rx.rx_mu[RX_TYPE_MU_OFDMA].ppdu.mcs_count[mcs],
  591. 1, ((mcs < (MAX_MCS - 1)) &&
  592. (preamble == DOT11_AX) &&
  593. (ppdu_type == HAL_RX_TYPE_MU_OFDMA)));
  594. DP_STATS_INCC(peer,
  595. rx.rx_mu[RX_TYPE_MU_MIMO].ppdu.mcs_count[MAX_MCS - 1],
  596. 1, ((mcs >= (MAX_MCS - 1)) &&
  597. (preamble == DOT11_AX) &&
  598. (ppdu_type == HAL_RX_TYPE_MU_MIMO)));
  599. DP_STATS_INCC(peer,
  600. rx.rx_mu[RX_TYPE_MU_MIMO].ppdu.mcs_count[mcs],
  601. 1, ((mcs < (MAX_MCS - 1)) &&
  602. (preamble == DOT11_AX) &&
  603. (ppdu_type == HAL_RX_TYPE_MU_MIMO)));
  604. /*
  605. * If invalid TID, it could be a non-qos frame, hence do not
  606. * update any AC counters
  607. */
  608. ac = TID_TO_WME_AC(ppdu_user->tid);
  609. if (ppdu->tid != HAL_TID_INVALID)
  610. DP_STATS_INC(peer, rx.wme_ac_type[ac], num_msdu);
  611. dp_peer_stats_notify(pdev, peer);
  612. DP_STATS_UPD(peer, rx.last_rssi, ppdu->rssi);
  613. if (peer == pdev->invalid_peer)
  614. continue;
  615. if (dp_is_subtype_data(ppdu->frame_ctrl))
  616. dp_rx_rate_stats_update(peer, ppdu, i);
  617. #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
  618. dp_wdi_event_handler(WDI_EVENT_UPDATE_DP_STATS, pdev->soc,
  619. &peer->stats, ppdu->peer_id,
  620. UPDATE_PEER_STATS, pdev->pdev_id);
  621. #endif
  622. dp_peer_unref_delete(peer);
  623. }
  624. }
  625. #endif
  626. /**
  627. * dp_rx_handle_mcopy_mode() - Allocate and deliver first MSDU payload
  628. * @soc: core txrx main context
  629. * @pdev: pdev structure
  630. * @ppdu_info: structure for rx ppdu ring
  631. * @nbuf: QDF nbuf
  632. * @fcs_ok_mpdu_cnt: fcs passsed mpdu index
  633. * @deliver_frame: flag to deliver wdi event
  634. *
  635. * Return: QDF_STATUS_SUCCESS - If nbuf to be freed by caller
  636. * QDF_STATUS_E_ALREADY - If nbuf not to be freed by caller
  637. */
  638. #ifdef FEATURE_PERPKT_INFO
  639. static inline QDF_STATUS
  640. dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  641. struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf,
  642. uint8_t fcs_ok_mpdu_cnt, bool deliver_frame)
  643. {
  644. uint16_t size = 0;
  645. struct ieee80211_frame *wh;
  646. uint32_t *nbuf_data;
  647. if (!ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload)
  648. return QDF_STATUS_SUCCESS;
  649. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  650. if (pdev->mcopy_mode == M_COPY) {
  651. if (pdev->m_copy_id.rx_ppdu_id == ppdu_info->com_info.ppdu_id)
  652. return QDF_STATUS_SUCCESS;
  653. }
  654. wh = (struct ieee80211_frame *)(ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload + 4);
  655. size = (ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload -
  656. qdf_nbuf_data(nbuf));
  657. if (qdf_nbuf_pull_head(nbuf, size) == NULL)
  658. return QDF_STATUS_SUCCESS;
  659. if (((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  660. IEEE80211_FC0_TYPE_MGT) ||
  661. ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  662. IEEE80211_FC0_TYPE_CTL)) {
  663. return QDF_STATUS_SUCCESS;
  664. }
  665. nbuf_data = (uint32_t *)qdf_nbuf_data(nbuf);
  666. *nbuf_data = pdev->ppdu_info.com_info.ppdu_id;
  667. /* only retain RX MSDU payload in the skb */
  668. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) - ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].payload_len);
  669. if (deliver_frame) {
  670. pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
  671. dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
  672. nbuf, HTT_INVALID_PEER,
  673. WDI_NO_VAL, pdev->pdev_id);
  674. }
  675. return QDF_STATUS_E_ALREADY;
  676. }
  677. #else
  678. static inline QDF_STATUS
  679. dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  680. struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf,
  681. uint8_t fcs_ok_cnt, bool deliver_frame)
  682. {
  683. return QDF_STATUS_SUCCESS;
  684. }
  685. #endif
  686. /**
  687. * dp_rx_mcopy_handle_last_mpdu() - cache and delive last MPDU header in a
  688. * status buffer if MPDU end tlv is received in different buffer
  689. * @soc: core txrx main context
  690. * @pdev: pdev structure
  691. * @ppdu_info: structure for rx ppdu ring
  692. * @status_nbuf: QDF nbuf
  693. *
  694. * Return: void
  695. */
  696. #ifdef FEATURE_PERPKT_INFO
  697. static inline void
  698. dp_rx_mcopy_handle_last_mpdu(struct dp_soc *soc, struct dp_pdev *pdev,
  699. struct hal_rx_ppdu_info *ppdu_info,
  700. qdf_nbuf_t status_nbuf)
  701. {
  702. QDF_STATUS mcopy_status;
  703. qdf_nbuf_t nbuf_clone = NULL;
  704. /* If the MPDU end tlv and RX header are received in different buffers,
  705. * process the RX header based on fcs status.
  706. */
  707. if (pdev->mcopy_status_nbuf) {
  708. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  709. if (pdev->mcopy_mode == M_COPY) {
  710. if (pdev->m_copy_id.rx_ppdu_id ==
  711. ppdu_info->com_info.ppdu_id)
  712. goto end1;
  713. }
  714. if (ppdu_info->is_fcs_passed) {
  715. nbuf_clone = qdf_nbuf_clone(pdev->mcopy_status_nbuf);
  716. if (!nbuf_clone) {
  717. QDF_TRACE(QDF_MODULE_ID_TXRX,
  718. QDF_TRACE_LEVEL_ERROR,
  719. "Failed to clone nbuf",
  720. __func__, __LINE__);
  721. goto end1;
  722. }
  723. pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
  724. dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
  725. nbuf_clone,
  726. HTT_INVALID_PEER,
  727. WDI_NO_VAL, pdev->pdev_id);
  728. ppdu_info->is_fcs_passed = false;
  729. }
  730. end1:
  731. qdf_nbuf_free(pdev->mcopy_status_nbuf);
  732. pdev->mcopy_status_nbuf = NULL;
  733. }
  734. /* If the MPDU end tlv and RX header are received in different buffers,
  735. * preserve the RX header as the fcs status will be received in MPDU
  736. * end tlv in next buffer. So, cache the buffer to be processd in next
  737. * iteration
  738. */
  739. if ((ppdu_info->fcs_ok_cnt + ppdu_info->fcs_err_cnt) !=
  740. ppdu_info->com_info.mpdu_cnt) {
  741. pdev->mcopy_status_nbuf = qdf_nbuf_clone(status_nbuf);
  742. if (pdev->mcopy_status_nbuf) {
  743. mcopy_status = dp_rx_handle_mcopy_mode(
  744. soc, pdev,
  745. ppdu_info,
  746. pdev->mcopy_status_nbuf,
  747. ppdu_info->fcs_ok_cnt,
  748. false);
  749. if (mcopy_status == QDF_STATUS_SUCCESS) {
  750. qdf_nbuf_free(pdev->mcopy_status_nbuf);
  751. pdev->mcopy_status_nbuf = NULL;
  752. }
  753. }
  754. }
  755. }
  756. #else
  757. static inline void
  758. dp_rx_mcopy_handle_last_mpdu(struct dp_soc *soc, struct dp_pdev *pdev,
  759. struct hal_rx_ppdu_info *ppdu_info,
  760. qdf_nbuf_t status_nbuf)
  761. {
  762. }
  763. #endif
  764. /**
  765. * dp_rx_mcopy_process_ppdu_info() - update mcopy ppdu info
  766. * @ppdu_info: structure for rx ppdu ring
  767. * @tlv_status: processed TLV status
  768. *
  769. * Return: void
  770. */
  771. #ifdef FEATURE_PERPKT_INFO
  772. static inline void
  773. dp_rx_mcopy_process_ppdu_info(struct dp_pdev *pdev,
  774. struct hal_rx_ppdu_info *ppdu_info,
  775. uint32_t tlv_status)
  776. {
  777. if (!pdev->mcopy_mode)
  778. return;
  779. /* The fcs status is received in MPDU end tlv. If the RX header
  780. * and its MPDU end tlv are received in different status buffer then
  781. * to process that header ppdu_info->is_fcs_passed is used.
  782. * If end tlv is received in next status buffer then com_info.mpdu_cnt
  783. * will be 0 at the time of receiving MPDU end tlv and we update the
  784. * is_fcs_passed flag based on ppdu_info->fcs_err.
  785. */
  786. if (tlv_status != HAL_TLV_STATUS_MPDU_END)
  787. return;
  788. if (!ppdu_info->fcs_err) {
  789. if (ppdu_info->fcs_ok_cnt >
  790. HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER) {
  791. dp_err("No. of MPDUs(%d) per status buff exceeded",
  792. ppdu_info->fcs_ok_cnt);
  793. return;
  794. }
  795. if (ppdu_info->com_info.mpdu_cnt)
  796. ppdu_info->fcs_ok_cnt++;
  797. else
  798. ppdu_info->is_fcs_passed = true;
  799. } else {
  800. if (ppdu_info->com_info.mpdu_cnt)
  801. ppdu_info->fcs_err_cnt++;
  802. else
  803. ppdu_info->is_fcs_passed = false;
  804. }
  805. }
  806. #else
  807. static inline void
  808. dp_rx_mcopy_process_ppdu_info(struct dp_pdev *pdev,
  809. struct hal_rx_ppdu_info *ppdu_info,
  810. uint32_t tlv_status)
  811. {
  812. }
  813. #endif
  814. #ifdef FEATURE_PERPKT_INFO
  815. static inline void
  816. dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  817. struct hal_rx_ppdu_info *ppdu_info,
  818. uint32_t tlv_status,
  819. qdf_nbuf_t status_nbuf)
  820. {
  821. QDF_STATUS mcopy_status;
  822. qdf_nbuf_t nbuf_clone = NULL;
  823. uint8_t fcs_ok_mpdu_cnt = 0;
  824. dp_rx_mcopy_handle_last_mpdu(soc, pdev, ppdu_info, status_nbuf);
  825. if (qdf_unlikely(!ppdu_info->com_info.mpdu_cnt))
  826. goto end;
  827. if (qdf_unlikely(!ppdu_info->fcs_ok_cnt))
  828. goto end;
  829. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  830. if (pdev->mcopy_mode == M_COPY)
  831. ppdu_info->fcs_ok_cnt = 1;
  832. while (fcs_ok_mpdu_cnt < ppdu_info->fcs_ok_cnt) {
  833. nbuf_clone = qdf_nbuf_clone(status_nbuf);
  834. if (!nbuf_clone) {
  835. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  836. "Failed to clone nbuf",
  837. __func__, __LINE__);
  838. goto end;
  839. }
  840. mcopy_status = dp_rx_handle_mcopy_mode(soc, pdev,
  841. ppdu_info,
  842. nbuf_clone,
  843. fcs_ok_mpdu_cnt,
  844. true);
  845. if (mcopy_status == QDF_STATUS_SUCCESS)
  846. qdf_nbuf_free(nbuf_clone);
  847. fcs_ok_mpdu_cnt++;
  848. }
  849. end:
  850. qdf_nbuf_free(status_nbuf);
  851. ppdu_info->fcs_ok_cnt = 0;
  852. ppdu_info->fcs_err_cnt = 0;
  853. ppdu_info->com_info.mpdu_cnt = 0;
  854. qdf_mem_zero(&ppdu_info->ppdu_msdu_info,
  855. HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER
  856. * sizeof(struct hal_rx_msdu_payload_info));
  857. }
  858. #else
  859. static inline void
  860. dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  861. struct hal_rx_ppdu_info *ppdu_info,
  862. uint32_t tlv_status,
  863. qdf_nbuf_t status_nbuf)
  864. {
  865. }
  866. #endif
  867. /**
  868. * dp_rx_handle_smart_mesh_mode() - Deliver header for smart mesh
  869. * @soc: Datapath SOC handle
  870. * @pdev: Datapath PDEV handle
  871. * @ppdu_info: Structure for rx ppdu info
  872. * @nbuf: Qdf nbuf abstraction for linux skb
  873. *
  874. * Return: 0 on success, 1 on failure
  875. */
  876. static inline int
  877. dp_rx_handle_smart_mesh_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  878. struct hal_rx_ppdu_info *ppdu_info,
  879. qdf_nbuf_t nbuf)
  880. {
  881. uint8_t size = 0;
  882. if (!pdev->monitor_vdev) {
  883. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  884. "[%s]:[%d] Monitor vdev is NULL !!",
  885. __func__, __LINE__);
  886. return 1;
  887. }
  888. if (!ppdu_info->msdu_info.first_msdu_payload) {
  889. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  890. "[%s]:[%d] First msdu payload not present",
  891. __func__, __LINE__);
  892. return 1;
  893. }
  894. /* Adding 4 bytes to get to start of 802.11 frame after phy_ppdu_id */
  895. size = (ppdu_info->msdu_info.first_msdu_payload -
  896. qdf_nbuf_data(nbuf)) + 4;
  897. ppdu_info->msdu_info.first_msdu_payload = NULL;
  898. if (qdf_nbuf_pull_head(nbuf, size) == NULL) {
  899. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  900. "[%s]:[%d] No header present",
  901. __func__, __LINE__);
  902. return 1;
  903. }
  904. /* Only retain RX MSDU payload in the skb */
  905. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
  906. ppdu_info->msdu_info.payload_len);
  907. if (!qdf_nbuf_update_radiotap(&pdev->ppdu_info.rx_status, nbuf,
  908. qdf_nbuf_headroom(nbuf))) {
  909. DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
  910. return 1;
  911. }
  912. pdev->monitor_vdev->osif_rx_mon(pdev->monitor_vdev->osif_vdev,
  913. nbuf, NULL);
  914. pdev->ppdu_info.rx_status.monitor_direct_used = 0;
  915. return 0;
  916. }
  917. #if defined(WLAN_CFR_ENABLE) && defined(WLAN_ENH_CFR_ENABLE)
  918. /*
  919. * dp_rx_mon_handle_cfr_mu_info() - Gather macaddr and ast_index of peer(s) in
  920. * the PPDU received, this will be used for correlation of CFR data captured
  921. * for an UL-MU-PPDU
  922. * @pdev: pdev ctx
  923. * @ppdu_info: pointer to ppdu info structure populated from ppdu status TLVs
  924. * @cdp_rx_ppdu: Rx PPDU indication structure
  925. *
  926. * Return: none
  927. */
  928. static inline void
  929. dp_rx_mon_handle_cfr_mu_info(struct dp_pdev *pdev,
  930. struct hal_rx_ppdu_info *ppdu_info,
  931. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  932. {
  933. struct dp_peer *peer;
  934. struct dp_soc *soc = pdev->soc;
  935. struct dp_ast_entry *ast_entry;
  936. struct mon_rx_user_status *rx_user_status;
  937. struct cdp_rx_stats_ppdu_user *rx_stats_peruser;
  938. uint32_t num_users;
  939. int user_id;
  940. uint32_t ast_index;
  941. qdf_spin_lock_bh(&soc->ast_lock);
  942. num_users = ppdu_info->com_info.num_users;
  943. for (user_id = 0; user_id < num_users; user_id++) {
  944. if (user_id > OFDMA_NUM_USERS) {
  945. qdf_spin_unlock_bh(&soc->ast_lock);
  946. return;
  947. }
  948. rx_user_status = &ppdu_info->rx_user_status[user_id];
  949. rx_stats_peruser = &cdp_rx_ppdu->user[user_id];
  950. ast_index = rx_user_status->ast_index;
  951. if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  952. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  953. continue;
  954. }
  955. ast_entry = soc->ast_table[ast_index];
  956. if (!ast_entry) {
  957. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  958. continue;
  959. }
  960. peer = ast_entry->peer;
  961. if (!peer || peer->peer_ids[0] == HTT_INVALID_PEER) {
  962. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  963. continue;
  964. }
  965. qdf_mem_copy(rx_stats_peruser->mac_addr,
  966. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  967. }
  968. qdf_spin_unlock_bh(&soc->ast_lock);
  969. }
  970. /*
  971. * dp_rx_mon_populate_cfr_ppdu_info() - Populate cdp ppdu info from hal ppdu
  972. * info
  973. * @pdev: pdev ctx
  974. * @ppdu_info: ppdu info structure from ppdu ring
  975. * @cdp_rx_ppdu : Rx PPDU indication structure
  976. *
  977. * Return: none
  978. */
  979. static inline void
  980. dp_rx_mon_populate_cfr_ppdu_info(struct dp_pdev *pdev,
  981. struct hal_rx_ppdu_info *ppdu_info,
  982. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  983. {
  984. int chain;
  985. cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
  986. cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
  987. cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
  988. cdp_rx_ppdu->num_users = ppdu_info->com_info.num_users;
  989. for (chain = 0; chain < MAX_CHAIN; chain++)
  990. cdp_rx_ppdu->per_chain_rssi[chain] =
  991. ppdu_info->rx_status.rssi[chain];
  992. dp_rx_mon_handle_cfr_mu_info(pdev, ppdu_info, cdp_rx_ppdu);
  993. }
  994. /**
  995. * dp_cfr_rcc_mode_status() - Return status of cfr rcc mode
  996. * @pdev: pdev ctx
  997. *
  998. * Return: True or False
  999. */
  1000. static inline bool
  1001. dp_cfr_rcc_mode_status(struct dp_pdev *pdev)
  1002. {
  1003. return pdev->cfr_rcc_mode;
  1004. }
  1005. /*
  1006. * dp_rx_mon_populate_cfr_info() - Populate cdp ppdu info from hal cfr info
  1007. * @pdev: pdev ctx
  1008. * @ppdu_info: ppdu info structure from ppdu ring
  1009. * @cdp_rx_ppdu: Rx PPDU indication structure
  1010. *
  1011. * Return: none
  1012. */
  1013. static inline void
  1014. dp_rx_mon_populate_cfr_info(struct dp_pdev *pdev,
  1015. struct hal_rx_ppdu_info *ppdu_info,
  1016. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1017. {
  1018. struct cdp_rx_ppdu_cfr_info *cfr_info;
  1019. if (!dp_cfr_rcc_mode_status(pdev))
  1020. return;
  1021. cfr_info = &cdp_rx_ppdu->cfr_info;
  1022. cfr_info->bb_captured_channel
  1023. = ppdu_info->cfr_info.bb_captured_channel;
  1024. cfr_info->bb_captured_timeout
  1025. = ppdu_info->cfr_info.bb_captured_timeout;
  1026. cfr_info->bb_captured_reason
  1027. = ppdu_info->cfr_info.bb_captured_reason;
  1028. cfr_info->rx_location_info_valid
  1029. = ppdu_info->cfr_info.rx_location_info_valid;
  1030. cfr_info->chan_capture_status
  1031. = ppdu_info->cfr_info.chan_capture_status;
  1032. cfr_info->rtt_che_buffer_pointer_high8
  1033. = ppdu_info->cfr_info.rtt_che_buffer_pointer_high8;
  1034. cfr_info->rtt_che_buffer_pointer_low32
  1035. = ppdu_info->cfr_info.rtt_che_buffer_pointer_low32;
  1036. }
  1037. /**
  1038. * dp_update_cfr_dbg_stats() - Increment RCC debug statistics
  1039. * @pdev: pdev structure
  1040. * @ppdu_info: structure for rx ppdu ring
  1041. *
  1042. * Return: none
  1043. */
  1044. static inline void
  1045. dp_update_cfr_dbg_stats(struct dp_pdev *pdev,
  1046. struct hal_rx_ppdu_info *ppdu_info)
  1047. {
  1048. struct hal_rx_ppdu_cfr_info *cfr = &ppdu_info->cfr_info;
  1049. DP_STATS_INC(pdev,
  1050. rcc.chan_capture_status[cfr->chan_capture_status], 1);
  1051. if (cfr->rx_location_info_valid) {
  1052. DP_STATS_INC(pdev, rcc.rx_loc_info_valid_cnt, 1);
  1053. if (cfr->bb_captured_channel) {
  1054. DP_STATS_INC(pdev, rcc.bb_captured_channel_cnt, 1);
  1055. DP_STATS_INC(pdev,
  1056. rcc.reason_cnt[cfr->bb_captured_reason],
  1057. 1);
  1058. } else if (cfr->bb_captured_timeout) {
  1059. DP_STATS_INC(pdev, rcc.bb_captured_timeout_cnt, 1);
  1060. DP_STATS_INC(pdev,
  1061. rcc.reason_cnt[cfr->bb_captured_reason],
  1062. 1);
  1063. }
  1064. }
  1065. }
  1066. /*
  1067. * dp_rx_handle_cfr() - Gather cfr info from hal ppdu info
  1068. * @soc: core txrx main context
  1069. * @pdev: pdev ctx
  1070. * @ppdu_info: ppdu info structure from ppdu ring
  1071. *
  1072. * Return: none
  1073. */
  1074. static inline void
  1075. dp_rx_handle_cfr(struct dp_soc *soc, struct dp_pdev *pdev,
  1076. struct hal_rx_ppdu_info *ppdu_info)
  1077. {
  1078. qdf_nbuf_t ppdu_nbuf;
  1079. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  1080. dp_update_cfr_dbg_stats(pdev, ppdu_info);
  1081. if (!ppdu_info->cfr_info.bb_captured_channel)
  1082. return;
  1083. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  1084. sizeof(struct cdp_rx_indication_ppdu),
  1085. 0,
  1086. 0,
  1087. FALSE);
  1088. if (ppdu_nbuf) {
  1089. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
  1090. dp_rx_mon_populate_cfr_info(pdev, ppdu_info, cdp_rx_ppdu);
  1091. dp_rx_mon_populate_cfr_ppdu_info(pdev, ppdu_info, cdp_rx_ppdu);
  1092. qdf_nbuf_put_tail(ppdu_nbuf,
  1093. sizeof(struct cdp_rx_indication_ppdu));
  1094. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
  1095. ppdu_nbuf, HTT_INVALID_PEER,
  1096. WDI_NO_VAL, pdev->pdev_id);
  1097. }
  1098. }
  1099. /**
  1100. * dp_rx_populate_cfr_non_assoc_sta() - Populate cfr ppdu info for PPDUs from
  1101. * non-associated stations
  1102. * @pdev: pdev ctx
  1103. * @ppdu_info: ppdu info structure from ppdu ring
  1104. * @cdp_rx_ppdu: Rx PPDU indication structure
  1105. *
  1106. * Return: none
  1107. */
  1108. static inline void
  1109. dp_rx_populate_cfr_non_assoc_sta(struct dp_pdev *pdev,
  1110. struct hal_rx_ppdu_info *ppdu_info,
  1111. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1112. {
  1113. if (!dp_cfr_rcc_mode_status(pdev))
  1114. return;
  1115. if (ppdu_info->cfr_info.bb_captured_channel)
  1116. dp_rx_mon_populate_cfr_ppdu_info(pdev, ppdu_info, cdp_rx_ppdu);
  1117. }
  1118. /**
  1119. * dp_bb_captured_chan_status() - Get the bb_captured_channel status
  1120. * @ppdu_info: structure for rx ppdu ring
  1121. *
  1122. * Return: Success/ Failure
  1123. */
  1124. static inline QDF_STATUS
  1125. dp_bb_captured_chan_status(struct dp_pdev *pdev,
  1126. struct hal_rx_ppdu_info *ppdu_info)
  1127. {
  1128. QDF_STATUS status = QDF_STATUS_E_FAILURE;
  1129. struct hal_rx_ppdu_cfr_info *cfr = &ppdu_info->cfr_info;
  1130. if (dp_cfr_rcc_mode_status(pdev)) {
  1131. if (cfr->bb_captured_channel)
  1132. status = QDF_STATUS_SUCCESS;
  1133. }
  1134. return status;
  1135. }
  1136. #else
  1137. static inline void
  1138. dp_rx_mon_handle_cfr_mu_info(struct dp_pdev *pdev,
  1139. struct hal_rx_ppdu_info *ppdu_info,
  1140. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1141. {
  1142. }
  1143. static inline void
  1144. dp_rx_mon_populate_cfr_ppdu_info(struct dp_pdev *pdev,
  1145. struct hal_rx_ppdu_info *ppdu_info,
  1146. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1147. {
  1148. }
  1149. static inline void
  1150. dp_rx_mon_populate_cfr_info(struct dp_pdev *pdev,
  1151. struct hal_rx_ppdu_info *ppdu_info,
  1152. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1153. {
  1154. }
  1155. static inline void
  1156. dp_rx_handle_cfr(struct dp_soc *soc, struct dp_pdev *pdev,
  1157. struct hal_rx_ppdu_info *ppdu_info)
  1158. {
  1159. }
  1160. static inline void
  1161. dp_rx_populate_cfr_non_assoc_sta(struct dp_pdev *pdev,
  1162. struct hal_rx_ppdu_info *ppdu_info,
  1163. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1164. {
  1165. }
  1166. static inline void
  1167. dp_update_cfr_dbg_stats(struct dp_pdev *pdev,
  1168. struct hal_rx_ppdu_info *ppdu_info)
  1169. {
  1170. }
  1171. static inline QDF_STATUS
  1172. dp_bb_captured_chan_status(struct dp_pdev *pdev,
  1173. struct hal_rx_ppdu_info *ppdu_info)
  1174. {
  1175. return QDF_STATUS_E_NOSUPPORT;
  1176. }
  1177. static inline bool
  1178. dp_cfr_rcc_mode_status(struct dp_pdev *pdev)
  1179. {
  1180. return false;
  1181. }
  1182. #endif
  1183. /**
  1184. * dp_rx_handle_ppdu_stats() - Allocate and deliver ppdu stats to cdp layer
  1185. * @soc: core txrx main context
  1186. * @pdev: pdev strcuture
  1187. * @ppdu_info: structure for rx ppdu ring
  1188. *
  1189. * Return: none
  1190. */
  1191. #ifdef FEATURE_PERPKT_INFO
  1192. static inline void
  1193. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  1194. struct hal_rx_ppdu_info *ppdu_info)
  1195. {
  1196. qdf_nbuf_t ppdu_nbuf;
  1197. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  1198. /*
  1199. * Do not allocate if fcs error,
  1200. * ast idx invalid / fctl invalid
  1201. *
  1202. * In CFR RCC mode - PPDU status TLVs of error pkts are also needed
  1203. */
  1204. if (ppdu_info->com_info.mpdu_cnt_fcs_ok == 0)
  1205. return;
  1206. if (ppdu_info->nac_info.fc_valid &&
  1207. ppdu_info->nac_info.to_ds_flag &&
  1208. ppdu_info->nac_info.mac_addr2_valid) {
  1209. struct dp_neighbour_peer *peer = NULL;
  1210. uint8_t rssi = ppdu_info->rx_status.rssi_comb;
  1211. qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
  1212. if (pdev->neighbour_peers_added) {
  1213. TAILQ_FOREACH(peer, &pdev->neighbour_peers_list,
  1214. neighbour_peer_list_elem) {
  1215. if (!qdf_mem_cmp(&peer->neighbour_peers_macaddr,
  1216. &ppdu_info->nac_info.mac_addr2,
  1217. QDF_MAC_ADDR_SIZE)) {
  1218. peer->rssi = rssi;
  1219. break;
  1220. }
  1221. }
  1222. }
  1223. qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
  1224. }
  1225. /* need not generate wdi event when mcopy, cfr rcc mode and
  1226. * enhanced stats are not enabled
  1227. */
  1228. if (!pdev->mcopy_mode && !pdev->enhanced_stats_en &&
  1229. !dp_cfr_rcc_mode_status(pdev))
  1230. return;
  1231. if (dp_cfr_rcc_mode_status(pdev))
  1232. dp_update_cfr_dbg_stats(pdev, ppdu_info);
  1233. if (!ppdu_info->rx_status.frame_control_info_valid ||
  1234. (ppdu_info->rx_status.ast_index == HAL_AST_IDX_INVALID)) {
  1235. if (!(pdev->mcopy_mode ||
  1236. (dp_bb_captured_chan_status(pdev, ppdu_info) ==
  1237. QDF_STATUS_SUCCESS)))
  1238. return;
  1239. }
  1240. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  1241. sizeof(struct cdp_rx_indication_ppdu),
  1242. 0, 0, FALSE);
  1243. if (ppdu_nbuf) {
  1244. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
  1245. dp_rx_mon_populate_cfr_info(pdev, ppdu_info, cdp_rx_ppdu);
  1246. dp_rx_populate_cdp_indication_ppdu(pdev,
  1247. ppdu_info, cdp_rx_ppdu);
  1248. qdf_nbuf_put_tail(ppdu_nbuf,
  1249. sizeof(struct cdp_rx_indication_ppdu));
  1250. dp_rx_stats_update(pdev, cdp_rx_ppdu);
  1251. if (cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) {
  1252. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC,
  1253. soc, ppdu_nbuf,
  1254. cdp_rx_ppdu->peer_id,
  1255. WDI_NO_VAL, pdev->pdev_id);
  1256. } else if (pdev->mcopy_mode || dp_cfr_rcc_mode_status(pdev)) {
  1257. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
  1258. ppdu_nbuf, HTT_INVALID_PEER,
  1259. WDI_NO_VAL, pdev->pdev_id);
  1260. } else {
  1261. qdf_nbuf_free(ppdu_nbuf);
  1262. }
  1263. }
  1264. }
  1265. #else
  1266. static inline void
  1267. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  1268. struct hal_rx_ppdu_info *ppdu_info)
  1269. {
  1270. }
  1271. #endif
  1272. /**
  1273. * dp_rx_process_peer_based_pktlog() - Process Rx pktlog if peer based
  1274. * filtering enabled
  1275. * @soc: core txrx main context
  1276. * @ppdu_info: Structure for rx ppdu info
  1277. * @status_nbuf: Qdf nbuf abstraction for linux skb
  1278. * @mac_id: mac_id/pdev_id correspondinggly for MCL and WIN
  1279. *
  1280. * Return: none
  1281. */
  1282. static inline void
  1283. dp_rx_process_peer_based_pktlog(struct dp_soc *soc,
  1284. struct hal_rx_ppdu_info *ppdu_info,
  1285. qdf_nbuf_t status_nbuf, uint32_t mac_id)
  1286. {
  1287. struct dp_peer *peer;
  1288. struct dp_ast_entry *ast_entry;
  1289. uint32_t ast_index;
  1290. ast_index = ppdu_info->rx_status.ast_index;
  1291. if (ast_index < wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  1292. ast_entry = soc->ast_table[ast_index];
  1293. if (ast_entry) {
  1294. peer = ast_entry->peer;
  1295. if (peer && (peer->peer_ids[0] != HTT_INVALID_PEER)) {
  1296. if (peer->peer_based_pktlog_filter) {
  1297. dp_wdi_event_handler(
  1298. WDI_EVENT_RX_DESC, soc,
  1299. status_nbuf,
  1300. peer->peer_ids[0],
  1301. WDI_NO_VAL, mac_id);
  1302. }
  1303. }
  1304. }
  1305. }
  1306. }
  1307. #if defined(HTT_UL_OFDMA_USER_INFO_V0_W0_VALID_M)
  1308. static inline void
  1309. dp_rx_ul_ofdma_ru_size_to_width(
  1310. uint32_t ru_size,
  1311. uint32_t *ru_width)
  1312. {
  1313. uint32_t width;
  1314. width = 0;
  1315. switch (ru_size) {
  1316. case HTT_UL_OFDMA_V0_RU_SIZE_RU_26:
  1317. width = 1;
  1318. break;
  1319. case HTT_UL_OFDMA_V0_RU_SIZE_RU_52:
  1320. width = 2;
  1321. break;
  1322. case HTT_UL_OFDMA_V0_RU_SIZE_RU_106:
  1323. width = 4;
  1324. break;
  1325. case HTT_UL_OFDMA_V0_RU_SIZE_RU_242:
  1326. width = 9;
  1327. break;
  1328. case HTT_UL_OFDMA_V0_RU_SIZE_RU_484:
  1329. width = 18;
  1330. break;
  1331. case HTT_UL_OFDMA_V0_RU_SIZE_RU_996:
  1332. width = 37;
  1333. break;
  1334. case HTT_UL_OFDMA_V0_RU_SIZE_RU_996x2:
  1335. width = 74;
  1336. break;
  1337. default:
  1338. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1339. "RU size to width convert err");
  1340. break;
  1341. }
  1342. *ru_width = width;
  1343. }
  1344. static inline void
  1345. dp_rx_mon_handle_mu_ul_info(struct hal_rx_ppdu_info *ppdu_info)
  1346. {
  1347. struct mon_rx_user_status *mon_rx_user_status;
  1348. uint32_t num_users;
  1349. uint32_t i;
  1350. uint32_t mu_ul_user_v0_word0;
  1351. uint32_t mu_ul_user_v0_word1;
  1352. uint32_t ru_width;
  1353. uint32_t ru_size;
  1354. if (!(ppdu_info->rx_status.reception_type == HAL_RX_TYPE_MU_OFDMA ||
  1355. ppdu_info->rx_status.reception_type == HAL_RX_TYPE_MU_MIMO))
  1356. return;
  1357. num_users = ppdu_info->com_info.num_users;
  1358. if (num_users > HAL_MAX_UL_MU_USERS)
  1359. num_users = HAL_MAX_UL_MU_USERS;
  1360. for (i = 0; i < num_users; i++) {
  1361. mon_rx_user_status = &ppdu_info->rx_user_status[i];
  1362. mu_ul_user_v0_word0 =
  1363. mon_rx_user_status->mu_ul_user_v0_word0;
  1364. mu_ul_user_v0_word1 =
  1365. mon_rx_user_status->mu_ul_user_v0_word1;
  1366. if (HTT_UL_OFDMA_USER_INFO_V0_W0_VALID_GET(
  1367. mu_ul_user_v0_word0) &&
  1368. !HTT_UL_OFDMA_USER_INFO_V0_W0_VER_GET(
  1369. mu_ul_user_v0_word0)) {
  1370. mon_rx_user_status->mcs =
  1371. HTT_UL_OFDMA_USER_INFO_V0_W1_MCS_GET(
  1372. mu_ul_user_v0_word1);
  1373. mon_rx_user_status->nss =
  1374. HTT_UL_OFDMA_USER_INFO_V0_W1_NSS_GET(
  1375. mu_ul_user_v0_word1) + 1;
  1376. mon_rx_user_status->mu_ul_info_valid = 1;
  1377. mon_rx_user_status->ofdma_ru_start_index =
  1378. HTT_UL_OFDMA_USER_INFO_V0_W1_RU_START_GET(
  1379. mu_ul_user_v0_word1);
  1380. ru_size =
  1381. HTT_UL_OFDMA_USER_INFO_V0_W1_RU_SIZE_GET(
  1382. mu_ul_user_v0_word1);
  1383. dp_rx_ul_ofdma_ru_size_to_width(ru_size, &ru_width);
  1384. mon_rx_user_status->ofdma_ru_width = ru_width;
  1385. mon_rx_user_status->ofdma_ru_size = ru_size;
  1386. }
  1387. }
  1388. }
  1389. #else
  1390. static inline void
  1391. dp_rx_mon_handle_mu_ul_info(struct hal_rx_ppdu_info *ppdu_info)
  1392. {
  1393. }
  1394. #endif
  1395. /**
  1396. * dp_rx_mon_status_process_tlv() - Process status TLV in status
  1397. * buffer on Rx status Queue posted by status SRNG processing.
  1398. * @soc: core txrx main context
  1399. * @mac_id: mac_id which is one of 3 mac_ids _ring
  1400. *
  1401. * Return: none
  1402. */
  1403. static inline void
  1404. dp_rx_mon_status_process_tlv(struct dp_soc *soc, uint32_t mac_id,
  1405. uint32_t quota)
  1406. {
  1407. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1408. struct hal_rx_ppdu_info *ppdu_info;
  1409. qdf_nbuf_t status_nbuf;
  1410. uint8_t *rx_tlv;
  1411. uint8_t *rx_tlv_start;
  1412. uint32_t tlv_status = HAL_TLV_STATUS_BUF_DONE;
  1413. QDF_STATUS enh_log_status = QDF_STATUS_SUCCESS;
  1414. struct cdp_pdev_mon_stats *rx_mon_stats;
  1415. int smart_mesh_status;
  1416. enum WDI_EVENT pktlog_mode = WDI_NO_VAL;
  1417. bool nbuf_used;
  1418. uint32_t rx_enh_capture_mode;
  1419. if (!pdev) {
  1420. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1421. "pdev is null for mac_id = %d", mac_id);
  1422. return;
  1423. }
  1424. ppdu_info = &pdev->ppdu_info;
  1425. rx_mon_stats = &pdev->rx_mon_stats;
  1426. if (pdev->mon_ppdu_status != DP_PPDU_STATUS_START)
  1427. return;
  1428. rx_enh_capture_mode = pdev->rx_enh_capture_mode;
  1429. while (!qdf_nbuf_is_queue_empty(&pdev->rx_status_q)) {
  1430. status_nbuf = qdf_nbuf_queue_remove(&pdev->rx_status_q);
  1431. rx_tlv = qdf_nbuf_data(status_nbuf);
  1432. rx_tlv_start = rx_tlv;
  1433. nbuf_used = false;
  1434. if ((pdev->monitor_vdev) || (pdev->enhanced_stats_en) ||
  1435. (pdev->mcopy_mode) || (dp_cfr_rcc_mode_status(pdev)) ||
  1436. (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED)) {
  1437. do {
  1438. tlv_status = hal_rx_status_get_tlv_info(rx_tlv,
  1439. ppdu_info, pdev->soc->hal_soc,
  1440. status_nbuf);
  1441. dp_rx_mon_update_dbg_ppdu_stats(ppdu_info,
  1442. rx_mon_stats);
  1443. dp_rx_mon_enh_capture_process(pdev, tlv_status,
  1444. status_nbuf, ppdu_info,
  1445. &nbuf_used);
  1446. dp_rx_mcopy_process_ppdu_info(pdev,
  1447. ppdu_info,
  1448. tlv_status);
  1449. rx_tlv = hal_rx_status_get_next_tlv(rx_tlv);
  1450. if ((rx_tlv - rx_tlv_start) >=
  1451. RX_DATA_BUFFER_SIZE)
  1452. break;
  1453. } while ((tlv_status == HAL_TLV_STATUS_PPDU_NOT_DONE) ||
  1454. (tlv_status == HAL_TLV_STATUS_HEADER) ||
  1455. (tlv_status == HAL_TLV_STATUS_MPDU_END) ||
  1456. (tlv_status == HAL_TLV_STATUS_MSDU_END));
  1457. }
  1458. if (pdev->dp_peer_based_pktlog) {
  1459. dp_rx_process_peer_based_pktlog(soc, ppdu_info,
  1460. status_nbuf, mac_id);
  1461. } else {
  1462. if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_FULL)
  1463. pktlog_mode = WDI_EVENT_RX_DESC;
  1464. else if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_LITE)
  1465. pktlog_mode = WDI_EVENT_LITE_RX;
  1466. if (pktlog_mode != WDI_NO_VAL)
  1467. dp_wdi_event_handler(pktlog_mode, soc,
  1468. status_nbuf,
  1469. HTT_INVALID_PEER,
  1470. WDI_NO_VAL, mac_id);
  1471. }
  1472. /* smart monitor vap and m_copy cannot co-exist */
  1473. if (ppdu_info->rx_status.monitor_direct_used && pdev->neighbour_peers_added
  1474. && pdev->monitor_vdev) {
  1475. smart_mesh_status = dp_rx_handle_smart_mesh_mode(soc,
  1476. pdev, ppdu_info, status_nbuf);
  1477. if (smart_mesh_status)
  1478. qdf_nbuf_free(status_nbuf);
  1479. } else if (qdf_unlikely(pdev->mcopy_mode)) {
  1480. dp_rx_process_mcopy_mode(soc, pdev,
  1481. ppdu_info, tlv_status,
  1482. status_nbuf);
  1483. } else if (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED) {
  1484. if (!nbuf_used)
  1485. qdf_nbuf_free(status_nbuf);
  1486. if (tlv_status == HAL_TLV_STATUS_PPDU_DONE)
  1487. enh_log_status =
  1488. dp_rx_handle_enh_capture(soc,
  1489. pdev, ppdu_info);
  1490. } else {
  1491. qdf_nbuf_free(status_nbuf);
  1492. }
  1493. if (tlv_status == HAL_TLV_STATUS_PPDU_NON_STD_DONE) {
  1494. dp_rx_mon_deliver_non_std(soc, mac_id);
  1495. } else if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) {
  1496. rx_mon_stats->status_ppdu_done++;
  1497. dp_rx_mon_handle_mu_ul_info(ppdu_info);
  1498. if (pdev->tx_capture_enabled
  1499. != CDP_TX_ENH_CAPTURE_DISABLED)
  1500. dp_send_ack_frame_to_stack(soc, pdev,
  1501. ppdu_info);
  1502. if (pdev->enhanced_stats_en ||
  1503. pdev->mcopy_mode || pdev->neighbour_peers_added)
  1504. dp_rx_handle_ppdu_stats(soc, pdev, ppdu_info);
  1505. else if (dp_cfr_rcc_mode_status(pdev))
  1506. dp_rx_handle_cfr(soc, pdev, ppdu_info);
  1507. pdev->mon_ppdu_status = DP_PPDU_STATUS_DONE;
  1508. /*
  1509. * if chan_num is not fetched correctly from ppdu RX TLV,
  1510. * get it from pdev saved.
  1511. */
  1512. if (qdf_unlikely(pdev->ppdu_info.rx_status.chan_num == 0))
  1513. pdev->ppdu_info.rx_status.chan_num = pdev->mon_chan_num;
  1514. /*
  1515. * if chan_freq is not fetched correctly from ppdu RX TLV,
  1516. * get it from pdev saved.
  1517. */
  1518. if (qdf_unlikely(pdev->ppdu_info.rx_status.chan_freq == 0)) {
  1519. pdev->ppdu_info.rx_status.chan_freq =
  1520. pdev->mon_chan_freq;
  1521. }
  1522. if (!soc->full_mon_mode)
  1523. dp_rx_mon_dest_process(soc, mac_id, quota);
  1524. pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  1525. }
  1526. }
  1527. return;
  1528. }
  1529. /*
  1530. * dp_rx_mon_status_srng_process() - Process monitor status ring
  1531. * post the status ring buffer to Rx status Queue for later
  1532. * processing when status ring is filled with status TLV.
  1533. * Allocate a new buffer to status ring if the filled buffer
  1534. * is posted.
  1535. *
  1536. * @soc: core txrx main context
  1537. * @mac_id: mac_id which is one of 3 mac_ids
  1538. * @quota: No. of ring entry that can be serviced in one shot.
  1539. * Return: uint32_t: No. of ring entry that is processed.
  1540. */
  1541. static inline uint32_t
  1542. dp_rx_mon_status_srng_process(struct dp_soc *soc, uint32_t mac_id,
  1543. uint32_t quota)
  1544. {
  1545. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1546. hal_soc_handle_t hal_soc;
  1547. void *mon_status_srng;
  1548. void *rxdma_mon_status_ring_entry;
  1549. QDF_STATUS status;
  1550. uint32_t work_done = 0;
  1551. if (!pdev) {
  1552. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1553. "pdev is null for mac_id = %d", mac_id);
  1554. return work_done;
  1555. }
  1556. mon_status_srng = soc->rxdma_mon_status_ring[mac_id].hal_srng;
  1557. qdf_assert(mon_status_srng);
  1558. if (!mon_status_srng || !hal_srng_initialized(mon_status_srng)) {
  1559. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1560. "%s %d : HAL Monitor Status Ring Init Failed -- %pK",
  1561. __func__, __LINE__, mon_status_srng);
  1562. return work_done;
  1563. }
  1564. hal_soc = soc->hal_soc;
  1565. qdf_assert(hal_soc);
  1566. if (qdf_unlikely(hal_srng_access_start(hal_soc, mon_status_srng)))
  1567. goto done;
  1568. /* mon_status_ring_desc => WBM_BUFFER_RING STRUCT =>
  1569. * BUFFER_ADDR_INFO STRUCT
  1570. */
  1571. while (qdf_likely((rxdma_mon_status_ring_entry =
  1572. hal_srng_src_peek_n_get_next(hal_soc, mon_status_srng))
  1573. && quota--)) {
  1574. uint32_t rx_buf_cookie;
  1575. qdf_nbuf_t status_nbuf;
  1576. struct dp_rx_desc *rx_desc;
  1577. uint8_t *status_buf;
  1578. qdf_dma_addr_t paddr;
  1579. uint64_t buf_addr;
  1580. struct rx_desc_pool *rx_desc_pool;
  1581. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1582. buf_addr =
  1583. (HAL_RX_BUFFER_ADDR_31_0_GET(
  1584. rxdma_mon_status_ring_entry) |
  1585. ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(
  1586. rxdma_mon_status_ring_entry)) << 32));
  1587. if (qdf_likely(buf_addr)) {
  1588. rx_buf_cookie =
  1589. HAL_RX_BUF_COOKIE_GET(
  1590. rxdma_mon_status_ring_entry);
  1591. rx_desc = dp_rx_cookie_2_va_mon_status(soc,
  1592. rx_buf_cookie);
  1593. qdf_assert(rx_desc);
  1594. status_nbuf = rx_desc->nbuf;
  1595. qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf,
  1596. QDF_DMA_FROM_DEVICE);
  1597. status_buf = qdf_nbuf_data(status_nbuf);
  1598. status = hal_get_rx_status_done(status_buf);
  1599. if (status != QDF_STATUS_SUCCESS) {
  1600. uint32_t hp, tp;
  1601. hal_get_sw_hptp(hal_soc, mon_status_srng,
  1602. &tp, &hp);
  1603. dp_info_rl("tlv tag status error hp:%u, tp:%u",
  1604. hp, tp);
  1605. pdev->rx_mon_stats.tlv_tag_status_err++;
  1606. /* RxDMA status done bit might not be set even
  1607. * though tp is moved by HW.
  1608. * So Hold on to current entry on
  1609. * monitor status ring
  1610. */
  1611. /* If done status is missing, hold onto status
  1612. * ring until status is done for this status
  1613. * ring buffer.
  1614. * Keep HP in mon_status_ring unchanged,
  1615. * and break from here.
  1616. * Check status for same buffer for next time
  1617. * dp_rx_mon_status_srng_process
  1618. */
  1619. break;
  1620. }
  1621. qdf_nbuf_set_pktlen(status_nbuf, RX_DATA_BUFFER_SIZE);
  1622. qdf_nbuf_unmap_nbytes_single(soc->osdev, status_nbuf,
  1623. QDF_DMA_FROM_DEVICE,
  1624. rx_desc_pool->buf_size);
  1625. /* Put the status_nbuf to queue */
  1626. qdf_nbuf_queue_add(&pdev->rx_status_q, status_nbuf);
  1627. } else {
  1628. union dp_rx_desc_list_elem_t *desc_list = NULL;
  1629. union dp_rx_desc_list_elem_t *tail = NULL;
  1630. uint32_t num_alloc_desc;
  1631. num_alloc_desc = dp_rx_get_free_desc_list(soc, mac_id,
  1632. rx_desc_pool,
  1633. 1,
  1634. &desc_list,
  1635. &tail);
  1636. /*
  1637. * No free descriptors available
  1638. */
  1639. if (qdf_unlikely(num_alloc_desc == 0)) {
  1640. work_done++;
  1641. break;
  1642. }
  1643. rx_desc = &desc_list->rx_desc;
  1644. }
  1645. status_nbuf = dp_rx_nbuf_prepare(soc, pdev);
  1646. /*
  1647. * qdf_nbuf alloc or map failed,
  1648. * free the dp rx desc to free list,
  1649. * fill in NULL dma address at current HP entry,
  1650. * keep HP in mon_status_ring unchanged,
  1651. * wait next time dp_rx_mon_status_srng_process
  1652. * to fill in buffer at current HP.
  1653. */
  1654. if (qdf_unlikely(!status_nbuf)) {
  1655. union dp_rx_desc_list_elem_t *desc_list = NULL;
  1656. union dp_rx_desc_list_elem_t *tail = NULL;
  1657. struct rx_desc_pool *rx_desc_pool;
  1658. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1659. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1660. "%s: fail to allocate or map qdf_nbuf",
  1661. __func__);
  1662. dp_rx_add_to_free_desc_list(&desc_list,
  1663. &tail, rx_desc);
  1664. dp_rx_add_desc_list_to_free_list(soc, &desc_list,
  1665. &tail, mac_id, rx_desc_pool);
  1666. hal_rxdma_buff_addr_info_set(
  1667. rxdma_mon_status_ring_entry,
  1668. 0, 0, HAL_RX_BUF_RBM_SW3_BM);
  1669. work_done++;
  1670. break;
  1671. }
  1672. paddr = qdf_nbuf_get_frag_paddr(status_nbuf, 0);
  1673. rx_desc->nbuf = status_nbuf;
  1674. rx_desc->in_use = 1;
  1675. hal_rxdma_buff_addr_info_set(rxdma_mon_status_ring_entry,
  1676. paddr, rx_desc->cookie, HAL_RX_BUF_RBM_SW3_BM);
  1677. hal_srng_src_get_next(hal_soc, mon_status_srng);
  1678. work_done++;
  1679. }
  1680. done:
  1681. hal_srng_access_end(hal_soc, mon_status_srng);
  1682. return work_done;
  1683. }
  1684. /*
  1685. * dp_rx_mon_status_process() - Process monitor status ring and
  1686. * TLV in status ring.
  1687. *
  1688. * @soc: core txrx main context
  1689. * @mac_id: mac_id which is one of 3 mac_ids
  1690. * @quota: No. of ring entry that can be serviced in one shot.
  1691. * Return: uint32_t: No. of ring entry that is processed.
  1692. */
  1693. uint32_t
  1694. dp_rx_mon_status_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
  1695. uint32_t work_done;
  1696. work_done = dp_rx_mon_status_srng_process(soc, mac_id, quota);
  1697. quota -= work_done;
  1698. dp_rx_mon_status_process_tlv(soc, mac_id, quota);
  1699. return work_done;
  1700. }
  1701. /**
  1702. * dp_mon_process() - Main monitor mode processing roution.
  1703. * This call monitor status ring process then monitor
  1704. * destination ring process.
  1705. * Called from the bottom half (tasklet/NET_RX_SOFTIRQ)
  1706. * @soc: core txrx main context
  1707. * @mac_id: mac_id which is one of 3 mac_ids
  1708. * @quota: No. of status ring entry that can be serviced in one shot.
  1709. * Return: uint32_t: No. of ring entry that is processed.
  1710. */
  1711. uint32_t
  1712. dp_mon_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
  1713. if (qdf_unlikely(soc->full_mon_mode))
  1714. return dp_rx_mon_process(soc, mac_id, quota);
  1715. return dp_rx_mon_status_process(soc, mac_id, quota);
  1716. }
  1717. QDF_STATUS
  1718. dp_rx_pdev_mon_status_buffers_alloc(struct dp_pdev *pdev, uint32_t mac_id)
  1719. {
  1720. uint8_t pdev_id = pdev->pdev_id;
  1721. struct dp_soc *soc = pdev->soc;
  1722. struct dp_srng *mon_status_ring;
  1723. uint32_t num_entries;
  1724. struct rx_desc_pool *rx_desc_pool;
  1725. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  1726. union dp_rx_desc_list_elem_t *desc_list = NULL;
  1727. union dp_rx_desc_list_elem_t *tail = NULL;
  1728. soc_cfg_ctx = soc->wlan_cfg_ctx;
  1729. mon_status_ring = &soc->rxdma_mon_status_ring[mac_id];
  1730. num_entries = mon_status_ring->num_entries;
  1731. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1732. dp_debug("Mon RX Desc Pool[%d] entries=%u",
  1733. pdev_id, num_entries);
  1734. return dp_rx_mon_status_buffers_replenish(soc, mac_id, mon_status_ring,
  1735. rx_desc_pool, num_entries,
  1736. &desc_list, &tail,
  1737. HAL_RX_BUF_RBM_SW3_BM);
  1738. }
  1739. QDF_STATUS
  1740. dp_rx_pdev_mon_status_desc_pool_alloc(struct dp_pdev *pdev, uint32_t mac_id)
  1741. {
  1742. uint8_t pdev_id = pdev->pdev_id;
  1743. struct dp_soc *soc = pdev->soc;
  1744. struct dp_srng *mon_status_ring;
  1745. uint32_t num_entries;
  1746. struct rx_desc_pool *rx_desc_pool;
  1747. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  1748. soc_cfg_ctx = soc->wlan_cfg_ctx;
  1749. mon_status_ring = &soc->rxdma_mon_status_ring[mac_id];
  1750. num_entries = mon_status_ring->num_entries;
  1751. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1752. dp_debug("Mon RX Desc Pool[%d] entries=%u", pdev_id, num_entries);
  1753. return dp_rx_desc_pool_alloc(soc, num_entries + 1, rx_desc_pool);
  1754. }
  1755. void
  1756. dp_rx_pdev_mon_status_desc_pool_init(struct dp_pdev *pdev, uint32_t mac_id)
  1757. {
  1758. uint32_t i;
  1759. uint8_t pdev_id = pdev->pdev_id;
  1760. struct dp_soc *soc = pdev->soc;
  1761. struct dp_srng *mon_status_ring;
  1762. uint32_t num_entries;
  1763. struct rx_desc_pool *rx_desc_pool;
  1764. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  1765. soc_cfg_ctx = soc->wlan_cfg_ctx;
  1766. mon_status_ring = &soc->rxdma_mon_status_ring[mac_id];
  1767. num_entries = mon_status_ring->num_entries;
  1768. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1769. dp_debug("Mon RX Desc status Pool[%d] init entries=%u",
  1770. pdev_id, num_entries);
  1771. rx_desc_pool->owner = HAL_RX_BUF_RBM_SW3_BM;
  1772. rx_desc_pool->buf_size = RX_DATA_BUFFER_SIZE;
  1773. rx_desc_pool->buf_alignment = RX_DATA_BUFFER_ALIGNMENT;
  1774. dp_rx_desc_pool_init(soc, mac_id, num_entries + 1, rx_desc_pool);
  1775. qdf_nbuf_queue_init(&pdev->rx_status_q);
  1776. pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  1777. qdf_mem_zero(&pdev->ppdu_info.rx_status,
  1778. sizeof(pdev->ppdu_info.rx_status));
  1779. qdf_mem_zero(&pdev->rx_mon_stats, sizeof(pdev->rx_mon_stats));
  1780. dp_rx_mon_init_dbg_ppdu_stats(&pdev->ppdu_info,
  1781. &pdev->rx_mon_stats);
  1782. for (i = 0; i < MAX_MU_USERS; i++) {
  1783. qdf_nbuf_queue_init(&pdev->mpdu_q[i]);
  1784. pdev->is_mpdu_hdr[i] = true;
  1785. }
  1786. qdf_mem_zero(pdev->msdu_list, sizeof(pdev->msdu_list[MAX_MU_USERS]));
  1787. pdev->rx_enh_capture_mode = CDP_RX_ENH_CAPTURE_DISABLED;
  1788. }
  1789. void
  1790. dp_rx_pdev_mon_status_desc_pool_deinit(struct dp_pdev *pdev, uint32_t mac_id) {
  1791. uint8_t pdev_id = pdev->pdev_id;
  1792. struct dp_soc *soc = pdev->soc;
  1793. struct rx_desc_pool *rx_desc_pool;
  1794. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1795. dp_debug("Mon RX Desc status Pool[%d] deinit", pdev_id);
  1796. dp_rx_desc_pool_deinit(soc, rx_desc_pool);
  1797. }
  1798. void
  1799. dp_rx_pdev_mon_status_desc_pool_free(struct dp_pdev *pdev, uint32_t mac_id) {
  1800. uint8_t pdev_id = pdev->pdev_id;
  1801. struct dp_soc *soc = pdev->soc;
  1802. struct rx_desc_pool *rx_desc_pool;
  1803. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1804. dp_debug("Mon RX Status Desc Pool Free pdev[%d]", pdev_id);
  1805. dp_rx_desc_pool_free(soc, rx_desc_pool);
  1806. }
  1807. void
  1808. dp_rx_pdev_mon_status_buffers_free(struct dp_pdev *pdev, uint32_t mac_id)
  1809. {
  1810. uint8_t pdev_id = pdev->pdev_id;
  1811. struct dp_soc *soc = pdev->soc;
  1812. struct rx_desc_pool *rx_desc_pool;
  1813. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1814. dp_debug("Mon RX Status Desc Pool Free pdev[%d]", pdev_id);
  1815. dp_rx_desc_nbuf_free(soc, rx_desc_pool);
  1816. }
  1817. /*
  1818. * dp_rx_buffers_replenish() - replenish monitor status ring with
  1819. * rx nbufs called during dp rx
  1820. * monitor status ring initialization
  1821. *
  1822. * @soc: core txrx main context
  1823. * @mac_id: mac_id which is one of 3 mac_ids
  1824. * @dp_rxdma_srng: dp monitor status circular ring
  1825. * @rx_desc_pool; Pointer to Rx descriptor pool
  1826. * @num_req_buffers: number of buffer to be replenished
  1827. * @desc_list: list of descs if called from dp rx monitor status
  1828. * process or NULL during dp rx initialization or
  1829. * out of buffer interrupt
  1830. * @tail: tail of descs list
  1831. * @owner: who owns the nbuf (host, NSS etc...)
  1832. * Return: return success or failure
  1833. */
  1834. static inline
  1835. QDF_STATUS dp_rx_mon_status_buffers_replenish(struct dp_soc *dp_soc,
  1836. uint32_t mac_id,
  1837. struct dp_srng *dp_rxdma_srng,
  1838. struct rx_desc_pool *rx_desc_pool,
  1839. uint32_t num_req_buffers,
  1840. union dp_rx_desc_list_elem_t **desc_list,
  1841. union dp_rx_desc_list_elem_t **tail,
  1842. uint8_t owner)
  1843. {
  1844. uint32_t num_alloc_desc;
  1845. uint16_t num_desc_to_free = 0;
  1846. uint32_t num_entries_avail;
  1847. uint32_t count = 0;
  1848. int sync_hw_ptr = 1;
  1849. qdf_dma_addr_t paddr;
  1850. qdf_nbuf_t rx_netbuf;
  1851. void *rxdma_ring_entry;
  1852. union dp_rx_desc_list_elem_t *next;
  1853. void *rxdma_srng;
  1854. struct dp_pdev *dp_pdev = dp_get_pdev_for_lmac_id(dp_soc, mac_id);
  1855. if (!dp_pdev) {
  1856. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1857. "pdev is null for mac_id = %d", mac_id);
  1858. return QDF_STATUS_E_FAILURE;
  1859. }
  1860. rxdma_srng = dp_rxdma_srng->hal_srng;
  1861. qdf_assert(rxdma_srng);
  1862. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1863. "[%s][%d] requested %d buffers for replenish",
  1864. __func__, __LINE__, num_req_buffers);
  1865. /*
  1866. * if desc_list is NULL, allocate the descs from freelist
  1867. */
  1868. if (!(*desc_list)) {
  1869. num_alloc_desc = dp_rx_get_free_desc_list(dp_soc, mac_id,
  1870. rx_desc_pool,
  1871. num_req_buffers,
  1872. desc_list,
  1873. tail);
  1874. if (!num_alloc_desc) {
  1875. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1876. "[%s][%d] no free rx_descs in freelist",
  1877. __func__, __LINE__);
  1878. return QDF_STATUS_E_NOMEM;
  1879. }
  1880. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1881. "[%s][%d] %d rx desc allocated", __func__, __LINE__,
  1882. num_alloc_desc);
  1883. num_req_buffers = num_alloc_desc;
  1884. }
  1885. hal_srng_access_start(dp_soc->hal_soc, rxdma_srng);
  1886. num_entries_avail = hal_srng_src_num_avail(dp_soc->hal_soc,
  1887. rxdma_srng, sync_hw_ptr);
  1888. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1889. "[%s][%d] no of available entries in rxdma ring: %d",
  1890. __func__, __LINE__, num_entries_avail);
  1891. if (num_entries_avail < num_req_buffers) {
  1892. num_desc_to_free = num_req_buffers - num_entries_avail;
  1893. num_req_buffers = num_entries_avail;
  1894. }
  1895. while (count <= num_req_buffers) {
  1896. rx_netbuf = dp_rx_nbuf_prepare(dp_soc, dp_pdev);
  1897. /*
  1898. * qdf_nbuf alloc or map failed,
  1899. * keep HP in mon_status_ring unchanged,
  1900. * wait dp_rx_mon_status_srng_process
  1901. * to fill in buffer at current HP.
  1902. */
  1903. if (qdf_unlikely(!rx_netbuf)) {
  1904. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1905. "%s: qdf_nbuf allocate or map fail, count %d",
  1906. __func__, count);
  1907. break;
  1908. }
  1909. paddr = qdf_nbuf_get_frag_paddr(rx_netbuf, 0);
  1910. next = (*desc_list)->next;
  1911. rxdma_ring_entry = hal_srng_src_get_cur_hp_n_move_next(
  1912. dp_soc->hal_soc,
  1913. rxdma_srng);
  1914. if (qdf_unlikely(!rxdma_ring_entry)) {
  1915. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1916. "[%s][%d] rxdma_ring_entry is NULL, count - %d",
  1917. __func__, __LINE__, count);
  1918. qdf_nbuf_unmap_nbytes_single(dp_soc->osdev, rx_netbuf,
  1919. QDF_DMA_FROM_DEVICE,
  1920. rx_desc_pool->buf_size);
  1921. qdf_nbuf_free(rx_netbuf);
  1922. break;
  1923. }
  1924. (*desc_list)->rx_desc.nbuf = rx_netbuf;
  1925. (*desc_list)->rx_desc.in_use = 1;
  1926. count++;
  1927. hal_rxdma_buff_addr_info_set(rxdma_ring_entry, paddr,
  1928. (*desc_list)->rx_desc.cookie, owner);
  1929. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1930. "[%s][%d] rx_desc=%pK, cookie=%d, nbuf=%pK, \
  1931. paddr=%pK",
  1932. __func__, __LINE__, &(*desc_list)->rx_desc,
  1933. (*desc_list)->rx_desc.cookie, rx_netbuf,
  1934. (void *)paddr);
  1935. *desc_list = next;
  1936. }
  1937. hal_srng_access_end(dp_soc->hal_soc, rxdma_srng);
  1938. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1939. "successfully replenished %d buffers", num_req_buffers);
  1940. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1941. "%d rx desc added back to free list", num_desc_to_free);
  1942. /*
  1943. * add any available free desc back to the free list
  1944. */
  1945. if (*desc_list) {
  1946. dp_rx_add_desc_list_to_free_list(dp_soc, desc_list, tail,
  1947. mac_id, rx_desc_pool);
  1948. }
  1949. return QDF_STATUS_SUCCESS;
  1950. }