dp_rx_mon.c 47 KB

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