dp_rx_mon_status.c 62 KB

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