dp_rx_mon_status.c 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587
  1. /*
  2. * Copyright (c) 2017-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_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. #define dp_rx_mon_status_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_DP_RX_MON_STATUS, params)
  35. #define dp_rx_mon_status_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DP_RX_MON_STATUS, params)
  36. #define dp_rx_mon_status_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_DP_RX_MON_STATUS, params)
  37. #define dp_rx_mon_status_info(params...) \
  38. __QDF_TRACE_FL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_RX_MON_STATUS, ## params)
  39. #define dp_rx_mon_status_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_RX_MON_STATUS, params)
  40. static inline
  41. QDF_STATUS dp_rx_mon_status_buffers_replenish(struct dp_soc *dp_soc,
  42. uint32_t mac_id,
  43. struct dp_srng *dp_rxdma_srng,
  44. struct rx_desc_pool *rx_desc_pool,
  45. uint32_t num_req_buffers,
  46. union dp_rx_desc_list_elem_t **desc_list,
  47. union dp_rx_desc_list_elem_t **tail,
  48. uint8_t owner);
  49. static inline void
  50. dp_rx_populate_cfr_non_assoc_sta(struct dp_pdev *pdev,
  51. struct hal_rx_ppdu_info *ppdu_info,
  52. struct cdp_rx_indication_ppdu *cdp_rx_ppdu);
  53. /**
  54. * dp_rx_mon_handle_status_buf_done () - Handle status buf DMA not done
  55. *
  56. * @pdev: DP pdev handle
  57. * @mon_status_srng: Monitor status SRNG
  58. *
  59. * As per MAC team's suggestion, If HP + 2 entry's DMA done is set,
  60. * skip HP + 1 entry and start processing in next interrupt.
  61. * If HP + 2 entry's DMA done is not set, poll onto HP + 1 entry
  62. * for it's DMA done TLV to be set.
  63. *
  64. * Return: enum dp_mon_reap_status
  65. */
  66. enum dp_mon_reap_status
  67. dp_rx_mon_handle_status_buf_done(struct dp_pdev *pdev,
  68. void *mon_status_srng)
  69. {
  70. struct dp_soc *soc = pdev->soc;
  71. hal_soc_handle_t hal_soc;
  72. void *ring_entry;
  73. uint32_t rx_buf_cookie;
  74. qdf_nbuf_t status_nbuf;
  75. struct dp_rx_desc *rx_desc;
  76. void *rx_tlv;
  77. QDF_STATUS buf_status;
  78. hal_soc = soc->hal_soc;
  79. ring_entry = hal_srng_src_peek_n_get_next_next(hal_soc,
  80. mon_status_srng);
  81. if (!ring_entry) {
  82. dp_rx_mon_status_debug("%pK: Monitor status ring entry is NULL for SRNG: %pK",
  83. soc, mon_status_srng);
  84. return DP_MON_STATUS_NO_DMA;
  85. }
  86. rx_buf_cookie = HAL_RX_BUF_COOKIE_GET(ring_entry);
  87. rx_desc = dp_rx_cookie_2_va_mon_status(soc, rx_buf_cookie);
  88. qdf_assert(rx_desc);
  89. status_nbuf = rx_desc->nbuf;
  90. qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf,
  91. QDF_DMA_FROM_DEVICE);
  92. rx_tlv = qdf_nbuf_data(status_nbuf);
  93. buf_status = hal_get_rx_status_done(rx_tlv);
  94. /* If status buffer DMA is not done,
  95. * 1. As per MAC team's suggestion, If HP + 2 entry's DMA done is set,
  96. * replenish HP + 1 entry and start processing in next interrupt.
  97. * 2. If HP + 2 entry's DMA done is not set
  98. * hold on to mon destination ring.
  99. */
  100. if (buf_status != QDF_STATUS_SUCCESS) {
  101. dp_err_rl("Monitor status ring: DMA is not done "
  102. "for nbuf: %pK", status_nbuf);
  103. pdev->rx_mon_stats.tlv_tag_status_err++;
  104. return DP_MON_STATUS_NO_DMA;
  105. }
  106. pdev->rx_mon_stats.status_buf_done_war++;
  107. return DP_MON_STATUS_REPLENISH;
  108. }
  109. #ifndef QCA_SUPPORT_FULL_MON
  110. /**
  111. * dp_rx_mon_process () - Core brain processing for monitor mode
  112. *
  113. * This API processes monitor destination ring followed by monitor status ring
  114. * Called from bottom half (tasklet/NET_RX_SOFTIRQ)
  115. *
  116. * @soc: datapath soc context
  117. * @int_ctx: interrupt context
  118. * @mac_id: mac_id on which interrupt is received
  119. * @quota: Number of status ring entry that can be serviced in one shot.
  120. *
  121. * @Return: Number of reaped status ring entries
  122. */
  123. static inline uint32_t
  124. dp_rx_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  125. uint32_t mac_id, uint32_t quota)
  126. {
  127. return quota;
  128. }
  129. #endif
  130. #ifdef WLAN_RX_PKT_CAPTURE_ENH
  131. #include "dp_rx_mon_feature.h"
  132. #else
  133. static QDF_STATUS
  134. dp_rx_handle_enh_capture(struct dp_soc *soc, struct dp_pdev *pdev,
  135. struct hal_rx_ppdu_info *ppdu_info)
  136. {
  137. return QDF_STATUS_SUCCESS;
  138. }
  139. static void
  140. dp_rx_mon_enh_capture_process(struct dp_pdev *pdev, uint32_t tlv_status,
  141. qdf_nbuf_t status_nbuf,
  142. struct hal_rx_ppdu_info *ppdu_info,
  143. bool *nbuf_used)
  144. {
  145. }
  146. #endif
  147. #ifdef WLAN_TX_PKT_CAPTURE_ENH
  148. #include "dp_rx_mon_feature.h"
  149. #else
  150. static QDF_STATUS
  151. dp_send_ack_frame_to_stack(struct dp_soc *soc,
  152. struct dp_pdev *pdev,
  153. struct hal_rx_ppdu_info *ppdu_info)
  154. {
  155. return QDF_STATUS_SUCCESS;
  156. }
  157. #endif
  158. #ifdef FEATURE_PERPKT_INFO
  159. static inline void
  160. dp_rx_populate_rx_rssi_chain(struct hal_rx_ppdu_info *ppdu_info,
  161. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  162. {
  163. uint8_t chain, bw;
  164. int8_t rssi;
  165. for (chain = 0; chain < SS_COUNT; chain++) {
  166. for (bw = 0; bw < MAX_BW; bw++) {
  167. rssi = ppdu_info->rx_status.rssi_chain[chain][bw];
  168. if (rssi != DP_RSSI_INVAL)
  169. cdp_rx_ppdu->rssi_chain[chain][bw] = rssi;
  170. else
  171. cdp_rx_ppdu->rssi_chain[chain][bw] = 0;
  172. }
  173. }
  174. }
  175. /*
  176. * dp_rx_populate_su_evm_details() - Populate su evm info
  177. * @ppdu_info: ppdu info structure from ppdu ring
  178. * @cdp_rx_ppdu: rx ppdu indication structure
  179. */
  180. static inline void
  181. dp_rx_populate_su_evm_details(struct hal_rx_ppdu_info *ppdu_info,
  182. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  183. {
  184. uint8_t pilot_evm;
  185. uint8_t nss_count;
  186. uint8_t pilot_count;
  187. nss_count = ppdu_info->evm_info.nss_count;
  188. pilot_count = ppdu_info->evm_info.pilot_count;
  189. if ((nss_count * pilot_count) > DP_RX_MAX_SU_EVM_COUNT) {
  190. qdf_err("pilot evm count is more than expected");
  191. return;
  192. }
  193. cdp_rx_ppdu->evm_info.pilot_count = pilot_count;
  194. cdp_rx_ppdu->evm_info.nss_count = nss_count;
  195. /* Populate evm for pilot_evm = nss_count*pilot_count */
  196. for (pilot_evm = 0; pilot_evm < nss_count * pilot_count; pilot_evm++) {
  197. cdp_rx_ppdu->evm_info.pilot_evm[pilot_evm] =
  198. ppdu_info->evm_info.pilot_evm[pilot_evm];
  199. }
  200. }
  201. /**
  202. * dp_rx_inc_rusize_cnt() - increment pdev stats based on RU size
  203. * @pdev: pdev ctx
  204. * @rx_user_status: mon rx user status
  205. *
  206. * Return: bool
  207. */
  208. static inline bool
  209. dp_rx_inc_rusize_cnt(struct dp_pdev *pdev,
  210. struct mon_rx_user_status *rx_user_status)
  211. {
  212. uint32_t ru_size;
  213. bool is_data;
  214. ru_size = rx_user_status->ofdma_ru_size;
  215. if (dp_is_subtype_data(rx_user_status->frame_control)) {
  216. DP_STATS_INC(pdev,
  217. ul_ofdma.data_rx_ru_size[ru_size], 1);
  218. is_data = true;
  219. } else {
  220. DP_STATS_INC(pdev,
  221. ul_ofdma.nondata_rx_ru_size[ru_size], 1);
  222. is_data = false;
  223. }
  224. return is_data;
  225. }
  226. /**
  227. * dp_rx_populate_cdp_indication_ppdu_user() - Populate per user cdp indication
  228. * @pdev: pdev ctx
  229. * @ppdu_info: ppdu info structure from ppdu ring
  230. * @cdp_rx_ppdu: Rx PPDU indication structure
  231. *
  232. * Return: none
  233. */
  234. static inline void
  235. dp_rx_populate_cdp_indication_ppdu_user(struct dp_pdev *pdev,
  236. struct hal_rx_ppdu_info *ppdu_info,
  237. struct cdp_rx_indication_ppdu
  238. *cdp_rx_ppdu)
  239. {
  240. struct dp_peer *peer;
  241. struct dp_soc *soc = pdev->soc;
  242. struct dp_ast_entry *ast_entry;
  243. uint32_t ast_index;
  244. int i;
  245. struct mon_rx_user_status *rx_user_status;
  246. struct mon_rx_user_info *rx_user_info;
  247. struct cdp_rx_stats_ppdu_user *rx_stats_peruser;
  248. int ru_size;
  249. bool is_data = false;
  250. uint32_t num_users;
  251. num_users = ppdu_info->com_info.num_users;
  252. for (i = 0; i < num_users; i++) {
  253. if (i > OFDMA_NUM_USERS)
  254. return;
  255. rx_user_status = &ppdu_info->rx_user_status[i];
  256. rx_user_info = &ppdu_info->rx_user_info[i];
  257. rx_stats_peruser = &cdp_rx_ppdu->user[i];
  258. ast_index = rx_user_status->ast_index;
  259. if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  260. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  261. continue;
  262. }
  263. ast_entry = soc->ast_table[ast_index];
  264. if (!ast_entry || ast_entry->peer_id == HTT_INVALID_PEER) {
  265. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  266. continue;
  267. }
  268. peer = dp_peer_get_ref_by_id(soc, ast_entry->peer_id,
  269. DP_MOD_ID_RX_PPDU_STATS);
  270. if (!peer) {
  271. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  272. continue;
  273. }
  274. rx_stats_peruser->is_bss_peer = peer->bss_peer;
  275. rx_stats_peruser->first_data_seq_ctrl =
  276. rx_user_status->first_data_seq_ctrl;
  277. rx_stats_peruser->frame_control_info_valid =
  278. rx_user_status->frame_control_info_valid;
  279. rx_stats_peruser->frame_control =
  280. rx_user_status->frame_control;
  281. rx_stats_peruser->qos_control_info_valid =
  282. rx_user_info->qos_control_info_valid;
  283. rx_stats_peruser->qos_control =
  284. rx_user_info->qos_control;
  285. rx_stats_peruser->tcp_msdu_count =
  286. rx_user_status->tcp_msdu_count;
  287. rx_stats_peruser->udp_msdu_count =
  288. rx_user_status->udp_msdu_count;
  289. rx_stats_peruser->other_msdu_count =
  290. rx_user_status->other_msdu_count;
  291. rx_stats_peruser->num_msdu =
  292. rx_stats_peruser->tcp_msdu_count +
  293. rx_stats_peruser->udp_msdu_count +
  294. rx_stats_peruser->other_msdu_count;
  295. rx_stats_peruser->preamble_type =
  296. rx_user_status->preamble_type;
  297. rx_stats_peruser->mpdu_cnt_fcs_ok =
  298. rx_user_status->mpdu_cnt_fcs_ok;
  299. rx_stats_peruser->mpdu_cnt_fcs_err =
  300. rx_user_status->mpdu_cnt_fcs_err;
  301. qdf_mem_copy(&rx_stats_peruser->mpdu_fcs_ok_bitmap,
  302. &rx_user_status->mpdu_fcs_ok_bitmap,
  303. HAL_RX_NUM_WORDS_PER_PPDU_BITMAP *
  304. sizeof(rx_user_status->mpdu_fcs_ok_bitmap[0]));
  305. rx_stats_peruser->mpdu_ok_byte_count =
  306. rx_user_status->mpdu_ok_byte_count;
  307. rx_stats_peruser->mpdu_err_byte_count =
  308. rx_user_status->mpdu_err_byte_count;
  309. cdp_rx_ppdu->num_mpdu += rx_user_status->mpdu_cnt_fcs_ok;
  310. cdp_rx_ppdu->num_msdu += rx_stats_peruser->num_msdu;
  311. rx_stats_peruser->retries =
  312. CDP_FC_IS_RETRY_SET(rx_stats_peruser->frame_control) ?
  313. rx_stats_peruser->mpdu_cnt_fcs_ok : 0;
  314. if (rx_stats_peruser->mpdu_cnt_fcs_ok > 1)
  315. rx_stats_peruser->is_ampdu = 1;
  316. else
  317. rx_stats_peruser->is_ampdu = 0;
  318. rx_stats_peruser->tid = ppdu_info->rx_status.tid;
  319. qdf_mem_copy(rx_stats_peruser->mac_addr,
  320. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  321. rx_stats_peruser->peer_id = peer->peer_id;
  322. cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
  323. rx_stats_peruser->vdev_id = peer->vdev->vdev_id;
  324. rx_stats_peruser->mu_ul_info_valid = 0;
  325. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  326. if (cdp_rx_ppdu->u.ppdu_type == HAL_RX_TYPE_MU_OFDMA ||
  327. cdp_rx_ppdu->u.ppdu_type == HAL_RX_TYPE_MU_MIMO) {
  328. if (rx_user_status->mu_ul_info_valid) {
  329. rx_stats_peruser->nss = rx_user_status->nss;
  330. rx_stats_peruser->mcs = rx_user_status->mcs;
  331. rx_stats_peruser->mu_ul_info_valid =
  332. rx_user_status->mu_ul_info_valid;
  333. rx_stats_peruser->ofdma_ru_start_index =
  334. rx_user_status->ofdma_ru_start_index;
  335. rx_stats_peruser->ofdma_ru_width =
  336. rx_user_status->ofdma_ru_width;
  337. rx_stats_peruser->user_index = i;
  338. ru_size = rx_user_status->ofdma_ru_size;
  339. /*
  340. * max RU size will be equal to
  341. * HTT_UL_OFDMA_V0_RU_SIZE_RU_996x2
  342. */
  343. if (ru_size >= OFDMA_NUM_RU_SIZE) {
  344. dp_err("invalid ru_size %d\n",
  345. ru_size);
  346. return;
  347. }
  348. is_data = dp_rx_inc_rusize_cnt(pdev,
  349. rx_user_status);
  350. }
  351. if (is_data) {
  352. /* counter to get number of MU OFDMA */
  353. pdev->stats.ul_ofdma.data_rx_ppdu++;
  354. pdev->stats.ul_ofdma.data_users[num_users]++;
  355. }
  356. }
  357. }
  358. }
  359. /**
  360. * dp_rx_populate_cdp_indication_ppdu() - Populate cdp rx indication structure
  361. * @pdev: pdev ctx
  362. * @ppdu_info: ppdu info structure from ppdu ring
  363. * @cdp_rx_ppdu: Rx PPDU indication structure
  364. *
  365. * Return: none
  366. */
  367. static inline void
  368. dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
  369. struct hal_rx_ppdu_info *ppdu_info,
  370. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  371. {
  372. struct dp_peer *peer;
  373. struct dp_soc *soc = pdev->soc;
  374. struct dp_ast_entry *ast_entry;
  375. uint32_t ast_index;
  376. uint32_t i;
  377. cdp_rx_ppdu->first_data_seq_ctrl =
  378. ppdu_info->rx_status.first_data_seq_ctrl;
  379. cdp_rx_ppdu->frame_ctrl =
  380. ppdu_info->rx_status.frame_control;
  381. cdp_rx_ppdu->tcp_msdu_count = ppdu_info->rx_status.tcp_msdu_count;
  382. cdp_rx_ppdu->udp_msdu_count = ppdu_info->rx_status.udp_msdu_count;
  383. cdp_rx_ppdu->other_msdu_count = ppdu_info->rx_status.other_msdu_count;
  384. cdp_rx_ppdu->u.preamble = ppdu_info->rx_status.preamble_type;
  385. /* num mpdu is consolidated and added together in num user loop */
  386. cdp_rx_ppdu->num_mpdu = ppdu_info->com_info.mpdu_cnt_fcs_ok;
  387. /* num msdu is consolidated and added together in num user loop */
  388. cdp_rx_ppdu->num_msdu = (cdp_rx_ppdu->tcp_msdu_count +
  389. cdp_rx_ppdu->udp_msdu_count +
  390. cdp_rx_ppdu->other_msdu_count);
  391. cdp_rx_ppdu->retries = CDP_FC_IS_RETRY_SET(cdp_rx_ppdu->frame_ctrl) ?
  392. ppdu_info->com_info.mpdu_cnt_fcs_ok : 0;
  393. if (ppdu_info->com_info.mpdu_cnt_fcs_ok > 1)
  394. cdp_rx_ppdu->is_ampdu = 1;
  395. else
  396. cdp_rx_ppdu->is_ampdu = 0;
  397. cdp_rx_ppdu->tid = ppdu_info->rx_status.tid;
  398. ast_index = ppdu_info->rx_status.ast_index;
  399. if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  400. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  401. cdp_rx_ppdu->num_users = 0;
  402. goto end;
  403. }
  404. ast_entry = soc->ast_table[ast_index];
  405. if (!ast_entry || ast_entry->peer_id == HTT_INVALID_PEER) {
  406. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  407. cdp_rx_ppdu->num_users = 0;
  408. goto end;
  409. }
  410. peer = dp_peer_get_ref_by_id(soc, ast_entry->peer_id,
  411. DP_MOD_ID_RX_PPDU_STATS);
  412. if (!peer) {
  413. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  414. cdp_rx_ppdu->num_users = 0;
  415. goto end;
  416. }
  417. qdf_mem_copy(cdp_rx_ppdu->mac_addr,
  418. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  419. cdp_rx_ppdu->peer_id = peer->peer_id;
  420. cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
  421. cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
  422. cdp_rx_ppdu->length = ppdu_info->rx_status.ppdu_len;
  423. cdp_rx_ppdu->duration = ppdu_info->rx_status.duration;
  424. cdp_rx_ppdu->u.bw = ppdu_info->rx_status.bw;
  425. cdp_rx_ppdu->u.nss = ppdu_info->rx_status.nss;
  426. cdp_rx_ppdu->u.mcs = ppdu_info->rx_status.mcs;
  427. if ((ppdu_info->rx_status.sgi == VHT_SGI_NYSM) &&
  428. (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC))
  429. cdp_rx_ppdu->u.gi = CDP_SGI_0_4_US;
  430. else
  431. cdp_rx_ppdu->u.gi = ppdu_info->rx_status.sgi;
  432. cdp_rx_ppdu->u.ldpc = ppdu_info->rx_status.ldpc;
  433. cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
  434. cdp_rx_ppdu->u.ltf_size = (ppdu_info->rx_status.he_data5 >>
  435. QDF_MON_STATUS_HE_LTF_SIZE_SHIFT) & 0x3;
  436. cdp_rx_ppdu->rssi = ppdu_info->rx_status.rssi_comb;
  437. cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
  438. cdp_rx_ppdu->channel = ppdu_info->rx_status.chan_num;
  439. cdp_rx_ppdu->beamformed = ppdu_info->rx_status.beamformed;
  440. cdp_rx_ppdu->num_bytes = ppdu_info->rx_status.ppdu_len;
  441. cdp_rx_ppdu->lsig_a = ppdu_info->rx_status.rate;
  442. cdp_rx_ppdu->u.ltf_size = ppdu_info->rx_status.ltf_size;
  443. dp_rx_populate_rx_rssi_chain(ppdu_info, cdp_rx_ppdu);
  444. dp_rx_populate_su_evm_details(ppdu_info, cdp_rx_ppdu);
  445. cdp_rx_ppdu->rx_antenna = ppdu_info->rx_status.rx_antenna;
  446. cdp_rx_ppdu->nf = ppdu_info->rx_status.chan_noise_floor;
  447. for (i = 0; i < MAX_CHAIN; i++)
  448. cdp_rx_ppdu->per_chain_rssi[i] = ppdu_info->rx_status.rssi[i];
  449. cdp_rx_ppdu->is_mcast_bcast = ppdu_info->nac_info.mcast_bcast;
  450. cdp_rx_ppdu->num_users = ppdu_info->com_info.num_users;
  451. cdp_rx_ppdu->num_mpdu = 0;
  452. cdp_rx_ppdu->num_msdu = 0;
  453. dp_rx_populate_cdp_indication_ppdu_user(pdev, ppdu_info, cdp_rx_ppdu);
  454. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  455. return;
  456. end:
  457. dp_rx_populate_cfr_non_assoc_sta(pdev, ppdu_info, cdp_rx_ppdu);
  458. }
  459. #else
  460. static inline void
  461. dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
  462. struct hal_rx_ppdu_info *ppdu_info,
  463. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  464. {
  465. }
  466. #endif
  467. /**
  468. * dp_rx_stats_update() - Update per-peer statistics
  469. * @soc: Datapath SOC handle
  470. * @peer: Datapath peer handle
  471. * @ppdu: PPDU Descriptor
  472. *
  473. * Return: None
  474. */
  475. #ifdef FEATURE_PERPKT_INFO
  476. static inline void dp_rx_rate_stats_update(struct dp_peer *peer,
  477. struct cdp_rx_indication_ppdu *ppdu,
  478. uint32_t user)
  479. {
  480. uint32_t ratekbps = 0;
  481. uint32_t ppdu_rx_rate = 0;
  482. uint32_t nss = 0;
  483. uint8_t mcs = 0;
  484. uint32_t rix;
  485. uint16_t ratecode;
  486. struct cdp_rx_stats_ppdu_user *ppdu_user = NULL;
  487. if (!peer || !ppdu)
  488. return;
  489. if (ppdu->u.ppdu_type != HAL_RX_TYPE_SU) {
  490. ppdu_user = &ppdu->user[user];
  491. if (ppdu_user->nss == 0)
  492. nss = 0;
  493. else
  494. nss = ppdu_user->nss - 1;
  495. mcs = ppdu_user->mcs;
  496. } else {
  497. if (ppdu->u.nss == 0)
  498. nss = 0;
  499. else
  500. nss = ppdu->u.nss - 1;
  501. mcs = ppdu->u.mcs;
  502. }
  503. ratekbps = dp_getrateindex(ppdu->u.gi,
  504. mcs,
  505. nss,
  506. ppdu->u.preamble,
  507. ppdu->u.bw,
  508. &rix,
  509. &ratecode);
  510. if (!ratekbps)
  511. return;
  512. ppdu->rix = rix;
  513. DP_STATS_UPD(peer, rx.last_rx_rate, ratekbps);
  514. dp_ath_rate_lpf(peer->stats.rx.avg_rx_rate, ratekbps);
  515. ppdu_rx_rate = dp_ath_rate_out(peer->stats.rx.avg_rx_rate);
  516. DP_STATS_UPD(peer, rx.rnd_avg_rx_rate, ppdu_rx_rate);
  517. ppdu->rx_ratekbps = ratekbps;
  518. ppdu->rx_ratecode = ratecode;
  519. if (ppdu->u.ppdu_type != HAL_RX_TYPE_SU)
  520. ppdu_user->rx_ratekbps = ratekbps;
  521. if (peer->vdev)
  522. peer->vdev->stats.rx.last_rx_rate = ratekbps;
  523. }
  524. static void dp_rx_stats_update(struct dp_pdev *pdev,
  525. struct cdp_rx_indication_ppdu *ppdu)
  526. {
  527. struct dp_soc *soc = NULL;
  528. uint8_t mcs, preamble, ac = 0, nss, ppdu_type;
  529. uint16_t num_msdu;
  530. uint8_t pkt_bw_offset;
  531. struct dp_peer *peer;
  532. struct cdp_rx_stats_ppdu_user *ppdu_user;
  533. uint32_t i;
  534. enum cdp_mu_packet_type mu_pkt_type;
  535. if (pdev)
  536. soc = pdev->soc;
  537. else
  538. return;
  539. if (!soc || soc->process_rx_status)
  540. return;
  541. preamble = ppdu->u.preamble;
  542. ppdu_type = ppdu->u.ppdu_type;
  543. for (i = 0; i < ppdu->num_users && i < CDP_MU_MAX_USERS; i++) {
  544. peer = NULL;
  545. ppdu_user = &ppdu->user[i];
  546. peer = dp_peer_get_ref_by_id(soc, ppdu_user->peer_id,
  547. DP_MOD_ID_RX_PPDU_STATS);
  548. if (!peer)
  549. peer = pdev->invalid_peer;
  550. if (ppdu_type == HAL_RX_TYPE_SU) {
  551. mcs = ppdu->u.mcs;
  552. nss = ppdu->u.nss;
  553. } else {
  554. mcs = ppdu_user->mcs;
  555. nss = ppdu_user->nss;
  556. }
  557. num_msdu = ppdu_user->num_msdu;
  558. switch (ppdu->u.bw) {
  559. case CMN_BW_20MHZ:
  560. pkt_bw_offset = PKT_BW_GAIN_20MHZ;
  561. break;
  562. case CMN_BW_40MHZ:
  563. pkt_bw_offset = PKT_BW_GAIN_40MHZ;
  564. break;
  565. case CMN_BW_80MHZ:
  566. pkt_bw_offset = PKT_BW_GAIN_80MHZ;
  567. break;
  568. case CMN_BW_160MHZ:
  569. pkt_bw_offset = PKT_BW_GAIN_160MHZ;
  570. break;
  571. default:
  572. pkt_bw_offset = 0;
  573. dp_rx_mon_status_debug("%pK: Invalid BW index = %d",
  574. soc, ppdu->u.bw);
  575. }
  576. DP_STATS_UPD(peer, rx.rssi, (ppdu->rssi + pkt_bw_offset));
  577. if (peer->stats.rx.avg_rssi == INVALID_RSSI)
  578. peer->stats.rx.avg_rssi =
  579. CDP_RSSI_IN(peer->stats.rx.rssi);
  580. else
  581. CDP_RSSI_UPDATE_AVG(peer->stats.rx.avg_rssi,
  582. peer->stats.rx.rssi);
  583. if ((preamble == DOT11_A) || (preamble == DOT11_B))
  584. nss = 1;
  585. if (ppdu_type == HAL_RX_TYPE_SU) {
  586. if (nss) {
  587. DP_STATS_INC(peer, rx.nss[nss - 1], num_msdu);
  588. DP_STATS_INC(peer, rx.ppdu_nss[nss - 1], 1);
  589. }
  590. DP_STATS_INC(peer, rx.mpdu_cnt_fcs_ok,
  591. ppdu_user->mpdu_cnt_fcs_ok);
  592. DP_STATS_INC(peer, rx.mpdu_cnt_fcs_err,
  593. ppdu_user->mpdu_cnt_fcs_err);
  594. }
  595. if (ppdu_type >= HAL_RX_TYPE_MU_MIMO &&
  596. ppdu_type <= HAL_RX_TYPE_MU_OFDMA) {
  597. if (ppdu_type == HAL_RX_TYPE_MU_MIMO)
  598. mu_pkt_type = RX_TYPE_MU_MIMO;
  599. else
  600. mu_pkt_type = RX_TYPE_MU_OFDMA;
  601. if (nss) {
  602. DP_STATS_INC(peer, rx.nss[nss - 1], num_msdu);
  603. DP_STATS_INC(peer,
  604. rx.rx_mu[mu_pkt_type].ppdu_nss[nss - 1],
  605. 1);
  606. }
  607. DP_STATS_INC(peer,
  608. rx.rx_mu[mu_pkt_type].mpdu_cnt_fcs_ok,
  609. ppdu_user->mpdu_cnt_fcs_ok);
  610. DP_STATS_INC(peer,
  611. rx.rx_mu[mu_pkt_type].mpdu_cnt_fcs_err,
  612. ppdu_user->mpdu_cnt_fcs_err);
  613. }
  614. DP_STATS_INC(peer, rx.sgi_count[ppdu->u.gi], num_msdu);
  615. DP_STATS_INC(peer, rx.bw[ppdu->u.bw], num_msdu);
  616. DP_STATS_INC(peer, rx.reception_type[ppdu->u.ppdu_type],
  617. num_msdu);
  618. DP_STATS_INC(peer, rx.ppdu_cnt[ppdu->u.ppdu_type], 1);
  619. DP_STATS_INCC(peer, rx.ampdu_cnt, num_msdu,
  620. ppdu_user->is_ampdu);
  621. DP_STATS_INCC(peer, rx.non_ampdu_cnt, num_msdu,
  622. !(ppdu_user->is_ampdu));
  623. DP_STATS_UPD(peer, rx.rx_rate, mcs);
  624. DP_STATS_INCC(peer,
  625. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  626. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
  627. DP_STATS_INCC(peer,
  628. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  629. ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
  630. DP_STATS_INCC(peer,
  631. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  632. ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B)));
  633. DP_STATS_INCC(peer,
  634. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  635. ((mcs < MAX_MCS_11B) && (preamble == DOT11_B)));
  636. DP_STATS_INCC(peer,
  637. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  638. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N)));
  639. DP_STATS_INCC(peer,
  640. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  641. ((mcs < MAX_MCS_11A) && (preamble == DOT11_N)));
  642. DP_STATS_INCC(peer,
  643. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  644. ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC)));
  645. DP_STATS_INCC(peer,
  646. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  647. ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
  648. DP_STATS_INCC(peer,
  649. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  650. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  651. DP_STATS_INCC(peer,
  652. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  653. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  654. DP_STATS_INCC(peer,
  655. rx.su_ax_ppdu_cnt.mcs_count[MAX_MCS - 1], 1,
  656. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX) &&
  657. (ppdu_type == HAL_RX_TYPE_SU)));
  658. DP_STATS_INCC(peer,
  659. rx.su_ax_ppdu_cnt.mcs_count[mcs], 1,
  660. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX) &&
  661. (ppdu_type == HAL_RX_TYPE_SU)));
  662. DP_STATS_INCC(peer,
  663. rx.rx_mu[RX_TYPE_MU_OFDMA].ppdu.mcs_count[MAX_MCS - 1],
  664. 1, ((mcs >= (MAX_MCS - 1)) &&
  665. (preamble == DOT11_AX) &&
  666. (ppdu_type == HAL_RX_TYPE_MU_OFDMA)));
  667. DP_STATS_INCC(peer,
  668. rx.rx_mu[RX_TYPE_MU_OFDMA].ppdu.mcs_count[mcs],
  669. 1, ((mcs < (MAX_MCS - 1)) &&
  670. (preamble == DOT11_AX) &&
  671. (ppdu_type == HAL_RX_TYPE_MU_OFDMA)));
  672. DP_STATS_INCC(peer,
  673. rx.rx_mu[RX_TYPE_MU_MIMO].ppdu.mcs_count[MAX_MCS - 1],
  674. 1, ((mcs >= (MAX_MCS - 1)) &&
  675. (preamble == DOT11_AX) &&
  676. (ppdu_type == HAL_RX_TYPE_MU_MIMO)));
  677. DP_STATS_INCC(peer,
  678. rx.rx_mu[RX_TYPE_MU_MIMO].ppdu.mcs_count[mcs],
  679. 1, ((mcs < (MAX_MCS - 1)) &&
  680. (preamble == DOT11_AX) &&
  681. (ppdu_type == HAL_RX_TYPE_MU_MIMO)));
  682. /*
  683. * If invalid TID, it could be a non-qos frame, hence do not
  684. * update any AC counters
  685. */
  686. ac = TID_TO_WME_AC(ppdu_user->tid);
  687. if (ppdu->tid != HAL_TID_INVALID)
  688. DP_STATS_INC(peer, rx.wme_ac_type[ac], num_msdu);
  689. dp_peer_stats_notify(pdev, peer);
  690. DP_STATS_UPD(peer, rx.last_rssi, ppdu->rssi);
  691. dp_peer_qos_stats_notify(pdev, ppdu_user);
  692. if (peer == pdev->invalid_peer)
  693. continue;
  694. if (dp_is_subtype_data(ppdu->frame_ctrl))
  695. dp_rx_rate_stats_update(peer, ppdu, i);
  696. #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
  697. dp_wdi_event_handler(WDI_EVENT_UPDATE_DP_STATS, pdev->soc,
  698. &peer->stats, ppdu->peer_id,
  699. UPDATE_PEER_STATS, pdev->pdev_id);
  700. #endif
  701. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  702. }
  703. }
  704. #endif
  705. /**
  706. * dp_rx_handle_mcopy_mode() - Allocate and deliver first MSDU payload
  707. * @soc: core txrx main context
  708. * @pdev: pdev structure
  709. * @ppdu_info: structure for rx ppdu ring
  710. * @nbuf: QDF nbuf
  711. * @fcs_ok_mpdu_cnt: fcs passsed mpdu index
  712. * @deliver_frame: flag to deliver wdi event
  713. *
  714. * Return: QDF_STATUS_SUCCESS - If nbuf to be freed by caller
  715. * QDF_STATUS_E_ALREADY - If nbuf not to be freed by caller
  716. */
  717. #ifdef FEATURE_PERPKT_INFO
  718. static inline QDF_STATUS
  719. dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  720. struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf,
  721. uint8_t fcs_ok_mpdu_cnt, bool deliver_frame)
  722. {
  723. uint16_t size = 0;
  724. struct ieee80211_frame *wh;
  725. uint32_t *nbuf_data;
  726. if (!ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload)
  727. return QDF_STATUS_SUCCESS;
  728. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  729. if (pdev->mcopy_mode == M_COPY) {
  730. if (pdev->m_copy_id.rx_ppdu_id == ppdu_info->com_info.ppdu_id)
  731. return QDF_STATUS_SUCCESS;
  732. }
  733. wh = (struct ieee80211_frame *)(ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload + 4);
  734. size = (ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload -
  735. qdf_nbuf_data(nbuf));
  736. if (qdf_nbuf_pull_head(nbuf, size) == NULL)
  737. return QDF_STATUS_SUCCESS;
  738. if (((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  739. IEEE80211_FC0_TYPE_MGT) ||
  740. ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  741. IEEE80211_FC0_TYPE_CTL)) {
  742. return QDF_STATUS_SUCCESS;
  743. }
  744. nbuf_data = (uint32_t *)qdf_nbuf_data(nbuf);
  745. *nbuf_data = pdev->ppdu_info.com_info.ppdu_id;
  746. /* only retain RX MSDU payload in the skb */
  747. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) - ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].payload_len);
  748. if (deliver_frame) {
  749. pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
  750. dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
  751. nbuf, HTT_INVALID_PEER,
  752. WDI_NO_VAL, pdev->pdev_id);
  753. }
  754. return QDF_STATUS_E_ALREADY;
  755. }
  756. #else
  757. static inline QDF_STATUS
  758. dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  759. struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf,
  760. uint8_t fcs_ok_cnt, bool deliver_frame)
  761. {
  762. return QDF_STATUS_SUCCESS;
  763. }
  764. #endif
  765. /**
  766. * dp_rx_mcopy_handle_last_mpdu() - cache and delive last MPDU header in a
  767. * status buffer if MPDU end tlv is received in different buffer
  768. * @soc: core txrx main context
  769. * @pdev: pdev structure
  770. * @ppdu_info: structure for rx ppdu ring
  771. * @status_nbuf: QDF nbuf
  772. *
  773. * Return: void
  774. */
  775. #ifdef FEATURE_PERPKT_INFO
  776. static inline void
  777. dp_rx_mcopy_handle_last_mpdu(struct dp_soc *soc, struct dp_pdev *pdev,
  778. struct hal_rx_ppdu_info *ppdu_info,
  779. qdf_nbuf_t status_nbuf)
  780. {
  781. QDF_STATUS mcopy_status;
  782. qdf_nbuf_t nbuf_clone = NULL;
  783. /* If the MPDU end tlv and RX header are received in different buffers,
  784. * process the RX header based on fcs status.
  785. */
  786. if (pdev->mcopy_status_nbuf) {
  787. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  788. if (pdev->mcopy_mode == M_COPY) {
  789. if (pdev->m_copy_id.rx_ppdu_id ==
  790. ppdu_info->com_info.ppdu_id)
  791. goto end1;
  792. }
  793. if (ppdu_info->is_fcs_passed) {
  794. nbuf_clone = qdf_nbuf_clone(pdev->mcopy_status_nbuf);
  795. if (!nbuf_clone) {
  796. QDF_TRACE(QDF_MODULE_ID_TXRX,
  797. QDF_TRACE_LEVEL_ERROR,
  798. "Failed to clone nbuf",
  799. __func__, __LINE__);
  800. goto end1;
  801. }
  802. pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
  803. dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
  804. nbuf_clone,
  805. HTT_INVALID_PEER,
  806. WDI_NO_VAL, pdev->pdev_id);
  807. ppdu_info->is_fcs_passed = false;
  808. }
  809. end1:
  810. qdf_nbuf_free(pdev->mcopy_status_nbuf);
  811. pdev->mcopy_status_nbuf = NULL;
  812. }
  813. /* If the MPDU end tlv and RX header are received in different buffers,
  814. * preserve the RX header as the fcs status will be received in MPDU
  815. * end tlv in next buffer. So, cache the buffer to be processd in next
  816. * iteration
  817. */
  818. if ((ppdu_info->fcs_ok_cnt + ppdu_info->fcs_err_cnt) !=
  819. ppdu_info->com_info.mpdu_cnt) {
  820. pdev->mcopy_status_nbuf = qdf_nbuf_clone(status_nbuf);
  821. if (pdev->mcopy_status_nbuf) {
  822. mcopy_status = dp_rx_handle_mcopy_mode(
  823. soc, pdev,
  824. ppdu_info,
  825. pdev->mcopy_status_nbuf,
  826. ppdu_info->fcs_ok_cnt,
  827. false);
  828. if (mcopy_status == QDF_STATUS_SUCCESS) {
  829. qdf_nbuf_free(pdev->mcopy_status_nbuf);
  830. pdev->mcopy_status_nbuf = NULL;
  831. }
  832. }
  833. }
  834. }
  835. #else
  836. static inline void
  837. dp_rx_mcopy_handle_last_mpdu(struct dp_soc *soc, struct dp_pdev *pdev,
  838. struct hal_rx_ppdu_info *ppdu_info,
  839. qdf_nbuf_t status_nbuf)
  840. {
  841. }
  842. #endif
  843. /**
  844. * dp_rx_mcopy_process_ppdu_info() - update mcopy ppdu info
  845. * @ppdu_info: structure for rx ppdu ring
  846. * @tlv_status: processed TLV status
  847. *
  848. * Return: void
  849. */
  850. #ifdef FEATURE_PERPKT_INFO
  851. static inline void
  852. dp_rx_mcopy_process_ppdu_info(struct dp_pdev *pdev,
  853. struct hal_rx_ppdu_info *ppdu_info,
  854. uint32_t tlv_status)
  855. {
  856. if (!pdev->mcopy_mode)
  857. return;
  858. /* The fcs status is received in MPDU end tlv. If the RX header
  859. * and its MPDU end tlv are received in different status buffer then
  860. * to process that header ppdu_info->is_fcs_passed is used.
  861. * If end tlv is received in next status buffer then com_info.mpdu_cnt
  862. * will be 0 at the time of receiving MPDU end tlv and we update the
  863. * is_fcs_passed flag based on ppdu_info->fcs_err.
  864. */
  865. if (tlv_status != HAL_TLV_STATUS_MPDU_END)
  866. return;
  867. if (!ppdu_info->fcs_err) {
  868. if (ppdu_info->fcs_ok_cnt >
  869. HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER) {
  870. dp_err("No. of MPDUs(%d) per status buff exceeded",
  871. ppdu_info->fcs_ok_cnt);
  872. return;
  873. }
  874. if (ppdu_info->com_info.mpdu_cnt)
  875. ppdu_info->fcs_ok_cnt++;
  876. else
  877. ppdu_info->is_fcs_passed = true;
  878. } else {
  879. if (ppdu_info->com_info.mpdu_cnt)
  880. ppdu_info->fcs_err_cnt++;
  881. else
  882. ppdu_info->is_fcs_passed = false;
  883. }
  884. }
  885. #else
  886. static inline void
  887. dp_rx_mcopy_process_ppdu_info(struct dp_pdev *pdev,
  888. struct hal_rx_ppdu_info *ppdu_info,
  889. uint32_t tlv_status)
  890. {
  891. }
  892. #endif
  893. #ifdef FEATURE_PERPKT_INFO
  894. static inline void
  895. dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  896. struct hal_rx_ppdu_info *ppdu_info,
  897. uint32_t tlv_status,
  898. qdf_nbuf_t status_nbuf)
  899. {
  900. QDF_STATUS mcopy_status;
  901. qdf_nbuf_t nbuf_clone = NULL;
  902. uint8_t fcs_ok_mpdu_cnt = 0;
  903. dp_rx_mcopy_handle_last_mpdu(soc, pdev, ppdu_info, status_nbuf);
  904. if (qdf_unlikely(!ppdu_info->com_info.mpdu_cnt))
  905. goto end;
  906. if (qdf_unlikely(!ppdu_info->fcs_ok_cnt))
  907. goto end;
  908. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  909. if (pdev->mcopy_mode == M_COPY)
  910. ppdu_info->fcs_ok_cnt = 1;
  911. while (fcs_ok_mpdu_cnt < ppdu_info->fcs_ok_cnt) {
  912. nbuf_clone = qdf_nbuf_clone(status_nbuf);
  913. if (!nbuf_clone) {
  914. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  915. "Failed to clone nbuf",
  916. __func__, __LINE__);
  917. goto end;
  918. }
  919. mcopy_status = dp_rx_handle_mcopy_mode(soc, pdev,
  920. ppdu_info,
  921. nbuf_clone,
  922. fcs_ok_mpdu_cnt,
  923. true);
  924. if (mcopy_status == QDF_STATUS_SUCCESS)
  925. qdf_nbuf_free(nbuf_clone);
  926. fcs_ok_mpdu_cnt++;
  927. }
  928. end:
  929. qdf_nbuf_free(status_nbuf);
  930. ppdu_info->fcs_ok_cnt = 0;
  931. ppdu_info->fcs_err_cnt = 0;
  932. ppdu_info->com_info.mpdu_cnt = 0;
  933. qdf_mem_zero(&ppdu_info->ppdu_msdu_info,
  934. HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER
  935. * sizeof(struct hal_rx_msdu_payload_info));
  936. }
  937. #else
  938. static inline void
  939. dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  940. struct hal_rx_ppdu_info *ppdu_info,
  941. uint32_t tlv_status,
  942. qdf_nbuf_t status_nbuf)
  943. {
  944. }
  945. #endif
  946. /**
  947. * dp_rx_handle_smart_mesh_mode() - Deliver header for smart mesh
  948. * @soc: Datapath SOC handle
  949. * @pdev: Datapath PDEV handle
  950. * @ppdu_info: Structure for rx ppdu info
  951. * @nbuf: Qdf nbuf abstraction for linux skb
  952. *
  953. * Return: 0 on success, 1 on failure
  954. */
  955. static inline int
  956. dp_rx_handle_smart_mesh_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  957. struct hal_rx_ppdu_info *ppdu_info,
  958. qdf_nbuf_t nbuf)
  959. {
  960. uint8_t size = 0;
  961. if (!pdev->monitor_vdev) {
  962. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  963. "[%s]:[%d] Monitor vdev is NULL !!",
  964. __func__, __LINE__);
  965. return 1;
  966. }
  967. if (!ppdu_info->msdu_info.first_msdu_payload) {
  968. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  969. "[%s]:[%d] First msdu payload not present",
  970. __func__, __LINE__);
  971. return 1;
  972. }
  973. /* Adding 4 bytes to get to start of 802.11 frame after phy_ppdu_id */
  974. size = (ppdu_info->msdu_info.first_msdu_payload -
  975. qdf_nbuf_data(nbuf)) + 4;
  976. ppdu_info->msdu_info.first_msdu_payload = NULL;
  977. if (qdf_nbuf_pull_head(nbuf, size) == NULL) {
  978. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  979. "[%s]:[%d] No header present",
  980. __func__, __LINE__);
  981. return 1;
  982. }
  983. /* Only retain RX MSDU payload in the skb */
  984. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
  985. ppdu_info->msdu_info.payload_len);
  986. if (!qdf_nbuf_update_radiotap(&pdev->ppdu_info.rx_status, nbuf,
  987. qdf_nbuf_headroom(nbuf))) {
  988. DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
  989. return 1;
  990. }
  991. pdev->monitor_vdev->osif_rx_mon(pdev->monitor_vdev->osif_vdev,
  992. nbuf, NULL);
  993. pdev->ppdu_info.rx_status.monitor_direct_used = 0;
  994. return 0;
  995. }
  996. #if defined(WLAN_CFR_ENABLE) && defined(WLAN_ENH_CFR_ENABLE)
  997. /*
  998. * dp_rx_mon_handle_cfr_mu_info() - Gather macaddr and ast_index of peer(s) in
  999. * the PPDU received, this will be used for correlation of CFR data captured
  1000. * for an UL-MU-PPDU
  1001. * @pdev: pdev ctx
  1002. * @ppdu_info: pointer to ppdu info structure populated from ppdu status TLVs
  1003. * @cdp_rx_ppdu: Rx PPDU indication structure
  1004. *
  1005. * Return: none
  1006. */
  1007. static inline void
  1008. dp_rx_mon_handle_cfr_mu_info(struct dp_pdev *pdev,
  1009. struct hal_rx_ppdu_info *ppdu_info,
  1010. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1011. {
  1012. struct dp_peer *peer;
  1013. struct dp_soc *soc = pdev->soc;
  1014. struct dp_ast_entry *ast_entry;
  1015. struct mon_rx_user_status *rx_user_status;
  1016. struct cdp_rx_stats_ppdu_user *rx_stats_peruser;
  1017. uint32_t num_users;
  1018. int user_id;
  1019. uint32_t ast_index;
  1020. qdf_spin_lock_bh(&soc->ast_lock);
  1021. num_users = ppdu_info->com_info.num_users;
  1022. for (user_id = 0; user_id < num_users; user_id++) {
  1023. if (user_id > OFDMA_NUM_USERS) {
  1024. qdf_spin_unlock_bh(&soc->ast_lock);
  1025. return;
  1026. }
  1027. rx_user_status = &ppdu_info->rx_user_status[user_id];
  1028. rx_stats_peruser = &cdp_rx_ppdu->user[user_id];
  1029. ast_index = rx_user_status->ast_index;
  1030. if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  1031. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  1032. continue;
  1033. }
  1034. ast_entry = soc->ast_table[ast_index];
  1035. if (!ast_entry || ast_entry->peer_id == HTT_INVALID_PEER) {
  1036. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  1037. continue;
  1038. }
  1039. peer = dp_peer_get_ref_by_id(soc, ast_entry->peer_id,
  1040. DP_MOD_ID_RX_PPDU_STATS);
  1041. if (!peer) {
  1042. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  1043. continue;
  1044. }
  1045. qdf_mem_copy(rx_stats_peruser->mac_addr,
  1046. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  1047. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  1048. }
  1049. qdf_spin_unlock_bh(&soc->ast_lock);
  1050. }
  1051. /*
  1052. * dp_rx_mon_populate_cfr_ppdu_info() - Populate cdp ppdu info from hal ppdu
  1053. * info
  1054. * @pdev: pdev ctx
  1055. * @ppdu_info: ppdu info structure from ppdu ring
  1056. * @cdp_rx_ppdu : Rx PPDU indication structure
  1057. *
  1058. * Return: none
  1059. */
  1060. static inline void
  1061. dp_rx_mon_populate_cfr_ppdu_info(struct dp_pdev *pdev,
  1062. struct hal_rx_ppdu_info *ppdu_info,
  1063. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1064. {
  1065. int chain;
  1066. cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
  1067. cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
  1068. cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
  1069. cdp_rx_ppdu->num_users = ppdu_info->com_info.num_users;
  1070. for (chain = 0; chain < MAX_CHAIN; chain++)
  1071. cdp_rx_ppdu->per_chain_rssi[chain] =
  1072. ppdu_info->rx_status.rssi[chain];
  1073. dp_rx_mon_handle_cfr_mu_info(pdev, ppdu_info, cdp_rx_ppdu);
  1074. }
  1075. /**
  1076. * dp_cfr_rcc_mode_status() - Return status of cfr rcc mode
  1077. * @pdev: pdev ctx
  1078. *
  1079. * Return: True or False
  1080. */
  1081. static inline bool
  1082. dp_cfr_rcc_mode_status(struct dp_pdev *pdev)
  1083. {
  1084. return pdev->cfr_rcc_mode;
  1085. }
  1086. /*
  1087. * dp_rx_mon_populate_cfr_info() - Populate cdp ppdu info from hal cfr info
  1088. * @pdev: pdev ctx
  1089. * @ppdu_info: ppdu info structure from ppdu ring
  1090. * @cdp_rx_ppdu: Rx PPDU indication structure
  1091. *
  1092. * Return: none
  1093. */
  1094. static inline void
  1095. dp_rx_mon_populate_cfr_info(struct dp_pdev *pdev,
  1096. struct hal_rx_ppdu_info *ppdu_info,
  1097. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1098. {
  1099. struct cdp_rx_ppdu_cfr_info *cfr_info;
  1100. if (!dp_cfr_rcc_mode_status(pdev))
  1101. return;
  1102. cfr_info = &cdp_rx_ppdu->cfr_info;
  1103. cfr_info->bb_captured_channel
  1104. = ppdu_info->cfr_info.bb_captured_channel;
  1105. cfr_info->bb_captured_timeout
  1106. = ppdu_info->cfr_info.bb_captured_timeout;
  1107. cfr_info->bb_captured_reason
  1108. = ppdu_info->cfr_info.bb_captured_reason;
  1109. cfr_info->rx_location_info_valid
  1110. = ppdu_info->cfr_info.rx_location_info_valid;
  1111. cfr_info->chan_capture_status
  1112. = ppdu_info->cfr_info.chan_capture_status;
  1113. cfr_info->rtt_che_buffer_pointer_high8
  1114. = ppdu_info->cfr_info.rtt_che_buffer_pointer_high8;
  1115. cfr_info->rtt_che_buffer_pointer_low32
  1116. = ppdu_info->cfr_info.rtt_che_buffer_pointer_low32;
  1117. cfr_info->rtt_cfo_measurement
  1118. = (int16_t)ppdu_info->cfr_info.rtt_cfo_measurement;
  1119. cfr_info->agc_gain_info0
  1120. = ppdu_info->cfr_info.agc_gain_info0;
  1121. cfr_info->agc_gain_info1
  1122. = ppdu_info->cfr_info.agc_gain_info1;
  1123. cfr_info->agc_gain_info2
  1124. = ppdu_info->cfr_info.agc_gain_info2;
  1125. cfr_info->agc_gain_info3
  1126. = ppdu_info->cfr_info.agc_gain_info3;
  1127. cfr_info->rx_start_ts
  1128. = ppdu_info->cfr_info.rx_start_ts;
  1129. }
  1130. /**
  1131. * dp_update_cfr_dbg_stats() - Increment RCC debug statistics
  1132. * @pdev: pdev structure
  1133. * @ppdu_info: structure for rx ppdu ring
  1134. *
  1135. * Return: none
  1136. */
  1137. static inline void
  1138. dp_update_cfr_dbg_stats(struct dp_pdev *pdev,
  1139. struct hal_rx_ppdu_info *ppdu_info)
  1140. {
  1141. struct hal_rx_ppdu_cfr_info *cfr = &ppdu_info->cfr_info;
  1142. DP_STATS_INC(pdev,
  1143. rcc.chan_capture_status[cfr->chan_capture_status], 1);
  1144. if (cfr->rx_location_info_valid) {
  1145. DP_STATS_INC(pdev, rcc.rx_loc_info_valid_cnt, 1);
  1146. if (cfr->bb_captured_channel) {
  1147. DP_STATS_INC(pdev, rcc.bb_captured_channel_cnt, 1);
  1148. DP_STATS_INC(pdev,
  1149. rcc.reason_cnt[cfr->bb_captured_reason],
  1150. 1);
  1151. } else if (cfr->bb_captured_timeout) {
  1152. DP_STATS_INC(pdev, rcc.bb_captured_timeout_cnt, 1);
  1153. DP_STATS_INC(pdev,
  1154. rcc.reason_cnt[cfr->bb_captured_reason],
  1155. 1);
  1156. }
  1157. }
  1158. }
  1159. /*
  1160. * dp_rx_handle_cfr() - Gather cfr info from hal ppdu info
  1161. * @soc: core txrx main context
  1162. * @pdev: pdev ctx
  1163. * @ppdu_info: ppdu info structure from ppdu ring
  1164. *
  1165. * Return: none
  1166. */
  1167. static inline void
  1168. dp_rx_handle_cfr(struct dp_soc *soc, struct dp_pdev *pdev,
  1169. struct hal_rx_ppdu_info *ppdu_info)
  1170. {
  1171. qdf_nbuf_t ppdu_nbuf;
  1172. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  1173. dp_update_cfr_dbg_stats(pdev, ppdu_info);
  1174. if (!ppdu_info->cfr_info.bb_captured_channel)
  1175. return;
  1176. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  1177. sizeof(struct cdp_rx_indication_ppdu),
  1178. 0,
  1179. 0,
  1180. FALSE);
  1181. if (ppdu_nbuf) {
  1182. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
  1183. dp_rx_mon_populate_cfr_info(pdev, ppdu_info, cdp_rx_ppdu);
  1184. dp_rx_mon_populate_cfr_ppdu_info(pdev, ppdu_info, cdp_rx_ppdu);
  1185. qdf_nbuf_put_tail(ppdu_nbuf,
  1186. sizeof(struct cdp_rx_indication_ppdu));
  1187. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
  1188. ppdu_nbuf, HTT_INVALID_PEER,
  1189. WDI_NO_VAL, pdev->pdev_id);
  1190. }
  1191. }
  1192. /**
  1193. * dp_rx_populate_cfr_non_assoc_sta() - Populate cfr ppdu info for PPDUs from
  1194. * non-associated stations
  1195. * @pdev: pdev ctx
  1196. * @ppdu_info: ppdu info structure from ppdu ring
  1197. * @cdp_rx_ppdu: Rx PPDU indication structure
  1198. *
  1199. * Return: none
  1200. */
  1201. static inline void
  1202. dp_rx_populate_cfr_non_assoc_sta(struct dp_pdev *pdev,
  1203. struct hal_rx_ppdu_info *ppdu_info,
  1204. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1205. {
  1206. if (!dp_cfr_rcc_mode_status(pdev))
  1207. return;
  1208. if (ppdu_info->cfr_info.bb_captured_channel)
  1209. dp_rx_mon_populate_cfr_ppdu_info(pdev, ppdu_info, cdp_rx_ppdu);
  1210. }
  1211. /**
  1212. * dp_bb_captured_chan_status() - Get the bb_captured_channel status
  1213. * @ppdu_info: structure for rx ppdu ring
  1214. *
  1215. * Return: Success/ Failure
  1216. */
  1217. static inline QDF_STATUS
  1218. dp_bb_captured_chan_status(struct dp_pdev *pdev,
  1219. struct hal_rx_ppdu_info *ppdu_info)
  1220. {
  1221. QDF_STATUS status = QDF_STATUS_E_FAILURE;
  1222. struct hal_rx_ppdu_cfr_info *cfr = &ppdu_info->cfr_info;
  1223. if (dp_cfr_rcc_mode_status(pdev)) {
  1224. if (cfr->bb_captured_channel)
  1225. status = QDF_STATUS_SUCCESS;
  1226. }
  1227. return status;
  1228. }
  1229. #else
  1230. static inline void
  1231. dp_rx_mon_handle_cfr_mu_info(struct dp_pdev *pdev,
  1232. struct hal_rx_ppdu_info *ppdu_info,
  1233. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1234. {
  1235. }
  1236. static inline void
  1237. dp_rx_mon_populate_cfr_ppdu_info(struct dp_pdev *pdev,
  1238. struct hal_rx_ppdu_info *ppdu_info,
  1239. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1240. {
  1241. }
  1242. static inline void
  1243. dp_rx_mon_populate_cfr_info(struct dp_pdev *pdev,
  1244. struct hal_rx_ppdu_info *ppdu_info,
  1245. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1246. {
  1247. }
  1248. static inline void
  1249. dp_rx_handle_cfr(struct dp_soc *soc, struct dp_pdev *pdev,
  1250. struct hal_rx_ppdu_info *ppdu_info)
  1251. {
  1252. }
  1253. static inline void
  1254. dp_rx_populate_cfr_non_assoc_sta(struct dp_pdev *pdev,
  1255. struct hal_rx_ppdu_info *ppdu_info,
  1256. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  1257. {
  1258. }
  1259. static inline void
  1260. dp_update_cfr_dbg_stats(struct dp_pdev *pdev,
  1261. struct hal_rx_ppdu_info *ppdu_info)
  1262. {
  1263. }
  1264. static inline QDF_STATUS
  1265. dp_bb_captured_chan_status(struct dp_pdev *pdev,
  1266. struct hal_rx_ppdu_info *ppdu_info)
  1267. {
  1268. return QDF_STATUS_E_NOSUPPORT;
  1269. }
  1270. static inline bool
  1271. dp_cfr_rcc_mode_status(struct dp_pdev *pdev)
  1272. {
  1273. return false;
  1274. }
  1275. #endif
  1276. /**
  1277. * dp_rx_handle_ppdu_stats() - Allocate and deliver ppdu stats to cdp layer
  1278. * @soc: core txrx main context
  1279. * @pdev: pdev strcuture
  1280. * @ppdu_info: structure for rx ppdu ring
  1281. *
  1282. * Return: none
  1283. */
  1284. #ifdef FEATURE_PERPKT_INFO
  1285. static inline void
  1286. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  1287. struct hal_rx_ppdu_info *ppdu_info)
  1288. {
  1289. qdf_nbuf_t ppdu_nbuf;
  1290. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  1291. /*
  1292. * Do not allocate if fcs error,
  1293. * ast idx invalid / fctl invalid
  1294. *
  1295. * In CFR RCC mode - PPDU status TLVs of error pkts are also needed
  1296. */
  1297. if (ppdu_info->com_info.mpdu_cnt_fcs_ok == 0)
  1298. return;
  1299. if (ppdu_info->nac_info.fc_valid &&
  1300. ppdu_info->nac_info.to_ds_flag &&
  1301. ppdu_info->nac_info.mac_addr2_valid) {
  1302. struct dp_neighbour_peer *peer = NULL;
  1303. uint8_t rssi = ppdu_info->rx_status.rssi_comb;
  1304. qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
  1305. if (pdev->neighbour_peers_added) {
  1306. TAILQ_FOREACH(peer, &pdev->neighbour_peers_list,
  1307. neighbour_peer_list_elem) {
  1308. if (!qdf_mem_cmp(&peer->neighbour_peers_macaddr,
  1309. &ppdu_info->nac_info.mac_addr2,
  1310. QDF_MAC_ADDR_SIZE)) {
  1311. peer->rssi = rssi;
  1312. break;
  1313. }
  1314. }
  1315. }
  1316. qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
  1317. }
  1318. /* need not generate wdi event when mcopy, cfr rcc mode and
  1319. * enhanced stats are not enabled
  1320. */
  1321. if (!pdev->mcopy_mode && !pdev->enhanced_stats_en &&
  1322. !dp_cfr_rcc_mode_status(pdev))
  1323. return;
  1324. if (dp_cfr_rcc_mode_status(pdev))
  1325. dp_update_cfr_dbg_stats(pdev, ppdu_info);
  1326. if (!ppdu_info->rx_status.frame_control_info_valid ||
  1327. (ppdu_info->rx_status.ast_index == HAL_AST_IDX_INVALID)) {
  1328. if (!(pdev->mcopy_mode ||
  1329. (dp_bb_captured_chan_status(pdev, ppdu_info) ==
  1330. QDF_STATUS_SUCCESS)))
  1331. return;
  1332. }
  1333. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  1334. sizeof(struct cdp_rx_indication_ppdu),
  1335. 0, 0, FALSE);
  1336. if (ppdu_nbuf) {
  1337. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
  1338. dp_rx_mon_populate_cfr_info(pdev, ppdu_info, cdp_rx_ppdu);
  1339. dp_rx_populate_cdp_indication_ppdu(pdev,
  1340. ppdu_info, cdp_rx_ppdu);
  1341. if (!qdf_nbuf_put_tail(ppdu_nbuf,
  1342. sizeof(struct cdp_rx_indication_ppdu)))
  1343. return;
  1344. dp_rx_stats_update(pdev, cdp_rx_ppdu);
  1345. if (cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) {
  1346. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC,
  1347. soc, ppdu_nbuf,
  1348. cdp_rx_ppdu->peer_id,
  1349. WDI_NO_VAL, pdev->pdev_id);
  1350. } else if (pdev->mcopy_mode || dp_cfr_rcc_mode_status(pdev)) {
  1351. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
  1352. ppdu_nbuf, HTT_INVALID_PEER,
  1353. WDI_NO_VAL, pdev->pdev_id);
  1354. } else {
  1355. qdf_nbuf_free(ppdu_nbuf);
  1356. }
  1357. }
  1358. }
  1359. #else
  1360. static inline void
  1361. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  1362. struct hal_rx_ppdu_info *ppdu_info)
  1363. {
  1364. }
  1365. #endif
  1366. /**
  1367. * dp_rx_process_peer_based_pktlog() - Process Rx pktlog if peer based
  1368. * filtering enabled
  1369. * @soc: core txrx main context
  1370. * @ppdu_info: Structure for rx ppdu info
  1371. * @status_nbuf: Qdf nbuf abstraction for linux skb
  1372. * @pdev_id: mac_id/pdev_id correspondinggly for MCL and WIN
  1373. *
  1374. * Return: none
  1375. */
  1376. static inline void
  1377. dp_rx_process_peer_based_pktlog(struct dp_soc *soc,
  1378. struct hal_rx_ppdu_info *ppdu_info,
  1379. qdf_nbuf_t status_nbuf, uint32_t pdev_id)
  1380. {
  1381. struct dp_peer *peer;
  1382. struct dp_ast_entry *ast_entry;
  1383. uint32_t ast_index;
  1384. ast_index = ppdu_info->rx_status.ast_index;
  1385. if (ast_index < wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  1386. ast_entry = soc->ast_table[ast_index];
  1387. if (ast_entry) {
  1388. peer = dp_peer_get_ref_by_id(soc, ast_entry->peer_id,
  1389. DP_MOD_ID_RX_PPDU_STATS);
  1390. if (peer) {
  1391. if ((peer->peer_id != HTT_INVALID_PEER) &&
  1392. (peer->peer_based_pktlog_filter)) {
  1393. dp_wdi_event_handler(
  1394. WDI_EVENT_RX_DESC, soc,
  1395. status_nbuf,
  1396. peer->peer_id,
  1397. WDI_NO_VAL, pdev_id);
  1398. }
  1399. dp_peer_unref_delete(peer,
  1400. DP_MOD_ID_RX_PPDU_STATS);
  1401. }
  1402. }
  1403. }
  1404. }
  1405. #if defined(HTT_UL_OFDMA_USER_INFO_V0_W0_VALID_M)
  1406. static inline void
  1407. dp_rx_ul_ofdma_ru_size_to_width(
  1408. uint32_t ru_size,
  1409. uint32_t *ru_width)
  1410. {
  1411. uint32_t width;
  1412. width = 0;
  1413. switch (ru_size) {
  1414. case HTT_UL_OFDMA_V0_RU_SIZE_RU_26:
  1415. width = 1;
  1416. break;
  1417. case HTT_UL_OFDMA_V0_RU_SIZE_RU_52:
  1418. width = 2;
  1419. break;
  1420. case HTT_UL_OFDMA_V0_RU_SIZE_RU_106:
  1421. width = 4;
  1422. break;
  1423. case HTT_UL_OFDMA_V0_RU_SIZE_RU_242:
  1424. width = 9;
  1425. break;
  1426. case HTT_UL_OFDMA_V0_RU_SIZE_RU_484:
  1427. width = 18;
  1428. break;
  1429. case HTT_UL_OFDMA_V0_RU_SIZE_RU_996:
  1430. width = 37;
  1431. break;
  1432. case HTT_UL_OFDMA_V0_RU_SIZE_RU_996x2:
  1433. width = 74;
  1434. break;
  1435. default:
  1436. dp_rx_mon_status_err("RU size to width convert err");
  1437. break;
  1438. }
  1439. *ru_width = width;
  1440. }
  1441. static inline void
  1442. dp_rx_mon_handle_mu_ul_info(struct hal_rx_ppdu_info *ppdu_info)
  1443. {
  1444. struct mon_rx_user_status *mon_rx_user_status;
  1445. uint32_t num_users;
  1446. uint32_t i;
  1447. uint32_t mu_ul_user_v0_word0;
  1448. uint32_t mu_ul_user_v0_word1;
  1449. uint32_t ru_width;
  1450. uint32_t ru_size;
  1451. if (!(ppdu_info->rx_status.reception_type == HAL_RX_TYPE_MU_OFDMA ||
  1452. ppdu_info->rx_status.reception_type == HAL_RX_TYPE_MU_MIMO))
  1453. return;
  1454. num_users = ppdu_info->com_info.num_users;
  1455. if (num_users > HAL_MAX_UL_MU_USERS)
  1456. num_users = HAL_MAX_UL_MU_USERS;
  1457. for (i = 0; i < num_users; i++) {
  1458. mon_rx_user_status = &ppdu_info->rx_user_status[i];
  1459. mu_ul_user_v0_word0 =
  1460. mon_rx_user_status->mu_ul_user_v0_word0;
  1461. mu_ul_user_v0_word1 =
  1462. mon_rx_user_status->mu_ul_user_v0_word1;
  1463. if (HTT_UL_OFDMA_USER_INFO_V0_W0_VALID_GET(
  1464. mu_ul_user_v0_word0) &&
  1465. !HTT_UL_OFDMA_USER_INFO_V0_W0_VER_GET(
  1466. mu_ul_user_v0_word0)) {
  1467. mon_rx_user_status->mcs =
  1468. HTT_UL_OFDMA_USER_INFO_V0_W1_MCS_GET(
  1469. mu_ul_user_v0_word1);
  1470. mon_rx_user_status->nss =
  1471. HTT_UL_OFDMA_USER_INFO_V0_W1_NSS_GET(
  1472. mu_ul_user_v0_word1) + 1;
  1473. mon_rx_user_status->mu_ul_info_valid = 1;
  1474. mon_rx_user_status->ofdma_ru_start_index =
  1475. HTT_UL_OFDMA_USER_INFO_V0_W1_RU_START_GET(
  1476. mu_ul_user_v0_word1);
  1477. ru_size =
  1478. HTT_UL_OFDMA_USER_INFO_V0_W1_RU_SIZE_GET(
  1479. mu_ul_user_v0_word1);
  1480. dp_rx_ul_ofdma_ru_size_to_width(ru_size, &ru_width);
  1481. mon_rx_user_status->ofdma_ru_width = ru_width;
  1482. mon_rx_user_status->ofdma_ru_size = ru_size;
  1483. }
  1484. }
  1485. }
  1486. #else
  1487. static inline void
  1488. dp_rx_mon_handle_mu_ul_info(struct hal_rx_ppdu_info *ppdu_info)
  1489. {
  1490. }
  1491. #endif
  1492. /**
  1493. * dp_rx_mon_status_process_tlv() - Process status TLV in status
  1494. * buffer on Rx status Queue posted by status SRNG processing.
  1495. * @soc: core txrx main context
  1496. * @int_ctx: interrupt context
  1497. * @mac_id: mac_id which is one of 3 mac_ids _ring
  1498. * @quota: amount of work which can be done
  1499. *
  1500. * Return: none
  1501. */
  1502. static inline void
  1503. dp_rx_mon_status_process_tlv(struct dp_soc *soc, struct dp_intr *int_ctx,
  1504. uint32_t mac_id, uint32_t quota)
  1505. {
  1506. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1507. struct hal_rx_ppdu_info *ppdu_info;
  1508. qdf_nbuf_t status_nbuf;
  1509. uint8_t *rx_tlv;
  1510. uint8_t *rx_tlv_start;
  1511. uint32_t tlv_status = HAL_TLV_STATUS_BUF_DONE;
  1512. QDF_STATUS enh_log_status = QDF_STATUS_SUCCESS;
  1513. struct cdp_pdev_mon_stats *rx_mon_stats;
  1514. int smart_mesh_status;
  1515. enum WDI_EVENT pktlog_mode = WDI_NO_VAL;
  1516. bool nbuf_used;
  1517. uint32_t rx_enh_capture_mode;
  1518. if (!pdev) {
  1519. dp_rx_mon_status_debug("%pK: pdev is null for mac_id = %d", soc,
  1520. mac_id);
  1521. return;
  1522. }
  1523. ppdu_info = &pdev->ppdu_info;
  1524. rx_mon_stats = &pdev->rx_mon_stats;
  1525. if (pdev->mon_ppdu_status != DP_PPDU_STATUS_START)
  1526. return;
  1527. rx_enh_capture_mode = pdev->rx_enh_capture_mode;
  1528. while (!qdf_nbuf_is_queue_empty(&pdev->rx_status_q)) {
  1529. status_nbuf = qdf_nbuf_queue_remove(&pdev->rx_status_q);
  1530. rx_tlv = qdf_nbuf_data(status_nbuf);
  1531. rx_tlv_start = rx_tlv;
  1532. nbuf_used = false;
  1533. if ((pdev->monitor_vdev) || (pdev->enhanced_stats_en) ||
  1534. (pdev->mcopy_mode) || (dp_cfr_rcc_mode_status(pdev)) ||
  1535. (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED)) {
  1536. do {
  1537. tlv_status = hal_rx_status_get_tlv_info(rx_tlv,
  1538. ppdu_info, pdev->soc->hal_soc,
  1539. status_nbuf);
  1540. dp_rx_mon_update_dbg_ppdu_stats(ppdu_info,
  1541. rx_mon_stats);
  1542. dp_rx_mon_enh_capture_process(pdev, tlv_status,
  1543. status_nbuf, ppdu_info,
  1544. &nbuf_used);
  1545. dp_rx_mcopy_process_ppdu_info(pdev,
  1546. ppdu_info,
  1547. tlv_status);
  1548. rx_tlv = hal_rx_status_get_next_tlv(rx_tlv);
  1549. if ((rx_tlv - rx_tlv_start) >=
  1550. RX_MON_STATUS_BUF_SIZE)
  1551. break;
  1552. } while ((tlv_status == HAL_TLV_STATUS_PPDU_NOT_DONE) ||
  1553. (tlv_status == HAL_TLV_STATUS_HEADER) ||
  1554. (tlv_status == HAL_TLV_STATUS_MPDU_END) ||
  1555. (tlv_status == HAL_TLV_STATUS_MSDU_END));
  1556. }
  1557. if (pdev->dp_peer_based_pktlog) {
  1558. dp_rx_process_peer_based_pktlog(soc, ppdu_info,
  1559. status_nbuf,
  1560. pdev->pdev_id);
  1561. } else {
  1562. if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_FULL)
  1563. pktlog_mode = WDI_EVENT_RX_DESC;
  1564. else if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_LITE)
  1565. pktlog_mode = WDI_EVENT_LITE_RX;
  1566. if (pktlog_mode != WDI_NO_VAL)
  1567. dp_wdi_event_handler(pktlog_mode, soc,
  1568. status_nbuf,
  1569. HTT_INVALID_PEER,
  1570. WDI_NO_VAL, pdev->pdev_id);
  1571. }
  1572. /* smart monitor vap and m_copy cannot co-exist */
  1573. if (ppdu_info->rx_status.monitor_direct_used && pdev->neighbour_peers_added
  1574. && pdev->monitor_vdev) {
  1575. smart_mesh_status = dp_rx_handle_smart_mesh_mode(soc,
  1576. pdev, ppdu_info, status_nbuf);
  1577. if (smart_mesh_status)
  1578. qdf_nbuf_free(status_nbuf);
  1579. } else if (qdf_unlikely(pdev->mcopy_mode)) {
  1580. dp_rx_process_mcopy_mode(soc, pdev,
  1581. ppdu_info, tlv_status,
  1582. status_nbuf);
  1583. } else if (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED) {
  1584. if (!nbuf_used)
  1585. qdf_nbuf_free(status_nbuf);
  1586. if (tlv_status == HAL_TLV_STATUS_PPDU_DONE)
  1587. enh_log_status =
  1588. dp_rx_handle_enh_capture(soc,
  1589. pdev, ppdu_info);
  1590. } else {
  1591. qdf_nbuf_free(status_nbuf);
  1592. }
  1593. if (tlv_status == HAL_TLV_STATUS_PPDU_NON_STD_DONE) {
  1594. dp_rx_mon_deliver_non_std(soc, mac_id);
  1595. } else if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) {
  1596. rx_mon_stats->status_ppdu_done++;
  1597. dp_rx_mon_handle_mu_ul_info(ppdu_info);
  1598. if (pdev->tx_capture_enabled
  1599. != CDP_TX_ENH_CAPTURE_DISABLED)
  1600. dp_send_ack_frame_to_stack(soc, pdev,
  1601. ppdu_info);
  1602. if (pdev->enhanced_stats_en ||
  1603. pdev->mcopy_mode || pdev->neighbour_peers_added)
  1604. dp_rx_handle_ppdu_stats(soc, pdev, ppdu_info);
  1605. else if (dp_cfr_rcc_mode_status(pdev))
  1606. dp_rx_handle_cfr(soc, pdev, ppdu_info);
  1607. pdev->mon_ppdu_status = DP_PPDU_STATUS_DONE;
  1608. /*
  1609. * if chan_num is not fetched correctly from ppdu RX TLV,
  1610. * get it from pdev saved.
  1611. */
  1612. if (qdf_unlikely(pdev->ppdu_info.rx_status.chan_num == 0))
  1613. pdev->ppdu_info.rx_status.chan_num = pdev->mon_chan_num;
  1614. /*
  1615. * if chan_freq is not fetched correctly from ppdu RX TLV,
  1616. * get it from pdev saved.
  1617. */
  1618. if (qdf_unlikely(pdev->ppdu_info.rx_status.chan_freq == 0)) {
  1619. pdev->ppdu_info.rx_status.chan_freq =
  1620. pdev->mon_chan_freq;
  1621. }
  1622. if (!soc->full_mon_mode)
  1623. dp_rx_mon_dest_process(soc, int_ctx, mac_id,
  1624. quota);
  1625. pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  1626. }
  1627. }
  1628. return;
  1629. }
  1630. /*
  1631. * dp_rx_nbuf_prepare() - prepare RX nbuf
  1632. * @soc: core txrx main context
  1633. * @pdev: core txrx pdev context
  1634. *
  1635. * This function alloc & map nbuf for RX dma usage, retry it if failed
  1636. * until retry times reaches max threshold or succeeded.
  1637. *
  1638. * Return: qdf_nbuf_t pointer if succeeded, NULL if failed.
  1639. */
  1640. static inline qdf_nbuf_t
  1641. dp_rx_nbuf_prepare(struct dp_soc *soc, struct dp_pdev *pdev)
  1642. {
  1643. uint8_t *buf;
  1644. int32_t nbuf_retry_count;
  1645. QDF_STATUS ret;
  1646. qdf_nbuf_t nbuf = NULL;
  1647. for (nbuf_retry_count = 0; nbuf_retry_count <
  1648. QDF_NBUF_ALLOC_MAP_RETRY_THRESHOLD;
  1649. nbuf_retry_count++) {
  1650. /* Allocate a new skb using alloc_skb */
  1651. nbuf = qdf_nbuf_alloc_no_recycler(RX_MON_STATUS_BUF_SIZE,
  1652. RX_MON_STATUS_BUF_RESERVATION,
  1653. RX_DATA_BUFFER_ALIGNMENT);
  1654. if (!nbuf) {
  1655. DP_STATS_INC(pdev, replenish.nbuf_alloc_fail, 1);
  1656. continue;
  1657. }
  1658. buf = qdf_nbuf_data(nbuf);
  1659. memset(buf, 0, RX_MON_STATUS_BUF_SIZE);
  1660. ret = qdf_nbuf_map_nbytes_single(soc->osdev, nbuf,
  1661. QDF_DMA_FROM_DEVICE,
  1662. RX_MON_STATUS_BUF_SIZE);
  1663. /* nbuf map failed */
  1664. if (qdf_unlikely(QDF_IS_STATUS_ERROR(ret))) {
  1665. qdf_nbuf_free(nbuf);
  1666. DP_STATS_INC(pdev, replenish.map_err, 1);
  1667. continue;
  1668. }
  1669. /* qdf_nbuf alloc and map succeeded */
  1670. break;
  1671. }
  1672. /* qdf_nbuf still alloc or map failed */
  1673. if (qdf_unlikely(nbuf_retry_count >=
  1674. QDF_NBUF_ALLOC_MAP_RETRY_THRESHOLD))
  1675. return NULL;
  1676. return nbuf;
  1677. }
  1678. /*
  1679. * dp_rx_mon_status_srng_process() - Process monitor status ring
  1680. * post the status ring buffer to Rx status Queue for later
  1681. * processing when status ring is filled with status TLV.
  1682. * Allocate a new buffer to status ring if the filled buffer
  1683. * is posted.
  1684. * @soc: core txrx main context
  1685. * @int_ctx: interrupt context
  1686. * @mac_id: mac_id which is one of 3 mac_ids
  1687. * @quota: No. of ring entry that can be serviced in one shot.
  1688. * Return: uint32_t: No. of ring entry that is processed.
  1689. */
  1690. static inline uint32_t
  1691. dp_rx_mon_status_srng_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  1692. uint32_t mac_id, uint32_t quota)
  1693. {
  1694. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1695. hal_soc_handle_t hal_soc;
  1696. void *mon_status_srng;
  1697. void *rxdma_mon_status_ring_entry;
  1698. QDF_STATUS status;
  1699. enum dp_mon_reap_status reap_status;
  1700. uint32_t work_done = 0;
  1701. if (!pdev) {
  1702. dp_rx_mon_status_debug("%pK: pdev is null for mac_id = %d",
  1703. soc, mac_id);
  1704. return work_done;
  1705. }
  1706. mon_status_srng = soc->rxdma_mon_status_ring[mac_id].hal_srng;
  1707. qdf_assert(mon_status_srng);
  1708. if (!mon_status_srng || !hal_srng_initialized(mon_status_srng)) {
  1709. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1710. "%s %d : HAL Monitor Status Ring Init Failed -- %pK",
  1711. __func__, __LINE__, mon_status_srng);
  1712. return work_done;
  1713. }
  1714. hal_soc = soc->hal_soc;
  1715. qdf_assert(hal_soc);
  1716. if (qdf_unlikely(dp_srng_access_start(int_ctx, soc, mon_status_srng)))
  1717. goto done;
  1718. /* mon_status_ring_desc => WBM_BUFFER_RING STRUCT =>
  1719. * BUFFER_ADDR_INFO STRUCT
  1720. */
  1721. while (qdf_likely((rxdma_mon_status_ring_entry =
  1722. hal_srng_src_peek_n_get_next(hal_soc, mon_status_srng))
  1723. && quota--)) {
  1724. uint32_t rx_buf_cookie;
  1725. qdf_nbuf_t status_nbuf;
  1726. struct dp_rx_desc *rx_desc;
  1727. uint8_t *status_buf;
  1728. qdf_dma_addr_t paddr;
  1729. uint64_t buf_addr;
  1730. struct rx_desc_pool *rx_desc_pool;
  1731. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1732. buf_addr =
  1733. (HAL_RX_BUFFER_ADDR_31_0_GET(
  1734. rxdma_mon_status_ring_entry) |
  1735. ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(
  1736. rxdma_mon_status_ring_entry)) << 32));
  1737. if (qdf_likely(buf_addr)) {
  1738. rx_buf_cookie =
  1739. HAL_RX_BUF_COOKIE_GET(
  1740. rxdma_mon_status_ring_entry);
  1741. rx_desc = dp_rx_cookie_2_va_mon_status(soc,
  1742. rx_buf_cookie);
  1743. qdf_assert(rx_desc);
  1744. status_nbuf = rx_desc->nbuf;
  1745. qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf,
  1746. QDF_DMA_FROM_DEVICE);
  1747. status_buf = qdf_nbuf_data(status_nbuf);
  1748. status = hal_get_rx_status_done(status_buf);
  1749. if (status != QDF_STATUS_SUCCESS) {
  1750. uint32_t hp, tp;
  1751. hal_get_sw_hptp(hal_soc, mon_status_srng,
  1752. &tp, &hp);
  1753. dp_info_rl("tlv tag status error hp:%u, tp:%u",
  1754. hp, tp);
  1755. /* RxDMA status done bit might not be set even
  1756. * though tp is moved by HW.
  1757. */
  1758. /* If done status is missing:
  1759. * 1. As per MAC team's suggestion,
  1760. * when HP + 1 entry is peeked and if DMA
  1761. * is not done and if HP + 2 entry's DMA done
  1762. * is set. skip HP + 1 entry and
  1763. * start processing in next interrupt.
  1764. * 2. If HP + 2 entry's DMA done is not set,
  1765. * poll onto HP + 1 entry DMA done to be set.
  1766. * Check status for same buffer for next time
  1767. * dp_rx_mon_status_srng_process
  1768. */
  1769. reap_status = dp_rx_mon_handle_status_buf_done(pdev,
  1770. mon_status_srng);
  1771. if (reap_status == DP_MON_STATUS_NO_DMA)
  1772. continue;
  1773. else if (reap_status == DP_MON_STATUS_REPLENISH) {
  1774. qdf_nbuf_unmap_nbytes_single(
  1775. soc->osdev, status_nbuf,
  1776. QDF_DMA_FROM_DEVICE,
  1777. rx_desc_pool->buf_size);
  1778. qdf_nbuf_free(status_nbuf);
  1779. goto buf_replenish;
  1780. }
  1781. }
  1782. qdf_nbuf_set_pktlen(status_nbuf,
  1783. RX_MON_STATUS_BUF_SIZE);
  1784. qdf_nbuf_unmap_nbytes_single(soc->osdev, status_nbuf,
  1785. QDF_DMA_FROM_DEVICE,
  1786. rx_desc_pool->buf_size);
  1787. /* Put the status_nbuf to queue */
  1788. qdf_nbuf_queue_add(&pdev->rx_status_q, status_nbuf);
  1789. } else {
  1790. union dp_rx_desc_list_elem_t *desc_list = NULL;
  1791. union dp_rx_desc_list_elem_t *tail = NULL;
  1792. uint32_t num_alloc_desc;
  1793. num_alloc_desc = dp_rx_get_free_desc_list(soc, mac_id,
  1794. rx_desc_pool,
  1795. 1,
  1796. &desc_list,
  1797. &tail);
  1798. /*
  1799. * No free descriptors available
  1800. */
  1801. if (qdf_unlikely(num_alloc_desc == 0)) {
  1802. work_done++;
  1803. break;
  1804. }
  1805. rx_desc = &desc_list->rx_desc;
  1806. }
  1807. buf_replenish:
  1808. status_nbuf = dp_rx_nbuf_prepare(soc, pdev);
  1809. /*
  1810. * qdf_nbuf alloc or map failed,
  1811. * free the dp rx desc to free list,
  1812. * fill in NULL dma address at current HP entry,
  1813. * keep HP in mon_status_ring unchanged,
  1814. * wait next time dp_rx_mon_status_srng_process
  1815. * to fill in buffer at current HP.
  1816. */
  1817. if (qdf_unlikely(!status_nbuf)) {
  1818. union dp_rx_desc_list_elem_t *desc_list = NULL;
  1819. union dp_rx_desc_list_elem_t *tail = NULL;
  1820. struct rx_desc_pool *rx_desc_pool;
  1821. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1822. dp_info_rl("fail to allocate or map qdf_nbuf");
  1823. dp_rx_add_to_free_desc_list(&desc_list,
  1824. &tail, rx_desc);
  1825. dp_rx_add_desc_list_to_free_list(soc, &desc_list,
  1826. &tail, mac_id, rx_desc_pool);
  1827. hal_rxdma_buff_addr_info_set(
  1828. rxdma_mon_status_ring_entry,
  1829. 0, 0, HAL_RX_BUF_RBM_SW3_BM);
  1830. work_done++;
  1831. break;
  1832. }
  1833. paddr = qdf_nbuf_get_frag_paddr(status_nbuf, 0);
  1834. rx_desc->nbuf = status_nbuf;
  1835. rx_desc->in_use = 1;
  1836. hal_rxdma_buff_addr_info_set(rxdma_mon_status_ring_entry,
  1837. paddr, rx_desc->cookie, HAL_RX_BUF_RBM_SW3_BM);
  1838. hal_srng_src_get_next(hal_soc, mon_status_srng);
  1839. work_done++;
  1840. }
  1841. done:
  1842. dp_srng_access_end(int_ctx, soc, mon_status_srng);
  1843. return work_done;
  1844. }
  1845. uint32_t
  1846. dp_rx_mon_status_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  1847. uint32_t mac_id, uint32_t quota)
  1848. {
  1849. uint32_t work_done;
  1850. work_done = dp_rx_mon_status_srng_process(soc, int_ctx, mac_id, quota);
  1851. quota -= work_done;
  1852. dp_rx_mon_status_process_tlv(soc, int_ctx, mac_id, quota);
  1853. return work_done;
  1854. }
  1855. #ifndef DISABLE_MON_CONFIG
  1856. uint32_t
  1857. dp_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  1858. uint32_t mac_id, uint32_t quota)
  1859. {
  1860. if (qdf_unlikely(soc->full_mon_mode))
  1861. return dp_rx_mon_process(soc, int_ctx, mac_id, quota);
  1862. return dp_rx_mon_status_process(soc, int_ctx, mac_id, quota);
  1863. }
  1864. #else
  1865. uint32_t
  1866. dp_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  1867. uint32_t mac_id, uint32_t quota)
  1868. {
  1869. return 0;
  1870. }
  1871. #endif
  1872. QDF_STATUS
  1873. dp_rx_pdev_mon_status_buffers_alloc(struct dp_pdev *pdev, uint32_t mac_id)
  1874. {
  1875. uint8_t pdev_id = pdev->pdev_id;
  1876. struct dp_soc *soc = pdev->soc;
  1877. struct dp_srng *mon_status_ring;
  1878. uint32_t num_entries;
  1879. struct rx_desc_pool *rx_desc_pool;
  1880. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  1881. union dp_rx_desc_list_elem_t *desc_list = NULL;
  1882. union dp_rx_desc_list_elem_t *tail = NULL;
  1883. soc_cfg_ctx = soc->wlan_cfg_ctx;
  1884. mon_status_ring = &soc->rxdma_mon_status_ring[mac_id];
  1885. num_entries = mon_status_ring->num_entries;
  1886. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1887. dp_debug("Mon RX Desc Pool[%d] entries=%u",
  1888. pdev_id, num_entries);
  1889. return dp_rx_mon_status_buffers_replenish(soc, mac_id, mon_status_ring,
  1890. rx_desc_pool, num_entries,
  1891. &desc_list, &tail,
  1892. HAL_RX_BUF_RBM_SW3_BM);
  1893. }
  1894. QDF_STATUS
  1895. dp_rx_pdev_mon_status_desc_pool_alloc(struct dp_pdev *pdev, uint32_t mac_id)
  1896. {
  1897. uint8_t pdev_id = pdev->pdev_id;
  1898. struct dp_soc *soc = pdev->soc;
  1899. struct dp_srng *mon_status_ring;
  1900. uint32_t num_entries;
  1901. struct rx_desc_pool *rx_desc_pool;
  1902. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  1903. soc_cfg_ctx = soc->wlan_cfg_ctx;
  1904. mon_status_ring = &soc->rxdma_mon_status_ring[mac_id];
  1905. num_entries = mon_status_ring->num_entries;
  1906. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1907. dp_debug("Mon RX Desc Pool[%d] entries=%u", pdev_id, num_entries);
  1908. rx_desc_pool->desc_type = DP_RX_DESC_STATUS_TYPE;
  1909. return dp_rx_desc_pool_alloc(soc, num_entries + 1, rx_desc_pool);
  1910. }
  1911. void
  1912. dp_rx_pdev_mon_status_desc_pool_init(struct dp_pdev *pdev, uint32_t mac_id)
  1913. {
  1914. uint32_t i;
  1915. uint8_t pdev_id = pdev->pdev_id;
  1916. struct dp_soc *soc = pdev->soc;
  1917. struct dp_srng *mon_status_ring;
  1918. uint32_t num_entries;
  1919. struct rx_desc_pool *rx_desc_pool;
  1920. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  1921. soc_cfg_ctx = soc->wlan_cfg_ctx;
  1922. mon_status_ring = &soc->rxdma_mon_status_ring[mac_id];
  1923. num_entries = mon_status_ring->num_entries;
  1924. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1925. dp_debug("Mon RX Desc status Pool[%d] init entries=%u",
  1926. pdev_id, num_entries);
  1927. rx_desc_pool->owner = HAL_RX_BUF_RBM_SW3_BM;
  1928. rx_desc_pool->buf_size = RX_MON_STATUS_BUF_SIZE;
  1929. rx_desc_pool->buf_alignment = RX_DATA_BUFFER_ALIGNMENT;
  1930. /* Disable frag processing flag */
  1931. dp_rx_enable_mon_dest_frag(rx_desc_pool, false);
  1932. dp_rx_desc_pool_init(soc, mac_id, num_entries + 1, rx_desc_pool);
  1933. qdf_nbuf_queue_init(&pdev->rx_status_q);
  1934. pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  1935. qdf_mem_zero(&pdev->ppdu_info, sizeof(pdev->ppdu_info));
  1936. /*
  1937. * Set last_ppdu_id to HAL_INVALID_PPDU_ID in order to avoid ppdu_id
  1938. * match with '0' ppdu_id from monitor status ring
  1939. */
  1940. pdev->ppdu_info.com_info.last_ppdu_id = HAL_INVALID_PPDU_ID;
  1941. qdf_mem_zero(&pdev->rx_mon_stats, sizeof(pdev->rx_mon_stats));
  1942. dp_rx_mon_init_dbg_ppdu_stats(&pdev->ppdu_info,
  1943. &pdev->rx_mon_stats);
  1944. for (i = 0; i < MAX_MU_USERS; i++) {
  1945. qdf_nbuf_queue_init(&pdev->mpdu_q[i]);
  1946. pdev->is_mpdu_hdr[i] = true;
  1947. }
  1948. qdf_mem_zero(pdev->msdu_list, sizeof(pdev->msdu_list[MAX_MU_USERS]));
  1949. pdev->rx_enh_capture_mode = CDP_RX_ENH_CAPTURE_DISABLED;
  1950. }
  1951. void
  1952. dp_rx_pdev_mon_status_desc_pool_deinit(struct dp_pdev *pdev, uint32_t mac_id) {
  1953. uint8_t pdev_id = pdev->pdev_id;
  1954. struct dp_soc *soc = pdev->soc;
  1955. struct rx_desc_pool *rx_desc_pool;
  1956. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1957. dp_debug("Mon RX Desc status Pool[%d] deinit", pdev_id);
  1958. dp_rx_desc_pool_deinit(soc, rx_desc_pool);
  1959. }
  1960. void
  1961. dp_rx_pdev_mon_status_desc_pool_free(struct dp_pdev *pdev, uint32_t mac_id) {
  1962. uint8_t pdev_id = pdev->pdev_id;
  1963. struct dp_soc *soc = pdev->soc;
  1964. struct rx_desc_pool *rx_desc_pool;
  1965. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1966. dp_debug("Mon RX Status Desc Pool Free pdev[%d]", pdev_id);
  1967. dp_rx_desc_pool_free(soc, rx_desc_pool);
  1968. }
  1969. void
  1970. dp_rx_pdev_mon_status_buffers_free(struct dp_pdev *pdev, uint32_t mac_id)
  1971. {
  1972. uint8_t pdev_id = pdev->pdev_id;
  1973. struct dp_soc *soc = pdev->soc;
  1974. struct rx_desc_pool *rx_desc_pool;
  1975. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1976. dp_debug("Mon RX Status Desc Pool Free pdev[%d]", pdev_id);
  1977. dp_rx_desc_nbuf_free(soc, rx_desc_pool);
  1978. }
  1979. /*
  1980. * dp_rx_buffers_replenish() - replenish monitor status ring with
  1981. * rx nbufs called during dp rx
  1982. * monitor status ring initialization
  1983. *
  1984. * @soc: core txrx main context
  1985. * @mac_id: mac_id which is one of 3 mac_ids
  1986. * @dp_rxdma_srng: dp monitor status circular ring
  1987. * @rx_desc_pool; Pointer to Rx descriptor pool
  1988. * @num_req_buffers: number of buffer to be replenished
  1989. * @desc_list: list of descs if called from dp rx monitor status
  1990. * process or NULL during dp rx initialization or
  1991. * out of buffer interrupt
  1992. * @tail: tail of descs list
  1993. * @owner: who owns the nbuf (host, NSS etc...)
  1994. * Return: return success or failure
  1995. */
  1996. static inline
  1997. QDF_STATUS dp_rx_mon_status_buffers_replenish(struct dp_soc *dp_soc,
  1998. uint32_t mac_id,
  1999. struct dp_srng *dp_rxdma_srng,
  2000. struct rx_desc_pool *rx_desc_pool,
  2001. uint32_t num_req_buffers,
  2002. union dp_rx_desc_list_elem_t **desc_list,
  2003. union dp_rx_desc_list_elem_t **tail,
  2004. uint8_t owner)
  2005. {
  2006. uint32_t num_alloc_desc;
  2007. uint16_t num_desc_to_free = 0;
  2008. uint32_t num_entries_avail;
  2009. uint32_t count = 0;
  2010. int sync_hw_ptr = 1;
  2011. qdf_dma_addr_t paddr;
  2012. qdf_nbuf_t rx_netbuf;
  2013. void *rxdma_ring_entry;
  2014. union dp_rx_desc_list_elem_t *next;
  2015. void *rxdma_srng;
  2016. struct dp_pdev *dp_pdev = dp_get_pdev_for_lmac_id(dp_soc, mac_id);
  2017. if (!dp_pdev) {
  2018. dp_rx_mon_status_debug("%pK: pdev is null for mac_id = %d",
  2019. dp_soc, mac_id);
  2020. return QDF_STATUS_E_FAILURE;
  2021. }
  2022. rxdma_srng = dp_rxdma_srng->hal_srng;
  2023. qdf_assert(rxdma_srng);
  2024. dp_rx_mon_status_debug("%pK: requested %d buffers for replenish",
  2025. dp_soc, num_req_buffers);
  2026. /*
  2027. * if desc_list is NULL, allocate the descs from freelist
  2028. */
  2029. if (!(*desc_list)) {
  2030. num_alloc_desc = dp_rx_get_free_desc_list(dp_soc, mac_id,
  2031. rx_desc_pool,
  2032. num_req_buffers,
  2033. desc_list,
  2034. tail);
  2035. if (!num_alloc_desc) {
  2036. dp_rx_mon_status_err("%pK: no free rx_descs in freelist",
  2037. dp_soc);
  2038. return QDF_STATUS_E_NOMEM;
  2039. }
  2040. dp_rx_mon_status_debug("%pK: %d rx desc allocated", dp_soc,
  2041. num_alloc_desc);
  2042. num_req_buffers = num_alloc_desc;
  2043. }
  2044. hal_srng_access_start(dp_soc->hal_soc, rxdma_srng);
  2045. num_entries_avail = hal_srng_src_num_avail(dp_soc->hal_soc,
  2046. rxdma_srng, sync_hw_ptr);
  2047. dp_rx_mon_status_debug("%pK: no of available entries in rxdma ring: %d",
  2048. dp_soc, num_entries_avail);
  2049. if (num_entries_avail < num_req_buffers) {
  2050. num_desc_to_free = num_req_buffers - num_entries_avail;
  2051. num_req_buffers = num_entries_avail;
  2052. }
  2053. while (count <= num_req_buffers) {
  2054. rx_netbuf = dp_rx_nbuf_prepare(dp_soc, dp_pdev);
  2055. /*
  2056. * qdf_nbuf alloc or map failed,
  2057. * keep HP in mon_status_ring unchanged,
  2058. * wait dp_rx_mon_status_srng_process
  2059. * to fill in buffer at current HP.
  2060. */
  2061. if (qdf_unlikely(!rx_netbuf)) {
  2062. dp_rx_mon_status_err("%pK: qdf_nbuf allocate or map fail, count %d",
  2063. dp_soc, count);
  2064. break;
  2065. }
  2066. paddr = qdf_nbuf_get_frag_paddr(rx_netbuf, 0);
  2067. next = (*desc_list)->next;
  2068. rxdma_ring_entry = hal_srng_src_get_cur_hp_n_move_next(
  2069. dp_soc->hal_soc,
  2070. rxdma_srng);
  2071. if (qdf_unlikely(!rxdma_ring_entry)) {
  2072. dp_rx_mon_status_err("%pK: rxdma_ring_entry is NULL, count - %d",
  2073. dp_soc, count);
  2074. qdf_nbuf_unmap_nbytes_single(dp_soc->osdev, rx_netbuf,
  2075. QDF_DMA_FROM_DEVICE,
  2076. rx_desc_pool->buf_size);
  2077. qdf_nbuf_free(rx_netbuf);
  2078. break;
  2079. }
  2080. (*desc_list)->rx_desc.nbuf = rx_netbuf;
  2081. (*desc_list)->rx_desc.in_use = 1;
  2082. count++;
  2083. hal_rxdma_buff_addr_info_set(rxdma_ring_entry, paddr,
  2084. (*desc_list)->rx_desc.cookie, owner);
  2085. dp_rx_mon_status_debug("%pK: rx_desc=%pK, cookie=%d, nbuf=%pK, paddr=%pK",
  2086. dp_soc, &(*desc_list)->rx_desc,
  2087. (*desc_list)->rx_desc.cookie, rx_netbuf,
  2088. (void *)paddr);
  2089. *desc_list = next;
  2090. }
  2091. hal_srng_access_end(dp_soc->hal_soc, rxdma_srng);
  2092. dp_rx_mon_status_debug("%pK: successfully replenished %d buffers",
  2093. dp_soc, num_req_buffers);
  2094. dp_rx_mon_status_debug("%pK: %d rx desc added back to free list",
  2095. dp_soc, num_desc_to_free);
  2096. /*
  2097. * add any available free desc back to the free list
  2098. */
  2099. if (*desc_list) {
  2100. dp_rx_add_desc_list_to_free_list(dp_soc, desc_list, tail,
  2101. mac_id, rx_desc_pool);
  2102. }
  2103. return QDF_STATUS_SUCCESS;
  2104. }
  2105. #if !defined(DISABLE_MON_CONFIG) && defined(MON_ENABLE_DROP_FOR_MAC)
  2106. /**
  2107. * dp_mon_status_srng_drop_for_mac() - Drop the mon status ring packets for
  2108. * a given mac
  2109. * @pdev: DP pdev
  2110. * @mac_id: mac id
  2111. * @quota: maximum number of ring entries that can be processed
  2112. *
  2113. * Return: Number of ring entries reaped
  2114. */
  2115. static uint32_t
  2116. dp_mon_status_srng_drop_for_mac(struct dp_pdev *pdev, uint32_t mac_id,
  2117. uint32_t quota)
  2118. {
  2119. struct dp_soc *soc = pdev->soc;
  2120. void *mon_status_srng;
  2121. hal_soc_handle_t hal_soc;
  2122. void *ring_desc;
  2123. uint32_t reap_cnt = 0;
  2124. if (qdf_unlikely(!soc || !soc->hal_soc))
  2125. return reap_cnt;
  2126. mon_status_srng = soc->rxdma_mon_status_ring[mac_id].hal_srng;
  2127. if (qdf_unlikely(!mon_status_srng ||
  2128. !hal_srng_initialized(mon_status_srng)))
  2129. return reap_cnt;
  2130. hal_soc = soc->hal_soc;
  2131. if (qdf_unlikely(hal_srng_access_start(hal_soc, mon_status_srng)))
  2132. return reap_cnt;
  2133. while ((ring_desc =
  2134. hal_srng_src_peek_n_get_next(hal_soc, mon_status_srng)) &&
  2135. reap_cnt < MON_DROP_REAP_LIMIT && quota--) {
  2136. uint64_t buf_addr;
  2137. uint32_t rx_buf_cookie;
  2138. struct dp_rx_desc *rx_desc;
  2139. qdf_nbuf_t status_nbuf;
  2140. uint8_t *status_buf;
  2141. enum dp_mon_reap_status reap_status;
  2142. qdf_dma_addr_t iova;
  2143. struct rx_desc_pool *rx_desc_pool;
  2144. rx_desc_pool = &soc->rx_desc_status[mac_id];
  2145. buf_addr = (HAL_RX_BUFFER_ADDR_31_0_GET(ring_desc) |
  2146. ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(ring_desc)) << 32));
  2147. if (qdf_likely(buf_addr)) {
  2148. rx_buf_cookie = HAL_RX_BUF_COOKIE_GET(ring_desc);
  2149. rx_desc = dp_rx_cookie_2_va_mon_status(soc,
  2150. rx_buf_cookie);
  2151. qdf_assert(rx_desc);
  2152. status_nbuf = rx_desc->nbuf;
  2153. qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf,
  2154. QDF_DMA_FROM_DEVICE);
  2155. status_buf = qdf_nbuf_data(status_nbuf);
  2156. if (hal_get_rx_status_done(status_buf) !=
  2157. QDF_STATUS_SUCCESS) {
  2158. /* If done status is missing:
  2159. * 1. As per MAC team's suggestion,
  2160. * when HP + 1 entry is peeked and if DMA
  2161. * is not done and if HP + 2 entry's DMA done
  2162. * is set. skip HP + 1 entry and
  2163. * start processing in next interrupt.
  2164. * 2. If HP + 2 entry's DMA done is not set,
  2165. * poll onto HP + 1 entry DMA done to be set.
  2166. * Check status for same buffer for next time
  2167. * dp_rx_mon_status_srng_process
  2168. */
  2169. reap_status =
  2170. dp_rx_mon_handle_status_buf_done(pdev,
  2171. mon_status_srng);
  2172. if (reap_status == DP_MON_STATUS_NO_DMA)
  2173. break;
  2174. }
  2175. qdf_nbuf_unmap_nbytes_single(soc->osdev, status_nbuf,
  2176. QDF_DMA_FROM_DEVICE,
  2177. rx_desc_pool->buf_size);
  2178. qdf_nbuf_free(status_nbuf);
  2179. } else {
  2180. union dp_rx_desc_list_elem_t *rx_desc_elem;
  2181. qdf_spin_lock_bh(&rx_desc_pool->lock);
  2182. if (!rx_desc_pool->freelist) {
  2183. qdf_spin_unlock_bh(&rx_desc_pool->lock);
  2184. break;
  2185. }
  2186. rx_desc_elem = rx_desc_pool->freelist;
  2187. rx_desc_pool->freelist = rx_desc_pool->freelist->next;
  2188. qdf_spin_unlock_bh(&rx_desc_pool->lock);
  2189. rx_desc = &rx_desc_elem->rx_desc;
  2190. }
  2191. status_nbuf = dp_rx_nbuf_prepare(soc, pdev);
  2192. if (qdf_unlikely(!status_nbuf)) {
  2193. union dp_rx_desc_list_elem_t *desc_list = NULL;
  2194. union dp_rx_desc_list_elem_t *tail = NULL;
  2195. dp_info_rl("fail to allocate or map nbuf");
  2196. dp_rx_add_to_free_desc_list(&desc_list, &tail,
  2197. rx_desc);
  2198. dp_rx_add_desc_list_to_free_list(soc,
  2199. &desc_list,
  2200. &tail, mac_id,
  2201. rx_desc_pool);
  2202. hal_rxdma_buff_addr_info_set(ring_desc, 0, 0,
  2203. HAL_RX_BUF_RBM_SW3_BM);
  2204. break;
  2205. }
  2206. iova = qdf_nbuf_get_frag_paddr(status_nbuf, 0);
  2207. rx_desc->nbuf = status_nbuf;
  2208. rx_desc->in_use = 1;
  2209. hal_rxdma_buff_addr_info_set(ring_desc, iova, rx_desc->cookie,
  2210. HAL_RX_BUF_RBM_SW3_BM);
  2211. reap_cnt++;
  2212. hal_srng_src_get_next(hal_soc, mon_status_srng);
  2213. }
  2214. hal_srng_access_end(hal_soc, mon_status_srng);
  2215. return reap_cnt;
  2216. }
  2217. uint32_t dp_mon_drop_packets_for_mac(struct dp_pdev *pdev, uint32_t mac_id,
  2218. uint32_t quota)
  2219. {
  2220. uint32_t work_done;
  2221. work_done = dp_mon_status_srng_drop_for_mac(pdev, mac_id, quota);
  2222. dp_mon_dest_srng_drop_for_mac(pdev, mac_id);
  2223. return work_done;
  2224. }
  2225. #else
  2226. uint32_t dp_mon_drop_packets_for_mac(struct dp_pdev *pdev, uint32_t mac_id,
  2227. uint32_t quota)
  2228. {
  2229. return 0;
  2230. }
  2231. #endif