ipa_api.c 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #include "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 "ipa_uc_offload.h"
  14. #include <linux/pci.h>
  15. #include "ipa_api.h"
  16. #include "ipa_i.h"
  17. /*
  18. * The following for adding code (ie. for EMULATION) not found on x86.
  19. */
  20. #if defined(CONFIG_IPA_EMULATION)
  21. # include "ipa_emulation_stubs.h"
  22. #endif
  23. #define DRV_NAME "ipa"
  24. #define IPA_API_DISPATCH_RETURN(api, p...) \
  25. do { \
  26. if (!ipa_api_ctrl) { \
  27. pr_err("%s:%d IPA HW is not supported\n", \
  28. __func__, __LINE__); \
  29. ret = -EPERM; \
  30. } \
  31. else { \
  32. if (ipa_api_ctrl->api) { \
  33. ret = ipa_api_ctrl->api(p); \
  34. } else { \
  35. WARN(1, \
  36. "%s not implemented for IPA ver %d\n", \
  37. __func__, ipa_api_hw_type); \
  38. ret = -EPERM; \
  39. } \
  40. } \
  41. } while (0)
  42. #define IPA_API_DISPATCH(api, p...) \
  43. do { \
  44. if (!ipa_api_ctrl) \
  45. pr_err("%s:%d IPA HW is not supported\n", \
  46. __func__, __LINE__); \
  47. else { \
  48. if (ipa_api_ctrl->api) { \
  49. ipa_api_ctrl->api(p); \
  50. } else { \
  51. WARN(1, \
  52. "%s not implemented for IPA ver %d\n",\
  53. __func__, ipa_api_hw_type); \
  54. } \
  55. } \
  56. } while (0)
  57. #define IPA_API_DISPATCH_RETURN_PTR(api, p...) \
  58. do { \
  59. if (!ipa_api_ctrl) { \
  60. pr_err("%s:%d IPA HW is not supported\n", \
  61. __func__, __LINE__); \
  62. ret = NULL; \
  63. } \
  64. else { \
  65. if (ipa_api_ctrl->api) { \
  66. ret = ipa_api_ctrl->api(p); \
  67. } else { \
  68. WARN(1, "%s not implemented for IPA ver %d\n",\
  69. __func__, ipa_api_hw_type); \
  70. ret = NULL; \
  71. } \
  72. } \
  73. } while (0)
  74. #define IPA_API_DISPATCH_RETURN_BOOL(api, p...) \
  75. do { \
  76. if (!ipa_api_ctrl) { \
  77. pr_err("%s:%d IPA HW is not supported\n", \
  78. __func__, __LINE__); \
  79. ret = false; \
  80. } \
  81. else { \
  82. if (ipa_api_ctrl->api) { \
  83. ret = ipa_api_ctrl->api(p); \
  84. } else { \
  85. WARN(1, "%s not implemented for IPA ver %d\n",\
  86. __func__, ipa_api_hw_type); \
  87. ret = false; \
  88. } \
  89. } \
  90. } while (0)
  91. #if defined(CONFIG_IPA_EMULATION)
  92. static bool running_emulation = true;
  93. #else
  94. static bool running_emulation;
  95. #endif
  96. static enum ipa_hw_type ipa_api_hw_type;
  97. static struct ipa_api_controller *ipa_api_ctrl;
  98. const char *ipa_clients_strings[IPA_CLIENT_MAX] = {
  99. __stringify(IPA_CLIENT_HSIC1_PROD),
  100. __stringify(IPA_CLIENT_HSIC1_CONS),
  101. __stringify(IPA_CLIENT_HSIC2_PROD),
  102. __stringify(IPA_CLIENT_HSIC2_CONS),
  103. __stringify(IPA_CLIENT_HSIC3_PROD),
  104. __stringify(IPA_CLIENT_HSIC3_CONS),
  105. __stringify(IPA_CLIENT_HSIC4_PROD),
  106. __stringify(IPA_CLIENT_HSIC4_CONS),
  107. __stringify(IPA_CLIENT_HSIC5_PROD),
  108. __stringify(IPA_CLIENT_HSIC5_CONS),
  109. __stringify(IPA_CLIENT_WLAN1_PROD),
  110. __stringify(IPA_CLIENT_WLAN1_CONS),
  111. __stringify(IPA_CLIENT_WLAN2_PROD),
  112. __stringify(IPA_CLIENT_WLAN2_CONS),
  113. __stringify(RESERVED_PROD_14),
  114. __stringify(IPA_CLIENT_WLAN3_CONS),
  115. __stringify(RESERVED_PROD_16),
  116. __stringify(IPA_CLIENT_WLAN4_CONS),
  117. __stringify(IPA_CLIENT_USB_PROD),
  118. __stringify(IPA_CLIENT_USB_CONS),
  119. __stringify(IPA_CLIENT_USB2_PROD),
  120. __stringify(IPA_CLIENT_USB2_CONS),
  121. __stringify(IPA_CLIENT_USB3_PROD),
  122. __stringify(IPA_CLIENT_USB3_CONS),
  123. __stringify(IPA_CLIENT_USB4_PROD),
  124. __stringify(IPA_CLIENT_USB4_CONS),
  125. __stringify(IPA_CLIENT_UC_USB_PROD),
  126. __stringify(IPA_CLIENT_USB_DPL_CONS),
  127. __stringify(IPA_CLIENT_A2_EMBEDDED_PROD),
  128. __stringify(IPA_CLIENT_A2_EMBEDDED_CONS),
  129. __stringify(IPA_CLIENT_A2_TETHERED_PROD),
  130. __stringify(IPA_CLIENT_A2_TETHERED_CONS),
  131. __stringify(IPA_CLIENT_APPS_LAN_PROD),
  132. __stringify(IPA_CLIENT_APPS_LAN_CONS),
  133. __stringify(IPA_CLIENT_APPS_WAN_PROD),
  134. __stringify(IPA_CLIENT_APPS_WAN_CONS),
  135. __stringify(IPA_CLIENT_APPS_CMD_PROD),
  136. __stringify(IPA_CLIENT_A5_LAN_WAN_CONS),
  137. __stringify(IPA_CLIENT_ODU_PROD),
  138. __stringify(IPA_CLIENT_ODU_EMB_CONS),
  139. __stringify(RESERVED_PROD_40),
  140. __stringify(IPA_CLIENT_ODU_TETH_CONS),
  141. __stringify(IPA_CLIENT_MHI_PROD),
  142. __stringify(IPA_CLIENT_MHI_CONS),
  143. __stringify(IPA_CLIENT_MEMCPY_DMA_SYNC_PROD),
  144. __stringify(IPA_CLIENT_MEMCPY_DMA_SYNC_CONS),
  145. __stringify(IPA_CLIENT_MEMCPY_DMA_ASYNC_PROD),
  146. __stringify(IPA_CLIENT_MEMCPY_DMA_ASYNC_CONS),
  147. __stringify(IPA_CLIENT_ETHERNET_PROD),
  148. __stringify(IPA_CLIENT_ETHERNET_CONS),
  149. __stringify(IPA_CLIENT_Q6_LAN_PROD),
  150. __stringify(IPA_CLIENT_Q6_LAN_CONS),
  151. __stringify(IPA_CLIENT_Q6_WAN_PROD),
  152. __stringify(IPA_CLIENT_Q6_WAN_CONS),
  153. __stringify(IPA_CLIENT_Q6_CMD_PROD),
  154. __stringify(IPA_CLIENT_Q6_DUN_CONS),
  155. __stringify(IPA_CLIENT_Q6_DECOMP_PROD),
  156. __stringify(IPA_CLIENT_Q6_DECOMP_CONS),
  157. __stringify(IPA_CLIENT_Q6_DECOMP2_PROD),
  158. __stringify(IPA_CLIENT_Q6_DECOMP2_CONS),
  159. __stringify(RESERVED_PROD_60),
  160. __stringify(IPA_CLIENT_Q6_LTE_WIFI_AGGR_CONS),
  161. __stringify(IPA_CLIENT_TEST_PROD),
  162. __stringify(IPA_CLIENT_TEST_CONS),
  163. __stringify(IPA_CLIENT_TEST1_PROD),
  164. __stringify(IPA_CLIENT_TEST1_CONS),
  165. __stringify(IPA_CLIENT_TEST2_PROD),
  166. __stringify(IPA_CLIENT_TEST2_CONS),
  167. __stringify(IPA_CLIENT_TEST3_PROD),
  168. __stringify(IPA_CLIENT_TEST3_CONS),
  169. __stringify(IPA_CLIENT_TEST4_PROD),
  170. __stringify(IPA_CLIENT_TEST4_CONS),
  171. __stringify(RESERVED_PROD_72),
  172. __stringify(IPA_CLIENT_DUMMY_CONS),
  173. __stringify(IPA_CLIENT_Q6_DL_NLO_DATA_PROD),
  174. __stringify(IPA_CLIENT_Q6_UL_NLO_DATA_CONS),
  175. __stringify(RESERVED_PROD_76),
  176. __stringify(IPA_CLIENT_Q6_UL_NLO_ACK_CONS),
  177. __stringify(RESERVED_PROD_78),
  178. __stringify(IPA_CLIENT_Q6_QBAP_STATUS_CONS),
  179. __stringify(RESERVED_PROD_80),
  180. __stringify(IPA_CLIENT_MHI_DPL_CONS),
  181. __stringify(RESERVED_PROD_82),
  182. __stringify(IPA_CLIENT_ODL_DPL_CONS),
  183. __stringify(IPA_CLIENT_Q6_AUDIO_DMA_MHI_PROD),
  184. __stringify(IPA_CLIENT_Q6_AUDIO_DMA_MHI_CONS),
  185. __stringify(IPA_CLIENT_WIGIG_PROD),
  186. __stringify(IPA_CLIENT_WIGIG1_CONS),
  187. __stringify(RESERVERD_PROD_88),
  188. __stringify(IPA_CLIENT_WIGIG2_CONS),
  189. __stringify(RESERVERD_PROD_90),
  190. __stringify(IPA_CLIENT_WIGIG3_CONS),
  191. __stringify(RESERVERD_PROD_92),
  192. __stringify(IPA_CLIENT_WIGIG4_CONS),
  193. __stringify(RESERVERD_PROD_94),
  194. __stringify(IPA_CLIENT_APPS_WAN_COAL_CONS),
  195. __stringify(IPA_CLIENT_MHI_PRIME_RMNET_PROD),
  196. __stringify(IPA_CLIENT_MHI_PRIME_RMNET_CONS),
  197. __stringify(IPA_CLIENT_MHI_PRIME_TETH_PROD),
  198. __stringify(IPA_CLIENT_MHI_PRIME_TETH_CONS),
  199. __stringify(IPA_CLIENT_MHI_PRIME_DPL_PROD),
  200. __stringify(RESERVERD_CONS_101),
  201. __stringify(IPA_CLIENT_AQC_ETHERNET_PROD),
  202. __stringify(IPA_CLIENT_AQC_ETHERNET_CONS),
  203. __stringify(IPA_CLIENT_APPS_WAN_LOW_LAT_PROD),
  204. __stringify(IPA_CLIENT_APPS_WAN_LOW_LAT_CONS),
  205. };
  206. EXPORT_SYMBOL(ipa_clients_strings);
  207. /**
  208. * ipa_write_64() - convert 64 bit value to byte array
  209. * @w: 64 bit integer
  210. * @dest: byte array
  211. *
  212. * Return value: converted value
  213. */
  214. u8 *ipa_write_64(u64 w, u8 *dest)
  215. {
  216. if (unlikely(dest == NULL)) {
  217. pr_err("%s: NULL address\n", __func__);
  218. return dest;
  219. }
  220. *dest++ = (u8)((w) & 0xFF);
  221. *dest++ = (u8)((w >> 8) & 0xFF);
  222. *dest++ = (u8)((w >> 16) & 0xFF);
  223. *dest++ = (u8)((w >> 24) & 0xFF);
  224. *dest++ = (u8)((w >> 32) & 0xFF);
  225. *dest++ = (u8)((w >> 40) & 0xFF);
  226. *dest++ = (u8)((w >> 48) & 0xFF);
  227. *dest++ = (u8)((w >> 56) & 0xFF);
  228. return dest;
  229. }
  230. /**
  231. * ipa_write_32() - convert 32 bit value to byte array
  232. * @w: 32 bit integer
  233. * @dest: byte array
  234. *
  235. * Return value: converted value
  236. */
  237. u8 *ipa_write_32(u32 w, u8 *dest)
  238. {
  239. if (unlikely(dest == NULL)) {
  240. pr_err("%s: NULL address\n", __func__);
  241. return dest;
  242. }
  243. *dest++ = (u8)((w) & 0xFF);
  244. *dest++ = (u8)((w >> 8) & 0xFF);
  245. *dest++ = (u8)((w >> 16) & 0xFF);
  246. *dest++ = (u8)((w >> 24) & 0xFF);
  247. return dest;
  248. }
  249. /**
  250. * ipa_write_16() - convert 16 bit value to byte array
  251. * @hw: 16 bit integer
  252. * @dest: byte array
  253. *
  254. * Return value: converted value
  255. */
  256. u8 *ipa_write_16(u16 hw, u8 *dest)
  257. {
  258. if (unlikely(dest == NULL)) {
  259. pr_err("%s: NULL address\n", __func__);
  260. return dest;
  261. }
  262. *dest++ = (u8)((hw) & 0xFF);
  263. *dest++ = (u8)((hw >> 8) & 0xFF);
  264. return dest;
  265. }
  266. /**
  267. * ipa_write_8() - convert 8 bit value to byte array
  268. * @hw: 8 bit integer
  269. * @dest: byte array
  270. *
  271. * Return value: converted value
  272. */
  273. u8 *ipa_write_8(u8 b, u8 *dest)
  274. {
  275. if (unlikely(dest == NULL)) {
  276. WARN(1, "%s: NULL address\n", __func__);
  277. return dest;
  278. }
  279. *dest++ = (b) & 0xFF;
  280. return dest;
  281. }
  282. /**
  283. * ipa_pad_to_64() - pad byte array to 64 bit value
  284. * @dest: byte array
  285. *
  286. * Return value: padded value
  287. */
  288. u8 *ipa_pad_to_64(u8 *dest)
  289. {
  290. int i;
  291. int j;
  292. if (unlikely(dest == NULL)) {
  293. WARN(1, "%s: NULL address\n", __func__);
  294. return dest;
  295. }
  296. i = (long)dest & 0x7;
  297. if (i)
  298. for (j = 0; j < (8 - i); j++)
  299. *dest++ = 0;
  300. return dest;
  301. }
  302. /**
  303. * ipa_pad_to_32() - pad byte array to 32 bit value
  304. * @dest: byte array
  305. *
  306. * Return value: padded value
  307. */
  308. u8 *ipa_pad_to_32(u8 *dest)
  309. {
  310. int i;
  311. int j;
  312. if (unlikely(dest == NULL)) {
  313. WARN(1, "%s: NULL address\n", __func__);
  314. return dest;
  315. }
  316. i = (long)dest & 0x7;
  317. if (i)
  318. for (j = 0; j < (4 - i); j++)
  319. *dest++ = 0;
  320. return dest;
  321. }
  322. int ipa_smmu_store_sgt(struct sg_table **out_ch_ptr,
  323. struct sg_table *in_sgt_ptr)
  324. {
  325. unsigned int nents;
  326. if (in_sgt_ptr != NULL) {
  327. *out_ch_ptr = kzalloc(sizeof(struct sg_table), GFP_KERNEL);
  328. if (*out_ch_ptr == NULL)
  329. return -ENOMEM;
  330. nents = in_sgt_ptr->nents;
  331. (*out_ch_ptr)->sgl =
  332. kcalloc(nents, sizeof(struct scatterlist),
  333. GFP_KERNEL);
  334. if ((*out_ch_ptr)->sgl == NULL) {
  335. kfree(*out_ch_ptr);
  336. *out_ch_ptr = NULL;
  337. return -ENOMEM;
  338. }
  339. memcpy((*out_ch_ptr)->sgl, in_sgt_ptr->sgl,
  340. nents*sizeof((*out_ch_ptr)->sgl));
  341. (*out_ch_ptr)->nents = nents;
  342. (*out_ch_ptr)->orig_nents = in_sgt_ptr->orig_nents;
  343. }
  344. return 0;
  345. }
  346. EXPORT_SYMBOL(ipa_smmu_store_sgt);
  347. int ipa_smmu_free_sgt(struct sg_table **out_sgt_ptr)
  348. {
  349. if (*out_sgt_ptr != NULL) {
  350. kfree((*out_sgt_ptr)->sgl);
  351. (*out_sgt_ptr)->sgl = NULL;
  352. kfree(*out_sgt_ptr);
  353. *out_sgt_ptr = NULL;
  354. }
  355. return 0;
  356. }
  357. EXPORT_SYMBOL(ipa_smmu_free_sgt);
  358. /**
  359. * ipa_cfg_ep - IPA end-point configuration
  360. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  361. * @ipa_ep_cfg: [in] IPA end-point configuration params
  362. *
  363. * This includes nat, header, mode, aggregation and route settings and is a one
  364. * shot API to configure the IPA end-point fully
  365. *
  366. * Returns: 0 on success, negative on failure
  367. *
  368. * Note: Should not be called from atomic context
  369. */
  370. int ipa_cfg_ep(u32 clnt_hdl, const struct ipa_ep_cfg *ipa_ep_cfg)
  371. {
  372. int ret;
  373. IPA_API_DISPATCH_RETURN(ipa_cfg_ep, clnt_hdl, ipa_ep_cfg);
  374. return ret;
  375. }
  376. EXPORT_SYMBOL(ipa_cfg_ep);
  377. /**
  378. * ipa_cfg_ep_nat() - IPA end-point NAT configuration
  379. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  380. * @ep_nat: [in] IPA NAT end-point configuration params
  381. *
  382. * Returns: 0 on success, negative on failure
  383. *
  384. * Note: Should not be called from atomic context
  385. */
  386. int ipa_cfg_ep_nat(u32 clnt_hdl, const struct ipa_ep_cfg_nat *ep_nat)
  387. {
  388. int ret;
  389. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_nat, clnt_hdl, ep_nat);
  390. return ret;
  391. }
  392. EXPORT_SYMBOL(ipa_cfg_ep_nat);
  393. /**
  394. * ipa_cfg_ep_conn_track() - IPA end-point IPv6CT configuration
  395. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  396. * @ep_conn_track: [in] IPA IPv6CT end-point configuration params
  397. *
  398. * Returns: 0 on success, negative on failure
  399. *
  400. * Note: Should not be called from atomic context
  401. */
  402. int ipa_cfg_ep_conn_track(u32 clnt_hdl,
  403. const struct ipa_ep_cfg_conn_track *ep_conn_track)
  404. {
  405. int ret;
  406. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_conn_track, clnt_hdl,
  407. ep_conn_track);
  408. return ret;
  409. }
  410. EXPORT_SYMBOL(ipa_cfg_ep_conn_track);
  411. /**
  412. * ipa_cfg_ep_hdr() - IPA end-point header configuration
  413. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  414. * @ipa_ep_cfg: [in] IPA end-point configuration params
  415. *
  416. * Returns: 0 on success, negative on failure
  417. *
  418. * Note: Should not be called from atomic context
  419. */
  420. int ipa_cfg_ep_hdr(u32 clnt_hdl, const struct ipa_ep_cfg_hdr *ep_hdr)
  421. {
  422. int ret;
  423. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_hdr, clnt_hdl, ep_hdr);
  424. return ret;
  425. }
  426. EXPORT_SYMBOL(ipa_cfg_ep_hdr);
  427. /**
  428. * ipa_cfg_ep_hdr_ext() - IPA end-point extended header configuration
  429. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  430. * @ep_hdr_ext: [in] IPA end-point configuration params
  431. *
  432. * Returns: 0 on success, negative on failure
  433. *
  434. * Note: Should not be called from atomic context
  435. */
  436. int ipa_cfg_ep_hdr_ext(u32 clnt_hdl,
  437. const struct ipa_ep_cfg_hdr_ext *ep_hdr_ext)
  438. {
  439. int ret;
  440. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_hdr_ext, clnt_hdl, ep_hdr_ext);
  441. return ret;
  442. }
  443. EXPORT_SYMBOL(ipa_cfg_ep_hdr_ext);
  444. /**
  445. * ipa_cfg_ep_mode() - IPA end-point mode configuration
  446. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  447. * @ipa_ep_cfg: [in] IPA end-point configuration params
  448. *
  449. * Returns: 0 on success, negative on failure
  450. *
  451. * Note: Should not be called from atomic context
  452. */
  453. int ipa_cfg_ep_mode(u32 clnt_hdl, const struct ipa_ep_cfg_mode *ep_mode)
  454. {
  455. int ret;
  456. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_mode, clnt_hdl, ep_mode);
  457. return ret;
  458. }
  459. EXPORT_SYMBOL(ipa_cfg_ep_mode);
  460. /**
  461. * ipa_cfg_ep_aggr() - IPA end-point aggregation configuration
  462. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  463. * @ipa_ep_cfg: [in] IPA end-point configuration params
  464. *
  465. * Returns: 0 on success, negative on failure
  466. *
  467. * Note: Should not be called from atomic context
  468. */
  469. int ipa_cfg_ep_aggr(u32 clnt_hdl, const struct ipa_ep_cfg_aggr *ep_aggr)
  470. {
  471. int ret;
  472. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_aggr, clnt_hdl, ep_aggr);
  473. return ret;
  474. }
  475. EXPORT_SYMBOL(ipa_cfg_ep_aggr);
  476. /**
  477. * ipa_cfg_ep_deaggr() - IPA end-point deaggregation configuration
  478. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  479. * @ep_deaggr: [in] IPA end-point configuration params
  480. *
  481. * Returns: 0 on success, negative on failure
  482. *
  483. * Note: Should not be called from atomic context
  484. */
  485. int ipa_cfg_ep_deaggr(u32 clnt_hdl,
  486. const struct ipa_ep_cfg_deaggr *ep_deaggr)
  487. {
  488. int ret;
  489. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_deaggr, clnt_hdl, ep_deaggr);
  490. return ret;
  491. }
  492. EXPORT_SYMBOL(ipa_cfg_ep_deaggr);
  493. /**
  494. * ipa_cfg_ep_route() - IPA end-point routing configuration
  495. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  496. * @ipa_ep_cfg: [in] IPA end-point configuration params
  497. *
  498. * Returns: 0 on success, negative on failure
  499. *
  500. * Note: Should not be called from atomic context
  501. */
  502. int ipa_cfg_ep_route(u32 clnt_hdl, const struct ipa_ep_cfg_route *ep_route)
  503. {
  504. int ret;
  505. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_route, clnt_hdl, ep_route);
  506. return ret;
  507. }
  508. EXPORT_SYMBOL(ipa_cfg_ep_route);
  509. /**
  510. * ipa_cfg_ep_holb() - IPA end-point holb configuration
  511. *
  512. * If an IPA producer pipe is full, IPA HW by default will block
  513. * indefinitely till space opens up. During this time no packets
  514. * including those from unrelated pipes will be processed. Enabling
  515. * HOLB means IPA HW will be allowed to drop packets as/when needed
  516. * and indefinite blocking is avoided.
  517. *
  518. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  519. * @ipa_ep_cfg: [in] IPA end-point configuration params
  520. *
  521. * Returns: 0 on success, negative on failure
  522. */
  523. int ipa_cfg_ep_holb(u32 clnt_hdl, const struct ipa_ep_cfg_holb *ep_holb)
  524. {
  525. int ret;
  526. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_holb, clnt_hdl, ep_holb);
  527. return ret;
  528. }
  529. EXPORT_SYMBOL(ipa_cfg_ep_holb);
  530. /**
  531. * ipa_cfg_ep_cfg() - IPA end-point cfg configuration
  532. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  533. * @ipa_ep_cfg: [in] IPA end-point configuration params
  534. *
  535. * Returns: 0 on success, negative on failure
  536. *
  537. * Note: Should not be called from atomic context
  538. */
  539. int ipa_cfg_ep_cfg(u32 clnt_hdl, const struct ipa_ep_cfg_cfg *cfg)
  540. {
  541. int ret;
  542. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_cfg, clnt_hdl, cfg);
  543. return ret;
  544. }
  545. EXPORT_SYMBOL(ipa_cfg_ep_cfg);
  546. /**
  547. * ipa_cfg_ep_metadata_mask() - IPA end-point meta-data mask configuration
  548. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  549. * @ipa_ep_cfg: [in] IPA end-point configuration params
  550. *
  551. * Returns: 0 on success, negative on failure
  552. *
  553. * Note: Should not be called from atomic context
  554. */
  555. int ipa_cfg_ep_metadata_mask(u32 clnt_hdl, const struct ipa_ep_cfg_metadata_mask
  556. *metadata_mask)
  557. {
  558. int ret;
  559. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_metadata_mask, clnt_hdl,
  560. metadata_mask);
  561. return ret;
  562. }
  563. EXPORT_SYMBOL(ipa_cfg_ep_metadata_mask);
  564. /**
  565. * ipa_cfg_ep_holb_by_client() - IPA end-point holb configuration
  566. *
  567. * Wrapper function for ipa_cfg_ep_holb() with client name instead of
  568. * client handle. This function is used for clients that does not have
  569. * client handle.
  570. *
  571. * @client: [in] client name
  572. * @ipa_ep_cfg: [in] IPA end-point configuration params
  573. *
  574. * Returns: 0 on success, negative on failure
  575. */
  576. int ipa_cfg_ep_holb_by_client(enum ipa_client_type client,
  577. const struct ipa_ep_cfg_holb *ep_holb)
  578. {
  579. int ret;
  580. IPA_API_DISPATCH_RETURN(ipa_cfg_ep_holb_by_client, client, ep_holb);
  581. return ret;
  582. }
  583. EXPORT_SYMBOL(ipa_cfg_ep_holb_by_client);
  584. /**
  585. * ipa_add_hdr_usr() - add the specified headers to SW and optionally
  586. * commit them to IPA HW
  587. * @hdrs: [inout] set of headers to add
  588. * @user_only: [in] indicate rules installed by userspace
  589. *
  590. * Returns: 0 on success, negative on failure
  591. *
  592. * Note: Should not be called from atomic context
  593. */
  594. int ipa_add_hdr_usr(struct ipa_ioc_add_hdr *hdrs, bool user_only)
  595. {
  596. int ret;
  597. IPA_API_DISPATCH_RETURN(ipa_add_hdr_usr, hdrs, user_only);
  598. return ret;
  599. }
  600. EXPORT_SYMBOL(ipa_add_hdr_usr);
  601. /**
  602. * ipa_reset_hdr() - reset the current header table in SW (does not commit to
  603. * HW)
  604. *
  605. * @user_only: [in] indicate delete rules installed by userspace
  606. * Returns: 0 on success, negative on failure
  607. *
  608. * Note: Should not be called from atomic context
  609. */
  610. int ipa_reset_hdr(bool user_only)
  611. {
  612. int ret;
  613. IPA_API_DISPATCH_RETURN(ipa_reset_hdr, user_only);
  614. return ret;
  615. }
  616. EXPORT_SYMBOL(ipa_reset_hdr);
  617. /**
  618. * ipa_add_hdr_proc_ctx() - add the specified headers to SW
  619. * and optionally commit them to IPA HW
  620. * @proc_ctxs: [inout] set of processing context headers to add
  621. * @user_only: [in] indicate rules installed by userspace
  622. *
  623. * Returns: 0 on success, negative on failure
  624. *
  625. * Note: Should not be called from atomic context
  626. */
  627. int ipa_add_hdr_proc_ctx(struct ipa_ioc_add_hdr_proc_ctx *proc_ctxs,
  628. bool user_only)
  629. {
  630. int ret;
  631. IPA_API_DISPATCH_RETURN(ipa_add_hdr_proc_ctx, proc_ctxs, user_only);
  632. return ret;
  633. }
  634. EXPORT_SYMBOL(ipa_add_hdr_proc_ctx);
  635. /**
  636. * ipa_del_hdr_proc_ctx() -
  637. * Remove the specified processing context headers from SW and
  638. * optionally commit them to IPA HW.
  639. * @hdls: [inout] set of processing context headers to delete
  640. *
  641. * Returns: 0 on success, negative on failure
  642. *
  643. * Note: Should not be called from atomic context
  644. */
  645. int ipa_del_hdr_proc_ctx(struct ipa_ioc_del_hdr_proc_ctx *hdls)
  646. {
  647. int ret;
  648. IPA_API_DISPATCH_RETURN(ipa_del_hdr_proc_ctx, hdls);
  649. return ret;
  650. }
  651. EXPORT_SYMBOL(ipa_del_hdr_proc_ctx);
  652. /**
  653. * ipa_add_rt_rule_v2() - Add the specified routing rules to SW
  654. * and optionally commit to IPA HW
  655. * @rules: [inout] set of routing rules to add
  656. *
  657. * Returns: 0 on success, negative on failure
  658. *
  659. * Note: Should not be called from atomic context
  660. */
  661. int ipa_add_rt_rule_v2(struct ipa_ioc_add_rt_rule_v2 *rules)
  662. {
  663. int ret;
  664. IPA_API_DISPATCH_RETURN(ipa_add_rt_rule_v2, rules);
  665. return ret;
  666. }
  667. EXPORT_SYMBOL(ipa_add_rt_rule_v2);
  668. /**
  669. * ipa_add_rt_rule_usr() - Add the specified routing rules to SW and optionally
  670. * commit to IPA HW
  671. * @rules: [inout] set of routing rules to add
  672. * @user_only: [in] indicate rules installed by userspace
  673. *
  674. * Returns: 0 on success, negative on failure
  675. *
  676. * Note: Should not be called from atomic context
  677. */
  678. int ipa_add_rt_rule_usr(struct ipa_ioc_add_rt_rule *rules, bool user_only)
  679. {
  680. int ret;
  681. IPA_API_DISPATCH_RETURN(ipa_add_rt_rule_usr, rules, user_only);
  682. return ret;
  683. }
  684. EXPORT_SYMBOL(ipa_add_rt_rule_usr);
  685. /**
  686. * ipa_add_rt_rule_usr_v2() - Add the specified routing rules to
  687. * SW and optionally commit to IPA HW
  688. * @rules: [inout] set of routing rules to add
  689. * @user_only: [in] indicate rules installed by userspace
  690. *
  691. * Returns: 0 on success, negative on failure
  692. *
  693. * Note: Should not be called from atomic context
  694. */
  695. int ipa_add_rt_rule_usr_v2(struct ipa_ioc_add_rt_rule_v2 *rules, bool user_only)
  696. {
  697. int ret;
  698. IPA_API_DISPATCH_RETURN(ipa_add_rt_rule_usr_v2, rules, user_only);
  699. return ret;
  700. }
  701. EXPORT_SYMBOL(ipa_add_rt_rule_usr_v2);
  702. /**
  703. * ipa_del_rt_rule() - Remove the specified routing rules to SW and optionally
  704. * commit to IPA HW
  705. * @hdls: [inout] set of routing rules to delete
  706. *
  707. * Returns: 0 on success, negative on failure
  708. *
  709. * Note: Should not be called from atomic context
  710. */
  711. int ipa_del_rt_rule(struct ipa_ioc_del_rt_rule *hdls)
  712. {
  713. int ret;
  714. IPA_API_DISPATCH_RETURN(ipa_del_rt_rule, hdls);
  715. return ret;
  716. }
  717. EXPORT_SYMBOL(ipa_del_rt_rule);
  718. /**
  719. * ipa_commit_rt_rule() - Commit the current SW routing table of specified type
  720. * to IPA HW
  721. * @ip: The family of routing tables
  722. *
  723. * Returns: 0 on success, negative on failure
  724. *
  725. * Note: Should not be called from atomic context
  726. */
  727. int ipa_commit_rt(enum ipa_ip_type ip)
  728. {
  729. int ret;
  730. IPA_API_DISPATCH_RETURN(ipa_commit_rt, ip);
  731. return ret;
  732. }
  733. EXPORT_SYMBOL(ipa_commit_rt);
  734. /**
  735. * ipa_reset_rt() - reset the current SW routing table of specified type
  736. * (does not commit to HW)
  737. * @ip: The family of routing tables
  738. * @user_only: [in] indicate delete rules installed by userspace
  739. *
  740. * Returns: 0 on success, negative on failure
  741. *
  742. * Note: Should not be called from atomic context
  743. */
  744. int ipa_reset_rt(enum ipa_ip_type ip, bool user_only)
  745. {
  746. int ret;
  747. IPA_API_DISPATCH_RETURN(ipa_reset_rt, ip, user_only);
  748. return ret;
  749. }
  750. EXPORT_SYMBOL(ipa_reset_rt);
  751. /**
  752. * ipa_get_rt_tbl() - lookup the specified routing table and return handle if it
  753. * exists, if lookup succeeds the routing table ref cnt is increased
  754. * @lookup: [inout] routing table to lookup and its handle
  755. *
  756. * Returns: 0 on success, negative on failure
  757. *
  758. * Note: Should not be called from atomic context
  759. * Caller should call ipa_put_rt_tbl later if this function succeeds
  760. */
  761. int ipa_get_rt_tbl(struct ipa_ioc_get_rt_tbl *lookup)
  762. {
  763. int ret;
  764. IPA_API_DISPATCH_RETURN(ipa_get_rt_tbl, lookup);
  765. return ret;
  766. }
  767. EXPORT_SYMBOL(ipa_get_rt_tbl);
  768. /**
  769. * ipa_query_rt_index() - find the routing table index
  770. * which name and ip type are given as parameters
  771. * @in: [out] the index of the wanted routing table
  772. *
  773. * Returns: the routing table which name is given as parameter, or NULL if it
  774. * doesn't exist
  775. */
  776. int ipa_query_rt_index(struct ipa_ioc_get_rt_tbl_indx *in)
  777. {
  778. int ret;
  779. IPA_API_DISPATCH_RETURN(ipa_query_rt_index, in);
  780. return ret;
  781. }
  782. EXPORT_SYMBOL(ipa_query_rt_index);
  783. /**
  784. * ipa_mdfy_rt_rule() - Modify the specified routing rules in SW and optionally
  785. * commit to IPA HW
  786. *
  787. * Returns: 0 on success, negative on failure
  788. *
  789. * Note: Should not be called from atomic context
  790. */
  791. int ipa_mdfy_rt_rule(struct ipa_ioc_mdfy_rt_rule *hdls)
  792. {
  793. int ret;
  794. IPA_API_DISPATCH_RETURN(ipa_mdfy_rt_rule, hdls);
  795. return ret;
  796. }
  797. EXPORT_SYMBOL(ipa_mdfy_rt_rule);
  798. /**
  799. * ipa_mdfy_rt_rule_v2() - Modify the specified routing rules in
  800. * SW and optionally commit to IPA HW
  801. *
  802. * Returns: 0 on success, negative on failure
  803. *
  804. * Note: Should not be called from atomic context
  805. */
  806. int ipa_mdfy_rt_rule_v2(struct ipa_ioc_mdfy_rt_rule_v2 *hdls)
  807. {
  808. int ret;
  809. IPA_API_DISPATCH_RETURN(ipa_mdfy_rt_rule_v2, hdls);
  810. return ret;
  811. }
  812. EXPORT_SYMBOL(ipa_mdfy_rt_rule_v2);
  813. /**
  814. * ipa_add_flt_rule() - Add the specified filtering rules to SW and optionally
  815. * commit to IPA HW
  816. * @rules: [inout] set of filtering rules to add
  817. *
  818. * Returns: 0 on success, negative on failure
  819. *
  820. * Note: Should not be called from atomic context
  821. */
  822. int ipa_add_flt_rule(struct ipa_ioc_add_flt_rule *rules)
  823. {
  824. int ret;
  825. IPA_API_DISPATCH_RETURN(ipa_add_flt_rule, rules);
  826. return ret;
  827. }
  828. EXPORT_SYMBOL(ipa_add_flt_rule);
  829. /**
  830. * ipa_add_flt_rule_v2() - Add the specified filtering rules to
  831. * SW and optionally commit to IPA HW
  832. * @rules: [inout] set of filtering rules to add
  833. *
  834. * Returns: 0 on success, negative on failure
  835. *
  836. * Note: Should not be called from atomic context
  837. */
  838. int ipa_add_flt_rule_v2(struct ipa_ioc_add_flt_rule_v2 *rules)
  839. {
  840. int ret;
  841. IPA_API_DISPATCH_RETURN(ipa_add_flt_rule_v2, rules);
  842. return ret;
  843. }
  844. EXPORT_SYMBOL(ipa_add_flt_rule_v2);
  845. /**
  846. * ipa_add_flt_rule_usr() - Add the specified filtering rules to
  847. * SW and optionally commit to IPA HW
  848. * @rules: [inout] set of filtering rules to add
  849. * @user_only: [in] indicate rules installed by userspace
  850. *
  851. * Returns: 0 on success, negative on failure
  852. *
  853. * Note: Should not be called from atomic context
  854. */
  855. int ipa_add_flt_rule_usr(struct ipa_ioc_add_flt_rule *rules, bool user_only)
  856. {
  857. int ret;
  858. IPA_API_DISPATCH_RETURN(ipa_add_flt_rule_usr, rules, user_only);
  859. return ret;
  860. }
  861. EXPORT_SYMBOL(ipa_add_flt_rule_usr);
  862. /**
  863. * ipa_add_flt_rule_usr_v2() - Add the specified filtering rules
  864. * to SW and optionally commit to IPA HW
  865. * @rules: [inout] set of filtering rules to add
  866. * @user_only: [in] indicate rules installed by userspace
  867. *
  868. * Returns: 0 on success, negative on failure
  869. *
  870. * Note: Should not be called from atomic context
  871. */
  872. int ipa_add_flt_rule_usr_v2(struct ipa_ioc_add_flt_rule_v2 *rules,
  873. bool user_only)
  874. {
  875. int ret;
  876. IPA_API_DISPATCH_RETURN(ipa_add_flt_rule_usr_v2,
  877. rules, user_only);
  878. return ret;
  879. }
  880. EXPORT_SYMBOL(ipa_add_flt_rule_usr_v2);
  881. /**
  882. * ipa_del_flt_rule() - Remove the specified filtering rules from SW and
  883. * optionally commit to IPA HW
  884. *
  885. * Returns: 0 on success, negative on failure
  886. *
  887. * Note: Should not be called from atomic context
  888. */
  889. int ipa_del_flt_rule(struct ipa_ioc_del_flt_rule *hdls)
  890. {
  891. int ret;
  892. IPA_API_DISPATCH_RETURN(ipa_del_flt_rule, hdls);
  893. return ret;
  894. }
  895. EXPORT_SYMBOL(ipa_del_flt_rule);
  896. /**
  897. * ipa_mdfy_flt_rule() - Modify the specified filtering rules in SW and
  898. * optionally commit to IPA HW
  899. *
  900. * Returns: 0 on success, negative on failure
  901. *
  902. * Note: Should not be called from atomic context
  903. */
  904. int ipa_mdfy_flt_rule(struct ipa_ioc_mdfy_flt_rule *hdls)
  905. {
  906. int ret;
  907. IPA_API_DISPATCH_RETURN(ipa_mdfy_flt_rule, hdls);
  908. return ret;
  909. }
  910. EXPORT_SYMBOL(ipa_mdfy_flt_rule);
  911. /**
  912. * ipa_mdfy_flt_rule_v2() - Modify the specified filtering rules
  913. * in SW and optionally commit to IPA HW
  914. *
  915. * Returns: 0 on success, negative on failure
  916. *
  917. * Note: Should not be called from atomic context
  918. */
  919. int ipa_mdfy_flt_rule_v2(struct ipa_ioc_mdfy_flt_rule_v2 *hdls)
  920. {
  921. int ret;
  922. IPA_API_DISPATCH_RETURN(ipa_mdfy_flt_rule_v2, hdls);
  923. return ret;
  924. }
  925. EXPORT_SYMBOL(ipa_mdfy_flt_rule_v2);
  926. /**
  927. * ipa_commit_flt() - Commit the current SW filtering table of specified type to
  928. * IPA HW
  929. * @ip: [in] the family of routing tables
  930. *
  931. * Returns: 0 on success, negative on failure
  932. *
  933. * Note: Should not be called from atomic context
  934. */
  935. int ipa_commit_flt(enum ipa_ip_type ip)
  936. {
  937. int ret;
  938. IPA_API_DISPATCH_RETURN(ipa_commit_flt, ip);
  939. return ret;
  940. }
  941. EXPORT_SYMBOL(ipa_commit_flt);
  942. /**
  943. * ipa_reset_flt() - Reset the current SW filtering table of specified type
  944. * (does not commit to HW)
  945. * @ip: [in] the family of routing tables
  946. * @user_only: [in] indicate delete rules installed by userspace
  947. *
  948. * Returns: 0 on success, negative on failure
  949. *
  950. * Note: Should not be called from atomic context
  951. */
  952. int ipa_reset_flt(enum ipa_ip_type ip, bool user_only)
  953. {
  954. int ret;
  955. IPA_API_DISPATCH_RETURN(ipa_reset_flt, ip, user_only);
  956. return ret;
  957. }
  958. EXPORT_SYMBOL(ipa_reset_flt);
  959. /**
  960. * ipa_allocate_nat_device() - Allocates memory for the NAT device
  961. * @mem: [in/out] memory parameters
  962. *
  963. * Called by NAT client driver to allocate memory for the NAT entries. Based on
  964. * the request size either shared or system memory will be used.
  965. *
  966. * Returns: 0 on success, negative on failure
  967. */
  968. int ipa_allocate_nat_device(struct ipa_ioc_nat_alloc_mem *mem)
  969. {
  970. int ret;
  971. IPA_API_DISPATCH_RETURN(ipa_allocate_nat_device, mem);
  972. return ret;
  973. }
  974. EXPORT_SYMBOL(ipa_allocate_nat_device);
  975. /**
  976. * ipa_allocate_nat_table() - Allocates memory for the NAT table
  977. * @table_alloc: [in/out] memory parameters
  978. *
  979. * Called by NAT client to allocate memory for the table entries.
  980. * Based on the request size either shared or system memory will be used.
  981. *
  982. * Returns: 0 on success, negative on failure
  983. */
  984. int ipa_allocate_nat_table(struct ipa_ioc_nat_ipv6ct_table_alloc *table_alloc)
  985. {
  986. int ret;
  987. IPA_API_DISPATCH_RETURN(ipa_allocate_nat_table, table_alloc);
  988. return ret;
  989. }
  990. EXPORT_SYMBOL(ipa_allocate_nat_table);
  991. /**
  992. * ipa_allocate_ipv6ct_table() - Allocates memory for the IPv6CT table
  993. * @table_alloc: [in/out] memory parameters
  994. *
  995. * Called by IPv6CT client to allocate memory for the table entries.
  996. * Based on the request size either shared or system memory will be used.
  997. *
  998. * Returns: 0 on success, negative on failure
  999. */
  1000. int ipa_allocate_ipv6ct_table(
  1001. struct ipa_ioc_nat_ipv6ct_table_alloc *table_alloc)
  1002. {
  1003. int ret;
  1004. IPA_API_DISPATCH_RETURN(ipa_allocate_ipv6ct_table, table_alloc);
  1005. return ret;
  1006. }
  1007. EXPORT_SYMBOL(ipa_allocate_ipv6ct_table);
  1008. /**
  1009. * ipa_nat_init_cmd() - Post IP_V4_NAT_INIT command to IPA HW
  1010. * @init: [in] initialization command attributes
  1011. *
  1012. * Called by NAT client driver to post IP_V4_NAT_INIT command to IPA HW
  1013. *
  1014. * Returns: 0 on success, negative on failure
  1015. */
  1016. int ipa_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
  1017. {
  1018. int ret;
  1019. IPA_API_DISPATCH_RETURN(ipa_nat_init_cmd, init);
  1020. return ret;
  1021. }
  1022. EXPORT_SYMBOL(ipa_nat_init_cmd);
  1023. /**
  1024. * ipa_ipv6ct_init_cmd() - Post IP_V6_CONN_TRACK_INIT command to IPA HW
  1025. * @init: [in] initialization command attributes
  1026. *
  1027. * Called by IPv6CT client driver to post IP_V6_CONN_TRACK_INIT command
  1028. * to IPA HW.
  1029. *
  1030. * Returns: 0 on success, negative on failure
  1031. */
  1032. int ipa_ipv6ct_init_cmd(struct ipa_ioc_ipv6ct_init *init)
  1033. {
  1034. int ret;
  1035. IPA_API_DISPATCH_RETURN(ipa_ipv6ct_init_cmd, init);
  1036. return ret;
  1037. }
  1038. EXPORT_SYMBOL(ipa_ipv6ct_init_cmd);
  1039. /**
  1040. * ipa_nat_dma_cmd() - Post NAT_DMA command to IPA HW
  1041. * @dma: [in] initialization command attributes
  1042. *
  1043. * Called by NAT client driver to post NAT_DMA command to IPA HW
  1044. *
  1045. * Returns: 0 on success, negative on failure
  1046. */
  1047. int ipa_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
  1048. {
  1049. int ret;
  1050. IPA_API_DISPATCH_RETURN(ipa_nat_dma_cmd, dma);
  1051. return ret;
  1052. }
  1053. EXPORT_SYMBOL(ipa_nat_dma_cmd);
  1054. /**
  1055. * ipa_table_dma_cmd() - Post TABLE_DMA command to IPA HW
  1056. * @dma: [in] initialization command attributes
  1057. *
  1058. * Called by NAT/IPv6CT client to post TABLE_DMA command to IPA HW
  1059. *
  1060. * Returns: 0 on success, negative on failure
  1061. */
  1062. int ipa_table_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
  1063. {
  1064. int ret;
  1065. IPA_API_DISPATCH_RETURN(ipa_table_dma_cmd, dma);
  1066. return ret;
  1067. }
  1068. EXPORT_SYMBOL(ipa_table_dma_cmd);
  1069. /**
  1070. * ipa_nat_del_cmd() - Delete the NAT table
  1071. * @del: [in] delete NAT table parameters
  1072. *
  1073. * Called by NAT client driver to delete the nat table
  1074. *
  1075. * Returns: 0 on success, negative on failure
  1076. */
  1077. int ipa_nat_del_cmd(struct ipa_ioc_v4_nat_del *del)
  1078. {
  1079. int ret;
  1080. IPA_API_DISPATCH_RETURN(ipa_nat_del_cmd, del);
  1081. return ret;
  1082. }
  1083. EXPORT_SYMBOL(ipa_nat_del_cmd);
  1084. /**
  1085. * ipa_del_nat_table() - Delete the NAT table
  1086. * @del: [in] delete table parameters
  1087. *
  1088. * Called by NAT client to delete the table
  1089. *
  1090. * Returns: 0 on success, negative on failure
  1091. */
  1092. int ipa_del_nat_table(struct ipa_ioc_nat_ipv6ct_table_del *del)
  1093. {
  1094. int ret;
  1095. IPA_API_DISPATCH_RETURN(ipa_del_nat_table, del);
  1096. return ret;
  1097. }
  1098. EXPORT_SYMBOL(ipa_del_nat_table);
  1099. /**
  1100. * ipa_del_ipv6ct_table() - Delete the IPv6CT table
  1101. * @del: [in] delete table parameters
  1102. *
  1103. * Called by IPv6CT client to delete the table
  1104. *
  1105. * Returns: 0 on success, negative on failure
  1106. */
  1107. int ipa_del_ipv6ct_table(struct ipa_ioc_nat_ipv6ct_table_del *del)
  1108. {
  1109. int ret;
  1110. IPA_API_DISPATCH_RETURN(ipa_del_ipv6ct_table, del);
  1111. return ret;
  1112. }
  1113. EXPORT_SYMBOL(ipa_del_ipv6ct_table);
  1114. /**
  1115. * ipa3_nat_mdfy_pdn() - Modify a PDN entry in PDN config table in IPA SRAM
  1116. * @mdfy_pdn: [in] PDN info to be written to SRAM
  1117. *
  1118. * Called by NAT client driver to modify an entry in the PDN config table
  1119. *
  1120. * Returns: 0 on success, negative on failure
  1121. */
  1122. int ipa_nat_mdfy_pdn(struct ipa_ioc_nat_pdn_entry *mdfy_pdn)
  1123. {
  1124. int ret;
  1125. IPA_API_DISPATCH_RETURN(ipa_nat_mdfy_pdn, mdfy_pdn);
  1126. return ret;
  1127. }
  1128. EXPORT_SYMBOL(ipa_nat_mdfy_pdn);
  1129. int ipa_sys_setup(struct ipa_sys_connect_params *sys_in,
  1130. unsigned long *ipa_bam_or_gsi_hdl,
  1131. u32 *ipa_pipe_num, u32 *clnt_hdl, bool en_status)
  1132. {
  1133. int ret;
  1134. IPA_API_DISPATCH_RETURN(ipa_sys_setup, sys_in, ipa_bam_or_gsi_hdl,
  1135. ipa_pipe_num, clnt_hdl, en_status);
  1136. return ret;
  1137. }
  1138. EXPORT_SYMBOL(ipa_sys_setup);
  1139. int ipa_sys_teardown(u32 clnt_hdl)
  1140. {
  1141. int ret;
  1142. IPA_API_DISPATCH_RETURN(ipa_sys_teardown, clnt_hdl);
  1143. return ret;
  1144. }
  1145. EXPORT_SYMBOL(ipa_sys_teardown);
  1146. int ipa_sys_update_gsi_hdls(u32 clnt_hdl, unsigned long gsi_ch_hdl,
  1147. unsigned long gsi_ev_hdl)
  1148. {
  1149. int ret;
  1150. IPA_API_DISPATCH_RETURN(ipa_sys_update_gsi_hdls, clnt_hdl,
  1151. gsi_ch_hdl, gsi_ev_hdl);
  1152. return ret;
  1153. }
  1154. EXPORT_SYMBOL(ipa_sys_update_gsi_hdls);
  1155. /**
  1156. * ipa_set_wlan_tx_info() -set WDI statistics from uc
  1157. * @info: [inout] set info populated by driver
  1158. *
  1159. * Returns: 0 on success, negative on failure
  1160. *
  1161. * @note Cannot be called from atomic context
  1162. *
  1163. */
  1164. int ipa_set_wlan_tx_info(struct ipa_wdi_tx_info *info)
  1165. {
  1166. int ret;
  1167. IPA_API_DISPATCH_RETURN(ipa_set_wlan_tx_info, info);
  1168. return ret;
  1169. }
  1170. EXPORT_SYMBOL(ipa_set_wlan_tx_info);
  1171. /**
  1172. * ipa_wigig_internal_init() - get uc db and register uC
  1173. * ready CB if uC not ready, wigig only.
  1174. * @inout: [in/out] uc ready input/output parameters
  1175. * from/to client
  1176. * @int_notify: [in] wigig misc interrupt handler function
  1177. * @uc_db_pa: [out] uC db physical address
  1178. *
  1179. * Returns: 0 on success, negative on failure
  1180. *
  1181. */
  1182. int ipa_wigig_internal_init(
  1183. struct ipa_wdi_uc_ready_params *inout,
  1184. ipa_wigig_misc_int_cb int_notify,
  1185. phys_addr_t *uc_db_pa)
  1186. {
  1187. int ret;
  1188. IPA_API_DISPATCH_RETURN(ipa_wigig_internal_init, inout,
  1189. int_notify, uc_db_pa);
  1190. return ret;
  1191. }
  1192. EXPORT_SYMBOL(ipa_wigig_internal_init);
  1193. /**
  1194. * teth_bridge_init() - Initialize the Tethering bridge driver
  1195. * @params - in/out params for USB initialization API (please look at struct
  1196. * definition for more info)
  1197. *
  1198. * USB driver gets a pointer to a callback function (usb_notify_cb) and an
  1199. * associated data. USB driver installs this callback function in the call to
  1200. * ipa_connect().
  1201. *
  1202. * Builds IPA resource manager dependency graph.
  1203. *
  1204. * Return codes: 0: success,
  1205. * -EINVAL - Bad parameter
  1206. * Other negative value - Failure
  1207. */
  1208. int teth_bridge_init(struct teth_bridge_init_params *params)
  1209. {
  1210. int ret;
  1211. IPA_API_DISPATCH_RETURN(teth_bridge_init, params);
  1212. return ret;
  1213. }
  1214. EXPORT_SYMBOL(teth_bridge_init);
  1215. /**
  1216. * teth_bridge_disconnect() - Disconnect tethering bridge module
  1217. */
  1218. int teth_bridge_disconnect(enum ipa_client_type client)
  1219. {
  1220. int ret;
  1221. IPA_API_DISPATCH_RETURN(teth_bridge_disconnect, client);
  1222. return ret;
  1223. }
  1224. EXPORT_SYMBOL(teth_bridge_disconnect);
  1225. /**
  1226. * teth_bridge_connect() - Connect bridge for a tethered Rmnet / MBIM call
  1227. * @connect_params: Connection info
  1228. *
  1229. * Return codes: 0: success
  1230. * -EINVAL: invalid parameters
  1231. * -EPERM: Operation not permitted as the bridge is already
  1232. * connected
  1233. */
  1234. int teth_bridge_connect(struct teth_bridge_connect_params *connect_params)
  1235. {
  1236. int ret;
  1237. IPA_API_DISPATCH_RETURN(teth_bridge_connect, connect_params);
  1238. return ret;
  1239. }
  1240. EXPORT_SYMBOL(teth_bridge_connect);
  1241. /* ipa_set_client() - provide client mapping
  1242. * @client: client type
  1243. *
  1244. * Return value: none
  1245. */
  1246. void ipa_set_client(int index, enum ipacm_client_enum client, bool uplink)
  1247. {
  1248. IPA_API_DISPATCH(ipa_set_client, index, client, uplink);
  1249. }
  1250. EXPORT_SYMBOL(ipa_set_client);
  1251. /**
  1252. * ipa_get_client() - provide client mapping
  1253. * @client: client type
  1254. *
  1255. * Return value: none
  1256. */
  1257. enum ipacm_client_enum ipa_get_client(int pipe_idx)
  1258. {
  1259. int ret;
  1260. IPA_API_DISPATCH_RETURN(ipa_get_client, pipe_idx);
  1261. return ret;
  1262. }
  1263. EXPORT_SYMBOL(ipa_get_client);
  1264. /**
  1265. * ipa_get_client_uplink() - provide client mapping
  1266. * @client: client type
  1267. *
  1268. * Return value: none
  1269. */
  1270. bool ipa_get_client_uplink(int pipe_idx)
  1271. {
  1272. int ret;
  1273. IPA_API_DISPATCH_RETURN(ipa_get_client_uplink, pipe_idx);
  1274. return ret;
  1275. }
  1276. EXPORT_SYMBOL(ipa_get_client_uplink);
  1277. int ipa_mhi_init_engine(struct ipa_mhi_init_engine *params)
  1278. {
  1279. int ret;
  1280. IPA_API_DISPATCH_RETURN(ipa_mhi_init_engine, params);
  1281. return ret;
  1282. }
  1283. EXPORT_SYMBOL(ipa_mhi_init_engine);
  1284. /**
  1285. * ipa_connect_mhi_pipe() - Connect pipe to IPA and start corresponding
  1286. * MHI channel
  1287. * @in: connect parameters
  1288. * @clnt_hdl: [out] client handle for this pipe
  1289. *
  1290. * This function is called by IPA MHI client driver on MHI channel start.
  1291. * This function is called after MHI engine was started.
  1292. * This function is doing the following:
  1293. * - Send command to uC to start corresponding MHI channel
  1294. * - Configure IPA EP control
  1295. *
  1296. * Return codes: 0 : success
  1297. * negative : error
  1298. */
  1299. int ipa_connect_mhi_pipe(struct ipa_mhi_connect_params_internal *in,
  1300. u32 *clnt_hdl)
  1301. {
  1302. int ret;
  1303. IPA_API_DISPATCH_RETURN(ipa_connect_mhi_pipe, in, clnt_hdl);
  1304. return ret;
  1305. }
  1306. EXPORT_SYMBOL(ipa_connect_mhi_pipe);
  1307. /**
  1308. * ipa_disconnect_mhi_pipe() - Disconnect pipe from IPA and reset corresponding
  1309. * MHI channel
  1310. * @in: connect parameters
  1311. * @clnt_hdl: [out] client handle for this pipe
  1312. *
  1313. * This function is called by IPA MHI client driver on MHI channel reset.
  1314. * This function is called after MHI channel was started.
  1315. * This function is doing the following:
  1316. * - Send command to uC to reset corresponding MHI channel
  1317. * - Configure IPA EP control
  1318. *
  1319. * Return codes: 0 : success
  1320. * negative : error
  1321. */
  1322. int ipa_disconnect_mhi_pipe(u32 clnt_hdl)
  1323. {
  1324. int ret;
  1325. IPA_API_DISPATCH_RETURN(ipa_disconnect_mhi_pipe, clnt_hdl);
  1326. return ret;
  1327. }
  1328. EXPORT_SYMBOL(ipa_disconnect_mhi_pipe);
  1329. bool ipa_mhi_stop_gsi_channel(enum ipa_client_type client)
  1330. {
  1331. bool ret;
  1332. IPA_API_DISPATCH_RETURN_BOOL(ipa_mhi_stop_gsi_channel, client);
  1333. return ret;
  1334. }
  1335. EXPORT_SYMBOL(ipa_mhi_stop_gsi_channel);
  1336. int ipa_uc_mhi_reset_channel(int channelHandle)
  1337. {
  1338. int ret;
  1339. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_reset_channel, channelHandle);
  1340. return ret;
  1341. }
  1342. EXPORT_SYMBOL(ipa_uc_mhi_reset_channel);
  1343. bool ipa_mhi_sps_channel_empty(enum ipa_client_type client)
  1344. {
  1345. bool ret;
  1346. IPA_API_DISPATCH_RETURN_BOOL(ipa_mhi_sps_channel_empty, client);
  1347. return ret;
  1348. }
  1349. EXPORT_SYMBOL(ipa_mhi_sps_channel_empty);
  1350. int ipa_qmi_enable_force_clear_datapath_send(
  1351. struct ipa_enable_force_clear_datapath_req_msg_v01 *req)
  1352. {
  1353. int ret;
  1354. IPA_API_DISPATCH_RETURN(ipa_qmi_enable_force_clear_datapath_send, req);
  1355. return ret;
  1356. }
  1357. EXPORT_SYMBOL(ipa_qmi_enable_force_clear_datapath_send);
  1358. int ipa_qmi_disable_force_clear_datapath_send(
  1359. struct ipa_disable_force_clear_datapath_req_msg_v01 *req)
  1360. {
  1361. int ret;
  1362. IPA_API_DISPATCH_RETURN(ipa_qmi_disable_force_clear_datapath_send, req);
  1363. return ret;
  1364. }
  1365. EXPORT_SYMBOL(ipa_qmi_disable_force_clear_datapath_send);
  1366. int ipa_generate_tag_process(void)
  1367. {
  1368. int ret;
  1369. IPA_API_DISPATCH_RETURN(ipa_generate_tag_process);
  1370. return ret;
  1371. }
  1372. EXPORT_SYMBOL(ipa_generate_tag_process);
  1373. int ipa_disable_sps_pipe(enum ipa_client_type client)
  1374. {
  1375. int ret;
  1376. IPA_API_DISPATCH_RETURN(ipa_disable_sps_pipe, client);
  1377. return ret;
  1378. }
  1379. EXPORT_SYMBOL(ipa_disable_sps_pipe);
  1380. int ipa_mhi_reset_channel_internal(enum ipa_client_type client)
  1381. {
  1382. int ret;
  1383. IPA_API_DISPATCH_RETURN(ipa_mhi_reset_channel_internal, client);
  1384. return ret;
  1385. }
  1386. EXPORT_SYMBOL(ipa_mhi_reset_channel_internal);
  1387. int ipa_mhi_start_channel_internal(enum ipa_client_type client)
  1388. {
  1389. int ret;
  1390. IPA_API_DISPATCH_RETURN(ipa_mhi_start_channel_internal, client);
  1391. return ret;
  1392. }
  1393. EXPORT_SYMBOL(ipa_mhi_start_channel_internal);
  1394. void ipa_get_holb(int ep_idx, struct ipa_ep_cfg_holb *holb)
  1395. {
  1396. IPA_API_DISPATCH(ipa_get_holb, ep_idx, holb);
  1397. }
  1398. EXPORT_SYMBOL(ipa_get_holb);
  1399. void ipa_set_tag_process_before_gating(bool val)
  1400. {
  1401. IPA_API_DISPATCH(ipa_set_tag_process_before_gating, val);
  1402. }
  1403. EXPORT_SYMBOL(ipa_set_tag_process_before_gating);
  1404. int ipa_mhi_query_ch_info(enum ipa_client_type client,
  1405. struct gsi_chan_info *ch_info)
  1406. {
  1407. int ret;
  1408. IPA_API_DISPATCH_RETURN(ipa_mhi_query_ch_info, client, ch_info);
  1409. return ret;
  1410. }
  1411. EXPORT_SYMBOL(ipa_mhi_query_ch_info);
  1412. int ipa_uc_mhi_suspend_channel(int channelHandle)
  1413. {
  1414. int ret;
  1415. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_suspend_channel, channelHandle);
  1416. return ret;
  1417. }
  1418. EXPORT_SYMBOL(ipa_uc_mhi_suspend_channel);
  1419. int ipa_uc_mhi_stop_event_update_channel(int channelHandle)
  1420. {
  1421. int ret;
  1422. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_stop_event_update_channel,
  1423. channelHandle);
  1424. return ret;
  1425. }
  1426. EXPORT_SYMBOL(ipa_uc_mhi_stop_event_update_channel);
  1427. bool ipa_has_open_aggr_frame(enum ipa_client_type client)
  1428. {
  1429. bool ret;
  1430. IPA_API_DISPATCH_RETURN_BOOL(ipa_has_open_aggr_frame, client);
  1431. return ret;
  1432. }
  1433. EXPORT_SYMBOL(ipa_has_open_aggr_frame);
  1434. int ipa_mhi_resume_channels_internal(enum ipa_client_type client,
  1435. bool LPTransitionRejected, bool brstmode_enabled,
  1436. union __packed gsi_channel_scratch ch_scratch, u8 index)
  1437. {
  1438. int ret;
  1439. IPA_API_DISPATCH_RETURN(ipa_mhi_resume_channels_internal, client,
  1440. LPTransitionRejected, brstmode_enabled, ch_scratch,
  1441. index);
  1442. return ret;
  1443. }
  1444. EXPORT_SYMBOL(ipa_mhi_resume_channels_internal);
  1445. int ipa_uc_mhi_send_dl_ul_sync_info(union IpaHwMhiDlUlSyncCmdData_t *cmd)
  1446. {
  1447. int ret;
  1448. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_send_dl_ul_sync_info,
  1449. cmd);
  1450. return ret;
  1451. }
  1452. EXPORT_SYMBOL(ipa_uc_mhi_send_dl_ul_sync_info);
  1453. int ipa_mhi_destroy_channel(enum ipa_client_type client)
  1454. {
  1455. int ret;
  1456. IPA_API_DISPATCH_RETURN(ipa_mhi_destroy_channel, client);
  1457. return ret;
  1458. }
  1459. EXPORT_SYMBOL(ipa_mhi_destroy_channel);
  1460. int ipa_uc_mhi_init(void (*ready_cb)(void),
  1461. void (*wakeup_request_cb)(void))
  1462. {
  1463. int ret;
  1464. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_init, ready_cb, wakeup_request_cb);
  1465. return ret;
  1466. }
  1467. EXPORT_SYMBOL(ipa_uc_mhi_init);
  1468. void ipa_uc_mhi_cleanup(void)
  1469. {
  1470. IPA_API_DISPATCH(ipa_uc_mhi_cleanup);
  1471. }
  1472. EXPORT_SYMBOL(ipa_uc_mhi_cleanup);
  1473. int ipa_uc_mhi_print_stats(char *dbg_buff, int size)
  1474. {
  1475. int ret;
  1476. IPA_API_DISPATCH_RETURN(ipa_uc_mhi_print_stats, dbg_buff, size);
  1477. return ret;
  1478. }
  1479. EXPORT_SYMBOL(ipa_uc_mhi_print_stats);
  1480. /**
  1481. * ipa_uc_state_check() - Check the status of the uC interface
  1482. *
  1483. * Return value: 0 if the uC is loaded, interface is initialized
  1484. * and there was no recent failure in one of the commands.
  1485. * A negative value is returned otherwise.
  1486. */
  1487. int ipa_uc_state_check(void)
  1488. {
  1489. int ret;
  1490. IPA_API_DISPATCH_RETURN(ipa_uc_state_check);
  1491. return ret;
  1492. }
  1493. EXPORT_SYMBOL(ipa_uc_state_check);
  1494. int ipa_write_qmap_id(struct ipa_ioc_write_qmapid *param_in)
  1495. {
  1496. int ret;
  1497. IPA_API_DISPATCH_RETURN(ipa_write_qmap_id, param_in);
  1498. return ret;
  1499. }
  1500. EXPORT_SYMBOL(ipa_write_qmap_id);
  1501. /**
  1502. * ipa_remove_interrupt_handler() - Removes handler to an interrupt type
  1503. * @interrupt: Interrupt type
  1504. *
  1505. * Removes the handler and disable the specific bit in IRQ_EN register
  1506. */
  1507. int ipa_remove_interrupt_handler(enum ipa_irq_type interrupt)
  1508. {
  1509. int ret;
  1510. IPA_API_DISPATCH_RETURN(ipa_remove_interrupt_handler, interrupt);
  1511. return ret;
  1512. }
  1513. EXPORT_SYMBOL(ipa_remove_interrupt_handler);
  1514. /**
  1515. * ipa_get_hw_type() - Return IPA HW version
  1516. *
  1517. * Return value: enum ipa_hw_type
  1518. */
  1519. enum ipa_hw_type ipa_get_hw_type_internal(void)
  1520. {
  1521. return ipa_api_hw_type;
  1522. }
  1523. /**
  1524. * ipa_start_gsi_channel()- Startsa GSI channel in IPA
  1525. *
  1526. * Return value: 0 on success, negative otherwise
  1527. */
  1528. int ipa_start_gsi_channel(u32 clnt_hdl)
  1529. {
  1530. int ret;
  1531. IPA_API_DISPATCH_RETURN(ipa_start_gsi_channel, clnt_hdl);
  1532. return ret;
  1533. }
  1534. EXPORT_SYMBOL(ipa_start_gsi_channel);
  1535. /**
  1536. * ipa_get_version_string() - Get string representation of IPA version
  1537. * @ver: IPA version
  1538. *
  1539. * Return: Constant string representation
  1540. */
  1541. const char *ipa_get_version_string(enum ipa_hw_type ver)
  1542. {
  1543. const char *str;
  1544. switch (ver) {
  1545. case IPA_HW_v1_0:
  1546. str = "1.0";
  1547. break;
  1548. case IPA_HW_v1_1:
  1549. str = "1.1";
  1550. break;
  1551. case IPA_HW_v2_0:
  1552. str = "2.0";
  1553. break;
  1554. case IPA_HW_v2_1:
  1555. str = "2.1";
  1556. break;
  1557. case IPA_HW_v2_5:
  1558. str = "2.5/2.6";
  1559. break;
  1560. case IPA_HW_v2_6L:
  1561. str = "2.6L";
  1562. break;
  1563. case IPA_HW_v3_0:
  1564. str = "3.0";
  1565. break;
  1566. case IPA_HW_v3_1:
  1567. str = "3.1";
  1568. break;
  1569. case IPA_HW_v3_5:
  1570. str = "3.5";
  1571. break;
  1572. case IPA_HW_v3_5_1:
  1573. str = "3.5.1";
  1574. break;
  1575. case IPA_HW_v4_0:
  1576. str = "4.0";
  1577. break;
  1578. case IPA_HW_v4_1:
  1579. str = "4.1";
  1580. break;
  1581. case IPA_HW_v4_2:
  1582. str = "4.2";
  1583. break;
  1584. case IPA_HW_v4_5:
  1585. str = "4.5";
  1586. break;
  1587. case IPA_HW_v4_7:
  1588. str = "4.7";
  1589. break;
  1590. case IPA_HW_v4_9:
  1591. str = "4.9";
  1592. break;
  1593. default:
  1594. str = "Invalid version";
  1595. break;
  1596. }
  1597. return str;
  1598. }
  1599. EXPORT_SYMBOL(ipa_get_version_string);
  1600. static const struct of_device_id ipa_plat_drv_match[] = {
  1601. { .compatible = "qcom,ipa", },
  1602. { .compatible = "qcom,ipa-smmu-ap-cb", },
  1603. { .compatible = "qcom,ipa-smmu-wlan-cb", },
  1604. { .compatible = "qcom,ipa-smmu-uc-cb", },
  1605. { .compatible = "qcom,ipa-smmu-11ad-cb", },
  1606. { .compatible = "qcom,smp2p-map-ipa-1-in", },
  1607. { .compatible = "qcom,smp2p-map-ipa-1-out", },
  1608. {}
  1609. };
  1610. /*********************************************************/
  1611. /* PCIe Version */
  1612. /*********************************************************/
  1613. static const struct of_device_id ipa_pci_drv_match[] = {
  1614. { .compatible = "qcom,ipa", },
  1615. {}
  1616. };
  1617. /*
  1618. * Forward declarations of static functions required for PCI
  1619. * registraion
  1620. *
  1621. * VENDOR and DEVICE should be defined in pci_ids.h
  1622. */
  1623. static int ipa_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
  1624. static void ipa_pci_remove(struct pci_dev *pdev);
  1625. static void ipa_pci_shutdown(struct pci_dev *pdev);
  1626. static pci_ers_result_t ipa_pci_io_error_detected(struct pci_dev *dev,
  1627. pci_channel_state_t state);
  1628. static pci_ers_result_t ipa_pci_io_slot_reset(struct pci_dev *dev);
  1629. static void ipa_pci_io_resume(struct pci_dev *dev);
  1630. #define LOCAL_VENDOR 0x17CB
  1631. #define LOCAL_DEVICE 0x00ff
  1632. static const char ipa_pci_driver_name[] = "qcipav3";
  1633. static const struct pci_device_id ipa_pci_tbl[] = {
  1634. { PCI_DEVICE(LOCAL_VENDOR, LOCAL_DEVICE) },
  1635. { 0, 0, 0, 0, 0, 0, 0 }
  1636. };
  1637. MODULE_DEVICE_TABLE(pci, ipa_pci_tbl);
  1638. /* PCI Error Recovery */
  1639. static const struct pci_error_handlers ipa_pci_err_handler = {
  1640. .error_detected = ipa_pci_io_error_detected,
  1641. .slot_reset = ipa_pci_io_slot_reset,
  1642. .resume = ipa_pci_io_resume,
  1643. };
  1644. static struct pci_driver ipa_pci_driver = {
  1645. .name = ipa_pci_driver_name,
  1646. .id_table = ipa_pci_tbl,
  1647. .probe = ipa_pci_probe,
  1648. .remove = ipa_pci_remove,
  1649. .shutdown = ipa_pci_shutdown,
  1650. .err_handler = &ipa_pci_err_handler
  1651. };
  1652. static int ipa_generic_plat_drv_probe(struct platform_device *pdev_p)
  1653. {
  1654. int result;
  1655. /*
  1656. * IPA probe function can be called for multiple times as the same probe
  1657. * function handles multiple compatibilities
  1658. */
  1659. pr_debug("ipa: IPA driver probing started for %s\n",
  1660. pdev_p->dev.of_node->name);
  1661. if (!ipa_api_ctrl) {
  1662. ipa_api_ctrl = kzalloc(sizeof(*ipa_api_ctrl), GFP_KERNEL);
  1663. if (!ipa_api_ctrl)
  1664. return -ENOMEM;
  1665. /* Get IPA HW Version */
  1666. result = of_property_read_u32(pdev_p->dev.of_node,
  1667. "qcom,ipa-hw-ver", &ipa_api_hw_type);
  1668. if ((result) || (ipa_api_hw_type == 0)) {
  1669. pr_err("ipa: get resource failed for ipa-hw-ver!\n");
  1670. kfree(ipa_api_ctrl);
  1671. ipa_api_ctrl = 0;
  1672. return -ENODEV;
  1673. }
  1674. pr_debug("ipa: ipa_api_hw_type = %d\n", ipa_api_hw_type);
  1675. }
  1676. /* call probe based on IPA HW version */
  1677. switch (ipa_api_hw_type) {
  1678. case IPA_HW_v3_0:
  1679. case IPA_HW_v3_1:
  1680. case IPA_HW_v3_5:
  1681. case IPA_HW_v3_5_1:
  1682. case IPA_HW_v4_0:
  1683. case IPA_HW_v4_1:
  1684. case IPA_HW_v4_2:
  1685. case IPA_HW_v4_5:
  1686. case IPA_HW_v4_7:
  1687. case IPA_HW_v4_9:
  1688. result = ipa3_plat_drv_probe(pdev_p, ipa_api_ctrl,
  1689. ipa_plat_drv_match);
  1690. break;
  1691. default:
  1692. pr_err("ipa: unsupported version %d\n", ipa_api_hw_type);
  1693. return -EPERM;
  1694. }
  1695. if (result && result != -EPROBE_DEFER)
  1696. pr_err("ipa: ipa_plat_drv_probe failed\n");
  1697. return result;
  1698. }
  1699. static int ipa_ap_suspend(struct device *dev)
  1700. {
  1701. int ret;
  1702. IPA_API_DISPATCH_RETURN(ipa_ap_suspend, dev);
  1703. return ret;
  1704. }
  1705. static int ipa_ap_resume(struct device *dev)
  1706. {
  1707. int ret;
  1708. IPA_API_DISPATCH_RETURN(ipa_ap_resume, dev);
  1709. return ret;
  1710. }
  1711. /**
  1712. * ipa_inc_client_enable_clks() - Increase active clients counter, and
  1713. * enable ipa clocks if necessary
  1714. *
  1715. * Please do not use this API, use the wrapper macros instead (ipa_i.h)
  1716. * IPA_ACTIVE_CLIENTS_INC_XXX();
  1717. *
  1718. * Return codes:
  1719. * None
  1720. */
  1721. void ipa_inc_client_enable_clks(struct ipa_active_client_logging_info *id)
  1722. {
  1723. IPA_API_DISPATCH(ipa_inc_client_enable_clks, id);
  1724. }
  1725. EXPORT_SYMBOL(ipa_inc_client_enable_clks);
  1726. /**
  1727. * ipa_dec_client_disable_clks() - Increase active clients counter, and
  1728. * enable ipa clocks if necessary
  1729. *
  1730. * Please do not use this API, use the wrapper macros instead (ipa_i.h)
  1731. * IPA_ACTIVE_CLIENTS_DEC_XXX();
  1732. *
  1733. * Return codes:
  1734. * None
  1735. */
  1736. void ipa_dec_client_disable_clks(struct ipa_active_client_logging_info *id)
  1737. {
  1738. IPA_API_DISPATCH(ipa_dec_client_disable_clks, id);
  1739. }
  1740. EXPORT_SYMBOL(ipa_dec_client_disable_clks);
  1741. /**
  1742. * ipa_inc_client_enable_clks_no_block() - Only increment the number of active
  1743. * clients if no asynchronous actions should be done.Asynchronous actions are
  1744. * locking a mutex and waking up IPA HW.
  1745. *
  1746. * Please do not use this API, use the wrapper macros instead(ipa_i.h)
  1747. *
  1748. *
  1749. * Return codes : 0 for success
  1750. * -EPERM if an asynchronous action should have been done
  1751. */
  1752. int ipa_inc_client_enable_clks_no_block(
  1753. struct ipa_active_client_logging_info *id)
  1754. {
  1755. int ret;
  1756. IPA_API_DISPATCH_RETURN(ipa_inc_client_enable_clks_no_block, id);
  1757. return ret;
  1758. }
  1759. EXPORT_SYMBOL(ipa_inc_client_enable_clks_no_block);
  1760. /**
  1761. * ipa_suspend_resource_no_block() - suspend client endpoints related to the
  1762. * IPA_RM resource and decrement active clients counter. This function is
  1763. * guaranteed to avoid sleeping.
  1764. *
  1765. * @resource: [IN] IPA Resource Manager resource
  1766. *
  1767. * Return codes: 0 on success, negative on failure.
  1768. */
  1769. int ipa_suspend_resource_no_block(enum ipa_rm_resource_name resource)
  1770. {
  1771. int ret;
  1772. IPA_API_DISPATCH_RETURN(ipa_suspend_resource_no_block, resource);
  1773. return ret;
  1774. }
  1775. EXPORT_SYMBOL(ipa_suspend_resource_no_block);
  1776. /**
  1777. * ipa_resume_resource() - resume client endpoints related to the IPA_RM
  1778. * resource.
  1779. *
  1780. * @resource: [IN] IPA Resource Manager resource
  1781. *
  1782. * Return codes: 0 on success, negative on failure.
  1783. */
  1784. int ipa_resume_resource(enum ipa_rm_resource_name resource)
  1785. {
  1786. int ret;
  1787. IPA_API_DISPATCH_RETURN(ipa_resume_resource, resource);
  1788. return ret;
  1789. }
  1790. EXPORT_SYMBOL(ipa_resume_resource);
  1791. /**
  1792. * ipa_suspend_resource_sync() - suspend client endpoints related to the IPA_RM
  1793. * resource and decrement active clients counter, which may result in clock
  1794. * gating of IPA clocks.
  1795. *
  1796. * @resource: [IN] IPA Resource Manager resource
  1797. *
  1798. * Return codes: 0 on success, negative on failure.
  1799. */
  1800. int ipa_suspend_resource_sync(enum ipa_rm_resource_name resource)
  1801. {
  1802. int ret;
  1803. IPA_API_DISPATCH_RETURN(ipa_suspend_resource_sync, resource);
  1804. return ret;
  1805. }
  1806. EXPORT_SYMBOL(ipa_suspend_resource_sync);
  1807. /**
  1808. * ipa_set_required_perf_profile() - set IPA to the specified performance
  1809. * profile based on the bandwidth, unless minimum voltage required is
  1810. * higher. In this case the floor_voltage specified will be used.
  1811. * @floor_voltage: minimum voltage to operate
  1812. * @bandwidth_mbps: needed bandwidth from IPA
  1813. *
  1814. * Return codes: 0 on success, negative on failure.
  1815. */
  1816. int ipa_set_required_perf_profile(enum ipa_voltage_level floor_voltage,
  1817. u32 bandwidth_mbps)
  1818. {
  1819. int ret;
  1820. IPA_API_DISPATCH_RETURN(ipa_set_required_perf_profile, floor_voltage,
  1821. bandwidth_mbps);
  1822. return ret;
  1823. }
  1824. EXPORT_SYMBOL(ipa_set_required_perf_profile);
  1825. /**
  1826. * ipa_get_ipc_logbuf() - return a pointer to IPA driver IPC log
  1827. */
  1828. void *ipa_get_ipc_logbuf(void)
  1829. {
  1830. void *ret;
  1831. IPA_API_DISPATCH_RETURN_PTR(ipa_get_ipc_logbuf);
  1832. return ret;
  1833. }
  1834. EXPORT_SYMBOL(ipa_get_ipc_logbuf);
  1835. /**
  1836. * ipa_get_ipc_logbuf_low() - return a pointer to IPA driver IPC low prio log
  1837. */
  1838. void *ipa_get_ipc_logbuf_low(void)
  1839. {
  1840. void *ret;
  1841. IPA_API_DISPATCH_RETURN_PTR(ipa_get_ipc_logbuf_low);
  1842. return ret;
  1843. }
  1844. EXPORT_SYMBOL(ipa_get_ipc_logbuf_low);
  1845. /**
  1846. * ipa_assert() - general function for assertion
  1847. */
  1848. void ipa_assert(void)
  1849. {
  1850. pr_err("IPA: unrecoverable error has occurred, asserting\n");
  1851. BUG();
  1852. }
  1853. EXPORT_SYMBOL(ipa_assert);
  1854. /**
  1855. * ipa_rx_poll() - Poll the rx packets from IPA HW in the
  1856. * softirq context
  1857. *
  1858. * @budget: number of packets to be polled in single iteration
  1859. *
  1860. * Return codes: >= 0 : Actual number of packets polled
  1861. *
  1862. */
  1863. int ipa_rx_poll(u32 clnt_hdl, int budget)
  1864. {
  1865. int ret;
  1866. IPA_API_DISPATCH_RETURN(ipa_rx_poll, clnt_hdl, budget);
  1867. return ret;
  1868. }
  1869. EXPORT_SYMBOL(ipa_rx_poll);
  1870. /**
  1871. * ipa_recycle_wan_skb() - Recycle the Wan skb
  1872. *
  1873. * @skb: skb that needs to recycle
  1874. *
  1875. */
  1876. void ipa_recycle_wan_skb(struct sk_buff *skb)
  1877. {
  1878. IPA_API_DISPATCH(ipa_recycle_wan_skb, skb);
  1879. }
  1880. EXPORT_SYMBOL(ipa_recycle_wan_skb);
  1881. /**
  1882. * ipa_setup_uc_ntn_pipes() - setup uc offload pipes
  1883. */
  1884. int ipa_setup_uc_ntn_pipes(struct ipa_ntn_conn_in_params *inp,
  1885. ipa_notify_cb notify, void *priv, u8 hdr_len,
  1886. struct ipa_ntn_conn_out_params *outp)
  1887. {
  1888. int ret;
  1889. IPA_API_DISPATCH_RETURN(ipa_setup_uc_ntn_pipes, inp,
  1890. notify, priv, hdr_len, outp);
  1891. return ret;
  1892. }
  1893. EXPORT_SYMBOL(ipa_setup_uc_ntn_pipes);
  1894. /**
  1895. * ipa_tear_down_uc_offload_pipes() - tear down uc offload pipes
  1896. */
  1897. int ipa_tear_down_uc_offload_pipes(int ipa_ep_idx_ul,
  1898. int ipa_ep_idx_dl, struct ipa_ntn_conn_in_params *params)
  1899. {
  1900. int ret;
  1901. IPA_API_DISPATCH_RETURN(ipa_tear_down_uc_offload_pipes, ipa_ep_idx_ul,
  1902. ipa_ep_idx_dl, params);
  1903. return ret;
  1904. }
  1905. EXPORT_SYMBOL(ipa_tear_down_uc_offload_pipes);
  1906. /**
  1907. * ipa_get_pdev() - return a pointer to IPA dev struct
  1908. *
  1909. * Return value: a pointer to IPA dev struct
  1910. *
  1911. */
  1912. struct device *ipa_get_pdev(void)
  1913. {
  1914. struct device *ret;
  1915. IPA_API_DISPATCH_RETURN_PTR(ipa_get_pdev);
  1916. return ret;
  1917. }
  1918. EXPORT_SYMBOL(ipa_get_pdev);
  1919. int ipa_ntn_uc_reg_rdyCB(void (*ipauc_ready_cb)(void *user_data),
  1920. void *user_data)
  1921. {
  1922. int ret;
  1923. IPA_API_DISPATCH_RETURN(ipa_ntn_uc_reg_rdyCB,
  1924. ipauc_ready_cb, user_data);
  1925. return ret;
  1926. }
  1927. EXPORT_SYMBOL(ipa_ntn_uc_reg_rdyCB);
  1928. void ipa_ntn_uc_dereg_rdyCB(void)
  1929. {
  1930. IPA_API_DISPATCH(ipa_ntn_uc_dereg_rdyCB);
  1931. }
  1932. EXPORT_SYMBOL(ipa_ntn_uc_dereg_rdyCB);
  1933. /**
  1934. * ipa_conn_wdi_pipes() - connect wdi pipes
  1935. */
  1936. int ipa_conn_wdi_pipes(struct ipa_wdi_conn_in_params *in,
  1937. struct ipa_wdi_conn_out_params *out,
  1938. ipa_wdi_meter_notifier_cb wdi_notify)
  1939. {
  1940. int ret;
  1941. IPA_API_DISPATCH_RETURN(ipa_conn_wdi_pipes, in, out, wdi_notify);
  1942. return ret;
  1943. }
  1944. EXPORT_SYMBOL(ipa_conn_wdi_pipes);
  1945. /**
  1946. * ipa_disconn_wdi_pipes() - disconnect wdi pipes
  1947. */
  1948. int ipa_disconn_wdi_pipes(int ipa_ep_idx_tx, int ipa_ep_idx_rx)
  1949. {
  1950. int ret;
  1951. IPA_API_DISPATCH_RETURN(ipa_disconn_wdi_pipes, ipa_ep_idx_tx,
  1952. ipa_ep_idx_rx);
  1953. return ret;
  1954. }
  1955. EXPORT_SYMBOL(ipa_disconn_wdi_pipes);
  1956. /**
  1957. * ipa_enable_wdi_pipes() - enable wdi pipes
  1958. */
  1959. int ipa_enable_wdi_pipes(int ipa_ep_idx_tx, int ipa_ep_idx_rx)
  1960. {
  1961. int ret;
  1962. IPA_API_DISPATCH_RETURN(ipa_enable_wdi_pipes, ipa_ep_idx_tx,
  1963. ipa_ep_idx_rx);
  1964. return ret;
  1965. }
  1966. EXPORT_SYMBOL(ipa_enable_wdi_pipes);
  1967. /**
  1968. * ipa_disable_wdi_pipes() - disable wdi pipes
  1969. */
  1970. int ipa_disable_wdi_pipes(int ipa_ep_idx_tx, int ipa_ep_idx_rx)
  1971. {
  1972. int ret;
  1973. IPA_API_DISPATCH_RETURN(ipa_disable_wdi_pipes, ipa_ep_idx_tx,
  1974. ipa_ep_idx_rx);
  1975. return ret;
  1976. }
  1977. EXPORT_SYMBOL(ipa_disable_wdi_pipes);
  1978. /**
  1979. * ipa_wigig_uc_msi_init() - smmu map\unmap msi related wigig HW registers
  1980. * and init\deinit uC msi config
  1981. */
  1982. int ipa_wigig_uc_msi_init(bool init,
  1983. phys_addr_t periph_baddr_pa,
  1984. phys_addr_t pseudo_cause_pa,
  1985. phys_addr_t int_gen_tx_pa,
  1986. phys_addr_t int_gen_rx_pa,
  1987. phys_addr_t dma_ep_misc_pa)
  1988. {
  1989. int ret;
  1990. IPA_API_DISPATCH_RETURN(ipa_wigig_uc_msi_init, init,
  1991. periph_baddr_pa,
  1992. pseudo_cause_pa,
  1993. int_gen_tx_pa,
  1994. int_gen_rx_pa,
  1995. dma_ep_misc_pa);
  1996. return ret;
  1997. }
  1998. EXPORT_SYMBOL(ipa_wigig_uc_msi_init);
  1999. /**
  2000. * ipa_conn_wigig_rx_pipe_i() - connect wigig rx pipe
  2001. */
  2002. int ipa_conn_wigig_rx_pipe_i(void *in, struct ipa_wigig_conn_out_params *out,
  2003. struct dentry **parent)
  2004. {
  2005. int ret;
  2006. IPA_API_DISPATCH_RETURN(ipa_conn_wigig_rx_pipe_i, in, out, parent);
  2007. return ret;
  2008. }
  2009. EXPORT_SYMBOL(ipa_conn_wigig_rx_pipe_i);
  2010. /**
  2011. * ipa_conn_wigig_client_i() - connect a wigig client
  2012. */
  2013. int ipa_conn_wigig_client_i(void *in,
  2014. struct ipa_wigig_conn_out_params *out,
  2015. ipa_notify_cb tx_notify,
  2016. void *priv)
  2017. {
  2018. int ret;
  2019. IPA_API_DISPATCH_RETURN(ipa_conn_wigig_client_i, in, out,
  2020. tx_notify, priv);
  2021. return ret;
  2022. }
  2023. EXPORT_SYMBOL(ipa_conn_wigig_client_i);
  2024. /**
  2025. * ipa_disconn_wigig_pipe_i() - disconnect a wigig pipe
  2026. */
  2027. int ipa_disconn_wigig_pipe_i(enum ipa_client_type client,
  2028. struct ipa_wigig_pipe_setup_info_smmu *pipe_smmu,
  2029. void *dbuff)
  2030. {
  2031. int ret;
  2032. IPA_API_DISPATCH_RETURN(ipa_disconn_wigig_pipe_i, client,
  2033. pipe_smmu, dbuff);
  2034. return ret;
  2035. }
  2036. EXPORT_SYMBOL(ipa_disconn_wigig_pipe_i);
  2037. /**
  2038. * ipa_enable_wigig_pipe() - enable a wigig pipe
  2039. */
  2040. int ipa_enable_wigig_pipe_i(enum ipa_client_type client)
  2041. {
  2042. int ret;
  2043. IPA_API_DISPATCH_RETURN(ipa_enable_wigig_pipe_i, client);
  2044. return ret;
  2045. }
  2046. EXPORT_SYMBOL(ipa_enable_wigig_pipe_i);
  2047. /**
  2048. * ipa_disable_wigig_pipe_i() - disable a wigig pipe
  2049. */
  2050. int ipa_disable_wigig_pipe_i(enum ipa_client_type client)
  2051. {
  2052. int ret;
  2053. IPA_API_DISPATCH_RETURN(ipa_disable_wigig_pipe_i, client);
  2054. return ret;
  2055. }
  2056. EXPORT_SYMBOL(ipa_disable_wigig_pipe_i);
  2057. /**
  2058. * ipa_tz_unlock_reg() - Allow AP access to memory regions controlled by TZ
  2059. */
  2060. int ipa_tz_unlock_reg(struct ipa_tz_unlock_reg_info *reg_info, u16 num_regs)
  2061. {
  2062. int ret;
  2063. IPA_API_DISPATCH_RETURN(ipa_tz_unlock_reg, reg_info, num_regs);
  2064. return ret;
  2065. }
  2066. void ipa_register_client_callback(int (*client_cb)(bool is_lock),
  2067. bool (*teth_port_state)(void),
  2068. enum ipa_client_type client)
  2069. {
  2070. IPA_API_DISPATCH(ipa_register_client_callback,
  2071. client_cb, teth_port_state, client);
  2072. }
  2073. EXPORT_SYMBOL(ipa_register_client_callback);
  2074. void ipa_deregister_client_callback(enum ipa_client_type client)
  2075. {
  2076. IPA_API_DISPATCH(ipa_deregister_client_callback,
  2077. client);
  2078. }
  2079. EXPORT_SYMBOL(ipa_deregister_client_callback);
  2080. int ipa_uc_debug_stats_alloc(
  2081. struct IpaHwOffloadStatsAllocCmdData_t cmdinfo)
  2082. {
  2083. int ret;
  2084. IPA_API_DISPATCH_RETURN(ipa_uc_debug_stats_alloc, cmdinfo);
  2085. return ret;
  2086. }
  2087. EXPORT_SYMBOL(ipa_uc_debug_stats_alloc);
  2088. int ipa_uc_debug_stats_dealloc(uint32_t prot_id)
  2089. {
  2090. int ret;
  2091. IPA_API_DISPATCH_RETURN(ipa_uc_debug_stats_dealloc, prot_id);
  2092. return ret;
  2093. }
  2094. EXPORT_SYMBOL(ipa_uc_debug_stats_dealloc);
  2095. void ipa_get_gsi_stats(int prot_id,
  2096. struct ipa_uc_dbg_ring_stats *stats)
  2097. {
  2098. IPA_API_DISPATCH(ipa_get_gsi_stats,
  2099. prot_id, stats);
  2100. }
  2101. EXPORT_SYMBOL(ipa_get_gsi_stats);
  2102. int ipa_get_prot_id(enum ipa_client_type client)
  2103. {
  2104. int ret;
  2105. IPA_API_DISPATCH_RETURN(ipa_get_prot_id,
  2106. client);
  2107. return ret;
  2108. }
  2109. EXPORT_SYMBOL(ipa_get_prot_id);
  2110. static const struct dev_pm_ops ipa_pm_ops = {
  2111. .suspend_noirq = ipa_ap_suspend,
  2112. .resume_noirq = ipa_ap_resume,
  2113. };
  2114. static struct platform_driver ipa_plat_drv = {
  2115. .probe = ipa_generic_plat_drv_probe,
  2116. .driver = {
  2117. .name = DRV_NAME,
  2118. .pm = &ipa_pm_ops,
  2119. .of_match_table = ipa_plat_drv_match,
  2120. },
  2121. };
  2122. /*********************************************************/
  2123. /* PCIe Version */
  2124. /*********************************************************/
  2125. static int ipa_pci_probe(
  2126. struct pci_dev *pci_dev,
  2127. const struct pci_device_id *ent)
  2128. {
  2129. int result;
  2130. if (!pci_dev || !ent) {
  2131. pr_err(
  2132. "Bad arg: pci_dev (%pK) and/or ent (%pK)\n",
  2133. pci_dev, ent);
  2134. return -EOPNOTSUPP;
  2135. }
  2136. if (!ipa_api_ctrl) {
  2137. ipa_api_ctrl = kzalloc(sizeof(*ipa_api_ctrl), GFP_KERNEL);
  2138. if (ipa_api_ctrl == NULL)
  2139. return -ENOMEM;
  2140. /* Get IPA HW Version */
  2141. result = of_property_read_u32(NULL,
  2142. "qcom,ipa-hw-ver", &ipa_api_hw_type);
  2143. if (result || ipa_api_hw_type == 0) {
  2144. pr_err("ipa: get resource failed for ipa-hw-ver!\n");
  2145. kfree(ipa_api_ctrl);
  2146. ipa_api_ctrl = NULL;
  2147. return -ENODEV;
  2148. }
  2149. pr_debug("ipa: ipa_api_hw_type = %d\n", ipa_api_hw_type);
  2150. }
  2151. /*
  2152. * Call a reduced version of platform_probe appropriate for PCIe
  2153. */
  2154. result = ipa3_pci_drv_probe(pci_dev, ipa_api_ctrl, ipa_pci_drv_match);
  2155. if (result && result != -EPROBE_DEFER)
  2156. pr_err("ipa: ipa3_pci_drv_probe failed\n");
  2157. return result;
  2158. }
  2159. static void ipa_pci_remove(struct pci_dev *pci_dev)
  2160. {
  2161. }
  2162. static void ipa_pci_shutdown(struct pci_dev *pci_dev)
  2163. {
  2164. }
  2165. static pci_ers_result_t ipa_pci_io_error_detected(struct pci_dev *pci_dev,
  2166. pci_channel_state_t state)
  2167. {
  2168. return 0;
  2169. }
  2170. static pci_ers_result_t ipa_pci_io_slot_reset(struct pci_dev *pci_dev)
  2171. {
  2172. return 0;
  2173. }
  2174. static void ipa_pci_io_resume(struct pci_dev *pci_dev)
  2175. {
  2176. }
  2177. static int __init ipa_module_init(void)
  2178. {
  2179. pr_debug("IPA module init\n");
  2180. ipa3_ctx = kzalloc(sizeof(*ipa3_ctx), GFP_KERNEL);
  2181. if (!ipa3_ctx) {
  2182. return -ENOMEM;
  2183. }
  2184. mutex_init(&ipa3_ctx->lock);
  2185. if (running_emulation) {
  2186. /* Register as a PCI device driver */
  2187. return pci_register_driver(&ipa_pci_driver);
  2188. }
  2189. /* Register as a platform device driver */
  2190. return platform_driver_register(&ipa_plat_drv);
  2191. }
  2192. subsys_initcall(ipa_module_init);
  2193. static void __exit ipa_module_exit(void)
  2194. {
  2195. if (running_emulation)
  2196. pci_unregister_driver(&ipa_pci_driver);
  2197. platform_driver_unregister(&ipa_plat_drv);
  2198. kfree(ipa3_ctx);
  2199. ipa3_ctx = NULL;
  2200. }
  2201. module_exit(ipa_module_exit);
  2202. MODULE_SOFTDEP("pre: subsys-pil-tz");
  2203. MODULE_SOFTDEP("pre: qcom-arm-smmu-mod");
  2204. MODULE_LICENSE("GPL v2");
  2205. MODULE_DESCRIPTION("IPA HW device driver");