dp_rx_mon_status.c 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607
  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 = ppdu->rssi;
  427. else
  428. peer->stats.rx.avg_rssi =
  429. DP_GET_AVG_RSSI(peer->stats.rx.avg_rssi, ppdu->rssi);
  430. if ((preamble == DOT11_A) || (preamble == DOT11_B))
  431. ppdu->u.nss = 1;
  432. if (ppdu->u.nss)
  433. DP_STATS_INC(peer, rx.nss[ppdu->u.nss - 1], num_msdu);
  434. DP_STATS_INC(peer, rx.sgi_count[ppdu->u.gi], num_msdu);
  435. DP_STATS_INC(peer, rx.bw[ppdu->u.bw], num_msdu);
  436. DP_STATS_INC(peer, rx.reception_type[ppdu->u.ppdu_type], num_msdu);
  437. DP_STATS_INCC(peer, rx.ampdu_cnt, num_msdu, ppdu->is_ampdu);
  438. DP_STATS_INCC(peer, rx.non_ampdu_cnt, num_msdu, !(ppdu->is_ampdu));
  439. DP_STATS_UPD(peer, rx.rx_rate, mcs);
  440. DP_STATS_INCC(peer,
  441. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  442. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
  443. DP_STATS_INCC(peer,
  444. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  445. ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
  446. DP_STATS_INCC(peer,
  447. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  448. ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B)));
  449. DP_STATS_INCC(peer,
  450. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  451. ((mcs < MAX_MCS_11B) && (preamble == DOT11_B)));
  452. DP_STATS_INCC(peer,
  453. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  454. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N)));
  455. DP_STATS_INCC(peer,
  456. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  457. ((mcs < MAX_MCS_11A) && (preamble == DOT11_N)));
  458. DP_STATS_INCC(peer,
  459. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  460. ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC)));
  461. DP_STATS_INCC(peer,
  462. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  463. ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
  464. DP_STATS_INCC(peer,
  465. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  466. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  467. DP_STATS_INCC(peer,
  468. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  469. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  470. /*
  471. * If invalid TID, it could be a non-qos frame, hence do not update
  472. * any AC counters
  473. */
  474. ac = TID_TO_WME_AC(ppdu->tid);
  475. if (ppdu->tid != HAL_TID_INVALID)
  476. DP_STATS_INC(peer, rx.wme_ac_type[ac], num_msdu);
  477. dp_peer_stats_notify(pdev, peer);
  478. DP_STATS_UPD(peer, rx.last_rssi, ppdu->rssi);
  479. if (is_invalid_peer)
  480. return;
  481. if (dp_is_subtype_data(ppdu->frame_ctrl))
  482. dp_rx_rate_stats_update(peer, ppdu);
  483. #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
  484. dp_wdi_event_handler(WDI_EVENT_UPDATE_DP_STATS, pdev->soc,
  485. &peer->stats, ppdu->peer_id,
  486. UPDATE_PEER_STATS, pdev->pdev_id);
  487. #endif
  488. }
  489. #endif
  490. /*
  491. * dp_rx_get_fcs_ok_msdu() - get ppdu status buffer containing fcs_ok msdu
  492. * @pdev: pdev object
  493. * @ppdu_info: ppdu info object
  494. *
  495. * Return: nbuf
  496. */
  497. static inline qdf_nbuf_t
  498. dp_rx_get_fcs_ok_msdu(struct dp_pdev *pdev,
  499. struct hal_rx_ppdu_info *ppdu_info)
  500. {
  501. uint16_t mpdu_fcs_ok;
  502. qdf_nbuf_t status_nbuf = NULL;
  503. unsigned long *fcs_ok_bitmap;
  504. if (qdf_unlikely(qdf_nbuf_is_queue_empty(&pdev->rx_ppdu_buf_q)))
  505. return NULL;
  506. /* Obtain fcs_ok passed index from bitmap
  507. * this index is used to get fcs passed first msdu payload
  508. */
  509. fcs_ok_bitmap =
  510. (unsigned long *)&ppdu_info->com_info.mpdu_fcs_ok_bitmap[0];
  511. mpdu_fcs_ok = qdf_find_first_bit(fcs_ok_bitmap,
  512. HAL_RX_MAX_MPDU);
  513. if (qdf_unlikely(mpdu_fcs_ok >= HAL_RX_MAX_MPDU))
  514. goto end;
  515. if (qdf_unlikely(!ppdu_info->ppdu_msdu_info[mpdu_fcs_ok].nbuf))
  516. goto end;
  517. /* Get status buffer by indexing mpdu_fcs_ok index
  518. * containing first msdu payload with fcs passed
  519. * and clone the buffer
  520. */
  521. status_nbuf = ppdu_info->ppdu_msdu_info[mpdu_fcs_ok].nbuf;
  522. ppdu_info->ppdu_msdu_info[mpdu_fcs_ok].nbuf = NULL;
  523. /* Take ref of status nbuf as this nbuf is to be
  524. * freeed by upper layer.
  525. */
  526. qdf_nbuf_ref(status_nbuf);
  527. ppdu_info->fcs_ok_msdu_info.first_msdu_payload =
  528. ppdu_info->ppdu_msdu_info[mpdu_fcs_ok].first_msdu_payload;
  529. ppdu_info->fcs_ok_msdu_info.payload_len =
  530. ppdu_info->ppdu_msdu_info[mpdu_fcs_ok].payload_len;
  531. end:
  532. /* Free the ppdu status buffer queue */
  533. qdf_nbuf_queue_free(&pdev->rx_ppdu_buf_q);
  534. qdf_mem_zero(&ppdu_info->ppdu_msdu_info,
  535. (ppdu_info->com_info.mpdu_cnt_fcs_ok +
  536. ppdu_info->com_info.mpdu_cnt_fcs_err)
  537. * sizeof(struct hal_rx_msdu_payload_info));
  538. return status_nbuf;
  539. }
  540. static inline void
  541. dp_rx_handle_ppdu_status_buf(struct dp_pdev *pdev,
  542. struct hal_rx_ppdu_info *ppdu_info,
  543. qdf_nbuf_t status_nbuf)
  544. {
  545. qdf_nbuf_t dropnbuf;
  546. if (qdf_nbuf_queue_len(&pdev->rx_ppdu_buf_q) >
  547. HAL_RX_MAX_MPDU) {
  548. dropnbuf = qdf_nbuf_queue_remove(&pdev->rx_ppdu_buf_q);
  549. qdf_nbuf_free(dropnbuf);
  550. }
  551. qdf_nbuf_queue_add(&pdev->rx_ppdu_buf_q, status_nbuf);
  552. }
  553. /**
  554. * dp_rx_handle_mcopy_mode() - Allocate and deliver first MSDU payload
  555. * @soc: core txrx main context
  556. * @pdev: pdev strcuture
  557. * @ppdu_info: structure for rx ppdu ring
  558. *
  559. * Return: QDF_STATUS_SUCCESS - If nbuf to be freed by caller
  560. * QDF_STATUS_E_ALREADY - If nbuf not to be freed by caller
  561. */
  562. #ifdef FEATURE_PERPKT_INFO
  563. static inline QDF_STATUS
  564. dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  565. struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf)
  566. {
  567. uint8_t size = 0;
  568. struct ieee80211_frame *wh;
  569. uint32_t *nbuf_data;
  570. if (!ppdu_info->fcs_ok_msdu_info.first_msdu_payload)
  571. return QDF_STATUS_SUCCESS;
  572. if (pdev->m_copy_id.rx_ppdu_id == ppdu_info->com_info.ppdu_id)
  573. return QDF_STATUS_SUCCESS;
  574. pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
  575. wh = (struct ieee80211_frame *)
  576. (ppdu_info->fcs_ok_msdu_info.first_msdu_payload + 4);
  577. size = (ppdu_info->fcs_ok_msdu_info.first_msdu_payload -
  578. qdf_nbuf_data(nbuf));
  579. if (qdf_nbuf_pull_head(nbuf, size) == NULL)
  580. return QDF_STATUS_SUCCESS;
  581. if (((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  582. IEEE80211_FC0_TYPE_MGT) ||
  583. ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  584. IEEE80211_FC0_TYPE_CTL)) {
  585. return QDF_STATUS_SUCCESS;
  586. }
  587. ppdu_info->fcs_ok_msdu_info.first_msdu_payload = NULL;
  588. nbuf_data = (uint32_t *)qdf_nbuf_data(nbuf);
  589. *nbuf_data = pdev->ppdu_info.com_info.ppdu_id;
  590. /* only retain RX MSDU payload in the skb */
  591. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
  592. ppdu_info->fcs_ok_msdu_info.payload_len);
  593. dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
  594. nbuf, HTT_INVALID_PEER, WDI_NO_VAL, pdev->pdev_id);
  595. return QDF_STATUS_E_ALREADY;
  596. }
  597. #else
  598. static inline QDF_STATUS
  599. dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  600. struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf)
  601. {
  602. return QDF_STATUS_SUCCESS;
  603. }
  604. #endif
  605. #ifdef FEATURE_PERPKT_INFO
  606. static inline void
  607. dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  608. struct hal_rx_ppdu_info *ppdu_info,
  609. uint32_t tlv_status,
  610. qdf_nbuf_t status_nbuf)
  611. {
  612. QDF_STATUS mcopy_status;
  613. if (qdf_unlikely(!ppdu_info->com_info.mpdu_cnt)) {
  614. qdf_nbuf_free(status_nbuf);
  615. return;
  616. }
  617. /* Add buffers to queue until we receive
  618. * HAL_TLV_STATUS_PPDU_DONE
  619. */
  620. dp_rx_handle_ppdu_status_buf(pdev, ppdu_info, status_nbuf);
  621. /* If tlv_status is PPDU_DONE, process rx_ppdu_buf_q
  622. * and devliver fcs_ok msdu buffer
  623. */
  624. if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) {
  625. if (qdf_unlikely(ppdu_info->com_info.mpdu_cnt !=
  626. (ppdu_info->com_info.mpdu_cnt_fcs_ok +
  627. ppdu_info->com_info.mpdu_cnt_fcs_err))) {
  628. qdf_nbuf_queue_free(&pdev->rx_ppdu_buf_q);
  629. return;
  630. }
  631. /* Get rx ppdu status buffer having fcs ok msdu */
  632. status_nbuf = dp_rx_get_fcs_ok_msdu(pdev, ppdu_info);
  633. if (status_nbuf) {
  634. mcopy_status = dp_rx_handle_mcopy_mode(soc, pdev,
  635. ppdu_info,
  636. status_nbuf);
  637. if (mcopy_status == QDF_STATUS_SUCCESS)
  638. qdf_nbuf_free(status_nbuf);
  639. }
  640. }
  641. }
  642. #else
  643. static inline void
  644. dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  645. struct hal_rx_ppdu_info *ppdu_info,
  646. uint32_t tlv_status,
  647. qdf_nbuf_t status_nbuf)
  648. {
  649. }
  650. #endif
  651. /**
  652. * dp_rx_handle_smart_mesh_mode() - Deliver header for smart mesh
  653. * @soc: Datapath SOC handle
  654. * @pdev: Datapath PDEV handle
  655. * @ppdu_info: Structure for rx ppdu info
  656. * @nbuf: Qdf nbuf abstraction for linux skb
  657. *
  658. * Return: 0 on success, 1 on failure
  659. */
  660. static inline int
  661. dp_rx_handle_smart_mesh_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  662. struct hal_rx_ppdu_info *ppdu_info,
  663. qdf_nbuf_t nbuf)
  664. {
  665. uint8_t size = 0;
  666. if (!pdev->monitor_vdev) {
  667. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  668. "[%s]:[%d] Monitor vdev is NULL !!",
  669. __func__, __LINE__);
  670. return 1;
  671. }
  672. if (!ppdu_info->msdu_info.first_msdu_payload) {
  673. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  674. "[%s]:[%d] First msdu payload not present",
  675. __func__, __LINE__);
  676. return 1;
  677. }
  678. /* Adding 4 bytes to get to start of 802.11 frame after phy_ppdu_id */
  679. size = (ppdu_info->msdu_info.first_msdu_payload -
  680. qdf_nbuf_data(nbuf)) + 4;
  681. ppdu_info->msdu_info.first_msdu_payload = NULL;
  682. if (qdf_nbuf_pull_head(nbuf, size) == NULL) {
  683. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  684. "[%s]:[%d] No header present",
  685. __func__, __LINE__);
  686. return 1;
  687. }
  688. /* Only retain RX MSDU payload in the skb */
  689. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
  690. ppdu_info->msdu_info.payload_len);
  691. if (!qdf_nbuf_update_radiotap(&pdev->ppdu_info.rx_status, nbuf,
  692. qdf_nbuf_headroom(nbuf))) {
  693. DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
  694. return 1;
  695. }
  696. pdev->monitor_vdev->osif_rx_mon(pdev->monitor_vdev->osif_vdev,
  697. nbuf, NULL);
  698. pdev->ppdu_info.rx_status.monitor_direct_used = 0;
  699. return 0;
  700. }
  701. /**
  702. * dp_rx_handle_ppdu_stats() - Allocate and deliver ppdu stats to cdp layer
  703. * @soc: core txrx main context
  704. * @pdev: pdev strcuture
  705. * @ppdu_info: structure for rx ppdu ring
  706. *
  707. * Return: none
  708. */
  709. #ifdef FEATURE_PERPKT_INFO
  710. static inline void
  711. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  712. struct hal_rx_ppdu_info *ppdu_info)
  713. {
  714. qdf_nbuf_t ppdu_nbuf;
  715. struct dp_peer *peer;
  716. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  717. /*
  718. * Do not allocate if fcs error,
  719. * ast idx invalid / fctl invalid
  720. */
  721. if (ppdu_info->com_info.mpdu_cnt_fcs_ok == 0)
  722. return;
  723. if (ppdu_info->nac_info.fc_valid &&
  724. ppdu_info->nac_info.to_ds_flag &&
  725. ppdu_info->nac_info.mac_addr2_valid) {
  726. struct dp_neighbour_peer *peer = NULL;
  727. uint8_t rssi = ppdu_info->rx_status.rssi_comb;
  728. qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
  729. if (pdev->neighbour_peers_added) {
  730. TAILQ_FOREACH(peer, &pdev->neighbour_peers_list,
  731. neighbour_peer_list_elem) {
  732. if (!qdf_mem_cmp(&peer->neighbour_peers_macaddr,
  733. &ppdu_info->nac_info.mac_addr2,
  734. QDF_MAC_ADDR_SIZE)) {
  735. peer->rssi = rssi;
  736. break;
  737. }
  738. }
  739. }
  740. qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
  741. }
  742. /* need not generate wdi event when mcopy and
  743. * enhanced stats are not enabled
  744. */
  745. if (!pdev->mcopy_mode && !pdev->enhanced_stats_en)
  746. return;
  747. if (!pdev->mcopy_mode) {
  748. if (!ppdu_info->rx_status.frame_control_info_valid)
  749. return;
  750. if (ppdu_info->rx_status.ast_index == HAL_AST_IDX_INVALID)
  751. return;
  752. }
  753. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  754. sizeof(struct cdp_rx_indication_ppdu), 0, 0, FALSE);
  755. if (ppdu_nbuf) {
  756. dp_rx_populate_cdp_indication_ppdu(pdev, ppdu_info, ppdu_nbuf);
  757. qdf_nbuf_put_tail(ppdu_nbuf,
  758. sizeof(struct cdp_rx_indication_ppdu));
  759. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
  760. peer = dp_peer_find_by_id(soc, cdp_rx_ppdu->peer_id);
  761. if (peer) {
  762. cdp_rx_ppdu->cookie = (void *)peer->wlanstats_ctx;
  763. dp_rx_stats_update(pdev, peer, cdp_rx_ppdu);
  764. dp_peer_unref_del_find_by_id(peer);
  765. }
  766. if (cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) {
  767. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC,
  768. soc, ppdu_nbuf,
  769. cdp_rx_ppdu->peer_id,
  770. WDI_NO_VAL, pdev->pdev_id);
  771. } else if (pdev->mcopy_mode) {
  772. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
  773. ppdu_nbuf, HTT_INVALID_PEER,
  774. WDI_NO_VAL, pdev->pdev_id);
  775. } else {
  776. qdf_nbuf_free(ppdu_nbuf);
  777. }
  778. }
  779. }
  780. #else
  781. static inline void
  782. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  783. struct hal_rx_ppdu_info *ppdu_info)
  784. {
  785. }
  786. #endif
  787. /**
  788. * dp_rx_process_peer_based_pktlog() - Process Rx pktlog if peer based
  789. * filtering enabled
  790. * @soc: core txrx main context
  791. * @ppdu_info: Structure for rx ppdu info
  792. * @status_nbuf: Qdf nbuf abstraction for linux skb
  793. * @mac_id: mac_id/pdev_id correspondinggly for MCL and WIN
  794. *
  795. * Return: none
  796. */
  797. static inline void
  798. dp_rx_process_peer_based_pktlog(struct dp_soc *soc,
  799. struct hal_rx_ppdu_info *ppdu_info,
  800. qdf_nbuf_t status_nbuf, uint32_t mac_id)
  801. {
  802. struct dp_peer *peer;
  803. struct dp_ast_entry *ast_entry;
  804. uint32_t ast_index;
  805. ast_index = ppdu_info->rx_status.ast_index;
  806. if (ast_index < wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  807. ast_entry = soc->ast_table[ast_index];
  808. if (ast_entry) {
  809. peer = ast_entry->peer;
  810. if (peer && (peer->peer_ids[0] != HTT_INVALID_PEER)) {
  811. if (peer->peer_based_pktlog_filter) {
  812. dp_wdi_event_handler(
  813. WDI_EVENT_RX_DESC, soc,
  814. status_nbuf,
  815. peer->peer_ids[0],
  816. WDI_NO_VAL, mac_id);
  817. }
  818. }
  819. }
  820. }
  821. }
  822. #if defined(HTT_UL_OFDMA_USER_INFO_V0_W0_VALID_M)
  823. static inline void
  824. dp_rx_ul_ofdma_ru_size_to_width(
  825. uint32_t ru_size,
  826. uint32_t *ru_width)
  827. {
  828. uint32_t width;
  829. width = 0;
  830. switch (ru_size) {
  831. case HTT_UL_OFDMA_V0_RU_SIZE_RU_26:
  832. width = 1;
  833. break;
  834. case HTT_UL_OFDMA_V0_RU_SIZE_RU_52:
  835. width = 2;
  836. break;
  837. case HTT_UL_OFDMA_V0_RU_SIZE_RU_106:
  838. width = 4;
  839. break;
  840. case HTT_UL_OFDMA_V0_RU_SIZE_RU_242:
  841. width = 9;
  842. break;
  843. case HTT_UL_OFDMA_V0_RU_SIZE_RU_484:
  844. width = 18;
  845. break;
  846. case HTT_UL_OFDMA_V0_RU_SIZE_RU_996:
  847. width = 37;
  848. break;
  849. case HTT_UL_OFDMA_V0_RU_SIZE_RU_996x2:
  850. width = 74;
  851. break;
  852. default:
  853. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  854. "RU size to width convert err");
  855. break;
  856. }
  857. *ru_width = width;
  858. }
  859. static inline void
  860. dp_rx_mon_handle_ofdma_info(struct hal_rx_ppdu_info *ppdu_info)
  861. {
  862. struct mon_rx_user_status *mon_rx_user_status;
  863. uint32_t num_users;
  864. uint32_t i;
  865. uint32_t ul_ofdma_user_v0_word0;
  866. uint32_t ul_ofdma_user_v0_word1;
  867. uint32_t ru_width;
  868. if (ppdu_info->rx_status.reception_type != HAL_RX_TYPE_MU_OFDMA)
  869. return;
  870. num_users = ppdu_info->com_info.num_users;
  871. if (num_users > HAL_MAX_UL_MU_USERS)
  872. num_users = HAL_MAX_UL_MU_USERS;
  873. for (i = 0; i < num_users; i++) {
  874. mon_rx_user_status = &ppdu_info->rx_user_status[i];
  875. ul_ofdma_user_v0_word0 =
  876. mon_rx_user_status->ul_ofdma_user_v0_word0;
  877. ul_ofdma_user_v0_word1 =
  878. mon_rx_user_status->ul_ofdma_user_v0_word1;
  879. if (HTT_UL_OFDMA_USER_INFO_V0_W0_VALID_GET(
  880. ul_ofdma_user_v0_word0) &&
  881. !HTT_UL_OFDMA_USER_INFO_V0_W0_VER_GET(
  882. ul_ofdma_user_v0_word0)) {
  883. mon_rx_user_status->mcs =
  884. HTT_UL_OFDMA_USER_INFO_V0_W1_MCS_GET(
  885. ul_ofdma_user_v0_word1);
  886. mon_rx_user_status->nss =
  887. HTT_UL_OFDMA_USER_INFO_V0_W1_NSS_GET(
  888. ul_ofdma_user_v0_word1);
  889. mon_rx_user_status->ofdma_info_valid = 1;
  890. mon_rx_user_status->dl_ofdma_ru_start_index =
  891. HTT_UL_OFDMA_USER_INFO_V0_W1_RU_START_GET(
  892. ul_ofdma_user_v0_word1);
  893. dp_rx_ul_ofdma_ru_size_to_width(
  894. HTT_UL_OFDMA_USER_INFO_V0_W1_RU_SIZE_GET(
  895. ul_ofdma_user_v0_word1),
  896. &ru_width);
  897. mon_rx_user_status->dl_ofdma_ru_width = ru_width;
  898. }
  899. }
  900. }
  901. #else
  902. static inline void
  903. dp_rx_mon_handle_ofdma_info(struct hal_rx_ppdu_info *ppdu_info)
  904. {
  905. }
  906. #endif
  907. /**
  908. * dp_rx_mon_status_process_tlv() - Process status TLV in status
  909. * buffer on Rx status Queue posted by status SRNG processing.
  910. * @soc: core txrx main context
  911. * @mac_id: mac_id which is one of 3 mac_ids _ring
  912. *
  913. * Return: none
  914. */
  915. static inline void
  916. dp_rx_mon_status_process_tlv(struct dp_soc *soc, uint32_t mac_id,
  917. uint32_t quota)
  918. {
  919. struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id);
  920. struct hal_rx_ppdu_info *ppdu_info;
  921. qdf_nbuf_t status_nbuf;
  922. uint8_t *rx_tlv;
  923. uint8_t *rx_tlv_start;
  924. uint32_t tlv_status = HAL_TLV_STATUS_BUF_DONE;
  925. QDF_STATUS enh_log_status = QDF_STATUS_SUCCESS;
  926. struct cdp_pdev_mon_stats *rx_mon_stats;
  927. int smart_mesh_status;
  928. enum WDI_EVENT pktlog_mode = WDI_NO_VAL;
  929. bool nbuf_used;
  930. uint32_t rx_enh_capture_mode;
  931. ppdu_info = &pdev->ppdu_info;
  932. rx_mon_stats = &pdev->rx_mon_stats;
  933. if (pdev->mon_ppdu_status != DP_PPDU_STATUS_START)
  934. return;
  935. rx_enh_capture_mode = pdev->rx_enh_capture_mode;
  936. while (!qdf_nbuf_is_queue_empty(&pdev->rx_status_q)) {
  937. status_nbuf = qdf_nbuf_queue_remove(&pdev->rx_status_q);
  938. rx_tlv = qdf_nbuf_data(status_nbuf);
  939. rx_tlv_start = rx_tlv;
  940. nbuf_used = false;
  941. if ((pdev->monitor_vdev) || (pdev->enhanced_stats_en) ||
  942. pdev->mcopy_mode ||
  943. (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED)) {
  944. do {
  945. tlv_status = hal_rx_status_get_tlv_info(rx_tlv,
  946. ppdu_info, pdev->soc->hal_soc,
  947. status_nbuf);
  948. dp_rx_mon_update_dbg_ppdu_stats(ppdu_info,
  949. rx_mon_stats);
  950. dp_rx_mon_enh_capture_process(pdev, tlv_status,
  951. status_nbuf, ppdu_info,
  952. &nbuf_used);
  953. rx_tlv = hal_rx_status_get_next_tlv(rx_tlv);
  954. if ((rx_tlv - rx_tlv_start) >= RX_BUFFER_SIZE)
  955. break;
  956. } while ((tlv_status == HAL_TLV_STATUS_PPDU_NOT_DONE) ||
  957. (tlv_status == HAL_TLV_STATUS_HEADER) ||
  958. (tlv_status == HAL_TLV_STATUS_MPDU_END) ||
  959. (tlv_status == HAL_TLV_STATUS_MSDU_END));
  960. }
  961. if (pdev->dp_peer_based_pktlog) {
  962. dp_rx_process_peer_based_pktlog(soc, ppdu_info,
  963. status_nbuf, mac_id);
  964. } else {
  965. if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_FULL)
  966. pktlog_mode = WDI_EVENT_RX_DESC;
  967. else if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_LITE)
  968. pktlog_mode = WDI_EVENT_LITE_RX;
  969. if (pktlog_mode != WDI_NO_VAL)
  970. dp_wdi_event_handler(pktlog_mode, soc,
  971. status_nbuf,
  972. HTT_INVALID_PEER,
  973. WDI_NO_VAL, mac_id);
  974. }
  975. /* smart monitor vap and m_copy cannot co-exist */
  976. if (ppdu_info->rx_status.monitor_direct_used && pdev->neighbour_peers_added
  977. && pdev->monitor_vdev) {
  978. smart_mesh_status = dp_rx_handle_smart_mesh_mode(soc,
  979. pdev, ppdu_info, status_nbuf);
  980. if (smart_mesh_status)
  981. qdf_nbuf_free(status_nbuf);
  982. } else if (qdf_unlikely(pdev->mcopy_mode)) {
  983. dp_rx_process_mcopy_mode(soc, pdev,
  984. ppdu_info, tlv_status,
  985. status_nbuf);
  986. } else if (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED) {
  987. if (!nbuf_used)
  988. qdf_nbuf_free(status_nbuf);
  989. if (tlv_status == HAL_TLV_STATUS_PPDU_DONE)
  990. enh_log_status =
  991. dp_rx_handle_enh_capture(soc,
  992. pdev, ppdu_info);
  993. } else {
  994. qdf_nbuf_free(status_nbuf);
  995. }
  996. if (tlv_status == HAL_TLV_STATUS_PPDU_NON_STD_DONE) {
  997. dp_rx_mon_deliver_non_std(soc, mac_id);
  998. } else if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) {
  999. rx_mon_stats->status_ppdu_done++;
  1000. dp_rx_mon_handle_ofdma_info(ppdu_info);
  1001. if (pdev->enhanced_stats_en ||
  1002. pdev->mcopy_mode || pdev->neighbour_peers_added)
  1003. dp_rx_handle_ppdu_stats(soc, pdev, ppdu_info);
  1004. pdev->mon_ppdu_status = DP_PPDU_STATUS_DONE;
  1005. dp_rx_mon_dest_process(soc, mac_id, quota);
  1006. pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  1007. }
  1008. }
  1009. return;
  1010. }
  1011. /*
  1012. * dp_rx_mon_status_srng_process() - Process monitor status ring
  1013. * post the status ring buffer to Rx status Queue for later
  1014. * processing when status ring is filled with status TLV.
  1015. * Allocate a new buffer to status ring if the filled buffer
  1016. * is posted.
  1017. *
  1018. * @soc: core txrx main context
  1019. * @mac_id: mac_id which is one of 3 mac_ids
  1020. * @quota: No. of ring entry that can be serviced in one shot.
  1021. * Return: uint32_t: No. of ring entry that is processed.
  1022. */
  1023. static inline uint32_t
  1024. dp_rx_mon_status_srng_process(struct dp_soc *soc, uint32_t mac_id,
  1025. uint32_t quota)
  1026. {
  1027. struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id);
  1028. hal_soc_handle_t hal_soc;
  1029. void *mon_status_srng;
  1030. void *rxdma_mon_status_ring_entry;
  1031. QDF_STATUS status;
  1032. uint32_t work_done = 0;
  1033. int mac_for_pdev = dp_get_mac_id_for_mac(soc, mac_id);
  1034. mon_status_srng = pdev->rxdma_mon_status_ring[mac_for_pdev].hal_srng;
  1035. qdf_assert(mon_status_srng);
  1036. if (!mon_status_srng || !hal_srng_initialized(mon_status_srng)) {
  1037. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1038. "%s %d : HAL Monitor Status Ring Init Failed -- %pK",
  1039. __func__, __LINE__, mon_status_srng);
  1040. return work_done;
  1041. }
  1042. hal_soc = soc->hal_soc;
  1043. qdf_assert(hal_soc);
  1044. if (qdf_unlikely(hal_srng_access_start(hal_soc, mon_status_srng)))
  1045. goto done;
  1046. /* mon_status_ring_desc => WBM_BUFFER_RING STRUCT =>
  1047. * BUFFER_ADDR_INFO STRUCT
  1048. */
  1049. while (qdf_likely((rxdma_mon_status_ring_entry =
  1050. hal_srng_src_peek(hal_soc, mon_status_srng))
  1051. && quota--)) {
  1052. uint32_t rx_buf_cookie;
  1053. qdf_nbuf_t status_nbuf;
  1054. struct dp_rx_desc *rx_desc;
  1055. uint8_t *status_buf;
  1056. qdf_dma_addr_t paddr;
  1057. uint64_t buf_addr;
  1058. buf_addr =
  1059. (HAL_RX_BUFFER_ADDR_31_0_GET(
  1060. rxdma_mon_status_ring_entry) |
  1061. ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(
  1062. rxdma_mon_status_ring_entry)) << 32));
  1063. if (qdf_likely(buf_addr)) {
  1064. rx_buf_cookie =
  1065. HAL_RX_BUF_COOKIE_GET(
  1066. rxdma_mon_status_ring_entry);
  1067. rx_desc = dp_rx_cookie_2_va_mon_status(soc,
  1068. rx_buf_cookie);
  1069. qdf_assert(rx_desc);
  1070. status_nbuf = rx_desc->nbuf;
  1071. qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf,
  1072. QDF_DMA_FROM_DEVICE);
  1073. status_buf = qdf_nbuf_data(status_nbuf);
  1074. status = hal_get_rx_status_done(status_buf);
  1075. if (status != QDF_STATUS_SUCCESS) {
  1076. uint32_t hp, tp;
  1077. hal_get_sw_hptp(hal_soc, mon_status_srng,
  1078. &tp, &hp);
  1079. dp_info_rl("tlv tag status error hp:%u, tp:%u",
  1080. hp, tp);
  1081. pdev->rx_mon_stats.tlv_tag_status_err++;
  1082. /* WAR for missing status: Skip status entry */
  1083. hal_srng_src_get_next(hal_soc, mon_status_srng);
  1084. continue;
  1085. }
  1086. qdf_nbuf_set_pktlen(status_nbuf, RX_BUFFER_SIZE);
  1087. qdf_nbuf_unmap_single(soc->osdev, status_nbuf,
  1088. QDF_DMA_FROM_DEVICE);
  1089. /* Put the status_nbuf to queue */
  1090. qdf_nbuf_queue_add(&pdev->rx_status_q, status_nbuf);
  1091. } else {
  1092. union dp_rx_desc_list_elem_t *desc_list = NULL;
  1093. union dp_rx_desc_list_elem_t *tail = NULL;
  1094. struct rx_desc_pool *rx_desc_pool;
  1095. uint32_t num_alloc_desc;
  1096. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1097. num_alloc_desc = dp_rx_get_free_desc_list(soc, mac_id,
  1098. rx_desc_pool,
  1099. 1,
  1100. &desc_list,
  1101. &tail);
  1102. /*
  1103. * No free descriptors available
  1104. */
  1105. if (qdf_unlikely(num_alloc_desc == 0)) {
  1106. work_done++;
  1107. break;
  1108. }
  1109. rx_desc = &desc_list->rx_desc;
  1110. }
  1111. status_nbuf = dp_rx_nbuf_prepare(soc, pdev);
  1112. /*
  1113. * qdf_nbuf alloc or map failed,
  1114. * free the dp rx desc to free list,
  1115. * fill in NULL dma address at current HP entry,
  1116. * keep HP in mon_status_ring unchanged,
  1117. * wait next time dp_rx_mon_status_srng_process
  1118. * to fill in buffer at current HP.
  1119. */
  1120. if (qdf_unlikely(!status_nbuf)) {
  1121. union dp_rx_desc_list_elem_t *desc_list = NULL;
  1122. union dp_rx_desc_list_elem_t *tail = NULL;
  1123. struct rx_desc_pool *rx_desc_pool;
  1124. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1125. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1126. "%s: fail to allocate or map qdf_nbuf",
  1127. __func__);
  1128. dp_rx_add_to_free_desc_list(&desc_list,
  1129. &tail, rx_desc);
  1130. dp_rx_add_desc_list_to_free_list(soc, &desc_list,
  1131. &tail, mac_id, rx_desc_pool);
  1132. hal_rxdma_buff_addr_info_set(
  1133. rxdma_mon_status_ring_entry,
  1134. 0, 0, HAL_RX_BUF_RBM_SW3_BM);
  1135. work_done++;
  1136. break;
  1137. }
  1138. paddr = qdf_nbuf_get_frag_paddr(status_nbuf, 0);
  1139. rx_desc->nbuf = status_nbuf;
  1140. rx_desc->in_use = 1;
  1141. hal_rxdma_buff_addr_info_set(rxdma_mon_status_ring_entry,
  1142. paddr, rx_desc->cookie, HAL_RX_BUF_RBM_SW3_BM);
  1143. hal_srng_src_get_next(hal_soc, mon_status_srng);
  1144. work_done++;
  1145. }
  1146. done:
  1147. hal_srng_access_end(hal_soc, mon_status_srng);
  1148. return work_done;
  1149. }
  1150. /*
  1151. * dp_rx_mon_status_process() - Process monitor status ring and
  1152. * TLV in status ring.
  1153. *
  1154. * @soc: core txrx main context
  1155. * @mac_id: mac_id which is one of 3 mac_ids
  1156. * @quota: No. of ring entry that can be serviced in one shot.
  1157. * Return: uint32_t: No. of ring entry that is processed.
  1158. */
  1159. static inline uint32_t
  1160. dp_rx_mon_status_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
  1161. uint32_t work_done;
  1162. work_done = dp_rx_mon_status_srng_process(soc, mac_id, quota);
  1163. quota -= work_done;
  1164. dp_rx_mon_status_process_tlv(soc, mac_id, quota);
  1165. return work_done;
  1166. }
  1167. /**
  1168. * dp_mon_process() - Main monitor mode processing roution.
  1169. * This call monitor status ring process then monitor
  1170. * destination ring process.
  1171. * Called from the bottom half (tasklet/NET_RX_SOFTIRQ)
  1172. * @soc: core txrx main context
  1173. * @mac_id: mac_id which is one of 3 mac_ids
  1174. * @quota: No. of status ring entry that can be serviced in one shot.
  1175. * Return: uint32_t: No. of ring entry that is processed.
  1176. */
  1177. uint32_t
  1178. dp_mon_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
  1179. return dp_rx_mon_status_process(soc, mac_id, quota);
  1180. }
  1181. /**
  1182. * dp_rx_pdev_mon_status_detach() - detach dp rx for status ring
  1183. * @pdev: core txrx pdev context
  1184. * @mac_id: mac_id/pdev_id correspondinggly for MCL and WIN
  1185. *
  1186. * This function will detach DP RX status ring from
  1187. * main device context. will free DP Rx resources for
  1188. * status ring
  1189. *
  1190. * Return: QDF_STATUS_SUCCESS: success
  1191. * QDF_STATUS_E_RESOURCES: Error return
  1192. */
  1193. QDF_STATUS
  1194. dp_rx_pdev_mon_status_detach(struct dp_pdev *pdev, int mac_id)
  1195. {
  1196. struct dp_soc *soc = pdev->soc;
  1197. struct rx_desc_pool *rx_desc_pool;
  1198. rx_desc_pool = &soc->rx_desc_status[mac_id];
  1199. if (rx_desc_pool->pool_size != 0) {
  1200. if (!dp_is_soc_reinit(soc))
  1201. dp_rx_desc_nbuf_and_pool_free(soc, mac_id,
  1202. rx_desc_pool);
  1203. else
  1204. dp_rx_desc_nbuf_free(soc, rx_desc_pool);
  1205. }
  1206. return QDF_STATUS_SUCCESS;
  1207. }
  1208. /*
  1209. * dp_rx_buffers_replenish() - replenish monitor status ring with
  1210. * rx nbufs called during dp rx
  1211. * monitor status ring initialization
  1212. *
  1213. * @soc: core txrx main context
  1214. * @mac_id: mac_id which is one of 3 mac_ids
  1215. * @dp_rxdma_srng: dp monitor status circular ring
  1216. * @rx_desc_pool; Pointer to Rx descriptor pool
  1217. * @num_req_buffers: number of buffer to be replenished
  1218. * @desc_list: list of descs if called from dp rx monitor status
  1219. * process or NULL during dp rx initialization or
  1220. * out of buffer interrupt
  1221. * @tail: tail of descs list
  1222. * @owner: who owns the nbuf (host, NSS etc...)
  1223. * Return: return success or failure
  1224. */
  1225. static inline
  1226. QDF_STATUS dp_rx_mon_status_buffers_replenish(struct dp_soc *dp_soc,
  1227. uint32_t mac_id,
  1228. struct dp_srng *dp_rxdma_srng,
  1229. struct rx_desc_pool *rx_desc_pool,
  1230. uint32_t num_req_buffers,
  1231. union dp_rx_desc_list_elem_t **desc_list,
  1232. union dp_rx_desc_list_elem_t **tail,
  1233. uint8_t owner)
  1234. {
  1235. uint32_t num_alloc_desc;
  1236. uint16_t num_desc_to_free = 0;
  1237. uint32_t num_entries_avail;
  1238. uint32_t count = 0;
  1239. int sync_hw_ptr = 1;
  1240. qdf_dma_addr_t paddr;
  1241. qdf_nbuf_t rx_netbuf;
  1242. void *rxdma_ring_entry;
  1243. union dp_rx_desc_list_elem_t *next;
  1244. void *rxdma_srng;
  1245. struct dp_pdev *dp_pdev = dp_get_pdev_for_mac_id(dp_soc, mac_id);
  1246. rxdma_srng = dp_rxdma_srng->hal_srng;
  1247. qdf_assert(rxdma_srng);
  1248. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1249. "[%s][%d] requested %d buffers for replenish",
  1250. __func__, __LINE__, num_req_buffers);
  1251. /*
  1252. * if desc_list is NULL, allocate the descs from freelist
  1253. */
  1254. if (!(*desc_list)) {
  1255. num_alloc_desc = dp_rx_get_free_desc_list(dp_soc, mac_id,
  1256. rx_desc_pool,
  1257. num_req_buffers,
  1258. desc_list,
  1259. tail);
  1260. if (!num_alloc_desc) {
  1261. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1262. "[%s][%d] no free rx_descs in freelist",
  1263. __func__, __LINE__);
  1264. return QDF_STATUS_E_NOMEM;
  1265. }
  1266. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1267. "[%s][%d] %d rx desc allocated", __func__, __LINE__,
  1268. num_alloc_desc);
  1269. num_req_buffers = num_alloc_desc;
  1270. }
  1271. hal_srng_access_start(dp_soc->hal_soc, rxdma_srng);
  1272. num_entries_avail = hal_srng_src_num_avail(dp_soc->hal_soc,
  1273. rxdma_srng, sync_hw_ptr);
  1274. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1275. "[%s][%d] no of available entries in rxdma ring: %d",
  1276. __func__, __LINE__, num_entries_avail);
  1277. if (num_entries_avail < num_req_buffers) {
  1278. num_desc_to_free = num_req_buffers - num_entries_avail;
  1279. num_req_buffers = num_entries_avail;
  1280. }
  1281. while (count < num_req_buffers) {
  1282. rx_netbuf = dp_rx_nbuf_prepare(dp_soc, dp_pdev);
  1283. /*
  1284. * qdf_nbuf alloc or map failed,
  1285. * keep HP in mon_status_ring unchanged,
  1286. * wait dp_rx_mon_status_srng_process
  1287. * to fill in buffer at current HP.
  1288. */
  1289. if (qdf_unlikely(!rx_netbuf)) {
  1290. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1291. "%s: qdf_nbuf allocate or map fail, count %d",
  1292. __func__, count);
  1293. break;
  1294. }
  1295. paddr = qdf_nbuf_get_frag_paddr(rx_netbuf, 0);
  1296. next = (*desc_list)->next;
  1297. rxdma_ring_entry = hal_srng_src_get_next(dp_soc->hal_soc,
  1298. rxdma_srng);
  1299. if (qdf_unlikely(!rxdma_ring_entry)) {
  1300. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1301. "[%s][%d] rxdma_ring_entry is NULL, count - %d",
  1302. __func__, __LINE__, count);
  1303. qdf_nbuf_unmap_single(dp_soc->osdev, rx_netbuf,
  1304. QDF_DMA_FROM_DEVICE);
  1305. qdf_nbuf_free(rx_netbuf);
  1306. break;
  1307. }
  1308. (*desc_list)->rx_desc.nbuf = rx_netbuf;
  1309. (*desc_list)->rx_desc.in_use = 1;
  1310. count++;
  1311. hal_rxdma_buff_addr_info_set(rxdma_ring_entry, paddr,
  1312. (*desc_list)->rx_desc.cookie, owner);
  1313. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1314. "[%s][%d] rx_desc=%pK, cookie=%d, nbuf=%pK, \
  1315. paddr=%pK",
  1316. __func__, __LINE__, &(*desc_list)->rx_desc,
  1317. (*desc_list)->rx_desc.cookie, rx_netbuf,
  1318. (void *)paddr);
  1319. *desc_list = next;
  1320. }
  1321. hal_srng_access_end(dp_soc->hal_soc, rxdma_srng);
  1322. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1323. "successfully replenished %d buffers", num_req_buffers);
  1324. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1325. "%d rx desc added back to free list", num_desc_to_free);
  1326. /*
  1327. * add any available free desc back to the free list
  1328. */
  1329. if (*desc_list) {
  1330. dp_rx_add_desc_list_to_free_list(dp_soc, desc_list, tail,
  1331. mac_id, rx_desc_pool);
  1332. }
  1333. return QDF_STATUS_SUCCESS;
  1334. }
  1335. /**
  1336. * dp_rx_pdev_mon_status_attach() - attach DP RX monitor status ring
  1337. * @pdev: core txrx pdev context
  1338. * @ring_id: ring number
  1339. * This function will attach a DP RX monitor status ring into pDEV
  1340. * and replenish monitor status ring with buffer.
  1341. *
  1342. * Return: QDF_STATUS_SUCCESS: success
  1343. * QDF_STATUS_E_RESOURCES: Error return
  1344. */
  1345. QDF_STATUS
  1346. dp_rx_pdev_mon_status_attach(struct dp_pdev *pdev, int ring_id) {
  1347. struct dp_soc *soc = pdev->soc;
  1348. union dp_rx_desc_list_elem_t *desc_list = NULL;
  1349. union dp_rx_desc_list_elem_t *tail = NULL;
  1350. struct dp_srng *mon_status_ring;
  1351. uint32_t num_entries;
  1352. uint32_t i;
  1353. struct rx_desc_pool *rx_desc_pool;
  1354. QDF_STATUS status;
  1355. int mac_for_pdev = dp_get_mac_id_for_mac(soc, ring_id);
  1356. mon_status_ring = &pdev->rxdma_mon_status_ring[mac_for_pdev];
  1357. num_entries = mon_status_ring->num_entries;
  1358. rx_desc_pool = &soc->rx_desc_status[ring_id];
  1359. dp_info("Mon RX Status Pool[%d] entries=%d",
  1360. ring_id, num_entries);
  1361. status = dp_rx_desc_pool_alloc(soc, ring_id, num_entries + 1,
  1362. rx_desc_pool);
  1363. if (!QDF_IS_STATUS_SUCCESS(status))
  1364. return status;
  1365. dp_debug("Mon RX Status Buffers Replenish ring_id=%d", ring_id);
  1366. status = dp_rx_mon_status_buffers_replenish(soc, ring_id,
  1367. mon_status_ring,
  1368. rx_desc_pool,
  1369. num_entries,
  1370. &desc_list, &tail,
  1371. HAL_RX_BUF_RBM_SW3_BM);
  1372. if (!QDF_IS_STATUS_SUCCESS(status))
  1373. return status;
  1374. qdf_nbuf_queue_init(&pdev->rx_status_q);
  1375. qdf_nbuf_queue_init(&pdev->rx_ppdu_buf_q);
  1376. pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  1377. qdf_mem_zero(&(pdev->ppdu_info.rx_status),
  1378. sizeof(pdev->ppdu_info.rx_status));
  1379. qdf_mem_zero(&pdev->rx_mon_stats,
  1380. sizeof(pdev->rx_mon_stats));
  1381. dp_rx_mon_init_dbg_ppdu_stats(&pdev->ppdu_info,
  1382. &pdev->rx_mon_stats);
  1383. for (i = 0; i < MAX_MU_USERS; i++) {
  1384. qdf_nbuf_queue_init(&pdev->mpdu_q[i]);
  1385. pdev->is_mpdu_hdr[i] = true;
  1386. }
  1387. qdf_mem_zero(pdev->msdu_list, sizeof(pdev->msdu_list[MAX_MU_USERS]));
  1388. pdev->rx_enh_capture_mode = CDP_RX_ENH_CAPTURE_DISABLED;
  1389. return QDF_STATUS_SUCCESS;
  1390. }