dp_rx_mon.c 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709
  1. /*
  2. * Copyright (c) 2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #include "hal_hw_headers.h"
  20. #include "dp_types.h"
  21. #include "dp_rx.h"
  22. #include "dp_peer.h"
  23. #include "hal_rx.h"
  24. #include "hal_api.h"
  25. #include "qdf_trace.h"
  26. #include "qdf_nbuf.h"
  27. #include "hal_api_mon.h"
  28. #include "dp_internal.h"
  29. #include "qdf_mem.h" /* qdf_mem_malloc,free */
  30. #include "dp_htt.h"
  31. #include "dp_mon.h"
  32. #include "dp_rx_mon.h"
  33. #include "htt.h"
  34. #ifdef FEATURE_PERPKT_INFO
  35. #include "dp_ratetable.h"
  36. #endif
  37. #ifndef IEEE80211_FCO_SUBTYPE_ACTION_NO_ACK
  38. #define IEEE80211_FCO_SUBTYPE_ACTION_NO_ACK 0xe0
  39. #endif
  40. #if defined(WLAN_CFR_ENABLE) && defined(WLAN_ENH_CFR_ENABLE)
  41. void
  42. dp_rx_mon_handle_cfr_mu_info(struct dp_pdev *pdev,
  43. struct hal_rx_ppdu_info *ppdu_info,
  44. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  45. {
  46. struct dp_peer *peer;
  47. struct dp_soc *soc = pdev->soc;
  48. struct dp_ast_entry *ast_entry;
  49. struct mon_rx_user_status *rx_user_status;
  50. struct cdp_rx_stats_ppdu_user *rx_stats_peruser;
  51. uint32_t num_users;
  52. int user_id;
  53. uint32_t ast_index;
  54. qdf_spin_lock_bh(&soc->ast_lock);
  55. num_users = ppdu_info->com_info.num_users;
  56. for (user_id = 0; user_id < num_users; user_id++) {
  57. if (user_id > OFDMA_NUM_USERS) {
  58. qdf_spin_unlock_bh(&soc->ast_lock);
  59. return;
  60. }
  61. rx_user_status = &ppdu_info->rx_user_status[user_id];
  62. rx_stats_peruser = &cdp_rx_ppdu->user[user_id];
  63. ast_index = rx_user_status->ast_index;
  64. if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  65. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  66. continue;
  67. }
  68. ast_entry = soc->ast_table[ast_index];
  69. if (!ast_entry || ast_entry->peer_id == HTT_INVALID_PEER) {
  70. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  71. continue;
  72. }
  73. peer = dp_peer_get_ref_by_id(soc, ast_entry->peer_id,
  74. DP_MOD_ID_RX_PPDU_STATS);
  75. if (!peer) {
  76. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  77. continue;
  78. }
  79. qdf_mem_copy(rx_stats_peruser->mac_addr,
  80. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  81. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  82. }
  83. qdf_spin_unlock_bh(&soc->ast_lock);
  84. }
  85. void
  86. dp_rx_mon_populate_cfr_ppdu_info(struct dp_pdev *pdev,
  87. struct hal_rx_ppdu_info *ppdu_info,
  88. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  89. {
  90. struct dp_peer *peer;
  91. struct dp_ast_entry *ast_entry;
  92. struct dp_soc *soc = pdev->soc;
  93. uint32_t ast_index;
  94. int chain;
  95. cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
  96. cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
  97. cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
  98. for (chain = 0; chain < MAX_CHAIN; chain++)
  99. cdp_rx_ppdu->per_chain_rssi[chain] =
  100. ppdu_info->rx_status.rssi[chain];
  101. cdp_rx_ppdu->u.ltf_size = ppdu_info->rx_status.ltf_size;
  102. cdp_rx_ppdu->beamformed = ppdu_info->rx_status.beamformed;
  103. cdp_rx_ppdu->u.ldpc = ppdu_info->rx_status.ldpc;
  104. if ((ppdu_info->rx_status.sgi == VHT_SGI_NYSM) &&
  105. (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC))
  106. cdp_rx_ppdu->u.gi = CDP_SGI_0_4_US;
  107. else
  108. cdp_rx_ppdu->u.gi = ppdu_info->rx_status.sgi;
  109. if (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC) {
  110. cdp_rx_ppdu->u.stbc = ppdu_info->rx_status.is_stbc;
  111. } else if (ppdu_info->rx_status.preamble_type ==
  112. HAL_RX_PKT_TYPE_11AX) {
  113. cdp_rx_ppdu->u.stbc = (ppdu_info->rx_status.he_data3 >>
  114. QDF_MON_STATUS_STBC_SHIFT) & 0x1;
  115. cdp_rx_ppdu->u.dcm = (ppdu_info->rx_status.he_data3 >>
  116. QDF_MON_STATUS_DCM_SHIFT) & 0x1;
  117. }
  118. dp_rx_mon_handle_cfr_mu_info(pdev, ppdu_info, cdp_rx_ppdu);
  119. ast_index = ppdu_info->rx_status.ast_index;
  120. if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  121. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  122. cdp_rx_ppdu->num_users = 0;
  123. return;
  124. }
  125. ast_entry = soc->ast_table[ast_index];
  126. if (!ast_entry || ast_entry->peer_id == HTT_INVALID_PEER) {
  127. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  128. cdp_rx_ppdu->num_users = 0;
  129. return;
  130. }
  131. peer = dp_peer_get_ref_by_id(soc, ast_entry->peer_id,
  132. DP_MOD_ID_RX_PPDU_STATS);
  133. if (!peer) {
  134. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  135. cdp_rx_ppdu->num_users = 0;
  136. return;
  137. }
  138. cdp_rx_ppdu->peer_id = peer->peer_id;
  139. cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
  140. cdp_rx_ppdu->num_users = ppdu_info->com_info.num_users;
  141. }
  142. bool
  143. dp_cfr_rcc_mode_status(struct dp_pdev *pdev)
  144. {
  145. return pdev->cfr_rcc_mode;
  146. }
  147. void
  148. dp_rx_mon_populate_cfr_info(struct dp_pdev *pdev,
  149. struct hal_rx_ppdu_info *ppdu_info,
  150. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  151. {
  152. struct cdp_rx_ppdu_cfr_info *cfr_info;
  153. if (!dp_cfr_rcc_mode_status(pdev))
  154. return;
  155. cfr_info = &cdp_rx_ppdu->cfr_info;
  156. cfr_info->bb_captured_channel
  157. = ppdu_info->cfr_info.bb_captured_channel;
  158. cfr_info->bb_captured_timeout
  159. = ppdu_info->cfr_info.bb_captured_timeout;
  160. cfr_info->bb_captured_reason
  161. = ppdu_info->cfr_info.bb_captured_reason;
  162. cfr_info->rx_location_info_valid
  163. = ppdu_info->cfr_info.rx_location_info_valid;
  164. cfr_info->chan_capture_status
  165. = ppdu_info->cfr_info.chan_capture_status;
  166. cfr_info->rtt_che_buffer_pointer_high8
  167. = ppdu_info->cfr_info.rtt_che_buffer_pointer_high8;
  168. cfr_info->rtt_che_buffer_pointer_low32
  169. = ppdu_info->cfr_info.rtt_che_buffer_pointer_low32;
  170. cfr_info->rtt_cfo_measurement
  171. = (int16_t)ppdu_info->cfr_info.rtt_cfo_measurement;
  172. cfr_info->agc_gain_info0
  173. = ppdu_info->cfr_info.agc_gain_info0;
  174. cfr_info->agc_gain_info1
  175. = ppdu_info->cfr_info.agc_gain_info1;
  176. cfr_info->agc_gain_info2
  177. = ppdu_info->cfr_info.agc_gain_info2;
  178. cfr_info->agc_gain_info3
  179. = ppdu_info->cfr_info.agc_gain_info3;
  180. cfr_info->rx_start_ts
  181. = ppdu_info->cfr_info.rx_start_ts;
  182. cfr_info->mcs_rate
  183. = ppdu_info->cfr_info.mcs_rate;
  184. cfr_info->gi_type
  185. = ppdu_info->cfr_info.gi_type;
  186. }
  187. void
  188. dp_update_cfr_dbg_stats(struct dp_pdev *pdev,
  189. struct hal_rx_ppdu_info *ppdu_info)
  190. {
  191. struct hal_rx_ppdu_cfr_info *cfr = &ppdu_info->cfr_info;
  192. DP_STATS_INC(pdev,
  193. rcc.chan_capture_status[cfr->chan_capture_status], 1);
  194. if (cfr->rx_location_info_valid) {
  195. DP_STATS_INC(pdev, rcc.rx_loc_info_valid_cnt, 1);
  196. if (cfr->bb_captured_channel) {
  197. DP_STATS_INC(pdev, rcc.bb_captured_channel_cnt, 1);
  198. DP_STATS_INC(pdev,
  199. rcc.reason_cnt[cfr->bb_captured_reason],
  200. 1);
  201. } else if (cfr->bb_captured_timeout) {
  202. DP_STATS_INC(pdev, rcc.bb_captured_timeout_cnt, 1);
  203. DP_STATS_INC(pdev,
  204. rcc.reason_cnt[cfr->bb_captured_reason],
  205. 1);
  206. }
  207. }
  208. }
  209. void
  210. dp_rx_handle_cfr(struct dp_soc *soc, struct dp_pdev *pdev,
  211. struct hal_rx_ppdu_info *ppdu_info)
  212. {
  213. qdf_nbuf_t ppdu_nbuf;
  214. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  215. dp_update_cfr_dbg_stats(pdev, ppdu_info);
  216. if (!ppdu_info->cfr_info.bb_captured_channel)
  217. return;
  218. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  219. sizeof(struct cdp_rx_indication_ppdu),
  220. 0,
  221. 0,
  222. FALSE);
  223. if (ppdu_nbuf) {
  224. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
  225. dp_rx_mon_populate_cfr_info(pdev, ppdu_info, cdp_rx_ppdu);
  226. dp_rx_mon_populate_cfr_ppdu_info(pdev, ppdu_info, cdp_rx_ppdu);
  227. qdf_nbuf_put_tail(ppdu_nbuf,
  228. sizeof(struct cdp_rx_indication_ppdu));
  229. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
  230. ppdu_nbuf, HTT_INVALID_PEER,
  231. WDI_NO_VAL, pdev->pdev_id);
  232. }
  233. }
  234. void
  235. dp_rx_populate_cfr_non_assoc_sta(struct dp_pdev *pdev,
  236. struct hal_rx_ppdu_info *ppdu_info,
  237. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  238. {
  239. if (!dp_cfr_rcc_mode_status(pdev))
  240. return;
  241. if (ppdu_info->cfr_info.bb_captured_channel)
  242. dp_rx_mon_populate_cfr_ppdu_info(pdev, ppdu_info, cdp_rx_ppdu);
  243. }
  244. /**
  245. * dp_bb_captured_chan_status() - Get the bb_captured_channel status
  246. * @ppdu_info: structure for rx ppdu ring
  247. *
  248. * Return: Success/ Failure
  249. */
  250. static inline QDF_STATUS
  251. dp_bb_captured_chan_status(struct dp_pdev *pdev,
  252. struct hal_rx_ppdu_info *ppdu_info)
  253. {
  254. QDF_STATUS status = QDF_STATUS_E_FAILURE;
  255. struct hal_rx_ppdu_cfr_info *cfr = &ppdu_info->cfr_info;
  256. if (dp_cfr_rcc_mode_status(pdev)) {
  257. if (cfr->bb_captured_channel)
  258. status = QDF_STATUS_SUCCESS;
  259. }
  260. return status;
  261. }
  262. #else
  263. static inline QDF_STATUS
  264. dp_bb_captured_chan_status(struct dp_pdev *pdev,
  265. struct hal_rx_ppdu_info *ppdu_info)
  266. {
  267. return QDF_STATUS_E_NOSUPPORT;
  268. }
  269. #endif /* WLAN_CFR_ENABLE */
  270. #ifdef QCA_ENHANCED_STATS_SUPPORT
  271. void
  272. dp_rx_populate_rx_rssi_chain(struct hal_rx_ppdu_info *ppdu_info,
  273. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  274. {
  275. uint8_t chain, bw;
  276. int8_t rssi;
  277. for (chain = 0; chain < SS_COUNT; chain++) {
  278. for (bw = 0; bw < MAX_BW; bw++) {
  279. rssi = ppdu_info->rx_status.rssi_chain[chain][bw];
  280. if (rssi != DP_RSSI_INVAL)
  281. cdp_rx_ppdu->rssi_chain[chain][bw] = rssi;
  282. else
  283. cdp_rx_ppdu->rssi_chain[chain][bw] = 0;
  284. }
  285. }
  286. }
  287. void
  288. dp_rx_populate_su_evm_details(struct hal_rx_ppdu_info *ppdu_info,
  289. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  290. {
  291. uint8_t pilot_evm;
  292. uint8_t nss_count;
  293. uint8_t pilot_count;
  294. nss_count = ppdu_info->evm_info.nss_count;
  295. pilot_count = ppdu_info->evm_info.pilot_count;
  296. if ((nss_count * pilot_count) > DP_RX_MAX_SU_EVM_COUNT) {
  297. qdf_err("pilot evm count is more than expected");
  298. return;
  299. }
  300. cdp_rx_ppdu->evm_info.pilot_count = pilot_count;
  301. cdp_rx_ppdu->evm_info.nss_count = nss_count;
  302. /* Populate evm for pilot_evm = nss_count*pilot_count */
  303. for (pilot_evm = 0; pilot_evm < nss_count * pilot_count; pilot_evm++) {
  304. cdp_rx_ppdu->evm_info.pilot_evm[pilot_evm] =
  305. ppdu_info->evm_info.pilot_evm[pilot_evm];
  306. }
  307. }
  308. /**
  309. * dp_rx_inc_rusize_cnt() - increment pdev stats based on RU size
  310. * @pdev: pdev ctx
  311. * @rx_user_status: mon rx user status
  312. *
  313. * Return: bool
  314. */
  315. static inline bool
  316. dp_rx_inc_rusize_cnt(struct dp_pdev *pdev,
  317. struct mon_rx_user_status *rx_user_status)
  318. {
  319. uint32_t ru_size;
  320. bool is_data;
  321. ru_size = rx_user_status->ofdma_ru_size;
  322. if (dp_is_subtype_data(rx_user_status->frame_control)) {
  323. DP_STATS_INC(pdev,
  324. ul_ofdma.data_rx_ru_size[ru_size], 1);
  325. is_data = true;
  326. } else {
  327. DP_STATS_INC(pdev,
  328. ul_ofdma.nondata_rx_ru_size[ru_size], 1);
  329. is_data = false;
  330. }
  331. return is_data;
  332. }
  333. /**
  334. * dp_rx_populate_cdp_indication_ppdu_user() - Populate per user cdp indication
  335. * @pdev: pdev ctx
  336. * @ppdu_info: ppdu info structure from ppdu ring
  337. * @cdp_rx_ppdu: Rx PPDU indication structure
  338. *
  339. * Return: none
  340. */
  341. static void
  342. dp_rx_populate_cdp_indication_ppdu_user(struct dp_pdev *pdev,
  343. struct hal_rx_ppdu_info *ppdu_info,
  344. struct cdp_rx_indication_ppdu
  345. *cdp_rx_ppdu)
  346. {
  347. struct dp_peer *peer;
  348. struct dp_soc *soc = pdev->soc;
  349. struct dp_ast_entry *ast_entry;
  350. uint32_t ast_index;
  351. int i;
  352. struct mon_rx_user_status *rx_user_status;
  353. struct mon_rx_user_info *rx_user_info;
  354. struct cdp_rx_stats_ppdu_user *rx_stats_peruser;
  355. int ru_size;
  356. bool is_data = false;
  357. uint32_t num_users;
  358. struct dp_mon_ops *mon_ops;
  359. num_users = ppdu_info->com_info.num_users;
  360. for (i = 0; i < num_users; i++) {
  361. if (i > OFDMA_NUM_USERS)
  362. return;
  363. rx_user_status = &ppdu_info->rx_user_status[i];
  364. rx_user_info = &ppdu_info->rx_user_info[i];
  365. rx_stats_peruser = &cdp_rx_ppdu->user[i];
  366. ast_index = rx_user_status->ast_index;
  367. if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  368. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  369. continue;
  370. }
  371. ast_entry = soc->ast_table[ast_index];
  372. if (!ast_entry || ast_entry->peer_id == HTT_INVALID_PEER) {
  373. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  374. continue;
  375. }
  376. peer = dp_peer_get_ref_by_id(soc, ast_entry->peer_id,
  377. DP_MOD_ID_RX_PPDU_STATS);
  378. if (!peer) {
  379. rx_stats_peruser->peer_id = HTT_INVALID_PEER;
  380. continue;
  381. }
  382. rx_stats_peruser->is_bss_peer = peer->bss_peer;
  383. rx_stats_peruser->first_data_seq_ctrl =
  384. rx_user_status->first_data_seq_ctrl;
  385. rx_stats_peruser->frame_control_info_valid =
  386. rx_user_status->frame_control_info_valid;
  387. rx_stats_peruser->frame_control =
  388. rx_user_status->frame_control;
  389. rx_stats_peruser->qos_control_info_valid =
  390. rx_user_info->qos_control_info_valid;
  391. rx_stats_peruser->qos_control =
  392. rx_user_info->qos_control;
  393. rx_stats_peruser->tcp_msdu_count =
  394. rx_user_status->tcp_msdu_count;
  395. rx_stats_peruser->udp_msdu_count =
  396. rx_user_status->udp_msdu_count;
  397. rx_stats_peruser->other_msdu_count =
  398. rx_user_status->other_msdu_count;
  399. rx_stats_peruser->num_msdu =
  400. rx_stats_peruser->tcp_msdu_count +
  401. rx_stats_peruser->udp_msdu_count +
  402. rx_stats_peruser->other_msdu_count;
  403. rx_stats_peruser->preamble_type =
  404. rx_user_status->preamble_type;
  405. rx_stats_peruser->mpdu_cnt_fcs_ok =
  406. rx_user_status->mpdu_cnt_fcs_ok;
  407. rx_stats_peruser->mpdu_cnt_fcs_err =
  408. rx_user_status->mpdu_cnt_fcs_err;
  409. qdf_mem_copy(&rx_stats_peruser->mpdu_fcs_ok_bitmap,
  410. &rx_user_status->mpdu_fcs_ok_bitmap,
  411. HAL_RX_NUM_WORDS_PER_PPDU_BITMAP *
  412. sizeof(rx_user_status->mpdu_fcs_ok_bitmap[0]));
  413. rx_stats_peruser->mpdu_ok_byte_count =
  414. rx_user_status->mpdu_ok_byte_count;
  415. rx_stats_peruser->mpdu_err_byte_count =
  416. rx_user_status->mpdu_err_byte_count;
  417. cdp_rx_ppdu->num_mpdu += rx_user_status->mpdu_cnt_fcs_ok;
  418. cdp_rx_ppdu->num_msdu += rx_stats_peruser->num_msdu;
  419. rx_stats_peruser->retries =
  420. CDP_FC_IS_RETRY_SET(rx_stats_peruser->frame_control) ?
  421. rx_stats_peruser->mpdu_cnt_fcs_ok : 0;
  422. if (rx_stats_peruser->mpdu_cnt_fcs_ok > 1)
  423. rx_stats_peruser->is_ampdu = 1;
  424. else
  425. rx_stats_peruser->is_ampdu = 0;
  426. rx_stats_peruser->tid = ppdu_info->rx_status.tid;
  427. qdf_mem_copy(rx_stats_peruser->mac_addr,
  428. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  429. rx_stats_peruser->peer_id = peer->peer_id;
  430. cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
  431. rx_stats_peruser->vdev_id = peer->vdev->vdev_id;
  432. rx_stats_peruser->mu_ul_info_valid = 0;
  433. mon_ops = dp_mon_ops_get(soc);
  434. if (mon_ops && mon_ops->mon_rx_populate_ppdu_usr_info)
  435. mon_ops->mon_rx_populate_ppdu_usr_info(rx_user_status,
  436. rx_stats_peruser);
  437. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  438. if (cdp_rx_ppdu->u.ppdu_type == HAL_RX_TYPE_MU_OFDMA ||
  439. cdp_rx_ppdu->u.ppdu_type == HAL_RX_TYPE_MU_MIMO) {
  440. if (rx_user_status->mu_ul_info_valid) {
  441. rx_stats_peruser->nss = rx_user_status->nss;
  442. rx_stats_peruser->mcs = rx_user_status->mcs;
  443. rx_stats_peruser->mu_ul_info_valid =
  444. rx_user_status->mu_ul_info_valid;
  445. rx_stats_peruser->ofdma_ru_start_index =
  446. rx_user_status->ofdma_ru_start_index;
  447. rx_stats_peruser->ofdma_ru_width =
  448. rx_user_status->ofdma_ru_width;
  449. rx_stats_peruser->user_index = i;
  450. ru_size = rx_user_status->ofdma_ru_size;
  451. /*
  452. * max RU size will be equal to
  453. * HTT_UL_OFDMA_V0_RU_SIZE_RU_996x2
  454. */
  455. if (ru_size >= OFDMA_NUM_RU_SIZE) {
  456. dp_err("invalid ru_size %d\n",
  457. ru_size);
  458. return;
  459. }
  460. is_data = dp_rx_inc_rusize_cnt(pdev,
  461. rx_user_status);
  462. }
  463. if (is_data) {
  464. /* counter to get number of MU OFDMA */
  465. pdev->stats.ul_ofdma.data_rx_ppdu++;
  466. pdev->stats.ul_ofdma.data_users[num_users]++;
  467. }
  468. }
  469. }
  470. }
  471. /**
  472. * dp_rx_populate_cdp_indication_ppdu() - Populate cdp rx indication structure
  473. * @pdev: pdev ctx
  474. * @ppdu_info: ppdu info structure from ppdu ring
  475. * @cdp_rx_ppdu: Rx PPDU indication structure
  476. *
  477. * Return: none
  478. */
  479. static void
  480. dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
  481. struct hal_rx_ppdu_info *ppdu_info,
  482. struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
  483. {
  484. struct dp_peer *peer;
  485. struct dp_soc *soc = pdev->soc;
  486. struct dp_ast_entry *ast_entry;
  487. uint32_t ast_index;
  488. uint32_t i;
  489. struct dp_mon_ops *mon_ops;
  490. cdp_rx_ppdu->first_data_seq_ctrl =
  491. ppdu_info->rx_status.first_data_seq_ctrl;
  492. cdp_rx_ppdu->frame_ctrl =
  493. ppdu_info->rx_status.frame_control;
  494. cdp_rx_ppdu->tcp_msdu_count = ppdu_info->rx_status.tcp_msdu_count;
  495. cdp_rx_ppdu->udp_msdu_count = ppdu_info->rx_status.udp_msdu_count;
  496. cdp_rx_ppdu->other_msdu_count = ppdu_info->rx_status.other_msdu_count;
  497. cdp_rx_ppdu->u.preamble = ppdu_info->rx_status.preamble_type;
  498. /* num mpdu is consolidated and added together in num user loop */
  499. cdp_rx_ppdu->num_mpdu = ppdu_info->com_info.mpdu_cnt_fcs_ok;
  500. /* num msdu is consolidated and added together in num user loop */
  501. cdp_rx_ppdu->num_msdu = (cdp_rx_ppdu->tcp_msdu_count +
  502. cdp_rx_ppdu->udp_msdu_count +
  503. cdp_rx_ppdu->other_msdu_count);
  504. cdp_rx_ppdu->retries = CDP_FC_IS_RETRY_SET(cdp_rx_ppdu->frame_ctrl) ?
  505. ppdu_info->com_info.mpdu_cnt_fcs_ok : 0;
  506. if (ppdu_info->com_info.mpdu_cnt_fcs_ok > 1)
  507. cdp_rx_ppdu->is_ampdu = 1;
  508. else
  509. cdp_rx_ppdu->is_ampdu = 0;
  510. cdp_rx_ppdu->tid = ppdu_info->rx_status.tid;
  511. ast_index = ppdu_info->rx_status.ast_index;
  512. if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  513. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  514. cdp_rx_ppdu->num_users = 0;
  515. goto end;
  516. }
  517. ast_entry = soc->ast_table[ast_index];
  518. if (!ast_entry || ast_entry->peer_id == HTT_INVALID_PEER) {
  519. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  520. cdp_rx_ppdu->num_users = 0;
  521. goto end;
  522. }
  523. peer = dp_peer_get_ref_by_id(soc, ast_entry->peer_id,
  524. DP_MOD_ID_RX_PPDU_STATS);
  525. if (!peer) {
  526. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  527. cdp_rx_ppdu->num_users = 0;
  528. goto end;
  529. }
  530. qdf_mem_copy(cdp_rx_ppdu->mac_addr,
  531. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  532. cdp_rx_ppdu->peer_id = peer->peer_id;
  533. cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
  534. cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
  535. cdp_rx_ppdu->length = ppdu_info->rx_status.ppdu_len;
  536. cdp_rx_ppdu->duration = ppdu_info->rx_status.duration;
  537. cdp_rx_ppdu->u.bw = ppdu_info->rx_status.bw;
  538. cdp_rx_ppdu->u.nss = ppdu_info->rx_status.nss;
  539. cdp_rx_ppdu->u.mcs = ppdu_info->rx_status.mcs;
  540. if ((ppdu_info->rx_status.sgi == VHT_SGI_NYSM) &&
  541. (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC))
  542. cdp_rx_ppdu->u.gi = CDP_SGI_0_4_US;
  543. else
  544. cdp_rx_ppdu->u.gi = ppdu_info->rx_status.sgi;
  545. cdp_rx_ppdu->u.ldpc = ppdu_info->rx_status.ldpc;
  546. cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
  547. cdp_rx_ppdu->u.ltf_size = (ppdu_info->rx_status.he_data5 >>
  548. QDF_MON_STATUS_HE_LTF_SIZE_SHIFT) & 0x3;
  549. cdp_rx_ppdu->rssi = ppdu_info->rx_status.rssi_comb;
  550. cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
  551. cdp_rx_ppdu->channel = ppdu_info->rx_status.chan_num;
  552. cdp_rx_ppdu->beamformed = ppdu_info->rx_status.beamformed;
  553. cdp_rx_ppdu->num_bytes = ppdu_info->rx_status.ppdu_len;
  554. cdp_rx_ppdu->lsig_a = ppdu_info->rx_status.rate;
  555. cdp_rx_ppdu->u.ltf_size = ppdu_info->rx_status.ltf_size;
  556. if (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC) {
  557. cdp_rx_ppdu->u.stbc = ppdu_info->rx_status.is_stbc;
  558. } else if (ppdu_info->rx_status.preamble_type ==
  559. HAL_RX_PKT_TYPE_11AX) {
  560. cdp_rx_ppdu->u.stbc = (ppdu_info->rx_status.he_data3 >>
  561. QDF_MON_STATUS_STBC_SHIFT) & 0x1;
  562. cdp_rx_ppdu->u.dcm = (ppdu_info->rx_status.he_data3 >>
  563. QDF_MON_STATUS_DCM_SHIFT) & 0x1;
  564. }
  565. dp_rx_populate_rx_rssi_chain(ppdu_info, cdp_rx_ppdu);
  566. dp_rx_populate_su_evm_details(ppdu_info, cdp_rx_ppdu);
  567. cdp_rx_ppdu->rx_antenna = ppdu_info->rx_status.rx_antenna;
  568. mon_ops = dp_mon_ops_get(pdev->soc);
  569. if (mon_ops && mon_ops->mon_rx_populate_ppdu_info)
  570. mon_ops->mon_rx_populate_ppdu_info(ppdu_info,
  571. cdp_rx_ppdu);
  572. cdp_rx_ppdu->nf = ppdu_info->rx_status.chan_noise_floor;
  573. for (i = 0; i < MAX_CHAIN; i++)
  574. cdp_rx_ppdu->per_chain_rssi[i] = ppdu_info->rx_status.rssi[i];
  575. cdp_rx_ppdu->is_mcast_bcast = ppdu_info->nac_info.mcast_bcast;
  576. cdp_rx_ppdu->num_users = ppdu_info->com_info.num_users;
  577. cdp_rx_ppdu->num_mpdu = 0;
  578. cdp_rx_ppdu->num_msdu = 0;
  579. dp_rx_populate_cdp_indication_ppdu_user(pdev, ppdu_info, cdp_rx_ppdu);
  580. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  581. return;
  582. end:
  583. dp_rx_populate_cfr_non_assoc_sta(pdev, ppdu_info, cdp_rx_ppdu);
  584. }
  585. /**
  586. * dp_rx_stats_update() - Update per-peer statistics
  587. * @soc: Datapath SOC handle
  588. * @peer: Datapath peer handle
  589. * @ppdu: PPDU Descriptor
  590. *
  591. * Return: None
  592. */
  593. static inline void dp_rx_rate_stats_update(struct dp_peer *peer,
  594. struct cdp_rx_indication_ppdu *ppdu,
  595. uint32_t user)
  596. {
  597. uint32_t ratekbps = 0;
  598. uint32_t ppdu_rx_rate = 0;
  599. uint32_t nss = 0;
  600. uint8_t mcs = 0;
  601. uint32_t rix;
  602. uint16_t ratecode;
  603. struct cdp_rx_stats_ppdu_user *ppdu_user = NULL;
  604. if (!peer || !ppdu)
  605. return;
  606. ppdu_user = &ppdu->user[user];
  607. if (ppdu->u.ppdu_type != HAL_RX_TYPE_SU) {
  608. if (ppdu_user->nss == 0)
  609. nss = 0;
  610. else
  611. nss = ppdu_user->nss - 1;
  612. mcs = ppdu_user->mcs;
  613. } else {
  614. if (ppdu->u.nss == 0)
  615. nss = 0;
  616. else
  617. nss = ppdu->u.nss - 1;
  618. mcs = ppdu->u.mcs;
  619. }
  620. ratekbps = dp_getrateindex(ppdu->u.gi,
  621. mcs,
  622. nss,
  623. ppdu->u.preamble,
  624. ppdu->u.bw,
  625. &rix,
  626. &ratecode);
  627. if (!ratekbps) {
  628. ppdu->rix = 0;
  629. ppdu->rx_ratekbps = 0;
  630. ppdu->rx_ratecode = 0;
  631. ppdu_user->rx_ratekbps = 0;
  632. return;
  633. }
  634. ppdu->rix = rix;
  635. DP_STATS_UPD(peer, rx.last_rx_rate, ratekbps);
  636. peer->stats.rx.avg_rx_rate =
  637. dp_ath_rate_lpf(peer->stats.rx.avg_rx_rate, ratekbps);
  638. ppdu_rx_rate = dp_ath_rate_out(peer->stats.rx.avg_rx_rate);
  639. DP_STATS_UPD(peer, rx.rnd_avg_rx_rate, ppdu_rx_rate);
  640. ppdu->rx_ratekbps = ratekbps;
  641. ppdu->rx_ratecode = ratecode;
  642. ppdu_user->rx_ratekbps = ratekbps;
  643. if (peer->vdev)
  644. peer->vdev->stats.rx.last_rx_rate = ratekbps;
  645. }
  646. #ifdef WLAN_FEATURE_11BE
  647. static inline uint8_t dp_get_bw_offset_frm_bw(struct dp_soc *soc,
  648. enum CMN_BW_TYPES bw)
  649. {
  650. uint8_t pkt_bw_offset;
  651. switch (bw) {
  652. case CMN_BW_20MHZ:
  653. pkt_bw_offset = PKT_BW_GAIN_20MHZ;
  654. break;
  655. case CMN_BW_40MHZ:
  656. pkt_bw_offset = PKT_BW_GAIN_40MHZ;
  657. break;
  658. case CMN_BW_80MHZ:
  659. pkt_bw_offset = PKT_BW_GAIN_80MHZ;
  660. break;
  661. case CMN_BW_160MHZ:
  662. pkt_bw_offset = PKT_BW_GAIN_160MHZ;
  663. break;
  664. case CMN_BW_320MHZ:
  665. pkt_bw_offset = PKT_BW_GAIN_320MHZ;
  666. break;
  667. default:
  668. pkt_bw_offset = 0;
  669. dp_rx_mon_status_debug("%pK: Invalid BW index = %d",
  670. soc, bw);
  671. }
  672. return pkt_bw_offset;
  673. }
  674. #else
  675. static inline uint8_t dp_get_bw_offset_frm_bw(struct dp_soc *soc,
  676. enum CMN_BW_TYPES bw)
  677. {
  678. uint8_t pkt_bw_offset;
  679. switch (bw) {
  680. case CMN_BW_20MHZ:
  681. pkt_bw_offset = PKT_BW_GAIN_20MHZ;
  682. break;
  683. case CMN_BW_40MHZ:
  684. pkt_bw_offset = PKT_BW_GAIN_40MHZ;
  685. break;
  686. case CMN_BW_80MHZ:
  687. pkt_bw_offset = PKT_BW_GAIN_80MHZ;
  688. break;
  689. case CMN_BW_160MHZ:
  690. pkt_bw_offset = PKT_BW_GAIN_160MHZ;
  691. break;
  692. default:
  693. pkt_bw_offset = 0;
  694. dp_rx_mon_status_debug("%pK: Invalid BW index = %d",
  695. soc, bw);
  696. }
  697. return pkt_bw_offset;
  698. }
  699. #endif
  700. static void dp_rx_stats_update(struct dp_pdev *pdev,
  701. struct cdp_rx_indication_ppdu *ppdu)
  702. {
  703. struct dp_soc *soc = NULL;
  704. uint8_t mcs, preamble, ac = 0, nss, ppdu_type;
  705. uint16_t num_msdu;
  706. uint8_t pkt_bw_offset;
  707. struct dp_peer *peer;
  708. struct cdp_rx_stats_ppdu_user *ppdu_user;
  709. uint32_t i;
  710. enum cdp_mu_packet_type mu_pkt_type;
  711. struct dp_mon_ops *mon_ops;
  712. if (pdev)
  713. soc = pdev->soc;
  714. else
  715. return;
  716. if (!soc || soc->process_rx_status)
  717. return;
  718. preamble = ppdu->u.preamble;
  719. ppdu_type = ppdu->u.ppdu_type;
  720. for (i = 0; i < ppdu->num_users && i < CDP_MU_MAX_USERS; i++) {
  721. peer = NULL;
  722. ppdu_user = &ppdu->user[i];
  723. peer = dp_peer_get_ref_by_id(soc, ppdu_user->peer_id,
  724. DP_MOD_ID_RX_PPDU_STATS);
  725. if (!peer)
  726. peer = pdev->invalid_peer;
  727. if ((preamble == DOT11_A) || (preamble == DOT11_B))
  728. ppdu->u.nss = 1;
  729. if (ppdu_type == HAL_RX_TYPE_SU) {
  730. mcs = ppdu->u.mcs;
  731. nss = ppdu->u.nss;
  732. } else {
  733. mcs = ppdu_user->mcs;
  734. nss = ppdu_user->nss;
  735. }
  736. num_msdu = ppdu_user->num_msdu;
  737. pkt_bw_offset = dp_get_bw_offset_frm_bw(soc, ppdu->u.bw);
  738. DP_STATS_UPD(peer, rx.snr, (ppdu->rssi + pkt_bw_offset));
  739. if (peer->stats.rx.avg_snr == CDP_INVALID_SNR)
  740. peer->stats.rx.avg_snr =
  741. CDP_SNR_IN(peer->stats.rx.snr);
  742. else
  743. CDP_SNR_UPDATE_AVG(peer->stats.rx.avg_snr,
  744. peer->stats.rx.snr);
  745. if (ppdu_type == HAL_RX_TYPE_SU) {
  746. if (nss) {
  747. DP_STATS_INC(peer, rx.nss[nss - 1], num_msdu);
  748. DP_STATS_INC(peer, rx.ppdu_nss[nss - 1], 1);
  749. }
  750. DP_STATS_INC(peer, rx.mpdu_cnt_fcs_ok,
  751. ppdu_user->mpdu_cnt_fcs_ok);
  752. DP_STATS_INC(peer, rx.mpdu_cnt_fcs_err,
  753. ppdu_user->mpdu_cnt_fcs_err);
  754. }
  755. if (ppdu_type >= HAL_RX_TYPE_MU_MIMO &&
  756. ppdu_type <= HAL_RX_TYPE_MU_OFDMA) {
  757. if (ppdu_type == HAL_RX_TYPE_MU_MIMO)
  758. mu_pkt_type = TXRX_TYPE_MU_MIMO;
  759. else
  760. mu_pkt_type = TXRX_TYPE_MU_OFDMA;
  761. if (nss) {
  762. DP_STATS_INC(peer, rx.nss[nss - 1], num_msdu);
  763. DP_STATS_INC(peer,
  764. rx.rx_mu[mu_pkt_type].ppdu_nss[nss - 1],
  765. 1);
  766. }
  767. DP_STATS_INC(peer,
  768. rx.rx_mu[mu_pkt_type].mpdu_cnt_fcs_ok,
  769. ppdu_user->mpdu_cnt_fcs_ok);
  770. DP_STATS_INC(peer,
  771. rx.rx_mu[mu_pkt_type].mpdu_cnt_fcs_err,
  772. ppdu_user->mpdu_cnt_fcs_err);
  773. }
  774. DP_STATS_INC(peer, rx.sgi_count[ppdu->u.gi], num_msdu);
  775. DP_STATS_INC(peer, rx.bw[ppdu->u.bw], num_msdu);
  776. DP_STATS_INC(peer, rx.reception_type[ppdu->u.ppdu_type],
  777. num_msdu);
  778. DP_STATS_INC(peer, rx.ppdu_cnt[ppdu->u.ppdu_type], 1);
  779. DP_STATS_INCC(peer, rx.ampdu_cnt, num_msdu,
  780. ppdu_user->is_ampdu);
  781. DP_STATS_INCC(peer, rx.non_ampdu_cnt, num_msdu,
  782. !(ppdu_user->is_ampdu));
  783. DP_STATS_UPD(peer, rx.rx_rate, mcs);
  784. DP_STATS_INCC(peer,
  785. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  786. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
  787. DP_STATS_INCC(peer,
  788. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  789. ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
  790. DP_STATS_INCC(peer,
  791. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  792. ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B)));
  793. DP_STATS_INCC(peer,
  794. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  795. ((mcs < MAX_MCS_11B) && (preamble == DOT11_B)));
  796. DP_STATS_INCC(peer,
  797. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  798. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N)));
  799. DP_STATS_INCC(peer,
  800. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  801. ((mcs < MAX_MCS_11A) && (preamble == DOT11_N)));
  802. DP_STATS_INCC(peer,
  803. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  804. ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC)));
  805. DP_STATS_INCC(peer,
  806. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  807. ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
  808. DP_STATS_INCC(peer,
  809. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  810. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  811. DP_STATS_INCC(peer,
  812. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  813. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  814. DP_STATS_INCC(peer,
  815. rx.su_ax_ppdu_cnt.mcs_count[MAX_MCS - 1], 1,
  816. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX) &&
  817. (ppdu_type == HAL_RX_TYPE_SU)));
  818. DP_STATS_INCC(peer,
  819. rx.su_ax_ppdu_cnt.mcs_count[mcs], 1,
  820. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX) &&
  821. (ppdu_type == HAL_RX_TYPE_SU)));
  822. DP_STATS_INCC(peer,
  823. rx.rx_mu[TXRX_TYPE_MU_OFDMA].ppdu.mcs_count[MAX_MCS - 1],
  824. 1, ((mcs >= (MAX_MCS - 1)) &&
  825. (preamble == DOT11_AX) &&
  826. (ppdu_type == HAL_RX_TYPE_MU_OFDMA)));
  827. DP_STATS_INCC(peer,
  828. rx.rx_mu[TXRX_TYPE_MU_OFDMA].ppdu.mcs_count[mcs],
  829. 1, ((mcs < (MAX_MCS - 1)) &&
  830. (preamble == DOT11_AX) &&
  831. (ppdu_type == HAL_RX_TYPE_MU_OFDMA)));
  832. DP_STATS_INCC(peer,
  833. rx.rx_mu[TXRX_TYPE_MU_MIMO].ppdu.mcs_count[MAX_MCS - 1],
  834. 1, ((mcs >= (MAX_MCS - 1)) &&
  835. (preamble == DOT11_AX) &&
  836. (ppdu_type == HAL_RX_TYPE_MU_MIMO)));
  837. DP_STATS_INCC(peer,
  838. rx.rx_mu[TXRX_TYPE_MU_MIMO].ppdu.mcs_count[mcs],
  839. 1, ((mcs < (MAX_MCS - 1)) &&
  840. (preamble == DOT11_AX) &&
  841. (ppdu_type == HAL_RX_TYPE_MU_MIMO)));
  842. /*
  843. * If invalid TID, it could be a non-qos frame, hence do not
  844. * update any AC counters
  845. */
  846. ac = TID_TO_WME_AC(ppdu_user->tid);
  847. if (ppdu->tid != HAL_TID_INVALID)
  848. DP_STATS_INC(peer, rx.wme_ac_type[ac], num_msdu);
  849. mon_ops = dp_mon_ops_get(soc);
  850. if (mon_ops && mon_ops->mon_rx_stats_update)
  851. mon_ops->mon_rx_stats_update(peer, ppdu, ppdu_user);
  852. dp_peer_stats_notify(pdev, peer);
  853. DP_STATS_UPD(peer, rx.last_snr, (ppdu->rssi + pkt_bw_offset));
  854. dp_peer_qos_stats_notify(pdev, ppdu_user);
  855. if (peer == pdev->invalid_peer)
  856. continue;
  857. if (dp_is_subtype_data(ppdu->frame_ctrl))
  858. dp_rx_rate_stats_update(peer, ppdu, i);
  859. #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
  860. dp_wdi_event_handler(WDI_EVENT_UPDATE_DP_STATS, pdev->soc,
  861. &peer->stats, ppdu->peer_id,
  862. UPDATE_PEER_STATS, pdev->pdev_id);
  863. #endif
  864. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  865. }
  866. }
  867. void
  868. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  869. struct hal_rx_ppdu_info *ppdu_info)
  870. {
  871. qdf_nbuf_t ppdu_nbuf;
  872. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  873. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  874. /*
  875. * Do not allocate if fcs error,
  876. * ast idx invalid / fctl invalid
  877. *
  878. * In CFR RCC mode - PPDU status TLVs of error pkts are also needed
  879. */
  880. if (ppdu_info->com_info.mpdu_cnt_fcs_ok == 0)
  881. return;
  882. if (ppdu_info->nac_info.fc_valid &&
  883. ppdu_info->nac_info.to_ds_flag &&
  884. ppdu_info->nac_info.mac_addr2_valid) {
  885. struct dp_neighbour_peer *peer = NULL;
  886. uint8_t rssi = ppdu_info->rx_status.rssi_comb;
  887. qdf_spin_lock_bh(&mon_pdev->neighbour_peer_mutex);
  888. if (mon_pdev->neighbour_peers_added) {
  889. TAILQ_FOREACH(peer, &mon_pdev->neighbour_peers_list,
  890. neighbour_peer_list_elem) {
  891. if (!qdf_mem_cmp(&peer->neighbour_peers_macaddr,
  892. &ppdu_info->nac_info.mac_addr2,
  893. QDF_MAC_ADDR_SIZE)) {
  894. peer->rssi = rssi;
  895. break;
  896. }
  897. }
  898. }
  899. qdf_spin_unlock_bh(&mon_pdev->neighbour_peer_mutex);
  900. } else {
  901. dp_info("Neighbour peers RSSI update failed! fc_valid = %d, to_ds_flag = %d and mac_addr2_valid = %d",
  902. ppdu_info->nac_info.fc_valid,
  903. ppdu_info->nac_info.to_ds_flag,
  904. ppdu_info->nac_info.mac_addr2_valid);
  905. }
  906. /* need not generate wdi event when mcopy, cfr rcc mode and
  907. * enhanced stats are not enabled
  908. */
  909. if (!mon_pdev->mcopy_mode && !mon_pdev->enhanced_stats_en &&
  910. !dp_cfr_rcc_mode_status(pdev))
  911. return;
  912. if (dp_cfr_rcc_mode_status(pdev))
  913. dp_update_cfr_dbg_stats(pdev, ppdu_info);
  914. if (!ppdu_info->rx_status.frame_control_info_valid ||
  915. (ppdu_info->rx_status.ast_index == HAL_AST_IDX_INVALID)) {
  916. if (!(mon_pdev->mcopy_mode ||
  917. (dp_bb_captured_chan_status(pdev, ppdu_info) ==
  918. QDF_STATUS_SUCCESS)))
  919. return;
  920. }
  921. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  922. sizeof(struct cdp_rx_indication_ppdu),
  923. 0, 0, FALSE);
  924. if (ppdu_nbuf) {
  925. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)qdf_nbuf_data(ppdu_nbuf);
  926. qdf_mem_zero(cdp_rx_ppdu, sizeof(struct cdp_rx_indication_ppdu));
  927. dp_rx_mon_populate_cfr_info(pdev, ppdu_info, cdp_rx_ppdu);
  928. dp_rx_populate_cdp_indication_ppdu(pdev,
  929. ppdu_info, cdp_rx_ppdu);
  930. if (!qdf_nbuf_put_tail(ppdu_nbuf,
  931. sizeof(struct cdp_rx_indication_ppdu)))
  932. return;
  933. dp_rx_stats_update(pdev, cdp_rx_ppdu);
  934. if (cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) {
  935. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC,
  936. soc, ppdu_nbuf,
  937. cdp_rx_ppdu->peer_id,
  938. WDI_NO_VAL, pdev->pdev_id);
  939. } else if (mon_pdev->mcopy_mode || dp_cfr_rcc_mode_status(pdev)) {
  940. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
  941. ppdu_nbuf, HTT_INVALID_PEER,
  942. WDI_NO_VAL, pdev->pdev_id);
  943. } else {
  944. qdf_nbuf_free(ppdu_nbuf);
  945. }
  946. }
  947. }
  948. #endif/* QCA_ENHANCED_STATS_SUPPORT */
  949. #ifdef QCA_MCOPY_SUPPORT
  950. QDF_STATUS
  951. dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  952. struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf,
  953. uint8_t fcs_ok_mpdu_cnt, bool deliver_frame)
  954. {
  955. uint16_t size = 0;
  956. struct ieee80211_frame *wh;
  957. uint32_t *nbuf_data;
  958. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  959. if (!ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload)
  960. return QDF_STATUS_SUCCESS;
  961. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  962. if (mon_pdev->mcopy_mode == M_COPY) {
  963. if (mon_pdev->m_copy_id.rx_ppdu_id == ppdu_info->com_info.ppdu_id)
  964. return QDF_STATUS_SUCCESS;
  965. }
  966. wh = (struct ieee80211_frame *)(ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload + 4);
  967. size = (ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload -
  968. qdf_nbuf_data(nbuf));
  969. if (qdf_nbuf_pull_head(nbuf, size) == NULL)
  970. return QDF_STATUS_SUCCESS;
  971. if (((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  972. IEEE80211_FC0_TYPE_MGT) ||
  973. ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  974. IEEE80211_FC0_TYPE_CTL)) {
  975. return QDF_STATUS_SUCCESS;
  976. }
  977. nbuf_data = (uint32_t *)qdf_nbuf_data(nbuf);
  978. *nbuf_data = mon_pdev->ppdu_info.com_info.ppdu_id;
  979. /* only retain RX MSDU payload in the skb */
  980. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) - ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].payload_len);
  981. if (deliver_frame) {
  982. mon_pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
  983. dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
  984. nbuf, HTT_INVALID_PEER,
  985. WDI_NO_VAL, pdev->pdev_id);
  986. }
  987. return QDF_STATUS_E_ALREADY;
  988. }
  989. void
  990. dp_rx_mcopy_handle_last_mpdu(struct dp_soc *soc, struct dp_pdev *pdev,
  991. struct hal_rx_ppdu_info *ppdu_info,
  992. qdf_nbuf_t status_nbuf)
  993. {
  994. QDF_STATUS mcopy_status;
  995. qdf_nbuf_t nbuf_clone = NULL;
  996. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  997. /* If the MPDU end tlv and RX header are received in different buffers,
  998. * process the RX header based on fcs status.
  999. */
  1000. if (mon_pdev->mcopy_status_nbuf) {
  1001. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  1002. if (mon_pdev->mcopy_mode == M_COPY) {
  1003. if (mon_pdev->m_copy_id.rx_ppdu_id ==
  1004. ppdu_info->com_info.ppdu_id)
  1005. goto end1;
  1006. }
  1007. if (ppdu_info->is_fcs_passed) {
  1008. nbuf_clone = qdf_nbuf_clone(mon_pdev->mcopy_status_nbuf);
  1009. if (!nbuf_clone) {
  1010. QDF_TRACE(QDF_MODULE_ID_TXRX,
  1011. QDF_TRACE_LEVEL_ERROR,
  1012. "Failed to clone nbuf");
  1013. goto end1;
  1014. }
  1015. mon_pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
  1016. dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
  1017. nbuf_clone,
  1018. HTT_INVALID_PEER,
  1019. WDI_NO_VAL, pdev->pdev_id);
  1020. ppdu_info->is_fcs_passed = false;
  1021. }
  1022. end1:
  1023. qdf_nbuf_free(mon_pdev->mcopy_status_nbuf);
  1024. mon_pdev->mcopy_status_nbuf = NULL;
  1025. }
  1026. /* If the MPDU end tlv and RX header are received in different buffers,
  1027. * preserve the RX header as the fcs status will be received in MPDU
  1028. * end tlv in next buffer. So, cache the buffer to be processd in next
  1029. * iteration
  1030. */
  1031. if ((ppdu_info->fcs_ok_cnt + ppdu_info->fcs_err_cnt) !=
  1032. ppdu_info->com_info.mpdu_cnt) {
  1033. mon_pdev->mcopy_status_nbuf = qdf_nbuf_clone(status_nbuf);
  1034. if (mon_pdev->mcopy_status_nbuf) {
  1035. mcopy_status = dp_rx_handle_mcopy_mode(
  1036. soc, pdev,
  1037. ppdu_info,
  1038. mon_pdev->mcopy_status_nbuf,
  1039. ppdu_info->fcs_ok_cnt,
  1040. false);
  1041. if (mcopy_status == QDF_STATUS_SUCCESS) {
  1042. qdf_nbuf_free(mon_pdev->mcopy_status_nbuf);
  1043. mon_pdev->mcopy_status_nbuf = NULL;
  1044. }
  1045. }
  1046. }
  1047. }
  1048. void
  1049. dp_rx_mcopy_process_ppdu_info(struct dp_pdev *pdev,
  1050. struct hal_rx_ppdu_info *ppdu_info,
  1051. uint32_t tlv_status)
  1052. {
  1053. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1054. if (!mon_pdev->mcopy_mode)
  1055. return;
  1056. /* The fcs status is received in MPDU end tlv. If the RX header
  1057. * and its MPDU end tlv are received in different status buffer then
  1058. * to process that header ppdu_info->is_fcs_passed is used.
  1059. * If end tlv is received in next status buffer then com_info.mpdu_cnt
  1060. * will be 0 at the time of receiving MPDU end tlv and we update the
  1061. * is_fcs_passed flag based on ppdu_info->fcs_err.
  1062. */
  1063. if (tlv_status != HAL_TLV_STATUS_MPDU_END)
  1064. return;
  1065. if (!ppdu_info->fcs_err) {
  1066. if (ppdu_info->fcs_ok_cnt >
  1067. HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER) {
  1068. dp_err("No. of MPDUs(%d) per status buff exceeded",
  1069. ppdu_info->fcs_ok_cnt);
  1070. return;
  1071. }
  1072. if (ppdu_info->com_info.mpdu_cnt)
  1073. ppdu_info->fcs_ok_cnt++;
  1074. else
  1075. ppdu_info->is_fcs_passed = true;
  1076. } else {
  1077. if (ppdu_info->com_info.mpdu_cnt)
  1078. ppdu_info->fcs_err_cnt++;
  1079. else
  1080. ppdu_info->is_fcs_passed = false;
  1081. }
  1082. }
  1083. void
  1084. dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  1085. struct hal_rx_ppdu_info *ppdu_info,
  1086. uint32_t tlv_status,
  1087. qdf_nbuf_t status_nbuf)
  1088. {
  1089. QDF_STATUS mcopy_status;
  1090. qdf_nbuf_t nbuf_clone = NULL;
  1091. uint8_t fcs_ok_mpdu_cnt = 0;
  1092. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1093. dp_rx_mcopy_handle_last_mpdu(soc, pdev, ppdu_info, status_nbuf);
  1094. if (qdf_unlikely(!ppdu_info->com_info.mpdu_cnt))
  1095. goto end;
  1096. if (qdf_unlikely(!ppdu_info->fcs_ok_cnt))
  1097. goto end;
  1098. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  1099. if (mon_pdev->mcopy_mode == M_COPY)
  1100. ppdu_info->fcs_ok_cnt = 1;
  1101. while (fcs_ok_mpdu_cnt < ppdu_info->fcs_ok_cnt) {
  1102. nbuf_clone = qdf_nbuf_clone(status_nbuf);
  1103. if (!nbuf_clone) {
  1104. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1105. "Failed to clone nbuf");
  1106. goto end;
  1107. }
  1108. mcopy_status = dp_rx_handle_mcopy_mode(soc, pdev,
  1109. ppdu_info,
  1110. nbuf_clone,
  1111. fcs_ok_mpdu_cnt,
  1112. true);
  1113. if (mcopy_status == QDF_STATUS_SUCCESS)
  1114. qdf_nbuf_free(nbuf_clone);
  1115. fcs_ok_mpdu_cnt++;
  1116. }
  1117. end:
  1118. qdf_nbuf_free(status_nbuf);
  1119. ppdu_info->fcs_ok_cnt = 0;
  1120. ppdu_info->fcs_err_cnt = 0;
  1121. ppdu_info->com_info.mpdu_cnt = 0;
  1122. qdf_mem_zero(&ppdu_info->ppdu_msdu_info,
  1123. HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER
  1124. * sizeof(struct hal_rx_msdu_payload_info));
  1125. }
  1126. #endif /* QCA_MCOPY_SUPPORT */
  1127. int
  1128. dp_rx_handle_smart_mesh_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  1129. struct hal_rx_ppdu_info *ppdu_info,
  1130. qdf_nbuf_t nbuf)
  1131. {
  1132. uint8_t size = 0;
  1133. struct dp_mon_vdev *mon_vdev;
  1134. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1135. if (!mon_pdev->mvdev) {
  1136. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1137. "[%s]:[%d] Monitor vdev is NULL !!",
  1138. __func__, __LINE__);
  1139. return 1;
  1140. }
  1141. mon_vdev = mon_pdev->mvdev->monitor_vdev;
  1142. if (!ppdu_info->msdu_info.first_msdu_payload) {
  1143. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1144. "[%s]:[%d] First msdu payload not present",
  1145. __func__, __LINE__);
  1146. return 1;
  1147. }
  1148. /* Adding 4 bytes to get to start of 802.11 frame after phy_ppdu_id */
  1149. size = (ppdu_info->msdu_info.first_msdu_payload -
  1150. qdf_nbuf_data(nbuf)) + 4;
  1151. ppdu_info->msdu_info.first_msdu_payload = NULL;
  1152. if (!qdf_nbuf_pull_head(nbuf, size)) {
  1153. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1154. "[%s]:[%d] No header present",
  1155. __func__, __LINE__);
  1156. return 1;
  1157. }
  1158. /* Only retain RX MSDU payload in the skb */
  1159. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
  1160. ppdu_info->msdu_info.payload_len);
  1161. if (!qdf_nbuf_update_radiotap(&mon_pdev->ppdu_info.rx_status, nbuf,
  1162. qdf_nbuf_headroom(nbuf))) {
  1163. DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
  1164. return 1;
  1165. }
  1166. mon_vdev->osif_rx_mon(mon_pdev->mvdev->osif_vdev,
  1167. nbuf, NULL);
  1168. mon_pdev->ppdu_info.rx_status.monitor_direct_used = 0;
  1169. return 0;
  1170. }
  1171. qdf_nbuf_t
  1172. dp_rx_nbuf_prepare(struct dp_soc *soc, struct dp_pdev *pdev)
  1173. {
  1174. uint8_t *buf;
  1175. int32_t nbuf_retry_count;
  1176. QDF_STATUS ret;
  1177. qdf_nbuf_t nbuf = NULL;
  1178. for (nbuf_retry_count = 0; nbuf_retry_count <
  1179. QDF_NBUF_ALLOC_MAP_RETRY_THRESHOLD;
  1180. nbuf_retry_count++) {
  1181. /* Allocate a new skb using alloc_skb */
  1182. nbuf = qdf_nbuf_alloc_no_recycler(RX_MON_STATUS_BUF_SIZE,
  1183. RX_MON_STATUS_BUF_RESERVATION,
  1184. RX_DATA_BUFFER_ALIGNMENT);
  1185. if (!nbuf) {
  1186. DP_STATS_INC(pdev, replenish.nbuf_alloc_fail, 1);
  1187. continue;
  1188. }
  1189. buf = qdf_nbuf_data(nbuf);
  1190. memset(buf, 0, RX_MON_STATUS_BUF_SIZE);
  1191. ret = qdf_nbuf_map_nbytes_single(soc->osdev, nbuf,
  1192. QDF_DMA_FROM_DEVICE,
  1193. RX_MON_STATUS_BUF_SIZE);
  1194. /* nbuf map failed */
  1195. if (qdf_unlikely(QDF_IS_STATUS_ERROR(ret))) {
  1196. qdf_nbuf_free(nbuf);
  1197. DP_STATS_INC(pdev, replenish.map_err, 1);
  1198. continue;
  1199. }
  1200. /* qdf_nbuf alloc and map succeeded */
  1201. break;
  1202. }
  1203. /* qdf_nbuf still alloc or map failed */
  1204. if (qdf_unlikely(nbuf_retry_count >=
  1205. QDF_NBUF_ALLOC_MAP_RETRY_THRESHOLD))
  1206. return NULL;
  1207. return nbuf;
  1208. }
  1209. #ifndef DISABLE_MON_CONFIG
  1210. uint32_t
  1211. dp_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  1212. uint32_t mac_id, uint32_t quota)
  1213. {
  1214. struct dp_mon_soc *mon_soc = soc->monitor_soc;
  1215. if (mon_soc && mon_soc->mon_rx_process)
  1216. return mon_soc->mon_rx_process(soc, int_ctx,
  1217. mac_id, quota);
  1218. return 0;
  1219. }
  1220. #else
  1221. uint32_t
  1222. dp_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  1223. uint32_t mac_id, uint32_t quota)
  1224. {
  1225. return 0;
  1226. }
  1227. #endif
  1228. /**
  1229. * dp_send_mgmt_packet_to_stack(): send indicataion to upper layers
  1230. *
  1231. * @soc: soc handle
  1232. * @nbuf: Mgmt packet
  1233. * @pdev: pdev handle
  1234. *
  1235. * Return: QDF_STATUS_SUCCESS on success
  1236. * QDF_STATUS_E_INVAL in error
  1237. */
  1238. #ifdef QCA_MCOPY_SUPPORT
  1239. static inline QDF_STATUS
  1240. dp_send_mgmt_packet_to_stack(struct dp_soc *soc,
  1241. qdf_nbuf_t nbuf,
  1242. struct dp_pdev *pdev)
  1243. {
  1244. uint32_t *nbuf_data;
  1245. struct ieee80211_frame *wh;
  1246. qdf_frag_t addr;
  1247. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1248. if (!nbuf)
  1249. return QDF_STATUS_E_INVAL;
  1250. /* Get addr pointing to80211 header */
  1251. addr = dp_rx_mon_get_nbuf_80211_hdr(nbuf);
  1252. if (qdf_unlikely(!addr)) {
  1253. qdf_nbuf_free(nbuf);
  1254. return QDF_STATUS_E_INVAL;
  1255. }
  1256. /*check if this is not a mgmt packet*/
  1257. wh = (struct ieee80211_frame *)addr;
  1258. if (((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=
  1259. IEEE80211_FC0_TYPE_MGT) &&
  1260. ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=
  1261. IEEE80211_FC0_TYPE_CTL)) {
  1262. qdf_nbuf_free(nbuf);
  1263. return QDF_STATUS_E_INVAL;
  1264. }
  1265. nbuf_data = (uint32_t *)qdf_nbuf_push_head(nbuf, 4);
  1266. if (!nbuf_data) {
  1267. QDF_TRACE(QDF_MODULE_ID_DP,
  1268. QDF_TRACE_LEVEL_ERROR,
  1269. FL("No headroom"));
  1270. qdf_nbuf_free(nbuf);
  1271. return QDF_STATUS_E_INVAL;
  1272. }
  1273. *nbuf_data = mon_pdev->ppdu_info.com_info.ppdu_id;
  1274. dp_wdi_event_handler(WDI_EVENT_RX_MGMT_CTRL, soc, nbuf,
  1275. HTT_INVALID_PEER,
  1276. WDI_NO_VAL, pdev->pdev_id);
  1277. return QDF_STATUS_SUCCESS;
  1278. }
  1279. #else
  1280. static inline QDF_STATUS
  1281. dp_send_mgmt_packet_to_stack(struct dp_soc *soc,
  1282. qdf_nbuf_t nbuf,
  1283. struct dp_pdev *pdev)
  1284. {
  1285. return QDF_STATUS_SUCCESS;
  1286. }
  1287. #endif /* QCA_MCOPY_SUPPORT */
  1288. QDF_STATUS dp_rx_mon_process_dest_pktlog(struct dp_soc *soc,
  1289. uint32_t mac_id,
  1290. qdf_nbuf_t mpdu)
  1291. {
  1292. uint32_t event, msdu_timestamp = 0;
  1293. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1294. void *data;
  1295. struct ieee80211_frame *wh;
  1296. uint8_t type, subtype;
  1297. struct dp_mon_pdev *mon_pdev;
  1298. if (!pdev)
  1299. return QDF_STATUS_E_INVAL;
  1300. mon_pdev = pdev->monitor_pdev;
  1301. if (mon_pdev->rx_pktlog_cbf) {
  1302. if (qdf_nbuf_get_nr_frags(mpdu))
  1303. data = qdf_nbuf_get_frag_addr(mpdu, 0);
  1304. else
  1305. data = qdf_nbuf_data(mpdu);
  1306. /* CBF logging required, doesn't matter if it is a full mode
  1307. * or lite mode.
  1308. * Need to look for mpdu with:
  1309. * TYPE = ACTION, SUBTYPE = NO ACK in the header
  1310. */
  1311. event = WDI_EVENT_RX_CBF;
  1312. wh = (struct ieee80211_frame *)data;
  1313. type = (wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
  1314. subtype = (wh)->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
  1315. if (type == IEEE80211_FC0_TYPE_MGT &&
  1316. subtype == IEEE80211_FCO_SUBTYPE_ACTION_NO_ACK) {
  1317. msdu_timestamp = mon_pdev->ppdu_info.rx_status.tsft;
  1318. dp_rx_populate_cbf_hdr(soc,
  1319. mac_id, event,
  1320. mpdu,
  1321. msdu_timestamp);
  1322. }
  1323. }
  1324. return QDF_STATUS_SUCCESS;
  1325. }
  1326. QDF_STATUS dp_rx_mon_deliver(struct dp_soc *soc, uint32_t mac_id,
  1327. qdf_nbuf_t head_msdu, qdf_nbuf_t tail_msdu)
  1328. {
  1329. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1330. struct cdp_mon_status *rs;
  1331. qdf_nbuf_t mon_skb, skb_next;
  1332. qdf_nbuf_t mon_mpdu = NULL;
  1333. struct dp_mon_vdev *mon_vdev;
  1334. struct dp_mon_pdev *mon_pdev;
  1335. if (!pdev)
  1336. goto mon_deliver_fail;
  1337. mon_pdev = pdev->monitor_pdev;
  1338. rs = &mon_pdev->rx_mon_recv_status;
  1339. if (!mon_pdev->mvdev && !mon_pdev->mcopy_mode &&
  1340. !mon_pdev->rx_pktlog_cbf)
  1341. goto mon_deliver_fail;
  1342. /* restitch mon MPDU for delivery via monitor interface */
  1343. mon_mpdu = dp_rx_mon_restitch_mpdu(soc, mac_id, head_msdu,
  1344. tail_msdu, rs);
  1345. /* If MPDU restitch fails, free buffers*/
  1346. if (!mon_mpdu) {
  1347. dp_info("MPDU restitch failed, free buffers");
  1348. goto mon_deliver_fail;
  1349. }
  1350. dp_rx_mon_process_dest_pktlog(soc, mac_id, mon_mpdu);
  1351. /* monitor vap cannot be present when mcopy is enabled
  1352. * hence same skb can be consumed
  1353. */
  1354. if (mon_pdev->mcopy_mode)
  1355. return dp_send_mgmt_packet_to_stack(soc, mon_mpdu, pdev);
  1356. if (mon_mpdu && mon_pdev->mvdev &&
  1357. mon_pdev->mvdev->osif_vdev &&
  1358. mon_pdev->mvdev->monitor_vdev &&
  1359. mon_pdev->mvdev->monitor_vdev->osif_rx_mon) {
  1360. mon_vdev = mon_pdev->mvdev->monitor_vdev;
  1361. mon_pdev->ppdu_info.rx_status.ppdu_id =
  1362. mon_pdev->ppdu_info.com_info.ppdu_id;
  1363. mon_pdev->ppdu_info.rx_status.device_id = soc->device_id;
  1364. mon_pdev->ppdu_info.rx_status.chan_noise_floor =
  1365. pdev->chan_noise_floor;
  1366. dp_handle_tx_capture(soc, pdev, mon_mpdu);
  1367. if (!qdf_nbuf_update_radiotap(&mon_pdev->ppdu_info.rx_status,
  1368. mon_mpdu,
  1369. qdf_nbuf_headroom(mon_mpdu))) {
  1370. DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
  1371. goto mon_deliver_fail;
  1372. }
  1373. dp_rx_mon_update_pf_tag_to_buf_headroom(soc, mon_mpdu);
  1374. mon_vdev->osif_rx_mon(mon_pdev->mvdev->osif_vdev,
  1375. mon_mpdu,
  1376. &mon_pdev->ppdu_info.rx_status);
  1377. } else {
  1378. dp_rx_mon_dest_debug("%pK: mon_mpdu=%pK monitor_vdev %pK osif_vdev %pK"
  1379. , soc, mon_mpdu, mon_pdev->mvdev,
  1380. (mon_pdev->mvdev ? mon_pdev->mvdev->osif_vdev
  1381. : NULL));
  1382. goto mon_deliver_fail;
  1383. }
  1384. return QDF_STATUS_SUCCESS;
  1385. mon_deliver_fail:
  1386. mon_skb = head_msdu;
  1387. while (mon_skb) {
  1388. skb_next = qdf_nbuf_next(mon_skb);
  1389. dp_rx_mon_dest_debug("%pK: [%s][%d] mon_skb=%pK len %u",
  1390. soc, __func__, __LINE__, mon_skb, mon_skb->len);
  1391. qdf_nbuf_free(mon_skb);
  1392. mon_skb = skb_next;
  1393. }
  1394. return QDF_STATUS_E_INVAL;
  1395. }
  1396. QDF_STATUS dp_rx_mon_deliver_non_std(struct dp_soc *soc,
  1397. uint32_t mac_id)
  1398. {
  1399. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1400. ol_txrx_rx_mon_fp osif_rx_mon;
  1401. qdf_nbuf_t dummy_msdu;
  1402. struct dp_mon_pdev *mon_pdev;
  1403. struct dp_mon_vdev *mon_vdev;
  1404. /* Sanity checking */
  1405. if (!pdev || !pdev->monitor_pdev)
  1406. goto mon_deliver_non_std_fail;
  1407. mon_pdev = pdev->monitor_pdev;
  1408. if (!mon_pdev->mvdev || !mon_pdev->mvdev ||
  1409. !mon_pdev->mvdev->monitor_vdev ||
  1410. !mon_pdev->mvdev->monitor_vdev->osif_rx_mon)
  1411. goto mon_deliver_non_std_fail;
  1412. mon_vdev = mon_pdev->mvdev->monitor_vdev;
  1413. /* Generate a dummy skb_buff */
  1414. osif_rx_mon = mon_vdev->osif_rx_mon;
  1415. dummy_msdu = qdf_nbuf_alloc(soc->osdev, MAX_MONITOR_HEADER,
  1416. MAX_MONITOR_HEADER, 4, FALSE);
  1417. if (!dummy_msdu)
  1418. goto allocate_dummy_msdu_fail;
  1419. qdf_nbuf_set_pktlen(dummy_msdu, 0);
  1420. qdf_nbuf_set_next(dummy_msdu, NULL);
  1421. mon_pdev->ppdu_info.rx_status.ppdu_id =
  1422. mon_pdev->ppdu_info.com_info.ppdu_id;
  1423. /* Apply the radio header to this dummy skb */
  1424. if (!qdf_nbuf_update_radiotap(&mon_pdev->ppdu_info.rx_status, dummy_msdu,
  1425. qdf_nbuf_headroom(dummy_msdu))) {
  1426. DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
  1427. qdf_nbuf_free(dummy_msdu);
  1428. goto mon_deliver_non_std_fail;
  1429. }
  1430. /* deliver to the user layer application */
  1431. osif_rx_mon(mon_pdev->mvdev->osif_vdev,
  1432. dummy_msdu, NULL);
  1433. /* Clear rx_status*/
  1434. qdf_mem_zero(&mon_pdev->ppdu_info.rx_status,
  1435. sizeof(mon_pdev->ppdu_info.rx_status));
  1436. mon_pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  1437. return QDF_STATUS_SUCCESS;
  1438. allocate_dummy_msdu_fail:
  1439. dp_rx_mon_dest_debug("%pK: mon_skb=%pK ",
  1440. soc, dummy_msdu);
  1441. mon_deliver_non_std_fail:
  1442. return QDF_STATUS_E_INVAL;
  1443. }
  1444. /**
  1445. * dp_rx_process_peer_based_pktlog() - Process Rx pktlog if peer based
  1446. * filtering enabled
  1447. * @soc: core txrx main context
  1448. * @ppdu_info: Structure for rx ppdu info
  1449. * @status_nbuf: Qdf nbuf abstraction for linux skb
  1450. * @pdev_id: mac_id/pdev_id correspondinggly for MCL and WIN
  1451. *
  1452. * Return: none
  1453. */
  1454. void
  1455. dp_rx_process_peer_based_pktlog(struct dp_soc *soc,
  1456. struct hal_rx_ppdu_info *ppdu_info,
  1457. qdf_nbuf_t status_nbuf, uint32_t pdev_id)
  1458. {
  1459. struct dp_peer *peer;
  1460. struct mon_rx_user_status *rx_user_status;
  1461. uint32_t num_users = ppdu_info->com_info.num_users;
  1462. uint16_t sw_peer_id;
  1463. /* Sanity check for num_users */
  1464. if (!num_users)
  1465. return;
  1466. qdf_assert_always(num_users <= CDP_MU_MAX_USERS);
  1467. rx_user_status = &ppdu_info->rx_user_status[num_users - 1];
  1468. sw_peer_id = rx_user_status->sw_peer_id;
  1469. peer = dp_peer_get_ref_by_id(soc, sw_peer_id,
  1470. DP_MOD_ID_RX_PPDU_STATS);
  1471. if (!peer)
  1472. return;
  1473. if ((peer->peer_id != HTT_INVALID_PEER) &&
  1474. (peer->peer_based_pktlog_filter)) {
  1475. dp_wdi_event_handler(
  1476. WDI_EVENT_RX_DESC, soc,
  1477. status_nbuf,
  1478. peer->peer_id,
  1479. WDI_NO_VAL, pdev_id);
  1480. }
  1481. dp_peer_unref_delete(peer,
  1482. DP_MOD_ID_RX_PPDU_STATS);
  1483. }