dp_htt.c 110 KB

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