dp_rx_mon_status.c 55 KB

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