ipa_i.h 91 KB

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