dp_htt.c 87 KB

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