ipa_api.c 86 KB

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