dp_rx_mon_status.c 57 KB

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