dp_rx_mon.c 44 KB

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