dp_rx_mon.c 56 KB

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