dp_htt.c 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045
  1. /*
  2. * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #include <htt.h>
  19. #include <hal_api.h>
  20. #include "dp_htt.h"
  21. #include "dp_peer.h"
  22. #include "dp_types.h"
  23. #include "dp_internal.h"
  24. #include "dp_rx_mon.h"
  25. #include "htt_stats.h"
  26. #include "htt_ppdu_stats.h"
  27. #include "qdf_mem.h" /* qdf_mem_malloc,free */
  28. #include "cdp_txrx_cmn_struct.h"
  29. #define HTT_TLV_HDR_LEN HTT_T2H_EXT_STATS_CONF_TLV_HDR_SIZE
  30. #define HTT_HTC_PKT_POOL_INIT_SIZE 64
  31. #define HTT_T2H_MAX_MSG_SIZE 2048
  32. #define HTT_MSG_BUF_SIZE(msg_bytes) \
  33. ((msg_bytes) + HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING)
  34. #define DP_EXT_MSG_LENGTH 2048
  35. #define DP_HTT_SEND_HTC_PKT(soc, pkt) \
  36. do { \
  37. if (htc_send_pkt(soc->htc_soc, &pkt->htc_pkt) == \
  38. QDF_STATUS_SUCCESS) \
  39. htt_htc_misc_pkt_list_add(soc, pkt); \
  40. } while (0)
  41. #define HTT_MGMT_CTRL_TLV_RESERVERD_LEN 12
  42. /*
  43. * dp_tx_stats_update() - Update per-peer statistics
  44. * @soc: Datapath soc handle
  45. * @peer: Datapath peer handle
  46. * @ppdu: PPDU Descriptor
  47. * @ack_rssi: RSSI of last ack received
  48. *
  49. * Return: None
  50. */
  51. #ifdef FEATURE_PERPKT_INFO
  52. static void dp_tx_stats_update(struct dp_soc *soc, struct dp_peer *peer,
  53. struct cdp_tx_completion_ppdu_user *ppdu, uint32_t ack_rssi)
  54. {
  55. struct dp_pdev *pdev = peer->vdev->pdev;
  56. uint8_t preamble, mcs;
  57. uint16_t num_msdu;
  58. preamble = ppdu->preamble;
  59. mcs = ppdu->mcs;
  60. num_msdu = ppdu->num_msdu;
  61. /* If the peer statistics are already processed as part of
  62. * per-MSDU completion handler, do not process these again in per-PPDU
  63. * indications */
  64. if (soc->process_tx_status)
  65. return;
  66. DP_STATS_INC_PKT(peer, tx.comp_pkt,
  67. num_msdu, (ppdu->success_bytes +
  68. ppdu->retry_bytes + ppdu->failed_bytes));
  69. DP_STATS_INC(peer, tx.tx_failed, ppdu->failed_msdus);
  70. DP_STATS_UPD(peer, tx.tx_rate, ppdu->tx_rate);
  71. DP_STATS_INC(peer, tx.sgi_count[ppdu->gi], num_msdu);
  72. DP_STATS_INC(peer, tx.bw[ppdu->bw], num_msdu);
  73. DP_STATS_INC(peer, tx.nss[ppdu->nss], num_msdu);
  74. DP_STATS_UPD(peer, tx.last_ack_rssi, ack_rssi);
  75. DP_STATS_INC(peer, tx.wme_ac_type[TID_TO_WME_AC(ppdu->tid)], num_msdu);
  76. DP_STATS_INCC(peer, tx.stbc, num_msdu, ppdu->stbc);
  77. DP_STATS_INCC(peer, tx.ldpc, num_msdu, ppdu->ldpc);
  78. DP_STATS_INC_PKT(peer, tx.tx_success, ppdu->success_msdus,
  79. ppdu->success_bytes);
  80. if (ppdu->is_mcast) {
  81. DP_STATS_INC_PKT(peer, tx.mcast, ppdu->mpdu_tried_mcast,
  82. (ppdu->success_bytes
  83. + ppdu->retry_bytes +
  84. ppdu->failed_bytes));
  85. } else {
  86. DP_STATS_INC_PKT(peer, tx.ucast, num_msdu, (ppdu->success_bytes
  87. + ppdu->retry_bytes +
  88. ppdu->failed_bytes));
  89. }
  90. DP_STATS_INC(peer, tx.retries,
  91. (ppdu->long_retries + ppdu->short_retries));
  92. DP_STATS_INCC(peer,
  93. tx.pkt_type[preamble].mcs_count[MAX_MCS-1], num_msdu,
  94. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
  95. DP_STATS_INCC(peer,
  96. tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  97. ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
  98. DP_STATS_INCC(peer,
  99. tx.pkt_type[preamble].mcs_count[MAX_MCS-1], num_msdu,
  100. ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B)));
  101. DP_STATS_INCC(peer,
  102. tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  103. ((mcs < (MAX_MCS_11B)) && (preamble == DOT11_B)));
  104. DP_STATS_INCC(peer,
  105. tx.pkt_type[preamble].mcs_count[MAX_MCS-1], num_msdu,
  106. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N)));
  107. DP_STATS_INCC(peer,
  108. tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  109. ((mcs < MAX_MCS_11A) && (preamble == DOT11_N)));
  110. DP_STATS_INCC(peer,
  111. tx.pkt_type[preamble].mcs_count[MAX_MCS-1], num_msdu,
  112. ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC)));
  113. DP_STATS_INCC(peer,
  114. tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  115. ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
  116. DP_STATS_INCC(peer,
  117. tx.pkt_type[preamble].mcs_count[MAX_MCS-1], num_msdu,
  118. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  119. DP_STATS_INCC(peer,
  120. tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  121. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  122. if (soc->cdp_soc.ol_ops->update_dp_stats) {
  123. soc->cdp_soc.ol_ops->update_dp_stats(pdev->osif_pdev,
  124. &peer->stats, ppdu->peer_id,
  125. UPDATE_PEER_STATS);
  126. dp_aggregate_vdev_stats(peer->vdev);
  127. }
  128. }
  129. #endif
  130. /*
  131. * htt_htc_pkt_alloc() - Allocate HTC packet buffer
  132. * @htt_soc: HTT SOC handle
  133. *
  134. * Return: Pointer to htc packet buffer
  135. */
  136. static struct dp_htt_htc_pkt *
  137. htt_htc_pkt_alloc(struct htt_soc *soc)
  138. {
  139. struct dp_htt_htc_pkt_union *pkt = NULL;
  140. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  141. if (soc->htt_htc_pkt_freelist) {
  142. pkt = soc->htt_htc_pkt_freelist;
  143. soc->htt_htc_pkt_freelist = soc->htt_htc_pkt_freelist->u.next;
  144. }
  145. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  146. if (pkt == NULL)
  147. pkt = qdf_mem_malloc(sizeof(*pkt));
  148. return &pkt->u.pkt; /* not actually a dereference */
  149. }
  150. /*
  151. * htt_htc_pkt_free() - Free HTC packet buffer
  152. * @htt_soc: HTT SOC handle
  153. */
  154. static void
  155. htt_htc_pkt_free(struct htt_soc *soc, struct dp_htt_htc_pkt *pkt)
  156. {
  157. struct dp_htt_htc_pkt_union *u_pkt =
  158. (struct dp_htt_htc_pkt_union *)pkt;
  159. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  160. u_pkt->u.next = soc->htt_htc_pkt_freelist;
  161. soc->htt_htc_pkt_freelist = u_pkt;
  162. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  163. }
  164. /*
  165. * htt_htc_pkt_pool_free() - Free HTC packet pool
  166. * @htt_soc: HTT SOC handle
  167. */
  168. static void
  169. htt_htc_pkt_pool_free(struct htt_soc *soc)
  170. {
  171. struct dp_htt_htc_pkt_union *pkt, *next;
  172. pkt = soc->htt_htc_pkt_freelist;
  173. while (pkt) {
  174. next = pkt->u.next;
  175. qdf_mem_free(pkt);
  176. pkt = next;
  177. }
  178. soc->htt_htc_pkt_freelist = NULL;
  179. }
  180. /*
  181. * htt_htc_misc_pkt_list_trim() - trim misc list
  182. * @htt_soc: HTT SOC handle
  183. * @level: max no. of pkts in list
  184. */
  185. static void
  186. htt_htc_misc_pkt_list_trim(struct htt_soc *soc, int level)
  187. {
  188. struct dp_htt_htc_pkt_union *pkt, *next, *prev = NULL;
  189. int i = 0;
  190. qdf_nbuf_t netbuf;
  191. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  192. pkt = soc->htt_htc_pkt_misclist;
  193. while (pkt) {
  194. next = pkt->u.next;
  195. /* trim the out grown list*/
  196. if (++i > level) {
  197. netbuf =
  198. (qdf_nbuf_t)(pkt->u.pkt.htc_pkt.pNetBufContext);
  199. qdf_nbuf_unmap(soc->osdev, netbuf, QDF_DMA_TO_DEVICE);
  200. qdf_nbuf_free(netbuf);
  201. qdf_mem_free(pkt);
  202. pkt = NULL;
  203. if (prev)
  204. prev->u.next = NULL;
  205. }
  206. prev = pkt;
  207. pkt = next;
  208. }
  209. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  210. }
  211. /*
  212. * htt_htc_misc_pkt_list_add() - Add pkt to misc list
  213. * @htt_soc: HTT SOC handle
  214. * @dp_htt_htc_pkt: pkt to be added to list
  215. */
  216. static void
  217. htt_htc_misc_pkt_list_add(struct htt_soc *soc, struct dp_htt_htc_pkt *pkt)
  218. {
  219. struct dp_htt_htc_pkt_union *u_pkt =
  220. (struct dp_htt_htc_pkt_union *)pkt;
  221. int misclist_trim_level = htc_get_tx_queue_depth(soc->htc_soc,
  222. pkt->htc_pkt.Endpoint)
  223. + DP_HTT_HTC_PKT_MISCLIST_SIZE;
  224. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  225. if (soc->htt_htc_pkt_misclist) {
  226. u_pkt->u.next = soc->htt_htc_pkt_misclist;
  227. soc->htt_htc_pkt_misclist = u_pkt;
  228. } else {
  229. soc->htt_htc_pkt_misclist = u_pkt;
  230. }
  231. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  232. /* only ce pipe size + tx_queue_depth could possibly be in use
  233. * free older packets in the misclist
  234. */
  235. htt_htc_misc_pkt_list_trim(soc, misclist_trim_level);
  236. }
  237. /*
  238. * htt_htc_misc_pkt_pool_free() - free pkts in misc list
  239. * @htt_soc: HTT SOC handle
  240. */
  241. static void
  242. htt_htc_misc_pkt_pool_free(struct htt_soc *soc)
  243. {
  244. struct dp_htt_htc_pkt_union *pkt, *next;
  245. qdf_nbuf_t netbuf;
  246. pkt = soc->htt_htc_pkt_misclist;
  247. while (pkt) {
  248. next = pkt->u.next;
  249. netbuf = (qdf_nbuf_t) (pkt->u.pkt.htc_pkt.pNetBufContext);
  250. qdf_nbuf_unmap(soc->osdev, netbuf, QDF_DMA_TO_DEVICE);
  251. soc->stats.htc_pkt_free++;
  252. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
  253. "%s: Pkt free count %d\n",
  254. __func__, soc->stats.htc_pkt_free);
  255. qdf_nbuf_free(netbuf);
  256. qdf_mem_free(pkt);
  257. pkt = next;
  258. }
  259. soc->htt_htc_pkt_misclist = NULL;
  260. }
  261. /*
  262. * htt_t2h_mac_addr_deswizzle() - Swap MAC addr bytes if FW endianess differ
  263. * @tgt_mac_addr: Target MAC
  264. * @buffer: Output buffer
  265. */
  266. static u_int8_t *
  267. htt_t2h_mac_addr_deswizzle(u_int8_t *tgt_mac_addr, u_int8_t *buffer)
  268. {
  269. #ifdef BIG_ENDIAN_HOST
  270. /*
  271. * The host endianness is opposite of the target endianness.
  272. * To make u_int32_t elements come out correctly, the target->host
  273. * upload has swizzled the bytes in each u_int32_t element of the
  274. * message.
  275. * For byte-array message fields like the MAC address, this
  276. * upload swizzling puts the bytes in the wrong order, and needs
  277. * to be undone.
  278. */
  279. buffer[0] = tgt_mac_addr[3];
  280. buffer[1] = tgt_mac_addr[2];
  281. buffer[2] = tgt_mac_addr[1];
  282. buffer[3] = tgt_mac_addr[0];
  283. buffer[4] = tgt_mac_addr[7];
  284. buffer[5] = tgt_mac_addr[6];
  285. return buffer;
  286. #else
  287. /*
  288. * The host endianness matches the target endianness -
  289. * we can use the mac addr directly from the message buffer.
  290. */
  291. return tgt_mac_addr;
  292. #endif
  293. }
  294. /*
  295. * dp_htt_h2t_send_complete_free_netbuf() - Free completed buffer
  296. * @soc: SOC handle
  297. * @status: Completion status
  298. * @netbuf: HTT buffer
  299. */
  300. static void
  301. dp_htt_h2t_send_complete_free_netbuf(
  302. void *soc, A_STATUS status, qdf_nbuf_t netbuf)
  303. {
  304. qdf_nbuf_free(netbuf);
  305. }
  306. /*
  307. * dp_htt_h2t_send_complete() - H2T completion handler
  308. * @context: Opaque context (HTT SOC handle)
  309. * @htc_pkt: HTC packet
  310. */
  311. static void
  312. dp_htt_h2t_send_complete(void *context, HTC_PACKET *htc_pkt)
  313. {
  314. void (*send_complete_part2)(
  315. void *soc, A_STATUS status, qdf_nbuf_t msdu);
  316. struct htt_soc *soc = (struct htt_soc *) context;
  317. struct dp_htt_htc_pkt *htt_pkt;
  318. qdf_nbuf_t netbuf;
  319. send_complete_part2 = htc_pkt->pPktContext;
  320. htt_pkt = container_of(htc_pkt, struct dp_htt_htc_pkt, htc_pkt);
  321. /* process (free or keep) the netbuf that held the message */
  322. netbuf = (qdf_nbuf_t) htc_pkt->pNetBufContext;
  323. /*
  324. * adf sendcomplete is required for windows only
  325. */
  326. /* qdf_nbuf_set_sendcompleteflag(netbuf, TRUE); */
  327. if (send_complete_part2 != NULL) {
  328. send_complete_part2(
  329. htt_pkt->soc_ctxt, htc_pkt->Status, netbuf);
  330. }
  331. /* free the htt_htc_pkt / HTC_PACKET object */
  332. htt_htc_pkt_free(soc, htt_pkt);
  333. }
  334. /*
  335. * htt_h2t_ver_req_msg() - Send HTT version request message to target
  336. * @htt_soc: HTT SOC handle
  337. *
  338. * Return: 0 on success; error code on failure
  339. */
  340. static int htt_h2t_ver_req_msg(struct htt_soc *soc)
  341. {
  342. struct dp_htt_htc_pkt *pkt;
  343. qdf_nbuf_t msg;
  344. uint32_t *msg_word;
  345. msg = qdf_nbuf_alloc(
  346. soc->osdev,
  347. HTT_MSG_BUF_SIZE(HTT_VER_REQ_BYTES),
  348. /* reserve room for the HTC header */
  349. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  350. if (!msg)
  351. return QDF_STATUS_E_NOMEM;
  352. /*
  353. * Set the length of the message.
  354. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  355. * separately during the below call to qdf_nbuf_push_head.
  356. * The contribution from the HTC header is added separately inside HTC.
  357. */
  358. if (qdf_nbuf_put_tail(msg, HTT_VER_REQ_BYTES) == NULL) {
  359. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  360. "%s: Failed to expand head for HTT_H2T_MSG_TYPE_VERSION_REQ msg\n",
  361. __func__);
  362. return QDF_STATUS_E_FAILURE;
  363. }
  364. /* fill in the message contents */
  365. msg_word = (u_int32_t *) qdf_nbuf_data(msg);
  366. /* rewind beyond alignment pad to get to the HTC header reserved area */
  367. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  368. *msg_word = 0;
  369. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_VERSION_REQ);
  370. pkt = htt_htc_pkt_alloc(soc);
  371. if (!pkt) {
  372. qdf_nbuf_free(msg);
  373. return QDF_STATUS_E_FAILURE;
  374. }
  375. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  376. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  377. dp_htt_h2t_send_complete_free_netbuf, qdf_nbuf_data(msg),
  378. qdf_nbuf_len(msg), soc->htc_endpoint,
  379. 1); /* tag - not relevant here */
  380. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  381. DP_HTT_SEND_HTC_PKT(soc, pkt);
  382. return 0;
  383. }
  384. /*
  385. * htt_srng_setup() - Send SRNG setup message to target
  386. * @htt_soc: HTT SOC handle
  387. * @mac_id: MAC Id
  388. * @hal_srng: Opaque HAL SRNG pointer
  389. * @hal_ring_type: SRNG ring type
  390. *
  391. * Return: 0 on success; error code on failure
  392. */
  393. int htt_srng_setup(void *htt_soc, int mac_id, void *hal_srng,
  394. int hal_ring_type)
  395. {
  396. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  397. struct dp_htt_htc_pkt *pkt;
  398. qdf_nbuf_t htt_msg;
  399. uint32_t *msg_word;
  400. struct hal_srng_params srng_params;
  401. qdf_dma_addr_t hp_addr, tp_addr;
  402. uint32_t ring_entry_size =
  403. hal_srng_get_entrysize(soc->hal_soc, hal_ring_type);
  404. int htt_ring_type, htt_ring_id;
  405. /* Sizes should be set in 4-byte words */
  406. ring_entry_size = ring_entry_size >> 2;
  407. htt_msg = qdf_nbuf_alloc(soc->osdev,
  408. HTT_MSG_BUF_SIZE(HTT_SRING_SETUP_SZ),
  409. /* reserve room for the HTC header */
  410. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  411. if (!htt_msg)
  412. goto fail0;
  413. hal_get_srng_params(soc->hal_soc, hal_srng, &srng_params);
  414. hp_addr = hal_srng_get_hp_addr(soc->hal_soc, hal_srng);
  415. tp_addr = hal_srng_get_tp_addr(soc->hal_soc, hal_srng);
  416. switch (hal_ring_type) {
  417. case RXDMA_BUF:
  418. #ifdef QCA_HOST2FW_RXBUF_RING
  419. if (srng_params.ring_id ==
  420. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0)) {
  421. htt_ring_id = HTT_HOST1_TO_FW_RXBUF_RING;
  422. htt_ring_type = HTT_SW_TO_SW_RING;
  423. #ifdef IPA_OFFLOAD
  424. } else if (srng_params.ring_id ==
  425. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF2)) {
  426. htt_ring_id = HTT_HOST2_TO_FW_RXBUF_RING;
  427. htt_ring_type = HTT_SW_TO_SW_RING;
  428. #endif
  429. #else
  430. if (srng_params.ring_id ==
  431. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0 +
  432. (mac_id * HAL_MAX_RINGS_PER_LMAC))) {
  433. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  434. htt_ring_type = HTT_SW_TO_HW_RING;
  435. #endif
  436. } else if (srng_params.ring_id ==
  437. #ifdef IPA_OFFLOAD
  438. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF1 +
  439. #else
  440. (HAL_SRNG_WMAC1_SW2RXDMA1_BUF +
  441. #endif
  442. (mac_id * HAL_MAX_RINGS_PER_LMAC))) {
  443. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  444. htt_ring_type = HTT_SW_TO_HW_RING;
  445. } else {
  446. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  447. "%s: Ring %d currently not supported\n",
  448. __func__, srng_params.ring_id);
  449. goto fail1;
  450. }
  451. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  452. "%s: ring_type %d ring_id %d\n",
  453. __func__, hal_ring_type, srng_params.ring_id);
  454. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  455. "%s: hp_addr 0x%llx tp_addr 0x%llx\n",
  456. __func__, (uint64_t)hp_addr, (uint64_t)tp_addr);
  457. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  458. "%s: htt_ring_id %d\n", __func__, htt_ring_id);
  459. break;
  460. case RXDMA_MONITOR_BUF:
  461. htt_ring_id = HTT_RXDMA_MONITOR_BUF_RING;
  462. htt_ring_type = HTT_SW_TO_HW_RING;
  463. break;
  464. case RXDMA_MONITOR_STATUS:
  465. htt_ring_id = HTT_RXDMA_MONITOR_STATUS_RING;
  466. htt_ring_type = HTT_SW_TO_HW_RING;
  467. break;
  468. case RXDMA_MONITOR_DST:
  469. htt_ring_id = HTT_RXDMA_MONITOR_DEST_RING;
  470. htt_ring_type = HTT_HW_TO_SW_RING;
  471. break;
  472. case RXDMA_MONITOR_DESC:
  473. htt_ring_id = HTT_RXDMA_MONITOR_DESC_RING;
  474. htt_ring_type = HTT_SW_TO_HW_RING;
  475. break;
  476. case RXDMA_DST:
  477. htt_ring_id = HTT_RXDMA_NON_MONITOR_DEST_RING;
  478. htt_ring_type = HTT_HW_TO_SW_RING;
  479. break;
  480. default:
  481. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  482. "%s: Ring currently not supported\n", __func__);
  483. goto fail1;
  484. }
  485. /*
  486. * Set the length of the message.
  487. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  488. * separately during the below call to qdf_nbuf_push_head.
  489. * The contribution from the HTC header is added separately inside HTC.
  490. */
  491. if (qdf_nbuf_put_tail(htt_msg, HTT_SRING_SETUP_SZ) == NULL) {
  492. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  493. "%s: Failed to expand head for SRING_SETUP msg\n",
  494. __func__);
  495. return QDF_STATUS_E_FAILURE;
  496. }
  497. msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
  498. /* rewind beyond alignment pad to get to the HTC header reserved area */
  499. qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
  500. /* word 0 */
  501. *msg_word = 0;
  502. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_SRING_SETUP);
  503. if ((htt_ring_type == HTT_SW_TO_HW_RING) ||
  504. (htt_ring_type == HTT_HW_TO_SW_RING))
  505. HTT_SRING_SETUP_PDEV_ID_SET(*msg_word,
  506. DP_SW2HW_MACID(mac_id));
  507. else
  508. HTT_SRING_SETUP_PDEV_ID_SET(*msg_word, mac_id);
  509. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  510. "%s: mac_id %d\n", __func__, mac_id);
  511. HTT_SRING_SETUP_RING_TYPE_SET(*msg_word, htt_ring_type);
  512. /* TODO: Discuss with FW on changing this to unique ID and using
  513. * htt_ring_type to send the type of ring
  514. */
  515. HTT_SRING_SETUP_RING_ID_SET(*msg_word, htt_ring_id);
  516. /* word 1 */
  517. msg_word++;
  518. *msg_word = 0;
  519. HTT_SRING_SETUP_RING_BASE_ADDR_LO_SET(*msg_word,
  520. srng_params.ring_base_paddr & 0xffffffff);
  521. /* word 2 */
  522. msg_word++;
  523. *msg_word = 0;
  524. HTT_SRING_SETUP_RING_BASE_ADDR_HI_SET(*msg_word,
  525. (uint64_t)srng_params.ring_base_paddr >> 32);
  526. /* word 3 */
  527. msg_word++;
  528. *msg_word = 0;
  529. HTT_SRING_SETUP_ENTRY_SIZE_SET(*msg_word, ring_entry_size);
  530. HTT_SRING_SETUP_RING_SIZE_SET(*msg_word,
  531. (ring_entry_size * srng_params.num_entries));
  532. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  533. "%s: entry_size %d\n", __func__,
  534. ring_entry_size);
  535. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  536. "%s: num_entries %d\n", __func__,
  537. srng_params.num_entries);
  538. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  539. "%s: ring_size %d\n", __func__,
  540. (ring_entry_size * srng_params.num_entries));
  541. if (htt_ring_type == HTT_SW_TO_HW_RING)
  542. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_LOOPCOUNT_DISABLE_SET(
  543. *msg_word, 1);
  544. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_MSI_SWAP_SET(*msg_word,
  545. !!(srng_params.flags & HAL_SRNG_MSI_SWAP));
  546. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_TLV_SWAP_SET(*msg_word,
  547. !!(srng_params.flags & HAL_SRNG_DATA_TLV_SWAP));
  548. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_HOST_FW_SWAP_SET(*msg_word,
  549. !!(srng_params.flags & HAL_SRNG_RING_PTR_SWAP));
  550. /* word 4 */
  551. msg_word++;
  552. *msg_word = 0;
  553. HTT_SRING_SETUP_HEAD_OFFSET32_REMOTE_BASE_ADDR_LO_SET(*msg_word,
  554. hp_addr & 0xffffffff);
  555. /* word 5 */
  556. msg_word++;
  557. *msg_word = 0;
  558. HTT_SRING_SETUP_HEAD_OFFSET32_REMOTE_BASE_ADDR_HI_SET(*msg_word,
  559. (uint64_t)hp_addr >> 32);
  560. /* word 6 */
  561. msg_word++;
  562. *msg_word = 0;
  563. HTT_SRING_SETUP_TAIL_OFFSET32_REMOTE_BASE_ADDR_LO_SET(*msg_word,
  564. tp_addr & 0xffffffff);
  565. /* word 7 */
  566. msg_word++;
  567. *msg_word = 0;
  568. HTT_SRING_SETUP_TAIL_OFFSET32_REMOTE_BASE_ADDR_HI_SET(*msg_word,
  569. (uint64_t)tp_addr >> 32);
  570. /* word 8 */
  571. msg_word++;
  572. *msg_word = 0;
  573. HTT_SRING_SETUP_RING_MSI_ADDR_LO_SET(*msg_word,
  574. srng_params.msi_addr & 0xffffffff);
  575. /* word 9 */
  576. msg_word++;
  577. *msg_word = 0;
  578. HTT_SRING_SETUP_RING_MSI_ADDR_HI_SET(*msg_word,
  579. (uint64_t)(srng_params.msi_addr) >> 32);
  580. /* word 10 */
  581. msg_word++;
  582. *msg_word = 0;
  583. HTT_SRING_SETUP_RING_MSI_DATA_SET(*msg_word,
  584. srng_params.msi_data);
  585. /* word 11 */
  586. msg_word++;
  587. *msg_word = 0;
  588. HTT_SRING_SETUP_INTR_BATCH_COUNTER_TH_SET(*msg_word,
  589. srng_params.intr_batch_cntr_thres_entries *
  590. ring_entry_size);
  591. HTT_SRING_SETUP_INTR_TIMER_TH_SET(*msg_word,
  592. srng_params.intr_timer_thres_us >> 3);
  593. /* word 12 */
  594. msg_word++;
  595. *msg_word = 0;
  596. if (srng_params.flags & HAL_SRNG_LOW_THRES_INTR_ENABLE) {
  597. /* TODO: Setting low threshold to 1/8th of ring size - see
  598. * if this needs to be configurable
  599. */
  600. HTT_SRING_SETUP_INTR_LOW_TH_SET(*msg_word,
  601. srng_params.low_threshold);
  602. }
  603. /* "response_required" field should be set if a HTT response message is
  604. * required after setting up the ring.
  605. */
  606. pkt = htt_htc_pkt_alloc(soc);
  607. if (!pkt)
  608. goto fail1;
  609. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  610. SET_HTC_PACKET_INFO_TX(
  611. &pkt->htc_pkt,
  612. dp_htt_h2t_send_complete_free_netbuf,
  613. qdf_nbuf_data(htt_msg),
  614. qdf_nbuf_len(htt_msg),
  615. soc->htc_endpoint,
  616. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  617. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  618. DP_HTT_SEND_HTC_PKT(soc, pkt);
  619. return QDF_STATUS_SUCCESS;
  620. fail1:
  621. qdf_nbuf_free(htt_msg);
  622. fail0:
  623. return QDF_STATUS_E_FAILURE;
  624. }
  625. /*
  626. * htt_h2t_rx_ring_cfg() - Send SRNG packet and TLV filter
  627. * config message to target
  628. * @htt_soc: HTT SOC handle
  629. * @pdev_id: PDEV Id
  630. * @hal_srng: Opaque HAL SRNG pointer
  631. * @hal_ring_type: SRNG ring type
  632. * @ring_buf_size: SRNG buffer size
  633. * @htt_tlv_filter: Rx SRNG TLV and filter setting
  634. * Return: 0 on success; error code on failure
  635. */
  636. int htt_h2t_rx_ring_cfg(void *htt_soc, int pdev_id, void *hal_srng,
  637. int hal_ring_type, int ring_buf_size,
  638. struct htt_rx_ring_tlv_filter *htt_tlv_filter)
  639. {
  640. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  641. struct dp_htt_htc_pkt *pkt;
  642. qdf_nbuf_t htt_msg;
  643. uint32_t *msg_word;
  644. struct hal_srng_params srng_params;
  645. uint32_t htt_ring_type, htt_ring_id;
  646. uint32_t tlv_filter;
  647. htt_msg = qdf_nbuf_alloc(soc->osdev,
  648. HTT_MSG_BUF_SIZE(HTT_RX_RING_SELECTION_CFG_SZ),
  649. /* reserve room for the HTC header */
  650. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  651. if (!htt_msg)
  652. goto fail0;
  653. hal_get_srng_params(soc->hal_soc, hal_srng, &srng_params);
  654. switch (hal_ring_type) {
  655. case RXDMA_BUF:
  656. #if QCA_HOST2FW_RXBUF_RING
  657. htt_ring_id = HTT_HOST1_TO_FW_RXBUF_RING;
  658. htt_ring_type = HTT_SW_TO_SW_RING;
  659. #else
  660. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  661. htt_ring_type = HTT_SW_TO_HW_RING;
  662. #endif
  663. break;
  664. case RXDMA_MONITOR_BUF:
  665. htt_ring_id = HTT_RXDMA_MONITOR_BUF_RING;
  666. htt_ring_type = HTT_SW_TO_HW_RING;
  667. break;
  668. case RXDMA_MONITOR_STATUS:
  669. htt_ring_id = HTT_RXDMA_MONITOR_STATUS_RING;
  670. htt_ring_type = HTT_SW_TO_HW_RING;
  671. break;
  672. case RXDMA_MONITOR_DST:
  673. htt_ring_id = HTT_RXDMA_MONITOR_DEST_RING;
  674. htt_ring_type = HTT_HW_TO_SW_RING;
  675. break;
  676. case RXDMA_MONITOR_DESC:
  677. htt_ring_id = HTT_RXDMA_MONITOR_DESC_RING;
  678. htt_ring_type = HTT_SW_TO_HW_RING;
  679. break;
  680. case RXDMA_DST:
  681. htt_ring_id = HTT_RXDMA_NON_MONITOR_DEST_RING;
  682. htt_ring_type = HTT_HW_TO_SW_RING;
  683. break;
  684. default:
  685. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  686. "%s: Ring currently not supported\n", __func__);
  687. goto fail1;
  688. }
  689. /*
  690. * Set the length of the message.
  691. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  692. * separately during the below call to qdf_nbuf_push_head.
  693. * The contribution from the HTC header is added separately inside HTC.
  694. */
  695. if (qdf_nbuf_put_tail(htt_msg, HTT_RX_RING_SELECTION_CFG_SZ) == NULL) {
  696. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  697. "%s: Failed to expand head for RX Ring Cfg msg\n",
  698. __func__);
  699. goto fail1; /* failure */
  700. }
  701. msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
  702. /* rewind beyond alignment pad to get to the HTC header reserved area */
  703. qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
  704. /* word 0 */
  705. *msg_word = 0;
  706. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_RING_SELECTION_CFG);
  707. /*
  708. * pdev_id is indexed from 0 whereas mac_id is indexed from 1
  709. * SW_TO_SW and SW_TO_HW rings are unaffected by this
  710. */
  711. if (htt_ring_type == HTT_SW_TO_SW_RING ||
  712. htt_ring_type == HTT_SW_TO_HW_RING)
  713. HTT_RX_RING_SELECTION_CFG_PDEV_ID_SET(*msg_word,
  714. DP_SW2HW_MACID(pdev_id));
  715. /* TODO: Discuss with FW on changing this to unique ID and using
  716. * htt_ring_type to send the type of ring
  717. */
  718. HTT_RX_RING_SELECTION_CFG_RING_ID_SET(*msg_word, htt_ring_id);
  719. HTT_RX_RING_SELECTION_CFG_STATUS_TLV_SET(*msg_word,
  720. !!(srng_params.flags & HAL_SRNG_MSI_SWAP));
  721. HTT_RX_RING_SELECTION_CFG_PKT_TLV_SET(*msg_word,
  722. !!(srng_params.flags & HAL_SRNG_DATA_TLV_SWAP));
  723. /* word 1 */
  724. msg_word++;
  725. *msg_word = 0;
  726. HTT_RX_RING_SELECTION_CFG_RING_BUFFER_SIZE_SET(*msg_word,
  727. ring_buf_size);
  728. /* word 2 */
  729. msg_word++;
  730. *msg_word = 0;
  731. if (htt_tlv_filter->enable_fp) {
  732. /* TYPE: MGMT */
  733. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  734. FP, MGMT, 0000,
  735. (htt_tlv_filter->fp_mgmt_filter &
  736. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  737. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  738. FP, MGMT, 0001,
  739. (htt_tlv_filter->fp_mgmt_filter &
  740. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  741. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  742. FP, MGMT, 0010,
  743. (htt_tlv_filter->fp_mgmt_filter &
  744. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  745. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  746. FP, MGMT, 0011,
  747. (htt_tlv_filter->fp_mgmt_filter &
  748. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  749. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  750. FP, MGMT, 0100,
  751. (htt_tlv_filter->fp_mgmt_filter &
  752. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  753. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  754. FP, MGMT, 0101,
  755. (htt_tlv_filter->fp_mgmt_filter &
  756. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  757. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  758. FP, MGMT, 0110,
  759. (htt_tlv_filter->fp_mgmt_filter &
  760. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  761. /* reserved */
  762. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, FP,
  763. MGMT, 0111,
  764. (htt_tlv_filter->fp_mgmt_filter &
  765. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  766. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  767. FP, MGMT, 1000,
  768. (htt_tlv_filter->fp_mgmt_filter &
  769. FILTER_MGMT_BEACON) ? 1 : 0);
  770. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  771. FP, MGMT, 1001,
  772. (htt_tlv_filter->fp_mgmt_filter &
  773. FILTER_MGMT_ATIM) ? 1 : 0);
  774. }
  775. if (htt_tlv_filter->enable_md) {
  776. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
  777. MGMT, 0000, 1);
  778. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
  779. MGMT, 0001, 1);
  780. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
  781. MGMT, 0010, 1);
  782. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
  783. MGMT, 0011, 1);
  784. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
  785. MGMT, 0100, 1);
  786. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
  787. MGMT, 0101, 1);
  788. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
  789. MGMT, 0110, 1);
  790. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
  791. MGMT, 0111, 1);
  792. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
  793. MGMT, 1000, 1);
  794. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
  795. MGMT, 1001, 1);
  796. }
  797. if (htt_tlv_filter->enable_mo) {
  798. /* TYPE: MGMT */
  799. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  800. MO, MGMT, 0000,
  801. (htt_tlv_filter->mo_mgmt_filter &
  802. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  803. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  804. MO, MGMT, 0001,
  805. (htt_tlv_filter->mo_mgmt_filter &
  806. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  807. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  808. MO, MGMT, 0010,
  809. (htt_tlv_filter->mo_mgmt_filter &
  810. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  811. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  812. MO, MGMT, 0011,
  813. (htt_tlv_filter->mo_mgmt_filter &
  814. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  815. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  816. MO, MGMT, 0100,
  817. (htt_tlv_filter->mo_mgmt_filter &
  818. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  819. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  820. MO, MGMT, 0101,
  821. (htt_tlv_filter->mo_mgmt_filter &
  822. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  823. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  824. MO, MGMT, 0110,
  825. (htt_tlv_filter->mo_mgmt_filter &
  826. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  827. /* reserved */
  828. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MO,
  829. MGMT, 0111,
  830. (htt_tlv_filter->mo_mgmt_filter &
  831. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  832. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  833. MO, MGMT, 1000,
  834. (htt_tlv_filter->mo_mgmt_filter &
  835. FILTER_MGMT_BEACON) ? 1 : 0);
  836. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  837. MO, MGMT, 1001,
  838. (htt_tlv_filter->mo_mgmt_filter &
  839. FILTER_MGMT_ATIM) ? 1 : 0);
  840. }
  841. /* word 3 */
  842. msg_word++;
  843. *msg_word = 0;
  844. if (htt_tlv_filter->enable_fp) {
  845. /* TYPE: MGMT */
  846. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  847. FP, MGMT, 1010,
  848. (htt_tlv_filter->fp_mgmt_filter &
  849. FILTER_MGMT_DISASSOC) ? 1 : 0);
  850. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  851. FP, MGMT, 1011,
  852. (htt_tlv_filter->fp_mgmt_filter &
  853. FILTER_MGMT_AUTH) ? 1 : 0);
  854. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  855. FP, MGMT, 1100,
  856. (htt_tlv_filter->fp_mgmt_filter &
  857. FILTER_MGMT_DEAUTH) ? 1 : 0);
  858. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  859. FP, MGMT, 1101,
  860. (htt_tlv_filter->fp_mgmt_filter &
  861. FILTER_MGMT_ACTION) ? 1 : 0);
  862. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  863. FP, MGMT, 1110,
  864. (htt_tlv_filter->fp_mgmt_filter &
  865. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  866. /* reserved*/
  867. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, FP,
  868. MGMT, 1111,
  869. (htt_tlv_filter->fp_mgmt_filter &
  870. FILTER_MGMT_RESERVED_15) ? 1 : 0);
  871. }
  872. if (htt_tlv_filter->enable_md) {
  873. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MD,
  874. MGMT, 1010, 1);
  875. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MD,
  876. MGMT, 1011, 1);
  877. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MD,
  878. MGMT, 1100, 1);
  879. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MD,
  880. MGMT, 1101, 1);
  881. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MD,
  882. MGMT, 1110, 1);
  883. }
  884. if (htt_tlv_filter->enable_mo) {
  885. /* TYPE: MGMT */
  886. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  887. MO, MGMT, 1010,
  888. (htt_tlv_filter->mo_mgmt_filter &
  889. FILTER_MGMT_DISASSOC) ? 1 : 0);
  890. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  891. MO, MGMT, 1011,
  892. (htt_tlv_filter->mo_mgmt_filter &
  893. FILTER_MGMT_AUTH) ? 1 : 0);
  894. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  895. MO, MGMT, 1100,
  896. (htt_tlv_filter->mo_mgmt_filter &
  897. FILTER_MGMT_DEAUTH) ? 1 : 0);
  898. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  899. MO, MGMT, 1101,
  900. (htt_tlv_filter->mo_mgmt_filter &
  901. FILTER_MGMT_ACTION) ? 1 : 0);
  902. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  903. MO, MGMT, 1110,
  904. (htt_tlv_filter->mo_mgmt_filter &
  905. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  906. /* reserved*/
  907. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MO,
  908. MGMT, 1111,
  909. (htt_tlv_filter->mo_mgmt_filter &
  910. FILTER_MGMT_RESERVED_15) ? 1 : 0);
  911. }
  912. /* word 4 */
  913. msg_word++;
  914. *msg_word = 0;
  915. if (htt_tlv_filter->enable_fp) {
  916. /* TYPE: CTRL */
  917. /* reserved */
  918. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  919. CTRL, 0000,
  920. (htt_tlv_filter->fp_ctrl_filter &
  921. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  922. /* reserved */
  923. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  924. CTRL, 0001,
  925. (htt_tlv_filter->fp_ctrl_filter &
  926. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  927. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  928. CTRL, 0010,
  929. (htt_tlv_filter->fp_ctrl_filter &
  930. FILTER_CTRL_TRIGGER) ? 1 : 0);
  931. /* reserved */
  932. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  933. CTRL, 0011,
  934. (htt_tlv_filter->fp_ctrl_filter &
  935. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  936. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  937. CTRL, 0100,
  938. (htt_tlv_filter->fp_ctrl_filter &
  939. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  940. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  941. CTRL, 0101,
  942. (htt_tlv_filter->fp_ctrl_filter &
  943. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  944. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  945. CTRL, 0110,
  946. (htt_tlv_filter->fp_ctrl_filter &
  947. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  948. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  949. CTRL, 0111,
  950. (htt_tlv_filter->fp_ctrl_filter &
  951. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  952. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  953. CTRL, 1000,
  954. (htt_tlv_filter->fp_ctrl_filter &
  955. FILTER_CTRL_BA_REQ) ? 1 : 0);
  956. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  957. CTRL, 1001,
  958. (htt_tlv_filter->fp_ctrl_filter &
  959. FILTER_CTRL_BA) ? 1 : 0);
  960. }
  961. if (htt_tlv_filter->enable_md) {
  962. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  963. CTRL, 0000, 1);
  964. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  965. CTRL, 0001, 1);
  966. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  967. CTRL, 0010, 1);
  968. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  969. CTRL, 0011, 1);
  970. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  971. CTRL, 0100, 1);
  972. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  973. CTRL, 0101, 1);
  974. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  975. CTRL, 0110, 1);
  976. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  977. CTRL, 0111, 1);
  978. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  979. CTRL, 1000, 1);
  980. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  981. CTRL, 1001, 1);
  982. }
  983. if (htt_tlv_filter->enable_mo) {
  984. /* TYPE: CTRL */
  985. /* reserved */
  986. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  987. CTRL, 0000,
  988. (htt_tlv_filter->mo_ctrl_filter &
  989. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  990. /* reserved */
  991. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  992. CTRL, 0001,
  993. (htt_tlv_filter->mo_ctrl_filter &
  994. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  995. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  996. CTRL, 0010,
  997. (htt_tlv_filter->mo_ctrl_filter &
  998. FILTER_CTRL_TRIGGER) ? 1 : 0);
  999. /* reserved */
  1000. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1001. CTRL, 0011,
  1002. (htt_tlv_filter->mo_ctrl_filter &
  1003. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1004. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1005. CTRL, 0100,
  1006. (htt_tlv_filter->mo_ctrl_filter &
  1007. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1008. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1009. CTRL, 0101,
  1010. (htt_tlv_filter->mo_ctrl_filter &
  1011. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1012. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1013. CTRL, 0110,
  1014. (htt_tlv_filter->mo_ctrl_filter &
  1015. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1016. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1017. CTRL, 0111,
  1018. (htt_tlv_filter->mo_ctrl_filter &
  1019. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1020. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1021. CTRL, 1000,
  1022. (htt_tlv_filter->mo_ctrl_filter &
  1023. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1024. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1025. CTRL, 1001,
  1026. (htt_tlv_filter->mo_ctrl_filter &
  1027. FILTER_CTRL_BA) ? 1 : 0);
  1028. }
  1029. /* word 5 */
  1030. msg_word++;
  1031. *msg_word = 0;
  1032. if (htt_tlv_filter->enable_fp) {
  1033. /* TYPE: CTRL */
  1034. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1035. CTRL, 1010,
  1036. (htt_tlv_filter->fp_ctrl_filter &
  1037. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1038. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1039. CTRL, 1011,
  1040. (htt_tlv_filter->fp_ctrl_filter &
  1041. FILTER_CTRL_RTS) ? 1 : 0);
  1042. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1043. CTRL, 1100,
  1044. (htt_tlv_filter->fp_ctrl_filter &
  1045. FILTER_CTRL_CTS) ? 1 : 0);
  1046. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1047. CTRL, 1101,
  1048. (htt_tlv_filter->fp_ctrl_filter &
  1049. FILTER_CTRL_ACK) ? 1 : 0);
  1050. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1051. CTRL, 1110,
  1052. (htt_tlv_filter->fp_ctrl_filter &
  1053. FILTER_CTRL_CFEND) ? 1 : 0);
  1054. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1055. CTRL, 1111,
  1056. (htt_tlv_filter->fp_ctrl_filter &
  1057. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1058. /* TYPE: DATA */
  1059. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1060. DATA, MCAST,
  1061. (htt_tlv_filter->fp_data_filter &
  1062. FILTER_DATA_MCAST) ? 1 : 0);
  1063. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1064. DATA, UCAST,
  1065. (htt_tlv_filter->fp_data_filter &
  1066. FILTER_DATA_UCAST) ? 1 : 0);
  1067. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1068. DATA, NULL,
  1069. (htt_tlv_filter->fp_data_filter &
  1070. FILTER_DATA_NULL) ? 1 : 0);
  1071. }
  1072. if (htt_tlv_filter->enable_md) {
  1073. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1074. CTRL, 1010, 1);
  1075. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1076. CTRL, 1011, 1);
  1077. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1078. CTRL, 1100, 1);
  1079. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1080. CTRL, 1101, 1);
  1081. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1082. CTRL, 1110, 1);
  1083. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1084. CTRL, 1111, 1);
  1085. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1086. DATA, MCAST, 1);
  1087. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1088. DATA, UCAST, 1);
  1089. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1090. DATA, NULL, 1);
  1091. }
  1092. if (htt_tlv_filter->enable_mo) {
  1093. /* TYPE: CTRL */
  1094. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1095. CTRL, 1010,
  1096. (htt_tlv_filter->mo_ctrl_filter &
  1097. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1098. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1099. CTRL, 1011,
  1100. (htt_tlv_filter->mo_ctrl_filter &
  1101. FILTER_CTRL_RTS) ? 1 : 0);
  1102. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1103. CTRL, 1100,
  1104. (htt_tlv_filter->mo_ctrl_filter &
  1105. FILTER_CTRL_CTS) ? 1 : 0);
  1106. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1107. CTRL, 1101,
  1108. (htt_tlv_filter->mo_ctrl_filter &
  1109. FILTER_CTRL_ACK) ? 1 : 0);
  1110. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1111. CTRL, 1110,
  1112. (htt_tlv_filter->mo_ctrl_filter &
  1113. FILTER_CTRL_CFEND) ? 1 : 0);
  1114. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1115. CTRL, 1111,
  1116. (htt_tlv_filter->mo_ctrl_filter &
  1117. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1118. /* TYPE: DATA */
  1119. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1120. DATA, MCAST,
  1121. (htt_tlv_filter->mo_data_filter &
  1122. FILTER_DATA_MCAST) ? 1 : 0);
  1123. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1124. DATA, UCAST,
  1125. (htt_tlv_filter->mo_data_filter &
  1126. FILTER_DATA_UCAST) ? 1 : 0);
  1127. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1128. DATA, NULL,
  1129. (htt_tlv_filter->mo_data_filter &
  1130. FILTER_DATA_NULL) ? 1 : 0);
  1131. }
  1132. /* word 6 */
  1133. msg_word++;
  1134. *msg_word = 0;
  1135. tlv_filter = 0;
  1136. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MPDU_START,
  1137. htt_tlv_filter->mpdu_start);
  1138. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MSDU_START,
  1139. htt_tlv_filter->msdu_start);
  1140. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PACKET,
  1141. htt_tlv_filter->packet);
  1142. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MSDU_END,
  1143. htt_tlv_filter->msdu_end);
  1144. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MPDU_END,
  1145. htt_tlv_filter->mpdu_end);
  1146. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PACKET_HEADER,
  1147. htt_tlv_filter->packet_header);
  1148. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, ATTENTION,
  1149. htt_tlv_filter->attention);
  1150. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_START,
  1151. htt_tlv_filter->ppdu_start);
  1152. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END,
  1153. htt_tlv_filter->ppdu_end);
  1154. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END_USER_STATS,
  1155. htt_tlv_filter->ppdu_end_user_stats);
  1156. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter,
  1157. PPDU_END_USER_STATS_EXT,
  1158. htt_tlv_filter->ppdu_end_user_stats_ext);
  1159. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END_STATUS_DONE,
  1160. htt_tlv_filter->ppdu_end_status_done);
  1161. /* RESERVED bit maps to header_per_msdu in htt_tlv_filter*/
  1162. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, RESERVED,
  1163. htt_tlv_filter->header_per_msdu);
  1164. HTT_RX_RING_SELECTION_CFG_TLV_FILTER_IN_FLAG_SET(*msg_word, tlv_filter);
  1165. /* "response_required" field should be set if a HTT response message is
  1166. * required after setting up the ring.
  1167. */
  1168. pkt = htt_htc_pkt_alloc(soc);
  1169. if (!pkt)
  1170. goto fail1;
  1171. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  1172. SET_HTC_PACKET_INFO_TX(
  1173. &pkt->htc_pkt,
  1174. dp_htt_h2t_send_complete_free_netbuf,
  1175. qdf_nbuf_data(htt_msg),
  1176. qdf_nbuf_len(htt_msg),
  1177. soc->htc_endpoint,
  1178. 1); /* tag - not relevant here */
  1179. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  1180. DP_HTT_SEND_HTC_PKT(soc, pkt);
  1181. return QDF_STATUS_SUCCESS;
  1182. fail1:
  1183. qdf_nbuf_free(htt_msg);
  1184. fail0:
  1185. return QDF_STATUS_E_FAILURE;
  1186. }
  1187. #if defined(CONFIG_WIN) && WDI_EVENT_ENABLE
  1188. static inline QDF_STATUS dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
  1189. struct dp_soc *soc, qdf_nbuf_t htt_msg)
  1190. {
  1191. uint32_t pdev_id;
  1192. uint32_t *msg_word = NULL;
  1193. uint32_t msg_remain_len = 0;
  1194. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1195. /*COOKIE MSB*/
  1196. pdev_id = *(msg_word + 2);
  1197. /* stats message length + 16 size of HTT header*/
  1198. msg_remain_len = qdf_min(htt_stats->msg_len + 16,
  1199. (uint32_t)DP_EXT_MSG_LENGTH);
  1200. dp_wdi_event_handler(WDI_EVENT_HTT_STATS, soc,
  1201. msg_word, msg_remain_len,
  1202. WDI_NO_VAL, pdev_id);
  1203. if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
  1204. htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
  1205. }
  1206. /* Need to be freed here as WDI handler will
  1207. * make a copy of pkt to send data to application
  1208. */
  1209. qdf_nbuf_free(htt_msg);
  1210. return QDF_STATUS_SUCCESS;
  1211. }
  1212. #else
  1213. static inline QDF_STATUS dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
  1214. struct dp_soc *soc, qdf_nbuf_t htt_msg)
  1215. {
  1216. return QDF_STATUS_E_NOSUPPORT;
  1217. }
  1218. #endif
  1219. /**
  1220. * dp_process_htt_stat_msg(): Process the list of buffers of HTT EXT stats
  1221. * @htt_stats: htt stats info
  1222. *
  1223. * The FW sends the HTT EXT STATS as a stream of T2H messages. Each T2H message
  1224. * contains sub messages which are identified by a TLV header.
  1225. * In this function we will process the stream of T2H messages and read all the
  1226. * TLV contained in the message.
  1227. *
  1228. * THe following cases have been taken care of
  1229. * Case 1: When the tlv_remain_length <= msg_remain_length of HTT MSG buffer
  1230. * In this case the buffer will contain multiple tlvs.
  1231. * Case 2: When the tlv_remain_length > msg_remain_length of HTT MSG buffer.
  1232. * Only one tlv will be contained in the HTT message and this tag
  1233. * will extend onto the next buffer.
  1234. * Case 3: When the buffer is the continuation of the previous message
  1235. * Case 4: tlv length is 0. which will indicate the end of message
  1236. *
  1237. * return: void
  1238. */
  1239. static inline void dp_process_htt_stat_msg(struct htt_stats_context *htt_stats,
  1240. struct dp_soc *soc)
  1241. {
  1242. htt_tlv_tag_t tlv_type = 0xff;
  1243. qdf_nbuf_t htt_msg = NULL;
  1244. uint32_t *msg_word;
  1245. uint8_t *tlv_buf_head = NULL;
  1246. uint8_t *tlv_buf_tail = NULL;
  1247. uint32_t msg_remain_len = 0;
  1248. uint32_t tlv_remain_len = 0;
  1249. uint32_t *tlv_start;
  1250. int cookie_val;
  1251. /* Process node in the HTT message queue */
  1252. while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
  1253. != NULL) {
  1254. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1255. cookie_val = *(msg_word + 1);
  1256. if (cookie_val) {
  1257. if (dp_send_htt_stat_resp(htt_stats, soc, htt_msg)
  1258. == QDF_STATUS_SUCCESS) {
  1259. continue;
  1260. }
  1261. }
  1262. /* read 5th word */
  1263. msg_word = msg_word + 4;
  1264. msg_remain_len = qdf_min(htt_stats->msg_len,
  1265. (uint32_t) DP_EXT_MSG_LENGTH);
  1266. /* Keep processing the node till node length is 0 */
  1267. while (msg_remain_len) {
  1268. /*
  1269. * if message is not a continuation of previous message
  1270. * read the tlv type and tlv length
  1271. */
  1272. if (!tlv_buf_head) {
  1273. tlv_type = HTT_STATS_TLV_TAG_GET(
  1274. *msg_word);
  1275. tlv_remain_len = HTT_STATS_TLV_LENGTH_GET(
  1276. *msg_word);
  1277. }
  1278. if (tlv_remain_len == 0) {
  1279. msg_remain_len = 0;
  1280. if (tlv_buf_head) {
  1281. qdf_mem_free(tlv_buf_head);
  1282. tlv_buf_head = NULL;
  1283. tlv_buf_tail = NULL;
  1284. }
  1285. goto error;
  1286. }
  1287. if (!tlv_buf_head)
  1288. tlv_remain_len += HTT_TLV_HDR_LEN;
  1289. if ((tlv_remain_len <= msg_remain_len)) {
  1290. /* Case 3 */
  1291. if (tlv_buf_head) {
  1292. qdf_mem_copy(tlv_buf_tail,
  1293. (uint8_t *)msg_word,
  1294. tlv_remain_len);
  1295. tlv_start = (uint32_t *)tlv_buf_head;
  1296. } else {
  1297. /* Case 1 */
  1298. tlv_start = msg_word;
  1299. }
  1300. dp_htt_stats_print_tag(tlv_type, tlv_start);
  1301. msg_remain_len -= tlv_remain_len;
  1302. msg_word = (uint32_t *)
  1303. (((uint8_t *)msg_word) +
  1304. tlv_remain_len);
  1305. tlv_remain_len = 0;
  1306. if (tlv_buf_head) {
  1307. qdf_mem_free(tlv_buf_head);
  1308. tlv_buf_head = NULL;
  1309. tlv_buf_tail = NULL;
  1310. }
  1311. } else { /* tlv_remain_len > msg_remain_len */
  1312. /* Case 2 & 3 */
  1313. if (!tlv_buf_head) {
  1314. tlv_buf_head = qdf_mem_malloc(
  1315. tlv_remain_len);
  1316. if (!tlv_buf_head) {
  1317. QDF_TRACE(QDF_MODULE_ID_TXRX,
  1318. QDF_TRACE_LEVEL_ERROR,
  1319. "Alloc failed");
  1320. goto error;
  1321. }
  1322. tlv_buf_tail = tlv_buf_head;
  1323. }
  1324. qdf_mem_copy(tlv_buf_tail, (uint8_t *)msg_word,
  1325. msg_remain_len);
  1326. tlv_remain_len -= msg_remain_len;
  1327. tlv_buf_tail += msg_remain_len;
  1328. }
  1329. }
  1330. if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
  1331. htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
  1332. }
  1333. qdf_nbuf_free(htt_msg);
  1334. }
  1335. return;
  1336. error:
  1337. qdf_nbuf_free(htt_msg);
  1338. while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
  1339. != NULL)
  1340. qdf_nbuf_free(htt_msg);
  1341. }
  1342. void htt_t2h_stats_handler(void *context)
  1343. {
  1344. struct dp_soc *soc = (struct dp_soc *)context;
  1345. struct htt_stats_context htt_stats;
  1346. uint32_t length;
  1347. uint32_t *msg_word;
  1348. qdf_nbuf_t htt_msg = NULL;
  1349. uint8_t done;
  1350. uint8_t rem_stats;
  1351. if (!soc || !qdf_atomic_read(&soc->cmn_init_done)) {
  1352. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1353. "soc: 0x%pK, init_done: %d", soc,
  1354. qdf_atomic_read(&soc->cmn_init_done));
  1355. return;
  1356. }
  1357. qdf_mem_zero(&htt_stats, sizeof(htt_stats));
  1358. qdf_nbuf_queue_init(&htt_stats.msg);
  1359. /* pull one completed stats from soc->htt_stats_msg and process */
  1360. qdf_spin_lock_bh(&soc->htt_stats.lock);
  1361. if (!soc->htt_stats.num_stats) {
  1362. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  1363. return;
  1364. }
  1365. while ((htt_msg = qdf_nbuf_queue_remove(&soc->htt_stats.msg)) != NULL) {
  1366. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1367. msg_word = msg_word + HTT_T2H_EXT_STATS_TLV_START_OFFSET;
  1368. length = HTT_T2H_EXT_STATS_CONF_TLV_LENGTH_GET(*msg_word);
  1369. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  1370. qdf_nbuf_queue_add(&htt_stats.msg, htt_msg);
  1371. /*
  1372. * HTT EXT stats response comes as stream of TLVs which span over
  1373. * multiple T2H messages.
  1374. * The first message will carry length of the response.
  1375. * For rest of the messages length will be zero.
  1376. */
  1377. if (length)
  1378. htt_stats.msg_len = length;
  1379. /*
  1380. * Done bit signifies that this is the last T2H buffer in the
  1381. * stream of HTT EXT STATS message
  1382. */
  1383. if (done)
  1384. break;
  1385. }
  1386. rem_stats = --soc->htt_stats.num_stats;
  1387. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  1388. dp_process_htt_stat_msg(&htt_stats, soc);
  1389. /* If there are more stats to process, schedule stats work again */
  1390. if (rem_stats)
  1391. qdf_sched_work(0, &soc->htt_stats.work);
  1392. }
  1393. /*
  1394. * dp_get_ppdu_info_user_index: Find place holder for the received
  1395. * ppdu stats info
  1396. * pdev: DP pdev handle
  1397. *
  1398. * return:user index to be populated
  1399. */
  1400. #ifdef FEATURE_PERPKT_INFO
  1401. static uint8_t dp_get_ppdu_info_user_index(struct dp_pdev *pdev,
  1402. uint16_t peer_id)
  1403. {
  1404. uint8_t user_index = 0;
  1405. struct cdp_tx_completion_ppdu *ppdu_desc;
  1406. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  1407. ppdu_desc =
  1408. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
  1409. while ((user_index + 1) <= pdev->tx_ppdu_info.last_user) {
  1410. ppdu_user_desc = &ppdu_desc->user[user_index];
  1411. if (ppdu_user_desc->peer_id != peer_id) {
  1412. user_index++;
  1413. continue;
  1414. } else {
  1415. /* Max users possible is 8 so user array index should
  1416. * not exceed 7
  1417. */
  1418. qdf_assert_always(user_index <= CDP_MU_MAX_USER_INDEX);
  1419. return user_index;
  1420. }
  1421. }
  1422. pdev->tx_ppdu_info.last_user++;
  1423. /* Max users possible is 8 so last user should not exceed 8 */
  1424. qdf_assert_always(pdev->tx_ppdu_info.last_user <= CDP_MU_MAX_USERS);
  1425. return pdev->tx_ppdu_info.last_user - 1;
  1426. }
  1427. /*
  1428. * dp_process_ppdu_stats_common_tlv: Process htt_ppdu_stats_common_tlv
  1429. * pdev: DP pdev handle
  1430. * @tag_buf: buffer containing the tlv htt_ppdu_stats_common_tlv
  1431. *
  1432. * return:void
  1433. */
  1434. static void dp_process_ppdu_stats_common_tlv(struct dp_pdev *pdev,
  1435. uint32_t *tag_buf)
  1436. {
  1437. uint16_t frame_type;
  1438. uint16_t freq;
  1439. struct dp_soc *soc = NULL;
  1440. struct cdp_tx_completion_ppdu *ppdu_desc;
  1441. htt_ppdu_stats_common_tlv *dp_stats_buf =
  1442. (htt_ppdu_stats_common_tlv *)tag_buf;
  1443. ppdu_desc =
  1444. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
  1445. ppdu_desc->ppdu_id = dp_stats_buf->ppdu_id;
  1446. tag_buf += 2;
  1447. ppdu_desc->num_users =
  1448. HTT_PPDU_STATS_COMMON_TLV_NUM_USERS_GET(*tag_buf);
  1449. tag_buf++;
  1450. frame_type = HTT_PPDU_STATS_COMMON_TLV_FRM_TYPE_GET(*tag_buf);
  1451. if ((frame_type == HTT_STATS_FTYPE_TIDQ_DATA_SU) ||
  1452. (frame_type == HTT_STATS_FTYPE_TIDQ_DATA_MU))
  1453. ppdu_desc->frame_type = CDP_PPDU_FTYPE_DATA;
  1454. else
  1455. ppdu_desc->frame_type = CDP_PPDU_FTYPE_CTRL;
  1456. tag_buf += 2;
  1457. ppdu_desc->tx_duration = *tag_buf;
  1458. tag_buf += 3;
  1459. ppdu_desc->ppdu_start_timestamp = *tag_buf;
  1460. ppdu_desc->ppdu_end_timestamp = 0; /*TODO: value to be provided by FW */
  1461. tag_buf++;
  1462. freq = HTT_PPDU_STATS_COMMON_TLV_CHAN_MHZ_GET(*tag_buf);
  1463. if (freq != ppdu_desc->channel) {
  1464. soc = pdev->soc;
  1465. ppdu_desc->channel = freq;
  1466. if (soc && soc->cdp_soc.ol_ops->freq_to_channel)
  1467. pdev->operating_channel =
  1468. soc->cdp_soc.ol_ops->freq_to_channel(pdev->osif_pdev, freq);
  1469. }
  1470. ppdu_desc->phy_mode = HTT_PPDU_STATS_COMMON_TLV_PHY_MODE_GET(*tag_buf);
  1471. }
  1472. /*
  1473. * dp_process_ppdu_stats_user_common_tlv: Process ppdu_stats_user_common
  1474. * @tag_buf: buffer containing the tlv htt_ppdu_stats_user_common_tlv
  1475. *
  1476. * return:void
  1477. */
  1478. static void dp_process_ppdu_stats_user_common_tlv(
  1479. struct dp_pdev *pdev, uint32_t *tag_buf)
  1480. {
  1481. uint16_t peer_id;
  1482. struct dp_peer *peer;
  1483. struct cdp_tx_completion_ppdu *ppdu_desc;
  1484. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  1485. uint8_t curr_user_index = 0;
  1486. ppdu_desc =
  1487. (struct cdp_tx_completion_ppdu *) qdf_nbuf_data(pdev->tx_ppdu_info.buf);
  1488. tag_buf++;
  1489. peer_id = HTT_PPDU_STATS_USER_COMMON_TLV_SW_PEER_ID_GET(*tag_buf);
  1490. peer = dp_peer_find_by_id(pdev->soc, peer_id);
  1491. if (!peer)
  1492. return;
  1493. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
  1494. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  1495. ppdu_user_desc->peer_id = peer_id;
  1496. tag_buf++;
  1497. if (HTT_PPDU_STATS_USER_COMMON_TLV_MCAST_GET(*tag_buf)) {
  1498. ppdu_user_desc->is_mcast = true;
  1499. ppdu_user_desc->mpdu_tried_mcast =
  1500. HTT_PPDU_STATS_USER_COMMON_TLV_MPDUS_TRIED_GET(*tag_buf);
  1501. } else {
  1502. ppdu_user_desc->mpdu_tried_ucast =
  1503. HTT_PPDU_STATS_USER_COMMON_TLV_MPDUS_TRIED_GET(*tag_buf);
  1504. }
  1505. tag_buf++;
  1506. ppdu_user_desc->qos_ctrl =
  1507. HTT_PPDU_STATS_USER_COMMON_TLV_QOS_CTRL_GET(*tag_buf);
  1508. ppdu_user_desc->frame_ctrl =
  1509. HTT_PPDU_STATS_USER_COMMON_TLV_FRAME_CTRL_GET(*tag_buf);
  1510. }
  1511. /**
  1512. * dp_process_ppdu_stats_user_rate_tlv() - Process htt_ppdu_stats_user_rate_tlv
  1513. * @pdev: DP pdev handle
  1514. * @tag_buf: T2H message buffer carrying the user rate TLV
  1515. *
  1516. * return:void
  1517. */
  1518. static void dp_process_ppdu_stats_user_rate_tlv(struct dp_pdev *pdev,
  1519. uint32_t *tag_buf)
  1520. {
  1521. uint16_t peer_id;
  1522. struct dp_peer *peer;
  1523. struct cdp_tx_completion_ppdu *ppdu_desc;
  1524. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  1525. uint8_t curr_user_index = 0;
  1526. ppdu_desc =
  1527. (struct cdp_tx_completion_ppdu *) qdf_nbuf_data(pdev->tx_ppdu_info.buf);
  1528. tag_buf++;
  1529. peer_id = HTT_PPDU_STATS_USER_RATE_TLV_SW_PEER_ID_GET(*tag_buf);
  1530. peer = dp_peer_find_by_id(pdev->soc, peer_id);
  1531. if (!peer)
  1532. return;
  1533. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
  1534. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  1535. ppdu_user_desc->peer_id = peer_id;
  1536. ppdu_user_desc->tid =
  1537. HTT_PPDU_STATS_USER_RATE_TLV_TID_NUM_GET(*tag_buf);
  1538. qdf_mem_copy(ppdu_user_desc->mac_addr, peer->mac_addr.raw,
  1539. DP_MAC_ADDR_LEN);
  1540. tag_buf += 2;
  1541. ppdu_user_desc->ru_tones = (HTT_PPDU_STATS_USER_RATE_TLV_RU_END_GET(*tag_buf) -
  1542. HTT_PPDU_STATS_USER_RATE_TLV_RU_START_GET(*tag_buf)) + 1;
  1543. tag_buf += 2;
  1544. ppdu_user_desc->ppdu_type =
  1545. HTT_PPDU_STATS_USER_RATE_TLV_PPDU_TYPE_GET(*tag_buf);
  1546. tag_buf++;
  1547. ppdu_user_desc->tx_rate = *tag_buf;
  1548. ppdu_user_desc->ltf_size =
  1549. HTT_PPDU_STATS_USER_RATE_TLV_LTF_SIZE_GET(*tag_buf);
  1550. ppdu_user_desc->stbc =
  1551. HTT_PPDU_STATS_USER_RATE_TLV_STBC_GET(*tag_buf);
  1552. ppdu_user_desc->he_re =
  1553. HTT_PPDU_STATS_USER_RATE_TLV_HE_RE_GET(*tag_buf);
  1554. ppdu_user_desc->txbf =
  1555. HTT_PPDU_STATS_USER_RATE_TLV_TXBF_GET(*tag_buf);
  1556. ppdu_user_desc->bw =
  1557. HTT_PPDU_STATS_USER_RATE_TLV_BW_GET(*tag_buf);
  1558. ppdu_user_desc->nss = HTT_PPDU_STATS_USER_RATE_TLV_NSS_GET(*tag_buf);
  1559. ppdu_user_desc->mcs = HTT_PPDU_STATS_USER_RATE_TLV_MCS_GET(*tag_buf);
  1560. ppdu_user_desc->preamble =
  1561. HTT_PPDU_STATS_USER_RATE_TLV_PREAMBLE_GET(*tag_buf);
  1562. ppdu_user_desc->gi = HTT_PPDU_STATS_USER_RATE_TLV_GI_GET(*tag_buf);
  1563. ppdu_user_desc->dcm = HTT_PPDU_STATS_USER_RATE_TLV_DCM_GET(*tag_buf);
  1564. ppdu_user_desc->ldpc = HTT_PPDU_STATS_USER_RATE_TLV_LDPC_GET(*tag_buf);
  1565. }
  1566. /*
  1567. * dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv: Process
  1568. * htt_ppdu_stats_enq_mpdu_bitmap_64_tlv
  1569. * pdev: DP PDEV handle
  1570. * @tag_buf: buffer containing the tlv htt_ppdu_stats_enq_mpdu_bitmap_64_tlv
  1571. *
  1572. * return:void
  1573. */
  1574. static void dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv(
  1575. struct dp_pdev *pdev, uint32_t *tag_buf)
  1576. {
  1577. htt_ppdu_stats_enq_mpdu_bitmap_64_tlv *dp_stats_buf =
  1578. (htt_ppdu_stats_enq_mpdu_bitmap_64_tlv *)tag_buf;
  1579. struct cdp_tx_completion_ppdu *ppdu_desc;
  1580. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  1581. uint8_t curr_user_index = 0;
  1582. uint16_t peer_id;
  1583. struct dp_peer *peer;
  1584. ppdu_desc =
  1585. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
  1586. tag_buf++;
  1587. peer_id =
  1588. HTT_PPDU_STATS_ENQ_MPDU_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  1589. peer = dp_peer_find_by_id(pdev->soc, peer_id);
  1590. if (!peer)
  1591. return;
  1592. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
  1593. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  1594. ppdu_user_desc->peer_id = peer_id;
  1595. ppdu_user_desc->start_seq = dp_stats_buf->start_seq;
  1596. qdf_mem_copy(&ppdu_user_desc->enq_bitmap, &dp_stats_buf->enq_bitmap,
  1597. CDP_BA_64_BIT_MAP_SIZE_DWORDS);
  1598. }
  1599. /*
  1600. * dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv: Process
  1601. * htt_ppdu_stats_enq_mpdu_bitmap_256_tlv
  1602. * soc: DP SOC handle
  1603. * @tag_buf: buffer containing the tlv htt_ppdu_stats_enq_mpdu_bitmap_256_tlv
  1604. *
  1605. * return:void
  1606. */
  1607. static void dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv(
  1608. struct dp_pdev *pdev, uint32_t *tag_buf)
  1609. {
  1610. htt_ppdu_stats_enq_mpdu_bitmap_256_tlv *dp_stats_buf =
  1611. (htt_ppdu_stats_enq_mpdu_bitmap_256_tlv *)tag_buf;
  1612. struct cdp_tx_completion_ppdu *ppdu_desc;
  1613. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  1614. uint8_t curr_user_index = 0;
  1615. uint16_t peer_id;
  1616. struct dp_peer *peer;
  1617. ppdu_desc =
  1618. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
  1619. tag_buf++;
  1620. peer_id =
  1621. HTT_PPDU_STATS_ENQ_MPDU_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  1622. peer = dp_peer_find_by_id(pdev->soc, peer_id);
  1623. if (!peer)
  1624. return;
  1625. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
  1626. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  1627. ppdu_user_desc->peer_id = peer_id;
  1628. ppdu_user_desc->start_seq = dp_stats_buf->start_seq;
  1629. qdf_mem_copy(&ppdu_user_desc->enq_bitmap, &dp_stats_buf->enq_bitmap,
  1630. CDP_BA_256_BIT_MAP_SIZE_DWORDS);
  1631. }
  1632. /*
  1633. * dp_process_ppdu_stats_user_cmpltn_common_tlv: Process
  1634. * htt_ppdu_stats_user_cmpltn_common_tlv
  1635. * soc: DP SOC handle
  1636. * @tag_buf: buffer containing the tlv htt_ppdu_stats_user_cmpltn_common_tlv
  1637. *
  1638. * return:void
  1639. */
  1640. static void dp_process_ppdu_stats_user_cmpltn_common_tlv(
  1641. struct dp_pdev *pdev, uint32_t *tag_buf)
  1642. {
  1643. uint16_t peer_id;
  1644. struct dp_peer *peer;
  1645. struct cdp_tx_completion_ppdu *ppdu_desc;
  1646. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  1647. uint8_t curr_user_index = 0;
  1648. htt_ppdu_stats_user_cmpltn_common_tlv *dp_stats_buf =
  1649. (htt_ppdu_stats_user_cmpltn_common_tlv *)tag_buf;
  1650. ppdu_desc =
  1651. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
  1652. tag_buf++;
  1653. peer_id =
  1654. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_SW_PEER_ID_GET(*tag_buf);
  1655. peer = dp_peer_find_by_id(pdev->soc, peer_id);
  1656. if (!peer)
  1657. return;
  1658. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
  1659. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  1660. ppdu_user_desc->peer_id = peer_id;
  1661. ppdu_user_desc->completion_status =
  1662. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_COMPLETION_STATUS_GET(
  1663. *tag_buf);
  1664. ppdu_user_desc->tid =
  1665. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_TID_NUM_GET(*tag_buf);
  1666. tag_buf++;
  1667. ppdu_desc->ack_rssi = dp_stats_buf->ack_rssi;
  1668. tag_buf++;
  1669. ppdu_user_desc->mpdu_success =
  1670. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPDU_SUCCESS_GET(*tag_buf);
  1671. tag_buf++;
  1672. ppdu_user_desc->long_retries =
  1673. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_LONG_RETRY_GET(*tag_buf);
  1674. ppdu_user_desc->short_retries =
  1675. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_SHORT_RETRY_GET(*tag_buf);
  1676. ppdu_user_desc->retry_msdus =
  1677. ppdu_user_desc->long_retries + ppdu_user_desc->short_retries;
  1678. ppdu_user_desc->is_ampdu =
  1679. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_IS_AMPDU_GET(*tag_buf);
  1680. }
  1681. /*
  1682. * dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv: Process
  1683. * htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv
  1684. * pdev: DP PDEV handle
  1685. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv
  1686. *
  1687. * return:void
  1688. */
  1689. static void dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv(
  1690. struct dp_pdev *pdev, uint32_t *tag_buf)
  1691. {
  1692. htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv *dp_stats_buf =
  1693. (htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv *)tag_buf;
  1694. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  1695. struct cdp_tx_completion_ppdu *ppdu_desc;
  1696. uint8_t curr_user_index = 0;
  1697. uint16_t peer_id;
  1698. struct dp_peer *peer;
  1699. ppdu_desc =
  1700. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
  1701. tag_buf++;
  1702. peer_id =
  1703. HTT_PPDU_STATS_USER_CMPLTN_BA_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  1704. peer = dp_peer_find_by_id(pdev->soc, peer_id);
  1705. if (!peer)
  1706. return;
  1707. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
  1708. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  1709. ppdu_user_desc->peer_id = peer_id;
  1710. ppdu_user_desc->ba_seq_no = dp_stats_buf->ba_seq_no;
  1711. qdf_mem_copy(&ppdu_user_desc->ba_bitmap, &dp_stats_buf->ba_bitmap,
  1712. CDP_BA_64_BIT_MAP_SIZE_DWORDS);
  1713. }
  1714. /*
  1715. * dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv: Process
  1716. * htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv
  1717. * pdev: DP PDEV handle
  1718. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv
  1719. *
  1720. * return:void
  1721. */
  1722. static void dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv(
  1723. struct dp_pdev *pdev, uint32_t *tag_buf)
  1724. {
  1725. htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv *dp_stats_buf =
  1726. (htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv *)tag_buf;
  1727. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  1728. struct cdp_tx_completion_ppdu *ppdu_desc;
  1729. uint8_t curr_user_index = 0;
  1730. uint16_t peer_id;
  1731. struct dp_peer *peer;
  1732. ppdu_desc =
  1733. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
  1734. tag_buf++;
  1735. peer_id =
  1736. HTT_PPDU_STATS_USER_CMPLTN_BA_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  1737. peer = dp_peer_find_by_id(pdev->soc, peer_id);
  1738. if (!peer)
  1739. return;
  1740. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
  1741. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  1742. ppdu_user_desc->peer_id = peer_id;
  1743. ppdu_user_desc->ba_seq_no = dp_stats_buf->ba_seq_no;
  1744. qdf_mem_copy(&ppdu_user_desc->ba_bitmap, &dp_stats_buf->ba_bitmap,
  1745. CDP_BA_256_BIT_MAP_SIZE_DWORDS);
  1746. }
  1747. /*
  1748. * dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv: Process
  1749. * htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  1750. * pdev: DP PDE handle
  1751. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  1752. *
  1753. * return:void
  1754. */
  1755. static void dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv(
  1756. struct dp_pdev *pdev, uint32_t *tag_buf)
  1757. {
  1758. uint16_t peer_id;
  1759. struct dp_peer *peer;
  1760. struct cdp_tx_completion_ppdu *ppdu_desc;
  1761. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  1762. uint8_t curr_user_index = 0;
  1763. ppdu_desc =
  1764. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
  1765. tag_buf += 2;
  1766. peer_id =
  1767. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_SW_PEER_ID_GET(*tag_buf);
  1768. peer = dp_peer_find_by_id(pdev->soc, peer_id);
  1769. if (!peer)
  1770. return;
  1771. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
  1772. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  1773. ppdu_user_desc->peer_id = peer_id;
  1774. tag_buf++;
  1775. ppdu_user_desc->num_mpdu =
  1776. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_NUM_MPDU_GET(*tag_buf);
  1777. ppdu_user_desc->num_msdu =
  1778. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_NUM_MSDU_GET(*tag_buf);
  1779. ppdu_user_desc->success_msdus = ppdu_user_desc->num_msdu;
  1780. tag_buf += 2;
  1781. ppdu_user_desc->success_bytes = *tag_buf;
  1782. }
  1783. /*
  1784. * dp_process_ppdu_stats_user_common_array_tlv: Process
  1785. * htt_ppdu_stats_user_common_array_tlv
  1786. * pdev: DP PDEV handle
  1787. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  1788. *
  1789. * return:void
  1790. */
  1791. static void dp_process_ppdu_stats_user_common_array_tlv(struct dp_pdev *pdev,
  1792. uint32_t *tag_buf)
  1793. {
  1794. uint32_t peer_id;
  1795. struct dp_peer *peer;
  1796. struct cdp_tx_completion_ppdu *ppdu_desc;
  1797. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  1798. uint8_t curr_user_index = 0;
  1799. struct htt_tx_ppdu_stats_info *dp_stats_buf;
  1800. ppdu_desc =
  1801. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(pdev->tx_ppdu_info.buf);
  1802. tag_buf++;
  1803. dp_stats_buf = (struct htt_tx_ppdu_stats_info *)tag_buf;
  1804. tag_buf += 3;
  1805. peer_id =
  1806. HTT_PPDU_STATS_ARRAY_ITEM_TLV_PEERID_GET(*tag_buf);
  1807. peer = dp_peer_find_by_id(pdev->soc, peer_id);
  1808. if (!peer) {
  1809. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1810. "Invalid peer");
  1811. return;
  1812. }
  1813. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id);
  1814. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  1815. ppdu_user_desc->retry_bytes = dp_stats_buf->tx_retry_bytes;
  1816. ppdu_user_desc->failed_bytes = dp_stats_buf->tx_failed_bytes;
  1817. tag_buf++;
  1818. ppdu_user_desc->success_msdus =
  1819. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_SUCC_MSDUS_GET(*tag_buf);
  1820. ppdu_user_desc->retry_bytes =
  1821. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_RETRY_MSDUS_GET(*tag_buf);
  1822. tag_buf++;
  1823. ppdu_user_desc->failed_msdus =
  1824. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_FAILED_MSDUS_GET(*tag_buf);
  1825. }
  1826. /*
  1827. * dp_process_ppdu_stats_flush_tlv: Process
  1828. * htt_ppdu_stats_flush_tlv
  1829. * @pdev: DP PDEV handle
  1830. * @tag_buf: buffer containing the htt_ppdu_stats_flush_tlv
  1831. *
  1832. * return:void
  1833. */
  1834. static void dp_process_ppdu_stats_user_compltn_flush_tlv(struct dp_pdev *pdev,
  1835. uint32_t *tag_buf)
  1836. {
  1837. uint32_t peer_id;
  1838. uint32_t drop_reason;
  1839. uint8_t tid;
  1840. uint32_t num_msdu;
  1841. struct dp_peer *peer;
  1842. tag_buf++;
  1843. drop_reason = *tag_buf;
  1844. tag_buf++;
  1845. num_msdu = HTT_PPDU_STATS_FLUSH_TLV_NUM_MSDU_GET(*tag_buf);
  1846. tag_buf++;
  1847. peer_id =
  1848. HTT_PPDU_STATS_FLUSH_TLV_SW_PEER_ID_GET(*tag_buf);
  1849. peer = dp_peer_find_by_id(pdev->soc, peer_id);
  1850. if (!peer)
  1851. return;
  1852. tid = HTT_PPDU_STATS_FLUSH_TLV_TID_NUM_GET(*tag_buf);
  1853. if (drop_reason == HTT_FLUSH_EXCESS_RETRIES) {
  1854. DP_STATS_INC(peer, tx.excess_retries_per_ac[TID_TO_WME_AC(tid)],
  1855. num_msdu);
  1856. }
  1857. }
  1858. /*
  1859. * dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv: Process
  1860. * htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  1861. * @pdev: DP PDEV handle
  1862. * @tag_buf: buffer containing the htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  1863. * @length: tlv_length
  1864. *
  1865. * return:void
  1866. */
  1867. static void dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv(
  1868. struct dp_pdev *pdev, uint32_t *tag_buf, uint32_t length)
  1869. {
  1870. htt_ppdu_stats_tx_mgmtctrl_payload_tlv *dp_stats_buf;
  1871. qdf_nbuf_t nbuf;
  1872. uint32_t payload_size;
  1873. if ((!pdev->tx_sniffer_enable) && (!pdev->mcopy_mode))
  1874. return;
  1875. payload_size = length - HTT_MGMT_CTRL_TLV_RESERVERD_LEN;
  1876. nbuf = NULL;
  1877. dp_stats_buf = (htt_ppdu_stats_tx_mgmtctrl_payload_tlv *)tag_buf;
  1878. nbuf = qdf_nbuf_alloc(pdev->soc->osdev, payload_size, 0, 4, true);
  1879. if (!nbuf) {
  1880. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1881. "Nbuf Allocation failed for Mgmt. payload");
  1882. qdf_assert(0);
  1883. return;
  1884. }
  1885. qdf_nbuf_put_tail(nbuf, payload_size);
  1886. qdf_mem_copy(qdf_nbuf_data(nbuf), dp_stats_buf->payload, payload_size);
  1887. dp_wdi_event_handler(WDI_EVENT_TX_MGMT_CTRL, pdev->soc,
  1888. nbuf, HTT_INVALID_PEER,
  1889. WDI_NO_VAL, pdev->pdev_id);
  1890. }
  1891. /**
  1892. * dp_process_ppdu_tag(): Function to process the PPDU TLVs
  1893. * @soc: DP Physical device (radio) handle
  1894. * @tag_buf: TLV buffer
  1895. *
  1896. * return: void
  1897. */
  1898. static void dp_process_ppdu_tag(struct dp_pdev *pdev, uint32_t *tag_buf,
  1899. uint32_t tlv_len)
  1900. {
  1901. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  1902. switch (tlv_type) {
  1903. case HTT_PPDU_STATS_COMMON_TLV:
  1904. dp_process_ppdu_stats_common_tlv(pdev, tag_buf);
  1905. break;
  1906. case HTT_PPDU_STATS_USR_COMMON_TLV:
  1907. dp_process_ppdu_stats_user_common_tlv(pdev, tag_buf);
  1908. break;
  1909. case HTT_PPDU_STATS_USR_RATE_TLV:
  1910. qdf_assert_always(tlv_len ==
  1911. sizeof(htt_ppdu_stats_user_rate_tlv));
  1912. dp_process_ppdu_stats_user_rate_tlv(pdev, tag_buf);
  1913. break;
  1914. case HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_64_TLV:
  1915. dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv(pdev, tag_buf);
  1916. break;
  1917. case HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_256_TLV:
  1918. dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv(pdev, tag_buf);
  1919. break;
  1920. case HTT_PPDU_STATS_USR_COMPLTN_COMMON_TLV:
  1921. dp_process_ppdu_stats_user_cmpltn_common_tlv(pdev, tag_buf);
  1922. break;
  1923. case HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_64_TLV:
  1924. dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv(pdev,
  1925. tag_buf);
  1926. break;
  1927. case HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_256_TLV:
  1928. dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv(pdev,
  1929. tag_buf);
  1930. break;
  1931. case HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV:
  1932. dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv(pdev,
  1933. tag_buf);
  1934. break;
  1935. case HTT_PPDU_STATS_USR_COMMON_ARRAY_TLV:
  1936. dp_process_ppdu_stats_user_common_array_tlv(pdev,
  1937. tag_buf);
  1938. break;
  1939. case HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV:
  1940. dp_process_ppdu_stats_user_compltn_flush_tlv(pdev,
  1941. tag_buf);
  1942. break;
  1943. case HTT_PPDU_STATS_TX_MGMTCTRL_PAYLOAD_TLV:
  1944. dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv(pdev,
  1945. tag_buf, tlv_len);
  1946. break;
  1947. default:
  1948. break;
  1949. }
  1950. }
  1951. static QDF_STATUS dp_htt_process_tlv(struct dp_pdev *pdev,
  1952. qdf_nbuf_t htt_t2h_msg)
  1953. {
  1954. uint32_t length;
  1955. uint32_t ppdu_id;
  1956. uint8_t tlv_type;
  1957. uint32_t tlv_length;
  1958. uint8_t *tlv_buf;
  1959. QDF_STATUS status = QDF_STATUS_E_PENDING;
  1960. uint32_t *msg_word = (uint32_t *) qdf_nbuf_data(htt_t2h_msg);
  1961. length = HTT_T2H_PPDU_STATS_PAYLOAD_SIZE_GET(*msg_word);
  1962. msg_word = msg_word + 1;
  1963. ppdu_id = HTT_T2H_PPDU_STATS_PPDU_ID_GET(*msg_word);
  1964. msg_word = msg_word + 3;
  1965. while (length > 0) {
  1966. tlv_buf = (uint8_t *)msg_word;
  1967. tlv_type = HTT_STATS_TLV_TAG_GET(*msg_word);
  1968. tlv_length = HTT_STATS_TLV_LENGTH_GET(*msg_word);
  1969. if (tlv_length == 0)
  1970. break;
  1971. if (tlv_type == HTT_PPDU_STATS_SCH_CMD_STATUS_TLV)
  1972. status = QDF_STATUS_SUCCESS;
  1973. tlv_length += HTT_TLV_HDR_LEN;
  1974. dp_process_ppdu_tag(pdev, msg_word, tlv_length);
  1975. msg_word = (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  1976. length -= (tlv_length);
  1977. }
  1978. return status;
  1979. }
  1980. #endif /* FEATURE_PERPKT_INFO */
  1981. /**
  1982. * dp_txrx_ppdu_stats_handler() - Function to process HTT PPDU stats from FW
  1983. * @soc: DP SOC handle
  1984. * @pdev_id: pdev id
  1985. * @htt_t2h_msg: HTT message nbuf
  1986. *
  1987. * return:void
  1988. */
  1989. #if defined(WDI_EVENT_ENABLE)
  1990. #ifdef FEATURE_PERPKT_INFO
  1991. static void dp_txrx_ppdu_stats_handler(struct dp_soc *soc,
  1992. uint8_t pdev_id, qdf_nbuf_t htt_t2h_msg)
  1993. {
  1994. struct dp_pdev *pdev = soc->pdev_list[pdev_id];
  1995. struct dp_vdev *vdev;
  1996. struct dp_peer *peer;
  1997. struct cdp_tx_completion_ppdu *ppdu_desc;
  1998. int status;
  1999. int i;
  2000. if (!pdev->enhanced_stats_en && !pdev->tx_sniffer_enable &&
  2001. !pdev->mcopy_mode)
  2002. return;
  2003. if (!pdev->tx_ppdu_info.buf) {
  2004. /*
  2005. * Todo: For MU/OFDMA, we need to account for multiple user
  2006. * descriptors in a PPDU, in skb size.
  2007. * The allocation has to be moved to ppdu_cmn tlv processing
  2008. */
  2009. pdev->tx_ppdu_info.buf = qdf_nbuf_alloc(soc->osdev,
  2010. sizeof(struct cdp_tx_completion_ppdu), 0, 4,
  2011. TRUE);
  2012. if (!pdev->tx_ppdu_info.buf) {
  2013. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2014. "Nbuf Allocation failed for HTT PPDU");
  2015. return;
  2016. }
  2017. qdf_mem_zero(qdf_nbuf_data(pdev->tx_ppdu_info.buf),
  2018. sizeof(struct cdp_tx_completion_ppdu));
  2019. if (qdf_nbuf_put_tail(pdev->tx_ppdu_info.buf,
  2020. sizeof(struct cdp_tx_completion_ppdu)) == NULL) {
  2021. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2022. "No tailroom for HTT PPDU");
  2023. qdf_nbuf_free(pdev->tx_ppdu_info.buf);
  2024. pdev->tx_ppdu_info.buf = NULL;
  2025. pdev->tx_ppdu_info.last_user = 0;
  2026. return;
  2027. }
  2028. }
  2029. status = dp_htt_process_tlv(pdev, htt_t2h_msg);
  2030. if (status == QDF_STATUS_SUCCESS) {
  2031. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2032. qdf_nbuf_data(pdev->tx_ppdu_info.buf);
  2033. vdev = dp_get_vdev_from_soc_vdev_id_wifi3(soc,
  2034. ppdu_desc->vdev_id);
  2035. for (i = 0; i < ppdu_desc->num_users; i++) {
  2036. peer = dp_peer_find_by_id(soc,
  2037. ppdu_desc->user[i].peer_id);
  2038. if (!peer)
  2039. continue;
  2040. ppdu_desc->num_mpdu += ppdu_desc->user[i].num_mpdu;
  2041. ppdu_desc->num_msdu += ppdu_desc->user[i].num_msdu;
  2042. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_DATA) {
  2043. dp_tx_stats_update(soc, peer,
  2044. &ppdu_desc->user[i],
  2045. ppdu_desc->ack_rssi);
  2046. }
  2047. }
  2048. dp_wdi_event_handler(WDI_EVENT_TX_PPDU_DESC, soc,
  2049. pdev->tx_ppdu_info.buf, HTT_INVALID_PEER,
  2050. WDI_NO_VAL, pdev_id);
  2051. pdev->tx_ppdu_info.buf = NULL;
  2052. pdev->tx_ppdu_info.last_user = 0;
  2053. }
  2054. }
  2055. #else
  2056. static void dp_txrx_ppdu_stats_handler(struct dp_soc *soc,
  2057. uint8_t pdev_id, qdf_nbuf_t htt_t2h_msg)
  2058. {
  2059. }
  2060. #endif
  2061. #endif
  2062. /**
  2063. * dp_txrx_fw_stats_handler() - Function to process HTT EXT stats
  2064. * @soc: DP SOC handle
  2065. * @htt_t2h_msg: HTT message nbuf
  2066. *
  2067. * return:void
  2068. */
  2069. static inline void dp_txrx_fw_stats_handler(struct dp_soc *soc,
  2070. qdf_nbuf_t htt_t2h_msg)
  2071. {
  2072. uint8_t done;
  2073. qdf_nbuf_t msg_copy;
  2074. uint32_t *msg_word;
  2075. msg_word = (uint32_t *) qdf_nbuf_data(htt_t2h_msg);
  2076. msg_word = msg_word + 3;
  2077. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  2078. /*
  2079. * HTT EXT stats response comes as stream of TLVs which span over
  2080. * multiple T2H messages.
  2081. * The first message will carry length of the response.
  2082. * For rest of the messages length will be zero.
  2083. *
  2084. * Clone the T2H message buffer and store it in a list to process
  2085. * it later.
  2086. *
  2087. * The original T2H message buffers gets freed in the T2H HTT event
  2088. * handler
  2089. */
  2090. msg_copy = qdf_nbuf_clone(htt_t2h_msg);
  2091. if (!msg_copy) {
  2092. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  2093. "T2H messge clone failed for HTT EXT STATS");
  2094. goto error;
  2095. }
  2096. qdf_spin_lock_bh(&soc->htt_stats.lock);
  2097. qdf_nbuf_queue_add(&soc->htt_stats.msg, msg_copy);
  2098. /*
  2099. * Done bit signifies that this is the last T2H buffer in the stream of
  2100. * HTT EXT STATS message
  2101. */
  2102. if (done) {
  2103. soc->htt_stats.num_stats++;
  2104. qdf_sched_work(0, &soc->htt_stats.work);
  2105. }
  2106. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  2107. return;
  2108. error:
  2109. qdf_spin_lock_bh(&soc->htt_stats.lock);
  2110. while ((msg_copy = qdf_nbuf_queue_remove(&soc->htt_stats.msg))
  2111. != NULL) {
  2112. qdf_nbuf_free(msg_copy);
  2113. }
  2114. soc->htt_stats.num_stats = 0;
  2115. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  2116. return;
  2117. }
  2118. /*
  2119. * htt_soc_attach_target() - SOC level HTT setup
  2120. * @htt_soc: HTT SOC handle
  2121. *
  2122. * Return: 0 on success; error code on failure
  2123. */
  2124. int htt_soc_attach_target(void *htt_soc)
  2125. {
  2126. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  2127. return htt_h2t_ver_req_msg(soc);
  2128. }
  2129. #if defined(WDI_EVENT_ENABLE) && !defined(REMOVE_PKT_LOG)
  2130. /*
  2131. * dp_ppdu_stats_ind_handler() - PPDU stats msg handler
  2132. * @htt_soc: HTT SOC handle
  2133. * @msg_word: Pointer to payload
  2134. * @htt_t2h_msg: HTT msg nbuf
  2135. *
  2136. * Return: None
  2137. */
  2138. static void
  2139. dp_ppdu_stats_ind_handler(struct htt_soc *soc,
  2140. uint32_t *msg_word,
  2141. qdf_nbuf_t htt_t2h_msg)
  2142. {
  2143. u_int8_t pdev_id;
  2144. qdf_nbuf_set_pktlen(htt_t2h_msg, HTT_T2H_MAX_MSG_SIZE);
  2145. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  2146. "received HTT_T2H_MSG_TYPE_PPDU_STATS_IND\n");
  2147. pdev_id = HTT_T2H_PPDU_STATS_PDEV_ID_GET(*msg_word);
  2148. pdev_id = DP_HW2SW_MACID(pdev_id);
  2149. dp_txrx_ppdu_stats_handler(soc->dp_soc, pdev_id,
  2150. htt_t2h_msg);
  2151. dp_wdi_event_handler(WDI_EVENT_LITE_T2H, soc->dp_soc,
  2152. htt_t2h_msg, HTT_INVALID_PEER, WDI_NO_VAL,
  2153. pdev_id);
  2154. }
  2155. #else
  2156. dp_ppdu_stats_ind_handler(struct htt_soc *soc,
  2157. qdf_nbuf_t htt_t2h_msg)
  2158. {
  2159. }
  2160. #endif
  2161. #if defined(WDI_EVENT_ENABLE) && \
  2162. !defined(REMOVE_PKT_LOG) && defined(CONFIG_WIN)
  2163. /*
  2164. * dp_pktlog_msg_handler() - Pktlog msg handler
  2165. * @htt_soc: HTT SOC handle
  2166. * @msg_word: Pointer to payload
  2167. *
  2168. * Return: None
  2169. */
  2170. static void
  2171. dp_pktlog_msg_handler(struct htt_soc *soc,
  2172. uint32_t *msg_word)
  2173. {
  2174. uint8_t pdev_id;
  2175. uint32_t *pl_hdr;
  2176. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  2177. "received HTT_T2H_MSG_TYPE_PKTLOG\n");
  2178. pdev_id = HTT_T2H_PKTLOG_PDEV_ID_GET(*msg_word);
  2179. pdev_id = DP_HW2SW_MACID(pdev_id);
  2180. pl_hdr = (msg_word + 1);
  2181. dp_wdi_event_handler(WDI_EVENT_OFFLOAD_ALL, soc->dp_soc,
  2182. pl_hdr, HTT_INVALID_PEER, WDI_NO_VAL,
  2183. pdev_id);
  2184. }
  2185. #else
  2186. static void
  2187. dp_pktlog_msg_handler(struct htt_soc *soc,
  2188. uint32_t *msg_word)
  2189. {
  2190. }
  2191. #endif
  2192. /*
  2193. * dp_htt_t2h_msg_handler() - Generic Target to host Msg/event handler
  2194. * @context: Opaque context (HTT SOC handle)
  2195. * @pkt: HTC packet
  2196. */
  2197. static void dp_htt_t2h_msg_handler(void *context, HTC_PACKET *pkt)
  2198. {
  2199. struct htt_soc *soc = (struct htt_soc *) context;
  2200. qdf_nbuf_t htt_t2h_msg = (qdf_nbuf_t) pkt->pPktContext;
  2201. u_int32_t *msg_word;
  2202. enum htt_t2h_msg_type msg_type;
  2203. /* check for successful message reception */
  2204. if (pkt->Status != QDF_STATUS_SUCCESS) {
  2205. if (pkt->Status != QDF_STATUS_E_CANCELED)
  2206. soc->stats.htc_err_cnt++;
  2207. qdf_nbuf_free(htt_t2h_msg);
  2208. return;
  2209. }
  2210. /* TODO: Check if we should pop the HTC/HTT header alignment padding */
  2211. msg_word = (u_int32_t *) qdf_nbuf_data(htt_t2h_msg);
  2212. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  2213. switch (msg_type) {
  2214. case HTT_T2H_MSG_TYPE_PEER_MAP:
  2215. {
  2216. u_int8_t mac_addr_deswizzle_buf[HTT_MAC_ADDR_LEN];
  2217. u_int8_t *peer_mac_addr;
  2218. u_int16_t peer_id;
  2219. u_int16_t hw_peer_id;
  2220. u_int8_t vdev_id;
  2221. peer_id = HTT_RX_PEER_MAP_PEER_ID_GET(*msg_word);
  2222. hw_peer_id =
  2223. HTT_RX_PEER_MAP_HW_PEER_ID_GET(*(msg_word+2));
  2224. vdev_id = HTT_RX_PEER_MAP_VDEV_ID_GET(*msg_word);
  2225. peer_mac_addr = htt_t2h_mac_addr_deswizzle(
  2226. (u_int8_t *) (msg_word+1),
  2227. &mac_addr_deswizzle_buf[0]);
  2228. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2229. QDF_TRACE_LEVEL_INFO,
  2230. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  2231. peer_id, vdev_id);
  2232. dp_rx_peer_map_handler(soc->dp_soc, peer_id, hw_peer_id,
  2233. vdev_id, peer_mac_addr);
  2234. break;
  2235. }
  2236. case HTT_T2H_MSG_TYPE_PEER_UNMAP:
  2237. {
  2238. u_int16_t peer_id;
  2239. peer_id = HTT_RX_PEER_UNMAP_PEER_ID_GET(*msg_word);
  2240. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id);
  2241. break;
  2242. }
  2243. case HTT_T2H_MSG_TYPE_SEC_IND:
  2244. {
  2245. u_int16_t peer_id;
  2246. enum htt_sec_type sec_type;
  2247. int is_unicast;
  2248. peer_id = HTT_SEC_IND_PEER_ID_GET(*msg_word);
  2249. sec_type = HTT_SEC_IND_SEC_TYPE_GET(*msg_word);
  2250. is_unicast = HTT_SEC_IND_UNICAST_GET(*msg_word);
  2251. /* point to the first part of the Michael key */
  2252. msg_word++;
  2253. dp_rx_sec_ind_handler(
  2254. soc->dp_soc, peer_id, sec_type, is_unicast,
  2255. msg_word, msg_word + 2);
  2256. break;
  2257. }
  2258. case HTT_T2H_MSG_TYPE_PPDU_STATS_IND:
  2259. {
  2260. dp_ppdu_stats_ind_handler(soc, msg_word, htt_t2h_msg);
  2261. break;
  2262. }
  2263. case HTT_T2H_MSG_TYPE_PKTLOG:
  2264. {
  2265. dp_pktlog_msg_handler(soc, msg_word);
  2266. break;
  2267. }
  2268. case HTT_T2H_MSG_TYPE_VERSION_CONF:
  2269. {
  2270. htc_pm_runtime_put(soc->htc_soc);
  2271. soc->tgt_ver.major = HTT_VER_CONF_MAJOR_GET(*msg_word);
  2272. soc->tgt_ver.minor = HTT_VER_CONF_MINOR_GET(*msg_word);
  2273. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_HIGH,
  2274. "target uses HTT version %d.%d; host uses %d.%d\n",
  2275. soc->tgt_ver.major, soc->tgt_ver.minor,
  2276. HTT_CURRENT_VERSION_MAJOR,
  2277. HTT_CURRENT_VERSION_MINOR);
  2278. if (soc->tgt_ver.major != HTT_CURRENT_VERSION_MAJOR) {
  2279. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2280. QDF_TRACE_LEVEL_ERROR,
  2281. "*** Incompatible host/target HTT versions!\n");
  2282. }
  2283. /* abort if the target is incompatible with the host */
  2284. qdf_assert(soc->tgt_ver.major ==
  2285. HTT_CURRENT_VERSION_MAJOR);
  2286. if (soc->tgt_ver.minor != HTT_CURRENT_VERSION_MINOR) {
  2287. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2288. QDF_TRACE_LEVEL_WARN,
  2289. "*** Warning: host/target HTT versions"
  2290. " are different, though compatible!\n");
  2291. }
  2292. break;
  2293. }
  2294. case HTT_T2H_MSG_TYPE_RX_ADDBA:
  2295. {
  2296. uint16_t peer_id;
  2297. uint8_t tid;
  2298. uint8_t win_sz;
  2299. uint16_t status;
  2300. struct dp_peer *peer;
  2301. /*
  2302. * Update REO Queue Desc with new values
  2303. */
  2304. peer_id = HTT_RX_ADDBA_PEER_ID_GET(*msg_word);
  2305. tid = HTT_RX_ADDBA_TID_GET(*msg_word);
  2306. win_sz = HTT_RX_ADDBA_WIN_SIZE_GET(*msg_word);
  2307. peer = dp_peer_find_by_id(soc->dp_soc, peer_id);
  2308. /*
  2309. * Window size needs to be incremented by 1
  2310. * since fw needs to represent a value of 256
  2311. * using just 8 bits
  2312. */
  2313. if (peer) {
  2314. status = dp_addba_requestprocess_wifi3(peer,
  2315. 0, tid, 0, win_sz + 1, 0xffff);
  2316. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2317. QDF_TRACE_LEVEL_INFO,
  2318. FL("PeerID %d BAW %d TID %d stat %d\n"),
  2319. peer_id, win_sz, tid, status);
  2320. } else {
  2321. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2322. QDF_TRACE_LEVEL_ERROR,
  2323. FL("Peer not found peer id %d\n"),
  2324. peer_id);
  2325. }
  2326. break;
  2327. }
  2328. case HTT_T2H_MSG_TYPE_EXT_STATS_CONF:
  2329. {
  2330. dp_txrx_fw_stats_handler(soc->dp_soc, htt_t2h_msg);
  2331. break;
  2332. }
  2333. default:
  2334. break;
  2335. };
  2336. /* Free the indication buffer */
  2337. qdf_nbuf_free(htt_t2h_msg);
  2338. }
  2339. /*
  2340. * dp_htt_h2t_full() - Send full handler (called from HTC)
  2341. * @context: Opaque context (HTT SOC handle)
  2342. * @pkt: HTC packet
  2343. *
  2344. * Return: enum htc_send_full_action
  2345. */
  2346. static enum htc_send_full_action
  2347. dp_htt_h2t_full(void *context, HTC_PACKET *pkt)
  2348. {
  2349. return HTC_SEND_FULL_KEEP;
  2350. }
  2351. /*
  2352. * dp_htt_hif_t2h_hp_callback() - HIF callback for high priority T2H messages
  2353. * @context: Opaque context (HTT SOC handle)
  2354. * @nbuf: nbuf containing T2H message
  2355. * @pipe_id: HIF pipe ID
  2356. *
  2357. * Return: QDF_STATUS
  2358. *
  2359. * TODO: Temporary change to bypass HTC connection for this new HIF pipe, which
  2360. * will be used for packet log and other high-priority HTT messsages. Proper
  2361. * HTC connection to be added later once required FW changes are available
  2362. */
  2363. static QDF_STATUS
  2364. dp_htt_hif_t2h_hp_callback (void *context, qdf_nbuf_t nbuf, uint8_t pipe_id)
  2365. {
  2366. A_STATUS rc = QDF_STATUS_SUCCESS;
  2367. HTC_PACKET htc_pkt;
  2368. qdf_assert_always(pipe_id == DP_HTT_T2H_HP_PIPE);
  2369. qdf_mem_zero(&htc_pkt, sizeof(htc_pkt));
  2370. htc_pkt.Status = QDF_STATUS_SUCCESS;
  2371. htc_pkt.pPktContext = (void *)nbuf;
  2372. dp_htt_t2h_msg_handler(context, &htc_pkt);
  2373. return rc;
  2374. }
  2375. /*
  2376. * htt_htc_soc_attach() - Register SOC level HTT instance with HTC
  2377. * @htt_soc: HTT SOC handle
  2378. *
  2379. * Return: 0 on success; error code on failure
  2380. */
  2381. static int
  2382. htt_htc_soc_attach(struct htt_soc *soc)
  2383. {
  2384. struct htc_service_connect_req connect;
  2385. struct htc_service_connect_resp response;
  2386. A_STATUS status;
  2387. struct dp_soc *dpsoc = soc->dp_soc;
  2388. qdf_mem_set(&connect, sizeof(connect), 0);
  2389. qdf_mem_set(&response, sizeof(response), 0);
  2390. connect.pMetaData = NULL;
  2391. connect.MetaDataLength = 0;
  2392. connect.EpCallbacks.pContext = soc;
  2393. connect.EpCallbacks.EpTxComplete = dp_htt_h2t_send_complete;
  2394. connect.EpCallbacks.EpTxCompleteMultiple = NULL;
  2395. connect.EpCallbacks.EpRecv = dp_htt_t2h_msg_handler;
  2396. /* rx buffers currently are provided by HIF, not by EpRecvRefill */
  2397. connect.EpCallbacks.EpRecvRefill = NULL;
  2398. /* N/A, fill is done by HIF */
  2399. connect.EpCallbacks.RecvRefillWaterMark = 1;
  2400. connect.EpCallbacks.EpSendFull = dp_htt_h2t_full;
  2401. /*
  2402. * Specify how deep to let a queue get before htc_send_pkt will
  2403. * call the EpSendFull function due to excessive send queue depth.
  2404. */
  2405. connect.MaxSendQueueDepth = DP_HTT_MAX_SEND_QUEUE_DEPTH;
  2406. /* disable flow control for HTT data message service */
  2407. connect.ConnectionFlags |= HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
  2408. /* connect to control service */
  2409. connect.service_id = HTT_DATA_MSG_SVC;
  2410. status = htc_connect_service(soc->htc_soc, &connect, &response);
  2411. if (status != A_OK)
  2412. return QDF_STATUS_E_FAILURE;
  2413. soc->htc_endpoint = response.Endpoint;
  2414. hif_save_htc_htt_config_endpoint(dpsoc->hif_handle, soc->htc_endpoint);
  2415. dp_hif_update_pipe_callback(soc->dp_soc, (void *)soc,
  2416. dp_htt_hif_t2h_hp_callback, DP_HTT_T2H_HP_PIPE);
  2417. return 0; /* success */
  2418. }
  2419. /*
  2420. * htt_soc_attach() - SOC level HTT initialization
  2421. * @dp_soc: Opaque Data path SOC handle
  2422. * @ctrl_psoc: Opaque ctrl SOC handle
  2423. * @htc_soc: SOC level HTC handle
  2424. * @hal_soc: Opaque HAL SOC handle
  2425. * @osdev: QDF device
  2426. *
  2427. * Return: HTT handle on success; NULL on failure
  2428. */
  2429. void *
  2430. htt_soc_attach(void *dp_soc, void *ctrl_psoc, HTC_HANDLE htc_soc,
  2431. void *hal_soc, qdf_device_t osdev)
  2432. {
  2433. struct htt_soc *soc;
  2434. int i;
  2435. soc = qdf_mem_malloc(sizeof(*soc));
  2436. if (!soc)
  2437. goto fail1;
  2438. soc->osdev = osdev;
  2439. soc->ctrl_psoc = ctrl_psoc;
  2440. soc->dp_soc = dp_soc;
  2441. soc->htc_soc = htc_soc;
  2442. soc->hal_soc = hal_soc;
  2443. /* TODO: See if any NSS related context is requred in htt_soc */
  2444. soc->htt_htc_pkt_freelist = NULL;
  2445. if (htt_htc_soc_attach(soc))
  2446. goto fail2;
  2447. /* TODO: See if any Rx data specific intialization is required. For
  2448. * MCL use cases, the data will be received as single packet and
  2449. * should not required any descriptor or reorder handling
  2450. */
  2451. HTT_TX_MUTEX_INIT(&soc->htt_tx_mutex);
  2452. /* pre-allocate some HTC_PACKET objects */
  2453. for (i = 0; i < HTT_HTC_PKT_POOL_INIT_SIZE; i++) {
  2454. struct dp_htt_htc_pkt_union *pkt;
  2455. pkt = qdf_mem_malloc(sizeof(*pkt));
  2456. if (!pkt)
  2457. break;
  2458. htt_htc_pkt_free(soc, &pkt->u.pkt);
  2459. }
  2460. return soc;
  2461. fail2:
  2462. qdf_mem_free(soc);
  2463. fail1:
  2464. return NULL;
  2465. }
  2466. /*
  2467. * htt_soc_detach() - Detach SOC level HTT
  2468. * @htt_soc: HTT SOC handle
  2469. */
  2470. void
  2471. htt_soc_detach(void *htt_soc)
  2472. {
  2473. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  2474. htt_htc_misc_pkt_pool_free(soc);
  2475. htt_htc_pkt_pool_free(soc);
  2476. HTT_TX_MUTEX_DESTROY(&soc->htt_tx_mutex);
  2477. qdf_mem_free(soc);
  2478. }
  2479. /**
  2480. * dp_h2t_ext_stats_msg_send(): function to contruct HTT message to pass to FW
  2481. * @pdev: DP PDEV handle
  2482. * @stats_type_upload_mask: stats type requested by user
  2483. * @config_param_0: extra configuration parameters
  2484. * @config_param_1: extra configuration parameters
  2485. * @config_param_2: extra configuration parameters
  2486. * @config_param_3: extra configuration parameters
  2487. *
  2488. * return: QDF STATUS
  2489. */
  2490. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  2491. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  2492. uint32_t config_param_1, uint32_t config_param_2,
  2493. uint32_t config_param_3, int cookie_val)
  2494. {
  2495. struct htt_soc *soc = pdev->soc->htt_handle;
  2496. struct dp_htt_htc_pkt *pkt;
  2497. qdf_nbuf_t msg;
  2498. uint32_t *msg_word;
  2499. uint8_t pdev_mask;
  2500. msg = qdf_nbuf_alloc(
  2501. soc->osdev,
  2502. HTT_MSG_BUF_SIZE(HTT_H2T_EXT_STATS_REQ_MSG_SZ),
  2503. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  2504. if (!msg)
  2505. return QDF_STATUS_E_NOMEM;
  2506. /*TODO:Add support for SOC stats
  2507. * Bit 0: SOC Stats
  2508. * Bit 1: Pdev stats for pdev id 0
  2509. * Bit 2: Pdev stats for pdev id 1
  2510. * Bit 3: Pdev stats for pdev id 2
  2511. */
  2512. pdev_mask = 1 << (pdev->pdev_id + 1);
  2513. /*
  2514. * Set the length of the message.
  2515. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  2516. * separately during the below call to qdf_nbuf_push_head.
  2517. * The contribution from the HTC header is added separately inside HTC.
  2518. */
  2519. if (qdf_nbuf_put_tail(msg, HTT_H2T_EXT_STATS_REQ_MSG_SZ) == NULL) {
  2520. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2521. "Failed to expand head for HTT_EXT_STATS");
  2522. qdf_nbuf_free(msg);
  2523. return QDF_STATUS_E_FAILURE;
  2524. }
  2525. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  2526. "-----%s:%d----\n cookie <-> %d\n config_param_0 %u\n"
  2527. "config_param_1 %u\n config_param_2 %u\n"
  2528. "config_param_4 %u\n -------------\n",
  2529. __func__, __LINE__, cookie_val, config_param_0,
  2530. config_param_1, config_param_2, config_param_3);
  2531. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  2532. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  2533. *msg_word = 0;
  2534. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_EXT_STATS_REQ);
  2535. HTT_H2T_EXT_STATS_REQ_PDEV_MASK_SET(*msg_word, pdev_mask);
  2536. HTT_H2T_EXT_STATS_REQ_STATS_TYPE_SET(*msg_word, stats_type_upload_mask);
  2537. /* word 1 */
  2538. msg_word++;
  2539. *msg_word = 0;
  2540. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_0);
  2541. /* word 2 */
  2542. msg_word++;
  2543. *msg_word = 0;
  2544. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_1);
  2545. /* word 3 */
  2546. msg_word++;
  2547. *msg_word = 0;
  2548. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_2);
  2549. /* word 4 */
  2550. msg_word++;
  2551. *msg_word = 0;
  2552. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_3);
  2553. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, 0);
  2554. /* word 5 */
  2555. msg_word++;
  2556. /* word 6 */
  2557. msg_word++;
  2558. *msg_word = 0;
  2559. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_val);
  2560. /* word 7 */
  2561. msg_word++;
  2562. *msg_word = 0;
  2563. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, pdev->pdev_id);
  2564. pkt = htt_htc_pkt_alloc(soc);
  2565. if (!pkt) {
  2566. qdf_nbuf_free(msg);
  2567. return QDF_STATUS_E_NOMEM;
  2568. }
  2569. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  2570. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  2571. dp_htt_h2t_send_complete_free_netbuf,
  2572. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  2573. soc->htc_endpoint,
  2574. 1); /* tag - not relevant here */
  2575. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  2576. DP_HTT_SEND_HTC_PKT(soc, pkt);
  2577. return 0;
  2578. }
  2579. /* This macro will revert once proper HTT header will define for
  2580. * HTT_H2T_MSG_TYPE_PPDU_STATS_CFG in htt.h file
  2581. * */
  2582. #if defined(WDI_EVENT_ENABLE)
  2583. /**
  2584. * dp_h2t_cfg_stats_msg_send(): function to construct HTT message to pass to FW
  2585. * @pdev: DP PDEV handle
  2586. * @stats_type_upload_mask: stats type requested by user
  2587. * @mac_id: Mac id number
  2588. *
  2589. * return: QDF STATUS
  2590. */
  2591. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  2592. uint32_t stats_type_upload_mask, uint8_t mac_id)
  2593. {
  2594. struct htt_soc *soc = pdev->soc->htt_handle;
  2595. struct dp_htt_htc_pkt *pkt;
  2596. qdf_nbuf_t msg;
  2597. uint32_t *msg_word;
  2598. uint8_t pdev_mask;
  2599. msg = qdf_nbuf_alloc(
  2600. soc->osdev,
  2601. HTT_MSG_BUF_SIZE(HTT_H2T_PPDU_STATS_CFG_MSG_SZ),
  2602. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  2603. if (!msg) {
  2604. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2605. "Fail to allocate HTT_H2T_PPDU_STATS_CFG_MSG_SZ msg buffer\n");
  2606. qdf_assert(0);
  2607. return QDF_STATUS_E_NOMEM;
  2608. }
  2609. /*TODO:Add support for SOC stats
  2610. * Bit 0: SOC Stats
  2611. * Bit 1: Pdev stats for pdev id 0
  2612. * Bit 2: Pdev stats for pdev id 1
  2613. * Bit 3: Pdev stats for pdev id 2
  2614. */
  2615. pdev_mask = 1 << DP_SW2HW_MACID(mac_id);
  2616. /*
  2617. * Set the length of the message.
  2618. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  2619. * separately during the below call to qdf_nbuf_push_head.
  2620. * The contribution from the HTC header is added separately inside HTC.
  2621. */
  2622. if (qdf_nbuf_put_tail(msg, HTT_H2T_PPDU_STATS_CFG_MSG_SZ) == NULL) {
  2623. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2624. "Failed to expand head for HTT_CFG_STATS\n");
  2625. qdf_nbuf_free(msg);
  2626. return QDF_STATUS_E_FAILURE;
  2627. }
  2628. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  2629. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  2630. *msg_word = 0;
  2631. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG);
  2632. HTT_H2T_PPDU_STATS_CFG_PDEV_MASK_SET(*msg_word, pdev_mask);
  2633. HTT_H2T_PPDU_STATS_CFG_TLV_BITMASK_SET(*msg_word,
  2634. stats_type_upload_mask);
  2635. pkt = htt_htc_pkt_alloc(soc);
  2636. if (!pkt) {
  2637. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2638. "Fail to allocate dp_htt_htc_pkt buffer\n");
  2639. qdf_assert(0);
  2640. qdf_nbuf_free(msg);
  2641. return QDF_STATUS_E_NOMEM;
  2642. }
  2643. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  2644. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  2645. dp_htt_h2t_send_complete_free_netbuf,
  2646. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  2647. soc->htc_endpoint,
  2648. 1); /* tag - not relevant here */
  2649. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  2650. DP_HTT_SEND_HTC_PKT(soc, pkt);
  2651. return 0;
  2652. }
  2653. #endif