dp_rx_mon.c 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710
  1. /*
  2. * Copyright (c) 2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021,2022 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. NO_PUNCTURE,
  626. &rix,
  627. &ratecode);
  628. if (!ratekbps) {
  629. ppdu->rix = 0;
  630. ppdu->rx_ratekbps = 0;
  631. ppdu->rx_ratecode = 0;
  632. ppdu_user->rx_ratekbps = 0;
  633. return;
  634. }
  635. ppdu->rix = rix;
  636. DP_STATS_UPD(peer, rx.last_rx_rate, ratekbps);
  637. peer->stats.rx.avg_rx_rate =
  638. dp_ath_rate_lpf(peer->stats.rx.avg_rx_rate, ratekbps);
  639. ppdu_rx_rate = dp_ath_rate_out(peer->stats.rx.avg_rx_rate);
  640. DP_STATS_UPD(peer, rx.rnd_avg_rx_rate, ppdu_rx_rate);
  641. ppdu->rx_ratekbps = ratekbps;
  642. ppdu->rx_ratecode = ratecode;
  643. ppdu_user->rx_ratekbps = ratekbps;
  644. if (peer->vdev)
  645. peer->vdev->stats.rx.last_rx_rate = ratekbps;
  646. }
  647. #ifdef WLAN_FEATURE_11BE
  648. static inline uint8_t dp_get_bw_offset_frm_bw(struct dp_soc *soc,
  649. enum CMN_BW_TYPES bw)
  650. {
  651. uint8_t pkt_bw_offset;
  652. switch (bw) {
  653. case CMN_BW_20MHZ:
  654. pkt_bw_offset = PKT_BW_GAIN_20MHZ;
  655. break;
  656. case CMN_BW_40MHZ:
  657. pkt_bw_offset = PKT_BW_GAIN_40MHZ;
  658. break;
  659. case CMN_BW_80MHZ:
  660. pkt_bw_offset = PKT_BW_GAIN_80MHZ;
  661. break;
  662. case CMN_BW_160MHZ:
  663. pkt_bw_offset = PKT_BW_GAIN_160MHZ;
  664. break;
  665. case CMN_BW_320MHZ:
  666. pkt_bw_offset = PKT_BW_GAIN_320MHZ;
  667. break;
  668. default:
  669. pkt_bw_offset = 0;
  670. dp_rx_mon_status_debug("%pK: Invalid BW index = %d",
  671. soc, bw);
  672. }
  673. return pkt_bw_offset;
  674. }
  675. #else
  676. static inline uint8_t dp_get_bw_offset_frm_bw(struct dp_soc *soc,
  677. enum CMN_BW_TYPES bw)
  678. {
  679. uint8_t pkt_bw_offset;
  680. switch (bw) {
  681. case CMN_BW_20MHZ:
  682. pkt_bw_offset = PKT_BW_GAIN_20MHZ;
  683. break;
  684. case CMN_BW_40MHZ:
  685. pkt_bw_offset = PKT_BW_GAIN_40MHZ;
  686. break;
  687. case CMN_BW_80MHZ:
  688. pkt_bw_offset = PKT_BW_GAIN_80MHZ;
  689. break;
  690. case CMN_BW_160MHZ:
  691. pkt_bw_offset = PKT_BW_GAIN_160MHZ;
  692. break;
  693. default:
  694. pkt_bw_offset = 0;
  695. dp_rx_mon_status_debug("%pK: Invalid BW index = %d",
  696. soc, bw);
  697. }
  698. return pkt_bw_offset;
  699. }
  700. #endif
  701. static void dp_rx_stats_update(struct dp_pdev *pdev,
  702. struct cdp_rx_indication_ppdu *ppdu)
  703. {
  704. struct dp_soc *soc = NULL;
  705. uint8_t mcs, preamble, ac = 0, nss, ppdu_type;
  706. uint16_t num_msdu;
  707. uint8_t pkt_bw_offset;
  708. struct dp_peer *peer;
  709. struct cdp_rx_stats_ppdu_user *ppdu_user;
  710. uint32_t i;
  711. enum cdp_mu_packet_type mu_pkt_type;
  712. struct dp_mon_ops *mon_ops;
  713. if (pdev)
  714. soc = pdev->soc;
  715. else
  716. return;
  717. if (!soc || soc->process_rx_status)
  718. return;
  719. preamble = ppdu->u.preamble;
  720. ppdu_type = ppdu->u.ppdu_type;
  721. for (i = 0; i < ppdu->num_users && i < CDP_MU_MAX_USERS; i++) {
  722. peer = NULL;
  723. ppdu_user = &ppdu->user[i];
  724. peer = dp_peer_get_ref_by_id(soc, ppdu_user->peer_id,
  725. DP_MOD_ID_RX_PPDU_STATS);
  726. if (!peer)
  727. peer = pdev->invalid_peer;
  728. if ((preamble == DOT11_A) || (preamble == DOT11_B))
  729. ppdu->u.nss = 1;
  730. if (ppdu_type == HAL_RX_TYPE_SU) {
  731. mcs = ppdu->u.mcs;
  732. nss = ppdu->u.nss;
  733. } else {
  734. mcs = ppdu_user->mcs;
  735. nss = ppdu_user->nss;
  736. }
  737. num_msdu = ppdu_user->num_msdu;
  738. pkt_bw_offset = dp_get_bw_offset_frm_bw(soc, ppdu->u.bw);
  739. DP_STATS_UPD(peer, rx.snr, (ppdu->rssi + pkt_bw_offset));
  740. if (peer->stats.rx.avg_snr == CDP_INVALID_SNR)
  741. peer->stats.rx.avg_snr =
  742. CDP_SNR_IN(peer->stats.rx.snr);
  743. else
  744. CDP_SNR_UPDATE_AVG(peer->stats.rx.avg_snr,
  745. peer->stats.rx.snr);
  746. if (ppdu_type == HAL_RX_TYPE_SU) {
  747. if (nss) {
  748. DP_STATS_INC(peer, rx.nss[nss - 1], num_msdu);
  749. DP_STATS_INC(peer, rx.ppdu_nss[nss - 1], 1);
  750. }
  751. DP_STATS_INC(peer, rx.mpdu_cnt_fcs_ok,
  752. ppdu_user->mpdu_cnt_fcs_ok);
  753. DP_STATS_INC(peer, rx.mpdu_cnt_fcs_err,
  754. ppdu_user->mpdu_cnt_fcs_err);
  755. }
  756. if (ppdu_type >= HAL_RX_TYPE_MU_MIMO &&
  757. ppdu_type <= HAL_RX_TYPE_MU_OFDMA) {
  758. if (ppdu_type == HAL_RX_TYPE_MU_MIMO)
  759. mu_pkt_type = TXRX_TYPE_MU_MIMO;
  760. else
  761. mu_pkt_type = TXRX_TYPE_MU_OFDMA;
  762. if (nss) {
  763. DP_STATS_INC(peer, rx.nss[nss - 1], num_msdu);
  764. DP_STATS_INC(peer,
  765. rx.rx_mu[mu_pkt_type].ppdu_nss[nss - 1],
  766. 1);
  767. }
  768. DP_STATS_INC(peer,
  769. rx.rx_mu[mu_pkt_type].mpdu_cnt_fcs_ok,
  770. ppdu_user->mpdu_cnt_fcs_ok);
  771. DP_STATS_INC(peer,
  772. rx.rx_mu[mu_pkt_type].mpdu_cnt_fcs_err,
  773. ppdu_user->mpdu_cnt_fcs_err);
  774. }
  775. DP_STATS_INC(peer, rx.sgi_count[ppdu->u.gi], num_msdu);
  776. DP_STATS_INC(peer, rx.bw[ppdu->u.bw], num_msdu);
  777. DP_STATS_INC(peer, rx.reception_type[ppdu->u.ppdu_type],
  778. num_msdu);
  779. DP_STATS_INC(peer, rx.ppdu_cnt[ppdu->u.ppdu_type], 1);
  780. DP_STATS_INCC(peer, rx.ampdu_cnt, num_msdu,
  781. ppdu_user->is_ampdu);
  782. DP_STATS_INCC(peer, rx.non_ampdu_cnt, num_msdu,
  783. !(ppdu_user->is_ampdu));
  784. DP_STATS_UPD(peer, rx.rx_rate, mcs);
  785. DP_STATS_INCC(peer,
  786. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  787. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
  788. DP_STATS_INCC(peer,
  789. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  790. ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
  791. DP_STATS_INCC(peer,
  792. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  793. ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B)));
  794. DP_STATS_INCC(peer,
  795. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  796. ((mcs < MAX_MCS_11B) && (preamble == DOT11_B)));
  797. DP_STATS_INCC(peer,
  798. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  799. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N)));
  800. DP_STATS_INCC(peer,
  801. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  802. ((mcs < MAX_MCS_11A) && (preamble == DOT11_N)));
  803. DP_STATS_INCC(peer,
  804. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  805. ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC)));
  806. DP_STATS_INCC(peer,
  807. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  808. ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
  809. DP_STATS_INCC(peer,
  810. rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
  811. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  812. DP_STATS_INCC(peer,
  813. rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  814. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  815. DP_STATS_INCC(peer,
  816. rx.su_ax_ppdu_cnt.mcs_count[MAX_MCS - 1], 1,
  817. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX) &&
  818. (ppdu_type == HAL_RX_TYPE_SU)));
  819. DP_STATS_INCC(peer,
  820. rx.su_ax_ppdu_cnt.mcs_count[mcs], 1,
  821. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX) &&
  822. (ppdu_type == HAL_RX_TYPE_SU)));
  823. DP_STATS_INCC(peer,
  824. rx.rx_mu[TXRX_TYPE_MU_OFDMA].ppdu.mcs_count[MAX_MCS - 1],
  825. 1, ((mcs >= (MAX_MCS - 1)) &&
  826. (preamble == DOT11_AX) &&
  827. (ppdu_type == HAL_RX_TYPE_MU_OFDMA)));
  828. DP_STATS_INCC(peer,
  829. rx.rx_mu[TXRX_TYPE_MU_OFDMA].ppdu.mcs_count[mcs],
  830. 1, ((mcs < (MAX_MCS - 1)) &&
  831. (preamble == DOT11_AX) &&
  832. (ppdu_type == HAL_RX_TYPE_MU_OFDMA)));
  833. DP_STATS_INCC(peer,
  834. rx.rx_mu[TXRX_TYPE_MU_MIMO].ppdu.mcs_count[MAX_MCS - 1],
  835. 1, ((mcs >= (MAX_MCS - 1)) &&
  836. (preamble == DOT11_AX) &&
  837. (ppdu_type == HAL_RX_TYPE_MU_MIMO)));
  838. DP_STATS_INCC(peer,
  839. rx.rx_mu[TXRX_TYPE_MU_MIMO].ppdu.mcs_count[mcs],
  840. 1, ((mcs < (MAX_MCS - 1)) &&
  841. (preamble == DOT11_AX) &&
  842. (ppdu_type == HAL_RX_TYPE_MU_MIMO)));
  843. /*
  844. * If invalid TID, it could be a non-qos frame, hence do not
  845. * update any AC counters
  846. */
  847. ac = TID_TO_WME_AC(ppdu_user->tid);
  848. if (ppdu->tid != HAL_TID_INVALID)
  849. DP_STATS_INC(peer, rx.wme_ac_type[ac], num_msdu);
  850. mon_ops = dp_mon_ops_get(soc);
  851. if (mon_ops && mon_ops->mon_rx_stats_update)
  852. mon_ops->mon_rx_stats_update(peer, ppdu, ppdu_user);
  853. dp_peer_stats_notify(pdev, peer);
  854. DP_STATS_UPD(peer, rx.last_snr, (ppdu->rssi + pkt_bw_offset));
  855. dp_peer_qos_stats_notify(pdev, ppdu_user);
  856. if (peer == pdev->invalid_peer)
  857. continue;
  858. if (dp_is_subtype_data(ppdu->frame_ctrl))
  859. dp_rx_rate_stats_update(peer, ppdu, i);
  860. #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
  861. dp_wdi_event_handler(WDI_EVENT_UPDATE_DP_STATS, pdev->soc,
  862. &peer->stats, ppdu->peer_id,
  863. UPDATE_PEER_STATS, pdev->pdev_id);
  864. #endif
  865. dp_peer_unref_delete(peer, DP_MOD_ID_RX_PPDU_STATS);
  866. }
  867. }
  868. void
  869. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  870. struct hal_rx_ppdu_info *ppdu_info)
  871. {
  872. qdf_nbuf_t ppdu_nbuf;
  873. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  874. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  875. /*
  876. * Do not allocate if fcs error,
  877. * ast idx invalid / fctl invalid
  878. *
  879. * In CFR RCC mode - PPDU status TLVs of error pkts are also needed
  880. */
  881. if (ppdu_info->com_info.mpdu_cnt_fcs_ok == 0)
  882. return;
  883. if (ppdu_info->nac_info.fc_valid &&
  884. ppdu_info->nac_info.to_ds_flag &&
  885. ppdu_info->nac_info.mac_addr2_valid) {
  886. struct dp_neighbour_peer *peer = NULL;
  887. uint8_t rssi = ppdu_info->rx_status.rssi_comb;
  888. qdf_spin_lock_bh(&mon_pdev->neighbour_peer_mutex);
  889. if (mon_pdev->neighbour_peers_added) {
  890. TAILQ_FOREACH(peer, &mon_pdev->neighbour_peers_list,
  891. neighbour_peer_list_elem) {
  892. if (!qdf_mem_cmp(&peer->neighbour_peers_macaddr,
  893. &ppdu_info->nac_info.mac_addr2,
  894. QDF_MAC_ADDR_SIZE)) {
  895. peer->rssi = rssi;
  896. break;
  897. }
  898. }
  899. }
  900. qdf_spin_unlock_bh(&mon_pdev->neighbour_peer_mutex);
  901. } else {
  902. dp_info("Neighbour peers RSSI update failed! fc_valid = %d, to_ds_flag = %d and mac_addr2_valid = %d",
  903. ppdu_info->nac_info.fc_valid,
  904. ppdu_info->nac_info.to_ds_flag,
  905. ppdu_info->nac_info.mac_addr2_valid);
  906. }
  907. /* need not generate wdi event when mcopy, cfr rcc mode and
  908. * enhanced stats are not enabled
  909. */
  910. if (!mon_pdev->mcopy_mode && !mon_pdev->enhanced_stats_en &&
  911. !dp_cfr_rcc_mode_status(pdev))
  912. return;
  913. if (dp_cfr_rcc_mode_status(pdev))
  914. dp_update_cfr_dbg_stats(pdev, ppdu_info);
  915. if (!ppdu_info->rx_status.frame_control_info_valid ||
  916. (ppdu_info->rx_status.ast_index == HAL_AST_IDX_INVALID)) {
  917. if (!(mon_pdev->mcopy_mode ||
  918. (dp_bb_captured_chan_status(pdev, ppdu_info) ==
  919. QDF_STATUS_SUCCESS)))
  920. return;
  921. }
  922. ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
  923. sizeof(struct cdp_rx_indication_ppdu),
  924. 0, 0, FALSE);
  925. if (ppdu_nbuf) {
  926. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)qdf_nbuf_data(ppdu_nbuf);
  927. qdf_mem_zero(cdp_rx_ppdu, sizeof(struct cdp_rx_indication_ppdu));
  928. dp_rx_mon_populate_cfr_info(pdev, ppdu_info, cdp_rx_ppdu);
  929. dp_rx_populate_cdp_indication_ppdu(pdev,
  930. ppdu_info, cdp_rx_ppdu);
  931. if (!qdf_nbuf_put_tail(ppdu_nbuf,
  932. sizeof(struct cdp_rx_indication_ppdu)))
  933. return;
  934. dp_rx_stats_update(pdev, cdp_rx_ppdu);
  935. if (cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) {
  936. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC,
  937. soc, ppdu_nbuf,
  938. cdp_rx_ppdu->peer_id,
  939. WDI_NO_VAL, pdev->pdev_id);
  940. } else if (mon_pdev->mcopy_mode || dp_cfr_rcc_mode_status(pdev)) {
  941. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
  942. ppdu_nbuf, HTT_INVALID_PEER,
  943. WDI_NO_VAL, pdev->pdev_id);
  944. } else {
  945. qdf_nbuf_free(ppdu_nbuf);
  946. }
  947. }
  948. }
  949. #endif/* QCA_ENHANCED_STATS_SUPPORT */
  950. #ifdef QCA_MCOPY_SUPPORT
  951. QDF_STATUS
  952. dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  953. struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf,
  954. uint8_t fcs_ok_mpdu_cnt, bool deliver_frame)
  955. {
  956. uint16_t size = 0;
  957. struct ieee80211_frame *wh;
  958. uint32_t *nbuf_data;
  959. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  960. if (!ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload)
  961. return QDF_STATUS_SUCCESS;
  962. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  963. if (mon_pdev->mcopy_mode == M_COPY) {
  964. if (mon_pdev->m_copy_id.rx_ppdu_id == ppdu_info->com_info.ppdu_id)
  965. return QDF_STATUS_SUCCESS;
  966. }
  967. wh = (struct ieee80211_frame *)(ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload + 4);
  968. size = (ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].first_msdu_payload -
  969. qdf_nbuf_data(nbuf));
  970. if (qdf_nbuf_pull_head(nbuf, size) == NULL)
  971. return QDF_STATUS_SUCCESS;
  972. if (((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  973. IEEE80211_FC0_TYPE_MGT) ||
  974. ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
  975. IEEE80211_FC0_TYPE_CTL)) {
  976. return QDF_STATUS_SUCCESS;
  977. }
  978. nbuf_data = (uint32_t *)qdf_nbuf_data(nbuf);
  979. *nbuf_data = mon_pdev->ppdu_info.com_info.ppdu_id;
  980. /* only retain RX MSDU payload in the skb */
  981. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) - ppdu_info->ppdu_msdu_info[fcs_ok_mpdu_cnt].payload_len);
  982. if (deliver_frame) {
  983. mon_pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
  984. dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
  985. nbuf, HTT_INVALID_PEER,
  986. WDI_NO_VAL, pdev->pdev_id);
  987. }
  988. return QDF_STATUS_E_ALREADY;
  989. }
  990. void
  991. dp_rx_mcopy_handle_last_mpdu(struct dp_soc *soc, struct dp_pdev *pdev,
  992. struct hal_rx_ppdu_info *ppdu_info,
  993. qdf_nbuf_t status_nbuf)
  994. {
  995. QDF_STATUS mcopy_status;
  996. qdf_nbuf_t nbuf_clone = NULL;
  997. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  998. /* If the MPDU end tlv and RX header are received in different buffers,
  999. * process the RX header based on fcs status.
  1000. */
  1001. if (mon_pdev->mcopy_status_nbuf) {
  1002. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  1003. if (mon_pdev->mcopy_mode == M_COPY) {
  1004. if (mon_pdev->m_copy_id.rx_ppdu_id ==
  1005. ppdu_info->com_info.ppdu_id)
  1006. goto end1;
  1007. }
  1008. if (ppdu_info->is_fcs_passed) {
  1009. nbuf_clone = qdf_nbuf_clone(mon_pdev->mcopy_status_nbuf);
  1010. if (!nbuf_clone) {
  1011. QDF_TRACE(QDF_MODULE_ID_TXRX,
  1012. QDF_TRACE_LEVEL_ERROR,
  1013. "Failed to clone nbuf");
  1014. goto end1;
  1015. }
  1016. mon_pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
  1017. dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
  1018. nbuf_clone,
  1019. HTT_INVALID_PEER,
  1020. WDI_NO_VAL, pdev->pdev_id);
  1021. ppdu_info->is_fcs_passed = false;
  1022. }
  1023. end1:
  1024. qdf_nbuf_free(mon_pdev->mcopy_status_nbuf);
  1025. mon_pdev->mcopy_status_nbuf = NULL;
  1026. }
  1027. /* If the MPDU end tlv and RX header are received in different buffers,
  1028. * preserve the RX header as the fcs status will be received in MPDU
  1029. * end tlv in next buffer. So, cache the buffer to be processd in next
  1030. * iteration
  1031. */
  1032. if ((ppdu_info->fcs_ok_cnt + ppdu_info->fcs_err_cnt) !=
  1033. ppdu_info->com_info.mpdu_cnt) {
  1034. mon_pdev->mcopy_status_nbuf = qdf_nbuf_clone(status_nbuf);
  1035. if (mon_pdev->mcopy_status_nbuf) {
  1036. mcopy_status = dp_rx_handle_mcopy_mode(
  1037. soc, pdev,
  1038. ppdu_info,
  1039. mon_pdev->mcopy_status_nbuf,
  1040. ppdu_info->fcs_ok_cnt,
  1041. false);
  1042. if (mcopy_status == QDF_STATUS_SUCCESS) {
  1043. qdf_nbuf_free(mon_pdev->mcopy_status_nbuf);
  1044. mon_pdev->mcopy_status_nbuf = NULL;
  1045. }
  1046. }
  1047. }
  1048. }
  1049. void
  1050. dp_rx_mcopy_process_ppdu_info(struct dp_pdev *pdev,
  1051. struct hal_rx_ppdu_info *ppdu_info,
  1052. uint32_t tlv_status)
  1053. {
  1054. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1055. if (!mon_pdev->mcopy_mode)
  1056. return;
  1057. /* The fcs status is received in MPDU end tlv. If the RX header
  1058. * and its MPDU end tlv are received in different status buffer then
  1059. * to process that header ppdu_info->is_fcs_passed is used.
  1060. * If end tlv is received in next status buffer then com_info.mpdu_cnt
  1061. * will be 0 at the time of receiving MPDU end tlv and we update the
  1062. * is_fcs_passed flag based on ppdu_info->fcs_err.
  1063. */
  1064. if (tlv_status != HAL_TLV_STATUS_MPDU_END)
  1065. return;
  1066. if (!ppdu_info->fcs_err) {
  1067. if (ppdu_info->fcs_ok_cnt >
  1068. HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER) {
  1069. dp_err("No. of MPDUs(%d) per status buff exceeded",
  1070. ppdu_info->fcs_ok_cnt);
  1071. return;
  1072. }
  1073. if (ppdu_info->com_info.mpdu_cnt)
  1074. ppdu_info->fcs_ok_cnt++;
  1075. else
  1076. ppdu_info->is_fcs_passed = true;
  1077. } else {
  1078. if (ppdu_info->com_info.mpdu_cnt)
  1079. ppdu_info->fcs_err_cnt++;
  1080. else
  1081. ppdu_info->is_fcs_passed = false;
  1082. }
  1083. }
  1084. void
  1085. dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  1086. struct hal_rx_ppdu_info *ppdu_info,
  1087. uint32_t tlv_status,
  1088. qdf_nbuf_t status_nbuf)
  1089. {
  1090. QDF_STATUS mcopy_status;
  1091. qdf_nbuf_t nbuf_clone = NULL;
  1092. uint8_t fcs_ok_mpdu_cnt = 0;
  1093. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1094. dp_rx_mcopy_handle_last_mpdu(soc, pdev, ppdu_info, status_nbuf);
  1095. if (qdf_unlikely(!ppdu_info->com_info.mpdu_cnt))
  1096. goto end;
  1097. if (qdf_unlikely(!ppdu_info->fcs_ok_cnt))
  1098. goto end;
  1099. /* For M_COPY mode only one msdu per ppdu is sent to upper layer*/
  1100. if (mon_pdev->mcopy_mode == M_COPY)
  1101. ppdu_info->fcs_ok_cnt = 1;
  1102. while (fcs_ok_mpdu_cnt < ppdu_info->fcs_ok_cnt) {
  1103. nbuf_clone = qdf_nbuf_clone(status_nbuf);
  1104. if (!nbuf_clone) {
  1105. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1106. "Failed to clone nbuf");
  1107. goto end;
  1108. }
  1109. mcopy_status = dp_rx_handle_mcopy_mode(soc, pdev,
  1110. ppdu_info,
  1111. nbuf_clone,
  1112. fcs_ok_mpdu_cnt,
  1113. true);
  1114. if (mcopy_status == QDF_STATUS_SUCCESS)
  1115. qdf_nbuf_free(nbuf_clone);
  1116. fcs_ok_mpdu_cnt++;
  1117. }
  1118. end:
  1119. qdf_nbuf_free(status_nbuf);
  1120. ppdu_info->fcs_ok_cnt = 0;
  1121. ppdu_info->fcs_err_cnt = 0;
  1122. ppdu_info->com_info.mpdu_cnt = 0;
  1123. qdf_mem_zero(&ppdu_info->ppdu_msdu_info,
  1124. HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER
  1125. * sizeof(struct hal_rx_msdu_payload_info));
  1126. }
  1127. #endif /* QCA_MCOPY_SUPPORT */
  1128. int
  1129. dp_rx_handle_smart_mesh_mode(struct dp_soc *soc, struct dp_pdev *pdev,
  1130. struct hal_rx_ppdu_info *ppdu_info,
  1131. qdf_nbuf_t nbuf)
  1132. {
  1133. uint8_t size = 0;
  1134. struct dp_mon_vdev *mon_vdev;
  1135. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1136. if (!mon_pdev->mvdev) {
  1137. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1138. "[%s]:[%d] Monitor vdev is NULL !!",
  1139. __func__, __LINE__);
  1140. return 1;
  1141. }
  1142. mon_vdev = mon_pdev->mvdev->monitor_vdev;
  1143. if (!ppdu_info->msdu_info.first_msdu_payload) {
  1144. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1145. "[%s]:[%d] First msdu payload not present",
  1146. __func__, __LINE__);
  1147. return 1;
  1148. }
  1149. /* Adding 4 bytes to get to start of 802.11 frame after phy_ppdu_id */
  1150. size = (ppdu_info->msdu_info.first_msdu_payload -
  1151. qdf_nbuf_data(nbuf)) + 4;
  1152. ppdu_info->msdu_info.first_msdu_payload = NULL;
  1153. if (!qdf_nbuf_pull_head(nbuf, size)) {
  1154. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1155. "[%s]:[%d] No header present",
  1156. __func__, __LINE__);
  1157. return 1;
  1158. }
  1159. /* Only retain RX MSDU payload in the skb */
  1160. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
  1161. ppdu_info->msdu_info.payload_len);
  1162. if (!qdf_nbuf_update_radiotap(&mon_pdev->ppdu_info.rx_status, nbuf,
  1163. qdf_nbuf_headroom(nbuf))) {
  1164. DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
  1165. return 1;
  1166. }
  1167. mon_vdev->osif_rx_mon(mon_pdev->mvdev->osif_vdev,
  1168. nbuf, NULL);
  1169. mon_pdev->ppdu_info.rx_status.monitor_direct_used = 0;
  1170. return 0;
  1171. }
  1172. qdf_nbuf_t
  1173. dp_rx_nbuf_prepare(struct dp_soc *soc, struct dp_pdev *pdev)
  1174. {
  1175. uint8_t *buf;
  1176. int32_t nbuf_retry_count;
  1177. QDF_STATUS ret;
  1178. qdf_nbuf_t nbuf = NULL;
  1179. for (nbuf_retry_count = 0; nbuf_retry_count <
  1180. QDF_NBUF_ALLOC_MAP_RETRY_THRESHOLD;
  1181. nbuf_retry_count++) {
  1182. /* Allocate a new skb using alloc_skb */
  1183. nbuf = qdf_nbuf_alloc_no_recycler(RX_MON_STATUS_BUF_SIZE,
  1184. RX_MON_STATUS_BUF_RESERVATION,
  1185. RX_DATA_BUFFER_ALIGNMENT);
  1186. if (!nbuf) {
  1187. DP_STATS_INC(pdev, replenish.nbuf_alloc_fail, 1);
  1188. continue;
  1189. }
  1190. buf = qdf_nbuf_data(nbuf);
  1191. memset(buf, 0, RX_MON_STATUS_BUF_SIZE);
  1192. ret = qdf_nbuf_map_nbytes_single(soc->osdev, nbuf,
  1193. QDF_DMA_FROM_DEVICE,
  1194. RX_MON_STATUS_BUF_SIZE);
  1195. /* nbuf map failed */
  1196. if (qdf_unlikely(QDF_IS_STATUS_ERROR(ret))) {
  1197. qdf_nbuf_free(nbuf);
  1198. DP_STATS_INC(pdev, replenish.map_err, 1);
  1199. continue;
  1200. }
  1201. /* qdf_nbuf alloc and map succeeded */
  1202. break;
  1203. }
  1204. /* qdf_nbuf still alloc or map failed */
  1205. if (qdf_unlikely(nbuf_retry_count >=
  1206. QDF_NBUF_ALLOC_MAP_RETRY_THRESHOLD))
  1207. return NULL;
  1208. return nbuf;
  1209. }
  1210. #ifndef DISABLE_MON_CONFIG
  1211. uint32_t
  1212. dp_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  1213. uint32_t mac_id, uint32_t quota)
  1214. {
  1215. struct dp_mon_soc *mon_soc = soc->monitor_soc;
  1216. if (mon_soc && mon_soc->mon_rx_process)
  1217. return mon_soc->mon_rx_process(soc, int_ctx,
  1218. mac_id, quota);
  1219. return 0;
  1220. }
  1221. #else
  1222. uint32_t
  1223. dp_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  1224. uint32_t mac_id, uint32_t quota)
  1225. {
  1226. return 0;
  1227. }
  1228. #endif
  1229. /**
  1230. * dp_send_mgmt_packet_to_stack(): send indicataion to upper layers
  1231. *
  1232. * @soc: soc handle
  1233. * @nbuf: Mgmt packet
  1234. * @pdev: pdev handle
  1235. *
  1236. * Return: QDF_STATUS_SUCCESS on success
  1237. * QDF_STATUS_E_INVAL in error
  1238. */
  1239. #ifdef QCA_MCOPY_SUPPORT
  1240. static inline QDF_STATUS
  1241. dp_send_mgmt_packet_to_stack(struct dp_soc *soc,
  1242. qdf_nbuf_t nbuf,
  1243. struct dp_pdev *pdev)
  1244. {
  1245. uint32_t *nbuf_data;
  1246. struct ieee80211_frame *wh;
  1247. qdf_frag_t addr;
  1248. struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
  1249. if (!nbuf)
  1250. return QDF_STATUS_E_INVAL;
  1251. /* Get addr pointing to80211 header */
  1252. addr = dp_rx_mon_get_nbuf_80211_hdr(nbuf);
  1253. if (qdf_unlikely(!addr)) {
  1254. qdf_nbuf_free(nbuf);
  1255. return QDF_STATUS_E_INVAL;
  1256. }
  1257. /*check if this is not a mgmt packet*/
  1258. wh = (struct ieee80211_frame *)addr;
  1259. if (((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=
  1260. IEEE80211_FC0_TYPE_MGT) &&
  1261. ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=
  1262. IEEE80211_FC0_TYPE_CTL)) {
  1263. qdf_nbuf_free(nbuf);
  1264. return QDF_STATUS_E_INVAL;
  1265. }
  1266. nbuf_data = (uint32_t *)qdf_nbuf_push_head(nbuf, 4);
  1267. if (!nbuf_data) {
  1268. QDF_TRACE(QDF_MODULE_ID_DP,
  1269. QDF_TRACE_LEVEL_ERROR,
  1270. FL("No headroom"));
  1271. qdf_nbuf_free(nbuf);
  1272. return QDF_STATUS_E_INVAL;
  1273. }
  1274. *nbuf_data = mon_pdev->ppdu_info.com_info.ppdu_id;
  1275. dp_wdi_event_handler(WDI_EVENT_RX_MGMT_CTRL, soc, nbuf,
  1276. HTT_INVALID_PEER,
  1277. WDI_NO_VAL, pdev->pdev_id);
  1278. return QDF_STATUS_SUCCESS;
  1279. }
  1280. #else
  1281. static inline QDF_STATUS
  1282. dp_send_mgmt_packet_to_stack(struct dp_soc *soc,
  1283. qdf_nbuf_t nbuf,
  1284. struct dp_pdev *pdev)
  1285. {
  1286. return QDF_STATUS_SUCCESS;
  1287. }
  1288. #endif /* QCA_MCOPY_SUPPORT */
  1289. QDF_STATUS dp_rx_mon_process_dest_pktlog(struct dp_soc *soc,
  1290. uint32_t mac_id,
  1291. qdf_nbuf_t mpdu)
  1292. {
  1293. uint32_t event, msdu_timestamp = 0;
  1294. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1295. void *data;
  1296. struct ieee80211_frame *wh;
  1297. uint8_t type, subtype;
  1298. struct dp_mon_pdev *mon_pdev;
  1299. if (!pdev)
  1300. return QDF_STATUS_E_INVAL;
  1301. mon_pdev = pdev->monitor_pdev;
  1302. if (mon_pdev->rx_pktlog_cbf) {
  1303. if (qdf_nbuf_get_nr_frags(mpdu))
  1304. data = qdf_nbuf_get_frag_addr(mpdu, 0);
  1305. else
  1306. data = qdf_nbuf_data(mpdu);
  1307. /* CBF logging required, doesn't matter if it is a full mode
  1308. * or lite mode.
  1309. * Need to look for mpdu with:
  1310. * TYPE = ACTION, SUBTYPE = NO ACK in the header
  1311. */
  1312. event = WDI_EVENT_RX_CBF;
  1313. wh = (struct ieee80211_frame *)data;
  1314. type = (wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
  1315. subtype = (wh)->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
  1316. if (type == IEEE80211_FC0_TYPE_MGT &&
  1317. subtype == IEEE80211_FCO_SUBTYPE_ACTION_NO_ACK) {
  1318. msdu_timestamp = mon_pdev->ppdu_info.rx_status.tsft;
  1319. dp_rx_populate_cbf_hdr(soc,
  1320. mac_id, event,
  1321. mpdu,
  1322. msdu_timestamp);
  1323. }
  1324. }
  1325. return QDF_STATUS_SUCCESS;
  1326. }
  1327. QDF_STATUS dp_rx_mon_deliver(struct dp_soc *soc, uint32_t mac_id,
  1328. qdf_nbuf_t head_msdu, qdf_nbuf_t tail_msdu)
  1329. {
  1330. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1331. struct cdp_mon_status *rs;
  1332. qdf_nbuf_t mon_skb, skb_next;
  1333. qdf_nbuf_t mon_mpdu = NULL;
  1334. struct dp_mon_vdev *mon_vdev;
  1335. struct dp_mon_pdev *mon_pdev;
  1336. if (!pdev)
  1337. goto mon_deliver_fail;
  1338. mon_pdev = pdev->monitor_pdev;
  1339. rs = &mon_pdev->rx_mon_recv_status;
  1340. if (!mon_pdev->mvdev && !mon_pdev->mcopy_mode &&
  1341. !mon_pdev->rx_pktlog_cbf)
  1342. goto mon_deliver_fail;
  1343. /* restitch mon MPDU for delivery via monitor interface */
  1344. mon_mpdu = dp_rx_mon_restitch_mpdu(soc, mac_id, head_msdu,
  1345. tail_msdu, rs);
  1346. /* If MPDU restitch fails, free buffers*/
  1347. if (!mon_mpdu) {
  1348. dp_info("MPDU restitch failed, free buffers");
  1349. goto mon_deliver_fail;
  1350. }
  1351. dp_rx_mon_process_dest_pktlog(soc, mac_id, mon_mpdu);
  1352. /* monitor vap cannot be present when mcopy is enabled
  1353. * hence same skb can be consumed
  1354. */
  1355. if (mon_pdev->mcopy_mode)
  1356. return dp_send_mgmt_packet_to_stack(soc, mon_mpdu, pdev);
  1357. if (mon_mpdu && mon_pdev->mvdev &&
  1358. mon_pdev->mvdev->osif_vdev &&
  1359. mon_pdev->mvdev->monitor_vdev &&
  1360. mon_pdev->mvdev->monitor_vdev->osif_rx_mon) {
  1361. mon_vdev = mon_pdev->mvdev->monitor_vdev;
  1362. mon_pdev->ppdu_info.rx_status.ppdu_id =
  1363. mon_pdev->ppdu_info.com_info.ppdu_id;
  1364. mon_pdev->ppdu_info.rx_status.device_id = soc->device_id;
  1365. mon_pdev->ppdu_info.rx_status.chan_noise_floor =
  1366. pdev->chan_noise_floor;
  1367. dp_handle_tx_capture(soc, pdev, mon_mpdu);
  1368. if (!qdf_nbuf_update_radiotap(&mon_pdev->ppdu_info.rx_status,
  1369. mon_mpdu,
  1370. qdf_nbuf_headroom(mon_mpdu))) {
  1371. DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
  1372. goto mon_deliver_fail;
  1373. }
  1374. dp_rx_mon_update_pf_tag_to_buf_headroom(soc, mon_mpdu);
  1375. mon_vdev->osif_rx_mon(mon_pdev->mvdev->osif_vdev,
  1376. mon_mpdu,
  1377. &mon_pdev->ppdu_info.rx_status);
  1378. } else {
  1379. dp_rx_mon_dest_debug("%pK: mon_mpdu=%pK monitor_vdev %pK osif_vdev %pK"
  1380. , soc, mon_mpdu, mon_pdev->mvdev,
  1381. (mon_pdev->mvdev ? mon_pdev->mvdev->osif_vdev
  1382. : NULL));
  1383. goto mon_deliver_fail;
  1384. }
  1385. return QDF_STATUS_SUCCESS;
  1386. mon_deliver_fail:
  1387. mon_skb = head_msdu;
  1388. while (mon_skb) {
  1389. skb_next = qdf_nbuf_next(mon_skb);
  1390. dp_rx_mon_dest_debug("%pK: [%s][%d] mon_skb=%pK len %u",
  1391. soc, __func__, __LINE__, mon_skb, mon_skb->len);
  1392. qdf_nbuf_free(mon_skb);
  1393. mon_skb = skb_next;
  1394. }
  1395. return QDF_STATUS_E_INVAL;
  1396. }
  1397. QDF_STATUS dp_rx_mon_deliver_non_std(struct dp_soc *soc,
  1398. uint32_t mac_id)
  1399. {
  1400. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  1401. ol_txrx_rx_mon_fp osif_rx_mon;
  1402. qdf_nbuf_t dummy_msdu;
  1403. struct dp_mon_pdev *mon_pdev;
  1404. struct dp_mon_vdev *mon_vdev;
  1405. /* Sanity checking */
  1406. if (!pdev || !pdev->monitor_pdev)
  1407. goto mon_deliver_non_std_fail;
  1408. mon_pdev = pdev->monitor_pdev;
  1409. if (!mon_pdev->mvdev || !mon_pdev->mvdev ||
  1410. !mon_pdev->mvdev->monitor_vdev ||
  1411. !mon_pdev->mvdev->monitor_vdev->osif_rx_mon)
  1412. goto mon_deliver_non_std_fail;
  1413. mon_vdev = mon_pdev->mvdev->monitor_vdev;
  1414. /* Generate a dummy skb_buff */
  1415. osif_rx_mon = mon_vdev->osif_rx_mon;
  1416. dummy_msdu = qdf_nbuf_alloc(soc->osdev, MAX_MONITOR_HEADER,
  1417. MAX_MONITOR_HEADER, 4, FALSE);
  1418. if (!dummy_msdu)
  1419. goto allocate_dummy_msdu_fail;
  1420. qdf_nbuf_set_pktlen(dummy_msdu, 0);
  1421. qdf_nbuf_set_next(dummy_msdu, NULL);
  1422. mon_pdev->ppdu_info.rx_status.ppdu_id =
  1423. mon_pdev->ppdu_info.com_info.ppdu_id;
  1424. /* Apply the radio header to this dummy skb */
  1425. if (!qdf_nbuf_update_radiotap(&mon_pdev->ppdu_info.rx_status, dummy_msdu,
  1426. qdf_nbuf_headroom(dummy_msdu))) {
  1427. DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
  1428. qdf_nbuf_free(dummy_msdu);
  1429. goto mon_deliver_non_std_fail;
  1430. }
  1431. /* deliver to the user layer application */
  1432. osif_rx_mon(mon_pdev->mvdev->osif_vdev,
  1433. dummy_msdu, NULL);
  1434. /* Clear rx_status*/
  1435. qdf_mem_zero(&mon_pdev->ppdu_info.rx_status,
  1436. sizeof(mon_pdev->ppdu_info.rx_status));
  1437. mon_pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  1438. return QDF_STATUS_SUCCESS;
  1439. allocate_dummy_msdu_fail:
  1440. dp_rx_mon_dest_debug("%pK: mon_skb=%pK ",
  1441. soc, dummy_msdu);
  1442. mon_deliver_non_std_fail:
  1443. return QDF_STATUS_E_INVAL;
  1444. }
  1445. /**
  1446. * dp_rx_process_peer_based_pktlog() - Process Rx pktlog if peer based
  1447. * filtering enabled
  1448. * @soc: core txrx main context
  1449. * @ppdu_info: Structure for rx ppdu info
  1450. * @status_nbuf: Qdf nbuf abstraction for linux skb
  1451. * @pdev_id: mac_id/pdev_id correspondinggly for MCL and WIN
  1452. *
  1453. * Return: none
  1454. */
  1455. void
  1456. dp_rx_process_peer_based_pktlog(struct dp_soc *soc,
  1457. struct hal_rx_ppdu_info *ppdu_info,
  1458. qdf_nbuf_t status_nbuf, uint32_t pdev_id)
  1459. {
  1460. struct dp_peer *peer;
  1461. struct mon_rx_user_status *rx_user_status;
  1462. uint32_t num_users = ppdu_info->com_info.num_users;
  1463. uint16_t sw_peer_id;
  1464. /* Sanity check for num_users */
  1465. if (!num_users)
  1466. return;
  1467. qdf_assert_always(num_users <= CDP_MU_MAX_USERS);
  1468. rx_user_status = &ppdu_info->rx_user_status[num_users - 1];
  1469. sw_peer_id = rx_user_status->sw_peer_id;
  1470. peer = dp_peer_get_ref_by_id(soc, sw_peer_id,
  1471. DP_MOD_ID_RX_PPDU_STATS);
  1472. if (!peer)
  1473. return;
  1474. if ((peer->peer_id != HTT_INVALID_PEER) &&
  1475. (peer->peer_based_pktlog_filter)) {
  1476. dp_wdi_event_handler(
  1477. WDI_EVENT_RX_DESC, soc,
  1478. status_nbuf,
  1479. peer->peer_id,
  1480. WDI_NO_VAL, pdev_id);
  1481. }
  1482. dp_peer_unref_delete(peer,
  1483. DP_MOD_ID_RX_PPDU_STATS);
  1484. }