dp_htt.c 86 KB

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