ipa_api.c 85 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/ipa.h>
  6. #include <linux/device.h>
  7. #include <linux/init.h>
  8. #include <linux/kernel.h>
  9. #include <linux/mm.h>
  10. #include <linux/module.h>
  11. #include <linux/of.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/ipa_uc_offload.h>
  14. #include <linux/pci.h>
  15. #include "ipa_api.h"
  16. #include "ipa_v3/ipa_i.h"
  17. /*
  18. * The following for adding code (ie. for EMULATION) not found on x86.
  19. */
  20. #if defined(CONFIG_IPA_EMULATION)
  21. # include "ipa_v3/ipa_emulation_stubs.h"
  22. #endif
  23. #define DRV_NAME "ipa"
  24. #define IPA_API_DISPATCH_RETURN(api, p...) \
  25. do { \
  26. if (!ipa_api_ctrl) { \
  27. pr_err("%s:%d IPA HW is not supported\n", \
  28. __func__, __LINE__); \
  29. ret = -EPERM; \
  30. } \
  31. else { \
  32. if (ipa_api_ctrl->api) { \
  33. ret = ipa_api_ctrl->api(p); \
  34. } else { \
  35. WARN(1, \
  36. "%s not implemented for IPA ver %d\n", \
  37. __func__, ipa_api_hw_type); \
  38. ret = -EPERM; \
  39. } \
  40. } \
  41. } while (0)
  42. #define IPA_API_DISPATCH(api, p...) \
  43. do { \
  44. if (!ipa_api_ctrl) \
  45. pr_err("%s:%d IPA HW is not supported\n", \
  46. __func__, __LINE__); \
  47. else { \
  48. if (ipa_api_ctrl->api) { \
  49. ipa_api_ctrl->api(p); \
  50. } else { \
  51. WARN(1, \
  52. "%s not implemented for IPA ver %d\n",\
  53. __func__, ipa_api_hw_type); \
  54. } \
  55. } \
  56. } while (0)
  57. #define IPA_API_DISPATCH_RETURN_PTR(api, p...) \
  58. do { \
  59. if (!ipa_api_ctrl) { \
  60. pr_err("%s:%d IPA HW is not supported\n", \
  61. __func__, __LINE__); \
  62. ret = NULL; \
  63. } \
  64. else { \
  65. if (ipa_api_ctrl->api) { \
  66. ret = ipa_api_ctrl->api(p); \
  67. } else { \
  68. WARN(1, "%s not implemented for IPA ver %d\n",\
  69. __func__, ipa_api_hw_type); \
  70. ret = NULL; \
  71. } \
  72. } \
  73. } while (0)
  74. #define IPA_API_DISPATCH_RETURN_BOOL(api, p...) \
  75. do { \
  76. if (!ipa_api_ctrl) { \
  77. pr_err("%s:%d IPA HW is not supported\n", \
  78. __func__, __LINE__); \
  79. ret = false; \
  80. } \
  81. else { \
  82. if (ipa_api_ctrl->api) { \
  83. ret = ipa_api_ctrl->api(p); \
  84. } else { \
  85. WARN(1, "%s not implemented for IPA ver %d\n",\
  86. __func__, ipa_api_hw_type); \
  87. ret = false; \
  88. } \
  89. } \
  90. } while (0)
  91. #if defined(CONFIG_IPA_EMULATION)
  92. static bool running_emulation = true;
  93. #else
  94. static bool running_emulation;
  95. #endif
  96. static enum ipa_hw_type ipa_api_hw_type;
  97. static struct ipa_api_controller *ipa_api_ctrl;
  98. const char *ipa_clients_strings[IPA_CLIENT_MAX] = {
  99. __stringify(IPA_CLIENT_HSIC1_PROD),
  100. __stringify(IPA_CLIENT_HSIC1_CONS),
  101. __stringify(IPA_CLIENT_HSIC2_PROD),
  102. __stringify(IPA_CLIENT_HSIC2_CONS),
  103. __stringify(IPA_CLIENT_HSIC3_PROD),
  104. __stringify(IPA_CLIENT_HSIC3_CONS),
  105. __stringify(IPA_CLIENT_HSIC4_PROD),
  106. __stringify(IPA_CLIENT_HSIC4_CONS),
  107. __stringify(IPA_CLIENT_HSIC5_PROD),
  108. __stringify(IPA_CLIENT_HSIC5_CONS),
  109. __stringify(IPA_CLIENT_WLAN1_PROD),
  110. __stringify(IPA_CLIENT_WLAN1_CONS),
  111. __stringify(IPA_CLIENT_WLAN2_PROD),
  112. __stringify(IPA_CLIENT_WLAN2_CONS),
  113. __stringify(RESERVED_PROD_14),
  114. __stringify(IPA_CLIENT_WLAN3_CONS),
  115. __stringify(RESERVED_PROD_16),
  116. __stringify(IPA_CLIENT_WLAN4_CONS),
  117. __stringify(IPA_CLIENT_USB_PROD),
  118. __stringify(IPA_CLIENT_USB_CONS),
  119. __stringify(IPA_CLIENT_USB2_PROD),
  120. __stringify(IPA_CLIENT_USB2_CONS),
  121. __stringify(IPA_CLIENT_USB3_PROD),
  122. __stringify(IPA_CLIENT_USB3_CONS),
  123. __stringify(IPA_CLIENT_USB4_PROD),
  124. __stringify(IPA_CLIENT_USB4_CONS),
  125. __stringify(IPA_CLIENT_UC_USB_PROD),
  126. __stringify(IPA_CLIENT_USB_DPL_CONS),
  127. __stringify(IPA_CLIENT_A2_EMBEDDED_PROD),
  128. __stringify(IPA_CLIENT_A2_EMBEDDED_CONS),
  129. __stringify(IPA_CLIENT_A2_TETHERED_PROD),
  130. __stringify(IPA_CLIENT_A2_TETHERED_CONS),
  131. __stringify(IPA_CLIENT_APPS_LAN_PROD),
  132. __stringify(IPA_CLIENT_APPS_LAN_CONS),
  133. __stringify(IPA_CLIENT_APPS_WAN_PROD),
  134. __stringify(IPA_CLIENT_APPS_WAN_CONS),
  135. __stringify(IPA_CLIENT_APPS_CMD_PROD),
  136. __stringify(IPA_CLIENT_A5_LAN_WAN_CONS),
  137. __stringify(IPA_CLIENT_ODU_PROD),
  138. __stringify(IPA_CLIENT_ODU_EMB_CONS),
  139. __stringify(RESERVED_PROD_40),
  140. __stringify(IPA_CLIENT_ODU_TETH_CONS),
  141. __stringify(IPA_CLIENT_MHI_PROD),
  142. __stringify(IPA_CLIENT_MHI_CONS),
  143. __stringify(IPA_CLIENT_MEMCPY_DMA_SYNC_PROD),
  144. __stringify(IPA_CLIENT_MEMCPY_DMA_SYNC_CONS),
  145. __stringify(IPA_CLIENT_MEMCPY_DMA_ASYNC_PROD),
  146. __stringify(IPA_CLIENT_MEMCPY_DMA_ASYNC_CONS),
  147. __stringify(IPA_CLIENT_ETHERNET_PROD),
  148. __stringify(IPA_CLIENT_ETHERNET_CONS),
  149. __stringify(IPA_CLIENT_Q6_LAN_PROD),
  150. __stringify(IPA_CLIENT_Q6_LAN_CONS),
  151. __stringify(IPA_CLIENT_Q6_WAN_PROD),
  152. __stringify(IPA_CLIENT_Q6_WAN_CONS),
  153. __stringify(IPA_CLIENT_Q6_CMD_PROD),
  154. __stringify(IPA_CLIENT_Q6_DUN_CONS),
  155. __stringify(IPA_CLIENT_Q6_DECOMP_PROD),
  156. __stringify(IPA_CLIENT_Q6_DECOMP_CONS),
  157. __stringify(IPA_CLIENT_Q6_DECOMP2_PROD),
  158. __stringify(IPA_CLIENT_Q6_DECOMP2_CONS),
  159. __stringify(RESERVED_PROD_60),
  160. __stringify(IPA_CLIENT_Q6_LTE_WIFI_AGGR_CONS),
  161. __stringify(IPA_CLIENT_TEST_PROD),
  162. __stringify(IPA_CLIENT_TEST_CONS),
  163. __stringify(IPA_CLIENT_TEST1_PROD),
  164. __stringify(IPA_CLIENT_TEST1_CONS),
  165. __stringify(IPA_CLIENT_TEST2_PROD),
  166. __stringify(IPA_CLIENT_TEST2_CONS),
  167. __stringify(IPA_CLIENT_TEST3_PROD),
  168. __stringify(IPA_CLIENT_TEST3_CONS),
  169. __stringify(IPA_CLIENT_TEST4_PROD),
  170. __stringify(IPA_CLIENT_TEST4_CONS),
  171. __stringify(RESERVED_PROD_72),
  172. __stringify(IPA_CLIENT_DUMMY_CONS),
  173. __stringify(IPA_CLIENT_Q6_DL_NLO_DATA_PROD),
  174. __stringify(IPA_CLIENT_Q6_UL_NLO_DATA_CONS),
  175. __stringify(RESERVED_PROD_76),
  176. __stringify(IPA_CLIENT_Q6_UL_NLO_ACK_CONS),
  177. __stringify(RESERVED_PROD_78),
  178. __stringify(IPA_CLIENT_Q6_QBAP_STATUS_CONS),
  179. __stringify(RESERVED_PROD_80),
  180. __stringify(IPA_CLIENT_MHI_DPL_CONS),
  181. __stringify(RESERVED_PROD_82),
  182. __stringify(IPA_CLIENT_ODL_DPL_CONS),
  183. __stringify(IPA_CLIENT_Q6_AUDIO_DMA_MHI_PROD),
  184. __stringify(IPA_CLIENT_Q6_AUDIO_DMA_MHI_CONS),
  185. __stringify(IPA_CLIENT_WIGIG_PROD),
  186. __stringify(IPA_CLIENT_WIGIG1_CONS),
  187. __stringify(RESERVERD_PROD_88),
  188. __stringify(IPA_CLIENT_WIGIG2_CONS),
  189. __stringify(RESERVERD_PROD_90),
  190. __stringify(IPA_CLIENT_WIGIG3_CONS),
  191. __stringify(RESERVERD_PROD_92),
  192. __stringify(IPA_CLIENT_WIGIG4_CONS),
  193. __stringify(RESERVERD_PROD_94),
  194. __stringify(IPA_CLIENT_APPS_WAN_COAL_CONS),
  195. __stringify(IPA_CLIENT_MHI_PRIME_RMNET_PROD),
  196. __stringify(IPA_CLIENT_MHI_PRIME_RMNET_CONS),
  197. __stringify(IPA_CLIENT_MHI_PRIME_TETH_PROD),
  198. __stringify(IPA_CLIENT_MHI_PRIME_TETH_CONS),
  199. __stringify(IPA_CLIENT_MHI_PRIME_DPL_PROD),
  200. };
  201. /**
  202. * ipa_write_64() - convert 64 bit value to byte array
  203. * @w: 64 bit integer
  204. * @dest: byte array
  205. *
  206. * Return value: converted value
  207. */
  208. u8 *ipa_write_64(u64 w, u8 *dest)
  209. {
  210. if (unlikely(dest == NULL)) {
  211. pr_err("%s: NULL address\n", __func__);
  212. return dest;
  213. }
  214. *dest++ = (u8)((w) & 0xFF);
  215. *dest++ = (u8)((w >> 8) & 0xFF);
  216. *dest++ = (u8)((w >> 16) & 0xFF);
  217. *dest++ = (u8)((w >> 24) & 0xFF);
  218. *dest++ = (u8)((w >> 32) & 0xFF);
  219. *dest++ = (u8)((w >> 40) & 0xFF);
  220. *dest++ = (u8)((w >> 48) & 0xFF);
  221. *dest++ = (u8)((w >> 56) & 0xFF);
  222. return dest;
  223. }
  224. /**
  225. * ipa_write_32() - convert 32 bit value to byte array
  226. * @w: 32 bit integer
  227. * @dest: byte array
  228. *
  229. * Return value: converted value
  230. */
  231. u8 *ipa_write_32(u32 w, u8 *dest)
  232. {
  233. if (unlikely(dest == NULL)) {
  234. pr_err("%s: NULL address\n", __func__);
  235. return dest;
  236. }
  237. *dest++ = (u8)((w) & 0xFF);
  238. *dest++ = (u8)((w >> 8) & 0xFF);
  239. *dest++ = (u8)((w >> 16) & 0xFF);
  240. *dest++ = (u8)((w >> 24) & 0xFF);
  241. return dest;
  242. }
  243. /**
  244. * ipa_write_16() - convert 16 bit value to byte array
  245. * @hw: 16 bit integer
  246. * @dest: byte array
  247. *
  248. * Return value: converted value
  249. */
  250. u8 *ipa_write_16(u16 hw, u8 *dest)
  251. {
  252. if (unlikely(dest == NULL)) {
  253. pr_err("%s: NULL address\n", __func__);
  254. return dest;
  255. }
  256. *dest++ = (u8)((hw) & 0xFF);
  257. *dest++ = (u8)((hw >> 8) & 0xFF);
  258. return dest;
  259. }
  260. /**
  261. * ipa_write_8() - convert 8 bit value to byte array
  262. * @hw: 8 bit integer
  263. * @dest: byte array
  264. *
  265. * Return value: converted value
  266. */
  267. u8 *ipa_write_8(u8 b, u8 *dest)
  268. {
  269. if (unlikely(dest == NULL)) {
  270. WARN(1, "%s: NULL address\n", __func__);
  271. return dest;
  272. }
  273. *dest++ = (b) & 0xFF;
  274. return dest;
  275. }
  276. /**
  277. * ipa_pad_to_64() - pad byte array to 64 bit value
  278. * @dest: byte array
  279. *
  280. * Return value: padded value
  281. */
  282. u8 *ipa_pad_to_64(u8 *dest)
  283. {
  284. int i;
  285. int j;
  286. if (unlikely(dest == NULL)) {
  287. WARN(1, "%s: NULL address\n", __func__);
  288. return dest;
  289. }
  290. i = (long)dest & 0x7;
  291. if (i)
  292. for (j = 0; j < (8 - i); j++)
  293. *dest++ = 0;
  294. return dest;
  295. }
  296. /**
  297. * ipa_pad_to_32() - pad byte array to 32 bit value
  298. * @dest: byte array
  299. *
  300. * Return value: padded value
  301. */
  302. u8 *ipa_pad_to_32(u8 *dest)
  303. {
  304. int i;
  305. int j;
  306. if (unlikely(dest == NULL)) {
  307. WARN(1, "%s: NULL address\n", __func__);
  308. return dest;
  309. }
  310. i = (long)dest & 0x7;
  311. if (i)
  312. for (j = 0; j < (4 - i); j++)
  313. *dest++ = 0;
  314. return dest;
  315. }
  316. int ipa_smmu_store_sgt(struct sg_table **out_ch_ptr,
  317. struct sg_table *in_sgt_ptr)
  318. {
  319. unsigned int nents;
  320. if (in_sgt_ptr != NULL) {
  321. *out_ch_ptr = kzalloc(sizeof(struct sg_table), GFP_KERNEL);
  322. if (*out_ch_ptr == NULL)
  323. return -ENOMEM;
  324. nents = in_sgt_ptr->nents;
  325. (*out_ch_ptr)->sgl =
  326. kcalloc(nents, sizeof(struct scatterlist),
  327. GFP_KERNEL);
  328. if ((*out_ch_ptr)->sgl == NULL) {
  329. kfree(*out_ch_ptr);
  330. *out_ch_ptr = NULL;
  331. return -ENOMEM;
  332. }
  333. memcpy((*out_ch_ptr)->sgl, in_sgt_ptr->sgl,
  334. nents*sizeof((*out_ch_ptr)->sgl));
  335. (*out_ch_ptr)->nents = nents;
  336. (*out_ch_ptr)->orig_nents = in_sgt_ptr->orig_nents;
  337. }
  338. return 0;
  339. }
  340. int ipa_smmu_free_sgt(struct sg_table **out_sgt_ptr)
  341. {
  342. if (*out_sgt_ptr != NULL) {
  343. kfree((*out_sgt_ptr)->sgl);
  344. (*out_sgt_ptr)->sgl = NULL;
  345. kfree(*out_sgt_ptr);
  346. *out_sgt_ptr = NULL;
  347. }
  348. return 0;
  349. }
  350. /**
  351. * ipa_clear_endpoint_delay() - Clear ep_delay.
  352. * @clnt_hdl: [in] IPA client handle
  353. *
  354. * Returns: 0 on success, negative on failure
  355. *
  356. * Note: Should not be called from atomic context
  357. */
  358. int ipa_clear_endpoint_delay(u32 clnt_hdl)
  359. {
  360. int ret;
  361. IPA_API_DISPATCH_RETURN(ipa_clear_endpoint_delay, clnt_hdl);
  362. return ret;
  363. }
  364. EXPORT_SYMBOL(ipa_clear_endpoint_delay);
  365. /**
  366. * ipa_reset_endpoint() - reset an endpoint from BAM perspective
  367. * @clnt_hdl: [in] IPA client handle
  368. *
  369. * Returns: 0 on success, negative on failure
  370. *
  371. * Note: Should not be called from atomic context
  372. */
  373. int ipa_reset_endpoint(u32 clnt_hdl)
  374. {
  375. int ret;
  376. IPA_API_DISPATCH_RETURN(ipa_reset_endpoint, clnt_hdl);
  377. return ret;
  378. }
  379. EXPORT_SYMBOL(ipa_reset_endpoint);
  380. /**
  381. * ipa_disable_endpoint() - Disable an endpoint from IPA perspective
  382. * @clnt_hdl: [in] IPA client handle
  383. *
  384. * Returns: 0 on success, negative on failure
  385. *
  386. * Note: Should not be called from atomic context
  387. */
  388. int ipa_disable_endpoint(u32 clnt_hdl)
  389. {
  390. int ret;
  391. IPA_API_DISPATCH_RETURN(ipa_disable_endpoint, clnt_hdl);
  392. return ret;
  393. }
  394. EXPORT_SYMBOL(ipa_disable_endpoint);
  395. /**
  396. * ipa_cfg_ep - IPA end-point configuration
  397. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  398. * @ipa_ep_cfg: [in] IPA end-point configuration params
  399. *
  400. * This includes nat, header, mode, aggregation and route settings and is a one
  401. * shot API to configure the IPA end-point fully
  402. *
  403. * Returns: 0 on success, negative on failure
  404. *
  405. * Note: Should not be called from atomic context
  406. */
  407. int ipa_cfg_ep(u32 clnt_hdl, const struct ipa_ep_cfg *ipa_ep_cfg)
  408. {
  409. int ret;
  410. IPA_API_DISPATCH_RETURN(ipa_cfg_ep, clnt_hdl, ipa_ep_cfg);
  411. return ret;
  412. }
  413. EXPORT_SYMBOL(ipa_cfg_ep);
  414. /**
  415. * ipa_cfg_ep_nat() - IPA end-point NAT configuration
  416. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  417. * @ep_nat: [in] IPA NAT end-point configuration params
  418. *
  419. * Returns: 0 on success, negative on failure
  420. *
  421. * Note: Should not be called from atomic context
  422. */
  423. int ipa_cfg_ep_nat(u32 clnt_hdl, const struct ipa_ep_cfg_nat *ep_nat)
  424. {
  425. int ret;
  426. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_nat, clnt_hdl, ep_nat);
  427. return ret;
  428. }
  429. EXPORT_SYMBOL(ipa_cfg_ep_nat);
  430. /**
  431. * ipa_cfg_ep_conn_track() - IPA end-point IPv6CT configuration
  432. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  433. * @ep_conn_track: [in] IPA IPv6CT end-point configuration params
  434. *
  435. * Returns: 0 on success, negative on failure
  436. *
  437. * Note: Should not be called from atomic context
  438. */
  439. int ipa_cfg_ep_conn_track(u32 clnt_hdl,
  440. const struct ipa_ep_cfg_conn_track *ep_conn_track)
  441. {
  442. int ret;
  443. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_conn_track, clnt_hdl,
  444. ep_conn_track);
  445. return ret;
  446. }
  447. EXPORT_SYMBOL(ipa_cfg_ep_conn_track);
  448. /**
  449. * ipa_cfg_ep_hdr() - IPA end-point header configuration
  450. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  451. * @ipa_ep_cfg: [in] IPA end-point configuration params
  452. *
  453. * Returns: 0 on success, negative on failure
  454. *
  455. * Note: Should not be called from atomic context
  456. */
  457. int ipa_cfg_ep_hdr(u32 clnt_hdl, const struct ipa_ep_cfg_hdr *ep_hdr)
  458. {
  459. int ret;
  460. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_hdr, clnt_hdl, ep_hdr);
  461. return ret;
  462. }
  463. EXPORT_SYMBOL(ipa_cfg_ep_hdr);
  464. /**
  465. * ipa_cfg_ep_hdr_ext() - IPA end-point extended header configuration
  466. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  467. * @ep_hdr_ext: [in] IPA end-point configuration params
  468. *
  469. * Returns: 0 on success, negative on failure
  470. *
  471. * Note: Should not be called from atomic context
  472. */
  473. int ipa_cfg_ep_hdr_ext(u32 clnt_hdl,
  474. const struct ipa_ep_cfg_hdr_ext *ep_hdr_ext)
  475. {
  476. int ret;
  477. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_hdr_ext, clnt_hdl, ep_hdr_ext);
  478. return ret;
  479. }
  480. EXPORT_SYMBOL(ipa_cfg_ep_hdr_ext);
  481. /**
  482. * ipa_cfg_ep_mode() - IPA end-point mode configuration
  483. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  484. * @ipa_ep_cfg: [in] IPA end-point configuration params
  485. *
  486. * Returns: 0 on success, negative on failure
  487. *
  488. * Note: Should not be called from atomic context
  489. */
  490. int ipa_cfg_ep_mode(u32 clnt_hdl, const struct ipa_ep_cfg_mode *ep_mode)
  491. {
  492. int ret;
  493. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_mode, clnt_hdl, ep_mode);
  494. return ret;
  495. }
  496. EXPORT_SYMBOL(ipa_cfg_ep_mode);
  497. /**
  498. * ipa_cfg_ep_aggr() - IPA end-point aggregation configuration
  499. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  500. * @ipa_ep_cfg: [in] IPA end-point configuration params
  501. *
  502. * Returns: 0 on success, negative on failure
  503. *
  504. * Note: Should not be called from atomic context
  505. */
  506. int ipa_cfg_ep_aggr(u32 clnt_hdl, const struct ipa_ep_cfg_aggr *ep_aggr)
  507. {
  508. int ret;
  509. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_aggr, clnt_hdl, ep_aggr);
  510. return ret;
  511. }
  512. EXPORT_SYMBOL(ipa_cfg_ep_aggr);
  513. /**
  514. * ipa_cfg_ep_deaggr() - IPA end-point deaggregation configuration
  515. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  516. * @ep_deaggr: [in] IPA end-point configuration params
  517. *
  518. * Returns: 0 on success, negative on failure
  519. *
  520. * Note: Should not be called from atomic context
  521. */
  522. int ipa_cfg_ep_deaggr(u32 clnt_hdl,
  523. const struct ipa_ep_cfg_deaggr *ep_deaggr)
  524. {
  525. int ret;
  526. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_deaggr, clnt_hdl, ep_deaggr);
  527. return ret;
  528. }
  529. EXPORT_SYMBOL(ipa_cfg_ep_deaggr);
  530. /**
  531. * ipa_cfg_ep_route() - IPA end-point routing configuration
  532. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  533. * @ipa_ep_cfg: [in] IPA end-point configuration params
  534. *
  535. * Returns: 0 on success, negative on failure
  536. *
  537. * Note: Should not be called from atomic context
  538. */
  539. int ipa_cfg_ep_route(u32 clnt_hdl, const struct ipa_ep_cfg_route *ep_route)
  540. {
  541. int ret;
  542. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_route, clnt_hdl, ep_route);
  543. return ret;
  544. }
  545. EXPORT_SYMBOL(ipa_cfg_ep_route);
  546. /**
  547. * ipa_cfg_ep_holb() - IPA end-point holb configuration
  548. *
  549. * If an IPA producer pipe is full, IPA HW by default will block
  550. * indefinitely till space opens up. During this time no packets
  551. * including those from unrelated pipes will be processed. Enabling
  552. * HOLB means IPA HW will be allowed to drop packets as/when needed
  553. * and indefinite blocking is avoided.
  554. *
  555. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  556. * @ipa_ep_cfg: [in] IPA end-point configuration params
  557. *
  558. * Returns: 0 on success, negative on failure
  559. */
  560. int ipa_cfg_ep_holb(u32 clnt_hdl, const struct ipa_ep_cfg_holb *ep_holb)
  561. {
  562. int ret;
  563. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_holb, clnt_hdl, ep_holb);
  564. return ret;
  565. }
  566. EXPORT_SYMBOL(ipa_cfg_ep_holb);
  567. /**
  568. * ipa_cfg_ep_cfg() - IPA end-point cfg configuration
  569. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  570. * @ipa_ep_cfg: [in] IPA end-point configuration params
  571. *
  572. * Returns: 0 on success, negative on failure
  573. *
  574. * Note: Should not be called from atomic context
  575. */
  576. int ipa_cfg_ep_cfg(u32 clnt_hdl, const struct ipa_ep_cfg_cfg *cfg)
  577. {
  578. int ret;
  579. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_cfg, clnt_hdl, cfg);
  580. return ret;
  581. }
  582. EXPORT_SYMBOL(ipa_cfg_ep_cfg);
  583. /**
  584. * ipa_cfg_ep_metadata_mask() - IPA end-point meta-data mask configuration
  585. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  586. * @ipa_ep_cfg: [in] IPA end-point configuration params
  587. *
  588. * Returns: 0 on success, negative on failure
  589. *
  590. * Note: Should not be called from atomic context
  591. */
  592. int ipa_cfg_ep_metadata_mask(u32 clnt_hdl, const struct ipa_ep_cfg_metadata_mask
  593. *metadata_mask)
  594. {
  595. int ret;
  596. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_metadata_mask, clnt_hdl,
  597. metadata_mask);
  598. return ret;
  599. }
  600. EXPORT_SYMBOL(ipa_cfg_ep_metadata_mask);
  601. /**
  602. * ipa_cfg_ep_holb_by_client() - IPA end-point holb configuration
  603. *
  604. * Wrapper function for ipa_cfg_ep_holb() with client name instead of
  605. * client handle. This function is used for clients that does not have
  606. * client handle.
  607. *
  608. * @client: [in] client name
  609. * @ipa_ep_cfg: [in] IPA end-point configuration params
  610. *
  611. * Returns: 0 on success, negative on failure
  612. */
  613. int ipa_cfg_ep_holb_by_client(enum ipa_client_type client,
  614. const struct ipa_ep_cfg_holb *ep_holb)
  615. {
  616. int ret;
  617. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_holb_by_client, client, ep_holb);
  618. return ret;
  619. }
  620. EXPORT_SYMBOL(ipa_cfg_ep_holb_by_client);
  621. /**
  622. * ipa_cfg_ep_ctrl() - IPA end-point Control configuration
  623. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  624. * @ipa_ep_cfg_ctrl: [in] IPA end-point configuration params
  625. *
  626. * Returns: 0 on success, negative on failure
  627. */
  628. int ipa_cfg_ep_ctrl(u32 clnt_hdl, const struct ipa_ep_cfg_ctrl *ep_ctrl)
  629. {
  630. int ret;
  631. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_ctrl, clnt_hdl, ep_ctrl);
  632. return ret;
  633. }
  634. EXPORT_SYMBOL(ipa_cfg_ep_ctrl);
  635. /**
  636. * ipa_add_hdr() - add the specified headers to SW and optionally commit them to
  637. * IPA HW
  638. * @hdrs: [inout] set of headers to add
  639. *
  640. * Returns: 0 on success, negative on failure
  641. *
  642. * Note: Should not be called from atomic context
  643. */
  644. int ipa_add_hdr(struct ipa_ioc_add_hdr *hdrs)
  645. {
  646. int ret;
  647. IPA_API_DISPATCH_RETURN(ipa_add_hdr, hdrs);
  648. return ret;
  649. }
  650. EXPORT_SYMBOL(ipa_add_hdr);
  651. /**
  652. * ipa_add_hdr_usr() - add the specified headers to SW and optionally
  653. * commit them to IPA HW
  654. * @hdrs: [inout] set of headers to add
  655. * @user_only: [in] indicate rules installed by userspace
  656. *
  657. * Returns: 0 on success, negative on failure
  658. *
  659. * Note: Should not be called from atomic context
  660. */
  661. int ipa_add_hdr_usr(struct ipa_ioc_add_hdr *hdrs, bool user_only)
  662. {
  663. int ret;
  664. IPA_API_DISPATCH_RETURN(ipa_add_hdr_usr, hdrs, user_only);
  665. return ret;
  666. }
  667. EXPORT_SYMBOL(ipa_add_hdr_usr);
  668. /**
  669. * ipa_del_hdr() - Remove the specified headers from SW and optionally
  670. * commit them to IPA HW
  671. * @hdls: [inout] set of headers to delete
  672. *
  673. * Returns: 0 on success, negative on failure
  674. *
  675. * Note: Should not be called from atomic context
  676. */
  677. int ipa_del_hdr(struct ipa_ioc_del_hdr *hdls)
  678. {
  679. int ret;
  680. IPA_API_DISPATCH_RETURN(ipa_del_hdr, hdls);
  681. return ret;
  682. }
  683. EXPORT_SYMBOL(ipa_del_hdr);
  684. /**
  685. * ipa_commit_hdr() - commit to IPA HW the current header table in SW
  686. *
  687. * Returns: 0 on success, negative on failure
  688. *
  689. * Note: Should not be called from atomic context
  690. */
  691. int ipa_commit_hdr(void)
  692. {
  693. int ret;
  694. IPA_API_DISPATCH_RETURN(ipa_commit_hdr);
  695. return ret;
  696. }
  697. EXPORT_SYMBOL(ipa_commit_hdr);
  698. /**
  699. * ipa_reset_hdr() - reset the current header table in SW (does not commit to
  700. * HW)
  701. *
  702. * @user_only: [in] indicate delete rules installed by userspace
  703. * Returns: 0 on success, negative on failure
  704. *
  705. * Note: Should not be called from atomic context
  706. */
  707. int ipa_reset_hdr(bool user_only)
  708. {
  709. int ret;
  710. IPA_API_DISPATCH_RETURN(ipa_reset_hdr, user_only);
  711. return ret;
  712. }
  713. EXPORT_SYMBOL(ipa_reset_hdr);
  714. /**
  715. * ipa_get_hdr() - Lookup the specified header resource
  716. * @lookup: [inout] header to lookup and its handle
  717. *
  718. * lookup the specified header resource and return handle if it exists
  719. *
  720. * Returns: 0 on success, negative on failure
  721. *
  722. * Note: Should not be called from atomic context
  723. * Caller should call ipa_put_hdr later if this function succeeds
  724. */
  725. int ipa_get_hdr(struct ipa_ioc_get_hdr *lookup)
  726. {
  727. int ret;
  728. IPA_API_DISPATCH_RETURN(ipa_get_hdr, lookup);
  729. return ret;
  730. }
  731. EXPORT_SYMBOL(ipa_get_hdr);
  732. /**
  733. * ipa_put_hdr() - Release the specified header handle
  734. * @hdr_hdl: [in] the header handle to release
  735. *
  736. * Returns: 0 on success, negative on failure
  737. *
  738. * Note: Should not be called from atomic context
  739. */
  740. int ipa_put_hdr(u32 hdr_hdl)
  741. {
  742. int ret;
  743. IPA_API_DISPATCH_RETURN(ipa_put_hdr, hdr_hdl);
  744. return ret;
  745. }
  746. EXPORT_SYMBOL(ipa_put_hdr);
  747. /**
  748. * ipa_copy_hdr() - Lookup the specified header resource and return a copy of it
  749. * @copy: [inout] header to lookup and its copy
  750. *
  751. * lookup the specified header resource and return a copy of it (along with its
  752. * attributes) if it exists, this would be called for partial headers
  753. *
  754. * Returns: 0 on success, negative on failure
  755. *
  756. * Note: Should not be called from atomic context
  757. */
  758. int ipa_copy_hdr(struct ipa_ioc_copy_hdr *copy)
  759. {
  760. int ret;
  761. IPA_API_DISPATCH_RETURN(ipa_copy_hdr, copy);
  762. return ret;
  763. }
  764. EXPORT_SYMBOL(ipa_copy_hdr);
  765. /**
  766. * ipa_add_hdr_proc_ctx() - add the specified headers to SW
  767. * and optionally commit them to IPA HW
  768. * @proc_ctxs: [inout] set of processing context headers to add
  769. * @user_only: [in] indicate rules installed by userspace
  770. *
  771. * Returns: 0 on success, negative on failure
  772. *
  773. * Note: Should not be called from atomic context
  774. */
  775. int ipa_add_hdr_proc_ctx(struct ipa_ioc_add_hdr_proc_ctx *proc_ctxs,
  776. bool user_only)
  777. {
  778. int ret;
  779. IPA_API_DISPATCH_RETURN(ipa_add_hdr_proc_ctx, proc_ctxs, user_only);
  780. return ret;
  781. }
  782. EXPORT_SYMBOL(ipa_add_hdr_proc_ctx);
  783. /**
  784. * ipa_del_hdr_proc_ctx() -
  785. * Remove the specified processing context headers from SW and
  786. * optionally commit them to IPA HW.
  787. * @hdls: [inout] set of processing context headers to delete
  788. *
  789. * Returns: 0 on success, negative on failure
  790. *
  791. * Note: Should not be called from atomic context
  792. */
  793. int ipa_del_hdr_proc_ctx(struct ipa_ioc_del_hdr_proc_ctx *hdls)
  794. {
  795. int ret;
  796. IPA_API_DISPATCH_RETURN(ipa_del_hdr_proc_ctx, hdls);
  797. return ret;
  798. }
  799. EXPORT_SYMBOL(ipa_del_hdr_proc_ctx);
  800. /**
  801. * ipa_add_rt_rule() - Add the specified routing rules to SW and optionally
  802. * commit to IPA HW
  803. * @rules: [inout] set of routing rules to add
  804. *
  805. * Returns: 0 on success, negative on failure
  806. *
  807. * Note: Should not be called from atomic context
  808. */
  809. int ipa_add_rt_rule(struct ipa_ioc_add_rt_rule *rules)
  810. {
  811. int ret;
  812. IPA_API_DISPATCH_RETURN(ipa_add_rt_rule, rules);
  813. return ret;
  814. }
  815. EXPORT_SYMBOL(ipa_add_rt_rule);
  816. /**
  817. * ipa_add_rt_rule_v2() - Add the specified routing rules to SW
  818. * and optionally commit to IPA HW
  819. * @rules: [inout] set of routing rules to add
  820. *
  821. * Returns: 0 on success, negative on failure
  822. *
  823. * Note: Should not be called from atomic context
  824. */
  825. int ipa_add_rt_rule_v2(struct ipa_ioc_add_rt_rule_v2 *rules)
  826. {
  827. int ret;
  828. IPA_API_DISPATCH_RETURN(ipa_add_rt_rule_v2, rules);
  829. return ret;
  830. }
  831. EXPORT_SYMBOL(ipa_add_rt_rule_v2);
  832. /**
  833. * ipa_add_rt_rule_usr() - Add the specified routing rules to SW and optionally
  834. * commit to IPA HW
  835. * @rules: [inout] set of routing rules to add
  836. * @user_only: [in] indicate rules installed by userspace
  837. *
  838. * Returns: 0 on success, negative on failure
  839. *
  840. * Note: Should not be called from atomic context
  841. */
  842. int ipa_add_rt_rule_usr(struct ipa_ioc_add_rt_rule *rules, bool user_only)
  843. {
  844. int ret;
  845. IPA_API_DISPATCH_RETURN(ipa_add_rt_rule_usr, rules, user_only);
  846. return ret;
  847. }
  848. EXPORT_SYMBOL(ipa_add_rt_rule_usr);
  849. /**
  850. * ipa_add_rt_rule_usr_v2() - Add the specified routing rules to
  851. * SW and optionally commit to IPA HW
  852. * @rules: [inout] set of routing rules to add
  853. * @user_only: [in] indicate rules installed by userspace
  854. *
  855. * Returns: 0 on success, negative on failure
  856. *
  857. * Note: Should not be called from atomic context
  858. */
  859. int ipa_add_rt_rule_usr_v2(struct ipa_ioc_add_rt_rule_v2 *rules, bool user_only)
  860. {
  861. int ret;
  862. IPA_API_DISPATCH_RETURN(ipa_add_rt_rule_usr_v2, rules, user_only);
  863. return ret;
  864. }
  865. EXPORT_SYMBOL(ipa_add_rt_rule_usr_v2);
  866. /**
  867. * ipa_del_rt_rule() - Remove the specified routing rules to SW and optionally
  868. * commit to IPA HW
  869. * @hdls: [inout] set of routing rules to delete
  870. *
  871. * Returns: 0 on success, negative on failure
  872. *
  873. * Note: Should not be called from atomic context
  874. */
  875. int ipa_del_rt_rule(struct ipa_ioc_del_rt_rule *hdls)
  876. {
  877. int ret;
  878. IPA_API_DISPATCH_RETURN(ipa_del_rt_rule, hdls);
  879. return ret;
  880. }
  881. EXPORT_SYMBOL(ipa_del_rt_rule);
  882. /**
  883. * ipa_commit_rt_rule() - Commit the current SW routing table of specified type
  884. * to IPA HW
  885. * @ip: The family of routing tables
  886. *
  887. * Returns: 0 on success, negative on failure
  888. *
  889. * Note: Should not be called from atomic context
  890. */
  891. int ipa_commit_rt(enum ipa_ip_type ip)
  892. {
  893. int ret;
  894. IPA_API_DISPATCH_RETURN(ipa_commit_rt, ip);
  895. return ret;
  896. }
  897. EXPORT_SYMBOL(ipa_commit_rt);
  898. /**
  899. * ipa_reset_rt() - reset the current SW routing table of specified type
  900. * (does not commit to HW)
  901. * @ip: The family of routing tables
  902. * @user_only: [in] indicate delete rules installed by userspace
  903. *
  904. * Returns: 0 on success, negative on failure
  905. *
  906. * Note: Should not be called from atomic context
  907. */
  908. int ipa_reset_rt(enum ipa_ip_type ip, bool user_only)
  909. {
  910. int ret;
  911. IPA_API_DISPATCH_RETURN(ipa_reset_rt, ip, user_only);
  912. return ret;
  913. }
  914. EXPORT_SYMBOL(ipa_reset_rt);
  915. /**
  916. * ipa_get_rt_tbl() - lookup the specified routing table and return handle if it
  917. * exists, if lookup succeeds the routing table ref cnt is increased
  918. * @lookup: [inout] routing table to lookup and its handle
  919. *
  920. * Returns: 0 on success, negative on failure
  921. *
  922. * Note: Should not be called from atomic context
  923. * Caller should call ipa_put_rt_tbl later if this function succeeds
  924. */
  925. int ipa_get_rt_tbl(struct ipa_ioc_get_rt_tbl *lookup)
  926. {
  927. int ret;
  928. IPA_API_DISPATCH_RETURN(ipa_get_rt_tbl, lookup);
  929. return ret;
  930. }
  931. EXPORT_SYMBOL(ipa_get_rt_tbl);
  932. /**
  933. * ipa_put_rt_tbl() - Release the specified routing table handle
  934. * @rt_tbl_hdl: [in] the routing table handle to release
  935. *
  936. * Returns: 0 on success, negative on failure
  937. *
  938. * Note: Should not be called from atomic context
  939. */
  940. int ipa_put_rt_tbl(u32 rt_tbl_hdl)
  941. {
  942. int ret;
  943. IPA_API_DISPATCH_RETURN(ipa_put_rt_tbl, rt_tbl_hdl);
  944. return ret;
  945. }
  946. EXPORT_SYMBOL(ipa_put_rt_tbl);
  947. /**
  948. * ipa_query_rt_index() - find the routing table index
  949. * which name and ip type are given as parameters
  950. * @in: [out] the index of the wanted routing table
  951. *
  952. * Returns: the routing table which name is given as parameter, or NULL if it
  953. * doesn't exist
  954. */
  955. int ipa_query_rt_index(struct ipa_ioc_get_rt_tbl_indx *in)
  956. {
  957. int ret;
  958. IPA_API_DISPATCH_RETURN(ipa_query_rt_index, in);
  959. return ret;
  960. }
  961. EXPORT_SYMBOL(ipa_query_rt_index);
  962. /**
  963. * ipa_mdfy_rt_rule() - Modify the specified routing rules in SW and optionally
  964. * commit to IPA HW
  965. *
  966. * Returns: 0 on success, negative on failure
  967. *
  968. * Note: Should not be called from atomic context
  969. */
  970. int ipa_mdfy_rt_rule(struct ipa_ioc_mdfy_rt_rule *hdls)
  971. {
  972. int ret;
  973. IPA_API_DISPATCH_RETURN(ipa_mdfy_rt_rule, hdls);
  974. return ret;
  975. }
  976. EXPORT_SYMBOL(ipa_mdfy_rt_rule);
  977. /**
  978. * ipa_mdfy_rt_rule_v2() - Modify the specified routing rules in
  979. * SW and optionally commit to IPA HW
  980. *
  981. * Returns: 0 on success, negative on failure
  982. *
  983. * Note: Should not be called from atomic context
  984. */
  985. int ipa_mdfy_rt_rule_v2(struct ipa_ioc_mdfy_rt_rule_v2 *hdls)
  986. {
  987. int ret;
  988. IPA_API_DISPATCH_RETURN(ipa_mdfy_rt_rule_v2, hdls);
  989. return ret;
  990. }
  991. EXPORT_SYMBOL(ipa_mdfy_rt_rule_v2);
  992. /**
  993. * ipa_add_flt_rule() - Add the specified filtering rules to SW and optionally
  994. * commit to IPA HW
  995. * @rules: [inout] set of filtering rules to add
  996. *
  997. * Returns: 0 on success, negative on failure
  998. *
  999. * Note: Should not be called from atomic context
  1000. */
  1001. int ipa_add_flt_rule(struct ipa_ioc_add_flt_rule *rules)
  1002. {
  1003. int ret;
  1004. IPA_API_DISPATCH_RETURN(ipa_add_flt_rule, rules);
  1005. return ret;
  1006. }
  1007. EXPORT_SYMBOL(ipa_add_flt_rule);
  1008. /**
  1009. * ipa_add_flt_rule_v2() - Add the specified filtering rules to
  1010. * SW and optionally commit to IPA HW
  1011. * @rules: [inout] set of filtering rules to add
  1012. *
  1013. * Returns: 0 on success, negative on failure
  1014. *
  1015. * Note: Should not be called from atomic context
  1016. */
  1017. int ipa_add_flt_rule_v2(struct ipa_ioc_add_flt_rule_v2 *rules)
  1018. {
  1019. int ret;
  1020. IPA_API_DISPATCH_RETURN(ipa_add_flt_rule_v2, rules);
  1021. return ret;
  1022. }
  1023. EXPORT_SYMBOL(ipa_add_flt_rule_v2);
  1024. /**
  1025. * ipa_add_flt_rule_usr() - Add the specified filtering rules to
  1026. * SW and optionally commit to IPA HW
  1027. * @rules: [inout] set of filtering rules to add
  1028. * @user_only: [in] indicate rules installed by userspace
  1029. *
  1030. * Returns: 0 on success, negative on failure
  1031. *
  1032. * Note: Should not be called from atomic context
  1033. */
  1034. int ipa_add_flt_rule_usr(struct ipa_ioc_add_flt_rule *rules, bool user_only)
  1035. {
  1036. int ret;
  1037. IPA_API_DISPATCH_RETURN(ipa_add_flt_rule_usr, rules, user_only);
  1038. return ret;
  1039. }
  1040. EXPORT_SYMBOL(ipa_add_flt_rule_usr);
  1041. /**
  1042. * ipa_add_flt_rule_usr_v2() - Add the specified filtering rules
  1043. * to SW and optionally commit to IPA HW
  1044. * @rules: [inout] set of filtering rules to add
  1045. * @user_only: [in] indicate rules installed by userspace
  1046. *
  1047. * Returns: 0 on success, negative on failure
  1048. *
  1049. * Note: Should not be called from atomic context
  1050. */
  1051. int ipa_add_flt_rule_usr_v2(struct ipa_ioc_add_flt_rule_v2 *rules,
  1052. bool user_only)
  1053. {
  1054. int ret;
  1055. IPA_API_DISPATCH_RETURN(ipa_add_flt_rule_usr_v2,
  1056. rules, user_only);
  1057. return ret;
  1058. }
  1059. EXPORT_SYMBOL(ipa_add_flt_rule_usr_v2);
  1060. /**
  1061. * ipa_del_flt_rule() - Remove the specified filtering rules from SW and
  1062. * optionally commit to IPA HW
  1063. *
  1064. * Returns: 0 on success, negative on failure
  1065. *
  1066. * Note: Should not be called from atomic context
  1067. */
  1068. int ipa_del_flt_rule(struct ipa_ioc_del_flt_rule *hdls)
  1069. {
  1070. int ret;
  1071. IPA_API_DISPATCH_RETURN(ipa_del_flt_rule, hdls);
  1072. return ret;
  1073. }
  1074. EXPORT_SYMBOL(ipa_del_flt_rule);
  1075. /**
  1076. * ipa_mdfy_flt_rule() - Modify the specified filtering rules in SW and
  1077. * optionally commit to IPA HW
  1078. *
  1079. * Returns: 0 on success, negative on failure
  1080. *
  1081. * Note: Should not be called from atomic context
  1082. */
  1083. int ipa_mdfy_flt_rule(struct ipa_ioc_mdfy_flt_rule *hdls)
  1084. {
  1085. int ret;
  1086. IPA_API_DISPATCH_RETURN(ipa_mdfy_flt_rule, hdls);
  1087. return ret;
  1088. }
  1089. EXPORT_SYMBOL(ipa_mdfy_flt_rule);
  1090. /**
  1091. * ipa_mdfy_flt_rule_v2() - Modify the specified filtering rules
  1092. * in SW and optionally commit to IPA HW
  1093. *
  1094. * Returns: 0 on success, negative on failure
  1095. *
  1096. * Note: Should not be called from atomic context
  1097. */
  1098. int ipa_mdfy_flt_rule_v2(struct ipa_ioc_mdfy_flt_rule_v2 *hdls)
  1099. {
  1100. int ret;
  1101. IPA_API_DISPATCH_RETURN(ipa_mdfy_flt_rule_v2, hdls);
  1102. return ret;
  1103. }
  1104. EXPORT_SYMBOL(ipa_mdfy_flt_rule_v2);
  1105. /**
  1106. * ipa_commit_flt() - Commit the current SW filtering table of specified type to
  1107. * IPA HW
  1108. * @ip: [in] the family of routing tables
  1109. *
  1110. * Returns: 0 on success, negative on failure
  1111. *
  1112. * Note: Should not be called from atomic context
  1113. */
  1114. int ipa_commit_flt(enum ipa_ip_type ip)
  1115. {
  1116. int ret;
  1117. IPA_API_DISPATCH_RETURN(ipa_commit_flt, ip);
  1118. return ret;
  1119. }
  1120. EXPORT_SYMBOL(ipa_commit_flt);
  1121. /**
  1122. * ipa_reset_flt() - Reset the current SW filtering table of specified type
  1123. * (does not commit to HW)
  1124. * @ip: [in] the family of routing tables
  1125. * @user_only: [in] indicate delete rules installed by userspace
  1126. *
  1127. * Returns: 0 on success, negative on failure
  1128. *
  1129. * Note: Should not be called from atomic context
  1130. */
  1131. int ipa_reset_flt(enum ipa_ip_type ip, bool user_only)
  1132. {
  1133. int ret;
  1134. IPA_API_DISPATCH_RETURN(ipa_reset_flt, ip, user_only);
  1135. return ret;
  1136. }
  1137. EXPORT_SYMBOL(ipa_reset_flt);
  1138. /**
  1139. * ipa_allocate_nat_device() - Allocates memory for the NAT device
  1140. * @mem: [in/out] memory parameters
  1141. *
  1142. * Called by NAT client driver to allocate memory for the NAT entries. Based on
  1143. * the request size either shared or system memory will be used.
  1144. *
  1145. * Returns: 0 on success, negative on failure
  1146. */
  1147. int ipa_allocate_nat_device(struct ipa_ioc_nat_alloc_mem *mem)
  1148. {
  1149. int ret;
  1150. IPA_API_DISPATCH_RETURN(ipa_allocate_nat_device, mem);
  1151. return ret;
  1152. }
  1153. EXPORT_SYMBOL(ipa_allocate_nat_device);
  1154. /**
  1155. * ipa_allocate_nat_table() - Allocates memory for the NAT table
  1156. * @table_alloc: [in/out] memory parameters
  1157. *
  1158. * Called by NAT client to allocate memory for the table entries.
  1159. * Based on the request size either shared or system memory will be used.
  1160. *
  1161. * Returns: 0 on success, negative on failure
  1162. */
  1163. int ipa_allocate_nat_table(struct ipa_ioc_nat_ipv6ct_table_alloc *table_alloc)
  1164. {
  1165. int ret;
  1166. IPA_API_DISPATCH_RETURN(ipa_allocate_nat_table, table_alloc);
  1167. return ret;
  1168. }
  1169. EXPORT_SYMBOL(ipa_allocate_nat_table);
  1170. /**
  1171. * ipa_allocate_ipv6ct_table() - Allocates memory for the IPv6CT table
  1172. * @table_alloc: [in/out] memory parameters
  1173. *
  1174. * Called by IPv6CT client to allocate memory for the table entries.
  1175. * Based on the request size either shared or system memory will be used.
  1176. *
  1177. * Returns: 0 on success, negative on failure
  1178. */
  1179. int ipa_allocate_ipv6ct_table(
  1180. struct ipa_ioc_nat_ipv6ct_table_alloc *table_alloc)
  1181. {
  1182. int ret;
  1183. IPA_API_DISPATCH_RETURN(ipa_allocate_ipv6ct_table, table_alloc);
  1184. return ret;
  1185. }
  1186. EXPORT_SYMBOL(ipa_allocate_ipv6ct_table);
  1187. /**
  1188. * ipa_nat_init_cmd() - Post IP_V4_NAT_INIT command to IPA HW
  1189. * @init: [in] initialization command attributes
  1190. *
  1191. * Called by NAT client driver to post IP_V4_NAT_INIT command to IPA HW
  1192. *
  1193. * Returns: 0 on success, negative on failure
  1194. */
  1195. int ipa_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
  1196. {
  1197. int ret;
  1198. IPA_API_DISPATCH_RETURN(ipa_nat_init_cmd, init);
  1199. return ret;
  1200. }
  1201. EXPORT_SYMBOL(ipa_nat_init_cmd);
  1202. /**
  1203. * ipa_ipv6ct_init_cmd() - Post IP_V6_CONN_TRACK_INIT command to IPA HW
  1204. * @init: [in] initialization command attributes
  1205. *
  1206. * Called by IPv6CT client driver to post IP_V6_CONN_TRACK_INIT command
  1207. * to IPA HW.
  1208. *
  1209. * Returns: 0 on success, negative on failure
  1210. */
  1211. int ipa_ipv6ct_init_cmd(struct ipa_ioc_ipv6ct_init *init)
  1212. {
  1213. int ret;
  1214. IPA_API_DISPATCH_RETURN(ipa_ipv6ct_init_cmd, init);
  1215. return ret;
  1216. }
  1217. EXPORT_SYMBOL(ipa_ipv6ct_init_cmd);
  1218. /**
  1219. * ipa_nat_dma_cmd() - Post NAT_DMA command to IPA HW
  1220. * @dma: [in] initialization command attributes
  1221. *
  1222. * Called by NAT client driver to post NAT_DMA command to IPA HW
  1223. *
  1224. * Returns: 0 on success, negative on failure
  1225. */
  1226. int ipa_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
  1227. {
  1228. int ret;
  1229. IPA_API_DISPATCH_RETURN(ipa_nat_dma_cmd, dma);
  1230. return ret;
  1231. }
  1232. EXPORT_SYMBOL(ipa_nat_dma_cmd);
  1233. /**
  1234. * ipa_table_dma_cmd() - Post TABLE_DMA command to IPA HW
  1235. * @dma: [in] initialization command attributes
  1236. *
  1237. * Called by NAT/IPv6CT client to post TABLE_DMA command to IPA HW
  1238. *
  1239. * Returns: 0 on success, negative on failure
  1240. */
  1241. int ipa_table_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
  1242. {
  1243. int ret;
  1244. IPA_API_DISPATCH_RETURN(ipa_table_dma_cmd, dma);
  1245. return ret;
  1246. }
  1247. EXPORT_SYMBOL(ipa_table_dma_cmd);
  1248. /**
  1249. * ipa_nat_del_cmd() - Delete the NAT table
  1250. * @del: [in] delete NAT table parameters
  1251. *
  1252. * Called by NAT client driver to delete the nat table
  1253. *
  1254. * Returns: 0 on success, negative on failure
  1255. */
  1256. int ipa_nat_del_cmd(struct ipa_ioc_v4_nat_del *del)
  1257. {
  1258. int ret;
  1259. IPA_API_DISPATCH_RETURN(ipa_nat_del_cmd, del);
  1260. return ret;
  1261. }
  1262. EXPORT_SYMBOL(ipa_nat_del_cmd);
  1263. /**
  1264. * ipa_del_nat_table() - Delete the NAT table
  1265. * @del: [in] delete table parameters
  1266. *
  1267. * Called by NAT client to delete the table
  1268. *
  1269. * Returns: 0 on success, negative on failure
  1270. */
  1271. int ipa_del_nat_table(struct ipa_ioc_nat_ipv6ct_table_del *del)
  1272. {
  1273. int ret;
  1274. IPA_API_DISPATCH_RETURN(ipa_del_nat_table, del);
  1275. return ret;
  1276. }
  1277. EXPORT_SYMBOL(ipa_del_nat_table);
  1278. /**
  1279. * ipa_del_ipv6ct_table() - Delete the IPv6CT table
  1280. * @del: [in] delete table parameters
  1281. *
  1282. * Called by IPv6CT client to delete the table
  1283. *
  1284. * Returns: 0 on success, negative on failure
  1285. */
  1286. int ipa_del_ipv6ct_table(struct ipa_ioc_nat_ipv6ct_table_del *del)
  1287. {
  1288. int ret;
  1289. IPA_API_DISPATCH_RETURN(ipa_del_ipv6ct_table, del);
  1290. return ret;
  1291. }
  1292. EXPORT_SYMBOL(ipa_del_ipv6ct_table);
  1293. /**
  1294. * ipa3_nat_mdfy_pdn() - Modify a PDN entry in PDN config table in IPA SRAM
  1295. * @mdfy_pdn: [in] PDN info to be written to SRAM
  1296. *
  1297. * Called by NAT client driver to modify an entry in the PDN config table
  1298. *
  1299. * Returns: 0 on success, negative on failure
  1300. */
  1301. int ipa_nat_mdfy_pdn(struct ipa_ioc_nat_pdn_entry *mdfy_pdn)
  1302. {
  1303. int ret;
  1304. IPA_API_DISPATCH_RETURN(ipa_nat_mdfy_pdn, mdfy_pdn);
  1305. return ret;
  1306. }
  1307. EXPORT_SYMBOL(ipa_nat_mdfy_pdn);
  1308. /**
  1309. * ipa_send_msg() - Send "message" from kernel client to IPA driver
  1310. * @meta: [in] message meta-data
  1311. * @buff: [in] the payload for message
  1312. * @callback: [in] free callback
  1313. *
  1314. * Client supplies the message meta-data and payload which IPA driver buffers
  1315. * till read by user-space. After read from user space IPA driver invokes the
  1316. * callback supplied to free the message payload. Client must not touch/free
  1317. * the message payload after calling this API.
  1318. *
  1319. * Returns: 0 on success, negative on failure
  1320. *
  1321. * Note: Should not be called from atomic context
  1322. */
  1323. int ipa_send_msg(struct ipa_msg_meta *meta, void *buff,
  1324. ipa_msg_free_fn callback)
  1325. {
  1326. int ret;
  1327. IPA_API_DISPATCH_RETURN(ipa_send_msg, meta, buff, callback);
  1328. return ret;
  1329. }
  1330. EXPORT_SYMBOL(ipa_send_msg);
  1331. /**
  1332. * ipa_register_pull_msg() - register pull message type
  1333. * @meta: [in] message meta-data
  1334. * @callback: [in] pull callback
  1335. *
  1336. * Register message callback by kernel client with IPA driver for IPA driver to
  1337. * pull message on-demand.
  1338. *
  1339. * Returns: 0 on success, negative on failure
  1340. *
  1341. * Note: Should not be called from atomic context
  1342. */
  1343. int ipa_register_pull_msg(struct ipa_msg_meta *meta, ipa_msg_pull_fn callback)
  1344. {
  1345. int ret;
  1346. IPA_API_DISPATCH_RETURN(ipa_register_pull_msg, meta, callback);
  1347. return ret;
  1348. }
  1349. EXPORT_SYMBOL(ipa_register_pull_msg);
  1350. /**
  1351. * ipa_deregister_pull_msg() - De-register pull message type
  1352. * @meta: [in] message meta-data
  1353. *
  1354. * De-register "message" by kernel client from IPA driver
  1355. *
  1356. * Returns: 0 on success, negative on failure
  1357. *
  1358. * Note: Should not be called from atomic context
  1359. */
  1360. int ipa_deregister_pull_msg(struct ipa_msg_meta *meta)
  1361. {
  1362. int ret;
  1363. IPA_API_DISPATCH_RETURN(ipa_deregister_pull_msg, meta);
  1364. return ret;
  1365. }
  1366. EXPORT_SYMBOL(ipa_deregister_pull_msg);
  1367. /**
  1368. * ipa_register_intf() - register "logical" interface
  1369. * @name: [in] interface name
  1370. * @tx: [in] TX properties of the interface
  1371. * @rx: [in] RX properties of the interface
  1372. *
  1373. * Register an interface and its tx and rx properties, this allows
  1374. * configuration of rules from user-space
  1375. *
  1376. * Returns: 0 on success, negative on failure
  1377. *
  1378. * Note: Should not be called from atomic context
  1379. */
  1380. int ipa_register_intf(const char *name, const struct ipa_tx_intf *tx,
  1381. const struct ipa_rx_intf *rx)
  1382. {
  1383. int ret;
  1384. IPA_API_DISPATCH_RETURN(ipa_register_intf, name, tx, rx);
  1385. return ret;
  1386. }
  1387. EXPORT_SYMBOL(ipa_register_intf);
  1388. /**
  1389. * ipa_register_intf_ext() - register "logical" interface which has only
  1390. * extended properties
  1391. * @name: [in] interface name
  1392. * @tx: [in] TX properties of the interface
  1393. * @rx: [in] RX properties of the interface
  1394. * @ext: [in] EXT properties of the interface
  1395. *
  1396. * Register an interface and its tx, rx and ext properties, this allows
  1397. * configuration of rules from user-space
  1398. *
  1399. * Returns: 0 on success, negative on failure
  1400. *
  1401. * Note: Should not be called from atomic context
  1402. */
  1403. int ipa_register_intf_ext(const char *name, const struct ipa_tx_intf *tx,
  1404. const struct ipa_rx_intf *rx,
  1405. const struct ipa_ext_intf *ext)
  1406. {
  1407. int ret;
  1408. IPA_API_DISPATCH_RETURN(ipa_register_intf_ext, name, tx, rx, ext);
  1409. return ret;
  1410. }
  1411. EXPORT_SYMBOL(ipa_register_intf_ext);
  1412. /**
  1413. * ipa_deregister_intf() - de-register previously registered logical interface
  1414. * @name: [in] interface name
  1415. *
  1416. * De-register a previously registered interface
  1417. *
  1418. * Returns: 0 on success, negative on failure
  1419. *
  1420. * Note: Should not be called from atomic context
  1421. */
  1422. int ipa_deregister_intf(const char *name)
  1423. {
  1424. int ret;
  1425. IPA_API_DISPATCH_RETURN(ipa_deregister_intf, name);
  1426. return ret;
  1427. }
  1428. EXPORT_SYMBOL(ipa_deregister_intf);
  1429. /**
  1430. * ipa_set_aggr_mode() - Set the aggregation mode which is a global setting
  1431. * @mode: [in] the desired aggregation mode for e.g. straight MBIM, QCNCM,
  1432. * etc
  1433. *
  1434. * Returns: 0 on success
  1435. */
  1436. int ipa_set_aggr_mode(enum ipa_aggr_mode mode)
  1437. {
  1438. int ret;
  1439. IPA_API_DISPATCH_RETURN(ipa_set_aggr_mode, mode);
  1440. return ret;
  1441. }
  1442. EXPORT_SYMBOL(ipa_set_aggr_mode);
  1443. /**
  1444. * ipa_set_qcncm_ndp_sig() - Set the NDP signature used for QCNCM aggregation
  1445. * mode
  1446. * @sig: [in] the first 3 bytes of QCNCM NDP signature (expected to be
  1447. * "QND")
  1448. *
  1449. * Set the NDP signature used for QCNCM aggregation mode. The fourth byte
  1450. * (expected to be 'P') needs to be set using the header addition mechanism
  1451. *
  1452. * Returns: 0 on success, negative on failure
  1453. */
  1454. int ipa_set_qcncm_ndp_sig(char sig[3])
  1455. {
  1456. int ret;
  1457. IPA_API_DISPATCH_RETURN(ipa_set_qcncm_ndp_sig, sig);
  1458. return ret;
  1459. }
  1460. EXPORT_SYMBOL(ipa_set_qcncm_ndp_sig);
  1461. /**
  1462. * ipa_set_single_ndp_per_mbim() - Enable/disable single NDP per MBIM frame
  1463. * configuration
  1464. * @enable: [in] true for single NDP/MBIM; false otherwise
  1465. *
  1466. * Returns: 0 on success
  1467. */
  1468. int ipa_set_single_ndp_per_mbim(bool enable)
  1469. {
  1470. int ret;
  1471. IPA_API_DISPATCH_RETURN(ipa_set_single_ndp_per_mbim, enable);
  1472. return ret;
  1473. }
  1474. EXPORT_SYMBOL(ipa_set_single_ndp_per_mbim);
  1475. /**
  1476. * ipa_tx_dp() - Data-path tx handler
  1477. * @dst: [in] which IPA destination to route tx packets to
  1478. * @skb: [in] the packet to send
  1479. * @metadata: [in] TX packet meta-data
  1480. *
  1481. * Data-path tx handler, this is used for both SW data-path which by-passes most
  1482. * IPA HW blocks AND the regular HW data-path for WLAN AMPDU traffic only. If
  1483. * dst is a "valid" CONS type, then SW data-path is used. If dst is the
  1484. * WLAN_AMPDU PROD type, then HW data-path for WLAN AMPDU is used. Anything else
  1485. * is an error. For errors, client needs to free the skb as needed. For success,
  1486. * IPA driver will later invoke client callback if one was supplied. That
  1487. * callback should free the skb. If no callback supplied, IPA driver will free
  1488. * the skb internally
  1489. *
  1490. * The function will use two descriptors for this send command
  1491. * (for A5_WLAN_AMPDU_PROD only one desciprtor will be sent),
  1492. * the first descriptor will be used to inform the IPA hardware that
  1493. * apps need to push data into the IPA (IP_PACKET_INIT immediate command).
  1494. * Once this send was done from SPS point-of-view the IPA driver will
  1495. * get notified by the supplied callback - ipa_sps_irq_tx_comp()
  1496. *
  1497. * ipa_sps_irq_tx_comp will call to the user supplied
  1498. * callback (from ipa_connect)
  1499. *
  1500. * Returns: 0 on success, negative on failure
  1501. */
  1502. int ipa_tx_dp(enum ipa_client_type dst, struct sk_buff *skb,
  1503. struct ipa_tx_meta *meta)
  1504. {
  1505. int ret;
  1506. IPA_API_DISPATCH_RETURN(ipa_tx_dp, dst, skb, meta);
  1507. return ret;
  1508. }
  1509. EXPORT_SYMBOL(ipa_tx_dp);
  1510. /**
  1511. * ipa_tx_dp_mul() - Data-path tx handler for multiple packets
  1512. * @src: [in] - Client that is sending data
  1513. * @ipa_tx_data_desc: [in] data descriptors from wlan
  1514. *
  1515. * this is used for to transfer data descriptors that received
  1516. * from WLAN1_PROD pipe to IPA HW
  1517. *
  1518. * The function will send data descriptors from WLAN1_PROD (one
  1519. * at a time) using sps_transfer_one. Will set EOT flag for last
  1520. * descriptor Once this send was done from SPS point-of-view the
  1521. * IPA driver will get notified by the supplied callback -
  1522. * ipa_sps_irq_tx_no_aggr_notify()
  1523. *
  1524. * ipa_sps_irq_tx_no_aggr_notify will call to the user supplied
  1525. * callback (from ipa_connect)
  1526. *
  1527. * Returns: 0 on success, negative on failure
  1528. */
  1529. int ipa_tx_dp_mul(enum ipa_client_type src,
  1530. struct ipa_tx_data_desc *data_desc)
  1531. {
  1532. int ret;
  1533. IPA_API_DISPATCH_RETURN(ipa_tx_dp_mul, src, data_desc);
  1534. return ret;
  1535. }
  1536. EXPORT_SYMBOL(ipa_tx_dp_mul);
  1537. void ipa_free_skb(struct ipa_rx_data *data)
  1538. {
  1539. IPA_API_DISPATCH(ipa_free_skb, data);
  1540. }
  1541. EXPORT_SYMBOL(ipa_free_skb);
  1542. /**
  1543. * ipa_setup_sys_pipe() - Setup an IPA end-point in system-BAM mode and perform
  1544. * IPA EP configuration
  1545. * @sys_in: [in] input needed to setup BAM pipe and configure EP
  1546. * @clnt_hdl: [out] client handle
  1547. *
  1548. * - configure the end-point registers with the supplied
  1549. * parameters from the user.
  1550. * - call SPS APIs to create a system-to-bam connection with IPA.
  1551. * - allocate descriptor FIFO
  1552. * - register callback function(ipa_sps_irq_rx_notify or
  1553. * ipa_sps_irq_tx_notify - depends on client type) in case the driver is
  1554. * not configured to pulling mode
  1555. *
  1556. * Returns: 0 on success, negative on failure
  1557. */
  1558. int ipa_setup_sys_pipe(struct ipa_sys_connect_params *sys_in, u32 *clnt_hdl)
  1559. {
  1560. int ret;
  1561. IPA_API_DISPATCH_RETURN(ipa_setup_sys_pipe, sys_in, clnt_hdl);
  1562. return ret;
  1563. }
  1564. EXPORT_SYMBOL(ipa_setup_sys_pipe);
  1565. /**
  1566. * ipa_teardown_sys_pipe() - Teardown the system-BAM pipe and cleanup IPA EP
  1567. * @clnt_hdl: [in] the handle obtained from ipa_setup_sys_pipe
  1568. *
  1569. * Returns: 0 on success, negative on failure
  1570. */
  1571. int ipa_teardown_sys_pipe(u32 clnt_hdl)
  1572. {
  1573. int ret;
  1574. IPA_API_DISPATCH_RETURN(ipa_teardown_sys_pipe, clnt_hdl);
  1575. return ret;
  1576. }
  1577. EXPORT_SYMBOL(ipa_teardown_sys_pipe);
  1578. int ipa_sys_setup(struct ipa_sys_connect_params *sys_in,
  1579. unsigned long *ipa_bam_or_gsi_hdl,
  1580. u32 *ipa_pipe_num, u32 *clnt_hdl, bool en_status)
  1581. {
  1582. int ret;
  1583. IPA_API_DISPATCH_RETURN(ipa_sys_setup, sys_in, ipa_bam_or_gsi_hdl,
  1584. ipa_pipe_num, clnt_hdl, en_status);
  1585. return ret;
  1586. }
  1587. EXPORT_SYMBOL(ipa_sys_setup);
  1588. int ipa_sys_teardown(u32 clnt_hdl)
  1589. {
  1590. int ret;
  1591. IPA_API_DISPATCH_RETURN(ipa_sys_teardown, clnt_hdl);
  1592. return ret;
  1593. }
  1594. EXPORT_SYMBOL(ipa_sys_teardown);
  1595. int ipa_sys_update_gsi_hdls(u32 clnt_hdl, unsigned long gsi_ch_hdl,
  1596. unsigned long gsi_ev_hdl)
  1597. {
  1598. int ret;
  1599. IPA_API_DISPATCH_RETURN(ipa_sys_update_gsi_hdls, clnt_hdl,
  1600. gsi_ch_hdl, gsi_ev_hdl);
  1601. return ret;
  1602. }
  1603. EXPORT_SYMBOL(ipa_sys_update_gsi_hdls);
  1604. /**
  1605. * ipa_connect_wdi_pipe() - WDI client connect
  1606. * @in: [in] input parameters from client
  1607. * @out: [out] output params to client
  1608. *
  1609. * Returns: 0 on success, negative on failure
  1610. *
  1611. * Note: Should not be called from atomic context
  1612. */
  1613. int ipa_connect_wdi_pipe(struct ipa_wdi_in_params *in,
  1614. struct ipa_wdi_out_params *out)
  1615. {
  1616. int ret;
  1617. IPA_API_DISPATCH_RETURN(ipa_connect_wdi_pipe, in, out);
  1618. return ret;
  1619. }
  1620. EXPORT_SYMBOL(ipa_connect_wdi_pipe);
  1621. /**
  1622. * ipa_disconnect_wdi_pipe() - WDI client disconnect
  1623. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  1624. *
  1625. * Returns: 0 on success, negative on failure
  1626. *
  1627. * Note: Should not be called from atomic context
  1628. */
  1629. int ipa_disconnect_wdi_pipe(u32 clnt_hdl)
  1630. {
  1631. int ret;
  1632. IPA_API_DISPATCH_RETURN(ipa_disconnect_wdi_pipe, clnt_hdl);
  1633. return ret;
  1634. }
  1635. EXPORT_SYMBOL(ipa_disconnect_wdi_pipe);
  1636. /**
  1637. * ipa_enable_wdi_pipe() - WDI client enable
  1638. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  1639. *
  1640. * Returns: 0 on success, negative on failure
  1641. *
  1642. * Note: Should not be called from atomic context
  1643. */
  1644. int ipa_enable_wdi_pipe(u32 clnt_hdl)
  1645. {
  1646. int ret;
  1647. IPA_API_DISPATCH_RETURN(ipa_enable_wdi_pipe, clnt_hdl);
  1648. return ret;
  1649. }
  1650. EXPORT_SYMBOL(ipa_enable_wdi_pipe);
  1651. /**
  1652. * ipa_disable_wdi_pipe() - WDI client disable
  1653. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  1654. *
  1655. * Returns: 0 on success, negative on failure
  1656. *
  1657. * Note: Should not be called from atomic context
  1658. */
  1659. int ipa_disable_wdi_pipe(u32 clnt_hdl)
  1660. {
  1661. int ret;
  1662. IPA_API_DISPATCH_RETURN(ipa_disable_wdi_pipe, clnt_hdl);
  1663. return ret;
  1664. }
  1665. EXPORT_SYMBOL(ipa_disable_wdi_pipe);
  1666. /**
  1667. * ipa_resume_wdi_pipe() - WDI client resume
  1668. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  1669. *
  1670. * Returns: 0 on success, negative on failure
  1671. *
  1672. * Note: Should not be called from atomic context
  1673. */
  1674. int ipa_resume_wdi_pipe(u32 clnt_hdl)
  1675. {
  1676. int ret;
  1677. IPA_API_DISPATCH_RETURN(ipa_resume_wdi_pipe, clnt_hdl);
  1678. return ret;
  1679. }
  1680. EXPORT_SYMBOL(ipa_resume_wdi_pipe);
  1681. /**
  1682. * ipa_suspend_wdi_pipe() - WDI client suspend
  1683. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  1684. *
  1685. * Returns: 0 on success, negative on failure
  1686. *
  1687. * Note: Should not be called from atomic context
  1688. */
  1689. int ipa_suspend_wdi_pipe(u32 clnt_hdl)
  1690. {
  1691. int ret;
  1692. IPA_API_DISPATCH_RETURN(ipa_suspend_wdi_pipe, clnt_hdl);
  1693. return ret;
  1694. }
  1695. EXPORT_SYMBOL(ipa_suspend_wdi_pipe);
  1696. /**
  1697. * ipa_get_wdi_stats() - Query WDI statistics from uc
  1698. * @stats: [inout] stats blob from client populated by driver
  1699. *
  1700. * Returns: 0 on success, negative on failure
  1701. *
  1702. * @note Cannot be called from atomic context
  1703. *
  1704. */
  1705. int ipa_get_wdi_stats(struct IpaHwStatsWDIInfoData_t *stats)
  1706. {
  1707. int ret;
  1708. IPA_API_DISPATCH_RETURN(ipa_get_wdi_stats, stats);
  1709. return ret;
  1710. }
  1711. EXPORT_SYMBOL(ipa_get_wdi_stats);
  1712. /**
  1713. * ipa_get_smem_restr_bytes()- Return IPA smem restricted bytes
  1714. *
  1715. * Return value: u16 - number of IPA smem restricted bytes
  1716. */
  1717. u16 ipa_get_smem_restr_bytes(void)
  1718. {
  1719. int ret;
  1720. IPA_API_DISPATCH_RETURN(ipa_get_smem_restr_bytes);
  1721. return ret;
  1722. }
  1723. EXPORT_SYMBOL(ipa_get_smem_restr_bytes);
  1724. /**
  1725. * ipa_broadcast_wdi_quota_reach_ind() - quota reach
  1726. * @uint32_t fid: [in] input netdev ID
  1727. * @uint64_t num_bytes: [in] used bytes
  1728. *
  1729. * Returns: 0 on success, negative on failure
  1730. */
  1731. int ipa_broadcast_wdi_quota_reach_ind(uint32_t fid,
  1732. uint64_t num_bytes)
  1733. {
  1734. int ret;
  1735. IPA_API_DISPATCH_RETURN(ipa_broadcast_wdi_quota_reach_ind,
  1736. fid, num_bytes);
  1737. return ret;
  1738. }
  1739. EXPORT_SYMBOL(ipa_broadcast_wdi_quota_reach_ind);
  1740. /**
  1741. * ipa_uc_wdi_get_dbpa() - To retrieve
  1742. * doorbell physical address of wlan pipes
  1743. * @param: [in/out] input/output parameters
  1744. * from/to client
  1745. *
  1746. * Returns: 0 on success, negative on failure
  1747. *
  1748. */
  1749. int ipa_uc_wdi_get_dbpa(
  1750. struct ipa_wdi_db_params *param)
  1751. {
  1752. int ret;
  1753. IPA_API_DISPATCH_RETURN(ipa_uc_wdi_get_dbpa, param);
  1754. return ret;
  1755. }
  1756. EXPORT_SYMBOL(ipa_uc_wdi_get_dbpa);
  1757. /**
  1758. * ipa_uc_reg_rdyCB() - To register uC
  1759. * ready CB if uC not ready, wdi only.
  1760. * @inout: [in/out] input/output parameters
  1761. * from/to client
  1762. *
  1763. * Returns: 0 on success, negative on failure
  1764. *
  1765. */
  1766. int ipa_uc_reg_rdyCB(
  1767. struct ipa_wdi_uc_ready_params *inout)
  1768. {
  1769. int ret;
  1770. IPA_API_DISPATCH_RETURN(ipa_uc_reg_rdyCB, inout);
  1771. return ret;
  1772. }
  1773. EXPORT_SYMBOL(ipa_uc_reg_rdyCB);
  1774. /**
  1775. * ipa_wigig_internal_init() - get uc db and register uC
  1776. * ready CB if uC not ready, wigig only.
  1777. * @inout: [in/out] uc ready input/output parameters
  1778. * from/to client
  1779. * @int_notify: [in] wigig misc interrupt handler function
  1780. * @uc_db_pa: [out] uC db physical address
  1781. *
  1782. * Returns: 0 on success, negative on failure
  1783. *
  1784. */
  1785. int ipa_wigig_internal_init(
  1786. struct ipa_wdi_uc_ready_params *inout,
  1787. ipa_wigig_misc_int_cb int_notify,
  1788. phys_addr_t *uc_db_pa)
  1789. {
  1790. int ret;
  1791. IPA_API_DISPATCH_RETURN(ipa_wigig_internal_init, inout,
  1792. int_notify, uc_db_pa);
  1793. return ret;
  1794. }
  1795. EXPORT_SYMBOL(ipa_wigig_internal_init);
  1796. /**
  1797. * ipa_uc_dereg_rdyCB() - To de-register uC ready CB
  1798. *
  1799. * Returns: 0 on success, negative on failure
  1800. *
  1801. */
  1802. int ipa_uc_dereg_rdyCB(void)
  1803. {
  1804. int ret;
  1805. IPA_API_DISPATCH_RETURN(ipa_uc_dereg_rdyCB);
  1806. return ret;
  1807. }
  1808. EXPORT_SYMBOL(ipa_uc_dereg_rdyCB);
  1809. /**
  1810. * teth_bridge_init() - Initialize the Tethering bridge driver
  1811. * @params - in/out params for USB initialization API (please look at struct
  1812. * definition for more info)
  1813. *
  1814. * USB driver gets a pointer to a callback function (usb_notify_cb) and an
  1815. * associated data. USB driver installs this callback function in the call to
  1816. * ipa_connect().
  1817. *
  1818. * Builds IPA resource manager dependency graph.
  1819. *
  1820. * Return codes: 0: success,
  1821. * -EINVAL - Bad parameter
  1822. * Other negative value - Failure
  1823. */
  1824. int teth_bridge_init(struct teth_bridge_init_params *params)
  1825. {
  1826. int ret;
  1827. IPA_API_DISPATCH_RETURN(teth_bridge_init, params);
  1828. return ret;
  1829. }
  1830. EXPORT_SYMBOL(teth_bridge_init);
  1831. /**
  1832. * teth_bridge_disconnect() - Disconnect tethering bridge module
  1833. */
  1834. int teth_bridge_disconnect(enum ipa_client_type client)
  1835. {
  1836. int ret;
  1837. IPA_API_DISPATCH_RETURN(teth_bridge_disconnect, client);
  1838. return ret;
  1839. }
  1840. EXPORT_SYMBOL(teth_bridge_disconnect);
  1841. /**
  1842. * teth_bridge_connect() - Connect bridge for a tethered Rmnet / MBIM call
  1843. * @connect_params: Connection info
  1844. *
  1845. * Return codes: 0: success
  1846. * -EINVAL: invalid parameters
  1847. * -EPERM: Operation not permitted as the bridge is already
  1848. * connected
  1849. */
  1850. int teth_bridge_connect(struct teth_bridge_connect_params *connect_params)
  1851. {
  1852. int ret;
  1853. IPA_API_DISPATCH_RETURN(teth_bridge_connect, connect_params);
  1854. return ret;
  1855. }
  1856. EXPORT_SYMBOL(teth_bridge_connect);
  1857. /* ipa_set_client() - provide client mapping
  1858. * @client: client type
  1859. *
  1860. * Return value: none
  1861. */
  1862. void ipa_set_client(int index, enum ipacm_client_enum client, bool uplink)
  1863. {
  1864. IPA_API_DISPATCH(ipa_set_client, index, client, uplink);
  1865. }
  1866. EXPORT_SYMBOL(ipa_set_client);
  1867. /**
  1868. * ipa_get_client() - provide client mapping
  1869. * @client: client type
  1870. *
  1871. * Return value: none
  1872. */
  1873. enum ipacm_client_enum ipa_get_client(int pipe_idx)
  1874. {
  1875. int ret;
  1876. IPA_API_DISPATCH_RETURN(ipa_get_client, pipe_idx);
  1877. return ret;
  1878. }
  1879. EXPORT_SYMBOL(ipa_get_client);
  1880. /**
  1881. * ipa_get_client_uplink() - provide client mapping
  1882. * @client: client type
  1883. *
  1884. * Return value: none
  1885. */
  1886. bool ipa_get_client_uplink(int pipe_idx)
  1887. {
  1888. int ret;
  1889. IPA_API_DISPATCH_RETURN(ipa_get_client_uplink, pipe_idx);
  1890. return ret;
  1891. }
  1892. EXPORT_SYMBOL(ipa_get_client_uplink);
  1893. /**
  1894. * ipa_dma_init() -Initialize IPADMA.
  1895. *
  1896. * This function initialize all IPADMA internal data and connect in dma:
  1897. * MEMCPY_DMA_SYNC_PROD ->MEMCPY_DMA_SYNC_CONS
  1898. * MEMCPY_DMA_ASYNC_PROD->MEMCPY_DMA_SYNC_CONS
  1899. *
  1900. * Return codes: 0: success
  1901. * -EFAULT: IPADMA is already initialized
  1902. * -ENOMEM: allocating memory error
  1903. * -EPERM: pipe connection failed
  1904. */
  1905. int ipa_dma_init(void)
  1906. {
  1907. int ret;
  1908. IPA_API_DISPATCH_RETURN(ipa_dma_init);
  1909. return ret;
  1910. }
  1911. EXPORT_SYMBOL(ipa_dma_init);
  1912. /**
  1913. * ipa_dma_enable() -Vote for IPA clocks.
  1914. *
  1915. *Return codes: 0: success
  1916. * -EINVAL: IPADMA is not initialized
  1917. * -EPERM: Operation not permitted as ipa_dma is already
  1918. * enabled
  1919. */
  1920. int ipa_dma_enable(void)
  1921. {
  1922. int ret;
  1923. IPA_API_DISPATCH_RETURN(ipa_dma_enable);
  1924. return ret;
  1925. }
  1926. EXPORT_SYMBOL(ipa_dma_enable);
  1927. /**
  1928. * ipa_dma_disable()- Unvote for IPA clocks.
  1929. *
  1930. * enter to power save mode.
  1931. *
  1932. * Return codes: 0: success
  1933. * -EINVAL: IPADMA is not initialized
  1934. * -EPERM: Operation not permitted as ipa_dma is already
  1935. * diabled
  1936. * -EFAULT: can not disable ipa_dma as there are pending
  1937. * memcopy works
  1938. */
  1939. int ipa_dma_disable(void)
  1940. {
  1941. int ret;
  1942. IPA_API_DISPATCH_RETURN(ipa_dma_disable);
  1943. return ret;
  1944. }
  1945. EXPORT_SYMBOL(ipa_dma_disable);
  1946. /**
  1947. * ipa_dma_sync_memcpy()- Perform synchronous memcpy using IPA.
  1948. *
  1949. * @dest: physical address to store the copied data.
  1950. * @src: physical address of the source data to copy.
  1951. * @len: number of bytes to copy.
  1952. *
  1953. * Return codes: 0: success
  1954. * -EINVAL: invalid params
  1955. * -EPERM: operation not permitted as ipa_dma isn't enable or
  1956. * initialized
  1957. * -SPS_ERROR: on sps faliures
  1958. * -EFAULT: other
  1959. */
  1960. int ipa_dma_sync_memcpy(u64 dest, u64 src, int len)
  1961. {
  1962. int ret;
  1963. IPA_API_DISPATCH_RETURN(ipa_dma_sync_memcpy, dest, src, len);
  1964. return ret;
  1965. }
  1966. EXPORT_SYMBOL(ipa_dma_sync_memcpy);
  1967. /**
  1968. * ipa_dma_async_memcpy()- Perform asynchronous memcpy using IPA.
  1969. *
  1970. * @dest: physical address to store the copied data.
  1971. * @src: physical address of the source data to copy.
  1972. * @len: number of bytes to copy.
  1973. * @user_cb: callback function to notify the client when the copy was done.
  1974. * @user_param: cookie for user_cb.
  1975. *
  1976. * Return codes: 0: success
  1977. * -EINVAL: invalid params
  1978. * -EPERM: operation not permitted as ipa_dma isn't enable or
  1979. * initialized
  1980. * -SPS_ERROR: on sps faliures
  1981. * -EFAULT: descr fifo is full.
  1982. */
  1983. int ipa_dma_async_memcpy(u64 dest, u64 src, int len,
  1984. void (*user_cb)(void *user1), void *user_param)
  1985. {
  1986. int ret;
  1987. IPA_API_DISPATCH_RETURN(ipa_dma_async_memcpy, dest, src, len, user_cb,
  1988. user_param);
  1989. return ret;
  1990. }
  1991. EXPORT_SYMBOL(ipa_dma_async_memcpy);
  1992. /**
  1993. * ipa_dma_uc_memcpy() - Perform a memcpy action using IPA uC
  1994. * @dest: physical address to store the copied data.
  1995. * @src: physical address of the source data to copy.
  1996. * @len: number of bytes to copy.
  1997. *
  1998. * Return codes: 0: success
  1999. * -EINVAL: invalid params
  2000. * -EPERM: operation not permitted as ipa_dma isn't enable or
  2001. * initialized
  2002. * -EBADF: IPA uC is not loaded
  2003. */
  2004. int ipa_dma_uc_memcpy(phys_addr_t dest, phys_addr_t src, int len)
  2005. {
  2006. int ret;
  2007. IPA_API_DISPATCH_RETURN(ipa_dma_uc_memcpy, dest, src, len);
  2008. return ret;
  2009. }
  2010. EXPORT_SYMBOL(ipa_dma_uc_memcpy);
  2011. /**
  2012. * ipa_dma_destroy() -teardown IPADMA pipes and release ipadma.
  2013. *
  2014. * this is a blocking function, returns just after destroying IPADMA.
  2015. */
  2016. void ipa_dma_destroy(void)
  2017. {
  2018. IPA_API_DISPATCH(ipa_dma_destroy);
  2019. }
  2020. EXPORT_SYMBOL(ipa_dma_destroy);
  2021. int ipa_mhi_init_engine(struct ipa_mhi_init_engine *params)
  2022. {
  2023. int ret;
  2024. IPA_API_DISPATCH_RETURN(ipa_mhi_init_engine, params);
  2025. return ret;
  2026. }
  2027. EXPORT_SYMBOL(ipa_mhi_init_engine);
  2028. /**
  2029. * ipa_connect_mhi_pipe() - Connect pipe to IPA and start corresponding
  2030. * MHI channel
  2031. * @in: connect parameters
  2032. * @clnt_hdl: [out] client handle for this pipe
  2033. *
  2034. * This function is called by IPA MHI client driver on MHI channel start.
  2035. * This function is called after MHI engine was started.
  2036. * This function is doing the following:
  2037. * - Send command to uC to start corresponding MHI channel
  2038. * - Configure IPA EP control
  2039. *
  2040. * Return codes: 0 : success
  2041. * negative : error
  2042. */
  2043. int ipa_connect_mhi_pipe(struct ipa_mhi_connect_params_internal *in,
  2044. u32 *clnt_hdl)
  2045. {
  2046. int ret;
  2047. IPA_API_DISPATCH_RETURN(ipa_connect_mhi_pipe, in, clnt_hdl);
  2048. return ret;
  2049. }
  2050. EXPORT_SYMBOL(ipa_connect_mhi_pipe);
  2051. /**
  2052. * ipa_disconnect_mhi_pipe() - Disconnect pipe from IPA and reset corresponding
  2053. * MHI channel
  2054. * @in: connect parameters
  2055. * @clnt_hdl: [out] client handle for this pipe
  2056. *
  2057. * This function is called by IPA MHI client driver on MHI channel reset.
  2058. * This function is called after MHI channel was started.
  2059. * This function is doing the following:
  2060. * - Send command to uC to reset corresponding MHI channel
  2061. * - Configure IPA EP control
  2062. *
  2063. * Return codes: 0 : success
  2064. * negative : error
  2065. */
  2066. int ipa_disconnect_mhi_pipe(u32 clnt_hdl)
  2067. {
  2068. int ret;
  2069. IPA_API_DISPATCH_RETURN(ipa_disconnect_mhi_pipe, clnt_hdl);
  2070. return ret;
  2071. }
  2072. EXPORT_SYMBOL(ipa_disconnect_mhi_pipe);
  2073. bool ipa_mhi_stop_gsi_channel(enum ipa_client_type client)
  2074. {
  2075. bool ret;
  2076. IPA_API_DISPATCH_RETURN_BOOL(ipa_mhi_stop_gsi_channel, client);
  2077. return ret;
  2078. }
  2079. int ipa_uc_mhi_reset_channel(int channelHandle)
  2080. {
  2081. int ret;
  2082. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_reset_channel, channelHandle);
  2083. return ret;
  2084. }
  2085. bool ipa_mhi_sps_channel_empty(enum ipa_client_type client)
  2086. {
  2087. bool ret;
  2088. IPA_API_DISPATCH_RETURN_BOOL(ipa_mhi_sps_channel_empty, client);
  2089. return ret;
  2090. }
  2091. int ipa_qmi_enable_force_clear_datapath_send(
  2092. struct ipa_enable_force_clear_datapath_req_msg_v01 *req)
  2093. {
  2094. int ret;
  2095. IPA_API_DISPATCH_RETURN(ipa_qmi_enable_force_clear_datapath_send, req);
  2096. return ret;
  2097. }
  2098. int ipa_qmi_disable_force_clear_datapath_send(
  2099. struct ipa_disable_force_clear_datapath_req_msg_v01 *req)
  2100. {
  2101. int ret;
  2102. IPA_API_DISPATCH_RETURN(ipa_qmi_disable_force_clear_datapath_send, req);
  2103. return ret;
  2104. }
  2105. int ipa_generate_tag_process(void)
  2106. {
  2107. int ret;
  2108. IPA_API_DISPATCH_RETURN(ipa_generate_tag_process);
  2109. return ret;
  2110. }
  2111. int ipa_disable_sps_pipe(enum ipa_client_type client)
  2112. {
  2113. int ret;
  2114. IPA_API_DISPATCH_RETURN(ipa_disable_sps_pipe, client);
  2115. return ret;
  2116. }
  2117. int ipa_mhi_reset_channel_internal(enum ipa_client_type client)
  2118. {
  2119. int ret;
  2120. IPA_API_DISPATCH_RETURN(ipa_mhi_reset_channel_internal, client);
  2121. return ret;
  2122. }
  2123. int ipa_mhi_start_channel_internal(enum ipa_client_type client)
  2124. {
  2125. int ret;
  2126. IPA_API_DISPATCH_RETURN(ipa_mhi_start_channel_internal, client);
  2127. return ret;
  2128. }
  2129. void ipa_get_holb(int ep_idx, struct ipa_ep_cfg_holb *holb)
  2130. {
  2131. IPA_API_DISPATCH(ipa_get_holb, ep_idx, holb);
  2132. }
  2133. void ipa_set_tag_process_before_gating(bool val)
  2134. {
  2135. IPA_API_DISPATCH(ipa_set_tag_process_before_gating, val);
  2136. }
  2137. int ipa_mhi_query_ch_info(enum ipa_client_type client,
  2138. struct gsi_chan_info *ch_info)
  2139. {
  2140. int ret;
  2141. IPA_API_DISPATCH_RETURN(ipa_mhi_query_ch_info, client, ch_info);
  2142. return ret;
  2143. }
  2144. int ipa_uc_mhi_suspend_channel(int channelHandle)
  2145. {
  2146. int ret;
  2147. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_suspend_channel, channelHandle);
  2148. return ret;
  2149. }
  2150. int ipa_uc_mhi_stop_event_update_channel(int channelHandle)
  2151. {
  2152. int ret;
  2153. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_stop_event_update_channel,
  2154. channelHandle);
  2155. return ret;
  2156. }
  2157. bool ipa_has_open_aggr_frame(enum ipa_client_type client)
  2158. {
  2159. bool ret;
  2160. IPA_API_DISPATCH_RETURN_BOOL(ipa_has_open_aggr_frame, client);
  2161. return ret;
  2162. }
  2163. int ipa_mhi_resume_channels_internal(enum ipa_client_type client,
  2164. bool LPTransitionRejected, bool brstmode_enabled,
  2165. union __packed gsi_channel_scratch ch_scratch, u8 index)
  2166. {
  2167. int ret;
  2168. IPA_API_DISPATCH_RETURN(ipa_mhi_resume_channels_internal, client,
  2169. LPTransitionRejected, brstmode_enabled, ch_scratch,
  2170. index);
  2171. return ret;
  2172. }
  2173. int ipa_uc_mhi_send_dl_ul_sync_info(union IpaHwMhiDlUlSyncCmdData_t *cmd)
  2174. {
  2175. int ret;
  2176. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_send_dl_ul_sync_info,
  2177. cmd);
  2178. return ret;
  2179. }
  2180. int ipa_mhi_destroy_channel(enum ipa_client_type client)
  2181. {
  2182. int ret;
  2183. IPA_API_DISPATCH_RETURN(ipa_mhi_destroy_channel, client);
  2184. return ret;
  2185. }
  2186. int ipa_uc_mhi_init(void (*ready_cb)(void),
  2187. void (*wakeup_request_cb)(void))
  2188. {
  2189. int ret;
  2190. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_init, ready_cb, wakeup_request_cb);
  2191. return ret;
  2192. }
  2193. void ipa_uc_mhi_cleanup(void)
  2194. {
  2195. IPA_API_DISPATCH(ipa_uc_mhi_cleanup);
  2196. }
  2197. int ipa_uc_mhi_print_stats(char *dbg_buff, int size)
  2198. {
  2199. int ret;
  2200. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_print_stats, dbg_buff, size);
  2201. return ret;
  2202. }
  2203. /**
  2204. * ipa_uc_state_check() - Check the status of the uC interface
  2205. *
  2206. * Return value: 0 if the uC is loaded, interface is initialized
  2207. * and there was no recent failure in one of the commands.
  2208. * A negative value is returned otherwise.
  2209. */
  2210. int ipa_uc_state_check(void)
  2211. {
  2212. int ret;
  2213. IPA_API_DISPATCH_RETURN(ipa_uc_state_check);
  2214. return ret;
  2215. }
  2216. int ipa_write_qmap_id(struct ipa_ioc_write_qmapid *param_in)
  2217. {
  2218. int ret;
  2219. IPA_API_DISPATCH_RETURN(ipa_write_qmap_id, param_in);
  2220. return ret;
  2221. }
  2222. EXPORT_SYMBOL(ipa_write_qmap_id);
  2223. /**
  2224. * ipa_add_interrupt_handler() - Adds handler to an interrupt type
  2225. * @interrupt: Interrupt type
  2226. * @handler: The handler to be added
  2227. * @deferred_flag: whether the handler processing should be deferred in
  2228. * a workqueue
  2229. * @private_data: the client's private data
  2230. *
  2231. * Adds handler to an interrupt type and enable the specific bit
  2232. * in IRQ_EN register, associated interrupt in IRQ_STTS register will be enabled
  2233. */
  2234. int ipa_add_interrupt_handler(enum ipa_irq_type interrupt,
  2235. ipa_irq_handler_t handler,
  2236. bool deferred_flag,
  2237. void *private_data)
  2238. {
  2239. int ret;
  2240. IPA_API_DISPATCH_RETURN(ipa_add_interrupt_handler, interrupt, handler,
  2241. deferred_flag, private_data);
  2242. return ret;
  2243. }
  2244. EXPORT_SYMBOL(ipa_add_interrupt_handler);
  2245. /**
  2246. * ipa_remove_interrupt_handler() - Removes handler to an interrupt type
  2247. * @interrupt: Interrupt type
  2248. *
  2249. * Removes the handler and disable the specific bit in IRQ_EN register
  2250. */
  2251. int ipa_remove_interrupt_handler(enum ipa_irq_type interrupt)
  2252. {
  2253. int ret;
  2254. IPA_API_DISPATCH_RETURN(ipa_remove_interrupt_handler, interrupt);
  2255. return ret;
  2256. }
  2257. EXPORT_SYMBOL(ipa_remove_interrupt_handler);
  2258. /**
  2259. * ipa_restore_suspend_handler() - restores the original suspend IRQ handler
  2260. * as it was registered in the IPA init sequence.
  2261. * Return codes:
  2262. * 0: success
  2263. * -EPERM: failed to remove current handler or failed to add original handler
  2264. */
  2265. int ipa_restore_suspend_handler(void)
  2266. {
  2267. int ret;
  2268. IPA_API_DISPATCH_RETURN(ipa_restore_suspend_handler);
  2269. return ret;
  2270. }
  2271. EXPORT_SYMBOL(ipa_restore_suspend_handler);
  2272. /**
  2273. * ipa_bam_reg_dump() - Dump selected BAM registers for IPA and DMA-BAM
  2274. *
  2275. * Function is rate limited to avoid flooding kernel log buffer
  2276. */
  2277. void ipa_bam_reg_dump(void)
  2278. {
  2279. IPA_API_DISPATCH(ipa_bam_reg_dump);
  2280. }
  2281. EXPORT_SYMBOL(ipa_bam_reg_dump);
  2282. /**
  2283. * ipa_get_ep_mapping() - provide endpoint mapping
  2284. * @client: client type
  2285. *
  2286. * Return value: endpoint mapping
  2287. */
  2288. int ipa_get_ep_mapping(enum ipa_client_type client)
  2289. {
  2290. int ret;
  2291. IPA_API_DISPATCH_RETURN(ipa_get_ep_mapping, client);
  2292. return ret;
  2293. }
  2294. EXPORT_SYMBOL(ipa_get_ep_mapping);
  2295. /**
  2296. * ipa_is_ready() - check if IPA module was initialized
  2297. * successfully
  2298. *
  2299. * Return value: true for yes; false for no
  2300. */
  2301. bool ipa_is_ready(void)
  2302. {
  2303. if (!ipa_api_ctrl || !ipa_api_ctrl->ipa_is_ready)
  2304. return false;
  2305. return ipa_api_ctrl->ipa_is_ready();
  2306. }
  2307. EXPORT_SYMBOL(ipa_is_ready);
  2308. /**
  2309. * ipa_proxy_clk_vote() - called to add IPA clock proxy vote
  2310. *
  2311. * Return value: none
  2312. */
  2313. void ipa_proxy_clk_vote(void)
  2314. {
  2315. IPA_API_DISPATCH(ipa_proxy_clk_vote);
  2316. }
  2317. EXPORT_SYMBOL(ipa_proxy_clk_vote);
  2318. /**
  2319. * ipa_proxy_clk_unvote() - called to remove IPA clock proxy vote
  2320. *
  2321. * Return value: none
  2322. */
  2323. void ipa_proxy_clk_unvote(void)
  2324. {
  2325. IPA_API_DISPATCH(ipa_proxy_clk_unvote);
  2326. }
  2327. EXPORT_SYMBOL(ipa_proxy_clk_unvote);
  2328. /**
  2329. * ipa_get_hw_type() - Return IPA HW version
  2330. *
  2331. * Return value: enum ipa_hw_type
  2332. */
  2333. enum ipa_hw_type ipa_get_hw_type(void)
  2334. {
  2335. return ipa_api_hw_type;
  2336. }
  2337. EXPORT_SYMBOL(ipa_get_hw_type);
  2338. /**
  2339. * ipa_is_client_handle_valid() - check if IPA client handle is valid handle
  2340. *
  2341. * Return value: true for yes; false for no
  2342. */
  2343. bool ipa_is_client_handle_valid(u32 clnt_hdl)
  2344. {
  2345. if (!ipa_api_ctrl || !ipa_api_ctrl->ipa_is_client_handle_valid)
  2346. return false;
  2347. return ipa_api_ctrl->ipa_is_client_handle_valid(clnt_hdl);
  2348. }
  2349. EXPORT_SYMBOL(ipa_is_client_handle_valid);
  2350. /**
  2351. * ipa_get_client_mapping() - provide client mapping
  2352. * @pipe_idx: IPA end-point number
  2353. *
  2354. * Return value: client mapping
  2355. */
  2356. enum ipa_client_type ipa_get_client_mapping(int pipe_idx)
  2357. {
  2358. int ret;
  2359. IPA_API_DISPATCH_RETURN(ipa_get_client_mapping, pipe_idx);
  2360. return ret;
  2361. }
  2362. EXPORT_SYMBOL(ipa_get_client_mapping);
  2363. /**
  2364. * ipa_get_rm_resource_from_ep() - this function is part of the deprecated
  2365. * RM mechanism but is still used by some drivers so we kept the definition.
  2366. */
  2367. enum ipa_rm_resource_name ipa_get_rm_resource_from_ep(int pipe_idx)
  2368. {
  2369. IPAERR("IPA RM is not supported idx=%d\n", pipe_idx);
  2370. return -EFAULT;
  2371. }
  2372. EXPORT_SYMBOL(ipa_get_rm_resource_from_ep);
  2373. /**
  2374. * ipa_get_modem_cfg_emb_pipe_flt()- Return ipa_ctx->modem_cfg_emb_pipe_flt
  2375. *
  2376. * Return value: true if modem configures embedded pipe flt, false otherwise
  2377. */
  2378. bool ipa_get_modem_cfg_emb_pipe_flt(void)
  2379. {
  2380. if (!ipa_api_ctrl || !ipa_api_ctrl->ipa_get_modem_cfg_emb_pipe_flt)
  2381. return false;
  2382. return ipa_api_ctrl->ipa_get_modem_cfg_emb_pipe_flt();
  2383. }
  2384. EXPORT_SYMBOL(ipa_get_modem_cfg_emb_pipe_flt);
  2385. /**
  2386. * ipa_get_transport_type()- Return ipa_ctx->transport_prototype
  2387. *
  2388. * Return value: enum ipa_transport_type
  2389. */
  2390. enum ipa_transport_type ipa_get_transport_type(void)
  2391. {
  2392. int ret;
  2393. IPA_API_DISPATCH_RETURN(ipa_get_transport_type);
  2394. return ret;
  2395. }
  2396. EXPORT_SYMBOL(ipa_get_transport_type);
  2397. /**
  2398. * ipa_get_smmu_domain()- Return the smmu domain
  2399. *
  2400. * Return value: pointer to iommu domain if smmu_cb valid, NULL otherwise
  2401. */
  2402. struct iommu_domain *ipa_get_smmu_domain(void)
  2403. {
  2404. struct iommu_domain *ret;
  2405. IPA_API_DISPATCH_RETURN_PTR(ipa_get_smmu_domain);
  2406. return ret;
  2407. }
  2408. EXPORT_SYMBOL(ipa_get_smmu_domain);
  2409. /**
  2410. * ipa_disable_apps_wan_cons_deaggr()- set
  2411. * ipa_ctx->ipa_client_apps_wan_cons_agg_gro
  2412. *
  2413. * Return value: 0 or negative in case of failure
  2414. */
  2415. int ipa_disable_apps_wan_cons_deaggr(uint32_t agg_size, uint32_t agg_count)
  2416. {
  2417. int ret;
  2418. IPA_API_DISPATCH_RETURN(ipa_disable_apps_wan_cons_deaggr, agg_size,
  2419. agg_count);
  2420. return ret;
  2421. }
  2422. EXPORT_SYMBOL(ipa_disable_apps_wan_cons_deaggr);
  2423. /**
  2424. * ipa_get_dma_dev()- Returns ipa_ctx dma dev pointer
  2425. *
  2426. * Return value: pointer to ipa_ctx dma dev pointer
  2427. */
  2428. struct device *ipa_get_dma_dev(void)
  2429. {
  2430. struct device *ret;
  2431. IPA_API_DISPATCH_RETURN_PTR(ipa_get_dma_dev);
  2432. return ret;
  2433. }
  2434. EXPORT_SYMBOL(ipa_get_dma_dev);
  2435. /**
  2436. * ipa_release_wdi_mapping() - release iommu mapping
  2437. *
  2438. *
  2439. * @num_buffers: number of buffers to be released
  2440. *
  2441. * @info: pointer to wdi buffers info array
  2442. *
  2443. * Return codes: 0 : success
  2444. * negative : error
  2445. */
  2446. int ipa_release_wdi_mapping(u32 num_buffers, struct ipa_wdi_buffer_info *info)
  2447. {
  2448. int ret;
  2449. IPA_API_DISPATCH_RETURN(ipa_release_wdi_mapping, num_buffers, info);
  2450. return ret;
  2451. }
  2452. EXPORT_SYMBOL(ipa_release_wdi_mapping);
  2453. /**
  2454. * ipa_create_wdi_mapping() - Perform iommu mapping
  2455. *
  2456. *
  2457. * @num_buffers: number of buffers to be mapped
  2458. *
  2459. * @info: pointer to wdi buffers info array
  2460. *
  2461. * Return codes: 0 : success
  2462. * negative : error
  2463. */
  2464. int ipa_create_wdi_mapping(u32 num_buffers, struct ipa_wdi_buffer_info *info)
  2465. {
  2466. int ret;
  2467. IPA_API_DISPATCH_RETURN(ipa_create_wdi_mapping, num_buffers, info);
  2468. return ret;
  2469. }
  2470. EXPORT_SYMBOL(ipa_create_wdi_mapping);
  2471. /**
  2472. * ipa_get_gsi_ep_info() - provide gsi ep information
  2473. * @client: IPA client type
  2474. *
  2475. * Return value: pointer to ipa_gsi_ep_info
  2476. */
  2477. const struct ipa_gsi_ep_config *ipa_get_gsi_ep_info(enum ipa_client_type client)
  2478. {
  2479. if (!ipa_api_ctrl || !ipa_api_ctrl->ipa_get_gsi_ep_info)
  2480. return NULL;
  2481. return ipa_api_ctrl->ipa_get_gsi_ep_info(client);
  2482. }
  2483. EXPORT_SYMBOL(ipa_get_gsi_ep_info);
  2484. /**
  2485. * ipa_stop_gsi_channel()- Stops a GSI channel in IPA
  2486. *
  2487. * Return value: 0 on success, negative otherwise
  2488. */
  2489. int ipa_stop_gsi_channel(u32 clnt_hdl)
  2490. {
  2491. int ret;
  2492. IPA_API_DISPATCH_RETURN(ipa_stop_gsi_channel, clnt_hdl);
  2493. return ret;
  2494. }
  2495. EXPORT_SYMBOL(ipa_stop_gsi_channel);
  2496. /**
  2497. * ipa_start_gsi_channel()- Startsa GSI channel in IPA
  2498. *
  2499. * Return value: 0 on success, negative otherwise
  2500. */
  2501. int ipa_start_gsi_channel(u32 clnt_hdl)
  2502. {
  2503. int ret;
  2504. IPA_API_DISPATCH_RETURN(ipa_start_gsi_channel, clnt_hdl);
  2505. return ret;
  2506. }
  2507. EXPORT_SYMBOL(ipa_start_gsi_channel);
  2508. /**
  2509. * ipa_is_vlan_mode - check if a LAN driver should load in VLAN mode
  2510. * @iface - type of vlan capable device
  2511. * @res - query result: true for vlan mode, false for non vlan mode
  2512. *
  2513. * API must be called after ipa_is_ready() returns true, otherwise it will fail
  2514. *
  2515. * Returns: 0 on success, negative on failure
  2516. */
  2517. int ipa_is_vlan_mode(enum ipa_vlan_ifaces iface, bool *res)
  2518. {
  2519. int ret;
  2520. IPA_API_DISPATCH_RETURN(ipa_is_vlan_mode, iface, res);
  2521. return ret;
  2522. }
  2523. EXPORT_SYMBOL(ipa_is_vlan_mode);
  2524. /**
  2525. * ipa_get_version_string() - Get string representation of IPA version
  2526. * @ver: IPA version
  2527. *
  2528. * Return: Constant string representation
  2529. */
  2530. const char *ipa_get_version_string(enum ipa_hw_type ver)
  2531. {
  2532. const char *str;
  2533. switch (ver) {
  2534. case IPA_HW_v1_0:
  2535. str = "1.0";
  2536. break;
  2537. case IPA_HW_v1_1:
  2538. str = "1.1";
  2539. break;
  2540. case IPA_HW_v2_0:
  2541. str = "2.0";
  2542. break;
  2543. case IPA_HW_v2_1:
  2544. str = "2.1";
  2545. break;
  2546. case IPA_HW_v2_5:
  2547. str = "2.5/2.6";
  2548. break;
  2549. case IPA_HW_v2_6L:
  2550. str = "2.6L";
  2551. break;
  2552. case IPA_HW_v3_0:
  2553. str = "3.0";
  2554. break;
  2555. case IPA_HW_v3_1:
  2556. str = "3.1";
  2557. break;
  2558. case IPA_HW_v3_5:
  2559. str = "3.5";
  2560. break;
  2561. case IPA_HW_v3_5_1:
  2562. str = "3.5.1";
  2563. break;
  2564. case IPA_HW_v4_0:
  2565. str = "4.0";
  2566. break;
  2567. case IPA_HW_v4_1:
  2568. str = "4.1";
  2569. break;
  2570. case IPA_HW_v4_2:
  2571. str = "4.2";
  2572. break;
  2573. case IPA_HW_v4_5:
  2574. str = "4.5";
  2575. break;
  2576. case IPA_HW_v4_7:
  2577. str = "4.7";
  2578. break;
  2579. default:
  2580. str = "Invalid version";
  2581. break;
  2582. }
  2583. return str;
  2584. }
  2585. EXPORT_SYMBOL(ipa_get_version_string);
  2586. static const struct of_device_id ipa_plat_drv_match[] = {
  2587. { .compatible = "qcom,ipa", },
  2588. { .compatible = "qcom,ipa-smmu-ap-cb", },
  2589. { .compatible = "qcom,ipa-smmu-wlan-cb", },
  2590. { .compatible = "qcom,ipa-smmu-uc-cb", },
  2591. { .compatible = "qcom,ipa-smmu-11ad-cb", },
  2592. { .compatible = "qcom,smp2p-map-ipa-1-in", },
  2593. { .compatible = "qcom,smp2p-map-ipa-1-out", },
  2594. {}
  2595. };
  2596. /*********************************************************/
  2597. /* PCIe Version */
  2598. /*********************************************************/
  2599. static const struct of_device_id ipa_pci_drv_match[] = {
  2600. { .compatible = "qcom,ipa", },
  2601. {}
  2602. };
  2603. /*
  2604. * Forward declarations of static functions required for PCI
  2605. * registraion
  2606. *
  2607. * VENDOR and DEVICE should be defined in pci_ids.h
  2608. */
  2609. static int ipa_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
  2610. static void ipa_pci_remove(struct pci_dev *pdev);
  2611. static void ipa_pci_shutdown(struct pci_dev *pdev);
  2612. static pci_ers_result_t ipa_pci_io_error_detected(struct pci_dev *dev,
  2613. pci_channel_state_t state);
  2614. static pci_ers_result_t ipa_pci_io_slot_reset(struct pci_dev *dev);
  2615. static void ipa_pci_io_resume(struct pci_dev *dev);
  2616. #define LOCAL_VENDOR 0x17CB
  2617. #define LOCAL_DEVICE 0x00ff
  2618. static const char ipa_pci_driver_name[] = "qcipav3";
  2619. static const struct pci_device_id ipa_pci_tbl[] = {
  2620. { PCI_DEVICE(LOCAL_VENDOR, LOCAL_DEVICE) },
  2621. { 0, 0, 0, 0, 0, 0, 0 }
  2622. };
  2623. MODULE_DEVICE_TABLE(pci, ipa_pci_tbl);
  2624. /* PCI Error Recovery */
  2625. static const struct pci_error_handlers ipa_pci_err_handler = {
  2626. .error_detected = ipa_pci_io_error_detected,
  2627. .slot_reset = ipa_pci_io_slot_reset,
  2628. .resume = ipa_pci_io_resume,
  2629. };
  2630. static struct pci_driver ipa_pci_driver = {
  2631. .name = ipa_pci_driver_name,
  2632. .id_table = ipa_pci_tbl,
  2633. .probe = ipa_pci_probe,
  2634. .remove = ipa_pci_remove,
  2635. .shutdown = ipa_pci_shutdown,
  2636. .err_handler = &ipa_pci_err_handler
  2637. };
  2638. static int ipa_generic_plat_drv_probe(struct platform_device *pdev_p)
  2639. {
  2640. int result;
  2641. /*
  2642. * IPA probe function can be called for multiple times as the same probe
  2643. * function handles multiple compatibilities
  2644. */
  2645. pr_debug("ipa: IPA driver probing started for %s\n",
  2646. pdev_p->dev.of_node->name);
  2647. if (!ipa_api_ctrl) {
  2648. ipa_api_ctrl = kzalloc(sizeof(*ipa_api_ctrl), GFP_KERNEL);
  2649. if (!ipa_api_ctrl)
  2650. return -ENOMEM;
  2651. /* Get IPA HW Version */
  2652. result = of_property_read_u32(pdev_p->dev.of_node,
  2653. "qcom,ipa-hw-ver", &ipa_api_hw_type);
  2654. if ((result) || (ipa_api_hw_type == 0)) {
  2655. pr_err("ipa: get resource failed for ipa-hw-ver!\n");
  2656. kfree(ipa_api_ctrl);
  2657. ipa_api_ctrl = 0;
  2658. return -ENODEV;
  2659. }
  2660. pr_debug("ipa: ipa_api_hw_type = %d\n", ipa_api_hw_type);
  2661. }
  2662. /* call probe based on IPA HW version */
  2663. switch (ipa_api_hw_type) {
  2664. case IPA_HW_v3_0:
  2665. case IPA_HW_v3_1:
  2666. case IPA_HW_v3_5:
  2667. case IPA_HW_v3_5_1:
  2668. case IPA_HW_v4_0:
  2669. case IPA_HW_v4_1:
  2670. case IPA_HW_v4_2:
  2671. case IPA_HW_v4_5:
  2672. case IPA_HW_v4_7:
  2673. result = ipa3_plat_drv_probe(pdev_p, ipa_api_ctrl,
  2674. ipa_plat_drv_match);
  2675. break;
  2676. default:
  2677. pr_err("ipa: unsupported version %d\n", ipa_api_hw_type);
  2678. return -EPERM;
  2679. }
  2680. if (result && result != -EPROBE_DEFER)
  2681. pr_err("ipa: ipa_plat_drv_probe failed\n");
  2682. return result;
  2683. }
  2684. static int ipa_ap_suspend(struct device *dev)
  2685. {
  2686. int ret;
  2687. IPA_API_DISPATCH_RETURN(ipa_ap_suspend, dev);
  2688. return ret;
  2689. }
  2690. static int ipa_ap_resume(struct device *dev)
  2691. {
  2692. int ret;
  2693. IPA_API_DISPATCH_RETURN(ipa_ap_resume, dev);
  2694. return ret;
  2695. }
  2696. int ipa_register_ipa_ready_cb(void (*ipa_ready_cb)(void *user_data),
  2697. void *user_data)
  2698. {
  2699. int ret;
  2700. IPA_API_DISPATCH_RETURN(ipa_register_ipa_ready_cb,
  2701. ipa_ready_cb, user_data);
  2702. return ret;
  2703. }
  2704. EXPORT_SYMBOL(ipa_register_ipa_ready_cb);
  2705. /**
  2706. * ipa_inc_client_enable_clks() - Increase active clients counter, and
  2707. * enable ipa clocks if necessary
  2708. *
  2709. * Please do not use this API, use the wrapper macros instead (ipa_i.h)
  2710. * IPA_ACTIVE_CLIENTS_INC_XXX();
  2711. *
  2712. * Return codes:
  2713. * None
  2714. */
  2715. void ipa_inc_client_enable_clks(struct ipa_active_client_logging_info *id)
  2716. {
  2717. IPA_API_DISPATCH(ipa_inc_client_enable_clks, id);
  2718. }
  2719. EXPORT_SYMBOL(ipa_inc_client_enable_clks);
  2720. /**
  2721. * ipa_dec_client_disable_clks() - Increase active clients counter, and
  2722. * enable ipa clocks if necessary
  2723. *
  2724. * Please do not use this API, use the wrapper macros instead (ipa_i.h)
  2725. * IPA_ACTIVE_CLIENTS_DEC_XXX();
  2726. *
  2727. * Return codes:
  2728. * None
  2729. */
  2730. void ipa_dec_client_disable_clks(struct ipa_active_client_logging_info *id)
  2731. {
  2732. IPA_API_DISPATCH(ipa_dec_client_disable_clks, id);
  2733. }
  2734. EXPORT_SYMBOL(ipa_dec_client_disable_clks);
  2735. /**
  2736. * ipa_inc_client_enable_clks_no_block() - Only increment the number of active
  2737. * clients if no asynchronous actions should be done.Asynchronous actions are
  2738. * locking a mutex and waking up IPA HW.
  2739. *
  2740. * Please do not use this API, use the wrapper macros instead(ipa_i.h)
  2741. *
  2742. *
  2743. * Return codes : 0 for success
  2744. * -EPERM if an asynchronous action should have been done
  2745. */
  2746. int ipa_inc_client_enable_clks_no_block(
  2747. struct ipa_active_client_logging_info *id)
  2748. {
  2749. int ret;
  2750. IPA_API_DISPATCH_RETURN(ipa_inc_client_enable_clks_no_block, id);
  2751. return ret;
  2752. }
  2753. EXPORT_SYMBOL(ipa_inc_client_enable_clks_no_block);
  2754. /**
  2755. * ipa_suspend_resource_no_block() - suspend client endpoints related to the
  2756. * IPA_RM resource and decrement active clients counter. This function is
  2757. * guaranteed to avoid sleeping.
  2758. *
  2759. * @resource: [IN] IPA Resource Manager resource
  2760. *
  2761. * Return codes: 0 on success, negative on failure.
  2762. */
  2763. int ipa_suspend_resource_no_block(enum ipa_rm_resource_name resource)
  2764. {
  2765. int ret;
  2766. IPA_API_DISPATCH_RETURN(ipa_suspend_resource_no_block, resource);
  2767. return ret;
  2768. }
  2769. EXPORT_SYMBOL(ipa_suspend_resource_no_block);
  2770. /**
  2771. * ipa_resume_resource() - resume client endpoints related to the IPA_RM
  2772. * resource.
  2773. *
  2774. * @resource: [IN] IPA Resource Manager resource
  2775. *
  2776. * Return codes: 0 on success, negative on failure.
  2777. */
  2778. int ipa_resume_resource(enum ipa_rm_resource_name resource)
  2779. {
  2780. int ret;
  2781. IPA_API_DISPATCH_RETURN(ipa_resume_resource, resource);
  2782. return ret;
  2783. }
  2784. EXPORT_SYMBOL(ipa_resume_resource);
  2785. /**
  2786. * ipa_suspend_resource_sync() - suspend client endpoints related to the IPA_RM
  2787. * resource and decrement active clients counter, which may result in clock
  2788. * gating of IPA clocks.
  2789. *
  2790. * @resource: [IN] IPA Resource Manager resource
  2791. *
  2792. * Return codes: 0 on success, negative on failure.
  2793. */
  2794. int ipa_suspend_resource_sync(enum ipa_rm_resource_name resource)
  2795. {
  2796. int ret;
  2797. IPA_API_DISPATCH_RETURN(ipa_suspend_resource_sync, resource);
  2798. return ret;
  2799. }
  2800. EXPORT_SYMBOL(ipa_suspend_resource_sync);
  2801. /**
  2802. * ipa_set_required_perf_profile() - set IPA to the specified performance
  2803. * profile based on the bandwidth, unless minimum voltage required is
  2804. * higher. In this case the floor_voltage specified will be used.
  2805. * @floor_voltage: minimum voltage to operate
  2806. * @bandwidth_mbps: needed bandwidth from IPA
  2807. *
  2808. * Return codes: 0 on success, negative on failure.
  2809. */
  2810. int ipa_set_required_perf_profile(enum ipa_voltage_level floor_voltage,
  2811. u32 bandwidth_mbps)
  2812. {
  2813. int ret;
  2814. IPA_API_DISPATCH_RETURN(ipa_set_required_perf_profile, floor_voltage,
  2815. bandwidth_mbps);
  2816. return ret;
  2817. }
  2818. EXPORT_SYMBOL(ipa_set_required_perf_profile);
  2819. /**
  2820. * ipa_get_ipc_logbuf() - return a pointer to IPA driver IPC log
  2821. */
  2822. void *ipa_get_ipc_logbuf(void)
  2823. {
  2824. void *ret;
  2825. IPA_API_DISPATCH_RETURN_PTR(ipa_get_ipc_logbuf);
  2826. return ret;
  2827. }
  2828. EXPORT_SYMBOL(ipa_get_ipc_logbuf);
  2829. /**
  2830. * ipa_get_ipc_logbuf_low() - return a pointer to IPA driver IPC low prio log
  2831. */
  2832. void *ipa_get_ipc_logbuf_low(void)
  2833. {
  2834. void *ret;
  2835. IPA_API_DISPATCH_RETURN_PTR(ipa_get_ipc_logbuf_low);
  2836. return ret;
  2837. }
  2838. EXPORT_SYMBOL(ipa_get_ipc_logbuf_low);
  2839. /**
  2840. * ipa_assert() - general function for assertion
  2841. */
  2842. void ipa_assert(void)
  2843. {
  2844. pr_err("IPA: unrecoverable error has occurred, asserting\n");
  2845. BUG();
  2846. }
  2847. /**
  2848. * ipa_rx_poll() - Poll the rx packets from IPA HW in the
  2849. * softirq context
  2850. *
  2851. * @budget: number of packets to be polled in single iteration
  2852. *
  2853. * Return codes: >= 0 : Actual number of packets polled
  2854. *
  2855. */
  2856. int ipa_rx_poll(u32 clnt_hdl, int budget)
  2857. {
  2858. int ret;
  2859. IPA_API_DISPATCH_RETURN(ipa_rx_poll, clnt_hdl, budget);
  2860. return ret;
  2861. }
  2862. EXPORT_SYMBOL(ipa_rx_poll);
  2863. /**
  2864. * ipa_recycle_wan_skb() - Recycle the Wan skb
  2865. *
  2866. * @skb: skb that needs to recycle
  2867. *
  2868. */
  2869. void ipa_recycle_wan_skb(struct sk_buff *skb)
  2870. {
  2871. IPA_API_DISPATCH(ipa_recycle_wan_skb, skb);
  2872. }
  2873. EXPORT_SYMBOL(ipa_recycle_wan_skb);
  2874. /**
  2875. * ipa_setup_uc_ntn_pipes() - setup uc offload pipes
  2876. */
  2877. int ipa_setup_uc_ntn_pipes(struct ipa_ntn_conn_in_params *inp,
  2878. ipa_notify_cb notify, void *priv, u8 hdr_len,
  2879. struct ipa_ntn_conn_out_params *outp)
  2880. {
  2881. int ret;
  2882. IPA_API_DISPATCH_RETURN(ipa_setup_uc_ntn_pipes, inp,
  2883. notify, priv, hdr_len, outp);
  2884. return ret;
  2885. }
  2886. /**
  2887. * ipa_tear_down_uc_offload_pipes() - tear down uc offload pipes
  2888. */
  2889. int ipa_tear_down_uc_offload_pipes(int ipa_ep_idx_ul,
  2890. int ipa_ep_idx_dl, struct ipa_ntn_conn_in_params *params)
  2891. {
  2892. int ret;
  2893. IPA_API_DISPATCH_RETURN(ipa_tear_down_uc_offload_pipes, ipa_ep_idx_ul,
  2894. ipa_ep_idx_dl, params);
  2895. return ret;
  2896. }
  2897. /**
  2898. * ipa_get_pdev() - return a pointer to IPA dev struct
  2899. *
  2900. * Return value: a pointer to IPA dev struct
  2901. *
  2902. */
  2903. struct device *ipa_get_pdev(void)
  2904. {
  2905. struct device *ret;
  2906. IPA_API_DISPATCH_RETURN_PTR(ipa_get_pdev);
  2907. return ret;
  2908. }
  2909. EXPORT_SYMBOL(ipa_get_pdev);
  2910. int ipa_ntn_uc_reg_rdyCB(void (*ipauc_ready_cb)(void *user_data),
  2911. void *user_data)
  2912. {
  2913. int ret;
  2914. IPA_API_DISPATCH_RETURN(ipa_ntn_uc_reg_rdyCB,
  2915. ipauc_ready_cb, user_data);
  2916. return ret;
  2917. }
  2918. EXPORT_SYMBOL(ipa_ntn_uc_reg_rdyCB);
  2919. void ipa_ntn_uc_dereg_rdyCB(void)
  2920. {
  2921. IPA_API_DISPATCH(ipa_ntn_uc_dereg_rdyCB);
  2922. }
  2923. EXPORT_SYMBOL(ipa_ntn_uc_dereg_rdyCB);
  2924. int ipa_get_smmu_params(struct ipa_smmu_in_params *in,
  2925. struct ipa_smmu_out_params *out)
  2926. {
  2927. int ret;
  2928. IPA_API_DISPATCH_RETURN(ipa_get_smmu_params, in, out);
  2929. return ret;
  2930. }
  2931. EXPORT_SYMBOL(ipa_get_smmu_params);
  2932. /**
  2933. * ipa_conn_wdi_pipes() - connect wdi pipes
  2934. */
  2935. int ipa_conn_wdi_pipes(struct ipa_wdi_conn_in_params *in,
  2936. struct ipa_wdi_conn_out_params *out,
  2937. ipa_wdi_meter_notifier_cb wdi_notify)
  2938. {
  2939. int ret;
  2940. IPA_API_DISPATCH_RETURN(ipa_conn_wdi_pipes, in, out, wdi_notify);
  2941. return ret;
  2942. }
  2943. /**
  2944. * ipa_disconn_wdi_pipes() - disconnect wdi pipes
  2945. */
  2946. int ipa_disconn_wdi_pipes(int ipa_ep_idx_tx, int ipa_ep_idx_rx)
  2947. {
  2948. int ret;
  2949. IPA_API_DISPATCH_RETURN(ipa_disconn_wdi_pipes, ipa_ep_idx_tx,
  2950. ipa_ep_idx_rx);
  2951. return ret;
  2952. }
  2953. /**
  2954. * ipa_enable_wdi_pipes() - enable wdi pipes
  2955. */
  2956. int ipa_enable_wdi_pipes(int ipa_ep_idx_tx, int ipa_ep_idx_rx)
  2957. {
  2958. int ret;
  2959. IPA_API_DISPATCH_RETURN(ipa_enable_wdi_pipes, ipa_ep_idx_tx,
  2960. ipa_ep_idx_rx);
  2961. return ret;
  2962. }
  2963. /**
  2964. * ipa_disable_wdi_pipes() - disable wdi pipes
  2965. */
  2966. int ipa_disable_wdi_pipes(int ipa_ep_idx_tx, int ipa_ep_idx_rx)
  2967. {
  2968. int ret;
  2969. IPA_API_DISPATCH_RETURN(ipa_disable_wdi_pipes, ipa_ep_idx_tx,
  2970. ipa_ep_idx_rx);
  2971. return ret;
  2972. }
  2973. /**
  2974. * ipa_wigig_uc_msi_init() - smmu map\unmap msi related wigig HW registers
  2975. * and init\deinit uC msi config
  2976. */
  2977. int ipa_wigig_uc_msi_init(bool init,
  2978. phys_addr_t periph_baddr_pa,
  2979. phys_addr_t pseudo_cause_pa,
  2980. phys_addr_t int_gen_tx_pa,
  2981. phys_addr_t int_gen_rx_pa,
  2982. phys_addr_t dma_ep_misc_pa)
  2983. {
  2984. int ret;
  2985. IPA_API_DISPATCH_RETURN(ipa_wigig_uc_msi_init, init,
  2986. periph_baddr_pa,
  2987. pseudo_cause_pa,
  2988. int_gen_tx_pa,
  2989. int_gen_rx_pa,
  2990. dma_ep_misc_pa);
  2991. return ret;
  2992. }
  2993. EXPORT_SYMBOL(ipa_wigig_uc_msi_init);
  2994. /**
  2995. * ipa_conn_wigig_rx_pipe_i() - connect wigig rx pipe
  2996. */
  2997. int ipa_conn_wigig_rx_pipe_i(void *in, struct ipa_wigig_conn_out_params *out,
  2998. struct dentry **parent)
  2999. {
  3000. int ret;
  3001. IPA_API_DISPATCH_RETURN(ipa_conn_wigig_rx_pipe_i, in, out, parent);
  3002. return ret;
  3003. }
  3004. EXPORT_SYMBOL(ipa_conn_wigig_rx_pipe_i);
  3005. /**
  3006. * ipa_conn_wigig_client_i() - connect a wigig client
  3007. */
  3008. int ipa_conn_wigig_client_i(void *in,
  3009. struct ipa_wigig_conn_out_params *out,
  3010. ipa_notify_cb tx_notify,
  3011. void *priv)
  3012. {
  3013. int ret;
  3014. IPA_API_DISPATCH_RETURN(ipa_conn_wigig_client_i, in, out,
  3015. tx_notify, priv);
  3016. return ret;
  3017. }
  3018. EXPORT_SYMBOL(ipa_conn_wigig_client_i);
  3019. /**
  3020. * ipa_disconn_wigig_pipe_i() - disconnect a wigig pipe
  3021. */
  3022. int ipa_disconn_wigig_pipe_i(enum ipa_client_type client,
  3023. struct ipa_wigig_pipe_setup_info_smmu *pipe_smmu,
  3024. void *dbuff)
  3025. {
  3026. int ret;
  3027. IPA_API_DISPATCH_RETURN(ipa_disconn_wigig_pipe_i, client,
  3028. pipe_smmu, dbuff);
  3029. return ret;
  3030. }
  3031. EXPORT_SYMBOL(ipa_disconn_wigig_pipe_i);
  3032. /**
  3033. * ipa_enable_wigig_pipe() - enable a wigig pipe
  3034. */
  3035. int ipa_enable_wigig_pipe_i(enum ipa_client_type client)
  3036. {
  3037. int ret;
  3038. IPA_API_DISPATCH_RETURN(ipa_enable_wigig_pipe_i, client);
  3039. return ret;
  3040. }
  3041. EXPORT_SYMBOL(ipa_enable_wigig_pipe_i);
  3042. /**
  3043. * ipa_disable_wigig_pipe_i() - disable a wigig pipe
  3044. */
  3045. int ipa_disable_wigig_pipe_i(enum ipa_client_type client)
  3046. {
  3047. int ret;
  3048. IPA_API_DISPATCH_RETURN(ipa_disable_wigig_pipe_i, client);
  3049. return ret;
  3050. }
  3051. EXPORT_SYMBOL(ipa_disable_wigig_pipe_i);
  3052. /**
  3053. * ipa_tz_unlock_reg() - Allow AP access to memory regions controlled by TZ
  3054. */
  3055. int ipa_tz_unlock_reg(struct ipa_tz_unlock_reg_info *reg_info, u16 num_regs)
  3056. {
  3057. int ret;
  3058. IPA_API_DISPATCH_RETURN(ipa_tz_unlock_reg, reg_info, num_regs);
  3059. return ret;
  3060. }
  3061. void ipa_register_client_callback(int (*client_cb)(bool is_lock),
  3062. bool (*teth_port_state)(void),
  3063. enum ipa_client_type client)
  3064. {
  3065. IPA_API_DISPATCH(ipa_register_client_callback,
  3066. client_cb, teth_port_state, client);
  3067. }
  3068. void ipa_deregister_client_callback(enum ipa_client_type client)
  3069. {
  3070. IPA_API_DISPATCH(ipa_deregister_client_callback,
  3071. client);
  3072. }
  3073. static const struct dev_pm_ops ipa_pm_ops = {
  3074. .suspend_noirq = ipa_ap_suspend,
  3075. .resume_noirq = ipa_ap_resume,
  3076. };
  3077. static struct platform_driver ipa_plat_drv = {
  3078. .probe = ipa_generic_plat_drv_probe,
  3079. .driver = {
  3080. .name = DRV_NAME,
  3081. .pm = &ipa_pm_ops,
  3082. .of_match_table = ipa_plat_drv_match,
  3083. },
  3084. };
  3085. /*********************************************************/
  3086. /* PCIe Version */
  3087. /*********************************************************/
  3088. static int ipa_pci_probe(
  3089. struct pci_dev *pci_dev,
  3090. const struct pci_device_id *ent)
  3091. {
  3092. int result;
  3093. if (!pci_dev || !ent) {
  3094. pr_err(
  3095. "Bad arg: pci_dev (%pK) and/or ent (%pK)\n",
  3096. pci_dev, ent);
  3097. return -EOPNOTSUPP;
  3098. }
  3099. if (!ipa_api_ctrl) {
  3100. ipa_api_ctrl = kzalloc(sizeof(*ipa_api_ctrl), GFP_KERNEL);
  3101. if (ipa_api_ctrl == NULL)
  3102. return -ENOMEM;
  3103. /* Get IPA HW Version */
  3104. result = of_property_read_u32(NULL,
  3105. "qcom,ipa-hw-ver", &ipa_api_hw_type);
  3106. if (result || ipa_api_hw_type == 0) {
  3107. pr_err("ipa: get resource failed for ipa-hw-ver!\n");
  3108. kfree(ipa_api_ctrl);
  3109. ipa_api_ctrl = NULL;
  3110. return -ENODEV;
  3111. }
  3112. pr_debug("ipa: ipa_api_hw_type = %d\n", ipa_api_hw_type);
  3113. }
  3114. /*
  3115. * Call a reduced version of platform_probe appropriate for PCIe
  3116. */
  3117. result = ipa3_pci_drv_probe(pci_dev, ipa_api_ctrl, ipa_pci_drv_match);
  3118. if (result && result != -EPROBE_DEFER)
  3119. pr_err("ipa: ipa3_pci_drv_probe failed\n");
  3120. if (running_emulation)
  3121. ipa_ut_module_init();
  3122. return result;
  3123. }
  3124. static void ipa_pci_remove(struct pci_dev *pci_dev)
  3125. {
  3126. if (running_emulation)
  3127. ipa_ut_module_exit();
  3128. }
  3129. static void ipa_pci_shutdown(struct pci_dev *pci_dev)
  3130. {
  3131. }
  3132. static pci_ers_result_t ipa_pci_io_error_detected(struct pci_dev *pci_dev,
  3133. pci_channel_state_t state)
  3134. {
  3135. return 0;
  3136. }
  3137. static pci_ers_result_t ipa_pci_io_slot_reset(struct pci_dev *pci_dev)
  3138. {
  3139. return 0;
  3140. }
  3141. static void ipa_pci_io_resume(struct pci_dev *pci_dev)
  3142. {
  3143. }
  3144. static int __init ipa_module_init(void)
  3145. {
  3146. pr_debug("IPA module init\n");
  3147. if (running_emulation) {
  3148. /* Register as a PCI device driver */
  3149. return pci_register_driver(&ipa_pci_driver);
  3150. }
  3151. /* Register as a platform device driver */
  3152. return platform_driver_register(&ipa_plat_drv);
  3153. }
  3154. subsys_initcall(ipa_module_init);
  3155. MODULE_LICENSE("GPL v2");
  3156. MODULE_DESCRIPTION("IPA HW device driver");