ipa_api.c 85 KB

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