dp_htt.c 114 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #include <htt.h>
  19. #include <hal_hw_headers.h>
  20. #include <hal_api.h>
  21. #include "dp_peer.h"
  22. #include "dp_types.h"
  23. #include "dp_internal.h"
  24. #include "dp_rx.h"
  25. #include "htt_stats.h"
  26. #include "htt_ppdu_stats.h"
  27. #include "dp_htt.h"
  28. #ifdef WIFI_MONITOR_SUPPORT
  29. #include <dp_mon.h>
  30. #endif
  31. #include "qdf_mem.h" /* qdf_mem_malloc,free */
  32. #include "cdp_txrx_cmn_struct.h"
  33. #ifdef FEATURE_PERPKT_INFO
  34. #include "dp_ratetable.h"
  35. #endif
  36. #include <qdf_module.h>
  37. #define HTT_TLV_HDR_LEN HTT_T2H_EXT_STATS_CONF_TLV_HDR_SIZE
  38. #define HTT_HTC_PKT_POOL_INIT_SIZE 64
  39. #define HTT_MSG_BUF_SIZE(msg_bytes) \
  40. ((msg_bytes) + HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING)
  41. #define HTT_PID_BIT_MASK 0x3
  42. #define DP_EXT_MSG_LENGTH 2048
  43. #define HTT_HEADER_LEN 16
  44. #define HTT_MGMT_CTRL_TLV_HDR_RESERVERD_LEN 16
  45. #define HTT_SHIFT_UPPER_TIMESTAMP 32
  46. #define HTT_MASK_UPPER_TIMESTAMP 0xFFFFFFFF00000000
  47. #define HTT_BKP_STATS_MAX_QUEUE_DEPTH 16
  48. struct dp_htt_htc_pkt *
  49. htt_htc_pkt_alloc(struct htt_soc *soc)
  50. {
  51. struct dp_htt_htc_pkt_union *pkt = NULL;
  52. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  53. if (soc->htt_htc_pkt_freelist) {
  54. pkt = soc->htt_htc_pkt_freelist;
  55. soc->htt_htc_pkt_freelist = soc->htt_htc_pkt_freelist->u.next;
  56. }
  57. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  58. if (!pkt)
  59. pkt = qdf_mem_malloc(sizeof(*pkt));
  60. if (!pkt)
  61. return NULL;
  62. htc_packet_set_magic_cookie(&(pkt->u.pkt.htc_pkt), 0);
  63. return &pkt->u.pkt; /* not actually a dereference */
  64. }
  65. qdf_export_symbol(htt_htc_pkt_alloc);
  66. void
  67. htt_htc_pkt_free(struct htt_soc *soc, struct dp_htt_htc_pkt *pkt)
  68. {
  69. struct dp_htt_htc_pkt_union *u_pkt =
  70. (struct dp_htt_htc_pkt_union *)pkt;
  71. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  72. htc_packet_set_magic_cookie(&(u_pkt->u.pkt.htc_pkt), 0);
  73. u_pkt->u.next = soc->htt_htc_pkt_freelist;
  74. soc->htt_htc_pkt_freelist = u_pkt;
  75. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  76. }
  77. qdf_export_symbol(htt_htc_pkt_free);
  78. /*
  79. * htt_htc_pkt_pool_free() - Free HTC packet pool
  80. * @htt_soc: HTT SOC handle
  81. */
  82. void
  83. htt_htc_pkt_pool_free(struct htt_soc *soc)
  84. {
  85. struct dp_htt_htc_pkt_union *pkt, *next;
  86. pkt = soc->htt_htc_pkt_freelist;
  87. while (pkt) {
  88. next = pkt->u.next;
  89. qdf_mem_free(pkt);
  90. pkt = next;
  91. }
  92. soc->htt_htc_pkt_freelist = NULL;
  93. }
  94. #ifndef ENABLE_CE4_COMP_DISABLE_HTT_HTC_MISC_LIST
  95. /*
  96. * htt_htc_misc_pkt_list_trim() - trim misc list
  97. * @htt_soc: HTT SOC handle
  98. * @level: max no. of pkts in list
  99. */
  100. static void
  101. htt_htc_misc_pkt_list_trim(struct htt_soc *soc, int level)
  102. {
  103. struct dp_htt_htc_pkt_union *pkt, *next, *prev = NULL;
  104. int i = 0;
  105. qdf_nbuf_t netbuf;
  106. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  107. pkt = soc->htt_htc_pkt_misclist;
  108. while (pkt) {
  109. next = pkt->u.next;
  110. /* trim the out grown list*/
  111. if (++i > level) {
  112. netbuf =
  113. (qdf_nbuf_t)(pkt->u.pkt.htc_pkt.pNetBufContext);
  114. qdf_nbuf_unmap(soc->osdev, netbuf, QDF_DMA_TO_DEVICE);
  115. qdf_nbuf_free(netbuf);
  116. qdf_mem_free(pkt);
  117. pkt = NULL;
  118. if (prev)
  119. prev->u.next = NULL;
  120. }
  121. prev = pkt;
  122. pkt = next;
  123. }
  124. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  125. }
  126. /*
  127. * htt_htc_misc_pkt_list_add() - Add pkt to misc list
  128. * @htt_soc: HTT SOC handle
  129. * @dp_htt_htc_pkt: pkt to be added to list
  130. */
  131. void
  132. htt_htc_misc_pkt_list_add(struct htt_soc *soc, struct dp_htt_htc_pkt *pkt)
  133. {
  134. struct dp_htt_htc_pkt_union *u_pkt =
  135. (struct dp_htt_htc_pkt_union *)pkt;
  136. int misclist_trim_level = htc_get_tx_queue_depth(soc->htc_soc,
  137. pkt->htc_pkt.Endpoint)
  138. + DP_HTT_HTC_PKT_MISCLIST_SIZE;
  139. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  140. if (soc->htt_htc_pkt_misclist) {
  141. u_pkt->u.next = soc->htt_htc_pkt_misclist;
  142. soc->htt_htc_pkt_misclist = u_pkt;
  143. } else {
  144. soc->htt_htc_pkt_misclist = u_pkt;
  145. }
  146. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  147. /* only ce pipe size + tx_queue_depth could possibly be in use
  148. * free older packets in the misclist
  149. */
  150. htt_htc_misc_pkt_list_trim(soc, misclist_trim_level);
  151. }
  152. qdf_export_symbol(htt_htc_misc_pkt_list_add);
  153. #endif /* ENABLE_CE4_COMP_DISABLE_HTT_HTC_MISC_LIST */
  154. /*
  155. * htt_htc_misc_pkt_pool_free() - free pkts in misc list
  156. * @htt_soc: HTT SOC handle
  157. */
  158. static void
  159. htt_htc_misc_pkt_pool_free(struct htt_soc *soc)
  160. {
  161. struct dp_htt_htc_pkt_union *pkt, *next;
  162. qdf_nbuf_t netbuf;
  163. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  164. pkt = soc->htt_htc_pkt_misclist;
  165. while (pkt) {
  166. next = pkt->u.next;
  167. if (htc_packet_get_magic_cookie(&(pkt->u.pkt.htc_pkt)) !=
  168. HTC_PACKET_MAGIC_COOKIE) {
  169. pkt = next;
  170. soc->stats.skip_count++;
  171. continue;
  172. }
  173. netbuf = (qdf_nbuf_t) (pkt->u.pkt.htc_pkt.pNetBufContext);
  174. qdf_nbuf_unmap(soc->osdev, netbuf, QDF_DMA_TO_DEVICE);
  175. soc->stats.htc_pkt_free++;
  176. dp_htt_info("%pK: Pkt free count %d",
  177. soc->dp_soc, soc->stats.htc_pkt_free);
  178. qdf_nbuf_free(netbuf);
  179. qdf_mem_free(pkt);
  180. pkt = next;
  181. }
  182. soc->htt_htc_pkt_misclist = NULL;
  183. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  184. dp_info("HTC Packets, fail count = %d, skip count = %d",
  185. soc->stats.fail_count, soc->stats.skip_count);
  186. }
  187. /*
  188. * htt_t2h_mac_addr_deswizzle() - Swap MAC addr bytes if FW endianness differ
  189. * @tgt_mac_addr: Target MAC
  190. * @buffer: Output buffer
  191. */
  192. static u_int8_t *
  193. htt_t2h_mac_addr_deswizzle(u_int8_t *tgt_mac_addr, u_int8_t *buffer)
  194. {
  195. #ifdef BIG_ENDIAN_HOST
  196. /*
  197. * The host endianness is opposite of the target endianness.
  198. * To make u_int32_t elements come out correctly, the target->host
  199. * upload has swizzled the bytes in each u_int32_t element of the
  200. * message.
  201. * For byte-array message fields like the MAC address, this
  202. * upload swizzling puts the bytes in the wrong order, and needs
  203. * to be undone.
  204. */
  205. buffer[0] = tgt_mac_addr[3];
  206. buffer[1] = tgt_mac_addr[2];
  207. buffer[2] = tgt_mac_addr[1];
  208. buffer[3] = tgt_mac_addr[0];
  209. buffer[4] = tgt_mac_addr[7];
  210. buffer[5] = tgt_mac_addr[6];
  211. return buffer;
  212. #else
  213. /*
  214. * The host endianness matches the target endianness -
  215. * we can use the mac addr directly from the message buffer.
  216. */
  217. return tgt_mac_addr;
  218. #endif
  219. }
  220. /*
  221. * dp_htt_h2t_send_complete_free_netbuf() - Free completed buffer
  222. * @soc: SOC handle
  223. * @status: Completion status
  224. * @netbuf: HTT buffer
  225. */
  226. static void
  227. dp_htt_h2t_send_complete_free_netbuf(
  228. void *soc, A_STATUS status, qdf_nbuf_t netbuf)
  229. {
  230. qdf_nbuf_free(netbuf);
  231. }
  232. #ifdef ENABLE_CE4_COMP_DISABLE_HTT_HTC_MISC_LIST
  233. /*
  234. * dp_htt_h2t_send_complete() - H2T completion handler
  235. * @context: Opaque context (HTT SOC handle)
  236. * @htc_pkt: HTC packet
  237. */
  238. static void
  239. dp_htt_h2t_send_complete(void *context, HTC_PACKET *htc_pkt)
  240. {
  241. struct htt_soc *soc = (struct htt_soc *) context;
  242. struct dp_htt_htc_pkt *htt_pkt;
  243. qdf_nbuf_t netbuf;
  244. htt_pkt = container_of(htc_pkt, struct dp_htt_htc_pkt, htc_pkt);
  245. /* process (free or keep) the netbuf that held the message */
  246. netbuf = (qdf_nbuf_t) htc_pkt->pNetBufContext;
  247. /*
  248. * adf sendcomplete is required for windows only
  249. */
  250. /* qdf_nbuf_set_sendcompleteflag(netbuf, TRUE); */
  251. /* free the htt_htc_pkt / HTC_PACKET object */
  252. qdf_nbuf_free(netbuf);
  253. htt_htc_pkt_free(soc, htt_pkt);
  254. }
  255. #else /* ENABLE_CE4_COMP_DISABLE_HTT_HTC_MISC_LIST */
  256. /*
  257. * * dp_htt_h2t_send_complete() - H2T completion handler
  258. * * @context: Opaque context (HTT SOC handle)
  259. * * @htc_pkt: HTC packet
  260. * */
  261. static void
  262. dp_htt_h2t_send_complete(void *context, HTC_PACKET *htc_pkt)
  263. {
  264. void (*send_complete_part2)(
  265. void *soc, QDF_STATUS status, qdf_nbuf_t msdu);
  266. struct htt_soc *soc = (struct htt_soc *) context;
  267. struct dp_htt_htc_pkt *htt_pkt;
  268. qdf_nbuf_t netbuf;
  269. send_complete_part2 = htc_pkt->pPktContext;
  270. htt_pkt = container_of(htc_pkt, struct dp_htt_htc_pkt, htc_pkt);
  271. /* process (free or keep) the netbuf that held the message */
  272. netbuf = (qdf_nbuf_t) htc_pkt->pNetBufContext;
  273. /*
  274. * adf sendcomplete is required for windows only
  275. */
  276. /* qdf_nbuf_set_sendcompleteflag(netbuf, TRUE); */
  277. if (send_complete_part2){
  278. send_complete_part2(
  279. htt_pkt->soc_ctxt, htc_pkt->Status, netbuf);
  280. }
  281. /* free the htt_htc_pkt / HTC_PACKET object */
  282. htt_htc_pkt_free(soc, htt_pkt);
  283. }
  284. #endif /* ENABLE_CE4_COMP_DISABLE_HTT_HTC_MISC_LIST */
  285. /*
  286. * htt_h2t_ver_req_msg() - Send HTT version request message to target
  287. * @htt_soc: HTT SOC handle
  288. *
  289. * Return: 0 on success; error code on failure
  290. */
  291. static int htt_h2t_ver_req_msg(struct htt_soc *soc)
  292. {
  293. struct dp_htt_htc_pkt *pkt;
  294. qdf_nbuf_t msg;
  295. uint32_t *msg_word;
  296. QDF_STATUS status;
  297. msg = qdf_nbuf_alloc(
  298. soc->osdev,
  299. HTT_MSG_BUF_SIZE(HTT_VER_REQ_BYTES),
  300. /* reserve room for the HTC header */
  301. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  302. if (!msg)
  303. return QDF_STATUS_E_NOMEM;
  304. /*
  305. * Set the length of the message.
  306. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  307. * separately during the below call to qdf_nbuf_push_head.
  308. * The contribution from the HTC header is added separately inside HTC.
  309. */
  310. if (qdf_nbuf_put_tail(msg, HTT_VER_REQ_BYTES) == NULL) {
  311. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  312. "%s: Failed to expand head for HTT_H2T_MSG_TYPE_VERSION_REQ msg",
  313. __func__);
  314. return QDF_STATUS_E_FAILURE;
  315. }
  316. /* fill in the message contents */
  317. msg_word = (u_int32_t *) qdf_nbuf_data(msg);
  318. /* rewind beyond alignment pad to get to the HTC header reserved area */
  319. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  320. *msg_word = 0;
  321. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_VERSION_REQ);
  322. pkt = htt_htc_pkt_alloc(soc);
  323. if (!pkt) {
  324. qdf_nbuf_free(msg);
  325. return QDF_STATUS_E_FAILURE;
  326. }
  327. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  328. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  329. dp_htt_h2t_send_complete_free_netbuf, qdf_nbuf_data(msg),
  330. qdf_nbuf_len(msg), soc->htc_endpoint,
  331. HTC_TX_PACKET_TAG_RTPM_PUT_RC);
  332. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  333. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_VERSION_REQ,
  334. NULL);
  335. if (status != QDF_STATUS_SUCCESS) {
  336. qdf_nbuf_free(msg);
  337. htt_htc_pkt_free(soc, pkt);
  338. }
  339. return status;
  340. }
  341. /*
  342. * htt_srng_setup() - Send SRNG setup message to target
  343. * @htt_soc: HTT SOC handle
  344. * @mac_id: MAC Id
  345. * @hal_srng: Opaque HAL SRNG pointer
  346. * @hal_ring_type: SRNG ring type
  347. *
  348. * Return: 0 on success; error code on failure
  349. */
  350. int htt_srng_setup(struct htt_soc *soc, int mac_id,
  351. hal_ring_handle_t hal_ring_hdl,
  352. int hal_ring_type)
  353. {
  354. struct dp_htt_htc_pkt *pkt;
  355. qdf_nbuf_t htt_msg;
  356. uint32_t *msg_word;
  357. struct hal_srng_params srng_params;
  358. qdf_dma_addr_t hp_addr, tp_addr;
  359. uint32_t ring_entry_size =
  360. hal_srng_get_entrysize(soc->hal_soc, hal_ring_type);
  361. int htt_ring_type, htt_ring_id;
  362. uint8_t *htt_logger_bufp;
  363. int target_pdev_id;
  364. int lmac_id = dp_get_lmac_id_for_pdev_id(soc->dp_soc, 0, mac_id);
  365. QDF_STATUS status;
  366. /* Sizes should be set in 4-byte words */
  367. ring_entry_size = ring_entry_size >> 2;
  368. htt_msg = qdf_nbuf_alloc(soc->osdev,
  369. HTT_MSG_BUF_SIZE(HTT_SRING_SETUP_SZ),
  370. /* reserve room for the HTC header */
  371. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  372. if (!htt_msg)
  373. goto fail0;
  374. hal_get_srng_params(soc->hal_soc, hal_ring_hdl, &srng_params);
  375. hp_addr = hal_srng_get_hp_addr(soc->hal_soc, hal_ring_hdl);
  376. tp_addr = hal_srng_get_tp_addr(soc->hal_soc, hal_ring_hdl);
  377. switch (hal_ring_type) {
  378. case RXDMA_BUF:
  379. #ifdef QCA_HOST2FW_RXBUF_RING
  380. if (srng_params.ring_id ==
  381. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0 +
  382. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  383. htt_ring_id = HTT_HOST1_TO_FW_RXBUF_RING;
  384. htt_ring_type = HTT_SW_TO_SW_RING;
  385. #ifdef IPA_OFFLOAD
  386. } else if (srng_params.ring_id ==
  387. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF2 +
  388. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  389. htt_ring_id = HTT_HOST2_TO_FW_RXBUF_RING;
  390. htt_ring_type = HTT_SW_TO_SW_RING;
  391. #endif
  392. #else
  393. if (srng_params.ring_id ==
  394. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0 +
  395. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  396. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  397. htt_ring_type = HTT_SW_TO_HW_RING;
  398. #endif
  399. } else if (srng_params.ring_id ==
  400. #ifdef IPA_OFFLOAD
  401. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF1 +
  402. #else
  403. (HAL_SRNG_WMAC1_SW2RXDMA1_BUF +
  404. #endif
  405. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  406. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  407. htt_ring_type = HTT_SW_TO_HW_RING;
  408. } else {
  409. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  410. "%s: Ring %d currently not supported",
  411. __func__, srng_params.ring_id);
  412. goto fail1;
  413. }
  414. dp_info("ring_type %d ring_id %d htt_ring_id %d hp_addr 0x%llx tp_addr 0x%llx",
  415. hal_ring_type, srng_params.ring_id, htt_ring_id,
  416. (uint64_t)hp_addr,
  417. (uint64_t)tp_addr);
  418. break;
  419. case RXDMA_MONITOR_BUF:
  420. htt_ring_id = HTT_RXDMA_MONITOR_BUF_RING;
  421. htt_ring_type = HTT_SW_TO_HW_RING;
  422. break;
  423. case RXDMA_MONITOR_STATUS:
  424. htt_ring_id = HTT_RXDMA_MONITOR_STATUS_RING;
  425. htt_ring_type = HTT_SW_TO_HW_RING;
  426. break;
  427. case RXDMA_MONITOR_DST:
  428. htt_ring_id = HTT_RXDMA_MONITOR_DEST_RING;
  429. htt_ring_type = HTT_HW_TO_SW_RING;
  430. break;
  431. case RXDMA_MONITOR_DESC:
  432. htt_ring_id = HTT_RXDMA_MONITOR_DESC_RING;
  433. htt_ring_type = HTT_SW_TO_HW_RING;
  434. break;
  435. case RXDMA_DST:
  436. htt_ring_id = HTT_RXDMA_NON_MONITOR_DEST_RING;
  437. htt_ring_type = HTT_HW_TO_SW_RING;
  438. break;
  439. #ifdef QCA_MONITOR_2_0_SUPPORT_WAR
  440. // WAR till fw htt.h changes are merged
  441. case TX_MONITOR_BUF:
  442. htt_ring_id = HTT_TX_MON_HOST2MON_BUF_RING;
  443. htt_ring_type = HTT_SW_TO_HW_RING;
  444. break;
  445. case TX_MONITOR_DST:
  446. htt_ring_id = HTT_TX_MON_MON2HOST_DEST_RING;
  447. htt_ring_type = HTT_HW_TO_SW_RING;
  448. break;
  449. #endif
  450. default:
  451. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  452. "%s: Ring currently not supported", __func__);
  453. goto fail1;
  454. }
  455. /*
  456. * Set the length of the message.
  457. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  458. * separately during the below call to qdf_nbuf_push_head.
  459. * The contribution from the HTC header is added separately inside HTC.
  460. */
  461. if (qdf_nbuf_put_tail(htt_msg, HTT_SRING_SETUP_SZ) == NULL) {
  462. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  463. "%s: Failed to expand head for SRING_SETUP msg",
  464. __func__);
  465. return QDF_STATUS_E_FAILURE;
  466. }
  467. msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
  468. /* rewind beyond alignment pad to get to the HTC header reserved area */
  469. qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
  470. /* word 0 */
  471. *msg_word = 0;
  472. htt_logger_bufp = (uint8_t *)msg_word;
  473. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_SRING_SETUP);
  474. target_pdev_id =
  475. dp_get_target_pdev_id_for_host_pdev_id(soc->dp_soc, mac_id);
  476. if ((htt_ring_type == HTT_SW_TO_HW_RING) ||
  477. (htt_ring_type == HTT_HW_TO_SW_RING))
  478. HTT_SRING_SETUP_PDEV_ID_SET(*msg_word, target_pdev_id);
  479. else
  480. HTT_SRING_SETUP_PDEV_ID_SET(*msg_word, mac_id);
  481. dp_info("mac_id %d", mac_id);
  482. HTT_SRING_SETUP_RING_TYPE_SET(*msg_word, htt_ring_type);
  483. /* TODO: Discuss with FW on changing this to unique ID and using
  484. * htt_ring_type to send the type of ring
  485. */
  486. HTT_SRING_SETUP_RING_ID_SET(*msg_word, htt_ring_id);
  487. /* word 1 */
  488. msg_word++;
  489. *msg_word = 0;
  490. HTT_SRING_SETUP_RING_BASE_ADDR_LO_SET(*msg_word,
  491. srng_params.ring_base_paddr & 0xffffffff);
  492. /* word 2 */
  493. msg_word++;
  494. *msg_word = 0;
  495. HTT_SRING_SETUP_RING_BASE_ADDR_HI_SET(*msg_word,
  496. (uint64_t)srng_params.ring_base_paddr >> 32);
  497. /* word 3 */
  498. msg_word++;
  499. *msg_word = 0;
  500. HTT_SRING_SETUP_ENTRY_SIZE_SET(*msg_word, ring_entry_size);
  501. HTT_SRING_SETUP_RING_SIZE_SET(*msg_word,
  502. (ring_entry_size * srng_params.num_entries));
  503. dp_info("entry_size %d", ring_entry_size);
  504. dp_info("num_entries %d", srng_params.num_entries);
  505. dp_info("ring_size %d", (ring_entry_size * srng_params.num_entries));
  506. if (htt_ring_type == HTT_SW_TO_HW_RING)
  507. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_LOOPCOUNT_DISABLE_SET(
  508. *msg_word, 1);
  509. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_MSI_SWAP_SET(*msg_word,
  510. !!(srng_params.flags & HAL_SRNG_MSI_SWAP));
  511. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_TLV_SWAP_SET(*msg_word,
  512. !!(srng_params.flags & HAL_SRNG_DATA_TLV_SWAP));
  513. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_HOST_FW_SWAP_SET(*msg_word,
  514. !!(srng_params.flags & HAL_SRNG_RING_PTR_SWAP));
  515. /* word 4 */
  516. msg_word++;
  517. *msg_word = 0;
  518. HTT_SRING_SETUP_HEAD_OFFSET32_REMOTE_BASE_ADDR_LO_SET(*msg_word,
  519. hp_addr & 0xffffffff);
  520. /* word 5 */
  521. msg_word++;
  522. *msg_word = 0;
  523. HTT_SRING_SETUP_HEAD_OFFSET32_REMOTE_BASE_ADDR_HI_SET(*msg_word,
  524. (uint64_t)hp_addr >> 32);
  525. /* word 6 */
  526. msg_word++;
  527. *msg_word = 0;
  528. HTT_SRING_SETUP_TAIL_OFFSET32_REMOTE_BASE_ADDR_LO_SET(*msg_word,
  529. tp_addr & 0xffffffff);
  530. /* word 7 */
  531. msg_word++;
  532. *msg_word = 0;
  533. HTT_SRING_SETUP_TAIL_OFFSET32_REMOTE_BASE_ADDR_HI_SET(*msg_word,
  534. (uint64_t)tp_addr >> 32);
  535. /* word 8 */
  536. msg_word++;
  537. *msg_word = 0;
  538. HTT_SRING_SETUP_RING_MSI_ADDR_LO_SET(*msg_word,
  539. srng_params.msi_addr & 0xffffffff);
  540. /* word 9 */
  541. msg_word++;
  542. *msg_word = 0;
  543. HTT_SRING_SETUP_RING_MSI_ADDR_HI_SET(*msg_word,
  544. (uint64_t)(srng_params.msi_addr) >> 32);
  545. /* word 10 */
  546. msg_word++;
  547. *msg_word = 0;
  548. HTT_SRING_SETUP_RING_MSI_DATA_SET(*msg_word,
  549. qdf_cpu_to_le32(srng_params.msi_data));
  550. /* word 11 */
  551. msg_word++;
  552. *msg_word = 0;
  553. HTT_SRING_SETUP_INTR_BATCH_COUNTER_TH_SET(*msg_word,
  554. srng_params.intr_batch_cntr_thres_entries *
  555. ring_entry_size);
  556. HTT_SRING_SETUP_INTR_TIMER_TH_SET(*msg_word,
  557. srng_params.intr_timer_thres_us >> 3);
  558. /* word 12 */
  559. msg_word++;
  560. *msg_word = 0;
  561. if (srng_params.flags & HAL_SRNG_LOW_THRES_INTR_ENABLE) {
  562. /* TODO: Setting low threshold to 1/8th of ring size - see
  563. * if this needs to be configurable
  564. */
  565. HTT_SRING_SETUP_INTR_LOW_TH_SET(*msg_word,
  566. srng_params.low_threshold);
  567. }
  568. /* "response_required" field should be set if a HTT response message is
  569. * required after setting up the ring.
  570. */
  571. pkt = htt_htc_pkt_alloc(soc);
  572. if (!pkt)
  573. goto fail1;
  574. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  575. SET_HTC_PACKET_INFO_TX(
  576. &pkt->htc_pkt,
  577. dp_htt_h2t_send_complete_free_netbuf,
  578. qdf_nbuf_data(htt_msg),
  579. qdf_nbuf_len(htt_msg),
  580. soc->htc_endpoint,
  581. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  582. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  583. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_SRING_SETUP,
  584. htt_logger_bufp);
  585. if (status != QDF_STATUS_SUCCESS) {
  586. qdf_nbuf_free(htt_msg);
  587. htt_htc_pkt_free(soc, pkt);
  588. }
  589. return status;
  590. fail1:
  591. qdf_nbuf_free(htt_msg);
  592. fail0:
  593. return QDF_STATUS_E_FAILURE;
  594. }
  595. qdf_export_symbol(htt_srng_setup);
  596. #ifdef QCA_SUPPORT_FULL_MON
  597. /**
  598. * htt_h2t_full_mon_cfg() - Send full monitor configuarion msg to FW
  599. *
  600. * @htt_soc: HTT Soc handle
  601. * @pdev_id: Radio id
  602. * @dp_full_mon_config: enabled/disable configuration
  603. *
  604. * Return: Success when HTT message is sent, error on failure
  605. */
  606. int htt_h2t_full_mon_cfg(struct htt_soc *htt_soc,
  607. uint8_t pdev_id,
  608. enum dp_full_mon_config config)
  609. {
  610. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  611. struct dp_htt_htc_pkt *pkt;
  612. qdf_nbuf_t htt_msg;
  613. uint32_t *msg_word;
  614. uint8_t *htt_logger_bufp;
  615. htt_msg = qdf_nbuf_alloc(soc->osdev,
  616. HTT_MSG_BUF_SIZE(
  617. HTT_RX_FULL_MONITOR_MODE_SETUP_SZ),
  618. /* reserve room for the HTC header */
  619. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  620. 4,
  621. TRUE);
  622. if (!htt_msg)
  623. return QDF_STATUS_E_FAILURE;
  624. /*
  625. * Set the length of the message.
  626. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  627. * separately during the below call to qdf_nbuf_push_head.
  628. * The contribution from the HTC header is added separately inside HTC.
  629. */
  630. if (!qdf_nbuf_put_tail(htt_msg, HTT_RX_FULL_MONITOR_MODE_SETUP_SZ)) {
  631. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  632. "%s: Failed to expand head for RX Ring Cfg msg",
  633. __func__);
  634. goto fail1;
  635. }
  636. msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
  637. /* rewind beyond alignment pad to get to the HTC header reserved area */
  638. qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
  639. /* word 0 */
  640. *msg_word = 0;
  641. htt_logger_bufp = (uint8_t *)msg_word;
  642. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FULL_MONITOR_MODE);
  643. HTT_RX_FULL_MONITOR_MODE_OPERATION_PDEV_ID_SET(
  644. *msg_word, DP_SW2HW_MACID(pdev_id));
  645. msg_word++;
  646. *msg_word = 0;
  647. /* word 1 */
  648. if (config == DP_FULL_MON_ENABLE) {
  649. HTT_RX_FULL_MONITOR_MODE_ENABLE_SET(*msg_word, true);
  650. HTT_RX_FULL_MONITOR_MODE_ZERO_MPDU_SET(*msg_word, true);
  651. HTT_RX_FULL_MONITOR_MODE_NON_ZERO_MPDU_SET(*msg_word, true);
  652. HTT_RX_FULL_MONITOR_MODE_RELEASE_RINGS_SET(*msg_word, 0x2);
  653. } else if (config == DP_FULL_MON_DISABLE) {
  654. /* As per MAC team's suggestion, While disbaling full monitor
  655. * mode, Set 'en' bit to true in full monitor mode register.
  656. */
  657. HTT_RX_FULL_MONITOR_MODE_ENABLE_SET(*msg_word, true);
  658. HTT_RX_FULL_MONITOR_MODE_ZERO_MPDU_SET(*msg_word, false);
  659. HTT_RX_FULL_MONITOR_MODE_NON_ZERO_MPDU_SET(*msg_word, false);
  660. HTT_RX_FULL_MONITOR_MODE_RELEASE_RINGS_SET(*msg_word, 0x2);
  661. }
  662. pkt = htt_htc_pkt_alloc(soc);
  663. if (!pkt) {
  664. qdf_err("HTC packet allocation failed");
  665. goto fail1;
  666. }
  667. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  668. SET_HTC_PACKET_INFO_TX(
  669. &pkt->htc_pkt,
  670. dp_htt_h2t_send_complete_free_netbuf,
  671. qdf_nbuf_data(htt_msg),
  672. qdf_nbuf_len(htt_msg),
  673. soc->htc_endpoint,
  674. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  675. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  676. qdf_debug("config: %d", config);
  677. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_RX_FULL_MONITOR_MODE,
  678. htt_logger_bufp);
  679. return QDF_STATUS_SUCCESS;
  680. fail1:
  681. qdf_nbuf_free(htt_msg);
  682. return QDF_STATUS_E_FAILURE;
  683. }
  684. qdf_export_symbol(htt_h2t_full_mon_cfg);
  685. #else
  686. int htt_h2t_full_mon_cfg(struct htt_soc *htt_soc,
  687. uint8_t pdev_id,
  688. enum dp_full_mon_config config)
  689. {
  690. return 0;
  691. }
  692. qdf_export_symbol(htt_h2t_full_mon_cfg);
  693. #endif
  694. /*
  695. * htt_h2t_rx_ring_cfg() - Send SRNG packet and TLV filter
  696. * config message to target
  697. * @htt_soc: HTT SOC handle
  698. * @pdev_id: WIN- PDEV Id, MCL- mac id
  699. * @hal_srng: Opaque HAL SRNG pointer
  700. * @hal_ring_type: SRNG ring type
  701. * @ring_buf_size: SRNG buffer size
  702. * @htt_tlv_filter: Rx SRNG TLV and filter setting
  703. * Return: 0 on success; error code on failure
  704. */
  705. int htt_h2t_rx_ring_cfg(struct htt_soc *htt_soc, int pdev_id,
  706. hal_ring_handle_t hal_ring_hdl,
  707. int hal_ring_type, int ring_buf_size,
  708. struct htt_rx_ring_tlv_filter *htt_tlv_filter)
  709. {
  710. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  711. struct dp_htt_htc_pkt *pkt;
  712. qdf_nbuf_t htt_msg;
  713. uint32_t *msg_word;
  714. struct hal_srng_params srng_params;
  715. uint32_t htt_ring_type, htt_ring_id;
  716. uint32_t tlv_filter;
  717. uint8_t *htt_logger_bufp;
  718. struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx = soc->dp_soc->wlan_cfg_ctx;
  719. uint32_t mon_drop_th = wlan_cfg_get_mon_drop_thresh(wlan_cfg_ctx);
  720. int target_pdev_id;
  721. QDF_STATUS status;
  722. htt_msg = qdf_nbuf_alloc(soc->osdev,
  723. HTT_MSG_BUF_SIZE(HTT_RX_RING_SELECTION_CFG_SZ),
  724. /* reserve room for the HTC header */
  725. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  726. if (!htt_msg)
  727. goto fail0;
  728. hal_get_srng_params(soc->hal_soc, hal_ring_hdl, &srng_params);
  729. switch (hal_ring_type) {
  730. case RXDMA_BUF:
  731. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  732. htt_ring_type = HTT_SW_TO_HW_RING;
  733. break;
  734. case RXDMA_MONITOR_BUF:
  735. htt_ring_id = HTT_RXDMA_MONITOR_BUF_RING;
  736. htt_ring_type = HTT_SW_TO_HW_RING;
  737. break;
  738. case RXDMA_MONITOR_STATUS:
  739. htt_ring_id = HTT_RXDMA_MONITOR_STATUS_RING;
  740. htt_ring_type = HTT_SW_TO_HW_RING;
  741. break;
  742. case RXDMA_MONITOR_DST:
  743. htt_ring_id = HTT_RXDMA_MONITOR_DEST_RING;
  744. htt_ring_type = HTT_HW_TO_SW_RING;
  745. break;
  746. case RXDMA_MONITOR_DESC:
  747. htt_ring_id = HTT_RXDMA_MONITOR_DESC_RING;
  748. htt_ring_type = HTT_SW_TO_HW_RING;
  749. break;
  750. case RXDMA_DST:
  751. htt_ring_id = HTT_RXDMA_NON_MONITOR_DEST_RING;
  752. htt_ring_type = HTT_HW_TO_SW_RING;
  753. break;
  754. default:
  755. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  756. "%s: Ring currently not supported", __func__);
  757. goto fail1;
  758. }
  759. /*
  760. * Set the length of the message.
  761. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  762. * separately during the below call to qdf_nbuf_push_head.
  763. * The contribution from the HTC header is added separately inside HTC.
  764. */
  765. if (qdf_nbuf_put_tail(htt_msg, HTT_RX_RING_SELECTION_CFG_SZ) == NULL) {
  766. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  767. "%s: Failed to expand head for RX Ring Cfg msg",
  768. __func__);
  769. goto fail1; /* failure */
  770. }
  771. msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
  772. /* rewind beyond alignment pad to get to the HTC header reserved area */
  773. qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
  774. /* word 0 */
  775. htt_logger_bufp = (uint8_t *)msg_word;
  776. *msg_word = 0;
  777. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_RING_SELECTION_CFG);
  778. /*
  779. * pdev_id is indexed from 0 whereas mac_id is indexed from 1
  780. * SW_TO_SW and SW_TO_HW rings are unaffected by this
  781. */
  782. target_pdev_id =
  783. dp_get_target_pdev_id_for_host_pdev_id(soc->dp_soc, pdev_id);
  784. if (htt_ring_type == HTT_SW_TO_SW_RING ||
  785. htt_ring_type == HTT_SW_TO_HW_RING)
  786. HTT_RX_RING_SELECTION_CFG_PDEV_ID_SET(*msg_word,
  787. target_pdev_id);
  788. /* TODO: Discuss with FW on changing this to unique ID and using
  789. * htt_ring_type to send the type of ring
  790. */
  791. HTT_RX_RING_SELECTION_CFG_RING_ID_SET(*msg_word, htt_ring_id);
  792. HTT_RX_RING_SELECTION_CFG_STATUS_TLV_SET(*msg_word,
  793. !!(srng_params.flags & HAL_SRNG_MSI_SWAP));
  794. HTT_RX_RING_SELECTION_CFG_RX_OFFSETS_VALID_SET(*msg_word,
  795. htt_tlv_filter->offset_valid);
  796. if (mon_drop_th > 0)
  797. HTT_RX_RING_SELECTION_CFG_DROP_THRESHOLD_VALID_SET(*msg_word,
  798. 1);
  799. else
  800. HTT_RX_RING_SELECTION_CFG_DROP_THRESHOLD_VALID_SET(*msg_word,
  801. 0);
  802. /* word 1 */
  803. msg_word++;
  804. *msg_word = 0;
  805. HTT_RX_RING_SELECTION_CFG_RING_BUFFER_SIZE_SET(*msg_word,
  806. ring_buf_size);
  807. dp_mon_rx_packet_length_set(soc->dp_soc, msg_word, htt_tlv_filter);
  808. /* word 2 */
  809. msg_word++;
  810. *msg_word = 0;
  811. if (htt_tlv_filter->enable_fp) {
  812. /* TYPE: MGMT */
  813. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  814. FP, MGMT, 0000,
  815. (htt_tlv_filter->fp_mgmt_filter &
  816. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  817. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  818. FP, MGMT, 0001,
  819. (htt_tlv_filter->fp_mgmt_filter &
  820. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  821. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  822. FP, MGMT, 0010,
  823. (htt_tlv_filter->fp_mgmt_filter &
  824. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  825. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  826. FP, MGMT, 0011,
  827. (htt_tlv_filter->fp_mgmt_filter &
  828. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  829. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  830. FP, MGMT, 0100,
  831. (htt_tlv_filter->fp_mgmt_filter &
  832. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  833. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  834. FP, MGMT, 0101,
  835. (htt_tlv_filter->fp_mgmt_filter &
  836. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  837. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  838. FP, MGMT, 0110,
  839. (htt_tlv_filter->fp_mgmt_filter &
  840. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  841. /* reserved */
  842. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, FP,
  843. MGMT, 0111,
  844. (htt_tlv_filter->fp_mgmt_filter &
  845. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  846. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  847. FP, MGMT, 1000,
  848. (htt_tlv_filter->fp_mgmt_filter &
  849. FILTER_MGMT_BEACON) ? 1 : 0);
  850. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  851. FP, MGMT, 1001,
  852. (htt_tlv_filter->fp_mgmt_filter &
  853. FILTER_MGMT_ATIM) ? 1 : 0);
  854. }
  855. if (htt_tlv_filter->enable_md) {
  856. /* TYPE: MGMT */
  857. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  858. MD, MGMT, 0000,
  859. (htt_tlv_filter->md_mgmt_filter &
  860. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  861. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  862. MD, MGMT, 0001,
  863. (htt_tlv_filter->md_mgmt_filter &
  864. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  865. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  866. MD, MGMT, 0010,
  867. (htt_tlv_filter->md_mgmt_filter &
  868. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  869. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  870. MD, MGMT, 0011,
  871. (htt_tlv_filter->md_mgmt_filter &
  872. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  873. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  874. MD, MGMT, 0100,
  875. (htt_tlv_filter->md_mgmt_filter &
  876. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  877. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  878. MD, MGMT, 0101,
  879. (htt_tlv_filter->md_mgmt_filter &
  880. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  881. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  882. MD, MGMT, 0110,
  883. (htt_tlv_filter->md_mgmt_filter &
  884. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  885. /* reserved */
  886. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
  887. MGMT, 0111,
  888. (htt_tlv_filter->md_mgmt_filter &
  889. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  890. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  891. MD, MGMT, 1000,
  892. (htt_tlv_filter->md_mgmt_filter &
  893. FILTER_MGMT_BEACON) ? 1 : 0);
  894. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  895. MD, MGMT, 1001,
  896. (htt_tlv_filter->md_mgmt_filter &
  897. FILTER_MGMT_ATIM) ? 1 : 0);
  898. }
  899. if (htt_tlv_filter->enable_mo) {
  900. /* TYPE: MGMT */
  901. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  902. MO, MGMT, 0000,
  903. (htt_tlv_filter->mo_mgmt_filter &
  904. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  905. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  906. MO, MGMT, 0001,
  907. (htt_tlv_filter->mo_mgmt_filter &
  908. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  909. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  910. MO, MGMT, 0010,
  911. (htt_tlv_filter->mo_mgmt_filter &
  912. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  913. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  914. MO, MGMT, 0011,
  915. (htt_tlv_filter->mo_mgmt_filter &
  916. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  917. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  918. MO, MGMT, 0100,
  919. (htt_tlv_filter->mo_mgmt_filter &
  920. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  921. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  922. MO, MGMT, 0101,
  923. (htt_tlv_filter->mo_mgmt_filter &
  924. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  925. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  926. MO, MGMT, 0110,
  927. (htt_tlv_filter->mo_mgmt_filter &
  928. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  929. /* reserved */
  930. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MO,
  931. MGMT, 0111,
  932. (htt_tlv_filter->mo_mgmt_filter &
  933. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  934. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  935. MO, MGMT, 1000,
  936. (htt_tlv_filter->mo_mgmt_filter &
  937. FILTER_MGMT_BEACON) ? 1 : 0);
  938. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  939. MO, MGMT, 1001,
  940. (htt_tlv_filter->mo_mgmt_filter &
  941. FILTER_MGMT_ATIM) ? 1 : 0);
  942. }
  943. /* word 3 */
  944. msg_word++;
  945. *msg_word = 0;
  946. if (htt_tlv_filter->enable_fp) {
  947. /* TYPE: MGMT */
  948. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  949. FP, MGMT, 1010,
  950. (htt_tlv_filter->fp_mgmt_filter &
  951. FILTER_MGMT_DISASSOC) ? 1 : 0);
  952. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  953. FP, MGMT, 1011,
  954. (htt_tlv_filter->fp_mgmt_filter &
  955. FILTER_MGMT_AUTH) ? 1 : 0);
  956. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  957. FP, MGMT, 1100,
  958. (htt_tlv_filter->fp_mgmt_filter &
  959. FILTER_MGMT_DEAUTH) ? 1 : 0);
  960. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  961. FP, MGMT, 1101,
  962. (htt_tlv_filter->fp_mgmt_filter &
  963. FILTER_MGMT_ACTION) ? 1 : 0);
  964. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  965. FP, MGMT, 1110,
  966. (htt_tlv_filter->fp_mgmt_filter &
  967. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  968. /* reserved*/
  969. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, FP,
  970. MGMT, 1111,
  971. (htt_tlv_filter->fp_mgmt_filter &
  972. FILTER_MGMT_RESERVED_15) ? 1 : 0);
  973. }
  974. if (htt_tlv_filter->enable_md) {
  975. /* TYPE: MGMT */
  976. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  977. MD, MGMT, 1010,
  978. (htt_tlv_filter->md_mgmt_filter &
  979. FILTER_MGMT_DISASSOC) ? 1 : 0);
  980. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  981. MD, MGMT, 1011,
  982. (htt_tlv_filter->md_mgmt_filter &
  983. FILTER_MGMT_AUTH) ? 1 : 0);
  984. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  985. MD, MGMT, 1100,
  986. (htt_tlv_filter->md_mgmt_filter &
  987. FILTER_MGMT_DEAUTH) ? 1 : 0);
  988. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  989. MD, MGMT, 1101,
  990. (htt_tlv_filter->md_mgmt_filter &
  991. FILTER_MGMT_ACTION) ? 1 : 0);
  992. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  993. MD, MGMT, 1110,
  994. (htt_tlv_filter->md_mgmt_filter &
  995. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  996. }
  997. if (htt_tlv_filter->enable_mo) {
  998. /* TYPE: MGMT */
  999. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1000. MO, MGMT, 1010,
  1001. (htt_tlv_filter->mo_mgmt_filter &
  1002. FILTER_MGMT_DISASSOC) ? 1 : 0);
  1003. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1004. MO, MGMT, 1011,
  1005. (htt_tlv_filter->mo_mgmt_filter &
  1006. FILTER_MGMT_AUTH) ? 1 : 0);
  1007. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1008. MO, MGMT, 1100,
  1009. (htt_tlv_filter->mo_mgmt_filter &
  1010. FILTER_MGMT_DEAUTH) ? 1 : 0);
  1011. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1012. MO, MGMT, 1101,
  1013. (htt_tlv_filter->mo_mgmt_filter &
  1014. FILTER_MGMT_ACTION) ? 1 : 0);
  1015. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1016. MO, MGMT, 1110,
  1017. (htt_tlv_filter->mo_mgmt_filter &
  1018. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  1019. /* reserved*/
  1020. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MO,
  1021. MGMT, 1111,
  1022. (htt_tlv_filter->mo_mgmt_filter &
  1023. FILTER_MGMT_RESERVED_15) ? 1 : 0);
  1024. }
  1025. /* word 4 */
  1026. msg_word++;
  1027. *msg_word = 0;
  1028. if (htt_tlv_filter->enable_fp) {
  1029. /* TYPE: CTRL */
  1030. /* reserved */
  1031. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1032. CTRL, 0000,
  1033. (htt_tlv_filter->fp_ctrl_filter &
  1034. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1035. /* reserved */
  1036. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1037. CTRL, 0001,
  1038. (htt_tlv_filter->fp_ctrl_filter &
  1039. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1040. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1041. CTRL, 0010,
  1042. (htt_tlv_filter->fp_ctrl_filter &
  1043. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1044. /* reserved */
  1045. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1046. CTRL, 0011,
  1047. (htt_tlv_filter->fp_ctrl_filter &
  1048. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1049. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1050. CTRL, 0100,
  1051. (htt_tlv_filter->fp_ctrl_filter &
  1052. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1053. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1054. CTRL, 0101,
  1055. (htt_tlv_filter->fp_ctrl_filter &
  1056. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1057. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1058. CTRL, 0110,
  1059. (htt_tlv_filter->fp_ctrl_filter &
  1060. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1061. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1062. CTRL, 0111,
  1063. (htt_tlv_filter->fp_ctrl_filter &
  1064. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1065. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1066. CTRL, 1000,
  1067. (htt_tlv_filter->fp_ctrl_filter &
  1068. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1069. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1070. CTRL, 1001,
  1071. (htt_tlv_filter->fp_ctrl_filter &
  1072. FILTER_CTRL_BA) ? 1 : 0);
  1073. }
  1074. if (htt_tlv_filter->enable_md) {
  1075. /* TYPE: CTRL */
  1076. /* reserved */
  1077. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1078. CTRL, 0000,
  1079. (htt_tlv_filter->md_ctrl_filter &
  1080. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1081. /* reserved */
  1082. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1083. CTRL, 0001,
  1084. (htt_tlv_filter->md_ctrl_filter &
  1085. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1086. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1087. CTRL, 0010,
  1088. (htt_tlv_filter->md_ctrl_filter &
  1089. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1090. /* reserved */
  1091. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1092. CTRL, 0011,
  1093. (htt_tlv_filter->md_ctrl_filter &
  1094. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1095. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1096. CTRL, 0100,
  1097. (htt_tlv_filter->md_ctrl_filter &
  1098. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1099. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1100. CTRL, 0101,
  1101. (htt_tlv_filter->md_ctrl_filter &
  1102. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1103. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1104. CTRL, 0110,
  1105. (htt_tlv_filter->md_ctrl_filter &
  1106. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1107. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1108. CTRL, 0111,
  1109. (htt_tlv_filter->md_ctrl_filter &
  1110. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1111. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1112. CTRL, 1000,
  1113. (htt_tlv_filter->md_ctrl_filter &
  1114. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1115. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1116. CTRL, 1001,
  1117. (htt_tlv_filter->md_ctrl_filter &
  1118. FILTER_CTRL_BA) ? 1 : 0);
  1119. }
  1120. if (htt_tlv_filter->enable_mo) {
  1121. /* TYPE: CTRL */
  1122. /* reserved */
  1123. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1124. CTRL, 0000,
  1125. (htt_tlv_filter->mo_ctrl_filter &
  1126. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1127. /* reserved */
  1128. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1129. CTRL, 0001,
  1130. (htt_tlv_filter->mo_ctrl_filter &
  1131. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1132. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1133. CTRL, 0010,
  1134. (htt_tlv_filter->mo_ctrl_filter &
  1135. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1136. /* reserved */
  1137. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1138. CTRL, 0011,
  1139. (htt_tlv_filter->mo_ctrl_filter &
  1140. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1141. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1142. CTRL, 0100,
  1143. (htt_tlv_filter->mo_ctrl_filter &
  1144. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1145. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1146. CTRL, 0101,
  1147. (htt_tlv_filter->mo_ctrl_filter &
  1148. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1149. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1150. CTRL, 0110,
  1151. (htt_tlv_filter->mo_ctrl_filter &
  1152. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1153. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1154. CTRL, 0111,
  1155. (htt_tlv_filter->mo_ctrl_filter &
  1156. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1157. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1158. CTRL, 1000,
  1159. (htt_tlv_filter->mo_ctrl_filter &
  1160. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1161. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1162. CTRL, 1001,
  1163. (htt_tlv_filter->mo_ctrl_filter &
  1164. FILTER_CTRL_BA) ? 1 : 0);
  1165. }
  1166. /* word 5 */
  1167. msg_word++;
  1168. *msg_word = 0;
  1169. if (htt_tlv_filter->enable_fp) {
  1170. /* TYPE: CTRL */
  1171. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1172. CTRL, 1010,
  1173. (htt_tlv_filter->fp_ctrl_filter &
  1174. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1175. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1176. CTRL, 1011,
  1177. (htt_tlv_filter->fp_ctrl_filter &
  1178. FILTER_CTRL_RTS) ? 1 : 0);
  1179. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1180. CTRL, 1100,
  1181. (htt_tlv_filter->fp_ctrl_filter &
  1182. FILTER_CTRL_CTS) ? 1 : 0);
  1183. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1184. CTRL, 1101,
  1185. (htt_tlv_filter->fp_ctrl_filter &
  1186. FILTER_CTRL_ACK) ? 1 : 0);
  1187. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1188. CTRL, 1110,
  1189. (htt_tlv_filter->fp_ctrl_filter &
  1190. FILTER_CTRL_CFEND) ? 1 : 0);
  1191. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1192. CTRL, 1111,
  1193. (htt_tlv_filter->fp_ctrl_filter &
  1194. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1195. /* TYPE: DATA */
  1196. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1197. DATA, MCAST,
  1198. (htt_tlv_filter->fp_data_filter &
  1199. FILTER_DATA_MCAST) ? 1 : 0);
  1200. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1201. DATA, UCAST,
  1202. (htt_tlv_filter->fp_data_filter &
  1203. FILTER_DATA_UCAST) ? 1 : 0);
  1204. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1205. DATA, NULL,
  1206. (htt_tlv_filter->fp_data_filter &
  1207. FILTER_DATA_NULL) ? 1 : 0);
  1208. }
  1209. if (htt_tlv_filter->enable_md) {
  1210. /* TYPE: CTRL */
  1211. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1212. CTRL, 1010,
  1213. (htt_tlv_filter->md_ctrl_filter &
  1214. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1215. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1216. CTRL, 1011,
  1217. (htt_tlv_filter->md_ctrl_filter &
  1218. FILTER_CTRL_RTS) ? 1 : 0);
  1219. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1220. CTRL, 1100,
  1221. (htt_tlv_filter->md_ctrl_filter &
  1222. FILTER_CTRL_CTS) ? 1 : 0);
  1223. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1224. CTRL, 1101,
  1225. (htt_tlv_filter->md_ctrl_filter &
  1226. FILTER_CTRL_ACK) ? 1 : 0);
  1227. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1228. CTRL, 1110,
  1229. (htt_tlv_filter->md_ctrl_filter &
  1230. FILTER_CTRL_CFEND) ? 1 : 0);
  1231. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1232. CTRL, 1111,
  1233. (htt_tlv_filter->md_ctrl_filter &
  1234. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1235. /* TYPE: DATA */
  1236. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1237. DATA, MCAST,
  1238. (htt_tlv_filter->md_data_filter &
  1239. FILTER_DATA_MCAST) ? 1 : 0);
  1240. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1241. DATA, UCAST,
  1242. (htt_tlv_filter->md_data_filter &
  1243. FILTER_DATA_UCAST) ? 1 : 0);
  1244. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1245. DATA, NULL,
  1246. (htt_tlv_filter->md_data_filter &
  1247. FILTER_DATA_NULL) ? 1 : 0);
  1248. }
  1249. if (htt_tlv_filter->enable_mo) {
  1250. /* TYPE: CTRL */
  1251. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1252. CTRL, 1010,
  1253. (htt_tlv_filter->mo_ctrl_filter &
  1254. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1255. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1256. CTRL, 1011,
  1257. (htt_tlv_filter->mo_ctrl_filter &
  1258. FILTER_CTRL_RTS) ? 1 : 0);
  1259. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1260. CTRL, 1100,
  1261. (htt_tlv_filter->mo_ctrl_filter &
  1262. FILTER_CTRL_CTS) ? 1 : 0);
  1263. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1264. CTRL, 1101,
  1265. (htt_tlv_filter->mo_ctrl_filter &
  1266. FILTER_CTRL_ACK) ? 1 : 0);
  1267. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1268. CTRL, 1110,
  1269. (htt_tlv_filter->mo_ctrl_filter &
  1270. FILTER_CTRL_CFEND) ? 1 : 0);
  1271. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1272. CTRL, 1111,
  1273. (htt_tlv_filter->mo_ctrl_filter &
  1274. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1275. /* TYPE: DATA */
  1276. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1277. DATA, MCAST,
  1278. (htt_tlv_filter->mo_data_filter &
  1279. FILTER_DATA_MCAST) ? 1 : 0);
  1280. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1281. DATA, UCAST,
  1282. (htt_tlv_filter->mo_data_filter &
  1283. FILTER_DATA_UCAST) ? 1 : 0);
  1284. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1285. DATA, NULL,
  1286. (htt_tlv_filter->mo_data_filter &
  1287. FILTER_DATA_NULL) ? 1 : 0);
  1288. }
  1289. /* word 6 */
  1290. msg_word++;
  1291. *msg_word = 0;
  1292. tlv_filter = 0;
  1293. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MPDU_START,
  1294. htt_tlv_filter->mpdu_start);
  1295. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MSDU_START,
  1296. htt_tlv_filter->msdu_start);
  1297. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PACKET,
  1298. htt_tlv_filter->packet);
  1299. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MSDU_END,
  1300. htt_tlv_filter->msdu_end);
  1301. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MPDU_END,
  1302. htt_tlv_filter->mpdu_end);
  1303. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PACKET_HEADER,
  1304. htt_tlv_filter->packet_header);
  1305. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, ATTENTION,
  1306. htt_tlv_filter->attention);
  1307. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_START,
  1308. htt_tlv_filter->ppdu_start);
  1309. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END,
  1310. htt_tlv_filter->ppdu_end);
  1311. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END_USER_STATS,
  1312. htt_tlv_filter->ppdu_end_user_stats);
  1313. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter,
  1314. PPDU_END_USER_STATS_EXT,
  1315. htt_tlv_filter->ppdu_end_user_stats_ext);
  1316. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END_STATUS_DONE,
  1317. htt_tlv_filter->ppdu_end_status_done);
  1318. /* RESERVED bit maps to header_per_msdu in htt_tlv_filter*/
  1319. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, RESERVED,
  1320. htt_tlv_filter->header_per_msdu);
  1321. HTT_RX_RING_SELECTION_CFG_TLV_FILTER_IN_FLAG_SET(*msg_word, tlv_filter);
  1322. msg_word++;
  1323. *msg_word = 0;
  1324. if (htt_tlv_filter->offset_valid) {
  1325. HTT_RX_RING_SELECTION_CFG_RX_PACKET_OFFSET_SET(*msg_word,
  1326. htt_tlv_filter->rx_packet_offset);
  1327. HTT_RX_RING_SELECTION_CFG_RX_HEADER_OFFSET_SET(*msg_word,
  1328. htt_tlv_filter->rx_header_offset);
  1329. msg_word++;
  1330. *msg_word = 0;
  1331. HTT_RX_RING_SELECTION_CFG_RX_MPDU_END_OFFSET_SET(*msg_word,
  1332. htt_tlv_filter->rx_mpdu_end_offset);
  1333. HTT_RX_RING_SELECTION_CFG_RX_MPDU_START_OFFSET_SET(*msg_word,
  1334. htt_tlv_filter->rx_mpdu_start_offset);
  1335. msg_word++;
  1336. *msg_word = 0;
  1337. HTT_RX_RING_SELECTION_CFG_RX_MSDU_END_OFFSET_SET(*msg_word,
  1338. htt_tlv_filter->rx_msdu_end_offset);
  1339. HTT_RX_RING_SELECTION_CFG_RX_MSDU_START_OFFSET_SET(*msg_word,
  1340. htt_tlv_filter->rx_msdu_start_offset);
  1341. msg_word++;
  1342. *msg_word = 0;
  1343. HTT_RX_RING_SELECTION_CFG_RX_ATTENTION_OFFSET_SET(*msg_word,
  1344. htt_tlv_filter->rx_attn_offset);
  1345. msg_word++;
  1346. *msg_word = 0;
  1347. } else {
  1348. msg_word += 4;
  1349. *msg_word = 0;
  1350. }
  1351. if (mon_drop_th > 0)
  1352. HTT_RX_RING_SELECTION_CFG_RX_DROP_THRESHOLD_SET(*msg_word,
  1353. mon_drop_th);
  1354. dp_mon_rx_enable_mpdu_logging(soc->dp_soc, msg_word, htt_tlv_filter);
  1355. msg_word++;
  1356. *msg_word = 0;
  1357. dp_mon_rx_wmask_subscribe(soc->dp_soc, msg_word, htt_tlv_filter);
  1358. /* "response_required" field should be set if a HTT response message is
  1359. * required after setting up the ring.
  1360. */
  1361. pkt = htt_htc_pkt_alloc(soc);
  1362. if (!pkt)
  1363. goto fail1;
  1364. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  1365. SET_HTC_PACKET_INFO_TX(
  1366. &pkt->htc_pkt,
  1367. dp_htt_h2t_send_complete_free_netbuf,
  1368. qdf_nbuf_data(htt_msg),
  1369. qdf_nbuf_len(htt_msg),
  1370. soc->htc_endpoint,
  1371. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  1372. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  1373. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  1374. HTT_H2T_MSG_TYPE_RX_RING_SELECTION_CFG,
  1375. htt_logger_bufp);
  1376. if (status != QDF_STATUS_SUCCESS) {
  1377. qdf_nbuf_free(htt_msg);
  1378. htt_htc_pkt_free(soc, pkt);
  1379. }
  1380. return status;
  1381. fail1:
  1382. qdf_nbuf_free(htt_msg);
  1383. fail0:
  1384. return QDF_STATUS_E_FAILURE;
  1385. }
  1386. qdf_export_symbol(htt_h2t_rx_ring_cfg);
  1387. #if defined(HTT_STATS_ENABLE)
  1388. static inline QDF_STATUS dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
  1389. struct dp_soc *soc, qdf_nbuf_t htt_msg)
  1390. {
  1391. uint32_t pdev_id;
  1392. uint32_t *msg_word = NULL;
  1393. uint32_t msg_remain_len = 0;
  1394. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1395. /*COOKIE MSB*/
  1396. pdev_id = *(msg_word + 2) & HTT_PID_BIT_MASK;
  1397. /* stats message length + 16 size of HTT header*/
  1398. msg_remain_len = qdf_min(htt_stats->msg_len + 16,
  1399. (uint32_t)DP_EXT_MSG_LENGTH);
  1400. dp_wdi_event_handler(WDI_EVENT_HTT_STATS, soc,
  1401. msg_word, msg_remain_len,
  1402. WDI_NO_VAL, pdev_id);
  1403. if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
  1404. htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
  1405. }
  1406. /* Need to be freed here as WDI handler will
  1407. * make a copy of pkt to send data to application
  1408. */
  1409. qdf_nbuf_free(htt_msg);
  1410. return QDF_STATUS_SUCCESS;
  1411. }
  1412. #else
  1413. static inline QDF_STATUS
  1414. dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
  1415. struct dp_soc *soc, qdf_nbuf_t htt_msg)
  1416. {
  1417. return QDF_STATUS_E_NOSUPPORT;
  1418. }
  1419. #endif
  1420. #ifdef HTT_STATS_DEBUGFS_SUPPORT
  1421. /* dp_send_htt_stats_dbgfs_msg() - Function to send htt data to upper layer.
  1422. * @pdev: dp pdev handle
  1423. * @msg_word: HTT msg
  1424. * @msg_len: Length of HTT msg sent
  1425. *
  1426. * Return: none
  1427. */
  1428. static inline void
  1429. dp_htt_stats_dbgfs_send_msg(struct dp_pdev *pdev, uint32_t *msg_word,
  1430. uint32_t msg_len)
  1431. {
  1432. struct htt_dbgfs_cfg dbgfs_cfg;
  1433. int done = 0;
  1434. /* send 5th word of HTT msg to upper layer */
  1435. dbgfs_cfg.msg_word = (msg_word + 4);
  1436. dbgfs_cfg.m = pdev->dbgfs_cfg->m;
  1437. /* stats message length + 16 size of HTT header*/
  1438. msg_len = qdf_min(msg_len + HTT_HEADER_LEN, (uint32_t)DP_EXT_MSG_LENGTH);
  1439. if (pdev->dbgfs_cfg->htt_stats_dbgfs_msg_process)
  1440. pdev->dbgfs_cfg->htt_stats_dbgfs_msg_process(&dbgfs_cfg,
  1441. (msg_len - HTT_HEADER_LEN));
  1442. /* Get TLV Done bit from 4th msg word */
  1443. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*(msg_word + 3));
  1444. if (done) {
  1445. if (qdf_event_set(&pdev->dbgfs_cfg->htt_stats_dbgfs_event))
  1446. dp_htt_err("%pK: Failed to set event for debugfs htt stats"
  1447. , pdev->soc);
  1448. }
  1449. }
  1450. #else
  1451. static inline void
  1452. dp_htt_stats_dbgfs_send_msg(struct dp_pdev *pdev, uint32_t *msg_word,
  1453. uint32_t msg_len)
  1454. {
  1455. }
  1456. #endif /* HTT_STATS_DEBUGFS_SUPPORT */
  1457. #ifdef WLAN_SYSFS_DP_STATS
  1458. /* dp_htt_stats_sysfs_update_config() - Function to send htt data to upper layer.
  1459. * @pdev: dp pdev handle
  1460. *
  1461. * This function sets the process id and printing mode within the sysfs config
  1462. * struct. which enables DP_PRINT statements within this process to write to the
  1463. * console buffer provided by the user space.
  1464. *
  1465. * Return: None
  1466. */
  1467. static inline void
  1468. dp_htt_stats_sysfs_update_config(struct dp_pdev *pdev)
  1469. {
  1470. struct dp_soc *soc = pdev->soc;
  1471. if (!soc) {
  1472. dp_htt_err("soc is null");
  1473. return;
  1474. }
  1475. if (!soc->sysfs_config) {
  1476. dp_htt_err("soc->sysfs_config is NULL");
  1477. return;
  1478. }
  1479. /* set sysfs config parameters */
  1480. soc->sysfs_config->process_id = qdf_get_current_pid();
  1481. soc->sysfs_config->printing_mode = PRINTING_MODE_ENABLED;
  1482. }
  1483. /*
  1484. * dp_htt_stats_sysfs_set_event() - Set sysfs stats event.
  1485. * @soc: soc handle.
  1486. * @msg_word: Pointer to htt msg word.
  1487. *
  1488. * @return: void
  1489. */
  1490. static inline void
  1491. dp_htt_stats_sysfs_set_event(struct dp_soc *soc, uint32_t *msg_word)
  1492. {
  1493. int done = 0;
  1494. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*(msg_word + 3));
  1495. if (done) {
  1496. if (qdf_event_set(&soc->sysfs_config->sysfs_txrx_fw_request_done))
  1497. dp_htt_err("%pK:event compl Fail to set event ",
  1498. soc);
  1499. }
  1500. }
  1501. #else /* WLAN_SYSFS_DP_STATS */
  1502. static inline void
  1503. dp_htt_stats_sysfs_update_config(struct dp_pdev *pdev)
  1504. {
  1505. }
  1506. static inline void
  1507. dp_htt_stats_sysfs_set_event(struct dp_soc *dp_soc, uint32_t *msg_word)
  1508. {
  1509. }
  1510. #endif /* WLAN_SYSFS_DP_STATS */
  1511. /**
  1512. * dp_process_htt_stat_msg(): Process the list of buffers of HTT EXT stats
  1513. * @htt_stats: htt stats info
  1514. *
  1515. * The FW sends the HTT EXT STATS as a stream of T2H messages. Each T2H message
  1516. * contains sub messages which are identified by a TLV header.
  1517. * In this function we will process the stream of T2H messages and read all the
  1518. * TLV contained in the message.
  1519. *
  1520. * THe following cases have been taken care of
  1521. * Case 1: When the tlv_remain_length <= msg_remain_length of HTT MSG buffer
  1522. * In this case the buffer will contain multiple tlvs.
  1523. * Case 2: When the tlv_remain_length > msg_remain_length of HTT MSG buffer.
  1524. * Only one tlv will be contained in the HTT message and this tag
  1525. * will extend onto the next buffer.
  1526. * Case 3: When the buffer is the continuation of the previous message
  1527. * Case 4: tlv length is 0. which will indicate the end of message
  1528. *
  1529. * return: void
  1530. */
  1531. static inline void dp_process_htt_stat_msg(struct htt_stats_context *htt_stats,
  1532. struct dp_soc *soc)
  1533. {
  1534. htt_tlv_tag_t tlv_type = 0xff;
  1535. qdf_nbuf_t htt_msg = NULL;
  1536. uint32_t *msg_word;
  1537. uint8_t *tlv_buf_head = NULL;
  1538. uint8_t *tlv_buf_tail = NULL;
  1539. uint32_t msg_remain_len = 0;
  1540. uint32_t tlv_remain_len = 0;
  1541. uint32_t *tlv_start;
  1542. int cookie_val = 0;
  1543. int cookie_msb = 0;
  1544. int pdev_id;
  1545. bool copy_stats = false;
  1546. struct dp_pdev *pdev;
  1547. /* Process node in the HTT message queue */
  1548. while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
  1549. != NULL) {
  1550. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1551. cookie_val = *(msg_word + 1);
  1552. htt_stats->msg_len = HTT_T2H_EXT_STATS_CONF_TLV_LENGTH_GET(
  1553. *(msg_word +
  1554. HTT_T2H_EXT_STATS_TLV_START_OFFSET));
  1555. if (cookie_val) {
  1556. if (dp_send_htt_stat_resp(htt_stats, soc, htt_msg)
  1557. == QDF_STATUS_SUCCESS) {
  1558. continue;
  1559. }
  1560. }
  1561. cookie_msb = *(msg_word + 2);
  1562. pdev_id = *(msg_word + 2) & HTT_PID_BIT_MASK;
  1563. pdev = soc->pdev_list[pdev_id];
  1564. if (!cookie_val && (cookie_msb & DBG_STATS_COOKIE_HTT_DBGFS)) {
  1565. dp_htt_stats_dbgfs_send_msg(pdev, msg_word,
  1566. htt_stats->msg_len);
  1567. qdf_nbuf_free(htt_msg);
  1568. continue;
  1569. }
  1570. if (!cookie_val && (cookie_msb & DBG_SYSFS_STATS_COOKIE))
  1571. dp_htt_stats_sysfs_update_config(pdev);
  1572. if (cookie_msb & DBG_STATS_COOKIE_DP_STATS)
  1573. copy_stats = true;
  1574. /* read 5th word */
  1575. msg_word = msg_word + 4;
  1576. msg_remain_len = qdf_min(htt_stats->msg_len,
  1577. (uint32_t) DP_EXT_MSG_LENGTH);
  1578. /* Keep processing the node till node length is 0 */
  1579. while (msg_remain_len) {
  1580. /*
  1581. * if message is not a continuation of previous message
  1582. * read the tlv type and tlv length
  1583. */
  1584. if (!tlv_buf_head) {
  1585. tlv_type = HTT_STATS_TLV_TAG_GET(
  1586. *msg_word);
  1587. tlv_remain_len = HTT_STATS_TLV_LENGTH_GET(
  1588. *msg_word);
  1589. }
  1590. if (tlv_remain_len == 0) {
  1591. msg_remain_len = 0;
  1592. if (tlv_buf_head) {
  1593. qdf_mem_free(tlv_buf_head);
  1594. tlv_buf_head = NULL;
  1595. tlv_buf_tail = NULL;
  1596. }
  1597. goto error;
  1598. }
  1599. if (!tlv_buf_head)
  1600. tlv_remain_len += HTT_TLV_HDR_LEN;
  1601. if ((tlv_remain_len <= msg_remain_len)) {
  1602. /* Case 3 */
  1603. if (tlv_buf_head) {
  1604. qdf_mem_copy(tlv_buf_tail,
  1605. (uint8_t *)msg_word,
  1606. tlv_remain_len);
  1607. tlv_start = (uint32_t *)tlv_buf_head;
  1608. } else {
  1609. /* Case 1 */
  1610. tlv_start = msg_word;
  1611. }
  1612. if (copy_stats)
  1613. dp_htt_stats_copy_tag(pdev,
  1614. tlv_type,
  1615. tlv_start);
  1616. else
  1617. dp_htt_stats_print_tag(pdev,
  1618. tlv_type,
  1619. tlv_start);
  1620. if (tlv_type == HTT_STATS_PEER_DETAILS_TAG ||
  1621. tlv_type == HTT_STATS_PEER_STATS_CMN_TAG)
  1622. dp_peer_update_inactive_time(pdev,
  1623. tlv_type,
  1624. tlv_start);
  1625. msg_remain_len -= tlv_remain_len;
  1626. msg_word = (uint32_t *)
  1627. (((uint8_t *)msg_word) +
  1628. tlv_remain_len);
  1629. tlv_remain_len = 0;
  1630. if (tlv_buf_head) {
  1631. qdf_mem_free(tlv_buf_head);
  1632. tlv_buf_head = NULL;
  1633. tlv_buf_tail = NULL;
  1634. }
  1635. } else { /* tlv_remain_len > msg_remain_len */
  1636. /* Case 2 & 3 */
  1637. if (!tlv_buf_head) {
  1638. tlv_buf_head = qdf_mem_malloc(
  1639. tlv_remain_len);
  1640. if (!tlv_buf_head) {
  1641. QDF_TRACE(QDF_MODULE_ID_TXRX,
  1642. QDF_TRACE_LEVEL_ERROR,
  1643. "Alloc failed");
  1644. goto error;
  1645. }
  1646. tlv_buf_tail = tlv_buf_head;
  1647. }
  1648. qdf_mem_copy(tlv_buf_tail, (uint8_t *)msg_word,
  1649. msg_remain_len);
  1650. tlv_remain_len -= msg_remain_len;
  1651. tlv_buf_tail += msg_remain_len;
  1652. }
  1653. }
  1654. if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
  1655. htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
  1656. }
  1657. /* indicate event completion in case the event is done */
  1658. if (!cookie_val && (cookie_msb & DBG_SYSFS_STATS_COOKIE))
  1659. dp_htt_stats_sysfs_set_event(soc, msg_word);
  1660. qdf_nbuf_free(htt_msg);
  1661. }
  1662. return;
  1663. error:
  1664. qdf_nbuf_free(htt_msg);
  1665. while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
  1666. != NULL)
  1667. qdf_nbuf_free(htt_msg);
  1668. }
  1669. void htt_t2h_stats_handler(void *context)
  1670. {
  1671. struct dp_soc *soc = (struct dp_soc *)context;
  1672. struct htt_stats_context htt_stats;
  1673. uint32_t *msg_word;
  1674. qdf_nbuf_t htt_msg = NULL;
  1675. uint8_t done;
  1676. uint32_t rem_stats;
  1677. if (!soc) {
  1678. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1679. "soc is NULL");
  1680. return;
  1681. }
  1682. if (!qdf_atomic_read(&soc->cmn_init_done)) {
  1683. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1684. "soc: 0x%pK, init_done: %d", soc,
  1685. qdf_atomic_read(&soc->cmn_init_done));
  1686. return;
  1687. }
  1688. qdf_mem_zero(&htt_stats, sizeof(htt_stats));
  1689. qdf_nbuf_queue_init(&htt_stats.msg);
  1690. /* pull one completed stats from soc->htt_stats_msg and process */
  1691. qdf_spin_lock_bh(&soc->htt_stats.lock);
  1692. if (!soc->htt_stats.num_stats) {
  1693. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  1694. return;
  1695. }
  1696. while ((htt_msg = qdf_nbuf_queue_remove(&soc->htt_stats.msg)) != NULL) {
  1697. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1698. msg_word = msg_word + HTT_T2H_EXT_STATS_TLV_START_OFFSET;
  1699. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  1700. qdf_nbuf_queue_add(&htt_stats.msg, htt_msg);
  1701. /*
  1702. * Done bit signifies that this is the last T2H buffer in the
  1703. * stream of HTT EXT STATS message
  1704. */
  1705. if (done)
  1706. break;
  1707. }
  1708. rem_stats = --soc->htt_stats.num_stats;
  1709. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  1710. /* If there are more stats to process, schedule stats work again.
  1711. * Scheduling prior to processing ht_stats to queue with early
  1712. * index
  1713. */
  1714. if (rem_stats)
  1715. qdf_sched_work(0, &soc->htt_stats.work);
  1716. dp_process_htt_stat_msg(&htt_stats, soc);
  1717. }
  1718. /**
  1719. * dp_txrx_fw_stats_handler() - Function to process HTT EXT stats
  1720. * @soc: DP SOC handle
  1721. * @htt_t2h_msg: HTT message nbuf
  1722. *
  1723. * return:void
  1724. */
  1725. static inline void dp_txrx_fw_stats_handler(struct dp_soc *soc,
  1726. qdf_nbuf_t htt_t2h_msg)
  1727. {
  1728. uint8_t done;
  1729. qdf_nbuf_t msg_copy;
  1730. uint32_t *msg_word;
  1731. msg_word = (uint32_t *)qdf_nbuf_data(htt_t2h_msg);
  1732. msg_word = msg_word + 3;
  1733. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  1734. /*
  1735. * HTT EXT stats response comes as stream of TLVs which span over
  1736. * multiple T2H messages.
  1737. * The first message will carry length of the response.
  1738. * For rest of the messages length will be zero.
  1739. *
  1740. * Clone the T2H message buffer and store it in a list to process
  1741. * it later.
  1742. *
  1743. * The original T2H message buffers gets freed in the T2H HTT event
  1744. * handler
  1745. */
  1746. msg_copy = qdf_nbuf_clone(htt_t2h_msg);
  1747. if (!msg_copy) {
  1748. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  1749. "T2H messge clone failed for HTT EXT STATS");
  1750. goto error;
  1751. }
  1752. qdf_spin_lock_bh(&soc->htt_stats.lock);
  1753. qdf_nbuf_queue_add(&soc->htt_stats.msg, msg_copy);
  1754. /*
  1755. * Done bit signifies that this is the last T2H buffer in the stream of
  1756. * HTT EXT STATS message
  1757. */
  1758. if (done) {
  1759. soc->htt_stats.num_stats++;
  1760. qdf_sched_work(0, &soc->htt_stats.work);
  1761. }
  1762. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  1763. return;
  1764. error:
  1765. qdf_spin_lock_bh(&soc->htt_stats.lock);
  1766. while ((msg_copy = qdf_nbuf_queue_remove(&soc->htt_stats.msg))
  1767. != NULL) {
  1768. qdf_nbuf_free(msg_copy);
  1769. }
  1770. soc->htt_stats.num_stats = 0;
  1771. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  1772. return;
  1773. }
  1774. /*
  1775. * htt_soc_attach_target() - SOC level HTT setup
  1776. * @htt_soc: HTT SOC handle
  1777. *
  1778. * Return: 0 on success; error code on failure
  1779. */
  1780. int htt_soc_attach_target(struct htt_soc *htt_soc)
  1781. {
  1782. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  1783. return htt_h2t_ver_req_msg(soc);
  1784. }
  1785. void htt_set_htc_handle(struct htt_soc *htt_soc, HTC_HANDLE htc_soc)
  1786. {
  1787. htt_soc->htc_soc = htc_soc;
  1788. }
  1789. HTC_HANDLE htt_get_htc_handle(struct htt_soc *htt_soc)
  1790. {
  1791. return htt_soc->htc_soc;
  1792. }
  1793. struct htt_soc *htt_soc_attach(struct dp_soc *soc, HTC_HANDLE htc_handle)
  1794. {
  1795. int i;
  1796. int j;
  1797. int alloc_size = HTT_SW_UMAC_RING_IDX_MAX * sizeof(unsigned long);
  1798. struct htt_soc *htt_soc = NULL;
  1799. htt_soc = qdf_mem_malloc(sizeof(*htt_soc));
  1800. if (!htt_soc) {
  1801. dp_err("HTT attach failed");
  1802. return NULL;
  1803. }
  1804. for (i = 0; i < MAX_PDEV_CNT; i++) {
  1805. htt_soc->pdevid_tt[i].umac_ttt = qdf_mem_malloc(alloc_size);
  1806. if (!htt_soc->pdevid_tt[i].umac_ttt)
  1807. break;
  1808. qdf_mem_set(htt_soc->pdevid_tt[i].umac_ttt, alloc_size, -1);
  1809. htt_soc->pdevid_tt[i].lmac_ttt = qdf_mem_malloc(alloc_size);
  1810. if (!htt_soc->pdevid_tt[i].lmac_ttt) {
  1811. qdf_mem_free(htt_soc->pdevid_tt[i].umac_ttt);
  1812. break;
  1813. }
  1814. qdf_mem_set(htt_soc->pdevid_tt[i].lmac_ttt, alloc_size, -1);
  1815. }
  1816. if (i != MAX_PDEV_CNT) {
  1817. for (j = 0; j < i; j++) {
  1818. qdf_mem_free(htt_soc->pdevid_tt[j].umac_ttt);
  1819. qdf_mem_free(htt_soc->pdevid_tt[j].lmac_ttt);
  1820. }
  1821. qdf_mem_free(htt_soc);
  1822. return NULL;
  1823. }
  1824. htt_soc->dp_soc = soc;
  1825. htt_soc->htc_soc = htc_handle;
  1826. HTT_TX_MUTEX_INIT(&htt_soc->htt_tx_mutex);
  1827. return htt_soc;
  1828. }
  1829. #if defined(WDI_EVENT_ENABLE) && \
  1830. !defined(REMOVE_PKT_LOG)
  1831. /*
  1832. * dp_pktlog_msg_handler() - Pktlog msg handler
  1833. * @htt_soc: HTT SOC handle
  1834. * @msg_word: Pointer to payload
  1835. *
  1836. * Return: None
  1837. */
  1838. static void
  1839. dp_pktlog_msg_handler(struct htt_soc *soc,
  1840. uint32_t *msg_word)
  1841. {
  1842. uint8_t pdev_id;
  1843. uint8_t target_pdev_id;
  1844. uint32_t *pl_hdr;
  1845. target_pdev_id = HTT_T2H_PKTLOG_PDEV_ID_GET(*msg_word);
  1846. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  1847. target_pdev_id);
  1848. pl_hdr = (msg_word + 1);
  1849. dp_wdi_event_handler(WDI_EVENT_OFFLOAD_ALL, soc->dp_soc,
  1850. pl_hdr, HTT_INVALID_PEER, WDI_NO_VAL,
  1851. pdev_id);
  1852. }
  1853. #else
  1854. static void
  1855. dp_pktlog_msg_handler(struct htt_soc *soc,
  1856. uint32_t *msg_word)
  1857. {
  1858. }
  1859. #endif
  1860. /*
  1861. * time_allow_print() - time allow print
  1862. * @htt_ring_tt: ringi_id array of timestamps
  1863. * @ring_id: ring_id (index)
  1864. *
  1865. * Return: 1 for successfully saving timestamp in array
  1866. * and 0 for timestamp falling within 2 seconds after last one
  1867. */
  1868. static bool time_allow_print(unsigned long *htt_ring_tt, u_int8_t ring_id)
  1869. {
  1870. unsigned long tstamp;
  1871. unsigned long delta;
  1872. tstamp = qdf_get_system_timestamp();
  1873. if (!htt_ring_tt)
  1874. return 0; //unable to print backpressure messages
  1875. if (htt_ring_tt[ring_id] == -1) {
  1876. htt_ring_tt[ring_id] = tstamp;
  1877. return 1;
  1878. }
  1879. delta = tstamp - htt_ring_tt[ring_id];
  1880. if (delta >= 2000) {
  1881. htt_ring_tt[ring_id] = tstamp;
  1882. return 1;
  1883. }
  1884. return 0;
  1885. }
  1886. static void dp_htt_alert_print(enum htt_t2h_msg_type msg_type,
  1887. struct dp_pdev *pdev, u_int8_t ring_id,
  1888. u_int16_t hp_idx, u_int16_t tp_idx,
  1889. u_int32_t bkp_time, char *ring_stype)
  1890. {
  1891. dp_alert("seq_num %u msg_type: %d pdev_id: %d ring_type: %s ",
  1892. pdev->bkp_stats.seq_num, msg_type, pdev->pdev_id, ring_stype);
  1893. dp_alert("ring_id: %d hp_idx: %d tp_idx: %d bkpressure_time_ms: %d ",
  1894. ring_id, hp_idx, tp_idx, bkp_time);
  1895. }
  1896. /**
  1897. * dp_get_srng_ring_state_from_hal(): Get hal level ring stats
  1898. * @soc: DP_SOC handle
  1899. * @srng: DP_SRNG handle
  1900. * @ring_type: srng src/dst ring
  1901. *
  1902. * Return: void
  1903. */
  1904. static QDF_STATUS
  1905. dp_get_srng_ring_state_from_hal(struct dp_soc *soc,
  1906. struct dp_pdev *pdev,
  1907. struct dp_srng *srng,
  1908. enum hal_ring_type ring_type,
  1909. struct dp_srng_ring_state *state)
  1910. {
  1911. struct hal_soc *hal_soc;
  1912. if (!soc || !srng || !srng->hal_srng || !state)
  1913. return QDF_STATUS_E_INVAL;
  1914. hal_soc = (struct hal_soc *)soc->hal_soc;
  1915. hal_get_sw_hptp(soc->hal_soc, srng->hal_srng, &state->sw_tail,
  1916. &state->sw_head);
  1917. hal_get_hw_hptp(soc->hal_soc, srng->hal_srng, &state->hw_head,
  1918. &state->hw_tail, ring_type);
  1919. state->ring_type = ring_type;
  1920. return QDF_STATUS_SUCCESS;
  1921. }
  1922. #ifdef QCA_MONITOR_PKT_SUPPORT
  1923. static void
  1924. dp_queue_mon_ring_stats(struct dp_pdev *pdev,
  1925. int lmac_id, uint32_t *num_srng,
  1926. struct dp_soc_srngs_state *soc_srngs_state)
  1927. {
  1928. QDF_STATUS status;
  1929. if (pdev->soc->wlan_cfg_ctx->rxdma1_enable) {
  1930. status = dp_get_srng_ring_state_from_hal
  1931. (pdev->soc, pdev,
  1932. &pdev->soc->rxdma_mon_buf_ring[lmac_id],
  1933. RXDMA_MONITOR_BUF,
  1934. &soc_srngs_state->ring_state[*num_srng]);
  1935. if (status == QDF_STATUS_SUCCESS)
  1936. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  1937. status = dp_get_srng_ring_state_from_hal
  1938. (pdev->soc, pdev,
  1939. &pdev->soc->rxdma_mon_dst_ring[lmac_id],
  1940. RXDMA_MONITOR_DST,
  1941. &soc_srngs_state->ring_state[*num_srng]);
  1942. if (status == QDF_STATUS_SUCCESS)
  1943. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  1944. status = dp_get_srng_ring_state_from_hal
  1945. (pdev->soc, pdev,
  1946. &pdev->soc->rxdma_mon_desc_ring[lmac_id],
  1947. RXDMA_MONITOR_DESC,
  1948. &soc_srngs_state->ring_state[*num_srng]);
  1949. if (status == QDF_STATUS_SUCCESS)
  1950. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  1951. }
  1952. }
  1953. #else
  1954. static void
  1955. dp_queue_mon_ring_stats(struct dp_pdev *pdev,
  1956. int lmac_id, uint32_t *num_srng,
  1957. struct dp_soc_srngs_state *soc_srngs_state)
  1958. {
  1959. }
  1960. #endif
  1961. /**
  1962. * dp_queue_srng_ring_stats(): Print pdev hal level ring stats
  1963. * @pdev: DP_pdev handle
  1964. *
  1965. * Return: void
  1966. */
  1967. static void dp_queue_ring_stats(struct dp_pdev *pdev)
  1968. {
  1969. uint32_t i;
  1970. int mac_id;
  1971. int lmac_id;
  1972. uint32_t j = 0;
  1973. struct dp_soc_srngs_state * soc_srngs_state = NULL;
  1974. struct dp_soc_srngs_state *drop_srngs_state = NULL;
  1975. QDF_STATUS status;
  1976. soc_srngs_state = qdf_mem_malloc(sizeof(struct dp_soc_srngs_state));
  1977. if (!soc_srngs_state) {
  1978. dp_htt_alert("Memory alloc failed for back pressure event");
  1979. return;
  1980. }
  1981. status = dp_get_srng_ring_state_from_hal
  1982. (pdev->soc, pdev,
  1983. &pdev->soc->reo_exception_ring,
  1984. REO_EXCEPTION,
  1985. &soc_srngs_state->ring_state[j]);
  1986. if (status == QDF_STATUS_SUCCESS)
  1987. qdf_assert_always(++j < DP_MAX_SRNGS);
  1988. status = dp_get_srng_ring_state_from_hal
  1989. (pdev->soc, pdev,
  1990. &pdev->soc->reo_reinject_ring,
  1991. REO_REINJECT,
  1992. &soc_srngs_state->ring_state[j]);
  1993. if (status == QDF_STATUS_SUCCESS)
  1994. qdf_assert_always(++j < DP_MAX_SRNGS);
  1995. status = dp_get_srng_ring_state_from_hal
  1996. (pdev->soc, pdev,
  1997. &pdev->soc->reo_cmd_ring,
  1998. REO_CMD,
  1999. &soc_srngs_state->ring_state[j]);
  2000. if (status == QDF_STATUS_SUCCESS)
  2001. qdf_assert_always(++j < DP_MAX_SRNGS);
  2002. status = dp_get_srng_ring_state_from_hal
  2003. (pdev->soc, pdev,
  2004. &pdev->soc->reo_status_ring,
  2005. REO_STATUS,
  2006. &soc_srngs_state->ring_state[j]);
  2007. if (status == QDF_STATUS_SUCCESS)
  2008. qdf_assert_always(++j < DP_MAX_SRNGS);
  2009. status = dp_get_srng_ring_state_from_hal
  2010. (pdev->soc, pdev,
  2011. &pdev->soc->rx_rel_ring,
  2012. WBM2SW_RELEASE,
  2013. &soc_srngs_state->ring_state[j]);
  2014. if (status == QDF_STATUS_SUCCESS)
  2015. qdf_assert_always(++j < DP_MAX_SRNGS);
  2016. status = dp_get_srng_ring_state_from_hal
  2017. (pdev->soc, pdev,
  2018. &pdev->soc->tcl_cmd_credit_ring,
  2019. TCL_CMD_CREDIT,
  2020. &soc_srngs_state->ring_state[j]);
  2021. if (status == QDF_STATUS_SUCCESS)
  2022. qdf_assert_always(++j < DP_MAX_SRNGS);
  2023. status = dp_get_srng_ring_state_from_hal
  2024. (pdev->soc, pdev,
  2025. &pdev->soc->tcl_status_ring,
  2026. TCL_STATUS,
  2027. &soc_srngs_state->ring_state[j]);
  2028. if (status == QDF_STATUS_SUCCESS)
  2029. qdf_assert_always(++j < DP_MAX_SRNGS);
  2030. status = dp_get_srng_ring_state_from_hal
  2031. (pdev->soc, pdev,
  2032. &pdev->soc->wbm_desc_rel_ring,
  2033. SW2WBM_RELEASE,
  2034. &soc_srngs_state->ring_state[j]);
  2035. if (status == QDF_STATUS_SUCCESS)
  2036. qdf_assert_always(++j < DP_MAX_SRNGS);
  2037. for (i = 0; i < MAX_REO_DEST_RINGS; i++) {
  2038. status = dp_get_srng_ring_state_from_hal
  2039. (pdev->soc, pdev,
  2040. &pdev->soc->reo_dest_ring[i],
  2041. REO_DST,
  2042. &soc_srngs_state->ring_state[j]);
  2043. if (status == QDF_STATUS_SUCCESS)
  2044. qdf_assert_always(++j < DP_MAX_SRNGS);
  2045. }
  2046. for (i = 0; i < pdev->soc->num_tcl_data_rings; i++) {
  2047. status = dp_get_srng_ring_state_from_hal
  2048. (pdev->soc, pdev,
  2049. &pdev->soc->tcl_data_ring[i],
  2050. TCL_DATA,
  2051. &soc_srngs_state->ring_state[j]);
  2052. if (status == QDF_STATUS_SUCCESS)
  2053. qdf_assert_always(++j < DP_MAX_SRNGS);
  2054. }
  2055. for (i = 0; i < MAX_TCL_DATA_RINGS; i++) {
  2056. status = dp_get_srng_ring_state_from_hal
  2057. (pdev->soc, pdev,
  2058. &pdev->soc->tx_comp_ring[i],
  2059. WBM2SW_RELEASE,
  2060. &soc_srngs_state->ring_state[j]);
  2061. if (status == QDF_STATUS_SUCCESS)
  2062. qdf_assert_always(++j < DP_MAX_SRNGS);
  2063. }
  2064. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc, 0, pdev->pdev_id);
  2065. status = dp_get_srng_ring_state_from_hal
  2066. (pdev->soc, pdev,
  2067. &pdev->soc->rx_refill_buf_ring
  2068. [lmac_id],
  2069. RXDMA_BUF,
  2070. &soc_srngs_state->ring_state[j]);
  2071. if (status == QDF_STATUS_SUCCESS)
  2072. qdf_assert_always(++j < DP_MAX_SRNGS);
  2073. status = dp_get_srng_ring_state_from_hal
  2074. (pdev->soc, pdev,
  2075. &pdev->rx_refill_buf_ring2,
  2076. RXDMA_BUF,
  2077. &soc_srngs_state->ring_state[j]);
  2078. if (status == QDF_STATUS_SUCCESS)
  2079. qdf_assert_always(++j < DP_MAX_SRNGS);
  2080. for (i = 0; i < MAX_RX_MAC_RINGS; i++) {
  2081. dp_get_srng_ring_state_from_hal
  2082. (pdev->soc, pdev,
  2083. &pdev->rx_mac_buf_ring[i],
  2084. RXDMA_BUF,
  2085. &soc_srngs_state->ring_state[j]);
  2086. if (status == QDF_STATUS_SUCCESS)
  2087. qdf_assert_always(++j < DP_MAX_SRNGS);
  2088. }
  2089. for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
  2090. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc,
  2091. mac_id, pdev->pdev_id);
  2092. dp_queue_mon_ring_stats(pdev, lmac_id, &j,
  2093. soc_srngs_state);
  2094. status = dp_get_srng_ring_state_from_hal
  2095. (pdev->soc, pdev,
  2096. &pdev->soc->rxdma_mon_status_ring[lmac_id],
  2097. RXDMA_MONITOR_STATUS,
  2098. &soc_srngs_state->ring_state[j]);
  2099. if (status == QDF_STATUS_SUCCESS)
  2100. qdf_assert_always(++j < DP_MAX_SRNGS);
  2101. }
  2102. for (i = 0; i < NUM_RXDMA_RINGS_PER_PDEV; i++) {
  2103. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc,
  2104. i, pdev->pdev_id);
  2105. status = dp_get_srng_ring_state_from_hal
  2106. (pdev->soc, pdev,
  2107. &pdev->soc->rxdma_err_dst_ring
  2108. [lmac_id],
  2109. RXDMA_DST,
  2110. &soc_srngs_state->ring_state[j]);
  2111. if (status == QDF_STATUS_SUCCESS)
  2112. qdf_assert_always(++j < DP_MAX_SRNGS);
  2113. }
  2114. soc_srngs_state->max_ring_id = j;
  2115. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  2116. soc_srngs_state->seq_num = pdev->bkp_stats.seq_num;
  2117. if (pdev->bkp_stats.queue_depth >= HTT_BKP_STATS_MAX_QUEUE_DEPTH) {
  2118. drop_srngs_state = TAILQ_FIRST(&pdev->bkp_stats.list);
  2119. qdf_assert_always(drop_srngs_state);
  2120. TAILQ_REMOVE(&pdev->bkp_stats.list, drop_srngs_state,
  2121. list_elem);
  2122. qdf_mem_free(drop_srngs_state);
  2123. pdev->bkp_stats.queue_depth--;
  2124. }
  2125. pdev->bkp_stats.queue_depth++;
  2126. TAILQ_INSERT_TAIL(&pdev->bkp_stats.list, soc_srngs_state,
  2127. list_elem);
  2128. pdev->bkp_stats.seq_num++;
  2129. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  2130. qdf_queue_work(0, pdev->bkp_stats.work_queue,
  2131. &pdev->bkp_stats.work);
  2132. }
  2133. /*
  2134. * dp_htt_bkp_event_alert() - htt backpressure event alert
  2135. * @msg_word: htt packet context
  2136. * @htt_soc: HTT SOC handle
  2137. *
  2138. * Return: after attempting to print stats
  2139. */
  2140. static void dp_htt_bkp_event_alert(u_int32_t *msg_word, struct htt_soc *soc)
  2141. {
  2142. u_int8_t ring_type;
  2143. u_int8_t pdev_id;
  2144. uint8_t target_pdev_id;
  2145. u_int8_t ring_id;
  2146. u_int16_t hp_idx;
  2147. u_int16_t tp_idx;
  2148. u_int32_t bkp_time;
  2149. enum htt_t2h_msg_type msg_type;
  2150. struct dp_soc *dpsoc;
  2151. struct dp_pdev *pdev;
  2152. struct dp_htt_timestamp *radio_tt;
  2153. if (!soc)
  2154. return;
  2155. dpsoc = (struct dp_soc *)soc->dp_soc;
  2156. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  2157. ring_type = HTT_T2H_RX_BKPRESSURE_RING_TYPE_GET(*msg_word);
  2158. target_pdev_id = HTT_T2H_RX_BKPRESSURE_PDEV_ID_GET(*msg_word);
  2159. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2160. target_pdev_id);
  2161. if (pdev_id >= MAX_PDEV_CNT) {
  2162. dp_htt_debug("%pK: pdev id %d is invalid", soc, pdev_id);
  2163. return;
  2164. }
  2165. pdev = (struct dp_pdev *)dpsoc->pdev_list[pdev_id];
  2166. ring_id = HTT_T2H_RX_BKPRESSURE_RINGID_GET(*msg_word);
  2167. hp_idx = HTT_T2H_RX_BKPRESSURE_HEAD_IDX_GET(*(msg_word + 1));
  2168. tp_idx = HTT_T2H_RX_BKPRESSURE_TAIL_IDX_GET(*(msg_word + 1));
  2169. bkp_time = HTT_T2H_RX_BKPRESSURE_TIME_MS_GET(*(msg_word + 2));
  2170. radio_tt = &soc->pdevid_tt[pdev_id];
  2171. switch (ring_type) {
  2172. case HTT_SW_RING_TYPE_UMAC:
  2173. if (!time_allow_print(radio_tt->umac_ttt, ring_id))
  2174. return;
  2175. dp_htt_alert_print(msg_type, pdev, ring_id, hp_idx, tp_idx,
  2176. bkp_time, "HTT_SW_RING_TYPE_UMAC");
  2177. break;
  2178. case HTT_SW_RING_TYPE_LMAC:
  2179. if (!time_allow_print(radio_tt->lmac_ttt, ring_id))
  2180. return;
  2181. dp_htt_alert_print(msg_type, pdev, ring_id, hp_idx, tp_idx,
  2182. bkp_time, "HTT_SW_RING_TYPE_LMAC");
  2183. break;
  2184. default:
  2185. dp_htt_alert_print(msg_type, pdev, ring_id, hp_idx, tp_idx,
  2186. bkp_time, "UNKNOWN");
  2187. break;
  2188. }
  2189. dp_queue_ring_stats(pdev);
  2190. }
  2191. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  2192. /*
  2193. * dp_offload_ind_handler() - offload msg handler
  2194. * @htt_soc: HTT SOC handle
  2195. * @msg_word: Pointer to payload
  2196. *
  2197. * Return: None
  2198. */
  2199. static void
  2200. dp_offload_ind_handler(struct htt_soc *soc, uint32_t *msg_word)
  2201. {
  2202. u_int8_t pdev_id;
  2203. u_int8_t target_pdev_id;
  2204. target_pdev_id = HTT_T2H_PPDU_STATS_PDEV_ID_GET(*msg_word);
  2205. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2206. target_pdev_id);
  2207. dp_wdi_event_handler(WDI_EVENT_PKT_CAPTURE_OFFLOAD_TX_DATA, soc->dp_soc,
  2208. msg_word, HTT_INVALID_VDEV, WDI_NO_VAL,
  2209. pdev_id);
  2210. }
  2211. #else
  2212. static void
  2213. dp_offload_ind_handler(struct htt_soc *soc, uint32_t *msg_word)
  2214. {
  2215. }
  2216. #endif
  2217. #ifdef WLAN_FEATURE_11BE_MLO
  2218. static void dp_htt_mlo_peer_map_handler(struct htt_soc *soc,
  2219. uint32_t *msg_word)
  2220. {
  2221. uint8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  2222. uint8_t *mlo_peer_mac_addr;
  2223. uint16_t mlo_peer_id;
  2224. uint8_t num_links;
  2225. struct dp_mlo_flow_override_info mlo_flow_info[DP_MLO_FLOW_INFO_MAX];
  2226. mlo_peer_id = HTT_RX_MLO_PEER_MAP_MLO_PEER_ID_GET(*msg_word);
  2227. num_links =
  2228. HTT_RX_MLO_PEER_MAP_NUM_LOGICAL_LINKS_GET(*msg_word);
  2229. mlo_peer_mac_addr =
  2230. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  2231. &mac_addr_deswizzle_buf[0]);
  2232. mlo_flow_info[0].ast_idx =
  2233. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2234. mlo_flow_info[0].ast_idx_valid =
  2235. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2236. mlo_flow_info[0].chip_id =
  2237. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2238. mlo_flow_info[0].tidmask =
  2239. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2240. mlo_flow_info[0].cache_set_num =
  2241. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2242. mlo_flow_info[1].ast_idx =
  2243. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2244. mlo_flow_info[1].ast_idx_valid =
  2245. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2246. mlo_flow_info[1].chip_id =
  2247. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2248. mlo_flow_info[1].tidmask =
  2249. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2250. mlo_flow_info[1].cache_set_num =
  2251. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2252. mlo_flow_info[2].ast_idx =
  2253. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2254. mlo_flow_info[2].ast_idx_valid =
  2255. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2256. mlo_flow_info[2].chip_id =
  2257. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2258. mlo_flow_info[2].tidmask =
  2259. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2260. mlo_flow_info[2].cache_set_num =
  2261. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2262. dp_rx_mlo_peer_map_handler(soc->dp_soc, mlo_peer_id,
  2263. mlo_peer_mac_addr,
  2264. mlo_flow_info);
  2265. }
  2266. static void dp_htt_mlo_peer_unmap_handler(struct htt_soc *soc,
  2267. uint32_t *msg_word)
  2268. {
  2269. uint16_t mlo_peer_id;
  2270. mlo_peer_id = HTT_RX_MLO_PEER_UNMAP_MLO_PEER_ID_GET(*msg_word);
  2271. dp_rx_mlo_peer_unmap_handler(soc->dp_soc, mlo_peer_id);
  2272. }
  2273. #else
  2274. static void dp_htt_mlo_peer_map_handler(struct htt_soc *soc,
  2275. uint32_t *msg_word)
  2276. {
  2277. qdf_assert_always(0);
  2278. }
  2279. static void dp_htt_mlo_peer_unmap_handler(struct htt_soc *soc,
  2280. uint32_t *msg_word)
  2281. {
  2282. qdf_assert_always(0);
  2283. }
  2284. #endif
  2285. /*
  2286. * dp_htt_t2h_msg_handler() - Generic Target to host Msg/event handler
  2287. * @context: Opaque context (HTT SOC handle)
  2288. * @pkt: HTC packet
  2289. */
  2290. static void dp_htt_t2h_msg_handler(void *context, HTC_PACKET *pkt)
  2291. {
  2292. struct htt_soc *soc = (struct htt_soc *) context;
  2293. qdf_nbuf_t htt_t2h_msg = (qdf_nbuf_t) pkt->pPktContext;
  2294. u_int32_t *msg_word;
  2295. enum htt_t2h_msg_type msg_type;
  2296. bool free_buf = true;
  2297. /* check for successful message reception */
  2298. if (pkt->Status != QDF_STATUS_SUCCESS) {
  2299. if (pkt->Status != QDF_STATUS_E_CANCELED)
  2300. soc->stats.htc_err_cnt++;
  2301. qdf_nbuf_free(htt_t2h_msg);
  2302. return;
  2303. }
  2304. /* TODO: Check if we should pop the HTC/HTT header alignment padding */
  2305. msg_word = (u_int32_t *) qdf_nbuf_data(htt_t2h_msg);
  2306. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  2307. htt_event_record(soc->htt_logger_handle,
  2308. msg_type, (uint8_t *)msg_word);
  2309. switch (msg_type) {
  2310. case HTT_T2H_MSG_TYPE_BKPRESSURE_EVENT_IND:
  2311. {
  2312. dp_htt_bkp_event_alert(msg_word, soc);
  2313. break;
  2314. }
  2315. case HTT_T2H_MSG_TYPE_PEER_MAP:
  2316. {
  2317. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  2318. u_int8_t *peer_mac_addr;
  2319. u_int16_t peer_id;
  2320. u_int16_t hw_peer_id;
  2321. u_int8_t vdev_id;
  2322. u_int8_t is_wds;
  2323. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  2324. peer_id = HTT_RX_PEER_MAP_PEER_ID_GET(*msg_word);
  2325. hw_peer_id =
  2326. HTT_RX_PEER_MAP_HW_PEER_ID_GET(*(msg_word+2));
  2327. vdev_id = HTT_RX_PEER_MAP_VDEV_ID_GET(*msg_word);
  2328. peer_mac_addr = htt_t2h_mac_addr_deswizzle(
  2329. (u_int8_t *) (msg_word+1),
  2330. &mac_addr_deswizzle_buf[0]);
  2331. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2332. QDF_TRACE_LEVEL_INFO,
  2333. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  2334. peer_id, vdev_id);
  2335. /*
  2336. * check if peer already exists for this peer_id, if so
  2337. * this peer map event is in response for a wds peer add
  2338. * wmi command sent during wds source port learning.
  2339. * in this case just add the ast entry to the existing
  2340. * peer ast_list.
  2341. */
  2342. is_wds = !!(dpsoc->peer_id_to_obj_map[peer_id]);
  2343. dp_rx_peer_map_handler(soc->dp_soc, peer_id, hw_peer_id,
  2344. vdev_id, peer_mac_addr, 0,
  2345. is_wds);
  2346. break;
  2347. }
  2348. case HTT_T2H_MSG_TYPE_PEER_UNMAP:
  2349. {
  2350. u_int16_t peer_id;
  2351. u_int8_t vdev_id;
  2352. u_int8_t mac_addr[QDF_MAC_ADDR_SIZE] = {0};
  2353. peer_id = HTT_RX_PEER_UNMAP_PEER_ID_GET(*msg_word);
  2354. vdev_id = HTT_RX_PEER_UNMAP_VDEV_ID_GET(*msg_word);
  2355. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  2356. vdev_id, mac_addr, 0,
  2357. DP_PEER_WDS_COUNT_INVALID);
  2358. break;
  2359. }
  2360. case HTT_T2H_MSG_TYPE_SEC_IND:
  2361. {
  2362. u_int16_t peer_id;
  2363. enum cdp_sec_type sec_type;
  2364. int is_unicast;
  2365. peer_id = HTT_SEC_IND_PEER_ID_GET(*msg_word);
  2366. sec_type = HTT_SEC_IND_SEC_TYPE_GET(*msg_word);
  2367. is_unicast = HTT_SEC_IND_UNICAST_GET(*msg_word);
  2368. /* point to the first part of the Michael key */
  2369. msg_word++;
  2370. dp_rx_sec_ind_handler(
  2371. soc->dp_soc, peer_id, sec_type, is_unicast,
  2372. msg_word, msg_word + 2);
  2373. break;
  2374. }
  2375. case HTT_T2H_MSG_TYPE_PPDU_STATS_IND:
  2376. {
  2377. free_buf =
  2378. dp_monitor_ppdu_stats_ind_handler(soc,
  2379. msg_word,
  2380. htt_t2h_msg);
  2381. break;
  2382. }
  2383. case HTT_T2H_MSG_TYPE_PKTLOG:
  2384. {
  2385. dp_pktlog_msg_handler(soc, msg_word);
  2386. break;
  2387. }
  2388. case HTT_T2H_MSG_TYPE_VERSION_CONF:
  2389. {
  2390. /*
  2391. * HTC maintains runtime pm count for H2T messages that
  2392. * have a response msg from FW. This count ensures that
  2393. * in the case FW does not sent out the response or host
  2394. * did not process this indication runtime_put happens
  2395. * properly in the cleanup path.
  2396. */
  2397. if (htc_dec_return_runtime_cnt(soc->htc_soc) >= 0)
  2398. htc_pm_runtime_put(soc->htc_soc);
  2399. else
  2400. soc->stats.htt_ver_req_put_skip++;
  2401. soc->tgt_ver.major = HTT_VER_CONF_MAJOR_GET(*msg_word);
  2402. soc->tgt_ver.minor = HTT_VER_CONF_MINOR_GET(*msg_word);
  2403. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW,
  2404. "target uses HTT version %d.%d; host uses %d.%d",
  2405. soc->tgt_ver.major, soc->tgt_ver.minor,
  2406. HTT_CURRENT_VERSION_MAJOR,
  2407. HTT_CURRENT_VERSION_MINOR);
  2408. if (soc->tgt_ver.major != HTT_CURRENT_VERSION_MAJOR) {
  2409. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2410. QDF_TRACE_LEVEL_WARN,
  2411. "*** Incompatible host/target HTT versions!");
  2412. }
  2413. /* abort if the target is incompatible with the host */
  2414. qdf_assert(soc->tgt_ver.major ==
  2415. HTT_CURRENT_VERSION_MAJOR);
  2416. if (soc->tgt_ver.minor != HTT_CURRENT_VERSION_MINOR) {
  2417. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2418. QDF_TRACE_LEVEL_INFO_LOW,
  2419. "*** Warning: host/target HTT versions"
  2420. " are different, though compatible!");
  2421. }
  2422. break;
  2423. }
  2424. case HTT_T2H_MSG_TYPE_RX_ADDBA:
  2425. {
  2426. uint16_t peer_id;
  2427. uint8_t tid;
  2428. uint8_t win_sz;
  2429. uint16_t status;
  2430. struct dp_peer *peer;
  2431. /*
  2432. * Update REO Queue Desc with new values
  2433. */
  2434. peer_id = HTT_RX_ADDBA_PEER_ID_GET(*msg_word);
  2435. tid = HTT_RX_ADDBA_TID_GET(*msg_word);
  2436. win_sz = HTT_RX_ADDBA_WIN_SIZE_GET(*msg_word);
  2437. peer = dp_peer_get_ref_by_id(soc->dp_soc, peer_id,
  2438. DP_MOD_ID_HTT);
  2439. /*
  2440. * Window size needs to be incremented by 1
  2441. * since fw needs to represent a value of 256
  2442. * using just 8 bits
  2443. */
  2444. if (peer) {
  2445. status = dp_addba_requestprocess_wifi3(
  2446. (struct cdp_soc_t *)soc->dp_soc,
  2447. peer->mac_addr.raw, peer->vdev->vdev_id,
  2448. 0, tid, 0, win_sz + 1, 0xffff);
  2449. /*
  2450. * If PEER_LOCK_REF_PROTECT enbled dec ref
  2451. * which is inc by dp_peer_get_ref_by_id
  2452. */
  2453. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  2454. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2455. QDF_TRACE_LEVEL_INFO,
  2456. FL("PeerID %d BAW %d TID %d stat %d"),
  2457. peer_id, win_sz, tid, status);
  2458. } else {
  2459. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2460. QDF_TRACE_LEVEL_ERROR,
  2461. FL("Peer not found peer id %d"),
  2462. peer_id);
  2463. }
  2464. break;
  2465. }
  2466. case HTT_T2H_MSG_TYPE_EXT_STATS_CONF:
  2467. {
  2468. dp_txrx_fw_stats_handler(soc->dp_soc, htt_t2h_msg);
  2469. break;
  2470. }
  2471. case HTT_T2H_MSG_TYPE_PEER_MAP_V2:
  2472. {
  2473. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  2474. u_int8_t *peer_mac_addr;
  2475. u_int16_t peer_id;
  2476. u_int16_t hw_peer_id;
  2477. u_int8_t vdev_id;
  2478. bool is_wds;
  2479. u_int16_t ast_hash;
  2480. struct dp_ast_flow_override_info ast_flow_info;
  2481. qdf_mem_set(&ast_flow_info, 0,
  2482. sizeof(struct dp_ast_flow_override_info));
  2483. peer_id = HTT_RX_PEER_MAP_V2_SW_PEER_ID_GET(*msg_word);
  2484. hw_peer_id =
  2485. HTT_RX_PEER_MAP_V2_HW_PEER_ID_GET(*(msg_word + 2));
  2486. vdev_id = HTT_RX_PEER_MAP_V2_VDEV_ID_GET(*msg_word);
  2487. peer_mac_addr =
  2488. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  2489. &mac_addr_deswizzle_buf[0]);
  2490. is_wds =
  2491. HTT_RX_PEER_MAP_V2_NEXT_HOP_GET(*(msg_word + 3));
  2492. ast_hash =
  2493. HTT_RX_PEER_MAP_V2_AST_HASH_VALUE_GET(*(msg_word + 3));
  2494. /*
  2495. * Update 4 ast_index per peer, ast valid mask
  2496. * and TID flow valid mask.
  2497. * AST valid mask is 3 bit field corresponds to
  2498. * ast_index[3:1]. ast_index 0 is always valid.
  2499. */
  2500. ast_flow_info.ast_valid_mask =
  2501. HTT_RX_PEER_MAP_V2_AST_VALID_MASK_GET(*(msg_word + 3));
  2502. ast_flow_info.ast_idx[0] = hw_peer_id;
  2503. ast_flow_info.ast_flow_mask[0] =
  2504. HTT_RX_PEER_MAP_V2_AST_0_FLOW_MASK_GET(*(msg_word + 4));
  2505. ast_flow_info.ast_idx[1] =
  2506. HTT_RX_PEER_MAP_V2_AST_INDEX_1_GET(*(msg_word + 4));
  2507. ast_flow_info.ast_flow_mask[1] =
  2508. HTT_RX_PEER_MAP_V2_AST_1_FLOW_MASK_GET(*(msg_word + 4));
  2509. ast_flow_info.ast_idx[2] =
  2510. HTT_RX_PEER_MAP_V2_AST_INDEX_2_GET(*(msg_word + 5));
  2511. ast_flow_info.ast_flow_mask[2] =
  2512. HTT_RX_PEER_MAP_V2_AST_2_FLOW_MASK_GET(*(msg_word + 4));
  2513. ast_flow_info.ast_idx[3] =
  2514. HTT_RX_PEER_MAP_V2_AST_INDEX_3_GET(*(msg_word + 6));
  2515. ast_flow_info.ast_flow_mask[3] =
  2516. HTT_RX_PEER_MAP_V2_AST_3_FLOW_MASK_GET(*(msg_word + 4));
  2517. /*
  2518. * TID valid mask is applicable only
  2519. * for HI and LOW priority flows.
  2520. * tid_valid_mas is 8 bit field corresponds
  2521. * to TID[7:0]
  2522. */
  2523. ast_flow_info.tid_valid_low_pri_mask =
  2524. HTT_RX_PEER_MAP_V2_TID_VALID_LOW_PRI_GET(*(msg_word + 5));
  2525. ast_flow_info.tid_valid_hi_pri_mask =
  2526. HTT_RX_PEER_MAP_V2_TID_VALID_HI_PRI_GET(*(msg_word + 5));
  2527. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2528. QDF_TRACE_LEVEL_INFO,
  2529. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  2530. peer_id, vdev_id);
  2531. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2532. QDF_TRACE_LEVEL_INFO,
  2533. "ast_idx[0] %d ast_idx[1] %d ast_idx[2] %d ast_idx[3] %d n",
  2534. ast_flow_info.ast_idx[0],
  2535. ast_flow_info.ast_idx[1],
  2536. ast_flow_info.ast_idx[2],
  2537. ast_flow_info.ast_idx[3]);
  2538. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  2539. hw_peer_id, vdev_id,
  2540. peer_mac_addr, ast_hash,
  2541. is_wds);
  2542. /*
  2543. * Update ast indexes for flow override support
  2544. * Applicable only for non wds peers
  2545. */
  2546. if (!soc->dp_soc->ast_offload_support)
  2547. dp_peer_ast_index_flow_queue_map_create(
  2548. soc->dp_soc, is_wds,
  2549. peer_id, peer_mac_addr,
  2550. &ast_flow_info);
  2551. break;
  2552. }
  2553. case HTT_T2H_MSG_TYPE_PEER_UNMAP_V2:
  2554. {
  2555. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  2556. u_int8_t *mac_addr;
  2557. u_int16_t peer_id;
  2558. u_int8_t vdev_id;
  2559. u_int8_t is_wds;
  2560. u_int32_t free_wds_count;
  2561. peer_id =
  2562. HTT_RX_PEER_UNMAP_V2_SW_PEER_ID_GET(*msg_word);
  2563. vdev_id = HTT_RX_PEER_UNMAP_V2_VDEV_ID_GET(*msg_word);
  2564. mac_addr =
  2565. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  2566. &mac_addr_deswizzle_buf[0]);
  2567. is_wds =
  2568. HTT_RX_PEER_UNMAP_V2_NEXT_HOP_GET(*(msg_word + 2));
  2569. free_wds_count =
  2570. HTT_RX_PEER_UNMAP_V2_PEER_WDS_FREE_COUNT_GET(*(msg_word + 4));
  2571. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2572. QDF_TRACE_LEVEL_INFO,
  2573. "HTT_T2H_MSG_TYPE_PEER_UNMAP msg for peer id %d vdev id %d n",
  2574. peer_id, vdev_id);
  2575. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  2576. vdev_id, mac_addr,
  2577. is_wds, free_wds_count);
  2578. break;
  2579. }
  2580. case HTT_T2H_MSG_TYPE_RX_DELBA:
  2581. {
  2582. uint16_t peer_id;
  2583. uint8_t tid;
  2584. uint8_t win_sz;
  2585. QDF_STATUS status;
  2586. peer_id = HTT_RX_DELBA_PEER_ID_GET(*msg_word);
  2587. tid = HTT_RX_DELBA_TID_GET(*msg_word);
  2588. win_sz = HTT_RX_DELBA_WIN_SIZE_GET(*msg_word);
  2589. status = dp_rx_delba_ind_handler(
  2590. soc->dp_soc,
  2591. peer_id, tid, win_sz);
  2592. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2593. QDF_TRACE_LEVEL_INFO,
  2594. FL("DELBA PeerID %d BAW %d TID %d stat %d"),
  2595. peer_id, win_sz, tid, status);
  2596. break;
  2597. }
  2598. case HTT_T2H_MSG_TYPE_FSE_CMEM_BASE_SEND:
  2599. {
  2600. uint16_t num_entries;
  2601. uint32_t cmem_ba_lo;
  2602. uint32_t cmem_ba_hi;
  2603. num_entries = HTT_CMEM_BASE_SEND_NUM_ENTRIES_GET(*msg_word);
  2604. cmem_ba_lo = *(msg_word + 1);
  2605. cmem_ba_hi = *(msg_word + 2);
  2606. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  2607. FL("CMEM FSE num_entries %u CMEM BA LO %x HI %x"),
  2608. num_entries, cmem_ba_lo, cmem_ba_hi);
  2609. dp_rx_fst_update_cmem_params(soc->dp_soc, num_entries,
  2610. cmem_ba_lo, cmem_ba_hi);
  2611. break;
  2612. }
  2613. case HTT_T2H_MSG_TYPE_TX_OFFLOAD_DELIVER_IND:
  2614. {
  2615. dp_offload_ind_handler(soc, msg_word);
  2616. break;
  2617. }
  2618. case HTT_T2H_MSG_TYPE_PEER_MAP_V3:
  2619. {
  2620. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  2621. u_int8_t *peer_mac_addr;
  2622. u_int16_t peer_id;
  2623. u_int16_t hw_peer_id;
  2624. u_int8_t vdev_id;
  2625. uint8_t is_wds;
  2626. u_int16_t ast_hash = 0;
  2627. peer_id = HTT_RX_PEER_MAP_V3_SW_PEER_ID_GET(*msg_word);
  2628. vdev_id = HTT_RX_PEER_MAP_V3_VDEV_ID_GET(*msg_word);
  2629. peer_mac_addr =
  2630. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  2631. &mac_addr_deswizzle_buf[0]);
  2632. hw_peer_id = HTT_RX_PEER_MAP_V3_HW_PEER_ID_GET(*(msg_word + 3));
  2633. ast_hash = HTT_RX_PEER_MAP_V3_CACHE_SET_NUM_GET(*(msg_word + 3));
  2634. is_wds = HTT_RX_PEER_MAP_V3_NEXT_HOP_GET(*(msg_word + 4));
  2635. dp_htt_info("HTT_T2H_MSG_TYPE_PEER_MAP_V3 msg for peer id %d vdev id %d n",
  2636. peer_id, vdev_id);
  2637. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  2638. hw_peer_id, vdev_id,
  2639. peer_mac_addr, ast_hash,
  2640. is_wds);
  2641. break;
  2642. }
  2643. case HTT_T2H_MSG_TYPE_MLO_RX_PEER_MAP:
  2644. {
  2645. dp_htt_mlo_peer_map_handler(soc, msg_word);
  2646. break;
  2647. }
  2648. case HTT_T2H_MSG_TYPE_MLO_RX_PEER_UNMAP:
  2649. {
  2650. dp_htt_mlo_peer_unmap_handler(soc, msg_word);
  2651. break;
  2652. }
  2653. default:
  2654. break;
  2655. };
  2656. /* Free the indication buffer */
  2657. if (free_buf)
  2658. qdf_nbuf_free(htt_t2h_msg);
  2659. }
  2660. /*
  2661. * dp_htt_h2t_full() - Send full handler (called from HTC)
  2662. * @context: Opaque context (HTT SOC handle)
  2663. * @pkt: HTC packet
  2664. *
  2665. * Return: enum htc_send_full_action
  2666. */
  2667. static enum htc_send_full_action
  2668. dp_htt_h2t_full(void *context, HTC_PACKET *pkt)
  2669. {
  2670. return HTC_SEND_FULL_KEEP;
  2671. }
  2672. /*
  2673. * dp_htt_hif_t2h_hp_callback() - HIF callback for high priority T2H messages
  2674. * @context: Opaque context (HTT SOC handle)
  2675. * @nbuf: nbuf containing T2H message
  2676. * @pipe_id: HIF pipe ID
  2677. *
  2678. * Return: QDF_STATUS
  2679. *
  2680. * TODO: Temporary change to bypass HTC connection for this new HIF pipe, which
  2681. * will be used for packet log and other high-priority HTT messages. Proper
  2682. * HTC connection to be added later once required FW changes are available
  2683. */
  2684. static QDF_STATUS
  2685. dp_htt_hif_t2h_hp_callback (void *context, qdf_nbuf_t nbuf, uint8_t pipe_id)
  2686. {
  2687. QDF_STATUS rc = QDF_STATUS_SUCCESS;
  2688. HTC_PACKET htc_pkt;
  2689. qdf_assert_always(pipe_id == DP_HTT_T2H_HP_PIPE);
  2690. qdf_mem_zero(&htc_pkt, sizeof(htc_pkt));
  2691. htc_pkt.Status = QDF_STATUS_SUCCESS;
  2692. htc_pkt.pPktContext = (void *)nbuf;
  2693. dp_htt_t2h_msg_handler(context, &htc_pkt);
  2694. return rc;
  2695. }
  2696. /*
  2697. * htt_htc_soc_attach() - Register SOC level HTT instance with HTC
  2698. * @htt_soc: HTT SOC handle
  2699. *
  2700. * Return: QDF_STATUS
  2701. */
  2702. static QDF_STATUS
  2703. htt_htc_soc_attach(struct htt_soc *soc)
  2704. {
  2705. struct htc_service_connect_req connect;
  2706. struct htc_service_connect_resp response;
  2707. QDF_STATUS status;
  2708. struct dp_soc *dpsoc = soc->dp_soc;
  2709. qdf_mem_zero(&connect, sizeof(connect));
  2710. qdf_mem_zero(&response, sizeof(response));
  2711. connect.pMetaData = NULL;
  2712. connect.MetaDataLength = 0;
  2713. connect.EpCallbacks.pContext = soc;
  2714. connect.EpCallbacks.EpTxComplete = dp_htt_h2t_send_complete;
  2715. connect.EpCallbacks.EpTxCompleteMultiple = NULL;
  2716. connect.EpCallbacks.EpRecv = dp_htt_t2h_msg_handler;
  2717. /* rx buffers currently are provided by HIF, not by EpRecvRefill */
  2718. connect.EpCallbacks.EpRecvRefill = NULL;
  2719. /* N/A, fill is done by HIF */
  2720. connect.EpCallbacks.RecvRefillWaterMark = 1;
  2721. connect.EpCallbacks.EpSendFull = dp_htt_h2t_full;
  2722. /*
  2723. * Specify how deep to let a queue get before htc_send_pkt will
  2724. * call the EpSendFull function due to excessive send queue depth.
  2725. */
  2726. connect.MaxSendQueueDepth = DP_HTT_MAX_SEND_QUEUE_DEPTH;
  2727. /* disable flow control for HTT data message service */
  2728. connect.ConnectionFlags |= HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
  2729. /* connect to control service */
  2730. connect.service_id = HTT_DATA_MSG_SVC;
  2731. status = htc_connect_service(soc->htc_soc, &connect, &response);
  2732. if (status != QDF_STATUS_SUCCESS)
  2733. return status;
  2734. soc->htc_endpoint = response.Endpoint;
  2735. hif_save_htc_htt_config_endpoint(dpsoc->hif_handle, soc->htc_endpoint);
  2736. htt_interface_logging_init(&soc->htt_logger_handle, soc->ctrl_psoc);
  2737. dp_hif_update_pipe_callback(soc->dp_soc, (void *)soc,
  2738. dp_htt_hif_t2h_hp_callback, DP_HTT_T2H_HP_PIPE);
  2739. return QDF_STATUS_SUCCESS; /* success */
  2740. }
  2741. /*
  2742. * htt_soc_initialize() - SOC level HTT initialization
  2743. * @htt_soc: Opaque htt SOC handle
  2744. * @ctrl_psoc: Opaque ctrl SOC handle
  2745. * @htc_soc: SOC level HTC handle
  2746. * @hal_soc: Opaque HAL SOC handle
  2747. * @osdev: QDF device
  2748. *
  2749. * Return: HTT handle on success; NULL on failure
  2750. */
  2751. void *
  2752. htt_soc_initialize(struct htt_soc *htt_soc,
  2753. struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
  2754. HTC_HANDLE htc_soc,
  2755. hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev)
  2756. {
  2757. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  2758. soc->osdev = osdev;
  2759. soc->ctrl_psoc = ctrl_psoc;
  2760. soc->htc_soc = htc_soc;
  2761. soc->hal_soc = hal_soc_hdl;
  2762. if (htt_htc_soc_attach(soc))
  2763. goto fail2;
  2764. return soc;
  2765. fail2:
  2766. return NULL;
  2767. }
  2768. void htt_soc_htc_dealloc(struct htt_soc *htt_handle)
  2769. {
  2770. htt_interface_logging_deinit(htt_handle->htt_logger_handle);
  2771. htt_htc_misc_pkt_pool_free(htt_handle);
  2772. htt_htc_pkt_pool_free(htt_handle);
  2773. }
  2774. /*
  2775. * htt_soc_htc_prealloc() - HTC memory prealloc
  2776. * @htt_soc: SOC level HTT handle
  2777. *
  2778. * Return: QDF_STATUS_SUCCESS on Success or
  2779. * QDF_STATUS_E_NOMEM on allocation failure
  2780. */
  2781. QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *soc)
  2782. {
  2783. int i;
  2784. soc->htt_htc_pkt_freelist = NULL;
  2785. /* pre-allocate some HTC_PACKET objects */
  2786. for (i = 0; i < HTT_HTC_PKT_POOL_INIT_SIZE; i++) {
  2787. struct dp_htt_htc_pkt_union *pkt;
  2788. pkt = qdf_mem_malloc(sizeof(*pkt));
  2789. if (!pkt)
  2790. return QDF_STATUS_E_NOMEM;
  2791. htt_htc_pkt_free(soc, &pkt->u.pkt);
  2792. }
  2793. return QDF_STATUS_SUCCESS;
  2794. }
  2795. /*
  2796. * htt_soc_detach() - Free SOC level HTT handle
  2797. * @htt_hdl: HTT SOC handle
  2798. */
  2799. void htt_soc_detach(struct htt_soc *htt_hdl)
  2800. {
  2801. int i;
  2802. struct htt_soc *htt_handle = (struct htt_soc *)htt_hdl;
  2803. for (i = 0; i < MAX_PDEV_CNT; i++) {
  2804. qdf_mem_free(htt_handle->pdevid_tt[i].umac_ttt);
  2805. qdf_mem_free(htt_handle->pdevid_tt[i].lmac_ttt);
  2806. }
  2807. HTT_TX_MUTEX_DESTROY(&htt_handle->htt_tx_mutex);
  2808. qdf_mem_free(htt_handle);
  2809. }
  2810. /**
  2811. * dp_h2t_ext_stats_msg_send(): function to contruct HTT message to pass to FW
  2812. * @pdev: DP PDEV handle
  2813. * @stats_type_upload_mask: stats type requested by user
  2814. * @config_param_0: extra configuration parameters
  2815. * @config_param_1: extra configuration parameters
  2816. * @config_param_2: extra configuration parameters
  2817. * @config_param_3: extra configuration parameters
  2818. * @mac_id: mac number
  2819. *
  2820. * return: QDF STATUS
  2821. */
  2822. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  2823. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  2824. uint32_t config_param_1, uint32_t config_param_2,
  2825. uint32_t config_param_3, int cookie_val, int cookie_msb,
  2826. uint8_t mac_id)
  2827. {
  2828. struct htt_soc *soc = pdev->soc->htt_handle;
  2829. struct dp_htt_htc_pkt *pkt;
  2830. qdf_nbuf_t msg;
  2831. uint32_t *msg_word;
  2832. uint8_t pdev_mask = 0;
  2833. uint8_t *htt_logger_bufp;
  2834. int mac_for_pdev;
  2835. int target_pdev_id;
  2836. QDF_STATUS status;
  2837. msg = qdf_nbuf_alloc(
  2838. soc->osdev,
  2839. HTT_MSG_BUF_SIZE(HTT_H2T_EXT_STATS_REQ_MSG_SZ),
  2840. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  2841. if (!msg)
  2842. return QDF_STATUS_E_NOMEM;
  2843. /*TODO:Add support for SOC stats
  2844. * Bit 0: SOC Stats
  2845. * Bit 1: Pdev stats for pdev id 0
  2846. * Bit 2: Pdev stats for pdev id 1
  2847. * Bit 3: Pdev stats for pdev id 2
  2848. */
  2849. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  2850. target_pdev_id =
  2851. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  2852. pdev_mask = 1 << target_pdev_id;
  2853. /*
  2854. * Set the length of the message.
  2855. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  2856. * separately during the below call to qdf_nbuf_push_head.
  2857. * The contribution from the HTC header is added separately inside HTC.
  2858. */
  2859. if (qdf_nbuf_put_tail(msg, HTT_H2T_EXT_STATS_REQ_MSG_SZ) == NULL) {
  2860. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2861. "Failed to expand head for HTT_EXT_STATS");
  2862. qdf_nbuf_free(msg);
  2863. return QDF_STATUS_E_FAILURE;
  2864. }
  2865. dp_htt_tx_stats_info("%pK: cookie <-> %d\n config_param_0 %u\n"
  2866. "config_param_1 %u\n config_param_2 %u\n"
  2867. "config_param_4 %u\n -------------",
  2868. pdev->soc, cookie_val,
  2869. config_param_0,
  2870. config_param_1, config_param_2, config_param_3);
  2871. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  2872. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  2873. htt_logger_bufp = (uint8_t *)msg_word;
  2874. *msg_word = 0;
  2875. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_EXT_STATS_REQ);
  2876. HTT_H2T_EXT_STATS_REQ_PDEV_MASK_SET(*msg_word, pdev_mask);
  2877. HTT_H2T_EXT_STATS_REQ_STATS_TYPE_SET(*msg_word, stats_type_upload_mask);
  2878. /* word 1 */
  2879. msg_word++;
  2880. *msg_word = 0;
  2881. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_0);
  2882. /* word 2 */
  2883. msg_word++;
  2884. *msg_word = 0;
  2885. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_1);
  2886. /* word 3 */
  2887. msg_word++;
  2888. *msg_word = 0;
  2889. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_2);
  2890. /* word 4 */
  2891. msg_word++;
  2892. *msg_word = 0;
  2893. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_3);
  2894. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, 0);
  2895. /* word 5 */
  2896. msg_word++;
  2897. /* word 6 */
  2898. msg_word++;
  2899. *msg_word = 0;
  2900. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_val);
  2901. /* word 7 */
  2902. msg_word++;
  2903. *msg_word = 0;
  2904. /* Currently Using last 2 bits for pdev_id
  2905. * For future reference, reserving 3 bits in cookie_msb for pdev_id
  2906. */
  2907. cookie_msb = (cookie_msb | pdev->pdev_id);
  2908. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_msb);
  2909. pkt = htt_htc_pkt_alloc(soc);
  2910. if (!pkt) {
  2911. qdf_nbuf_free(msg);
  2912. return QDF_STATUS_E_NOMEM;
  2913. }
  2914. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  2915. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  2916. dp_htt_h2t_send_complete_free_netbuf,
  2917. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  2918. soc->htc_endpoint,
  2919. /* tag for FW response msg not guaranteed */
  2920. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  2921. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  2922. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_EXT_STATS_REQ,
  2923. htt_logger_bufp);
  2924. if (status != QDF_STATUS_SUCCESS) {
  2925. qdf_nbuf_free(msg);
  2926. htt_htc_pkt_free(soc, pkt);
  2927. }
  2928. return status;
  2929. }
  2930. /**
  2931. * dp_h2t_3tuple_config_send(): function to contruct 3 tuple configuration
  2932. * HTT message to pass to FW
  2933. * @pdev: DP PDEV handle
  2934. * @tuple_mask: tuple configuration to report 3 tuple hash value in either
  2935. * toeplitz_2_or_4 or flow_id_toeplitz in MSDU START TLV.
  2936. *
  2937. * tuple_mask[1:0]:
  2938. * 00 - Do not report 3 tuple hash value
  2939. * 10 - Report 3 tuple hash value in toeplitz_2_or_4
  2940. * 01 - Report 3 tuple hash value in flow_id_toeplitz
  2941. * 11 - Report 3 tuple hash value in both toeplitz_2_or_4 & flow_id_toeplitz
  2942. *
  2943. * return: QDF STATUS
  2944. */
  2945. QDF_STATUS dp_h2t_3tuple_config_send(struct dp_pdev *pdev,
  2946. uint32_t tuple_mask, uint8_t mac_id)
  2947. {
  2948. struct htt_soc *soc = pdev->soc->htt_handle;
  2949. struct dp_htt_htc_pkt *pkt;
  2950. qdf_nbuf_t msg;
  2951. uint32_t *msg_word;
  2952. uint8_t *htt_logger_bufp;
  2953. int mac_for_pdev;
  2954. int target_pdev_id;
  2955. msg = qdf_nbuf_alloc(
  2956. soc->osdev,
  2957. HTT_MSG_BUF_SIZE(HTT_3_TUPLE_HASH_CFG_REQ_BYTES),
  2958. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  2959. if (!msg)
  2960. return QDF_STATUS_E_NOMEM;
  2961. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  2962. target_pdev_id =
  2963. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  2964. /*
  2965. * Set the length of the message.
  2966. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  2967. * separately during the below call to qdf_nbuf_push_head.
  2968. * The contribution from the HTC header is added separately inside HTC.
  2969. */
  2970. if (!qdf_nbuf_put_tail(msg, HTT_3_TUPLE_HASH_CFG_REQ_BYTES)) {
  2971. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2972. "Failed to expand head for HTT_3TUPLE_CONFIG");
  2973. qdf_nbuf_free(msg);
  2974. return QDF_STATUS_E_FAILURE;
  2975. }
  2976. dp_htt_info("%pK: config_param_sent 0x%x for target_pdev %d\n -------------",
  2977. pdev->soc, tuple_mask, target_pdev_id);
  2978. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  2979. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  2980. htt_logger_bufp = (uint8_t *)msg_word;
  2981. *msg_word = 0;
  2982. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG);
  2983. HTT_RX_3_TUPLE_HASH_PDEV_ID_SET(*msg_word, target_pdev_id);
  2984. msg_word++;
  2985. *msg_word = 0;
  2986. HTT_H2T_FLOW_ID_TOEPLITZ_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  2987. HTT_H2T_TOEPLITZ_2_OR_4_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  2988. pkt = htt_htc_pkt_alloc(soc);
  2989. if (!pkt) {
  2990. qdf_nbuf_free(msg);
  2991. return QDF_STATUS_E_NOMEM;
  2992. }
  2993. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  2994. SET_HTC_PACKET_INFO_TX(
  2995. &pkt->htc_pkt,
  2996. dp_htt_h2t_send_complete_free_netbuf,
  2997. qdf_nbuf_data(msg),
  2998. qdf_nbuf_len(msg),
  2999. soc->htc_endpoint,
  3000. /* tag for no FW response msg */
  3001. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3002. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3003. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG,
  3004. htt_logger_bufp);
  3005. return QDF_STATUS_SUCCESS;
  3006. }
  3007. /* This macro will revert once proper HTT header will define for
  3008. * HTT_H2T_MSG_TYPE_PPDU_STATS_CFG in htt.h file
  3009. * */
  3010. #if defined(WDI_EVENT_ENABLE)
  3011. /**
  3012. * dp_h2t_cfg_stats_msg_send(): function to construct HTT message to pass to FW
  3013. * @pdev: DP PDEV handle
  3014. * @stats_type_upload_mask: stats type requested by user
  3015. * @mac_id: Mac id number
  3016. *
  3017. * return: QDF STATUS
  3018. */
  3019. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  3020. uint32_t stats_type_upload_mask, uint8_t mac_id)
  3021. {
  3022. struct htt_soc *soc = pdev->soc->htt_handle;
  3023. struct dp_htt_htc_pkt *pkt;
  3024. qdf_nbuf_t msg;
  3025. uint32_t *msg_word;
  3026. uint8_t pdev_mask;
  3027. QDF_STATUS status;
  3028. msg = qdf_nbuf_alloc(
  3029. soc->osdev,
  3030. HTT_MSG_BUF_SIZE(HTT_H2T_PPDU_STATS_CFG_MSG_SZ),
  3031. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  3032. if (!msg) {
  3033. dp_htt_err("%pK: Fail to allocate HTT_H2T_PPDU_STATS_CFG_MSG_SZ msg buffer"
  3034. , pdev->soc);
  3035. qdf_assert(0);
  3036. return QDF_STATUS_E_NOMEM;
  3037. }
  3038. /*TODO:Add support for SOC stats
  3039. * Bit 0: SOC Stats
  3040. * Bit 1: Pdev stats for pdev id 0
  3041. * Bit 2: Pdev stats for pdev id 1
  3042. * Bit 3: Pdev stats for pdev id 2
  3043. */
  3044. pdev_mask = 1 << dp_get_target_pdev_id_for_host_pdev_id(pdev->soc,
  3045. mac_id);
  3046. /*
  3047. * Set the length of the message.
  3048. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3049. * separately during the below call to qdf_nbuf_push_head.
  3050. * The contribution from the HTC header is added separately inside HTC.
  3051. */
  3052. if (qdf_nbuf_put_tail(msg, HTT_H2T_PPDU_STATS_CFG_MSG_SZ) == NULL) {
  3053. dp_htt_err("%pK: Failed to expand head for HTT_CFG_STATS"
  3054. , pdev->soc);
  3055. qdf_nbuf_free(msg);
  3056. return QDF_STATUS_E_FAILURE;
  3057. }
  3058. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  3059. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3060. *msg_word = 0;
  3061. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG);
  3062. HTT_H2T_PPDU_STATS_CFG_PDEV_MASK_SET(*msg_word, pdev_mask);
  3063. HTT_H2T_PPDU_STATS_CFG_TLV_BITMASK_SET(*msg_word,
  3064. stats_type_upload_mask);
  3065. pkt = htt_htc_pkt_alloc(soc);
  3066. if (!pkt) {
  3067. dp_htt_err("%pK: Fail to allocate dp_htt_htc_pkt buffer", pdev->soc);
  3068. qdf_assert(0);
  3069. qdf_nbuf_free(msg);
  3070. return QDF_STATUS_E_NOMEM;
  3071. }
  3072. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3073. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3074. dp_htt_h2t_send_complete_free_netbuf,
  3075. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  3076. soc->htc_endpoint,
  3077. /* tag for no FW response msg */
  3078. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3079. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3080. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG,
  3081. (uint8_t *)msg_word);
  3082. if (status != QDF_STATUS_SUCCESS) {
  3083. qdf_nbuf_free(msg);
  3084. htt_htc_pkt_free(soc, pkt);
  3085. }
  3086. return status;
  3087. }
  3088. qdf_export_symbol(dp_h2t_cfg_stats_msg_send);
  3089. #endif
  3090. void
  3091. dp_peer_update_inactive_time(struct dp_pdev *pdev, uint32_t tag_type,
  3092. uint32_t *tag_buf)
  3093. {
  3094. struct dp_peer *peer = NULL;
  3095. switch (tag_type) {
  3096. case HTT_STATS_PEER_DETAILS_TAG:
  3097. {
  3098. htt_peer_details_tlv *dp_stats_buf =
  3099. (htt_peer_details_tlv *)tag_buf;
  3100. pdev->fw_stats_peer_id = dp_stats_buf->sw_peer_id;
  3101. }
  3102. break;
  3103. case HTT_STATS_PEER_STATS_CMN_TAG:
  3104. {
  3105. htt_peer_stats_cmn_tlv *dp_stats_buf =
  3106. (htt_peer_stats_cmn_tlv *)tag_buf;
  3107. peer = dp_peer_get_ref_by_id(pdev->soc, pdev->fw_stats_peer_id,
  3108. DP_MOD_ID_HTT);
  3109. if (peer && !peer->bss_peer) {
  3110. peer->stats.tx.inactive_time =
  3111. dp_stats_buf->inactive_time;
  3112. qdf_event_set(&pdev->fw_peer_stats_event);
  3113. }
  3114. if (peer)
  3115. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  3116. }
  3117. break;
  3118. default:
  3119. qdf_err("Invalid tag_type");
  3120. }
  3121. }
  3122. /**
  3123. * dp_htt_rx_flow_fst_setup(): Send HTT Rx FST setup message to FW
  3124. * @pdev: DP pdev handle
  3125. * @fse_setup_info: FST setup parameters
  3126. *
  3127. * Return: Success when HTT message is sent, error on failure
  3128. */
  3129. QDF_STATUS
  3130. dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev,
  3131. struct dp_htt_rx_flow_fst_setup *fse_setup_info)
  3132. {
  3133. struct htt_soc *soc = pdev->soc->htt_handle;
  3134. struct dp_htt_htc_pkt *pkt;
  3135. qdf_nbuf_t msg;
  3136. u_int32_t *msg_word;
  3137. struct htt_h2t_msg_rx_fse_setup_t *fse_setup;
  3138. uint8_t *htt_logger_bufp;
  3139. u_int32_t *key;
  3140. QDF_STATUS status;
  3141. msg = qdf_nbuf_alloc(
  3142. soc->osdev,
  3143. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_setup_t)),
  3144. /* reserve room for the HTC header */
  3145. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3146. if (!msg)
  3147. return QDF_STATUS_E_NOMEM;
  3148. /*
  3149. * Set the length of the message.
  3150. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3151. * separately during the below call to qdf_nbuf_push_head.
  3152. * The contribution from the HTC header is added separately inside HTC.
  3153. */
  3154. if (!qdf_nbuf_put_tail(msg,
  3155. sizeof(struct htt_h2t_msg_rx_fse_setup_t))) {
  3156. qdf_err("Failed to expand head for HTT RX_FSE_SETUP msg");
  3157. return QDF_STATUS_E_FAILURE;
  3158. }
  3159. /* fill in the message contents */
  3160. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  3161. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_setup_t));
  3162. /* rewind beyond alignment pad to get to the HTC header reserved area */
  3163. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3164. htt_logger_bufp = (uint8_t *)msg_word;
  3165. *msg_word = 0;
  3166. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG);
  3167. fse_setup = (struct htt_h2t_msg_rx_fse_setup_t *)msg_word;
  3168. HTT_RX_FSE_SETUP_PDEV_ID_SET(*msg_word, fse_setup_info->pdev_id);
  3169. msg_word++;
  3170. HTT_RX_FSE_SETUP_NUM_REC_SET(*msg_word, fse_setup_info->max_entries);
  3171. HTT_RX_FSE_SETUP_MAX_SEARCH_SET(*msg_word, fse_setup_info->max_search);
  3172. HTT_RX_FSE_SETUP_IP_DA_SA_PREFIX_SET(*msg_word,
  3173. fse_setup_info->ip_da_sa_prefix);
  3174. msg_word++;
  3175. HTT_RX_FSE_SETUP_BASE_ADDR_LO_SET(*msg_word,
  3176. fse_setup_info->base_addr_lo);
  3177. msg_word++;
  3178. HTT_RX_FSE_SETUP_BASE_ADDR_HI_SET(*msg_word,
  3179. fse_setup_info->base_addr_hi);
  3180. key = (u_int32_t *)fse_setup_info->hash_key;
  3181. fse_setup->toeplitz31_0 = *key++;
  3182. fse_setup->toeplitz63_32 = *key++;
  3183. fse_setup->toeplitz95_64 = *key++;
  3184. fse_setup->toeplitz127_96 = *key++;
  3185. fse_setup->toeplitz159_128 = *key++;
  3186. fse_setup->toeplitz191_160 = *key++;
  3187. fse_setup->toeplitz223_192 = *key++;
  3188. fse_setup->toeplitz255_224 = *key++;
  3189. fse_setup->toeplitz287_256 = *key++;
  3190. fse_setup->toeplitz314_288 = *key;
  3191. msg_word++;
  3192. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz31_0);
  3193. msg_word++;
  3194. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz63_32);
  3195. msg_word++;
  3196. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz95_64);
  3197. msg_word++;
  3198. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz127_96);
  3199. msg_word++;
  3200. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz159_128);
  3201. msg_word++;
  3202. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz191_160);
  3203. msg_word++;
  3204. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz223_192);
  3205. msg_word++;
  3206. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz255_224);
  3207. msg_word++;
  3208. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz287_256);
  3209. msg_word++;
  3210. HTT_RX_FSE_SETUP_HASH_314_288_SET(*msg_word,
  3211. fse_setup->toeplitz314_288);
  3212. pkt = htt_htc_pkt_alloc(soc);
  3213. if (!pkt) {
  3214. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  3215. qdf_assert(0);
  3216. qdf_nbuf_free(msg);
  3217. return QDF_STATUS_E_RESOURCES; /* failure */
  3218. }
  3219. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3220. SET_HTC_PACKET_INFO_TX(
  3221. &pkt->htc_pkt,
  3222. dp_htt_h2t_send_complete_free_netbuf,
  3223. qdf_nbuf_data(msg),
  3224. qdf_nbuf_len(msg),
  3225. soc->htc_endpoint,
  3226. /* tag for no FW response msg */
  3227. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3228. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3229. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  3230. HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG,
  3231. htt_logger_bufp);
  3232. if (status == QDF_STATUS_SUCCESS) {
  3233. dp_info("HTT_H2T RX_FSE_SETUP sent to FW for pdev = %u",
  3234. fse_setup_info->pdev_id);
  3235. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
  3236. (void *)fse_setup_info->hash_key,
  3237. fse_setup_info->hash_key_len);
  3238. } else {
  3239. qdf_nbuf_free(msg);
  3240. htt_htc_pkt_free(soc, pkt);
  3241. }
  3242. return status;
  3243. }
  3244. /**
  3245. * dp_htt_rx_flow_fse_operation(): Send HTT Flow Search Entry msg to
  3246. * add/del a flow in HW
  3247. * @pdev: DP pdev handle
  3248. * @fse_op_info: Flow entry parameters
  3249. *
  3250. * Return: Success when HTT message is sent, error on failure
  3251. */
  3252. QDF_STATUS
  3253. dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev,
  3254. struct dp_htt_rx_flow_fst_operation *fse_op_info)
  3255. {
  3256. struct htt_soc *soc = pdev->soc->htt_handle;
  3257. struct dp_htt_htc_pkt *pkt;
  3258. qdf_nbuf_t msg;
  3259. u_int32_t *msg_word;
  3260. struct htt_h2t_msg_rx_fse_operation_t *fse_operation;
  3261. uint8_t *htt_logger_bufp;
  3262. QDF_STATUS status;
  3263. msg = qdf_nbuf_alloc(
  3264. soc->osdev,
  3265. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_operation_t)),
  3266. /* reserve room for the HTC header */
  3267. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3268. if (!msg)
  3269. return QDF_STATUS_E_NOMEM;
  3270. /*
  3271. * Set the length of the message.
  3272. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3273. * separately during the below call to qdf_nbuf_push_head.
  3274. * The contribution from the HTC header is added separately inside HTC.
  3275. */
  3276. if (!qdf_nbuf_put_tail(msg,
  3277. sizeof(struct htt_h2t_msg_rx_fse_operation_t))) {
  3278. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  3279. qdf_nbuf_free(msg);
  3280. return QDF_STATUS_E_FAILURE;
  3281. }
  3282. /* fill in the message contents */
  3283. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  3284. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_operation_t));
  3285. /* rewind beyond alignment pad to get to the HTC header reserved area */
  3286. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3287. htt_logger_bufp = (uint8_t *)msg_word;
  3288. *msg_word = 0;
  3289. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG);
  3290. fse_operation = (struct htt_h2t_msg_rx_fse_operation_t *)msg_word;
  3291. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, fse_op_info->pdev_id);
  3292. msg_word++;
  3293. HTT_RX_FSE_IPSEC_VALID_SET(*msg_word, false);
  3294. if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_ENTRY) {
  3295. HTT_RX_FSE_OPERATION_SET(*msg_word,
  3296. HTT_RX_FSE_CACHE_INVALIDATE_ENTRY);
  3297. msg_word++;
  3298. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  3299. *msg_word,
  3300. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_31_0));
  3301. msg_word++;
  3302. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  3303. *msg_word,
  3304. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_63_32));
  3305. msg_word++;
  3306. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  3307. *msg_word,
  3308. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_95_64));
  3309. msg_word++;
  3310. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  3311. *msg_word,
  3312. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_127_96));
  3313. msg_word++;
  3314. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  3315. *msg_word,
  3316. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_31_0));
  3317. msg_word++;
  3318. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  3319. *msg_word,
  3320. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_63_32));
  3321. msg_word++;
  3322. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  3323. *msg_word,
  3324. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_95_64));
  3325. msg_word++;
  3326. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  3327. *msg_word,
  3328. qdf_htonl(
  3329. fse_op_info->rx_flow->flow_tuple_info.dest_ip_127_96));
  3330. msg_word++;
  3331. HTT_RX_FSE_SOURCEPORT_SET(
  3332. *msg_word,
  3333. fse_op_info->rx_flow->flow_tuple_info.src_port);
  3334. HTT_RX_FSE_DESTPORT_SET(
  3335. *msg_word,
  3336. fse_op_info->rx_flow->flow_tuple_info.dest_port);
  3337. msg_word++;
  3338. HTT_RX_FSE_L4_PROTO_SET(
  3339. *msg_word,
  3340. fse_op_info->rx_flow->flow_tuple_info.l4_protocol);
  3341. } else if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_FULL) {
  3342. HTT_RX_FSE_OPERATION_SET(*msg_word,
  3343. HTT_RX_FSE_CACHE_INVALIDATE_FULL);
  3344. } else if (fse_op_info->op_code == DP_HTT_FST_DISABLE) {
  3345. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_DISABLE);
  3346. } else if (fse_op_info->op_code == DP_HTT_FST_ENABLE) {
  3347. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_ENABLE);
  3348. }
  3349. pkt = htt_htc_pkt_alloc(soc);
  3350. if (!pkt) {
  3351. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  3352. qdf_assert(0);
  3353. qdf_nbuf_free(msg);
  3354. return QDF_STATUS_E_RESOURCES; /* failure */
  3355. }
  3356. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3357. SET_HTC_PACKET_INFO_TX(
  3358. &pkt->htc_pkt,
  3359. dp_htt_h2t_send_complete_free_netbuf,
  3360. qdf_nbuf_data(msg),
  3361. qdf_nbuf_len(msg),
  3362. soc->htc_endpoint,
  3363. /* tag for no FW response msg */
  3364. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3365. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3366. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  3367. HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG,
  3368. htt_logger_bufp);
  3369. if (status == QDF_STATUS_SUCCESS) {
  3370. dp_info("HTT_H2T RX_FSE_OPERATION_CFG sent to FW for pdev = %u",
  3371. fse_op_info->pdev_id);
  3372. } else {
  3373. qdf_nbuf_free(msg);
  3374. htt_htc_pkt_free(soc, pkt);
  3375. }
  3376. return status;
  3377. }
  3378. /**
  3379. * dp_htt_rx_fisa_config(): Send HTT msg to configure FISA
  3380. * @pdev: DP pdev handle
  3381. * @fse_op_info: Flow entry parameters
  3382. *
  3383. * Return: Success when HTT message is sent, error on failure
  3384. */
  3385. QDF_STATUS
  3386. dp_htt_rx_fisa_config(struct dp_pdev *pdev,
  3387. struct dp_htt_rx_fisa_cfg *fisa_config)
  3388. {
  3389. struct htt_soc *soc = pdev->soc->htt_handle;
  3390. struct dp_htt_htc_pkt *pkt;
  3391. qdf_nbuf_t msg;
  3392. u_int32_t *msg_word;
  3393. struct htt_h2t_msg_type_fisa_config_t *htt_fisa_config;
  3394. uint8_t *htt_logger_bufp;
  3395. uint32_t len;
  3396. QDF_STATUS status;
  3397. len = HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_type_fisa_config_t));
  3398. msg = qdf_nbuf_alloc(soc->osdev,
  3399. len,
  3400. /* reserve room for the HTC header */
  3401. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  3402. 4,
  3403. TRUE);
  3404. if (!msg)
  3405. return QDF_STATUS_E_NOMEM;
  3406. /*
  3407. * Set the length of the message.
  3408. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3409. * separately during the below call to qdf_nbuf_push_head.
  3410. * The contribution from the HTC header is added separately inside HTC.
  3411. */
  3412. if (!qdf_nbuf_put_tail(msg,
  3413. sizeof(struct htt_h2t_msg_type_fisa_config_t))) {
  3414. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  3415. qdf_nbuf_free(msg);
  3416. return QDF_STATUS_E_FAILURE;
  3417. }
  3418. /* fill in the message contents */
  3419. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  3420. memset(msg_word, 0, sizeof(struct htt_h2t_msg_type_fisa_config_t));
  3421. /* rewind beyond alignment pad to get to the HTC header reserved area */
  3422. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3423. htt_logger_bufp = (uint8_t *)msg_word;
  3424. *msg_word = 0;
  3425. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FISA_CFG);
  3426. htt_fisa_config = (struct htt_h2t_msg_type_fisa_config_t *)msg_word;
  3427. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, htt_fisa_config->pdev_id);
  3428. msg_word++;
  3429. HTT_RX_FISA_CONFIG_FISA_V2_ENABLE_SET(*msg_word, 1);
  3430. HTT_RX_FISA_CONFIG_FISA_V2_AGGR_LIMIT_SET(*msg_word, 0xf);
  3431. msg_word++;
  3432. htt_fisa_config->fisa_timeout_threshold = fisa_config->fisa_timeout;
  3433. pkt = htt_htc_pkt_alloc(soc);
  3434. if (!pkt) {
  3435. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  3436. qdf_assert(0);
  3437. qdf_nbuf_free(msg);
  3438. return QDF_STATUS_E_RESOURCES; /* failure */
  3439. }
  3440. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3441. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3442. dp_htt_h2t_send_complete_free_netbuf,
  3443. qdf_nbuf_data(msg),
  3444. qdf_nbuf_len(msg),
  3445. soc->htc_endpoint,
  3446. /* tag for no FW response msg */
  3447. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3448. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3449. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_RX_FISA_CFG,
  3450. htt_logger_bufp);
  3451. if (status == QDF_STATUS_SUCCESS) {
  3452. dp_info("HTT_H2T_MSG_TYPE_RX_FISA_CFG sent to FW for pdev = %u",
  3453. fisa_config->pdev_id);
  3454. } else {
  3455. qdf_nbuf_free(msg);
  3456. htt_htc_pkt_free(soc, pkt);
  3457. }
  3458. return status;
  3459. }
  3460. /**
  3461. * dp_bk_pressure_stats_handler(): worker function to print back pressure
  3462. * stats
  3463. *
  3464. * @context : argument to work function
  3465. */
  3466. static void dp_bk_pressure_stats_handler(void *context)
  3467. {
  3468. struct dp_pdev *pdev = (struct dp_pdev *)context;
  3469. struct dp_soc_srngs_state *soc_srngs_state = NULL;
  3470. const char *ring_name;
  3471. int i;
  3472. struct dp_srng_ring_state *ring_state;
  3473. bool empty_flag;
  3474. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  3475. /* Extract only first entry for printing in one work event */
  3476. if (pdev->bkp_stats.queue_depth &&
  3477. !TAILQ_EMPTY(&pdev->bkp_stats.list)) {
  3478. soc_srngs_state = TAILQ_FIRST(&pdev->bkp_stats.list);
  3479. TAILQ_REMOVE(&pdev->bkp_stats.list, soc_srngs_state,
  3480. list_elem);
  3481. pdev->bkp_stats.queue_depth--;
  3482. }
  3483. empty_flag = TAILQ_EMPTY(&pdev->bkp_stats.list);
  3484. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  3485. if (soc_srngs_state) {
  3486. DP_PRINT_STATS("### BKP stats for seq_num %u START ###",
  3487. soc_srngs_state->seq_num);
  3488. for (i = 0; i < soc_srngs_state->max_ring_id; i++) {
  3489. ring_state = &soc_srngs_state->ring_state[i];
  3490. ring_name = dp_srng_get_str_from_hal_ring_type
  3491. (ring_state->ring_type);
  3492. DP_PRINT_STATS("%s: SW:Head pointer = %d Tail Pointer = %d\n",
  3493. ring_name,
  3494. ring_state->sw_head,
  3495. ring_state->sw_tail);
  3496. DP_PRINT_STATS("%s: HW:Head pointer = %d Tail Pointer = %d\n",
  3497. ring_name,
  3498. ring_state->hw_head,
  3499. ring_state->hw_tail);
  3500. }
  3501. DP_PRINT_STATS("### BKP stats for seq_num %u COMPLETE ###",
  3502. soc_srngs_state->seq_num);
  3503. qdf_mem_free(soc_srngs_state);
  3504. }
  3505. dp_print_napi_stats(pdev->soc);
  3506. /* Schedule work again if queue is not empty */
  3507. if (!empty_flag)
  3508. qdf_queue_work(0, pdev->bkp_stats.work_queue,
  3509. &pdev->bkp_stats.work);
  3510. }
  3511. /*
  3512. * dp_pdev_bkp_stats_detach() - detach resources for back pressure stats
  3513. * processing
  3514. * @pdev: Datapath PDEV handle
  3515. *
  3516. */
  3517. void dp_pdev_bkp_stats_detach(struct dp_pdev *pdev)
  3518. {
  3519. struct dp_soc_srngs_state *ring_state, *ring_state_next;
  3520. if (!pdev->bkp_stats.work_queue)
  3521. return;
  3522. qdf_flush_workqueue(0, pdev->bkp_stats.work_queue);
  3523. qdf_destroy_workqueue(0, pdev->bkp_stats.work_queue);
  3524. qdf_flush_work(&pdev->bkp_stats.work);
  3525. qdf_disable_work(&pdev->bkp_stats.work);
  3526. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  3527. TAILQ_FOREACH_SAFE(ring_state, &pdev->bkp_stats.list,
  3528. list_elem, ring_state_next) {
  3529. TAILQ_REMOVE(&pdev->bkp_stats.list, ring_state,
  3530. list_elem);
  3531. qdf_mem_free(ring_state);
  3532. }
  3533. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  3534. qdf_spinlock_destroy(&pdev->bkp_stats.list_lock);
  3535. }
  3536. /*
  3537. * dp_pdev_bkp_stats_attach() - attach resources for back pressure stats
  3538. * processing
  3539. * @pdev: Datapath PDEV handle
  3540. *
  3541. * Return: QDF_STATUS_SUCCESS: Success
  3542. * QDF_STATUS_E_NOMEM: Error
  3543. */
  3544. QDF_STATUS dp_pdev_bkp_stats_attach(struct dp_pdev *pdev)
  3545. {
  3546. TAILQ_INIT(&pdev->bkp_stats.list);
  3547. pdev->bkp_stats.seq_num = 0;
  3548. pdev->bkp_stats.queue_depth = 0;
  3549. qdf_create_work(0, &pdev->bkp_stats.work,
  3550. dp_bk_pressure_stats_handler, pdev);
  3551. pdev->bkp_stats.work_queue =
  3552. qdf_alloc_unbound_workqueue("dp_bkp_work_queue");
  3553. if (!pdev->bkp_stats.work_queue)
  3554. goto fail;
  3555. qdf_spinlock_create(&pdev->bkp_stats.list_lock);
  3556. return QDF_STATUS_SUCCESS;
  3557. fail:
  3558. dp_htt_alert("BKP stats attach failed");
  3559. qdf_flush_work(&pdev->bkp_stats.work);
  3560. qdf_disable_work(&pdev->bkp_stats.work);
  3561. return QDF_STATUS_E_FAILURE;
  3562. }