dp_rx_mon.c 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879
  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. rx_user_status->preamble_type;
  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. if (rx_stats_peruser->mpdu_cnt_fcs_ok > 1)
  400. rx_stats_peruser->is_ampdu = 1;
  401. else
  402. rx_stats_peruser->is_ampdu = 0;
  403. rx_stats_peruser->tid = ppdu_info->rx_status.tid;
  404. qdf_mem_copy(rx_stats_peruser->mac_addr,
  405. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  406. rx_stats_peruser->peer_id = peer->peer_id;
  407. cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
  408. rx_stats_peruser->vdev_id = peer->vdev->vdev_id;
  409. rx_stats_peruser->mu_ul_info_valid = 0;
  410. mon_ops = dp_mon_ops_get(soc);
  411. if (mon_ops && mon_ops->mon_rx_populate_ppdu_usr_info)
  412. mon_ops->mon_rx_populate_ppdu_usr_info(rx_user_status,
  413. rx_stats_peruser);
  414. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  415. if (cdp_rx_ppdu->u.ppdu_type == HAL_RX_TYPE_MU_OFDMA ||
  416. cdp_rx_ppdu->u.ppdu_type == HAL_RX_TYPE_MU_MIMO) {
  417. if (rx_user_status->mu_ul_info_valid) {
  418. rx_stats_peruser->nss = rx_user_status->nss;
  419. rx_stats_peruser->mcs = rx_user_status->mcs;
  420. rx_stats_peruser->mu_ul_info_valid =
  421. rx_user_status->mu_ul_info_valid;
  422. rx_stats_peruser->ofdma_ru_start_index =
  423. rx_user_status->ofdma_ru_start_index;
  424. rx_stats_peruser->ofdma_ru_width =
  425. rx_user_status->ofdma_ru_width;
  426. rx_stats_peruser->user_index = i;
  427. ru_size = rx_user_status->ofdma_ru_size;
  428. /*
  429. * max RU size will be equal to
  430. * HTT_UL_OFDMA_V0_RU_SIZE_RU_996x2
  431. */
  432. if (ru_size >= OFDMA_NUM_RU_SIZE) {
  433. dp_err("invalid ru_size %d\n",
  434. ru_size);
  435. return;
  436. }
  437. is_data = dp_rx_inc_rusize_cnt(pdev,
  438. rx_user_status);
  439. }
  440. if (is_data) {
  441. /* counter to get number of MU OFDMA */
  442. pdev->stats.ul_ofdma.data_rx_ppdu++;
  443. pdev->stats.ul_ofdma.data_users[num_users]++;
  444. }
  445. }
  446. }
  447. }
  448. /**
  449. * dp_rx_populate_cdp_indication_ppdu() - Populate cdp rx indication structure
  450. * @pdev: pdev ctx
  451. * @ppdu_info: ppdu info structure from ppdu ring
  452. * @cdp_rx_ppdu: Rx PPDU indication structure
  453. *
  454. * Return: none
  455. */
  456. static void
  457. dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
  458. struct hal_rx_ppdu_info *ppdu_info,
  459. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  460. {
  461. struct dp_peer *peer;
  462. struct dp_soc *soc = pdev->soc;
  463. uint32_t i;
  464. struct dp_mon_ops *mon_ops;
  465. uint16_t sw_peer_id;
  466. struct mon_rx_user_status *rx_user_status;
  467. uint32_t num_users = ppdu_info->com_info.num_users;
  468. cdp_rx_ppdu->first_data_seq_ctrl =
  469. ppdu_info->rx_status.first_data_seq_ctrl;
  470. cdp_rx_ppdu->frame_ctrl =
  471. ppdu_info->rx_status.frame_control;
  472. cdp_rx_ppdu->tcp_msdu_count = ppdu_info->rx_status.tcp_msdu_count;
  473. cdp_rx_ppdu->udp_msdu_count = ppdu_info->rx_status.udp_msdu_count;
  474. cdp_rx_ppdu->other_msdu_count = ppdu_info->rx_status.other_msdu_count;
  475. cdp_rx_ppdu->u.preamble = ppdu_info->rx_status.preamble_type;
  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.bw = ppdu_info->rx_status.bw;
  507. cdp_rx_ppdu->u.nss = ppdu_info->rx_status.nss;
  508. cdp_rx_ppdu->u.mcs = ppdu_info->rx_status.mcs;
  509. if ((ppdu_info->rx_status.sgi == VHT_SGI_NYSM) &&
  510. (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC))
  511. cdp_rx_ppdu->u.gi = CDP_SGI_0_4_US;
  512. else
  513. cdp_rx_ppdu->u.gi = ppdu_info->rx_status.sgi;
  514. cdp_rx_ppdu->u.ldpc = ppdu_info->rx_status.ldpc;
  515. cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
  516. cdp_rx_ppdu->u.ltf_size = (ppdu_info->rx_status.he_data5 >>
  517. QDF_MON_STATUS_HE_LTF_SIZE_SHIFT) & 0x3;
  518. cdp_rx_ppdu->rssi = ppdu_info->rx_status.rssi_comb;
  519. cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
  520. cdp_rx_ppdu->channel = ppdu_info->rx_status.chan_num;
  521. cdp_rx_ppdu->beamformed = ppdu_info->rx_status.beamformed;
  522. cdp_rx_ppdu->num_bytes = ppdu_info->rx_status.ppdu_len;
  523. cdp_rx_ppdu->lsig_a = ppdu_info->rx_status.rate;
  524. cdp_rx_ppdu->u.ltf_size = ppdu_info->rx_status.ltf_size;
  525. if (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC) {
  526. cdp_rx_ppdu->u.stbc = ppdu_info->rx_status.is_stbc;
  527. } else if (ppdu_info->rx_status.preamble_type ==
  528. HAL_RX_PKT_TYPE_11AX) {
  529. cdp_rx_ppdu->u.stbc = (ppdu_info->rx_status.he_data3 >>
  530. QDF_MON_STATUS_STBC_SHIFT) & 0x1;
  531. cdp_rx_ppdu->u.dcm = (ppdu_info->rx_status.he_data3 >>
  532. QDF_MON_STATUS_DCM_SHIFT) & 0x1;
  533. }
  534. dp_rx_populate_rx_rssi_chain(ppdu_info, cdp_rx_ppdu);
  535. dp_rx_populate_su_evm_details(ppdu_info, cdp_rx_ppdu);
  536. cdp_rx_ppdu->rx_antenna = ppdu_info->rx_status.rx_antenna;
  537. mon_ops = dp_mon_ops_get(pdev->soc);
  538. if (mon_ops && mon_ops->mon_rx_populate_ppdu_info)
  539. mon_ops->mon_rx_populate_ppdu_info(ppdu_info,
  540. cdp_rx_ppdu);
  541. cdp_rx_ppdu->nf = ppdu_info->rx_status.chan_noise_floor;
  542. for (i = 0; i < MAX_CHAIN; i++)
  543. cdp_rx_ppdu->per_chain_rssi[i] = ppdu_info->rx_status.rssi[i];
  544. cdp_rx_ppdu->is_mcast_bcast = ppdu_info->nac_info.mcast_bcast;
  545. cdp_rx_ppdu->num_users = ppdu_info->com_info.num_users;
  546. cdp_rx_ppdu->num_mpdu = 0;
  547. cdp_rx_ppdu->num_msdu = 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. enum PUNCTURED_MODES punc_mode = NO_PUNCTURE;
  574. struct dp_mon_peer *mon_peer = NULL;
  575. if (!peer || !ppdu)
  576. return;
  577. mon_peer = peer->monitor_peer;
  578. ppdu_user = &ppdu->user[user];
  579. if (!mon_peer)
  580. return;
  581. if (ppdu->u.ppdu_type != HAL_RX_TYPE_SU) {
  582. if (ppdu_user->nss == 0)
  583. nss = 0;
  584. else
  585. nss = ppdu_user->nss - 1;
  586. mcs = ppdu_user->mcs;
  587. mon_peer->stats.rx.nss_info = ppdu_user->nss;
  588. mon_peer->stats.rx.mcs_info = ppdu_user->mcs;
  589. } else {
  590. if (ppdu->u.nss == 0)
  591. nss = 0;
  592. else
  593. nss = ppdu->u.nss - 1;
  594. mcs = ppdu->u.mcs;
  595. mon_peer->stats.rx.nss_info = ppdu->u.nss;
  596. mon_peer->stats.rx.mcs_info = ppdu->u.mcs;
  597. }
  598. ratekbps = dp_getrateindex(ppdu->u.gi,
  599. mcs,
  600. nss,
  601. ppdu->u.preamble,
  602. ppdu->u.bw,
  603. punc_mode,
  604. &rix,
  605. &ratecode);
  606. if (!ratekbps) {
  607. ppdu->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. DP_STATS_UPD(mon_peer, rx.last_rx_rate, ratekbps);
  618. mon_peer->stats.rx.avg_rx_rate =
  619. dp_ath_rate_lpf(mon_peer->stats.rx.avg_rx_rate, ratekbps);
  620. ppdu_rx_rate = dp_ath_rate_out(mon_peer->stats.rx.avg_rx_rate);
  621. DP_STATS_UPD(mon_peer, rx.rnd_avg_rx_rate, ppdu_rx_rate);
  622. ppdu->rx_ratekbps = ratekbps;
  623. ppdu->rx_ratecode = ratecode;
  624. ppdu_user->rx_ratekbps = ratekbps;
  625. if (peer->vdev)
  626. peer->vdev->stats.rx.last_rx_rate = ratekbps;
  627. }
  628. #ifdef WLAN_FEATURE_11BE
  629. static inline uint8_t dp_get_bw_offset_frm_bw(struct dp_soc *soc,
  630. enum CMN_BW_TYPES bw)
  631. {
  632. uint8_t pkt_bw_offset;
  633. switch (bw) {
  634. case CMN_BW_20MHZ:
  635. pkt_bw_offset = PKT_BW_GAIN_20MHZ;
  636. break;
  637. case CMN_BW_40MHZ:
  638. pkt_bw_offset = PKT_BW_GAIN_40MHZ;
  639. break;
  640. case CMN_BW_80MHZ:
  641. pkt_bw_offset = PKT_BW_GAIN_80MHZ;
  642. break;
  643. case CMN_BW_160MHZ:
  644. pkt_bw_offset = PKT_BW_GAIN_160MHZ;
  645. break;
  646. case CMN_BW_320MHZ:
  647. pkt_bw_offset = PKT_BW_GAIN_320MHZ;
  648. break;
  649. default:
  650. pkt_bw_offset = 0;
  651. dp_rx_mon_status_debug("%pK: Invalid BW index = %d",
  652. soc, bw);
  653. }
  654. return pkt_bw_offset;
  655. }
  656. #else
  657. static inline uint8_t dp_get_bw_offset_frm_bw(struct dp_soc *soc,
  658. enum CMN_BW_TYPES bw)
  659. {
  660. uint8_t pkt_bw_offset;
  661. switch (bw) {
  662. case CMN_BW_20MHZ:
  663. pkt_bw_offset = PKT_BW_GAIN_20MHZ;
  664. break;
  665. case CMN_BW_40MHZ:
  666. pkt_bw_offset = PKT_BW_GAIN_40MHZ;
  667. break;
  668. case CMN_BW_80MHZ:
  669. pkt_bw_offset = PKT_BW_GAIN_80MHZ;
  670. break;
  671. case CMN_BW_160MHZ:
  672. pkt_bw_offset = PKT_BW_GAIN_160MHZ;
  673. break;
  674. default:
  675. pkt_bw_offset = 0;
  676. dp_rx_mon_status_debug("%pK: Invalid BW index = %d",
  677. soc, bw);
  678. }
  679. return pkt_bw_offset;
  680. }
  681. #endif
  682. static void dp_rx_stats_update(struct dp_pdev *pdev,
  683. struct cdp_rx_indication_ppdu *ppdu)
  684. {
  685. struct dp_soc *soc = NULL;
  686. uint8_t mcs, preamble, ac = 0, nss, ppdu_type;
  687. uint16_t num_msdu;
  688. uint8_t pkt_bw_offset;
  689. struct dp_peer *peer;
  690. struct dp_mon_peer *mon_peer;
  691. struct cdp_rx_stats_ppdu_user *ppdu_user;
  692. uint32_t i;
  693. enum cdp_mu_packet_type mu_pkt_type;
  694. struct dp_mon_ops *mon_ops;
  695. struct dp_mon_pdev *mon_pdev = NULL;
  696. if (pdev)
  697. soc = pdev->soc;
  698. else
  699. return;
  700. if (!soc || soc->process_rx_status)
  701. return;
  702. mon_pdev = pdev->monitor_pdev;
  703. preamble = ppdu->u.preamble;
  704. ppdu_type = ppdu->u.ppdu_type;
  705. for (i = 0; i < ppdu->num_users && i < CDP_MU_MAX_USERS; i++) {
  706. peer = NULL;
  707. ppdu_user = &ppdu->user[i];
  708. peer = dp_peer_get_ref_by_id(soc, ppdu_user->peer_id,
  709. DP_MOD_ID_RX_PPDU_STATS);
  710. if (!peer)
  711. mon_peer = mon_pdev->invalid_mon_peer;
  712. else
  713. mon_peer = peer->monitor_peer;
  714. if (!mon_peer) {
  715. if (peer)
  716. dp_peer_unref_delete(peer,
  717. DP_MOD_ID_RX_PPDU_STATS);
  718. continue;
  719. }
  720. if ((preamble == DOT11_A) || (preamble == DOT11_B))
  721. ppdu->u.nss = 1;
  722. if (ppdu_type == HAL_RX_TYPE_SU) {
  723. mcs = ppdu->u.mcs;
  724. nss = ppdu->u.nss;
  725. } else {
  726. mcs = ppdu_user->mcs;
  727. nss = ppdu_user->nss;
  728. }
  729. num_msdu = ppdu_user->num_msdu;
  730. pkt_bw_offset = dp_get_bw_offset_frm_bw(soc, ppdu->u.bw);
  731. DP_STATS_UPD(mon_peer, rx.snr, (ppdu->rssi + pkt_bw_offset));
  732. if (mon_peer->stats.rx.avg_snr == CDP_INVALID_SNR)
  733. mon_peer->stats.rx.avg_snr =
  734. CDP_SNR_IN(mon_peer->stats.rx.snr);
  735. else
  736. CDP_SNR_UPDATE_AVG(mon_peer->stats.rx.avg_snr,
  737. mon_peer->stats.rx.snr);
  738. if (ppdu_type == HAL_RX_TYPE_SU) {
  739. if (nss) {
  740. DP_STATS_INC(mon_peer, rx.nss[nss - 1], num_msdu);
  741. DP_STATS_INC(mon_peer, rx.ppdu_nss[nss - 1], 1);
  742. }
  743. DP_STATS_INC(mon_peer, rx.mpdu_cnt_fcs_ok,
  744. ppdu_user->mpdu_cnt_fcs_ok);
  745. DP_STATS_INC(mon_peer, rx.mpdu_cnt_fcs_err,
  746. ppdu_user->mpdu_cnt_fcs_err);
  747. }
  748. if (ppdu_type >= HAL_RX_TYPE_MU_MIMO &&
  749. ppdu_type <= HAL_RX_TYPE_MU_OFDMA) {
  750. if (ppdu_type == HAL_RX_TYPE_MU_MIMO)
  751. mu_pkt_type = TXRX_TYPE_MU_MIMO;
  752. else
  753. mu_pkt_type = TXRX_TYPE_MU_OFDMA;
  754. if (nss) {
  755. DP_STATS_INC(mon_peer, rx.nss[nss - 1], num_msdu);
  756. DP_STATS_INC(mon_peer,
  757. rx.rx_mu[mu_pkt_type].ppdu_nss[nss - 1],
  758. 1);
  759. }
  760. DP_STATS_INC(mon_peer,
  761. rx.rx_mu[mu_pkt_type].mpdu_cnt_fcs_ok,
  762. ppdu_user->mpdu_cnt_fcs_ok);
  763. DP_STATS_INC(mon_peer,
  764. rx.rx_mu[mu_pkt_type].mpdu_cnt_fcs_err,
  765. ppdu_user->mpdu_cnt_fcs_err);
  766. }
  767. DP_STATS_INC(mon_peer, rx.sgi_count[ppdu->u.gi], num_msdu);
  768. DP_STATS_INC(mon_peer, rx.bw[ppdu->u.bw], num_msdu);
  769. DP_STATS_INC(mon_peer, rx.reception_type[ppdu->u.ppdu_type],
  770. num_msdu);
  771. DP_STATS_INC(mon_peer, rx.ppdu_cnt[ppdu->u.ppdu_type], 1);
  772. DP_STATS_INCC(mon_peer, rx.ampdu_cnt, num_msdu,
  773. ppdu_user->is_ampdu);
  774. DP_STATS_INCC(mon_peer, rx.non_ampdu_cnt, num_msdu,
  775. !(ppdu_user->is_ampdu));
  776. DP_STATS_UPD(mon_peer, rx.rx_rate, mcs);
  777. DP_STATS_INCC(mon_peer,
  778. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  779. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
  780. DP_STATS_INCC(mon_peer,
  781. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  782. ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
  783. DP_STATS_INCC(mon_peer,
  784. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  785. ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B)));
  786. DP_STATS_INCC(mon_peer,
  787. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  788. ((mcs < MAX_MCS_11B) && (preamble == DOT11_B)));
  789. DP_STATS_INCC(mon_peer,
  790. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  791. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N)));
  792. DP_STATS_INCC(mon_peer,
  793. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  794. ((mcs < MAX_MCS_11A) && (preamble == DOT11_N)));
  795. DP_STATS_INCC(mon_peer,
  796. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  797. ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC)));
  798. DP_STATS_INCC(mon_peer,
  799. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  800. ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
  801. DP_STATS_INCC(mon_peer,
  802. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  803. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  804. DP_STATS_INCC(mon_peer,
  805. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  806. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  807. DP_STATS_INCC(mon_peer,
  808. rx.su_ax_ppdu_cnt.mcs_count[MAX_MCS - 1], 1,
  809. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX) &&
  810. (ppdu_type == HAL_RX_TYPE_SU)));
  811. DP_STATS_INCC(mon_peer,
  812. rx.su_ax_ppdu_cnt.mcs_count[mcs], 1,
  813. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX) &&
  814. (ppdu_type == HAL_RX_TYPE_SU)));
  815. DP_STATS_INCC(mon_peer,
  816. rx.rx_mu[TXRX_TYPE_MU_OFDMA].ppdu.mcs_count[MAX_MCS - 1],
  817. 1, ((mcs >= (MAX_MCS - 1)) &&
  818. (preamble == DOT11_AX) &&
  819. (ppdu_type == HAL_RX_TYPE_MU_OFDMA)));
  820. DP_STATS_INCC(mon_peer,
  821. rx.rx_mu[TXRX_TYPE_MU_OFDMA].ppdu.mcs_count[mcs],
  822. 1, ((mcs < (MAX_MCS - 1)) &&
  823. (preamble == DOT11_AX) &&
  824. (ppdu_type == HAL_RX_TYPE_MU_OFDMA)));
  825. DP_STATS_INCC(mon_peer,
  826. rx.rx_mu[TXRX_TYPE_MU_MIMO].ppdu.mcs_count[MAX_MCS - 1],
  827. 1, ((mcs >= (MAX_MCS - 1)) &&
  828. (preamble == DOT11_AX) &&
  829. (ppdu_type == HAL_RX_TYPE_MU_MIMO)));
  830. DP_STATS_INCC(mon_peer,
  831. rx.rx_mu[TXRX_TYPE_MU_MIMO].ppdu.mcs_count[mcs],
  832. 1, ((mcs < (MAX_MCS - 1)) &&
  833. (preamble == DOT11_AX) &&
  834. (ppdu_type == HAL_RX_TYPE_MU_MIMO)));
  835. /*
  836. * If invalid TID, it could be a non-qos frame, hence do not
  837. * update any AC counters
  838. */
  839. ac = TID_TO_WME_AC(ppdu_user->tid);
  840. if (ppdu->tid != HAL_TID_INVALID)
  841. DP_STATS_INC(mon_peer, rx.wme_ac_type[ac], num_msdu);
  842. DP_STATS_INC(mon_peer, rx.rx_ppdus, 1);
  843. DP_STATS_INC(mon_peer, rx.rx_mpdus,
  844. (ppdu_user->mpdu_cnt_fcs_ok + ppdu_user->mpdu_cnt_fcs_err));
  845. mon_ops = dp_mon_ops_get(soc);
  846. if (mon_ops && mon_ops->mon_rx_stats_update)
  847. mon_ops->mon_rx_stats_update(mon_peer, ppdu, ppdu_user);
  848. if (!peer)
  849. continue;
  850. dp_peer_stats_notify(pdev, peer);
  851. DP_STATS_UPD(mon_peer, rx.last_snr,
  852. (ppdu->rssi + pkt_bw_offset));
  853. dp_peer_qos_stats_notify(pdev, ppdu_user);
  854. if (dp_is_subtype_data(ppdu->frame_ctrl))
  855. dp_rx_rate_stats_update(peer, ppdu, i);
  856. dp_send_stats_event(pdev, peer, ppdu_user->peer_id);
  857. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  858. }
  859. }
  860. void
  861. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  862. struct hal_rx_ppdu_info *ppdu_info)
  863. {
  864. qdf_nbuf_t ppdu_nbuf;
  865. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  866. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  867. /*
  868. * Do not allocate if fcs error,
  869. * ast idx invalid / fctl invalid
  870. *
  871. * In CFR RCC mode - PPDU status TLVs of error pkts are also needed
  872. */
  873. if (ppdu_info->com_info.mpdu_cnt_fcs_ok == 0)
  874. return;
  875. if (ppdu_info->nac_info.fc_valid &&
  876. ppdu_info->nac_info.to_ds_flag &&
  877. ppdu_info->nac_info.mac_addr2_valid) {
  878. struct dp_neighbour_peer *peer = NULL;
  879. uint8_t rssi = ppdu_info->rx_status.rssi_comb;
  880. qdf_spin_lock_bh(&mon_pdev->neighbour_peer_mutex);
  881. if (mon_pdev->neighbour_peers_added) {
  882. TAILQ_FOREACH(peer, &mon_pdev->neighbour_peers_list,
  883. neighbour_peer_list_elem) {
  884. if (!qdf_mem_cmp(&peer->neighbour_peers_macaddr,
  885. &ppdu_info->nac_info.mac_addr2,
  886. QDF_MAC_ADDR_SIZE)) {
  887. peer->rssi = rssi;
  888. break;
  889. }
  890. }
  891. }
  892. qdf_spin_unlock_bh(&mon_pdev->neighbour_peer_mutex);
  893. } else {
  894. dp_info("Neighbour peers RSSI update failed! fc_valid = %d, to_ds_flag = %d and mac_addr2_valid = %d",
  895. ppdu_info->nac_info.fc_valid,
  896. ppdu_info->nac_info.to_ds_flag,
  897. ppdu_info->nac_info.mac_addr2_valid);
  898. }
  899. /* need not generate wdi event when mcopy, cfr rcc mode and
  900. * enhanced stats are not enabled
  901. */
  902. if (!mon_pdev->mcopy_mode && !mon_pdev->enhanced_stats_en &&
  903. !dp_cfr_rcc_mode_status(pdev))
  904. return;
  905. if (dp_cfr_rcc_mode_status(pdev))
  906. dp_update_cfr_dbg_stats(pdev, ppdu_info);
  907. if (!ppdu_info->rx_status.frame_control_info_valid ||
  908. (ppdu_info->rx_status.ast_index == HAL_AST_IDX_INVALID)) {
  909. if (!(mon_pdev->mcopy_mode ||
  910. (dp_bb_captured_chan_status(pdev, ppdu_info) ==
  911. QDF_STATUS_SUCCESS)))
  912. return;
  913. }
  914. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  915. sizeof(struct cdp_rx_indication_ppdu),
  916. 0, 0, FALSE);
  917. if (ppdu_nbuf) {
  918. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)qdf_nbuf_data(ppdu_nbuf);
  919. qdf_mem_zero(cdp_rx_ppdu, sizeof(struct cdp_rx_indication_ppdu));
  920. dp_rx_mon_populate_cfr_info(pdev, ppdu_info, cdp_rx_ppdu);
  921. dp_rx_populate_cdp_indication_ppdu(pdev,
  922. ppdu_info, cdp_rx_ppdu);
  923. if (!qdf_nbuf_put_tail(ppdu_nbuf,
  924. sizeof(struct cdp_rx_indication_ppdu)))
  925. return;
  926. dp_rx_stats_update(pdev, cdp_rx_ppdu);
  927. if (cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) {
  928. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC,
  929. soc, ppdu_nbuf,
  930. cdp_rx_ppdu->peer_id,
  931. WDI_NO_VAL, pdev->pdev_id);
  932. } else if (mon_pdev->mcopy_mode || dp_cfr_rcc_mode_status(pdev)) {
  933. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
  934. ppdu_nbuf, HTT_INVALID_PEER,
  935. WDI_NO_VAL, pdev->pdev_id);
  936. } else {
  937. qdf_nbuf_free(ppdu_nbuf);
  938. }
  939. }
  940. }
  941. #endif/* QCA_ENHANCED_STATS_SUPPORT */
  942. #ifdef QCA_UNDECODED_METADATA_SUPPORT
  943. /**
  944. * dp_rx_populate_cdp_indication_ppdu_undecoded_metadata() - Populate cdp
  945. * rx indication structure
  946. * @pdev: pdev ctx
  947. * @ppdu_info: ppdu info structure from ppdu ring
  948. * @cdp_rx_ppdu: Rx PPDU indication structure
  949. *
  950. * Return: none
  951. */
  952. static void
  953. dp_rx_populate_cdp_indication_ppdu_undecoded_metadata(struct dp_pdev *pdev,
  954. struct hal_rx_ppdu_info *ppdu_info,
  955. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  956. {
  957. uint32_t chain;
  958. cdp_rx_ppdu->phyrx_abort = ppdu_info->rx_status.phyrx_abort;
  959. cdp_rx_ppdu->phyrx_abort_reason =
  960. ppdu_info->rx_status.phyrx_abort_reason;
  961. cdp_rx_ppdu->first_data_seq_ctrl =
  962. ppdu_info->rx_status.first_data_seq_ctrl;
  963. cdp_rx_ppdu->frame_ctrl =
  964. ppdu_info->rx_status.frame_control;
  965. cdp_rx_ppdu->tcp_msdu_count = ppdu_info->rx_status.tcp_msdu_count;
  966. cdp_rx_ppdu->udp_msdu_count = ppdu_info->rx_status.udp_msdu_count;
  967. cdp_rx_ppdu->other_msdu_count = ppdu_info->rx_status.other_msdu_count;
  968. cdp_rx_ppdu->u.preamble = ppdu_info->rx_status.preamble_type;
  969. cdp_rx_ppdu->num_mpdu = ppdu_info->com_info.mpdu_cnt_fcs_ok;
  970. cdp_rx_ppdu->num_msdu = (cdp_rx_ppdu->tcp_msdu_count +
  971. cdp_rx_ppdu->udp_msdu_count +
  972. cdp_rx_ppdu->other_msdu_count);
  973. cdp_rx_ppdu->retries = CDP_FC_IS_RETRY_SET(cdp_rx_ppdu->frame_ctrl) ?
  974. ppdu_info->com_info.mpdu_cnt_fcs_ok : 0;
  975. if (ppdu_info->com_info.mpdu_cnt_fcs_ok > 1)
  976. cdp_rx_ppdu->is_ampdu = 1;
  977. else
  978. cdp_rx_ppdu->is_ampdu = 0;
  979. cdp_rx_ppdu->tid = ppdu_info->rx_status.tid;
  980. cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
  981. cdp_rx_ppdu->length = ppdu_info->rx_status.ppdu_len;
  982. cdp_rx_ppdu->duration = ppdu_info->rx_status.duration;
  983. cdp_rx_ppdu->u.bw = ppdu_info->rx_status.bw;
  984. cdp_rx_ppdu->u.nss = ppdu_info->rx_status.nss;
  985. cdp_rx_ppdu->u.mcs = ppdu_info->rx_status.mcs;
  986. if (ppdu_info->rx_status.sgi == VHT_SGI_NYSM &&
  987. ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC)
  988. cdp_rx_ppdu->u.gi = CDP_SGI_0_4_US;
  989. else
  990. cdp_rx_ppdu->u.gi = ppdu_info->rx_status.sgi;
  991. cdp_rx_ppdu->u.ldpc = ppdu_info->rx_status.ldpc;
  992. cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
  993. cdp_rx_ppdu->u.ltf_size = (ppdu_info->rx_status.he_data5 >>
  994. QDF_MON_STATUS_HE_LTF_SIZE_SHIFT) & 0x3;
  995. cdp_rx_ppdu->rssi = ppdu_info->rx_status.rssi_comb;
  996. cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
  997. cdp_rx_ppdu->channel = ppdu_info->rx_status.chan_num;
  998. cdp_rx_ppdu->beamformed = ppdu_info->rx_status.beamformed;
  999. cdp_rx_ppdu->num_bytes = ppdu_info->rx_status.ppdu_len;
  1000. cdp_rx_ppdu->lsig_a = ppdu_info->rx_status.rate;
  1001. cdp_rx_ppdu->u.ltf_size = ppdu_info->rx_status.ltf_size;
  1002. if (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC) {
  1003. cdp_rx_ppdu->u.stbc = ppdu_info->rx_status.is_stbc;
  1004. cdp_rx_ppdu->vht_no_txop_ps =
  1005. ppdu_info->rx_status.vht_no_txop_ps;
  1006. cdp_rx_ppdu->vht_crc = ppdu_info->rx_status.vht_crc;
  1007. cdp_rx_ppdu->group_id = ppdu_info->rx_status.vht_flag_values5;
  1008. } else if (ppdu_info->rx_status.preamble_type ==
  1009. HAL_RX_PKT_TYPE_11AX) {
  1010. cdp_rx_ppdu->u.stbc = (ppdu_info->rx_status.he_data3 >>
  1011. QDF_MON_STATUS_STBC_SHIFT) & 0x1;
  1012. cdp_rx_ppdu->u.dcm = (ppdu_info->rx_status.he_data3 >>
  1013. QDF_MON_STATUS_DCM_SHIFT) & 0x1;
  1014. } else {
  1015. cdp_rx_ppdu->u.stbc = ppdu_info->rx_status.ht_stbc;
  1016. cdp_rx_ppdu->ht_length = ppdu_info->rx_status.ht_length;
  1017. cdp_rx_ppdu->ht_smoothing = ppdu_info->rx_status.smoothing;
  1018. cdp_rx_ppdu->ht_not_sounding =
  1019. ppdu_info->rx_status.not_sounding;
  1020. cdp_rx_ppdu->ht_aggregation = ppdu_info->rx_status.aggregation;
  1021. cdp_rx_ppdu->ht_stbc = ppdu_info->rx_status.ht_stbc;
  1022. cdp_rx_ppdu->ht_crc = ppdu_info->rx_status.ht_crc;
  1023. }
  1024. cdp_rx_ppdu->l_sig_length = ppdu_info->rx_status.l_sig_length;
  1025. cdp_rx_ppdu->l_sig_a_parity = ppdu_info->rx_status.l_sig_a_parity;
  1026. cdp_rx_ppdu->l_sig_a_pkt_type = ppdu_info->rx_status.l_sig_a_pkt_type;
  1027. if (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AX) {
  1028. cdp_rx_ppdu->he_crc = ppdu_info->rx_status.he_crc;
  1029. cdp_rx_ppdu->bss_color_id =
  1030. ppdu_info->rx_status.he_data3 & 0x3F;
  1031. cdp_rx_ppdu->beam_change = (ppdu_info->rx_status.he_data3 >>
  1032. QDF_MON_STATUS_BEAM_CHANGE_SHIFT) & 0x1;
  1033. cdp_rx_ppdu->dl_ul_flag = (ppdu_info->rx_status.he_data3 >>
  1034. QDF_MON_STATUS_DL_UL_SHIFT) & 0x1;
  1035. cdp_rx_ppdu->ldpc_extra_sym = (ppdu_info->rx_status.he_data3 >>
  1036. QDF_MON_STATUS_LDPC_EXTRA_SYMBOL_SHIFT) & 0x1;
  1037. cdp_rx_ppdu->special_reuse =
  1038. ppdu_info->rx_status.he_data4 & 0xF;
  1039. cdp_rx_ppdu->ltf_sym = (ppdu_info->rx_status.he_data5 >>
  1040. QDF_MON_STATUS_HE_LTF_SYM_SHIFT) & 0x7;
  1041. cdp_rx_ppdu->txbf = (ppdu_info->rx_status.he_data5 >>
  1042. QDF_MON_STATUS_TXBF_SHIFT) & 0x1;
  1043. cdp_rx_ppdu->pe_disambiguity = (ppdu_info->rx_status.he_data5 >>
  1044. QDF_MON_STATUS_PE_DISAMBIGUITY_SHIFT) & 0x1;
  1045. cdp_rx_ppdu->pre_fec_pad = (ppdu_info->rx_status.he_data5 >>
  1046. QDF_MON_STATUS_PRE_FEC_PAD_SHIFT) & 0x3;
  1047. cdp_rx_ppdu->dopplar = (ppdu_info->rx_status.he_data6 >>
  1048. QDF_MON_STATUS_DOPPLER_SHIFT) & 0x1;
  1049. cdp_rx_ppdu->txop_duration = (ppdu_info->rx_status.he_data6 >>
  1050. QDF_MON_STATUS_TXOP_SHIFT) & 0x7F;
  1051. cdp_rx_ppdu->sig_b_mcs = ppdu_info->rx_status.he_flags1 & 0x7;
  1052. cdp_rx_ppdu->sig_b_dcm = (ppdu_info->rx_status.he_flags1 >>
  1053. QDF_MON_STATUS_DCM_FLAG_1_SHIFT) & 0x1;
  1054. cdp_rx_ppdu->sig_b_sym = (ppdu_info->rx_status.he_flags2 >>
  1055. QDF_MON_STATUS_NUM_SIG_B_SYMBOLS_SHIFT) & 0xF;
  1056. cdp_rx_ppdu->sig_b_comp = (ppdu_info->rx_status.he_flags2 >>
  1057. QDF_MON_STATUS_SIG_B_COMPRESSION_FLAG_2_SHIFT) & 0x1;
  1058. }
  1059. dp_rx_populate_rx_rssi_chain(ppdu_info, cdp_rx_ppdu);
  1060. dp_rx_populate_su_evm_details(ppdu_info, cdp_rx_ppdu);
  1061. cdp_rx_ppdu->rx_antenna = ppdu_info->rx_status.rx_antenna;
  1062. cdp_rx_ppdu->nf = ppdu_info->rx_status.chan_noise_floor;
  1063. for (chain = 0; chain < MAX_CHAIN; chain++)
  1064. cdp_rx_ppdu->per_chain_rssi[chain] =
  1065. ppdu_info->rx_status.rssi[chain];
  1066. cdp_rx_ppdu->is_mcast_bcast = ppdu_info->nac_info.mcast_bcast;
  1067. cdp_rx_ppdu->num_users = ppdu_info->com_info.num_users;
  1068. dp_rx_populate_cdp_indication_ppdu_user(pdev, ppdu_info, cdp_rx_ppdu);
  1069. }
  1070. void
  1071. dp_rx_handle_ppdu_undecoded_metadata(struct dp_soc *soc, struct dp_pdev *pdev,
  1072. struct hal_rx_ppdu_info *ppdu_info)
  1073. {
  1074. qdf_nbuf_t ppdu_nbuf;
  1075. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  1076. /* Return if RX_ABORT not set */
  1077. if (ppdu_info->rx_status.phyrx_abort == 0)
  1078. return;
  1079. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  1080. sizeof(struct cdp_rx_indication_ppdu),
  1081. 0, 0, FALSE);
  1082. if (ppdu_nbuf) {
  1083. cdp_rx_ppdu = ((struct cdp_rx_indication_ppdu *)
  1084. qdf_nbuf_data(ppdu_nbuf));
  1085. qdf_mem_zero(cdp_rx_ppdu,
  1086. sizeof(struct cdp_rx_indication_ppdu));
  1087. dp_rx_populate_cdp_indication_ppdu_undecoded_metadata(pdev,
  1088. ppdu_info, cdp_rx_ppdu);
  1089. if (!qdf_nbuf_put_tail(ppdu_nbuf,
  1090. sizeof(struct cdp_rx_indication_ppdu)))
  1091. return;
  1092. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC_UNDECODED_METADATA,
  1093. soc, ppdu_nbuf, HTT_INVALID_PEER,
  1094. WDI_NO_VAL, pdev->pdev_id);
  1095. }
  1096. }
  1097. #endif/* QCA_UNDECODED_METADATA_SUPPORT */
  1098. #ifdef QCA_MCOPY_SUPPORT
  1099. QDF_STATUS
  1100. dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  1101. struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf,
  1102. uint8_t fcs_ok_mpdu_cnt, bool deliver_frame)
  1103. {
  1104. uint16_t size = 0;
  1105. struct ieee80211_frame *wh;
  1106. uint32_t *nbuf_data;
  1107. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1108. if (!ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload)
  1109. return QDF_STATUS_SUCCESS;
  1110. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  1111. if (mon_pdev->mcopy_mode == M_COPY) {
  1112. if (mon_pdev->m_copy_id.rx_ppdu_id == ppdu_info->com_info.ppdu_id)
  1113. return QDF_STATUS_SUCCESS;
  1114. }
  1115. wh = (struct ieee80211_frame *)(ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload + 4);
  1116. size = (ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload -
  1117. qdf_nbuf_data(nbuf));
  1118. if (qdf_nbuf_pull_head(nbuf, size) == NULL)
  1119. return QDF_STATUS_SUCCESS;
  1120. if (((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  1121. IEEE80211_FC0_TYPE_MGT) ||
  1122. ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  1123. IEEE80211_FC0_TYPE_CTL)) {
  1124. return QDF_STATUS_SUCCESS;
  1125. }
  1126. nbuf_data = (uint32_t *)qdf_nbuf_data(nbuf);
  1127. *nbuf_data = mon_pdev->ppdu_info.com_info.ppdu_id;
  1128. /* only retain RX MSDU payload in the skb */
  1129. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) - ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].payload_len);
  1130. if (deliver_frame) {
  1131. mon_pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
  1132. dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
  1133. nbuf, HTT_INVALID_PEER,
  1134. WDI_NO_VAL, pdev->pdev_id);
  1135. }
  1136. return QDF_STATUS_E_ALREADY;
  1137. }
  1138. void
  1139. dp_rx_mcopy_handle_last_mpdu(struct dp_soc *soc, struct dp_pdev *pdev,
  1140. struct hal_rx_ppdu_info *ppdu_info,
  1141. qdf_nbuf_t status_nbuf)
  1142. {
  1143. QDF_STATUS mcopy_status;
  1144. qdf_nbuf_t nbuf_clone = NULL;
  1145. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1146. /* If the MPDU end tlv and RX header are received in different buffers,
  1147. * process the RX header based on fcs status.
  1148. */
  1149. if (mon_pdev->mcopy_status_nbuf) {
  1150. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  1151. if (mon_pdev->mcopy_mode == M_COPY) {
  1152. if (mon_pdev->m_copy_id.rx_ppdu_id ==
  1153. ppdu_info->com_info.ppdu_id)
  1154. goto end1;
  1155. }
  1156. if (ppdu_info->is_fcs_passed) {
  1157. nbuf_clone = qdf_nbuf_clone(mon_pdev->mcopy_status_nbuf);
  1158. if (!nbuf_clone) {
  1159. QDF_TRACE(QDF_MODULE_ID_TXRX,
  1160. QDF_TRACE_LEVEL_ERROR,
  1161. "Failed to clone nbuf");
  1162. goto end1;
  1163. }
  1164. mon_pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
  1165. dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
  1166. nbuf_clone,
  1167. HTT_INVALID_PEER,
  1168. WDI_NO_VAL, pdev->pdev_id);
  1169. ppdu_info->is_fcs_passed = false;
  1170. }
  1171. end1:
  1172. qdf_nbuf_free(mon_pdev->mcopy_status_nbuf);
  1173. mon_pdev->mcopy_status_nbuf = NULL;
  1174. }
  1175. /* If the MPDU end tlv and RX header are received in different buffers,
  1176. * preserve the RX header as the fcs status will be received in MPDU
  1177. * end tlv in next buffer. So, cache the buffer to be processd in next
  1178. * iteration
  1179. */
  1180. if ((ppdu_info->fcs_ok_cnt + ppdu_info->fcs_err_cnt) !=
  1181. ppdu_info->com_info.mpdu_cnt) {
  1182. mon_pdev->mcopy_status_nbuf = qdf_nbuf_clone(status_nbuf);
  1183. if (mon_pdev->mcopy_status_nbuf) {
  1184. mcopy_status = dp_rx_handle_mcopy_mode(
  1185. soc, pdev,
  1186. ppdu_info,
  1187. mon_pdev->mcopy_status_nbuf,
  1188. ppdu_info->fcs_ok_cnt,
  1189. false);
  1190. if (mcopy_status == QDF_STATUS_SUCCESS) {
  1191. qdf_nbuf_free(mon_pdev->mcopy_status_nbuf);
  1192. mon_pdev->mcopy_status_nbuf = NULL;
  1193. }
  1194. }
  1195. }
  1196. }
  1197. void
  1198. dp_rx_mcopy_process_ppdu_info(struct dp_pdev *pdev,
  1199. struct hal_rx_ppdu_info *ppdu_info,
  1200. uint32_t tlv_status)
  1201. {
  1202. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1203. if (!mon_pdev->mcopy_mode)
  1204. return;
  1205. /* The fcs status is received in MPDU end tlv. If the RX header
  1206. * and its MPDU end tlv are received in different status buffer then
  1207. * to process that header ppdu_info->is_fcs_passed is used.
  1208. * If end tlv is received in next status buffer then com_info.mpdu_cnt
  1209. * will be 0 at the time of receiving MPDU end tlv and we update the
  1210. * is_fcs_passed flag based on ppdu_info->fcs_err.
  1211. */
  1212. if (tlv_status != HAL_TLV_STATUS_MPDU_END)
  1213. return;
  1214. if (!ppdu_info->fcs_err) {
  1215. if (ppdu_info->fcs_ok_cnt >
  1216. HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER) {
  1217. dp_err("No. of MPDUs(%d) per status buff exceeded",
  1218. ppdu_info->fcs_ok_cnt);
  1219. return;
  1220. }
  1221. if (ppdu_info->com_info.mpdu_cnt)
  1222. ppdu_info->fcs_ok_cnt++;
  1223. else
  1224. ppdu_info->is_fcs_passed = true;
  1225. } else {
  1226. if (ppdu_info->com_info.mpdu_cnt)
  1227. ppdu_info->fcs_err_cnt++;
  1228. else
  1229. ppdu_info->is_fcs_passed = false;
  1230. }
  1231. }
  1232. void
  1233. dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  1234. struct hal_rx_ppdu_info *ppdu_info,
  1235. uint32_t tlv_status,
  1236. qdf_nbuf_t status_nbuf)
  1237. {
  1238. QDF_STATUS mcopy_status;
  1239. qdf_nbuf_t nbuf_clone = NULL;
  1240. uint8_t fcs_ok_mpdu_cnt = 0;
  1241. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1242. dp_rx_mcopy_handle_last_mpdu(soc, pdev, ppdu_info, status_nbuf);
  1243. if (qdf_unlikely(!ppdu_info->com_info.mpdu_cnt))
  1244. goto end;
  1245. if (qdf_unlikely(!ppdu_info->fcs_ok_cnt))
  1246. goto end;
  1247. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  1248. if (mon_pdev->mcopy_mode == M_COPY)
  1249. ppdu_info->fcs_ok_cnt = 1;
  1250. while (fcs_ok_mpdu_cnt < ppdu_info->fcs_ok_cnt) {
  1251. nbuf_clone = qdf_nbuf_clone(status_nbuf);
  1252. if (!nbuf_clone) {
  1253. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1254. "Failed to clone nbuf");
  1255. goto end;
  1256. }
  1257. mcopy_status = dp_rx_handle_mcopy_mode(soc, pdev,
  1258. ppdu_info,
  1259. nbuf_clone,
  1260. fcs_ok_mpdu_cnt,
  1261. true);
  1262. if (mcopy_status == QDF_STATUS_SUCCESS)
  1263. qdf_nbuf_free(nbuf_clone);
  1264. fcs_ok_mpdu_cnt++;
  1265. }
  1266. end:
  1267. qdf_nbuf_free(status_nbuf);
  1268. ppdu_info->fcs_ok_cnt = 0;
  1269. ppdu_info->fcs_err_cnt = 0;
  1270. ppdu_info->com_info.mpdu_cnt = 0;
  1271. qdf_mem_zero(&ppdu_info->ppdu_msdu_info,
  1272. HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER
  1273. * sizeof(struct hal_rx_msdu_payload_info));
  1274. }
  1275. #endif /* QCA_MCOPY_SUPPORT */
  1276. int
  1277. dp_rx_handle_smart_mesh_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  1278. struct hal_rx_ppdu_info *ppdu_info,
  1279. qdf_nbuf_t nbuf)
  1280. {
  1281. uint8_t size = 0;
  1282. struct dp_mon_vdev *mon_vdev;
  1283. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1284. if (!mon_pdev->mvdev) {
  1285. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1286. "[%s]:[%d] Monitor vdev is NULL !!",
  1287. __func__, __LINE__);
  1288. return 1;
  1289. }
  1290. mon_vdev = mon_pdev->mvdev->monitor_vdev;
  1291. if (!ppdu_info->msdu_info.first_msdu_payload) {
  1292. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1293. "[%s]:[%d] First msdu payload not present",
  1294. __func__, __LINE__);
  1295. return 1;
  1296. }
  1297. /* Adding 4 bytes to get to start of 802.11 frame after phy_ppdu_id */
  1298. size = (ppdu_info->msdu_info.first_msdu_payload -
  1299. qdf_nbuf_data(nbuf)) + 4;
  1300. ppdu_info->msdu_info.first_msdu_payload = NULL;
  1301. if (!qdf_nbuf_pull_head(nbuf, size)) {
  1302. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1303. "[%s]:[%d] No header present",
  1304. __func__, __LINE__);
  1305. return 1;
  1306. }
  1307. /* Only retain RX MSDU payload in the skb */
  1308. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
  1309. ppdu_info->msdu_info.payload_len);
  1310. if (!qdf_nbuf_update_radiotap(&mon_pdev->ppdu_info.rx_status, nbuf,
  1311. qdf_nbuf_headroom(nbuf))) {
  1312. DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
  1313. return 1;
  1314. }
  1315. mon_vdev->osif_rx_mon(mon_pdev->mvdev->osif_vdev,
  1316. nbuf, NULL);
  1317. mon_pdev->ppdu_info.rx_status.monitor_direct_used = 0;
  1318. return 0;
  1319. }
  1320. qdf_nbuf_t
  1321. dp_rx_nbuf_prepare(struct dp_soc *soc, struct dp_pdev *pdev)
  1322. {
  1323. uint8_t *buf;
  1324. int32_t nbuf_retry_count;
  1325. QDF_STATUS ret;
  1326. qdf_nbuf_t nbuf = NULL;
  1327. for (nbuf_retry_count = 0; nbuf_retry_count <
  1328. QDF_NBUF_ALLOC_MAP_RETRY_THRESHOLD;
  1329. nbuf_retry_count++) {
  1330. /* Allocate a new skb using alloc_skb */
  1331. nbuf = qdf_nbuf_alloc_no_recycler(RX_MON_STATUS_BUF_SIZE,
  1332. RX_MON_STATUS_BUF_RESERVATION,
  1333. RX_DATA_BUFFER_ALIGNMENT);
  1334. if (!nbuf) {
  1335. DP_STATS_INC(pdev, replenish.nbuf_alloc_fail, 1);
  1336. continue;
  1337. }
  1338. buf = qdf_nbuf_data(nbuf);
  1339. memset(buf, 0, RX_MON_STATUS_BUF_SIZE);
  1340. ret = qdf_nbuf_map_nbytes_single(soc->osdev, nbuf,
  1341. QDF_DMA_FROM_DEVICE,
  1342. RX_MON_STATUS_BUF_SIZE);
  1343. /* nbuf map failed */
  1344. if (qdf_unlikely(QDF_IS_STATUS_ERROR(ret))) {
  1345. qdf_nbuf_free(nbuf);
  1346. DP_STATS_INC(pdev, replenish.map_err, 1);
  1347. continue;
  1348. }
  1349. /* qdf_nbuf alloc and map succeeded */
  1350. break;
  1351. }
  1352. /* qdf_nbuf still alloc or map failed */
  1353. if (qdf_unlikely(nbuf_retry_count >=
  1354. QDF_NBUF_ALLOC_MAP_RETRY_THRESHOLD))
  1355. return NULL;
  1356. return nbuf;
  1357. }
  1358. #ifndef DISABLE_MON_CONFIG
  1359. uint32_t
  1360. dp_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  1361. uint32_t mac_id, uint32_t quota)
  1362. {
  1363. struct dp_mon_soc *mon_soc = soc->monitor_soc;
  1364. if (mon_soc && mon_soc->mon_rx_process)
  1365. return mon_soc->mon_rx_process(soc, int_ctx,
  1366. mac_id, quota);
  1367. return 0;
  1368. }
  1369. #else
  1370. uint32_t
  1371. dp_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  1372. uint32_t mac_id, uint32_t quota)
  1373. {
  1374. return 0;
  1375. }
  1376. #endif
  1377. /**
  1378. * dp_send_mgmt_packet_to_stack(): send indicataion to upper layers
  1379. *
  1380. * @soc: soc handle
  1381. * @nbuf: Mgmt packet
  1382. * @pdev: pdev handle
  1383. *
  1384. * Return: QDF_STATUS_SUCCESS on success
  1385. * QDF_STATUS_E_INVAL in error
  1386. */
  1387. #ifdef QCA_MCOPY_SUPPORT
  1388. static inline QDF_STATUS
  1389. dp_send_mgmt_packet_to_stack(struct dp_soc *soc,
  1390. qdf_nbuf_t nbuf,
  1391. struct dp_pdev *pdev)
  1392. {
  1393. uint32_t *nbuf_data;
  1394. struct ieee80211_frame *wh;
  1395. qdf_frag_t addr;
  1396. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1397. if (!nbuf)
  1398. return QDF_STATUS_E_INVAL;
  1399. /* Get addr pointing to80211 header */
  1400. addr = dp_rx_mon_get_nbuf_80211_hdr(nbuf);
  1401. if (qdf_unlikely(!addr)) {
  1402. qdf_nbuf_free(nbuf);
  1403. return QDF_STATUS_E_INVAL;
  1404. }
  1405. /*check if this is not a mgmt packet*/
  1406. wh = (struct ieee80211_frame *)addr;
  1407. if (((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=
  1408. IEEE80211_FC0_TYPE_MGT) &&
  1409. ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=
  1410. IEEE80211_FC0_TYPE_CTL)) {
  1411. qdf_nbuf_free(nbuf);
  1412. return QDF_STATUS_E_INVAL;
  1413. }
  1414. nbuf_data = (uint32_t *)qdf_nbuf_push_head(nbuf, 4);
  1415. if (!nbuf_data) {
  1416. QDF_TRACE(QDF_MODULE_ID_DP,
  1417. QDF_TRACE_LEVEL_ERROR,
  1418. FL("No headroom"));
  1419. qdf_nbuf_free(nbuf);
  1420. return QDF_STATUS_E_INVAL;
  1421. }
  1422. *nbuf_data = mon_pdev->ppdu_info.com_info.ppdu_id;
  1423. dp_wdi_event_handler(WDI_EVENT_RX_MGMT_CTRL, soc, nbuf,
  1424. HTT_INVALID_PEER,
  1425. WDI_NO_VAL, pdev->pdev_id);
  1426. return QDF_STATUS_SUCCESS;
  1427. }
  1428. #else
  1429. static inline QDF_STATUS
  1430. dp_send_mgmt_packet_to_stack(struct dp_soc *soc,
  1431. qdf_nbuf_t nbuf,
  1432. struct dp_pdev *pdev)
  1433. {
  1434. return QDF_STATUS_SUCCESS;
  1435. }
  1436. #endif /* QCA_MCOPY_SUPPORT */
  1437. QDF_STATUS dp_rx_mon_process_dest_pktlog(struct dp_soc *soc,
  1438. uint32_t mac_id,
  1439. qdf_nbuf_t mpdu)
  1440. {
  1441. uint32_t event, msdu_timestamp = 0;
  1442. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1443. void *data;
  1444. struct ieee80211_frame *wh;
  1445. uint8_t type, subtype;
  1446. struct dp_mon_pdev *mon_pdev;
  1447. if (!pdev)
  1448. return QDF_STATUS_E_INVAL;
  1449. mon_pdev = pdev->monitor_pdev;
  1450. if (mon_pdev->rx_pktlog_cbf) {
  1451. if (qdf_nbuf_get_nr_frags(mpdu))
  1452. data = qdf_nbuf_get_frag_addr(mpdu, 0);
  1453. else
  1454. data = qdf_nbuf_data(mpdu);
  1455. /* CBF logging required, doesn't matter if it is a full mode
  1456. * or lite mode.
  1457. * Need to look for mpdu with:
  1458. * TYPE = ACTION, SUBTYPE = NO ACK in the header
  1459. */
  1460. event = WDI_EVENT_RX_CBF;
  1461. wh = (struct ieee80211_frame *)data;
  1462. type = (wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
  1463. subtype = (wh)->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
  1464. if (type == IEEE80211_FC0_TYPE_MGT &&
  1465. subtype == IEEE80211_FCO_SUBTYPE_ACTION_NO_ACK) {
  1466. msdu_timestamp = mon_pdev->ppdu_info.rx_status.tsft;
  1467. dp_rx_populate_cbf_hdr(soc,
  1468. mac_id, event,
  1469. mpdu,
  1470. msdu_timestamp);
  1471. }
  1472. }
  1473. return QDF_STATUS_SUCCESS;
  1474. }
  1475. QDF_STATUS dp_rx_mon_deliver(struct dp_soc *soc, uint32_t mac_id,
  1476. qdf_nbuf_t head_msdu, qdf_nbuf_t tail_msdu)
  1477. {
  1478. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1479. struct cdp_mon_status *rs;
  1480. qdf_nbuf_t mon_skb, skb_next;
  1481. qdf_nbuf_t mon_mpdu = NULL;
  1482. struct dp_mon_vdev *mon_vdev;
  1483. struct dp_mon_pdev *mon_pdev;
  1484. if (!pdev)
  1485. goto mon_deliver_fail;
  1486. mon_pdev = pdev->monitor_pdev;
  1487. rs = &mon_pdev->rx_mon_recv_status;
  1488. if (!mon_pdev->mvdev && !mon_pdev->mcopy_mode &&
  1489. !mon_pdev->rx_pktlog_cbf)
  1490. goto mon_deliver_fail;
  1491. /* restitch mon MPDU for delivery via monitor interface */
  1492. mon_mpdu = dp_rx_mon_restitch_mpdu(soc, mac_id, head_msdu,
  1493. tail_msdu, rs);
  1494. /* If MPDU restitch fails, free buffers*/
  1495. if (!mon_mpdu) {
  1496. dp_info("MPDU restitch failed, free buffers");
  1497. goto mon_deliver_fail;
  1498. }
  1499. dp_rx_mon_process_dest_pktlog(soc, mac_id, mon_mpdu);
  1500. /* monitor vap cannot be present when mcopy is enabled
  1501. * hence same skb can be consumed
  1502. */
  1503. if (mon_pdev->mcopy_mode)
  1504. return dp_send_mgmt_packet_to_stack(soc, mon_mpdu, pdev);
  1505. if (mon_mpdu && mon_pdev->mvdev &&
  1506. mon_pdev->mvdev->osif_vdev &&
  1507. mon_pdev->mvdev->monitor_vdev &&
  1508. mon_pdev->mvdev->monitor_vdev->osif_rx_mon) {
  1509. mon_vdev = mon_pdev->mvdev->monitor_vdev;
  1510. mon_pdev->ppdu_info.rx_status.ppdu_id =
  1511. mon_pdev->ppdu_info.com_info.ppdu_id;
  1512. mon_pdev->ppdu_info.rx_status.device_id = soc->device_id;
  1513. mon_pdev->ppdu_info.rx_status.chan_noise_floor =
  1514. pdev->chan_noise_floor;
  1515. dp_handle_tx_capture(soc, pdev, mon_mpdu);
  1516. if (!qdf_nbuf_update_radiotap(&mon_pdev->ppdu_info.rx_status,
  1517. mon_mpdu,
  1518. qdf_nbuf_headroom(mon_mpdu))) {
  1519. DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
  1520. goto mon_deliver_fail;
  1521. }
  1522. dp_rx_mon_update_pf_tag_to_buf_headroom(soc, mon_mpdu);
  1523. mon_vdev->osif_rx_mon(mon_pdev->mvdev->osif_vdev,
  1524. mon_mpdu,
  1525. &mon_pdev->ppdu_info.rx_status);
  1526. } else {
  1527. dp_rx_mon_dest_debug("%pK: mon_mpdu=%pK monitor_vdev %pK osif_vdev %pK"
  1528. , soc, mon_mpdu, mon_pdev->mvdev,
  1529. (mon_pdev->mvdev ? mon_pdev->mvdev->osif_vdev
  1530. : NULL));
  1531. goto mon_deliver_fail;
  1532. }
  1533. return QDF_STATUS_SUCCESS;
  1534. mon_deliver_fail:
  1535. mon_skb = head_msdu;
  1536. while (mon_skb) {
  1537. skb_next = qdf_nbuf_next(mon_skb);
  1538. dp_rx_mon_dest_debug("%pK: [%s][%d] mon_skb=%pK len %u",
  1539. soc, __func__, __LINE__, mon_skb, mon_skb->len);
  1540. qdf_nbuf_free(mon_skb);
  1541. mon_skb = skb_next;
  1542. }
  1543. return QDF_STATUS_E_INVAL;
  1544. }
  1545. QDF_STATUS dp_rx_mon_deliver_non_std(struct dp_soc *soc,
  1546. uint32_t mac_id)
  1547. {
  1548. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1549. ol_txrx_rx_mon_fp osif_rx_mon;
  1550. qdf_nbuf_t dummy_msdu;
  1551. struct dp_mon_pdev *mon_pdev;
  1552. struct dp_mon_vdev *mon_vdev;
  1553. /* Sanity checking */
  1554. if (!pdev || !pdev->monitor_pdev)
  1555. goto mon_deliver_non_std_fail;
  1556. mon_pdev = pdev->monitor_pdev;
  1557. if (!mon_pdev->mvdev || !mon_pdev->mvdev ||
  1558. !mon_pdev->mvdev->monitor_vdev ||
  1559. !mon_pdev->mvdev->monitor_vdev->osif_rx_mon)
  1560. goto mon_deliver_non_std_fail;
  1561. mon_vdev = mon_pdev->mvdev->monitor_vdev;
  1562. /* Generate a dummy skb_buff */
  1563. osif_rx_mon = mon_vdev->osif_rx_mon;
  1564. dummy_msdu = qdf_nbuf_alloc(soc->osdev, MAX_MONITOR_HEADER,
  1565. MAX_MONITOR_HEADER, 4, FALSE);
  1566. if (!dummy_msdu)
  1567. goto allocate_dummy_msdu_fail;
  1568. qdf_nbuf_set_pktlen(dummy_msdu, 0);
  1569. qdf_nbuf_set_next(dummy_msdu, NULL);
  1570. mon_pdev->ppdu_info.rx_status.ppdu_id =
  1571. mon_pdev->ppdu_info.com_info.ppdu_id;
  1572. /* Apply the radio header to this dummy skb */
  1573. if (!qdf_nbuf_update_radiotap(&mon_pdev->ppdu_info.rx_status, dummy_msdu,
  1574. qdf_nbuf_headroom(dummy_msdu))) {
  1575. DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
  1576. qdf_nbuf_free(dummy_msdu);
  1577. goto mon_deliver_non_std_fail;
  1578. }
  1579. /* deliver to the user layer application */
  1580. osif_rx_mon(mon_pdev->mvdev->osif_vdev,
  1581. dummy_msdu, NULL);
  1582. /* Clear rx_status*/
  1583. qdf_mem_zero(&mon_pdev->ppdu_info.rx_status,
  1584. sizeof(mon_pdev->ppdu_info.rx_status));
  1585. mon_pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  1586. return QDF_STATUS_SUCCESS;
  1587. allocate_dummy_msdu_fail:
  1588. dp_rx_mon_dest_debug("%pK: mon_skb=%pK ",
  1589. soc, dummy_msdu);
  1590. mon_deliver_non_std_fail:
  1591. return QDF_STATUS_E_INVAL;
  1592. }
  1593. /**
  1594. * dp_rx_process_peer_based_pktlog() - Process Rx pktlog if peer based
  1595. * filtering enabled
  1596. * @soc: core txrx main context
  1597. * @ppdu_info: Structure for rx ppdu info
  1598. * @status_nbuf: Qdf nbuf abstraction for linux skb
  1599. * @pdev_id: mac_id/pdev_id correspondinggly for MCL and WIN
  1600. *
  1601. * Return: none
  1602. */
  1603. void
  1604. dp_rx_process_peer_based_pktlog(struct dp_soc *soc,
  1605. struct hal_rx_ppdu_info *ppdu_info,
  1606. qdf_nbuf_t status_nbuf, uint32_t pdev_id)
  1607. {
  1608. struct dp_peer *peer;
  1609. struct mon_rx_user_status *rx_user_status;
  1610. uint32_t num_users = ppdu_info->com_info.num_users;
  1611. uint16_t sw_peer_id;
  1612. /* Sanity check for num_users */
  1613. if (!num_users)
  1614. return;
  1615. qdf_assert_always(num_users <= CDP_MU_MAX_USERS);
  1616. rx_user_status = &ppdu_info->rx_user_status[num_users - 1];
  1617. sw_peer_id = rx_user_status->sw_peer_id;
  1618. peer = dp_peer_get_ref_by_id(soc, sw_peer_id,
  1619. DP_MOD_ID_RX_PPDU_STATS);
  1620. if (!peer)
  1621. return;
  1622. if ((peer->peer_id != HTT_INVALID_PEER) && (peer->monitor_peer) &&
  1623. (peer->monitor_peer->peer_based_pktlog_filter)) {
  1624. dp_wdi_event_handler(
  1625. WDI_EVENT_RX_DESC, soc,
  1626. status_nbuf,
  1627. peer->peer_id,
  1628. WDI_NO_VAL, pdev_id);
  1629. }
  1630. dp_peer_unref_delete(peer,
  1631. DP_MOD_ID_RX_PPDU_STATS);
  1632. }