ipa_api.c 87 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854
  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() - Data-path tx handler
  1481. * @dst: [in] which IPA destination to route tx packets to
  1482. * @skb: [in] the packet to send
  1483. * @metadata: [in] TX packet meta-data
  1484. *
  1485. * Data-path tx handler, this is used for both SW data-path which by-passes most
  1486. * IPA HW blocks AND the regular HW data-path for WLAN AMPDU traffic only. If
  1487. * dst is a "valid" CONS type, then SW data-path is used. If dst is the
  1488. * WLAN_AMPDU PROD type, then HW data-path for WLAN AMPDU is used. Anything else
  1489. * is an error. For errors, client needs to free the skb as needed. For success,
  1490. * IPA driver will later invoke client callback if one was supplied. That
  1491. * callback should free the skb. If no callback supplied, IPA driver will free
  1492. * the skb internally
  1493. *
  1494. * The function will use two descriptors for this send command
  1495. * (for A5_WLAN_AMPDU_PROD only one desciprtor will be sent),
  1496. * the first descriptor will be used to inform the IPA hardware that
  1497. * apps need to push data into the IPA (IP_PACKET_INIT immediate command).
  1498. * Once this send was done from SPS point-of-view the IPA driver will
  1499. * get notified by the supplied callback - ipa_sps_irq_tx_comp()
  1500. *
  1501. * ipa_sps_irq_tx_comp will call to the user supplied
  1502. * callback (from ipa_connect)
  1503. *
  1504. * Returns: 0 on success, negative on failure
  1505. */
  1506. int ipa_tx_dp(enum ipa_client_type dst, struct sk_buff *skb,
  1507. struct ipa_tx_meta *meta)
  1508. {
  1509. int ret;
  1510. IPA_API_DISPATCH_RETURN(ipa_tx_dp, dst, skb, meta);
  1511. return ret;
  1512. }
  1513. EXPORT_SYMBOL(ipa_tx_dp);
  1514. /**
  1515. * ipa_tx_dp_mul() - Data-path tx handler for multiple packets
  1516. * @src: [in] - Client that is sending data
  1517. * @ipa_tx_data_desc: [in] data descriptors from wlan
  1518. *
  1519. * this is used for to transfer data descriptors that received
  1520. * from WLAN1_PROD pipe to IPA HW
  1521. *
  1522. * The function will send data descriptors from WLAN1_PROD (one
  1523. * at a time) using sps_transfer_one. Will set EOT flag for last
  1524. * descriptor Once this send was done from SPS point-of-view the
  1525. * IPA driver will get notified by the supplied callback -
  1526. * ipa_sps_irq_tx_no_aggr_notify()
  1527. *
  1528. * ipa_sps_irq_tx_no_aggr_notify will call to the user supplied
  1529. * callback (from ipa_connect)
  1530. *
  1531. * Returns: 0 on success, negative on failure
  1532. */
  1533. int ipa_tx_dp_mul(enum ipa_client_type src,
  1534. struct ipa_tx_data_desc *data_desc)
  1535. {
  1536. int ret;
  1537. IPA_API_DISPATCH_RETURN(ipa_tx_dp_mul, src, data_desc);
  1538. return ret;
  1539. }
  1540. EXPORT_SYMBOL(ipa_tx_dp_mul);
  1541. void ipa_free_skb(struct ipa_rx_data *data)
  1542. {
  1543. IPA_API_DISPATCH(ipa_free_skb, data);
  1544. }
  1545. EXPORT_SYMBOL(ipa_free_skb);
  1546. /**
  1547. * ipa_setup_sys_pipe() - Setup an IPA end-point in system-BAM mode and perform
  1548. * IPA EP configuration
  1549. * @sys_in: [in] input needed to setup BAM pipe and configure EP
  1550. * @clnt_hdl: [out] client handle
  1551. *
  1552. * - configure the end-point registers with the supplied
  1553. * parameters from the user.
  1554. * - call SPS APIs to create a system-to-bam connection with IPA.
  1555. * - allocate descriptor FIFO
  1556. * - register callback function(ipa_sps_irq_rx_notify or
  1557. * ipa_sps_irq_tx_notify - depends on client type) in case the driver is
  1558. * not configured to pulling mode
  1559. *
  1560. * Returns: 0 on success, negative on failure
  1561. */
  1562. int ipa_setup_sys_pipe(struct ipa_sys_connect_params *sys_in, u32 *clnt_hdl)
  1563. {
  1564. int ret;
  1565. IPA_API_DISPATCH_RETURN(ipa_setup_sys_pipe, sys_in, clnt_hdl);
  1566. return ret;
  1567. }
  1568. EXPORT_SYMBOL(ipa_setup_sys_pipe);
  1569. /**
  1570. * ipa_teardown_sys_pipe() - Teardown the system-BAM pipe and cleanup IPA EP
  1571. * @clnt_hdl: [in] the handle obtained from ipa_setup_sys_pipe
  1572. *
  1573. * Returns: 0 on success, negative on failure
  1574. */
  1575. int ipa_teardown_sys_pipe(u32 clnt_hdl)
  1576. {
  1577. int ret;
  1578. IPA_API_DISPATCH_RETURN(ipa_teardown_sys_pipe, clnt_hdl);
  1579. return ret;
  1580. }
  1581. EXPORT_SYMBOL(ipa_teardown_sys_pipe);
  1582. int ipa_sys_setup(struct ipa_sys_connect_params *sys_in,
  1583. unsigned long *ipa_bam_or_gsi_hdl,
  1584. u32 *ipa_pipe_num, u32 *clnt_hdl, bool en_status)
  1585. {
  1586. int ret;
  1587. IPA_API_DISPATCH_RETURN(ipa_sys_setup, sys_in, ipa_bam_or_gsi_hdl,
  1588. ipa_pipe_num, clnt_hdl, en_status);
  1589. return ret;
  1590. }
  1591. EXPORT_SYMBOL(ipa_sys_setup);
  1592. int ipa_sys_teardown(u32 clnt_hdl)
  1593. {
  1594. int ret;
  1595. IPA_API_DISPATCH_RETURN(ipa_sys_teardown, clnt_hdl);
  1596. return ret;
  1597. }
  1598. EXPORT_SYMBOL(ipa_sys_teardown);
  1599. int ipa_sys_update_gsi_hdls(u32 clnt_hdl, unsigned long gsi_ch_hdl,
  1600. unsigned long gsi_ev_hdl)
  1601. {
  1602. int ret;
  1603. IPA_API_DISPATCH_RETURN(ipa_sys_update_gsi_hdls, clnt_hdl,
  1604. gsi_ch_hdl, gsi_ev_hdl);
  1605. return ret;
  1606. }
  1607. EXPORT_SYMBOL(ipa_sys_update_gsi_hdls);
  1608. /**
  1609. * ipa_connect_wdi_pipe() - WDI client connect
  1610. * @in: [in] input parameters from client
  1611. * @out: [out] output params to client
  1612. *
  1613. * Returns: 0 on success, negative on failure
  1614. *
  1615. * Note: Should not be called from atomic context
  1616. */
  1617. int ipa_connect_wdi_pipe(struct ipa_wdi_in_params *in,
  1618. struct ipa_wdi_out_params *out)
  1619. {
  1620. int ret;
  1621. IPA_API_DISPATCH_RETURN(ipa_connect_wdi_pipe, in, out);
  1622. return ret;
  1623. }
  1624. EXPORT_SYMBOL(ipa_connect_wdi_pipe);
  1625. /**
  1626. * ipa_disconnect_wdi_pipe() - WDI client disconnect
  1627. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  1628. *
  1629. * Returns: 0 on success, negative on failure
  1630. *
  1631. * Note: Should not be called from atomic context
  1632. */
  1633. int ipa_disconnect_wdi_pipe(u32 clnt_hdl)
  1634. {
  1635. int ret;
  1636. IPA_API_DISPATCH_RETURN(ipa_disconnect_wdi_pipe, clnt_hdl);
  1637. return ret;
  1638. }
  1639. EXPORT_SYMBOL(ipa_disconnect_wdi_pipe);
  1640. /**
  1641. * ipa_enable_wdi_pipe() - WDI client enable
  1642. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  1643. *
  1644. * Returns: 0 on success, negative on failure
  1645. *
  1646. * Note: Should not be called from atomic context
  1647. */
  1648. int ipa_enable_wdi_pipe(u32 clnt_hdl)
  1649. {
  1650. int ret;
  1651. IPA_API_DISPATCH_RETURN(ipa_enable_wdi_pipe, clnt_hdl);
  1652. return ret;
  1653. }
  1654. EXPORT_SYMBOL(ipa_enable_wdi_pipe);
  1655. /**
  1656. * ipa_disable_wdi_pipe() - WDI client disable
  1657. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  1658. *
  1659. * Returns: 0 on success, negative on failure
  1660. *
  1661. * Note: Should not be called from atomic context
  1662. */
  1663. int ipa_disable_wdi_pipe(u32 clnt_hdl)
  1664. {
  1665. int ret;
  1666. IPA_API_DISPATCH_RETURN(ipa_disable_wdi_pipe, clnt_hdl);
  1667. return ret;
  1668. }
  1669. EXPORT_SYMBOL(ipa_disable_wdi_pipe);
  1670. /**
  1671. * ipa_resume_wdi_pipe() - WDI client resume
  1672. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  1673. *
  1674. * Returns: 0 on success, negative on failure
  1675. *
  1676. * Note: Should not be called from atomic context
  1677. */
  1678. int ipa_resume_wdi_pipe(u32 clnt_hdl)
  1679. {
  1680. int ret;
  1681. IPA_API_DISPATCH_RETURN(ipa_resume_wdi_pipe, clnt_hdl);
  1682. return ret;
  1683. }
  1684. EXPORT_SYMBOL(ipa_resume_wdi_pipe);
  1685. /**
  1686. * ipa_suspend_wdi_pipe() - WDI client suspend
  1687. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  1688. *
  1689. * Returns: 0 on success, negative on failure
  1690. *
  1691. * Note: Should not be called from atomic context
  1692. */
  1693. int ipa_suspend_wdi_pipe(u32 clnt_hdl)
  1694. {
  1695. int ret;
  1696. IPA_API_DISPATCH_RETURN(ipa_suspend_wdi_pipe, clnt_hdl);
  1697. return ret;
  1698. }
  1699. EXPORT_SYMBOL(ipa_suspend_wdi_pipe);
  1700. /**
  1701. * ipa_get_wdi_stats() - Query WDI statistics from uc
  1702. * @stats: [inout] stats blob from client populated by driver
  1703. *
  1704. * Returns: 0 on success, negative on failure
  1705. *
  1706. * @note Cannot be called from atomic context
  1707. *
  1708. */
  1709. int ipa_get_wdi_stats(struct IpaHwStatsWDIInfoData_t *stats)
  1710. {
  1711. int ret;
  1712. IPA_API_DISPATCH_RETURN(ipa_get_wdi_stats, stats);
  1713. return ret;
  1714. }
  1715. EXPORT_SYMBOL(ipa_get_wdi_stats);
  1716. /**
  1717. * ipa_uc_bw_monitor() - start uc bw monitoring
  1718. * @info: [inout] set info populated by driver
  1719. *
  1720. * Returns: 0 on success, negative on failure
  1721. *
  1722. * @note Cannot be called from atomic context
  1723. *
  1724. */
  1725. int ipa_uc_bw_monitor(struct ipa_wdi_bw_info *info)
  1726. {
  1727. int ret;
  1728. IPA_API_DISPATCH_RETURN(ipa_uc_bw_monitor, info);
  1729. return ret;
  1730. }
  1731. EXPORT_SYMBOL(ipa_uc_bw_monitor);
  1732. /**
  1733. * ipa_set_wlan_tx_info() -set WDI statistics from uc
  1734. * @info: [inout] set info populated by driver
  1735. *
  1736. * Returns: 0 on success, negative on failure
  1737. *
  1738. * @note Cannot be called from atomic context
  1739. *
  1740. */
  1741. int ipa_set_wlan_tx_info(struct ipa_wdi_tx_info *info)
  1742. {
  1743. int ret;
  1744. IPA_API_DISPATCH_RETURN(ipa_set_wlan_tx_info, info);
  1745. return ret;
  1746. }
  1747. EXPORT_SYMBOL(ipa_set_wlan_tx_info);
  1748. /**
  1749. * ipa_get_smem_restr_bytes()- Return IPA smem restricted bytes
  1750. *
  1751. * Return value: u16 - number of IPA smem restricted bytes
  1752. */
  1753. u16 ipa_get_smem_restr_bytes(void)
  1754. {
  1755. int ret;
  1756. IPA_API_DISPATCH_RETURN(ipa_get_smem_restr_bytes);
  1757. return ret;
  1758. }
  1759. EXPORT_SYMBOL(ipa_get_smem_restr_bytes);
  1760. /**
  1761. * ipa_broadcast_wdi_quota_reach_ind() - quota reach
  1762. * @uint32_t fid: [in] input netdev ID
  1763. * @uint64_t num_bytes: [in] used bytes
  1764. *
  1765. * Returns: 0 on success, negative on failure
  1766. */
  1767. int ipa_broadcast_wdi_quota_reach_ind(uint32_t fid,
  1768. uint64_t num_bytes)
  1769. {
  1770. int ret;
  1771. IPA_API_DISPATCH_RETURN(ipa_broadcast_wdi_quota_reach_ind,
  1772. fid, num_bytes);
  1773. return ret;
  1774. }
  1775. EXPORT_SYMBOL(ipa_broadcast_wdi_quota_reach_ind);
  1776. /**
  1777. * ipa_uc_wdi_get_dbpa() - To retrieve
  1778. * doorbell physical address of wlan pipes
  1779. * @param: [in/out] input/output parameters
  1780. * from/to client
  1781. *
  1782. * Returns: 0 on success, negative on failure
  1783. *
  1784. */
  1785. int ipa_uc_wdi_get_dbpa(
  1786. struct ipa_wdi_db_params *param)
  1787. {
  1788. int ret;
  1789. IPA_API_DISPATCH_RETURN(ipa_uc_wdi_get_dbpa, param);
  1790. return ret;
  1791. }
  1792. EXPORT_SYMBOL(ipa_uc_wdi_get_dbpa);
  1793. /**
  1794. * ipa_uc_reg_rdyCB() - To register uC
  1795. * ready CB if uC not ready, wdi only.
  1796. * @inout: [in/out] input/output parameters
  1797. * from/to client
  1798. *
  1799. * Returns: 0 on success, negative on failure
  1800. *
  1801. */
  1802. int ipa_uc_reg_rdyCB(
  1803. struct ipa_wdi_uc_ready_params *inout)
  1804. {
  1805. int ret;
  1806. IPA_API_DISPATCH_RETURN(ipa_uc_reg_rdyCB, inout);
  1807. return ret;
  1808. }
  1809. EXPORT_SYMBOL(ipa_uc_reg_rdyCB);
  1810. /**
  1811. * ipa_wigig_internal_init() - get uc db and register uC
  1812. * ready CB if uC not ready, wigig only.
  1813. * @inout: [in/out] uc ready input/output parameters
  1814. * from/to client
  1815. * @int_notify: [in] wigig misc interrupt handler function
  1816. * @uc_db_pa: [out] uC db physical address
  1817. *
  1818. * Returns: 0 on success, negative on failure
  1819. *
  1820. */
  1821. int ipa_wigig_internal_init(
  1822. struct ipa_wdi_uc_ready_params *inout,
  1823. ipa_wigig_misc_int_cb int_notify,
  1824. phys_addr_t *uc_db_pa)
  1825. {
  1826. int ret;
  1827. IPA_API_DISPATCH_RETURN(ipa_wigig_internal_init, inout,
  1828. int_notify, uc_db_pa);
  1829. return ret;
  1830. }
  1831. EXPORT_SYMBOL(ipa_wigig_internal_init);
  1832. /**
  1833. * ipa_uc_dereg_rdyCB() - To de-register uC ready CB
  1834. *
  1835. * Returns: 0 on success, negative on failure
  1836. *
  1837. */
  1838. int ipa_uc_dereg_rdyCB(void)
  1839. {
  1840. int ret;
  1841. IPA_API_DISPATCH_RETURN(ipa_uc_dereg_rdyCB);
  1842. return ret;
  1843. }
  1844. EXPORT_SYMBOL(ipa_uc_dereg_rdyCB);
  1845. /**
  1846. * teth_bridge_init() - Initialize the Tethering bridge driver
  1847. * @params - in/out params for USB initialization API (please look at struct
  1848. * definition for more info)
  1849. *
  1850. * USB driver gets a pointer to a callback function (usb_notify_cb) and an
  1851. * associated data. USB driver installs this callback function in the call to
  1852. * ipa_connect().
  1853. *
  1854. * Builds IPA resource manager dependency graph.
  1855. *
  1856. * Return codes: 0: success,
  1857. * -EINVAL - Bad parameter
  1858. * Other negative value - Failure
  1859. */
  1860. int teth_bridge_init(struct teth_bridge_init_params *params)
  1861. {
  1862. int ret;
  1863. IPA_API_DISPATCH_RETURN(teth_bridge_init, params);
  1864. return ret;
  1865. }
  1866. EXPORT_SYMBOL(teth_bridge_init);
  1867. /**
  1868. * teth_bridge_disconnect() - Disconnect tethering bridge module
  1869. */
  1870. int teth_bridge_disconnect(enum ipa_client_type client)
  1871. {
  1872. int ret;
  1873. IPA_API_DISPATCH_RETURN(teth_bridge_disconnect, client);
  1874. return ret;
  1875. }
  1876. EXPORT_SYMBOL(teth_bridge_disconnect);
  1877. /**
  1878. * teth_bridge_connect() - Connect bridge for a tethered Rmnet / MBIM call
  1879. * @connect_params: Connection info
  1880. *
  1881. * Return codes: 0: success
  1882. * -EINVAL: invalid parameters
  1883. * -EPERM: Operation not permitted as the bridge is already
  1884. * connected
  1885. */
  1886. int teth_bridge_connect(struct teth_bridge_connect_params *connect_params)
  1887. {
  1888. int ret;
  1889. IPA_API_DISPATCH_RETURN(teth_bridge_connect, connect_params);
  1890. return ret;
  1891. }
  1892. EXPORT_SYMBOL(teth_bridge_connect);
  1893. /* ipa_set_client() - provide client mapping
  1894. * @client: client type
  1895. *
  1896. * Return value: none
  1897. */
  1898. void ipa_set_client(int index, enum ipacm_client_enum client, bool uplink)
  1899. {
  1900. IPA_API_DISPATCH(ipa_set_client, index, client, uplink);
  1901. }
  1902. EXPORT_SYMBOL(ipa_set_client);
  1903. /**
  1904. * ipa_get_client() - provide client mapping
  1905. * @client: client type
  1906. *
  1907. * Return value: none
  1908. */
  1909. enum ipacm_client_enum ipa_get_client(int pipe_idx)
  1910. {
  1911. int ret;
  1912. IPA_API_DISPATCH_RETURN(ipa_get_client, pipe_idx);
  1913. return ret;
  1914. }
  1915. EXPORT_SYMBOL(ipa_get_client);
  1916. /**
  1917. * ipa_get_client_uplink() - provide client mapping
  1918. * @client: client type
  1919. *
  1920. * Return value: none
  1921. */
  1922. bool ipa_get_client_uplink(int pipe_idx)
  1923. {
  1924. int ret;
  1925. IPA_API_DISPATCH_RETURN(ipa_get_client_uplink, pipe_idx);
  1926. return ret;
  1927. }
  1928. EXPORT_SYMBOL(ipa_get_client_uplink);
  1929. /**
  1930. * ipa_dma_init() -Initialize IPADMA.
  1931. *
  1932. * This function initialize all IPADMA internal data and connect in dma:
  1933. * MEMCPY_DMA_SYNC_PROD ->MEMCPY_DMA_SYNC_CONS
  1934. * MEMCPY_DMA_ASYNC_PROD->MEMCPY_DMA_SYNC_CONS
  1935. *
  1936. * Return codes: 0: success
  1937. * -EFAULT: IPADMA is already initialized
  1938. * -ENOMEM: allocating memory error
  1939. * -EPERM: pipe connection failed
  1940. */
  1941. int ipa_dma_init(void)
  1942. {
  1943. int ret;
  1944. IPA_API_DISPATCH_RETURN(ipa_dma_init);
  1945. return ret;
  1946. }
  1947. EXPORT_SYMBOL(ipa_dma_init);
  1948. /**
  1949. * ipa_dma_enable() -Vote for IPA clocks.
  1950. *
  1951. *Return codes: 0: success
  1952. * -EINVAL: IPADMA is not initialized
  1953. * -EPERM: Operation not permitted as ipa_dma is already
  1954. * enabled
  1955. */
  1956. int ipa_dma_enable(void)
  1957. {
  1958. int ret;
  1959. IPA_API_DISPATCH_RETURN(ipa_dma_enable);
  1960. return ret;
  1961. }
  1962. EXPORT_SYMBOL(ipa_dma_enable);
  1963. /**
  1964. * ipa_dma_disable()- Unvote for IPA clocks.
  1965. *
  1966. * enter to power save mode.
  1967. *
  1968. * Return codes: 0: success
  1969. * -EINVAL: IPADMA is not initialized
  1970. * -EPERM: Operation not permitted as ipa_dma is already
  1971. * diabled
  1972. * -EFAULT: can not disable ipa_dma as there are pending
  1973. * memcopy works
  1974. */
  1975. int ipa_dma_disable(void)
  1976. {
  1977. int ret;
  1978. IPA_API_DISPATCH_RETURN(ipa_dma_disable);
  1979. return ret;
  1980. }
  1981. EXPORT_SYMBOL(ipa_dma_disable);
  1982. /**
  1983. * ipa_dma_sync_memcpy()- Perform synchronous memcpy using IPA.
  1984. *
  1985. * @dest: physical address to store the copied data.
  1986. * @src: physical address of the source data to copy.
  1987. * @len: number of bytes to copy.
  1988. *
  1989. * Return codes: 0: success
  1990. * -EINVAL: invalid params
  1991. * -EPERM: operation not permitted as ipa_dma isn't enable or
  1992. * initialized
  1993. * -SPS_ERROR: on sps faliures
  1994. * -EFAULT: other
  1995. */
  1996. int ipa_dma_sync_memcpy(u64 dest, u64 src, int len)
  1997. {
  1998. int ret;
  1999. IPA_API_DISPATCH_RETURN(ipa_dma_sync_memcpy, dest, src, len);
  2000. return ret;
  2001. }
  2002. EXPORT_SYMBOL(ipa_dma_sync_memcpy);
  2003. /**
  2004. * ipa_dma_async_memcpy()- Perform asynchronous memcpy using IPA.
  2005. *
  2006. * @dest: physical address to store the copied data.
  2007. * @src: physical address of the source data to copy.
  2008. * @len: number of bytes to copy.
  2009. * @user_cb: callback function to notify the client when the copy was done.
  2010. * @user_param: cookie for user_cb.
  2011. *
  2012. * Return codes: 0: success
  2013. * -EINVAL: invalid params
  2014. * -EPERM: operation not permitted as ipa_dma isn't enable or
  2015. * initialized
  2016. * -SPS_ERROR: on sps faliures
  2017. * -EFAULT: descr fifo is full.
  2018. */
  2019. int ipa_dma_async_memcpy(u64 dest, u64 src, int len,
  2020. void (*user_cb)(void *user1), void *user_param)
  2021. {
  2022. int ret;
  2023. IPA_API_DISPATCH_RETURN(ipa_dma_async_memcpy, dest, src, len, user_cb,
  2024. user_param);
  2025. return ret;
  2026. }
  2027. EXPORT_SYMBOL(ipa_dma_async_memcpy);
  2028. /**
  2029. * ipa_dma_uc_memcpy() - Perform a memcpy action using IPA uC
  2030. * @dest: physical address to store the copied data.
  2031. * @src: physical address of the source data to copy.
  2032. * @len: number of bytes to copy.
  2033. *
  2034. * Return codes: 0: success
  2035. * -EINVAL: invalid params
  2036. * -EPERM: operation not permitted as ipa_dma isn't enable or
  2037. * initialized
  2038. * -EBADF: IPA uC is not loaded
  2039. */
  2040. int ipa_dma_uc_memcpy(phys_addr_t dest, phys_addr_t src, int len)
  2041. {
  2042. int ret;
  2043. IPA_API_DISPATCH_RETURN(ipa_dma_uc_memcpy, dest, src, len);
  2044. return ret;
  2045. }
  2046. EXPORT_SYMBOL(ipa_dma_uc_memcpy);
  2047. /**
  2048. * ipa_dma_destroy() -teardown IPADMA pipes and release ipadma.
  2049. *
  2050. * this is a blocking function, returns just after destroying IPADMA.
  2051. */
  2052. void ipa_dma_destroy(void)
  2053. {
  2054. IPA_API_DISPATCH(ipa_dma_destroy);
  2055. }
  2056. EXPORT_SYMBOL(ipa_dma_destroy);
  2057. int ipa_mhi_init_engine(struct ipa_mhi_init_engine *params)
  2058. {
  2059. int ret;
  2060. IPA_API_DISPATCH_RETURN(ipa_mhi_init_engine, params);
  2061. return ret;
  2062. }
  2063. EXPORT_SYMBOL(ipa_mhi_init_engine);
  2064. /**
  2065. * ipa_connect_mhi_pipe() - Connect pipe to IPA and start corresponding
  2066. * MHI channel
  2067. * @in: connect parameters
  2068. * @clnt_hdl: [out] client handle for this pipe
  2069. *
  2070. * This function is called by IPA MHI client driver on MHI channel start.
  2071. * This function is called after MHI engine was started.
  2072. * This function is doing the following:
  2073. * - Send command to uC to start corresponding MHI channel
  2074. * - Configure IPA EP control
  2075. *
  2076. * Return codes: 0 : success
  2077. * negative : error
  2078. */
  2079. int ipa_connect_mhi_pipe(struct ipa_mhi_connect_params_internal *in,
  2080. u32 *clnt_hdl)
  2081. {
  2082. int ret;
  2083. IPA_API_DISPATCH_RETURN(ipa_connect_mhi_pipe, in, clnt_hdl);
  2084. return ret;
  2085. }
  2086. EXPORT_SYMBOL(ipa_connect_mhi_pipe);
  2087. /**
  2088. * ipa_disconnect_mhi_pipe() - Disconnect pipe from IPA and reset corresponding
  2089. * MHI channel
  2090. * @in: connect parameters
  2091. * @clnt_hdl: [out] client handle for this pipe
  2092. *
  2093. * This function is called by IPA MHI client driver on MHI channel reset.
  2094. * This function is called after MHI channel was started.
  2095. * This function is doing the following:
  2096. * - Send command to uC to reset corresponding MHI channel
  2097. * - Configure IPA EP control
  2098. *
  2099. * Return codes: 0 : success
  2100. * negative : error
  2101. */
  2102. int ipa_disconnect_mhi_pipe(u32 clnt_hdl)
  2103. {
  2104. int ret;
  2105. IPA_API_DISPATCH_RETURN(ipa_disconnect_mhi_pipe, clnt_hdl);
  2106. return ret;
  2107. }
  2108. EXPORT_SYMBOL(ipa_disconnect_mhi_pipe);
  2109. bool ipa_mhi_stop_gsi_channel(enum ipa_client_type client)
  2110. {
  2111. bool ret;
  2112. IPA_API_DISPATCH_RETURN_BOOL(ipa_mhi_stop_gsi_channel, client);
  2113. return ret;
  2114. }
  2115. int ipa_uc_mhi_reset_channel(int channelHandle)
  2116. {
  2117. int ret;
  2118. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_reset_channel, channelHandle);
  2119. return ret;
  2120. }
  2121. bool ipa_mhi_sps_channel_empty(enum ipa_client_type client)
  2122. {
  2123. bool ret;
  2124. IPA_API_DISPATCH_RETURN_BOOL(ipa_mhi_sps_channel_empty, client);
  2125. return ret;
  2126. }
  2127. int ipa_qmi_enable_force_clear_datapath_send(
  2128. struct ipa_enable_force_clear_datapath_req_msg_v01 *req)
  2129. {
  2130. int ret;
  2131. IPA_API_DISPATCH_RETURN(ipa_qmi_enable_force_clear_datapath_send, req);
  2132. return ret;
  2133. }
  2134. int ipa_qmi_disable_force_clear_datapath_send(
  2135. struct ipa_disable_force_clear_datapath_req_msg_v01 *req)
  2136. {
  2137. int ret;
  2138. IPA_API_DISPATCH_RETURN(ipa_qmi_disable_force_clear_datapath_send, req);
  2139. return ret;
  2140. }
  2141. int ipa_generate_tag_process(void)
  2142. {
  2143. int ret;
  2144. IPA_API_DISPATCH_RETURN(ipa_generate_tag_process);
  2145. return ret;
  2146. }
  2147. int ipa_disable_sps_pipe(enum ipa_client_type client)
  2148. {
  2149. int ret;
  2150. IPA_API_DISPATCH_RETURN(ipa_disable_sps_pipe, client);
  2151. return ret;
  2152. }
  2153. int ipa_mhi_reset_channel_internal(enum ipa_client_type client)
  2154. {
  2155. int ret;
  2156. IPA_API_DISPATCH_RETURN(ipa_mhi_reset_channel_internal, client);
  2157. return ret;
  2158. }
  2159. int ipa_mhi_start_channel_internal(enum ipa_client_type client)
  2160. {
  2161. int ret;
  2162. IPA_API_DISPATCH_RETURN(ipa_mhi_start_channel_internal, client);
  2163. return ret;
  2164. }
  2165. void ipa_get_holb(int ep_idx, struct ipa_ep_cfg_holb *holb)
  2166. {
  2167. IPA_API_DISPATCH(ipa_get_holb, ep_idx, holb);
  2168. }
  2169. void ipa_set_tag_process_before_gating(bool val)
  2170. {
  2171. IPA_API_DISPATCH(ipa_set_tag_process_before_gating, val);
  2172. }
  2173. int ipa_mhi_query_ch_info(enum ipa_client_type client,
  2174. struct gsi_chan_info *ch_info)
  2175. {
  2176. int ret;
  2177. IPA_API_DISPATCH_RETURN(ipa_mhi_query_ch_info, client, ch_info);
  2178. return ret;
  2179. }
  2180. int ipa_uc_mhi_suspend_channel(int channelHandle)
  2181. {
  2182. int ret;
  2183. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_suspend_channel, channelHandle);
  2184. return ret;
  2185. }
  2186. int ipa_uc_mhi_stop_event_update_channel(int channelHandle)
  2187. {
  2188. int ret;
  2189. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_stop_event_update_channel,
  2190. channelHandle);
  2191. return ret;
  2192. }
  2193. bool ipa_has_open_aggr_frame(enum ipa_client_type client)
  2194. {
  2195. bool ret;
  2196. IPA_API_DISPATCH_RETURN_BOOL(ipa_has_open_aggr_frame, client);
  2197. return ret;
  2198. }
  2199. int ipa_mhi_resume_channels_internal(enum ipa_client_type client,
  2200. bool LPTransitionRejected, bool brstmode_enabled,
  2201. union __packed gsi_channel_scratch ch_scratch, u8 index)
  2202. {
  2203. int ret;
  2204. IPA_API_DISPATCH_RETURN(ipa_mhi_resume_channels_internal, client,
  2205. LPTransitionRejected, brstmode_enabled, ch_scratch,
  2206. index);
  2207. return ret;
  2208. }
  2209. int ipa_uc_mhi_send_dl_ul_sync_info(union IpaHwMhiDlUlSyncCmdData_t *cmd)
  2210. {
  2211. int ret;
  2212. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_send_dl_ul_sync_info,
  2213. cmd);
  2214. return ret;
  2215. }
  2216. int ipa_mhi_destroy_channel(enum ipa_client_type client)
  2217. {
  2218. int ret;
  2219. IPA_API_DISPATCH_RETURN(ipa_mhi_destroy_channel, client);
  2220. return ret;
  2221. }
  2222. int ipa_uc_mhi_init(void (*ready_cb)(void),
  2223. void (*wakeup_request_cb)(void))
  2224. {
  2225. int ret;
  2226. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_init, ready_cb, wakeup_request_cb);
  2227. return ret;
  2228. }
  2229. void ipa_uc_mhi_cleanup(void)
  2230. {
  2231. IPA_API_DISPATCH(ipa_uc_mhi_cleanup);
  2232. }
  2233. int ipa_uc_mhi_print_stats(char *dbg_buff, int size)
  2234. {
  2235. int ret;
  2236. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_print_stats, dbg_buff, size);
  2237. return ret;
  2238. }
  2239. /**
  2240. * ipa_uc_state_check() - Check the status of the uC interface
  2241. *
  2242. * Return value: 0 if the uC is loaded, interface is initialized
  2243. * and there was no recent failure in one of the commands.
  2244. * A negative value is returned otherwise.
  2245. */
  2246. int ipa_uc_state_check(void)
  2247. {
  2248. int ret;
  2249. IPA_API_DISPATCH_RETURN(ipa_uc_state_check);
  2250. return ret;
  2251. }
  2252. int ipa_write_qmap_id(struct ipa_ioc_write_qmapid *param_in)
  2253. {
  2254. int ret;
  2255. IPA_API_DISPATCH_RETURN(ipa_write_qmap_id, param_in);
  2256. return ret;
  2257. }
  2258. EXPORT_SYMBOL(ipa_write_qmap_id);
  2259. /**
  2260. * ipa_add_interrupt_handler() - Adds handler to an interrupt type
  2261. * @interrupt: Interrupt type
  2262. * @handler: The handler to be added
  2263. * @deferred_flag: whether the handler processing should be deferred in
  2264. * a workqueue
  2265. * @private_data: the client's private data
  2266. *
  2267. * Adds handler to an interrupt type and enable the specific bit
  2268. * in IRQ_EN register, associated interrupt in IRQ_STTS register will be enabled
  2269. */
  2270. int ipa_add_interrupt_handler(enum ipa_irq_type interrupt,
  2271. ipa_irq_handler_t handler,
  2272. bool deferred_flag,
  2273. void *private_data)
  2274. {
  2275. int ret;
  2276. IPA_API_DISPATCH_RETURN(ipa_add_interrupt_handler, interrupt, handler,
  2277. deferred_flag, private_data);
  2278. return ret;
  2279. }
  2280. EXPORT_SYMBOL(ipa_add_interrupt_handler);
  2281. /**
  2282. * ipa_remove_interrupt_handler() - Removes handler to an interrupt type
  2283. * @interrupt: Interrupt type
  2284. *
  2285. * Removes the handler and disable the specific bit in IRQ_EN register
  2286. */
  2287. int ipa_remove_interrupt_handler(enum ipa_irq_type interrupt)
  2288. {
  2289. int ret;
  2290. IPA_API_DISPATCH_RETURN(ipa_remove_interrupt_handler, interrupt);
  2291. return ret;
  2292. }
  2293. EXPORT_SYMBOL(ipa_remove_interrupt_handler);
  2294. /**
  2295. * ipa_restore_suspend_handler() - restores the original suspend IRQ handler
  2296. * as it was registered in the IPA init sequence.
  2297. * Return codes:
  2298. * 0: success
  2299. * -EPERM: failed to remove current handler or failed to add original handler
  2300. */
  2301. int ipa_restore_suspend_handler(void)
  2302. {
  2303. int ret;
  2304. IPA_API_DISPATCH_RETURN(ipa_restore_suspend_handler);
  2305. return ret;
  2306. }
  2307. EXPORT_SYMBOL(ipa_restore_suspend_handler);
  2308. /**
  2309. * ipa_bam_reg_dump() - Dump selected BAM registers for IPA and DMA-BAM
  2310. *
  2311. * Function is rate limited to avoid flooding kernel log buffer
  2312. */
  2313. void ipa_bam_reg_dump(void)
  2314. {
  2315. IPA_API_DISPATCH(ipa_bam_reg_dump);
  2316. }
  2317. EXPORT_SYMBOL(ipa_bam_reg_dump);
  2318. /**
  2319. * ipa_get_ep_mapping() - provide endpoint mapping
  2320. * @client: client type
  2321. *
  2322. * Return value: endpoint mapping
  2323. */
  2324. int ipa_get_ep_mapping(enum ipa_client_type client)
  2325. {
  2326. int ret;
  2327. IPA_API_DISPATCH_RETURN(ipa_get_ep_mapping, client);
  2328. return ret;
  2329. }
  2330. EXPORT_SYMBOL(ipa_get_ep_mapping);
  2331. /**
  2332. * ipa_is_ready() - check if IPA module was initialized
  2333. * successfully
  2334. *
  2335. * Return value: true for yes; false for no
  2336. */
  2337. bool ipa_is_ready(void)
  2338. {
  2339. if (!ipa_api_ctrl || !ipa_api_ctrl->ipa_is_ready)
  2340. return false;
  2341. return ipa_api_ctrl->ipa_is_ready();
  2342. }
  2343. EXPORT_SYMBOL(ipa_is_ready);
  2344. /**
  2345. * ipa_proxy_clk_vote() - called to add IPA clock proxy vote
  2346. *
  2347. * Return value: none
  2348. */
  2349. void ipa_proxy_clk_vote(void)
  2350. {
  2351. IPA_API_DISPATCH(ipa_proxy_clk_vote);
  2352. }
  2353. EXPORT_SYMBOL(ipa_proxy_clk_vote);
  2354. /**
  2355. * ipa_proxy_clk_unvote() - called to remove IPA clock proxy vote
  2356. *
  2357. * Return value: none
  2358. */
  2359. void ipa_proxy_clk_unvote(void)
  2360. {
  2361. IPA_API_DISPATCH(ipa_proxy_clk_unvote);
  2362. }
  2363. EXPORT_SYMBOL(ipa_proxy_clk_unvote);
  2364. /**
  2365. * ipa_get_hw_type() - Return IPA HW version
  2366. *
  2367. * Return value: enum ipa_hw_type
  2368. */
  2369. enum ipa_hw_type ipa_get_hw_type(void)
  2370. {
  2371. return ipa_api_hw_type;
  2372. }
  2373. EXPORT_SYMBOL(ipa_get_hw_type);
  2374. /**
  2375. * ipa_is_client_handle_valid() - check if IPA client handle is valid handle
  2376. *
  2377. * Return value: true for yes; false for no
  2378. */
  2379. bool ipa_is_client_handle_valid(u32 clnt_hdl)
  2380. {
  2381. if (!ipa_api_ctrl || !ipa_api_ctrl->ipa_is_client_handle_valid)
  2382. return false;
  2383. return ipa_api_ctrl->ipa_is_client_handle_valid(clnt_hdl);
  2384. }
  2385. EXPORT_SYMBOL(ipa_is_client_handle_valid);
  2386. /**
  2387. * ipa_get_client_mapping() - provide client mapping
  2388. * @pipe_idx: IPA end-point number
  2389. *
  2390. * Return value: client mapping
  2391. */
  2392. enum ipa_client_type ipa_get_client_mapping(int pipe_idx)
  2393. {
  2394. int ret;
  2395. IPA_API_DISPATCH_RETURN(ipa_get_client_mapping, pipe_idx);
  2396. return ret;
  2397. }
  2398. EXPORT_SYMBOL(ipa_get_client_mapping);
  2399. /**
  2400. * ipa_get_rm_resource_from_ep() - this function is part of the deprecated
  2401. * RM mechanism but is still used by some drivers so we kept the definition.
  2402. */
  2403. enum ipa_rm_resource_name ipa_get_rm_resource_from_ep(int pipe_idx)
  2404. {
  2405. IPAERR("IPA RM is not supported idx=%d\n", pipe_idx);
  2406. return -EFAULT;
  2407. }
  2408. EXPORT_SYMBOL(ipa_get_rm_resource_from_ep);
  2409. /**
  2410. * ipa_get_modem_cfg_emb_pipe_flt()- Return ipa_ctx->modem_cfg_emb_pipe_flt
  2411. *
  2412. * Return value: true if modem configures embedded pipe flt, false otherwise
  2413. */
  2414. bool ipa_get_modem_cfg_emb_pipe_flt(void)
  2415. {
  2416. if (!ipa_api_ctrl || !ipa_api_ctrl->ipa_get_modem_cfg_emb_pipe_flt)
  2417. return false;
  2418. return ipa_api_ctrl->ipa_get_modem_cfg_emb_pipe_flt();
  2419. }
  2420. EXPORT_SYMBOL(ipa_get_modem_cfg_emb_pipe_flt);
  2421. /**
  2422. * ipa_get_transport_type()- Return ipa_ctx->transport_prototype
  2423. *
  2424. * Return value: enum ipa_transport_type
  2425. */
  2426. enum ipa_transport_type ipa_get_transport_type(void)
  2427. {
  2428. int ret;
  2429. IPA_API_DISPATCH_RETURN(ipa_get_transport_type);
  2430. return ret;
  2431. }
  2432. EXPORT_SYMBOL(ipa_get_transport_type);
  2433. /**
  2434. * ipa_get_smmu_domain()- Return the smmu domain
  2435. *
  2436. * Return value: pointer to iommu domain if smmu_cb valid, NULL otherwise
  2437. */
  2438. struct iommu_domain *ipa_get_smmu_domain(void)
  2439. {
  2440. struct iommu_domain *ret;
  2441. IPA_API_DISPATCH_RETURN_PTR(ipa_get_smmu_domain);
  2442. return ret;
  2443. }
  2444. EXPORT_SYMBOL(ipa_get_smmu_domain);
  2445. /**
  2446. * ipa_disable_apps_wan_cons_deaggr()- set
  2447. * ipa_ctx->ipa_client_apps_wan_cons_agg_gro
  2448. *
  2449. * Return value: 0 or negative in case of failure
  2450. */
  2451. int ipa_disable_apps_wan_cons_deaggr(uint32_t agg_size, uint32_t agg_count)
  2452. {
  2453. int ret;
  2454. IPA_API_DISPATCH_RETURN(ipa_disable_apps_wan_cons_deaggr, agg_size,
  2455. agg_count);
  2456. return ret;
  2457. }
  2458. EXPORT_SYMBOL(ipa_disable_apps_wan_cons_deaggr);
  2459. /**
  2460. * ipa_get_dma_dev()- Returns ipa_ctx dma dev pointer
  2461. *
  2462. * Return value: pointer to ipa_ctx dma dev pointer
  2463. */
  2464. struct device *ipa_get_dma_dev(void)
  2465. {
  2466. struct device *ret;
  2467. IPA_API_DISPATCH_RETURN_PTR(ipa_get_dma_dev);
  2468. return ret;
  2469. }
  2470. EXPORT_SYMBOL(ipa_get_dma_dev);
  2471. /**
  2472. * ipa_release_wdi_mapping() - release iommu mapping
  2473. *
  2474. *
  2475. * @num_buffers: number of buffers to be released
  2476. *
  2477. * @info: pointer to wdi buffers info array
  2478. *
  2479. * Return codes: 0 : success
  2480. * negative : error
  2481. */
  2482. int ipa_release_wdi_mapping(u32 num_buffers, struct ipa_wdi_buffer_info *info)
  2483. {
  2484. int ret;
  2485. IPA_API_DISPATCH_RETURN(ipa_release_wdi_mapping, num_buffers, info);
  2486. return ret;
  2487. }
  2488. EXPORT_SYMBOL(ipa_release_wdi_mapping);
  2489. /**
  2490. * ipa_create_wdi_mapping() - Perform iommu mapping
  2491. *
  2492. *
  2493. * @num_buffers: number of buffers to be mapped
  2494. *
  2495. * @info: pointer to wdi buffers info array
  2496. *
  2497. * Return codes: 0 : success
  2498. * negative : error
  2499. */
  2500. int ipa_create_wdi_mapping(u32 num_buffers, struct ipa_wdi_buffer_info *info)
  2501. {
  2502. int ret;
  2503. IPA_API_DISPATCH_RETURN(ipa_create_wdi_mapping, num_buffers, info);
  2504. return ret;
  2505. }
  2506. EXPORT_SYMBOL(ipa_create_wdi_mapping);
  2507. /**
  2508. * ipa_get_gsi_ep_info() - provide gsi ep information
  2509. * @client: IPA client type
  2510. *
  2511. * Return value: pointer to ipa_gsi_ep_info
  2512. */
  2513. const struct ipa_gsi_ep_config *ipa_get_gsi_ep_info(enum ipa_client_type client)
  2514. {
  2515. if (!ipa_api_ctrl || !ipa_api_ctrl->ipa_get_gsi_ep_info)
  2516. return NULL;
  2517. return ipa_api_ctrl->ipa_get_gsi_ep_info(client);
  2518. }
  2519. EXPORT_SYMBOL(ipa_get_gsi_ep_info);
  2520. /**
  2521. * ipa_stop_gsi_channel()- Stops a GSI channel in IPA
  2522. *
  2523. * Return value: 0 on success, negative otherwise
  2524. */
  2525. int ipa_stop_gsi_channel(u32 clnt_hdl)
  2526. {
  2527. int ret;
  2528. IPA_API_DISPATCH_RETURN(ipa_stop_gsi_channel, clnt_hdl);
  2529. return ret;
  2530. }
  2531. EXPORT_SYMBOL(ipa_stop_gsi_channel);
  2532. /**
  2533. * ipa_start_gsi_channel()- Startsa GSI channel in IPA
  2534. *
  2535. * Return value: 0 on success, negative otherwise
  2536. */
  2537. int ipa_start_gsi_channel(u32 clnt_hdl)
  2538. {
  2539. int ret;
  2540. IPA_API_DISPATCH_RETURN(ipa_start_gsi_channel, clnt_hdl);
  2541. return ret;
  2542. }
  2543. EXPORT_SYMBOL(ipa_start_gsi_channel);
  2544. /**
  2545. * ipa_is_vlan_mode - check if a LAN driver should load in VLAN mode
  2546. * @iface - type of vlan capable device
  2547. * @res - query result: true for vlan mode, false for non vlan mode
  2548. *
  2549. * API must be called after ipa_is_ready() returns true, otherwise it will fail
  2550. *
  2551. * Returns: 0 on success, negative on failure
  2552. */
  2553. int ipa_is_vlan_mode(enum ipa_vlan_ifaces iface, bool *res)
  2554. {
  2555. int ret;
  2556. IPA_API_DISPATCH_RETURN(ipa_is_vlan_mode, iface, res);
  2557. return ret;
  2558. }
  2559. EXPORT_SYMBOL(ipa_is_vlan_mode);
  2560. /**
  2561. * ipa_get_version_string() - Get string representation of IPA version
  2562. * @ver: IPA version
  2563. *
  2564. * Return: Constant string representation
  2565. */
  2566. const char *ipa_get_version_string(enum ipa_hw_type ver)
  2567. {
  2568. const char *str;
  2569. switch (ver) {
  2570. case IPA_HW_v1_0:
  2571. str = "1.0";
  2572. break;
  2573. case IPA_HW_v1_1:
  2574. str = "1.1";
  2575. break;
  2576. case IPA_HW_v2_0:
  2577. str = "2.0";
  2578. break;
  2579. case IPA_HW_v2_1:
  2580. str = "2.1";
  2581. break;
  2582. case IPA_HW_v2_5:
  2583. str = "2.5/2.6";
  2584. break;
  2585. case IPA_HW_v2_6L:
  2586. str = "2.6L";
  2587. break;
  2588. case IPA_HW_v3_0:
  2589. str = "3.0";
  2590. break;
  2591. case IPA_HW_v3_1:
  2592. str = "3.1";
  2593. break;
  2594. case IPA_HW_v3_5:
  2595. str = "3.5";
  2596. break;
  2597. case IPA_HW_v3_5_1:
  2598. str = "3.5.1";
  2599. break;
  2600. case IPA_HW_v4_0:
  2601. str = "4.0";
  2602. break;
  2603. case IPA_HW_v4_1:
  2604. str = "4.1";
  2605. break;
  2606. case IPA_HW_v4_2:
  2607. str = "4.2";
  2608. break;
  2609. case IPA_HW_v4_5:
  2610. str = "4.5";
  2611. break;
  2612. case IPA_HW_v4_7:
  2613. str = "4.7";
  2614. break;
  2615. case IPA_HW_v4_9:
  2616. str = "4.9";
  2617. break;
  2618. default:
  2619. str = "Invalid version";
  2620. break;
  2621. }
  2622. return str;
  2623. }
  2624. EXPORT_SYMBOL(ipa_get_version_string);
  2625. static const struct of_device_id ipa_plat_drv_match[] = {
  2626. { .compatible = "qcom,ipa", },
  2627. { .compatible = "qcom,ipa-smmu-ap-cb", },
  2628. { .compatible = "qcom,ipa-smmu-wlan-cb", },
  2629. { .compatible = "qcom,ipa-smmu-uc-cb", },
  2630. { .compatible = "qcom,ipa-smmu-11ad-cb", },
  2631. { .compatible = "qcom,smp2p-map-ipa-1-in", },
  2632. { .compatible = "qcom,smp2p-map-ipa-1-out", },
  2633. {}
  2634. };
  2635. /*********************************************************/
  2636. /* PCIe Version */
  2637. /*********************************************************/
  2638. static const struct of_device_id ipa_pci_drv_match[] = {
  2639. { .compatible = "qcom,ipa", },
  2640. {}
  2641. };
  2642. /*
  2643. * Forward declarations of static functions required for PCI
  2644. * registraion
  2645. *
  2646. * VENDOR and DEVICE should be defined in pci_ids.h
  2647. */
  2648. static int ipa_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
  2649. static void ipa_pci_remove(struct pci_dev *pdev);
  2650. static void ipa_pci_shutdown(struct pci_dev *pdev);
  2651. static pci_ers_result_t ipa_pci_io_error_detected(struct pci_dev *dev,
  2652. pci_channel_state_t state);
  2653. static pci_ers_result_t ipa_pci_io_slot_reset(struct pci_dev *dev);
  2654. static void ipa_pci_io_resume(struct pci_dev *dev);
  2655. #define LOCAL_VENDOR 0x17CB
  2656. #define LOCAL_DEVICE 0x00ff
  2657. static const char ipa_pci_driver_name[] = "qcipav3";
  2658. static const struct pci_device_id ipa_pci_tbl[] = {
  2659. { PCI_DEVICE(LOCAL_VENDOR, LOCAL_DEVICE) },
  2660. { 0, 0, 0, 0, 0, 0, 0 }
  2661. };
  2662. MODULE_DEVICE_TABLE(pci, ipa_pci_tbl);
  2663. /* PCI Error Recovery */
  2664. static const struct pci_error_handlers ipa_pci_err_handler = {
  2665. .error_detected = ipa_pci_io_error_detected,
  2666. .slot_reset = ipa_pci_io_slot_reset,
  2667. .resume = ipa_pci_io_resume,
  2668. };
  2669. static struct pci_driver ipa_pci_driver = {
  2670. .name = ipa_pci_driver_name,
  2671. .id_table = ipa_pci_tbl,
  2672. .probe = ipa_pci_probe,
  2673. .remove = ipa_pci_remove,
  2674. .shutdown = ipa_pci_shutdown,
  2675. .err_handler = &ipa_pci_err_handler
  2676. };
  2677. static int ipa_generic_plat_drv_probe(struct platform_device *pdev_p)
  2678. {
  2679. int result;
  2680. /*
  2681. * IPA probe function can be called for multiple times as the same probe
  2682. * function handles multiple compatibilities
  2683. */
  2684. pr_debug("ipa: IPA driver probing started for %s\n",
  2685. pdev_p->dev.of_node->name);
  2686. if (!ipa_api_ctrl) {
  2687. ipa_api_ctrl = kzalloc(sizeof(*ipa_api_ctrl), GFP_KERNEL);
  2688. if (!ipa_api_ctrl)
  2689. return -ENOMEM;
  2690. /* Get IPA HW Version */
  2691. result = of_property_read_u32(pdev_p->dev.of_node,
  2692. "qcom,ipa-hw-ver", &ipa_api_hw_type);
  2693. if ((result) || (ipa_api_hw_type == 0)) {
  2694. pr_err("ipa: get resource failed for ipa-hw-ver!\n");
  2695. kfree(ipa_api_ctrl);
  2696. ipa_api_ctrl = 0;
  2697. return -ENODEV;
  2698. }
  2699. pr_debug("ipa: ipa_api_hw_type = %d\n", ipa_api_hw_type);
  2700. }
  2701. /* call probe based on IPA HW version */
  2702. switch (ipa_api_hw_type) {
  2703. case IPA_HW_v3_0:
  2704. case IPA_HW_v3_1:
  2705. case IPA_HW_v3_5:
  2706. case IPA_HW_v3_5_1:
  2707. case IPA_HW_v4_0:
  2708. case IPA_HW_v4_1:
  2709. case IPA_HW_v4_2:
  2710. case IPA_HW_v4_5:
  2711. case IPA_HW_v4_7:
  2712. case IPA_HW_v4_9:
  2713. result = ipa3_plat_drv_probe(pdev_p, ipa_api_ctrl,
  2714. ipa_plat_drv_match);
  2715. break;
  2716. default:
  2717. pr_err("ipa: unsupported version %d\n", ipa_api_hw_type);
  2718. return -EPERM;
  2719. }
  2720. if (result && result != -EPROBE_DEFER)
  2721. pr_err("ipa: ipa_plat_drv_probe failed\n");
  2722. return result;
  2723. }
  2724. static int ipa_ap_suspend(struct device *dev)
  2725. {
  2726. int ret;
  2727. IPA_API_DISPATCH_RETURN(ipa_ap_suspend, dev);
  2728. return ret;
  2729. }
  2730. static int ipa_ap_resume(struct device *dev)
  2731. {
  2732. int ret;
  2733. IPA_API_DISPATCH_RETURN(ipa_ap_resume, dev);
  2734. return ret;
  2735. }
  2736. int ipa_register_ipa_ready_cb(void (*ipa_ready_cb)(void *user_data),
  2737. void *user_data)
  2738. {
  2739. int ret;
  2740. IPA_API_DISPATCH_RETURN(ipa_register_ipa_ready_cb,
  2741. ipa_ready_cb, user_data);
  2742. return ret;
  2743. }
  2744. EXPORT_SYMBOL(ipa_register_ipa_ready_cb);
  2745. /**
  2746. * ipa_inc_client_enable_clks() - Increase active clients counter, and
  2747. * enable ipa clocks if necessary
  2748. *
  2749. * Please do not use this API, use the wrapper macros instead (ipa_i.h)
  2750. * IPA_ACTIVE_CLIENTS_INC_XXX();
  2751. *
  2752. * Return codes:
  2753. * None
  2754. */
  2755. void ipa_inc_client_enable_clks(struct ipa_active_client_logging_info *id)
  2756. {
  2757. IPA_API_DISPATCH(ipa_inc_client_enable_clks, id);
  2758. }
  2759. EXPORT_SYMBOL(ipa_inc_client_enable_clks);
  2760. /**
  2761. * ipa_dec_client_disable_clks() - Increase active clients counter, and
  2762. * enable ipa clocks if necessary
  2763. *
  2764. * Please do not use this API, use the wrapper macros instead (ipa_i.h)
  2765. * IPA_ACTIVE_CLIENTS_DEC_XXX();
  2766. *
  2767. * Return codes:
  2768. * None
  2769. */
  2770. void ipa_dec_client_disable_clks(struct ipa_active_client_logging_info *id)
  2771. {
  2772. IPA_API_DISPATCH(ipa_dec_client_disable_clks, id);
  2773. }
  2774. EXPORT_SYMBOL(ipa_dec_client_disable_clks);
  2775. /**
  2776. * ipa_inc_client_enable_clks_no_block() - Only increment the number of active
  2777. * clients if no asynchronous actions should be done.Asynchronous actions are
  2778. * locking a mutex and waking up IPA HW.
  2779. *
  2780. * Please do not use this API, use the wrapper macros instead(ipa_i.h)
  2781. *
  2782. *
  2783. * Return codes : 0 for success
  2784. * -EPERM if an asynchronous action should have been done
  2785. */
  2786. int ipa_inc_client_enable_clks_no_block(
  2787. struct ipa_active_client_logging_info *id)
  2788. {
  2789. int ret;
  2790. IPA_API_DISPATCH_RETURN(ipa_inc_client_enable_clks_no_block, id);
  2791. return ret;
  2792. }
  2793. EXPORT_SYMBOL(ipa_inc_client_enable_clks_no_block);
  2794. /**
  2795. * ipa_suspend_resource_no_block() - suspend client endpoints related to the
  2796. * IPA_RM resource and decrement active clients counter. This function is
  2797. * guaranteed to avoid sleeping.
  2798. *
  2799. * @resource: [IN] IPA Resource Manager resource
  2800. *
  2801. * Return codes: 0 on success, negative on failure.
  2802. */
  2803. int ipa_suspend_resource_no_block(enum ipa_rm_resource_name resource)
  2804. {
  2805. int ret;
  2806. IPA_API_DISPATCH_RETURN(ipa_suspend_resource_no_block, resource);
  2807. return ret;
  2808. }
  2809. EXPORT_SYMBOL(ipa_suspend_resource_no_block);
  2810. /**
  2811. * ipa_resume_resource() - resume client endpoints related to the IPA_RM
  2812. * resource.
  2813. *
  2814. * @resource: [IN] IPA Resource Manager resource
  2815. *
  2816. * Return codes: 0 on success, negative on failure.
  2817. */
  2818. int ipa_resume_resource(enum ipa_rm_resource_name resource)
  2819. {
  2820. int ret;
  2821. IPA_API_DISPATCH_RETURN(ipa_resume_resource, resource);
  2822. return ret;
  2823. }
  2824. EXPORT_SYMBOL(ipa_resume_resource);
  2825. /**
  2826. * ipa_suspend_resource_sync() - suspend client endpoints related to the IPA_RM
  2827. * resource and decrement active clients counter, which may result in clock
  2828. * gating of IPA clocks.
  2829. *
  2830. * @resource: [IN] IPA Resource Manager resource
  2831. *
  2832. * Return codes: 0 on success, negative on failure.
  2833. */
  2834. int ipa_suspend_resource_sync(enum ipa_rm_resource_name resource)
  2835. {
  2836. int ret;
  2837. IPA_API_DISPATCH_RETURN(ipa_suspend_resource_sync, resource);
  2838. return ret;
  2839. }
  2840. EXPORT_SYMBOL(ipa_suspend_resource_sync);
  2841. /**
  2842. * ipa_set_required_perf_profile() - set IPA to the specified performance
  2843. * profile based on the bandwidth, unless minimum voltage required is
  2844. * higher. In this case the floor_voltage specified will be used.
  2845. * @floor_voltage: minimum voltage to operate
  2846. * @bandwidth_mbps: needed bandwidth from IPA
  2847. *
  2848. * Return codes: 0 on success, negative on failure.
  2849. */
  2850. int ipa_set_required_perf_profile(enum ipa_voltage_level floor_voltage,
  2851. u32 bandwidth_mbps)
  2852. {
  2853. int ret;
  2854. IPA_API_DISPATCH_RETURN(ipa_set_required_perf_profile, floor_voltage,
  2855. bandwidth_mbps);
  2856. return ret;
  2857. }
  2858. EXPORT_SYMBOL(ipa_set_required_perf_profile);
  2859. /**
  2860. * ipa_get_ipc_logbuf() - return a pointer to IPA driver IPC log
  2861. */
  2862. void *ipa_get_ipc_logbuf(void)
  2863. {
  2864. void *ret;
  2865. IPA_API_DISPATCH_RETURN_PTR(ipa_get_ipc_logbuf);
  2866. return ret;
  2867. }
  2868. EXPORT_SYMBOL(ipa_get_ipc_logbuf);
  2869. /**
  2870. * ipa_get_ipc_logbuf_low() - return a pointer to IPA driver IPC low prio log
  2871. */
  2872. void *ipa_get_ipc_logbuf_low(void)
  2873. {
  2874. void *ret;
  2875. IPA_API_DISPATCH_RETURN_PTR(ipa_get_ipc_logbuf_low);
  2876. return ret;
  2877. }
  2878. EXPORT_SYMBOL(ipa_get_ipc_logbuf_low);
  2879. /**
  2880. * ipa_assert() - general function for assertion
  2881. */
  2882. void ipa_assert(void)
  2883. {
  2884. pr_err("IPA: unrecoverable error has occurred, asserting\n");
  2885. BUG();
  2886. }
  2887. EXPORT_SYMBOL(ipa_assert);
  2888. /**
  2889. * ipa_rx_poll() - Poll the rx packets from IPA HW in the
  2890. * softirq context
  2891. *
  2892. * @budget: number of packets to be polled in single iteration
  2893. *
  2894. * Return codes: >= 0 : Actual number of packets polled
  2895. *
  2896. */
  2897. int ipa_rx_poll(u32 clnt_hdl, int budget)
  2898. {
  2899. int ret;
  2900. IPA_API_DISPATCH_RETURN(ipa_rx_poll, clnt_hdl, budget);
  2901. return ret;
  2902. }
  2903. EXPORT_SYMBOL(ipa_rx_poll);
  2904. /**
  2905. * ipa_recycle_wan_skb() - Recycle the Wan skb
  2906. *
  2907. * @skb: skb that needs to recycle
  2908. *
  2909. */
  2910. void ipa_recycle_wan_skb(struct sk_buff *skb)
  2911. {
  2912. IPA_API_DISPATCH(ipa_recycle_wan_skb, skb);
  2913. }
  2914. EXPORT_SYMBOL(ipa_recycle_wan_skb);
  2915. /**
  2916. * ipa_setup_uc_ntn_pipes() - setup uc offload pipes
  2917. */
  2918. int ipa_setup_uc_ntn_pipes(struct ipa_ntn_conn_in_params *inp,
  2919. ipa_notify_cb notify, void *priv, u8 hdr_len,
  2920. struct ipa_ntn_conn_out_params *outp)
  2921. {
  2922. int ret;
  2923. IPA_API_DISPATCH_RETURN(ipa_setup_uc_ntn_pipes, inp,
  2924. notify, priv, hdr_len, outp);
  2925. return ret;
  2926. }
  2927. /**
  2928. * ipa_tear_down_uc_offload_pipes() - tear down uc offload pipes
  2929. */
  2930. int ipa_tear_down_uc_offload_pipes(int ipa_ep_idx_ul,
  2931. int ipa_ep_idx_dl, struct ipa_ntn_conn_in_params *params)
  2932. {
  2933. int ret;
  2934. IPA_API_DISPATCH_RETURN(ipa_tear_down_uc_offload_pipes, ipa_ep_idx_ul,
  2935. ipa_ep_idx_dl, params);
  2936. return ret;
  2937. }
  2938. /**
  2939. * ipa_get_pdev() - return a pointer to IPA dev struct
  2940. *
  2941. * Return value: a pointer to IPA dev struct
  2942. *
  2943. */
  2944. struct device *ipa_get_pdev(void)
  2945. {
  2946. struct device *ret;
  2947. IPA_API_DISPATCH_RETURN_PTR(ipa_get_pdev);
  2948. return ret;
  2949. }
  2950. EXPORT_SYMBOL(ipa_get_pdev);
  2951. int ipa_ntn_uc_reg_rdyCB(void (*ipauc_ready_cb)(void *user_data),
  2952. void *user_data)
  2953. {
  2954. int ret;
  2955. IPA_API_DISPATCH_RETURN(ipa_ntn_uc_reg_rdyCB,
  2956. ipauc_ready_cb, user_data);
  2957. return ret;
  2958. }
  2959. EXPORT_SYMBOL(ipa_ntn_uc_reg_rdyCB);
  2960. void ipa_ntn_uc_dereg_rdyCB(void)
  2961. {
  2962. IPA_API_DISPATCH(ipa_ntn_uc_dereg_rdyCB);
  2963. }
  2964. EXPORT_SYMBOL(ipa_ntn_uc_dereg_rdyCB);
  2965. int ipa_get_smmu_params(struct ipa_smmu_in_params *in,
  2966. struct ipa_smmu_out_params *out)
  2967. {
  2968. int ret;
  2969. IPA_API_DISPATCH_RETURN(ipa_get_smmu_params, in, out);
  2970. return ret;
  2971. }
  2972. EXPORT_SYMBOL(ipa_get_smmu_params);
  2973. /**
  2974. * ipa_conn_wdi_pipes() - connect wdi pipes
  2975. */
  2976. int ipa_conn_wdi_pipes(struct ipa_wdi_conn_in_params *in,
  2977. struct ipa_wdi_conn_out_params *out,
  2978. ipa_wdi_meter_notifier_cb wdi_notify)
  2979. {
  2980. int ret;
  2981. IPA_API_DISPATCH_RETURN(ipa_conn_wdi_pipes, in, out, wdi_notify);
  2982. return ret;
  2983. }
  2984. /**
  2985. * ipa_disconn_wdi_pipes() - disconnect wdi pipes
  2986. */
  2987. int ipa_disconn_wdi_pipes(int ipa_ep_idx_tx, int ipa_ep_idx_rx)
  2988. {
  2989. int ret;
  2990. IPA_API_DISPATCH_RETURN(ipa_disconn_wdi_pipes, ipa_ep_idx_tx,
  2991. ipa_ep_idx_rx);
  2992. return ret;
  2993. }
  2994. /**
  2995. * ipa_enable_wdi_pipes() - enable wdi pipes
  2996. */
  2997. int ipa_enable_wdi_pipes(int ipa_ep_idx_tx, int ipa_ep_idx_rx)
  2998. {
  2999. int ret;
  3000. IPA_API_DISPATCH_RETURN(ipa_enable_wdi_pipes, ipa_ep_idx_tx,
  3001. ipa_ep_idx_rx);
  3002. return ret;
  3003. }
  3004. /**
  3005. * ipa_disable_wdi_pipes() - disable wdi pipes
  3006. */
  3007. int ipa_disable_wdi_pipes(int ipa_ep_idx_tx, int ipa_ep_idx_rx)
  3008. {
  3009. int ret;
  3010. IPA_API_DISPATCH_RETURN(ipa_disable_wdi_pipes, ipa_ep_idx_tx,
  3011. ipa_ep_idx_rx);
  3012. return ret;
  3013. }
  3014. /**
  3015. * ipa_wigig_uc_msi_init() - smmu map\unmap msi related wigig HW registers
  3016. * and init\deinit uC msi config
  3017. */
  3018. int ipa_wigig_uc_msi_init(bool init,
  3019. phys_addr_t periph_baddr_pa,
  3020. phys_addr_t pseudo_cause_pa,
  3021. phys_addr_t int_gen_tx_pa,
  3022. phys_addr_t int_gen_rx_pa,
  3023. phys_addr_t dma_ep_misc_pa)
  3024. {
  3025. int ret;
  3026. IPA_API_DISPATCH_RETURN(ipa_wigig_uc_msi_init, init,
  3027. periph_baddr_pa,
  3028. pseudo_cause_pa,
  3029. int_gen_tx_pa,
  3030. int_gen_rx_pa,
  3031. dma_ep_misc_pa);
  3032. return ret;
  3033. }
  3034. EXPORT_SYMBOL(ipa_wigig_uc_msi_init);
  3035. /**
  3036. * ipa_conn_wigig_rx_pipe_i() - connect wigig rx pipe
  3037. */
  3038. int ipa_conn_wigig_rx_pipe_i(void *in, struct ipa_wigig_conn_out_params *out,
  3039. struct dentry **parent)
  3040. {
  3041. int ret;
  3042. IPA_API_DISPATCH_RETURN(ipa_conn_wigig_rx_pipe_i, in, out, parent);
  3043. return ret;
  3044. }
  3045. EXPORT_SYMBOL(ipa_conn_wigig_rx_pipe_i);
  3046. /**
  3047. * ipa_conn_wigig_client_i() - connect a wigig client
  3048. */
  3049. int ipa_conn_wigig_client_i(void *in,
  3050. struct ipa_wigig_conn_out_params *out,
  3051. ipa_notify_cb tx_notify,
  3052. void *priv)
  3053. {
  3054. int ret;
  3055. IPA_API_DISPATCH_RETURN(ipa_conn_wigig_client_i, in, out,
  3056. tx_notify, priv);
  3057. return ret;
  3058. }
  3059. EXPORT_SYMBOL(ipa_conn_wigig_client_i);
  3060. /**
  3061. * ipa_disconn_wigig_pipe_i() - disconnect a wigig pipe
  3062. */
  3063. int ipa_disconn_wigig_pipe_i(enum ipa_client_type client,
  3064. struct ipa_wigig_pipe_setup_info_smmu *pipe_smmu,
  3065. void *dbuff)
  3066. {
  3067. int ret;
  3068. IPA_API_DISPATCH_RETURN(ipa_disconn_wigig_pipe_i, client,
  3069. pipe_smmu, dbuff);
  3070. return ret;
  3071. }
  3072. EXPORT_SYMBOL(ipa_disconn_wigig_pipe_i);
  3073. /**
  3074. * ipa_enable_wigig_pipe() - enable a wigig pipe
  3075. */
  3076. int ipa_enable_wigig_pipe_i(enum ipa_client_type client)
  3077. {
  3078. int ret;
  3079. IPA_API_DISPATCH_RETURN(ipa_enable_wigig_pipe_i, client);
  3080. return ret;
  3081. }
  3082. EXPORT_SYMBOL(ipa_enable_wigig_pipe_i);
  3083. /**
  3084. * ipa_disable_wigig_pipe_i() - disable a wigig pipe
  3085. */
  3086. int ipa_disable_wigig_pipe_i(enum ipa_client_type client)
  3087. {
  3088. int ret;
  3089. IPA_API_DISPATCH_RETURN(ipa_disable_wigig_pipe_i, client);
  3090. return ret;
  3091. }
  3092. EXPORT_SYMBOL(ipa_disable_wigig_pipe_i);
  3093. /**
  3094. * ipa_get_lan_rx_napi() - returns if NAPI is enabled in LAN RX
  3095. */
  3096. bool ipa_get_lan_rx_napi(void)
  3097. {
  3098. bool ret;
  3099. IPA_API_DISPATCH_RETURN_BOOL(ipa_get_lan_rx_napi);
  3100. return ret;
  3101. }
  3102. EXPORT_SYMBOL(ipa_get_lan_rx_napi);
  3103. /**
  3104. * ipa_tz_unlock_reg() - Allow AP access to memory regions controlled by TZ
  3105. */
  3106. int ipa_tz_unlock_reg(struct ipa_tz_unlock_reg_info *reg_info, u16 num_regs)
  3107. {
  3108. int ret;
  3109. IPA_API_DISPATCH_RETURN(ipa_tz_unlock_reg, reg_info, num_regs);
  3110. return ret;
  3111. }
  3112. void ipa_register_client_callback(int (*client_cb)(bool is_lock),
  3113. bool (*teth_port_state)(void),
  3114. enum ipa_client_type client)
  3115. {
  3116. IPA_API_DISPATCH(ipa_register_client_callback,
  3117. client_cb, teth_port_state, client);
  3118. }
  3119. EXPORT_SYMBOL(ipa_register_client_callback);
  3120. void ipa_deregister_client_callback(enum ipa_client_type client)
  3121. {
  3122. IPA_API_DISPATCH(ipa_deregister_client_callback,
  3123. client);
  3124. }
  3125. EXPORT_SYMBOL(ipa_deregister_client_callback);
  3126. int ipa_uc_debug_stats_alloc(
  3127. struct IpaHwOffloadStatsAllocCmdData_t cmdinfo)
  3128. {
  3129. int ret;
  3130. IPA_API_DISPATCH_RETURN(ipa_uc_debug_stats_alloc, cmdinfo);
  3131. return ret;
  3132. }
  3133. EXPORT_SYMBOL(ipa_uc_debug_stats_alloc);
  3134. int ipa_uc_debug_stats_dealloc(uint32_t prot_id)
  3135. {
  3136. int ret;
  3137. IPA_API_DISPATCH_RETURN(ipa_uc_debug_stats_dealloc, prot_id);
  3138. return ret;
  3139. }
  3140. EXPORT_SYMBOL(ipa_uc_debug_stats_dealloc);
  3141. void ipa_get_gsi_stats(int prot_id,
  3142. struct ipa_uc_dbg_ring_stats *stats)
  3143. {
  3144. IPA_API_DISPATCH(ipa_get_gsi_stats,
  3145. prot_id, stats);
  3146. }
  3147. EXPORT_SYMBOL(ipa_get_gsi_stats);
  3148. int ipa_get_prot_id(enum ipa_client_type client)
  3149. {
  3150. int ret;
  3151. IPA_API_DISPATCH_RETURN(ipa_get_prot_id,
  3152. client);
  3153. return ret;
  3154. }
  3155. EXPORT_SYMBOL(ipa_get_prot_id);
  3156. static const struct dev_pm_ops ipa_pm_ops = {
  3157. .suspend_noirq = ipa_ap_suspend,
  3158. .resume_noirq = ipa_ap_resume,
  3159. };
  3160. static struct platform_driver ipa_plat_drv = {
  3161. .probe = ipa_generic_plat_drv_probe,
  3162. .driver = {
  3163. .name = DRV_NAME,
  3164. .pm = &ipa_pm_ops,
  3165. .of_match_table = ipa_plat_drv_match,
  3166. },
  3167. };
  3168. /*********************************************************/
  3169. /* PCIe Version */
  3170. /*********************************************************/
  3171. static int ipa_pci_probe(
  3172. struct pci_dev *pci_dev,
  3173. const struct pci_device_id *ent)
  3174. {
  3175. int result;
  3176. if (!pci_dev || !ent) {
  3177. pr_err(
  3178. "Bad arg: pci_dev (%pK) and/or ent (%pK)\n",
  3179. pci_dev, ent);
  3180. return -EOPNOTSUPP;
  3181. }
  3182. if (!ipa_api_ctrl) {
  3183. ipa_api_ctrl = kzalloc(sizeof(*ipa_api_ctrl), GFP_KERNEL);
  3184. if (ipa_api_ctrl == NULL)
  3185. return -ENOMEM;
  3186. /* Get IPA HW Version */
  3187. result = of_property_read_u32(NULL,
  3188. "qcom,ipa-hw-ver", &ipa_api_hw_type);
  3189. if (result || ipa_api_hw_type == 0) {
  3190. pr_err("ipa: get resource failed for ipa-hw-ver!\n");
  3191. kfree(ipa_api_ctrl);
  3192. ipa_api_ctrl = NULL;
  3193. return -ENODEV;
  3194. }
  3195. pr_debug("ipa: ipa_api_hw_type = %d\n", ipa_api_hw_type);
  3196. }
  3197. /*
  3198. * Call a reduced version of platform_probe appropriate for PCIe
  3199. */
  3200. result = ipa3_pci_drv_probe(pci_dev, ipa_api_ctrl, ipa_pci_drv_match);
  3201. if (result && result != -EPROBE_DEFER)
  3202. pr_err("ipa: ipa3_pci_drv_probe failed\n");
  3203. return result;
  3204. }
  3205. static void ipa_pci_remove(struct pci_dev *pci_dev)
  3206. {
  3207. }
  3208. static void ipa_pci_shutdown(struct pci_dev *pci_dev)
  3209. {
  3210. }
  3211. static pci_ers_result_t ipa_pci_io_error_detected(struct pci_dev *pci_dev,
  3212. pci_channel_state_t state)
  3213. {
  3214. return 0;
  3215. }
  3216. static pci_ers_result_t ipa_pci_io_slot_reset(struct pci_dev *pci_dev)
  3217. {
  3218. return 0;
  3219. }
  3220. static void ipa_pci_io_resume(struct pci_dev *pci_dev)
  3221. {
  3222. }
  3223. static int __init ipa_module_init(void)
  3224. {
  3225. pr_debug("IPA module init\n");
  3226. if (running_emulation) {
  3227. /* Register as a PCI device driver */
  3228. return pci_register_driver(&ipa_pci_driver);
  3229. }
  3230. /* Register as a platform device driver */
  3231. return platform_driver_register(&ipa_plat_drv);
  3232. }
  3233. subsys_initcall(ipa_module_init);
  3234. static void __exit ipa_module_exit(void)
  3235. {
  3236. if (running_emulation)
  3237. pci_unregister_driver(&ipa_pci_driver);
  3238. platform_driver_unregister(&ipa_plat_drv);
  3239. }
  3240. module_exit(ipa_module_exit);
  3241. MODULE_SOFTDEP("pre: subsys-pil-tz");
  3242. MODULE_SOFTDEP("pre: qcom-arm-smmu-mod");
  3243. MODULE_LICENSE("GPL v2");
  3244. MODULE_DESCRIPTION("IPA HW device driver");