dp_rx_mon.c 48 KB

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