dp_htt.c 86 KB

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