hal_be_generic_api.h 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #ifndef _HAL_BE_GENERIC_API_H_
  20. #define _HAL_BE_GENERIC_API_H_
  21. #include <hal_be_hw_headers.h>
  22. #include "hal_be_tx.h"
  23. #include "hal_be_reo.h"
  24. #include <hal_api_mon.h>
  25. #include <hal_generic_api.h>
  26. #include <hal_be_api_mon.h>
  27. /**
  28. * hal_tx_comp_get_status() - TQM Release reason
  29. * @hal_desc: completion ring Tx status
  30. *
  31. * This function will parse the WBM completion descriptor and populate in
  32. * HAL structure
  33. *
  34. * Return: none
  35. */
  36. static inline void
  37. hal_tx_comp_get_status_generic_be(void *desc, void *ts1,
  38. struct hal_soc *hal)
  39. {
  40. uint8_t rate_stats_valid = 0;
  41. uint32_t rate_stats = 0;
  42. struct hal_tx_completion_status *ts =
  43. (struct hal_tx_completion_status *)ts1;
  44. ts->ppdu_id = HAL_TX_DESC_GET(desc, WBM2SW_COMPLETION_RING_TX,
  45. TQM_STATUS_NUMBER);
  46. ts->ack_frame_rssi = HAL_TX_DESC_GET(desc, WBM2SW_COMPLETION_RING_TX,
  47. ACK_FRAME_RSSI);
  48. ts->first_msdu = HAL_TX_DESC_GET(desc, WBM2SW_COMPLETION_RING_TX,
  49. FIRST_MSDU);
  50. ts->last_msdu = HAL_TX_DESC_GET(desc, WBM2SW_COMPLETION_RING_TX,
  51. LAST_MSDU);
  52. #if 0
  53. // TODO - This has to be calculated form first and last msdu
  54. ts->msdu_part_of_amsdu = HAL_TX_DESC_GET(desc,
  55. WBM2SW_COMPLETION_RING_TX,
  56. MSDU_PART_OF_AMSDU);
  57. #endif
  58. ts->peer_id = HAL_TX_DESC_GET(desc, WBM2SW_COMPLETION_RING_TX,
  59. SW_PEER_ID);
  60. ts->tid = HAL_TX_DESC_GET(desc, WBM2SW_COMPLETION_RING_TX, TID);
  61. ts->transmit_cnt = HAL_TX_DESC_GET(desc, WBM2SW_COMPLETION_RING_TX,
  62. TRANSMIT_COUNT);
  63. rate_stats = HAL_TX_DESC_GET(desc, HAL_TX_COMP, TX_RATE_STATS);
  64. rate_stats_valid = HAL_TX_MS(TX_RATE_STATS_INFO,
  65. TX_RATE_STATS_INFO_VALID, rate_stats);
  66. ts->valid = rate_stats_valid;
  67. if (rate_stats_valid) {
  68. ts->bw = HAL_TX_MS(TX_RATE_STATS_INFO, TRANSMIT_BW,
  69. rate_stats);
  70. ts->pkt_type = HAL_TX_MS(TX_RATE_STATS_INFO,
  71. TRANSMIT_PKT_TYPE, rate_stats);
  72. ts->stbc = HAL_TX_MS(TX_RATE_STATS_INFO,
  73. TRANSMIT_STBC, rate_stats);
  74. ts->ldpc = HAL_TX_MS(TX_RATE_STATS_INFO, TRANSMIT_LDPC,
  75. rate_stats);
  76. ts->sgi = HAL_TX_MS(TX_RATE_STATS_INFO, TRANSMIT_SGI,
  77. rate_stats);
  78. ts->mcs = HAL_TX_MS(TX_RATE_STATS_INFO, TRANSMIT_MCS,
  79. rate_stats);
  80. ts->ofdma = HAL_TX_MS(TX_RATE_STATS_INFO, OFDMA_TRANSMISSION,
  81. rate_stats);
  82. ts->tones_in_ru = HAL_TX_MS(TX_RATE_STATS_INFO, TONES_IN_RU,
  83. rate_stats);
  84. }
  85. ts->release_src = hal_tx_comp_get_buffer_source_generic_be(desc);
  86. ts->status = hal_tx_comp_get_release_reason(
  87. desc,
  88. hal_soc_to_hal_soc_handle(hal));
  89. ts->tsf = HAL_TX_DESC_GET(desc, UNIFIED_WBM_RELEASE_RING_6,
  90. TX_RATE_STATS_INFO_TX_RATE_STATS);
  91. }
  92. #if defined(QCA_WIFI_QCA6290_11AX_MU_UL) && defined(QCA_WIFI_QCA6290_11AX)
  93. /**
  94. * hal_rx_handle_other_tlvs() - handle special TLVs like MU_UL
  95. * tlv_tag: Taf of the TLVs
  96. * rx_tlv: the pointer to the TLVs
  97. * @ppdu_info: pointer to ppdu_info
  98. *
  99. * Return: true if the tlv is handled, false if not
  100. */
  101. static inline bool
  102. hal_rx_handle_other_tlvs(uint32_t tlv_tag, void *rx_tlv,
  103. struct hal_rx_ppdu_info *ppdu_info)
  104. {
  105. uint32_t value;
  106. switch (tlv_tag) {
  107. case WIFIPHYRX_HE_SIG_A_MU_UL_E:
  108. {
  109. uint8_t *he_sig_a_mu_ul_info =
  110. (uint8_t *)rx_tlv +
  111. HAL_RX_OFFSET(PHYRX_HE_SIG_A_MU_UL,
  112. HE_SIG_A_MU_UL_INFO_PHYRX_HE_SIG_A_MU_UL_INFO_DETAILS);
  113. ppdu_info->rx_status.he_flags = 1;
  114. value = HAL_RX_GET(he_sig_a_mu_ul_info, HE_SIG_A_MU_UL_INFO,
  115. FORMAT_INDICATION);
  116. if (value == 0) {
  117. ppdu_info->rx_status.he_data1 =
  118. QDF_MON_STATUS_HE_TRIG_FORMAT_TYPE;
  119. } else {
  120. ppdu_info->rx_status.he_data1 =
  121. QDF_MON_STATUS_HE_SU_FORMAT_TYPE;
  122. }
  123. /* data1 */
  124. ppdu_info->rx_status.he_data1 |=
  125. QDF_MON_STATUS_HE_BSS_COLOR_KNOWN |
  126. QDF_MON_STATUS_HE_DL_UL_KNOWN |
  127. QDF_MON_STATUS_HE_DATA_BW_RU_KNOWN;
  128. /* data2 */
  129. ppdu_info->rx_status.he_data2 |=
  130. QDF_MON_STATUS_TXOP_KNOWN;
  131. /*data3*/
  132. value = HAL_RX_GET(he_sig_a_mu_ul_info,
  133. HE_SIG_A_MU_UL_INFO, BSS_COLOR_ID);
  134. ppdu_info->rx_status.he_data3 = value;
  135. /* 1 for UL and 0 for DL */
  136. value = 1;
  137. value = value << QDF_MON_STATUS_DL_UL_SHIFT;
  138. ppdu_info->rx_status.he_data3 |= value;
  139. /*data4*/
  140. value = HAL_RX_GET(he_sig_a_mu_ul_info, HE_SIG_A_MU_UL_INFO,
  141. SPATIAL_REUSE);
  142. ppdu_info->rx_status.he_data4 = value;
  143. /*data5*/
  144. value = HAL_RX_GET(he_sig_a_mu_ul_info,
  145. HE_SIG_A_MU_UL_INFO, TRANSMIT_BW);
  146. ppdu_info->rx_status.he_data5 = value;
  147. ppdu_info->rx_status.bw = value;
  148. /*data6*/
  149. value = HAL_RX_GET(he_sig_a_mu_ul_info, HE_SIG_A_MU_UL_INFO,
  150. TXOP_DURATION);
  151. value = value << QDF_MON_STATUS_TXOP_SHIFT;
  152. ppdu_info->rx_status.he_data6 |= value;
  153. return true;
  154. }
  155. default:
  156. return false;
  157. }
  158. }
  159. #else
  160. static inline bool
  161. hal_rx_handle_other_tlvs(uint32_t tlv_tag, void *rx_tlv,
  162. struct hal_rx_ppdu_info *ppdu_info)
  163. {
  164. return false;
  165. }
  166. #endif /* QCA_WIFI_QCA6290_11AX_MU_UL && QCA_WIFI_QCA6290_11AX */
  167. #if defined(RX_PPDU_END_USER_STATS_OFDMA_INFO_VALID_OFFSET) && \
  168. defined(RX_PPDU_END_USER_STATS_SW_RESPONSE_REFERENCE_PTR_EXT_OFFSET)
  169. static inline void
  170. hal_rx_handle_mu_ul_info(void *rx_tlv,
  171. struct mon_rx_user_status *mon_rx_user_status)
  172. {
  173. mon_rx_user_status->mu_ul_user_v0_word0 =
  174. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS,
  175. SW_RESPONSE_REFERENCE_PTR);
  176. mon_rx_user_status->mu_ul_user_v0_word1 =
  177. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS,
  178. SW_RESPONSE_REFERENCE_PTR_EXT);
  179. }
  180. static inline void
  181. hal_rx_populate_byte_count(void *rx_tlv, void *ppduinfo,
  182. struct mon_rx_user_status *mon_rx_user_status)
  183. {
  184. uint32_t mpdu_ok_byte_count;
  185. uint32_t mpdu_err_byte_count;
  186. mpdu_ok_byte_count = HAL_RX_GET(rx_tlv,
  187. RX_PPDU_END_USER_STATS,
  188. MPDU_OK_BYTE_COUNT);
  189. mpdu_err_byte_count = HAL_RX_GET(rx_tlv,
  190. RX_PPDU_END_USER_STATS,
  191. MPDU_ERR_BYTE_COUNT);
  192. mon_rx_user_status->mpdu_ok_byte_count = mpdu_ok_byte_count;
  193. mon_rx_user_status->mpdu_err_byte_count = mpdu_err_byte_count;
  194. }
  195. #else
  196. static inline void
  197. hal_rx_handle_mu_ul_info(void *rx_tlv,
  198. struct mon_rx_user_status *mon_rx_user_status)
  199. {
  200. }
  201. static inline void
  202. hal_rx_populate_byte_count(void *rx_tlv, void *ppduinfo,
  203. struct mon_rx_user_status *mon_rx_user_status)
  204. {
  205. struct hal_rx_ppdu_info *ppdu_info =
  206. (struct hal_rx_ppdu_info *)ppduinfo;
  207. /* HKV1: doesn't support mpdu byte count */
  208. mon_rx_user_status->mpdu_ok_byte_count = ppdu_info->rx_status.ppdu_len;
  209. mon_rx_user_status->mpdu_err_byte_count = 0;
  210. }
  211. #endif
  212. static inline void
  213. hal_rx_populate_mu_user_info(void *rx_tlv, void *ppduinfo, uint32_t user_id,
  214. struct mon_rx_user_status *mon_rx_user_status)
  215. {
  216. struct mon_rx_info *mon_rx_info;
  217. struct mon_rx_user_info *mon_rx_user_info;
  218. struct hal_rx_ppdu_info *ppdu_info =
  219. (struct hal_rx_ppdu_info *)ppduinfo;
  220. mon_rx_info = &ppdu_info->rx_info;
  221. mon_rx_user_info = &ppdu_info->rx_user_info[user_id];
  222. mon_rx_user_info->qos_control_info_valid =
  223. mon_rx_info->qos_control_info_valid;
  224. mon_rx_user_info->qos_control = mon_rx_info->qos_control;
  225. mon_rx_user_status->ast_index = ppdu_info->rx_status.ast_index;
  226. mon_rx_user_status->tid = ppdu_info->rx_status.tid;
  227. mon_rx_user_status->tcp_msdu_count =
  228. ppdu_info->rx_status.tcp_msdu_count;
  229. mon_rx_user_status->udp_msdu_count =
  230. ppdu_info->rx_status.udp_msdu_count;
  231. mon_rx_user_status->other_msdu_count =
  232. ppdu_info->rx_status.other_msdu_count;
  233. mon_rx_user_status->frame_control = ppdu_info->rx_status.frame_control;
  234. mon_rx_user_status->frame_control_info_valid =
  235. ppdu_info->rx_status.frame_control_info_valid;
  236. mon_rx_user_status->data_sequence_control_info_valid =
  237. ppdu_info->rx_status.data_sequence_control_info_valid;
  238. mon_rx_user_status->first_data_seq_ctrl =
  239. ppdu_info->rx_status.first_data_seq_ctrl;
  240. mon_rx_user_status->preamble_type = ppdu_info->rx_status.preamble_type;
  241. mon_rx_user_status->ht_flags = ppdu_info->rx_status.ht_flags;
  242. mon_rx_user_status->rtap_flags = ppdu_info->rx_status.rtap_flags;
  243. mon_rx_user_status->vht_flags = ppdu_info->rx_status.vht_flags;
  244. mon_rx_user_status->he_flags = ppdu_info->rx_status.he_flags;
  245. mon_rx_user_status->rs_flags = ppdu_info->rx_status.rs_flags;
  246. mon_rx_user_status->mpdu_cnt_fcs_ok =
  247. ppdu_info->com_info.mpdu_cnt_fcs_ok;
  248. mon_rx_user_status->mpdu_cnt_fcs_err =
  249. ppdu_info->com_info.mpdu_cnt_fcs_err;
  250. qdf_mem_copy(&mon_rx_user_status->mpdu_fcs_ok_bitmap,
  251. &ppdu_info->com_info.mpdu_fcs_ok_bitmap,
  252. HAL_RX_NUM_WORDS_PER_PPDU_BITMAP *
  253. sizeof(ppdu_info->com_info.mpdu_fcs_ok_bitmap[0]));
  254. hal_rx_populate_byte_count(rx_tlv, ppdu_info, mon_rx_user_status);
  255. }
  256. #define HAL_RX_UPDATE_RSSI_PER_CHAIN_BW(chain, \
  257. ppdu_info, rssi_info_tlv) \
  258. { \
  259. ppdu_info->rx_status.rssi_chain[chain][0] = \
  260. HAL_RX_GET(rssi_info_tlv, RECEIVE_RSSI_INFO,\
  261. RSSI_PRI20_CHAIN##chain); \
  262. ppdu_info->rx_status.rssi_chain[chain][1] = \
  263. HAL_RX_GET(rssi_info_tlv, RECEIVE_RSSI_INFO,\
  264. RSSI_EXT20_CHAIN##chain); \
  265. ppdu_info->rx_status.rssi_chain[chain][2] = \
  266. HAL_RX_GET(rssi_info_tlv, RECEIVE_RSSI_INFO,\
  267. RSSI_EXT40_LOW20_CHAIN##chain); \
  268. ppdu_info->rx_status.rssi_chain[chain][3] = \
  269. HAL_RX_GET(rssi_info_tlv, RECEIVE_RSSI_INFO,\
  270. RSSI_EXT40_HIGH20_CHAIN##chain); \
  271. ppdu_info->rx_status.rssi_chain[chain][4] = \
  272. HAL_RX_GET(rssi_info_tlv, RECEIVE_RSSI_INFO,\
  273. RSSI_EXT80_LOW20_CHAIN##chain); \
  274. ppdu_info->rx_status.rssi_chain[chain][5] = \
  275. HAL_RX_GET(rssi_info_tlv, RECEIVE_RSSI_INFO,\
  276. RSSI_EXT80_LOW_HIGH20_CHAIN##chain); \
  277. ppdu_info->rx_status.rssi_chain[chain][6] = \
  278. HAL_RX_GET(rssi_info_tlv, RECEIVE_RSSI_INFO,\
  279. RSSI_EXT80_HIGH_LOW20_CHAIN##chain); \
  280. ppdu_info->rx_status.rssi_chain[chain][7] = \
  281. HAL_RX_GET(rssi_info_tlv, RECEIVE_RSSI_INFO,\
  282. RSSI_EXT80_HIGH20_CHAIN##chain); \
  283. } \
  284. #define HAL_RX_PPDU_UPDATE_RSSI(ppdu_info, rssi_info_tlv) \
  285. {HAL_RX_UPDATE_RSSI_PER_CHAIN_BW(0, ppdu_info, rssi_info_tlv) \
  286. HAL_RX_UPDATE_RSSI_PER_CHAIN_BW(1, ppdu_info, rssi_info_tlv) \
  287. HAL_RX_UPDATE_RSSI_PER_CHAIN_BW(2, ppdu_info, rssi_info_tlv) \
  288. HAL_RX_UPDATE_RSSI_PER_CHAIN_BW(3, ppdu_info, rssi_info_tlv) \
  289. HAL_RX_UPDATE_RSSI_PER_CHAIN_BW(4, ppdu_info, rssi_info_tlv) \
  290. HAL_RX_UPDATE_RSSI_PER_CHAIN_BW(5, ppdu_info, rssi_info_tlv) \
  291. HAL_RX_UPDATE_RSSI_PER_CHAIN_BW(6, ppdu_info, rssi_info_tlv) \
  292. HAL_RX_UPDATE_RSSI_PER_CHAIN_BW(7, ppdu_info, rssi_info_tlv)} \
  293. static inline uint32_t
  294. hal_rx_update_rssi_chain(struct hal_rx_ppdu_info *ppdu_info,
  295. uint8_t *rssi_info_tlv)
  296. {
  297. // TODO - Find all these registers for kiwi
  298. #if 0
  299. HAL_RX_PPDU_UPDATE_RSSI(ppdu_info, rssi_info_tlv)
  300. #endif
  301. return 0;
  302. }
  303. #ifdef WLAN_TX_PKT_CAPTURE_ENH
  304. static inline void
  305. hal_get_qos_control(void *rx_tlv,
  306. struct hal_rx_ppdu_info *ppdu_info)
  307. {
  308. ppdu_info->rx_info.qos_control_info_valid =
  309. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS,
  310. QOS_CONTROL_INFO_VALID);
  311. if (ppdu_info->rx_info.qos_control_info_valid)
  312. ppdu_info->rx_info.qos_control =
  313. HAL_RX_GET(rx_tlv,
  314. RX_PPDU_END_USER_STATS,
  315. QOS_CONTROL_FIELD);
  316. }
  317. static inline void
  318. hal_get_mac_addr1(uint8_t *rx_mpdu_start,
  319. struct hal_rx_ppdu_info *ppdu_info)
  320. {
  321. if ((ppdu_info->sw_frame_group_id
  322. == HAL_MPDU_SW_FRAME_GROUP_MGMT_PROBE_REQ) ||
  323. (ppdu_info->sw_frame_group_id ==
  324. HAL_MPDU_SW_FRAME_GROUP_CTRL_RTS)) {
  325. ppdu_info->rx_info.mac_addr1_valid =
  326. HAL_RX_GET_MAC_ADDR1_VALID(rx_mpdu_start);
  327. *(uint32_t *)&ppdu_info->rx_info.mac_addr1[0] =
  328. HAL_RX_GET(rx_mpdu_start,
  329. RX_MPDU_INFO,
  330. MAC_ADDR_AD1_31_0);
  331. if (ppdu_info->sw_frame_group_id ==
  332. HAL_MPDU_SW_FRAME_GROUP_CTRL_RTS) {
  333. *(uint32_t *)&ppdu_info->rx_info.mac_addr1[4] =
  334. HAL_RX_GET(rx_mpdu_start,
  335. RX_MPDU_INFO,
  336. MAC_ADDR_AD1_47_32);
  337. }
  338. }
  339. }
  340. #else
  341. static inline void
  342. hal_get_qos_control(void *rx_tlv,
  343. struct hal_rx_ppdu_info *ppdu_info)
  344. {
  345. }
  346. static inline void
  347. hal_get_mac_addr1(uint8_t *rx_mpdu_start,
  348. struct hal_rx_ppdu_info *ppdu_info)
  349. {
  350. }
  351. #endif
  352. static inline uint32_t
  353. hal_rx_parse_u_sig_cmn(struct hal_soc *hal_soc, void *rx_tlv,
  354. struct hal_rx_ppdu_info *ppdu_info)
  355. {
  356. struct hal_mon_usig_hdr *usig = (struct hal_mon_usig_hdr *)rx_tlv;
  357. struct hal_mon_usig_cmn *usig_1 = &usig->usig_1;
  358. uint8_t bad_usig_crc;
  359. bad_usig_crc = HAL_RX_MON_USIG_GET_RX_INTEGRITY_CHECK_PASSED(rx_tlv) ?
  360. 0 : 1;
  361. ppdu_info->rx_status.usig_common |=
  362. QDF_MON_STATUS_USIG_PHY_VERSION_KNOWN |
  363. QDF_MON_STATUS_USIG_BW_KNOWN |
  364. QDF_MON_STATUS_USIG_UL_DL_KNOWN |
  365. QDF_MON_STATUS_USIG_BSS_COLOR_KNOWN |
  366. QDF_MON_STATUS_USIG_TXOP_KNOWN;
  367. ppdu_info->rx_status.usig_common |= (usig_1->phy_version <<
  368. QDF_MON_STATUS_USIG_PHY_VERSION_SHIFT);
  369. ppdu_info->rx_status.usig_common |= (usig_1->bw <<
  370. QDF_MON_STATUS_USIG_BW_SHIFT);
  371. ppdu_info->rx_status.usig_common |= (usig_1->ul_dl <<
  372. QDF_MON_STATUS_USIG_UL_DL_SHIFT);
  373. ppdu_info->rx_status.usig_common |= (usig_1->bss_color <<
  374. QDF_MON_STATUS_USIG_BSS_COLOR_SHIFT);
  375. ppdu_info->rx_status.usig_common |= (usig_1->txop <<
  376. QDF_MON_STATUS_USIG_TXOP_SHIFT);
  377. ppdu_info->rx_status.usig_common |= bad_usig_crc;
  378. ppdu_info->u_sig_info.ul_dl = usig_1->ul_dl;
  379. ppdu_info->u_sig_info.bw = usig_1->bw;
  380. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  381. }
  382. static inline uint32_t
  383. hal_rx_parse_u_sig_tb(struct hal_soc *hal_soc, void *rx_tlv,
  384. struct hal_rx_ppdu_info *ppdu_info)
  385. {
  386. struct hal_mon_usig_hdr *usig = (struct hal_mon_usig_hdr *)rx_tlv;
  387. struct hal_mon_usig_tb *usig_tb = &usig->usig_2.tb;
  388. ppdu_info->rx_status.usig_mask |=
  389. QDF_MON_STATUS_USIG_DISREGARD_KNOWN |
  390. QDF_MON_STATUS_USIG_PPDU_TYPE_N_COMP_MODE_KNOWN |
  391. QDF_MON_STATUS_USIG_VALIDATE_KNOWN |
  392. QDF_MON_STATUS_USIG_TB_SPATIAL_REUSE_1_KNOWN |
  393. QDF_MON_STATUS_USIG_TB_SPATIAL_REUSE_2_KNOWN |
  394. QDF_MON_STATUS_USIG_TB_DISREGARD1_KNOWN |
  395. QDF_MON_STATUS_USIG_CRC_KNOWN |
  396. QDF_MON_STATUS_USIG_TAIL_KNOWN;
  397. ppdu_info->rx_status.usig_value |= (0x3F <<
  398. QDF_MON_STATUS_USIG_DISREGARD_SHIFT);
  399. ppdu_info->rx_status.usig_value |= (usig_tb->ppdu_type_comp_mode <<
  400. QDF_MON_STATUS_USIG_PPDU_TYPE_N_COMP_MODE_SHIFT);
  401. ppdu_info->rx_status.usig_value |= (0x1 <<
  402. QDF_MON_STATUS_USIG_VALIDATE_SHIFT);
  403. ppdu_info->rx_status.usig_value |= (usig_tb->spatial_reuse_1 <<
  404. QDF_MON_STATUS_USIG_TB_SPATIAL_REUSE_1_SHIFT);
  405. ppdu_info->rx_status.usig_value |= (usig_tb->spatial_reuse_2 <<
  406. QDF_MON_STATUS_USIG_TB_SPATIAL_REUSE_2_SHIFT);
  407. ppdu_info->rx_status.usig_value |= (0x1F <<
  408. QDF_MON_STATUS_USIG_TB_DISREGARD1_SHIFT);
  409. ppdu_info->rx_status.usig_value |= (usig_tb->crc <<
  410. QDF_MON_STATUS_USIG_CRC_SHIFT);
  411. ppdu_info->rx_status.usig_value |= (usig_tb->tail <<
  412. QDF_MON_STATUS_USIG_TAIL_SHIFT);
  413. ppdu_info->u_sig_info.ppdu_type_comp_mode =
  414. usig_tb->ppdu_type_comp_mode;
  415. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  416. }
  417. static inline uint32_t
  418. hal_rx_parse_u_sig_mu(struct hal_soc *hal_soc, void *rx_tlv,
  419. struct hal_rx_ppdu_info *ppdu_info)
  420. {
  421. struct hal_mon_usig_hdr *usig = (struct hal_mon_usig_hdr *)rx_tlv;
  422. struct hal_mon_usig_mu *usig_mu = &usig->usig_2.mu;
  423. ppdu_info->rx_status.usig_mask |=
  424. QDF_MON_STATUS_USIG_DISREGARD_KNOWN |
  425. QDF_MON_STATUS_USIG_PPDU_TYPE_N_COMP_MODE_KNOWN |
  426. QDF_MON_STATUS_USIG_VALIDATE_KNOWN |
  427. QDF_MON_STATUS_USIG_MU_VALIDATE1_SHIFT |
  428. QDF_MON_STATUS_USIG_MU_PUNCTURE_CH_INFO_KNOWN |
  429. QDF_MON_STATUS_USIG_MU_VALIDATE2_SHIFT |
  430. QDF_MON_STATUS_USIG_MU_EHT_SIG_MCS_KNOWN |
  431. QDF_MON_STATUS_USIG_MU_NUM_EHT_SIG_SYM_KNOWN |
  432. QDF_MON_STATUS_USIG_CRC_KNOWN |
  433. QDF_MON_STATUS_USIG_TAIL_KNOWN;
  434. ppdu_info->rx_status.usig_value |= (0x1F <<
  435. QDF_MON_STATUS_USIG_DISREGARD_SHIFT);
  436. ppdu_info->rx_status.usig_value |= (0x1 <<
  437. QDF_MON_STATUS_USIG_MU_VALIDATE1_SHIFT);
  438. ppdu_info->rx_status.usig_value |= (usig_mu->ppdu_type_comp_mode <<
  439. QDF_MON_STATUS_USIG_PPDU_TYPE_N_COMP_MODE_SHIFT);
  440. ppdu_info->rx_status.usig_value |= (0x1 <<
  441. QDF_MON_STATUS_USIG_VALIDATE_SHIFT);
  442. ppdu_info->rx_status.usig_value |= (usig_mu->punc_ch_info <<
  443. QDF_MON_STATUS_USIG_MU_PUNCTURE_CH_INFO_SHIFT);
  444. ppdu_info->rx_status.usig_value |= (0x1 <<
  445. QDF_MON_STATUS_USIG_MU_VALIDATE2_SHIFT);
  446. ppdu_info->rx_status.usig_value |= (usig_mu->eht_sig_mcs <<
  447. QDF_MON_STATUS_USIG_MU_EHT_SIG_MCS_SHIFT);
  448. ppdu_info->rx_status.usig_value |= (usig_mu->num_eht_sig_sym <<
  449. QDF_MON_STATUS_USIG_MU_NUM_EHT_SIG_SYM_SHIFT);
  450. ppdu_info->rx_status.usig_value |= (usig_mu->crc <<
  451. QDF_MON_STATUS_USIG_CRC_SHIFT);
  452. ppdu_info->rx_status.usig_value |= (usig_mu->tail <<
  453. QDF_MON_STATUS_USIG_TAIL_SHIFT);
  454. ppdu_info->u_sig_info.ppdu_type_comp_mode =
  455. usig_mu->ppdu_type_comp_mode;
  456. ppdu_info->u_sig_info.eht_sig_mcs = usig_mu->eht_sig_mcs;
  457. ppdu_info->u_sig_info.num_eht_sig_sym = usig_mu->num_eht_sig_sym;
  458. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  459. }
  460. static inline uint32_t
  461. hal_rx_parse_u_sig_hdr(struct hal_soc *hal_soc, void *rx_tlv,
  462. struct hal_rx_ppdu_info *ppdu_info)
  463. {
  464. struct hal_mon_usig_hdr *usig = (struct hal_mon_usig_hdr *)rx_tlv;
  465. struct hal_mon_usig_cmn *usig_1 = &usig->usig_1;
  466. ppdu_info->rx_status.usig_flags = 1;
  467. hal_rx_parse_u_sig_cmn(hal_soc, rx_tlv, ppdu_info);
  468. if (HAL_RX_MON_USIG_GET_PPDU_TYPE_N_COMP_MODE(rx_tlv) == 0 &&
  469. usig_1->ul_dl == 1)
  470. return hal_rx_parse_u_sig_tb(hal_soc, rx_tlv, ppdu_info);
  471. else
  472. return hal_rx_parse_u_sig_mu(hal_soc, rx_tlv, ppdu_info);
  473. }
  474. static inline uint32_t
  475. hal_rx_parse_usig_overflow(struct hal_soc *hal_soc, void *tlv,
  476. struct hal_rx_ppdu_info *ppdu_info)
  477. {
  478. struct hal_eht_sig_cc_usig_overflow *usig_ovflow =
  479. (struct hal_eht_sig_cc_usig_overflow *)tlv;
  480. ppdu_info->rx_status.eht_known |=
  481. QDF_MON_STATUS_EHT_SPATIAL_REUSE_KNOWN |
  482. QDF_MON_STATUS_EHT_EHT_LTF_KNOWN |
  483. QDF_MON_STATUS_EHT_LDPC_EXTRA_SYMBOL_SEG_KNOWN |
  484. QDF_MON_STATUS_EHT_PRE_FEC_PADDING_FACTOR_KNOWN |
  485. QDF_MON_STATUS_EHT_PE_DISAMBIGUITY_KNOWN |
  486. QDF_MON_STATUS_EHT_DISREARD_KNOWN;
  487. ppdu_info->rx_status.eht_data[0] |= (usig_ovflow->spatial_reuse <<
  488. QDF_MON_STATUS_EHT_SPATIAL_REUSE_SHIFT);
  489. /*
  490. * GI and LTF size are separately indicated in radiotap header
  491. * and hence will be parsed from other TLV
  492. **/
  493. ppdu_info->rx_status.eht_data[0] |= (usig_ovflow->num_ltf_sym <<
  494. QDF_MON_STATUS_EHT_EHT_LTF_SHIFT);
  495. ppdu_info->rx_status.eht_data[0] |= (usig_ovflow->ldpc_extra_sym <<
  496. QDF_MON_STATUS_EHT_LDPC_EXTRA_SYMBOL_SEG_SHIFT);
  497. ppdu_info->rx_status.eht_data[0] |= (usig_ovflow->pre_fec_pad_factor <<
  498. QDF_MON_STATUS_EHT_PRE_FEC_PADDING_FACTOR_SHIFT);
  499. ppdu_info->rx_status.eht_data[0] |= (usig_ovflow->pe_disambiguity <<
  500. QDF_MON_STATUS_EHT_PE_DISAMBIGUITY_SHIFT);
  501. ppdu_info->rx_status.eht_data[0] |= (0xF <<
  502. QDF_MON_STATUS_EHT_DISREGARD_SHIFT);
  503. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  504. }
  505. static inline uint32_t
  506. hal_rx_parse_non_ofdma_users(struct hal_soc *hal_soc, void *tlv,
  507. struct hal_rx_ppdu_info *ppdu_info)
  508. {
  509. struct hal_eht_sig_non_ofdma_cmn_eb *non_ofdma_cmn_eb =
  510. (struct hal_eht_sig_non_ofdma_cmn_eb *)tlv;
  511. ppdu_info->rx_status.eht_known |=
  512. QDF_MON_STATUS_EHT_NUM_NON_OFDMA_USERS_KNOWN;
  513. ppdu_info->rx_status.eht_data[4] |= (non_ofdma_cmn_eb->num_users <<
  514. QDF_MON_STATUS_EHT_NUM_NON_OFDMA_USERS_SHIFT);
  515. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  516. }
  517. static inline uint32_t
  518. hal_rx_parse_ru_allocation(struct hal_soc *hal_soc, void *tlv,
  519. struct hal_rx_ppdu_info *ppdu_info)
  520. {
  521. uint64_t *ehtsig_tlv = (uint64_t *)tlv;
  522. struct hal_eht_sig_ofdma_cmn_eb1 *ofdma_cmn_eb1;
  523. struct hal_eht_sig_ofdma_cmn_eb2 *ofdma_cmn_eb2;
  524. uint8_t num_ru_allocation_known = 0;
  525. ofdma_cmn_eb1 = (struct hal_eht_sig_ofdma_cmn_eb1 *)ehtsig_tlv;
  526. ofdma_cmn_eb2 = (struct hal_eht_sig_ofdma_cmn_eb2 *)(ehtsig_tlv + 1);
  527. switch (ppdu_info->u_sig_info.bw) {
  528. case HAL_EHT_BW_320_2:
  529. case HAL_EHT_BW_320_1:
  530. num_ru_allocation_known += 4;
  531. ppdu_info->rx_status.eht_data[3] |=
  532. (ofdma_cmn_eb2->ru_allocation2_6 <<
  533. QDF_MON_STATUS_EHT_RU_ALLOCATION2_6_SHIFT);
  534. ppdu_info->rx_status.eht_data[3] |=
  535. (ofdma_cmn_eb2->ru_allocation2_5 <<
  536. QDF_MON_STATUS_EHT_RU_ALLOCATION2_5_SHIFT);
  537. ppdu_info->rx_status.eht_data[3] |=
  538. (ofdma_cmn_eb2->ru_allocation2_4 <<
  539. QDF_MON_STATUS_EHT_RU_ALLOCATION2_4_SHIFT);
  540. ppdu_info->rx_status.eht_data[2] |=
  541. (ofdma_cmn_eb2->ru_allocation2_3 <<
  542. QDF_MON_STATUS_EHT_RU_ALLOCATION2_3_SHIFT);
  543. /* fallthrough */
  544. case HAL_EHT_BW_160:
  545. num_ru_allocation_known += 2;
  546. ppdu_info->rx_status.eht_data[2] |=
  547. (ofdma_cmn_eb2->ru_allocation2_2 <<
  548. QDF_MON_STATUS_EHT_RU_ALLOCATION2_2_SHIFT);
  549. ppdu_info->rx_status.eht_data[2] |=
  550. (ofdma_cmn_eb2->ru_allocation2_1 <<
  551. QDF_MON_STATUS_EHT_RU_ALLOCATION2_1_SHIFT);
  552. /* fallthrough */
  553. case HAL_EHT_BW_80:
  554. num_ru_allocation_known += 1;
  555. ppdu_info->rx_status.eht_data[1] |=
  556. (ofdma_cmn_eb1->ru_allocation1_2 <<
  557. QDF_MON_STATUS_EHT_RU_ALLOCATION1_2_SHIFT);
  558. /* fallthrough */
  559. case HAL_EHT_BW_40:
  560. case HAL_EHT_BW_20:
  561. num_ru_allocation_known += 1;
  562. ppdu_info->rx_status.eht_data[1] |=
  563. (ofdma_cmn_eb1->ru_allocation1_1 <<
  564. QDF_MON_STATUS_EHT_RU_ALLOCATION1_1_SHIFT);
  565. break;
  566. default:
  567. break;
  568. }
  569. ppdu_info->rx_status.eht_known |= (num_ru_allocation_known <<
  570. QDF_MON_STATUS_EHT_NUM_KNOWN_RU_ALLOCATIONS_SHIFT);
  571. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  572. }
  573. static inline uint32_t
  574. hal_rx_parse_eht_sig_mumimo_user_info(struct hal_soc *hal_soc, void *tlv,
  575. struct hal_rx_ppdu_info *ppdu_info)
  576. {
  577. struct hal_eht_sig_mu_mimo_user_info *user_info;
  578. uint32_t user_idx = ppdu_info->rx_status.num_eht_user_info_valid;
  579. user_info = (struct hal_eht_sig_mu_mimo_user_info *)tlv;
  580. ppdu_info->rx_status.eht_user_info[user_idx] |=
  581. QDF_MON_STATUS_EHT_USER_STA_ID_KNOWN |
  582. QDF_MON_STATUS_EHT_USER_MCS_KNOWN |
  583. QDF_MON_STATUS_EHT_USER_CODING_KNOWN |
  584. QDF_MON_STATUS_EHT_USER_SPATIAL_CONFIG_KNOWN;
  585. ppdu_info->rx_status.eht_user_info[user_idx] |= (user_info->sta_id <<
  586. QDF_MON_STATUS_EHT_USER_STA_ID_SHIFT);
  587. ppdu_info->rx_status.eht_user_info[user_idx] |= (user_info->mcs <<
  588. QDF_MON_STATUS_EHT_USER_MCS_SHIFT);
  589. ppdu_info->rx_status.eht_user_info[user_idx] |= (user_info->coding <<
  590. QDF_MON_STATUS_EHT_USER_CODING_SHIFT);
  591. ppdu_info->rx_status.eht_user_info[user_idx] |=
  592. (user_info->spatial_coding <<
  593. QDF_MON_STATUS_EHT_USER_SPATIAL_CONFIG_SHIFT);
  594. /* CRC for matched user block */
  595. ppdu_info->rx_status.eht_known |=
  596. QDF_MON_STATUS_EHT_USER_ENC_BLOCK_CRC_KNOWN |
  597. QDF_MON_STATUS_EHT_USER_ENC_BLOCK_TAIL_KNOWN;
  598. ppdu_info->rx_status.eht_data[4] |= (user_info->crc <<
  599. QDF_MON_STATUS_EHT_USER_ENC_BLOCK_CRC_SHIFT);
  600. ppdu_info->rx_status.num_eht_user_info_valid++;
  601. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  602. }
  603. static inline uint32_t
  604. hal_rx_parse_eht_sig_non_mumimo_user_info(struct hal_soc *hal_soc, void *tlv,
  605. struct hal_rx_ppdu_info *ppdu_info)
  606. {
  607. struct hal_eht_sig_non_mu_mimo_user_info *user_info;
  608. uint32_t user_idx = ppdu_info->rx_status.num_eht_user_info_valid;
  609. user_info = (struct hal_eht_sig_non_mu_mimo_user_info *)tlv;
  610. ppdu_info->rx_status.eht_user_info[user_idx] |=
  611. QDF_MON_STATUS_EHT_USER_STA_ID_KNOWN |
  612. QDF_MON_STATUS_EHT_USER_MCS_KNOWN |
  613. QDF_MON_STATUS_EHT_USER_CODING_KNOWN |
  614. QDF_MON_STATUS_EHT_USER_NSS_KNOWN |
  615. QDF_MON_STATUS_EHT_USER_BEAMFORMING_KNOWN;
  616. ppdu_info->rx_status.eht_user_info[user_idx] |= (user_info->sta_id <<
  617. QDF_MON_STATUS_EHT_USER_STA_ID_SHIFT);
  618. ppdu_info->rx_status.eht_user_info[user_idx] |= (user_info->mcs <<
  619. QDF_MON_STATUS_EHT_USER_MCS_SHIFT);
  620. ppdu_info->rx_status.eht_user_info[user_idx] |= (user_info->nss <<
  621. QDF_MON_STATUS_EHT_USER_NSS_SHIFT);
  622. ppdu_info->rx_status.eht_user_info[user_idx] |=
  623. (user_info->beamformed <<
  624. QDF_MON_STATUS_EHT_USER_BEAMFORMING_SHIFT);
  625. ppdu_info->rx_status.eht_user_info[user_idx] |= (user_info->coding <<
  626. QDF_MON_STATUS_EHT_USER_CODING_SHIFT);
  627. /* CRC for matched user block */
  628. ppdu_info->rx_status.eht_known |=
  629. QDF_MON_STATUS_EHT_USER_ENC_BLOCK_CRC_KNOWN |
  630. QDF_MON_STATUS_EHT_USER_ENC_BLOCK_TAIL_KNOWN;
  631. ppdu_info->rx_status.eht_data[4] |= (user_info->crc <<
  632. QDF_MON_STATUS_EHT_USER_ENC_BLOCK_CRC_SHIFT);
  633. ppdu_info->rx_status.num_eht_user_info_valid++;
  634. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  635. }
  636. static inline bool hal_rx_is_ofdma(struct hal_soc *hal_soc,
  637. struct hal_rx_ppdu_info *ppdu_info)
  638. {
  639. if (ppdu_info->u_sig_info.ppdu_type_comp_mode == 0 &&
  640. ppdu_info->u_sig_info.ul_dl == 0)
  641. return true;
  642. return false;
  643. }
  644. static inline bool hal_rx_is_non_ofdma(struct hal_soc *hal_soc,
  645. struct hal_rx_ppdu_info *ppdu_info)
  646. {
  647. uint32_t ppdu_type_comp_mode =
  648. ppdu_info->u_sig_info.ppdu_type_comp_mode;
  649. uint32_t ul_dl = ppdu_info->u_sig_info.ul_dl;
  650. if ((ppdu_type_comp_mode == 0 && ul_dl == 1) ||
  651. (ppdu_type_comp_mode == 0 && ul_dl == 2) ||
  652. (ppdu_type_comp_mode == 1 && ul_dl == 1))
  653. return true;
  654. return false;
  655. }
  656. static inline bool hal_rx_is_mu_mimo_user(struct hal_soc *hal_soc,
  657. struct hal_rx_ppdu_info *ppdu_info)
  658. {
  659. if (ppdu_info->u_sig_info.ppdu_type_comp_mode == 0 &&
  660. ppdu_info->u_sig_info.ul_dl == 2)
  661. return true;
  662. return false;
  663. }
  664. static inline bool
  665. hal_rx_is_frame_type_ndp(struct hal_soc *hal_soc,
  666. struct hal_rx_ppdu_info *ppdu_info)
  667. {
  668. if (ppdu_info->u_sig_info.ppdu_type_comp_mode == 1 &&
  669. ppdu_info->u_sig_info.eht_sig_mcs == 0 &&
  670. ppdu_info->u_sig_info.num_eht_sig_sym == 0)
  671. return true;
  672. return false;
  673. }
  674. static inline uint32_t
  675. hal_rx_parse_eht_sig_ndp(struct hal_soc *hal_soc, void *tlv,
  676. struct hal_rx_ppdu_info *ppdu_info)
  677. {
  678. struct hal_eht_sig_ndp_cmn_eb *eht_sig_ndp =
  679. (struct hal_eht_sig_ndp_cmn_eb *)tlv;
  680. ppdu_info->rx_status.eht_known |=
  681. QDF_MON_STATUS_EHT_SPATIAL_REUSE_KNOWN |
  682. QDF_MON_STATUS_EHT_EHT_LTF_KNOWN |
  683. QDF_MON_STATUS_EHT_NDP_NSS_KNOWN |
  684. QDF_MON_STATUS_EHT_NDP_BEAMFORMED_KNOWN |
  685. QDF_MON_STATUS_EHT_NDP_DISREGARD_KNOWN |
  686. QDF_MON_STATUS_EHT_CRC1_KNOWN |
  687. QDF_MON_STATUS_EHT_TAIL1_KNOWN;
  688. ppdu_info->rx_status.eht_data[0] |= (eht_sig_ndp->spatial_reuse <<
  689. QDF_MON_STATUS_EHT_SPATIAL_REUSE_SHIFT);
  690. /*
  691. * GI and LTF size are separately indicated in radiotap header
  692. * and hence will be parsed from other TLV
  693. **/
  694. ppdu_info->rx_status.eht_data[0] |= (eht_sig_ndp->num_ltf_sym <<
  695. QDF_MON_STATUS_EHT_EHT_LTF_SHIFT);
  696. ppdu_info->rx_status.eht_data[0] |= (0xF <<
  697. QDF_MON_STATUS_EHT_NDP_DISREGARD_SHIFT);
  698. ppdu_info->rx_status.eht_data[4] |= (eht_sig_ndp->nss <<
  699. QDF_MON_STATUS_EHT_NDP_NSS_SHIFT);
  700. ppdu_info->rx_status.eht_data[4] |= (eht_sig_ndp->beamformed <<
  701. QDF_MON_STATUS_EHT_NDP_BEAMFORMED_SHIFT);
  702. ppdu_info->rx_status.eht_data[0] |= (eht_sig_ndp->crc <<
  703. QDF_MON_STATUS_EHT_CRC1_SHIFT);
  704. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  705. }
  706. static inline uint32_t
  707. hal_rx_parse_eht_sig_non_ofdma(struct hal_soc *hal_soc, void *tlv,
  708. struct hal_rx_ppdu_info *ppdu_info)
  709. {
  710. hal_rx_parse_usig_overflow(hal_soc, tlv, ppdu_info);
  711. hal_rx_parse_non_ofdma_users(hal_soc, tlv, ppdu_info);
  712. if (hal_rx_is_mu_mimo_user(hal_soc, ppdu_info))
  713. hal_rx_parse_eht_sig_mumimo_user_info(hal_soc, tlv,
  714. ppdu_info);
  715. else
  716. hal_rx_parse_eht_sig_non_mumimo_user_info(hal_soc, tlv,
  717. ppdu_info);
  718. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  719. }
  720. static inline uint32_t
  721. hal_rx_parse_eht_sig_ofdma(struct hal_soc *hal_soc, void *tlv,
  722. struct hal_rx_ppdu_info *ppdu_info)
  723. {
  724. uint64_t *eht_sig_tlv = (uint64_t *)tlv;
  725. void *user_info = (void *)(eht_sig_tlv + 2);
  726. hal_rx_parse_usig_overflow(hal_soc, tlv, ppdu_info);
  727. hal_rx_parse_ru_allocation(hal_soc, tlv, ppdu_info);
  728. hal_rx_parse_eht_sig_non_mumimo_user_info(hal_soc, user_info,
  729. ppdu_info);
  730. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  731. }
  732. static inline uint32_t
  733. hal_rx_parse_eht_sig_hdr(struct hal_soc *hal_soc, uint8_t *tlv,
  734. struct hal_rx_ppdu_info *ppdu_info)
  735. {
  736. ppdu_info->rx_status.eht_flags = 1;
  737. if (hal_rx_is_frame_type_ndp(hal_soc, ppdu_info))
  738. hal_rx_parse_eht_sig_ndp(hal_soc, tlv, ppdu_info);
  739. else if (hal_rx_is_non_ofdma(hal_soc, ppdu_info))
  740. hal_rx_parse_eht_sig_non_ofdma(hal_soc, tlv, ppdu_info);
  741. else if (hal_rx_is_ofdma(hal_soc, ppdu_info))
  742. hal_rx_parse_eht_sig_ofdma(hal_soc, tlv, ppdu_info);
  743. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  744. }
  745. #ifdef WLAN_RX_MON_PARSE_CMN_USER_INFO
  746. static inline uint32_t
  747. hal_rx_parse_cmn_usr_info(struct hal_soc *hal_soc, uint8_t *tlv,
  748. struct hal_rx_ppdu_info *ppdu_info)
  749. {
  750. struct phyrx_common_user_info *cmn_usr_info =
  751. (struct phyrx_common_user_info *)tlv;
  752. ppdu_info->rx_status.eht_known |=
  753. QDF_MON_STATUS_EHT_GUARD_INTERVAL_KNOWN |
  754. QDF_MON_STATUS_EHT_LTF_KNOWN;
  755. ppdu_info->rx_status.eht_data[0] |= (cmn_usr_info->cp_setting <<
  756. QDF_MON_STATUS_EHT_GI_SHIFT);
  757. ppdu_info->rx_status.eht_data[0] |= (cmn_usr_info->ltf_size <<
  758. QDF_MON_STATUS_EHT_LTF_SHIFT);
  759. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  760. }
  761. #else
  762. static inline uint32_t
  763. hal_rx_parse_cmn_usr_info(struct hal_soc *hal_soc, uint8_t *tlv,
  764. struct hal_rx_ppdu_info *ppdu_info)
  765. {
  766. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  767. }
  768. #endif
  769. static inline enum ieee80211_eht_ru_size
  770. hal_rx_mon_hal_ru_size_to_ieee80211_ru_size(struct hal_soc *hal_soc,
  771. uint32_t hal_ru_size)
  772. {
  773. switch (hal_ru_size) {
  774. case HAL_EHT_RU_26:
  775. return IEEE80211_EHT_RU_26;
  776. case HAL_EHT_RU_52:
  777. return IEEE80211_EHT_RU_52;
  778. case HAL_EHT_RU_78:
  779. return IEEE80211_EHT_RU_52_26;
  780. case HAL_EHT_RU_106:
  781. return IEEE80211_EHT_RU_106;
  782. case HAL_EHT_RU_132:
  783. return IEEE80211_EHT_RU_106_26;
  784. case HAL_EHT_RU_242:
  785. return IEEE80211_EHT_RU_242;
  786. case HAL_EHT_RU_484:
  787. return IEEE80211_EHT_RU_484;
  788. case HAL_EHT_RU_726:
  789. return IEEE80211_EHT_RU_484_242;
  790. case HAL_EHT_RU_996:
  791. return IEEE80211_EHT_RU_996;
  792. case HAL_EHT_RU_996x2:
  793. return IEEE80211_EHT_RU_996x2;
  794. case HAL_EHT_RU_996x3:
  795. return IEEE80211_EHT_RU_996x3;
  796. case HAL_EHT_RU_996x4:
  797. return IEEE80211_EHT_RU_996x4;
  798. case HAL_EHT_RU_NONE:
  799. return IEEE80211_EHT_RU_INVALID;
  800. case HAL_EHT_RU_996_484:
  801. return IEEE80211_EHT_RU_996_484;
  802. case HAL_EHT_RU_996x2_484:
  803. return IEEE80211_EHT_RU_996x2_484;
  804. case HAL_EHT_RU_996x3_484:
  805. return IEEE80211_EHT_RU_996x3_484;
  806. case HAL_EHT_RU_996_484_242:
  807. return IEEE80211_EHT_RU_996_484_242;
  808. default:
  809. return IEEE80211_EHT_RU_INVALID;
  810. }
  811. }
  812. #define HAL_SET_RU_PER80(ru_320mhz, ru_per80, ru_idx_per80mhz, num_80mhz) \
  813. ((ru_320mhz) |= ((uint64_t)(ru_per80) << \
  814. (((num_80mhz) * NUM_RU_BITS_PER80) + \
  815. ((ru_idx_per80mhz) * NUM_RU_BITS_PER20))))
  816. static inline uint32_t
  817. hal_rx_parse_receive_user_info(struct hal_soc *hal_soc, uint8_t *tlv,
  818. struct hal_rx_ppdu_info *ppdu_info)
  819. {
  820. struct receive_user_info *rx_usr_info = (struct receive_user_info *)tlv;
  821. uint64_t ru_index_320mhz = 0;
  822. uint16_t ru_index_per80mhz;
  823. uint32_t ru_size = 0, num_80mhz_with_ru = 0;
  824. uint32_t ru_index = HAL_EHT_RU_INVALID;
  825. uint32_t rtap_ru_size = IEEE80211_EHT_RU_INVALID;
  826. ppdu_info->rx_status.eht_known |=
  827. QDF_MON_STATUS_EHT_CONTENT_CH_INDEX_KNOWN;
  828. ppdu_info->rx_status.eht_data[0] |=
  829. (rx_usr_info->dl_ofdma_content_channel <<
  830. QDF_MON_STATUS_EHT_CONTENT_CH_INDEX_SHIFT);
  831. if (!(rx_usr_info->reception_type == HAL_RX_TYPE_MU_MIMO ||
  832. rx_usr_info->reception_type == HAL_RX_TYPE_MU_OFDMA ||
  833. rx_usr_info->reception_type == HAL_RX_TYPE_MU_OFMDA_MIMO))
  834. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  835. /* RU allocation present only for OFDMA reception */
  836. if (rx_usr_info->ru_type_80_0 != HAL_EHT_RU_NONE) {
  837. ru_size += rx_usr_info->ru_type_80_0;
  838. ru_index = ru_index_per80mhz = rx_usr_info->ru_start_index_80_0;
  839. HAL_SET_RU_PER80(ru_index_320mhz, rx_usr_info->ru_type_80_0,
  840. ru_index_per80mhz, 0);
  841. num_80mhz_with_ru++;
  842. }
  843. if (rx_usr_info->ru_type_80_1 != HAL_EHT_RU_NONE) {
  844. ru_size += rx_usr_info->ru_type_80_1;
  845. ru_index = ru_index_per80mhz = rx_usr_info->ru_start_index_80_1;
  846. HAL_SET_RU_PER80(ru_index_320mhz, rx_usr_info->ru_type_80_1,
  847. ru_index_per80mhz, 1);
  848. num_80mhz_with_ru++;
  849. }
  850. if (rx_usr_info->ru_type_80_2 != HAL_EHT_RU_NONE) {
  851. ru_size += rx_usr_info->ru_type_80_2;
  852. ru_index = ru_index_per80mhz = rx_usr_info->ru_start_index_80_2;
  853. HAL_SET_RU_PER80(ru_index_320mhz, rx_usr_info->ru_type_80_2,
  854. ru_index_per80mhz, 2);
  855. num_80mhz_with_ru++;
  856. }
  857. if (rx_usr_info->ru_type_80_3 != HAL_EHT_RU_NONE) {
  858. ru_size += rx_usr_info->ru_type_80_3;
  859. ru_index = ru_index_per80mhz = rx_usr_info->ru_start_index_80_3;
  860. HAL_SET_RU_PER80(ru_index_320mhz, rx_usr_info->ru_type_80_3,
  861. ru_index_per80mhz, 3);
  862. num_80mhz_with_ru++;
  863. }
  864. if (num_80mhz_with_ru > 1) {
  865. /* Calculate the MRU index */
  866. switch (ru_index_320mhz) {
  867. case HAL_EHT_RU_996_484_0:
  868. case HAL_EHT_RU_996x2_484_0:
  869. case HAL_EHT_RU_996x3_484_0:
  870. ru_index = 0;
  871. break;
  872. case HAL_EHT_RU_996_484_1:
  873. case HAL_EHT_RU_996x2_484_1:
  874. case HAL_EHT_RU_996x3_484_1:
  875. ru_index = 1;
  876. break;
  877. case HAL_EHT_RU_996_484_2:
  878. case HAL_EHT_RU_996x2_484_2:
  879. case HAL_EHT_RU_996x3_484_2:
  880. ru_index = 2;
  881. break;
  882. case HAL_EHT_RU_996_484_3:
  883. case HAL_EHT_RU_996x2_484_3:
  884. case HAL_EHT_RU_996x3_484_3:
  885. ru_index = 3;
  886. break;
  887. case HAL_EHT_RU_996_484_4:
  888. case HAL_EHT_RU_996x2_484_4:
  889. case HAL_EHT_RU_996x3_484_4:
  890. ru_index = 4;
  891. break;
  892. case HAL_EHT_RU_996_484_5:
  893. case HAL_EHT_RU_996x2_484_5:
  894. case HAL_EHT_RU_996x3_484_5:
  895. ru_index = 5;
  896. break;
  897. case HAL_EHT_RU_996_484_6:
  898. case HAL_EHT_RU_996x2_484_6:
  899. case HAL_EHT_RU_996x3_484_6:
  900. ru_index = 6;
  901. break;
  902. case HAL_EHT_RU_996_484_7:
  903. case HAL_EHT_RU_996x2_484_7:
  904. case HAL_EHT_RU_996x3_484_7:
  905. ru_index = 7;
  906. break;
  907. case HAL_EHT_RU_996x2_484_8:
  908. ru_index = 8;
  909. break;
  910. case HAL_EHT_RU_996x2_484_9:
  911. ru_index = 9;
  912. break;
  913. case HAL_EHT_RU_996x2_484_10:
  914. ru_index = 10;
  915. break;
  916. case HAL_EHT_RU_996x2_484_11:
  917. ru_index = 11;
  918. break;
  919. default:
  920. ru_index = HAL_EHT_RU_INVALID;
  921. dp_debug("Invalid RU index");
  922. qdf_assert(0);
  923. break;
  924. }
  925. ru_size += 4;
  926. }
  927. rtap_ru_size = hal_rx_mon_hal_ru_size_to_ieee80211_ru_size(hal_soc,
  928. ru_size);
  929. if (rtap_ru_size != IEEE80211_EHT_RU_INVALID) {
  930. ppdu_info->rx_status.eht_known |=
  931. QDF_MON_STATUS_EHT_RU_MRU_SIZE_KNOWN;
  932. ppdu_info->rx_status.eht_data[1] |= (rtap_ru_size <<
  933. QDF_MON_STATUS_EHT_RU_MRU_SIZE_SHIFT);
  934. }
  935. if (ru_index != HAL_EHT_RU_INVALID) {
  936. ppdu_info->rx_status.eht_known |=
  937. QDF_MON_STATUS_EHT_RU_MRU_INDEX_KNOWN;
  938. ppdu_info->rx_status.eht_data[1] |= (ru_index <<
  939. QDF_MON_STATUS_EHT_RU_MRU_INDEX_SHIFT);
  940. }
  941. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  942. }
  943. /**
  944. * hal_rx_status_get_tlv_info() - process receive info TLV
  945. * @rx_tlv_hdr: pointer to TLV header
  946. * @ppdu_info: pointer to ppdu_info
  947. *
  948. * Return: HAL_TLV_STATUS_PPDU_NOT_DONE or HAL_TLV_STATUS_PPDU_DONE from tlv
  949. */
  950. static inline uint32_t
  951. hal_rx_status_get_tlv_info_generic_be(void *rx_tlv_hdr, void *ppduinfo,
  952. hal_soc_handle_t hal_soc_hdl,
  953. qdf_nbuf_t nbuf)
  954. {
  955. struct hal_soc *hal = (struct hal_soc *)hal_soc_hdl;
  956. uint32_t tlv_tag, user_id, tlv_len, value;
  957. uint8_t group_id = 0;
  958. uint8_t he_dcm = 0;
  959. uint8_t he_stbc = 0;
  960. uint16_t he_gi = 0;
  961. uint16_t he_ltf = 0;
  962. void *rx_tlv;
  963. bool unhandled = false;
  964. struct mon_rx_user_status *mon_rx_user_status;
  965. struct hal_rx_ppdu_info *ppdu_info =
  966. (struct hal_rx_ppdu_info *)ppduinfo;
  967. tlv_tag = HAL_RX_GET_USER_TLV64_TYPE(rx_tlv_hdr);
  968. user_id = HAL_RX_GET_USER_TLV64_USERID(rx_tlv_hdr);
  969. tlv_len = HAL_RX_GET_USER_TLV64_LEN(rx_tlv_hdr);
  970. rx_tlv = (uint8_t *)rx_tlv_hdr + HAL_RX_TLV64_HDR_SIZE;
  971. qdf_trace_hex_dump(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  972. rx_tlv, tlv_len);
  973. switch (tlv_tag) {
  974. case WIFIRX_PPDU_START_E:
  975. {
  976. if (qdf_unlikely(ppdu_info->com_info.last_ppdu_id ==
  977. HAL_RX_GET(rx_tlv, RX_PPDU_START, PHY_PPDU_ID)))
  978. hal_err("Matching ppdu_id(%u) detected",
  979. ppdu_info->com_info.last_ppdu_id);
  980. /* Reset ppdu_info before processing the ppdu */
  981. qdf_mem_zero(ppdu_info,
  982. sizeof(struct hal_rx_ppdu_info));
  983. ppdu_info->com_info.last_ppdu_id =
  984. ppdu_info->com_info.ppdu_id =
  985. HAL_RX_GET(rx_tlv, RX_PPDU_START,
  986. PHY_PPDU_ID);
  987. /* channel number is set in PHY meta data */
  988. ppdu_info->rx_status.chan_num =
  989. (HAL_RX_GET(rx_tlv, RX_PPDU_START,
  990. SW_PHY_META_DATA) & 0x0000FFFF);
  991. ppdu_info->rx_status.chan_freq =
  992. (HAL_RX_GET(rx_tlv, RX_PPDU_START,
  993. SW_PHY_META_DATA) & 0xFFFF0000) >> 16;
  994. if (ppdu_info->rx_status.chan_num &&
  995. ppdu_info->rx_status.chan_freq) {
  996. ppdu_info->rx_status.chan_freq =
  997. hal_rx_radiotap_num_to_freq(
  998. ppdu_info->rx_status.chan_num,
  999. ppdu_info->rx_status.chan_freq);
  1000. }
  1001. ppdu_info->com_info.ppdu_timestamp =
  1002. HAL_RX_GET(rx_tlv, RX_PPDU_START,
  1003. PPDU_START_TIMESTAMP_31_0);
  1004. ppdu_info->rx_status.ppdu_timestamp =
  1005. ppdu_info->com_info.ppdu_timestamp;
  1006. ppdu_info->rx_state = HAL_RX_MON_PPDU_START;
  1007. break;
  1008. }
  1009. case WIFIRX_PPDU_START_USER_INFO_E:
  1010. hal_rx_parse_receive_user_info(hal, rx_tlv, ppdu_info);
  1011. break;
  1012. case WIFIRX_PPDU_END_E:
  1013. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1014. "[%s][%d] ppdu_end_e len=%d",
  1015. __func__, __LINE__, tlv_len);
  1016. /* This is followed by sub-TLVs of PPDU_END */
  1017. ppdu_info->rx_state = HAL_RX_MON_PPDU_END;
  1018. break;
  1019. case WIFIPHYRX_LOCATION_E:
  1020. hal_rx_get_rtt_info(hal_soc_hdl, rx_tlv, ppdu_info);
  1021. break;
  1022. case WIFIRXPCU_PPDU_END_INFO_E:
  1023. ppdu_info->rx_status.rx_antenna =
  1024. HAL_RX_GET(rx_tlv, RXPCU_PPDU_END_INFO, RX_ANTENNA);
  1025. ppdu_info->rx_status.tsft =
  1026. HAL_RX_GET(rx_tlv, RXPCU_PPDU_END_INFO,
  1027. WB_TIMESTAMP_UPPER_32);
  1028. ppdu_info->rx_status.tsft = (ppdu_info->rx_status.tsft << 32) |
  1029. HAL_RX_GET(rx_tlv, RXPCU_PPDU_END_INFO,
  1030. WB_TIMESTAMP_LOWER_32);
  1031. ppdu_info->rx_status.duration =
  1032. HAL_RX_GET(rx_tlv, UNIFIED_RXPCU_PPDU_END_INFO_8,
  1033. RX_PPDU_DURATION);
  1034. hal_rx_get_bb_info(hal_soc_hdl, rx_tlv, ppdu_info);
  1035. break;
  1036. /*
  1037. * WIFIRX_PPDU_END_USER_STATS_E comes for each user received.
  1038. * for MU, based on num users we see this tlv that many times.
  1039. */
  1040. case WIFIRX_PPDU_END_USER_STATS_E:
  1041. {
  1042. unsigned long tid = 0;
  1043. uint16_t seq = 0;
  1044. ppdu_info->rx_status.ast_index =
  1045. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS,
  1046. AST_INDEX);
  1047. tid = HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS,
  1048. RECEIVED_QOS_DATA_TID_BITMAP);
  1049. ppdu_info->rx_status.tid = qdf_find_first_bit(&tid,
  1050. sizeof(tid) * 8);
  1051. if (ppdu_info->rx_status.tid == (sizeof(tid) * 8))
  1052. ppdu_info->rx_status.tid = HAL_TID_INVALID;
  1053. ppdu_info->rx_status.tcp_msdu_count =
  1054. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS,
  1055. TCP_MSDU_COUNT) +
  1056. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS,
  1057. TCP_ACK_MSDU_COUNT);
  1058. ppdu_info->rx_status.udp_msdu_count =
  1059. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS,
  1060. UDP_MSDU_COUNT);
  1061. ppdu_info->rx_status.other_msdu_count =
  1062. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS,
  1063. OTHER_MSDU_COUNT);
  1064. if (ppdu_info->sw_frame_group_id
  1065. != HAL_MPDU_SW_FRAME_GROUP_NULL_DATA) {
  1066. ppdu_info->rx_status.frame_control_info_valid =
  1067. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS,
  1068. FRAME_CONTROL_INFO_VALID);
  1069. if (ppdu_info->rx_status.frame_control_info_valid)
  1070. ppdu_info->rx_status.frame_control =
  1071. HAL_RX_GET(rx_tlv,
  1072. RX_PPDU_END_USER_STATS,
  1073. FRAME_CONTROL_FIELD);
  1074. hal_get_qos_control(rx_tlv, ppdu_info);
  1075. }
  1076. ppdu_info->rx_status.data_sequence_control_info_valid =
  1077. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS,
  1078. DATA_SEQUENCE_CONTROL_INFO_VALID);
  1079. seq = HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS,
  1080. FIRST_DATA_SEQ_CTRL);
  1081. if (ppdu_info->rx_status.data_sequence_control_info_valid)
  1082. ppdu_info->rx_status.first_data_seq_ctrl = seq;
  1083. ppdu_info->rx_status.preamble_type =
  1084. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS,
  1085. HT_CONTROL_FIELD_PKT_TYPE);
  1086. switch (ppdu_info->rx_status.preamble_type) {
  1087. case HAL_RX_PKT_TYPE_11N:
  1088. ppdu_info->rx_status.ht_flags = 1;
  1089. ppdu_info->rx_status.rtap_flags |= HT_SGI_PRESENT;
  1090. break;
  1091. case HAL_RX_PKT_TYPE_11AC:
  1092. ppdu_info->rx_status.vht_flags = 1;
  1093. break;
  1094. case HAL_RX_PKT_TYPE_11AX:
  1095. ppdu_info->rx_status.he_flags = 1;
  1096. break;
  1097. default:
  1098. break;
  1099. }
  1100. ppdu_info->com_info.mpdu_cnt_fcs_ok =
  1101. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS,
  1102. MPDU_CNT_FCS_OK);
  1103. ppdu_info->com_info.mpdu_cnt_fcs_err =
  1104. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS,
  1105. MPDU_CNT_FCS_ERR);
  1106. if ((ppdu_info->com_info.mpdu_cnt_fcs_ok |
  1107. ppdu_info->com_info.mpdu_cnt_fcs_err) > 1)
  1108. ppdu_info->rx_status.rs_flags |= IEEE80211_AMPDU_FLAG;
  1109. else
  1110. ppdu_info->rx_status.rs_flags &=
  1111. (~IEEE80211_AMPDU_FLAG);
  1112. ppdu_info->com_info.mpdu_fcs_ok_bitmap[0] =
  1113. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS,
  1114. FCS_OK_BITMAP_31_0);
  1115. ppdu_info->com_info.mpdu_fcs_ok_bitmap[1] =
  1116. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS,
  1117. FCS_OK_BITMAP_63_32);
  1118. if (user_id < HAL_MAX_UL_MU_USERS) {
  1119. mon_rx_user_status =
  1120. &ppdu_info->rx_user_status[user_id];
  1121. hal_rx_handle_mu_ul_info(rx_tlv, mon_rx_user_status);
  1122. ppdu_info->com_info.num_users++;
  1123. hal_rx_populate_mu_user_info(rx_tlv, ppdu_info,
  1124. user_id,
  1125. mon_rx_user_status);
  1126. }
  1127. break;
  1128. }
  1129. case WIFIRX_PPDU_END_USER_STATS_EXT_E:
  1130. ppdu_info->com_info.mpdu_fcs_ok_bitmap[2] =
  1131. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS_EXT,
  1132. FCS_OK_BITMAP_95_64);
  1133. ppdu_info->com_info.mpdu_fcs_ok_bitmap[3] =
  1134. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS_EXT,
  1135. FCS_OK_BITMAP_127_96);
  1136. ppdu_info->com_info.mpdu_fcs_ok_bitmap[4] =
  1137. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS_EXT,
  1138. FCS_OK_BITMAP_159_128);
  1139. ppdu_info->com_info.mpdu_fcs_ok_bitmap[5] =
  1140. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS_EXT,
  1141. FCS_OK_BITMAP_191_160);
  1142. ppdu_info->com_info.mpdu_fcs_ok_bitmap[6] =
  1143. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS_EXT,
  1144. FCS_OK_BITMAP_223_192);
  1145. ppdu_info->com_info.mpdu_fcs_ok_bitmap[7] =
  1146. HAL_RX_GET(rx_tlv, RX_PPDU_END_USER_STATS_EXT,
  1147. FCS_OK_BITMAP_255_224);
  1148. break;
  1149. case WIFIRX_PPDU_END_STATUS_DONE_E:
  1150. return HAL_TLV_STATUS_PPDU_DONE;
  1151. case WIFIDUMMY_E:
  1152. return HAL_TLV_STATUS_BUF_DONE;
  1153. case WIFIPHYRX_HT_SIG_E:
  1154. {
  1155. uint8_t *ht_sig_info = (uint8_t *)rx_tlv +
  1156. HAL_RX_OFFSET(UNIFIED_PHYRX_HT_SIG_0,
  1157. HT_SIG_INFO_PHYRX_HT_SIG_INFO_DETAILS);
  1158. value = HAL_RX_GET(ht_sig_info, HT_SIG_INFO,
  1159. FEC_CODING);
  1160. ppdu_info->rx_status.ldpc = (value == HAL_SU_MU_CODING_LDPC) ?
  1161. 1 : 0;
  1162. ppdu_info->rx_status.mcs = HAL_RX_GET(ht_sig_info,
  1163. HT_SIG_INFO, MCS);
  1164. ppdu_info->rx_status.ht_mcs = ppdu_info->rx_status.mcs;
  1165. ppdu_info->rx_status.bw = HAL_RX_GET(ht_sig_info,
  1166. HT_SIG_INFO, CBW);
  1167. ppdu_info->rx_status.sgi = HAL_RX_GET(ht_sig_info,
  1168. HT_SIG_INFO, SHORT_GI);
  1169. ppdu_info->rx_status.reception_type = HAL_RX_TYPE_SU;
  1170. ppdu_info->rx_status.nss = ((ppdu_info->rx_status.mcs) >>
  1171. HT_SIG_SU_NSS_SHIFT) + 1;
  1172. ppdu_info->rx_status.mcs &= ((1 << HT_SIG_SU_NSS_SHIFT) - 1);
  1173. break;
  1174. }
  1175. case WIFIPHYRX_L_SIG_B_E:
  1176. {
  1177. uint8_t *l_sig_b_info = (uint8_t *)rx_tlv +
  1178. HAL_RX_OFFSET(UNIFIED_PHYRX_L_SIG_B_0,
  1179. L_SIG_B_INFO_PHYRX_L_SIG_B_INFO_DETAILS);
  1180. value = HAL_RX_GET(l_sig_b_info, L_SIG_B_INFO, RATE);
  1181. ppdu_info->rx_status.l_sig_b_info = *((uint32_t *)l_sig_b_info);
  1182. switch (value) {
  1183. case 1:
  1184. ppdu_info->rx_status.rate = HAL_11B_RATE_3MCS;
  1185. ppdu_info->rx_status.mcs = HAL_LEGACY_MCS3;
  1186. break;
  1187. case 2:
  1188. ppdu_info->rx_status.rate = HAL_11B_RATE_2MCS;
  1189. ppdu_info->rx_status.mcs = HAL_LEGACY_MCS2;
  1190. break;
  1191. case 3:
  1192. ppdu_info->rx_status.rate = HAL_11B_RATE_1MCS;
  1193. ppdu_info->rx_status.mcs = HAL_LEGACY_MCS1;
  1194. break;
  1195. case 4:
  1196. ppdu_info->rx_status.rate = HAL_11B_RATE_0MCS;
  1197. ppdu_info->rx_status.mcs = HAL_LEGACY_MCS0;
  1198. break;
  1199. case 5:
  1200. ppdu_info->rx_status.rate = HAL_11B_RATE_6MCS;
  1201. ppdu_info->rx_status.mcs = HAL_LEGACY_MCS6;
  1202. break;
  1203. case 6:
  1204. ppdu_info->rx_status.rate = HAL_11B_RATE_5MCS;
  1205. ppdu_info->rx_status.mcs = HAL_LEGACY_MCS5;
  1206. break;
  1207. case 7:
  1208. ppdu_info->rx_status.rate = HAL_11B_RATE_4MCS;
  1209. ppdu_info->rx_status.mcs = HAL_LEGACY_MCS4;
  1210. break;
  1211. default:
  1212. break;
  1213. }
  1214. ppdu_info->rx_status.cck_flag = 1;
  1215. ppdu_info->rx_status.reception_type = HAL_RX_TYPE_SU;
  1216. break;
  1217. }
  1218. case WIFIPHYRX_L_SIG_A_E:
  1219. {
  1220. uint8_t *l_sig_a_info = (uint8_t *)rx_tlv +
  1221. HAL_RX_OFFSET(UNIFIED_PHYRX_L_SIG_A_0,
  1222. L_SIG_A_INFO_PHYRX_L_SIG_A_INFO_DETAILS);
  1223. value = HAL_RX_GET(l_sig_a_info, L_SIG_A_INFO, RATE);
  1224. ppdu_info->rx_status.l_sig_a_info = *((uint32_t *)l_sig_a_info);
  1225. switch (value) {
  1226. case 8:
  1227. ppdu_info->rx_status.rate = HAL_11A_RATE_0MCS;
  1228. ppdu_info->rx_status.mcs = HAL_LEGACY_MCS0;
  1229. break;
  1230. case 9:
  1231. ppdu_info->rx_status.rate = HAL_11A_RATE_1MCS;
  1232. ppdu_info->rx_status.mcs = HAL_LEGACY_MCS1;
  1233. break;
  1234. case 10:
  1235. ppdu_info->rx_status.rate = HAL_11A_RATE_2MCS;
  1236. ppdu_info->rx_status.mcs = HAL_LEGACY_MCS2;
  1237. break;
  1238. case 11:
  1239. ppdu_info->rx_status.rate = HAL_11A_RATE_3MCS;
  1240. ppdu_info->rx_status.mcs = HAL_LEGACY_MCS3;
  1241. break;
  1242. case 12:
  1243. ppdu_info->rx_status.rate = HAL_11A_RATE_4MCS;
  1244. ppdu_info->rx_status.mcs = HAL_LEGACY_MCS4;
  1245. break;
  1246. case 13:
  1247. ppdu_info->rx_status.rate = HAL_11A_RATE_5MCS;
  1248. ppdu_info->rx_status.mcs = HAL_LEGACY_MCS5;
  1249. break;
  1250. case 14:
  1251. ppdu_info->rx_status.rate = HAL_11A_RATE_6MCS;
  1252. ppdu_info->rx_status.mcs = HAL_LEGACY_MCS6;
  1253. break;
  1254. case 15:
  1255. ppdu_info->rx_status.rate = HAL_11A_RATE_7MCS;
  1256. ppdu_info->rx_status.mcs = HAL_LEGACY_MCS7;
  1257. break;
  1258. default:
  1259. break;
  1260. }
  1261. ppdu_info->rx_status.ofdm_flag = 1;
  1262. ppdu_info->rx_status.reception_type = HAL_RX_TYPE_SU;
  1263. break;
  1264. }
  1265. case WIFIPHYRX_VHT_SIG_A_E:
  1266. {
  1267. uint8_t *vht_sig_a_info = (uint8_t *)rx_tlv +
  1268. HAL_RX_OFFSET(UNIFIED_PHYRX_VHT_SIG_A_0,
  1269. VHT_SIG_A_INFO_PHYRX_VHT_SIG_A_INFO_DETAILS);
  1270. value = HAL_RX_GET(vht_sig_a_info, VHT_SIG_A_INFO,
  1271. SU_MU_CODING);
  1272. ppdu_info->rx_status.ldpc = (value == HAL_SU_MU_CODING_LDPC) ?
  1273. 1 : 0;
  1274. group_id = HAL_RX_GET(vht_sig_a_info, VHT_SIG_A_INFO, GROUP_ID);
  1275. ppdu_info->rx_status.vht_flag_values5 = group_id;
  1276. ppdu_info->rx_status.mcs = HAL_RX_GET(vht_sig_a_info,
  1277. VHT_SIG_A_INFO, MCS);
  1278. ppdu_info->rx_status.sgi = HAL_RX_GET(vht_sig_a_info,
  1279. VHT_SIG_A_INFO, GI_SETTING);
  1280. switch (hal->target_type) {
  1281. case TARGET_TYPE_QCA8074:
  1282. case TARGET_TYPE_QCA8074V2:
  1283. case TARGET_TYPE_QCA6018:
  1284. case TARGET_TYPE_QCA5018:
  1285. case TARGET_TYPE_QCN9000:
  1286. case TARGET_TYPE_QCN6122:
  1287. #ifdef QCA_WIFI_QCA6390
  1288. case TARGET_TYPE_QCA6390:
  1289. #endif
  1290. ppdu_info->rx_status.is_stbc =
  1291. HAL_RX_GET(vht_sig_a_info,
  1292. VHT_SIG_A_INFO, STBC);
  1293. value = HAL_RX_GET(vht_sig_a_info,
  1294. VHT_SIG_A_INFO, N_STS);
  1295. value = value & VHT_SIG_SU_NSS_MASK;
  1296. if (ppdu_info->rx_status.is_stbc && (value > 0))
  1297. value = ((value + 1) >> 1) - 1;
  1298. ppdu_info->rx_status.nss =
  1299. ((value & VHT_SIG_SU_NSS_MASK) + 1);
  1300. break;
  1301. case TARGET_TYPE_QCA6290:
  1302. #if !defined(QCA_WIFI_QCA6290_11AX)
  1303. ppdu_info->rx_status.is_stbc =
  1304. HAL_RX_GET(vht_sig_a_info,
  1305. VHT_SIG_A_INFO, STBC);
  1306. value = HAL_RX_GET(vht_sig_a_info,
  1307. VHT_SIG_A_INFO, N_STS);
  1308. value = value & VHT_SIG_SU_NSS_MASK;
  1309. if (ppdu_info->rx_status.is_stbc && (value > 0))
  1310. value = ((value + 1) >> 1) - 1;
  1311. ppdu_info->rx_status.nss =
  1312. ((value & VHT_SIG_SU_NSS_MASK) + 1);
  1313. #else
  1314. ppdu_info->rx_status.nss = 0;
  1315. #endif
  1316. break;
  1317. case TARGET_TYPE_QCA6490:
  1318. case TARGET_TYPE_QCA6750:
  1319. case TARGET_TYPE_KIWI:
  1320. ppdu_info->rx_status.nss = 0;
  1321. break;
  1322. default:
  1323. break;
  1324. }
  1325. ppdu_info->rx_status.vht_flag_values3[0] =
  1326. (((ppdu_info->rx_status.mcs) << 4)
  1327. | ppdu_info->rx_status.nss);
  1328. ppdu_info->rx_status.bw = HAL_RX_GET(vht_sig_a_info,
  1329. VHT_SIG_A_INFO, BANDWIDTH);
  1330. ppdu_info->rx_status.vht_flag_values2 =
  1331. ppdu_info->rx_status.bw;
  1332. ppdu_info->rx_status.vht_flag_values4 =
  1333. HAL_RX_GET(vht_sig_a_info,
  1334. VHT_SIG_A_INFO, SU_MU_CODING);
  1335. ppdu_info->rx_status.beamformed = HAL_RX_GET(vht_sig_a_info,
  1336. VHT_SIG_A_INFO, BEAMFORMED);
  1337. if (group_id == 0 || group_id == 63)
  1338. ppdu_info->rx_status.reception_type = HAL_RX_TYPE_SU;
  1339. else
  1340. ppdu_info->rx_status.reception_type =
  1341. HAL_RX_TYPE_MU_MIMO;
  1342. break;
  1343. }
  1344. case WIFIPHYRX_HE_SIG_A_SU_E:
  1345. {
  1346. uint8_t *he_sig_a_su_info = (uint8_t *)rx_tlv +
  1347. HAL_RX_OFFSET(UNIFIED_PHYRX_HE_SIG_A_SU_0,
  1348. HE_SIG_A_SU_INFO_PHYRX_HE_SIG_A_SU_INFO_DETAILS);
  1349. ppdu_info->rx_status.he_flags = 1;
  1350. value = HAL_RX_GET(he_sig_a_su_info, HE_SIG_A_SU_INFO,
  1351. FORMAT_INDICATION);
  1352. if (value == 0) {
  1353. ppdu_info->rx_status.he_data1 =
  1354. QDF_MON_STATUS_HE_TRIG_FORMAT_TYPE;
  1355. } else {
  1356. ppdu_info->rx_status.he_data1 =
  1357. QDF_MON_STATUS_HE_SU_FORMAT_TYPE;
  1358. }
  1359. /* data1 */
  1360. ppdu_info->rx_status.he_data1 |=
  1361. QDF_MON_STATUS_HE_BSS_COLOR_KNOWN |
  1362. QDF_MON_STATUS_HE_BEAM_CHANGE_KNOWN |
  1363. QDF_MON_STATUS_HE_DL_UL_KNOWN |
  1364. QDF_MON_STATUS_HE_MCS_KNOWN |
  1365. QDF_MON_STATUS_HE_DCM_KNOWN |
  1366. QDF_MON_STATUS_HE_CODING_KNOWN |
  1367. QDF_MON_STATUS_HE_LDPC_EXTRA_SYMBOL_KNOWN |
  1368. QDF_MON_STATUS_HE_STBC_KNOWN |
  1369. QDF_MON_STATUS_HE_DATA_BW_RU_KNOWN |
  1370. QDF_MON_STATUS_HE_DOPPLER_KNOWN;
  1371. /* data2 */
  1372. ppdu_info->rx_status.he_data2 =
  1373. QDF_MON_STATUS_HE_GI_KNOWN;
  1374. ppdu_info->rx_status.he_data2 |=
  1375. QDF_MON_STATUS_TXBF_KNOWN |
  1376. QDF_MON_STATUS_PE_DISAMBIGUITY_KNOWN |
  1377. QDF_MON_STATUS_TXOP_KNOWN |
  1378. QDF_MON_STATUS_LTF_SYMBOLS_KNOWN |
  1379. QDF_MON_STATUS_PRE_FEC_PADDING_KNOWN |
  1380. QDF_MON_STATUS_MIDABLE_PERIODICITY_KNOWN;
  1381. /* data3 */
  1382. value = HAL_RX_GET(he_sig_a_su_info,
  1383. HE_SIG_A_SU_INFO, BSS_COLOR_ID);
  1384. ppdu_info->rx_status.he_data3 = value;
  1385. value = HAL_RX_GET(he_sig_a_su_info,
  1386. HE_SIG_A_SU_INFO, BEAM_CHANGE);
  1387. value = value << QDF_MON_STATUS_BEAM_CHANGE_SHIFT;
  1388. ppdu_info->rx_status.he_data3 |= value;
  1389. value = HAL_RX_GET(he_sig_a_su_info,
  1390. HE_SIG_A_SU_INFO, DL_UL_FLAG);
  1391. value = value << QDF_MON_STATUS_DL_UL_SHIFT;
  1392. ppdu_info->rx_status.he_data3 |= value;
  1393. value = HAL_RX_GET(he_sig_a_su_info,
  1394. HE_SIG_A_SU_INFO, TRANSMIT_MCS);
  1395. ppdu_info->rx_status.mcs = value;
  1396. value = value << QDF_MON_STATUS_TRANSMIT_MCS_SHIFT;
  1397. ppdu_info->rx_status.he_data3 |= value;
  1398. value = HAL_RX_GET(he_sig_a_su_info,
  1399. HE_SIG_A_SU_INFO, DCM);
  1400. he_dcm = value;
  1401. value = value << QDF_MON_STATUS_DCM_SHIFT;
  1402. ppdu_info->rx_status.he_data3 |= value;
  1403. value = HAL_RX_GET(he_sig_a_su_info,
  1404. HE_SIG_A_SU_INFO, CODING);
  1405. ppdu_info->rx_status.ldpc = (value == HAL_SU_MU_CODING_LDPC) ?
  1406. 1 : 0;
  1407. value = value << QDF_MON_STATUS_CODING_SHIFT;
  1408. ppdu_info->rx_status.he_data3 |= value;
  1409. value = HAL_RX_GET(he_sig_a_su_info,
  1410. HE_SIG_A_SU_INFO,
  1411. LDPC_EXTRA_SYMBOL);
  1412. value = value << QDF_MON_STATUS_LDPC_EXTRA_SYMBOL_SHIFT;
  1413. ppdu_info->rx_status.he_data3 |= value;
  1414. value = HAL_RX_GET(he_sig_a_su_info,
  1415. HE_SIG_A_SU_INFO, STBC);
  1416. he_stbc = value;
  1417. value = value << QDF_MON_STATUS_STBC_SHIFT;
  1418. ppdu_info->rx_status.he_data3 |= value;
  1419. /* data4 */
  1420. value = HAL_RX_GET(he_sig_a_su_info, HE_SIG_A_SU_INFO,
  1421. SPATIAL_REUSE);
  1422. ppdu_info->rx_status.he_data4 = value;
  1423. /* data5 */
  1424. value = HAL_RX_GET(he_sig_a_su_info,
  1425. HE_SIG_A_SU_INFO, TRANSMIT_BW);
  1426. ppdu_info->rx_status.he_data5 = value;
  1427. ppdu_info->rx_status.bw = value;
  1428. value = HAL_RX_GET(he_sig_a_su_info,
  1429. HE_SIG_A_SU_INFO, CP_LTF_SIZE);
  1430. switch (value) {
  1431. case 0:
  1432. he_gi = HE_GI_0_8;
  1433. he_ltf = HE_LTF_1_X;
  1434. break;
  1435. case 1:
  1436. he_gi = HE_GI_0_8;
  1437. he_ltf = HE_LTF_2_X;
  1438. break;
  1439. case 2:
  1440. he_gi = HE_GI_1_6;
  1441. he_ltf = HE_LTF_2_X;
  1442. break;
  1443. case 3:
  1444. if (he_dcm && he_stbc) {
  1445. he_gi = HE_GI_0_8;
  1446. he_ltf = HE_LTF_4_X;
  1447. } else {
  1448. he_gi = HE_GI_3_2;
  1449. he_ltf = HE_LTF_4_X;
  1450. }
  1451. break;
  1452. }
  1453. ppdu_info->rx_status.sgi = he_gi;
  1454. ppdu_info->rx_status.ltf_size = he_ltf;
  1455. hal_get_radiotap_he_gi_ltf(&he_gi, &he_ltf);
  1456. value = he_gi << QDF_MON_STATUS_GI_SHIFT;
  1457. ppdu_info->rx_status.he_data5 |= value;
  1458. value = he_ltf << QDF_MON_STATUS_HE_LTF_SIZE_SHIFT;
  1459. ppdu_info->rx_status.he_data5 |= value;
  1460. value = HAL_RX_GET(he_sig_a_su_info, HE_SIG_A_SU_INFO, NSTS);
  1461. value = (value << QDF_MON_STATUS_HE_LTF_SYM_SHIFT);
  1462. ppdu_info->rx_status.he_data5 |= value;
  1463. value = HAL_RX_GET(he_sig_a_su_info, HE_SIG_A_SU_INFO,
  1464. PACKET_EXTENSION_A_FACTOR);
  1465. value = value << QDF_MON_STATUS_PRE_FEC_PAD_SHIFT;
  1466. ppdu_info->rx_status.he_data5 |= value;
  1467. value = HAL_RX_GET(he_sig_a_su_info, HE_SIG_A_SU_INFO, TXBF);
  1468. value = value << QDF_MON_STATUS_TXBF_SHIFT;
  1469. ppdu_info->rx_status.he_data5 |= value;
  1470. value = HAL_RX_GET(he_sig_a_su_info, HE_SIG_A_SU_INFO,
  1471. PACKET_EXTENSION_PE_DISAMBIGUITY);
  1472. value = value << QDF_MON_STATUS_PE_DISAMBIGUITY_SHIFT;
  1473. ppdu_info->rx_status.he_data5 |= value;
  1474. /* data6 */
  1475. value = HAL_RX_GET(he_sig_a_su_info, HE_SIG_A_SU_INFO, NSTS);
  1476. value++;
  1477. ppdu_info->rx_status.nss = value;
  1478. ppdu_info->rx_status.he_data6 = value;
  1479. value = HAL_RX_GET(he_sig_a_su_info, HE_SIG_A_SU_INFO,
  1480. DOPPLER_INDICATION);
  1481. value = value << QDF_MON_STATUS_DOPPLER_SHIFT;
  1482. ppdu_info->rx_status.he_data6 |= value;
  1483. value = HAL_RX_GET(he_sig_a_su_info, HE_SIG_A_SU_INFO,
  1484. TXOP_DURATION);
  1485. value = value << QDF_MON_STATUS_TXOP_SHIFT;
  1486. ppdu_info->rx_status.he_data6 |= value;
  1487. ppdu_info->rx_status.beamformed = HAL_RX_GET(he_sig_a_su_info,
  1488. HE_SIG_A_SU_INFO, TXBF);
  1489. ppdu_info->rx_status.reception_type = HAL_RX_TYPE_SU;
  1490. break;
  1491. }
  1492. case WIFIPHYRX_HE_SIG_A_MU_DL_E:
  1493. {
  1494. uint8_t *he_sig_a_mu_dl_info = (uint8_t *)rx_tlv +
  1495. HAL_RX_OFFSET(UNIFIED_PHYRX_HE_SIG_A_MU_DL_0,
  1496. HE_SIG_A_MU_DL_INFO_PHYRX_HE_SIG_A_MU_DL_INFO_DETAILS);
  1497. ppdu_info->rx_status.he_mu_flags = 1;
  1498. /* HE Flags */
  1499. /*data1*/
  1500. ppdu_info->rx_status.he_data1 =
  1501. QDF_MON_STATUS_HE_MU_FORMAT_TYPE;
  1502. ppdu_info->rx_status.he_data1 |=
  1503. QDF_MON_STATUS_HE_BSS_COLOR_KNOWN |
  1504. QDF_MON_STATUS_HE_DL_UL_KNOWN |
  1505. QDF_MON_STATUS_HE_LDPC_EXTRA_SYMBOL_KNOWN |
  1506. QDF_MON_STATUS_HE_STBC_KNOWN |
  1507. QDF_MON_STATUS_HE_DATA_BW_RU_KNOWN |
  1508. QDF_MON_STATUS_HE_DOPPLER_KNOWN;
  1509. /* data2 */
  1510. ppdu_info->rx_status.he_data2 =
  1511. QDF_MON_STATUS_HE_GI_KNOWN;
  1512. ppdu_info->rx_status.he_data2 |=
  1513. QDF_MON_STATUS_LTF_SYMBOLS_KNOWN |
  1514. QDF_MON_STATUS_PRE_FEC_PADDING_KNOWN |
  1515. QDF_MON_STATUS_PE_DISAMBIGUITY_KNOWN |
  1516. QDF_MON_STATUS_TXOP_KNOWN |
  1517. QDF_MON_STATUS_MIDABLE_PERIODICITY_KNOWN;
  1518. /*data3*/
  1519. value = HAL_RX_GET(he_sig_a_mu_dl_info,
  1520. HE_SIG_A_MU_DL_INFO, BSS_COLOR_ID);
  1521. ppdu_info->rx_status.he_data3 = value;
  1522. value = HAL_RX_GET(he_sig_a_mu_dl_info,
  1523. HE_SIG_A_MU_DL_INFO, DL_UL_FLAG);
  1524. value = value << QDF_MON_STATUS_DL_UL_SHIFT;
  1525. ppdu_info->rx_status.he_data3 |= value;
  1526. value = HAL_RX_GET(he_sig_a_mu_dl_info,
  1527. HE_SIG_A_MU_DL_INFO,
  1528. LDPC_EXTRA_SYMBOL);
  1529. value = value << QDF_MON_STATUS_LDPC_EXTRA_SYMBOL_SHIFT;
  1530. ppdu_info->rx_status.he_data3 |= value;
  1531. value = HAL_RX_GET(he_sig_a_mu_dl_info,
  1532. HE_SIG_A_MU_DL_INFO, STBC);
  1533. he_stbc = value;
  1534. value = value << QDF_MON_STATUS_STBC_SHIFT;
  1535. ppdu_info->rx_status.he_data3 |= value;
  1536. /*data4*/
  1537. value = HAL_RX_GET(he_sig_a_mu_dl_info, HE_SIG_A_MU_DL_INFO,
  1538. SPATIAL_REUSE);
  1539. ppdu_info->rx_status.he_data4 = value;
  1540. /*data5*/
  1541. value = HAL_RX_GET(he_sig_a_mu_dl_info,
  1542. HE_SIG_A_MU_DL_INFO, TRANSMIT_BW);
  1543. ppdu_info->rx_status.he_data5 = value;
  1544. ppdu_info->rx_status.bw = value;
  1545. value = HAL_RX_GET(he_sig_a_mu_dl_info,
  1546. HE_SIG_A_MU_DL_INFO, CP_LTF_SIZE);
  1547. switch (value) {
  1548. case 0:
  1549. he_gi = HE_GI_0_8;
  1550. he_ltf = HE_LTF_4_X;
  1551. break;
  1552. case 1:
  1553. he_gi = HE_GI_0_8;
  1554. he_ltf = HE_LTF_2_X;
  1555. break;
  1556. case 2:
  1557. he_gi = HE_GI_1_6;
  1558. he_ltf = HE_LTF_2_X;
  1559. break;
  1560. case 3:
  1561. he_gi = HE_GI_3_2;
  1562. he_ltf = HE_LTF_4_X;
  1563. break;
  1564. }
  1565. ppdu_info->rx_status.sgi = he_gi;
  1566. ppdu_info->rx_status.ltf_size = he_ltf;
  1567. hal_get_radiotap_he_gi_ltf(&he_gi, &he_ltf);
  1568. value = he_gi << QDF_MON_STATUS_GI_SHIFT;
  1569. ppdu_info->rx_status.he_data5 |= value;
  1570. value = he_ltf << QDF_MON_STATUS_HE_LTF_SIZE_SHIFT;
  1571. ppdu_info->rx_status.he_data5 |= value;
  1572. value = HAL_RX_GET(he_sig_a_mu_dl_info,
  1573. HE_SIG_A_MU_DL_INFO, NUM_LTF_SYMBOLS);
  1574. value = (value << QDF_MON_STATUS_HE_LTF_SYM_SHIFT);
  1575. ppdu_info->rx_status.he_data5 |= value;
  1576. value = HAL_RX_GET(he_sig_a_mu_dl_info, HE_SIG_A_MU_DL_INFO,
  1577. PACKET_EXTENSION_A_FACTOR);
  1578. value = value << QDF_MON_STATUS_PRE_FEC_PAD_SHIFT;
  1579. ppdu_info->rx_status.he_data5 |= value;
  1580. value = HAL_RX_GET(he_sig_a_mu_dl_info, HE_SIG_A_MU_DL_INFO,
  1581. PACKET_EXTENSION_PE_DISAMBIGUITY);
  1582. value = value << QDF_MON_STATUS_PE_DISAMBIGUITY_SHIFT;
  1583. ppdu_info->rx_status.he_data5 |= value;
  1584. /*data6*/
  1585. value = HAL_RX_GET(he_sig_a_mu_dl_info, HE_SIG_A_MU_DL_INFO,
  1586. DOPPLER_INDICATION);
  1587. value = value << QDF_MON_STATUS_DOPPLER_SHIFT;
  1588. ppdu_info->rx_status.he_data6 |= value;
  1589. value = HAL_RX_GET(he_sig_a_mu_dl_info, HE_SIG_A_MU_DL_INFO,
  1590. TXOP_DURATION);
  1591. value = value << QDF_MON_STATUS_TXOP_SHIFT;
  1592. ppdu_info->rx_status.he_data6 |= value;
  1593. /* HE-MU Flags */
  1594. /* HE-MU-flags1 */
  1595. ppdu_info->rx_status.he_flags1 =
  1596. QDF_MON_STATUS_SIG_B_MCS_KNOWN |
  1597. QDF_MON_STATUS_SIG_B_DCM_KNOWN |
  1598. QDF_MON_STATUS_SIG_B_COMPRESSION_FLAG_1_KNOWN |
  1599. QDF_MON_STATUS_SIG_B_SYM_NUM_KNOWN |
  1600. QDF_MON_STATUS_RU_0_KNOWN;
  1601. value = HAL_RX_GET(he_sig_a_mu_dl_info,
  1602. HE_SIG_A_MU_DL_INFO, MCS_OF_SIG_B);
  1603. ppdu_info->rx_status.he_flags1 |= value;
  1604. value = HAL_RX_GET(he_sig_a_mu_dl_info,
  1605. HE_SIG_A_MU_DL_INFO, DCM_OF_SIG_B);
  1606. value = value << QDF_MON_STATUS_DCM_FLAG_1_SHIFT;
  1607. ppdu_info->rx_status.he_flags1 |= value;
  1608. /* HE-MU-flags2 */
  1609. ppdu_info->rx_status.he_flags2 =
  1610. QDF_MON_STATUS_BW_KNOWN;
  1611. value = HAL_RX_GET(he_sig_a_mu_dl_info,
  1612. HE_SIG_A_MU_DL_INFO, TRANSMIT_BW);
  1613. ppdu_info->rx_status.he_flags2 |= value;
  1614. value = HAL_RX_GET(he_sig_a_mu_dl_info,
  1615. HE_SIG_A_MU_DL_INFO, COMP_MODE_SIG_B);
  1616. value = value << QDF_MON_STATUS_SIG_B_COMPRESSION_FLAG_2_SHIFT;
  1617. ppdu_info->rx_status.he_flags2 |= value;
  1618. value = HAL_RX_GET(he_sig_a_mu_dl_info,
  1619. HE_SIG_A_MU_DL_INFO, NUM_SIG_B_SYMBOLS);
  1620. value = value - 1;
  1621. value = value << QDF_MON_STATUS_NUM_SIG_B_SYMBOLS_SHIFT;
  1622. ppdu_info->rx_status.he_flags2 |= value;
  1623. ppdu_info->rx_status.reception_type = HAL_RX_TYPE_MU_MIMO;
  1624. break;
  1625. }
  1626. case WIFIPHYRX_HE_SIG_B1_MU_E:
  1627. {
  1628. uint8_t *he_sig_b1_mu_info = (uint8_t *)rx_tlv +
  1629. HAL_RX_OFFSET(UNIFIED_PHYRX_HE_SIG_B1_MU_0,
  1630. HE_SIG_B1_MU_INFO_PHYRX_HE_SIG_B1_MU_INFO_DETAILS);
  1631. ppdu_info->rx_status.he_sig_b_common_known |=
  1632. QDF_MON_STATUS_HE_SIG_B_COMMON_KNOWN_RU0;
  1633. /* TODO: Check on the availability of other fields in
  1634. * sig_b_common
  1635. */
  1636. value = HAL_RX_GET(he_sig_b1_mu_info,
  1637. HE_SIG_B1_MU_INFO, RU_ALLOCATION);
  1638. ppdu_info->rx_status.he_RU[0] = value;
  1639. ppdu_info->rx_status.reception_type = HAL_RX_TYPE_MU_MIMO;
  1640. break;
  1641. }
  1642. case WIFIPHYRX_HE_SIG_B2_MU_E:
  1643. {
  1644. uint8_t *he_sig_b2_mu_info = (uint8_t *)rx_tlv +
  1645. HAL_RX_OFFSET(UNIFIED_PHYRX_HE_SIG_B2_MU_0,
  1646. HE_SIG_B2_MU_INFO_PHYRX_HE_SIG_B2_MU_INFO_DETAILS);
  1647. /*
  1648. * Not all "HE" fields can be updated from
  1649. * WIFIPHYRX_HE_SIG_A_MU_DL_E TLV. Use WIFIPHYRX_HE_SIG_B2_MU_E
  1650. * to populate rest of the "HE" fields for MU scenarios.
  1651. */
  1652. /* HE-data1 */
  1653. ppdu_info->rx_status.he_data1 |=
  1654. QDF_MON_STATUS_HE_MCS_KNOWN |
  1655. QDF_MON_STATUS_HE_CODING_KNOWN;
  1656. /* HE-data2 */
  1657. /* HE-data3 */
  1658. value = HAL_RX_GET(he_sig_b2_mu_info,
  1659. HE_SIG_B2_MU_INFO, STA_MCS);
  1660. ppdu_info->rx_status.mcs = value;
  1661. value = value << QDF_MON_STATUS_TRANSMIT_MCS_SHIFT;
  1662. ppdu_info->rx_status.he_data3 |= value;
  1663. value = HAL_RX_GET(he_sig_b2_mu_info,
  1664. HE_SIG_B2_MU_INFO, STA_CODING);
  1665. value = value << QDF_MON_STATUS_CODING_SHIFT;
  1666. ppdu_info->rx_status.he_data3 |= value;
  1667. /* HE-data4 */
  1668. value = HAL_RX_GET(he_sig_b2_mu_info,
  1669. HE_SIG_B2_MU_INFO, STA_ID);
  1670. value = value << QDF_MON_STATUS_STA_ID_SHIFT;
  1671. ppdu_info->rx_status.he_data4 |= value;
  1672. /* HE-data5 */
  1673. /* HE-data6 */
  1674. value = HAL_RX_GET(he_sig_b2_mu_info,
  1675. HE_SIG_B2_MU_INFO, NSTS);
  1676. /* value n indicates n+1 spatial streams */
  1677. value++;
  1678. ppdu_info->rx_status.nss = value;
  1679. ppdu_info->rx_status.he_data6 |= value;
  1680. break;
  1681. }
  1682. case WIFIPHYRX_HE_SIG_B2_OFDMA_E:
  1683. {
  1684. uint8_t *he_sig_b2_ofdma_info =
  1685. (uint8_t *)rx_tlv +
  1686. HAL_RX_OFFSET(UNIFIED_PHYRX_HE_SIG_B2_OFDMA_0,
  1687. HE_SIG_B2_OFDMA_INFO_PHYRX_HE_SIG_B2_OFDMA_INFO_DETAILS);
  1688. /*
  1689. * Not all "HE" fields can be updated from
  1690. * WIFIPHYRX_HE_SIG_A_MU_DL_E TLV. Use WIFIPHYRX_HE_SIG_B2_MU_E
  1691. * to populate rest of "HE" fields for MU OFDMA scenarios.
  1692. */
  1693. /* HE-data1 */
  1694. ppdu_info->rx_status.he_data1 |=
  1695. QDF_MON_STATUS_HE_MCS_KNOWN |
  1696. QDF_MON_STATUS_HE_DCM_KNOWN |
  1697. QDF_MON_STATUS_HE_CODING_KNOWN;
  1698. /* HE-data2 */
  1699. ppdu_info->rx_status.he_data2 |=
  1700. QDF_MON_STATUS_TXBF_KNOWN;
  1701. /* HE-data3 */
  1702. value = HAL_RX_GET(he_sig_b2_ofdma_info,
  1703. HE_SIG_B2_OFDMA_INFO, STA_MCS);
  1704. ppdu_info->rx_status.mcs = value;
  1705. value = value << QDF_MON_STATUS_TRANSMIT_MCS_SHIFT;
  1706. ppdu_info->rx_status.he_data3 |= value;
  1707. value = HAL_RX_GET(he_sig_b2_ofdma_info,
  1708. HE_SIG_B2_OFDMA_INFO, STA_DCM);
  1709. he_dcm = value;
  1710. value = value << QDF_MON_STATUS_DCM_SHIFT;
  1711. ppdu_info->rx_status.he_data3 |= value;
  1712. value = HAL_RX_GET(he_sig_b2_ofdma_info,
  1713. HE_SIG_B2_OFDMA_INFO, STA_CODING);
  1714. value = value << QDF_MON_STATUS_CODING_SHIFT;
  1715. ppdu_info->rx_status.he_data3 |= value;
  1716. /* HE-data4 */
  1717. value = HAL_RX_GET(he_sig_b2_ofdma_info,
  1718. HE_SIG_B2_OFDMA_INFO, STA_ID);
  1719. value = value << QDF_MON_STATUS_STA_ID_SHIFT;
  1720. ppdu_info->rx_status.he_data4 |= value;
  1721. /* HE-data5 */
  1722. value = HAL_RX_GET(he_sig_b2_ofdma_info,
  1723. HE_SIG_B2_OFDMA_INFO, TXBF);
  1724. value = value << QDF_MON_STATUS_TXBF_SHIFT;
  1725. ppdu_info->rx_status.he_data5 |= value;
  1726. /* HE-data6 */
  1727. value = HAL_RX_GET(he_sig_b2_ofdma_info,
  1728. HE_SIG_B2_OFDMA_INFO, NSTS);
  1729. /* value n indicates n+1 spatial streams */
  1730. value++;
  1731. ppdu_info->rx_status.nss = value;
  1732. ppdu_info->rx_status.he_data6 |= value;
  1733. ppdu_info->rx_status.reception_type = HAL_RX_TYPE_MU_OFDMA;
  1734. break;
  1735. }
  1736. case WIFIPHYRX_RSSI_LEGACY_E:
  1737. {
  1738. uint8_t reception_type;
  1739. int8_t rssi_value;
  1740. uint8_t *rssi_info_tlv = (uint8_t *)rx_tlv +
  1741. HAL_RX_OFFSET(UNIFIED_PHYRX_RSSI_LEGACY_19,
  1742. RECEIVE_RSSI_INFO_PREAMBLE_RSSI_INFO_DETAILS);
  1743. ppdu_info->rx_status.rssi_comb = HAL_RX_GET(rx_tlv,
  1744. PHYRX_RSSI_LEGACY, RSSI_COMB);
  1745. ppdu_info->rx_status.bw = hal->ops->hal_rx_get_tlv(rx_tlv);
  1746. ppdu_info->rx_status.he_re = 0;
  1747. reception_type = HAL_RX_GET(rx_tlv,
  1748. PHYRX_RSSI_LEGACY,
  1749. RECEPTION_TYPE);
  1750. switch (reception_type) {
  1751. case QDF_RECEPTION_TYPE_ULOFMDA:
  1752. ppdu_info->rx_status.reception_type =
  1753. HAL_RX_TYPE_MU_OFDMA;
  1754. ppdu_info->rx_status.ulofdma_flag = 1;
  1755. ppdu_info->rx_status.he_data1 =
  1756. QDF_MON_STATUS_HE_TRIG_FORMAT_TYPE;
  1757. break;
  1758. case QDF_RECEPTION_TYPE_ULMIMO:
  1759. ppdu_info->rx_status.reception_type =
  1760. HAL_RX_TYPE_MU_MIMO;
  1761. ppdu_info->rx_status.he_data1 =
  1762. QDF_MON_STATUS_HE_MU_FORMAT_TYPE;
  1763. break;
  1764. default:
  1765. ppdu_info->rx_status.reception_type =
  1766. HAL_RX_TYPE_SU;
  1767. break;
  1768. }
  1769. hal_rx_update_rssi_chain(ppdu_info, rssi_info_tlv);
  1770. rssi_value = HAL_RX_GET(rssi_info_tlv,
  1771. RECEIVE_RSSI_INFO, RSSI_PRI20_CHAIN0);
  1772. ppdu_info->rx_status.rssi[0] = rssi_value;
  1773. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1774. "RSSI_PRI20_CHAIN0: %d\n", rssi_value);
  1775. rssi_value = HAL_RX_GET(rssi_info_tlv,
  1776. RECEIVE_RSSI_INFO, RSSI_PRI20_CHAIN1);
  1777. ppdu_info->rx_status.rssi[1] = rssi_value;
  1778. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1779. "RSSI_PRI20_CHAIN1: %d\n", rssi_value);
  1780. rssi_value = HAL_RX_GET(rssi_info_tlv,
  1781. RECEIVE_RSSI_INFO, RSSI_PRI20_CHAIN2);
  1782. ppdu_info->rx_status.rssi[2] = rssi_value;
  1783. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1784. "RSSI_PRI20_CHAIN2: %d\n", rssi_value);
  1785. rssi_value = HAL_RX_GET(rssi_info_tlv,
  1786. RECEIVE_RSSI_INFO, RSSI_PRI20_CHAIN3);
  1787. ppdu_info->rx_status.rssi[3] = rssi_value;
  1788. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1789. "RSSI_PRI20_CHAIN3: %d\n", rssi_value);
  1790. #ifdef DP_BE_NOTYET_WAR
  1791. // TODO - this is not preset for kiwi
  1792. rssi_value = HAL_RX_GET(rssi_info_tlv,
  1793. RECEIVE_RSSI_INFO, RSSI_PRI20_CHAIN4);
  1794. ppdu_info->rx_status.rssi[4] = rssi_value;
  1795. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1796. "RSSI_PRI20_CHAIN4: %d\n", rssi_value);
  1797. rssi_value = HAL_RX_GET(rssi_info_tlv,
  1798. RECEIVE_RSSI_INFO,
  1799. RSSI_PRI20_CHAIN5);
  1800. ppdu_info->rx_status.rssi[5] = rssi_value;
  1801. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1802. "RSSI_PRI20_CHAIN5: %d\n", rssi_value);
  1803. rssi_value = HAL_RX_GET(rssi_info_tlv,
  1804. RECEIVE_RSSI_INFO,
  1805. RSSI_PRI20_CHAIN6);
  1806. ppdu_info->rx_status.rssi[6] = rssi_value;
  1807. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1808. "RSSI_PRI20_CHAIN6: %d\n", rssi_value);
  1809. rssi_value = HAL_RX_GET(rssi_info_tlv,
  1810. RECEIVE_RSSI_INFO,
  1811. RSSI_PRI20_CHAIN7);
  1812. ppdu_info->rx_status.rssi[7] = rssi_value;
  1813. #endif
  1814. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1815. "RSSI_PRI20_CHAIN7: %d\n", rssi_value);
  1816. break;
  1817. }
  1818. case WIFIPHYRX_OTHER_RECEIVE_INFO_E:
  1819. hal_rx_proc_phyrx_other_receive_info_tlv(hal, rx_tlv_hdr,
  1820. ppdu_info);
  1821. break;
  1822. case WIFIPHYRX_GENERIC_U_SIG_E:
  1823. hal_rx_parse_u_sig_hdr(hal, rx_tlv, ppdu_info);
  1824. break;
  1825. case WIFIPHYRX_COMMON_USER_INFO_E:
  1826. hal_rx_parse_cmn_usr_info(hal, rx_tlv, ppdu_info);
  1827. break;
  1828. case WIFIRX_HEADER_E:
  1829. {
  1830. struct hal_rx_ppdu_common_info *com_info = &ppdu_info->com_info;
  1831. if (ppdu_info->fcs_ok_cnt >=
  1832. HAL_RX_MAX_MPDU_H_PER_STATUS_BUFFER) {
  1833. hal_err("Number of MPDUs(%d) per status buff exceeded",
  1834. ppdu_info->fcs_ok_cnt);
  1835. break;
  1836. }
  1837. /* Update first_msdu_payload for every mpdu and increment
  1838. * com_info->mpdu_cnt for every WIFIRX_HEADER_E TLV
  1839. */
  1840. ppdu_info->ppdu_msdu_info[ppdu_info->fcs_ok_cnt].first_msdu_payload =
  1841. rx_tlv;
  1842. ppdu_info->ppdu_msdu_info[ppdu_info->fcs_ok_cnt].payload_len = tlv_len;
  1843. ppdu_info->msdu_info.first_msdu_payload = rx_tlv;
  1844. ppdu_info->msdu_info.payload_len = tlv_len;
  1845. ppdu_info->user_id = user_id;
  1846. ppdu_info->hdr_len = tlv_len;
  1847. ppdu_info->data = rx_tlv;
  1848. ppdu_info->data += 4;
  1849. /* for every RX_HEADER TLV increment mpdu_cnt */
  1850. com_info->mpdu_cnt++;
  1851. return HAL_TLV_STATUS_HEADER;
  1852. }
  1853. case WIFIRX_MPDU_START_E:
  1854. {
  1855. uint8_t *rx_mpdu_start = (uint8_t *)rx_tlv;
  1856. uint32_t ppdu_id = HAL_RX_GET_PPDU_ID(rx_tlv);
  1857. uint8_t filter_category = 0;
  1858. ppdu_info->nac_info.fc_valid =
  1859. HAL_RX_MON_GET_FC_VALID(rx_tlv);
  1860. ppdu_info->nac_info.to_ds_flag =
  1861. HAL_RX_MON_GET_TO_DS_FLAG(rx_tlv);
  1862. ppdu_info->nac_info.frame_control =
  1863. HAL_RX_GET(rx_mpdu_start,
  1864. RX_MPDU_INFO,
  1865. MPDU_FRAME_CONTROL_FIELD);
  1866. ppdu_info->sw_frame_group_id =
  1867. HAL_RX_GET_SW_FRAME_GROUP_ID(rx_tlv);
  1868. ppdu_info->rx_user_status[user_id].sw_peer_id =
  1869. HAL_RX_GET(rx_mpdu_start,
  1870. RX_MPDU_INFO,
  1871. SW_PEER_ID);
  1872. if (ppdu_info->sw_frame_group_id ==
  1873. HAL_MPDU_SW_FRAME_GROUP_NULL_DATA) {
  1874. ppdu_info->rx_status.frame_control_info_valid =
  1875. ppdu_info->nac_info.fc_valid;
  1876. ppdu_info->rx_status.frame_control =
  1877. ppdu_info->nac_info.frame_control;
  1878. }
  1879. hal_get_mac_addr1(rx_mpdu_start,
  1880. ppdu_info);
  1881. ppdu_info->nac_info.mac_addr2_valid =
  1882. HAL_RX_MON_GET_MAC_ADDR2_VALID(rx_mpdu_start);
  1883. *(uint16_t *)&ppdu_info->nac_info.mac_addr2[0] =
  1884. HAL_RX_GET(rx_mpdu_start,
  1885. RX_MPDU_INFO,
  1886. MAC_ADDR_AD2_15_0);
  1887. *(uint32_t *)&ppdu_info->nac_info.mac_addr2[2] =
  1888. HAL_RX_GET(rx_mpdu_start,
  1889. RX_MPDU_INFO,
  1890. MAC_ADDR_AD2_47_16);
  1891. if (ppdu_info->rx_status.prev_ppdu_id != ppdu_id) {
  1892. ppdu_info->rx_status.prev_ppdu_id = ppdu_id;
  1893. ppdu_info->rx_status.ppdu_len =
  1894. HAL_RX_GET(rx_mpdu_start, RX_MPDU_INFO,
  1895. MPDU_LENGTH);
  1896. } else {
  1897. ppdu_info->rx_status.ppdu_len +=
  1898. HAL_RX_GET(rx_mpdu_start, RX_MPDU_INFO,
  1899. MPDU_LENGTH);
  1900. }
  1901. filter_category =
  1902. HAL_RX_GET_FILTER_CATEGORY(rx_tlv);
  1903. if (filter_category == 0)
  1904. ppdu_info->rx_status.rxpcu_filter_pass = 1;
  1905. else if (filter_category == 1)
  1906. ppdu_info->rx_status.monitor_direct_used = 1;
  1907. ppdu_info->nac_info.mcast_bcast =
  1908. HAL_RX_GET(rx_mpdu_start,
  1909. RX_MPDU_INFO,
  1910. MCAST_BCAST);
  1911. break;
  1912. }
  1913. case WIFIRX_MPDU_END_E:
  1914. ppdu_info->user_id = user_id;
  1915. ppdu_info->fcs_err =
  1916. HAL_RX_GET(rx_tlv, RX_MPDU_END,
  1917. FCS_ERR);
  1918. return HAL_TLV_STATUS_MPDU_END;
  1919. case WIFIRX_MSDU_END_E:
  1920. if (user_id < HAL_MAX_UL_MU_USERS) {
  1921. ppdu_info->rx_msdu_info[user_id].cce_metadata =
  1922. HAL_RX_TLV_CCE_METADATA_GET(rx_tlv);
  1923. ppdu_info->rx_msdu_info[user_id].fse_metadata =
  1924. HAL_RX_TLV_FSE_METADATA_GET(rx_tlv);
  1925. ppdu_info->rx_msdu_info[user_id].is_flow_idx_timeout =
  1926. HAL_RX_TLV_FLOW_IDX_TIMEOUT_GET(rx_tlv);
  1927. ppdu_info->rx_msdu_info[user_id].is_flow_idx_invalid =
  1928. HAL_RX_TLV_FLOW_IDX_INVALID_GET(rx_tlv);
  1929. ppdu_info->rx_msdu_info[user_id].flow_idx =
  1930. HAL_RX_TLV_FLOW_IDX_GET(rx_tlv);
  1931. }
  1932. return HAL_TLV_STATUS_MSDU_END;
  1933. case 0:
  1934. return HAL_TLV_STATUS_PPDU_DONE;
  1935. default:
  1936. if (hal_rx_handle_other_tlvs(tlv_tag, rx_tlv, ppdu_info))
  1937. unhandled = false;
  1938. else
  1939. unhandled = true;
  1940. break;
  1941. }
  1942. if (!unhandled)
  1943. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1944. "%s TLV type: %d, TLV len:%d %s",
  1945. __func__, tlv_tag, tlv_len,
  1946. unhandled == true ? "unhandled" : "");
  1947. qdf_trace_hex_dump(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1948. rx_tlv, tlv_len);
  1949. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  1950. }
  1951. static uint32_t
  1952. hal_rx_status_process_aggr_tlv(struct hal_soc *hal_soc,
  1953. struct hal_rx_ppdu_info *ppdu_info)
  1954. {
  1955. uint32_t aggr_tlv_tag = ppdu_info->tlv_aggr.tlv_tag;
  1956. switch (aggr_tlv_tag) {
  1957. case WIFIPHYRX_GENERIC_EHT_SIG_E:
  1958. hal_rx_parse_eht_sig_hdr(hal_soc, ppdu_info->tlv_aggr.buf,
  1959. ppdu_info);
  1960. break;
  1961. default:
  1962. /* Aggregated TLV cannot be handled */
  1963. qdf_assert(0);
  1964. break;
  1965. }
  1966. ppdu_info->tlv_aggr.in_progress = 0;
  1967. ppdu_info->tlv_aggr.cur_len = 0;
  1968. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  1969. }
  1970. static inline bool
  1971. hal_rx_status_tlv_should_aggregate(struct hal_soc *hal_soc, uint32_t tlv_tag)
  1972. {
  1973. switch (tlv_tag) {
  1974. case WIFIPHYRX_GENERIC_EHT_SIG_E:
  1975. return true;
  1976. }
  1977. return false;
  1978. }
  1979. static inline uint32_t
  1980. hal_rx_status_aggr_tlv(struct hal_soc *hal_soc, void *rx_tlv_hdr,
  1981. struct hal_rx_ppdu_info *ppdu_info,
  1982. qdf_nbuf_t nbuf)
  1983. {
  1984. uint32_t tlv_tag, user_id, tlv_len;
  1985. void *rx_tlv;
  1986. tlv_tag = HAL_RX_GET_USER_TLV64_TYPE(rx_tlv_hdr);
  1987. user_id = HAL_RX_GET_USER_TLV64_USERID(rx_tlv_hdr);
  1988. tlv_len = HAL_RX_GET_USER_TLV64_LEN(rx_tlv_hdr);
  1989. rx_tlv = (uint8_t *)rx_tlv_hdr + HAL_RX_TLV64_HDR_SIZE;
  1990. if (tlv_len <= HAL_RX_MON_MAX_AGGR_SIZE - ppdu_info->tlv_aggr.cur_len) {
  1991. qdf_mem_copy(ppdu_info->tlv_aggr.buf +
  1992. ppdu_info->tlv_aggr.cur_len,
  1993. rx_tlv, tlv_len);
  1994. ppdu_info->tlv_aggr.cur_len += tlv_len;
  1995. } else {
  1996. dp_err("Length of TLV exceeds max aggregation length");
  1997. qdf_assert(0);
  1998. }
  1999. return HAL_TLV_STATUS_PPDU_NOT_DONE;
  2000. }
  2001. static inline uint32_t
  2002. hal_rx_status_start_new_aggr_tlv(struct hal_soc *hal_soc, void *rx_tlv_hdr,
  2003. struct hal_rx_ppdu_info *ppdu_info,
  2004. qdf_nbuf_t nbuf)
  2005. {
  2006. uint32_t tlv_tag, user_id, tlv_len;
  2007. tlv_tag = HAL_RX_GET_USER_TLV64_TYPE(rx_tlv_hdr);
  2008. user_id = HAL_RX_GET_USER_TLV64_USERID(rx_tlv_hdr);
  2009. tlv_len = HAL_RX_GET_USER_TLV64_LEN(rx_tlv_hdr);
  2010. ppdu_info->tlv_aggr.in_progress = 1;
  2011. ppdu_info->tlv_aggr.tlv_tag = tlv_tag;
  2012. ppdu_info->tlv_aggr.cur_len = 0;
  2013. return hal_rx_status_aggr_tlv(hal_soc, rx_tlv_hdr, ppdu_info, nbuf);
  2014. }
  2015. static inline uint32_t
  2016. hal_rx_status_get_tlv_info_wrapper_be(void *rx_tlv_hdr, void *ppduinfo,
  2017. hal_soc_handle_t hal_soc_hdl,
  2018. qdf_nbuf_t nbuf)
  2019. {
  2020. struct hal_soc *hal = (struct hal_soc *)hal_soc_hdl;
  2021. uint32_t tlv_tag, user_id, tlv_len;
  2022. struct hal_rx_ppdu_info *ppdu_info =
  2023. (struct hal_rx_ppdu_info *)ppduinfo;
  2024. tlv_tag = HAL_RX_GET_USER_TLV64_TYPE(rx_tlv_hdr);
  2025. user_id = HAL_RX_GET_USER_TLV64_USERID(rx_tlv_hdr);
  2026. tlv_len = HAL_RX_GET_USER_TLV64_LEN(rx_tlv_hdr);
  2027. /*
  2028. * Handle the case where aggregation is in progress
  2029. * or the current TLV is one of the TLVs which should be
  2030. * aggregated
  2031. */
  2032. if (ppdu_info->tlv_aggr.in_progress) {
  2033. if (ppdu_info->tlv_aggr.tlv_tag == tlv_tag) {
  2034. return hal_rx_status_aggr_tlv(hal, rx_tlv_hdr,
  2035. ppdu_info, nbuf);
  2036. } else {
  2037. /* Finish aggregation of current TLV */
  2038. hal_rx_status_process_aggr_tlv(hal, ppdu_info);
  2039. }
  2040. }
  2041. if (hal_rx_status_tlv_should_aggregate(hal, tlv_tag)) {
  2042. return hal_rx_status_start_new_aggr_tlv(hal, rx_tlv_hdr,
  2043. ppduinfo, nbuf);
  2044. }
  2045. return hal_rx_status_get_tlv_info_generic_be(rx_tlv_hdr, ppduinfo,
  2046. hal_soc_hdl, nbuf);
  2047. }
  2048. /**
  2049. * hal_tx_set_pcp_tid_map_generic_be() - Configure default PCP to TID map table
  2050. * @soc: HAL SoC context
  2051. * @map: PCP-TID mapping table
  2052. *
  2053. * PCP are mapped to 8 TID values using TID values programmed
  2054. * in one set of mapping registers PCP_TID_MAP_<0 to 6>
  2055. * The mapping register has TID mapping for 8 PCP values
  2056. *
  2057. * Return: none
  2058. */
  2059. static void hal_tx_set_pcp_tid_map_generic_be(struct hal_soc *soc, uint8_t *map)
  2060. {
  2061. uint32_t addr, value;
  2062. addr = HWIO_TCL_R0_PCP_TID_MAP_ADDR(
  2063. MAC_TCL_REG_REG_BASE);
  2064. value = (map[0] |
  2065. (map[1] << HWIO_TCL_R0_PCP_TID_MAP_PCP_1_SHFT) |
  2066. (map[2] << HWIO_TCL_R0_PCP_TID_MAP_PCP_2_SHFT) |
  2067. (map[3] << HWIO_TCL_R0_PCP_TID_MAP_PCP_3_SHFT) |
  2068. (map[4] << HWIO_TCL_R0_PCP_TID_MAP_PCP_4_SHFT) |
  2069. (map[5] << HWIO_TCL_R0_PCP_TID_MAP_PCP_5_SHFT) |
  2070. (map[6] << HWIO_TCL_R0_PCP_TID_MAP_PCP_6_SHFT) |
  2071. (map[7] << HWIO_TCL_R0_PCP_TID_MAP_PCP_7_SHFT));
  2072. HAL_REG_WRITE(soc, addr, (value & HWIO_TCL_R0_PCP_TID_MAP_RMSK));
  2073. }
  2074. /**
  2075. * hal_tx_update_pcp_tid_generic_be() - Update the pcp tid map table with
  2076. * value received from user-space
  2077. * @soc: HAL SoC context
  2078. * @pcp: pcp value
  2079. * @tid : tid value
  2080. *
  2081. * Return: void
  2082. */
  2083. static void
  2084. hal_tx_update_pcp_tid_generic_be(struct hal_soc *soc,
  2085. uint8_t pcp, uint8_t tid)
  2086. {
  2087. uint32_t addr, value, regval;
  2088. addr = HWIO_TCL_R0_PCP_TID_MAP_ADDR(
  2089. MAC_TCL_REG_REG_BASE);
  2090. value = (uint32_t)tid << (HAL_TX_BITS_PER_TID * pcp);
  2091. /* Read back previous PCP TID config and update
  2092. * with new config.
  2093. */
  2094. regval = HAL_REG_READ(soc, addr);
  2095. regval &= ~(HAL_TX_TID_BITS_MASK << (HAL_TX_BITS_PER_TID * pcp));
  2096. regval |= value;
  2097. HAL_REG_WRITE(soc, addr,
  2098. (regval & HWIO_TCL_R0_PCP_TID_MAP_RMSK));
  2099. }
  2100. /**
  2101. * hal_tx_update_tidmap_prty_generic_be() - Update the tid map priority
  2102. * @soc: HAL SoC context
  2103. * @val: priority value
  2104. *
  2105. * Return: void
  2106. */
  2107. static
  2108. void hal_tx_update_tidmap_prty_generic_be(struct hal_soc *soc, uint8_t value)
  2109. {
  2110. uint32_t addr;
  2111. addr = HWIO_TCL_R0_TID_MAP_PRTY_ADDR(
  2112. MAC_TCL_REG_REG_BASE);
  2113. HAL_REG_WRITE(soc, addr,
  2114. (value & HWIO_TCL_R0_TID_MAP_PRTY_RMSK));
  2115. }
  2116. /**
  2117. * hal_rx_get_tlv_size_generic_be() - Get rx packet tlv size
  2118. * @rx_pkt_tlv_size: TLV size for regular RX packets
  2119. * @rx_mon_pkt_tlv_size: TLV size for monitor mode packets
  2120. *
  2121. * Return: size of rx pkt tlv before the actual data
  2122. */
  2123. static void hal_rx_get_tlv_size_generic_be(uint16_t *rx_pkt_tlv_size,
  2124. uint16_t *rx_mon_pkt_tlv_size)
  2125. {
  2126. *rx_pkt_tlv_size = RX_PKT_TLVS_LEN;
  2127. /* For now mon pkt tlv is same as rx pkt tlv */
  2128. *rx_mon_pkt_tlv_size = RX_PKT_TLVS_LEN;
  2129. }
  2130. /**
  2131. * hal_rx_flow_get_tuple_info_be() - Setup a flow search entry in HW FST
  2132. * @fst: Pointer to the Rx Flow Search Table
  2133. * @hal_hash: HAL 5 tuple hash
  2134. * @tuple_info: 5-tuple info of the flow returned to the caller
  2135. *
  2136. * Return: Success/Failure
  2137. */
  2138. static void *
  2139. hal_rx_flow_get_tuple_info_be(uint8_t *rx_fst, uint32_t hal_hash,
  2140. uint8_t *flow_tuple_info)
  2141. {
  2142. struct hal_rx_fst *fst = (struct hal_rx_fst *)rx_fst;
  2143. void *hal_fse = NULL;
  2144. struct hal_flow_tuple_info *tuple_info
  2145. = (struct hal_flow_tuple_info *)flow_tuple_info;
  2146. hal_fse = (uint8_t *)fst->base_vaddr +
  2147. (hal_hash * HAL_RX_FST_ENTRY_SIZE);
  2148. if (!hal_fse || !tuple_info)
  2149. return NULL;
  2150. if (!HAL_GET_FLD(hal_fse, RX_FLOW_SEARCH_ENTRY, VALID))
  2151. return NULL;
  2152. tuple_info->src_ip_127_96 =
  2153. qdf_ntohl(HAL_GET_FLD(hal_fse,
  2154. RX_FLOW_SEARCH_ENTRY,
  2155. SRC_IP_127_96));
  2156. tuple_info->src_ip_95_64 =
  2157. qdf_ntohl(HAL_GET_FLD(hal_fse,
  2158. RX_FLOW_SEARCH_ENTRY,
  2159. SRC_IP_95_64));
  2160. tuple_info->src_ip_63_32 =
  2161. qdf_ntohl(HAL_GET_FLD(hal_fse,
  2162. RX_FLOW_SEARCH_ENTRY,
  2163. SRC_IP_63_32));
  2164. tuple_info->src_ip_31_0 =
  2165. qdf_ntohl(HAL_GET_FLD(hal_fse,
  2166. RX_FLOW_SEARCH_ENTRY,
  2167. SRC_IP_31_0));
  2168. tuple_info->dest_ip_127_96 =
  2169. qdf_ntohl(HAL_GET_FLD(hal_fse,
  2170. RX_FLOW_SEARCH_ENTRY,
  2171. DEST_IP_127_96));
  2172. tuple_info->dest_ip_95_64 =
  2173. qdf_ntohl(HAL_GET_FLD(hal_fse,
  2174. RX_FLOW_SEARCH_ENTRY,
  2175. DEST_IP_95_64));
  2176. tuple_info->dest_ip_63_32 =
  2177. qdf_ntohl(HAL_GET_FLD(hal_fse,
  2178. RX_FLOW_SEARCH_ENTRY,
  2179. DEST_IP_63_32));
  2180. tuple_info->dest_ip_31_0 =
  2181. qdf_ntohl(HAL_GET_FLD(hal_fse,
  2182. RX_FLOW_SEARCH_ENTRY,
  2183. DEST_IP_31_0));
  2184. tuple_info->dest_port = HAL_GET_FLD(hal_fse,
  2185. RX_FLOW_SEARCH_ENTRY,
  2186. DEST_PORT);
  2187. tuple_info->src_port = HAL_GET_FLD(hal_fse,
  2188. RX_FLOW_SEARCH_ENTRY,
  2189. SRC_PORT);
  2190. tuple_info->l4_protocol = HAL_GET_FLD(hal_fse,
  2191. RX_FLOW_SEARCH_ENTRY,
  2192. L4_PROTOCOL);
  2193. return hal_fse;
  2194. }
  2195. /**
  2196. * hal_rx_flow_delete_entry_be() - Setup a flow search entry in HW FST
  2197. * @fst: Pointer to the Rx Flow Search Table
  2198. * @hal_rx_fse: Pointer to the Rx Flow that is to be deleted from the FST
  2199. *
  2200. * Return: Success/Failure
  2201. */
  2202. static QDF_STATUS
  2203. hal_rx_flow_delete_entry_be(uint8_t *rx_fst, void *hal_rx_fse)
  2204. {
  2205. uint8_t *fse = (uint8_t *)hal_rx_fse;
  2206. if (!HAL_GET_FLD(fse, RX_FLOW_SEARCH_ENTRY, VALID))
  2207. return QDF_STATUS_E_NOENT;
  2208. HAL_CLR_FLD(fse, RX_FLOW_SEARCH_ENTRY, VALID);
  2209. return QDF_STATUS_SUCCESS;
  2210. }
  2211. /**
  2212. * hal_rx_fst_get_fse_size_be() - Retrieve the size of each entry in Rx FST
  2213. *
  2214. * Return: size of each entry/flow in Rx FST
  2215. */
  2216. static inline uint32_t
  2217. hal_rx_fst_get_fse_size_be(void)
  2218. {
  2219. return HAL_RX_FST_ENTRY_SIZE;
  2220. }
  2221. /*
  2222. * TX MONITOR
  2223. */
  2224. #ifdef QCA_MONITOR_2_0_SUPPORT
  2225. /**
  2226. * hal_txmon_get_buffer_addr_generic_be() - api to get buffer address
  2227. * @tx_tlv: pointer to TLV header
  2228. * @status: hal mon buffer address status
  2229. *
  2230. * Return: Address to qdf_frag_t
  2231. */
  2232. static inline qdf_frag_t
  2233. hal_txmon_get_buffer_addr_generic_be(void *tx_tlv,
  2234. struct hal_mon_buf_addr_status *status)
  2235. {
  2236. struct mon_buffer_addr *hal_buffer_addr =
  2237. (struct mon_buffer_addr *)((uint8_t *)tx_tlv +
  2238. HAL_RX_TLV32_HDR_SIZE);
  2239. qdf_frag_t buf_addr = NULL;
  2240. buf_addr = (qdf_frag_t)(uintptr_t)((hal_buffer_addr->buffer_virt_addr_31_0 |
  2241. ((unsigned long long)hal_buffer_addr->buffer_virt_addr_63_32 <<
  2242. 32)));
  2243. /* qdf_frag_t is derived from buffer address tlv */
  2244. if (qdf_unlikely(status)) {
  2245. qdf_mem_copy(status,
  2246. (uint8_t *)tx_tlv + HAL_RX_TLV32_HDR_SIZE,
  2247. sizeof(struct hal_mon_buf_addr_status));
  2248. /* update hal_mon_buf_addr_status */
  2249. }
  2250. return buf_addr;
  2251. }
  2252. #if defined(TX_MONITOR_WORD_MASK)
  2253. /**
  2254. * hal_txmon_get_num_users() - get num users from tx_fes_setup tlv
  2255. *
  2256. * @tx_tlv: pointer to tx_fes_setup tlv header
  2257. *
  2258. * Return: number of users
  2259. */
  2260. static inline uint8_t
  2261. hal_txmon_get_num_users(void *tx_tlv)
  2262. {
  2263. hal_tx_fes_setup_t *tx_fes_setup = (hal_tx_fes_setup_t *)tx_tlv;
  2264. return tx_fes_setup->number_of_users;
  2265. }
  2266. /**
  2267. * hal_txmon_parse_tx_fes_setup() - parse tx_fes_setup tlv
  2268. *
  2269. * @tx_tlv: pointer to tx_fes_setup tlv header
  2270. * @ppdu_info: pointer to hal_tx_ppdu_info
  2271. *
  2272. * Return: void
  2273. */
  2274. static inline void
  2275. hal_txmon_parse_tx_fes_setup(void *tx_tlv,
  2276. struct hal_tx_ppdu_info *tx_ppdu_info)
  2277. {
  2278. hal_tx_fes_setup_t *tx_fes_setup = (hal_tx_fes_setup_t *)tx_tlv;
  2279. tx_ppdu_info->num_users = tx_fes_setup->number_of_users;
  2280. }
  2281. #else
  2282. /**
  2283. * hal_txmon_get_num_users() - get num users from tx_fes_setup tlv
  2284. *
  2285. * @tx_tlv: pointer to tx_fes_setup tlv header
  2286. *
  2287. * Return: number of users
  2288. */
  2289. static inline uint8_t
  2290. hal_txmon_get_num_users(void *tx_tlv)
  2291. {
  2292. uint8_t num_users = HAL_TX_DESC_GET(tx_tlv,
  2293. TX_FES_SETUP, NUMBER_OF_USERS);
  2294. return num_users;
  2295. }
  2296. /**
  2297. * hal_txmon_parse_tx_fes_setup() - parse tx_fes_setup tlv
  2298. *
  2299. * @tx_tlv: pointer to tx_fes_setup tlv header
  2300. * @ppdu_info: pointer to hal_tx_ppdu_info
  2301. *
  2302. * Return: void
  2303. */
  2304. static inline void
  2305. hal_txmon_parse_tx_fes_setup(void *tx_tlv,
  2306. struct hal_tx_ppdu_info *tx_ppdu_info)
  2307. {
  2308. tx_ppdu_info->num_users = HAL_TX_DESC_GET(tx_tlv,
  2309. TX_FES_SETUP,
  2310. NUMBER_OF_USERS);
  2311. }
  2312. #endif
  2313. /**
  2314. * hal_txmon_status_get_num_users_generic_be() - api to get num users
  2315. * from start of fes window
  2316. *
  2317. * @tx_tlv_hdr: pointer to TLV header
  2318. * @num_users: reference to number of user
  2319. *
  2320. * Return: status
  2321. */
  2322. static inline uint32_t
  2323. hal_txmon_status_get_num_users_generic_be(void *tx_tlv_hdr, uint8_t *num_users)
  2324. {
  2325. uint32_t tlv_tag, user_id, tlv_len;
  2326. uint32_t tlv_status = HAL_MON_TX_STATUS_PPDU_NOT_DONE;
  2327. void *tx_tlv;
  2328. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(tx_tlv_hdr);
  2329. user_id = HAL_RX_GET_USER_TLV32_USERID(tx_tlv_hdr);
  2330. tlv_len = HAL_RX_GET_USER_TLV32_LEN(tx_tlv_hdr);
  2331. tx_tlv = (uint8_t *)tx_tlv_hdr + HAL_RX_TLV32_HDR_SIZE;
  2332. /* window starts with either initiator or response */
  2333. switch (tlv_tag) {
  2334. case WIFITX_FES_SETUP_E:
  2335. {
  2336. *num_users = hal_txmon_get_num_users(tx_tlv);
  2337. tlv_status = HAL_MON_TX_FES_SETUP;
  2338. break;
  2339. }
  2340. case WIFIRX_RESPONSE_REQUIRED_INFO_E:
  2341. {
  2342. *num_users = HAL_TX_DESC_GET(tx_tlv,
  2343. RX_RESPONSE_REQUIRED_INFO,
  2344. RESPONSE_STA_COUNT);
  2345. tlv_status = HAL_MON_RX_RESPONSE_REQUIRED_INFO;
  2346. break;
  2347. }
  2348. };
  2349. return tlv_status;
  2350. }
  2351. /**
  2352. * hal_txmon_free_status_buffer() - api to free status buffer
  2353. * @pdev_handle: DP_PDEV handle
  2354. * @status_frag: qdf_frag_t buffer
  2355. *
  2356. * Return void
  2357. */
  2358. static inline void
  2359. hal_txmon_status_free_buffer_generic_be(qdf_frag_t status_frag)
  2360. {
  2361. uint32_t tlv_tag, tlv_len;
  2362. uint32_t tlv_status = HAL_MON_TX_STATUS_PPDU_NOT_DONE;
  2363. uint8_t *tx_tlv;
  2364. uint8_t *tx_tlv_start;
  2365. qdf_frag_t frag_buf = NULL;
  2366. tx_tlv = (uint8_t *)status_frag;
  2367. tx_tlv_start = tx_tlv;
  2368. /* parse tlv and populate tx_ppdu_info */
  2369. do {
  2370. /* TODO: check config_length is full monitor mode */
  2371. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(tx_tlv);
  2372. tlv_len = HAL_RX_GET_USER_TLV32_LEN(tx_tlv);
  2373. if (tlv_tag == WIFIMON_BUFFER_ADDR_E) {
  2374. frag_buf = hal_txmon_get_buffer_addr_generic_be(tx_tlv,
  2375. NULL);
  2376. if (frag_buf)
  2377. qdf_frag_free(frag_buf);
  2378. frag_buf = NULL;
  2379. }
  2380. /* need api definition for hal_tx_status_get_next_tlv */
  2381. tx_tlv = hal_tx_status_get_next_tlv(tx_tlv);
  2382. if ((tx_tlv - tx_tlv_start) >= TX_MON_STATUS_BUF_SIZE)
  2383. break;
  2384. } while (tlv_status == HAL_MON_TX_STATUS_PPDU_NOT_DONE);
  2385. }
  2386. /**
  2387. * hal_tx_get_ppdu_info() - api to get tx ppdu info
  2388. * @pdev_handle: DP_PDEV handle
  2389. * @prot_ppdu_info: populate dp_ppdu_info protection
  2390. * @tx_data_ppdu_info: populate dp_ppdu_info data
  2391. * @tlv_tag: Tag
  2392. *
  2393. * Return: dp_tx_ppdu_info pointer
  2394. */
  2395. static inline void *
  2396. hal_tx_get_ppdu_info(void *data_info, void *prot_info, uint32_t tlv_tag)
  2397. {
  2398. struct hal_tx_ppdu_info *prot_ppdu_info = prot_info;
  2399. switch (tlv_tag) {
  2400. case WIFITX_FES_SETUP_E:/* DOWNSTREAM */
  2401. case WIFITX_FLUSH_E:/* DOWNSTREAM */
  2402. case WIFIPCU_PPDU_SETUP_INIT_E:/* DOWNSTREAM */
  2403. case WIFITX_PEER_ENTRY_E:/* DOWNSTREAM */
  2404. case WIFITX_QUEUE_EXTENSION_E:/* DOWNSTREAM */
  2405. case WIFITX_MPDU_START_E:/* DOWNSTREAM */
  2406. case WIFITX_MSDU_START_E:/* DOWNSTREAM */
  2407. case WIFITX_DATA_E:/* DOWNSTREAM */
  2408. case WIFIMON_BUFFER_ADDR_E:/* DOWNSTREAM */
  2409. case WIFITX_MPDU_END_E:/* DOWNSTREAM */
  2410. case WIFITX_MSDU_END_E:/* DOWNSTREAM */
  2411. case WIFITX_LAST_MPDU_FETCHED_E:/* DOWNSTREAM */
  2412. case WIFITX_LAST_MPDU_END_E:/* DOWNSTREAM */
  2413. case WIFICOEX_TX_REQ_E:/* DOWNSTREAM */
  2414. case WIFITX_RAW_OR_NATIVE_FRAME_SETUP_E:/* DOWNSTREAM */
  2415. case WIFINDP_PREAMBLE_DONE_E:/* DOWNSTREAM */
  2416. case WIFISCH_CRITICAL_TLV_REFERENCE_E:/* DOWNSTREAM */
  2417. case WIFITX_LOOPBACK_SETUP_E:/* DOWNSTREAM */
  2418. case WIFITX_FES_SETUP_COMPLETE_E:/* DOWNSTREAM */
  2419. case WIFITQM_MPDU_GLOBAL_START_E:/* DOWNSTREAM */
  2420. case WIFITX_WUR_DATA_E:/* DOWNSTREAM */
  2421. case WIFISCHEDULER_END_E:/* DOWNSTREAM */
  2422. {
  2423. return data_info;
  2424. }
  2425. }
  2426. /*
  2427. * check current prot_tlv_status is start protection
  2428. * check current tlv_tag is either start protection or end protection
  2429. */
  2430. if (TXMON_HAL(prot_ppdu_info,
  2431. prot_tlv_status) == WIFITX_FES_STATUS_START_PROT_E) {
  2432. return prot_info;
  2433. } else if (tlv_tag == WIFITX_FES_STATUS_PROT_E ||
  2434. tlv_tag == WIFITX_FES_STATUS_START_PROT_E) {
  2435. TXMON_HAL(prot_ppdu_info, prot_tlv_status) = tlv_tag;
  2436. return prot_info;
  2437. } else {
  2438. return data_info;
  2439. }
  2440. return data_info;
  2441. }
  2442. /**
  2443. * hal_txmon_status_parse_tlv_generic_be() - api to parse status tlv.
  2444. * @data_ppdu_info: hal_txmon data ppdu info
  2445. * @prot_ppdu_info: hal_txmon prot ppdu info
  2446. * @data_status_info: pointer to data status info
  2447. * @prot_status_info: pointer to prot status info
  2448. * @tx_tlv_hdr: fragment of tx_tlv_hdr
  2449. * @status_frag: qdf_frag_t buffer
  2450. *
  2451. * Return: status
  2452. */
  2453. static inline uint32_t
  2454. hal_txmon_status_parse_tlv_generic_be(void *data_ppdu_info,
  2455. void *prot_ppdu_info,
  2456. void *data_status_info,
  2457. void *prot_status_info,
  2458. void *tx_tlv_hdr,
  2459. qdf_frag_t status_frag)
  2460. {
  2461. struct hal_tx_ppdu_info *tx_ppdu_info;
  2462. struct hal_tx_status_info *tx_status_info;
  2463. uint32_t tlv_tag, user_id, tlv_len;
  2464. qdf_frag_t frag_buf = NULL;
  2465. uint32_t status = HAL_MON_TX_STATUS_PPDU_NOT_DONE;
  2466. void *tx_tlv;
  2467. tlv_tag = HAL_RX_GET_USER_TLV32_TYPE(tx_tlv_hdr);
  2468. user_id = HAL_RX_GET_USER_TLV32_USERID(tx_tlv_hdr);
  2469. tlv_len = HAL_RX_GET_USER_TLV32_LEN(tx_tlv_hdr);
  2470. tx_tlv = (uint8_t *)tx_tlv_hdr + HAL_RX_TLV32_HDR_SIZE;
  2471. tx_ppdu_info = hal_tx_get_ppdu_info(data_ppdu_info,
  2472. prot_ppdu_info, tlv_tag);
  2473. tx_status_info = (tx_ppdu_info->is_data ? data_status_info :
  2474. prot_status_info);
  2475. /* parse tlv and populate tx_ppdu_info */
  2476. switch (tlv_tag) {
  2477. case WIFIMON_BUFFER_ADDR_E:
  2478. {
  2479. frag_buf = hal_txmon_get_buffer_addr_generic_be(tx_tlv, NULL);
  2480. if (frag_buf)
  2481. qdf_frag_free(frag_buf);
  2482. frag_buf = NULL;
  2483. status = HAL_MON_TX_BUFFER_ADDR;
  2484. break;
  2485. }
  2486. case WIFITX_FES_STATUS_START_PROT_E:
  2487. {
  2488. TXMON_HAL(tx_ppdu_info, prot_tlv_status) = tlv_tag;
  2489. break;
  2490. }
  2491. }
  2492. return status;
  2493. }
  2494. #endif /* QCA_MONITOR_2_0_SUPPORT */
  2495. #ifdef REO_SHARED_QREF_TABLE_EN
  2496. /* hal_reo_shared_qaddr_write(): Write REO tid queue addr
  2497. * LUT shared by SW and HW at the index given by peer id
  2498. * and tid.
  2499. *
  2500. * @hal_soc: hal soc pointer
  2501. * @reo_qref_addr: pointer to index pointed to be peer_id
  2502. * and tid
  2503. * @tid: tid queue number
  2504. * @hw_qdesc_paddr: reo queue addr
  2505. */
  2506. static void hal_reo_shared_qaddr_write_be(hal_soc_handle_t hal_soc_hdl,
  2507. uint16_t peer_id,
  2508. int tid,
  2509. qdf_dma_addr_t hw_qdesc_paddr)
  2510. {
  2511. struct hal_soc *hal = (struct hal_soc *)hal_soc_hdl;
  2512. struct rx_reo_queue_reference *reo_qref;
  2513. uint32_t peer_tid_idx;
  2514. /* Plug hw_desc_addr in Host reo queue reference table */
  2515. if (HAL_PEER_ID_IS_MLO(peer_id)) {
  2516. peer_tid_idx = ((peer_id - HAL_ML_PEER_ID_START) *
  2517. DP_MAX_TIDS) + tid;
  2518. reo_qref = (struct rx_reo_queue_reference *)
  2519. &hal->reo_qref.mlo_reo_qref_table_vaddr[peer_tid_idx];
  2520. } else {
  2521. peer_tid_idx = (peer_id * DP_MAX_TIDS) + tid;
  2522. reo_qref = (struct rx_reo_queue_reference *)
  2523. &hal->reo_qref.non_mlo_reo_qref_table_vaddr[peer_tid_idx];
  2524. }
  2525. reo_qref->rx_reo_queue_desc_addr_31_0 =
  2526. hw_qdesc_paddr & 0xffffffff;
  2527. reo_qref->rx_reo_queue_desc_addr_39_32 =
  2528. (hw_qdesc_paddr & 0xff00000000) >> 32;
  2529. if (hw_qdesc_paddr != 0)
  2530. reo_qref->receive_queue_number = tid;
  2531. else
  2532. reo_qref->receive_queue_number = 0;
  2533. hal_verbose_debug("hw_qdesc_paddr: %llx, tid: %d, reo_qref:%pK,"
  2534. "rx_reo_queue_desc_addr_31_0: %x,"
  2535. "rx_reo_queue_desc_addr_39_32: %x",
  2536. hw_qdesc_paddr, tid, reo_qref,
  2537. reo_qref->rx_reo_queue_desc_addr_31_0,
  2538. reo_qref->rx_reo_queue_desc_addr_39_32);
  2539. }
  2540. /**
  2541. * hal_reo_shared_qaddr_setup() - Allocate MLO and Non MLO reo queue
  2542. * reference table shared between SW and HW and initialize in Qdesc Base0
  2543. * base1 registers provided by HW.
  2544. *
  2545. * @hal_soc: HAL Soc handle
  2546. *
  2547. * Return: None
  2548. */
  2549. static void hal_reo_shared_qaddr_setup_be(hal_soc_handle_t hal_soc_hdl)
  2550. {
  2551. struct hal_soc *hal = (struct hal_soc *)hal_soc_hdl;
  2552. hal->reo_qref.reo_qref_table_en = 1;
  2553. hal->reo_qref.mlo_reo_qref_table_vaddr =
  2554. (uint64_t *)qdf_mem_alloc_consistent(
  2555. hal->qdf_dev, hal->qdf_dev->dev,
  2556. REO_QUEUE_REF_ML_TABLE_SIZE,
  2557. &hal->reo_qref.mlo_reo_qref_table_paddr);
  2558. hal->reo_qref.non_mlo_reo_qref_table_vaddr =
  2559. (uint64_t *)qdf_mem_alloc_consistent(
  2560. hal->qdf_dev, hal->qdf_dev->dev,
  2561. REO_QUEUE_REF_NON_ML_TABLE_SIZE,
  2562. &hal->reo_qref.non_mlo_reo_qref_table_paddr);
  2563. hal_verbose_debug("MLO table start paddr:%llx,"
  2564. "Non-MLO table start paddr:%llx,"
  2565. "MLO table start vaddr: %pK,"
  2566. "Non MLO table start vaddr: %pK",
  2567. hal->reo_qref.mlo_reo_qref_table_paddr,
  2568. hal->reo_qref.non_mlo_reo_qref_table_paddr,
  2569. hal->reo_qref.mlo_reo_qref_table_vaddr,
  2570. hal->reo_qref.non_mlo_reo_qref_table_vaddr);
  2571. }
  2572. /**
  2573. * hal_reo_shared_qaddr_init() - Zero out REO qref LUT and
  2574. * write start addr of MLO and Non MLO table in HW
  2575. *
  2576. * @hal_soc: HAL Soc handle
  2577. *
  2578. * Return: None
  2579. */
  2580. static void hal_reo_shared_qaddr_init_be(hal_soc_handle_t hal_soc_hdl)
  2581. {
  2582. struct hal_soc *hal = (struct hal_soc *)hal_soc_hdl;
  2583. qdf_mem_zero(hal->reo_qref.mlo_reo_qref_table_vaddr,
  2584. REO_QUEUE_REF_ML_TABLE_SIZE);
  2585. qdf_mem_zero(hal->reo_qref.non_mlo_reo_qref_table_vaddr,
  2586. REO_QUEUE_REF_NON_ML_TABLE_SIZE);
  2587. /* LUT_BASE0 and BASE1 registers expect upper 32bits of LUT base address
  2588. * and lower 8 bits to be 0. Shift the physical address by 8 to plug
  2589. * upper 32bits only
  2590. */
  2591. HAL_REG_WRITE(hal,
  2592. HWIO_REO_R0_QDESC_LUT_BASE0_ADDR_ADDR(REO_REG_REG_BASE),
  2593. hal->reo_qref.non_mlo_reo_qref_table_paddr >> 8);
  2594. HAL_REG_WRITE(hal,
  2595. HWIO_REO_R0_QDESC_LUT_BASE1_ADDR_ADDR(REO_REG_REG_BASE),
  2596. hal->reo_qref.mlo_reo_qref_table_paddr >> 8);
  2597. HAL_REG_WRITE(hal,
  2598. HWIO_REO_R0_QDESC_ADDR_READ_ADDR(REO_REG_REG_BASE),
  2599. HAL_SM(HWIO_REO_R0_QDESC_ADDR_READ, LUT_FEATURE_ENABLE,
  2600. 1));
  2601. HAL_REG_WRITE(hal,
  2602. HWIO_REO_R0_QDESC_MAX_SW_PEER_ID_ADDR(REO_REG_REG_BASE),
  2603. HAL_MS(HWIO_REO_R0_QDESC, MAX_SW_PEER_ID_MAX_SUPPORTED,
  2604. 0x1fff));
  2605. }
  2606. /**
  2607. * hal_reo_shared_qaddr_detach() - Free MLO and Non MLO reo queue
  2608. * reference table shared between SW and HW
  2609. *
  2610. * @hal_soc: HAL Soc handle
  2611. *
  2612. * Return: None
  2613. */
  2614. static void hal_reo_shared_qaddr_detach_be(hal_soc_handle_t hal_soc_hdl)
  2615. {
  2616. struct hal_soc *hal = (struct hal_soc *)hal_soc_hdl;
  2617. HAL_REG_WRITE(hal,
  2618. HWIO_REO_R0_QDESC_LUT_BASE0_ADDR_ADDR(REO_REG_REG_BASE),
  2619. 0);
  2620. HAL_REG_WRITE(hal,
  2621. HWIO_REO_R0_QDESC_LUT_BASE1_ADDR_ADDR(REO_REG_REG_BASE),
  2622. 0);
  2623. qdf_mem_free_consistent(hal->qdf_dev, hal->qdf_dev->dev,
  2624. REO_QUEUE_REF_ML_TABLE_SIZE,
  2625. hal->reo_qref.mlo_reo_qref_table_vaddr,
  2626. hal->reo_qref.mlo_reo_qref_table_paddr, 0);
  2627. qdf_mem_free_consistent(hal->qdf_dev, hal->qdf_dev->dev,
  2628. REO_QUEUE_REF_NON_ML_TABLE_SIZE,
  2629. hal->reo_qref.non_mlo_reo_qref_table_vaddr,
  2630. hal->reo_qref.non_mlo_reo_qref_table_paddr, 0);
  2631. }
  2632. #endif
  2633. #endif /* _HAL_BE_GENERIC_API_H_ */