ce_main.c 91 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236
  1. /*
  2. * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. #include "targcfg.h"
  27. #include "qdf_lock.h"
  28. #include "qdf_status.h"
  29. #include "qdf_status.h"
  30. #include <qdf_atomic.h> /* qdf_atomic_read */
  31. #include <targaddrs.h>
  32. #include "hif_io32.h"
  33. #include <hif.h>
  34. #include "regtable.h"
  35. #define ATH_MODULE_NAME hif
  36. #include <a_debug.h>
  37. #include "hif_main.h"
  38. #include "ce_api.h"
  39. #include "qdf_trace.h"
  40. #include "pld_common.h"
  41. #include "hif_debug.h"
  42. #include "ce_internal.h"
  43. #include "ce_reg.h"
  44. #include "ce_assignment.h"
  45. #include "ce_tasklet.h"
  46. #ifndef CONFIG_WIN
  47. #include "qwlan_version.h"
  48. #endif
  49. #define CE_POLL_TIMEOUT 10 /* ms */
  50. #define AGC_DUMP 1
  51. #define CHANINFO_DUMP 2
  52. #define BB_WATCHDOG_DUMP 3
  53. #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
  54. #define PCIE_ACCESS_DUMP 4
  55. #endif
  56. #include "mp_dev.h"
  57. #if (defined(QCA_WIFI_QCA8074) || defined(QCA_WIFI_QCA6290)) && \
  58. !defined(QCA_WIFI_SUPPORT_SRNG)
  59. #define QCA_WIFI_SUPPORT_SRNG
  60. #endif
  61. /* Forward references */
  62. QDF_STATUS hif_post_recv_buffers_for_pipe(struct HIF_CE_pipe_info *pipe_info);
  63. /*
  64. * Fix EV118783, poll to check whether a BMI response comes
  65. * other than waiting for the interruption which may be lost.
  66. */
  67. /* #define BMI_RSP_POLLING */
  68. #define BMI_RSP_TO_MILLISEC 1000
  69. #ifdef CONFIG_BYPASS_QMI
  70. #define BYPASS_QMI 1
  71. #else
  72. #define BYPASS_QMI 0
  73. #endif
  74. #ifdef CONFIG_WIN
  75. #if ENABLE_10_4_FW_HDR
  76. #define WDI_IPA_SERVICE_GROUP 5
  77. #define WDI_IPA_TX_SVC MAKE_SERVICE_ID(WDI_IPA_SERVICE_GROUP, 0)
  78. #define HTT_DATA2_MSG_SVC MAKE_SERVICE_ID(HTT_SERVICE_GROUP, 1)
  79. #define HTT_DATA3_MSG_SVC MAKE_SERVICE_ID(HTT_SERVICE_GROUP, 2)
  80. #endif /* ENABLE_10_4_FW_HDR */
  81. #endif
  82. QDF_STATUS hif_post_recv_buffers(struct hif_softc *scn);
  83. static void hif_config_rri_on_ddr(struct hif_softc *scn);
  84. /**
  85. * hif_target_access_log_dump() - dump access log
  86. *
  87. * dump access log
  88. *
  89. * Return: n/a
  90. */
  91. #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
  92. static void hif_target_access_log_dump(void)
  93. {
  94. hif_target_dump_access_log();
  95. }
  96. #endif
  97. void hif_trigger_dump(struct hif_opaque_softc *hif_ctx,
  98. uint8_t cmd_id, bool start)
  99. {
  100. struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
  101. switch (cmd_id) {
  102. case AGC_DUMP:
  103. if (start)
  104. priv_start_agc(scn);
  105. else
  106. priv_dump_agc(scn);
  107. break;
  108. case CHANINFO_DUMP:
  109. if (start)
  110. priv_start_cap_chaninfo(scn);
  111. else
  112. priv_dump_chaninfo(scn);
  113. break;
  114. case BB_WATCHDOG_DUMP:
  115. priv_dump_bbwatchdog(scn);
  116. break;
  117. #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
  118. case PCIE_ACCESS_DUMP:
  119. hif_target_access_log_dump();
  120. break;
  121. #endif
  122. default:
  123. HIF_ERROR("%s: Invalid htc dump command", __func__);
  124. break;
  125. }
  126. }
  127. static void ce_poll_timeout(void *arg)
  128. {
  129. struct CE_state *CE_state = (struct CE_state *)arg;
  130. if (CE_state->timer_inited) {
  131. ce_per_engine_service(CE_state->scn, CE_state->id);
  132. qdf_timer_mod(&CE_state->poll_timer, CE_POLL_TIMEOUT);
  133. }
  134. }
  135. static unsigned int roundup_pwr2(unsigned int n)
  136. {
  137. int i;
  138. unsigned int test_pwr2;
  139. if (!(n & (n - 1)))
  140. return n; /* already a power of 2 */
  141. test_pwr2 = 4;
  142. for (i = 0; i < 29; i++) {
  143. if (test_pwr2 > n)
  144. return test_pwr2;
  145. test_pwr2 = test_pwr2 << 1;
  146. }
  147. QDF_ASSERT(0); /* n too large */
  148. return 0;
  149. }
  150. #define ADRASTEA_SRC_WR_INDEX_OFFSET 0x3C
  151. #define ADRASTEA_DST_WR_INDEX_OFFSET 0x40
  152. static struct shadow_reg_cfg target_shadow_reg_cfg_map[] = {
  153. { 0, ADRASTEA_SRC_WR_INDEX_OFFSET},
  154. { 3, ADRASTEA_SRC_WR_INDEX_OFFSET},
  155. { 4, ADRASTEA_SRC_WR_INDEX_OFFSET},
  156. { 5, ADRASTEA_SRC_WR_INDEX_OFFSET},
  157. { 7, ADRASTEA_SRC_WR_INDEX_OFFSET},
  158. { 1, ADRASTEA_DST_WR_INDEX_OFFSET},
  159. { 2, ADRASTEA_DST_WR_INDEX_OFFSET},
  160. { 7, ADRASTEA_DST_WR_INDEX_OFFSET},
  161. { 8, ADRASTEA_DST_WR_INDEX_OFFSET},
  162. #ifdef QCA_WIFI_3_0_ADRASTEA
  163. { 9, ADRASTEA_DST_WR_INDEX_OFFSET},
  164. { 10, ADRASTEA_DST_WR_INDEX_OFFSET},
  165. { 11, ADRASTEA_DST_WR_INDEX_OFFSET},
  166. #endif
  167. };
  168. static struct shadow_reg_cfg target_shadow_reg_cfg_epping[] = {
  169. { 0, ADRASTEA_SRC_WR_INDEX_OFFSET},
  170. { 3, ADRASTEA_SRC_WR_INDEX_OFFSET},
  171. { 4, ADRASTEA_SRC_WR_INDEX_OFFSET},
  172. { 7, ADRASTEA_SRC_WR_INDEX_OFFSET},
  173. { 1, ADRASTEA_DST_WR_INDEX_OFFSET},
  174. { 2, ADRASTEA_DST_WR_INDEX_OFFSET},
  175. { 5, ADRASTEA_DST_WR_INDEX_OFFSET},
  176. { 7, ADRASTEA_DST_WR_INDEX_OFFSET},
  177. { 8, ADRASTEA_DST_WR_INDEX_OFFSET},
  178. };
  179. /* CE_PCI TABLE */
  180. /*
  181. * NOTE: the table below is out of date, though still a useful reference.
  182. * Refer to target_service_to_ce_map and hif_map_service_to_pipe for the actual
  183. * mapping of HTC services to HIF pipes.
  184. */
  185. /*
  186. * This authoritative table defines Copy Engine configuration and the mapping
  187. * of services/endpoints to CEs. A subset of this information is passed to
  188. * the Target during startup as a prerequisite to entering BMI phase.
  189. * See:
  190. * target_service_to_ce_map - Target-side mapping
  191. * hif_map_service_to_pipe - Host-side mapping
  192. * target_ce_config - Target-side configuration
  193. * host_ce_config - Host-side configuration
  194. ============================================================================
  195. Purpose | Service / Endpoint | CE | Dire | Xfer | Xfer
  196. | | | ctio | Size | Frequency
  197. | | | n | |
  198. ============================================================================
  199. tx | HTT_DATA (downlink) | CE 0 | h->t | medium - | very frequent
  200. descriptor | | | | O(100B) | and regular
  201. download | | | | |
  202. ----------------------------------------------------------------------------
  203. rx | HTT_DATA (uplink) | CE 1 | t->h | small - | frequent and
  204. indication | | | | O(10B) | regular
  205. upload | | | | |
  206. ----------------------------------------------------------------------------
  207. MSDU | DATA_BK (uplink) | CE 2 | t->h | large - | rare
  208. upload | | | | O(1000B) | (frequent
  209. e.g. noise | | | | | during IP1.0
  210. packets | | | | | testing)
  211. ----------------------------------------------------------------------------
  212. MSDU | DATA_BK (downlink) | CE 3 | h->t | large - | very rare
  213. download | | | | O(1000B) | (frequent
  214. e.g. | | | | | during IP1.0
  215. misdirecte | | | | | testing)
  216. d EAPOL | | | | |
  217. packets | | | | |
  218. ----------------------------------------------------------------------------
  219. n/a | DATA_BE, DATA_VI | CE 2 | t->h | | never(?)
  220. | DATA_VO (uplink) | | | |
  221. ----------------------------------------------------------------------------
  222. n/a | DATA_BE, DATA_VI | CE 3 | h->t | | never(?)
  223. | DATA_VO (downlink) | | | |
  224. ----------------------------------------------------------------------------
  225. WMI events | WMI_CONTROL (uplink) | CE 4 | t->h | medium - | infrequent
  226. | | | | O(100B) |
  227. ----------------------------------------------------------------------------
  228. WMI | WMI_CONTROL | CE 5 | h->t | medium - | infrequent
  229. messages | (downlink) | | | O(100B) |
  230. | | | | |
  231. ----------------------------------------------------------------------------
  232. n/a | HTC_CTRL_RSVD, | CE 1 | t->h | | never(?)
  233. | HTC_RAW_STREAMS | | | |
  234. | (uplink) | | | |
  235. ----------------------------------------------------------------------------
  236. n/a | HTC_CTRL_RSVD, | CE 0 | h->t | | never(?)
  237. | HTC_RAW_STREAMS | | | |
  238. | (downlink) | | | |
  239. ----------------------------------------------------------------------------
  240. diag | none (raw CE) | CE 7 | t<>h | 4 | Diag Window
  241. | | | | | infrequent
  242. ============================================================================
  243. */
  244. /*
  245. * Map from service/endpoint to Copy Engine.
  246. * This table is derived from the CE_PCI TABLE, above.
  247. * It is passed to the Target at startup for use by firmware.
  248. */
  249. static struct service_to_pipe target_service_to_ce_map_wlan[] = {
  250. {
  251. WMI_DATA_VO_SVC,
  252. PIPEDIR_OUT, /* out = UL = host -> target */
  253. 3,
  254. },
  255. {
  256. WMI_DATA_VO_SVC,
  257. PIPEDIR_IN, /* in = DL = target -> host */
  258. 2,
  259. },
  260. {
  261. WMI_DATA_BK_SVC,
  262. PIPEDIR_OUT, /* out = UL = host -> target */
  263. 3,
  264. },
  265. {
  266. WMI_DATA_BK_SVC,
  267. PIPEDIR_IN, /* in = DL = target -> host */
  268. 2,
  269. },
  270. {
  271. WMI_DATA_BE_SVC,
  272. PIPEDIR_OUT, /* out = UL = host -> target */
  273. 3,
  274. },
  275. {
  276. WMI_DATA_BE_SVC,
  277. PIPEDIR_IN, /* in = DL = target -> host */
  278. 2,
  279. },
  280. {
  281. WMI_DATA_VI_SVC,
  282. PIPEDIR_OUT, /* out = UL = host -> target */
  283. 3,
  284. },
  285. {
  286. WMI_DATA_VI_SVC,
  287. PIPEDIR_IN, /* in = DL = target -> host */
  288. 2,
  289. },
  290. {
  291. WMI_CONTROL_SVC,
  292. PIPEDIR_OUT, /* out = UL = host -> target */
  293. 3,
  294. },
  295. {
  296. WMI_CONTROL_SVC,
  297. PIPEDIR_IN, /* in = DL = target -> host */
  298. 2,
  299. },
  300. {
  301. HTC_CTRL_RSVD_SVC,
  302. PIPEDIR_OUT, /* out = UL = host -> target */
  303. 0, /* could be moved to 3 (share with WMI) */
  304. },
  305. {
  306. HTC_CTRL_RSVD_SVC,
  307. PIPEDIR_IN, /* in = DL = target -> host */
  308. 2,
  309. },
  310. {
  311. HTC_RAW_STREAMS_SVC, /* not currently used */
  312. PIPEDIR_OUT, /* out = UL = host -> target */
  313. 0,
  314. },
  315. {
  316. HTC_RAW_STREAMS_SVC, /* not currently used */
  317. PIPEDIR_IN, /* in = DL = target -> host */
  318. 2,
  319. },
  320. {
  321. HTT_DATA_MSG_SVC,
  322. PIPEDIR_OUT, /* out = UL = host -> target */
  323. 4,
  324. },
  325. {
  326. HTT_DATA_MSG_SVC,
  327. PIPEDIR_IN, /* in = DL = target -> host */
  328. 1,
  329. },
  330. {
  331. WDI_IPA_TX_SVC,
  332. PIPEDIR_OUT, /* in = DL = target -> host */
  333. 5,
  334. },
  335. #if defined(QCA_WIFI_3_0_ADRASTEA)
  336. {
  337. HTT_DATA2_MSG_SVC,
  338. PIPEDIR_IN, /* in = DL = target -> host */
  339. 9,
  340. },
  341. {
  342. HTT_DATA3_MSG_SVC,
  343. PIPEDIR_IN, /* in = DL = target -> host */
  344. 10,
  345. },
  346. {
  347. PACKET_LOG_SVC,
  348. PIPEDIR_IN, /* in = DL = target -> host */
  349. 11,
  350. },
  351. #endif
  352. /* (Additions here) */
  353. { /* Must be last */
  354. 0,
  355. 0,
  356. 0,
  357. },
  358. };
  359. /* PIPEDIR_OUT = HOST to Target */
  360. /* PIPEDIR_IN = TARGET to HOST */
  361. static struct service_to_pipe target_service_to_ce_map_qca8074[] = {
  362. { WMI_DATA_VO_SVC, PIPEDIR_OUT, 3, },
  363. { WMI_DATA_VO_SVC, PIPEDIR_IN, 2, },
  364. { WMI_DATA_BK_SVC, PIPEDIR_OUT, 3, },
  365. { WMI_DATA_BK_SVC, PIPEDIR_IN, 2, },
  366. { WMI_DATA_BE_SVC, PIPEDIR_OUT, 3, },
  367. { WMI_DATA_BE_SVC, PIPEDIR_IN, 2, },
  368. { WMI_DATA_VI_SVC, PIPEDIR_OUT, 3, },
  369. { WMI_DATA_VI_SVC, PIPEDIR_IN, 2, },
  370. { WMI_CONTROL_SVC, PIPEDIR_OUT, 3, },
  371. { WMI_CONTROL_SVC, PIPEDIR_IN, 2, },
  372. { WMI_CONTROL_SVC_WMAC1, PIPEDIR_OUT, 7},
  373. { WMI_CONTROL_SVC_WMAC1, PIPEDIR_IN, 2},
  374. { HTC_CTRL_RSVD_SVC, PIPEDIR_OUT, 0, },
  375. { HTC_CTRL_RSVD_SVC, PIPEDIR_IN, 1, },
  376. { HTC_RAW_STREAMS_SVC, PIPEDIR_OUT, 0},
  377. { HTC_RAW_STREAMS_SVC, PIPEDIR_IN, 1 },
  378. { HTT_DATA_MSG_SVC, PIPEDIR_OUT, 4, },
  379. { HTT_DATA_MSG_SVC, PIPEDIR_IN, 1, },
  380. { PACKET_LOG_SVC, PIPEDIR_IN, 5, },
  381. /* (Additions here) */
  382. { 0, 0, 0, },
  383. };
  384. static struct service_to_pipe target_service_to_ce_map_qca6290[] = {
  385. { WMI_DATA_VO_SVC, PIPEDIR_OUT, 3, },
  386. { WMI_DATA_VO_SVC, PIPEDIR_IN , 2, },
  387. { WMI_DATA_BK_SVC, PIPEDIR_OUT, 3, },
  388. { WMI_DATA_BK_SVC, PIPEDIR_IN , 2, },
  389. { WMI_DATA_BE_SVC, PIPEDIR_OUT, 3, },
  390. { WMI_DATA_BE_SVC, PIPEDIR_IN , 2, },
  391. { WMI_DATA_VI_SVC, PIPEDIR_OUT, 3, },
  392. { WMI_DATA_VI_SVC, PIPEDIR_IN , 2, },
  393. { WMI_CONTROL_SVC, PIPEDIR_OUT, 3, },
  394. { WMI_CONTROL_SVC, PIPEDIR_IN , 2, },
  395. { HTC_CTRL_RSVD_SVC, PIPEDIR_OUT, 0, },
  396. { HTC_CTRL_RSVD_SVC, PIPEDIR_IN , 2, },
  397. { HTT_DATA_MSG_SVC, PIPEDIR_OUT, 4, },
  398. { HTT_DATA_MSG_SVC, PIPEDIR_IN , 1, },
  399. /* (Additions here) */
  400. { 0, 0, 0, },
  401. };
  402. static struct service_to_pipe target_service_to_ce_map_ar900b[] = {
  403. {
  404. WMI_DATA_VO_SVC,
  405. PIPEDIR_OUT, /* out = UL = host -> target */
  406. 3,
  407. },
  408. {
  409. WMI_DATA_VO_SVC,
  410. PIPEDIR_IN, /* in = DL = target -> host */
  411. 2,
  412. },
  413. {
  414. WMI_DATA_BK_SVC,
  415. PIPEDIR_OUT, /* out = UL = host -> target */
  416. 3,
  417. },
  418. {
  419. WMI_DATA_BK_SVC,
  420. PIPEDIR_IN, /* in = DL = target -> host */
  421. 2,
  422. },
  423. {
  424. WMI_DATA_BE_SVC,
  425. PIPEDIR_OUT, /* out = UL = host -> target */
  426. 3,
  427. },
  428. {
  429. WMI_DATA_BE_SVC,
  430. PIPEDIR_IN, /* in = DL = target -> host */
  431. 2,
  432. },
  433. {
  434. WMI_DATA_VI_SVC,
  435. PIPEDIR_OUT, /* out = UL = host -> target */
  436. 3,
  437. },
  438. {
  439. WMI_DATA_VI_SVC,
  440. PIPEDIR_IN, /* in = DL = target -> host */
  441. 2,
  442. },
  443. {
  444. WMI_CONTROL_SVC,
  445. PIPEDIR_OUT, /* out = UL = host -> target */
  446. 3,
  447. },
  448. {
  449. WMI_CONTROL_SVC,
  450. PIPEDIR_IN, /* in = DL = target -> host */
  451. 2,
  452. },
  453. {
  454. HTC_CTRL_RSVD_SVC,
  455. PIPEDIR_OUT, /* out = UL = host -> target */
  456. 0, /* could be moved to 3 (share with WMI) */
  457. },
  458. {
  459. HTC_CTRL_RSVD_SVC,
  460. PIPEDIR_IN, /* in = DL = target -> host */
  461. 1,
  462. },
  463. {
  464. HTC_RAW_STREAMS_SVC, /* not currently used */
  465. PIPEDIR_OUT, /* out = UL = host -> target */
  466. 0,
  467. },
  468. {
  469. HTC_RAW_STREAMS_SVC, /* not currently used */
  470. PIPEDIR_IN, /* in = DL = target -> host */
  471. 1,
  472. },
  473. {
  474. HTT_DATA_MSG_SVC,
  475. PIPEDIR_OUT, /* out = UL = host -> target */
  476. 4,
  477. },
  478. #if WLAN_FEATURE_FASTPATH
  479. {
  480. HTT_DATA_MSG_SVC,
  481. PIPEDIR_IN, /* in = DL = target -> host */
  482. 5,
  483. },
  484. #else /* WLAN_FEATURE_FASTPATH */
  485. {
  486. HTT_DATA_MSG_SVC,
  487. PIPEDIR_IN, /* in = DL = target -> host */
  488. 1,
  489. },
  490. #endif /* WLAN_FEATURE_FASTPATH */
  491. /* (Additions here) */
  492. { /* Must be last */
  493. 0,
  494. 0,
  495. 0,
  496. },
  497. };
  498. static struct shadow_reg_cfg *target_shadow_reg_cfg = target_shadow_reg_cfg_map;
  499. static int shadow_cfg_sz = sizeof(target_shadow_reg_cfg_map);
  500. static struct service_to_pipe target_service_to_ce_map_wlan_epping[] = {
  501. {WMI_DATA_VO_SVC, PIPEDIR_OUT, 3,}, /* out = UL = host -> target */
  502. {WMI_DATA_VO_SVC, PIPEDIR_IN, 2,}, /* in = DL = target -> host */
  503. {WMI_DATA_BK_SVC, PIPEDIR_OUT, 4,}, /* out = UL = host -> target */
  504. {WMI_DATA_BK_SVC, PIPEDIR_IN, 1,}, /* in = DL = target -> host */
  505. {WMI_DATA_BE_SVC, PIPEDIR_OUT, 3,}, /* out = UL = host -> target */
  506. {WMI_DATA_BE_SVC, PIPEDIR_IN, 2,}, /* in = DL = target -> host */
  507. {WMI_DATA_VI_SVC, PIPEDIR_OUT, 3,}, /* out = UL = host -> target */
  508. {WMI_DATA_VI_SVC, PIPEDIR_IN, 2,}, /* in = DL = target -> host */
  509. {WMI_CONTROL_SVC, PIPEDIR_OUT, 3,}, /* out = UL = host -> target */
  510. {WMI_CONTROL_SVC, PIPEDIR_IN, 2,}, /* in = DL = target -> host */
  511. {HTC_CTRL_RSVD_SVC, PIPEDIR_OUT, 0,}, /* out = UL = host -> target */
  512. {HTC_CTRL_RSVD_SVC, PIPEDIR_IN, 2,}, /* in = DL = target -> host */
  513. {HTC_RAW_STREAMS_SVC, PIPEDIR_OUT, 0,}, /* out = UL = host -> target */
  514. {HTC_RAW_STREAMS_SVC, PIPEDIR_IN, 2,}, /* in = DL = target -> host */
  515. {HTT_DATA_MSG_SVC, PIPEDIR_OUT, 4,}, /* out = UL = host -> target */
  516. {HTT_DATA_MSG_SVC, PIPEDIR_IN, 1,}, /* in = DL = target -> host */
  517. {0, 0, 0,}, /* Must be last */
  518. };
  519. static void hif_select_service_to_pipe_map(struct hif_softc *scn,
  520. struct service_to_pipe **tgt_svc_map_to_use,
  521. uint32_t *sz_tgt_svc_map_to_use)
  522. {
  523. uint32_t mode = hif_get_conparam(scn);
  524. struct hif_target_info *tgt_info = &scn->target_info;
  525. if (QDF_IS_EPPING_ENABLED(mode)) {
  526. *tgt_svc_map_to_use = target_service_to_ce_map_wlan_epping;
  527. *sz_tgt_svc_map_to_use =
  528. sizeof(target_service_to_ce_map_wlan_epping);
  529. } else {
  530. switch (tgt_info->target_type) {
  531. default:
  532. *tgt_svc_map_to_use = target_service_to_ce_map_wlan;
  533. *sz_tgt_svc_map_to_use =
  534. sizeof(target_service_to_ce_map_wlan);
  535. break;
  536. case TARGET_TYPE_AR900B:
  537. case TARGET_TYPE_QCA9984:
  538. case TARGET_TYPE_IPQ4019:
  539. case TARGET_TYPE_QCA9888:
  540. case TARGET_TYPE_AR9888:
  541. case TARGET_TYPE_AR9888V2:
  542. *tgt_svc_map_to_use = target_service_to_ce_map_ar900b;
  543. *sz_tgt_svc_map_to_use =
  544. sizeof(target_service_to_ce_map_ar900b);
  545. break;
  546. case TARGET_TYPE_QCA6290:
  547. *tgt_svc_map_to_use = target_service_to_ce_map_qca6290;
  548. *sz_tgt_svc_map_to_use =
  549. sizeof(target_service_to_ce_map_qca6290);
  550. break;
  551. case TARGET_TYPE_QCA8074:
  552. *tgt_svc_map_to_use = target_service_to_ce_map_qca8074;
  553. *sz_tgt_svc_map_to_use =
  554. sizeof(target_service_to_ce_map_qca8074);
  555. break;
  556. }
  557. }
  558. }
  559. /**
  560. * ce_mark_datapath() - marks the ce_state->htt_rx_data accordingly
  561. * @ce_state : pointer to the state context of the CE
  562. *
  563. * Description:
  564. * Sets htt_rx_data attribute of the state structure if the
  565. * CE serves one of the HTT DATA services.
  566. *
  567. * Return:
  568. * false (attribute set to false)
  569. * true (attribute set to true);
  570. */
  571. static bool ce_mark_datapath(struct CE_state *ce_state)
  572. {
  573. struct service_to_pipe *svc_map;
  574. uint32_t map_sz, map_len;
  575. int i;
  576. bool rc = false;
  577. if (ce_state != NULL) {
  578. hif_select_service_to_pipe_map(ce_state->scn, &svc_map,
  579. &map_sz);
  580. map_len = map_sz / sizeof(struct service_to_pipe);
  581. for (i = 0; i < map_len; i++) {
  582. if ((svc_map[i].pipenum == ce_state->id) &&
  583. ((svc_map[i].service_id == HTT_DATA_MSG_SVC) ||
  584. (svc_map[i].service_id == HTT_DATA2_MSG_SVC) ||
  585. (svc_map[i].service_id == HTT_DATA3_MSG_SVC))) {
  586. /* HTT CEs are unidirectional */
  587. if (svc_map[i].pipedir == PIPEDIR_IN)
  588. ce_state->htt_rx_data = true;
  589. else
  590. ce_state->htt_tx_data = true;
  591. rc = true;
  592. }
  593. }
  594. }
  595. return rc;
  596. }
  597. /**
  598. * ce_ring_test_initial_indexes() - tests the initial ce ring indexes
  599. * @ce_id: ce in question
  600. * @ring: ring state being examined
  601. * @type: "src_ring" or "dest_ring" string for identifying the ring
  602. *
  603. * Warns on non-zero index values.
  604. * Causes a kernel panic if the ring is not empty durring initialization.
  605. */
  606. static void ce_ring_test_initial_indexes(int ce_id, struct CE_ring_state *ring,
  607. char *type)
  608. {
  609. if (ring->write_index != 0 || ring->sw_index != 0)
  610. HIF_ERROR("ce %d, %s, initial sw_index = %d, initial write_index =%d",
  611. ce_id, type, ring->sw_index, ring->write_index);
  612. if (ring->write_index != ring->sw_index)
  613. QDF_BUG(0);
  614. }
  615. /**
  616. * ce_srng_based() - Does this target use srng
  617. * @ce_state : pointer to the state context of the CE
  618. *
  619. * Description:
  620. * returns true if the target is SRNG based
  621. *
  622. * Return:
  623. * false (attribute set to false)
  624. * true (attribute set to true);
  625. */
  626. bool ce_srng_based(struct hif_softc *scn)
  627. {
  628. struct hif_opaque_softc *hif_hdl = GET_HIF_OPAQUE_HDL(scn);
  629. struct hif_target_info *tgt_info = hif_get_target_info_handle(hif_hdl);
  630. switch (tgt_info->target_type) {
  631. case TARGET_TYPE_QCA8074:
  632. case TARGET_TYPE_QCA6290:
  633. return true;
  634. default:
  635. return false;
  636. }
  637. return false;
  638. }
  639. #ifdef QCA_WIFI_SUPPORT_SRNG
  640. static struct ce_ops *ce_services_attach(struct hif_softc *scn)
  641. {
  642. if (ce_srng_based(scn))
  643. return ce_services_srng();
  644. return ce_services_legacy();
  645. }
  646. #else /* QCA_LITHIUM */
  647. static struct ce_ops *ce_services_attach(struct hif_softc *scn)
  648. {
  649. return ce_services_legacy();
  650. }
  651. #endif /* QCA_LITHIUM */
  652. static void hif_prepare_hal_shadow_register_cfg(struct hif_softc *scn,
  653. struct pld_shadow_reg_v2_cfg **shadow_config,
  654. int *num_shadow_registers_configured) {
  655. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  656. return hif_state->ce_services->ce_prepare_shadow_register_v2_cfg(
  657. scn, shadow_config, num_shadow_registers_configured);
  658. }
  659. static inline uint32_t ce_get_desc_size(struct hif_softc *scn,
  660. uint8_t ring_type)
  661. {
  662. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  663. return hif_state->ce_services->ce_get_desc_size(ring_type);
  664. }
  665. static struct CE_ring_state *ce_alloc_ring_state(struct CE_state *CE_state,
  666. uint8_t ring_type, uint32_t nentries)
  667. {
  668. uint32_t ce_nbytes;
  669. char *ptr;
  670. qdf_dma_addr_t base_addr;
  671. struct CE_ring_state *ce_ring;
  672. uint32_t desc_size;
  673. struct hif_softc *scn = CE_state->scn;
  674. ce_nbytes = sizeof(struct CE_ring_state)
  675. + (nentries * sizeof(void *));
  676. ptr = qdf_mem_malloc(ce_nbytes);
  677. if (!ptr)
  678. return NULL;
  679. ce_ring = (struct CE_ring_state *)ptr;
  680. ptr += sizeof(struct CE_ring_state);
  681. ce_ring->nentries = nentries;
  682. ce_ring->nentries_mask = nentries - 1;
  683. ce_ring->low_water_mark_nentries = 0;
  684. ce_ring->high_water_mark_nentries = nentries;
  685. ce_ring->per_transfer_context = (void **)ptr;
  686. desc_size = ce_get_desc_size(scn, ring_type);
  687. /* Legacy platforms that do not support cache
  688. * coherent DMA are unsupported
  689. */
  690. ce_ring->base_addr_owner_space_unaligned =
  691. qdf_mem_alloc_consistent(scn->qdf_dev,
  692. scn->qdf_dev->dev,
  693. (nentries *
  694. desc_size +
  695. CE_DESC_RING_ALIGN),
  696. &base_addr);
  697. if (ce_ring->base_addr_owner_space_unaligned
  698. == NULL) {
  699. HIF_ERROR("%s: ring has no DMA mem",
  700. __func__);
  701. qdf_mem_free(ptr);
  702. return NULL;
  703. }
  704. ce_ring->base_addr_CE_space_unaligned = base_addr;
  705. /* Correctly initialize memory to 0 to
  706. * prevent garbage data crashing system
  707. * when download firmware
  708. */
  709. qdf_mem_zero(ce_ring->base_addr_owner_space_unaligned,
  710. nentries * desc_size +
  711. CE_DESC_RING_ALIGN);
  712. if (ce_ring->base_addr_CE_space_unaligned & (CE_DESC_RING_ALIGN - 1)) {
  713. ce_ring->base_addr_CE_space =
  714. (ce_ring->base_addr_CE_space_unaligned +
  715. CE_DESC_RING_ALIGN - 1) & ~(CE_DESC_RING_ALIGN - 1);
  716. ce_ring->base_addr_owner_space = (void *)
  717. (((size_t) ce_ring->base_addr_owner_space_unaligned +
  718. CE_DESC_RING_ALIGN - 1) & ~(CE_DESC_RING_ALIGN - 1));
  719. } else {
  720. ce_ring->base_addr_CE_space =
  721. ce_ring->base_addr_CE_space_unaligned;
  722. ce_ring->base_addr_owner_space =
  723. ce_ring->base_addr_owner_space_unaligned;
  724. }
  725. return ce_ring;
  726. }
  727. static int ce_ring_setup(struct hif_softc *scn, uint8_t ring_type,
  728. uint32_t ce_id, struct CE_ring_state *ring,
  729. struct CE_attr *attr)
  730. {
  731. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  732. return hif_state->ce_services->ce_ring_setup(scn, ring_type, ce_id,
  733. ring, attr);
  734. }
  735. int hif_ce_bus_early_suspend(struct hif_softc *scn)
  736. {
  737. uint8_t ul_pipe, dl_pipe;
  738. int ce_id, status, ul_is_polled, dl_is_polled;
  739. struct CE_state *ce_state;
  740. status = hif_map_service_to_pipe(&scn->osc, WMI_CONTROL_SVC,
  741. &ul_pipe, &dl_pipe,
  742. &ul_is_polled, &dl_is_polled);
  743. if (status) {
  744. HIF_ERROR("%s: pipe_mapping failure", __func__);
  745. return status;
  746. }
  747. for (ce_id = 0; ce_id < scn->ce_count; ce_id++) {
  748. if (ce_id == ul_pipe)
  749. continue;
  750. if (ce_id == dl_pipe)
  751. continue;
  752. ce_state = scn->ce_id_to_state[ce_id];
  753. qdf_spin_lock_bh(&ce_state->ce_index_lock);
  754. if (ce_state->state == CE_RUNNING)
  755. ce_state->state = CE_PAUSED;
  756. qdf_spin_unlock_bh(&ce_state->ce_index_lock);
  757. }
  758. return status;
  759. }
  760. int hif_ce_bus_late_resume(struct hif_softc *scn)
  761. {
  762. int ce_id;
  763. struct CE_state *ce_state;
  764. int write_index;
  765. bool index_updated;
  766. for (ce_id = 0; ce_id < scn->ce_count; ce_id++) {
  767. ce_state = scn->ce_id_to_state[ce_id];
  768. qdf_spin_lock_bh(&ce_state->ce_index_lock);
  769. if (ce_state->state == CE_PENDING) {
  770. write_index = ce_state->src_ring->write_index;
  771. CE_SRC_RING_WRITE_IDX_SET(scn, ce_state->ctrl_addr,
  772. write_index);
  773. ce_state->state = CE_RUNNING;
  774. index_updated = true;
  775. } else {
  776. index_updated = false;
  777. }
  778. if (ce_state->state == CE_PAUSED)
  779. ce_state->state = CE_RUNNING;
  780. qdf_spin_unlock_bh(&ce_state->ce_index_lock);
  781. if (index_updated)
  782. hif_record_ce_desc_event(scn, ce_id,
  783. RESUME_WRITE_INDEX_UPDATE,
  784. NULL, NULL, write_index);
  785. }
  786. return 0;
  787. }
  788. /**
  789. * ce_oom_recovery() - try to recover rx ce from oom condition
  790. * @context: CE_state of the CE with oom rx ring
  791. *
  792. * the executing work Will continue to be rescheduled untill
  793. * at least 1 descriptor is successfully posted to the rx ring.
  794. *
  795. * return: none
  796. */
  797. static void ce_oom_recovery(void *context)
  798. {
  799. struct CE_state *ce_state = context;
  800. struct hif_softc *scn = ce_state->scn;
  801. struct HIF_CE_state *ce_softc = HIF_GET_CE_STATE(scn);
  802. struct HIF_CE_pipe_info *pipe_info =
  803. &ce_softc->pipe_info[ce_state->id];
  804. hif_post_recv_buffers_for_pipe(pipe_info);
  805. }
  806. /*
  807. * Initialize a Copy Engine based on caller-supplied attributes.
  808. * This may be called once to initialize both source and destination
  809. * rings or it may be called twice for separate source and destination
  810. * initialization. It may be that only one side or the other is
  811. * initialized by software/firmware.
  812. *
  813. * This should be called durring the initialization sequence before
  814. * interupts are enabled, so we don't have to worry about thread safety.
  815. */
  816. struct CE_handle *ce_init(struct hif_softc *scn,
  817. unsigned int CE_id, struct CE_attr *attr)
  818. {
  819. struct CE_state *CE_state;
  820. uint32_t ctrl_addr;
  821. unsigned int nentries;
  822. bool malloc_CE_state = false;
  823. bool malloc_src_ring = false;
  824. int status;
  825. QDF_ASSERT(CE_id < scn->ce_count);
  826. ctrl_addr = CE_BASE_ADDRESS(CE_id);
  827. CE_state = scn->ce_id_to_state[CE_id];
  828. if (!CE_state) {
  829. CE_state =
  830. (struct CE_state *)qdf_mem_malloc(sizeof(*CE_state));
  831. if (!CE_state) {
  832. HIF_ERROR("%s: CE_state has no mem", __func__);
  833. return NULL;
  834. }
  835. malloc_CE_state = true;
  836. qdf_spinlock_create(&CE_state->ce_index_lock);
  837. CE_state->id = CE_id;
  838. CE_state->ctrl_addr = ctrl_addr;
  839. CE_state->state = CE_RUNNING;
  840. CE_state->attr_flags = attr->flags;
  841. }
  842. CE_state->scn = scn;
  843. qdf_atomic_init(&CE_state->rx_pending);
  844. if (attr == NULL) {
  845. /* Already initialized; caller wants the handle */
  846. return (struct CE_handle *)CE_state;
  847. }
  848. if (CE_state->src_sz_max)
  849. QDF_ASSERT(CE_state->src_sz_max == attr->src_sz_max);
  850. else
  851. CE_state->src_sz_max = attr->src_sz_max;
  852. ce_init_ce_desc_event_log(CE_id,
  853. attr->src_nentries + attr->dest_nentries);
  854. /* source ring setup */
  855. nentries = attr->src_nentries;
  856. if (nentries) {
  857. struct CE_ring_state *src_ring;
  858. nentries = roundup_pwr2(nentries);
  859. if (CE_state->src_ring) {
  860. QDF_ASSERT(CE_state->src_ring->nentries == nentries);
  861. } else {
  862. src_ring = CE_state->src_ring =
  863. ce_alloc_ring_state(CE_state,
  864. CE_RING_SRC,
  865. nentries);
  866. if (!src_ring) {
  867. /* cannot allocate src ring. If the
  868. * CE_state is allocated locally free
  869. * CE_State and return error.
  870. */
  871. HIF_ERROR("%s: src ring has no mem", __func__);
  872. if (malloc_CE_state) {
  873. /* allocated CE_state locally */
  874. qdf_mem_free(CE_state);
  875. malloc_CE_state = false;
  876. }
  877. return NULL;
  878. }
  879. /* we can allocate src ring. Mark that the src ring is
  880. * allocated locally
  881. */
  882. malloc_src_ring = true;
  883. /*
  884. * Also allocate a shadow src ring in
  885. * regular mem to use for faster access.
  886. */
  887. src_ring->shadow_base_unaligned =
  888. qdf_mem_malloc(nentries *
  889. sizeof(struct CE_src_desc) +
  890. CE_DESC_RING_ALIGN);
  891. if (src_ring->shadow_base_unaligned == NULL) {
  892. HIF_ERROR("%s: src ring no shadow_base mem",
  893. __func__);
  894. goto error_no_dma_mem;
  895. }
  896. src_ring->shadow_base = (struct CE_src_desc *)
  897. (((size_t) src_ring->shadow_base_unaligned +
  898. CE_DESC_RING_ALIGN - 1) &
  899. ~(CE_DESC_RING_ALIGN - 1));
  900. status = ce_ring_setup(scn, CE_RING_SRC, CE_id,
  901. src_ring, attr);
  902. if (status < 0)
  903. goto error_target_access;
  904. ce_ring_test_initial_indexes(CE_id, src_ring,
  905. "src_ring");
  906. }
  907. }
  908. /* destination ring setup */
  909. nentries = attr->dest_nentries;
  910. if (nentries) {
  911. struct CE_ring_state *dest_ring;
  912. nentries = roundup_pwr2(nentries);
  913. if (CE_state->dest_ring) {
  914. QDF_ASSERT(CE_state->dest_ring->nentries == nentries);
  915. } else {
  916. dest_ring = CE_state->dest_ring =
  917. ce_alloc_ring_state(CE_state,
  918. CE_RING_DEST,
  919. nentries);
  920. if (!dest_ring) {
  921. /* cannot allocate dst ring. If the CE_state
  922. * or src ring is allocated locally free
  923. * CE_State and src ring and return error.
  924. */
  925. HIF_ERROR("%s: dest ring has no mem",
  926. __func__);
  927. goto error_no_dma_mem;
  928. }
  929. status = ce_ring_setup(scn, CE_RING_DEST, CE_id,
  930. dest_ring, attr);
  931. if (status < 0)
  932. goto error_target_access;
  933. ce_ring_test_initial_indexes(CE_id, dest_ring,
  934. "dest_ring");
  935. /* For srng based target, init status ring here */
  936. if (ce_srng_based(CE_state->scn)) {
  937. CE_state->status_ring =
  938. ce_alloc_ring_state(CE_state,
  939. CE_RING_STATUS,
  940. nentries);
  941. if (CE_state->status_ring == NULL) {
  942. /*Allocation failed. Cleanup*/
  943. qdf_mem_free(CE_state->dest_ring);
  944. if (malloc_src_ring) {
  945. qdf_mem_free
  946. (CE_state->src_ring);
  947. CE_state->src_ring = NULL;
  948. malloc_src_ring = false;
  949. }
  950. if (malloc_CE_state) {
  951. /* allocated CE_state locally */
  952. scn->ce_id_to_state[CE_id] =
  953. NULL;
  954. qdf_mem_free(CE_state);
  955. malloc_CE_state = false;
  956. }
  957. return NULL;
  958. }
  959. status = ce_ring_setup(scn, CE_RING_STATUS,
  960. CE_id, CE_state->status_ring,
  961. attr);
  962. if (status < 0)
  963. goto error_target_access;
  964. }
  965. /* epping */
  966. /* poll timer */
  967. if ((CE_state->attr_flags & CE_ATTR_ENABLE_POLL)) {
  968. qdf_timer_init(scn->qdf_dev,
  969. &CE_state->poll_timer,
  970. ce_poll_timeout,
  971. CE_state,
  972. QDF_TIMER_TYPE_SW);
  973. CE_state->timer_inited = true;
  974. qdf_timer_mod(&CE_state->poll_timer,
  975. CE_POLL_TIMEOUT);
  976. }
  977. }
  978. }
  979. if (!ce_srng_based(scn)) {
  980. /* Enable CE error interrupts */
  981. if (Q_TARGET_ACCESS_BEGIN(scn) < 0)
  982. goto error_target_access;
  983. CE_ERROR_INTR_ENABLE(scn, ctrl_addr);
  984. if (Q_TARGET_ACCESS_END(scn) < 0)
  985. goto error_target_access;
  986. }
  987. qdf_create_work(scn->qdf_dev, &CE_state->oom_allocation_work,
  988. ce_oom_recovery, CE_state);
  989. /* update the htt_data attribute */
  990. ce_mark_datapath(CE_state);
  991. scn->ce_id_to_state[CE_id] = CE_state;
  992. return (struct CE_handle *)CE_state;
  993. error_target_access:
  994. error_no_dma_mem:
  995. ce_fini((struct CE_handle *)CE_state);
  996. return NULL;
  997. }
  998. #ifdef WLAN_FEATURE_FASTPATH
  999. /**
  1000. * hif_enable_fastpath() Update that we have enabled fastpath mode
  1001. * @hif_ctx: HIF context
  1002. *
  1003. * For use in data path
  1004. *
  1005. * Retrun: void
  1006. */
  1007. void hif_enable_fastpath(struct hif_opaque_softc *hif_ctx)
  1008. {
  1009. struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
  1010. if (ce_srng_based(scn)) {
  1011. HIF_INFO("%s, srng rings do not support fastpath", __func__);
  1012. return;
  1013. }
  1014. HIF_DBG("%s, Enabling fastpath mode", __func__);
  1015. scn->fastpath_mode_on = true;
  1016. }
  1017. /**
  1018. * hif_is_fastpath_mode_enabled - API to query if fasthpath mode is enabled
  1019. * @hif_ctx: HIF Context
  1020. *
  1021. * For use in data path to skip HTC
  1022. *
  1023. * Return: bool
  1024. */
  1025. bool hif_is_fastpath_mode_enabled(struct hif_opaque_softc *hif_ctx)
  1026. {
  1027. struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
  1028. return scn->fastpath_mode_on;
  1029. }
  1030. /**
  1031. * hif_get_ce_handle - API to get CE handle for FastPath mode
  1032. * @hif_ctx: HIF Context
  1033. * @id: CopyEngine Id
  1034. *
  1035. * API to return CE handle for fastpath mode
  1036. *
  1037. * Return: void
  1038. */
  1039. void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int id)
  1040. {
  1041. struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
  1042. return scn->ce_id_to_state[id];
  1043. }
  1044. /**
  1045. * ce_h2t_tx_ce_cleanup() Place holder function for H2T CE cleanup.
  1046. * No processing is required inside this function.
  1047. * @ce_hdl: Cope engine handle
  1048. * Using an assert, this function makes sure that,
  1049. * the TX CE has been processed completely.
  1050. *
  1051. * This is called while dismantling CE structures. No other thread
  1052. * should be using these structures while dismantling is occuring
  1053. * therfore no locking is needed.
  1054. *
  1055. * Return: none
  1056. */
  1057. void ce_h2t_tx_ce_cleanup(struct CE_handle *ce_hdl)
  1058. {
  1059. struct CE_state *ce_state = (struct CE_state *)ce_hdl;
  1060. struct CE_ring_state *src_ring = ce_state->src_ring;
  1061. struct hif_softc *sc = ce_state->scn;
  1062. uint32_t sw_index, write_index;
  1063. if (hif_is_nss_wifi_enabled(sc))
  1064. return;
  1065. if (sc->fastpath_mode_on && ce_state->htt_tx_data) {
  1066. HIF_DBG("%s %d Fastpath mode ON, Cleaning up HTT Tx CE",
  1067. __func__, __LINE__);
  1068. sw_index = src_ring->sw_index;
  1069. write_index = src_ring->sw_index;
  1070. /* At this point Tx CE should be clean */
  1071. qdf_assert_always(sw_index == write_index);
  1072. }
  1073. }
  1074. /**
  1075. * ce_t2h_msg_ce_cleanup() - Cleanup buffers on the t2h datapath msg queue.
  1076. * @ce_hdl: Handle to CE
  1077. *
  1078. * These buffers are never allocated on the fly, but
  1079. * are allocated only once during HIF start and freed
  1080. * only once during HIF stop.
  1081. * NOTE:
  1082. * The assumption here is there is no in-flight DMA in progress
  1083. * currently, so that buffers can be freed up safely.
  1084. *
  1085. * Return: NONE
  1086. */
  1087. void ce_t2h_msg_ce_cleanup(struct CE_handle *ce_hdl)
  1088. {
  1089. struct CE_state *ce_state = (struct CE_state *)ce_hdl;
  1090. struct CE_ring_state *dst_ring = ce_state->dest_ring;
  1091. qdf_nbuf_t nbuf;
  1092. int i;
  1093. if (ce_state->scn->fastpath_mode_on == false)
  1094. return;
  1095. if (!ce_state->htt_rx_data)
  1096. return;
  1097. /*
  1098. * when fastpath_mode is on and for datapath CEs. Unlike other CE's,
  1099. * this CE is completely full: does not leave one blank space, to
  1100. * distinguish between empty queue & full queue. So free all the
  1101. * entries.
  1102. */
  1103. for (i = 0; i < dst_ring->nentries; i++) {
  1104. nbuf = dst_ring->per_transfer_context[i];
  1105. /*
  1106. * The reasons for doing this check are:
  1107. * 1) Protect against calling cleanup before allocating buffers
  1108. * 2) In a corner case, FASTPATH_mode_on may be set, but we
  1109. * could have a partially filled ring, because of a memory
  1110. * allocation failure in the middle of allocating ring.
  1111. * This check accounts for that case, checking
  1112. * fastpath_mode_on flag or started flag would not have
  1113. * covered that case. This is not in performance path,
  1114. * so OK to do this.
  1115. */
  1116. if (nbuf) {
  1117. qdf_nbuf_unmap_single(ce_state->scn->qdf_dev, nbuf,
  1118. QDF_DMA_FROM_DEVICE);
  1119. qdf_nbuf_free(nbuf);
  1120. }
  1121. }
  1122. }
  1123. /**
  1124. * hif_update_fastpath_recv_bufs_cnt() - Increments the Rx buf count by 1
  1125. * @scn: HIF handle
  1126. *
  1127. * Datapath Rx CEs are special case, where we reuse all the message buffers.
  1128. * Hence we have to post all the entries in the pipe, even, in the beginning
  1129. * unlike for other CE pipes where one less than dest_nentries are filled in
  1130. * the beginning.
  1131. *
  1132. * Return: None
  1133. */
  1134. static void hif_update_fastpath_recv_bufs_cnt(struct hif_softc *scn)
  1135. {
  1136. int pipe_num;
  1137. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  1138. if (scn->fastpath_mode_on == false)
  1139. return;
  1140. for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) {
  1141. struct HIF_CE_pipe_info *pipe_info =
  1142. &hif_state->pipe_info[pipe_num];
  1143. struct CE_state *ce_state =
  1144. scn->ce_id_to_state[pipe_info->pipe_num];
  1145. if (ce_state->htt_rx_data)
  1146. atomic_inc(&pipe_info->recv_bufs_needed);
  1147. }
  1148. }
  1149. #else
  1150. static inline void hif_update_fastpath_recv_bufs_cnt(struct hif_softc *scn)
  1151. {
  1152. }
  1153. static inline bool ce_is_fastpath_enabled(struct hif_softc *scn)
  1154. {
  1155. return false;
  1156. }
  1157. static inline bool ce_is_fastpath_handler_registered(struct CE_state *ce_state)
  1158. {
  1159. return false;
  1160. }
  1161. #endif /* WLAN_FEATURE_FASTPATH */
  1162. void ce_fini(struct CE_handle *copyeng)
  1163. {
  1164. struct CE_state *CE_state = (struct CE_state *)copyeng;
  1165. unsigned int CE_id = CE_state->id;
  1166. struct hif_softc *scn = CE_state->scn;
  1167. CE_state->state = CE_UNUSED;
  1168. scn->ce_id_to_state[CE_id] = NULL;
  1169. qdf_lro_deinit(CE_state->lro_data);
  1170. if (CE_state->src_ring) {
  1171. /* Cleanup the datapath Tx ring */
  1172. ce_h2t_tx_ce_cleanup(copyeng);
  1173. if (CE_state->src_ring->shadow_base_unaligned)
  1174. qdf_mem_free(CE_state->src_ring->shadow_base_unaligned);
  1175. if (CE_state->src_ring->base_addr_owner_space_unaligned)
  1176. qdf_mem_free_consistent(scn->qdf_dev,
  1177. scn->qdf_dev->dev,
  1178. (CE_state->src_ring->nentries *
  1179. sizeof(struct CE_src_desc) +
  1180. CE_DESC_RING_ALIGN),
  1181. CE_state->src_ring->
  1182. base_addr_owner_space_unaligned,
  1183. CE_state->src_ring->
  1184. base_addr_CE_space, 0);
  1185. qdf_mem_free(CE_state->src_ring);
  1186. }
  1187. if (CE_state->dest_ring) {
  1188. /* Cleanup the datapath Rx ring */
  1189. ce_t2h_msg_ce_cleanup(copyeng);
  1190. if (CE_state->dest_ring->base_addr_owner_space_unaligned)
  1191. qdf_mem_free_consistent(scn->qdf_dev,
  1192. scn->qdf_dev->dev,
  1193. (CE_state->dest_ring->nentries *
  1194. sizeof(struct CE_dest_desc) +
  1195. CE_DESC_RING_ALIGN),
  1196. CE_state->dest_ring->
  1197. base_addr_owner_space_unaligned,
  1198. CE_state->dest_ring->
  1199. base_addr_CE_space, 0);
  1200. qdf_mem_free(CE_state->dest_ring);
  1201. /* epping */
  1202. if (CE_state->timer_inited) {
  1203. CE_state->timer_inited = false;
  1204. qdf_timer_free(&CE_state->poll_timer);
  1205. }
  1206. }
  1207. if ((ce_srng_based(CE_state->scn)) && (CE_state->status_ring)) {
  1208. /* Cleanup the datapath Tx ring */
  1209. ce_h2t_tx_ce_cleanup(copyeng);
  1210. if (CE_state->status_ring->shadow_base_unaligned)
  1211. qdf_mem_free(
  1212. CE_state->status_ring->shadow_base_unaligned);
  1213. if (CE_state->status_ring->base_addr_owner_space_unaligned)
  1214. qdf_mem_free_consistent(scn->qdf_dev,
  1215. scn->qdf_dev->dev,
  1216. (CE_state->status_ring->nentries *
  1217. sizeof(struct CE_src_desc) +
  1218. CE_DESC_RING_ALIGN),
  1219. CE_state->status_ring->
  1220. base_addr_owner_space_unaligned,
  1221. CE_state->status_ring->
  1222. base_addr_CE_space, 0);
  1223. qdf_mem_free(CE_state->status_ring);
  1224. }
  1225. qdf_spinlock_destroy(&CE_state->ce_index_lock);
  1226. qdf_mem_free(CE_state);
  1227. }
  1228. void hif_detach_htc(struct hif_opaque_softc *hif_ctx)
  1229. {
  1230. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
  1231. qdf_mem_zero(&hif_state->msg_callbacks_pending,
  1232. sizeof(hif_state->msg_callbacks_pending));
  1233. qdf_mem_zero(&hif_state->msg_callbacks_current,
  1234. sizeof(hif_state->msg_callbacks_current));
  1235. }
  1236. /* Send the first nbytes bytes of the buffer */
  1237. QDF_STATUS
  1238. hif_send_head(struct hif_opaque_softc *hif_ctx,
  1239. uint8_t pipe, unsigned int transfer_id, unsigned int nbytes,
  1240. qdf_nbuf_t nbuf, unsigned int data_attr)
  1241. {
  1242. struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
  1243. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
  1244. struct HIF_CE_pipe_info *pipe_info = &(hif_state->pipe_info[pipe]);
  1245. struct CE_handle *ce_hdl = pipe_info->ce_hdl;
  1246. int bytes = nbytes, nfrags = 0;
  1247. struct ce_sendlist sendlist;
  1248. int status, i = 0;
  1249. unsigned int mux_id = 0;
  1250. QDF_ASSERT(nbytes <= qdf_nbuf_len(nbuf));
  1251. transfer_id =
  1252. (mux_id & MUX_ID_MASK) |
  1253. (transfer_id & TRANSACTION_ID_MASK);
  1254. data_attr &= DESC_DATA_FLAG_MASK;
  1255. /*
  1256. * The common case involves sending multiple fragments within a
  1257. * single download (the tx descriptor and the tx frame header).
  1258. * So, optimize for the case of multiple fragments by not even
  1259. * checking whether it's necessary to use a sendlist.
  1260. * The overhead of using a sendlist for a single buffer download
  1261. * is not a big deal, since it happens rarely (for WMI messages).
  1262. */
  1263. ce_sendlist_init(&sendlist);
  1264. do {
  1265. qdf_dma_addr_t frag_paddr;
  1266. int frag_bytes;
  1267. frag_paddr = qdf_nbuf_get_frag_paddr(nbuf, nfrags);
  1268. frag_bytes = qdf_nbuf_get_frag_len(nbuf, nfrags);
  1269. /*
  1270. * Clear the packet offset for all but the first CE desc.
  1271. */
  1272. if (i++ > 0)
  1273. data_attr &= ~QDF_CE_TX_PKT_OFFSET_BIT_M;
  1274. status = ce_sendlist_buf_add(&sendlist, frag_paddr,
  1275. frag_bytes >
  1276. bytes ? bytes : frag_bytes,
  1277. qdf_nbuf_get_frag_is_wordstream
  1278. (nbuf,
  1279. nfrags) ? 0 :
  1280. CE_SEND_FLAG_SWAP_DISABLE,
  1281. data_attr);
  1282. if (status != QDF_STATUS_SUCCESS) {
  1283. HIF_ERROR("%s: error, frag_num %d larger than limit",
  1284. __func__, nfrags);
  1285. return status;
  1286. }
  1287. bytes -= frag_bytes;
  1288. nfrags++;
  1289. } while (bytes > 0);
  1290. /* Make sure we have resources to handle this request */
  1291. qdf_spin_lock_bh(&pipe_info->completion_freeq_lock);
  1292. if (pipe_info->num_sends_allowed < nfrags) {
  1293. qdf_spin_unlock_bh(&pipe_info->completion_freeq_lock);
  1294. ce_pkt_error_count_incr(hif_state, HIF_PIPE_NO_RESOURCE);
  1295. return QDF_STATUS_E_RESOURCES;
  1296. }
  1297. pipe_info->num_sends_allowed -= nfrags;
  1298. qdf_spin_unlock_bh(&pipe_info->completion_freeq_lock);
  1299. if (qdf_unlikely(ce_hdl == NULL)) {
  1300. HIF_ERROR("%s: error CE handle is null", __func__);
  1301. return A_ERROR;
  1302. }
  1303. QDF_NBUF_UPDATE_TX_PKT_COUNT(nbuf, QDF_NBUF_TX_PKT_HIF);
  1304. DPTRACE(qdf_dp_trace(nbuf, QDF_DP_TRACE_HIF_PACKET_PTR_RECORD,
  1305. QDF_TRACE_DEFAULT_PDEV_ID, qdf_nbuf_data_addr(nbuf),
  1306. sizeof(qdf_nbuf_data(nbuf)), QDF_TX));
  1307. status = ce_sendlist_send(ce_hdl, nbuf, &sendlist, transfer_id);
  1308. QDF_ASSERT(status == QDF_STATUS_SUCCESS);
  1309. return status;
  1310. }
  1311. void hif_send_complete_check(struct hif_opaque_softc *hif_ctx, uint8_t pipe,
  1312. int force)
  1313. {
  1314. struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
  1315. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
  1316. if (!force) {
  1317. int resources;
  1318. /*
  1319. * Decide whether to actually poll for completions, or just
  1320. * wait for a later chance. If there seem to be plenty of
  1321. * resources left, then just wait, since checking involves
  1322. * reading a CE register, which is a relatively expensive
  1323. * operation.
  1324. */
  1325. resources = hif_get_free_queue_number(hif_ctx, pipe);
  1326. /*
  1327. * If at least 50% of the total resources are still available,
  1328. * don't bother checking again yet.
  1329. */
  1330. if (resources > (hif_state->host_ce_config[pipe].src_nentries >>
  1331. 1))
  1332. return;
  1333. }
  1334. #if ATH_11AC_TXCOMPACT
  1335. ce_per_engine_servicereap(scn, pipe);
  1336. #else
  1337. ce_per_engine_service(scn, pipe);
  1338. #endif
  1339. }
  1340. uint16_t
  1341. hif_get_free_queue_number(struct hif_opaque_softc *hif_ctx, uint8_t pipe)
  1342. {
  1343. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
  1344. struct HIF_CE_pipe_info *pipe_info = &(hif_state->pipe_info[pipe]);
  1345. uint16_t rv;
  1346. qdf_spin_lock_bh(&pipe_info->completion_freeq_lock);
  1347. rv = pipe_info->num_sends_allowed;
  1348. qdf_spin_unlock_bh(&pipe_info->completion_freeq_lock);
  1349. return rv;
  1350. }
  1351. /* Called by lower (CE) layer when a send to Target completes. */
  1352. static void
  1353. hif_pci_ce_send_done(struct CE_handle *copyeng, void *ce_context,
  1354. void *transfer_context, qdf_dma_addr_t CE_data,
  1355. unsigned int nbytes, unsigned int transfer_id,
  1356. unsigned int sw_index, unsigned int hw_index,
  1357. unsigned int toeplitz_hash_result)
  1358. {
  1359. struct HIF_CE_pipe_info *pipe_info =
  1360. (struct HIF_CE_pipe_info *)ce_context;
  1361. struct HIF_CE_state *hif_state = pipe_info->HIF_CE_state;
  1362. struct hif_softc *scn = HIF_GET_SOFTC(hif_state);
  1363. unsigned int sw_idx = sw_index, hw_idx = hw_index;
  1364. struct hif_msg_callbacks *msg_callbacks =
  1365. &pipe_info->pipe_callbacks;
  1366. do {
  1367. /*
  1368. * The upper layer callback will be triggered
  1369. * when last fragment is complteted.
  1370. */
  1371. if (transfer_context != CE_SENDLIST_ITEM_CTXT) {
  1372. if (scn->target_status == TARGET_STATUS_RESET) {
  1373. qdf_nbuf_unmap_single(scn->qdf_dev,
  1374. transfer_context,
  1375. QDF_DMA_TO_DEVICE);
  1376. qdf_nbuf_free(transfer_context);
  1377. } else
  1378. msg_callbacks->txCompletionHandler(
  1379. msg_callbacks->Context,
  1380. transfer_context, transfer_id,
  1381. toeplitz_hash_result);
  1382. }
  1383. qdf_spin_lock(&pipe_info->completion_freeq_lock);
  1384. pipe_info->num_sends_allowed++;
  1385. qdf_spin_unlock(&pipe_info->completion_freeq_lock);
  1386. } while (ce_completed_send_next(copyeng,
  1387. &ce_context, &transfer_context,
  1388. &CE_data, &nbytes, &transfer_id,
  1389. &sw_idx, &hw_idx,
  1390. &toeplitz_hash_result) == QDF_STATUS_SUCCESS);
  1391. }
  1392. /**
  1393. * hif_ce_do_recv(): send message from copy engine to upper layers
  1394. * @msg_callbacks: structure containing callback and callback context
  1395. * @netbuff: skb containing message
  1396. * @nbytes: number of bytes in the message
  1397. * @pipe_info: used for the pipe_number info
  1398. *
  1399. * Checks the packet length, configures the lenght in the netbuff,
  1400. * and calls the upper layer callback.
  1401. *
  1402. * return: None
  1403. */
  1404. static inline void hif_ce_do_recv(struct hif_msg_callbacks *msg_callbacks,
  1405. qdf_nbuf_t netbuf, int nbytes,
  1406. struct HIF_CE_pipe_info *pipe_info) {
  1407. if (nbytes <= pipe_info->buf_sz) {
  1408. qdf_nbuf_set_pktlen(netbuf, nbytes);
  1409. msg_callbacks->
  1410. rxCompletionHandler(msg_callbacks->Context,
  1411. netbuf, pipe_info->pipe_num);
  1412. } else {
  1413. HIF_ERROR("%s: Invalid Rx msg buf:%pK nbytes:%d",
  1414. __func__, netbuf, nbytes);
  1415. qdf_nbuf_free(netbuf);
  1416. }
  1417. }
  1418. /* Called by lower (CE) layer when data is received from the Target. */
  1419. static void
  1420. hif_pci_ce_recv_data(struct CE_handle *copyeng, void *ce_context,
  1421. void *transfer_context, qdf_dma_addr_t CE_data,
  1422. unsigned int nbytes, unsigned int transfer_id,
  1423. unsigned int flags)
  1424. {
  1425. struct HIF_CE_pipe_info *pipe_info =
  1426. (struct HIF_CE_pipe_info *)ce_context;
  1427. struct HIF_CE_state *hif_state = pipe_info->HIF_CE_state;
  1428. struct CE_state *ce_state = (struct CE_state *) copyeng;
  1429. struct hif_softc *scn = HIF_GET_SOFTC(hif_state);
  1430. #ifdef HIF_PCI
  1431. struct hif_pci_softc *hif_pci_sc = HIF_GET_PCI_SOFTC(hif_state);
  1432. #endif
  1433. struct hif_msg_callbacks *msg_callbacks =
  1434. &pipe_info->pipe_callbacks;
  1435. do {
  1436. #ifdef HIF_PCI
  1437. hif_pm_runtime_mark_last_busy(hif_pci_sc->dev);
  1438. #endif
  1439. qdf_nbuf_unmap_single(scn->qdf_dev,
  1440. (qdf_nbuf_t) transfer_context,
  1441. QDF_DMA_FROM_DEVICE);
  1442. atomic_inc(&pipe_info->recv_bufs_needed);
  1443. hif_post_recv_buffers_for_pipe(pipe_info);
  1444. if (scn->target_status == TARGET_STATUS_RESET)
  1445. qdf_nbuf_free(transfer_context);
  1446. else
  1447. hif_ce_do_recv(msg_callbacks, transfer_context,
  1448. nbytes, pipe_info);
  1449. /* Set up force_break flag if num of receices reaches
  1450. * MAX_NUM_OF_RECEIVES
  1451. */
  1452. ce_state->receive_count++;
  1453. if (qdf_unlikely(hif_ce_service_should_yield(scn, ce_state))) {
  1454. ce_state->force_break = 1;
  1455. break;
  1456. }
  1457. } while (ce_completed_recv_next(copyeng, &ce_context, &transfer_context,
  1458. &CE_data, &nbytes, &transfer_id,
  1459. &flags) == QDF_STATUS_SUCCESS);
  1460. }
  1461. /* TBDXXX: Set CE High Watermark; invoke txResourceAvailHandler in response */
  1462. void
  1463. hif_post_init(struct hif_opaque_softc *hif_ctx, void *unused,
  1464. struct hif_msg_callbacks *callbacks)
  1465. {
  1466. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
  1467. #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
  1468. spin_lock_init(&pcie_access_log_lock);
  1469. #endif
  1470. /* Save callbacks for later installation */
  1471. qdf_mem_copy(&hif_state->msg_callbacks_pending, callbacks,
  1472. sizeof(hif_state->msg_callbacks_pending));
  1473. }
  1474. static int hif_completion_thread_startup(struct HIF_CE_state *hif_state)
  1475. {
  1476. struct CE_handle *ce_diag = hif_state->ce_diag;
  1477. int pipe_num;
  1478. struct hif_softc *scn = HIF_GET_SOFTC(hif_state);
  1479. struct hif_msg_callbacks *hif_msg_callbacks =
  1480. &hif_state->msg_callbacks_current;
  1481. /* daemonize("hif_compl_thread"); */
  1482. if (scn->ce_count == 0) {
  1483. HIF_ERROR("%s: Invalid ce_count", __func__);
  1484. return -EINVAL;
  1485. }
  1486. if (!hif_msg_callbacks ||
  1487. !hif_msg_callbacks->rxCompletionHandler ||
  1488. !hif_msg_callbacks->txCompletionHandler) {
  1489. HIF_ERROR("%s: no completion handler registered", __func__);
  1490. return -EFAULT;
  1491. }
  1492. A_TARGET_ACCESS_LIKELY(scn);
  1493. for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) {
  1494. struct CE_attr attr;
  1495. struct HIF_CE_pipe_info *pipe_info;
  1496. pipe_info = &hif_state->pipe_info[pipe_num];
  1497. if (pipe_info->ce_hdl == ce_diag)
  1498. continue; /* Handle Diagnostic CE specially */
  1499. attr = hif_state->host_ce_config[pipe_num];
  1500. if (attr.src_nentries) {
  1501. /* pipe used to send to target */
  1502. HIF_DBG("%s: pipe_num:%d pipe_info:0x%pK",
  1503. __func__, pipe_num, pipe_info);
  1504. ce_send_cb_register(pipe_info->ce_hdl,
  1505. hif_pci_ce_send_done, pipe_info,
  1506. attr.flags & CE_ATTR_DISABLE_INTR);
  1507. pipe_info->num_sends_allowed = attr.src_nentries - 1;
  1508. }
  1509. if (attr.dest_nentries) {
  1510. /* pipe used to receive from target */
  1511. ce_recv_cb_register(pipe_info->ce_hdl,
  1512. hif_pci_ce_recv_data, pipe_info,
  1513. attr.flags & CE_ATTR_DISABLE_INTR);
  1514. }
  1515. if (attr.src_nentries)
  1516. qdf_spinlock_create(&pipe_info->completion_freeq_lock);
  1517. qdf_mem_copy(&pipe_info->pipe_callbacks, hif_msg_callbacks,
  1518. sizeof(pipe_info->pipe_callbacks));
  1519. }
  1520. A_TARGET_ACCESS_UNLIKELY(scn);
  1521. return 0;
  1522. }
  1523. /*
  1524. * Install pending msg callbacks.
  1525. *
  1526. * TBDXXX: This hack is needed because upper layers install msg callbacks
  1527. * for use with HTC before BMI is done; yet this HIF implementation
  1528. * needs to continue to use BMI msg callbacks. Really, upper layers
  1529. * should not register HTC callbacks until AFTER BMI phase.
  1530. */
  1531. static void hif_msg_callbacks_install(struct hif_softc *scn)
  1532. {
  1533. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  1534. qdf_mem_copy(&hif_state->msg_callbacks_current,
  1535. &hif_state->msg_callbacks_pending,
  1536. sizeof(hif_state->msg_callbacks_pending));
  1537. }
  1538. void hif_get_default_pipe(struct hif_opaque_softc *hif_hdl, uint8_t *ULPipe,
  1539. uint8_t *DLPipe)
  1540. {
  1541. int ul_is_polled, dl_is_polled;
  1542. (void)hif_map_service_to_pipe(hif_hdl, HTC_CTRL_RSVD_SVC,
  1543. ULPipe, DLPipe, &ul_is_polled, &dl_is_polled);
  1544. }
  1545. /**
  1546. * hif_dump_pipe_debug_count() - Log error count
  1547. * @scn: hif_softc pointer.
  1548. *
  1549. * Output the pipe error counts of each pipe to log file
  1550. *
  1551. * Return: N/A
  1552. */
  1553. void hif_dump_pipe_debug_count(struct hif_softc *scn)
  1554. {
  1555. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  1556. int pipe_num;
  1557. if (hif_state == NULL) {
  1558. HIF_ERROR("%s hif_state is NULL", __func__);
  1559. return;
  1560. }
  1561. for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) {
  1562. struct HIF_CE_pipe_info *pipe_info;
  1563. pipe_info = &hif_state->pipe_info[pipe_num];
  1564. if (pipe_info->nbuf_alloc_err_count > 0 ||
  1565. pipe_info->nbuf_dma_err_count > 0 ||
  1566. pipe_info->nbuf_ce_enqueue_err_count)
  1567. HIF_ERROR(
  1568. "%s: pipe_id = %d, recv_bufs_needed = %d, nbuf_alloc_err_count = %u, nbuf_dma_err_count = %u, nbuf_ce_enqueue_err_count = %u",
  1569. __func__, pipe_info->pipe_num,
  1570. atomic_read(&pipe_info->recv_bufs_needed),
  1571. pipe_info->nbuf_alloc_err_count,
  1572. pipe_info->nbuf_dma_err_count,
  1573. pipe_info->nbuf_ce_enqueue_err_count);
  1574. }
  1575. }
  1576. static void hif_post_recv_buffers_failure(struct HIF_CE_pipe_info *pipe_info,
  1577. void *nbuf, uint32_t *error_cnt,
  1578. enum hif_ce_event_type failure_type,
  1579. const char *failure_type_string)
  1580. {
  1581. int bufs_needed_tmp = atomic_inc_return(&pipe_info->recv_bufs_needed);
  1582. struct CE_state *CE_state = (struct CE_state *)pipe_info->ce_hdl;
  1583. struct hif_softc *scn = HIF_GET_SOFTC(pipe_info->HIF_CE_state);
  1584. int ce_id = CE_state->id;
  1585. uint32_t error_cnt_tmp;
  1586. qdf_spin_lock_bh(&pipe_info->recv_bufs_needed_lock);
  1587. error_cnt_tmp = ++(*error_cnt);
  1588. qdf_spin_unlock_bh(&pipe_info->recv_bufs_needed_lock);
  1589. HIF_DBG("%s: pipe_num %d, needed %d, err_cnt = %u, fail_type = %s",
  1590. __func__, pipe_info->pipe_num, bufs_needed_tmp, error_cnt_tmp,
  1591. failure_type_string);
  1592. hif_record_ce_desc_event(scn, ce_id, failure_type,
  1593. NULL, nbuf, bufs_needed_tmp);
  1594. /* if we fail to allocate the last buffer for an rx pipe,
  1595. * there is no trigger to refill the ce and we will
  1596. * eventually crash
  1597. */
  1598. if (bufs_needed_tmp == CE_state->dest_ring->nentries - 1)
  1599. qdf_sched_work(scn->qdf_dev, &CE_state->oom_allocation_work);
  1600. }
  1601. QDF_STATUS hif_post_recv_buffers_for_pipe(struct HIF_CE_pipe_info *pipe_info)
  1602. {
  1603. struct CE_handle *ce_hdl;
  1604. qdf_size_t buf_sz;
  1605. struct hif_softc *scn = HIF_GET_SOFTC(pipe_info->HIF_CE_state);
  1606. QDF_STATUS status;
  1607. uint32_t bufs_posted = 0;
  1608. buf_sz = pipe_info->buf_sz;
  1609. if (buf_sz == 0) {
  1610. /* Unused Copy Engine */
  1611. return QDF_STATUS_SUCCESS;
  1612. }
  1613. ce_hdl = pipe_info->ce_hdl;
  1614. qdf_spin_lock_bh(&pipe_info->recv_bufs_needed_lock);
  1615. while (atomic_read(&pipe_info->recv_bufs_needed) > 0) {
  1616. qdf_dma_addr_t CE_data; /* CE space buffer address */
  1617. qdf_nbuf_t nbuf;
  1618. atomic_dec(&pipe_info->recv_bufs_needed);
  1619. qdf_spin_unlock_bh(&pipe_info->recv_bufs_needed_lock);
  1620. nbuf = qdf_nbuf_alloc(scn->qdf_dev, buf_sz, 0, 4, false);
  1621. if (!nbuf) {
  1622. hif_post_recv_buffers_failure(pipe_info, nbuf,
  1623. &pipe_info->nbuf_alloc_err_count,
  1624. HIF_RX_NBUF_ALLOC_FAILURE,
  1625. "HIF_RX_NBUF_ALLOC_FAILURE");
  1626. return QDF_STATUS_E_NOMEM;
  1627. }
  1628. /*
  1629. * qdf_nbuf_peek_header(nbuf, &data, &unused);
  1630. * CE_data = dma_map_single(dev, data, buf_sz, );
  1631. * DMA_FROM_DEVICE);
  1632. */
  1633. status = qdf_nbuf_map_single(scn->qdf_dev, nbuf,
  1634. QDF_DMA_FROM_DEVICE);
  1635. if (qdf_unlikely(status != QDF_STATUS_SUCCESS)) {
  1636. hif_post_recv_buffers_failure(pipe_info, nbuf,
  1637. &pipe_info->nbuf_dma_err_count,
  1638. HIF_RX_NBUF_MAP_FAILURE,
  1639. "HIF_RX_NBUF_MAP_FAILURE");
  1640. qdf_nbuf_free(nbuf);
  1641. return status;
  1642. }
  1643. CE_data = qdf_nbuf_get_frag_paddr(nbuf, 0);
  1644. qdf_mem_dma_sync_single_for_device(scn->qdf_dev, CE_data,
  1645. buf_sz, DMA_FROM_DEVICE);
  1646. status = ce_recv_buf_enqueue(ce_hdl, (void *)nbuf, CE_data);
  1647. if (qdf_unlikely(status != QDF_STATUS_SUCCESS)) {
  1648. hif_post_recv_buffers_failure(pipe_info, nbuf,
  1649. &pipe_info->nbuf_ce_enqueue_err_count,
  1650. HIF_RX_NBUF_ENQUEUE_FAILURE,
  1651. "HIF_RX_NBUF_ENQUEUE_FAILURE");
  1652. qdf_nbuf_unmap_single(scn->qdf_dev, nbuf,
  1653. QDF_DMA_FROM_DEVICE);
  1654. qdf_nbuf_free(nbuf);
  1655. return status;
  1656. }
  1657. qdf_spin_lock_bh(&pipe_info->recv_bufs_needed_lock);
  1658. bufs_posted++;
  1659. }
  1660. pipe_info->nbuf_alloc_err_count =
  1661. (pipe_info->nbuf_alloc_err_count > bufs_posted) ?
  1662. pipe_info->nbuf_alloc_err_count - bufs_posted : 0;
  1663. pipe_info->nbuf_dma_err_count =
  1664. (pipe_info->nbuf_dma_err_count > bufs_posted) ?
  1665. pipe_info->nbuf_dma_err_count - bufs_posted : 0;
  1666. pipe_info->nbuf_ce_enqueue_err_count =
  1667. (pipe_info->nbuf_ce_enqueue_err_count > bufs_posted) ?
  1668. pipe_info->nbuf_ce_enqueue_err_count - bufs_posted : 0;
  1669. qdf_spin_unlock_bh(&pipe_info->recv_bufs_needed_lock);
  1670. return QDF_STATUS_SUCCESS;
  1671. }
  1672. /*
  1673. * Try to post all desired receive buffers for all pipes.
  1674. * Returns 0 for non fastpath rx copy engine as
  1675. * oom_allocation_work will be scheduled to recover any
  1676. * failures, non-zero if unable to completely replenish
  1677. * receive buffers for fastpath rx Copy engine.
  1678. */
  1679. QDF_STATUS hif_post_recv_buffers(struct hif_softc *scn)
  1680. {
  1681. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  1682. int pipe_num;
  1683. struct CE_state *ce_state;
  1684. QDF_STATUS qdf_status;
  1685. A_TARGET_ACCESS_LIKELY(scn);
  1686. for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) {
  1687. struct HIF_CE_pipe_info *pipe_info;
  1688. ce_state = scn->ce_id_to_state[pipe_num];
  1689. pipe_info = &hif_state->pipe_info[pipe_num];
  1690. if (hif_is_nss_wifi_enabled(scn) &&
  1691. ce_state && (ce_state->htt_rx_data))
  1692. continue;
  1693. qdf_status = hif_post_recv_buffers_for_pipe(pipe_info);
  1694. if (!QDF_IS_STATUS_SUCCESS(qdf_status) &&
  1695. ce_state->htt_rx_data &&
  1696. scn->fastpath_mode_on) {
  1697. A_TARGET_ACCESS_UNLIKELY(scn);
  1698. return qdf_status;
  1699. }
  1700. }
  1701. A_TARGET_ACCESS_UNLIKELY(scn);
  1702. return QDF_STATUS_SUCCESS;
  1703. }
  1704. QDF_STATUS hif_start(struct hif_opaque_softc *hif_ctx)
  1705. {
  1706. struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
  1707. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  1708. QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
  1709. hif_update_fastpath_recv_bufs_cnt(scn);
  1710. hif_msg_callbacks_install(scn);
  1711. if (hif_completion_thread_startup(hif_state))
  1712. return QDF_STATUS_E_FAILURE;
  1713. /* enable buffer cleanup */
  1714. hif_state->started = true;
  1715. /* Post buffers once to start things off. */
  1716. qdf_status = hif_post_recv_buffers(scn);
  1717. if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
  1718. /* cleanup is done in hif_ce_disable */
  1719. HIF_ERROR("%s:failed to post buffers", __func__);
  1720. return qdf_status;
  1721. }
  1722. return qdf_status;
  1723. }
  1724. static void hif_recv_buffer_cleanup_on_pipe(struct HIF_CE_pipe_info *pipe_info)
  1725. {
  1726. struct hif_softc *scn;
  1727. struct CE_handle *ce_hdl;
  1728. uint32_t buf_sz;
  1729. struct HIF_CE_state *hif_state;
  1730. qdf_nbuf_t netbuf;
  1731. qdf_dma_addr_t CE_data;
  1732. void *per_CE_context;
  1733. buf_sz = pipe_info->buf_sz;
  1734. /* Unused Copy Engine */
  1735. if (buf_sz == 0)
  1736. return;
  1737. hif_state = pipe_info->HIF_CE_state;
  1738. if (!hif_state->started)
  1739. return;
  1740. scn = HIF_GET_SOFTC(hif_state);
  1741. ce_hdl = pipe_info->ce_hdl;
  1742. if (scn->qdf_dev == NULL)
  1743. return;
  1744. while (ce_revoke_recv_next
  1745. (ce_hdl, &per_CE_context, (void **)&netbuf,
  1746. &CE_data) == QDF_STATUS_SUCCESS) {
  1747. if (netbuf) {
  1748. qdf_nbuf_unmap_single(scn->qdf_dev, netbuf,
  1749. QDF_DMA_FROM_DEVICE);
  1750. qdf_nbuf_free(netbuf);
  1751. }
  1752. }
  1753. }
  1754. static void hif_send_buffer_cleanup_on_pipe(struct HIF_CE_pipe_info *pipe_info)
  1755. {
  1756. struct CE_handle *ce_hdl;
  1757. struct HIF_CE_state *hif_state;
  1758. struct hif_softc *scn;
  1759. qdf_nbuf_t netbuf;
  1760. void *per_CE_context;
  1761. qdf_dma_addr_t CE_data;
  1762. unsigned int nbytes;
  1763. unsigned int id;
  1764. uint32_t buf_sz;
  1765. uint32_t toeplitz_hash_result;
  1766. buf_sz = pipe_info->buf_sz;
  1767. if (buf_sz == 0) {
  1768. /* Unused Copy Engine */
  1769. return;
  1770. }
  1771. hif_state = pipe_info->HIF_CE_state;
  1772. if (!hif_state->started) {
  1773. return;
  1774. }
  1775. scn = HIF_GET_SOFTC(hif_state);
  1776. ce_hdl = pipe_info->ce_hdl;
  1777. while (ce_cancel_send_next
  1778. (ce_hdl, &per_CE_context,
  1779. (void **)&netbuf, &CE_data, &nbytes,
  1780. &id, &toeplitz_hash_result) == QDF_STATUS_SUCCESS) {
  1781. if (netbuf != CE_SENDLIST_ITEM_CTXT) {
  1782. /*
  1783. * Packets enqueued by htt_h2t_ver_req_msg() and
  1784. * htt_h2t_rx_ring_cfg_msg_ll() have already been
  1785. * freed in htt_htc_misc_pkt_pool_free() in
  1786. * wlantl_close(), so do not free them here again
  1787. * by checking whether it's the endpoint
  1788. * which they are queued in.
  1789. */
  1790. if (id == scn->htc_htt_tx_endpoint)
  1791. return;
  1792. /* Indicate the completion to higher
  1793. * layer to free the buffer
  1794. */
  1795. if (pipe_info->pipe_callbacks.txCompletionHandler)
  1796. pipe_info->pipe_callbacks.
  1797. txCompletionHandler(pipe_info->
  1798. pipe_callbacks.Context,
  1799. netbuf, id, toeplitz_hash_result);
  1800. }
  1801. }
  1802. }
  1803. /*
  1804. * Cleanup residual buffers for device shutdown:
  1805. * buffers that were enqueued for receive
  1806. * buffers that were to be sent
  1807. * Note: Buffers that had completed but which were
  1808. * not yet processed are on a completion queue. They
  1809. * are handled when the completion thread shuts down.
  1810. */
  1811. static void hif_buffer_cleanup(struct HIF_CE_state *hif_state)
  1812. {
  1813. int pipe_num;
  1814. struct hif_softc *scn = HIF_GET_SOFTC(hif_state);
  1815. struct CE_state *ce_state;
  1816. for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) {
  1817. struct HIF_CE_pipe_info *pipe_info;
  1818. ce_state = scn->ce_id_to_state[pipe_num];
  1819. if (hif_is_nss_wifi_enabled(scn) && ce_state &&
  1820. ((ce_state->htt_tx_data) ||
  1821. (ce_state->htt_rx_data))) {
  1822. continue;
  1823. }
  1824. pipe_info = &hif_state->pipe_info[pipe_num];
  1825. hif_recv_buffer_cleanup_on_pipe(pipe_info);
  1826. hif_send_buffer_cleanup_on_pipe(pipe_info);
  1827. }
  1828. }
  1829. void hif_flush_surprise_remove(struct hif_opaque_softc *hif_ctx)
  1830. {
  1831. struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
  1832. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  1833. hif_buffer_cleanup(hif_state);
  1834. }
  1835. static void hif_destroy_oom_work(struct hif_softc *scn)
  1836. {
  1837. struct CE_state *ce_state;
  1838. int ce_id;
  1839. for (ce_id = 0; ce_id < scn->ce_count; ce_id++) {
  1840. ce_state = scn->ce_id_to_state[ce_id];
  1841. if (ce_state)
  1842. qdf_destroy_work(scn->qdf_dev,
  1843. &ce_state->oom_allocation_work);
  1844. }
  1845. }
  1846. void hif_ce_stop(struct hif_softc *scn)
  1847. {
  1848. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  1849. int pipe_num;
  1850. /*
  1851. * before cleaning up any memory, ensure irq &
  1852. * bottom half contexts will not be re-entered
  1853. */
  1854. hif_disable_isr(&scn->osc);
  1855. hif_destroy_oom_work(scn);
  1856. scn->hif_init_done = false;
  1857. /*
  1858. * At this point, asynchronous threads are stopped,
  1859. * The Target should not DMA nor interrupt, Host code may
  1860. * not initiate anything more. So we just need to clean
  1861. * up Host-side state.
  1862. */
  1863. if (scn->athdiag_procfs_inited) {
  1864. athdiag_procfs_remove();
  1865. scn->athdiag_procfs_inited = false;
  1866. }
  1867. hif_buffer_cleanup(hif_state);
  1868. for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) {
  1869. struct HIF_CE_pipe_info *pipe_info;
  1870. struct CE_attr attr;
  1871. struct CE_handle *ce_diag = hif_state->ce_diag;
  1872. pipe_info = &hif_state->pipe_info[pipe_num];
  1873. if (pipe_info->ce_hdl) {
  1874. if (pipe_info->ce_hdl != ce_diag) {
  1875. attr = hif_state->host_ce_config[pipe_num];
  1876. if (attr.src_nentries)
  1877. qdf_spinlock_destroy(&pipe_info->
  1878. completion_freeq_lock);
  1879. }
  1880. ce_fini(pipe_info->ce_hdl);
  1881. pipe_info->ce_hdl = NULL;
  1882. pipe_info->buf_sz = 0;
  1883. qdf_spinlock_destroy(&pipe_info->recv_bufs_needed_lock);
  1884. }
  1885. }
  1886. if (hif_state->sleep_timer_init) {
  1887. qdf_timer_stop(&hif_state->sleep_timer);
  1888. qdf_timer_free(&hif_state->sleep_timer);
  1889. hif_state->sleep_timer_init = false;
  1890. }
  1891. hif_state->started = false;
  1892. }
  1893. /**
  1894. * hif_get_target_ce_config() - get copy engine configuration
  1895. * @target_ce_config_ret: basic copy engine configuration
  1896. * @target_ce_config_sz_ret: size of the basic configuration in bytes
  1897. * @target_service_to_ce_map_ret: service mapping for the copy engines
  1898. * @target_service_to_ce_map_sz_ret: size of the mapping in bytes
  1899. * @target_shadow_reg_cfg_ret: shadow register configuration
  1900. * @shadow_cfg_sz_ret: size of the shadow register configuration in bytes
  1901. *
  1902. * providing accessor to these values outside of this file.
  1903. * currently these are stored in static pointers to const sections.
  1904. * there are multiple configurations that are selected from at compile time.
  1905. * Runtime selection would need to consider mode, target type and bus type.
  1906. *
  1907. * Return: return by parameter.
  1908. */
  1909. void hif_get_target_ce_config(struct hif_softc *scn,
  1910. struct CE_pipe_config **target_ce_config_ret,
  1911. uint32_t *target_ce_config_sz_ret,
  1912. struct service_to_pipe **target_service_to_ce_map_ret,
  1913. uint32_t *target_service_to_ce_map_sz_ret,
  1914. struct shadow_reg_cfg **target_shadow_reg_cfg_ret,
  1915. uint32_t *shadow_cfg_sz_ret)
  1916. {
  1917. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  1918. *target_ce_config_ret = hif_state->target_ce_config;
  1919. *target_ce_config_sz_ret = hif_state->target_ce_config_sz;
  1920. hif_select_service_to_pipe_map(scn, target_service_to_ce_map_ret,
  1921. target_service_to_ce_map_sz_ret);
  1922. if (target_shadow_reg_cfg_ret)
  1923. *target_shadow_reg_cfg_ret = target_shadow_reg_cfg;
  1924. if (shadow_cfg_sz_ret)
  1925. *shadow_cfg_sz_ret = shadow_cfg_sz;
  1926. }
  1927. #ifdef CONFIG_SHADOW_V2
  1928. static void hif_print_hal_shadow_register_cfg(struct pld_wlan_enable_cfg *cfg)
  1929. {
  1930. int i;
  1931. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1932. "%s: num_config %d\n", __func__, cfg->num_shadow_reg_v2_cfg);
  1933. for (i = 0; i < cfg->num_shadow_reg_v2_cfg; i++) {
  1934. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  1935. "%s: i %d, val %x\n", __func__, i,
  1936. cfg->shadow_reg_v2_cfg[i].addr);
  1937. }
  1938. }
  1939. #else
  1940. static void hif_print_hal_shadow_register_cfg(struct pld_wlan_enable_cfg *cfg)
  1941. {
  1942. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1943. "%s: CONFIG_SHADOW_V2 not defined\n", __func__);
  1944. }
  1945. #endif
  1946. /**
  1947. * hif_wlan_enable(): call the platform driver to enable wlan
  1948. * @scn: HIF Context
  1949. *
  1950. * This function passes the con_mode and CE configuration to
  1951. * platform driver to enable wlan.
  1952. *
  1953. * Return: linux error code
  1954. */
  1955. int hif_wlan_enable(struct hif_softc *scn)
  1956. {
  1957. struct pld_wlan_enable_cfg cfg;
  1958. enum pld_driver_mode mode;
  1959. uint32_t con_mode = hif_get_conparam(scn);
  1960. hif_get_target_ce_config(scn,
  1961. (struct CE_pipe_config **)&cfg.ce_tgt_cfg,
  1962. &cfg.num_ce_tgt_cfg,
  1963. (struct service_to_pipe **)&cfg.ce_svc_cfg,
  1964. &cfg.num_ce_svc_pipe_cfg,
  1965. (struct shadow_reg_cfg **)&cfg.shadow_reg_cfg,
  1966. &cfg.num_shadow_reg_cfg);
  1967. /* translate from structure size to array size */
  1968. cfg.num_ce_tgt_cfg /= sizeof(struct CE_pipe_config);
  1969. cfg.num_ce_svc_pipe_cfg /= sizeof(struct service_to_pipe);
  1970. cfg.num_shadow_reg_cfg /= sizeof(struct shadow_reg_cfg);
  1971. hif_prepare_hal_shadow_register_cfg(scn, &cfg.shadow_reg_v2_cfg,
  1972. &cfg.num_shadow_reg_v2_cfg);
  1973. hif_print_hal_shadow_register_cfg(&cfg);
  1974. if (QDF_GLOBAL_FTM_MODE == con_mode)
  1975. mode = PLD_FTM;
  1976. else if (QDF_GLOBAL_COLDBOOT_CALIB_MODE == con_mode)
  1977. mode = PLD_COLDBOOT_CALIBRATION;
  1978. else if (QDF_IS_EPPING_ENABLED(con_mode))
  1979. mode = PLD_EPPING;
  1980. else
  1981. mode = PLD_MISSION;
  1982. if (BYPASS_QMI)
  1983. return 0;
  1984. else
  1985. return pld_wlan_enable(scn->qdf_dev->dev, &cfg,
  1986. mode, QWLAN_VERSIONSTR);
  1987. }
  1988. #define CE_EPPING_USES_IRQ true
  1989. /**
  1990. * hif_ce_prepare_config() - load the correct static tables.
  1991. * @scn: hif context
  1992. *
  1993. * Epping uses different static attribute tables than mission mode.
  1994. */
  1995. void hif_ce_prepare_config(struct hif_softc *scn)
  1996. {
  1997. uint32_t mode = hif_get_conparam(scn);
  1998. struct hif_opaque_softc *hif_hdl = GET_HIF_OPAQUE_HDL(scn);
  1999. struct hif_target_info *tgt_info = hif_get_target_info_handle(hif_hdl);
  2000. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  2001. hif_state->ce_services = ce_services_attach(scn);
  2002. scn->ce_count = HOST_CE_COUNT;
  2003. /* if epping is enabled we need to use the epping configuration. */
  2004. if (QDF_IS_EPPING_ENABLED(mode)) {
  2005. if (CE_EPPING_USES_IRQ)
  2006. hif_state->host_ce_config = host_ce_config_wlan_epping_irq;
  2007. else
  2008. hif_state->host_ce_config = host_ce_config_wlan_epping_poll;
  2009. hif_state->target_ce_config = target_ce_config_wlan_epping;
  2010. hif_state->target_ce_config_sz = sizeof(target_ce_config_wlan_epping);
  2011. target_shadow_reg_cfg = target_shadow_reg_cfg_epping;
  2012. shadow_cfg_sz = sizeof(target_shadow_reg_cfg_epping);
  2013. }
  2014. switch (tgt_info->target_type) {
  2015. default:
  2016. hif_state->host_ce_config = host_ce_config_wlan;
  2017. hif_state->target_ce_config = target_ce_config_wlan;
  2018. hif_state->target_ce_config_sz = sizeof(target_ce_config_wlan);
  2019. break;
  2020. case TARGET_TYPE_AR900B:
  2021. case TARGET_TYPE_QCA9984:
  2022. case TARGET_TYPE_IPQ4019:
  2023. case TARGET_TYPE_QCA9888:
  2024. if (hif_is_attribute_set(scn, HIF_LOWDESC_CE_NO_PKTLOG_CFG)) {
  2025. hif_state->host_ce_config =
  2026. host_lowdesc_ce_cfg_wlan_ar900b_nopktlog;
  2027. } else if (hif_is_attribute_set(scn, HIF_LOWDESC_CE_CFG)) {
  2028. hif_state->host_ce_config =
  2029. host_lowdesc_ce_cfg_wlan_ar900b;
  2030. } else {
  2031. hif_state->host_ce_config = host_ce_config_wlan_ar900b;
  2032. }
  2033. hif_state->target_ce_config = target_ce_config_wlan_ar900b;
  2034. hif_state->target_ce_config_sz =
  2035. sizeof(target_ce_config_wlan_ar900b);
  2036. break;
  2037. case TARGET_TYPE_AR9888:
  2038. case TARGET_TYPE_AR9888V2:
  2039. if (hif_is_attribute_set(scn, HIF_LOWDESC_CE_CFG)) {
  2040. hif_state->host_ce_config = host_lowdesc_ce_cfg_wlan_ar9888;
  2041. } else {
  2042. hif_state->host_ce_config = host_ce_config_wlan_ar9888;
  2043. }
  2044. hif_state->target_ce_config = target_ce_config_wlan_ar9888;
  2045. hif_state->target_ce_config_sz =
  2046. sizeof(target_ce_config_wlan_ar9888);
  2047. break;
  2048. case TARGET_TYPE_QCA8074:
  2049. if (scn->bus_type == QDF_BUS_TYPE_PCI) {
  2050. hif_state->host_ce_config =
  2051. host_ce_config_wlan_qca8074_pci;
  2052. hif_state->target_ce_config =
  2053. target_ce_config_wlan_qca8074_pci;
  2054. hif_state->target_ce_config_sz =
  2055. sizeof(target_ce_config_wlan_qca8074_pci);
  2056. } else {
  2057. hif_state->host_ce_config = host_ce_config_wlan_qca8074;
  2058. hif_state->target_ce_config =
  2059. target_ce_config_wlan_qca8074;
  2060. hif_state->target_ce_config_sz =
  2061. sizeof(target_ce_config_wlan_qca8074);
  2062. }
  2063. break;
  2064. case TARGET_TYPE_QCA6290:
  2065. hif_state->host_ce_config = host_ce_config_wlan_qca6290;
  2066. hif_state->target_ce_config = target_ce_config_wlan_qca6290;
  2067. hif_state->target_ce_config_sz =
  2068. sizeof(target_ce_config_wlan_qca6290);
  2069. scn->ce_count = QCA_6290_CE_COUNT;
  2070. break;
  2071. }
  2072. QDF_BUG(scn->ce_count <= CE_COUNT_MAX);
  2073. }
  2074. /**
  2075. * hif_ce_open() - do ce specific allocations
  2076. * @hif_sc: pointer to hif context
  2077. *
  2078. * return: 0 for success or QDF_STATUS_E_NOMEM
  2079. */
  2080. QDF_STATUS hif_ce_open(struct hif_softc *hif_sc)
  2081. {
  2082. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_sc);
  2083. qdf_spinlock_create(&hif_state->irq_reg_lock);
  2084. qdf_spinlock_create(&hif_state->keep_awake_lock);
  2085. return QDF_STATUS_SUCCESS;
  2086. }
  2087. /**
  2088. * hif_ce_close() - do ce specific free
  2089. * @hif_sc: pointer to hif context
  2090. */
  2091. void hif_ce_close(struct hif_softc *hif_sc)
  2092. {
  2093. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_sc);
  2094. qdf_spinlock_destroy(&hif_state->irq_reg_lock);
  2095. qdf_spinlock_destroy(&hif_state->keep_awake_lock);
  2096. }
  2097. /**
  2098. * hif_unconfig_ce() - ensure resources from hif_config_ce are freed
  2099. * @hif_sc: hif context
  2100. *
  2101. * uses state variables to support cleaning up when hif_config_ce fails.
  2102. */
  2103. void hif_unconfig_ce(struct hif_softc *hif_sc)
  2104. {
  2105. int pipe_num;
  2106. struct HIF_CE_pipe_info *pipe_info;
  2107. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_sc);
  2108. for (pipe_num = 0; pipe_num < hif_sc->ce_count; pipe_num++) {
  2109. pipe_info = &hif_state->pipe_info[pipe_num];
  2110. if (pipe_info->ce_hdl) {
  2111. ce_unregister_irq(hif_state, (1 << pipe_num));
  2112. ce_fini(pipe_info->ce_hdl);
  2113. pipe_info->ce_hdl = NULL;
  2114. pipe_info->buf_sz = 0;
  2115. qdf_spinlock_destroy(&pipe_info->recv_bufs_needed_lock);
  2116. }
  2117. }
  2118. if (hif_sc->athdiag_procfs_inited) {
  2119. athdiag_procfs_remove();
  2120. hif_sc->athdiag_procfs_inited = false;
  2121. }
  2122. }
  2123. #ifdef CONFIG_BYPASS_QMI
  2124. #define FW_SHARED_MEM (2 * 1024 * 1024)
  2125. /**
  2126. * hif_post_static_buf_to_target() - post static buffer to WLAN FW
  2127. * @scn: pointer to HIF structure
  2128. *
  2129. * WLAN FW needs 2MB memory from DDR when QMI is disabled.
  2130. *
  2131. * Return: void
  2132. */
  2133. static void hif_post_static_buf_to_target(struct hif_softc *scn)
  2134. {
  2135. void *target_va;
  2136. phys_addr_t target_pa;
  2137. target_va = qdf_mem_alloc_consistent(scn->qdf_dev, scn->qdf_dev->dev,
  2138. FW_SHARED_MEM, &target_pa);
  2139. if (NULL == target_va) {
  2140. HIF_TRACE("Memory allocation failed could not post target buf");
  2141. return;
  2142. }
  2143. hif_write32_mb(scn->mem + BYPASS_QMI_TEMP_REGISTER, target_pa);
  2144. HIF_TRACE("target va %pK target pa %pa", target_va, &target_pa);
  2145. }
  2146. #else
  2147. static inline void hif_post_static_buf_to_target(struct hif_softc *scn)
  2148. {
  2149. }
  2150. #endif
  2151. static int hif_srng_sleep_state_adjust(struct hif_softc *scn, bool sleep_ok,
  2152. bool wait_for_it)
  2153. {
  2154. /* todo */
  2155. return 0;
  2156. }
  2157. /**
  2158. * hif_config_ce() - configure copy engines
  2159. * @scn: hif context
  2160. *
  2161. * Prepares fw, copy engine hardware and host sw according
  2162. * to the attributes selected by hif_ce_prepare_config.
  2163. *
  2164. * also calls athdiag_procfs_init
  2165. *
  2166. * return: 0 for success nonzero for failure.
  2167. */
  2168. int hif_config_ce(struct hif_softc *scn)
  2169. {
  2170. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  2171. struct hif_opaque_softc *hif_hdl = GET_HIF_OPAQUE_HDL(scn);
  2172. struct HIF_CE_pipe_info *pipe_info;
  2173. int pipe_num;
  2174. struct CE_state *ce_state;
  2175. #ifdef ADRASTEA_SHADOW_REGISTERS
  2176. int i;
  2177. #endif
  2178. QDF_STATUS rv = QDF_STATUS_SUCCESS;
  2179. scn->notice_send = true;
  2180. hif_post_static_buf_to_target(scn);
  2181. hif_state->fw_indicator_address = FW_INDICATOR_ADDRESS;
  2182. hif_config_rri_on_ddr(scn);
  2183. if (ce_srng_based(scn))
  2184. scn->bus_ops.hif_target_sleep_state_adjust =
  2185. &hif_srng_sleep_state_adjust;
  2186. for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) {
  2187. struct CE_attr *attr;
  2188. pipe_info = &hif_state->pipe_info[pipe_num];
  2189. pipe_info->pipe_num = pipe_num;
  2190. pipe_info->HIF_CE_state = hif_state;
  2191. attr = &hif_state->host_ce_config[pipe_num];
  2192. pipe_info->ce_hdl = ce_init(scn, pipe_num, attr);
  2193. ce_state = scn->ce_id_to_state[pipe_num];
  2194. qdf_spinlock_create(&pipe_info->recv_bufs_needed_lock);
  2195. QDF_ASSERT(pipe_info->ce_hdl != NULL);
  2196. if (pipe_info->ce_hdl == NULL) {
  2197. rv = QDF_STATUS_E_FAILURE;
  2198. A_TARGET_ACCESS_UNLIKELY(scn);
  2199. goto err;
  2200. }
  2201. ce_state->lro_data = qdf_lro_init();
  2202. if (attr->flags & CE_ATTR_DIAG) {
  2203. /* Reserve the ultimate CE for
  2204. * Diagnostic Window support
  2205. */
  2206. hif_state->ce_diag = pipe_info->ce_hdl;
  2207. continue;
  2208. }
  2209. if (hif_is_nss_wifi_enabled(scn) && ce_state &&
  2210. (ce_state->htt_rx_data))
  2211. continue;
  2212. pipe_info->buf_sz = (qdf_size_t) (attr->src_sz_max);
  2213. if (attr->dest_nentries > 0) {
  2214. atomic_set(&pipe_info->recv_bufs_needed,
  2215. init_buffer_count(attr->dest_nentries - 1));
  2216. /*SRNG based CE has one entry less */
  2217. if (ce_srng_based(scn))
  2218. atomic_dec(&pipe_info->recv_bufs_needed);
  2219. } else {
  2220. atomic_set(&pipe_info->recv_bufs_needed, 0);
  2221. }
  2222. ce_tasklet_init(hif_state, (1 << pipe_num));
  2223. ce_register_irq(hif_state, (1 << pipe_num));
  2224. }
  2225. if (athdiag_procfs_init(scn) != 0) {
  2226. A_TARGET_ACCESS_UNLIKELY(scn);
  2227. goto err;
  2228. }
  2229. scn->athdiag_procfs_inited = true;
  2230. HIF_DBG("%s: ce_init done", __func__);
  2231. init_tasklet_workers(hif_hdl);
  2232. HIF_DBG("%s: X, ret = %d", __func__, rv);
  2233. #ifdef ADRASTEA_SHADOW_REGISTERS
  2234. HIF_DBG("%s, Using Shadow Registers instead of CE Registers", __func__);
  2235. for (i = 0; i < NUM_SHADOW_REGISTERS; i++) {
  2236. HIF_DBG("%s Shadow Register%d is mapped to address %x",
  2237. __func__, i,
  2238. (A_TARGET_READ(scn, (SHADOW_ADDRESS(i))) << 2));
  2239. }
  2240. #endif
  2241. return rv != QDF_STATUS_SUCCESS;
  2242. err:
  2243. /* Failure, so clean up */
  2244. hif_unconfig_ce(scn);
  2245. HIF_TRACE("%s: X, ret = %d", __func__, rv);
  2246. return QDF_STATUS_SUCCESS != QDF_STATUS_E_FAILURE;
  2247. }
  2248. #ifdef WLAN_FEATURE_FASTPATH
  2249. /**
  2250. * hif_ce_fastpath_cb_register() - Register callback for fastpath msg handler
  2251. * @handler: Callback funtcion
  2252. * @context: handle for callback function
  2253. *
  2254. * Return: QDF_STATUS_SUCCESS on success or QDF_STATUS_E_FAILURE
  2255. */
  2256. int hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
  2257. fastpath_msg_handler handler,
  2258. void *context)
  2259. {
  2260. struct CE_state *ce_state;
  2261. struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
  2262. int i;
  2263. if (!scn) {
  2264. HIF_ERROR("%s: scn is NULL", __func__);
  2265. QDF_ASSERT(0);
  2266. return QDF_STATUS_E_FAILURE;
  2267. }
  2268. if (!scn->fastpath_mode_on) {
  2269. HIF_WARN("%s: Fastpath mode disabled", __func__);
  2270. return QDF_STATUS_E_FAILURE;
  2271. }
  2272. for (i = 0; i < scn->ce_count; i++) {
  2273. ce_state = scn->ce_id_to_state[i];
  2274. if (ce_state->htt_rx_data) {
  2275. ce_state->fastpath_handler = handler;
  2276. ce_state->context = context;
  2277. }
  2278. }
  2279. return QDF_STATUS_SUCCESS;
  2280. }
  2281. #endif
  2282. #ifdef IPA_OFFLOAD
  2283. /**
  2284. * hif_ce_ipa_get_ce_resource() - get uc resource on hif
  2285. * @scn: bus context
  2286. * @ce_sr_base_paddr: copyengine source ring base physical address
  2287. * @ce_sr_ring_size: copyengine source ring size
  2288. * @ce_reg_paddr: copyengine register physical address
  2289. *
  2290. * IPA micro controller data path offload feature enabled,
  2291. * HIF should release copy engine related resource information to IPA UC
  2292. * IPA UC will access hardware resource with released information
  2293. *
  2294. * Return: None
  2295. */
  2296. void hif_ce_ipa_get_ce_resource(struct hif_softc *scn,
  2297. qdf_dma_addr_t *ce_sr_base_paddr,
  2298. uint32_t *ce_sr_ring_size,
  2299. qdf_dma_addr_t *ce_reg_paddr)
  2300. {
  2301. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  2302. struct HIF_CE_pipe_info *pipe_info =
  2303. &(hif_state->pipe_info[HIF_PCI_IPA_UC_ASSIGNED_CE]);
  2304. struct CE_handle *ce_hdl = pipe_info->ce_hdl;
  2305. ce_ipa_get_resource(ce_hdl, ce_sr_base_paddr, ce_sr_ring_size,
  2306. ce_reg_paddr);
  2307. }
  2308. #endif /* IPA_OFFLOAD */
  2309. #ifdef ADRASTEA_SHADOW_REGISTERS
  2310. /*
  2311. * Current shadow register config
  2312. *
  2313. * -----------------------------------------------------------
  2314. * Shadow Register | CE | src/dst write index
  2315. * -----------------------------------------------------------
  2316. * 0 | 0 | src
  2317. * 1 No Config - Doesn't point to anything
  2318. * 2 No Config - Doesn't point to anything
  2319. * 3 | 3 | src
  2320. * 4 | 4 | src
  2321. * 5 | 5 | src
  2322. * 6 No Config - Doesn't point to anything
  2323. * 7 | 7 | src
  2324. * 8 No Config - Doesn't point to anything
  2325. * 9 No Config - Doesn't point to anything
  2326. * 10 No Config - Doesn't point to anything
  2327. * 11 No Config - Doesn't point to anything
  2328. * -----------------------------------------------------------
  2329. * 12 No Config - Doesn't point to anything
  2330. * 13 | 1 | dst
  2331. * 14 | 2 | dst
  2332. * 15 No Config - Doesn't point to anything
  2333. * 16 No Config - Doesn't point to anything
  2334. * 17 No Config - Doesn't point to anything
  2335. * 18 No Config - Doesn't point to anything
  2336. * 19 | 7 | dst
  2337. * 20 | 8 | dst
  2338. * 21 No Config - Doesn't point to anything
  2339. * 22 No Config - Doesn't point to anything
  2340. * 23 No Config - Doesn't point to anything
  2341. * -----------------------------------------------------------
  2342. *
  2343. *
  2344. * ToDo - Move shadow register config to following in the future
  2345. * This helps free up a block of shadow registers towards the end.
  2346. * Can be used for other purposes
  2347. *
  2348. * -----------------------------------------------------------
  2349. * Shadow Register | CE | src/dst write index
  2350. * -----------------------------------------------------------
  2351. * 0 | 0 | src
  2352. * 1 | 3 | src
  2353. * 2 | 4 | src
  2354. * 3 | 5 | src
  2355. * 4 | 7 | src
  2356. * -----------------------------------------------------------
  2357. * 5 | 1 | dst
  2358. * 6 | 2 | dst
  2359. * 7 | 7 | dst
  2360. * 8 | 8 | dst
  2361. * -----------------------------------------------------------
  2362. * 9 No Config - Doesn't point to anything
  2363. * 12 No Config - Doesn't point to anything
  2364. * 13 No Config - Doesn't point to anything
  2365. * 14 No Config - Doesn't point to anything
  2366. * 15 No Config - Doesn't point to anything
  2367. * 16 No Config - Doesn't point to anything
  2368. * 17 No Config - Doesn't point to anything
  2369. * 18 No Config - Doesn't point to anything
  2370. * 19 No Config - Doesn't point to anything
  2371. * 20 No Config - Doesn't point to anything
  2372. * 21 No Config - Doesn't point to anything
  2373. * 22 No Config - Doesn't point to anything
  2374. * 23 No Config - Doesn't point to anything
  2375. * -----------------------------------------------------------
  2376. */
  2377. u32 shadow_sr_wr_ind_addr(struct hif_softc *scn, u32 ctrl_addr)
  2378. {
  2379. u32 addr = 0;
  2380. u32 ce = COPY_ENGINE_ID(ctrl_addr);
  2381. switch (ce) {
  2382. case 0:
  2383. addr = SHADOW_VALUE0;
  2384. break;
  2385. case 3:
  2386. addr = SHADOW_VALUE3;
  2387. break;
  2388. case 4:
  2389. addr = SHADOW_VALUE4;
  2390. break;
  2391. case 5:
  2392. addr = SHADOW_VALUE5;
  2393. break;
  2394. case 7:
  2395. addr = SHADOW_VALUE7;
  2396. break;
  2397. default:
  2398. HIF_ERROR("invalid CE ctrl_addr (CE=%d)", ce);
  2399. QDF_ASSERT(0);
  2400. }
  2401. return addr;
  2402. }
  2403. u32 shadow_dst_wr_ind_addr(struct hif_softc *scn, u32 ctrl_addr)
  2404. {
  2405. u32 addr = 0;
  2406. u32 ce = COPY_ENGINE_ID(ctrl_addr);
  2407. switch (ce) {
  2408. case 1:
  2409. addr = SHADOW_VALUE13;
  2410. break;
  2411. case 2:
  2412. addr = SHADOW_VALUE14;
  2413. break;
  2414. case 5:
  2415. addr = SHADOW_VALUE17;
  2416. break;
  2417. case 7:
  2418. addr = SHADOW_VALUE19;
  2419. break;
  2420. case 8:
  2421. addr = SHADOW_VALUE20;
  2422. break;
  2423. case 9:
  2424. addr = SHADOW_VALUE21;
  2425. break;
  2426. case 10:
  2427. addr = SHADOW_VALUE22;
  2428. break;
  2429. case 11:
  2430. addr = SHADOW_VALUE23;
  2431. break;
  2432. default:
  2433. HIF_ERROR("invalid CE ctrl_addr (CE=%d)", ce);
  2434. QDF_ASSERT(0);
  2435. }
  2436. return addr;
  2437. }
  2438. #endif
  2439. #if defined(FEATURE_LRO)
  2440. void *hif_ce_get_lro_ctx(struct hif_opaque_softc *hif_hdl, int ctx_id)
  2441. {
  2442. struct CE_state *ce_state;
  2443. struct hif_softc *scn = HIF_GET_SOFTC(hif_hdl);
  2444. ce_state = scn->ce_id_to_state[ctx_id];
  2445. return ce_state->lro_data;
  2446. }
  2447. #endif
  2448. /**
  2449. * hif_map_service_to_pipe() - returns the ce ids pertaining to
  2450. * this service
  2451. * @scn: hif_softc pointer.
  2452. * @svc_id: Service ID for which the mapping is needed.
  2453. * @ul_pipe: address of the container in which ul pipe is returned.
  2454. * @dl_pipe: address of the container in which dl pipe is returned.
  2455. * @ul_is_polled: address of the container in which a bool
  2456. * indicating if the UL CE for this service
  2457. * is polled is returned.
  2458. * @dl_is_polled: address of the container in which a bool
  2459. * indicating if the DL CE for this service
  2460. * is polled is returned.
  2461. *
  2462. * Return: Indicates whether the service has been found in the table.
  2463. * Upon return, ul_is_polled is updated only if ul_pipe is updated.
  2464. * There will be warning logs if either leg has not been updated
  2465. * because it missed the entry in the table (but this is not an err).
  2466. */
  2467. int hif_map_service_to_pipe(struct hif_opaque_softc *hif_hdl, uint16_t svc_id,
  2468. uint8_t *ul_pipe, uint8_t *dl_pipe, int *ul_is_polled,
  2469. int *dl_is_polled)
  2470. {
  2471. int status = QDF_STATUS_E_INVAL;
  2472. unsigned int i;
  2473. struct service_to_pipe element;
  2474. struct service_to_pipe *tgt_svc_map_to_use;
  2475. uint32_t sz_tgt_svc_map_to_use;
  2476. struct hif_softc *scn = HIF_GET_SOFTC(hif_hdl);
  2477. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  2478. bool dl_updated = false;
  2479. bool ul_updated = false;
  2480. hif_select_service_to_pipe_map(scn, &tgt_svc_map_to_use,
  2481. &sz_tgt_svc_map_to_use);
  2482. *dl_is_polled = 0; /* polling for received messages not supported */
  2483. for (i = 0; i < (sz_tgt_svc_map_to_use/sizeof(element)); i++) {
  2484. memcpy(&element, &tgt_svc_map_to_use[i], sizeof(element));
  2485. if (element.service_id == svc_id) {
  2486. if (element.pipedir == PIPEDIR_OUT) {
  2487. *ul_pipe = element.pipenum;
  2488. *ul_is_polled =
  2489. (hif_state->host_ce_config[*ul_pipe].flags &
  2490. CE_ATTR_DISABLE_INTR) != 0;
  2491. ul_updated = true;
  2492. } else if (element.pipedir == PIPEDIR_IN) {
  2493. *dl_pipe = element.pipenum;
  2494. dl_updated = true;
  2495. }
  2496. status = QDF_STATUS_SUCCESS;
  2497. }
  2498. }
  2499. if (ul_updated == false)
  2500. HIF_INFO("%s: ul pipe is NOT updated for service %d",
  2501. __func__, svc_id);
  2502. if (dl_updated == false)
  2503. HIF_INFO("%s: dl pipe is NOT updated for service %d",
  2504. __func__, svc_id);
  2505. return status;
  2506. }
  2507. #ifdef SHADOW_REG_DEBUG
  2508. inline uint32_t DEBUG_CE_SRC_RING_READ_IDX_GET(struct hif_softc *scn,
  2509. uint32_t CE_ctrl_addr)
  2510. {
  2511. uint32_t read_from_hw, srri_from_ddr = 0;
  2512. read_from_hw = A_TARGET_READ(scn, CE_ctrl_addr + CURRENT_SRRI_ADDRESS);
  2513. srri_from_ddr = SRRI_FROM_DDR_ADDR(VADDR_FOR_CE(scn, CE_ctrl_addr));
  2514. if (read_from_hw != srri_from_ddr) {
  2515. HIF_ERROR("%s: error: read from ddr = %d actual read from register = %d, CE_MISC_INT_STATUS_GET = 0x%x",
  2516. __func__, srri_from_ddr, read_from_hw,
  2517. CE_MISC_INT_STATUS_GET(scn, CE_ctrl_addr));
  2518. QDF_ASSERT(0);
  2519. }
  2520. return srri_from_ddr;
  2521. }
  2522. inline uint32_t DEBUG_CE_DEST_RING_READ_IDX_GET(struct hif_softc *scn,
  2523. uint32_t CE_ctrl_addr)
  2524. {
  2525. uint32_t read_from_hw, drri_from_ddr = 0;
  2526. read_from_hw = A_TARGET_READ(scn, CE_ctrl_addr + CURRENT_DRRI_ADDRESS);
  2527. drri_from_ddr = DRRI_FROM_DDR_ADDR(VADDR_FOR_CE(scn, CE_ctrl_addr));
  2528. if (read_from_hw != drri_from_ddr) {
  2529. HIF_ERROR("error: read from ddr = %d actual read from register = %d, CE_MISC_INT_STATUS_GET = 0x%x",
  2530. drri_from_ddr, read_from_hw,
  2531. CE_MISC_INT_STATUS_GET(scn, CE_ctrl_addr));
  2532. QDF_ASSERT(0);
  2533. }
  2534. return drri_from_ddr;
  2535. }
  2536. #endif
  2537. #ifdef ADRASTEA_RRI_ON_DDR
  2538. /**
  2539. * hif_get_src_ring_read_index(): Called to get the SRRI
  2540. *
  2541. * @scn: hif_softc pointer
  2542. * @CE_ctrl_addr: base address of the CE whose RRI is to be read
  2543. *
  2544. * This function returns the SRRI to the caller. For CEs that
  2545. * dont have interrupts enabled, we look at the DDR based SRRI
  2546. *
  2547. * Return: SRRI
  2548. */
  2549. inline unsigned int hif_get_src_ring_read_index(struct hif_softc *scn,
  2550. uint32_t CE_ctrl_addr)
  2551. {
  2552. struct CE_attr attr;
  2553. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  2554. attr = hif_state->host_ce_config[COPY_ENGINE_ID(CE_ctrl_addr)];
  2555. if (attr.flags & CE_ATTR_DISABLE_INTR) {
  2556. return CE_SRC_RING_READ_IDX_GET_FROM_DDR(scn, CE_ctrl_addr);
  2557. } else {
  2558. if (TARGET_REGISTER_ACCESS_ALLOWED(scn))
  2559. return A_TARGET_READ(scn,
  2560. (CE_ctrl_addr) + CURRENT_SRRI_ADDRESS);
  2561. else
  2562. return CE_SRC_RING_READ_IDX_GET_FROM_DDR(scn,
  2563. CE_ctrl_addr);
  2564. }
  2565. }
  2566. /**
  2567. * hif_get_dst_ring_read_index(): Called to get the DRRI
  2568. *
  2569. * @scn: hif_softc pointer
  2570. * @CE_ctrl_addr: base address of the CE whose RRI is to be read
  2571. *
  2572. * This function returns the DRRI to the caller. For CEs that
  2573. * dont have interrupts enabled, we look at the DDR based DRRI
  2574. *
  2575. * Return: DRRI
  2576. */
  2577. inline unsigned int hif_get_dst_ring_read_index(struct hif_softc *scn,
  2578. uint32_t CE_ctrl_addr)
  2579. {
  2580. struct CE_attr attr;
  2581. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  2582. attr = hif_state->host_ce_config[COPY_ENGINE_ID(CE_ctrl_addr)];
  2583. if (attr.flags & CE_ATTR_DISABLE_INTR) {
  2584. return CE_DEST_RING_READ_IDX_GET_FROM_DDR(scn, CE_ctrl_addr);
  2585. } else {
  2586. if (TARGET_REGISTER_ACCESS_ALLOWED(scn))
  2587. return A_TARGET_READ(scn,
  2588. (CE_ctrl_addr) + CURRENT_DRRI_ADDRESS);
  2589. else
  2590. return CE_DEST_RING_READ_IDX_GET_FROM_DDR(scn,
  2591. CE_ctrl_addr);
  2592. }
  2593. }
  2594. /**
  2595. * hif_config_rri_on_ddr(): Configure the RRI on DDR mechanism
  2596. *
  2597. * @scn: hif_softc pointer
  2598. *
  2599. * This function allocates non cached memory on ddr and sends
  2600. * the physical address of this memory to the CE hardware. The
  2601. * hardware updates the RRI on this particular location.
  2602. *
  2603. * Return: None
  2604. */
  2605. static inline void hif_config_rri_on_ddr(struct hif_softc *scn)
  2606. {
  2607. unsigned int i;
  2608. qdf_dma_addr_t paddr_rri_on_ddr;
  2609. uint32_t high_paddr, low_paddr;
  2610. scn->vaddr_rri_on_ddr =
  2611. (uint32_t *)qdf_mem_alloc_consistent(scn->qdf_dev,
  2612. scn->qdf_dev->dev, (CE_COUNT*sizeof(uint32_t)),
  2613. &paddr_rri_on_ddr);
  2614. scn->paddr_rri_on_ddr = paddr_rri_on_ddr;
  2615. low_paddr = BITS0_TO_31(paddr_rri_on_ddr);
  2616. high_paddr = BITS32_TO_35(paddr_rri_on_ddr);
  2617. HIF_DBG("%s using srri and drri from DDR", __func__);
  2618. WRITE_CE_DDR_ADDRESS_FOR_RRI_LOW(scn, low_paddr);
  2619. WRITE_CE_DDR_ADDRESS_FOR_RRI_HIGH(scn, high_paddr);
  2620. for (i = 0; i < CE_COUNT; i++)
  2621. CE_IDX_UPD_EN_SET(scn, CE_BASE_ADDRESS(i));
  2622. qdf_mem_zero(scn->vaddr_rri_on_ddr, CE_COUNT*sizeof(uint32_t));
  2623. }
  2624. #else
  2625. /**
  2626. * hif_config_rri_on_ddr(): Configure the RRI on DDR mechanism
  2627. *
  2628. * @scn: hif_softc pointer
  2629. *
  2630. * This is a dummy implementation for platforms that don't
  2631. * support this functionality.
  2632. *
  2633. * Return: None
  2634. */
  2635. static inline void hif_config_rri_on_ddr(struct hif_softc *scn)
  2636. {
  2637. }
  2638. #endif
  2639. /**
  2640. * hif_dump_ce_registers() - dump ce registers
  2641. * @scn: hif_opaque_softc pointer.
  2642. *
  2643. * Output the copy engine registers
  2644. *
  2645. * Return: 0 for success or error code
  2646. */
  2647. int hif_dump_ce_registers(struct hif_softc *scn)
  2648. {
  2649. struct hif_opaque_softc *hif_hdl = GET_HIF_OPAQUE_HDL(scn);
  2650. uint32_t ce_reg_address = CE0_BASE_ADDRESS;
  2651. uint32_t ce_reg_values[CE_USEFUL_SIZE >> 2];
  2652. uint32_t ce_reg_word_size = CE_USEFUL_SIZE >> 2;
  2653. uint16_t i;
  2654. QDF_STATUS status;
  2655. for (i = 0; i < scn->ce_count; i++, ce_reg_address += CE_OFFSET) {
  2656. if (scn->ce_id_to_state[i] == NULL) {
  2657. HIF_DBG("CE%d not used.", i);
  2658. continue;
  2659. }
  2660. status = hif_diag_read_mem(hif_hdl, ce_reg_address,
  2661. (uint8_t *) &ce_reg_values[0],
  2662. ce_reg_word_size * sizeof(uint32_t));
  2663. if (status != QDF_STATUS_SUCCESS) {
  2664. HIF_ERROR("Dumping CE register failed!");
  2665. return -EACCES;
  2666. }
  2667. HIF_ERROR("CE%d=>\n", i);
  2668. qdf_trace_hex_dump(QDF_MODULE_ID_HIF, QDF_TRACE_LEVEL_DEBUG,
  2669. (uint8_t *) &ce_reg_values[0],
  2670. ce_reg_word_size * sizeof(uint32_t));
  2671. qdf_print("ADDR:[0x%08X], SR_WR_INDEX:%d\n", (ce_reg_address
  2672. + SR_WR_INDEX_ADDRESS),
  2673. ce_reg_values[SR_WR_INDEX_ADDRESS/4]);
  2674. qdf_print("ADDR:[0x%08X], CURRENT_SRRI:%d\n", (ce_reg_address
  2675. + CURRENT_SRRI_ADDRESS),
  2676. ce_reg_values[CURRENT_SRRI_ADDRESS/4]);
  2677. qdf_print("ADDR:[0x%08X], DST_WR_INDEX:%d\n", (ce_reg_address
  2678. + DST_WR_INDEX_ADDRESS),
  2679. ce_reg_values[DST_WR_INDEX_ADDRESS/4]);
  2680. qdf_print("ADDR:[0x%08X], CURRENT_DRRI:%d\n", (ce_reg_address
  2681. + CURRENT_DRRI_ADDRESS),
  2682. ce_reg_values[CURRENT_DRRI_ADDRESS/4]);
  2683. qdf_print("---\n");
  2684. }
  2685. return 0;
  2686. }
  2687. #ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT
  2688. struct hif_pipe_addl_info *hif_get_addl_pipe_info(struct hif_opaque_softc *osc,
  2689. struct hif_pipe_addl_info *hif_info, uint32_t pipe)
  2690. {
  2691. struct hif_softc *scn = HIF_GET_SOFTC(osc);
  2692. struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(scn);
  2693. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(osc);
  2694. struct HIF_CE_pipe_info *pipe_info = &(hif_state->pipe_info[pipe]);
  2695. struct CE_handle *ce_hdl = pipe_info->ce_hdl;
  2696. struct CE_state *ce_state = (struct CE_state *)ce_hdl;
  2697. struct CE_ring_state *src_ring = ce_state->src_ring;
  2698. struct CE_ring_state *dest_ring = ce_state->dest_ring;
  2699. if (src_ring) {
  2700. hif_info->ul_pipe.nentries = src_ring->nentries;
  2701. hif_info->ul_pipe.nentries_mask = src_ring->nentries_mask;
  2702. hif_info->ul_pipe.sw_index = src_ring->sw_index;
  2703. hif_info->ul_pipe.write_index = src_ring->write_index;
  2704. hif_info->ul_pipe.hw_index = src_ring->hw_index;
  2705. hif_info->ul_pipe.base_addr_CE_space =
  2706. src_ring->base_addr_CE_space;
  2707. hif_info->ul_pipe.base_addr_owner_space =
  2708. src_ring->base_addr_owner_space;
  2709. }
  2710. if (dest_ring) {
  2711. hif_info->dl_pipe.nentries = dest_ring->nentries;
  2712. hif_info->dl_pipe.nentries_mask = dest_ring->nentries_mask;
  2713. hif_info->dl_pipe.sw_index = dest_ring->sw_index;
  2714. hif_info->dl_pipe.write_index = dest_ring->write_index;
  2715. hif_info->dl_pipe.hw_index = dest_ring->hw_index;
  2716. hif_info->dl_pipe.base_addr_CE_space =
  2717. dest_ring->base_addr_CE_space;
  2718. hif_info->dl_pipe.base_addr_owner_space =
  2719. dest_ring->base_addr_owner_space;
  2720. }
  2721. hif_info->pci_mem = pci_resource_start(sc->pdev, 0);
  2722. hif_info->ctrl_addr = ce_state->ctrl_addr;
  2723. return hif_info;
  2724. }
  2725. uint32_t hif_set_nss_wifiol_mode(struct hif_opaque_softc *osc, uint32_t mode)
  2726. {
  2727. struct hif_softc *scn = HIF_GET_SOFTC(osc);
  2728. scn->nss_wifi_ol_mode = mode;
  2729. return 0;
  2730. }
  2731. #endif
  2732. void hif_set_attribute(struct hif_opaque_softc *osc, uint8_t hif_attrib)
  2733. {
  2734. struct hif_softc *scn = HIF_GET_SOFTC(osc);
  2735. scn->hif_attribute = hif_attrib;
  2736. }
  2737. /* disable interrupts (only applicable for legacy copy engine currently */
  2738. void hif_disable_interrupt(struct hif_opaque_softc *osc, uint32_t pipe_num)
  2739. {
  2740. struct hif_softc *scn = HIF_GET_SOFTC(osc);
  2741. struct CE_state *CE_state = scn->ce_id_to_state[pipe_num];
  2742. uint32_t ctrl_addr = CE_state->ctrl_addr;
  2743. Q_TARGET_ACCESS_BEGIN(scn);
  2744. CE_COPY_COMPLETE_INTR_DISABLE(scn, ctrl_addr);
  2745. Q_TARGET_ACCESS_END(scn);
  2746. }
  2747. /**
  2748. * hif_fw_event_handler() - hif fw event handler
  2749. * @hif_state: pointer to hif ce state structure
  2750. *
  2751. * Process fw events and raise HTC callback to process fw events.
  2752. *
  2753. * Return: none
  2754. */
  2755. static inline void hif_fw_event_handler(struct HIF_CE_state *hif_state)
  2756. {
  2757. struct hif_msg_callbacks *msg_callbacks =
  2758. &hif_state->msg_callbacks_current;
  2759. if (!msg_callbacks->fwEventHandler)
  2760. return;
  2761. msg_callbacks->fwEventHandler(msg_callbacks->Context,
  2762. QDF_STATUS_E_FAILURE);
  2763. }
  2764. #ifndef QCA_WIFI_3_0
  2765. /**
  2766. * hif_fw_interrupt_handler() - FW interrupt handler
  2767. * @irq: irq number
  2768. * @arg: the user pointer
  2769. *
  2770. * Called from the PCI interrupt handler when a
  2771. * firmware-generated interrupt to the Host.
  2772. *
  2773. * only registered for legacy ce devices
  2774. *
  2775. * Return: status of handled irq
  2776. */
  2777. irqreturn_t hif_fw_interrupt_handler(int irq, void *arg)
  2778. {
  2779. struct hif_softc *scn = arg;
  2780. struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
  2781. uint32_t fw_indicator_address, fw_indicator;
  2782. if (Q_TARGET_ACCESS_BEGIN(scn) < 0)
  2783. return ATH_ISR_NOSCHED;
  2784. fw_indicator_address = hif_state->fw_indicator_address;
  2785. /* For sudden unplug this will return ~0 */
  2786. fw_indicator = A_TARGET_READ(scn, fw_indicator_address);
  2787. if ((fw_indicator != ~0) && (fw_indicator & FW_IND_EVENT_PENDING)) {
  2788. /* ACK: clear Target-side pending event */
  2789. A_TARGET_WRITE(scn, fw_indicator_address,
  2790. fw_indicator & ~FW_IND_EVENT_PENDING);
  2791. if (Q_TARGET_ACCESS_END(scn) < 0)
  2792. return ATH_ISR_SCHED;
  2793. if (hif_state->started) {
  2794. hif_fw_event_handler(hif_state);
  2795. } else {
  2796. /*
  2797. * Probable Target failure before we're prepared
  2798. * to handle it. Generally unexpected.
  2799. */
  2800. AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
  2801. ("%s: Early firmware event indicated\n",
  2802. __func__));
  2803. }
  2804. } else {
  2805. if (Q_TARGET_ACCESS_END(scn) < 0)
  2806. return ATH_ISR_SCHED;
  2807. }
  2808. return ATH_ISR_SCHED;
  2809. }
  2810. #else
  2811. irqreturn_t hif_fw_interrupt_handler(int irq, void *arg)
  2812. {
  2813. return ATH_ISR_SCHED;
  2814. }
  2815. #endif /* #ifdef QCA_WIFI_3_0 */
  2816. /**
  2817. * hif_wlan_disable(): call the platform driver to disable wlan
  2818. * @scn: HIF Context
  2819. *
  2820. * This function passes the con_mode to platform driver to disable
  2821. * wlan.
  2822. *
  2823. * Return: void
  2824. */
  2825. void hif_wlan_disable(struct hif_softc *scn)
  2826. {
  2827. enum pld_driver_mode mode;
  2828. uint32_t con_mode = hif_get_conparam(scn);
  2829. if (QDF_GLOBAL_FTM_MODE == con_mode)
  2830. mode = PLD_FTM;
  2831. else if (QDF_IS_EPPING_ENABLED(con_mode))
  2832. mode = PLD_EPPING;
  2833. else
  2834. mode = PLD_MISSION;
  2835. pld_wlan_disable(scn->qdf_dev->dev, mode);
  2836. }
  2837. int hif_get_wake_ce_id(struct hif_softc *scn, uint8_t *ce_id)
  2838. {
  2839. QDF_STATUS status;
  2840. uint8_t ul_pipe, dl_pipe;
  2841. int ul_is_polled, dl_is_polled;
  2842. /* DL pipe for HTC_CTRL_RSVD_SVC should map to the wake CE */
  2843. status = hif_map_service_to_pipe(GET_HIF_OPAQUE_HDL(scn),
  2844. HTC_CTRL_RSVD_SVC,
  2845. &ul_pipe, &dl_pipe,
  2846. &ul_is_polled, &dl_is_polled);
  2847. if (status) {
  2848. HIF_ERROR("%s: failed to map pipe: %d", __func__, status);
  2849. return qdf_status_to_os_return(status);
  2850. }
  2851. *ce_id = dl_pipe;
  2852. return 0;
  2853. }