dp_rx_mon.c 43 KB

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