dp_rx_mon_status.c 45 KB

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