dp_htt.c 85 KB

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