ipa_i.h 97 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _IPA3_I_H_
  6. #define _IPA3_I_H_
  7. #include <linux/bitops.h>
  8. #include <linux/cdev.h>
  9. #include <linux/export.h>
  10. #include <linux/idr.h>
  11. #include <linux/list.h>
  12. #include <linux/mutex.h>
  13. #include <linux/skbuff.h>
  14. #include <linux/slab.h>
  15. #include <linux/notifier.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/netdevice.h>
  18. #include <linux/ipa.h>
  19. #include <linux/ipa_usb.h>
  20. #include <linux/iommu.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/firmware.h>
  23. #include "ipa_qmi_service.h"
  24. #include "../ipa_api.h"
  25. #include "ipahal/ipahal_reg.h"
  26. #include "ipahal/ipahal.h"
  27. #include "ipahal/ipahal_fltrt.h"
  28. #include "ipahal/ipahal_hw_stats.h"
  29. #include "../ipa_common_i.h"
  30. #include "ipa_uc_offload_i.h"
  31. #include "ipa_pm.h"
  32. #include "ipa_defs.h"
  33. #include <linux/mailbox_client.h>
  34. #include <linux/mailbox/qmp.h>
  35. #include <linux/rmnet_ipa_fd_ioctl.h>
  36. #define IPA_DEV_NAME_MAX_LEN 15
  37. #define DRV_NAME "ipa"
  38. #define IPA_COOKIE 0x57831603
  39. #define IPA_RT_RULE_COOKIE 0x57831604
  40. #define IPA_RT_TBL_COOKIE 0x57831605
  41. #define IPA_FLT_COOKIE 0x57831606
  42. #define IPA_HDR_COOKIE 0x57831607
  43. #define IPA_PROC_HDR_COOKIE 0x57831608
  44. #define MTU_BYTE 1500
  45. #define IPA_EP_NOT_ALLOCATED (-1)
  46. #define IPA3_MAX_NUM_PIPES 31
  47. #define IPA_SYS_DESC_FIFO_SZ 0x800
  48. #define IPA_SYS_TX_DATA_DESC_FIFO_SZ 0x1000
  49. #define IPA_COMMON_EVENT_RING_SIZE 0x7C00
  50. #define IPA_LAN_RX_HEADER_LENGTH (2)
  51. #define IPA_QMAP_HEADER_LENGTH (4)
  52. #define IPA_DL_CHECKSUM_LENGTH (8)
  53. #define IPA_NUM_DESC_PER_SW_TX (3)
  54. #define IPA_GENERIC_RX_POOL_SZ 192
  55. #define IPA_UC_FINISH_MAX 6
  56. #define IPA_UC_WAIT_MIN_SLEEP 1000
  57. #define IPA_UC_WAII_MAX_SLEEP 1200
  58. /*
  59. * The transport descriptor size was changed to GSI_CHAN_RE_SIZE_16B, but
  60. * IPA users still use sps_iovec size as FIFO element size.
  61. */
  62. #define IPA_FIFO_ELEMENT_SIZE 8
  63. #define IPA_MAX_STATUS_STAT_NUM 30
  64. #define IPA_IPC_LOG_PAGES 50
  65. #define IPA_MAX_NUM_REQ_CACHE 10
  66. #define NAPI_WEIGHT 60
  67. #define IPADBG(fmt, args...) \
  68. do { \
  69. pr_debug(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args);\
  70. if (ipa3_ctx) { \
  71. IPA_IPC_LOGGING(ipa3_ctx->logbuf, \
  72. DRV_NAME " %s:%d " fmt, ## args); \
  73. IPA_IPC_LOGGING(ipa3_ctx->logbuf_low, \
  74. DRV_NAME " %s:%d " fmt, ## args); \
  75. } \
  76. } while (0)
  77. #define IPADBG_LOW(fmt, args...) \
  78. do { \
  79. pr_debug(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args);\
  80. if (ipa3_ctx) \
  81. IPA_IPC_LOGGING(ipa3_ctx->logbuf_low, \
  82. DRV_NAME " %s:%d " fmt, ## args); \
  83. } while (0)
  84. #define IPAERR(fmt, args...) \
  85. do { \
  86. pr_err(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args);\
  87. if (ipa3_ctx) { \
  88. IPA_IPC_LOGGING(ipa3_ctx->logbuf, \
  89. DRV_NAME " %s:%d " fmt, ## args); \
  90. IPA_IPC_LOGGING(ipa3_ctx->logbuf_low, \
  91. DRV_NAME " %s:%d " fmt, ## args); \
  92. } \
  93. } while (0)
  94. #define IPAERR_RL(fmt, args...) \
  95. do { \
  96. pr_err_ratelimited_ipa(DRV_NAME " %s:%d " fmt, __func__,\
  97. __LINE__, ## args);\
  98. if (ipa3_ctx) { \
  99. IPA_IPC_LOGGING(ipa3_ctx->logbuf, \
  100. DRV_NAME " %s:%d " fmt, ## args); \
  101. IPA_IPC_LOGGING(ipa3_ctx->logbuf_low, \
  102. DRV_NAME " %s:%d " fmt, ## args); \
  103. } \
  104. } while (0)
  105. #define IPALOG_VnP_ADDRS(ptr) \
  106. do { \
  107. phys_addr_t b = (phys_addr_t) virt_to_phys(ptr); \
  108. IPAERR("%s: VIRT: %pK PHYS: %pa\n", \
  109. #ptr, ptr, &b); \
  110. } while (0)
  111. /* round addresses for closes page per SMMU requirements */
  112. #define IPA_SMMU_ROUND_TO_PAGE(iova, pa, size, iova_p, pa_p, size_p) \
  113. do { \
  114. (iova_p) = rounddown((iova), PAGE_SIZE); \
  115. (pa_p) = rounddown((pa), PAGE_SIZE); \
  116. (size_p) = roundup((size) + (pa) - (pa_p), PAGE_SIZE); \
  117. } while (0)
  118. #define WLAN_AMPDU_TX_EP 15
  119. #define WLAN_PROD_TX_EP 19
  120. #define WLAN1_CONS_RX_EP 14
  121. #define WLAN2_CONS_RX_EP 16
  122. #define WLAN3_CONS_RX_EP 17
  123. #define WLAN4_CONS_RX_EP 18
  124. #define IPA_RAM_NAT_OFST \
  125. IPA_MEM_PART(nat_tbl_ofst)
  126. #define IPA_RAM_NAT_SIZE \
  127. IPA_MEM_PART(nat_tbl_size)
  128. #define IPA_RAM_IPV6CT_OFST 0
  129. #define IPA_RAM_IPV6CT_SIZE 0
  130. #define IPA_MEM_CANARY_VAL 0xdeadbeef
  131. #define IS_IPV6CT_MEM_DEV(d) \
  132. (((void *) (d) == (void *) &ipa3_ctx->ipv6ct_mem))
  133. #define IS_NAT_MEM_DEV(d) \
  134. (((void *) (d) == (void *) &ipa3_ctx->nat_mem))
  135. #define IPA_STATS
  136. #ifdef IPA_STATS
  137. #define IPA_STATS_INC_CNT(val) (++val)
  138. #define IPA_STATS_DEC_CNT(val) (--val)
  139. #define IPA_STATS_EXCP_CNT(__excp, __base) do { \
  140. if (__excp < 0 || __excp >= IPAHAL_PKT_STATUS_EXCEPTION_MAX) \
  141. break; \
  142. ++__base[__excp]; \
  143. } while (0)
  144. #else
  145. #define IPA_STATS_INC_CNT(x) do { } while (0)
  146. #define IPA_STATS_DEC_CNT(x)
  147. #define IPA_STATS_EXCP_CNT(__excp, __base) do { } while (0)
  148. #endif
  149. #define IPA_HDR_BIN0 0
  150. #define IPA_HDR_BIN1 1
  151. #define IPA_HDR_BIN2 2
  152. #define IPA_HDR_BIN3 3
  153. #define IPA_HDR_BIN4 4
  154. #define IPA_HDR_BIN_MAX 5
  155. #define IPA_HDR_PROC_CTX_BIN0 0
  156. #define IPA_HDR_PROC_CTX_BIN1 1
  157. #define IPA_HDR_PROC_CTX_BIN_MAX 2
  158. #define IPA_RX_POOL_CEIL 32
  159. #define IPA_RX_SKB_SIZE 1792
  160. #define IPA_A5_MUX_HDR_NAME "ipa_excp_hdr"
  161. #define IPA_LAN_RX_HDR_NAME "ipa_lan_hdr"
  162. #define IPA_INVALID_L4_PROTOCOL 0xFF
  163. #define IPA_HDR_PROC_CTX_TABLE_ALIGNMENT_BYTE 8
  164. #define IPA_HDR_PROC_CTX_TABLE_ALIGNMENT(start_ofst) \
  165. (((start_ofst) + IPA_HDR_PROC_CTX_TABLE_ALIGNMENT_BYTE - 1) & \
  166. ~(IPA_HDR_PROC_CTX_TABLE_ALIGNMENT_BYTE - 1))
  167. #define MAX_RESOURCE_TO_CLIENTS (IPA_CLIENT_MAX)
  168. #define IPA_MEM_PART(x_) (ipa3_ctx->ctrl->mem_partition->x_)
  169. #define IPA_GSI_CHANNEL_STOP_MAX_RETRY 10
  170. #define IPA_GSI_CHANNEL_STOP_PKT_SIZE 1
  171. #define IPA_GSI_CHANNEL_EMPTY_MAX_RETRY 15
  172. #define IPA_GSI_CHANNEL_EMPTY_SLEEP_MIN_USEC (1000)
  173. #define IPA_GSI_CHANNEL_EMPTY_SLEEP_MAX_USEC (2000)
  174. #define IPA_SLEEP_CLK_RATE_KHZ (32)
  175. #define IPA3_ACTIVE_CLIENTS_LOG_BUFFER_SIZE_LINES 120
  176. #define IPA3_ACTIVE_CLIENTS_LOG_LINE_LEN 96
  177. #define IPA3_ACTIVE_CLIENTS_LOG_HASHTABLE_SIZE 50
  178. #define IPA3_ACTIVE_CLIENTS_LOG_NAME_LEN 40
  179. #define SMEM_IPA_FILTER_TABLE 497
  180. enum {
  181. SMEM_APPS,
  182. SMEM_MODEM,
  183. SMEM_Q6,
  184. SMEM_DSPS,
  185. SMEM_WCNSS,
  186. SMEM_CDSP,
  187. SMEM_RPM,
  188. SMEM_TZ,
  189. SMEM_SPSS,
  190. SMEM_HYP,
  191. NUM_SMEM_SUBSYSTEMS,
  192. };
  193. #define IPA_WDI_RX_RING_RES 0
  194. #define IPA_WDI_RX_RING_RP_RES 1
  195. #define IPA_WDI_RX_COMP_RING_RES 2
  196. #define IPA_WDI_RX_COMP_RING_WP_RES 3
  197. #define IPA_WDI_TX_RING_RES 4
  198. #define IPA_WDI_CE_RING_RES 5
  199. #define IPA_WDI_CE_DB_RES 6
  200. #define IPA_WDI_TX_DB_RES 7
  201. #define IPA_WDI_MAX_RES 8
  202. /* use QMAP header reserved bit to identify tethered traffic */
  203. #define IPA_QMAP_TETH_BIT (1 << 30)
  204. #ifdef CONFIG_ARM64
  205. /* Outer caches unsupported on ARM64 platforms */
  206. # define outer_flush_range(x, y)
  207. # define __cpuc_flush_dcache_area __flush_dcache_area
  208. #endif
  209. #define IPA_APP_VOTE_MAX 500
  210. #define IPA_SMP2P_OUT_CLK_RSP_CMPLT_IDX 0
  211. #define IPA_SMP2P_OUT_CLK_VOTE_IDX 1
  212. #define IPA_SMP2P_SMEM_STATE_MASK 3
  213. #define IPA_SUMMING_THRESHOLD (0x10)
  214. #define IPA_PIPE_MEM_START_OFST (0x0)
  215. #define IPA_PIPE_MEM_SIZE (0x0)
  216. #define IPA_MOBILE_AP_MODE(x) (x == IPA_MODE_MOBILE_AP_ETH || \
  217. x == IPA_MODE_MOBILE_AP_WAN || \
  218. x == IPA_MODE_MOBILE_AP_WLAN)
  219. #define IPA_CNOC_CLK_RATE (75 * 1000 * 1000UL)
  220. #define IPA_A5_MUX_HEADER_LENGTH (8)
  221. #define IPA_AGGR_MAX_STR_LENGTH (10)
  222. #define CLEANUP_TAG_PROCESS_TIMEOUT 1000
  223. #define IPA_AGGR_STR_IN_BYTES(str) \
  224. (strnlen((str), IPA_AGGR_MAX_STR_LENGTH - 1) + 1)
  225. #define IPA_ADJUST_AGGR_BYTE_HARD_LIMIT(X) (X/1000)
  226. #define IPA_TRANSPORT_PROD_TIMEOUT_MSEC 100
  227. #define IPA3_ACTIVE_CLIENTS_TABLE_BUF_SIZE 4096
  228. #define IPA3_ACTIVE_CLIENT_LOG_TYPE_EP 0
  229. #define IPA3_ACTIVE_CLIENT_LOG_TYPE_SIMPLE 1
  230. #define IPA3_ACTIVE_CLIENT_LOG_TYPE_RESOURCE 2
  231. #define IPA3_ACTIVE_CLIENT_LOG_TYPE_SPECIAL 3
  232. #define IPA_MHI_GSI_EVENT_RING_ID_START 10
  233. #define IPA_MHI_GSI_EVENT_RING_ID_END 12
  234. #define IPA_SMEM_SIZE (8 * 1024)
  235. #define IPA_GSI_CHANNEL_HALT_MIN_SLEEP 5000
  236. #define IPA_GSI_CHANNEL_HALT_MAX_SLEEP 10000
  237. #define IPA_GSI_CHANNEL_HALT_MAX_TRY 10
  238. /* round addresses for closes page per SMMU requirements */
  239. #define IPA_SMMU_ROUND_TO_PAGE(iova, pa, size, iova_p, pa_p, size_p) \
  240. do { \
  241. (iova_p) = rounddown((iova), PAGE_SIZE); \
  242. (pa_p) = rounddown((pa), PAGE_SIZE); \
  243. (size_p) = roundup((size) + (pa) - (pa_p), PAGE_SIZE); \
  244. } while (0)
  245. /* The relative location in /lib/firmware where the FWs will reside */
  246. #define IPA_FWS_PATH "ipa/ipa_fws.elf"
  247. /*
  248. * The following paths below are used when building the system for the
  249. * emulation environment.
  250. *
  251. * As new hardware platforms are added into the emulation environment,
  252. * please add the appropriate paths here for their firmwares.
  253. */
  254. #define IPA_FWS_PATH_4_0 "ipa/4.0/ipa_fws.elf"
  255. #define IPA_FWS_PATH_3_5_1 "ipa/3.5.1/ipa_fws.elf"
  256. #define IPA_FWS_PATH_4_5 "ipa/4.5/ipa_fws.elf"
  257. /*
  258. * The following will be used for determining/using access control
  259. * policy.
  260. */
  261. #define USE_SCM 0 /* use scm call to determine policy */
  262. #define OVERRIDE_SCM_TRUE 1 /* override scm call with true */
  263. #define OVERRIDE_SCM_FALSE 2 /* override scm call with false */
  264. #define SD_ENABLED 0 /* secure debug enabled. */
  265. #define SD_DISABLED 1 /* secure debug disabled. */
  266. #define IPA_MEM_INIT_VAL 0xFFFFFFFF
  267. #ifdef CONFIG_COMPAT
  268. #define IPA_IOC_ADD_HDR32 _IOWR(IPA_IOC_MAGIC, \
  269. IPA_IOCTL_ADD_HDR, \
  270. compat_uptr_t)
  271. #define IPA_IOC_DEL_HDR32 _IOWR(IPA_IOC_MAGIC, \
  272. IPA_IOCTL_DEL_HDR, \
  273. compat_uptr_t)
  274. #define IPA_IOC_ADD_RT_RULE32 _IOWR(IPA_IOC_MAGIC, \
  275. IPA_IOCTL_ADD_RT_RULE, \
  276. compat_uptr_t)
  277. #define IPA_IOC_DEL_RT_RULE32 _IOWR(IPA_IOC_MAGIC, \
  278. IPA_IOCTL_DEL_RT_RULE, \
  279. compat_uptr_t)
  280. #define IPA_IOC_ADD_FLT_RULE32 _IOWR(IPA_IOC_MAGIC, \
  281. IPA_IOCTL_ADD_FLT_RULE, \
  282. compat_uptr_t)
  283. #define IPA_IOC_DEL_FLT_RULE32 _IOWR(IPA_IOC_MAGIC, \
  284. IPA_IOCTL_DEL_FLT_RULE, \
  285. compat_uptr_t)
  286. #define IPA_IOC_GET_RT_TBL32 _IOWR(IPA_IOC_MAGIC, \
  287. IPA_IOCTL_GET_RT_TBL, \
  288. compat_uptr_t)
  289. #define IPA_IOC_COPY_HDR32 _IOWR(IPA_IOC_MAGIC, \
  290. IPA_IOCTL_COPY_HDR, \
  291. compat_uptr_t)
  292. #define IPA_IOC_QUERY_INTF32 _IOWR(IPA_IOC_MAGIC, \
  293. IPA_IOCTL_QUERY_INTF, \
  294. compat_uptr_t)
  295. #define IPA_IOC_QUERY_INTF_TX_PROPS32 _IOWR(IPA_IOC_MAGIC, \
  296. IPA_IOCTL_QUERY_INTF_TX_PROPS, \
  297. compat_uptr_t)
  298. #define IPA_IOC_QUERY_INTF_RX_PROPS32 _IOWR(IPA_IOC_MAGIC, \
  299. IPA_IOCTL_QUERY_INTF_RX_PROPS, \
  300. compat_uptr_t)
  301. #define IPA_IOC_QUERY_INTF_EXT_PROPS32 _IOWR(IPA_IOC_MAGIC, \
  302. IPA_IOCTL_QUERY_INTF_EXT_PROPS, \
  303. compat_uptr_t)
  304. #define IPA_IOC_GET_HDR32 _IOWR(IPA_IOC_MAGIC, \
  305. IPA_IOCTL_GET_HDR, \
  306. compat_uptr_t)
  307. #define IPA_IOC_ALLOC_NAT_MEM32 _IOWR(IPA_IOC_MAGIC, \
  308. IPA_IOCTL_ALLOC_NAT_MEM, \
  309. compat_uptr_t)
  310. #define IPA_IOC_ALLOC_NAT_TABLE32 _IOWR(IPA_IOC_MAGIC, \
  311. IPA_IOCTL_ALLOC_NAT_TABLE, \
  312. compat_uptr_t)
  313. #define IPA_IOC_ALLOC_IPV6CT_TABLE32 _IOWR(IPA_IOC_MAGIC, \
  314. IPA_IOCTL_ALLOC_IPV6CT_TABLE, \
  315. compat_uptr_t)
  316. #define IPA_IOC_V4_INIT_NAT32 _IOWR(IPA_IOC_MAGIC, \
  317. IPA_IOCTL_V4_INIT_NAT, \
  318. compat_uptr_t)
  319. #define IPA_IOC_INIT_IPV6CT_TABLE32 _IOWR(IPA_IOC_MAGIC, \
  320. IPA_IOCTL_INIT_IPV6CT_TABLE, \
  321. compat_uptr_t)
  322. #define IPA_IOC_TABLE_DMA_CMD32 _IOWR(IPA_IOC_MAGIC, \
  323. IPA_IOCTL_TABLE_DMA_CMD, \
  324. compat_uptr_t)
  325. #define IPA_IOC_V4_DEL_NAT32 _IOWR(IPA_IOC_MAGIC, \
  326. IPA_IOCTL_V4_DEL_NAT, \
  327. compat_uptr_t)
  328. #define IPA_IOC_DEL_NAT_TABLE32 _IOWR(IPA_IOC_MAGIC, \
  329. IPA_IOCTL_DEL_NAT_TABLE, \
  330. compat_uptr_t)
  331. #define IPA_IOC_DEL_IPV6CT_TABLE32 _IOWR(IPA_IOC_MAGIC, \
  332. IPA_IOCTL_DEL_IPV6CT_TABLE, \
  333. compat_uptr_t)
  334. #define IPA_IOC_NAT_MODIFY_PDN32 _IOWR(IPA_IOC_MAGIC, \
  335. IPA_IOCTL_NAT_MODIFY_PDN, \
  336. compat_uptr_t)
  337. #define IPA_IOC_GET_NAT_OFFSET32 _IOWR(IPA_IOC_MAGIC, \
  338. IPA_IOCTL_GET_NAT_OFFSET, \
  339. compat_uptr_t)
  340. #define IPA_IOC_PULL_MSG32 _IOWR(IPA_IOC_MAGIC, \
  341. IPA_IOCTL_PULL_MSG, \
  342. compat_uptr_t)
  343. #define IPA_IOC_RM_ADD_DEPENDENCY32 _IOWR(IPA_IOC_MAGIC, \
  344. IPA_IOCTL_RM_ADD_DEPENDENCY, \
  345. compat_uptr_t)
  346. #define IPA_IOC_RM_DEL_DEPENDENCY32 _IOWR(IPA_IOC_MAGIC, \
  347. IPA_IOCTL_RM_DEL_DEPENDENCY, \
  348. compat_uptr_t)
  349. #define IPA_IOC_GENERATE_FLT_EQ32 _IOWR(IPA_IOC_MAGIC, \
  350. IPA_IOCTL_GENERATE_FLT_EQ, \
  351. compat_uptr_t)
  352. #define IPA_IOC_QUERY_RT_TBL_INDEX32 _IOWR(IPA_IOC_MAGIC, \
  353. IPA_IOCTL_QUERY_RT_TBL_INDEX, \
  354. compat_uptr_t)
  355. #define IPA_IOC_WRITE_QMAPID32 _IOWR(IPA_IOC_MAGIC, \
  356. IPA_IOCTL_WRITE_QMAPID, \
  357. compat_uptr_t)
  358. #define IPA_IOC_MDFY_FLT_RULE32 _IOWR(IPA_IOC_MAGIC, \
  359. IPA_IOCTL_MDFY_FLT_RULE, \
  360. compat_uptr_t)
  361. #define IPA_IOC_NOTIFY_WAN_UPSTREAM_ROUTE_ADD32 _IOWR(IPA_IOC_MAGIC, \
  362. IPA_IOCTL_NOTIFY_WAN_UPSTREAM_ROUTE_ADD, \
  363. compat_uptr_t)
  364. #define IPA_IOC_NOTIFY_WAN_UPSTREAM_ROUTE_DEL32 _IOWR(IPA_IOC_MAGIC, \
  365. IPA_IOCTL_NOTIFY_WAN_UPSTREAM_ROUTE_DEL, \
  366. compat_uptr_t)
  367. #define IPA_IOC_NOTIFY_WAN_EMBMS_CONNECTED32 _IOWR(IPA_IOC_MAGIC, \
  368. IPA_IOCTL_NOTIFY_WAN_EMBMS_CONNECTED, \
  369. compat_uptr_t)
  370. #define IPA_IOC_ADD_HDR_PROC_CTX32 _IOWR(IPA_IOC_MAGIC, \
  371. IPA_IOCTL_ADD_HDR_PROC_CTX, \
  372. compat_uptr_t)
  373. #define IPA_IOC_DEL_HDR_PROC_CTX32 _IOWR(IPA_IOC_MAGIC, \
  374. IPA_IOCTL_DEL_HDR_PROC_CTX, \
  375. compat_uptr_t)
  376. #define IPA_IOC_MDFY_RT_RULE32 _IOWR(IPA_IOC_MAGIC, \
  377. IPA_IOCTL_MDFY_RT_RULE, \
  378. compat_uptr_t)
  379. #define IPA_IOC_GET_NAT_IN_SRAM_INFO32 _IOWR(IPA_IOC_MAGIC, \
  380. IPA_IOCTL_GET_NAT_IN_SRAM_INFO, \
  381. compat_uptr_t)
  382. #define IPA_IOC_APP_CLOCK_VOTE32 _IOWR(IPA_IOC_MAGIC, \
  383. IPA_IOCTL_APP_CLOCK_VOTE, \
  384. compat_uptr_t)
  385. #endif /* #ifdef CONFIG_COMPAT */
  386. #define IPA_TZ_UNLOCK_ATTRIBUTE 0x0C0311
  387. #define MBOX_TOUT_MS 100
  388. /* miscellaneous for rmnet_ipa and qmi_service */
  389. enum ipa_type_mode {
  390. IPA_HW_TYPE,
  391. PLATFORM_TYPE,
  392. IPA3_HW_MODE,
  393. };
  394. enum ipa_flag {
  395. IPA_ENDP_DELAY_WA_EN,
  396. IPA_HW_STATS_EN,
  397. IPA_MHI_EN,
  398. IPA_FLTRT_NOT_HASHABLE_EN,
  399. };
  400. enum ipa_icc_level {
  401. IPA_ICC_NONE,
  402. IPA_ICC_SVS2,
  403. IPA_ICC_SVS,
  404. IPA_ICC_NOMINAL,
  405. IPA_ICC_TURBO,
  406. IPA_ICC_LVL_MAX,
  407. };
  408. enum ipa_icc_path {
  409. IPA_ICC_IPA_TO_LLCC,
  410. IPA_ICC_LLCC_TO_EBIL,
  411. IPA_ICC_IPA_TO_IMEM,
  412. IPA_ICC_APSS_TO_IPA,
  413. IPA_ICC_PATH_MAX,
  414. };
  415. enum ipa_icc_type {
  416. IPA_ICC_AB,
  417. IPA_ICC_IB,
  418. IPA_ICC_TYPE_MAX,
  419. };
  420. #define IPA_ICC_MAX (IPA_ICC_PATH_MAX*IPA_ICC_TYPE_MAX)
  421. struct ipa3_active_client_htable_entry {
  422. struct hlist_node list;
  423. char id_string[IPA3_ACTIVE_CLIENTS_LOG_NAME_LEN];
  424. int count;
  425. enum ipa_active_client_log_type type;
  426. };
  427. struct ipa3_active_clients_log_ctx {
  428. spinlock_t lock;
  429. char *log_buffer[IPA3_ACTIVE_CLIENTS_LOG_BUFFER_SIZE_LINES];
  430. int log_head;
  431. int log_tail;
  432. bool log_rdy;
  433. struct hlist_head htable[IPA3_ACTIVE_CLIENTS_LOG_HASHTABLE_SIZE];
  434. };
  435. struct ipa3_client_names {
  436. enum ipa_client_type names[MAX_RESOURCE_TO_CLIENTS];
  437. int length;
  438. };
  439. struct ipa_smmu_cb_ctx {
  440. bool valid;
  441. struct device *dev;
  442. struct iommu_domain *iommu_domain;
  443. unsigned long next_addr;
  444. u32 va_start;
  445. u32 va_size;
  446. u32 va_end;
  447. bool shared;
  448. bool is_cache_coherent;
  449. };
  450. /**
  451. * struct ipa_flt_rule_add_i - filtering rule descriptor
  452. * includes in and out parameters
  453. * @rule: actual rule to be added
  454. * @at_rear: add at back of filtering table?
  455. * @flt_rule_hdl: out parameter, handle to rule, valid when status is 0
  456. * @status: output parameter, status of filtering rule add operation,
  457. * 0 for success,
  458. * -1 for failure
  459. *
  460. */
  461. struct ipa_flt_rule_add_i {
  462. u8 at_rear;
  463. u32 flt_rule_hdl;
  464. int status;
  465. struct ipa_flt_rule_i rule;
  466. };
  467. /**
  468. * struct ipa_flt_rule_mdfy_i - filtering rule descriptor
  469. * includes in and out parameters
  470. * @rule: actual rule to be added
  471. * @flt_rule_hdl: handle to rule
  472. * @status: output parameter, status of filtering rule modify operation,
  473. * 0 for success,
  474. * -1 for failure
  475. *
  476. */
  477. struct ipa_flt_rule_mdfy_i {
  478. u32 rule_hdl;
  479. int status;
  480. struct ipa_flt_rule_i rule;
  481. };
  482. /**
  483. * struct ipa_rt_rule_add_i - routing rule descriptor includes
  484. * in and out parameters
  485. * @rule: actual rule to be added
  486. * @at_rear: add at back of routing table, it is NOT possible to add rules at
  487. * the rear of the "default" routing tables
  488. * @rt_rule_hdl: output parameter, handle to rule, valid when status is 0
  489. * @status: output parameter, status of routing rule add operation,
  490. * 0 for success,
  491. * -1 for failure
  492. */
  493. struct ipa_rt_rule_add_i {
  494. u8 at_rear;
  495. u32 rt_rule_hdl;
  496. int status;
  497. struct ipa_rt_rule_i rule;
  498. };
  499. /**
  500. * struct ipa_rt_rule_mdfy_i - routing rule descriptor includes
  501. * in and out parameters
  502. * @rule: actual rule to be added
  503. * @rt_rule_hdl: handle to rule which supposed to modify
  504. * @status: output parameter, status of routing rule modify operation,
  505. * 0 for success,
  506. * -1 for failure
  507. *
  508. */
  509. struct ipa_rt_rule_mdfy_i {
  510. u32 rt_rule_hdl;
  511. int status;
  512. struct ipa_rt_rule_i rule;
  513. };
  514. /**
  515. * struct ipa_rt_rule_add_ext_i - routing rule descriptor
  516. * includes in and out parameters
  517. * @rule: actual rule to be added
  518. * @at_rear: add at back of routing table, it is NOT possible to add rules at
  519. * the rear of the "default" routing tables
  520. * @rt_rule_hdl: output parameter, handle to rule, valid when status is 0
  521. * @status: output parameter, status of routing rule add operation,
  522. * @rule_id: rule_id to be assigned to the routing rule. In case client
  523. * specifies rule_id as 0 the driver will assign a new rule_id
  524. * 0 for success,
  525. * -1 for failure
  526. */
  527. struct ipa_rt_rule_add_ext_i {
  528. uint8_t at_rear;
  529. uint32_t rt_rule_hdl;
  530. int status;
  531. uint16_t rule_id;
  532. struct ipa_rt_rule_i rule;
  533. };
  534. /**
  535. * struct ipa3_flt_entry - IPA filtering table entry
  536. * @link: entry's link in global filtering enrties list
  537. * @rule: filter rule
  538. * @cookie: cookie used for validity check
  539. * @tbl: filter table
  540. * @rt_tbl: routing table
  541. * @hw_len: entry's size
  542. * @id: rule handle - globally unique
  543. * @prio: rule 10bit priority which defines the order of the rule
  544. * among other rules at the same integrated table
  545. * @rule_id: rule 10bit ID to be returned in packet status
  546. * @cnt_idx: stats counter index
  547. * @ipacm_installed: indicate if installed by ipacm
  548. */
  549. struct ipa3_flt_entry {
  550. struct list_head link;
  551. u32 cookie;
  552. struct ipa_flt_rule_i rule;
  553. struct ipa3_flt_tbl *tbl;
  554. struct ipa3_rt_tbl *rt_tbl;
  555. u32 hw_len;
  556. int id;
  557. u16 prio;
  558. u16 rule_id;
  559. u8 cnt_idx;
  560. bool ipacm_installed;
  561. };
  562. /**
  563. * struct ipa3_rt_tbl - IPA routing table
  564. * @link: table's link in global routing tables list
  565. * @head_rt_rule_list: head of routing rules list
  566. * @name: routing table name
  567. * @idx: routing table index
  568. * @rule_cnt: number of rules in routing table
  569. * @ref_cnt: reference counter of routing table
  570. * @set: collection of routing tables
  571. * @cookie: cookie used for validity check
  572. * @in_sys: flag indicating if the table is located in system memory
  573. * @sz: the size of the routing table
  574. * @curr_mem: current routing tables block in sys memory
  575. * @prev_mem: previous routing table block in sys memory
  576. * @id: routing table id
  577. * @rule_ids: common idr structure that holds the rule_id for each rule
  578. */
  579. struct ipa3_rt_tbl {
  580. struct list_head link;
  581. u32 cookie;
  582. struct list_head head_rt_rule_list;
  583. char name[IPA_RESOURCE_NAME_MAX];
  584. u32 idx;
  585. u32 rule_cnt;
  586. u32 ref_cnt;
  587. struct ipa3_rt_tbl_set *set;
  588. bool in_sys[IPA_RULE_TYPE_MAX];
  589. u32 sz[IPA_RULE_TYPE_MAX];
  590. struct ipa_mem_buffer curr_mem[IPA_RULE_TYPE_MAX];
  591. struct ipa_mem_buffer prev_mem[IPA_RULE_TYPE_MAX];
  592. int id;
  593. struct idr *rule_ids;
  594. };
  595. /**
  596. * struct ipa3_hdr_entry - IPA header table entry
  597. * @link: entry's link in global header table entries list
  598. * @hdr: the header
  599. * @hdr_len: header length
  600. * @name: name of header table entry
  601. * @type: l2 header type
  602. * @is_partial: flag indicating if header table entry is partial
  603. * @is_hdr_proc_ctx: false - hdr entry resides in hdr table,
  604. * true - hdr entry resides in DDR and pointed to by proc ctx
  605. * @phys_base: physical address of entry in DDR when is_hdr_proc_ctx is true,
  606. * else 0
  607. * @proc_ctx: processing context header
  608. * @offset_entry: entry's offset
  609. * @cookie: cookie used for validity check
  610. * @ref_cnt: reference counter of routing table
  611. * @id: header entry id
  612. * @is_eth2_ofst_valid: is eth2_ofst field valid?
  613. * @eth2_ofst: offset to start of Ethernet-II/802.3 header
  614. * @user_deleted: is the header deleted by the user?
  615. * @ipacm_installed: indicate if installed by ipacm
  616. */
  617. struct ipa3_hdr_entry {
  618. struct list_head link;
  619. u32 cookie;
  620. u8 hdr[IPA_HDR_MAX_SIZE];
  621. u32 hdr_len;
  622. char name[IPA_RESOURCE_NAME_MAX];
  623. enum ipa_hdr_l2_type type;
  624. u8 is_partial;
  625. bool is_hdr_proc_ctx;
  626. dma_addr_t phys_base;
  627. struct ipa3_hdr_proc_ctx_entry *proc_ctx;
  628. struct ipa_hdr_offset_entry *offset_entry;
  629. u32 ref_cnt;
  630. int id;
  631. u8 is_eth2_ofst_valid;
  632. u16 eth2_ofst;
  633. bool user_deleted;
  634. bool ipacm_installed;
  635. };
  636. /**
  637. * struct ipa3_hdr_tbl - IPA header table
  638. * @head_hdr_entry_list: header entries list
  639. * @head_offset_list: header offset list
  640. * @head_free_offset_list: header free offset list
  641. * @hdr_cnt: number of headers
  642. * @end: the last header index
  643. */
  644. struct ipa3_hdr_tbl {
  645. struct list_head head_hdr_entry_list;
  646. struct list_head head_offset_list[IPA_HDR_BIN_MAX];
  647. struct list_head head_free_offset_list[IPA_HDR_BIN_MAX];
  648. u32 hdr_cnt;
  649. u32 end;
  650. };
  651. /**
  652. * struct ipa3_hdr_offset_entry - IPA header offset entry
  653. * @link: entry's link in global processing context header offset entries list
  654. * @offset: the offset
  655. * @bin: bin
  656. * @ipacm_installed: indicate if installed by ipacm
  657. */
  658. struct ipa3_hdr_proc_ctx_offset_entry {
  659. struct list_head link;
  660. u32 offset;
  661. u32 bin;
  662. bool ipacm_installed;
  663. };
  664. /**
  665. * struct ipa3_hdr_proc_ctx_entry - IPA processing context header table entry
  666. * @link: entry's link in global header table entries list
  667. * @type: header processing context type
  668. * @l2tp_params: L2TP parameters
  669. * @generic_params: generic proc_ctx params
  670. * @offset_entry: entry's offset
  671. * @hdr: the header
  672. * @cookie: cookie used for validity check
  673. * @ref_cnt: reference counter of routing table
  674. * @id: processing context header entry id
  675. * @user_deleted: is the hdr processing context deleted by the user?
  676. * @ipacm_installed: indicate if installed by ipacm
  677. */
  678. struct ipa3_hdr_proc_ctx_entry {
  679. struct list_head link;
  680. u32 cookie;
  681. enum ipa_hdr_proc_type type;
  682. struct ipa_l2tp_hdr_proc_ctx_params l2tp_params;
  683. struct ipa_eth_II_to_eth_II_ex_procparams generic_params;
  684. struct ipa3_hdr_proc_ctx_offset_entry *offset_entry;
  685. struct ipa3_hdr_entry *hdr;
  686. u32 ref_cnt;
  687. int id;
  688. bool user_deleted;
  689. bool ipacm_installed;
  690. };
  691. /**
  692. * struct ipa3_hdr_proc_ctx_tbl - IPA processing context header table
  693. * @head_proc_ctx_entry_list: header entries list
  694. * @head_offset_list: header offset list
  695. * @head_free_offset_list: header free offset list
  696. * @proc_ctx_cnt: number of processing context headers
  697. * @end: the last processing context header index
  698. * @start_offset: offset in words of processing context header table
  699. */
  700. struct ipa3_hdr_proc_ctx_tbl {
  701. struct list_head head_proc_ctx_entry_list;
  702. struct list_head head_offset_list[IPA_HDR_PROC_CTX_BIN_MAX];
  703. struct list_head head_free_offset_list[IPA_HDR_PROC_CTX_BIN_MAX];
  704. u32 proc_ctx_cnt;
  705. u32 end;
  706. u32 start_offset;
  707. };
  708. /**
  709. * struct ipa3_flt_tbl - IPA filter table
  710. * @head_flt_rule_list: filter rules list
  711. * @rule_cnt: number of filter rules
  712. * @in_sys: flag indicating if filter table is located in system memory
  713. * @sz: the size of the filter tables
  714. * @end: the last header index
  715. * @curr_mem: current filter tables block in sys memory
  716. * @prev_mem: previous filter table block in sys memory
  717. * @rule_ids: common idr structure that holds the rule_id for each rule
  718. */
  719. struct ipa3_flt_tbl {
  720. struct list_head head_flt_rule_list;
  721. u32 rule_cnt;
  722. bool in_sys[IPA_RULE_TYPE_MAX];
  723. u32 sz[IPA_RULE_TYPE_MAX];
  724. struct ipa_mem_buffer curr_mem[IPA_RULE_TYPE_MAX];
  725. struct ipa_mem_buffer prev_mem[IPA_RULE_TYPE_MAX];
  726. bool sticky_rear;
  727. struct idr *rule_ids;
  728. };
  729. /**
  730. * struct ipa3_rt_entry - IPA routing table entry
  731. * @link: entry's link in global routing table entries list
  732. * @rule: routing rule
  733. * @cookie: cookie used for validity check
  734. * @tbl: routing table
  735. * @hdr: header table
  736. * @proc_ctx: processing context table
  737. * @hw_len: the length of the table
  738. * @id: rule handle - globaly unique
  739. * @prio: rule 10bit priority which defines the order of the rule
  740. * among other rules at the integrated same table
  741. * @rule_id: rule 10bit ID to be returned in packet status
  742. * @rule_id_valid: indicate if rule_id_valid valid or not?
  743. * @cnt_idx: stats counter index
  744. * @ipacm_installed: indicate if installed by ipacm
  745. */
  746. struct ipa3_rt_entry {
  747. struct list_head link;
  748. u32 cookie;
  749. struct ipa_rt_rule_i rule;
  750. struct ipa3_rt_tbl *tbl;
  751. struct ipa3_hdr_entry *hdr;
  752. struct ipa3_hdr_proc_ctx_entry *proc_ctx;
  753. u32 hw_len;
  754. int id;
  755. u16 prio;
  756. u16 rule_id;
  757. u16 rule_id_valid;
  758. u8 cnt_idx;
  759. bool ipacm_installed;
  760. };
  761. /**
  762. * struct ipa3_rt_tbl_set - collection of routing tables
  763. * @head_rt_tbl_list: collection of routing tables
  764. * @tbl_cnt: number of routing tables
  765. * @rule_ids: idr structure that holds the rule_id for each rule
  766. */
  767. struct ipa3_rt_tbl_set {
  768. struct list_head head_rt_tbl_list;
  769. u32 tbl_cnt;
  770. struct idr rule_ids;
  771. };
  772. /**
  773. * struct ipa3_wlan_stats - Wlan stats for each wlan endpoint
  774. * @rx_pkts_rcvd: Packets sent by wlan driver
  775. * @rx_pkts_status_rcvd: Status packets received from ipa hw
  776. * @rx_hd_processed: Data Descriptors processed by IPA Driver
  777. * @rx_hd_reply: Data Descriptors recycled by wlan driver
  778. * @rx_hd_rcvd: Data Descriptors sent by wlan driver
  779. * @rx_pkt_leak: Packet count that are not recycled
  780. * @rx_dp_fail: Packets failed to transfer to IPA HW
  781. * @tx_pkts_rcvd: SKB Buffers received from ipa hw
  782. * @tx_pkts_sent: SKB Buffers sent to wlan driver
  783. * @tx_pkts_dropped: Dropped packets count
  784. */
  785. struct ipa3_wlan_stats {
  786. u32 rx_pkts_rcvd;
  787. u32 rx_pkts_status_rcvd;
  788. u32 rx_hd_processed;
  789. u32 rx_hd_reply;
  790. u32 rx_hd_rcvd;
  791. u32 rx_pkt_leak;
  792. u32 rx_dp_fail;
  793. u32 tx_pkts_rcvd;
  794. u32 tx_pkts_sent;
  795. u32 tx_pkts_dropped;
  796. };
  797. /**
  798. * struct ipa3_wlan_comm_memb - Wlan comm members
  799. * @wlan_spinlock: protects wlan comm buff list and its size
  800. * @ipa_tx_mul_spinlock: protects tx dp mul transfer
  801. * @wlan_comm_total_cnt: wlan common skb buffers allocated count
  802. * @wlan_comm_free_cnt: wlan common skb buffer free count
  803. * @total_tx_pkts_freed: Recycled Buffer count
  804. * @wlan_comm_desc_list: wlan common skb buffer list
  805. */
  806. struct ipa3_wlan_comm_memb {
  807. spinlock_t wlan_spinlock;
  808. spinlock_t ipa_tx_mul_spinlock;
  809. u32 wlan_comm_total_cnt;
  810. u32 wlan_comm_free_cnt;
  811. u32 total_tx_pkts_freed;
  812. struct list_head wlan_comm_desc_list;
  813. atomic_t active_clnt_cnt;
  814. };
  815. struct ipa_gsi_ep_mem_info {
  816. u16 evt_ring_len;
  817. u64 evt_ring_base_addr;
  818. void *evt_ring_base_vaddr;
  819. u16 chan_ring_len;
  820. u64 chan_ring_base_addr;
  821. void *chan_ring_base_vaddr;
  822. };
  823. struct ipa3_status_stats {
  824. struct ipahal_pkt_status status[IPA_MAX_STATUS_STAT_NUM];
  825. unsigned int curr;
  826. };
  827. /**
  828. * struct ipa3_ep_context - IPA end point context
  829. * @valid: flag indicating id EP context is valid
  830. * @client: EP client type
  831. * @gsi_chan_hdl: EP's GSI channel handle
  832. * @gsi_evt_ring_hdl: EP's GSI channel event ring handle
  833. * @gsi_mem_info: EP's GSI channel rings info
  834. * @chan_scratch: EP's GSI channel scratch info
  835. * @cfg: EP cionfiguration
  836. * @dst_pipe_index: destination pipe index
  837. * @rt_tbl_idx: routing table index
  838. * @priv: user provided information which will forwarded once the user is
  839. * notified for new data avail
  840. * @client_notify: user provided CB for EP events notification, the event is
  841. * data revived.
  842. * @skip_ep_cfg: boolean field that determines if EP should be configured
  843. * by IPA driver
  844. * @keep_ipa_awake: when true, IPA will not be clock gated
  845. * @disconnect_in_progress: Indicates client disconnect in progress.
  846. * @qmi_request_sent: Indicates whether QMI request to enable clear data path
  847. * request is sent or not.
  848. * @client_lock_unlock: callback function to take mutex lock/unlock for USB
  849. * clients
  850. */
  851. struct ipa3_ep_context {
  852. int valid;
  853. enum ipa_client_type client;
  854. unsigned long gsi_chan_hdl;
  855. unsigned long gsi_evt_ring_hdl;
  856. struct ipa_gsi_ep_mem_info gsi_mem_info;
  857. union __packed gsi_channel_scratch chan_scratch;
  858. struct gsi_chan_xfer_notify xfer_notify;
  859. bool xfer_notify_valid;
  860. struct ipa_ep_cfg cfg;
  861. struct ipa_ep_cfg_holb holb;
  862. struct ipahal_reg_ep_cfg_status status;
  863. u32 dst_pipe_index;
  864. u32 rt_tbl_idx;
  865. void *priv;
  866. void (*client_notify)(void *priv, enum ipa_dp_evt_type evt,
  867. unsigned long data);
  868. atomic_t avail_fifo_desc;
  869. u32 dflt_flt4_rule_hdl;
  870. u32 dflt_flt6_rule_hdl;
  871. bool skip_ep_cfg;
  872. bool keep_ipa_awake;
  873. struct ipa3_wlan_stats wstats;
  874. u32 uc_offload_state;
  875. u32 gsi_offload_state;
  876. atomic_t disconnect_in_progress;
  877. u32 qmi_request_sent;
  878. u32 eot_in_poll_err;
  879. bool ep_delay_set;
  880. /* sys MUST be the last element of this struct */
  881. struct ipa3_sys_context *sys;
  882. };
  883. /**
  884. * ipa_usb_xdci_chan_params - xDCI channel related properties
  885. *
  886. * @ipa_ep_cfg: IPA EP configuration
  887. * @client: type of "client"
  888. * @priv: callback cookie
  889. * @notify: callback
  890. * priv - callback cookie evt - type of event data - data relevant
  891. * to event. May not be valid. See event_type enum for valid
  892. * cases.
  893. * @skip_ep_cfg: boolean field that determines if EP should be
  894. * configured by IPA driver
  895. * @keep_ipa_awake: when true, IPA will not be clock gated
  896. * @evt_ring_params: parameters for the channel's event ring
  897. * @evt_scratch: parameters for the channel's event ring scratch
  898. * @chan_params: parameters for the channel
  899. * @chan_scratch: parameters for the channel's scratch
  900. *
  901. */
  902. struct ipa_request_gsi_channel_params {
  903. struct ipa_ep_cfg ipa_ep_cfg;
  904. enum ipa_client_type client;
  905. void *priv;
  906. ipa_notify_cb notify;
  907. bool skip_ep_cfg;
  908. bool keep_ipa_awake;
  909. struct gsi_evt_ring_props evt_ring_params;
  910. union __packed gsi_evt_scratch evt_scratch;
  911. struct gsi_chan_props chan_params;
  912. union __packed gsi_channel_scratch chan_scratch;
  913. };
  914. enum ipa3_sys_pipe_policy {
  915. IPA_POLICY_INTR_MODE,
  916. IPA_POLICY_NOINTR_MODE,
  917. IPA_POLICY_INTR_POLL_MODE,
  918. };
  919. struct ipa3_repl_ctx {
  920. struct ipa3_rx_pkt_wrapper **cache;
  921. atomic_t head_idx;
  922. atomic_t tail_idx;
  923. u32 capacity;
  924. atomic_t pending;
  925. };
  926. /**
  927. * struct ipa3_sys_context - IPA GPI pipes context
  928. * @head_desc_list: header descriptors list
  929. * @len: the size of the above list
  930. * @spinlock: protects the list and its size
  931. * @ep: IPA EP context
  932. * @xmit_eot_cnt: count of pending eot for tasklet to process
  933. * @tasklet: tasklet for eot write_done handle (tx_complete)
  934. *
  935. * IPA context specific to the GPI pipes a.k.a LAN IN/OUT and WAN
  936. */
  937. struct ipa3_sys_context {
  938. u32 len;
  939. atomic_t curr_polling_state;
  940. atomic_t workqueue_flushed;
  941. struct delayed_work switch_to_intr_work;
  942. enum ipa3_sys_pipe_policy policy;
  943. bool use_comm_evt_ring;
  944. bool nop_pending;
  945. int (*pyld_hdlr)(struct sk_buff *skb, struct ipa3_sys_context *sys);
  946. struct sk_buff * (*get_skb)(unsigned int len, gfp_t flags);
  947. void (*free_skb)(struct sk_buff *skb);
  948. void (*free_rx_wrapper)(struct ipa3_rx_pkt_wrapper *rk_pkt);
  949. u32 rx_buff_sz;
  950. u32 rx_pool_sz;
  951. struct sk_buff *prev_skb;
  952. unsigned int len_rem;
  953. unsigned int len_pad;
  954. unsigned int len_partial;
  955. bool drop_packet;
  956. struct work_struct work;
  957. struct delayed_work replenish_rx_work;
  958. struct work_struct repl_work;
  959. void (*repl_hdlr)(struct ipa3_sys_context *sys);
  960. struct ipa3_repl_ctx *repl;
  961. struct ipa3_repl_ctx *page_recycle_repl;
  962. u32 pkt_sent;
  963. struct napi_struct *napi_obj;
  964. struct list_head pending_pkts[GSI_VEID_MAX];
  965. atomic_t xmit_eot_cnt;
  966. struct tasklet_struct tasklet;
  967. bool skip_eot;
  968. u32 eob_drop_cnt;
  969. /* ordering is important - mutable fields go above */
  970. struct ipa3_ep_context *ep;
  971. struct list_head head_desc_list;
  972. struct list_head rcycl_list;
  973. spinlock_t spinlock;
  974. struct hrtimer db_timer;
  975. struct workqueue_struct *wq;
  976. struct workqueue_struct *repl_wq;
  977. struct ipa3_status_stats *status_stat;
  978. u32 pm_hdl;
  979. /* ordering is important - other immutable fields go below */
  980. };
  981. /**
  982. * enum ipa3_desc_type - IPA decriptors type
  983. *
  984. * IPA decriptors type, IPA supports DD and ICD but no CD
  985. */
  986. enum ipa3_desc_type {
  987. IPA_DATA_DESC,
  988. IPA_DATA_DESC_SKB,
  989. IPA_DATA_DESC_SKB_PAGED,
  990. IPA_IMM_CMD_DESC,
  991. };
  992. /**
  993. * struct ipa3_tx_pkt_wrapper - IPA Tx packet wrapper
  994. * @type: specify if this packet is for the skb or immediate command
  995. * @mem: memory buffer used by this Tx packet
  996. * @link: linked to the wrappers on that pipe
  997. * @callback: IPA client provided callback
  998. * @user1: cookie1 for above callback
  999. * @user2: cookie2 for above callback
  1000. * @sys: corresponding IPA sys context
  1001. * @cnt: 1 for single transfers,
  1002. * >1 and <0xFFFF for first of a "multiple" transfer,
  1003. * 0xFFFF for last desc, 0 for rest of "multiple' transfer
  1004. * @bounce: va of bounce buffer
  1005. * @unmap_dma: in case this is true, the buffer will not be dma unmapped
  1006. * @xmit_done: flag to indicate the last desc got tx complete on each ieob
  1007. *
  1008. * This struct can wrap both data packet and immediate command packet.
  1009. */
  1010. struct ipa3_tx_pkt_wrapper {
  1011. enum ipa3_desc_type type;
  1012. struct ipa_mem_buffer mem;
  1013. struct list_head link;
  1014. void (*callback)(void *user1, int user2);
  1015. void *user1;
  1016. int user2;
  1017. struct ipa3_sys_context *sys;
  1018. u32 cnt;
  1019. void *bounce;
  1020. bool no_unmap_dma;
  1021. bool xmit_done;
  1022. };
  1023. /**
  1024. * struct ipa3_dma_xfer_wrapper - IPADMA transfer descr wrapper
  1025. * @phys_addr_src: physical address of the source data to copy
  1026. * @phys_addr_dest: physical address to store the copied data
  1027. * @len: len in bytes to copy
  1028. * @link: linked to the wrappers list on the proper(sync/async) cons pipe
  1029. * @xfer_done: completion object for sync_memcpy completion
  1030. * @callback: IPADMA client provided completion callback
  1031. * @user1: cookie1 for above callback
  1032. *
  1033. * This struct can wrap both sync and async memcpy transfers descriptors.
  1034. */
  1035. struct ipa3_dma_xfer_wrapper {
  1036. u64 phys_addr_src;
  1037. u64 phys_addr_dest;
  1038. u16 len;
  1039. struct list_head link;
  1040. struct completion xfer_done;
  1041. void (*callback)(void *user1);
  1042. void *user1;
  1043. };
  1044. /**
  1045. * struct ipa3_desc - IPA descriptor
  1046. * @type: skb or immediate command or plain old data
  1047. * @pyld: points to skb
  1048. * @frag: points to paged fragment
  1049. * or kmalloc'ed immediate command parameters/plain old data
  1050. * @dma_address: dma mapped address of pyld
  1051. * @dma_address_valid: valid field for dma_address
  1052. * @is_tag_status: flag for IP_PACKET_TAG_STATUS imd cmd
  1053. * @len: length of the pyld
  1054. * @opcode: for immediate commands
  1055. * @callback: IPA client provided completion callback
  1056. * @user1: cookie1 for above callback
  1057. * @user2: cookie2 for above callback
  1058. * @xfer_done: completion object for sync completion
  1059. * @skip_db_ring: specifies whether GSI doorbell should not be rang
  1060. */
  1061. struct ipa3_desc {
  1062. enum ipa3_desc_type type;
  1063. void *pyld;
  1064. skb_frag_t *frag;
  1065. dma_addr_t dma_address;
  1066. bool dma_address_valid;
  1067. bool is_tag_status;
  1068. u16 len;
  1069. u16 opcode;
  1070. void (*callback)(void *user1, int user2);
  1071. void *user1;
  1072. int user2;
  1073. struct completion xfer_done;
  1074. bool skip_db_ring;
  1075. };
  1076. /**
  1077. * struct ipa3_rx_pkt_wrapper - IPA Rx packet wrapper
  1078. * @skb: skb
  1079. * @dma_address: DMA address of this Rx packet
  1080. * @link: linked to the Rx packets on that pipe
  1081. * @len: how many bytes are copied into skb's flat buffer
  1082. */
  1083. struct ipa3_rx_pkt_wrapper {
  1084. struct list_head link;
  1085. union {
  1086. struct ipa_rx_data data;
  1087. struct ipa_rx_page_data page_data;
  1088. };
  1089. u32 len;
  1090. struct work_struct work;
  1091. struct ipa3_sys_context *sys;
  1092. };
  1093. /**
  1094. * struct ipa3_nat_ipv6ct_tmp_mem - NAT/IPv6CT temporary memory
  1095. *
  1096. * In case NAT/IPv6CT table are destroyed the HW is provided with the
  1097. * temporary memory
  1098. *
  1099. * @vaddr: the address of the temporary memory
  1100. * @dma_handle: the handle of the temporary memory
  1101. */
  1102. struct ipa3_nat_ipv6ct_tmp_mem {
  1103. void *vaddr;
  1104. dma_addr_t dma_handle;
  1105. };
  1106. /**
  1107. * struct ipa3_nat_ipv6ct_common_mem - IPA NAT/IPv6CT memory device
  1108. * @name: the device name
  1109. * @lock: memory mutex
  1110. * @class: pointer to the struct class
  1111. * @dev: the dev_t of the device
  1112. * @cdev: cdev of the device
  1113. * @dev_num: device number
  1114. * @is_nat_mem: is the memory for v4 nat
  1115. * @is_ipv6ct_mem: is the memory for v6 nat
  1116. * @is_dev_init: flag indicating if device is initialized
  1117. * @is_hw_init: flag indicating if the corresponding HW is initialized
  1118. * @is_mapped: flag indicating if memory is mapped
  1119. * @phys_mem_size: the physical size in the shared memory
  1120. * @phys_mem_ofst: the offset in the shared memory
  1121. * @table_alloc_size: size (bytes) of table
  1122. * @vaddr: the virtual address in the system memory
  1123. * @dma_handle: the system memory DMA handle
  1124. * @base_address: table virtual address
  1125. * @base_table_addr: base table address
  1126. * @expansion_table_addr: expansion table address
  1127. * @table_entries: num of entries in the base table
  1128. * @expn_table_entries: num of entries in the expansion table
  1129. * @tmp_mem: temporary memory used to always provide HW with a legal memory
  1130. */
  1131. struct ipa3_nat_ipv6ct_common_mem {
  1132. char name[IPA_DEV_NAME_MAX_LEN];
  1133. struct mutex lock;
  1134. struct class *class;
  1135. struct device *dev;
  1136. struct cdev cdev;
  1137. dev_t dev_num;
  1138. bool is_nat_mem;
  1139. bool is_ipv6ct_mem;
  1140. bool is_dev_init;
  1141. bool is_hw_init;
  1142. bool is_mapped;
  1143. u32 phys_mem_size;
  1144. u32 phys_mem_ofst;
  1145. size_t table_alloc_size;
  1146. void *vaddr;
  1147. dma_addr_t dma_handle;
  1148. void *base_address;
  1149. char *base_table_addr;
  1150. char *expansion_table_addr;
  1151. u32 table_entries;
  1152. u32 expn_table_entries;
  1153. struct ipa3_nat_ipv6ct_tmp_mem *tmp_mem;
  1154. };
  1155. /**
  1156. * struct ipa3_nat_mem_loc_data - memory specific info per table memory type
  1157. * @is_mapped: has the memory been mapped?
  1158. * @io_vaddr: the virtual address in the sram memory
  1159. * @vaddr: the virtual address in the system memory
  1160. * @dma_handle: the system memory DMA handle
  1161. * @phys_addr: physical sram memory location
  1162. * @table_alloc_size: size (bytes) of table
  1163. * @table_entries: number of entries in table
  1164. * @expn_table_entries: number of entries in expansion table
  1165. * @base_address: same as vaddr above
  1166. * @base_table_addr: base table address
  1167. * @expansion_table_addr: base table's expansion table address
  1168. * @index_table_addr: index table address
  1169. * @index_table_expansion_addr: index table's expansion table address
  1170. */
  1171. struct ipa3_nat_mem_loc_data {
  1172. bool is_mapped;
  1173. void __iomem *io_vaddr;
  1174. void *vaddr;
  1175. dma_addr_t dma_handle;
  1176. unsigned long phys_addr;
  1177. size_t table_alloc_size;
  1178. u32 table_entries;
  1179. u32 expn_table_entries;
  1180. void *base_address;
  1181. char *base_table_addr;
  1182. char *expansion_table_addr;
  1183. char *index_table_addr;
  1184. char *index_table_expansion_addr;
  1185. };
  1186. /**
  1187. * struct ipa3_nat_mem - IPA NAT memory description
  1188. * @dev: the memory device structure
  1189. * @public_ip_addr: ip address of nat table
  1190. * @pdn_mem: pdn config table SW cache memory structure
  1191. * @is_tmp_mem_allocated: indicate if tmp mem has been allocated
  1192. * @last_alloc_loc: last memory type allocated
  1193. * @active_table: which table memory type is currently active
  1194. * @switch2ddr_cnt: how many times we've switched focust to ddr
  1195. * @switch2sram_cnt: how many times we've switched focust to sram
  1196. * @ddr_in_use: is there table in ddr
  1197. * @sram_in_use: is there table in sram
  1198. * @mem_loc: memory specific info per table memory type
  1199. */
  1200. struct ipa3_nat_mem {
  1201. struct ipa3_nat_ipv6ct_common_mem dev; /* this item must be first */
  1202. u32 public_ip_addr;
  1203. struct ipa_mem_buffer pdn_mem;
  1204. bool is_tmp_mem_allocated;
  1205. enum ipa3_nat_mem_in last_alloc_loc;
  1206. enum ipa3_nat_mem_in active_table;
  1207. u32 switch2ddr_cnt;
  1208. u32 switch2sram_cnt;
  1209. bool ddr_in_use;
  1210. bool sram_in_use;
  1211. struct ipa3_nat_mem_loc_data mem_loc[IPA_NAT_MEM_IN_MAX];
  1212. };
  1213. /**
  1214. * struct ipa3_ipv6ct_mem - IPA IPv6 connection tracking memory description
  1215. * @dev: the memory device structure
  1216. */
  1217. struct ipa3_ipv6ct_mem {
  1218. struct ipa3_nat_ipv6ct_common_mem dev; /* this item must be first */
  1219. };
  1220. /**
  1221. * enum ipa3_hw_mode - IPA hardware mode
  1222. * @IPA_HW_Normal: Regular IPA hardware
  1223. * @IPA_HW_Virtual: IPA hardware supporting virtual memory allocation
  1224. * @IPA_HW_PCIE: IPA hardware supporting memory allocation over PCIE Bridge
  1225. * @IPA_HW_Emulation: IPA emulation hardware
  1226. */
  1227. enum ipa3_hw_mode {
  1228. IPA_HW_MODE_NORMAL = 0,
  1229. IPA_HW_MODE_VIRTUAL = 1,
  1230. IPA_HW_MODE_PCIE = 2,
  1231. IPA_HW_MODE_EMULATION = 3,
  1232. };
  1233. /*
  1234. * enum ipa3_platform_type - Platform type
  1235. * @IPA_PLAT_TYPE_MDM: MDM platform (usually 32bit single core CPU platform)
  1236. * @IPA_PLAT_TYPE_MSM: MSM SOC platform (usually 64bit multi-core platform)
  1237. * @IPA_PLAT_TYPE_APQ: Similar to MSM but without modem
  1238. */
  1239. enum ipa3_platform_type {
  1240. IPA_PLAT_TYPE_MDM = 0,
  1241. IPA_PLAT_TYPE_MSM = 1,
  1242. IPA_PLAT_TYPE_APQ = 2,
  1243. };
  1244. enum ipa3_config_this_ep {
  1245. IPA_CONFIGURE_THIS_EP,
  1246. IPA_DO_NOT_CONFIGURE_THIS_EP,
  1247. };
  1248. struct ipa3_page_recycle_stats {
  1249. u64 total_replenished;
  1250. u64 tmp_alloc;
  1251. };
  1252. struct ipa3_stats {
  1253. u32 tx_sw_pkts;
  1254. u32 tx_hw_pkts;
  1255. u32 rx_pkts;
  1256. u32 rx_excp_pkts[IPAHAL_PKT_STATUS_EXCEPTION_MAX];
  1257. u32 rx_repl_repost;
  1258. u32 tx_pkts_compl;
  1259. u32 rx_q_len;
  1260. u32 msg_w[IPA_EVENT_MAX_NUM];
  1261. u32 msg_r[IPA_EVENT_MAX_NUM];
  1262. u32 stat_compl;
  1263. u32 aggr_close;
  1264. u32 wan_aggr_close;
  1265. u32 wan_rx_empty;
  1266. u32 wan_repl_rx_empty;
  1267. u32 lan_rx_empty;
  1268. u32 lan_repl_rx_empty;
  1269. u32 flow_enable;
  1270. u32 flow_disable;
  1271. u32 tx_non_linear;
  1272. struct ipa3_page_recycle_stats page_recycle_stats[2];
  1273. };
  1274. /* offset for each stats */
  1275. #define IPA3_UC_DEBUG_STATS_RINGFULL_OFF (0)
  1276. #define IPA3_UC_DEBUG_STATS_RINGEMPTY_OFF (4)
  1277. #define IPA3_UC_DEBUG_STATS_RINGUSAGEHIGH_OFF (8)
  1278. #define IPA3_UC_DEBUG_STATS_RINGUSAGELOW_OFF (12)
  1279. #define IPA3_UC_DEBUG_STATS_RINGUTILCOUNT_OFF (16)
  1280. #define IPA3_UC_DEBUG_STATS_OFF (20)
  1281. /**
  1282. * struct ipa3_uc_dbg_stats - uC dbg stats for offloading
  1283. * protocols
  1284. * @uc_dbg_stats_ofst: offset to SRAM base
  1285. * @uc_dbg_stats_size: stats size for all channels
  1286. * @uc_dbg_stats_mmio: mmio offset
  1287. */
  1288. struct ipa3_uc_dbg_stats {
  1289. u32 uc_dbg_stats_ofst;
  1290. u16 uc_dbg_stats_size;
  1291. void __iomem *uc_dbg_stats_mmio;
  1292. };
  1293. struct ipa3_active_clients {
  1294. struct mutex mutex;
  1295. atomic_t cnt;
  1296. int bus_vote_idx;
  1297. };
  1298. struct ipa3_wakelock_ref_cnt {
  1299. spinlock_t spinlock;
  1300. int cnt;
  1301. };
  1302. struct ipa3_tag_completion {
  1303. struct completion comp;
  1304. atomic_t cnt;
  1305. };
  1306. struct ipa3_controller;
  1307. /**
  1308. * struct ipa3_uc_hdlrs - IPA uC callback functions
  1309. * @ipa_uc_loaded_hdlr: Function handler when uC is loaded
  1310. * @ipa_uc_event_hdlr: Event handler function
  1311. * @ipa3_uc_response_hdlr: Response handler function
  1312. * @ipa_uc_event_log_info_hdlr: Log event handler function
  1313. */
  1314. struct ipa3_uc_hdlrs {
  1315. void (*ipa_uc_loaded_hdlr)(void);
  1316. void (*ipa_uc_event_hdlr)
  1317. (struct IpaHwSharedMemCommonMapping_t *uc_sram_mmio);
  1318. int (*ipa3_uc_response_hdlr)
  1319. (struct IpaHwSharedMemCommonMapping_t *uc_sram_mmio,
  1320. u32 *uc_status);
  1321. void (*ipa_uc_event_log_info_hdlr)
  1322. (struct IpaHwEventLogInfoData_t *uc_event_top_mmio);
  1323. };
  1324. /**
  1325. * enum ipa3_hw_flags - flags which defines the behavior of HW
  1326. *
  1327. * @IPA_HW_FLAG_HALT_SYSTEM_ON_ASSERT_FAILURE: Halt system in case of assert
  1328. * failure.
  1329. * @IPA_HW_FLAG_NO_REPORT_MHI_CHANNEL_ERORR: Channel error would be reported
  1330. * in the event ring only. No event to CPU.
  1331. * @IPA_HW_FLAG_NO_REPORT_MHI_CHANNEL_WAKE_UP: No need to report event
  1332. * IPA_HW_2_CPU_EVENT_MHI_WAKE_UP_REQUEST
  1333. * @IPA_HW_FLAG_WORK_OVER_DDR: Perform all transaction to external addresses by
  1334. * QMB (avoid memcpy)
  1335. * @IPA_HW_FLAG_NO_REPORT_OOB: If set do not report that the device is OOB in
  1336. * IN Channel
  1337. * @IPA_HW_FLAG_NO_REPORT_DB_MODE: If set, do not report that the device is
  1338. * entering a mode where it expects a doorbell to be rung for OUT Channel
  1339. * @IPA_HW_FLAG_NO_START_OOB_TIMER
  1340. */
  1341. enum ipa3_hw_flags {
  1342. IPA_HW_FLAG_HALT_SYSTEM_ON_ASSERT_FAILURE = 0x01,
  1343. IPA_HW_FLAG_NO_REPORT_MHI_CHANNEL_ERORR = 0x02,
  1344. IPA_HW_FLAG_NO_REPORT_MHI_CHANNEL_WAKE_UP = 0x04,
  1345. IPA_HW_FLAG_WORK_OVER_DDR = 0x08,
  1346. IPA_HW_FLAG_NO_REPORT_OOB = 0x10,
  1347. IPA_HW_FLAG_NO_REPORT_DB_MODE = 0x20,
  1348. IPA_HW_FLAG_NO_START_OOB_TIMER = 0x40
  1349. };
  1350. /**
  1351. * struct ipa3_uc_ctx - IPA uC context
  1352. * @uc_inited: Indicates if uC interface has been initialized
  1353. * @uc_loaded: Indicates if uC has loaded
  1354. * @uc_failed: Indicates if uC has failed / returned an error
  1355. * @uc_lock: uC interface lock to allow only one uC interaction at a time
  1356. * @uc_spinlock: same as uc_lock but for irq contexts
  1357. * @uc_completation: Completion mechanism to wait for uC commands
  1358. * @uc_sram_mmio: Pointer to uC mapped memory
  1359. * @pending_cmd: The last command sent waiting to be ACKed
  1360. * @uc_status: The last status provided by the uC
  1361. * @uc_error_type: error type from uC error event
  1362. * @uc_error_timestamp: tag timer sampled after uC crashed
  1363. */
  1364. struct ipa3_uc_ctx {
  1365. bool uc_inited;
  1366. bool uc_loaded;
  1367. bool uc_failed;
  1368. struct mutex uc_lock;
  1369. spinlock_t uc_spinlock;
  1370. struct completion uc_completion;
  1371. struct IpaHwSharedMemCommonMapping_t *uc_sram_mmio;
  1372. struct IpaHwEventLogInfoData_t *uc_event_top_mmio;
  1373. u32 uc_event_top_ofst;
  1374. u32 pending_cmd;
  1375. u32 uc_status;
  1376. u32 uc_error_type;
  1377. u32 uc_error_timestamp;
  1378. phys_addr_t rdy_ring_base_pa;
  1379. phys_addr_t rdy_ring_rp_pa;
  1380. u32 rdy_ring_size;
  1381. phys_addr_t rdy_comp_ring_base_pa;
  1382. phys_addr_t rdy_comp_ring_wp_pa;
  1383. u32 rdy_comp_ring_size;
  1384. u32 *rdy_ring_rp_va;
  1385. u32 *rdy_comp_ring_wp_va;
  1386. bool uc_event_ring_valid;
  1387. struct ipa_mem_buffer event_ring;
  1388. u32 ering_wp_local;
  1389. u32 ering_rp_local;
  1390. u32 ering_wp;
  1391. u32 ering_rp;
  1392. };
  1393. /**
  1394. * struct ipa3_uc_wdi_ctx
  1395. * @wdi_uc_top_ofst:
  1396. * @wdi_uc_top_mmio:
  1397. * @wdi_uc_stats_ofst:
  1398. * @wdi_uc_stats_mmio:
  1399. */
  1400. struct ipa3_uc_wdi_ctx {
  1401. /* WDI specific fields */
  1402. u32 wdi_uc_stats_ofst;
  1403. struct IpaHwStatsWDIInfoData_t *wdi_uc_stats_mmio;
  1404. void *priv;
  1405. ipa_uc_ready_cb uc_ready_cb;
  1406. /* for AP+STA stats update */
  1407. #ifdef IPA_WAN_MSG_IPv6_ADDR_GW_LEN
  1408. ipa_wdi_meter_notifier_cb stats_notify;
  1409. #endif
  1410. };
  1411. /**
  1412. * struct ipa3_uc_wigig_ctx
  1413. * @priv: wigig driver private data
  1414. * @uc_ready_cb: wigig driver uc ready callback
  1415. * @int_notify: wigig driver misc interrupt callback
  1416. */
  1417. struct ipa3_uc_wigig_ctx {
  1418. void *priv;
  1419. ipa_uc_ready_cb uc_ready_cb;
  1420. ipa_wigig_misc_int_cb misc_notify_cb;
  1421. };
  1422. /**
  1423. * struct ipa3_wdi2_ctx - IPA wdi2 context
  1424. */
  1425. struct ipa3_wdi2_ctx {
  1426. phys_addr_t rdy_ring_base_pa;
  1427. phys_addr_t rdy_ring_rp_pa;
  1428. u32 rdy_ring_size;
  1429. phys_addr_t rdy_comp_ring_base_pa;
  1430. phys_addr_t rdy_comp_ring_wp_pa;
  1431. u32 rdy_comp_ring_size;
  1432. u32 *rdy_ring_rp_va;
  1433. u32 *rdy_comp_ring_wp_va;
  1434. struct ipa3_uc_dbg_stats dbg_stats;
  1435. };
  1436. /**
  1437. * struct ipa3_wdi3_ctx - IPA wdi3 context
  1438. */
  1439. struct ipa3_wdi3_ctx {
  1440. struct ipa3_uc_dbg_stats dbg_stats;
  1441. };
  1442. /**
  1443. * struct ipa3_usb_ctx - IPA usb context
  1444. */
  1445. struct ipa3_usb_ctx {
  1446. struct ipa3_uc_dbg_stats dbg_stats;
  1447. };
  1448. /**
  1449. * struct ipa3_mhip_ctx - IPA mhip context
  1450. */
  1451. struct ipa3_mhip_ctx {
  1452. struct ipa3_uc_dbg_stats dbg_stats;
  1453. };
  1454. /**
  1455. * struct ipa3_aqc_ctx - IPA aqc context
  1456. */
  1457. struct ipa3_aqc_ctx {
  1458. struct ipa3_uc_dbg_stats dbg_stats;
  1459. };
  1460. /**
  1461. * struct ipa3_transport_pm - transport power management related members
  1462. * @transport_pm_mutex: Mutex to protect the transport_pm functionality.
  1463. */
  1464. struct ipa3_transport_pm {
  1465. atomic_t dec_clients;
  1466. atomic_t eot_activity;
  1467. struct mutex transport_pm_mutex;
  1468. };
  1469. /**
  1470. * struct ipa3cm_client_info - the client-info indicated from IPACM
  1471. * @ipacm_client_enum: the enum to indicate tether-client
  1472. * @ipacm_client_uplink: the bool to indicate pipe for uplink
  1473. */
  1474. struct ipa3cm_client_info {
  1475. enum ipacm_client_enum client_enum;
  1476. bool uplink;
  1477. };
  1478. /**
  1479. * struct ipacm_fnr_info - the fnr-info indicated from IPACM
  1480. * @ipacm_client_enum: the enum to indicate tether-client
  1481. * @ipacm_client_uplink: the bool to indicate pipe for uplink
  1482. */
  1483. struct ipacm_fnr_info {
  1484. bool valid;
  1485. uint8_t hw_counter_offset;
  1486. uint8_t sw_counter_offset;
  1487. };
  1488. struct ipa3_smp2p_info {
  1489. u32 out_base_id;
  1490. u32 in_base_id;
  1491. bool ipa_clk_on;
  1492. bool res_sent;
  1493. unsigned int smem_bit;
  1494. struct qcom_smem_state *smem_state;
  1495. };
  1496. /**
  1497. * struct ipa3_ready_cb_info - A list of all the registrations
  1498. * for an indication of IPA driver readiness
  1499. *
  1500. * @link: linked list link
  1501. * @ready_cb: callback
  1502. * @user_data: User data
  1503. *
  1504. */
  1505. struct ipa3_ready_cb_info {
  1506. struct list_head link;
  1507. ipa_ready_cb ready_cb;
  1508. void *user_data;
  1509. };
  1510. struct ipa_dma_task_info {
  1511. struct ipa_mem_buffer mem;
  1512. struct ipahal_imm_cmd_pyld *cmd_pyld;
  1513. };
  1514. struct ipa_quota_stats {
  1515. u64 num_ipv4_bytes;
  1516. u64 num_ipv6_bytes;
  1517. u32 num_ipv4_pkts;
  1518. u32 num_ipv6_pkts;
  1519. };
  1520. struct ipa_quota_stats_all {
  1521. struct ipa_quota_stats client[IPA_CLIENT_MAX];
  1522. };
  1523. struct ipa_drop_stats {
  1524. u32 drop_packet_cnt;
  1525. u32 drop_byte_cnt;
  1526. };
  1527. struct ipa_drop_stats_all {
  1528. struct ipa_drop_stats client[IPA_CLIENT_MAX];
  1529. };
  1530. struct ipa_hw_stats_quota {
  1531. struct ipahal_stats_init_quota init;
  1532. struct ipa_quota_stats_all stats;
  1533. };
  1534. struct ipa_hw_stats_teth {
  1535. struct ipahal_stats_init_tethering init;
  1536. struct ipa_quota_stats_all prod_stats_sum[IPA_CLIENT_MAX];
  1537. struct ipa_quota_stats_all prod_stats[IPA_CLIENT_MAX];
  1538. };
  1539. struct ipa_hw_stats_flt_rt {
  1540. struct ipahal_stats_init_flt_rt flt_v4_init;
  1541. struct ipahal_stats_init_flt_rt flt_v6_init;
  1542. struct ipahal_stats_init_flt_rt rt_v4_init;
  1543. struct ipahal_stats_init_flt_rt rt_v6_init;
  1544. };
  1545. struct ipa_hw_stats_drop {
  1546. struct ipahal_stats_init_drop init;
  1547. struct ipa_drop_stats_all stats;
  1548. };
  1549. struct ipa_hw_stats {
  1550. bool enabled;
  1551. struct ipa_hw_stats_quota quota;
  1552. struct ipa_hw_stats_teth teth;
  1553. struct ipa_hw_stats_flt_rt flt_rt;
  1554. struct ipa_hw_stats_drop drop;
  1555. };
  1556. struct ipa_cne_evt {
  1557. struct ipa_wan_msg wan_msg;
  1558. struct ipa_msg_meta msg_meta;
  1559. };
  1560. enum ipa_smmu_cb_type {
  1561. IPA_SMMU_CB_AP,
  1562. IPA_SMMU_CB_WLAN,
  1563. IPA_SMMU_CB_UC,
  1564. IPA_SMMU_CB_11AD,
  1565. IPA_SMMU_CB_MAX
  1566. };
  1567. #define VALID_IPA_SMMU_CB_TYPE(t) \
  1568. ((t) >= IPA_SMMU_CB_AP && (t) < IPA_SMMU_CB_MAX)
  1569. enum ipa_client_cb_type {
  1570. IPA_USB_CLNT,
  1571. IPA_MHI_CLNT,
  1572. IPA_MAX_CLNT
  1573. };
  1574. /**
  1575. * struct ipa_flt_rt_counter - IPA flt rt counters management
  1576. * @hdl: idr structure to manage hdl per request
  1577. * @used_hw: boolean array to track used hw counters
  1578. * @used_sw: boolean array to track used sw counters
  1579. * @hdl_lock: spinlock for flt_rt handle
  1580. */
  1581. struct ipa_flt_rt_counter {
  1582. struct idr hdl;
  1583. bool used_hw[IPA_FLT_RT_HW_COUNTER];
  1584. bool used_sw[IPA_FLT_RT_SW_COUNTER];
  1585. spinlock_t hdl_lock;
  1586. };
  1587. /**
  1588. * struct ipa3_char_device_context - IPA character device
  1589. * @class: pointer to the struct class
  1590. * @dev_num: device number
  1591. * @dev: the dev_t of the device
  1592. * @cdev: cdev of the device
  1593. */
  1594. struct ipa3_char_device_context {
  1595. struct class *class;
  1596. dev_t dev_num;
  1597. struct device *dev;
  1598. struct cdev cdev;
  1599. };
  1600. struct ipa3_pc_mbox_data {
  1601. struct mbox_client mbox_client;
  1602. struct mbox_chan *mbox;
  1603. };
  1604. enum ipa_fw_load_state {
  1605. IPA_FW_LOAD_STATE_INIT,
  1606. IPA_FW_LOAD_STATE_FWFILE_READY,
  1607. IPA_FW_LOAD_STATE_SMMU_DONE,
  1608. IPA_FW_LOAD_STATE_LOAD_READY,
  1609. IPA_FW_LOAD_STATE_LOADED,
  1610. };
  1611. enum ipa_fw_load_event {
  1612. IPA_FW_LOAD_EVNT_FWFILE_READY,
  1613. IPA_FW_LOAD_EVNT_SMMU_DONE,
  1614. };
  1615. struct ipa_fw_load_data {
  1616. enum ipa_fw_load_state state;
  1617. struct mutex lock;
  1618. };
  1619. struct ipa3_app_clock_vote {
  1620. struct mutex mutex;
  1621. u32 cnt;
  1622. };
  1623. /**
  1624. * struct ipa3_context - IPA context
  1625. * @cdev: cdev context
  1626. * @ep: list of all end points
  1627. * @skip_ep_cfg_shadow: state to update filter table correctly across power-save
  1628. * @ep_flt_bitmap: End-points supporting filtering bitmap
  1629. * @ep_flt_num: End-points supporting filtering number
  1630. * @resume_on_connect: resume ep on ipa connect
  1631. * @flt_tbl: list of all IPA filter tables
  1632. * @flt_rule_ids: idr structure that holds the rule_id for each rule
  1633. * @mode: IPA operating mode
  1634. * @mmio: iomem
  1635. * @ipa_wrapper_base: IPA wrapper base address
  1636. * @ipa_wrapper_size: size of the memory pointed to by ipa_wrapper_base
  1637. * @hdr_tbl: IPA header table
  1638. * @hdr_proc_ctx_tbl: IPA processing context table
  1639. * @rt_tbl_set: list of routing tables each of which is a list of rules
  1640. * @reap_rt_tbl_set: list of sys mem routing tables waiting to be reaped
  1641. * @flt_rule_cache: filter rule cache
  1642. * @rt_rule_cache: routing rule cache
  1643. * @hdr_cache: header cache
  1644. * @hdr_offset_cache: header offset cache
  1645. * @hdr_proc_ctx_cache: processing context cache
  1646. * @hdr_proc_ctx_offset_cache: processing context offset cache
  1647. * @rt_tbl_cache: routing table cache
  1648. * @tx_pkt_wrapper_cache: Tx packets cache
  1649. * @rx_pkt_wrapper_cache: Rx packets cache
  1650. * @rt_idx_bitmap: routing table index bitmap
  1651. * @lock: this does NOT protect the linked lists within ipa3_sys_context
  1652. * @smem_sz: shared memory size available for SW use starting
  1653. * from non-restricted bytes
  1654. * @smem_restricted_bytes: the bytes that SW should not use in the shared mem
  1655. * @nat_mem: NAT memory
  1656. * @ipv6ct_mem: IPv6CT memory
  1657. * @excp_hdr_hdl: exception header handle
  1658. * @dflt_v4_rt_rule_hdl: default v4 routing rule handle
  1659. * @dflt_v6_rt_rule_hdl: default v6 routing rule handle
  1660. * @aggregation_type: aggregation type used on USB client endpoint
  1661. * @aggregation_byte_limit: aggregation byte limit used on USB client endpoint
  1662. * @aggregation_time_limit: aggregation time limit used on USB client endpoint
  1663. * @hdr_tbl_lcl: where hdr tbl resides 1-local, 0-system
  1664. * @hdr_proc_ctx_tbl_lcl: where proc_ctx tbl resides true-local, false-system
  1665. * @hdr_mem: header memory
  1666. * @hdr_proc_ctx_mem: processing context memory
  1667. * @ip4_rt_tbl_lcl: where ip4 rt tables reside 1-local; 0-system
  1668. * @ip6_rt_tbl_lcl: where ip6 rt tables reside 1-local; 0-system
  1669. * @ip4_flt_tbl_lcl: where ip4 flt tables reside 1-local; 0-system
  1670. * @ip6_flt_tbl_lcl: where ip6 flt tables reside 1-local; 0-system
  1671. * @power_mgmt_wq: workqueue for power management
  1672. * @transport_power_mgmt_wq: workqueue transport related power management
  1673. * @tag_process_before_gating: indicates whether to start tag process before
  1674. * gating IPA clocks
  1675. * @transport_pm: transport power management related information
  1676. * @disconnect_lock: protects LAN_CONS packet receive notification CB
  1677. * @ipa3_active_clients: structure for reference counting connected IPA clients
  1678. * @ipa_hw_type: type of IPA HW type (e.g. IPA 1.0, IPA 1.1 etc')
  1679. * @ipa3_hw_mode: mode of IPA HW mode (e.g. Normal, Virtual or over PCIe)
  1680. * @use_ipa_teth_bridge: use tethering bridge driver
  1681. * @modem_cfg_emb_pipe_flt: modem configure embedded pipe filtering rules
  1682. * @logbuf: ipc log buffer for high priority messages
  1683. * @logbuf_low: ipc log buffer for low priority messages
  1684. * @ipa_wdi2: using wdi-2.0
  1685. * @ipa_fltrt_not_hashable: filter/route rules not hashable
  1686. * @use_64_bit_dma_mask: using 64bits dma mask
  1687. * @ctrl: holds the core specific operations based on
  1688. * core version (vtable like)
  1689. * @pkt_init_imm_opcode: opcode for IP_PACKET_INIT imm cmd
  1690. * @enable_clock_scaling: clock scaling is enabled ?
  1691. * @curr_ipa_clk_rate: IPA current clock rate
  1692. * @wcstats: wlan common buffer stats
  1693. * @uc_ctx: uC interface context
  1694. * @uc_wdi_ctx: WDI specific fields for uC interface
  1695. * @uc_wigig_ctx: WIGIG specific fields for uC interface
  1696. * @ipa_num_pipes: The number of pipes used by IPA HW
  1697. * @skip_uc_pipe_reset: Indicates whether pipe reset via uC needs to be avoided
  1698. * @ipa_client_apps_wan_cons_agg_gro: RMNET_IOCTL_INGRESS_FORMAT_AGG_DATA
  1699. * @apply_rg10_wa: Indicates whether to use register group 10 workaround
  1700. * @gsi_ch20_wa: Indicates whether to apply GSI physical channel 20 workaround
  1701. * @w_lock: Indicates the wakeup source.
  1702. * @wakelock_ref_cnt: Indicates the number of times wakelock is acquired
  1703. * @ipa_initialization_complete: Indicates that IPA is fully initialized
  1704. * @ipa_ready_cb_list: A list of all the clients who require a CB when IPA
  1705. * driver is ready/initialized.
  1706. * @init_completion_obj: Completion object to be used in case IPA driver hasn't
  1707. * @mhi_evid_limits: MHI event rings start and end ids
  1708. * finished initializing. Example of use - IOCTLs to /dev/ipa
  1709. * @flt_rt_counters: the counters usage info for flt rt stats
  1710. * @wdi3_ctx: IPA wdi3 context
  1711. * @gsi_info: channel/protocol info for GSI offloading uC stats
  1712. * @app_vote: holds userspace application clock vote count
  1713. * IPA context - holds all relevant info about IPA driver and its state
  1714. * @lan_rx_napi_enable: flag if NAPI is enabled on the LAN dp
  1715. * @lan_ndev: dummy netdev for LAN rx NAPI
  1716. * @napi_lan_rx: NAPI object for LAN rx
  1717. * @ipa_wan_skb_page - page recycling enabled on wwan data path
  1718. * @icc_num_cases - number of icc scaling level supported
  1719. * @icc_num_paths - number of paths icc would vote for bw
  1720. * @icc_clk - table for icc bw clock value
  1721. * @coal_cmd_pyld: holds the coslescing close frame command payload
  1722. */
  1723. struct ipa3_context {
  1724. struct ipa3_char_device_context cdev;
  1725. struct ipa3_ep_context ep[IPA3_MAX_NUM_PIPES];
  1726. bool skip_ep_cfg_shadow[IPA3_MAX_NUM_PIPES];
  1727. u32 ep_flt_bitmap;
  1728. u32 ep_flt_num;
  1729. bool resume_on_connect[IPA_CLIENT_MAX];
  1730. struct ipa3_flt_tbl flt_tbl[IPA3_MAX_NUM_PIPES][IPA_IP_MAX];
  1731. struct idr flt_rule_ids[IPA_IP_MAX];
  1732. void __iomem *mmio;
  1733. u32 ipa_wrapper_base;
  1734. u32 ipa_wrapper_size;
  1735. struct ipa3_hdr_tbl hdr_tbl;
  1736. struct ipa3_hdr_proc_ctx_tbl hdr_proc_ctx_tbl;
  1737. struct ipa3_rt_tbl_set rt_tbl_set[IPA_IP_MAX];
  1738. struct ipa3_rt_tbl_set reap_rt_tbl_set[IPA_IP_MAX];
  1739. struct kmem_cache *flt_rule_cache;
  1740. struct kmem_cache *rt_rule_cache;
  1741. struct kmem_cache *hdr_cache;
  1742. struct kmem_cache *hdr_offset_cache;
  1743. struct kmem_cache *hdr_proc_ctx_cache;
  1744. struct kmem_cache *hdr_proc_ctx_offset_cache;
  1745. struct kmem_cache *rt_tbl_cache;
  1746. struct kmem_cache *tx_pkt_wrapper_cache;
  1747. struct kmem_cache *rx_pkt_wrapper_cache;
  1748. unsigned long rt_idx_bitmap[IPA_IP_MAX];
  1749. struct mutex lock;
  1750. u16 smem_sz;
  1751. u16 smem_restricted_bytes;
  1752. u16 smem_reqd_sz;
  1753. struct ipa3_nat_mem nat_mem;
  1754. struct ipa3_ipv6ct_mem ipv6ct_mem;
  1755. u32 excp_hdr_hdl;
  1756. u32 dflt_v4_rt_rule_hdl;
  1757. u32 dflt_v6_rt_rule_hdl;
  1758. uint aggregation_type;
  1759. uint aggregation_byte_limit;
  1760. uint aggregation_time_limit;
  1761. bool hdr_tbl_lcl;
  1762. bool hdr_proc_ctx_tbl_lcl;
  1763. struct ipa_mem_buffer hdr_mem;
  1764. struct ipa_mem_buffer hdr_proc_ctx_mem;
  1765. bool ip4_rt_tbl_hash_lcl;
  1766. bool ip4_rt_tbl_nhash_lcl;
  1767. bool ip6_rt_tbl_hash_lcl;
  1768. bool ip6_rt_tbl_nhash_lcl;
  1769. bool ip4_flt_tbl_hash_lcl;
  1770. bool ip4_flt_tbl_nhash_lcl;
  1771. bool ip6_flt_tbl_hash_lcl;
  1772. bool ip6_flt_tbl_nhash_lcl;
  1773. struct ipa3_active_clients ipa3_active_clients;
  1774. struct ipa3_active_clients_log_ctx ipa3_active_clients_logging;
  1775. struct workqueue_struct *power_mgmt_wq;
  1776. struct workqueue_struct *transport_power_mgmt_wq;
  1777. bool tag_process_before_gating;
  1778. struct ipa3_transport_pm transport_pm;
  1779. unsigned long gsi_evt_comm_hdl;
  1780. u32 gsi_evt_comm_ring_rem;
  1781. u32 clnt_hdl_cmd;
  1782. u32 clnt_hdl_data_in;
  1783. u32 clnt_hdl_data_out;
  1784. spinlock_t disconnect_lock;
  1785. u8 a5_pipe_index;
  1786. struct list_head intf_list;
  1787. struct list_head msg_list;
  1788. struct list_head pull_msg_list;
  1789. struct mutex msg_lock;
  1790. struct list_head msg_wlan_client_list;
  1791. struct mutex msg_wlan_client_lock;
  1792. wait_queue_head_t msg_waitq;
  1793. enum ipa_hw_type ipa_hw_type;
  1794. enum ipa3_hw_mode ipa3_hw_mode;
  1795. enum ipa3_platform_type platform_type;
  1796. bool ipa_config_is_mhi;
  1797. bool use_ipa_teth_bridge;
  1798. bool modem_cfg_emb_pipe_flt;
  1799. bool ipa_wdi2;
  1800. bool ipa_wdi2_over_gsi;
  1801. bool ipa_wdi3_over_gsi;
  1802. bool ipa_endp_delay_wa;
  1803. bool ipa_fltrt_not_hashable;
  1804. bool use_64_bit_dma_mask;
  1805. /* featurize if memory footprint becomes a concern */
  1806. struct ipa3_stats stats;
  1807. void *smem_pipe_mem;
  1808. void *logbuf;
  1809. void *logbuf_low;
  1810. struct ipa3_controller *ctrl;
  1811. struct idr ipa_idr;
  1812. struct platform_device *master_pdev;
  1813. struct device *pdev;
  1814. struct device *uc_pdev;
  1815. spinlock_t idr_lock;
  1816. u32 enable_clock_scaling;
  1817. u32 enable_napi_chain;
  1818. u32 curr_ipa_clk_rate;
  1819. bool q6_proxy_clk_vote_valid;
  1820. struct mutex q6_proxy_clk_vote_mutex;
  1821. u32 q6_proxy_clk_vote_cnt;
  1822. u32 ipa_num_pipes;
  1823. dma_addr_t pkt_init_imm[IPA3_MAX_NUM_PIPES];
  1824. u32 pkt_init_imm_opcode;
  1825. struct ipa3_wlan_comm_memb wc_memb;
  1826. struct ipa3_uc_ctx uc_ctx;
  1827. struct ipa3_uc_wdi_ctx uc_wdi_ctx;
  1828. struct ipa3_uc_ntn_ctx uc_ntn_ctx;
  1829. struct ipa3_uc_wigig_ctx uc_wigig_ctx;
  1830. u32 wan_rx_ring_size;
  1831. u32 lan_rx_ring_size;
  1832. bool skip_uc_pipe_reset;
  1833. unsigned long gsi_dev_hdl;
  1834. u32 ee;
  1835. bool apply_rg10_wa;
  1836. bool gsi_ch20_wa;
  1837. bool s1_bypass_arr[IPA_SMMU_CB_MAX];
  1838. u32 wdi_map_cnt;
  1839. struct wakeup_source *w_lock;
  1840. struct ipa3_wakelock_ref_cnt wakelock_ref_cnt;
  1841. /* RMNET_IOCTL_INGRESS_FORMAT_AGG_DATA */
  1842. bool ipa_client_apps_wan_cons_agg_gro;
  1843. /* M-release support to know client pipes */
  1844. struct ipa3cm_client_info ipacm_client[IPA3_MAX_NUM_PIPES];
  1845. bool tethered_flow_control;
  1846. bool ipa_initialization_complete;
  1847. struct list_head ipa_ready_cb_list;
  1848. struct completion init_completion_obj;
  1849. struct completion uc_loaded_completion_obj;
  1850. struct ipa3_smp2p_info smp2p_info;
  1851. u32 mhi_evid_limits[2]; /* start and end values */
  1852. u32 ipa_tz_unlock_reg_num;
  1853. struct ipa_tz_unlock_reg_info *ipa_tz_unlock_reg;
  1854. struct ipa_dma_task_info dma_task_info;
  1855. struct ipa_hw_stats hw_stats;
  1856. struct ipa_flt_rt_counter flt_rt_counters;
  1857. struct ipa_cne_evt ipa_cne_evt_req_cache[IPA_MAX_NUM_REQ_CACHE];
  1858. int num_ipa_cne_evt_req;
  1859. struct mutex ipa_cne_evt_lock;
  1860. bool vlan_mode_iface[IPA_VLAN_IF_MAX];
  1861. bool wdi_over_pcie;
  1862. u32 entire_ipa_block_size;
  1863. bool do_register_collection_on_crash;
  1864. bool do_testbus_collection_on_crash;
  1865. bool do_non_tn_collection_on_crash;
  1866. bool do_ram_collection_on_crash;
  1867. u32 secure_debug_check_action;
  1868. u32 sd_state;
  1869. void __iomem *reg_collection_base;
  1870. struct ipa3_wdi2_ctx wdi2_ctx;
  1871. struct ipa3_pc_mbox_data pc_mbox;
  1872. struct ipa3_wdi3_ctx wdi3_ctx;
  1873. struct ipa3_usb_ctx usb_ctx;
  1874. struct ipa3_mhip_ctx mhip_ctx;
  1875. struct ipa3_aqc_ctx aqc_ctx;
  1876. atomic_t ipa_clk_vote;
  1877. int (*client_lock_unlock[IPA_MAX_CLNT])(bool is_lock);
  1878. struct ipa_fw_load_data fw_load_data;
  1879. bool (*get_teth_port_state[IPA_MAX_CLNT])(void);
  1880. atomic_t is_ssr;
  1881. struct IpaHwOffloadStatsAllocCmdData_t
  1882. gsi_info[IPA_HW_PROTOCOL_MAX];
  1883. bool ipa_wan_skb_page;
  1884. struct ipacm_fnr_info fnr_info;
  1885. /* dummy netdev for lan RX NAPI */
  1886. bool lan_rx_napi_enable;
  1887. struct net_device lan_ndev;
  1888. struct napi_struct napi_lan_rx;
  1889. u32 icc_num_cases;
  1890. u32 icc_num_paths;
  1891. u32 icc_clk[IPA_ICC_LVL_MAX][IPA_ICC_PATH_MAX][IPA_ICC_TYPE_MAX];
  1892. struct ipahal_imm_cmd_pyld *coal_cmd_pyld;
  1893. struct ipa3_app_clock_vote app_clock_vote;
  1894. };
  1895. struct ipa3_plat_drv_res {
  1896. bool use_ipa_teth_bridge;
  1897. u32 ipa_mem_base;
  1898. u32 ipa_mem_size;
  1899. u32 transport_mem_base;
  1900. u32 transport_mem_size;
  1901. u32 emulator_intcntrlr_mem_base;
  1902. u32 emulator_intcntrlr_mem_size;
  1903. u32 emulator_irq;
  1904. u32 ipa_irq;
  1905. u32 transport_irq;
  1906. u32 ipa_pipe_mem_start_ofst;
  1907. u32 ipa_pipe_mem_size;
  1908. enum ipa_hw_type ipa_hw_type;
  1909. enum ipa3_hw_mode ipa3_hw_mode;
  1910. enum ipa3_platform_type platform_type;
  1911. u32 ee;
  1912. bool modem_cfg_emb_pipe_flt;
  1913. bool ipa_wdi2;
  1914. bool ipa_wdi2_over_gsi;
  1915. bool ipa_wdi3_over_gsi;
  1916. bool ipa_fltrt_not_hashable;
  1917. bool use_64_bit_dma_mask;
  1918. bool use_bw_vote;
  1919. u32 wan_rx_ring_size;
  1920. u32 lan_rx_ring_size;
  1921. bool skip_uc_pipe_reset;
  1922. bool apply_rg10_wa;
  1923. bool gsi_ch20_wa;
  1924. bool tethered_flow_control;
  1925. bool lan_rx_napi_enable;
  1926. u32 mhi_evid_limits[2]; /* start and end values */
  1927. bool ipa_mhi_dynamic_config;
  1928. u32 ipa_tz_unlock_reg_num;
  1929. struct ipa_tz_unlock_reg_info *ipa_tz_unlock_reg;
  1930. struct ipa_pm_init_params pm_init;
  1931. bool wdi_over_pcie;
  1932. u32 entire_ipa_block_size;
  1933. bool do_register_collection_on_crash;
  1934. bool do_testbus_collection_on_crash;
  1935. bool do_non_tn_collection_on_crash;
  1936. bool do_ram_collection_on_crash;
  1937. u32 secure_debug_check_action;
  1938. bool ipa_endp_delay_wa;
  1939. bool skip_ieob_mask_wa;
  1940. bool ipa_wan_skb_page;
  1941. u32 icc_num_cases;
  1942. u32 icc_num_paths;
  1943. const char *icc_path_name[IPA_ICC_PATH_MAX];
  1944. u32 icc_clk_val[IPA_ICC_LVL_MAX][IPA_ICC_MAX];
  1945. };
  1946. /**
  1947. * struct ipa3_mem_partition - represents IPA RAM Map as read from DTS
  1948. * Order and type of members should not be changed without a suitable change
  1949. * to DTS file or the code that reads it.
  1950. *
  1951. * IPA SRAM memory layout:
  1952. * +-------------------------+
  1953. * | UC MEM |
  1954. * +-------------------------+
  1955. * | UC INFO |
  1956. * +-------------------------+
  1957. * | CANARY |
  1958. * +-------------------------+
  1959. * | CANARY |
  1960. * +-------------------------+
  1961. * | V4 FLT HDR HASHABLE |
  1962. * +-------------------------+
  1963. * | CANARY |
  1964. * +-------------------------+
  1965. * | CANARY |
  1966. * +-------------------------+
  1967. * | V4 FLT HDR NON-HASHABLE |
  1968. * +-------------------------+
  1969. * | CANARY |
  1970. * +-------------------------+
  1971. * | CANARY |
  1972. * +-------------------------+
  1973. * | V6 FLT HDR HASHABLE |
  1974. * +-------------------------+
  1975. * | CANARY |
  1976. * +-------------------------+
  1977. * | CANARY |
  1978. * +-------------------------+
  1979. * | V6 FLT HDR NON-HASHABLE |
  1980. * +-------------------------+
  1981. * | CANARY |
  1982. * +-------------------------+
  1983. * | CANARY |
  1984. * +-------------------------+
  1985. * | V4 RT HDR HASHABLE |
  1986. * +-------------------------+
  1987. * | CANARY |
  1988. * +-------------------------+
  1989. * | CANARY |
  1990. * +-------------------------+
  1991. * | V4 RT HDR NON-HASHABLE |
  1992. * +-------------------------+
  1993. * | CANARY |
  1994. * +-------------------------+
  1995. * | CANARY |
  1996. * +-------------------------+
  1997. * | V6 RT HDR HASHABLE |
  1998. * +-------------------------+
  1999. * | CANARY |
  2000. * +-------------------------+
  2001. * | CANARY |
  2002. * +-------------------------+
  2003. * | V6 RT HDR NON-HASHABLE |
  2004. * +-------------------------+
  2005. * | CANARY |
  2006. * +-------------------------+
  2007. * | CANARY |
  2008. * +-------------------------+
  2009. * | MODEM HDR |
  2010. * +-------------------------+
  2011. * | APPS HDR (IPA4.5) |
  2012. * +-------------------------+
  2013. * | CANARY |
  2014. * +-------------------------+
  2015. * | CANARY |
  2016. * +-------------------------+
  2017. * | MODEM PROC CTX |
  2018. * +-------------------------+
  2019. * | APPS PROC CTX |
  2020. * +-------------------------+
  2021. * | CANARY |
  2022. * +-------------------------+
  2023. * | CANARY |
  2024. * +-------------------------+
  2025. * | CANARY (IPA4.5) |
  2026. * +-------------------------+
  2027. * | CANARY (IPA4.5) |
  2028. * +-------------------------+
  2029. * | NAT TABLE (IPA4.5) |
  2030. * +-------------------------+
  2031. * | CANARY (IPA4.5) |
  2032. * +-------------------------+
  2033. * | CANARY (IPA4.5) |
  2034. * +-------------------------+
  2035. * | PDN CONFIG |
  2036. * +-------------------------+
  2037. * | CANARY |
  2038. * +-------------------------+
  2039. * | CANARY |
  2040. * +-------------------------+
  2041. * | QUOTA STATS |
  2042. * +-------------------------+
  2043. * | TETH STATS |
  2044. * +-------------------------+
  2045. * | FnR STATS |
  2046. * +-------------------------+
  2047. * | DROP STATS |
  2048. * +-------------------------+
  2049. * | CANARY (IPA4.5) |
  2050. * +-------------------------+
  2051. * | CANARY (IPA4.5) |
  2052. * +-------------------------+
  2053. * | MODEM MEM |
  2054. * +-------------------------+
  2055. * | Dummy (IPA4.5) |
  2056. * +-------------------------+
  2057. * | CANARY (IPA4.5) |
  2058. * +-------------------------+
  2059. * | UC DESC RAM (IPA3.5) |
  2060. * +-------------------------+
  2061. */
  2062. struct ipa3_mem_partition {
  2063. u32 ofst_start;
  2064. u32 v4_flt_hash_ofst;
  2065. u32 v4_flt_hash_size;
  2066. u32 v4_flt_hash_size_ddr;
  2067. u32 v4_flt_nhash_ofst;
  2068. u32 v4_flt_nhash_size;
  2069. u32 v4_flt_nhash_size_ddr;
  2070. u32 v6_flt_hash_ofst;
  2071. u32 v6_flt_hash_size;
  2072. u32 v6_flt_hash_size_ddr;
  2073. u32 v6_flt_nhash_ofst;
  2074. u32 v6_flt_nhash_size;
  2075. u32 v6_flt_nhash_size_ddr;
  2076. u32 v4_rt_num_index;
  2077. u32 v4_modem_rt_index_lo;
  2078. u32 v4_modem_rt_index_hi;
  2079. u32 v4_apps_rt_index_lo;
  2080. u32 v4_apps_rt_index_hi;
  2081. u32 v4_rt_hash_ofst;
  2082. u32 v4_rt_hash_size;
  2083. u32 v4_rt_hash_size_ddr;
  2084. u32 v4_rt_nhash_ofst;
  2085. u32 v4_rt_nhash_size;
  2086. u32 v4_rt_nhash_size_ddr;
  2087. u32 v6_rt_num_index;
  2088. u32 v6_modem_rt_index_lo;
  2089. u32 v6_modem_rt_index_hi;
  2090. u32 v6_apps_rt_index_lo;
  2091. u32 v6_apps_rt_index_hi;
  2092. u32 v6_rt_hash_ofst;
  2093. u32 v6_rt_hash_size;
  2094. u32 v6_rt_hash_size_ddr;
  2095. u32 v6_rt_nhash_ofst;
  2096. u32 v6_rt_nhash_size;
  2097. u32 v6_rt_nhash_size_ddr;
  2098. u32 modem_hdr_ofst;
  2099. u32 modem_hdr_size;
  2100. u32 apps_hdr_ofst;
  2101. u32 apps_hdr_size;
  2102. u32 apps_hdr_size_ddr;
  2103. u32 modem_hdr_proc_ctx_ofst;
  2104. u32 modem_hdr_proc_ctx_size;
  2105. u32 apps_hdr_proc_ctx_ofst;
  2106. u32 apps_hdr_proc_ctx_size;
  2107. u32 apps_hdr_proc_ctx_size_ddr;
  2108. u32 nat_tbl_ofst;
  2109. u32 nat_tbl_size;
  2110. u32 modem_comp_decomp_ofst;
  2111. u32 modem_comp_decomp_size;
  2112. u32 modem_ofst;
  2113. u32 modem_size;
  2114. u32 apps_v4_flt_hash_ofst;
  2115. u32 apps_v4_flt_hash_size;
  2116. u32 apps_v4_flt_nhash_ofst;
  2117. u32 apps_v4_flt_nhash_size;
  2118. u32 apps_v6_flt_hash_ofst;
  2119. u32 apps_v6_flt_hash_size;
  2120. u32 apps_v6_flt_nhash_ofst;
  2121. u32 apps_v6_flt_nhash_size;
  2122. u32 uc_info_ofst;
  2123. u32 uc_info_size;
  2124. u32 end_ofst;
  2125. u32 apps_v4_rt_hash_ofst;
  2126. u32 apps_v4_rt_hash_size;
  2127. u32 apps_v4_rt_nhash_ofst;
  2128. u32 apps_v4_rt_nhash_size;
  2129. u32 apps_v6_rt_hash_ofst;
  2130. u32 apps_v6_rt_hash_size;
  2131. u32 apps_v6_rt_nhash_ofst;
  2132. u32 apps_v6_rt_nhash_size;
  2133. u32 uc_descriptor_ram_ofst;
  2134. u32 uc_descriptor_ram_size;
  2135. u32 pdn_config_ofst;
  2136. u32 pdn_config_size;
  2137. u32 stats_quota_ofst;
  2138. u32 stats_quota_size;
  2139. u32 stats_tethering_ofst;
  2140. u32 stats_tethering_size;
  2141. u32 stats_fnr_ofst;
  2142. u32 stats_fnr_size;
  2143. /* Irrelevant starting IPA4.5 */
  2144. u32 stats_flt_v4_ofst;
  2145. u32 stats_flt_v4_size;
  2146. u32 stats_flt_v6_ofst;
  2147. u32 stats_flt_v6_size;
  2148. u32 stats_rt_v4_ofst;
  2149. u32 stats_rt_v4_size;
  2150. u32 stats_rt_v6_ofst;
  2151. u32 stats_rt_v6_size;
  2152. u32 stats_drop_ofst;
  2153. u32 stats_drop_size;
  2154. };
  2155. struct ipa3_controller {
  2156. struct ipa3_mem_partition *mem_partition;
  2157. u32 ipa_clk_rate_turbo;
  2158. u32 ipa_clk_rate_nominal;
  2159. u32 ipa_clk_rate_svs;
  2160. u32 ipa_clk_rate_svs2;
  2161. u32 clock_scaling_bw_threshold_turbo;
  2162. u32 clock_scaling_bw_threshold_nominal;
  2163. u32 clock_scaling_bw_threshold_svs;
  2164. u32 ipa_reg_base_ofst;
  2165. u32 max_holb_tmr_val;
  2166. void (*ipa_sram_read_settings)(void);
  2167. int (*ipa_init_sram)(void);
  2168. int (*ipa_init_hdr)(void);
  2169. int (*ipa_init_rt4)(void);
  2170. int (*ipa_init_rt6)(void);
  2171. int (*ipa_init_flt4)(void);
  2172. int (*ipa_init_flt6)(void);
  2173. int (*ipa3_read_ep_reg)(char *buff, int max_len, int pipe);
  2174. int (*ipa3_commit_flt)(enum ipa_ip_type ip);
  2175. int (*ipa3_commit_rt)(enum ipa_ip_type ip);
  2176. int (*ipa3_commit_hdr)(void);
  2177. void (*ipa3_enable_clks)(void);
  2178. void (*ipa3_disable_clks)(void);
  2179. struct icc_path *icc_path[IPA_ICC_PATH_MAX];
  2180. };
  2181. extern struct ipa3_context *ipa3_ctx;
  2182. /* public APIs */
  2183. /* Generic GSI channels functions */
  2184. int ipa3_request_gsi_channel(struct ipa_request_gsi_channel_params *params,
  2185. struct ipa_req_chan_out_params *out_params);
  2186. int ipa3_release_gsi_channel(u32 clnt_hdl);
  2187. int ipa3_start_gsi_channel(u32 clnt_hdl);
  2188. int ipa3_stop_gsi_channel(u32 clnt_hdl);
  2189. int ipa3_reset_gsi_channel(u32 clnt_hdl);
  2190. int ipa3_reset_gsi_event_ring(u32 clnt_hdl);
  2191. /* Specific xDCI channels functions */
  2192. int ipa3_set_usb_max_packet_size(
  2193. enum ipa_usb_max_usb_packet_size usb_max_packet_size);
  2194. int ipa3_xdci_start(u32 clnt_hdl, u8 xferrscidx, bool xferrscidx_valid);
  2195. int ipa3_xdci_connect(u32 clnt_hdl);
  2196. int ipa3_xdci_disconnect(u32 clnt_hdl, bool should_force_clear, u32 qmi_req_id);
  2197. void ipa3_xdci_ep_delay_rm(u32 clnt_hdl);
  2198. void ipa3_register_client_callback(int (*client_cb)(bool),
  2199. bool (*teth_port_state)(void),
  2200. enum ipa_client_type client_type);
  2201. void ipa3_deregister_client_callback(enum ipa_client_type client_type);
  2202. int ipa3_set_reset_client_prod_pipe_delay(bool set_reset,
  2203. enum ipa_client_type client);
  2204. int ipa3_start_stop_client_prod_gsi_chnl(enum ipa_client_type client,
  2205. bool start_chnl);
  2206. void ipa3_client_prod_post_shutdown_cleanup(void);
  2207. int ipa3_set_reset_client_cons_pipe_sus_holb(bool set_reset,
  2208. enum ipa_client_type client);
  2209. int ipa3_xdci_suspend(u32 ul_clnt_hdl, u32 dl_clnt_hdl,
  2210. bool should_force_clear, u32 qmi_req_id, bool is_dpl);
  2211. int ipa3_xdci_resume(u32 ul_clnt_hdl, u32 dl_clnt_hdl, bool is_dpl);
  2212. /*
  2213. * Remove ep delay
  2214. */
  2215. int ipa3_clear_endpoint_delay(u32 clnt_hdl);
  2216. /*
  2217. * Configuration
  2218. */
  2219. int ipa3_cfg_ep(u32 clnt_hdl, const struct ipa_ep_cfg *ipa_ep_cfg);
  2220. int ipa3_cfg_ep_nat(u32 clnt_hdl, const struct ipa_ep_cfg_nat *ipa_ep_cfg);
  2221. int ipa3_cfg_ep_conn_track(u32 clnt_hdl,
  2222. const struct ipa_ep_cfg_conn_track *ep_conn_track);
  2223. int ipa3_cfg_ep_hdr(u32 clnt_hdl, const struct ipa_ep_cfg_hdr *ipa_ep_cfg);
  2224. int ipa3_cfg_ep_hdr_ext(u32 clnt_hdl,
  2225. const struct ipa_ep_cfg_hdr_ext *ipa_ep_cfg);
  2226. int ipa3_cfg_ep_mode(u32 clnt_hdl, const struct ipa_ep_cfg_mode *ipa_ep_cfg);
  2227. int ipa3_cfg_ep_aggr(u32 clnt_hdl, const struct ipa_ep_cfg_aggr *ipa_ep_cfg);
  2228. int ipa3_cfg_ep_deaggr(u32 clnt_hdl,
  2229. const struct ipa_ep_cfg_deaggr *ipa_ep_cfg);
  2230. int ipa3_cfg_ep_route(u32 clnt_hdl, const struct ipa_ep_cfg_route *ipa_ep_cfg);
  2231. int ipa3_cfg_ep_holb(u32 clnt_hdl, const struct ipa_ep_cfg_holb *ipa_ep_cfg);
  2232. void ipa3_cal_ep_holb_scale_base_val(u32 tmr_val,
  2233. struct ipa_ep_cfg_holb *ep_holb);
  2234. int ipa3_cfg_ep_cfg(u32 clnt_hdl, const struct ipa_ep_cfg_cfg *ipa_ep_cfg);
  2235. int ipa3_cfg_ep_metadata_mask(u32 clnt_hdl,
  2236. const struct ipa_ep_cfg_metadata_mask *ipa_ep_cfg);
  2237. int ipa3_cfg_ep_holb_by_client(enum ipa_client_type client,
  2238. const struct ipa_ep_cfg_holb *ipa_ep_cfg);
  2239. int ipa3_cfg_ep_ctrl(u32 clnt_hdl, const struct ipa_ep_cfg_ctrl *ep_ctrl);
  2240. /*
  2241. * Header removal / addition
  2242. */
  2243. int ipa3_add_hdr(struct ipa_ioc_add_hdr *hdrs);
  2244. int ipa3_add_hdr_usr(struct ipa_ioc_add_hdr *hdrs, bool by_user);
  2245. int ipa3_del_hdr(struct ipa_ioc_del_hdr *hdls);
  2246. int ipa3_del_hdr_by_user(struct ipa_ioc_del_hdr *hdls, bool by_user);
  2247. int ipa3_commit_hdr(void);
  2248. int ipa3_reset_hdr(bool user_only);
  2249. int ipa3_get_hdr(struct ipa_ioc_get_hdr *lookup);
  2250. int ipa3_put_hdr(u32 hdr_hdl);
  2251. int ipa3_copy_hdr(struct ipa_ioc_copy_hdr *copy);
  2252. /*
  2253. * Header Processing Context
  2254. */
  2255. int ipa3_add_hdr_proc_ctx(struct ipa_ioc_add_hdr_proc_ctx *proc_ctxs,
  2256. bool user_only);
  2257. int ipa3_del_hdr_proc_ctx(struct ipa_ioc_del_hdr_proc_ctx *hdls);
  2258. int ipa3_del_hdr_proc_ctx_by_user(struct ipa_ioc_del_hdr_proc_ctx *hdls,
  2259. bool by_user);
  2260. /*
  2261. * Routing
  2262. */
  2263. int ipa3_add_rt_rule(struct ipa_ioc_add_rt_rule *rules);
  2264. int ipa3_add_rt_rule_v2(struct ipa_ioc_add_rt_rule_v2 *rules);
  2265. int ipa3_add_rt_rule_usr(struct ipa_ioc_add_rt_rule *rules,
  2266. bool user_only);
  2267. int ipa3_add_rt_rule_usr_v2(struct ipa_ioc_add_rt_rule_v2 *rules,
  2268. bool user_only);
  2269. int ipa3_add_rt_rule_ext(struct ipa_ioc_add_rt_rule_ext *rules);
  2270. int ipa3_add_rt_rule_ext_v2(struct ipa_ioc_add_rt_rule_ext_v2 *rules);
  2271. int ipa3_add_rt_rule_after(struct ipa_ioc_add_rt_rule_after *rules);
  2272. int ipa3_add_rt_rule_after_v2(struct ipa_ioc_add_rt_rule_after_v2
  2273. *rules);
  2274. int ipa3_del_rt_rule(struct ipa_ioc_del_rt_rule *hdls);
  2275. int ipa3_commit_rt(enum ipa_ip_type ip);
  2276. int ipa3_reset_rt(enum ipa_ip_type ip, bool user_only);
  2277. int ipa3_get_rt_tbl(struct ipa_ioc_get_rt_tbl *lookup);
  2278. int ipa3_put_rt_tbl(u32 rt_tbl_hdl);
  2279. int ipa3_query_rt_index(struct ipa_ioc_get_rt_tbl_indx *in);
  2280. int ipa3_mdfy_rt_rule(struct ipa_ioc_mdfy_rt_rule *rules);
  2281. int ipa3_mdfy_rt_rule_v2(struct ipa_ioc_mdfy_rt_rule_v2 *rules);
  2282. /*
  2283. * Filtering
  2284. */
  2285. int ipa3_add_flt_rule(struct ipa_ioc_add_flt_rule *rules);
  2286. int ipa3_add_flt_rule_v2(struct ipa_ioc_add_flt_rule_v2 *rules);
  2287. int ipa3_add_flt_rule_usr(struct ipa_ioc_add_flt_rule *rules,
  2288. bool user_only);
  2289. int ipa3_add_flt_rule_usr_v2(struct ipa_ioc_add_flt_rule_v2 *rules,
  2290. bool user_only);
  2291. int ipa3_add_flt_rule_after(struct ipa_ioc_add_flt_rule_after *rules);
  2292. int ipa3_add_flt_rule_after_v2(struct ipa_ioc_add_flt_rule_after_v2
  2293. *rules);
  2294. int ipa3_del_flt_rule(struct ipa_ioc_del_flt_rule *hdls);
  2295. int ipa3_mdfy_flt_rule(struct ipa_ioc_mdfy_flt_rule *rules);
  2296. int ipa3_mdfy_flt_rule_v2(struct ipa_ioc_mdfy_flt_rule_v2 *rules);
  2297. int ipa3_commit_flt(enum ipa_ip_type ip);
  2298. int ipa3_reset_flt(enum ipa_ip_type ip, bool user_only);
  2299. /*
  2300. * NAT
  2301. */
  2302. int ipa3_nat_ipv6ct_init_devices(void);
  2303. void ipa3_nat_ipv6ct_destroy_devices(void);
  2304. int ipa3_allocate_nat_device(struct ipa_ioc_nat_alloc_mem *mem);
  2305. int ipa3_allocate_nat_table(
  2306. struct ipa_ioc_nat_ipv6ct_table_alloc *table_alloc);
  2307. int ipa3_allocate_ipv6ct_table(
  2308. struct ipa_ioc_nat_ipv6ct_table_alloc *table_alloc);
  2309. int ipa3_nat_init_cmd(struct ipa_ioc_v4_nat_init *init);
  2310. int ipa3_ipv6ct_init_cmd(struct ipa_ioc_ipv6ct_init *init);
  2311. int ipa3_table_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma);
  2312. int ipa3_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma);
  2313. int ipa3_nat_del_cmd(struct ipa_ioc_v4_nat_del *del);
  2314. int ipa3_del_nat_table(struct ipa_ioc_nat_ipv6ct_table_del *del);
  2315. int ipa3_del_ipv6ct_table(struct ipa_ioc_nat_ipv6ct_table_del *del);
  2316. int ipa3_nat_mdfy_pdn(struct ipa_ioc_nat_pdn_entry *mdfy_pdn);
  2317. int ipa3_nat_get_sram_info(struct ipa_nat_in_sram_info *info_ptr);
  2318. int ipa3_app_clk_vote(enum ipa_app_clock_vote_type vote_type);
  2319. /*
  2320. * Messaging
  2321. */
  2322. int ipa3_send_msg(struct ipa_msg_meta *meta, void *buff,
  2323. ipa_msg_free_fn callback);
  2324. int ipa3_resend_wlan_msg(void);
  2325. int ipa3_register_pull_msg(struct ipa_msg_meta *meta, ipa_msg_pull_fn callback);
  2326. int ipa3_deregister_pull_msg(struct ipa_msg_meta *meta);
  2327. /*
  2328. * Interface
  2329. */
  2330. int ipa3_register_intf(const char *name, const struct ipa_tx_intf *tx,
  2331. const struct ipa_rx_intf *rx);
  2332. int ipa3_register_intf_ext(const char *name, const struct ipa_tx_intf *tx,
  2333. const struct ipa_rx_intf *rx,
  2334. const struct ipa_ext_intf *ext);
  2335. int ipa3_deregister_intf(const char *name);
  2336. /*
  2337. * Aggregation
  2338. */
  2339. int ipa3_set_aggr_mode(enum ipa_aggr_mode mode);
  2340. int ipa3_set_qcncm_ndp_sig(char sig[3]);
  2341. int ipa3_set_single_ndp_per_mbim(bool enable);
  2342. /*
  2343. * Data path
  2344. */
  2345. int ipa3_tx_dp(enum ipa_client_type dst, struct sk_buff *skb,
  2346. struct ipa_tx_meta *metadata);
  2347. /*
  2348. * To transfer multiple data packets
  2349. * While passing the data descriptor list, the anchor node
  2350. * should be of type struct ipa_tx_data_desc not list_head
  2351. */
  2352. int ipa3_tx_dp_mul(enum ipa_client_type dst,
  2353. struct ipa_tx_data_desc *data_desc);
  2354. void ipa3_free_skb(struct ipa_rx_data *data);
  2355. /*
  2356. * System pipes
  2357. */
  2358. int ipa3_setup_sys_pipe(struct ipa_sys_connect_params *sys_in, u32 *clnt_hdl);
  2359. int ipa3_teardown_sys_pipe(u32 clnt_hdl);
  2360. int ipa3_sys_setup(struct ipa_sys_connect_params *sys_in,
  2361. unsigned long *ipa_transport_hdl,
  2362. u32 *ipa_pipe_num, u32 *clnt_hdl, bool en_status);
  2363. int ipa3_sys_teardown(u32 clnt_hdl);
  2364. int ipa3_sys_update_gsi_hdls(u32 clnt_hdl, unsigned long gsi_ch_hdl,
  2365. unsigned long gsi_ev_hdl);
  2366. int ipa3_connect_wdi_pipe(struct ipa_wdi_in_params *in,
  2367. struct ipa_wdi_out_params *out);
  2368. int ipa3_connect_gsi_wdi_pipe(struct ipa_wdi_in_params *in,
  2369. struct ipa_wdi_out_params *out);
  2370. int ipa3_disconnect_wdi_pipe(u32 clnt_hdl);
  2371. int ipa3_enable_wdi_pipe(u32 clnt_hdl);
  2372. int ipa3_enable_gsi_wdi_pipe(u32 clnt_hdl);
  2373. int ipa3_disable_wdi_pipe(u32 clnt_hdl);
  2374. int ipa3_disable_gsi_wdi_pipe(u32 clnt_hdl);
  2375. int ipa3_disconnect_gsi_wdi_pipe(u32 clnt_hdl);
  2376. int ipa3_resume_wdi_pipe(u32 clnt_hdl);
  2377. int ipa3_resume_gsi_wdi_pipe(u32 clnt_hdl);
  2378. int ipa3_suspend_wdi_pipe(u32 clnt_hdl);
  2379. void ipa3_get_gsi_stats(int prot_id,
  2380. struct ipa_uc_dbg_ring_stats *stats);
  2381. int ipa3_get_wdi_gsi_stats(struct ipa_uc_dbg_ring_stats *stats);
  2382. int ipa3_get_wdi3_gsi_stats(struct ipa_uc_dbg_ring_stats *stats);
  2383. int ipa3_get_usb_gsi_stats(struct ipa_uc_dbg_ring_stats *stats);
  2384. int ipa3_get_aqc_gsi_stats(struct ipa_uc_dbg_ring_stats *stats);
  2385. int ipa3_get_wdi_stats(struct IpaHwStatsWDIInfoData_t *stats);
  2386. int ipa3_get_prot_id(enum ipa_client_type client);
  2387. u16 ipa3_get_smem_restr_bytes(void);
  2388. int ipa3_broadcast_wdi_quota_reach_ind(uint32_t fid, uint64_t num_bytes);
  2389. int ipa3_setup_uc_ntn_pipes(struct ipa_ntn_conn_in_params *in,
  2390. ipa_notify_cb notify, void *priv, u8 hdr_len,
  2391. struct ipa_ntn_conn_out_params *outp);
  2392. int ipa3_tear_down_uc_offload_pipes(int ipa_ep_idx_ul, int ipa_ep_idx_dl,
  2393. struct ipa_ntn_conn_in_params *params);
  2394. int ipa3_ntn_uc_reg_rdyCB(void (*ipauc_ready_cb)(void *), void *priv);
  2395. void ipa3_ntn_uc_dereg_rdyCB(void);
  2396. int ipa3_conn_wdi3_pipes(struct ipa_wdi_conn_in_params *in,
  2397. struct ipa_wdi_conn_out_params *out,
  2398. ipa_wdi_meter_notifier_cb wdi_notify);
  2399. int ipa3_disconn_wdi3_pipes(int ipa_ep_idx_tx, int ipa_ep_idx_rx);
  2400. int ipa3_enable_wdi3_pipes(int ipa_ep_idx_tx, int ipa_ep_idx_rx);
  2401. int ipa3_disable_wdi3_pipes(int ipa_ep_idx_tx, int ipa_ep_idx_rx);
  2402. int ipa3_conn_wigig_rx_pipe_i(void *in,
  2403. struct ipa_wigig_conn_out_params *out,
  2404. struct dentry **parent);
  2405. int ipa3_conn_wigig_client_i(void *in,
  2406. struct ipa_wigig_conn_out_params *out,
  2407. ipa_notify_cb tx_notify,
  2408. void *priv);
  2409. int ipa3_wigig_uc_msi_init(bool init,
  2410. phys_addr_t periph_baddr_pa,
  2411. phys_addr_t pseudo_cause_pa,
  2412. phys_addr_t int_gen_tx_pa,
  2413. phys_addr_t int_gen_rx_pa,
  2414. phys_addr_t dma_ep_misc_pa);
  2415. int ipa3_disconn_wigig_pipe_i(enum ipa_client_type client,
  2416. struct ipa_wigig_pipe_setup_info_smmu *pipe_smmu,
  2417. void *dbuff);
  2418. int ipa3_enable_wigig_pipe_i(enum ipa_client_type client);
  2419. int ipa3_disable_wigig_pipe_i(enum ipa_client_type client);
  2420. int ipa3_wigig_init_debugfs_i(struct dentry *dent);
  2421. /*
  2422. * To retrieve doorbell physical address of
  2423. * wlan pipes
  2424. */
  2425. int ipa3_uc_wdi_get_dbpa(struct ipa_wdi_db_params *out);
  2426. /*
  2427. * To register uC ready callback if uC not ready
  2428. * and also check uC readiness
  2429. * if uC not ready only, register callback
  2430. */
  2431. int ipa3_uc_reg_rdyCB(struct ipa_wdi_uc_ready_params *param);
  2432. /*
  2433. * To de-register uC ready callback
  2434. */
  2435. int ipa3_uc_dereg_rdyCB(void);
  2436. int ipa_create_uc_smmu_mapping(int res_idx, bool wlan_smmu_en,
  2437. phys_addr_t pa, struct sg_table *sgt, size_t len, bool device,
  2438. unsigned long *iova);
  2439. int ipa_create_gsi_smmu_mapping(int res_idx, bool wlan_smmu_en,
  2440. phys_addr_t pa, struct sg_table *sgt, size_t len, bool device,
  2441. unsigned long *iova);
  2442. void ipa3_release_wdi3_gsi_smmu_mappings(u8 dir);
  2443. /*
  2444. * Tethering bridge (Rmnet / MBIM)
  2445. */
  2446. int ipa3_teth_bridge_init(struct teth_bridge_init_params *params);
  2447. int ipa3_teth_bridge_disconnect(enum ipa_client_type client);
  2448. int ipa3_teth_bridge_connect(struct teth_bridge_connect_params *connect_params);
  2449. int ipa3_teth_bridge_get_pm_hdl(void);
  2450. /*
  2451. * Tethering client info
  2452. */
  2453. void ipa3_set_client(int index, enum ipacm_client_enum client, bool uplink);
  2454. enum ipacm_client_enum ipa3_get_client(int pipe_idx);
  2455. bool ipa3_get_client_uplink(int pipe_idx);
  2456. int ipa3_get_wlan_stats(struct ipa_get_wdi_sap_stats *wdi_sap_stats);
  2457. int ipa3_set_wlan_quota(struct ipa_set_wifi_quota *wdi_quota);
  2458. int ipa3_inform_wlan_bw(struct ipa_inform_wlan_bw *wdi_bw);
  2459. /*
  2460. * IPADMA
  2461. */
  2462. int ipa3_dma_init(void);
  2463. int ipa3_dma_enable(void);
  2464. int ipa3_dma_disable(void);
  2465. int ipa3_dma_sync_memcpy(u64 dest, u64 src, int len);
  2466. int ipa3_dma_async_memcpy(u64 dest, u64 src, int len,
  2467. void (*user_cb)(void *user1), void *user_param);
  2468. int ipa3_dma_uc_memcpy(phys_addr_t dest, phys_addr_t src, int len);
  2469. void ipa3_dma_destroy(void);
  2470. /*
  2471. * MHI
  2472. */
  2473. int ipa3_mhi_init_engine(struct ipa_mhi_init_engine *params);
  2474. int ipa3_connect_mhi_pipe(
  2475. struct ipa_mhi_connect_params_internal *in,
  2476. u32 *clnt_hdl);
  2477. int ipa3_disconnect_mhi_pipe(u32 clnt_hdl);
  2478. bool ipa3_mhi_stop_gsi_channel(enum ipa_client_type client);
  2479. int ipa3_mhi_reset_channel_internal(enum ipa_client_type client);
  2480. int ipa3_mhi_start_channel_internal(enum ipa_client_type client);
  2481. bool ipa3_has_open_aggr_frame(enum ipa_client_type client);
  2482. int ipa3_mhi_resume_channels_internal(enum ipa_client_type client,
  2483. bool LPTransitionRejected, bool brstmode_enabled,
  2484. union __packed gsi_channel_scratch ch_scratch, u8 index);
  2485. int ipa3_mhi_destroy_channel(enum ipa_client_type client);
  2486. /*
  2487. * mux id
  2488. */
  2489. int ipa3_write_qmap_id(struct ipa_ioc_write_qmapid *param_in);
  2490. /*
  2491. * interrupts
  2492. */
  2493. int ipa3_add_interrupt_handler(enum ipa_irq_type interrupt,
  2494. ipa_irq_handler_t handler,
  2495. bool deferred_flag,
  2496. void *private_data);
  2497. int ipa3_remove_interrupt_handler(enum ipa_irq_type interrupt);
  2498. /*
  2499. * Miscellaneous
  2500. */
  2501. int ipa3_get_ep_mapping(enum ipa_client_type client);
  2502. bool ipa3_is_ready(void);
  2503. int ipa3_ctx_get_type(enum ipa_type_mode type);
  2504. bool ipa3_ctx_get_flag(enum ipa_flag flag);
  2505. u32 ipa3_ctx_get_num_pipes(void);
  2506. void ipa3_proxy_clk_vote(void);
  2507. void ipa3_proxy_clk_unvote(void);
  2508. bool ipa3_is_client_handle_valid(u32 clnt_hdl);
  2509. enum ipa_client_type ipa3_get_client_mapping(int pipe_idx);
  2510. enum ipa_client_type ipa3_get_client_by_pipe(int pipe_idx);
  2511. void ipa_init_ep_flt_bitmap(void);
  2512. bool ipa_is_ep_support_flt(int pipe_idx);
  2513. bool ipa3_get_modem_cfg_emb_pipe_flt(void);
  2514. u8 ipa3_get_qmb_master_sel(enum ipa_client_type client);
  2515. int ipa3_get_smmu_params(struct ipa_smmu_in_params *in,
  2516. struct ipa_smmu_out_params *out);
  2517. bool ipa3_get_lan_rx_napi(void);
  2518. /* internal functions */
  2519. int ipa3_bind_api_controller(enum ipa_hw_type ipa_hw_type,
  2520. struct ipa_api_controller *api_ctrl);
  2521. bool ipa_is_modem_pipe(int pipe_idx);
  2522. int ipa3_send_one(struct ipa3_sys_context *sys, struct ipa3_desc *desc,
  2523. bool in_atomic);
  2524. int ipa3_send(struct ipa3_sys_context *sys,
  2525. u32 num_desc,
  2526. struct ipa3_desc *desc,
  2527. bool in_atomic);
  2528. int ipa3_get_ep_mapping(enum ipa_client_type client);
  2529. int ipa_get_ep_group(enum ipa_client_type client);
  2530. int ipa3_generate_hw_rule(enum ipa_ip_type ip,
  2531. const struct ipa_rule_attrib *attrib,
  2532. u8 **buf,
  2533. u16 *en_rule);
  2534. int ipa3_init_hw(void);
  2535. struct ipa3_rt_tbl *__ipa3_find_rt_tbl(enum ipa_ip_type ip, const char *name);
  2536. int ipa3_set_single_ndp_per_mbim(bool enable);
  2537. void ipa3_debugfs_init(void);
  2538. void ipa3_debugfs_remove(void);
  2539. void ipa3_dump_buff_internal(void *base, dma_addr_t phy_base, u32 size);
  2540. #ifdef IPA_DEBUG
  2541. #define IPA_DUMP_BUFF(base, phy_base, size) \
  2542. ipa3_dump_buff_internal(base, phy_base, size)
  2543. #else
  2544. #define IPA_DUMP_BUFF(base, phy_base, size)
  2545. #endif
  2546. int ipa3_init_mem_partition(enum ipa_hw_type ipa_hw_type);
  2547. int ipa3_controller_static_bind(struct ipa3_controller *controller,
  2548. enum ipa_hw_type ipa_hw_type);
  2549. int ipa3_cfg_route(struct ipahal_reg_route *route);
  2550. int ipa3_send_cmd_timeout(u16 num_desc, struct ipa3_desc *descr, u32 timeout);
  2551. int ipa3_send_cmd(u16 num_desc, struct ipa3_desc *descr);
  2552. int ipa3_cfg_filter(u32 disable);
  2553. int ipa3_straddle_boundary(u32 start, u32 end, u32 boundary);
  2554. struct ipa3_context *ipa3_get_ctx(void);
  2555. void ipa3_enable_clks(void);
  2556. void ipa3_disable_clks(void);
  2557. void ipa3_inc_client_enable_clks(struct ipa_active_client_logging_info *id);
  2558. int ipa3_inc_client_enable_clks_no_block(struct ipa_active_client_logging_info
  2559. *id);
  2560. void ipa3_dec_client_disable_clks(struct ipa_active_client_logging_info *id);
  2561. void ipa3_dec_client_disable_clks_no_block(
  2562. struct ipa_active_client_logging_info *id);
  2563. void ipa3_active_clients_log_dec(struct ipa_active_client_logging_info *id,
  2564. bool int_ctx);
  2565. void ipa3_active_clients_log_inc(struct ipa_active_client_logging_info *id,
  2566. bool int_ctx);
  2567. int ipa3_active_clients_log_print_buffer(char *buf, int size);
  2568. int ipa3_active_clients_log_print_table(char *buf, int size);
  2569. void ipa3_active_clients_log_clear(void);
  2570. int ipa3_interrupts_init(u32 ipa_irq, u32 ee, struct device *ipa_dev);
  2571. void ipa3_interrupts_destroy(u32 ipa_irq, struct device *ipa_dev);
  2572. int __ipa3_del_rt_rule(u32 rule_hdl);
  2573. int __ipa3_del_hdr(u32 hdr_hdl, bool by_user);
  2574. int __ipa3_release_hdr(u32 hdr_hdl);
  2575. int __ipa3_release_hdr_proc_ctx(u32 proc_ctx_hdl);
  2576. int _ipa_read_ep_reg_v3_0(char *buf, int max_len, int pipe);
  2577. int _ipa_read_ep_reg_v4_0(char *buf, int max_len, int pipe);
  2578. int _ipa_read_ipahal_regs(void);
  2579. void _ipa_enable_clks_v3_0(void);
  2580. void _ipa_disable_clks_v3_0(void);
  2581. struct device *ipa3_get_dma_dev(void);
  2582. void ipa3_suspend_active_aggr_wa(u32 clnt_hdl);
  2583. void ipa3_suspend_handler(enum ipa_irq_type interrupt,
  2584. void *private_data,
  2585. void *interrupt_data);
  2586. ssize_t ipa3_read(struct file *filp, char __user *buf, size_t count,
  2587. loff_t *f_pos);
  2588. int ipa3_pull_msg(struct ipa_msg_meta *meta, char *buff, size_t count);
  2589. int ipa3_query_intf(struct ipa_ioc_query_intf *lookup);
  2590. int ipa3_query_intf_tx_props(struct ipa_ioc_query_intf_tx_props *tx);
  2591. int ipa3_query_intf_rx_props(struct ipa_ioc_query_intf_rx_props *rx);
  2592. int ipa3_query_intf_ext_props(struct ipa_ioc_query_intf_ext_props *ext);
  2593. void wwan_cleanup(void);
  2594. int ipa3_teth_bridge_driver_init(void);
  2595. void ipa3_lan_rx_cb(void *priv, enum ipa_dp_evt_type evt, unsigned long data);
  2596. int _ipa_init_sram_v3(void);
  2597. int _ipa_init_hdr_v3_0(void);
  2598. int _ipa_init_rt4_v3(void);
  2599. int _ipa_init_rt6_v3(void);
  2600. int _ipa_init_flt4_v3(void);
  2601. int _ipa_init_flt6_v3(void);
  2602. int __ipa_commit_flt_v3(enum ipa_ip_type ip);
  2603. int __ipa_commit_rt_v3(enum ipa_ip_type ip);
  2604. int __ipa_commit_hdr_v3_0(void);
  2605. void ipa3_skb_recycle(struct sk_buff *skb);
  2606. void ipa3_install_dflt_flt_rules(u32 ipa_ep_idx);
  2607. void ipa3_delete_dflt_flt_rules(u32 ipa_ep_idx);
  2608. int ipa3_enable_data_path(u32 clnt_hdl);
  2609. int ipa3_disable_data_path(u32 clnt_hdl);
  2610. int ipa3_disable_gsi_data_path(u32 clnt_hdl);
  2611. int ipa3_alloc_rule_id(struct idr *rule_ids);
  2612. int ipa3_alloc_counter_id(struct ipa_ioc_flt_rt_counter_alloc *counter);
  2613. void ipa3_counter_remove_hdl(int hdl);
  2614. void ipa3_counter_id_remove_all(void);
  2615. int ipa3_id_alloc(void *ptr);
  2616. bool ipa3_check_idr_if_freed(void *ptr);
  2617. void *ipa3_id_find(u32 id);
  2618. void ipa3_id_remove(u32 id);
  2619. int ipa3_enable_force_clear(u32 request_id, bool throttle_source,
  2620. u32 source_pipe_bitmask);
  2621. int ipa3_disable_force_clear(u32 request_id);
  2622. int ipa3_set_required_perf_profile(enum ipa_voltage_level floor_voltage,
  2623. u32 bandwidth_mbps);
  2624. int ipa3_cfg_ep_status(u32 clnt_hdl,
  2625. const struct ipahal_reg_ep_cfg_status *ipa_ep_cfg);
  2626. int ipa3_suspend_resource_no_block(enum ipa_rm_resource_name name);
  2627. int ipa3_suspend_resource_sync(enum ipa_rm_resource_name name);
  2628. int ipa3_resume_resource(enum ipa_rm_resource_name name);
  2629. bool ipa3_should_pipe_be_suspended(enum ipa_client_type client);
  2630. int ipa3_tag_aggr_force_close(int pipe_num);
  2631. void ipa3_active_clients_unlock(void);
  2632. int ipa3_wdi_init(void);
  2633. int ipa3_write_qmapid_gsi_wdi_pipe(u32 clnt_hdl, u8 qmap_id);
  2634. int ipa3_write_qmapid_wdi_pipe(u32 clnt_hdl, u8 qmap_id);
  2635. int ipa3_write_qmapid_wdi3_gsi_pipe(u32 clnt_hdl, u8 qmap_id);
  2636. int ipa3_tag_process(struct ipa3_desc *desc, int num_descs,
  2637. unsigned long timeout);
  2638. void ipa3_q6_pre_shutdown_cleanup(void);
  2639. void ipa3_q6_post_shutdown_cleanup(void);
  2640. void ipa3_q6_pre_powerup_cleanup(void);
  2641. void ipa3_update_ssr_state(bool is_ssr);
  2642. int ipa3_init_q6_smem(void);
  2643. int ipa3_mhi_handle_ipa_config_req(struct ipa_config_req_msg_v01 *config_req);
  2644. int ipa3_mhi_query_ch_info(enum ipa_client_type client,
  2645. struct gsi_chan_info *ch_info);
  2646. int ipa3_uc_interface_init(void);
  2647. int ipa3_uc_is_gsi_channel_empty(enum ipa_client_type ipa_client);
  2648. int ipa3_uc_state_check(void);
  2649. int ipa3_uc_loaded_check(void);
  2650. int ipa3_uc_register_ready_cb(struct notifier_block *nb);
  2651. int ipa3_uc_unregister_ready_cb(struct notifier_block *nb);
  2652. int ipa3_uc_send_cmd(u32 cmd, u32 opcode, u32 expected_status,
  2653. bool polling_mode, unsigned long timeout_jiffies);
  2654. void ipa3_uc_register_handlers(enum ipa3_hw_features feature,
  2655. struct ipa3_uc_hdlrs *hdlrs);
  2656. int ipa3_uc_notify_clk_state(bool enabled);
  2657. int ipa3_dma_setup(void);
  2658. void ipa3_dma_shutdown(void);
  2659. void ipa3_dma_async_memcpy_notify_cb(void *priv,
  2660. enum ipa_dp_evt_type evt, unsigned long data);
  2661. int ipa3_uc_update_hw_flags(u32 flags);
  2662. int ipa3_uc_mhi_init(void (*ready_cb)(void), void (*wakeup_request_cb)(void));
  2663. void ipa3_uc_mhi_cleanup(void);
  2664. int ipa3_uc_mhi_send_dl_ul_sync_info(union IpaHwMhiDlUlSyncCmdData_t *cmd);
  2665. int ipa3_uc_mhi_init_engine(struct ipa_mhi_msi_info *msi, u32 mmio_addr,
  2666. u32 host_ctrl_addr, u32 host_data_addr, u32 first_ch_idx,
  2667. u32 first_evt_idx);
  2668. int ipa3_uc_mhi_init_channel(int ipa_ep_idx, int channelHandle,
  2669. int contexArrayIndex, int channelDirection);
  2670. int ipa3_uc_mhi_reset_channel(int channelHandle);
  2671. int ipa3_uc_mhi_suspend_channel(int channelHandle);
  2672. int ipa3_uc_mhi_resume_channel(int channelHandle, bool LPTransitionRejected);
  2673. int ipa3_uc_mhi_stop_event_update_channel(int channelHandle);
  2674. int ipa3_uc_mhi_print_stats(char *dbg_buff, int size);
  2675. int ipa3_uc_memcpy(phys_addr_t dest, phys_addr_t src, int len);
  2676. int ipa3_uc_send_remote_ipa_info(u32 remote_addr, uint32_t mbox_n);
  2677. int ipa3_uc_debug_stats_alloc(
  2678. struct IpaHwOffloadStatsAllocCmdData_t cmdinfo);
  2679. int ipa3_uc_debug_stats_dealloc(uint32_t protocol);
  2680. int ipa3_uc_quota_monitor(uint64_t quota);
  2681. int ipa3_uc_bw_monitor(struct ipa_wdi_bw_info *info);
  2682. int ipa3_uc_setup_event_ring(void);
  2683. int ipa3_set_wlan_tx_info(struct ipa_wdi_tx_info *info);
  2684. int ipa3_uc_debug_stats_dealloc(uint32_t prot_id);
  2685. void ipa3_tag_destroy_imm(void *user1, int user2);
  2686. const struct ipa_gsi_ep_config *ipa3_get_gsi_ep_info
  2687. (enum ipa_client_type client);
  2688. int ipa3_wigig_init_i(void);
  2689. int ipa3_wigig_internal_init(
  2690. struct ipa_wdi_uc_ready_params *inout,
  2691. ipa_wigig_misc_int_cb int_notify,
  2692. phys_addr_t *uc_db_pa);
  2693. /* Hardware stats */
  2694. #define IPA_STATS_MAX_PIPE_BIT 32
  2695. struct ipa_teth_stats_endpoints {
  2696. u32 prod_mask;
  2697. u32 dst_ep_mask[IPA_STATS_MAX_PIPE_BIT];
  2698. };
  2699. int ipa_hw_stats_init(void);
  2700. int ipa_init_flt_rt_stats(void);
  2701. int ipa_debugfs_init_stats(struct dentry *parent);
  2702. int ipa_init_quota_stats(u32 pipe_bitmask);
  2703. int ipa_get_quota_stats(struct ipa_quota_stats_all *out);
  2704. int ipa_reset_quota_stats(enum ipa_client_type client);
  2705. int ipa_reset_all_quota_stats(void);
  2706. int ipa_init_drop_stats(u32 pipe_bitmask);
  2707. int ipa_get_drop_stats(struct ipa_drop_stats_all *out);
  2708. int ipa_reset_drop_stats(enum ipa_client_type client);
  2709. int ipa_reset_all_drop_stats(void);
  2710. int ipa_init_teth_stats(struct ipa_teth_stats_endpoints *in);
  2711. int ipa_get_teth_stats(void);
  2712. int ipa_query_teth_stats(enum ipa_client_type prod,
  2713. struct ipa_quota_stats_all *out, bool reset);
  2714. int ipa_reset_teth_stats(enum ipa_client_type prod, enum ipa_client_type cons);
  2715. int ipa_reset_all_cons_teth_stats(enum ipa_client_type prod);
  2716. int ipa_reset_all_teth_stats(void);
  2717. int ipa_get_flt_rt_stats(struct ipa_ioc_flt_rt_query *query);
  2718. int ipa_set_flt_rt_stats(int index, struct ipa_flt_rt_stats stats);
  2719. bool ipa_get_fnr_info(struct ipacm_fnr_info *fnr_info);
  2720. u32 ipa3_get_num_pipes(void);
  2721. struct ipa_smmu_cb_ctx *ipa3_get_smmu_ctx(enum ipa_smmu_cb_type);
  2722. struct iommu_domain *ipa3_get_smmu_domain(void);
  2723. struct iommu_domain *ipa3_get_uc_smmu_domain(void);
  2724. struct iommu_domain *ipa3_get_wlan_smmu_domain(void);
  2725. struct iommu_domain *ipa3_get_smmu_domain_by_type
  2726. (enum ipa_smmu_cb_type cb_type);
  2727. int ipa3_iommu_map(struct iommu_domain *domain, unsigned long iova,
  2728. phys_addr_t paddr, size_t size, int prot);
  2729. int ipa3_ap_suspend(struct device *dev);
  2730. int ipa3_ap_resume(struct device *dev);
  2731. int ipa3_init_interrupts(void);
  2732. struct iommu_domain *ipa3_get_smmu_domain(void);
  2733. int ipa3_release_wdi_mapping(u32 num_buffers, struct ipa_wdi_buffer_info *info);
  2734. int ipa3_create_wdi_mapping(u32 num_buffers, struct ipa_wdi_buffer_info *info);
  2735. int ipa3_set_flt_tuple_mask(int pipe_idx, struct ipahal_reg_hash_tuple *tuple);
  2736. int ipa3_set_rt_tuple_mask(int tbl_idx, struct ipahal_reg_hash_tuple *tuple);
  2737. void ipa3_set_resorce_groups_min_max_limits(void);
  2738. int ipa3_suspend_apps_pipes(bool suspend);
  2739. void ipa3_force_close_coal(void);
  2740. int ipa3_flt_read_tbl_from_hw(u32 pipe_idx,
  2741. enum ipa_ip_type ip_type,
  2742. bool hashable,
  2743. struct ipahal_flt_rule_entry entry[],
  2744. int *num_entry);
  2745. int ipa3_rt_read_tbl_from_hw(u32 tbl_idx,
  2746. enum ipa_ip_type ip_type,
  2747. bool hashable,
  2748. struct ipahal_rt_rule_entry entry[],
  2749. int *num_entry);
  2750. int ipa3_restore_suspend_handler(void);
  2751. int ipa3_inject_dma_task_for_gsi(void);
  2752. int ipa3_uc_panic_notifier(struct notifier_block *this,
  2753. unsigned long event, void *ptr);
  2754. void ipa3_inc_acquire_wakelock(void);
  2755. void ipa3_dec_release_wakelock(void);
  2756. int ipa3_load_fws(const struct firmware *firmware, phys_addr_t gsi_mem_base,
  2757. enum gsi_ver);
  2758. int emulator_load_fws(
  2759. const struct firmware *firmware,
  2760. u32 transport_mem_base,
  2761. u32 transport_mem_size,
  2762. enum gsi_ver);
  2763. int ipa3_register_ipa_ready_cb(void (*ipa_ready_cb)(void *), void *user_data);
  2764. const char *ipa_hw_error_str(enum ipa3_hw_errors err_type);
  2765. int ipa_gsi_ch20_wa(void);
  2766. int ipa3_rx_poll(u32 clnt_hdl, int budget);
  2767. int ipa3_lan_rx_poll(u32 clnt_hdl, int weight);
  2768. int ipa3_smmu_map_peer_reg(phys_addr_t phys_addr, bool map,
  2769. enum ipa_smmu_cb_type cb_type);
  2770. int ipa3_smmu_map_peer_buff(u64 iova, u32 size, bool map, struct sg_table *sgt,
  2771. enum ipa_smmu_cb_type cb_type);
  2772. void ipa3_reset_freeze_vote(void);
  2773. int ipa3_ntn_init(void);
  2774. int ipa3_get_ntn_stats(struct Ipa3HwStatsNTNInfoData_t *stats);
  2775. struct dentry *ipa_debugfs_get_root(void);
  2776. struct device *ipa3_get_pdev(void);
  2777. void ipa3_enable_dcd(void);
  2778. void ipa3_disable_prefetch(enum ipa_client_type client);
  2779. int ipa3_alloc_common_event_ring(void);
  2780. int ipa3_allocate_dma_task_for_gsi(void);
  2781. void ipa3_free_dma_task_for_gsi(void);
  2782. int ipa3_allocate_coal_close_frame(void);
  2783. void ipa3_free_coal_close_frame(void);
  2784. int ipa3_set_clock_plan_from_pm(int idx);
  2785. void __ipa_gsi_irq_rx_scedule_poll(struct ipa3_sys_context *sys);
  2786. int ipa3_tz_unlock_reg(struct ipa_tz_unlock_reg_info *reg_info, u16 num_regs);
  2787. void ipa3_init_imm_cmd_desc(struct ipa3_desc *desc,
  2788. struct ipahal_imm_cmd_pyld *cmd_pyld);
  2789. int ipa3_is_vlan_mode(enum ipa_vlan_ifaces iface, bool *res);
  2790. uint ipa3_get_emulation_type(void);
  2791. int ipa3_get_transport_info(
  2792. phys_addr_t *phys_addr_ptr,
  2793. unsigned long *size_ptr);
  2794. irq_handler_t ipa3_get_isr(void);
  2795. void ipa_pc_qmp_enable(void);
  2796. u32 ipa3_get_r_rev_version(void);
  2797. #if defined(CONFIG_IPA3_REGDUMP)
  2798. int ipa_reg_save_init(u32 value);
  2799. void ipa_save_registers(void);
  2800. void ipa_save_gsi_ver(void);
  2801. #else
  2802. static inline int ipa_reg_save_init(u32 value) { return 0; }
  2803. static inline void ipa_save_registers(void) {};
  2804. static inline void ipa_save_gsi_ver(void) {};
  2805. #endif
  2806. #ifdef CONFIG_IPA_ETH
  2807. int ipa_eth_init(void);
  2808. void ipa_eth_exit(void);
  2809. #else
  2810. static inline int ipa_eth_init(void) { return 0; }
  2811. static inline void ipa_eth_exit(void) { }
  2812. #endif // CONFIG_IPA_ETH
  2813. int ipa3_get_gsi_chan_info(struct gsi_chan_info *gsi_chan_info,
  2814. unsigned long chan_hdl);
  2815. #if IS_ENABLED(CONFIG_IPA3_MHI_PRIME_MANAGER)
  2816. int ipa_mpm_mhip_xdci_pipe_enable(enum ipa_usb_teth_prot prot);
  2817. int ipa_mpm_mhip_xdci_pipe_disable(enum ipa_usb_teth_prot xdci_teth_prot);
  2818. int ipa_mpm_notify_wan_state(struct wan_ioctl_notify_wan_state *state);
  2819. int ipa3_is_mhip_offload_enabled(void);
  2820. int ipa_mpm_reset_dma_mode(enum ipa_client_type src_pipe,
  2821. enum ipa_client_type dst_pipe);
  2822. int ipa_mpm_panic_handler(char *buf, int size);
  2823. int ipa3_mpm_enable_adpl_over_odl(bool enable);
  2824. int ipa3_get_mhip_gsi_stats(struct ipa_uc_dbg_ring_stats *stats);
  2825. #else /* IS_ENABLED(CONFIG_IPA3_MHI_PRIME_MANAGER) */
  2826. static inline int ipa_mpm_mhip_xdci_pipe_enable(
  2827. enum ipa_usb_teth_prot prot)
  2828. {
  2829. return 0;
  2830. }
  2831. static inline int ipa_mpm_mhip_xdci_pipe_disable(
  2832. enum ipa_usb_teth_prot xdci_teth_prot)
  2833. {
  2834. return 0;
  2835. }
  2836. static inline int ipa_mpm_notify_wan_state(
  2837. struct wan_ioctl_notify_wan_state *state)
  2838. {
  2839. return 0;
  2840. }
  2841. static inline int ipa3_is_mhip_offload_enabled(void)
  2842. {
  2843. return 0;
  2844. }
  2845. static inline int ipa_mpm_reset_dma_mode(enum ipa_client_type src_pipe,
  2846. enum ipa_client_type dst_pipe)
  2847. {
  2848. return 0;
  2849. }
  2850. static inline int ipa_mpm_panic_handler(char *buf, int size)
  2851. {
  2852. return 0;
  2853. }
  2854. static inline int ipa3_get_mhip_gsi_stats(struct ipa_uc_dbg_ring_stats *stats)
  2855. {
  2856. return 0;
  2857. }
  2858. static inline int ipa3_mpm_enable_adpl_over_odl(bool enable)
  2859. {
  2860. return 0;
  2861. }
  2862. #endif /* IS_ENABLED(CONFIG_IPA3_MHI_PRIME_MANAGER) */
  2863. static inline void *alloc_and_init(u32 size, u32 init_val)
  2864. {
  2865. void *ptr = kmalloc(size, GFP_KERNEL);
  2866. if (ptr)
  2867. memset(ptr, init_val, size);
  2868. return ptr;
  2869. }
  2870. /* query ipa APQ mode*/
  2871. bool ipa3_is_apq(void);
  2872. /* check if odl is connected */
  2873. bool ipa3_is_odl_connected(void);
  2874. int ipa3_uc_send_enable_flow_control(uint16_t gsi_chid,
  2875. uint16_t redMarkerThreshold);
  2876. int ipa3_uc_send_disable_flow_control(void);
  2877. int ipa3_uc_send_update_flow_control(uint32_t bitmask,
  2878. uint8_t add_delete);
  2879. #endif /* _IPA3_I_H_ */