dp_rx_mon_status.c 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065
  1. /*
  2. * Copyright (c) 2017-2020 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_rx_mon.h"
  28. #include "dp_internal.h"
  29. #include "qdf_mem.h" /* qdf_mem_malloc,free */
  30. #include "htt.h"
  31. #ifdef FEATURE_PERPKT_INFO
  32. #include "dp_ratetable.h"
  33. #endif
  34. static inline void
  35. dp_rx_populate_cfr_non_assoc_sta(struct dp_pdev *pdev,
  36. struct hal_rx_ppdu_info *ppdu_info,
  37. struct cdp_rx_indication_ppdu *cdp_rx_ppdu);
  38. #ifdef WLAN_RX_PKT_CAPTURE_ENH
  39. #include "dp_rx_mon_feature.h"
  40. #else
  41. static QDF_STATUS
  42. dp_rx_handle_enh_capture(struct dp_soc *soc, struct dp_pdev *pdev,
  43. struct hal_rx_ppdu_info *ppdu_info)
  44. {
  45. return QDF_STATUS_SUCCESS;
  46. }
  47. static void
  48. dp_rx_mon_enh_capture_process(struct dp_pdev *pdev, uint32_t tlv_status,
  49. qdf_nbuf_t status_nbuf,
  50. struct hal_rx_ppdu_info *ppdu_info,
  51. bool *nbuf_used)
  52. {
  53. }
  54. #endif
  55. #ifdef WLAN_TX_PKT_CAPTURE_ENH
  56. #include "dp_rx_mon_feature.h"
  57. #else
  58. static QDF_STATUS
  59. dp_send_ack_frame_to_stack(struct dp_soc *soc,
  60. struct dp_pdev *pdev,
  61. struct hal_rx_ppdu_info *ppdu_info)
  62. {
  63. return QDF_STATUS_SUCCESS;
  64. }
  65. #endif
  66. #ifdef FEATURE_PERPKT_INFO
  67. static inline void
  68. dp_rx_populate_rx_rssi_chain(struct hal_rx_ppdu_info *ppdu_info,
  69. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  70. {
  71. uint8_t chain, bw;
  72. int8_t rssi;
  73. for (chain = 0; chain < SS_COUNT; chain++) {
  74. for (bw = 0; bw < MAX_BW; bw++) {
  75. rssi = ppdu_info->rx_status.rssi_chain[chain][bw];
  76. if (rssi != DP_RSSI_INVAL)
  77. cdp_rx_ppdu->rssi_chain[chain][bw] = rssi;
  78. else
  79. cdp_rx_ppdu->rssi_chain[chain][bw] = 0;
  80. }
  81. }
  82. }
  83. /*
  84. * dp_rx_populate_su_evm_details() - Populate su evm info
  85. * @ppdu_info: ppdu info structure from ppdu ring
  86. * @cdp_rx_ppdu: rx ppdu indication structure
  87. */
  88. static inline void
  89. dp_rx_populate_su_evm_details(struct hal_rx_ppdu_info *ppdu_info,
  90. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  91. {
  92. uint8_t pilot_evm;
  93. uint8_t nss_count;
  94. uint8_t pilot_count;
  95. nss_count = ppdu_info->evm_info.nss_count;
  96. pilot_count = ppdu_info->evm_info.pilot_count;
  97. if ((nss_count * pilot_count) > DP_RX_MAX_SU_EVM_COUNT) {
  98. qdf_err("pilot evm count is more than expected");
  99. return;
  100. }
  101. cdp_rx_ppdu->evm_info.pilot_count = pilot_count;
  102. cdp_rx_ppdu->evm_info.nss_count = nss_count;
  103. /* Populate evm for pilot_evm = nss_count*pilot_count */
  104. for (pilot_evm = 0; pilot_evm < nss_count * pilot_count; pilot_evm++) {
  105. cdp_rx_ppdu->evm_info.pilot_evm[pilot_evm] =
  106. ppdu_info->evm_info.pilot_evm[pilot_evm];
  107. }
  108. }
  109. /**
  110. * dp_rx_inc_rusize_cnt() - increment pdev stats based on RU size
  111. * @pdev: pdev ctx
  112. * @rx_user_status: mon rx user status
  113. *
  114. * Return: bool
  115. */
  116. static inline bool
  117. dp_rx_inc_rusize_cnt(struct dp_pdev *pdev,
  118. struct mon_rx_user_status *rx_user_status)
  119. {
  120. uint32_t ru_size;
  121. bool is_data;
  122. ru_size = rx_user_status->ofdma_ru_size;
  123. if (dp_is_subtype_data(rx_user_status->frame_control)) {
  124. DP_STATS_INC(pdev,
  125. ul_ofdma.data_rx_ru_size[ru_size], 1);
  126. is_data = true;
  127. } else {
  128. DP_STATS_INC(pdev,
  129. ul_ofdma.nondata_rx_ru_size[ru_size], 1);
  130. is_data = false;
  131. }
  132. return is_data;
  133. }
  134. /**
  135. * dp_rx_populate_cdp_indication_ppdu_user() - Populate per user cdp indication
  136. * @pdev: pdev ctx
  137. * @ppdu_info: ppdu info structure from ppdu ring
  138. * @cdp_rx_ppdu: Rx PPDU indication structure
  139. *
  140. * Return: none
  141. */
  142. static inline void
  143. dp_rx_populate_cdp_indication_ppdu_user(struct dp_pdev *pdev,
  144. struct hal_rx_ppdu_info *ppdu_info,
  145. struct cdp_rx_indication_ppdu
  146. *cdp_rx_ppdu)
  147. {
  148. struct dp_peer *peer;
  149. struct dp_soc *soc = pdev->soc;
  150. struct dp_ast_entry *ast_entry;
  151. uint32_t ast_index;
  152. int i;
  153. struct mon_rx_user_status *rx_user_status;
  154. struct cdp_rx_stats_ppdu_user *rx_stats_peruser;
  155. int ru_size;
  156. bool is_data = false;
  157. uint32_t num_users;
  158. num_users = ppdu_info->com_info.num_users;
  159. for (i = 0; i < num_users; i++) {
  160. if (i > OFDMA_NUM_USERS)
  161. return;
  162. rx_user_status = &ppdu_info->rx_user_status[i];
  163. rx_stats_peruser = &cdp_rx_ppdu->user[i];
  164. ast_index = rx_user_status->ast_index;
  165. if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  166. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  167. continue;
  168. }
  169. ast_entry = soc->ast_table[ast_index];
  170. if (!ast_entry) {
  171. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  172. continue;
  173. }
  174. peer = ast_entry->peer;
  175. if (!peer || peer->peer_ids[0] == HTT_INVALID_PEER) {
  176. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  177. continue;
  178. }
  179. rx_stats_peruser->first_data_seq_ctrl =
  180. rx_user_status->first_data_seq_ctrl;
  181. rx_stats_peruser->frame_control_info_valid =
  182. rx_user_status->frame_control_info_valid;
  183. rx_stats_peruser->frame_control =
  184. rx_user_status->frame_control;
  185. rx_stats_peruser->tcp_msdu_count =
  186. rx_user_status->tcp_msdu_count;
  187. rx_stats_peruser->udp_msdu_count =
  188. rx_user_status->udp_msdu_count;
  189. rx_stats_peruser->other_msdu_count =
  190. rx_user_status->other_msdu_count;
  191. rx_stats_peruser->num_msdu =
  192. rx_stats_peruser->tcp_msdu_count +
  193. rx_stats_peruser->udp_msdu_count +
  194. rx_stats_peruser->other_msdu_count;
  195. rx_stats_peruser->preamble_type =
  196. rx_user_status->preamble_type;
  197. rx_stats_peruser->mpdu_cnt_fcs_ok =
  198. rx_user_status->mpdu_cnt_fcs_ok;
  199. rx_stats_peruser->mpdu_cnt_fcs_err =
  200. rx_user_status->mpdu_cnt_fcs_err;
  201. qdf_mem_copy(&rx_stats_peruser->mpdu_fcs_ok_bitmap,
  202. &rx_user_status->mpdu_fcs_ok_bitmap,
  203. HAL_RX_NUM_WORDS_PER_PPDU_BITMAP *
  204. sizeof(rx_user_status->mpdu_fcs_ok_bitmap[0]));
  205. rx_stats_peruser->mpdu_ok_byte_count =
  206. rx_user_status->mpdu_ok_byte_count;
  207. rx_stats_peruser->mpdu_err_byte_count =
  208. rx_user_status->mpdu_err_byte_count;
  209. cdp_rx_ppdu->num_mpdu += rx_user_status->mpdu_cnt_fcs_ok;
  210. cdp_rx_ppdu->num_msdu += rx_stats_peruser->num_msdu;
  211. rx_stats_peruser->retries =
  212. CDP_FC_IS_RETRY_SET(rx_stats_peruser->frame_control) ?
  213. rx_stats_peruser->mpdu_cnt_fcs_ok : 0;
  214. if (rx_stats_peruser->mpdu_cnt_fcs_ok > 1)
  215. rx_stats_peruser->is_ampdu = 1;
  216. else
  217. rx_stats_peruser->is_ampdu = 0;
  218. rx_stats_peruser->tid = ppdu_info->rx_status.tid;
  219. qdf_mem_copy(rx_stats_peruser->mac_addr,
  220. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  221. rx_stats_peruser->peer_id = peer->peer_ids[0];
  222. cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
  223. rx_stats_peruser->vdev_id = peer->vdev->vdev_id;
  224. rx_stats_peruser->mu_ul_info_valid = 0;
  225. if (cdp_rx_ppdu->u.ppdu_type == HAL_RX_TYPE_MU_OFDMA ||
  226. cdp_rx_ppdu->u.ppdu_type == HAL_RX_TYPE_MU_MIMO) {
  227. if (rx_user_status->mu_ul_info_valid) {
  228. rx_stats_peruser->nss = rx_user_status->nss;
  229. rx_stats_peruser->mcs = rx_user_status->mcs;
  230. rx_stats_peruser->mu_ul_info_valid =
  231. rx_user_status->mu_ul_info_valid;
  232. rx_stats_peruser->ofdma_ru_start_index =
  233. rx_user_status->ofdma_ru_start_index;
  234. rx_stats_peruser->ofdma_ru_width =
  235. rx_user_status->ofdma_ru_width;
  236. rx_stats_peruser->user_index = i;
  237. ru_size = rx_user_status->ofdma_ru_size;
  238. /*
  239. * max RU size will be equal to
  240. * HTT_UL_OFDMA_V0_RU_SIZE_RU_996x2
  241. */
  242. if (ru_size >= OFDMA_NUM_RU_SIZE) {
  243. dp_err("invalid ru_size %d\n",
  244. ru_size);
  245. return;
  246. }
  247. is_data = dp_rx_inc_rusize_cnt(pdev,
  248. rx_user_status);
  249. }
  250. if (is_data) {
  251. /* counter to get number of MU OFDMA */
  252. pdev->stats.ul_ofdma.data_rx_ppdu++;
  253. pdev->stats.ul_ofdma.data_users[num_users]++;
  254. }
  255. }
  256. }
  257. }
  258. /**
  259. * dp_rx_populate_cdp_indication_ppdu() - Populate cdp rx indication structure
  260. * @pdev: pdev ctx
  261. * @ppdu_info: ppdu info structure from ppdu ring
  262. * @cdp_rx_ppdu: Rx PPDU indication structure
  263. *
  264. * Return: none
  265. */
  266. static inline void
  267. dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
  268. struct hal_rx_ppdu_info *ppdu_info,
  269. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  270. {
  271. struct dp_peer *peer;
  272. struct dp_soc *soc = pdev->soc;
  273. struct dp_ast_entry *ast_entry;
  274. uint32_t ast_index;
  275. uint32_t i;
  276. cdp_rx_ppdu->first_data_seq_ctrl =
  277. ppdu_info->rx_status.first_data_seq_ctrl;
  278. cdp_rx_ppdu->frame_ctrl =
  279. ppdu_info->rx_status.frame_control;
  280. cdp_rx_ppdu->tcp_msdu_count = ppdu_info->rx_status.tcp_msdu_count;
  281. cdp_rx_ppdu->udp_msdu_count = ppdu_info->rx_status.udp_msdu_count;
  282. cdp_rx_ppdu->other_msdu_count = ppdu_info->rx_status.other_msdu_count;
  283. cdp_rx_ppdu->u.preamble = ppdu_info->rx_status.preamble_type;
  284. /* num mpdu is consolidated and added together in num user loop */
  285. cdp_rx_ppdu->num_mpdu = ppdu_info->com_info.mpdu_cnt_fcs_ok;
  286. /* num msdu is consolidated and added together in num user loop */
  287. cdp_rx_ppdu->num_msdu = (cdp_rx_ppdu->tcp_msdu_count +
  288. cdp_rx_ppdu->udp_msdu_count +
  289. cdp_rx_ppdu->other_msdu_count);
  290. cdp_rx_ppdu->retries = CDP_FC_IS_RETRY_SET(cdp_rx_ppdu->frame_ctrl) ?
  291. ppdu_info->com_info.mpdu_cnt_fcs_ok : 0;
  292. if (ppdu_info->com_info.mpdu_cnt_fcs_ok > 1)
  293. cdp_rx_ppdu->is_ampdu = 1;
  294. else
  295. cdp_rx_ppdu->is_ampdu = 0;
  296. cdp_rx_ppdu->tid = ppdu_info->rx_status.tid;
  297. ast_index = ppdu_info->rx_status.ast_index;
  298. if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  299. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  300. cdp_rx_ppdu->num_users = 0;
  301. goto end;
  302. }
  303. ast_entry = soc->ast_table[ast_index];
  304. if (!ast_entry) {
  305. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  306. cdp_rx_ppdu->num_users = 0;
  307. goto end;
  308. }
  309. peer = ast_entry->peer;
  310. if (!peer || peer->peer_ids[0] == HTT_INVALID_PEER) {
  311. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  312. cdp_rx_ppdu->num_users = 0;
  313. goto end;
  314. }
  315. qdf_mem_copy(cdp_rx_ppdu->mac_addr,
  316. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  317. cdp_rx_ppdu->peer_id = peer->peer_ids[0];
  318. cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
  319. cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
  320. cdp_rx_ppdu->length = ppdu_info->rx_status.ppdu_len;
  321. cdp_rx_ppdu->duration = ppdu_info->rx_status.duration;
  322. cdp_rx_ppdu->u.bw = ppdu_info->rx_status.bw;
  323. cdp_rx_ppdu->u.nss = ppdu_info->rx_status.nss;
  324. cdp_rx_ppdu->u.mcs = ppdu_info->rx_status.mcs;
  325. if ((ppdu_info->rx_status.sgi == VHT_SGI_NYSM) &&
  326. (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC))
  327. cdp_rx_ppdu->u.gi = CDP_SGI_0_4_US;
  328. else
  329. cdp_rx_ppdu->u.gi = ppdu_info->rx_status.sgi;
  330. cdp_rx_ppdu->u.ldpc = ppdu_info->rx_status.ldpc;
  331. cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
  332. cdp_rx_ppdu->u.ltf_size = (ppdu_info->rx_status.he_data5 >>
  333. QDF_MON_STATUS_HE_LTF_SIZE_SHIFT) & 0x3;
  334. cdp_rx_ppdu->rssi = ppdu_info->rx_status.rssi_comb;
  335. cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
  336. cdp_rx_ppdu->channel = ppdu_info->rx_status.chan_num;
  337. cdp_rx_ppdu->beamformed = ppdu_info->rx_status.beamformed;
  338. cdp_rx_ppdu->num_bytes = ppdu_info->rx_status.ppdu_len;
  339. cdp_rx_ppdu->lsig_a = ppdu_info->rx_status.rate;
  340. cdp_rx_ppdu->u.ltf_size = ppdu_info->rx_status.ltf_size;
  341. dp_rx_populate_rx_rssi_chain(ppdu_info, cdp_rx_ppdu);
  342. dp_rx_populate_su_evm_details(ppdu_info, cdp_rx_ppdu);
  343. cdp_rx_ppdu->rx_antenna = ppdu_info->rx_status.rx_antenna;
  344. cdp_rx_ppdu->nf = ppdu_info->rx_status.chan_noise_floor;
  345. for (i = 0; i < MAX_CHAIN; i++)
  346. cdp_rx_ppdu->per_chain_rssi[i] = ppdu_info->rx_status.rssi[i];
  347. cdp_rx_ppdu->is_mcast_bcast = ppdu_info->nac_info.mcast_bcast;
  348. cdp_rx_ppdu->num_users = ppdu_info->com_info.num_users;
  349. cdp_rx_ppdu->num_mpdu = 0;
  350. cdp_rx_ppdu->num_msdu = 0;
  351. dp_rx_populate_cdp_indication_ppdu_user(pdev, ppdu_info, cdp_rx_ppdu);
  352. return;
  353. end:
  354. dp_rx_populate_cfr_non_assoc_sta(pdev, ppdu_info, cdp_rx_ppdu);
  355. }
  356. #else
  357. static inline void
  358. dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
  359. struct hal_rx_ppdu_info *ppdu_info,
  360. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  361. {
  362. }
  363. #endif
  364. /**
  365. * dp_rx_stats_update() - Update per-peer statistics
  366. * @soc: Datapath SOC handle
  367. * @peer: Datapath peer handle
  368. * @ppdu: PPDU Descriptor
  369. *
  370. * Return: None
  371. */
  372. #ifdef FEATURE_PERPKT_INFO
  373. static inline void dp_rx_rate_stats_update(struct dp_peer *peer,
  374. struct cdp_rx_indication_ppdu *ppdu,
  375. uint32_t user)
  376. {
  377. uint32_t ratekbps = 0;
  378. uint32_t ppdu_rx_rate = 0;
  379. uint32_t nss = 0;
  380. uint8_t mcs = 0;
  381. uint32_t rix;
  382. uint16_t ratecode;
  383. struct cdp_rx_stats_ppdu_user *ppdu_user = NULL;
  384. if (!peer || !ppdu)
  385. return;
  386. if (ppdu->u.ppdu_type != HAL_RX_TYPE_SU) {
  387. ppdu_user = &ppdu->user[user];
  388. if (ppdu_user->nss == 0)
  389. nss = 0;
  390. else
  391. nss = ppdu_user->nss - 1;
  392. mcs = ppdu_user->mcs;
  393. } else {
  394. mcs = ppdu->u.mcs;
  395. nss = ppdu->u.nss;
  396. }
  397. ratekbps = dp_getrateindex(ppdu->u.gi,
  398. mcs,
  399. nss,
  400. ppdu->u.preamble,
  401. ppdu->u.bw,
  402. &rix,
  403. &ratecode);
  404. if (!ratekbps)
  405. return;
  406. ppdu->rix = rix;
  407. DP_STATS_UPD(peer, rx.last_rx_rate, ratekbps);
  408. dp_ath_rate_lpf(peer->stats.rx.avg_rx_rate, ratekbps);
  409. ppdu_rx_rate = dp_ath_rate_out(peer->stats.rx.avg_rx_rate);
  410. DP_STATS_UPD(peer, rx.rnd_avg_rx_rate, ppdu_rx_rate);
  411. ppdu->rx_ratekbps = ratekbps;
  412. ppdu->rx_ratecode = ratecode;
  413. if (peer->vdev)
  414. peer->vdev->stats.rx.last_rx_rate = ratekbps;
  415. }
  416. static void dp_rx_stats_update(struct dp_pdev *pdev,
  417. struct cdp_rx_indication_ppdu *ppdu)
  418. {
  419. struct dp_soc *soc = NULL;
  420. uint8_t mcs, preamble, ac = 0, nss, ppdu_type;
  421. uint16_t num_msdu;
  422. uint8_t pkt_bw_offset;
  423. struct dp_peer *peer;
  424. struct cdp_rx_stats_ppdu_user *ppdu_user;
  425. uint32_t i;
  426. enum cdp_mu_packet_type mu_pkt_type;
  427. if (pdev)
  428. soc = pdev->soc;
  429. else
  430. return;
  431. if (!soc || soc->process_rx_status)
  432. return;
  433. preamble = ppdu->u.preamble;
  434. ppdu_type = ppdu->u.ppdu_type;
  435. for (i = 0; i < ppdu->num_users; i++) {
  436. ppdu_user = &ppdu->user[i];
  437. peer = dp_peer_find_by_id(soc, ppdu_user->peer_id);
  438. if (!peer)
  439. peer = pdev->invalid_peer;
  440. ppdu->cookie = (void *)peer->wlanstats_ctx;
  441. if (ppdu_type == HAL_RX_TYPE_SU) {
  442. mcs = ppdu->u.mcs;
  443. nss = ppdu->u.nss;
  444. } else {
  445. mcs = ppdu_user->mcs;
  446. nss = ppdu_user->nss;
  447. }
  448. num_msdu = ppdu_user->num_msdu;
  449. switch (ppdu->u.bw) {
  450. case CMN_BW_20MHZ:
  451. pkt_bw_offset = PKT_BW_GAIN_20MHZ;
  452. break;
  453. case CMN_BW_40MHZ:
  454. pkt_bw_offset = PKT_BW_GAIN_40MHZ;
  455. break;
  456. case CMN_BW_80MHZ:
  457. pkt_bw_offset = PKT_BW_GAIN_80MHZ;
  458. break;
  459. case CMN_BW_160MHZ:
  460. pkt_bw_offset = PKT_BW_GAIN_160MHZ;
  461. break;
  462. default:
  463. pkt_bw_offset = 0;
  464. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  465. "Invalid BW index = %d", ppdu->u.bw);
  466. }
  467. DP_STATS_UPD(peer, rx.rssi, (ppdu->rssi + pkt_bw_offset));
  468. if (peer->stats.rx.avg_rssi == INVALID_RSSI)
  469. peer->stats.rx.avg_rssi =
  470. CDP_RSSI_IN(peer->stats.rx.rssi);
  471. else
  472. CDP_RSSI_UPDATE_AVG(peer->stats.rx.avg_rssi,
  473. peer->stats.rx.rssi);
  474. if ((preamble == DOT11_A) || (preamble == DOT11_B))
  475. nss = 1;
  476. if (ppdu_type == HAL_RX_TYPE_SU) {
  477. if (nss) {
  478. DP_STATS_INC(peer, rx.nss[nss - 1], num_msdu);
  479. DP_STATS_INC(peer, rx.ppdu_nss[nss - 1], 1);
  480. }
  481. DP_STATS_INC(peer, rx.mpdu_cnt_fcs_ok,
  482. ppdu_user->mpdu_cnt_fcs_ok);
  483. DP_STATS_INC(peer, rx.mpdu_cnt_fcs_err,
  484. ppdu_user->mpdu_cnt_fcs_err);
  485. }
  486. if (ppdu_type >= HAL_RX_TYPE_MU_MIMO &&
  487. ppdu_type <= HAL_RX_TYPE_MU_OFDMA) {
  488. if (ppdu_type == HAL_RX_TYPE_MU_MIMO)
  489. mu_pkt_type = RX_TYPE_MU_MIMO;
  490. else
  491. mu_pkt_type = RX_TYPE_MU_OFDMA;
  492. if (nss) {
  493. DP_STATS_INC(peer, rx.nss[nss - 1], num_msdu);
  494. DP_STATS_INC(peer,
  495. rx.rx_mu[mu_pkt_type].ppdu_nss[nss - 1],
  496. 1);
  497. }
  498. DP_STATS_INC(peer,
  499. rx.rx_mu[mu_pkt_type].mpdu_cnt_fcs_ok,
  500. ppdu_user->mpdu_cnt_fcs_ok);
  501. DP_STATS_INC(peer,
  502. rx.rx_mu[mu_pkt_type].mpdu_cnt_fcs_err,
  503. ppdu_user->mpdu_cnt_fcs_err);
  504. }
  505. DP_STATS_INC(peer, rx.sgi_count[ppdu->u.gi], num_msdu);
  506. DP_STATS_INC(peer, rx.bw[ppdu->u.bw], num_msdu);
  507. DP_STATS_INC(peer, rx.reception_type[ppdu->u.ppdu_type],
  508. num_msdu);
  509. DP_STATS_INC(peer, rx.ppdu_cnt[ppdu->u.ppdu_type], 1);
  510. DP_STATS_INCC(peer, rx.ampdu_cnt, num_msdu,
  511. ppdu_user->is_ampdu);
  512. DP_STATS_INCC(peer, rx.non_ampdu_cnt, num_msdu,
  513. !(ppdu_user->is_ampdu));
  514. DP_STATS_UPD(peer, rx.rx_rate, mcs);
  515. DP_STATS_INCC(peer,
  516. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  517. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
  518. DP_STATS_INCC(peer,
  519. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  520. ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
  521. DP_STATS_INCC(peer,
  522. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  523. ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B)));
  524. DP_STATS_INCC(peer,
  525. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  526. ((mcs < MAX_MCS_11B) && (preamble == DOT11_B)));
  527. DP_STATS_INCC(peer,
  528. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  529. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N)));
  530. DP_STATS_INCC(peer,
  531. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  532. ((mcs < MAX_MCS_11A) && (preamble == DOT11_N)));
  533. DP_STATS_INCC(peer,
  534. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  535. ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC)));
  536. DP_STATS_INCC(peer,
  537. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  538. ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
  539. DP_STATS_INCC(peer,
  540. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  541. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  542. DP_STATS_INCC(peer,
  543. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  544. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  545. DP_STATS_INCC(peer,
  546. rx.su_ax_ppdu_cnt.mcs_count[MAX_MCS - 1], 1,
  547. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX) &&
  548. (ppdu_type == HAL_RX_TYPE_SU)));
  549. DP_STATS_INCC(peer,
  550. rx.su_ax_ppdu_cnt.mcs_count[mcs], 1,
  551. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX) &&
  552. (ppdu_type == HAL_RX_TYPE_SU)));
  553. DP_STATS_INCC(peer,
  554. rx.rx_mu[RX_TYPE_MU_OFDMA].ppdu.mcs_count[MAX_MCS - 1],
  555. 1, ((mcs >= (MAX_MCS - 1)) &&
  556. (preamble == DOT11_AX) &&
  557. (ppdu_type == HAL_RX_TYPE_MU_OFDMA)));
  558. DP_STATS_INCC(peer,
  559. rx.rx_mu[RX_TYPE_MU_OFDMA].ppdu.mcs_count[mcs],
  560. 1, ((mcs < (MAX_MCS - 1)) &&
  561. (preamble == DOT11_AX) &&
  562. (ppdu_type == HAL_RX_TYPE_MU_OFDMA)));
  563. DP_STATS_INCC(peer,
  564. rx.rx_mu[RX_TYPE_MU_MIMO].ppdu.mcs_count[MAX_MCS - 1],
  565. 1, ((mcs >= (MAX_MCS - 1)) &&
  566. (preamble == DOT11_AX) &&
  567. (ppdu_type == HAL_RX_TYPE_MU_MIMO)));
  568. DP_STATS_INCC(peer,
  569. rx.rx_mu[RX_TYPE_MU_MIMO].ppdu.mcs_count[mcs],
  570. 1, ((mcs < (MAX_MCS - 1)) &&
  571. (preamble == DOT11_AX) &&
  572. (ppdu_type == HAL_RX_TYPE_MU_MIMO)));
  573. /*
  574. * If invalid TID, it could be a non-qos frame, hence do not
  575. * update any AC counters
  576. */
  577. ac = TID_TO_WME_AC(ppdu_user->tid);
  578. if (ppdu->tid != HAL_TID_INVALID)
  579. DP_STATS_INC(peer, rx.wme_ac_type[ac], num_msdu);
  580. dp_peer_stats_notify(pdev, peer);
  581. DP_STATS_UPD(peer, rx.last_rssi, ppdu->rssi);
  582. if (peer == pdev->invalid_peer)
  583. continue;
  584. if (dp_is_subtype_data(ppdu->frame_ctrl))
  585. dp_rx_rate_stats_update(peer, ppdu, i);
  586. #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
  587. dp_wdi_event_handler(WDI_EVENT_UPDATE_DP_STATS, pdev->soc,
  588. &peer->stats, ppdu->peer_id,
  589. UPDATE_PEER_STATS, pdev->pdev_id);
  590. #endif
  591. dp_peer_unref_del_find_by_id(peer);
  592. }
  593. }
  594. #endif
  595. /*
  596. * dp_rx_get_fcs_ok_msdu() - get ppdu status buffer containing fcs_ok msdu
  597. * @pdev: pdev object
  598. * @ppdu_info: ppdu info object
  599. *
  600. * Return: nbuf
  601. */
  602. static inline qdf_nbuf_t
  603. dp_rx_get_fcs_ok_msdu(struct dp_pdev *pdev,
  604. struct hal_rx_ppdu_info *ppdu_info)
  605. {
  606. uint16_t mpdu_fcs_ok;
  607. qdf_nbuf_t status_nbuf = NULL;
  608. unsigned long *fcs_ok_bitmap;
  609. if (qdf_unlikely(qdf_nbuf_is_queue_empty(&pdev->rx_ppdu_buf_q)))
  610. return NULL;
  611. /* Obtain fcs_ok passed index from bitmap
  612. * this index is used to get fcs passed first msdu payload
  613. */
  614. fcs_ok_bitmap =
  615. (unsigned long *)&ppdu_info->com_info.mpdu_fcs_ok_bitmap[0];
  616. mpdu_fcs_ok = qdf_find_first_bit(fcs_ok_bitmap,
  617. HAL_RX_MAX_MPDU);
  618. if (qdf_unlikely(mpdu_fcs_ok >= HAL_RX_MAX_MPDU))
  619. goto end;
  620. if (qdf_unlikely(!ppdu_info->ppdu_msdu_info[mpdu_fcs_ok].nbuf))
  621. goto end;
  622. /* Get status buffer by indexing mpdu_fcs_ok index
  623. * containing first msdu payload with fcs passed
  624. * and clone the buffer
  625. */
  626. status_nbuf = ppdu_info->ppdu_msdu_info[mpdu_fcs_ok].nbuf;
  627. ppdu_info->ppdu_msdu_info[mpdu_fcs_ok].nbuf = NULL;
  628. /* Take ref of status nbuf as this nbuf is to be
  629. * freeed by upper layer.
  630. */
  631. qdf_nbuf_ref(status_nbuf);
  632. ppdu_info->fcs_ok_msdu_info.first_msdu_payload =
  633. ppdu_info->ppdu_msdu_info[mpdu_fcs_ok].first_msdu_payload;
  634. ppdu_info->fcs_ok_msdu_info.payload_len =
  635. ppdu_info->ppdu_msdu_info[mpdu_fcs_ok].payload_len;
  636. end:
  637. /* Free the ppdu status buffer queue */
  638. qdf_nbuf_queue_free(&pdev->rx_ppdu_buf_q);
  639. qdf_mem_zero(&ppdu_info->ppdu_msdu_info,
  640. (ppdu_info->com_info.mpdu_cnt_fcs_ok +
  641. ppdu_info->com_info.mpdu_cnt_fcs_err)
  642. * sizeof(struct hal_rx_msdu_payload_info));
  643. return status_nbuf;
  644. }
  645. static inline void
  646. dp_rx_handle_ppdu_status_buf(struct dp_pdev *pdev,
  647. struct hal_rx_ppdu_info *ppdu_info,
  648. qdf_nbuf_t status_nbuf)
  649. {
  650. qdf_nbuf_t dropnbuf;
  651. if (qdf_nbuf_queue_len(&pdev->rx_ppdu_buf_q) >
  652. HAL_RX_MAX_MPDU) {
  653. dropnbuf = qdf_nbuf_queue_remove(&pdev->rx_ppdu_buf_q);
  654. qdf_nbuf_free(dropnbuf);
  655. }
  656. qdf_nbuf_queue_add(&pdev->rx_ppdu_buf_q, status_nbuf);
  657. }
  658. /**
  659. * dp_rx_handle_mcopy_mode() - Allocate and deliver first MSDU payload
  660. * @soc: core txrx main context
  661. * @pdev: pdev strcuture
  662. * @ppdu_info: structure for rx ppdu ring
  663. *
  664. * Return: QDF_STATUS_SUCCESS - If nbuf to be freed by caller
  665. * QDF_STATUS_E_ALREADY - If nbuf not to be freed by caller
  666. */
  667. #ifdef FEATURE_PERPKT_INFO
  668. static inline QDF_STATUS
  669. dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  670. struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf)
  671. {
  672. uint8_t size = 0;
  673. struct ieee80211_frame *wh;
  674. uint32_t *nbuf_data;
  675. if (!ppdu_info->fcs_ok_msdu_info.first_msdu_payload)
  676. return QDF_STATUS_SUCCESS;
  677. if (pdev->m_copy_id.rx_ppdu_id == ppdu_info->com_info.ppdu_id)
  678. return QDF_STATUS_SUCCESS;
  679. pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
  680. wh = (struct ieee80211_frame *)
  681. (ppdu_info->fcs_ok_msdu_info.first_msdu_payload + 4);
  682. size = (ppdu_info->fcs_ok_msdu_info.first_msdu_payload -
  683. qdf_nbuf_data(nbuf));
  684. if (qdf_nbuf_pull_head(nbuf, size) == NULL)
  685. return QDF_STATUS_SUCCESS;
  686. if (((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  687. IEEE80211_FC0_TYPE_MGT) ||
  688. ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  689. IEEE80211_FC0_TYPE_CTL)) {
  690. return QDF_STATUS_SUCCESS;
  691. }
  692. ppdu_info->fcs_ok_msdu_info.first_msdu_payload = NULL;
  693. nbuf_data = (uint32_t *)qdf_nbuf_data(nbuf);
  694. *nbuf_data = pdev->ppdu_info.com_info.ppdu_id;
  695. /* only retain RX MSDU payload in the skb */
  696. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
  697. ppdu_info->fcs_ok_msdu_info.payload_len);
  698. dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
  699. nbuf, HTT_INVALID_PEER, WDI_NO_VAL, pdev->pdev_id);
  700. return QDF_STATUS_E_ALREADY;
  701. }
  702. #else
  703. static inline QDF_STATUS
  704. dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  705. struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf)
  706. {
  707. return QDF_STATUS_SUCCESS;
  708. }
  709. #endif
  710. #ifdef FEATURE_PERPKT_INFO
  711. static inline void
  712. dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  713. struct hal_rx_ppdu_info *ppdu_info,
  714. uint32_t tlv_status,
  715. qdf_nbuf_t status_nbuf)
  716. {
  717. QDF_STATUS mcopy_status;
  718. if (qdf_unlikely(!ppdu_info->com_info.mpdu_cnt)) {
  719. qdf_nbuf_free(status_nbuf);
  720. return;
  721. }
  722. /* Add buffers to queue until we receive
  723. * HAL_TLV_STATUS_PPDU_DONE
  724. */
  725. dp_rx_handle_ppdu_status_buf(pdev, ppdu_info, status_nbuf);
  726. /* If tlv_status is PPDU_DONE, process rx_ppdu_buf_q
  727. * and devliver fcs_ok msdu buffer
  728. */
  729. if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) {
  730. if (qdf_unlikely(ppdu_info->com_info.mpdu_cnt !=
  731. (ppdu_info->com_info.mpdu_cnt_fcs_ok +
  732. ppdu_info->com_info.mpdu_cnt_fcs_err))) {
  733. qdf_nbuf_queue_free(&pdev->rx_ppdu_buf_q);
  734. return;
  735. }
  736. /* Get rx ppdu status buffer having fcs ok msdu */
  737. status_nbuf = dp_rx_get_fcs_ok_msdu(pdev, ppdu_info);
  738. if (status_nbuf) {
  739. mcopy_status = dp_rx_handle_mcopy_mode(soc, pdev,
  740. ppdu_info,
  741. status_nbuf);
  742. if (mcopy_status == QDF_STATUS_SUCCESS)
  743. qdf_nbuf_free(status_nbuf);
  744. }
  745. }
  746. }
  747. #else
  748. static inline void
  749. dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  750. struct hal_rx_ppdu_info *ppdu_info,
  751. uint32_t tlv_status,
  752. qdf_nbuf_t status_nbuf)
  753. {
  754. }
  755. #endif
  756. /**
  757. * dp_rx_handle_smart_mesh_mode() - Deliver header for smart mesh
  758. * @soc: Datapath SOC handle
  759. * @pdev: Datapath PDEV handle
  760. * @ppdu_info: Structure for rx ppdu info
  761. * @nbuf: Qdf nbuf abstraction for linux skb
  762. *
  763. * Return: 0 on success, 1 on failure
  764. */
  765. static inline int
  766. dp_rx_handle_smart_mesh_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  767. struct hal_rx_ppdu_info *ppdu_info,
  768. qdf_nbuf_t nbuf)
  769. {
  770. uint8_t size = 0;
  771. if (!pdev->monitor_vdev) {
  772. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  773. "[%s]:[%d] Monitor vdev is NULL !!",
  774. __func__, __LINE__);
  775. return 1;
  776. }
  777. if (!ppdu_info->msdu_info.first_msdu_payload) {
  778. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  779. "[%s]:[%d] First msdu payload not present",
  780. __func__, __LINE__);
  781. return 1;
  782. }
  783. /* Adding 4 bytes to get to start of 802.11 frame after phy_ppdu_id */
  784. size = (ppdu_info->msdu_info.first_msdu_payload -
  785. qdf_nbuf_data(nbuf)) + 4;
  786. ppdu_info->msdu_info.first_msdu_payload = NULL;
  787. if (qdf_nbuf_pull_head(nbuf, size) == NULL) {
  788. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  789. "[%s]:[%d] No header present",
  790. __func__, __LINE__);
  791. return 1;
  792. }
  793. /* Only retain RX MSDU payload in the skb */
  794. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
  795. ppdu_info->msdu_info.payload_len);
  796. if (!qdf_nbuf_update_radiotap(&pdev->ppdu_info.rx_status, nbuf,
  797. qdf_nbuf_headroom(nbuf))) {
  798. DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
  799. return 1;
  800. }
  801. pdev->monitor_vdev->osif_rx_mon(pdev->monitor_vdev->osif_vdev,
  802. nbuf, NULL);
  803. pdev->ppdu_info.rx_status.monitor_direct_used = 0;
  804. return 0;
  805. }
  806. #if defined(WLAN_CFR_ENABLE) && defined(WLAN_ENH_CFR_ENABLE)
  807. /*
  808. * dp_rx_mon_handle_cfr_mu_info() - Gather macaddr and ast_index of peer(s) in
  809. * the PPDU received, this will be used for correlation of CFR data captured
  810. * for an UL-MU-PPDU
  811. * @pdev: pdev ctx
  812. * @ppdu_info: pointer to ppdu info structure populated from ppdu status TLVs
  813. * @cdp_rx_ppdu: Rx PPDU indication structure
  814. *
  815. * Return: none
  816. */
  817. static inline void
  818. dp_rx_mon_handle_cfr_mu_info(struct dp_pdev *pdev,
  819. struct hal_rx_ppdu_info *ppdu_info,
  820. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  821. {
  822. struct dp_peer *peer;
  823. struct dp_soc *soc = pdev->soc;
  824. struct dp_ast_entry *ast_entry;
  825. struct mon_rx_user_status *rx_user_status;
  826. struct cdp_rx_stats_ppdu_user *rx_stats_peruser;
  827. uint32_t num_users;
  828. int user_id;
  829. uint32_t ast_index;
  830. qdf_spin_lock_bh(&soc->ast_lock);
  831. num_users = ppdu_info->com_info.num_users;
  832. for (user_id = 0; user_id < num_users; user_id++) {
  833. if (user_id > OFDMA_NUM_USERS) {
  834. qdf_spin_unlock_bh(&soc->ast_lock);
  835. return;
  836. }
  837. rx_user_status = &ppdu_info->rx_user_status[user_id];
  838. rx_stats_peruser = &cdp_rx_ppdu->user[user_id];
  839. ast_index = rx_user_status->ast_index;
  840. if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  841. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  842. continue;
  843. }
  844. ast_entry = soc->ast_table[ast_index];
  845. if (!ast_entry) {
  846. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  847. continue;
  848. }
  849. peer = ast_entry->peer;
  850. if (!peer || peer->peer_ids[0] == HTT_INVALID_PEER) {
  851. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  852. continue;
  853. }
  854. qdf_mem_copy(rx_stats_peruser->mac_addr,
  855. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  856. }
  857. qdf_spin_unlock_bh(&soc->ast_lock);
  858. }
  859. /*
  860. * dp_rx_mon_populate_cfr_ppdu_info() - Populate cdp ppdu info from hal ppdu
  861. * info
  862. * @pdev: pdev ctx
  863. * @ppdu_info: ppdu info structure from ppdu ring
  864. * @cdp_rx_ppdu : Rx PPDU indication structure
  865. *
  866. * Return: none
  867. */
  868. static inline void
  869. dp_rx_mon_populate_cfr_ppdu_info(struct dp_pdev *pdev,
  870. struct hal_rx_ppdu_info *ppdu_info,
  871. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  872. {
  873. int chain;
  874. cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
  875. cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
  876. cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
  877. cdp_rx_ppdu->num_users = ppdu_info->com_info.num_users;
  878. for (chain = 0; chain < MAX_CHAIN; chain++)
  879. cdp_rx_ppdu->per_chain_rssi[chain] =
  880. ppdu_info->rx_status.rssi[chain];
  881. dp_rx_mon_handle_cfr_mu_info(pdev, ppdu_info, cdp_rx_ppdu);
  882. }
  883. /**
  884. * dp_cfr_rcc_mode_status() - Return status of cfr rcc mode
  885. * @pdev: pdev ctx
  886. *
  887. * Return: True or False
  888. */
  889. static inline bool
  890. dp_cfr_rcc_mode_status(struct dp_pdev *pdev)
  891. {
  892. return pdev->cfr_rcc_mode;
  893. }
  894. /*
  895. * dp_rx_mon_populate_cfr_info() - Populate cdp ppdu info from hal cfr info
  896. * @pdev: pdev ctx
  897. * @ppdu_info: ppdu info structure from ppdu ring
  898. * @cdp_rx_ppdu: Rx PPDU indication structure
  899. *
  900. * Return: none
  901. */
  902. static inline void
  903. dp_rx_mon_populate_cfr_info(struct dp_pdev *pdev,
  904. struct hal_rx_ppdu_info *ppdu_info,
  905. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  906. {
  907. struct cdp_rx_ppdu_cfr_info *cfr_info;
  908. if (!dp_cfr_rcc_mode_status(pdev))
  909. return;
  910. cfr_info = &cdp_rx_ppdu->cfr_info;
  911. cfr_info->bb_captured_channel
  912. = ppdu_info->cfr_info.bb_captured_channel;
  913. cfr_info->bb_captured_timeout
  914. = ppdu_info->cfr_info.bb_captured_timeout;
  915. cfr_info->bb_captured_reason
  916. = ppdu_info->cfr_info.bb_captured_reason;
  917. cfr_info->rx_location_info_valid
  918. = ppdu_info->cfr_info.rx_location_info_valid;
  919. cfr_info->chan_capture_status
  920. = ppdu_info->cfr_info.chan_capture_status;
  921. cfr_info->rtt_che_buffer_pointer_high8
  922. = ppdu_info->cfr_info.rtt_che_buffer_pointer_high8;
  923. cfr_info->rtt_che_buffer_pointer_low32
  924. = ppdu_info->cfr_info.rtt_che_buffer_pointer_low32;
  925. }
  926. /**
  927. * dp_update_cfr_dbg_stats() - Increment RCC debug statistics
  928. * @pdev: pdev structure
  929. * @ppdu_info: structure for rx ppdu ring
  930. *
  931. * Return: none
  932. */
  933. static inline void
  934. dp_update_cfr_dbg_stats(struct dp_pdev *pdev,
  935. struct hal_rx_ppdu_info *ppdu_info)
  936. {
  937. struct hal_rx_ppdu_cfr_info *cfr = &ppdu_info->cfr_info;
  938. DP_STATS_INC(pdev,
  939. rcc.chan_capture_status[cfr->chan_capture_status], 1);
  940. if (cfr->rx_location_info_valid) {
  941. DP_STATS_INC(pdev, rcc.rx_loc_info_valid_cnt, 1);
  942. if (cfr->bb_captured_channel) {
  943. DP_STATS_INC(pdev, rcc.bb_captured_channel_cnt, 1);
  944. DP_STATS_INC(pdev,
  945. rcc.reason_cnt[cfr->bb_captured_reason],
  946. 1);
  947. } else if (cfr->bb_captured_timeout) {
  948. DP_STATS_INC(pdev, rcc.bb_captured_timeout_cnt, 1);
  949. DP_STATS_INC(pdev,
  950. rcc.reason_cnt[cfr->bb_captured_reason],
  951. 1);
  952. }
  953. }
  954. }
  955. /*
  956. * dp_rx_handle_cfr() - Gather cfr info from hal ppdu info
  957. * @soc: core txrx main context
  958. * @pdev: pdev ctx
  959. * @ppdu_info: ppdu info structure from ppdu ring
  960. *
  961. * Return: none
  962. */
  963. static inline void
  964. dp_rx_handle_cfr(struct dp_soc *soc, struct dp_pdev *pdev,
  965. struct hal_rx_ppdu_info *ppdu_info)
  966. {
  967. qdf_nbuf_t ppdu_nbuf;
  968. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  969. dp_update_cfr_dbg_stats(pdev, ppdu_info);
  970. if (!ppdu_info->cfr_info.bb_captured_channel)
  971. return;
  972. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  973. sizeof(struct cdp_rx_indication_ppdu),
  974. 0,
  975. 0,
  976. FALSE);
  977. if (ppdu_nbuf) {
  978. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
  979. dp_rx_mon_populate_cfr_info(pdev, ppdu_info, cdp_rx_ppdu);
  980. dp_rx_mon_populate_cfr_ppdu_info(pdev, ppdu_info, cdp_rx_ppdu);
  981. qdf_nbuf_put_tail(ppdu_nbuf,
  982. sizeof(struct cdp_rx_indication_ppdu));
  983. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
  984. ppdu_nbuf, HTT_INVALID_PEER,
  985. WDI_NO_VAL, pdev->pdev_id);
  986. }
  987. }
  988. /**
  989. * dp_rx_populate_cfr_non_assoc_sta() - Populate cfr ppdu info for PPDUs from
  990. * non-associated stations
  991. * @pdev: pdev ctx
  992. * @ppdu_info: ppdu info structure from ppdu ring
  993. * @cdp_rx_ppdu: Rx PPDU indication structure
  994. *
  995. * Return: none
  996. */
  997. static inline void
  998. dp_rx_populate_cfr_non_assoc_sta(struct dp_pdev *pdev,
  999. struct hal_rx_ppdu_info *ppdu_info,
  1000. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1001. {
  1002. if (!dp_cfr_rcc_mode_status(pdev))
  1003. return;
  1004. if (ppdu_info->cfr_info.bb_captured_channel)
  1005. dp_rx_mon_populate_cfr_ppdu_info(pdev, ppdu_info, cdp_rx_ppdu);
  1006. }
  1007. /**
  1008. * dp_bb_captured_chan_status() - Get the bb_captured_channel status
  1009. * @ppdu_info: structure for rx ppdu ring
  1010. *
  1011. * Return: Success/ Failure
  1012. */
  1013. static inline QDF_STATUS
  1014. dp_bb_captured_chan_status(struct dp_pdev *pdev,
  1015. struct hal_rx_ppdu_info *ppdu_info)
  1016. {
  1017. QDF_STATUS status = QDF_STATUS_E_FAILURE;
  1018. struct hal_rx_ppdu_cfr_info *cfr = &ppdu_info->cfr_info;
  1019. if (dp_cfr_rcc_mode_status(pdev)) {
  1020. if (cfr->bb_captured_channel)
  1021. status = QDF_STATUS_SUCCESS;
  1022. }
  1023. return status;
  1024. }
  1025. #else
  1026. static inline void
  1027. dp_rx_mon_handle_cfr_mu_info(struct dp_pdev *pdev,
  1028. struct hal_rx_ppdu_info *ppdu_info,
  1029. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1030. {
  1031. }
  1032. static inline void
  1033. dp_rx_mon_populate_cfr_ppdu_info(struct dp_pdev *pdev,
  1034. struct hal_rx_ppdu_info *ppdu_info,
  1035. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1036. {
  1037. }
  1038. static inline void
  1039. dp_rx_mon_populate_cfr_info(struct dp_pdev *pdev,
  1040. struct hal_rx_ppdu_info *ppdu_info,
  1041. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1042. {
  1043. }
  1044. static inline void
  1045. dp_rx_handle_cfr(struct dp_soc *soc, struct dp_pdev *pdev,
  1046. struct hal_rx_ppdu_info *ppdu_info)
  1047. {
  1048. }
  1049. static inline void
  1050. dp_rx_populate_cfr_non_assoc_sta(struct dp_pdev *pdev,
  1051. struct hal_rx_ppdu_info *ppdu_info,
  1052. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1053. {
  1054. }
  1055. static inline void
  1056. dp_update_cfr_dbg_stats(struct dp_pdev *pdev,
  1057. struct hal_rx_ppdu_info *ppdu_info)
  1058. {
  1059. }
  1060. static inline QDF_STATUS
  1061. dp_bb_captured_chan_status(struct dp_pdev *pdev,
  1062. struct hal_rx_ppdu_info *ppdu_info)
  1063. {
  1064. return QDF_STATUS_E_NOSUPPORT;
  1065. }
  1066. static inline bool
  1067. dp_cfr_rcc_mode_status(struct dp_pdev *pdev)
  1068. {
  1069. return false;
  1070. }
  1071. #endif
  1072. /**
  1073. * dp_rx_handle_ppdu_stats() - Allocate and deliver ppdu stats to cdp layer
  1074. * @soc: core txrx main context
  1075. * @pdev: pdev strcuture
  1076. * @ppdu_info: structure for rx ppdu ring
  1077. *
  1078. * Return: none
  1079. */
  1080. #ifdef FEATURE_PERPKT_INFO
  1081. static inline void
  1082. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  1083. struct hal_rx_ppdu_info *ppdu_info)
  1084. {
  1085. qdf_nbuf_t ppdu_nbuf;
  1086. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  1087. /*
  1088. * Do not allocate if fcs error,
  1089. * ast idx invalid / fctl invalid
  1090. *
  1091. * In CFR RCC mode - PPDU status TLVs of error pkts are also needed
  1092. */
  1093. if (ppdu_info->com_info.mpdu_cnt_fcs_ok == 0)
  1094. return;
  1095. if (ppdu_info->nac_info.fc_valid &&
  1096. ppdu_info->nac_info.to_ds_flag &&
  1097. ppdu_info->nac_info.mac_addr2_valid) {
  1098. struct dp_neighbour_peer *peer = NULL;
  1099. uint8_t rssi = ppdu_info->rx_status.rssi_comb;
  1100. qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
  1101. if (pdev->neighbour_peers_added) {
  1102. TAILQ_FOREACH(peer, &pdev->neighbour_peers_list,
  1103. neighbour_peer_list_elem) {
  1104. if (!qdf_mem_cmp(&peer->neighbour_peers_macaddr,
  1105. &ppdu_info->nac_info.mac_addr2,
  1106. QDF_MAC_ADDR_SIZE)) {
  1107. peer->rssi = rssi;
  1108. break;
  1109. }
  1110. }
  1111. }
  1112. qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
  1113. }
  1114. /* need not generate wdi event when mcopy, cfr rcc mode and
  1115. * enhanced stats are not enabled
  1116. */
  1117. if (!pdev->mcopy_mode && !pdev->enhanced_stats_en &&
  1118. !dp_cfr_rcc_mode_status(pdev))
  1119. return;
  1120. if (dp_cfr_rcc_mode_status(pdev))
  1121. dp_update_cfr_dbg_stats(pdev, ppdu_info);
  1122. if (!ppdu_info->rx_status.frame_control_info_valid ||
  1123. (ppdu_info->rx_status.ast_index == HAL_AST_IDX_INVALID)) {
  1124. if (!(pdev->mcopy_mode ||
  1125. (dp_bb_captured_chan_status(pdev, ppdu_info) ==
  1126. QDF_STATUS_SUCCESS)))
  1127. return;
  1128. }
  1129. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  1130. sizeof(struct cdp_rx_indication_ppdu),
  1131. 0, 0, FALSE);
  1132. if (ppdu_nbuf) {
  1133. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
  1134. dp_rx_mon_populate_cfr_info(pdev, ppdu_info, cdp_rx_ppdu);
  1135. dp_rx_populate_cdp_indication_ppdu(pdev,
  1136. ppdu_info, cdp_rx_ppdu);
  1137. qdf_nbuf_put_tail(ppdu_nbuf,
  1138. sizeof(struct cdp_rx_indication_ppdu));
  1139. dp_rx_stats_update(pdev, cdp_rx_ppdu);
  1140. if (cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) {
  1141. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC,
  1142. soc, ppdu_nbuf,
  1143. cdp_rx_ppdu->peer_id,
  1144. WDI_NO_VAL, pdev->pdev_id);
  1145. } else if (pdev->mcopy_mode || dp_cfr_rcc_mode_status(pdev)) {
  1146. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
  1147. ppdu_nbuf, HTT_INVALID_PEER,
  1148. WDI_NO_VAL, pdev->pdev_id);
  1149. } else {
  1150. qdf_nbuf_free(ppdu_nbuf);
  1151. }
  1152. }
  1153. }
  1154. #else
  1155. static inline void
  1156. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  1157. struct hal_rx_ppdu_info *ppdu_info)
  1158. {
  1159. }
  1160. #endif
  1161. /**
  1162. * dp_rx_process_peer_based_pktlog() - Process Rx pktlog if peer based
  1163. * filtering enabled
  1164. * @soc: core txrx main context
  1165. * @ppdu_info: Structure for rx ppdu info
  1166. * @status_nbuf: Qdf nbuf abstraction for linux skb
  1167. * @mac_id: mac_id/pdev_id correspondinggly for MCL and WIN
  1168. *
  1169. * Return: none
  1170. */
  1171. static inline void
  1172. dp_rx_process_peer_based_pktlog(struct dp_soc *soc,
  1173. struct hal_rx_ppdu_info *ppdu_info,
  1174. qdf_nbuf_t status_nbuf, uint32_t mac_id)
  1175. {
  1176. struct dp_peer *peer;
  1177. struct dp_ast_entry *ast_entry;
  1178. uint32_t ast_index;
  1179. ast_index = ppdu_info->rx_status.ast_index;
  1180. if (ast_index < wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  1181. ast_entry = soc->ast_table[ast_index];
  1182. if (ast_entry) {
  1183. peer = ast_entry->peer;
  1184. if (peer && (peer->peer_ids[0] != HTT_INVALID_PEER)) {
  1185. if (peer->peer_based_pktlog_filter) {
  1186. dp_wdi_event_handler(
  1187. WDI_EVENT_RX_DESC, soc,
  1188. status_nbuf,
  1189. peer->peer_ids[0],
  1190. WDI_NO_VAL, mac_id);
  1191. }
  1192. }
  1193. }
  1194. }
  1195. }
  1196. #if defined(HTT_UL_OFDMA_USER_INFO_V0_W0_VALID_M)
  1197. static inline void
  1198. dp_rx_ul_ofdma_ru_size_to_width(
  1199. uint32_t ru_size,
  1200. uint32_t *ru_width)
  1201. {
  1202. uint32_t width;
  1203. width = 0;
  1204. switch (ru_size) {
  1205. case HTT_UL_OFDMA_V0_RU_SIZE_RU_26:
  1206. width = 1;
  1207. break;
  1208. case HTT_UL_OFDMA_V0_RU_SIZE_RU_52:
  1209. width = 2;
  1210. break;
  1211. case HTT_UL_OFDMA_V0_RU_SIZE_RU_106:
  1212. width = 4;
  1213. break;
  1214. case HTT_UL_OFDMA_V0_RU_SIZE_RU_242:
  1215. width = 9;
  1216. break;
  1217. case HTT_UL_OFDMA_V0_RU_SIZE_RU_484:
  1218. width = 18;
  1219. break;
  1220. case HTT_UL_OFDMA_V0_RU_SIZE_RU_996:
  1221. width = 37;
  1222. break;
  1223. case HTT_UL_OFDMA_V0_RU_SIZE_RU_996x2:
  1224. width = 74;
  1225. break;
  1226. default:
  1227. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1228. "RU size to width convert err");
  1229. break;
  1230. }
  1231. *ru_width = width;
  1232. }
  1233. static inline void
  1234. dp_rx_mon_handle_mu_ul_info(struct hal_rx_ppdu_info *ppdu_info)
  1235. {
  1236. struct mon_rx_user_status *mon_rx_user_status;
  1237. uint32_t num_users;
  1238. uint32_t i;
  1239. uint32_t mu_ul_user_v0_word0;
  1240. uint32_t mu_ul_user_v0_word1;
  1241. uint32_t ru_width;
  1242. uint32_t ru_size;
  1243. if (!(ppdu_info->rx_status.reception_type == HAL_RX_TYPE_MU_OFDMA ||
  1244. ppdu_info->rx_status.reception_type == HAL_RX_TYPE_MU_MIMO))
  1245. return;
  1246. num_users = ppdu_info->com_info.num_users;
  1247. if (num_users > HAL_MAX_UL_MU_USERS)
  1248. num_users = HAL_MAX_UL_MU_USERS;
  1249. for (i = 0; i < num_users; i++) {
  1250. mon_rx_user_status = &ppdu_info->rx_user_status[i];
  1251. mu_ul_user_v0_word0 =
  1252. mon_rx_user_status->mu_ul_user_v0_word0;
  1253. mu_ul_user_v0_word1 =
  1254. mon_rx_user_status->mu_ul_user_v0_word1;
  1255. if (HTT_UL_OFDMA_USER_INFO_V0_W0_VALID_GET(
  1256. mu_ul_user_v0_word0) &&
  1257. !HTT_UL_OFDMA_USER_INFO_V0_W0_VER_GET(
  1258. mu_ul_user_v0_word0)) {
  1259. mon_rx_user_status->mcs =
  1260. HTT_UL_OFDMA_USER_INFO_V0_W1_MCS_GET(
  1261. mu_ul_user_v0_word1);
  1262. mon_rx_user_status->nss =
  1263. HTT_UL_OFDMA_USER_INFO_V0_W1_NSS_GET(
  1264. mu_ul_user_v0_word1) + 1;
  1265. mon_rx_user_status->mu_ul_info_valid = 1;
  1266. mon_rx_user_status->ofdma_ru_start_index =
  1267. HTT_UL_OFDMA_USER_INFO_V0_W1_RU_START_GET(
  1268. mu_ul_user_v0_word1);
  1269. ru_size =
  1270. HTT_UL_OFDMA_USER_INFO_V0_W1_RU_SIZE_GET(
  1271. mu_ul_user_v0_word1);
  1272. dp_rx_ul_ofdma_ru_size_to_width(ru_size, &ru_width);
  1273. mon_rx_user_status->ofdma_ru_width = ru_width;
  1274. mon_rx_user_status->ofdma_ru_size = ru_size;
  1275. }
  1276. }
  1277. }
  1278. #else
  1279. static inline void
  1280. dp_rx_mon_handle_mu_ul_info(struct hal_rx_ppdu_info *ppdu_info)
  1281. {
  1282. }
  1283. #endif
  1284. /**
  1285. * dp_rx_mon_status_process_tlv() - Process status TLV in status
  1286. * buffer on Rx status Queue posted by status SRNG processing.
  1287. * @soc: core txrx main context
  1288. * @mac_id: mac_id which is one of 3 mac_ids _ring
  1289. *
  1290. * Return: none
  1291. */
  1292. static inline void
  1293. dp_rx_mon_status_process_tlv(struct dp_soc *soc, uint32_t mac_id,
  1294. uint32_t quota)
  1295. {
  1296. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1297. struct hal_rx_ppdu_info *ppdu_info;
  1298. qdf_nbuf_t status_nbuf;
  1299. uint8_t *rx_tlv;
  1300. uint8_t *rx_tlv_start;
  1301. uint32_t tlv_status = HAL_TLV_STATUS_BUF_DONE;
  1302. QDF_STATUS enh_log_status = QDF_STATUS_SUCCESS;
  1303. struct cdp_pdev_mon_stats *rx_mon_stats;
  1304. int smart_mesh_status;
  1305. enum WDI_EVENT pktlog_mode = WDI_NO_VAL;
  1306. bool nbuf_used;
  1307. uint32_t rx_enh_capture_mode;
  1308. ppdu_info = &pdev->ppdu_info;
  1309. rx_mon_stats = &pdev->rx_mon_stats;
  1310. if (pdev->mon_ppdu_status != DP_PPDU_STATUS_START)
  1311. return;
  1312. rx_enh_capture_mode = pdev->rx_enh_capture_mode;
  1313. while (!qdf_nbuf_is_queue_empty(&pdev->rx_status_q)) {
  1314. status_nbuf = qdf_nbuf_queue_remove(&pdev->rx_status_q);
  1315. rx_tlv = qdf_nbuf_data(status_nbuf);
  1316. rx_tlv_start = rx_tlv;
  1317. nbuf_used = false;
  1318. if ((pdev->monitor_vdev) || (pdev->enhanced_stats_en) ||
  1319. (pdev->mcopy_mode) || (dp_cfr_rcc_mode_status(pdev)) ||
  1320. (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED)) {
  1321. do {
  1322. tlv_status = hal_rx_status_get_tlv_info(rx_tlv,
  1323. ppdu_info, pdev->soc->hal_soc,
  1324. status_nbuf);
  1325. dp_rx_mon_update_dbg_ppdu_stats(ppdu_info,
  1326. rx_mon_stats);
  1327. dp_rx_mon_enh_capture_process(pdev, tlv_status,
  1328. status_nbuf, ppdu_info,
  1329. &nbuf_used);
  1330. rx_tlv = hal_rx_status_get_next_tlv(rx_tlv);
  1331. if ((rx_tlv - rx_tlv_start) >=
  1332. RX_DATA_BUFFER_SIZE)
  1333. break;
  1334. } while ((tlv_status == HAL_TLV_STATUS_PPDU_NOT_DONE) ||
  1335. (tlv_status == HAL_TLV_STATUS_HEADER) ||
  1336. (tlv_status == HAL_TLV_STATUS_MPDU_END) ||
  1337. (tlv_status == HAL_TLV_STATUS_MSDU_END));
  1338. }
  1339. if (pdev->dp_peer_based_pktlog) {
  1340. dp_rx_process_peer_based_pktlog(soc, ppdu_info,
  1341. status_nbuf, mac_id);
  1342. } else {
  1343. if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_FULL)
  1344. pktlog_mode = WDI_EVENT_RX_DESC;
  1345. else if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_LITE)
  1346. pktlog_mode = WDI_EVENT_LITE_RX;
  1347. if (pktlog_mode != WDI_NO_VAL)
  1348. dp_wdi_event_handler(pktlog_mode, soc,
  1349. status_nbuf,
  1350. HTT_INVALID_PEER,
  1351. WDI_NO_VAL, mac_id);
  1352. }
  1353. /* smart monitor vap and m_copy cannot co-exist */
  1354. if (ppdu_info->rx_status.monitor_direct_used && pdev->neighbour_peers_added
  1355. && pdev->monitor_vdev) {
  1356. smart_mesh_status = dp_rx_handle_smart_mesh_mode(soc,
  1357. pdev, ppdu_info, status_nbuf);
  1358. if (smart_mesh_status)
  1359. qdf_nbuf_free(status_nbuf);
  1360. } else if (qdf_unlikely(pdev->mcopy_mode)) {
  1361. dp_rx_process_mcopy_mode(soc, pdev,
  1362. ppdu_info, tlv_status,
  1363. status_nbuf);
  1364. } else if (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED) {
  1365. if (!nbuf_used)
  1366. qdf_nbuf_free(status_nbuf);
  1367. if (tlv_status == HAL_TLV_STATUS_PPDU_DONE)
  1368. enh_log_status =
  1369. dp_rx_handle_enh_capture(soc,
  1370. pdev, ppdu_info);
  1371. } else {
  1372. qdf_nbuf_free(status_nbuf);
  1373. }
  1374. if (tlv_status == HAL_TLV_STATUS_PPDU_NON_STD_DONE) {
  1375. dp_rx_mon_deliver_non_std(soc, mac_id);
  1376. } else if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) {
  1377. rx_mon_stats->status_ppdu_done++;
  1378. dp_rx_mon_handle_mu_ul_info(ppdu_info);
  1379. if (pdev->tx_capture_enabled
  1380. != CDP_TX_ENH_CAPTURE_DISABLED)
  1381. dp_send_ack_frame_to_stack(soc, pdev,
  1382. ppdu_info);
  1383. if (pdev->enhanced_stats_en ||
  1384. pdev->mcopy_mode || pdev->neighbour_peers_added)
  1385. dp_rx_handle_ppdu_stats(soc, pdev, ppdu_info);
  1386. else if (dp_cfr_rcc_mode_status(pdev))
  1387. dp_rx_handle_cfr(soc, pdev, ppdu_info);
  1388. pdev->mon_ppdu_status = DP_PPDU_STATUS_DONE;
  1389. /*
  1390. * if chan_num is not fetched correctly from ppdu RX TLV,
  1391. * get it from pdev saved.
  1392. */
  1393. if (qdf_unlikely(pdev->ppdu_info.rx_status.chan_num == 0))
  1394. pdev->ppdu_info.rx_status.chan_num = pdev->mon_chan_num;
  1395. /*
  1396. * if chan_freq is not fetched correctly from ppdu RX TLV,
  1397. * get it from pdev saved.
  1398. */
  1399. if (qdf_unlikely(pdev->ppdu_info.rx_status.chan_freq == 0)) {
  1400. pdev->ppdu_info.rx_status.chan_freq =
  1401. pdev->mon_chan_freq;
  1402. }
  1403. dp_rx_mon_dest_process(soc, mac_id, quota);
  1404. pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  1405. }
  1406. }
  1407. return;
  1408. }
  1409. /*
  1410. * dp_rx_mon_status_srng_process() - Process monitor status ring
  1411. * post the status ring buffer to Rx status Queue for later
  1412. * processing when status ring is filled with status TLV.
  1413. * Allocate a new buffer to status ring if the filled buffer
  1414. * is posted.
  1415. *
  1416. * @soc: core txrx main context
  1417. * @mac_id: mac_id which is one of 3 mac_ids
  1418. * @quota: No. of ring entry that can be serviced in one shot.
  1419. * Return: uint32_t: No. of ring entry that is processed.
  1420. */
  1421. static inline uint32_t
  1422. dp_rx_mon_status_srng_process(struct dp_soc *soc, uint32_t mac_id,
  1423. uint32_t quota)
  1424. {
  1425. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1426. hal_soc_handle_t hal_soc;
  1427. void *mon_status_srng;
  1428. void *rxdma_mon_status_ring_entry;
  1429. QDF_STATUS status;
  1430. uint32_t work_done = 0;
  1431. mon_status_srng = soc->rxdma_mon_status_ring[mac_id].hal_srng;
  1432. qdf_assert(mon_status_srng);
  1433. if (!mon_status_srng || !hal_srng_initialized(mon_status_srng)) {
  1434. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1435. "%s %d : HAL Monitor Status Ring Init Failed -- %pK",
  1436. __func__, __LINE__, mon_status_srng);
  1437. return work_done;
  1438. }
  1439. hal_soc = soc->hal_soc;
  1440. qdf_assert(hal_soc);
  1441. if (qdf_unlikely(hal_srng_access_start(hal_soc, mon_status_srng)))
  1442. goto done;
  1443. /* mon_status_ring_desc => WBM_BUFFER_RING STRUCT =>
  1444. * BUFFER_ADDR_INFO STRUCT
  1445. */
  1446. while (qdf_likely((rxdma_mon_status_ring_entry =
  1447. hal_srng_src_peek_n_get_next(hal_soc, mon_status_srng))
  1448. && quota--)) {
  1449. uint32_t rx_buf_cookie;
  1450. qdf_nbuf_t status_nbuf;
  1451. struct dp_rx_desc *rx_desc;
  1452. uint8_t *status_buf;
  1453. qdf_dma_addr_t paddr;
  1454. uint64_t buf_addr;
  1455. buf_addr =
  1456. (HAL_RX_BUFFER_ADDR_31_0_GET(
  1457. rxdma_mon_status_ring_entry) |
  1458. ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(
  1459. rxdma_mon_status_ring_entry)) << 32));
  1460. if (qdf_likely(buf_addr)) {
  1461. rx_buf_cookie =
  1462. HAL_RX_BUF_COOKIE_GET(
  1463. rxdma_mon_status_ring_entry);
  1464. rx_desc = dp_rx_cookie_2_va_mon_status(soc,
  1465. rx_buf_cookie);
  1466. qdf_assert(rx_desc);
  1467. status_nbuf = rx_desc->nbuf;
  1468. qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf,
  1469. QDF_DMA_FROM_DEVICE);
  1470. status_buf = qdf_nbuf_data(status_nbuf);
  1471. status = hal_get_rx_status_done(status_buf);
  1472. if (status != QDF_STATUS_SUCCESS) {
  1473. uint32_t hp, tp;
  1474. hal_get_sw_hptp(hal_soc, mon_status_srng,
  1475. &tp, &hp);
  1476. dp_info_rl("tlv tag status error hp:%u, tp:%u",
  1477. hp, tp);
  1478. pdev->rx_mon_stats.tlv_tag_status_err++;
  1479. /* WAR for missing status: Skip status entry */
  1480. hal_srng_src_get_next(hal_soc, mon_status_srng);
  1481. continue;
  1482. }
  1483. qdf_nbuf_set_pktlen(status_nbuf, RX_DATA_BUFFER_SIZE);
  1484. qdf_nbuf_unmap_single(soc->osdev, status_nbuf,
  1485. QDF_DMA_FROM_DEVICE);
  1486. /* Put the status_nbuf to queue */
  1487. qdf_nbuf_queue_add(&pdev->rx_status_q, status_nbuf);
  1488. } else {
  1489. union dp_rx_desc_list_elem_t *desc_list = NULL;
  1490. union dp_rx_desc_list_elem_t *tail = NULL;
  1491. struct rx_desc_pool *rx_desc_pool;
  1492. uint32_t num_alloc_desc;
  1493. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1494. num_alloc_desc = dp_rx_get_free_desc_list(soc, mac_id,
  1495. rx_desc_pool,
  1496. 1,
  1497. &desc_list,
  1498. &tail);
  1499. /*
  1500. * No free descriptors available
  1501. */
  1502. if (qdf_unlikely(num_alloc_desc == 0)) {
  1503. work_done++;
  1504. break;
  1505. }
  1506. rx_desc = &desc_list->rx_desc;
  1507. }
  1508. status_nbuf = dp_rx_nbuf_prepare(soc, pdev);
  1509. /*
  1510. * qdf_nbuf alloc or map failed,
  1511. * free the dp rx desc to free list,
  1512. * fill in NULL dma address at current HP entry,
  1513. * keep HP in mon_status_ring unchanged,
  1514. * wait next time dp_rx_mon_status_srng_process
  1515. * to fill in buffer at current HP.
  1516. */
  1517. if (qdf_unlikely(!status_nbuf)) {
  1518. union dp_rx_desc_list_elem_t *desc_list = NULL;
  1519. union dp_rx_desc_list_elem_t *tail = NULL;
  1520. struct rx_desc_pool *rx_desc_pool;
  1521. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1522. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1523. "%s: fail to allocate or map qdf_nbuf",
  1524. __func__);
  1525. dp_rx_add_to_free_desc_list(&desc_list,
  1526. &tail, rx_desc);
  1527. dp_rx_add_desc_list_to_free_list(soc, &desc_list,
  1528. &tail, mac_id, rx_desc_pool);
  1529. hal_rxdma_buff_addr_info_set(
  1530. rxdma_mon_status_ring_entry,
  1531. 0, 0, HAL_RX_BUF_RBM_SW3_BM);
  1532. work_done++;
  1533. break;
  1534. }
  1535. paddr = qdf_nbuf_get_frag_paddr(status_nbuf, 0);
  1536. rx_desc->nbuf = status_nbuf;
  1537. rx_desc->in_use = 1;
  1538. hal_rxdma_buff_addr_info_set(rxdma_mon_status_ring_entry,
  1539. paddr, rx_desc->cookie, HAL_RX_BUF_RBM_SW3_BM);
  1540. hal_srng_src_get_next(hal_soc, mon_status_srng);
  1541. work_done++;
  1542. }
  1543. done:
  1544. hal_srng_access_end(hal_soc, mon_status_srng);
  1545. return work_done;
  1546. }
  1547. /*
  1548. * dp_rx_mon_status_process() - Process monitor status ring and
  1549. * TLV in status ring.
  1550. *
  1551. * @soc: core txrx main context
  1552. * @mac_id: mac_id which is one of 3 mac_ids
  1553. * @quota: No. of ring entry that can be serviced in one shot.
  1554. * Return: uint32_t: No. of ring entry that is processed.
  1555. */
  1556. static inline uint32_t
  1557. dp_rx_mon_status_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
  1558. uint32_t work_done;
  1559. work_done = dp_rx_mon_status_srng_process(soc, mac_id, quota);
  1560. quota -= work_done;
  1561. dp_rx_mon_status_process_tlv(soc, mac_id, quota);
  1562. return work_done;
  1563. }
  1564. /**
  1565. * dp_mon_process() - Main monitor mode processing roution.
  1566. * This call monitor status ring process then monitor
  1567. * destination ring process.
  1568. * Called from the bottom half (tasklet/NET_RX_SOFTIRQ)
  1569. * @soc: core txrx main context
  1570. * @mac_id: mac_id which is one of 3 mac_ids
  1571. * @quota: No. of status ring entry that can be serviced in one shot.
  1572. * Return: uint32_t: No. of ring entry that is processed.
  1573. */
  1574. uint32_t
  1575. dp_mon_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
  1576. return dp_rx_mon_status_process(soc, mac_id, quota);
  1577. }
  1578. /**
  1579. * dp_rx_pdev_mon_status_detach() - detach dp rx for status ring
  1580. * @pdev: core txrx pdev context
  1581. * @mac_id: mac_id/pdev_id correspondinggly for MCL and WIN
  1582. *
  1583. * This function will detach DP RX status ring from
  1584. * main device context. will free DP Rx resources for
  1585. * status ring
  1586. *
  1587. * Return: QDF_STATUS_SUCCESS: success
  1588. * QDF_STATUS_E_RESOURCES: Error return
  1589. */
  1590. QDF_STATUS
  1591. dp_rx_pdev_mon_status_detach(struct dp_pdev *pdev, int mac_id)
  1592. {
  1593. struct dp_soc *soc = pdev->soc;
  1594. struct rx_desc_pool *rx_desc_pool;
  1595. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1596. if (rx_desc_pool->pool_size != 0) {
  1597. if (!dp_is_soc_reinit(soc))
  1598. dp_rx_desc_nbuf_and_pool_free(soc, mac_id,
  1599. rx_desc_pool);
  1600. else
  1601. dp_rx_desc_nbuf_free(soc, rx_desc_pool);
  1602. }
  1603. return QDF_STATUS_SUCCESS;
  1604. }
  1605. /*
  1606. * dp_rx_buffers_replenish() - replenish monitor status ring with
  1607. * rx nbufs called during dp rx
  1608. * monitor status ring initialization
  1609. *
  1610. * @soc: core txrx main context
  1611. * @mac_id: mac_id which is one of 3 mac_ids
  1612. * @dp_rxdma_srng: dp monitor status circular ring
  1613. * @rx_desc_pool; Pointer to Rx descriptor pool
  1614. * @num_req_buffers: number of buffer to be replenished
  1615. * @desc_list: list of descs if called from dp rx monitor status
  1616. * process or NULL during dp rx initialization or
  1617. * out of buffer interrupt
  1618. * @tail: tail of descs list
  1619. * @owner: who owns the nbuf (host, NSS etc...)
  1620. * Return: return success or failure
  1621. */
  1622. static inline
  1623. QDF_STATUS dp_rx_mon_status_buffers_replenish(struct dp_soc *dp_soc,
  1624. uint32_t mac_id,
  1625. struct dp_srng *dp_rxdma_srng,
  1626. struct rx_desc_pool *rx_desc_pool,
  1627. uint32_t num_req_buffers,
  1628. union dp_rx_desc_list_elem_t **desc_list,
  1629. union dp_rx_desc_list_elem_t **tail,
  1630. uint8_t owner)
  1631. {
  1632. uint32_t num_alloc_desc;
  1633. uint16_t num_desc_to_free = 0;
  1634. uint32_t num_entries_avail;
  1635. uint32_t count = 0;
  1636. int sync_hw_ptr = 1;
  1637. qdf_dma_addr_t paddr;
  1638. qdf_nbuf_t rx_netbuf;
  1639. void *rxdma_ring_entry;
  1640. union dp_rx_desc_list_elem_t *next;
  1641. void *rxdma_srng;
  1642. struct dp_pdev *dp_pdev = dp_get_pdev_for_lmac_id(dp_soc, mac_id);
  1643. rxdma_srng = dp_rxdma_srng->hal_srng;
  1644. qdf_assert(rxdma_srng);
  1645. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1646. "[%s][%d] requested %d buffers for replenish",
  1647. __func__, __LINE__, num_req_buffers);
  1648. /*
  1649. * if desc_list is NULL, allocate the descs from freelist
  1650. */
  1651. if (!(*desc_list)) {
  1652. num_alloc_desc = dp_rx_get_free_desc_list(dp_soc, mac_id,
  1653. rx_desc_pool,
  1654. num_req_buffers,
  1655. desc_list,
  1656. tail);
  1657. if (!num_alloc_desc) {
  1658. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1659. "[%s][%d] no free rx_descs in freelist",
  1660. __func__, __LINE__);
  1661. return QDF_STATUS_E_NOMEM;
  1662. }
  1663. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1664. "[%s][%d] %d rx desc allocated", __func__, __LINE__,
  1665. num_alloc_desc);
  1666. num_req_buffers = num_alloc_desc;
  1667. }
  1668. hal_srng_access_start(dp_soc->hal_soc, rxdma_srng);
  1669. num_entries_avail = hal_srng_src_num_avail(dp_soc->hal_soc,
  1670. rxdma_srng, sync_hw_ptr);
  1671. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1672. "[%s][%d] no of available entries in rxdma ring: %d",
  1673. __func__, __LINE__, num_entries_avail);
  1674. if (num_entries_avail < num_req_buffers) {
  1675. num_desc_to_free = num_req_buffers - num_entries_avail;
  1676. num_req_buffers = num_entries_avail;
  1677. }
  1678. while (count <= num_req_buffers) {
  1679. rx_netbuf = dp_rx_nbuf_prepare(dp_soc, dp_pdev);
  1680. /*
  1681. * qdf_nbuf alloc or map failed,
  1682. * keep HP in mon_status_ring unchanged,
  1683. * wait dp_rx_mon_status_srng_process
  1684. * to fill in buffer at current HP.
  1685. */
  1686. if (qdf_unlikely(!rx_netbuf)) {
  1687. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1688. "%s: qdf_nbuf allocate or map fail, count %d",
  1689. __func__, count);
  1690. break;
  1691. }
  1692. paddr = qdf_nbuf_get_frag_paddr(rx_netbuf, 0);
  1693. next = (*desc_list)->next;
  1694. rxdma_ring_entry = hal_srng_src_get_cur_hp_n_move_next(
  1695. dp_soc->hal_soc,
  1696. rxdma_srng);
  1697. if (qdf_unlikely(!rxdma_ring_entry)) {
  1698. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1699. "[%s][%d] rxdma_ring_entry is NULL, count - %d",
  1700. __func__, __LINE__, count);
  1701. qdf_nbuf_unmap_single(dp_soc->osdev, rx_netbuf,
  1702. QDF_DMA_FROM_DEVICE);
  1703. qdf_nbuf_free(rx_netbuf);
  1704. break;
  1705. }
  1706. (*desc_list)->rx_desc.nbuf = rx_netbuf;
  1707. (*desc_list)->rx_desc.in_use = 1;
  1708. count++;
  1709. hal_rxdma_buff_addr_info_set(rxdma_ring_entry, paddr,
  1710. (*desc_list)->rx_desc.cookie, owner);
  1711. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1712. "[%s][%d] rx_desc=%pK, cookie=%d, nbuf=%pK, \
  1713. paddr=%pK",
  1714. __func__, __LINE__, &(*desc_list)->rx_desc,
  1715. (*desc_list)->rx_desc.cookie, rx_netbuf,
  1716. (void *)paddr);
  1717. *desc_list = next;
  1718. }
  1719. hal_srng_access_end(dp_soc->hal_soc, rxdma_srng);
  1720. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1721. "successfully replenished %d buffers", num_req_buffers);
  1722. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1723. "%d rx desc added back to free list", num_desc_to_free);
  1724. /*
  1725. * add any available free desc back to the free list
  1726. */
  1727. if (*desc_list) {
  1728. dp_rx_add_desc_list_to_free_list(dp_soc, desc_list, tail,
  1729. mac_id, rx_desc_pool);
  1730. }
  1731. return QDF_STATUS_SUCCESS;
  1732. }
  1733. /**
  1734. * dp_rx_pdev_mon_status_attach() - attach DP RX monitor status ring
  1735. * @pdev: core txrx pdev context
  1736. * @ring_id: ring number
  1737. * This function will attach a DP RX monitor status ring into pDEV
  1738. * and replenish monitor status ring with buffer.
  1739. *
  1740. * Return: QDF_STATUS_SUCCESS: success
  1741. * QDF_STATUS_E_RESOURCES: Error return
  1742. */
  1743. QDF_STATUS
  1744. dp_rx_pdev_mon_status_attach(struct dp_pdev *pdev, int ring_id) {
  1745. struct dp_soc *soc = pdev->soc;
  1746. union dp_rx_desc_list_elem_t *desc_list = NULL;
  1747. union dp_rx_desc_list_elem_t *tail = NULL;
  1748. struct dp_srng *mon_status_ring;
  1749. uint32_t num_entries;
  1750. uint32_t i;
  1751. struct rx_desc_pool *rx_desc_pool;
  1752. QDF_STATUS status;
  1753. mon_status_ring = &soc->rxdma_mon_status_ring[ring_id];
  1754. num_entries = mon_status_ring->num_entries;
  1755. rx_desc_pool = &soc->rx_desc_status[ring_id];
  1756. dp_info("Mon RX Status Pool[%d] entries=%d",
  1757. ring_id, num_entries);
  1758. status = dp_rx_desc_pool_alloc(soc, ring_id, num_entries + 1,
  1759. rx_desc_pool);
  1760. if (!QDF_IS_STATUS_SUCCESS(status))
  1761. return status;
  1762. rx_desc_pool->buf_size = RX_DATA_BUFFER_SIZE;
  1763. rx_desc_pool->buf_alignment = RX_DATA_BUFFER_ALIGNMENT;
  1764. dp_debug("Mon RX Status Buffers Replenish ring_id=%d", ring_id);
  1765. status = dp_rx_mon_status_buffers_replenish(soc, ring_id,
  1766. mon_status_ring,
  1767. rx_desc_pool,
  1768. num_entries,
  1769. &desc_list, &tail,
  1770. HAL_RX_BUF_RBM_SW3_BM);
  1771. if (!QDF_IS_STATUS_SUCCESS(status))
  1772. return status;
  1773. qdf_nbuf_queue_init(&pdev->rx_status_q);
  1774. qdf_nbuf_queue_init(&pdev->rx_ppdu_buf_q);
  1775. pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  1776. qdf_mem_zero(&(pdev->ppdu_info.rx_status),
  1777. sizeof(pdev->ppdu_info.rx_status));
  1778. qdf_mem_zero(&pdev->rx_mon_stats,
  1779. sizeof(pdev->rx_mon_stats));
  1780. dp_rx_mon_init_dbg_ppdu_stats(&pdev->ppdu_info,
  1781. &pdev->rx_mon_stats);
  1782. for (i = 0; i < MAX_MU_USERS; i++) {
  1783. qdf_nbuf_queue_init(&pdev->mpdu_q[i]);
  1784. pdev->is_mpdu_hdr[i] = true;
  1785. }
  1786. qdf_mem_zero(pdev->msdu_list, sizeof(pdev->msdu_list[MAX_MU_USERS]));
  1787. pdev->rx_enh_capture_mode = CDP_RX_ENH_CAPTURE_DISABLED;
  1788. return QDF_STATUS_SUCCESS;
  1789. }