dp_rx_mon.c 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913
  1. /*
  2. * Copyright (c) 2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #include "hal_hw_headers.h"
  20. #include "dp_types.h"
  21. #include "dp_rx.h"
  22. #include "dp_peer.h"
  23. #include "hal_rx.h"
  24. #include "hal_api.h"
  25. #include "qdf_trace.h"
  26. #include "qdf_nbuf.h"
  27. #include "hal_api_mon.h"
  28. #include "dp_internal.h"
  29. #include "qdf_mem.h" /* qdf_mem_malloc,free */
  30. #include "dp_htt.h"
  31. #include "dp_mon.h"
  32. #include "dp_rx_mon.h"
  33. #include "htt.h"
  34. #ifdef FEATURE_PERPKT_INFO
  35. #include "dp_ratetable.h"
  36. #endif
  37. #ifndef IEEE80211_FCO_SUBTYPE_ACTION_NO_ACK
  38. #define IEEE80211_FCO_SUBTYPE_ACTION_NO_ACK 0xe0
  39. #endif
  40. #if defined(WLAN_CFR_ENABLE) && defined(WLAN_ENH_CFR_ENABLE)
  41. void
  42. dp_rx_mon_handle_cfr_mu_info(struct dp_pdev *pdev,
  43. struct hal_rx_ppdu_info *ppdu_info,
  44. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  45. {
  46. struct dp_peer *peer;
  47. struct dp_soc *soc = pdev->soc;
  48. struct mon_rx_user_status *rx_user_status;
  49. struct cdp_rx_stats_ppdu_user *rx_stats_peruser;
  50. uint32_t num_users;
  51. int user_id;
  52. uint16_t sw_peer_id;
  53. num_users = ppdu_info->com_info.num_users;
  54. for (user_id = 0; user_id < num_users; user_id++) {
  55. if (user_id > OFDMA_NUM_USERS) {
  56. return;
  57. }
  58. rx_user_status = &ppdu_info->rx_user_status[user_id];
  59. rx_stats_peruser = &cdp_rx_ppdu->user[user_id];
  60. sw_peer_id = rx_user_status->sw_peer_id;
  61. peer = dp_peer_get_ref_by_id(soc, sw_peer_id,
  62. DP_MOD_ID_RX_PPDU_STATS);
  63. if (!peer) {
  64. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  65. continue;
  66. }
  67. qdf_mem_copy(rx_stats_peruser->mac_addr,
  68. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  69. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  70. }
  71. }
  72. void
  73. dp_rx_mon_populate_cfr_ppdu_info(struct dp_pdev *pdev,
  74. struct hal_rx_ppdu_info *ppdu_info,
  75. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  76. {
  77. struct dp_peer *peer;
  78. struct dp_ast_entry *ast_entry;
  79. struct dp_soc *soc = pdev->soc;
  80. uint32_t ast_index;
  81. int chain;
  82. cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
  83. cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
  84. cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
  85. for (chain = 0; chain < MAX_CHAIN; chain++)
  86. cdp_rx_ppdu->per_chain_rssi[chain] =
  87. ppdu_info->rx_status.rssi[chain];
  88. cdp_rx_ppdu->u.ltf_size = ppdu_info->rx_status.ltf_size;
  89. cdp_rx_ppdu->beamformed = ppdu_info->rx_status.beamformed;
  90. cdp_rx_ppdu->u.ldpc = ppdu_info->rx_status.ldpc;
  91. if ((ppdu_info->rx_status.sgi == VHT_SGI_NYSM) &&
  92. (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC))
  93. cdp_rx_ppdu->u.gi = CDP_SGI_0_4_US;
  94. else
  95. cdp_rx_ppdu->u.gi = ppdu_info->rx_status.sgi;
  96. if (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC) {
  97. cdp_rx_ppdu->u.stbc = ppdu_info->rx_status.is_stbc;
  98. } else if (ppdu_info->rx_status.preamble_type ==
  99. HAL_RX_PKT_TYPE_11AX) {
  100. cdp_rx_ppdu->u.stbc = (ppdu_info->rx_status.he_data3 >>
  101. QDF_MON_STATUS_STBC_SHIFT) & 0x1;
  102. cdp_rx_ppdu->u.dcm = (ppdu_info->rx_status.he_data3 >>
  103. QDF_MON_STATUS_DCM_SHIFT) & 0x1;
  104. }
  105. dp_rx_mon_handle_cfr_mu_info(pdev, ppdu_info, cdp_rx_ppdu);
  106. ast_index = ppdu_info->rx_status.ast_index;
  107. if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  108. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  109. cdp_rx_ppdu->num_users = 0;
  110. return;
  111. }
  112. ast_entry = soc->ast_table[ast_index];
  113. if (!ast_entry || ast_entry->peer_id == HTT_INVALID_PEER) {
  114. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  115. cdp_rx_ppdu->num_users = 0;
  116. return;
  117. }
  118. peer = dp_peer_get_ref_by_id(soc, ast_entry->peer_id,
  119. DP_MOD_ID_RX_PPDU_STATS);
  120. if (!peer) {
  121. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  122. cdp_rx_ppdu->num_users = 0;
  123. return;
  124. }
  125. cdp_rx_ppdu->peer_id = peer->peer_id;
  126. cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
  127. cdp_rx_ppdu->num_users = ppdu_info->com_info.num_users;
  128. }
  129. bool
  130. dp_cfr_rcc_mode_status(struct dp_pdev *pdev)
  131. {
  132. return pdev->cfr_rcc_mode;
  133. }
  134. void
  135. dp_rx_mon_populate_cfr_info(struct dp_pdev *pdev,
  136. struct hal_rx_ppdu_info *ppdu_info,
  137. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  138. {
  139. struct cdp_rx_ppdu_cfr_info *cfr_info;
  140. if (!dp_cfr_rcc_mode_status(pdev))
  141. return;
  142. cfr_info = &cdp_rx_ppdu->cfr_info;
  143. cfr_info->bb_captured_channel
  144. = ppdu_info->cfr_info.bb_captured_channel;
  145. cfr_info->bb_captured_timeout
  146. = ppdu_info->cfr_info.bb_captured_timeout;
  147. cfr_info->bb_captured_reason
  148. = ppdu_info->cfr_info.bb_captured_reason;
  149. cfr_info->rx_location_info_valid
  150. = ppdu_info->cfr_info.rx_location_info_valid;
  151. cfr_info->chan_capture_status
  152. = ppdu_info->cfr_info.chan_capture_status;
  153. cfr_info->rtt_che_buffer_pointer_high8
  154. = ppdu_info->cfr_info.rtt_che_buffer_pointer_high8;
  155. cfr_info->rtt_che_buffer_pointer_low32
  156. = ppdu_info->cfr_info.rtt_che_buffer_pointer_low32;
  157. cfr_info->rtt_cfo_measurement
  158. = (int16_t)ppdu_info->cfr_info.rtt_cfo_measurement;
  159. cfr_info->agc_gain_info0
  160. = ppdu_info->cfr_info.agc_gain_info0;
  161. cfr_info->agc_gain_info1
  162. = ppdu_info->cfr_info.agc_gain_info1;
  163. cfr_info->agc_gain_info2
  164. = ppdu_info->cfr_info.agc_gain_info2;
  165. cfr_info->agc_gain_info3
  166. = ppdu_info->cfr_info.agc_gain_info3;
  167. cfr_info->rx_start_ts
  168. = ppdu_info->cfr_info.rx_start_ts;
  169. cfr_info->mcs_rate
  170. = ppdu_info->cfr_info.mcs_rate;
  171. cfr_info->gi_type
  172. = ppdu_info->cfr_info.gi_type;
  173. }
  174. void
  175. dp_update_cfr_dbg_stats(struct dp_pdev *pdev,
  176. struct hal_rx_ppdu_info *ppdu_info)
  177. {
  178. struct hal_rx_ppdu_cfr_info *cfr = &ppdu_info->cfr_info;
  179. DP_STATS_INC(pdev,
  180. rcc.chan_capture_status[cfr->chan_capture_status], 1);
  181. if (cfr->rx_location_info_valid) {
  182. DP_STATS_INC(pdev, rcc.rx_loc_info_valid_cnt, 1);
  183. if (cfr->bb_captured_channel) {
  184. DP_STATS_INC(pdev, rcc.bb_captured_channel_cnt, 1);
  185. DP_STATS_INC(pdev,
  186. rcc.reason_cnt[cfr->bb_captured_reason],
  187. 1);
  188. } else if (cfr->bb_captured_timeout) {
  189. DP_STATS_INC(pdev, rcc.bb_captured_timeout_cnt, 1);
  190. DP_STATS_INC(pdev,
  191. rcc.reason_cnt[cfr->bb_captured_reason],
  192. 1);
  193. }
  194. }
  195. }
  196. void
  197. dp_rx_handle_cfr(struct dp_soc *soc, struct dp_pdev *pdev,
  198. struct hal_rx_ppdu_info *ppdu_info)
  199. {
  200. qdf_nbuf_t ppdu_nbuf;
  201. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  202. dp_update_cfr_dbg_stats(pdev, ppdu_info);
  203. if (!ppdu_info->cfr_info.bb_captured_channel)
  204. return;
  205. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  206. sizeof(struct cdp_rx_indication_ppdu),
  207. 0,
  208. 0,
  209. FALSE);
  210. if (ppdu_nbuf) {
  211. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
  212. dp_rx_mon_populate_cfr_info(pdev, ppdu_info, cdp_rx_ppdu);
  213. dp_rx_mon_populate_cfr_ppdu_info(pdev, ppdu_info, cdp_rx_ppdu);
  214. qdf_nbuf_put_tail(ppdu_nbuf,
  215. sizeof(struct cdp_rx_indication_ppdu));
  216. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
  217. ppdu_nbuf, HTT_INVALID_PEER,
  218. WDI_NO_VAL, pdev->pdev_id);
  219. }
  220. }
  221. void
  222. dp_rx_populate_cfr_non_assoc_sta(struct dp_pdev *pdev,
  223. struct hal_rx_ppdu_info *ppdu_info,
  224. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  225. {
  226. if (!dp_cfr_rcc_mode_status(pdev))
  227. return;
  228. if (ppdu_info->cfr_info.bb_captured_channel)
  229. dp_rx_mon_populate_cfr_ppdu_info(pdev, ppdu_info, cdp_rx_ppdu);
  230. }
  231. /**
  232. * dp_bb_captured_chan_status() - Get the bb_captured_channel status
  233. * @ppdu_info: structure for rx ppdu ring
  234. *
  235. * Return: Success/ Failure
  236. */
  237. static inline QDF_STATUS
  238. dp_bb_captured_chan_status(struct dp_pdev *pdev,
  239. struct hal_rx_ppdu_info *ppdu_info)
  240. {
  241. QDF_STATUS status = QDF_STATUS_E_FAILURE;
  242. struct hal_rx_ppdu_cfr_info *cfr = &ppdu_info->cfr_info;
  243. if (dp_cfr_rcc_mode_status(pdev)) {
  244. if (cfr->bb_captured_channel)
  245. status = QDF_STATUS_SUCCESS;
  246. }
  247. return status;
  248. }
  249. #else
  250. static inline QDF_STATUS
  251. dp_bb_captured_chan_status(struct dp_pdev *pdev,
  252. struct hal_rx_ppdu_info *ppdu_info)
  253. {
  254. return QDF_STATUS_E_NOSUPPORT;
  255. }
  256. #endif /* WLAN_CFR_ENABLE */
  257. #ifdef QCA_ENHANCED_STATS_SUPPORT
  258. void
  259. dp_rx_populate_rx_rssi_chain(struct hal_rx_ppdu_info *ppdu_info,
  260. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  261. {
  262. uint8_t chain, bw;
  263. uint8_t rssi;
  264. for (chain = 0; chain < SS_COUNT; chain++) {
  265. for (bw = 0; bw < MAX_BW; bw++) {
  266. rssi = ppdu_info->rx_status.rssi_chain[chain][bw];
  267. if (rssi != DP_RSSI_INVAL)
  268. cdp_rx_ppdu->rssi_chain[chain][bw] = rssi;
  269. else
  270. cdp_rx_ppdu->rssi_chain[chain][bw] = 0;
  271. }
  272. }
  273. }
  274. void
  275. dp_rx_populate_su_evm_details(struct hal_rx_ppdu_info *ppdu_info,
  276. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  277. {
  278. uint8_t pilot_evm;
  279. uint8_t nss_count;
  280. uint8_t pilot_count;
  281. nss_count = ppdu_info->evm_info.nss_count;
  282. pilot_count = ppdu_info->evm_info.pilot_count;
  283. if ((nss_count * pilot_count) > DP_RX_MAX_SU_EVM_COUNT) {
  284. qdf_err("pilot evm count is more than expected");
  285. return;
  286. }
  287. cdp_rx_ppdu->evm_info.pilot_count = pilot_count;
  288. cdp_rx_ppdu->evm_info.nss_count = nss_count;
  289. /* Populate evm for pilot_evm = nss_count*pilot_count */
  290. for (pilot_evm = 0; pilot_evm < nss_count * pilot_count; pilot_evm++) {
  291. cdp_rx_ppdu->evm_info.pilot_evm[pilot_evm] =
  292. ppdu_info->evm_info.pilot_evm[pilot_evm];
  293. }
  294. }
  295. /**
  296. * dp_rx_inc_rusize_cnt() - increment pdev stats based on RU size
  297. * @pdev: pdev ctx
  298. * @rx_user_status: mon rx user status
  299. *
  300. * Return: bool
  301. */
  302. static inline bool
  303. dp_rx_inc_rusize_cnt(struct dp_pdev *pdev,
  304. struct mon_rx_user_status *rx_user_status)
  305. {
  306. uint32_t ru_size;
  307. bool is_data;
  308. ru_size = rx_user_status->ofdma_ru_size;
  309. if (dp_is_subtype_data(rx_user_status->frame_control)) {
  310. DP_STATS_INC(pdev,
  311. ul_ofdma.data_rx_ru_size[ru_size], 1);
  312. is_data = true;
  313. } else {
  314. DP_STATS_INC(pdev,
  315. ul_ofdma.nondata_rx_ru_size[ru_size], 1);
  316. is_data = false;
  317. }
  318. return is_data;
  319. }
  320. /**
  321. * dp_rx_populate_cdp_indication_ppdu_user() - Populate per user cdp indication
  322. * @pdev: pdev ctx
  323. * @ppdu_info: ppdu info structure from ppdu ring
  324. * @cdp_rx_ppdu: Rx PPDU indication structure
  325. *
  326. * Return: none
  327. */
  328. static void
  329. dp_rx_populate_cdp_indication_ppdu_user(struct dp_pdev *pdev,
  330. struct hal_rx_ppdu_info *ppdu_info,
  331. struct cdp_rx_indication_ppdu
  332. *cdp_rx_ppdu)
  333. {
  334. struct dp_peer *peer;
  335. struct dp_soc *soc = pdev->soc;
  336. int i;
  337. struct mon_rx_user_status *rx_user_status;
  338. struct mon_rx_user_info *rx_user_info;
  339. struct cdp_rx_stats_ppdu_user *rx_stats_peruser;
  340. int ru_size;
  341. bool is_data = false;
  342. uint32_t num_users;
  343. struct dp_mon_ops *mon_ops;
  344. uint16_t sw_peer_id;
  345. num_users = ppdu_info->com_info.num_users;
  346. for (i = 0; i < num_users; i++) {
  347. if (i > OFDMA_NUM_USERS)
  348. return;
  349. rx_user_status = &ppdu_info->rx_user_status[i];
  350. rx_user_info = &ppdu_info->rx_user_info[i];
  351. rx_stats_peruser = &cdp_rx_ppdu->user[i];
  352. sw_peer_id = rx_user_status->sw_peer_id;
  353. peer = dp_peer_get_ref_by_id(soc, sw_peer_id,
  354. DP_MOD_ID_RX_PPDU_STATS);
  355. if (!peer) {
  356. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  357. continue;
  358. }
  359. rx_stats_peruser->is_bss_peer = peer->bss_peer;
  360. rx_stats_peruser->first_data_seq_ctrl =
  361. rx_user_status->first_data_seq_ctrl;
  362. rx_stats_peruser->frame_control_info_valid =
  363. rx_user_status->frame_control_info_valid;
  364. rx_stats_peruser->frame_control =
  365. rx_user_status->frame_control;
  366. rx_stats_peruser->qos_control_info_valid =
  367. rx_user_info->qos_control_info_valid;
  368. rx_stats_peruser->qos_control =
  369. rx_user_info->qos_control;
  370. rx_stats_peruser->tcp_msdu_count =
  371. rx_user_status->tcp_msdu_count;
  372. rx_stats_peruser->udp_msdu_count =
  373. rx_user_status->udp_msdu_count;
  374. rx_stats_peruser->other_msdu_count =
  375. rx_user_status->other_msdu_count;
  376. rx_stats_peruser->num_msdu =
  377. rx_stats_peruser->tcp_msdu_count +
  378. rx_stats_peruser->udp_msdu_count +
  379. rx_stats_peruser->other_msdu_count;
  380. rx_stats_peruser->preamble_type =
  381. cdp_rx_ppdu->u.preamble;
  382. rx_stats_peruser->mpdu_cnt_fcs_ok =
  383. rx_user_status->mpdu_cnt_fcs_ok;
  384. rx_stats_peruser->mpdu_cnt_fcs_err =
  385. rx_user_status->mpdu_cnt_fcs_err;
  386. qdf_mem_copy(&rx_stats_peruser->mpdu_fcs_ok_bitmap,
  387. &rx_user_status->mpdu_fcs_ok_bitmap,
  388. HAL_RX_NUM_WORDS_PER_PPDU_BITMAP *
  389. sizeof(rx_user_status->mpdu_fcs_ok_bitmap[0]));
  390. rx_stats_peruser->mpdu_ok_byte_count =
  391. rx_user_status->mpdu_ok_byte_count;
  392. rx_stats_peruser->mpdu_err_byte_count =
  393. rx_user_status->mpdu_err_byte_count;
  394. cdp_rx_ppdu->num_mpdu += rx_user_status->mpdu_cnt_fcs_ok;
  395. cdp_rx_ppdu->num_msdu += rx_stats_peruser->num_msdu;
  396. rx_stats_peruser->retries =
  397. CDP_FC_IS_RETRY_SET(rx_stats_peruser->frame_control) ?
  398. rx_stats_peruser->mpdu_cnt_fcs_ok : 0;
  399. cdp_rx_ppdu->retries += rx_stats_peruser->retries;
  400. if (rx_stats_peruser->mpdu_cnt_fcs_ok > 1)
  401. rx_stats_peruser->is_ampdu = 1;
  402. else
  403. rx_stats_peruser->is_ampdu = 0;
  404. rx_stats_peruser->tid = ppdu_info->rx_status.tid;
  405. qdf_mem_copy(rx_stats_peruser->mac_addr,
  406. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  407. rx_stats_peruser->peer_id = peer->peer_id;
  408. cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
  409. rx_stats_peruser->vdev_id = peer->vdev->vdev_id;
  410. rx_stats_peruser->mu_ul_info_valid = 0;
  411. mon_ops = dp_mon_ops_get(soc);
  412. if (mon_ops && mon_ops->mon_rx_populate_ppdu_usr_info)
  413. mon_ops->mon_rx_populate_ppdu_usr_info(rx_user_status,
  414. rx_stats_peruser);
  415. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  416. if (cdp_rx_ppdu->u.ppdu_type == HAL_RX_TYPE_MU_OFDMA ||
  417. cdp_rx_ppdu->u.ppdu_type == HAL_RX_TYPE_MU_MIMO) {
  418. if (rx_user_status->mu_ul_info_valid) {
  419. rx_stats_peruser->nss = rx_user_status->nss;
  420. rx_stats_peruser->mcs = rx_user_status->mcs;
  421. rx_stats_peruser->mu_ul_info_valid =
  422. rx_user_status->mu_ul_info_valid;
  423. rx_stats_peruser->ofdma_ru_start_index =
  424. rx_user_status->ofdma_ru_start_index;
  425. rx_stats_peruser->ofdma_ru_width =
  426. rx_user_status->ofdma_ru_width;
  427. rx_stats_peruser->user_index = i;
  428. ru_size = rx_user_status->ofdma_ru_size;
  429. /*
  430. * max RU size will be equal to
  431. * HTT_UL_OFDMA_V0_RU_SIZE_RU_996x2
  432. */
  433. if (ru_size >= OFDMA_NUM_RU_SIZE) {
  434. dp_err("invalid ru_size %d\n",
  435. ru_size);
  436. return;
  437. }
  438. is_data = dp_rx_inc_rusize_cnt(pdev,
  439. rx_user_status);
  440. }
  441. if (is_data) {
  442. /* counter to get number of MU OFDMA */
  443. pdev->stats.ul_ofdma.data_rx_ppdu++;
  444. pdev->stats.ul_ofdma.data_users[num_users]++;
  445. }
  446. }
  447. }
  448. }
  449. /**
  450. * dp_rx_populate_cdp_indication_ppdu() - Populate cdp rx indication structure
  451. * @pdev: pdev ctx
  452. * @ppdu_info: ppdu info structure from ppdu ring
  453. * @cdp_rx_ppdu: Rx PPDU indication structure
  454. *
  455. * Return: none
  456. */
  457. static void
  458. dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
  459. struct hal_rx_ppdu_info *ppdu_info,
  460. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  461. {
  462. struct dp_peer *peer;
  463. struct dp_soc *soc = pdev->soc;
  464. uint32_t i;
  465. struct dp_mon_ops *mon_ops;
  466. uint16_t sw_peer_id;
  467. struct mon_rx_user_status *rx_user_status;
  468. uint32_t num_users = ppdu_info->com_info.num_users;
  469. cdp_rx_ppdu->first_data_seq_ctrl =
  470. ppdu_info->rx_status.first_data_seq_ctrl;
  471. cdp_rx_ppdu->frame_ctrl =
  472. ppdu_info->rx_status.frame_control;
  473. cdp_rx_ppdu->tcp_msdu_count = ppdu_info->rx_status.tcp_msdu_count;
  474. cdp_rx_ppdu->udp_msdu_count = ppdu_info->rx_status.udp_msdu_count;
  475. cdp_rx_ppdu->other_msdu_count = ppdu_info->rx_status.other_msdu_count;
  476. /* num mpdu is consolidated and added together in num user loop */
  477. cdp_rx_ppdu->num_mpdu = ppdu_info->com_info.mpdu_cnt_fcs_ok;
  478. /* num msdu is consolidated and added together in num user loop */
  479. cdp_rx_ppdu->num_msdu = (cdp_rx_ppdu->tcp_msdu_count +
  480. cdp_rx_ppdu->udp_msdu_count +
  481. cdp_rx_ppdu->other_msdu_count);
  482. cdp_rx_ppdu->retries = CDP_FC_IS_RETRY_SET(cdp_rx_ppdu->frame_ctrl) ?
  483. ppdu_info->com_info.mpdu_cnt_fcs_ok : 0;
  484. if (ppdu_info->com_info.mpdu_cnt_fcs_ok > 1)
  485. cdp_rx_ppdu->is_ampdu = 1;
  486. else
  487. cdp_rx_ppdu->is_ampdu = 0;
  488. cdp_rx_ppdu->tid = ppdu_info->rx_status.tid;
  489. qdf_assert_always(num_users <= CDP_MU_MAX_USERS);
  490. rx_user_status = &ppdu_info->rx_user_status[num_users - 1];
  491. sw_peer_id = rx_user_status->sw_peer_id;
  492. peer = dp_peer_get_ref_by_id(soc, sw_peer_id,
  493. DP_MOD_ID_RX_PPDU_STATS);
  494. if (!peer) {
  495. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  496. cdp_rx_ppdu->num_users = 0;
  497. goto end;
  498. }
  499. qdf_mem_copy(cdp_rx_ppdu->mac_addr,
  500. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  501. cdp_rx_ppdu->peer_id = peer->peer_id;
  502. cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
  503. cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
  504. cdp_rx_ppdu->length = ppdu_info->rx_status.ppdu_len;
  505. cdp_rx_ppdu->duration = ppdu_info->rx_status.duration;
  506. cdp_rx_ppdu->u.nss = ppdu_info->rx_status.nss;
  507. cdp_rx_ppdu->u.mcs = ppdu_info->rx_status.mcs;
  508. if ((ppdu_info->rx_status.sgi == VHT_SGI_NYSM) &&
  509. (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC))
  510. cdp_rx_ppdu->u.gi = CDP_SGI_0_4_US;
  511. else
  512. cdp_rx_ppdu->u.gi = ppdu_info->rx_status.sgi;
  513. cdp_rx_ppdu->u.ldpc = ppdu_info->rx_status.ldpc;
  514. cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
  515. cdp_rx_ppdu->u.ltf_size = (ppdu_info->rx_status.he_data5 >>
  516. QDF_MON_STATUS_HE_LTF_SIZE_SHIFT) & 0x3;
  517. cdp_rx_ppdu->rssi = ppdu_info->rx_status.rssi_comb;
  518. cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
  519. cdp_rx_ppdu->channel = ppdu_info->rx_status.chan_num;
  520. cdp_rx_ppdu->beamformed = ppdu_info->rx_status.beamformed;
  521. cdp_rx_ppdu->num_bytes = ppdu_info->rx_status.ppdu_len;
  522. cdp_rx_ppdu->lsig_a = ppdu_info->rx_status.rate;
  523. cdp_rx_ppdu->u.ltf_size = ppdu_info->rx_status.ltf_size;
  524. if (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC) {
  525. cdp_rx_ppdu->u.stbc = ppdu_info->rx_status.is_stbc;
  526. } else if (ppdu_info->rx_status.preamble_type ==
  527. HAL_RX_PKT_TYPE_11AX) {
  528. cdp_rx_ppdu->u.stbc = (ppdu_info->rx_status.he_data3 >>
  529. QDF_MON_STATUS_STBC_SHIFT) & 0x1;
  530. cdp_rx_ppdu->u.dcm = (ppdu_info->rx_status.he_data3 >>
  531. QDF_MON_STATUS_DCM_SHIFT) & 0x1;
  532. }
  533. dp_rx_populate_rx_rssi_chain(ppdu_info, cdp_rx_ppdu);
  534. dp_rx_populate_su_evm_details(ppdu_info, cdp_rx_ppdu);
  535. cdp_rx_ppdu->rx_antenna = ppdu_info->rx_status.rx_antenna;
  536. mon_ops = dp_mon_ops_get(pdev->soc);
  537. if (mon_ops && mon_ops->mon_rx_populate_ppdu_info)
  538. mon_ops->mon_rx_populate_ppdu_info(ppdu_info,
  539. cdp_rx_ppdu);
  540. cdp_rx_ppdu->nf = ppdu_info->rx_status.chan_noise_floor;
  541. for (i = 0; i < MAX_CHAIN; i++)
  542. cdp_rx_ppdu->per_chain_rssi[i] = ppdu_info->rx_status.rssi[i];
  543. cdp_rx_ppdu->is_mcast_bcast = ppdu_info->nac_info.mcast_bcast;
  544. cdp_rx_ppdu->num_users = ppdu_info->com_info.num_users;
  545. cdp_rx_ppdu->num_mpdu = 0;
  546. cdp_rx_ppdu->num_msdu = 0;
  547. cdp_rx_ppdu->retries = 0;
  548. dp_rx_populate_cdp_indication_ppdu_user(pdev, ppdu_info, cdp_rx_ppdu);
  549. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  550. return;
  551. end:
  552. dp_rx_populate_cfr_non_assoc_sta(pdev, ppdu_info, cdp_rx_ppdu);
  553. }
  554. /**
  555. * dp_rx_stats_update() - Update per-peer statistics
  556. * @soc: Datapath SOC handle
  557. * @peer: Datapath peer handle
  558. * @ppdu: PPDU Descriptor
  559. *
  560. * Return: None
  561. */
  562. static inline void dp_rx_rate_stats_update(struct dp_peer *peer,
  563. struct cdp_rx_indication_ppdu *ppdu,
  564. uint32_t user)
  565. {
  566. uint32_t ratekbps = 0;
  567. uint32_t ppdu_rx_rate = 0;
  568. uint32_t nss = 0;
  569. uint8_t mcs = 0;
  570. uint32_t rix;
  571. uint16_t ratecode = 0;
  572. struct cdp_rx_stats_ppdu_user *ppdu_user = NULL;
  573. struct dp_mon_peer *mon_peer = NULL;
  574. if (!peer || !ppdu)
  575. return;
  576. mon_peer = peer->monitor_peer;
  577. ppdu_user = &ppdu->user[user];
  578. if (!mon_peer)
  579. return;
  580. if (ppdu->u.ppdu_type != HAL_RX_TYPE_SU) {
  581. if (ppdu_user->nss == 0)
  582. nss = 0;
  583. else
  584. nss = ppdu_user->nss - 1;
  585. mcs = ppdu_user->mcs;
  586. mon_peer->stats.rx.nss_info = ppdu_user->nss;
  587. mon_peer->stats.rx.mcs_info = ppdu_user->mcs;
  588. } else {
  589. if (ppdu->u.nss == 0)
  590. nss = 0;
  591. else
  592. nss = ppdu->u.nss - 1;
  593. mcs = ppdu->u.mcs;
  594. mon_peer->stats.rx.nss_info = ppdu->u.nss;
  595. mon_peer->stats.rx.mcs_info = ppdu->u.mcs;
  596. }
  597. ratekbps = dp_getrateindex(ppdu->u.gi,
  598. mcs,
  599. nss,
  600. ppdu->u.preamble,
  601. ppdu->u.bw,
  602. ppdu->punc_bw,
  603. &rix,
  604. &ratecode);
  605. if (!ratekbps) {
  606. ppdu->rix = 0;
  607. ppdu_user->rix = 0;
  608. ppdu->rx_ratekbps = 0;
  609. ppdu->rx_ratecode = 0;
  610. ppdu_user->rx_ratekbps = 0;
  611. return;
  612. }
  613. mon_peer->stats.rx.bw_info = ppdu->u.bw;
  614. mon_peer->stats.rx.gi_info = ppdu->u.gi;
  615. mon_peer->stats.rx.preamble_info = ppdu->u.preamble;
  616. ppdu->rix = rix;
  617. ppdu_user->rix = rix;
  618. DP_STATS_UPD(mon_peer, rx.last_rx_rate, ratekbps);
  619. mon_peer->stats.rx.avg_rx_rate =
  620. dp_ath_rate_lpf(mon_peer->stats.rx.avg_rx_rate, ratekbps);
  621. ppdu_rx_rate = dp_ath_rate_out(mon_peer->stats.rx.avg_rx_rate);
  622. DP_STATS_UPD(mon_peer, rx.rnd_avg_rx_rate, ppdu_rx_rate);
  623. ppdu->rx_ratekbps = ratekbps;
  624. ppdu->rx_ratecode = ratecode;
  625. ppdu_user->rx_ratekbps = ratekbps;
  626. if (peer->vdev)
  627. peer->vdev->stats.rx.last_rx_rate = ratekbps;
  628. }
  629. #ifdef WLAN_FEATURE_11BE
  630. static inline uint8_t dp_get_bw_offset_frm_bw(struct dp_soc *soc,
  631. enum CMN_BW_TYPES bw)
  632. {
  633. uint8_t pkt_bw_offset;
  634. switch (bw) {
  635. case CMN_BW_20MHZ:
  636. pkt_bw_offset = PKT_BW_GAIN_20MHZ;
  637. break;
  638. case CMN_BW_40MHZ:
  639. pkt_bw_offset = PKT_BW_GAIN_40MHZ;
  640. break;
  641. case CMN_BW_80MHZ:
  642. pkt_bw_offset = PKT_BW_GAIN_80MHZ;
  643. break;
  644. case CMN_BW_160MHZ:
  645. pkt_bw_offset = PKT_BW_GAIN_160MHZ;
  646. break;
  647. case CMN_BW_320MHZ:
  648. pkt_bw_offset = PKT_BW_GAIN_320MHZ;
  649. break;
  650. default:
  651. pkt_bw_offset = 0;
  652. dp_rx_mon_status_debug("%pK: Invalid BW index = %d",
  653. soc, bw);
  654. }
  655. return pkt_bw_offset;
  656. }
  657. #else
  658. static inline uint8_t dp_get_bw_offset_frm_bw(struct dp_soc *soc,
  659. enum CMN_BW_TYPES bw)
  660. {
  661. uint8_t pkt_bw_offset;
  662. switch (bw) {
  663. case CMN_BW_20MHZ:
  664. pkt_bw_offset = PKT_BW_GAIN_20MHZ;
  665. break;
  666. case CMN_BW_40MHZ:
  667. pkt_bw_offset = PKT_BW_GAIN_40MHZ;
  668. break;
  669. case CMN_BW_80MHZ:
  670. pkt_bw_offset = PKT_BW_GAIN_80MHZ;
  671. break;
  672. case CMN_BW_160MHZ:
  673. pkt_bw_offset = PKT_BW_GAIN_160MHZ;
  674. break;
  675. default:
  676. pkt_bw_offset = 0;
  677. dp_rx_mon_status_debug("%pK: Invalid BW index = %d",
  678. soc, bw);
  679. }
  680. return pkt_bw_offset;
  681. }
  682. #endif
  683. static void dp_rx_stats_update(struct dp_pdev *pdev,
  684. struct cdp_rx_indication_ppdu *ppdu)
  685. {
  686. struct dp_soc *soc = NULL;
  687. uint8_t mcs, preamble, ac = 0, nss, ppdu_type;
  688. uint32_t num_msdu;
  689. uint8_t pkt_bw_offset;
  690. struct dp_peer *peer;
  691. struct dp_mon_peer *mon_peer;
  692. struct cdp_rx_stats_ppdu_user *ppdu_user;
  693. uint32_t i;
  694. enum cdp_mu_packet_type mu_pkt_type;
  695. struct dp_mon_ops *mon_ops;
  696. struct dp_mon_pdev *mon_pdev = NULL;
  697. if (pdev)
  698. soc = pdev->soc;
  699. else
  700. return;
  701. if (!soc || soc->process_rx_status)
  702. return;
  703. mon_pdev = pdev->monitor_pdev;
  704. preamble = ppdu->u.preamble;
  705. ppdu_type = ppdu->u.ppdu_type;
  706. for (i = 0; i < ppdu->num_users && i < CDP_MU_MAX_USERS; i++) {
  707. peer = NULL;
  708. ppdu_user = &ppdu->user[i];
  709. peer = dp_peer_get_ref_by_id(soc, ppdu_user->peer_id,
  710. DP_MOD_ID_RX_PPDU_STATS);
  711. if (!peer)
  712. mon_peer = mon_pdev->invalid_mon_peer;
  713. else
  714. mon_peer = peer->monitor_peer;
  715. if (!mon_peer) {
  716. if (peer)
  717. dp_peer_unref_delete(peer,
  718. DP_MOD_ID_RX_PPDU_STATS);
  719. continue;
  720. }
  721. if ((preamble == DOT11_A) || (preamble == DOT11_B))
  722. ppdu->u.nss = 1;
  723. if (ppdu_type == HAL_RX_TYPE_SU) {
  724. mcs = ppdu->u.mcs;
  725. nss = ppdu->u.nss;
  726. } else {
  727. mcs = ppdu_user->mcs;
  728. nss = ppdu_user->nss;
  729. }
  730. num_msdu = ppdu_user->num_msdu;
  731. pkt_bw_offset = dp_get_bw_offset_frm_bw(soc, ppdu->u.bw);
  732. DP_STATS_UPD(mon_peer, rx.snr, (ppdu->rssi + pkt_bw_offset));
  733. if (mon_peer->stats.rx.avg_snr == CDP_INVALID_SNR)
  734. mon_peer->stats.rx.avg_snr =
  735. CDP_SNR_IN(mon_peer->stats.rx.snr);
  736. else
  737. CDP_SNR_UPDATE_AVG(mon_peer->stats.rx.avg_snr,
  738. mon_peer->stats.rx.snr);
  739. if (ppdu_type == HAL_RX_TYPE_SU) {
  740. if (nss) {
  741. DP_STATS_INC(mon_peer, rx.nss[nss - 1], num_msdu);
  742. DP_STATS_INC(mon_peer, rx.ppdu_nss[nss - 1], 1);
  743. }
  744. DP_STATS_INC(mon_peer, rx.mpdu_cnt_fcs_ok,
  745. ppdu_user->mpdu_cnt_fcs_ok);
  746. DP_STATS_INC(mon_peer, rx.mpdu_cnt_fcs_err,
  747. ppdu_user->mpdu_cnt_fcs_err);
  748. }
  749. if (ppdu_type >= HAL_RX_TYPE_MU_MIMO &&
  750. ppdu_type <= HAL_RX_TYPE_MU_OFDMA) {
  751. if (ppdu_type == HAL_RX_TYPE_MU_MIMO)
  752. mu_pkt_type = TXRX_TYPE_MU_MIMO;
  753. else
  754. mu_pkt_type = TXRX_TYPE_MU_OFDMA;
  755. if (nss) {
  756. DP_STATS_INC(mon_peer, rx.nss[nss - 1], num_msdu);
  757. DP_STATS_INC(mon_peer,
  758. rx.rx_mu[mu_pkt_type].ppdu_nss[nss - 1],
  759. 1);
  760. }
  761. DP_STATS_INC(mon_peer,
  762. rx.rx_mu[mu_pkt_type].mpdu_cnt_fcs_ok,
  763. ppdu_user->mpdu_cnt_fcs_ok);
  764. DP_STATS_INC(mon_peer,
  765. rx.rx_mu[mu_pkt_type].mpdu_cnt_fcs_err,
  766. ppdu_user->mpdu_cnt_fcs_err);
  767. }
  768. DP_STATS_INC(mon_peer, rx.sgi_count[ppdu->u.gi], num_msdu);
  769. DP_STATS_INC(mon_peer, rx.bw[ppdu->u.bw], num_msdu);
  770. DP_STATS_INC(mon_peer, rx.reception_type[ppdu->u.ppdu_type],
  771. num_msdu);
  772. DP_STATS_INC(mon_peer, rx.ppdu_cnt[ppdu->u.ppdu_type], 1);
  773. DP_STATS_INCC(mon_peer, rx.ampdu_cnt, num_msdu,
  774. ppdu_user->is_ampdu);
  775. DP_STATS_INCC(mon_peer, rx.non_ampdu_cnt, num_msdu,
  776. !(ppdu_user->is_ampdu));
  777. DP_STATS_UPD(mon_peer, rx.rx_rate, mcs);
  778. DP_STATS_INCC(mon_peer,
  779. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  780. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
  781. DP_STATS_INCC(mon_peer,
  782. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  783. ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
  784. DP_STATS_INCC(mon_peer,
  785. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  786. ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B)));
  787. DP_STATS_INCC(mon_peer,
  788. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  789. ((mcs < MAX_MCS_11B) && (preamble == DOT11_B)));
  790. DP_STATS_INCC(mon_peer,
  791. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  792. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N)));
  793. DP_STATS_INCC(mon_peer,
  794. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  795. ((mcs < MAX_MCS_11A) && (preamble == DOT11_N)));
  796. DP_STATS_INCC(mon_peer,
  797. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  798. ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC)));
  799. DP_STATS_INCC(mon_peer,
  800. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  801. ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
  802. DP_STATS_INCC(mon_peer,
  803. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  804. ((mcs >= (MAX_MCS_11AX)) && (preamble == DOT11_AX)));
  805. DP_STATS_INCC(mon_peer,
  806. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  807. ((mcs < (MAX_MCS_11AX)) && (preamble == DOT11_AX)));
  808. DP_STATS_INCC(mon_peer,
  809. rx.su_ax_ppdu_cnt.mcs_count[MAX_MCS - 1], 1,
  810. ((mcs >= (MAX_MCS_11AX)) && (preamble == DOT11_AX) &&
  811. (ppdu_type == HAL_RX_TYPE_SU)));
  812. DP_STATS_INCC(mon_peer,
  813. rx.su_ax_ppdu_cnt.mcs_count[mcs], 1,
  814. ((mcs < (MAX_MCS_11AX)) && (preamble == DOT11_AX) &&
  815. (ppdu_type == HAL_RX_TYPE_SU)));
  816. DP_STATS_INCC(mon_peer,
  817. rx.rx_mu[TXRX_TYPE_MU_OFDMA].ppdu.mcs_count[MAX_MCS - 1],
  818. 1, ((mcs >= (MAX_MCS_11AX)) &&
  819. (preamble == DOT11_AX) &&
  820. (ppdu_type == HAL_RX_TYPE_MU_OFDMA)));
  821. DP_STATS_INCC(mon_peer,
  822. rx.rx_mu[TXRX_TYPE_MU_OFDMA].ppdu.mcs_count[mcs],
  823. 1, ((mcs < (MAX_MCS_11AX)) &&
  824. (preamble == DOT11_AX) &&
  825. (ppdu_type == HAL_RX_TYPE_MU_OFDMA)));
  826. DP_STATS_INCC(mon_peer,
  827. rx.rx_mu[TXRX_TYPE_MU_MIMO].ppdu.mcs_count[MAX_MCS - 1],
  828. 1, ((mcs >= (MAX_MCS_11AX)) &&
  829. (preamble == DOT11_AX) &&
  830. (ppdu_type == HAL_RX_TYPE_MU_MIMO)));
  831. DP_STATS_INCC(mon_peer,
  832. rx.rx_mu[TXRX_TYPE_MU_MIMO].ppdu.mcs_count[mcs],
  833. 1, ((mcs < (MAX_MCS_11AX)) &&
  834. (preamble == DOT11_AX) &&
  835. (ppdu_type == HAL_RX_TYPE_MU_MIMO)));
  836. /*
  837. * If invalid TID, it could be a non-qos frame, hence do not
  838. * update any AC counters
  839. */
  840. ac = TID_TO_WME_AC(ppdu_user->tid);
  841. if (ppdu->tid != HAL_TID_INVALID)
  842. DP_STATS_INC(mon_peer, rx.wme_ac_type[ac], num_msdu);
  843. DP_STATS_INC(mon_peer, rx.rx_ppdus, 1);
  844. DP_STATS_INC(mon_peer, rx.rx_mpdus,
  845. (ppdu_user->mpdu_cnt_fcs_ok + ppdu_user->mpdu_cnt_fcs_err));
  846. mon_ops = dp_mon_ops_get(soc);
  847. if (mon_ops && mon_ops->mon_rx_stats_update)
  848. mon_ops->mon_rx_stats_update(mon_peer, ppdu, ppdu_user);
  849. if (!peer)
  850. continue;
  851. dp_peer_stats_notify(pdev, peer);
  852. DP_STATS_UPD(mon_peer, rx.last_snr,
  853. (ppdu->rssi + pkt_bw_offset));
  854. dp_peer_qos_stats_notify(pdev, ppdu_user);
  855. if (dp_is_subtype_data(ppdu->frame_ctrl))
  856. dp_rx_rate_stats_update(peer, ppdu, i);
  857. dp_send_stats_event(pdev, peer, ppdu_user->peer_id);
  858. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  859. }
  860. }
  861. void
  862. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  863. struct hal_rx_ppdu_info *ppdu_info)
  864. {
  865. qdf_nbuf_t ppdu_nbuf;
  866. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  867. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  868. /*
  869. * Do not allocate if fcs error,
  870. * ast idx invalid / fctl invalid
  871. *
  872. * In CFR RCC mode - PPDU status TLVs of error pkts are also needed
  873. */
  874. if (ppdu_info->com_info.mpdu_cnt_fcs_ok == 0)
  875. return;
  876. if (ppdu_info->nac_info.fc_valid &&
  877. ppdu_info->nac_info.to_ds_flag &&
  878. ppdu_info->nac_info.mac_addr2_valid) {
  879. struct dp_neighbour_peer *peer = NULL;
  880. uint8_t rssi = ppdu_info->rx_status.rssi_comb;
  881. qdf_spin_lock_bh(&mon_pdev->neighbour_peer_mutex);
  882. if (mon_pdev->neighbour_peers_added) {
  883. TAILQ_FOREACH(peer, &mon_pdev->neighbour_peers_list,
  884. neighbour_peer_list_elem) {
  885. if (!qdf_mem_cmp(&peer->neighbour_peers_macaddr,
  886. &ppdu_info->nac_info.mac_addr2,
  887. QDF_MAC_ADDR_SIZE)) {
  888. peer->rssi = rssi;
  889. break;
  890. }
  891. }
  892. }
  893. qdf_spin_unlock_bh(&mon_pdev->neighbour_peer_mutex);
  894. } else {
  895. dp_info("Neighbour peers RSSI update failed! fc_valid = %d, to_ds_flag = %d and mac_addr2_valid = %d",
  896. ppdu_info->nac_info.fc_valid,
  897. ppdu_info->nac_info.to_ds_flag,
  898. ppdu_info->nac_info.mac_addr2_valid);
  899. }
  900. /* need not generate wdi event when mcopy, cfr rcc mode and
  901. * enhanced stats are not enabled
  902. */
  903. if (!mon_pdev->mcopy_mode && !mon_pdev->enhanced_stats_en &&
  904. !dp_cfr_rcc_mode_status(pdev))
  905. return;
  906. if (dp_cfr_rcc_mode_status(pdev))
  907. dp_update_cfr_dbg_stats(pdev, ppdu_info);
  908. if (!ppdu_info->rx_status.frame_control_info_valid ||
  909. (ppdu_info->rx_status.ast_index == HAL_AST_IDX_INVALID)) {
  910. if (!(mon_pdev->mcopy_mode ||
  911. (dp_bb_captured_chan_status(pdev, ppdu_info) ==
  912. QDF_STATUS_SUCCESS)))
  913. return;
  914. }
  915. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  916. sizeof(struct cdp_rx_indication_ppdu),
  917. 0, 0, FALSE);
  918. if (ppdu_nbuf) {
  919. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)qdf_nbuf_data(ppdu_nbuf);
  920. qdf_mem_zero(cdp_rx_ppdu, sizeof(struct cdp_rx_indication_ppdu));
  921. dp_rx_mon_populate_cfr_info(pdev, ppdu_info, cdp_rx_ppdu);
  922. dp_rx_populate_cdp_indication_ppdu(pdev,
  923. ppdu_info, cdp_rx_ppdu);
  924. if (!qdf_nbuf_put_tail(ppdu_nbuf,
  925. sizeof(struct cdp_rx_indication_ppdu)))
  926. return;
  927. dp_rx_stats_update(pdev, cdp_rx_ppdu);
  928. if (cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) {
  929. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC,
  930. soc, ppdu_nbuf,
  931. cdp_rx_ppdu->peer_id,
  932. WDI_NO_VAL, pdev->pdev_id);
  933. } else if (mon_pdev->mcopy_mode || dp_cfr_rcc_mode_status(pdev)) {
  934. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
  935. ppdu_nbuf, HTT_INVALID_PEER,
  936. WDI_NO_VAL, pdev->pdev_id);
  937. } else {
  938. qdf_nbuf_free(ppdu_nbuf);
  939. }
  940. }
  941. }
  942. #endif/* QCA_ENHANCED_STATS_SUPPORT */
  943. #ifdef QCA_UNDECODED_METADATA_SUPPORT
  944. #define RX_PHYERR_MASK_GET64(_val1, _val2) (((uint64_t)(_val2) << 32) | (_val1))
  945. /**
  946. * dp_rx_populate_cdp_indication_ppdu_undecoded_metadata() - Populate cdp
  947. * rx indication structure
  948. * @pdev: pdev ctx
  949. * @ppdu_info: ppdu info structure from ppdu ring
  950. * @cdp_rx_ppdu: Rx PPDU indication structure
  951. *
  952. * Return: none
  953. */
  954. static void
  955. dp_rx_populate_cdp_indication_ppdu_undecoded_metadata(struct dp_pdev *pdev,
  956. struct hal_rx_ppdu_info *ppdu_info,
  957. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  958. {
  959. uint32_t chain;
  960. cdp_rx_ppdu->phyrx_abort = ppdu_info->rx_status.phyrx_abort;
  961. cdp_rx_ppdu->phyrx_abort_reason =
  962. ppdu_info->rx_status.phyrx_abort_reason;
  963. cdp_rx_ppdu->first_data_seq_ctrl =
  964. ppdu_info->rx_status.first_data_seq_ctrl;
  965. cdp_rx_ppdu->frame_ctrl =
  966. ppdu_info->rx_status.frame_control;
  967. cdp_rx_ppdu->tcp_msdu_count = ppdu_info->rx_status.tcp_msdu_count;
  968. cdp_rx_ppdu->udp_msdu_count = ppdu_info->rx_status.udp_msdu_count;
  969. cdp_rx_ppdu->other_msdu_count = ppdu_info->rx_status.other_msdu_count;
  970. cdp_rx_ppdu->u.preamble = ppdu_info->rx_status.preamble_type;
  971. cdp_rx_ppdu->num_mpdu = ppdu_info->com_info.mpdu_cnt_fcs_ok;
  972. cdp_rx_ppdu->num_msdu = (cdp_rx_ppdu->tcp_msdu_count +
  973. cdp_rx_ppdu->udp_msdu_count +
  974. cdp_rx_ppdu->other_msdu_count);
  975. cdp_rx_ppdu->retries = CDP_FC_IS_RETRY_SET(cdp_rx_ppdu->frame_ctrl) ?
  976. ppdu_info->com_info.mpdu_cnt_fcs_ok : 0;
  977. if (ppdu_info->com_info.mpdu_cnt_fcs_ok > 1)
  978. cdp_rx_ppdu->is_ampdu = 1;
  979. else
  980. cdp_rx_ppdu->is_ampdu = 0;
  981. cdp_rx_ppdu->tid = ppdu_info->rx_status.tid;
  982. cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
  983. cdp_rx_ppdu->length = ppdu_info->rx_status.ppdu_len;
  984. cdp_rx_ppdu->duration = ppdu_info->rx_status.duration;
  985. cdp_rx_ppdu->u.bw = ppdu_info->rx_status.bw;
  986. cdp_rx_ppdu->u.nss = ppdu_info->rx_status.nss;
  987. cdp_rx_ppdu->u.mcs = ppdu_info->rx_status.mcs;
  988. if (ppdu_info->rx_status.sgi == VHT_SGI_NYSM &&
  989. ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC)
  990. cdp_rx_ppdu->u.gi = CDP_SGI_0_4_US;
  991. else
  992. cdp_rx_ppdu->u.gi = ppdu_info->rx_status.sgi;
  993. cdp_rx_ppdu->u.ldpc = ppdu_info->rx_status.ldpc;
  994. cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
  995. cdp_rx_ppdu->u.ltf_size = (ppdu_info->rx_status.he_data5 >>
  996. QDF_MON_STATUS_HE_LTF_SIZE_SHIFT) & 0x3;
  997. cdp_rx_ppdu->rssi = ppdu_info->rx_status.rssi_comb;
  998. cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
  999. cdp_rx_ppdu->channel = ppdu_info->rx_status.chan_num;
  1000. cdp_rx_ppdu->beamformed = ppdu_info->rx_status.beamformed;
  1001. cdp_rx_ppdu->num_bytes = ppdu_info->rx_status.ppdu_len;
  1002. cdp_rx_ppdu->lsig_a = ppdu_info->rx_status.rate;
  1003. cdp_rx_ppdu->u.ltf_size = ppdu_info->rx_status.ltf_size;
  1004. if (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC) {
  1005. cdp_rx_ppdu->u.stbc = ppdu_info->rx_status.is_stbc;
  1006. cdp_rx_ppdu->vht_no_txop_ps =
  1007. ppdu_info->rx_status.vht_no_txop_ps;
  1008. cdp_rx_ppdu->vht_crc = ppdu_info->rx_status.vht_crc;
  1009. cdp_rx_ppdu->group_id = ppdu_info->rx_status.vht_flag_values5;
  1010. } else if (ppdu_info->rx_status.preamble_type ==
  1011. HAL_RX_PKT_TYPE_11AX) {
  1012. cdp_rx_ppdu->u.stbc = (ppdu_info->rx_status.he_data3 >>
  1013. QDF_MON_STATUS_STBC_SHIFT) & 0x1;
  1014. cdp_rx_ppdu->u.dcm = (ppdu_info->rx_status.he_data3 >>
  1015. QDF_MON_STATUS_DCM_SHIFT) & 0x1;
  1016. } else {
  1017. cdp_rx_ppdu->u.stbc = ppdu_info->rx_status.ht_stbc;
  1018. cdp_rx_ppdu->ht_length = ppdu_info->rx_status.ht_length;
  1019. cdp_rx_ppdu->ht_smoothing = ppdu_info->rx_status.smoothing;
  1020. cdp_rx_ppdu->ht_not_sounding =
  1021. ppdu_info->rx_status.not_sounding;
  1022. cdp_rx_ppdu->ht_aggregation = ppdu_info->rx_status.aggregation;
  1023. cdp_rx_ppdu->ht_stbc = ppdu_info->rx_status.ht_stbc;
  1024. cdp_rx_ppdu->ht_crc = ppdu_info->rx_status.ht_crc;
  1025. }
  1026. cdp_rx_ppdu->l_sig_length = ppdu_info->rx_status.l_sig_length;
  1027. cdp_rx_ppdu->l_sig_a_parity = ppdu_info->rx_status.l_sig_a_parity;
  1028. cdp_rx_ppdu->l_sig_a_pkt_type = ppdu_info->rx_status.l_sig_a_pkt_type;
  1029. if (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AX) {
  1030. cdp_rx_ppdu->he_crc = ppdu_info->rx_status.he_crc;
  1031. cdp_rx_ppdu->bss_color_id =
  1032. ppdu_info->rx_status.he_data3 & 0x3F;
  1033. cdp_rx_ppdu->beam_change = (ppdu_info->rx_status.he_data3 >>
  1034. QDF_MON_STATUS_BEAM_CHANGE_SHIFT) & 0x1;
  1035. cdp_rx_ppdu->dl_ul_flag = (ppdu_info->rx_status.he_data3 >>
  1036. QDF_MON_STATUS_DL_UL_SHIFT) & 0x1;
  1037. cdp_rx_ppdu->ldpc_extra_sym = (ppdu_info->rx_status.he_data3 >>
  1038. QDF_MON_STATUS_LDPC_EXTRA_SYMBOL_SHIFT) & 0x1;
  1039. cdp_rx_ppdu->special_reuse =
  1040. ppdu_info->rx_status.he_data4 & 0xF;
  1041. cdp_rx_ppdu->ltf_sym = (ppdu_info->rx_status.he_data5 >>
  1042. QDF_MON_STATUS_HE_LTF_SYM_SHIFT) & 0x7;
  1043. cdp_rx_ppdu->txbf = (ppdu_info->rx_status.he_data5 >>
  1044. QDF_MON_STATUS_TXBF_SHIFT) & 0x1;
  1045. cdp_rx_ppdu->pe_disambiguity = (ppdu_info->rx_status.he_data5 >>
  1046. QDF_MON_STATUS_PE_DISAMBIGUITY_SHIFT) & 0x1;
  1047. cdp_rx_ppdu->pre_fec_pad = (ppdu_info->rx_status.he_data5 >>
  1048. QDF_MON_STATUS_PRE_FEC_PAD_SHIFT) & 0x3;
  1049. cdp_rx_ppdu->dopplar = (ppdu_info->rx_status.he_data6 >>
  1050. QDF_MON_STATUS_DOPPLER_SHIFT) & 0x1;
  1051. cdp_rx_ppdu->txop_duration = (ppdu_info->rx_status.he_data6 >>
  1052. QDF_MON_STATUS_TXOP_SHIFT) & 0x7F;
  1053. cdp_rx_ppdu->sig_b_mcs = ppdu_info->rx_status.he_flags1 & 0x7;
  1054. cdp_rx_ppdu->sig_b_dcm = (ppdu_info->rx_status.he_flags1 >>
  1055. QDF_MON_STATUS_DCM_FLAG_1_SHIFT) & 0x1;
  1056. cdp_rx_ppdu->sig_b_sym = (ppdu_info->rx_status.he_flags2 >>
  1057. QDF_MON_STATUS_NUM_SIG_B_SYMBOLS_SHIFT) & 0xF;
  1058. cdp_rx_ppdu->sig_b_comp = (ppdu_info->rx_status.he_flags2 >>
  1059. QDF_MON_STATUS_SIG_B_COMPRESSION_FLAG_2_SHIFT) & 0x1;
  1060. }
  1061. dp_rx_populate_rx_rssi_chain(ppdu_info, cdp_rx_ppdu);
  1062. dp_rx_populate_su_evm_details(ppdu_info, cdp_rx_ppdu);
  1063. cdp_rx_ppdu->rx_antenna = ppdu_info->rx_status.rx_antenna;
  1064. cdp_rx_ppdu->nf = ppdu_info->rx_status.chan_noise_floor;
  1065. for (chain = 0; chain < MAX_CHAIN; chain++)
  1066. cdp_rx_ppdu->per_chain_rssi[chain] =
  1067. ppdu_info->rx_status.rssi[chain];
  1068. cdp_rx_ppdu->is_mcast_bcast = ppdu_info->nac_info.mcast_bcast;
  1069. cdp_rx_ppdu->num_users = ppdu_info->com_info.num_users;
  1070. dp_rx_populate_cdp_indication_ppdu_user(pdev, ppdu_info, cdp_rx_ppdu);
  1071. }
  1072. /**
  1073. * dp_rx_is_valid_undecoded_frame() - Check unencoded frame received valid
  1074. * or not against configured error mask
  1075. * @err_mask: configured err mask
  1076. * @err_code: Received error reason code for phy abort
  1077. *
  1078. * Return: true / false
  1079. */
  1080. static inline bool
  1081. dp_rx_is_valid_undecoded_frame(uint64_t err_mask, uint8_t err_code)
  1082. {
  1083. if (err_code < CDP_PHYRX_ERR_MAX &&
  1084. (err_mask & (1L << err_code)))
  1085. return true;
  1086. return false;
  1087. }
  1088. void
  1089. dp_rx_handle_ppdu_undecoded_metadata(struct dp_soc *soc, struct dp_pdev *pdev,
  1090. struct hal_rx_ppdu_info *ppdu_info)
  1091. {
  1092. qdf_nbuf_t ppdu_nbuf;
  1093. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  1094. uint8_t abort_reason = 0;
  1095. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1096. uint64_t mask64;
  1097. /* Return if RX_ABORT not set */
  1098. if (ppdu_info->rx_status.phyrx_abort == 0)
  1099. return;
  1100. mask64 = RX_PHYERR_MASK_GET64(mon_pdev->phyrx_error_mask,
  1101. mon_pdev->phyrx_error_mask_cont);
  1102. abort_reason = ppdu_info->rx_status.phyrx_abort_reason;
  1103. if (!dp_rx_is_valid_undecoded_frame(mask64, abort_reason))
  1104. return;
  1105. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  1106. sizeof(struct cdp_rx_indication_ppdu),
  1107. 0, 0, FALSE);
  1108. if (ppdu_nbuf) {
  1109. cdp_rx_ppdu = ((struct cdp_rx_indication_ppdu *)
  1110. qdf_nbuf_data(ppdu_nbuf));
  1111. qdf_mem_zero(cdp_rx_ppdu,
  1112. sizeof(struct cdp_rx_indication_ppdu));
  1113. dp_rx_populate_cdp_indication_ppdu_undecoded_metadata(pdev,
  1114. ppdu_info, cdp_rx_ppdu);
  1115. if (!qdf_nbuf_put_tail(ppdu_nbuf,
  1116. sizeof(struct cdp_rx_indication_ppdu))) {
  1117. return;
  1118. }
  1119. mon_pdev->rx_mon_stats.rx_undecoded_count++;
  1120. mon_pdev->rx_mon_stats.rx_undecoded_error[abort_reason] += 1;
  1121. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC_UNDECODED_METADATA,
  1122. soc, ppdu_nbuf, HTT_INVALID_PEER,
  1123. WDI_NO_VAL, pdev->pdev_id);
  1124. }
  1125. }
  1126. #endif/* QCA_UNDECODED_METADATA_SUPPORT */
  1127. #ifdef QCA_MCOPY_SUPPORT
  1128. QDF_STATUS
  1129. dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  1130. struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf,
  1131. uint8_t fcs_ok_mpdu_cnt, bool deliver_frame)
  1132. {
  1133. uint16_t size = 0;
  1134. struct ieee80211_frame *wh;
  1135. uint32_t *nbuf_data;
  1136. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1137. if (!ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload)
  1138. return QDF_STATUS_SUCCESS;
  1139. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  1140. if (mon_pdev->mcopy_mode == M_COPY) {
  1141. if (mon_pdev->m_copy_id.rx_ppdu_id == ppdu_info->com_info.ppdu_id)
  1142. return QDF_STATUS_SUCCESS;
  1143. }
  1144. wh = (struct ieee80211_frame *)(ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload + 4);
  1145. size = (ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload -
  1146. qdf_nbuf_data(nbuf));
  1147. if (qdf_nbuf_pull_head(nbuf, size) == NULL)
  1148. return QDF_STATUS_SUCCESS;
  1149. if (((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  1150. IEEE80211_FC0_TYPE_MGT) ||
  1151. ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  1152. IEEE80211_FC0_TYPE_CTL)) {
  1153. return QDF_STATUS_SUCCESS;
  1154. }
  1155. nbuf_data = (uint32_t *)qdf_nbuf_data(nbuf);
  1156. *nbuf_data = mon_pdev->ppdu_info.com_info.ppdu_id;
  1157. /* only retain RX MSDU payload in the skb */
  1158. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) - ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].payload_len);
  1159. if (deliver_frame) {
  1160. mon_pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
  1161. dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
  1162. nbuf, HTT_INVALID_PEER,
  1163. WDI_NO_VAL, pdev->pdev_id);
  1164. }
  1165. return QDF_STATUS_E_ALREADY;
  1166. }
  1167. void
  1168. dp_rx_mcopy_handle_last_mpdu(struct dp_soc *soc, struct dp_pdev *pdev,
  1169. struct hal_rx_ppdu_info *ppdu_info,
  1170. qdf_nbuf_t status_nbuf)
  1171. {
  1172. QDF_STATUS mcopy_status;
  1173. qdf_nbuf_t nbuf_clone = NULL;
  1174. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1175. /* If the MPDU end tlv and RX header are received in different buffers,
  1176. * process the RX header based on fcs status.
  1177. */
  1178. if (mon_pdev->mcopy_status_nbuf) {
  1179. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  1180. if (mon_pdev->mcopy_mode == M_COPY) {
  1181. if (mon_pdev->m_copy_id.rx_ppdu_id ==
  1182. ppdu_info->com_info.ppdu_id)
  1183. goto end1;
  1184. }
  1185. if (ppdu_info->is_fcs_passed) {
  1186. nbuf_clone = qdf_nbuf_clone(mon_pdev->mcopy_status_nbuf);
  1187. if (!nbuf_clone) {
  1188. QDF_TRACE(QDF_MODULE_ID_TXRX,
  1189. QDF_TRACE_LEVEL_ERROR,
  1190. "Failed to clone nbuf");
  1191. goto end1;
  1192. }
  1193. mon_pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
  1194. dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
  1195. nbuf_clone,
  1196. HTT_INVALID_PEER,
  1197. WDI_NO_VAL, pdev->pdev_id);
  1198. ppdu_info->is_fcs_passed = false;
  1199. }
  1200. end1:
  1201. qdf_nbuf_free(mon_pdev->mcopy_status_nbuf);
  1202. mon_pdev->mcopy_status_nbuf = NULL;
  1203. }
  1204. /* If the MPDU end tlv and RX header are received in different buffers,
  1205. * preserve the RX header as the fcs status will be received in MPDU
  1206. * end tlv in next buffer. So, cache the buffer to be processd in next
  1207. * iteration
  1208. */
  1209. if ((ppdu_info->fcs_ok_cnt + ppdu_info->fcs_err_cnt) !=
  1210. ppdu_info->com_info.mpdu_cnt) {
  1211. mon_pdev->mcopy_status_nbuf = qdf_nbuf_clone(status_nbuf);
  1212. if (mon_pdev->mcopy_status_nbuf) {
  1213. mcopy_status = dp_rx_handle_mcopy_mode(
  1214. soc, pdev,
  1215. ppdu_info,
  1216. mon_pdev->mcopy_status_nbuf,
  1217. ppdu_info->fcs_ok_cnt,
  1218. false);
  1219. if (mcopy_status == QDF_STATUS_SUCCESS) {
  1220. qdf_nbuf_free(mon_pdev->mcopy_status_nbuf);
  1221. mon_pdev->mcopy_status_nbuf = NULL;
  1222. }
  1223. }
  1224. }
  1225. }
  1226. void
  1227. dp_rx_mcopy_process_ppdu_info(struct dp_pdev *pdev,
  1228. struct hal_rx_ppdu_info *ppdu_info,
  1229. uint32_t tlv_status)
  1230. {
  1231. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1232. if (!mon_pdev->mcopy_mode)
  1233. return;
  1234. /* The fcs status is received in MPDU end tlv. If the RX header
  1235. * and its MPDU end tlv are received in different status buffer then
  1236. * to process that header ppdu_info->is_fcs_passed is used.
  1237. * If end tlv is received in next status buffer then com_info.mpdu_cnt
  1238. * will be 0 at the time of receiving MPDU end tlv and we update the
  1239. * is_fcs_passed flag based on ppdu_info->fcs_err.
  1240. */
  1241. if (tlv_status != HAL_TLV_STATUS_MPDU_END)
  1242. return;
  1243. if (!ppdu_info->fcs_err) {
  1244. if (ppdu_info->fcs_ok_cnt >
  1245. HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER) {
  1246. dp_err("No. of MPDUs(%d) per status buff exceeded",
  1247. ppdu_info->fcs_ok_cnt);
  1248. return;
  1249. }
  1250. if (ppdu_info->com_info.mpdu_cnt)
  1251. ppdu_info->fcs_ok_cnt++;
  1252. else
  1253. ppdu_info->is_fcs_passed = true;
  1254. } else {
  1255. if (ppdu_info->com_info.mpdu_cnt)
  1256. ppdu_info->fcs_err_cnt++;
  1257. else
  1258. ppdu_info->is_fcs_passed = false;
  1259. }
  1260. }
  1261. void
  1262. dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  1263. struct hal_rx_ppdu_info *ppdu_info,
  1264. uint32_t tlv_status,
  1265. qdf_nbuf_t status_nbuf)
  1266. {
  1267. QDF_STATUS mcopy_status;
  1268. qdf_nbuf_t nbuf_clone = NULL;
  1269. uint8_t fcs_ok_mpdu_cnt = 0;
  1270. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1271. dp_rx_mcopy_handle_last_mpdu(soc, pdev, ppdu_info, status_nbuf);
  1272. if (qdf_unlikely(!ppdu_info->com_info.mpdu_cnt))
  1273. goto end;
  1274. if (qdf_unlikely(!ppdu_info->fcs_ok_cnt))
  1275. goto end;
  1276. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  1277. if (mon_pdev->mcopy_mode == M_COPY)
  1278. ppdu_info->fcs_ok_cnt = 1;
  1279. while (fcs_ok_mpdu_cnt < ppdu_info->fcs_ok_cnt) {
  1280. nbuf_clone = qdf_nbuf_clone(status_nbuf);
  1281. if (!nbuf_clone) {
  1282. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1283. "Failed to clone nbuf");
  1284. goto end;
  1285. }
  1286. mcopy_status = dp_rx_handle_mcopy_mode(soc, pdev,
  1287. ppdu_info,
  1288. nbuf_clone,
  1289. fcs_ok_mpdu_cnt,
  1290. true);
  1291. if (mcopy_status == QDF_STATUS_SUCCESS)
  1292. qdf_nbuf_free(nbuf_clone);
  1293. fcs_ok_mpdu_cnt++;
  1294. }
  1295. end:
  1296. qdf_nbuf_free(status_nbuf);
  1297. ppdu_info->fcs_ok_cnt = 0;
  1298. ppdu_info->fcs_err_cnt = 0;
  1299. ppdu_info->com_info.mpdu_cnt = 0;
  1300. qdf_mem_zero(&ppdu_info->ppdu_msdu_info,
  1301. HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER
  1302. * sizeof(struct hal_rx_msdu_payload_info));
  1303. }
  1304. #endif /* QCA_MCOPY_SUPPORT */
  1305. int
  1306. dp_rx_handle_smart_mesh_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  1307. struct hal_rx_ppdu_info *ppdu_info,
  1308. qdf_nbuf_t nbuf)
  1309. {
  1310. uint8_t size = 0;
  1311. struct dp_mon_vdev *mon_vdev;
  1312. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1313. if (!mon_pdev->mvdev) {
  1314. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1315. "[%s]:[%d] Monitor vdev is NULL !!",
  1316. __func__, __LINE__);
  1317. return 1;
  1318. }
  1319. mon_vdev = mon_pdev->mvdev->monitor_vdev;
  1320. if (!ppdu_info->msdu_info.first_msdu_payload) {
  1321. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1322. "[%s]:[%d] First msdu payload not present",
  1323. __func__, __LINE__);
  1324. return 1;
  1325. }
  1326. /* Adding 4 bytes to get to start of 802.11 frame after phy_ppdu_id */
  1327. size = (ppdu_info->msdu_info.first_msdu_payload -
  1328. qdf_nbuf_data(nbuf)) + 4;
  1329. ppdu_info->msdu_info.first_msdu_payload = NULL;
  1330. if (!qdf_nbuf_pull_head(nbuf, size)) {
  1331. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1332. "[%s]:[%d] No header present",
  1333. __func__, __LINE__);
  1334. return 1;
  1335. }
  1336. /* Only retain RX MSDU payload in the skb */
  1337. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
  1338. ppdu_info->msdu_info.payload_len);
  1339. if (!qdf_nbuf_update_radiotap(&mon_pdev->ppdu_info.rx_status, nbuf,
  1340. qdf_nbuf_headroom(nbuf))) {
  1341. DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
  1342. return 1;
  1343. }
  1344. mon_vdev->osif_rx_mon(mon_pdev->mvdev->osif_vdev,
  1345. nbuf, NULL);
  1346. mon_pdev->ppdu_info.rx_status.monitor_direct_used = 0;
  1347. return 0;
  1348. }
  1349. qdf_nbuf_t
  1350. dp_rx_nbuf_prepare(struct dp_soc *soc, struct dp_pdev *pdev)
  1351. {
  1352. uint8_t *buf;
  1353. int32_t nbuf_retry_count;
  1354. QDF_STATUS ret;
  1355. qdf_nbuf_t nbuf = NULL;
  1356. for (nbuf_retry_count = 0; nbuf_retry_count <
  1357. QDF_NBUF_ALLOC_MAP_RETRY_THRESHOLD;
  1358. nbuf_retry_count++) {
  1359. /* Allocate a new skb using alloc_skb */
  1360. nbuf = qdf_nbuf_alloc_no_recycler(RX_MON_STATUS_BUF_SIZE,
  1361. RX_MON_STATUS_BUF_RESERVATION,
  1362. RX_DATA_BUFFER_ALIGNMENT);
  1363. if (!nbuf) {
  1364. DP_STATS_INC(pdev, replenish.nbuf_alloc_fail, 1);
  1365. continue;
  1366. }
  1367. buf = qdf_nbuf_data(nbuf);
  1368. memset(buf, 0, RX_MON_STATUS_BUF_SIZE);
  1369. ret = qdf_nbuf_map_nbytes_single(soc->osdev, nbuf,
  1370. QDF_DMA_FROM_DEVICE,
  1371. RX_MON_STATUS_BUF_SIZE);
  1372. /* nbuf map failed */
  1373. if (qdf_unlikely(QDF_IS_STATUS_ERROR(ret))) {
  1374. qdf_nbuf_free(nbuf);
  1375. DP_STATS_INC(pdev, replenish.map_err, 1);
  1376. continue;
  1377. }
  1378. /* qdf_nbuf alloc and map succeeded */
  1379. break;
  1380. }
  1381. /* qdf_nbuf still alloc or map failed */
  1382. if (qdf_unlikely(nbuf_retry_count >=
  1383. QDF_NBUF_ALLOC_MAP_RETRY_THRESHOLD))
  1384. return NULL;
  1385. return nbuf;
  1386. }
  1387. #ifndef DISABLE_MON_CONFIG
  1388. uint32_t
  1389. dp_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  1390. uint32_t mac_id, uint32_t quota)
  1391. {
  1392. struct dp_mon_soc *mon_soc = soc->monitor_soc;
  1393. if (mon_soc && mon_soc->mon_rx_process)
  1394. return mon_soc->mon_rx_process(soc, int_ctx,
  1395. mac_id, quota);
  1396. return 0;
  1397. }
  1398. #else
  1399. uint32_t
  1400. dp_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  1401. uint32_t mac_id, uint32_t quota)
  1402. {
  1403. return 0;
  1404. }
  1405. #endif
  1406. /**
  1407. * dp_send_mgmt_packet_to_stack(): send indicataion to upper layers
  1408. *
  1409. * @soc: soc handle
  1410. * @nbuf: Mgmt packet
  1411. * @pdev: pdev handle
  1412. *
  1413. * Return: QDF_STATUS_SUCCESS on success
  1414. * QDF_STATUS_E_INVAL in error
  1415. */
  1416. #ifdef QCA_MCOPY_SUPPORT
  1417. static inline QDF_STATUS
  1418. dp_send_mgmt_packet_to_stack(struct dp_soc *soc,
  1419. qdf_nbuf_t nbuf,
  1420. struct dp_pdev *pdev)
  1421. {
  1422. uint32_t *nbuf_data;
  1423. struct ieee80211_frame *wh;
  1424. qdf_frag_t addr;
  1425. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1426. if (!nbuf)
  1427. return QDF_STATUS_E_INVAL;
  1428. /* Get addr pointing to80211 header */
  1429. addr = dp_rx_mon_get_nbuf_80211_hdr(nbuf);
  1430. if (qdf_unlikely(!addr)) {
  1431. qdf_nbuf_free(nbuf);
  1432. return QDF_STATUS_E_INVAL;
  1433. }
  1434. /*check if this is not a mgmt packet*/
  1435. wh = (struct ieee80211_frame *)addr;
  1436. if (((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=
  1437. IEEE80211_FC0_TYPE_MGT) &&
  1438. ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=
  1439. IEEE80211_FC0_TYPE_CTL)) {
  1440. qdf_nbuf_free(nbuf);
  1441. return QDF_STATUS_E_INVAL;
  1442. }
  1443. nbuf_data = (uint32_t *)qdf_nbuf_push_head(nbuf, 4);
  1444. if (!nbuf_data) {
  1445. QDF_TRACE(QDF_MODULE_ID_DP,
  1446. QDF_TRACE_LEVEL_ERROR,
  1447. FL("No headroom"));
  1448. qdf_nbuf_free(nbuf);
  1449. return QDF_STATUS_E_INVAL;
  1450. }
  1451. *nbuf_data = mon_pdev->ppdu_info.com_info.ppdu_id;
  1452. dp_wdi_event_handler(WDI_EVENT_RX_MGMT_CTRL, soc, nbuf,
  1453. HTT_INVALID_PEER,
  1454. WDI_NO_VAL, pdev->pdev_id);
  1455. return QDF_STATUS_SUCCESS;
  1456. }
  1457. #else
  1458. static inline QDF_STATUS
  1459. dp_send_mgmt_packet_to_stack(struct dp_soc *soc,
  1460. qdf_nbuf_t nbuf,
  1461. struct dp_pdev *pdev)
  1462. {
  1463. return QDF_STATUS_SUCCESS;
  1464. }
  1465. #endif /* QCA_MCOPY_SUPPORT */
  1466. QDF_STATUS dp_rx_mon_process_dest_pktlog(struct dp_soc *soc,
  1467. uint32_t mac_id,
  1468. qdf_nbuf_t mpdu)
  1469. {
  1470. uint32_t event, msdu_timestamp = 0;
  1471. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1472. void *data;
  1473. struct ieee80211_frame *wh;
  1474. uint8_t type, subtype;
  1475. struct dp_mon_pdev *mon_pdev;
  1476. if (!pdev)
  1477. return QDF_STATUS_E_INVAL;
  1478. mon_pdev = pdev->monitor_pdev;
  1479. if (mon_pdev->rx_pktlog_cbf) {
  1480. if (qdf_nbuf_get_nr_frags(mpdu))
  1481. data = qdf_nbuf_get_frag_addr(mpdu, 0);
  1482. else
  1483. data = qdf_nbuf_data(mpdu);
  1484. /* CBF logging required, doesn't matter if it is a full mode
  1485. * or lite mode.
  1486. * Need to look for mpdu with:
  1487. * TYPE = ACTION, SUBTYPE = NO ACK in the header
  1488. */
  1489. event = WDI_EVENT_RX_CBF;
  1490. wh = (struct ieee80211_frame *)data;
  1491. type = (wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
  1492. subtype = (wh)->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
  1493. if (type == IEEE80211_FC0_TYPE_MGT &&
  1494. subtype == IEEE80211_FCO_SUBTYPE_ACTION_NO_ACK) {
  1495. msdu_timestamp = mon_pdev->ppdu_info.rx_status.tsft;
  1496. dp_rx_populate_cbf_hdr(soc,
  1497. mac_id, event,
  1498. mpdu,
  1499. msdu_timestamp);
  1500. }
  1501. }
  1502. return QDF_STATUS_SUCCESS;
  1503. }
  1504. QDF_STATUS dp_rx_mon_deliver(struct dp_soc *soc, uint32_t mac_id,
  1505. qdf_nbuf_t head_msdu, qdf_nbuf_t tail_msdu)
  1506. {
  1507. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1508. struct cdp_mon_status *rs;
  1509. qdf_nbuf_t mon_skb, skb_next;
  1510. qdf_nbuf_t mon_mpdu = NULL;
  1511. struct dp_mon_vdev *mon_vdev;
  1512. struct dp_mon_pdev *mon_pdev;
  1513. if (!pdev)
  1514. goto mon_deliver_fail;
  1515. mon_pdev = pdev->monitor_pdev;
  1516. rs = &mon_pdev->rx_mon_recv_status;
  1517. if (!mon_pdev->mvdev && !mon_pdev->mcopy_mode &&
  1518. !mon_pdev->rx_pktlog_cbf)
  1519. goto mon_deliver_fail;
  1520. /* restitch mon MPDU for delivery via monitor interface */
  1521. mon_mpdu = dp_rx_mon_restitch_mpdu(soc, mac_id, head_msdu,
  1522. tail_msdu, rs);
  1523. /* If MPDU restitch fails, free buffers*/
  1524. if (!mon_mpdu) {
  1525. dp_info("MPDU restitch failed, free buffers");
  1526. goto mon_deliver_fail;
  1527. }
  1528. dp_rx_mon_process_dest_pktlog(soc, mac_id, mon_mpdu);
  1529. /* monitor vap cannot be present when mcopy is enabled
  1530. * hence same skb can be consumed
  1531. */
  1532. if (mon_pdev->mcopy_mode)
  1533. return dp_send_mgmt_packet_to_stack(soc, mon_mpdu, pdev);
  1534. if (mon_mpdu && mon_pdev->mvdev &&
  1535. mon_pdev->mvdev->osif_vdev &&
  1536. mon_pdev->mvdev->monitor_vdev &&
  1537. mon_pdev->mvdev->monitor_vdev->osif_rx_mon) {
  1538. mon_vdev = mon_pdev->mvdev->monitor_vdev;
  1539. mon_pdev->ppdu_info.rx_status.ppdu_id =
  1540. mon_pdev->ppdu_info.com_info.ppdu_id;
  1541. mon_pdev->ppdu_info.rx_status.device_id = soc->device_id;
  1542. mon_pdev->ppdu_info.rx_status.chan_noise_floor =
  1543. pdev->chan_noise_floor;
  1544. dp_handle_tx_capture(soc, pdev, mon_mpdu);
  1545. if (!qdf_nbuf_update_radiotap(&mon_pdev->ppdu_info.rx_status,
  1546. mon_mpdu,
  1547. qdf_nbuf_headroom(mon_mpdu))) {
  1548. DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
  1549. goto mon_deliver_fail;
  1550. }
  1551. dp_rx_mon_update_pf_tag_to_buf_headroom(soc, mon_mpdu);
  1552. mon_vdev->osif_rx_mon(mon_pdev->mvdev->osif_vdev,
  1553. mon_mpdu,
  1554. &mon_pdev->ppdu_info.rx_status);
  1555. } else {
  1556. dp_rx_mon_dest_debug("%pK: mon_mpdu=%pK monitor_vdev %pK osif_vdev %pK"
  1557. , soc, mon_mpdu, mon_pdev->mvdev,
  1558. (mon_pdev->mvdev ? mon_pdev->mvdev->osif_vdev
  1559. : NULL));
  1560. goto mon_deliver_fail;
  1561. }
  1562. return QDF_STATUS_SUCCESS;
  1563. mon_deliver_fail:
  1564. mon_skb = head_msdu;
  1565. while (mon_skb) {
  1566. skb_next = qdf_nbuf_next(mon_skb);
  1567. dp_rx_mon_dest_debug("%pK: [%s][%d] mon_skb=%pK len %u",
  1568. soc, __func__, __LINE__, mon_skb, mon_skb->len);
  1569. qdf_nbuf_free(mon_skb);
  1570. mon_skb = skb_next;
  1571. }
  1572. return QDF_STATUS_E_INVAL;
  1573. }
  1574. QDF_STATUS dp_rx_mon_deliver_non_std(struct dp_soc *soc,
  1575. uint32_t mac_id)
  1576. {
  1577. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1578. ol_txrx_rx_mon_fp osif_rx_mon;
  1579. qdf_nbuf_t dummy_msdu;
  1580. struct dp_mon_pdev *mon_pdev;
  1581. struct dp_mon_vdev *mon_vdev;
  1582. /* Sanity checking */
  1583. if (!pdev || !pdev->monitor_pdev)
  1584. goto mon_deliver_non_std_fail;
  1585. mon_pdev = pdev->monitor_pdev;
  1586. if (!mon_pdev->mvdev || !mon_pdev->mvdev ||
  1587. !mon_pdev->mvdev->monitor_vdev ||
  1588. !mon_pdev->mvdev->monitor_vdev->osif_rx_mon)
  1589. goto mon_deliver_non_std_fail;
  1590. mon_vdev = mon_pdev->mvdev->monitor_vdev;
  1591. /* Generate a dummy skb_buff */
  1592. osif_rx_mon = mon_vdev->osif_rx_mon;
  1593. dummy_msdu = qdf_nbuf_alloc(soc->osdev, MAX_MONITOR_HEADER,
  1594. MAX_MONITOR_HEADER, 4, FALSE);
  1595. if (!dummy_msdu)
  1596. goto allocate_dummy_msdu_fail;
  1597. qdf_nbuf_set_pktlen(dummy_msdu, 0);
  1598. qdf_nbuf_set_next(dummy_msdu, NULL);
  1599. mon_pdev->ppdu_info.rx_status.ppdu_id =
  1600. mon_pdev->ppdu_info.com_info.ppdu_id;
  1601. /* Apply the radio header to this dummy skb */
  1602. if (!qdf_nbuf_update_radiotap(&mon_pdev->ppdu_info.rx_status, dummy_msdu,
  1603. qdf_nbuf_headroom(dummy_msdu))) {
  1604. DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
  1605. qdf_nbuf_free(dummy_msdu);
  1606. goto mon_deliver_non_std_fail;
  1607. }
  1608. /* deliver to the user layer application */
  1609. osif_rx_mon(mon_pdev->mvdev->osif_vdev,
  1610. dummy_msdu, NULL);
  1611. /* Clear rx_status*/
  1612. qdf_mem_zero(&mon_pdev->ppdu_info.rx_status,
  1613. sizeof(mon_pdev->ppdu_info.rx_status));
  1614. mon_pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  1615. return QDF_STATUS_SUCCESS;
  1616. allocate_dummy_msdu_fail:
  1617. dp_rx_mon_dest_debug("%pK: mon_skb=%pK ",
  1618. soc, dummy_msdu);
  1619. mon_deliver_non_std_fail:
  1620. return QDF_STATUS_E_INVAL;
  1621. }
  1622. /**
  1623. * dp_rx_process_peer_based_pktlog() - Process Rx pktlog if peer based
  1624. * filtering enabled
  1625. * @soc: core txrx main context
  1626. * @ppdu_info: Structure for rx ppdu info
  1627. * @status_nbuf: Qdf nbuf abstraction for linux skb
  1628. * @pdev_id: mac_id/pdev_id correspondinggly for MCL and WIN
  1629. *
  1630. * Return: none
  1631. */
  1632. void
  1633. dp_rx_process_peer_based_pktlog(struct dp_soc *soc,
  1634. struct hal_rx_ppdu_info *ppdu_info,
  1635. qdf_nbuf_t status_nbuf, uint32_t pdev_id)
  1636. {
  1637. struct dp_peer *peer;
  1638. struct mon_rx_user_status *rx_user_status;
  1639. uint32_t num_users = ppdu_info->com_info.num_users;
  1640. uint16_t sw_peer_id;
  1641. /* Sanity check for num_users */
  1642. if (!num_users)
  1643. return;
  1644. qdf_assert_always(num_users <= CDP_MU_MAX_USERS);
  1645. rx_user_status = &ppdu_info->rx_user_status[num_users - 1];
  1646. sw_peer_id = rx_user_status->sw_peer_id;
  1647. peer = dp_peer_get_ref_by_id(soc, sw_peer_id,
  1648. DP_MOD_ID_RX_PPDU_STATS);
  1649. if (!peer)
  1650. return;
  1651. if ((peer->peer_id != HTT_INVALID_PEER) && (peer->monitor_peer) &&
  1652. (peer->monitor_peer->peer_based_pktlog_filter)) {
  1653. dp_wdi_event_handler(
  1654. WDI_EVENT_RX_DESC, soc,
  1655. status_nbuf,
  1656. peer->peer_id,
  1657. WDI_NO_VAL, pdev_id);
  1658. }
  1659. dp_peer_unref_delete(peer,
  1660. DP_MOD_ID_RX_PPDU_STATS);
  1661. }