ipa.h 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _IPA_H_
  6. #define _IPA_H_
  7. #include <linux/msm_ipa.h>
  8. #include <linux/skbuff.h>
  9. #include <linux/types.h>
  10. #include <linux/if_ether.h>
  11. #include <linux/ipa_qmi_service_v01.h>
  12. #include "msm_gsi.h"
  13. #define IPA_APPS_MAX_BW_IN_MBPS 700
  14. #define IPA_BW_THRESHOLD_MAX 3
  15. #define IPA_MAX_CH_STATS_SUPPORTED 5
  16. /**
  17. * enum ipa_transport_type
  18. * transport type: either GSI or SPS
  19. */
  20. enum ipa_transport_type {
  21. IPA_TRANSPORT_TYPE_SPS,
  22. IPA_TRANSPORT_TYPE_GSI
  23. };
  24. /**
  25. * enum ipa_nat_en_type - NAT setting type in IPA end-point
  26. */
  27. enum ipa_nat_en_type {
  28. IPA_BYPASS_NAT,
  29. IPA_SRC_NAT,
  30. IPA_DST_NAT,
  31. };
  32. /**
  33. * enum ipa_ipv6ct_en_type - IPv6CT setting type in IPA end-point
  34. */
  35. enum ipa_ipv6ct_en_type {
  36. IPA_BYPASS_IPV6CT,
  37. IPA_ENABLE_IPV6CT,
  38. };
  39. /**
  40. * enum ipa_mode_type - mode setting type in IPA end-point
  41. * @BASIC: basic mode
  42. * @ENABLE_FRAMING_HDLC: not currently supported
  43. * @ENABLE_DEFRAMING_HDLC: not currently supported
  44. * @DMA: all data arriving IPA will not go through IPA logic blocks, this
  45. * allows IPA to work as DMA for specific pipes.
  46. */
  47. enum ipa_mode_type {
  48. IPA_BASIC,
  49. IPA_ENABLE_FRAMING_HDLC,
  50. IPA_ENABLE_DEFRAMING_HDLC,
  51. IPA_DMA,
  52. };
  53. /**
  54. * enum ipa_aggr_en_type - aggregation setting type in IPA
  55. * end-point
  56. */
  57. enum ipa_aggr_en_type {
  58. IPA_BYPASS_AGGR,
  59. IPA_ENABLE_AGGR,
  60. IPA_ENABLE_DEAGGR,
  61. };
  62. /**
  63. * enum ipa_aggr_type - type of aggregation in IPA end-point
  64. */
  65. enum ipa_aggr_type {
  66. IPA_MBIM_16 = 0,
  67. IPA_HDLC = 1,
  68. IPA_TLP = 2,
  69. IPA_RNDIS = 3,
  70. IPA_GENERIC = 4,
  71. IPA_COALESCE = 5,
  72. IPA_QCMAP = 6,
  73. };
  74. /**
  75. * enum ipa_aggr_mode - global aggregation mode
  76. */
  77. enum ipa_aggr_mode {
  78. IPA_MBIM_AGGR,
  79. IPA_QCNCM_AGGR,
  80. };
  81. /**
  82. * enum ipa_dp_evt_type - type of event client callback is
  83. * invoked for on data path
  84. * @IPA_RECEIVE: data is struct sk_buff
  85. * @IPA_WRITE_DONE: data is struct sk_buff
  86. */
  87. enum ipa_dp_evt_type {
  88. IPA_RECEIVE,
  89. IPA_WRITE_DONE,
  90. };
  91. /**
  92. * enum hdr_total_len_or_pad_type - type of value held by TOTAL_LEN_OR_PAD
  93. * field in header configuration register.
  94. * @IPA_HDR_PAD: field is used as padding length
  95. * @IPA_HDR_TOTAL_LEN: field is used as total length
  96. */
  97. enum hdr_total_len_or_pad_type {
  98. IPA_HDR_PAD = 0,
  99. IPA_HDR_TOTAL_LEN = 1,
  100. };
  101. /**
  102. * struct ipa_ep_cfg_nat - NAT configuration in IPA end-point
  103. * @nat_en: This defines the default NAT mode for the pipe: in case of
  104. * filter miss - the default NAT mode defines the NATing operation
  105. * on the packet. Valid for Input Pipes only (IPA consumer)
  106. */
  107. struct ipa_ep_cfg_nat {
  108. enum ipa_nat_en_type nat_en;
  109. };
  110. /**
  111. * struct ipa_ep_cfg_conn_track - IPv6 Connection tracking configuration in
  112. * IPA end-point
  113. * @conn_track_en: Defines speculative conn_track action, means if specific
  114. * pipe needs to have UL/DL IPv6 Connection Tracking or Bypass
  115. * IPv6 Connection Tracking. 0: Bypass IPv6 Connection Tracking
  116. * 1: IPv6 UL/DL Connection Tracking.
  117. * Valid for Input Pipes only (IPA consumer)
  118. */
  119. struct ipa_ep_cfg_conn_track {
  120. enum ipa_ipv6ct_en_type conn_track_en;
  121. };
  122. /**
  123. * struct ipa_ep_cfg_hdr - header configuration in IPA end-point
  124. *
  125. * @hdr_len:Header length in bytes to be added/removed. Assuming
  126. * header len is constant per endpoint. Valid for
  127. * both Input and Output Pipes
  128. * @hdr_ofst_metadata_valid: 0: Metadata_Ofst value is invalid, i.e., no
  129. * metadata within header.
  130. * 1: Metadata_Ofst value is valid, i.e., metadata
  131. * within header is in offset Metadata_Ofst Valid
  132. * for Input Pipes only (IPA Consumer) (for output
  133. * pipes, metadata already set within the header)
  134. * @hdr_ofst_metadata: Offset within header in which metadata resides
  135. * Size of metadata - 4bytes
  136. * Example - Stream ID/SSID/mux ID.
  137. * Valid for Input Pipes only (IPA Consumer) (for output
  138. * pipes, metadata already set within the header)
  139. * @hdr_additional_const_len: Defines the constant length that should be added
  140. * to the payload length in order for IPA to update
  141. * correctly the length field within the header
  142. * (valid only in case Hdr_Ofst_Pkt_Size_Valid=1)
  143. * Valid for Output Pipes (IPA Producer)
  144. * Starting IPA4.5, this field in H/W requires more bits
  145. * to support larger range, but no spare bits to use.
  146. * So the MSB part is done thourgh the EXT register.
  147. * When accessing this register, need to access the EXT
  148. * register as well.
  149. * @hdr_ofst_pkt_size_valid: 0: Hdr_Ofst_Pkt_Size value is invalid, i.e., no
  150. * length field within the inserted header
  151. * 1: Hdr_Ofst_Pkt_Size value is valid, i.e., a
  152. * packet length field resides within the header
  153. * Valid for Output Pipes (IPA Producer)
  154. * @hdr_ofst_pkt_size: Offset within header in which packet size reside. Upon
  155. * Header Insertion, IPA will update this field within the
  156. * header with the packet length . Assumption is that
  157. * header length field size is constant and is 2Bytes
  158. * Valid for Output Pipes (IPA Producer)
  159. * Starting IPA4.5, this field in H/W requires more bits
  160. * to support larger range, but no spare bits to use.
  161. * So the MSB part is done thourgh the EXT register.
  162. * When accessing this register, need to access the EXT
  163. * register as well.
  164. * @hdr_a5_mux: Determines whether A5 Mux header should be added to the packet.
  165. * This bit is valid only when Hdr_En=01(Header Insertion)
  166. * SW should set this bit for IPA-to-A5 pipes.
  167. * 0: Do not insert A5 Mux Header
  168. * 1: Insert A5 Mux Header
  169. * Valid for Output Pipes (IPA Producer)
  170. * @hdr_remove_additional: bool switch, remove more of the header
  171. * based on the aggregation configuration (register
  172. * HDR_LEN_INC_DEAGG_HDR)
  173. * @hdr_metadata_reg_valid: bool switch, metadata from
  174. * register INIT_HDR_METADATA_n is valid.
  175. * (relevant only for IPA Consumer pipes)
  176. * Starting IPA4.5, this parameter is irrelevant and H/W
  177. * assumes it is always valid.
  178. */
  179. struct ipa_ep_cfg_hdr {
  180. u32 hdr_len;
  181. u32 hdr_ofst_metadata_valid;
  182. u32 hdr_ofst_metadata;
  183. u32 hdr_additional_const_len;
  184. u32 hdr_ofst_pkt_size_valid;
  185. u32 hdr_ofst_pkt_size;
  186. u32 hdr_a5_mux;
  187. u32 hdr_remove_additional;
  188. u32 hdr_metadata_reg_valid;
  189. };
  190. /**
  191. * struct ipa_ep_cfg_hdr_ext - extended header configuration in IPA end-point
  192. * @hdr_pad_to_alignment: Pad packet to specified alignment
  193. * (2^pad to alignment value), i.e. value of 3 means pad to 2^3 = 8 bytes
  194. * alignment. Alignment is to 0,2 up to 32 bytes (IPAv2 does not support 64
  195. * byte alignment). Valid for Output Pipes only (IPA Producer).
  196. * @hdr_total_len_or_pad_offset: Offset to length field containing either
  197. * total length or pad length, per hdr_total_len_or_pad config
  198. * @hdr_payload_len_inc_padding: 0-IPA_ENDP_INIT_HDR_n's
  199. * HDR_OFST_PKT_SIZE does
  200. * not includes padding bytes size, payload_len = packet length,
  201. * 1-IPA_ENDP_INIT_HDR_n's HDR_OFST_PKT_SIZE includes
  202. * padding bytes size, payload_len = packet length + padding
  203. * @hdr_total_len_or_pad: field is used as PAD length ot as Total length
  204. * (header + packet + padding)
  205. * @hdr_total_len_or_pad_valid: 0-Ignore TOTAL_LEN_OR_PAD field, 1-Process
  206. * TOTAL_LEN_OR_PAD field
  207. * @hdr_little_endian: 0-Big Endian, 1-Little Endian
  208. * @hdr: The header structure. Used starting IPA4.5 where part of the info
  209. * at the header structure is implemented via the EXT register at the H/W
  210. */
  211. struct ipa_ep_cfg_hdr_ext {
  212. u32 hdr_pad_to_alignment;
  213. u32 hdr_total_len_or_pad_offset;
  214. bool hdr_payload_len_inc_padding;
  215. enum hdr_total_len_or_pad_type hdr_total_len_or_pad;
  216. bool hdr_total_len_or_pad_valid;
  217. bool hdr_little_endian;
  218. struct ipa_ep_cfg_hdr *hdr;
  219. };
  220. /**
  221. * struct ipa_ep_cfg_mode - mode configuration in IPA end-point
  222. * @mode: Valid for Input Pipes only (IPA Consumer)
  223. * @dst: This parameter specifies the output pipe to which the packets
  224. * will be routed to.
  225. * This parameter is valid for Mode=DMA and not valid for
  226. * Mode=Basic
  227. * Valid for Input Pipes only (IPA Consumer)
  228. */
  229. struct ipa_ep_cfg_mode {
  230. enum ipa_mode_type mode;
  231. enum ipa_client_type dst;
  232. };
  233. /**
  234. * struct ipa_ep_cfg_aggr - aggregation configuration in IPA end-point
  235. *
  236. * @aggr_en: Valid for both Input and Output Pipes
  237. * @aggr: aggregation type (Valid for both Input and Output Pipes)
  238. * @aggr_byte_limit: Limit of aggregated packet size in KB (<=32KB) When set
  239. * to 0, there is no size limitation on the aggregation.
  240. * When both, Aggr_Byte_Limit and Aggr_Time_Limit are set
  241. * to 0, there is no aggregation, every packet is sent
  242. * independently according to the aggregation structure
  243. * Valid for Output Pipes only (IPA Producer )
  244. * @aggr_time_limit: Timer to close aggregated packet When set to 0,
  245. * there is no time limitation on the aggregation. When
  246. * both, Aggr_Byte_Limit and Aggr_Time_Limit are set to 0,
  247. * there is no aggregation, every packet is sent
  248. * independently according to the aggregation structure
  249. * Valid for Output Pipes only (IPA Producer).
  250. * Time unit is -->> usec <<--
  251. * @aggr_pkt_limit: Defines if EOF close aggregation or not. if set to false
  252. * HW closes aggregation (sends EOT) only based on its
  253. * aggregation config (byte/time limit, etc). if set to
  254. * true EOF closes aggregation in addition to HW based
  255. * aggregation closure. Valid for Output Pipes only (IPA
  256. * Producer). EOF affects only Pipes configured for
  257. * generic aggregation.
  258. * @aggr_hard_byte_limit_en: If set to 1, byte-limit aggregation for this
  259. * pipe will apply a hard-limit behavior which will not
  260. * allow frames to be closed with more than byte-limit
  261. * bytes. If set to 0, previous byte-limit behavior
  262. * will apply - frames close once a packet causes the
  263. * accumulated byte-count to cross the byte-limit
  264. * threshold (closed frame will contain that packet).
  265. * @aggr_sw_eof_active: 0: EOF does not close aggregation. HW closes aggregation
  266. * (sends EOT) only based on its aggregation config
  267. * (byte/time limit, etc).
  268. * 1: EOF closes aggregation in addition to HW based
  269. * aggregation closure. Valid for Output Pipes only (IPA
  270. * Producer). EOF affects only Pipes configured for generic
  271. * aggregation.
  272. * @pulse_generator: Pulse generator number to be used.
  273. * For internal use.
  274. * Supported starting IPA4.5.
  275. * @scaled_time: Time limit in accordance to the pulse generator
  276. * granularity.
  277. * For internal use
  278. * Supported starting IPA4.5
  279. */
  280. struct ipa_ep_cfg_aggr {
  281. enum ipa_aggr_en_type aggr_en;
  282. enum ipa_aggr_type aggr;
  283. u32 aggr_byte_limit;
  284. u32 aggr_time_limit;
  285. u32 aggr_pkt_limit;
  286. u32 aggr_hard_byte_limit_en;
  287. bool aggr_sw_eof_active;
  288. u8 pulse_generator;
  289. u8 scaled_time;
  290. };
  291. /**
  292. * struct ipa_ep_cfg_route - route configuration in IPA end-point
  293. * @rt_tbl_hdl: Defines the default routing table index to be used in case there
  294. * is no filter rule matching, valid for Input Pipes only (IPA
  295. * Consumer). Clients should set this to 0 which will cause default
  296. * v4 and v6 routes setup internally by IPA driver to be used for
  297. * this end-point
  298. */
  299. struct ipa_ep_cfg_route {
  300. u32 rt_tbl_hdl;
  301. };
  302. /**
  303. * struct ipa_ep_cfg_holb - head of line blocking configuration in IPA end-point
  304. * @en: enable(1 => ok to drop pkt)/disable(0 => never drop pkt)
  305. * @tmr_val: duration in units of 128 IPA clk clock cyles [0,511], 1 clk=1.28us
  306. * IPAv2.5 support 32 bit HOLB timeout value, previous versions
  307. * supports 16 bit
  308. * IPAv4.2: splitting timer value into 2 fields. Timer value is:
  309. * BASE_VALUE * (2^SCALE)
  310. * IPA4.5: tmr_val is in -->>msec<<--. Range is dynamic based
  311. * on H/W configuration. (IPA4.5 absolute maximum is 0.65535*31 -> ~20sec).
  312. * @base_val : IPA4.2 only field. base value of the timer.
  313. * @scale : IPA4.2 only field. scale value for timer.
  314. * @pulse_generator: Pulse generator number to be used.
  315. * For internal use.
  316. * Supported starting IPA4.5.
  317. * @scaled_time: Time limit in accordance to the pulse generator granularity
  318. * For internal use
  319. * Supported starting IPA4.5
  320. */
  321. struct ipa_ep_cfg_holb {
  322. u32 tmr_val;
  323. u32 base_val;
  324. u32 scale;
  325. u16 en;
  326. u8 pulse_generator;
  327. u8 scaled_time;
  328. };
  329. /**
  330. * struct ipa_ep_cfg_deaggr - deaggregation configuration in IPA end-point
  331. * @deaggr_hdr_len: Deaggregation Header length in bytes. Valid only for Input
  332. * Pipes, which are configured for 'Generic' deaggregation.
  333. * @syspipe_err_detection - If set to 1, enables error detection for
  334. * de-aggregration. Valid only for Input Pipes, which are configured
  335. * for 'Generic' deaggregation.
  336. * Note: if this bit is set, de-aggregated frames must be contiguous
  337. * in memory.
  338. * @packet_offset_valid: - 0: PACKET_OFFSET is not used, 1: PACKET_OFFSET is
  339. * used.
  340. * @packet_offset_location: Location of packet offset field, which specifies
  341. * the offset to the packet from the start of the packet offset field.
  342. * @ignore_min_pkt_err - Ignore packets smaller than header. This is intended
  343. * for use in RNDIS de-aggregated pipes, to silently ignore a redundant
  344. * 1-byte trailer in MSFT implementation.
  345. * @max_packet_len: DEAGGR Max Packet Length in Bytes. A Packet with higher
  346. * size wil be treated as an error. 0 - Packet Length is not Bound,
  347. * IPA should not check for a Max Packet Length.
  348. */
  349. struct ipa_ep_cfg_deaggr {
  350. u32 deaggr_hdr_len;
  351. bool syspipe_err_detection;
  352. bool packet_offset_valid;
  353. u32 packet_offset_location;
  354. bool ignore_min_pkt_err;
  355. u32 max_packet_len;
  356. };
  357. /**
  358. * enum ipa_cs_offload - checksum offload setting
  359. */
  360. enum ipa_cs_offload {
  361. IPA_DISABLE_CS_OFFLOAD,
  362. /*
  363. * For enum value = 1, we check the csum required/valid bit which is the
  364. * same bit used for both DL and UL but have different meanings.
  365. * For UL pipe, HW checks if it needs to perform Csum caluclation.
  366. * For DL pipe, HW checks if the csum is valid or invalid
  367. */
  368. IPA_ENABLE_CS_OFFLOAD_UL,
  369. IPA_ENABLE_CS_DL_QMAP = IPA_ENABLE_CS_OFFLOAD_UL,
  370. IPA_ENABLE_CS_OFFLOAD_DL,
  371. IPA_CS_RSVD
  372. };
  373. /**
  374. * struct ipa_ep_cfg_cfg - IPA ENDP_INIT Configuration register
  375. * @frag_offload_en: - 0 - IP packet fragment handling is disabled. IP packet
  376. * fragments should be sent to SW. SW is responsible for
  377. * configuring filter rules, and IP packet filter exception should be
  378. * used to send all fragments to SW. 1 - IP packet fragment
  379. * handling is enabled. IPA checks for fragments and uses frag
  380. * rules table for processing fragments. Valid only for Input Pipes
  381. * (IPA Consumer)
  382. * @cs_offload_en: Checksum offload enable: 00: Disable checksum offload, 01:
  383. * Enable checksum calculation offload (UL) - For output pipe
  384. * (IPA producer) specifies that checksum trailer is to be added.
  385. * For input pipe (IPA consumer) specifies presence of checksum
  386. * header and IPA checksum calculation accordingly. 10: Enable
  387. * checksum calculation offload (DL) - For output pipe (IPA
  388. * producer) specifies that checksum trailer is to be added. For
  389. * input pipe (IPA consumer) specifies IPA checksum calculation.
  390. * 11: Reserved
  391. * @cs_metadata_hdr_offset: Offset in Words (4 bytes) within header in which
  392. * checksum meta info header (4 bytes) starts (UL). Values are 0-15, which
  393. * mean 0 - 60 byte checksum header offset. Valid for input
  394. * pipes only (IPA consumer)
  395. * @gen_qmb_master_sel: Select bit for ENDP GEN-QMB master. This is used to
  396. * separate DDR & PCIe transactions in-order to limit them as
  397. * a group (using MAX_WRITES/READS limiation). Valid for input and
  398. * output pipes (IPA consumer+producer)
  399. */
  400. struct ipa_ep_cfg_cfg {
  401. bool frag_offload_en;
  402. enum ipa_cs_offload cs_offload_en;
  403. u8 cs_metadata_hdr_offset;
  404. u8 gen_qmb_master_sel;
  405. };
  406. /**
  407. * struct ipa_ep_cfg_metadata_mask - Endpoint initialization hdr metadata mask
  408. * @metadata_mask: Mask specifying which metadata bits to write to
  409. * IPA_ENDP_INIT_HDR_n.s HDR_OFST_METADATA. Only
  410. * masked metadata bits (set to 1) will be written. Valid for Output
  411. * Pipes only (IPA Producer)
  412. */
  413. struct ipa_ep_cfg_metadata_mask {
  414. u32 metadata_mask;
  415. };
  416. /**
  417. * struct ipa_ep_cfg_metadata - Meta Data configuration in IPA end-point
  418. * @md: This defines the meta data from tx data descriptor
  419. * @qmap_id: qmap id
  420. */
  421. struct ipa_ep_cfg_metadata {
  422. u32 qmap_id;
  423. };
  424. /**
  425. * struct ipa_ep_cfg_seq - HPS/DPS sequencer type configuration in IPA end-point
  426. * @set_dynamic: 0 - HPS/DPS seq type is configured statically,
  427. * 1 - HPS/DPS seq type is set to seq_type
  428. * @seq_type: HPS/DPS sequencer type configuration
  429. */
  430. struct ipa_ep_cfg_seq {
  431. bool set_dynamic;
  432. int seq_type;
  433. };
  434. /**
  435. * struct ipa_ep_cfg - configuration of IPA end-point
  436. * @nat: NAT parameters
  437. * @conn_track: IPv6CT parameters
  438. * @hdr: Header parameters
  439. * @hdr_ext: Extended header parameters
  440. * @mode: Mode parameters
  441. * @aggr: Aggregation parameters
  442. * @deaggr: Deaggregation params
  443. * @route: Routing parameters
  444. * @cfg: Configuration register data
  445. * @metadata_mask: Hdr metadata mask
  446. * @meta: Meta Data
  447. * @seq: HPS/DPS sequencers configuration
  448. */
  449. struct ipa_ep_cfg {
  450. struct ipa_ep_cfg_nat nat;
  451. struct ipa_ep_cfg_conn_track conn_track;
  452. struct ipa_ep_cfg_hdr hdr;
  453. struct ipa_ep_cfg_hdr_ext hdr_ext;
  454. struct ipa_ep_cfg_mode mode;
  455. struct ipa_ep_cfg_aggr aggr;
  456. struct ipa_ep_cfg_deaggr deaggr;
  457. struct ipa_ep_cfg_route route;
  458. struct ipa_ep_cfg_cfg cfg;
  459. struct ipa_ep_cfg_metadata_mask metadata_mask;
  460. struct ipa_ep_cfg_metadata meta;
  461. struct ipa_ep_cfg_seq seq;
  462. };
  463. /**
  464. * struct ipa_ep_cfg_ctrl - Control configuration in IPA end-point
  465. * @ipa_ep_suspend: 0 - ENDP is enabled, 1 - ENDP is suspended (disabled).
  466. * Valid for PROD Endpoints
  467. * @ipa_ep_delay: 0 - ENDP is free-running, 1 - ENDP is delayed.
  468. * SW controls the data flow of an endpoint usind this bit.
  469. * Valid for CONS Endpoints
  470. */
  471. struct ipa_ep_cfg_ctrl {
  472. bool ipa_ep_suspend;
  473. bool ipa_ep_delay;
  474. };
  475. /**
  476. * x should be in bytes
  477. */
  478. #define IPA_NUM_OF_FIFO_DESC(x) (x/sizeof(struct sps_iovec))
  479. typedef void (*ipa_notify_cb)(void *priv, enum ipa_dp_evt_type evt,
  480. unsigned long data);
  481. /**
  482. * enum ipa_wdi_meter_evt_type - type of event client callback is
  483. * for AP+STA mode metering
  484. * @IPA_GET_WDI_SAP_STATS: get IPA_stats betwen SAP and STA -
  485. * use ipa_get_wdi_sap_stats structure
  486. * @IPA_SET_WIFI_QUOTA: set quota limit on STA -
  487. * use ipa_set_wifi_quota structure
  488. * @IPA_SET_WLAN_BW: set wlan BW -
  489. * use ipa_set_wlan_bw structure
  490. */
  491. enum ipa_wdi_meter_evt_type {
  492. IPA_GET_WDI_SAP_STATS,
  493. IPA_SET_WIFI_QUOTA,
  494. IPA_INFORM_WLAN_BW,
  495. };
  496. struct ipa_get_wdi_sap_stats {
  497. /* indicate to reset stats after query */
  498. uint8_t reset_stats;
  499. /* indicate valid stats from wlan-fw */
  500. uint8_t stats_valid;
  501. /* Tx: SAP->STA */
  502. uint64_t ipv4_tx_packets;
  503. uint64_t ipv4_tx_bytes;
  504. /* Rx: STA->SAP */
  505. uint64_t ipv4_rx_packets;
  506. uint64_t ipv4_rx_bytes;
  507. uint64_t ipv6_tx_packets;
  508. uint64_t ipv6_tx_bytes;
  509. uint64_t ipv6_rx_packets;
  510. uint64_t ipv6_rx_bytes;
  511. };
  512. /**
  513. * struct ipa_set_wifi_quota - structure used for
  514. * IPA_SET_WIFI_QUOTA.
  515. *
  516. * @quota_bytes: Quota (in bytes) for the STA interface.
  517. * @set_quota: Indicate whether to set the quota (use 1) or
  518. * unset the quota.
  519. *
  520. */
  521. struct ipa_set_wifi_quota {
  522. uint64_t quota_bytes;
  523. uint8_t set_quota;
  524. /* indicate valid quota set from wlan-fw */
  525. uint8_t set_valid;
  526. };
  527. /**
  528. * struct ipa_inform_wlan_bw - structure used for
  529. * IPA_INFORM_WLAN_BW.
  530. *
  531. * @index: Indicate which bw-index hit
  532. * @throughput: throughput usage
  533. *
  534. */
  535. struct ipa_inform_wlan_bw {
  536. uint8_t index;
  537. uint64_t throughput;
  538. };
  539. typedef void (*ipa_wdi_meter_notifier_cb)(enum ipa_wdi_meter_evt_type evt,
  540. void *data);
  541. /**
  542. * struct ipa_tx_intf - interface tx properties
  543. * @num_props: number of tx properties
  544. * @prop: the tx properties array
  545. */
  546. struct ipa_tx_intf {
  547. u32 num_props;
  548. struct ipa_ioc_tx_intf_prop *prop;
  549. };
  550. /**
  551. * struct ipa_rx_intf - interface rx properties
  552. * @num_props: number of rx properties
  553. * @prop: the rx properties array
  554. */
  555. struct ipa_rx_intf {
  556. u32 num_props;
  557. struct ipa_ioc_rx_intf_prop *prop;
  558. };
  559. /**
  560. * struct ipa_ext_intf - interface ext properties
  561. * @excp_pipe_valid: is next field valid?
  562. * @excp_pipe: exception packets should be routed to this pipe
  563. * @num_props: number of ext properties
  564. * @prop: the ext properties array
  565. */
  566. struct ipa_ext_intf {
  567. bool excp_pipe_valid;
  568. enum ipa_client_type excp_pipe;
  569. u32 num_props;
  570. struct ipa_ioc_ext_intf_prop *prop;
  571. };
  572. /**
  573. * struct ipa_sys_connect_params - information needed to setup an IPA end-point
  574. * in system-BAM mode
  575. * @ipa_ep_cfg: IPA EP configuration
  576. * @client: the type of client who "owns" the EP
  577. * @desc_fifo_sz: size of desc FIFO. This number is used to allocate the desc
  578. * fifo for BAM. For GSI, this size is used by IPA driver as a
  579. * baseline to calculate the GSI ring size in the following way:
  580. * For PROD pipes, GSI ring is 4 * desc_fifo_sz.
  581. For PROD pipes, GSI ring is 2 * desc_fifo_sz.
  582. * @priv: callback cookie
  583. * @notify: callback
  584. * priv - callback cookie
  585. * evt - type of event
  586. * data - data relevant to event. May not be valid. See event_type
  587. * enum for valid cases.
  588. * @skip_ep_cfg: boolean field that determines if EP should be configured
  589. * by IPA driver
  590. * @keep_ipa_awake: when true, IPA will not be clock gated
  591. * @napi_enabled: when true, IPA call client callback to start polling
  592. */
  593. struct ipa_sys_connect_params {
  594. struct ipa_ep_cfg ipa_ep_cfg;
  595. enum ipa_client_type client;
  596. u32 desc_fifo_sz;
  597. void *priv;
  598. ipa_notify_cb notify;
  599. bool skip_ep_cfg;
  600. bool keep_ipa_awake;
  601. struct napi_struct *napi_obj;
  602. bool recycle_enabled;
  603. };
  604. /**
  605. * struct ipa_tx_meta - meta-data for the TX packet
  606. * @dma_address: dma mapped address of TX packet
  607. * @dma_address_valid: is above field valid?
  608. */
  609. struct ipa_tx_meta {
  610. u8 pkt_init_dst_ep;
  611. bool pkt_init_dst_ep_valid;
  612. bool pkt_init_dst_ep_remote;
  613. dma_addr_t dma_address;
  614. bool dma_address_valid;
  615. };
  616. /**
  617. * typedef ipa_msg_free_fn - callback function
  618. * @param buff - [in] the message payload to free
  619. * @param len - [in] size of message payload
  620. * @param type - [in] the message type
  621. *
  622. * Message callback registered by kernel client with IPA driver to
  623. * free message payload after IPA driver processing is complete
  624. *
  625. * No return value
  626. */
  627. typedef void (*ipa_msg_free_fn)(void *buff, u32 len, u32 type);
  628. /**
  629. * typedef ipa_msg_pull_fn - callback function
  630. * @param buff - [in] where to copy message payload
  631. * @param len - [in] size of buffer to copy payload into
  632. * @param type - [in] the message type
  633. *
  634. * Message callback registered by kernel client with IPA driver for
  635. * IPA driver to pull messages from the kernel client upon demand from
  636. * user-space
  637. *
  638. * Returns how many bytes were copied into the buffer.
  639. */
  640. typedef int (*ipa_msg_pull_fn)(void *buff, u32 len, u32 type);
  641. /**
  642. * enum ipa_voltage_level - IPA Voltage levels
  643. */
  644. enum ipa_voltage_level {
  645. IPA_VOLTAGE_UNSPECIFIED,
  646. IPA_VOLTAGE_SVS2 = IPA_VOLTAGE_UNSPECIFIED,
  647. IPA_VOLTAGE_SVS,
  648. IPA_VOLTAGE_NOMINAL,
  649. IPA_VOLTAGE_TURBO,
  650. IPA_VOLTAGE_MAX,
  651. };
  652. /**
  653. * enum ipa_rm_event - IPA RM events
  654. *
  655. * Indicate the resource state change
  656. */
  657. enum ipa_rm_event {
  658. IPA_RM_RESOURCE_GRANTED,
  659. IPA_RM_RESOURCE_RELEASED
  660. };
  661. typedef void (*ipa_rm_notify_cb)(void *user_data,
  662. enum ipa_rm_event event,
  663. unsigned long data);
  664. /**
  665. * struct ipa_rm_register_params - information needed to
  666. * register IPA RM client with IPA RM
  667. *
  668. * @user_data: IPA RM client provided information
  669. * to be passed to notify_cb callback below
  670. * @notify_cb: callback which is called by resource
  671. * to notify the IPA RM client about its state
  672. * change IPA RM client is expected to perform non
  673. * blocking operations only in notify_cb and
  674. * release notification context as soon as
  675. * possible.
  676. */
  677. struct ipa_rm_register_params {
  678. void *user_data;
  679. ipa_rm_notify_cb notify_cb;
  680. };
  681. /**
  682. * struct ipa_rm_create_params - information needed to initialize
  683. * the resource
  684. * @name: resource name
  685. * @floor_voltage: floor voltage needed for client to operate in maximum
  686. * bandwidth.
  687. * @reg_params: register parameters, contains are ignored
  688. * for consumer resource NULL should be provided
  689. * for consumer resource
  690. * @request_resource: function which should be called to request resource,
  691. * NULL should be provided for producer resource
  692. * @release_resource: function which should be called to release resource,
  693. * NULL should be provided for producer resource
  694. *
  695. * IPA RM client is expected to perform non blocking operations only
  696. * in request_resource and release_resource functions and
  697. * release notification context as soon as possible.
  698. */
  699. struct ipa_rm_create_params {
  700. enum ipa_rm_resource_name name;
  701. enum ipa_voltage_level floor_voltage;
  702. struct ipa_rm_register_params reg_params;
  703. int (*request_resource)(void);
  704. int (*release_resource)(void);
  705. };
  706. /**
  707. * struct ipa_rm_perf_profile - information regarding IPA RM client performance
  708. * profile
  709. *
  710. * @max_bandwidth_mbps: maximum bandwidth need of the client in Mbps
  711. */
  712. struct ipa_rm_perf_profile {
  713. u32 max_supported_bandwidth_mbps;
  714. };
  715. #define A2_MUX_HDR_NAME_V4_PREF "dmux_hdr_v4_"
  716. #define A2_MUX_HDR_NAME_V6_PREF "dmux_hdr_v6_"
  717. /**
  718. * struct ipa_tx_data_desc - information needed
  719. * to send data packet to HW link: link to data descriptors
  720. * priv: client specific private data
  721. * @pyld_buffer: pointer to the data buffer that holds frame
  722. * @pyld_len: length of the data packet
  723. */
  724. struct ipa_tx_data_desc {
  725. struct list_head link;
  726. void *priv;
  727. void *pyld_buffer;
  728. u16 pyld_len;
  729. };
  730. /**
  731. * struct ipa_rx_data - information needed
  732. * to send to wlan driver on receiving data from ipa hw
  733. * @skb: skb
  734. * @dma_addr: DMA address of this Rx packet
  735. */
  736. struct ipa_rx_data {
  737. struct sk_buff *skb;
  738. dma_addr_t dma_addr;
  739. };
  740. /**
  741. * enum ipa_irq_type - IPA Interrupt Type
  742. * Used to register handlers for IPA interrupts
  743. *
  744. * Below enum is a logical mapping and not the actual interrupt bit in HW
  745. */
  746. enum ipa_irq_type {
  747. IPA_BAD_SNOC_ACCESS_IRQ,
  748. IPA_UC_IRQ_0,
  749. IPA_UC_IRQ_1,
  750. IPA_UC_IRQ_2,
  751. IPA_UC_IRQ_3,
  752. IPA_UC_IN_Q_NOT_EMPTY_IRQ,
  753. IPA_UC_RX_CMD_Q_NOT_FULL_IRQ,
  754. IPA_PROC_TO_UC_ACK_Q_NOT_EMPTY_IRQ,
  755. IPA_RX_ERR_IRQ,
  756. IPA_DEAGGR_ERR_IRQ,
  757. IPA_TX_ERR_IRQ,
  758. IPA_STEP_MODE_IRQ,
  759. IPA_PROC_ERR_IRQ,
  760. IPA_TX_SUSPEND_IRQ,
  761. IPA_TX_HOLB_DROP_IRQ,
  762. IPA_BAM_GSI_IDLE_IRQ,
  763. IPA_PIPE_YELLOW_MARKER_BELOW_IRQ,
  764. IPA_PIPE_RED_MARKER_BELOW_IRQ,
  765. IPA_PIPE_YELLOW_MARKER_ABOVE_IRQ,
  766. IPA_PIPE_RED_MARKER_ABOVE_IRQ,
  767. IPA_UCP_IRQ,
  768. IPA_DCMP_IRQ,
  769. IPA_GSI_EE_IRQ,
  770. IPA_GSI_IPA_IF_TLV_RCVD_IRQ,
  771. IPA_GSI_UC_IRQ,
  772. IPA_TLV_LEN_MIN_DSM_IRQ,
  773. IPA_DRBIP_PKT_EXCEED_MAX_SIZE_IRQ,
  774. IPA_DRBIP_DATA_SCTR_CFG_ERROR_IRQ,
  775. IPA_DRBIP_IMM_CMD_NO_FLSH_HZRD_IRQ,
  776. IPA_IRQ_MAX
  777. };
  778. /**
  779. * typedef ipa_irq_handler_t - irq handler/callback type
  780. * @param ipa_irq_type - [in] interrupt type
  781. * @param private_data - [in, out] the client private data
  782. * @param interrupt_data - [out] interrupt information data
  783. *
  784. * callback registered by ipa_add_interrupt_handler function to
  785. * handle a specific interrupt type
  786. *
  787. * No return value
  788. */
  789. typedef void (*ipa_irq_handler_t)(enum ipa_irq_type interrupt,
  790. void *private_data,
  791. void *interrupt_data);
  792. /**
  793. * struct IpaHwBamStats_t - Structure holding the BAM statistics
  794. *
  795. * @bamFifoFull : Number of times Bam Fifo got full - For In Ch: Good,
  796. * For Out Ch: Bad
  797. * @bamFifoEmpty : Number of times Bam Fifo got empty - For In Ch: Bad,
  798. * For Out Ch: Good
  799. * @bamFifoUsageHigh : Number of times Bam fifo usage went above 75% -
  800. * For In Ch: Good, For Out Ch: Bad
  801. * @bamFifoUsageLow : Number of times Bam fifo usage went below 25% -
  802. * For In Ch: Bad, For Out Ch: Good
  803. */
  804. struct IpaHwBamStats_t {
  805. u32 bamFifoFull;
  806. u32 bamFifoEmpty;
  807. u32 bamFifoUsageHigh;
  808. u32 bamFifoUsageLow;
  809. u32 bamUtilCount;
  810. } __packed;
  811. /**
  812. * struct IpaHwRingStats_t - Structure holding the Ring statistics
  813. *
  814. * @ringFull : Number of times Transfer Ring got full - For In Ch: Good,
  815. * For Out Ch: Bad
  816. * @ringEmpty : Number of times Transfer Ring got empty - For In Ch: Bad,
  817. * For Out Ch: Good
  818. * @ringUsageHigh : Number of times Transfer Ring usage went above 75% -
  819. * For In Ch: Good, For Out Ch: Bad
  820. * @ringUsageLow : Number of times Transfer Ring usage went below 25% -
  821. * For In Ch: Bad, For Out Ch: Good
  822. */
  823. struct IpaHwRingStats_t {
  824. u32 ringFull;
  825. u32 ringEmpty;
  826. u32 ringUsageHigh;
  827. u32 ringUsageLow;
  828. u32 RingUtilCount;
  829. } __packed;
  830. /**
  831. * struct IpaHwStatsWDIRxInfoData_t - Structure holding the WDI Rx channel
  832. * structures
  833. *
  834. * @max_outstanding_pkts : Number of outstanding packets in Rx Ring
  835. * @num_pkts_processed : Number of packets processed - cumulative
  836. * @rx_ring_rp_value : Read pointer last advertized to the WLAN FW
  837. * @rx_ind_ring_stats : Ring info
  838. * @bam_stats : BAM info
  839. * @num_bam_int_handled : Number of Bam Interrupts handled by FW
  840. * @num_db : Number of times the doorbell was rung
  841. * @num_unexpected_db : Number of unexpected doorbells
  842. * @num_pkts_in_dis_uninit_state : number of completions we
  843. * received in disabled or uninitialized state
  844. * @num_ic_inj_vdev_change : Number of times the Imm Cmd is
  845. * injected due to vdev_id change
  846. * @num_ic_inj_fw_desc_change : Number of times the Imm Cmd is
  847. * injected due to fw_desc change
  848. * @num_qmb_int_handled : Number of QMB interrupts handled
  849. */
  850. struct IpaHwStatsWDIRxInfoData_t {
  851. u32 max_outstanding_pkts;
  852. u32 num_pkts_processed;
  853. u32 rx_ring_rp_value;
  854. struct IpaHwRingStats_t rx_ind_ring_stats;
  855. struct IpaHwBamStats_t bam_stats;
  856. u32 num_bam_int_handled;
  857. u32 num_db;
  858. u32 num_unexpected_db;
  859. u32 num_pkts_in_dis_uninit_state;
  860. u32 num_ic_inj_vdev_change;
  861. u32 num_ic_inj_fw_desc_change;
  862. u32 num_qmb_int_handled;
  863. u32 reserved1;
  864. u32 reserved2;
  865. } __packed;
  866. /**
  867. * struct IpaHwStatsWDITxInfoData_t - Structure holding the WDI Tx channel
  868. * structures
  869. *
  870. * @num_pkts_processed : Number of packets processed - cumulative
  871. * @copy_engine_doorbell_value : latest value of doorbell written to copy engine
  872. * @num_db_fired : Number of DB from uC FW to Copy engine
  873. * @tx_comp_ring_stats : ring info
  874. * @bam_stats : BAM info
  875. * @num_db : Number of times the doorbell was rung
  876. * @num_unexpected_db : Number of unexpected doorbells
  877. * @num_bam_int_handled : Number of Bam Interrupts handled by FW
  878. * @num_bam_int_in_non_running_state : Number of Bam interrupts while not in
  879. * Running state
  880. * @num_qmb_int_handled : Number of QMB interrupts handled
  881. */
  882. struct IpaHwStatsWDITxInfoData_t {
  883. u32 num_pkts_processed;
  884. u32 copy_engine_doorbell_value;
  885. u32 num_db_fired;
  886. struct IpaHwRingStats_t tx_comp_ring_stats;
  887. struct IpaHwBamStats_t bam_stats;
  888. u32 num_db;
  889. u32 num_unexpected_db;
  890. u32 num_bam_int_handled;
  891. u32 num_bam_int_in_non_running_state;
  892. u32 num_qmb_int_handled;
  893. u32 num_bam_int_handled_while_wait_for_bam;
  894. } __packed;
  895. /**
  896. * struct IpaHwStatsWDIInfoData_t - Structure holding the WDI channel structures
  897. *
  898. * @rx_ch_stats : RX stats
  899. * @tx_ch_stats : TX stats
  900. */
  901. struct IpaHwStatsWDIInfoData_t {
  902. struct IpaHwStatsWDIRxInfoData_t rx_ch_stats;
  903. struct IpaHwStatsWDITxInfoData_t tx_ch_stats;
  904. } __packed;
  905. /**
  906. * struct ipa_wdi_ul_params - WDI_RX configuration
  907. * @rdy_ring_base_pa: physical address of the base of the Rx ring (containing
  908. * Rx buffers)
  909. * @rdy_ring_size: size of the Rx ring in bytes
  910. * @rdy_ring_rp_pa: physical address of the location through which IPA uc is
  911. * reading (WDI-1.0)
  912. * @rdy_comp_ring_base_pa: physical address of the base of the Rx completion
  913. * ring (WDI-2.0)
  914. * @rdy_comp_ring_wp_pa: physical address of the location through which IPA
  915. * uc is writing (WDI-2.0)
  916. * @rdy_comp_ring_size: size of the Rx_completion ring in bytes
  917. * expected to communicate about the Read pointer into the Rx Ring
  918. */
  919. struct ipa_wdi_ul_params {
  920. phys_addr_t rdy_ring_base_pa;
  921. u32 rdy_ring_size;
  922. phys_addr_t rdy_ring_rp_pa;
  923. phys_addr_t rdy_comp_ring_base_pa;
  924. phys_addr_t rdy_comp_ring_wp_pa;
  925. u32 rdy_comp_ring_size;
  926. u32 *rdy_ring_rp_va;
  927. u32 *rdy_comp_ring_wp_va;
  928. };
  929. /**
  930. * struct ipa_wdi_ul_params_smmu - WDI_RX configuration (with WLAN SMMU)
  931. * @rdy_ring: SG table describing the Rx ring (containing Rx buffers)
  932. * @rdy_ring_size: size of the Rx ring in bytes
  933. * @rdy_ring_rp_pa: physical address of the location through which IPA uc is
  934. * expected to communicate about the Read pointer into the Rx Ring
  935. */
  936. struct ipa_wdi_ul_params_smmu {
  937. struct sg_table rdy_ring;
  938. u32 rdy_ring_size;
  939. phys_addr_t rdy_ring_rp_pa;
  940. struct sg_table rdy_comp_ring;
  941. phys_addr_t rdy_comp_ring_wp_pa;
  942. u32 rdy_comp_ring_size;
  943. u32 *rdy_ring_rp_va;
  944. u32 *rdy_comp_ring_wp_va;
  945. };
  946. /**
  947. * struct ipa_wdi_dl_params - WDI_TX configuration
  948. * @comp_ring_base_pa: physical address of the base of the Tx completion ring
  949. * @comp_ring_size: size of the Tx completion ring in bytes
  950. * @ce_ring_base_pa: physical address of the base of the Copy Engine Source
  951. * Ring
  952. * @ce_door_bell_pa: physical address of the doorbell that the IPA uC has to
  953. * write into to trigger the copy engine
  954. * @ce_ring_size: Copy Engine Ring size in bytes
  955. * @num_tx_buffers: Number of pkt buffers allocated
  956. */
  957. struct ipa_wdi_dl_params {
  958. phys_addr_t comp_ring_base_pa;
  959. u32 comp_ring_size;
  960. phys_addr_t ce_ring_base_pa;
  961. phys_addr_t ce_door_bell_pa;
  962. u32 ce_ring_size;
  963. u32 num_tx_buffers;
  964. };
  965. /**
  966. * struct ipa_wdi_dl_params_smmu - WDI_TX configuration (with WLAN SMMU)
  967. * @comp_ring: SG table describing the Tx completion ring
  968. * @comp_ring_size: size of the Tx completion ring in bytes
  969. * @ce_ring: SG table describing the Copy Engine Source Ring
  970. * @ce_door_bell_pa: physical address of the doorbell that the IPA uC has to
  971. * write into to trigger the copy engine
  972. * @ce_ring_size: Copy Engine Ring size in bytes
  973. * @num_tx_buffers: Number of pkt buffers allocated
  974. */
  975. struct ipa_wdi_dl_params_smmu {
  976. struct sg_table comp_ring;
  977. u32 comp_ring_size;
  978. struct sg_table ce_ring;
  979. phys_addr_t ce_door_bell_pa;
  980. u32 ce_ring_size;
  981. u32 num_tx_buffers;
  982. };
  983. /**
  984. * struct ipa_wdi_in_params - information provided by WDI client
  985. * @sys: IPA EP configuration info
  986. * @ul: WDI_RX configuration info
  987. * @dl: WDI_TX configuration info
  988. * @ul_smmu: WDI_RX configuration info when WLAN uses SMMU
  989. * @dl_smmu: WDI_TX configuration info when WLAN uses SMMU
  990. * @smmu_enabled: true if WLAN uses SMMU
  991. * @ipa_wdi_meter_notifier_cb: Get WDI stats and quato info
  992. */
  993. struct ipa_wdi_in_params {
  994. struct ipa_sys_connect_params sys;
  995. union {
  996. struct ipa_wdi_ul_params ul;
  997. struct ipa_wdi_dl_params dl;
  998. struct ipa_wdi_ul_params_smmu ul_smmu;
  999. struct ipa_wdi_dl_params_smmu dl_smmu;
  1000. } u;
  1001. bool smmu_enabled;
  1002. #ifdef IPA_WAN_MSG_IPv6_ADDR_GW_LEN
  1003. ipa_wdi_meter_notifier_cb wdi_notify;
  1004. #endif
  1005. };
  1006. enum ipa_upstream_type {
  1007. IPA_UPSTEAM_MODEM = 1,
  1008. IPA_UPSTEAM_WLAN,
  1009. IPA_UPSTEAM_MAX
  1010. };
  1011. /**
  1012. * struct ipa_wdi_out_params - information provided to WDI client
  1013. * @uc_door_bell_pa: physical address of IPA uc doorbell
  1014. * @clnt_hdl: opaque handle assigned to client
  1015. */
  1016. struct ipa_wdi_out_params {
  1017. phys_addr_t uc_door_bell_pa;
  1018. u32 clnt_hdl;
  1019. };
  1020. /**
  1021. * struct ipa_wdi_db_params - information provided to retrieve
  1022. * physical address of uC doorbell
  1023. * @client: type of "client" (IPA_CLIENT_WLAN#_PROD/CONS)
  1024. * @uc_door_bell_pa: physical address of IPA uc doorbell
  1025. */
  1026. struct ipa_wdi_db_params {
  1027. enum ipa_client_type client;
  1028. phys_addr_t uc_door_bell_pa;
  1029. };
  1030. /**
  1031. * struct ipa_wdi_uc_ready_params - uC ready CB parameters
  1032. * @is_uC_ready: uC loaded or not
  1033. * @priv : callback cookie
  1034. * @notify: callback
  1035. */
  1036. typedef void (*ipa_uc_ready_cb)(void *priv);
  1037. struct ipa_wdi_uc_ready_params {
  1038. bool is_uC_ready;
  1039. void *priv;
  1040. ipa_uc_ready_cb notify;
  1041. };
  1042. /**
  1043. * struct ipa_wdi_buffer_info - address info of a WLAN allocated buffer
  1044. * @pa: physical address of the buffer
  1045. * @iova: IOVA of the buffer as embedded inside the WDI descriptors
  1046. * @size: size in bytes of the buffer
  1047. * @result: result of map or unmap operations (out param)
  1048. *
  1049. * IPA driver will create/release IOMMU mapping in IPA SMMU from iova->pa
  1050. */
  1051. struct ipa_wdi_buffer_info {
  1052. phys_addr_t pa;
  1053. unsigned long iova;
  1054. size_t size;
  1055. int result;
  1056. };
  1057. /**
  1058. * struct ipa_wdi_bw_info - address info of a WLAN allocated buffer
  1059. * @threshold: throughput wants to be monitored
  1060. * @num: number of threshold entries
  1061. * @stop: true to stop monitoring
  1062. *
  1063. * IPA driver will create/release IOMMU mapping in IPA SMMU from iova->pa
  1064. */
  1065. struct ipa_wdi_bw_info {
  1066. uint64_t threshold[IPA_BW_THRESHOLD_MAX];
  1067. int num;
  1068. bool stop;
  1069. };
  1070. /**
  1071. * struct ipa_wdi_tx_info - sw tx info from WLAN
  1072. * @sta_tx: sw tx stats on sta interface
  1073. * @ap_tx: sw tx stats on ap interface
  1074. *
  1075. * IPA driver will create/release IOMMU mapping in IPA SMMU from iova->pa
  1076. */
  1077. struct ipa_wdi_tx_info {
  1078. uint64_t sta_tx;
  1079. uint64_t ap_tx;
  1080. };
  1081. /**
  1082. * struct ipa_gsi_ep_config - IPA GSI endpoint configurations
  1083. *
  1084. * @ipa_ep_num: IPA EP pipe number
  1085. * @ipa_gsi_chan_num: GSI channel number
  1086. * @ipa_if_tlv: number of IPA_IF TLV
  1087. * @ipa_if_aos: number of IPA_IF AOS
  1088. * @ee: Execution environment
  1089. * @prefetch_mode: Prefetch mode to be used
  1090. * @prefetch_threshold: Prefetch empty level threshold.
  1091. * relevant for smart and free prefetch modes
  1092. */
  1093. struct ipa_gsi_ep_config {
  1094. int ipa_ep_num;
  1095. int ipa_gsi_chan_num;
  1096. int ipa_if_tlv;
  1097. int ipa_if_aos;
  1098. int ee;
  1099. enum gsi_prefetch_mode prefetch_mode;
  1100. uint8_t prefetch_threshold;
  1101. };
  1102. /**
  1103. * struct ipa_smmu_in_params - information provided from client
  1104. * @ipa_smmu_client_type: clinet requesting for the smmu info.
  1105. */
  1106. enum ipa_smmu_client_type {
  1107. IPA_SMMU_WLAN_CLIENT,
  1108. IPA_SMMU_AP_CLIENT,
  1109. IPA_SMMU_WIGIG_CLIENT,
  1110. IPA_SMMU_CLIENT_MAX
  1111. };
  1112. struct ipa_smmu_in_params {
  1113. enum ipa_smmu_client_type smmu_client;
  1114. };
  1115. /**
  1116. * struct ipa_smmu_out_params - information provided to IPA client
  1117. * @smmu_enable: IPA S1 SMMU enable/disable status
  1118. * @shared_cb: is client CB shared (mappings should be done by client only)
  1119. */
  1120. struct ipa_smmu_out_params {
  1121. bool smmu_enable;
  1122. bool shared_cb;
  1123. };
  1124. #if IS_ENABLED(CONFIG_IPA3)
  1125. /*
  1126. * Configuration
  1127. */
  1128. /**
  1129. * ipa_cfg_ep_ctrl() - IPA end-point Control configuration
  1130. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  1131. * @ipa_ep_cfg_ctrl: [in] IPA end-point configuration params
  1132. *
  1133. * Returns: 0 on success, negative on failure
  1134. */
  1135. int ipa_cfg_ep_ctrl(u32 clnt_hdl, const struct ipa_ep_cfg_ctrl *ep_ctrl);
  1136. /*
  1137. * Routing
  1138. */
  1139. /**
  1140. * ipa_add_rt_rule() - Add the specified routing rules to SW and optionally
  1141. * commit to IPA HW
  1142. * @rules: [inout] set of routing rules to add
  1143. *
  1144. * Returns: 0 on success, negative on failure
  1145. *
  1146. * Note: Should not be called from atomic context
  1147. */
  1148. int ipa_add_rt_rule(struct ipa_ioc_add_rt_rule *rules);
  1149. /**
  1150. * ipa_put_rt_tbl() - Release the specified routing table handle
  1151. * @rt_tbl_hdl: [in] the routing table handle to release
  1152. *
  1153. * Returns: 0 on success, negative on failure
  1154. *
  1155. * Note: Should not be called from atomic context
  1156. */
  1157. int ipa_put_rt_tbl(u32 rt_tbl_hdl);
  1158. /*
  1159. * Interface
  1160. */
  1161. int ipa_register_intf(const char *name,
  1162. const struct ipa_tx_intf *tx,
  1163. const struct ipa_rx_intf *rx);
  1164. /*
  1165. * Aggregation
  1166. */
  1167. /**
  1168. * ipa_set_aggr_mode() - Set the aggregation mode which is a global setting
  1169. * @mode: [in] the desired aggregation mode for e.g. straight MBIM, QCNCM,
  1170. * etc
  1171. *
  1172. * Returns: 0 on success
  1173. */
  1174. int ipa_set_aggr_mode(enum ipa_aggr_mode mode);
  1175. /**
  1176. * ipa_set_qcncm_ndp_sig() - Set the NDP signature used for QCNCM aggregation
  1177. * mode
  1178. * @sig: [in] the first 3 bytes of QCNCM NDP signature (expected to be
  1179. * "QND")
  1180. *
  1181. * Set the NDP signature used for QCNCM aggregation mode. The fourth byte
  1182. * (expected to be 'P') needs to be set using the header addition mechanism
  1183. *
  1184. * Returns: 0 on success, negative on failure
  1185. */
  1186. int ipa_set_qcncm_ndp_sig(char sig[3]);
  1187. /**
  1188. * ipa_set_single_ndp_per_mbim() - Enable/disable single NDP per MBIM frame
  1189. * configuration
  1190. * @enable: [in] true for single NDP/MBIM; false otherwise
  1191. *
  1192. * Returns: 0 on success
  1193. */
  1194. int ipa_set_single_ndp_per_mbim(bool enable);
  1195. /*
  1196. * interrupts
  1197. */
  1198. /**
  1199. * ipa_add_interrupt_handler() - Adds handler to an interrupt type
  1200. * @interrupt: Interrupt type
  1201. * @handler: The handler to be added
  1202. * @deferred_flag: whether the handler processing should be deferred in
  1203. * a workqueue
  1204. * @private_data: the client's private data
  1205. *
  1206. * Adds handler to an interrupt type and enable the specific bit
  1207. * in IRQ_EN register, associated interrupt in IRQ_STTS register will be enabled
  1208. */
  1209. int ipa_add_interrupt_handler(enum ipa_irq_type interrupt,
  1210. ipa_irq_handler_t handler,
  1211. bool deferred_flag,
  1212. void *private_data);
  1213. /**
  1214. * ipa_restore_suspend_handler() - restores the original suspend IRQ handler
  1215. * as it was registered in the IPA init sequence.
  1216. * Return codes:
  1217. * 0: success
  1218. * -EPERM: failed to remove current handler or failed to add original handler
  1219. */
  1220. int ipa_restore_suspend_handler(void);
  1221. /*
  1222. * Messaging
  1223. */
  1224. /**
  1225. * ipa_send_msg() - Send "message" from kernel client to IPA driver
  1226. * @meta: [in] message meta-data
  1227. * @buff: [in] the payload for message
  1228. * @callback: [in] free callback
  1229. *
  1230. * Client supplies the message meta-data and payload which IPA driver buffers
  1231. * till read by user-space. After read from user space IPA driver invokes the
  1232. * callback supplied to free the message payload. Client must not touch/free
  1233. * the message payload after calling this API.
  1234. *
  1235. * Returns: 0 on success, negative on failure
  1236. *
  1237. * Note: Should not be called from atomic context
  1238. */
  1239. int ipa_send_msg(struct ipa_msg_meta *meta, void *buff,
  1240. ipa_msg_free_fn callback);
  1241. /*
  1242. * Data path
  1243. */
  1244. /**
  1245. * ipa_tx_dp() - Data-path tx handler
  1246. * @dst: [in] which IPA destination to route tx packets to
  1247. * @skb: [in] the packet to send
  1248. * @metadata: [in] TX packet meta-data
  1249. *
  1250. * Data-path tx handler, this is used for both SW data-path which by-passes most
  1251. * IPA HW blocks AND the regular HW data-path for WLAN AMPDU traffic only. If
  1252. * dst is a "valid" CONS type, then SW data-path is used. If dst is the
  1253. * WLAN_AMPDU PROD type, then HW data-path for WLAN AMPDU is used. Anything else
  1254. * is an error. For errors, client needs to free the skb as needed. For success,
  1255. * IPA driver will later invoke client callback if one was supplied. That
  1256. * callback should free the skb. If no callback supplied, IPA driver will free
  1257. * the skb internally
  1258. *
  1259. * The function will use two descriptors for this send command
  1260. * (for A5_WLAN_AMPDU_PROD only one desciprtor will be sent),
  1261. * the first descriptor will be used to inform the IPA hardware that
  1262. * apps need to push data into the IPA (IP_PACKET_INIT immediate command).
  1263. * Once this send was done from SPS point-of-view the IPA driver will
  1264. * get notified by the supplied callback - ipa_sps_irq_tx_comp()
  1265. *
  1266. * ipa_sps_irq_tx_comp will call to the user supplied
  1267. * callback (from ipa_connect)
  1268. *
  1269. * Returns: 0 on success, negative on failure
  1270. */
  1271. int ipa_tx_dp(enum ipa_client_type dst, struct sk_buff *skb,
  1272. struct ipa_tx_meta *metadata);
  1273. /*
  1274. * ipa_rmnet_ctl_xmit - QMAP Flow control TX
  1275. *
  1276. * @skb - tx QMAP control packet
  1277. *
  1278. * Note: This need to be called after client receive rmnet_ctl_
  1279. * ready_cb and want to send TX flow control message.
  1280. *
  1281. * This funciton will return 0 on success, -EAGAIN if pipe if full.
  1282. */
  1283. int ipa_rmnet_ctl_xmit(struct sk_buff *skb);
  1284. void ipa_free_skb(struct ipa_rx_data *data);
  1285. /*
  1286. * System pipes
  1287. */
  1288. /**
  1289. * ipa_setup_sys_pipe() - Setup an IPA end-point in system-BAM mode and perform
  1290. * IPA EP configuration
  1291. * @sys_in: [in] input needed to setup BAM pipe and configure EP
  1292. * @clnt_hdl: [out] client handle
  1293. *
  1294. * - configure the end-point registers with the supplied
  1295. * parameters from the user.
  1296. * - call SPS APIs to create a system-to-bam connection with IPA.
  1297. * - allocate descriptor FIFO
  1298. * - register callback function(ipa_sps_irq_rx_notify or
  1299. * ipa_sps_irq_tx_notify - depends on client type) in case the driver is
  1300. * not configured to pulling mode
  1301. *
  1302. * Returns: 0 on success, negative on failure
  1303. */
  1304. int ipa_setup_sys_pipe(struct ipa_sys_connect_params *sys_in, u32 *clnt_hdl);
  1305. /**
  1306. * ipa_teardown_sys_pipe() - Teardown the system-BAM pipe and cleanup IPA EP
  1307. * @clnt_hdl: [in] the handle obtained from ipa_setup_sys_pipe
  1308. *
  1309. * Returns: 0 on success, negative on failure
  1310. */
  1311. int ipa_teardown_sys_pipe(u32 clnt_hdl);
  1312. int ipa_connect_wdi_pipe(struct ipa_wdi_in_params *in,
  1313. struct ipa_wdi_out_params *out);
  1314. int ipa_disconnect_wdi_pipe(u32 clnt_hdl);
  1315. int ipa_enable_wdi_pipe(u32 clnt_hdl);
  1316. int ipa_disable_wdi_pipe(u32 clnt_hdl);
  1317. int ipa_resume_wdi_pipe(u32 clnt_hdl);
  1318. int ipa_suspend_wdi_pipe(u32 clnt_hdl);
  1319. /**
  1320. * ipa_get_wdi_stats() - Query WDI statistics from uc
  1321. * @stats: [inout] stats blob from client populated by driver
  1322. *
  1323. * Returns: 0 on success, negative on failure
  1324. *
  1325. * @note Cannot be called from atomic context
  1326. *
  1327. */
  1328. int ipa_get_wdi_stats(struct IpaHwStatsWDIInfoData_t *stats);
  1329. int ipa_uc_bw_monitor(struct ipa_wdi_bw_info *info);
  1330. /**
  1331. * ipa_broadcast_wdi_quota_reach_ind() - quota reach
  1332. * @uint32_t fid: [in] input netdev ID
  1333. * @uint64_t num_bytes: [in] used bytes
  1334. *
  1335. * Returns: 0 on success, negative on failure
  1336. */
  1337. int ipa_broadcast_wdi_quota_reach_ind(uint32_t fid,
  1338. uint64_t num_bytes);
  1339. /*
  1340. * To retrieve doorbell physical address of
  1341. * wlan pipes
  1342. */
  1343. int ipa_uc_wdi_get_dbpa(struct ipa_wdi_db_params *out);
  1344. /*
  1345. * IPADMA
  1346. */
  1347. /**
  1348. * ipa_dma_init() -Initialize IPADMA.
  1349. *
  1350. * This function initialize all IPADMA internal data and connect in dma:
  1351. * MEMCPY_DMA_SYNC_PROD ->MEMCPY_DMA_SYNC_CONS
  1352. * MEMCPY_DMA_ASYNC_PROD->MEMCPY_DMA_SYNC_CONS
  1353. *
  1354. * Return codes: 0: success
  1355. * -EFAULT: IPADMA is already initialized
  1356. * -ENOMEM: allocating memory error
  1357. * -EPERM: pipe connection failed
  1358. */
  1359. int ipa_dma_init(void);
  1360. /**
  1361. * ipa_dma_enable() -Vote for IPA clocks.
  1362. *
  1363. *Return codes: 0: success
  1364. * -EINVAL: IPADMA is not initialized
  1365. * -EPERM: Operation not permitted as ipa_dma is already
  1366. * enabled
  1367. */
  1368. int ipa_dma_enable(void);
  1369. /**
  1370. * ipa_dma_disable()- Unvote for IPA clocks.
  1371. *
  1372. * enter to power save mode.
  1373. *
  1374. * Return codes: 0: success
  1375. * -EINVAL: IPADMA is not initialized
  1376. * -EPERM: Operation not permitted as ipa_dma is already
  1377. * diabled
  1378. * -EFAULT: can not disable ipa_dma as there are pending
  1379. * memcopy works
  1380. */
  1381. int ipa_dma_disable(void);
  1382. /**
  1383. * ipa_dma_sync_memcpy()- Perform synchronous memcpy using IPA.
  1384. *
  1385. * @dest: physical address to store the copied data.
  1386. * @src: physical address of the source data to copy.
  1387. * @len: number of bytes to copy.
  1388. *
  1389. * Return codes: 0: success
  1390. * -EINVAL: invalid params
  1391. * -EPERM: operation not permitted as ipa_dma isn't enable or
  1392. * initialized
  1393. * -SPS_ERROR: on sps faliures
  1394. * -EFAULT: other
  1395. */
  1396. int ipa_dma_sync_memcpy(u64 dest, u64 src, int len);
  1397. /**
  1398. * ipa_dma_async_memcpy()- Perform asynchronous memcpy using IPA.
  1399. *
  1400. * @dest: physical address to store the copied data.
  1401. * @src: physical address of the source data to copy.
  1402. * @len: number of bytes to copy.
  1403. * @user_cb: callback function to notify the client when the copy was done.
  1404. * @user_param: cookie for user_cb.
  1405. *
  1406. * Return codes: 0: success
  1407. * -EINVAL: invalid params
  1408. * -EPERM: operation not permitted as ipa_dma isn't enable or
  1409. * initialized
  1410. * -SPS_ERROR: on sps faliures
  1411. * -EFAULT: descr fifo is full.
  1412. */
  1413. int ipa_dma_async_memcpy(u64 dest, u64 src, int len,
  1414. void (*user_cb)(void *user1), void *user_param);
  1415. /**
  1416. * ipa_dma_destroy() -teardown IPADMA pipes and release ipadma.
  1417. *
  1418. * this is a blocking function, returns just after destroying IPADMA.
  1419. */
  1420. void ipa_dma_destroy(void);
  1421. /*
  1422. * Miscellaneous
  1423. */
  1424. int ipa_get_ep_mapping(enum ipa_client_type client);
  1425. bool ipa_is_ready(void);
  1426. enum ipa_hw_type ipa_get_hw_type(void);
  1427. const struct ipa_gsi_ep_config *ipa_get_gsi_ep_info(
  1428. enum ipa_client_type client);
  1429. int ipa_stop_gsi_channel(u32 clnt_hdl);
  1430. typedef void (*ipa_ready_cb)(void *user_data);
  1431. typedef void (*ipa_rmnet_ctl_ready_cb)(void *user_data);
  1432. typedef void (*ipa_rmnet_ctl_stop_cb)(void *user_data);
  1433. typedef void (*ipa_rmnet_ctl_rx_notify_cb)(void *user_data, void *rx_data);
  1434. /**
  1435. * ipa_register_ipa_ready_cb() - register a callback to be invoked
  1436. * when IPA core driver initialization is complete.
  1437. *
  1438. * @ipa_ready_cb: CB to be triggered.
  1439. * @user_data: Data to be sent to the originator of the CB.
  1440. *
  1441. * Note: This function is expected to be utilized when ipa_is_ready
  1442. * function returns false.
  1443. * An IPA client may also use this function directly rather than
  1444. * calling ipa_is_ready beforehand, as if this API returns -EEXIST,
  1445. * this means IPA initialization is complete (and no callback will
  1446. * be triggered).
  1447. * When the callback is triggered, the client MUST perform his
  1448. * operations in a different context.
  1449. *
  1450. * The function will return 0 on success, -ENOMEM on memory issues and
  1451. * -EEXIST if IPA initialization is complete already.
  1452. */
  1453. int ipa_register_ipa_ready_cb(void (*ipa_ready_cb)(void *user_data),
  1454. void *user_data);
  1455. /**
  1456. * ipa_register_rmnet_ctl_cb() - register callbacks to be invoked
  1457. * to rmnet_ctl for qmap flow control pipes setup/teardown/rx_notify.
  1458. *
  1459. * @ipa_rmnet_ctl_ready_cb: CB to be called when pipes setup.
  1460. * @user_data1: user_data for ipa_rmnet_ctl_ready_cb.
  1461. * @ipa_rmnet_ctl_stop_cb: CB to be called when pipes teardown.
  1462. * @user_data2: user_data for ipa_rmnet_ctl_stop_cb.
  1463. * @ipa_rmnet_ctl_rx_notify_cb: CB to be called when receive rx pkts.
  1464. * @user_data3: user_data for ipa_rmnet_ctl_rx_notify_cb.
  1465. * @rx_data: RX data buffer.
  1466. *
  1467. * Note: This function is expected to be utilized for rmnet_ctl
  1468. * module when new qmap flow control is enabled.
  1469. *
  1470. * The function will return 0 on success, -EAGAIN if IPA not ready,
  1471. * -ENXIO is feature is not enabled, -EEXIST if already called.
  1472. */
  1473. int ipa_register_rmnet_ctl_cb(
  1474. void (*ipa_rmnet_ctl_ready_cb)(void *user_data1),
  1475. void *user_data1,
  1476. void (*ipa_rmnet_ctl_stop_cb)(void *user_data2),
  1477. void *user_data2,
  1478. void (*ipa_rmnet_ctl_rx_notify_cb)(void *user_data3, void *rx_data),
  1479. void *user_data3);
  1480. /**
  1481. * ipa_unregister_rmnet_ctl_cb() - unregister callbacks to be
  1482. * invoked to rmnet_ctl for qmap flow control pipes
  1483. * setup/teardown/rx_notify.
  1484. *
  1485. * Note: This function is expected to be utilized for rmnet_ctl
  1486. * module when new qmap flow control is enabled.
  1487. *
  1488. * The function will return 0 on success, -EAGAIN if IPA not ready,
  1489. * -ENXIO is feature is not enabled.
  1490. */
  1491. int ipa_unregister_rmnet_ctl_cb(void);
  1492. int ipa_get_smmu_params(struct ipa_smmu_in_params *in,
  1493. struct ipa_smmu_out_params *out);
  1494. /**
  1495. * ipa_is_vlan_mode - check if a LAN driver should load in VLAN mode
  1496. * @iface - type of vlan capable device
  1497. * @res - query result: true for vlan mode, false for non vlan mode
  1498. *
  1499. * API must be called after ipa_is_ready() returns true, otherwise it will fail
  1500. *
  1501. * Returns: 0 on success, negative on failure
  1502. */
  1503. int ipa_is_vlan_mode(enum ipa_vlan_ifaces iface, bool *res);
  1504. /**
  1505. * ipa_get_lan_rx_napi - returns true if NAPI is enabled in the LAN RX dp
  1506. */
  1507. bool ipa_get_lan_rx_napi(void);
  1508. int ipa_mhi_handle_ipa_config_req(struct ipa_config_req_msg_v01 *config_req);
  1509. int ipa_wigig_save_regs(void);
  1510. /*
  1511. * this function needs to be removed, but wlan driver is checking return value
  1512. * to see if IPA is present, so we can't return -EPERM
  1513. */
  1514. static inline int ipa_uc_reg_rdyCB(
  1515. struct ipa_wdi_uc_ready_params *inout)
  1516. {
  1517. return -EFAULT;
  1518. }
  1519. #else /* IS_ENABLED(CONFIG_IPA3) */
  1520. /*
  1521. * Configuration
  1522. */
  1523. static inline int ipa_cfg_ep_ctrl(u32 clnt_hdl,
  1524. const struct ipa_ep_cfg_ctrl *ep_ctrl)
  1525. {
  1526. return -EPERM;
  1527. }
  1528. /*
  1529. * Routing
  1530. */
  1531. static inline int ipa_add_rt_rule(struct ipa_ioc_add_rt_rule *rules)
  1532. {
  1533. return -EPERM;
  1534. }
  1535. static inline int ipa_put_rt_tbl(u32 rt_tbl_hdl)
  1536. {
  1537. return -EPERM;
  1538. }
  1539. /*
  1540. * Interface
  1541. */
  1542. static inline int ipa_register_intf(const char *name,
  1543. const struct ipa_tx_intf *tx,
  1544. const struct ipa_rx_intf *rx)
  1545. {
  1546. return -EPERM;
  1547. }
  1548. /*
  1549. * Aggregation
  1550. */
  1551. static inline int ipa_set_aggr_mode(enum ipa_aggr_mode mode)
  1552. {
  1553. return -EPERM;
  1554. }
  1555. static inline int ipa_set_qcncm_ndp_sig(char sig[3])
  1556. {
  1557. return -EPERM;
  1558. }
  1559. static inline int ipa_set_single_ndp_per_mbim(bool enable)
  1560. {
  1561. return -EPERM;
  1562. }
  1563. /*
  1564. * interrupts
  1565. */
  1566. static inline int ipa_add_interrupt_handler(enum ipa_irq_type interrupt,
  1567. ipa_irq_handler_t handler,
  1568. bool deferred_flag,
  1569. void *private_data)
  1570. {
  1571. return -EPERM;
  1572. }
  1573. static inline int ipa_restore_suspend_handler(void)
  1574. {
  1575. return -EPERM;
  1576. }
  1577. /*
  1578. * Messaging
  1579. */
  1580. static inline int ipa_send_msg(struct ipa_msg_meta *meta, void *buff,
  1581. ipa_msg_free_fn callback)
  1582. {
  1583. return -EPERM;
  1584. }
  1585. /*
  1586. * Data path
  1587. */
  1588. static inline int ipa_tx_dp(enum ipa_client_type dst, struct sk_buff *skb,
  1589. struct ipa_tx_meta *metadata)
  1590. {
  1591. return -EPERM;
  1592. }
  1593. /*
  1594. * QMAP Flow control TX
  1595. */
  1596. static inline int ipa_rmnet_ctl_xmit(struct sk_buff *skb)
  1597. {
  1598. return -EPERM;
  1599. }
  1600. static inline void ipa_free_skb(struct ipa_rx_data *rx_in)
  1601. {
  1602. }
  1603. /*
  1604. * System pipes
  1605. */
  1606. static inline int ipa_setup_sys_pipe(struct ipa_sys_connect_params *sys_in,
  1607. u32 *clnt_hdl)
  1608. {
  1609. return -EPERM;
  1610. }
  1611. static inline int ipa_teardown_sys_pipe(u32 clnt_hdl)
  1612. {
  1613. return -EPERM;
  1614. }
  1615. static inline int ipa_connect_wdi_pipe(struct ipa_wdi_in_params *in,
  1616. struct ipa_wdi_out_params *out)
  1617. {
  1618. return -EPERM;
  1619. }
  1620. static inline int ipa_disconnect_wdi_pipe(u32 clnt_hdl)
  1621. {
  1622. return -EPERM;
  1623. }
  1624. static inline int ipa_enable_wdi_pipe(u32 clnt_hdl)
  1625. {
  1626. return -EPERM;
  1627. }
  1628. static inline int ipa_disable_wdi_pipe(u32 clnt_hdl)
  1629. {
  1630. return -EPERM;
  1631. }
  1632. static inline int ipa_resume_wdi_pipe(u32 clnt_hdl)
  1633. {
  1634. return -EPERM;
  1635. }
  1636. static inline int ipa_suspend_wdi_pipe(u32 clnt_hdl)
  1637. {
  1638. return -EPERM;
  1639. }
  1640. static inline int ipa_broadcast_wdi_quota_reach_ind(uint32_t fid,
  1641. uint64_t num_bytes)
  1642. {
  1643. return -EPERM;
  1644. }
  1645. static inline int ipa_uc_wdi_get_dbpa(
  1646. struct ipa_wdi_db_params *out)
  1647. {
  1648. return -EPERM;
  1649. }
  1650. /*
  1651. * IPADMA
  1652. */
  1653. static inline int ipa_dma_init(void)
  1654. {
  1655. return -EPERM;
  1656. }
  1657. static inline int ipa_dma_enable(void)
  1658. {
  1659. return -EPERM;
  1660. }
  1661. static inline int ipa_dma_disable(void)
  1662. {
  1663. return -EPERM;
  1664. }
  1665. static inline int ipa_dma_sync_memcpy(phys_addr_t dest, phys_addr_t src
  1666. , int len)
  1667. {
  1668. return -EPERM;
  1669. }
  1670. static inline int ipa_dma_async_memcpy(phys_addr_t dest, phys_addr_t src
  1671. , int len, void (*user_cb)(void *user1),
  1672. void *user_param)
  1673. {
  1674. return -EPERM;
  1675. }
  1676. static inline void ipa_dma_destroy(void)
  1677. {
  1678. }
  1679. /*
  1680. * Miscellaneous
  1681. */
  1682. static inline int ipa_get_wdi_stats(struct IpaHwStatsWDIInfoData_t *stats)
  1683. {
  1684. return -EPERM;
  1685. }
  1686. static inline int ipa_uc_bw_monitor(struct ipa_wdi_bw_info *info)
  1687. {
  1688. return -EPERM;
  1689. }
  1690. static inline int ipa_get_ep_mapping(enum ipa_client_type client)
  1691. {
  1692. return -EPERM;
  1693. }
  1694. static inline bool ipa_is_ready(void)
  1695. {
  1696. return false;
  1697. }
  1698. static inline enum ipa_hw_type ipa_get_hw_type(void)
  1699. {
  1700. return IPA_HW_None;
  1701. }
  1702. static inline int ipa_register_ipa_ready_cb(
  1703. void (*ipa_ready_cb)(void *user_data),
  1704. void *user_data)
  1705. {
  1706. return -EPERM;
  1707. }
  1708. static inline int ipa_get_smmu_params(struct ipa_smmu_in_params *in,
  1709. struct ipa_smmu_out_params *out)
  1710. {
  1711. return -EPERM;
  1712. }
  1713. static inline int ipa_is_vlan_mode(enum ipa_vlan_ifaces iface, bool *res)
  1714. {
  1715. return -EPERM;
  1716. }
  1717. static inline bool ipa_get_lan_rx_napi(void)
  1718. {
  1719. return false;
  1720. }
  1721. static inline const struct ipa_gsi_ep_config *ipa_get_gsi_ep_info(
  1722. enum ipa_client_type client)
  1723. {
  1724. return NULL;
  1725. }
  1726. static inline int ipa_stop_gsi_channel(u32 clnt_hdl)
  1727. {
  1728. return -EPERM;
  1729. }
  1730. static inline int ipa_register_rmnet_ctl_cb(
  1731. void (*ipa_rmnet_ctl_ready_cb)(void *user_data1),
  1732. void *user_data1,
  1733. void (*ipa_rmnet_ctl_stop_cb)(void *user_data2),
  1734. void *user_data2,
  1735. void (*ipa_rmnet_ctl_rx_notify_cb)(void *user_data3, void *rx_data),
  1736. void *user_data3)
  1737. {
  1738. return -EPERM;
  1739. }
  1740. static inline int ipa_unregister_rmnet_ctl_cb(void)
  1741. {
  1742. return -EPERM;
  1743. }
  1744. static inline int ipa_uc_reg_rdyCB(
  1745. struct ipa_wdi_uc_ready_params *inout)
  1746. {
  1747. return -EPERM;
  1748. }
  1749. #endif /* IS_ENABLED(CONFIG_IPA3) */
  1750. /* stubs - to be removed once dependent drivers remove references */
  1751. static inline int ipa_reset_endpoint(u32 clnt_hdl)
  1752. {
  1753. return -EPERM;
  1754. }
  1755. static inline int ipa_clear_endpoint_delay(u32 clnt_hdl)
  1756. {
  1757. return -EPERM;
  1758. }
  1759. static inline int ipa_commit_hdr(void)
  1760. {
  1761. return -EPERM;
  1762. }
  1763. static inline int ipa_put_hdr(u32 hdr_hdl)
  1764. {
  1765. return -EPERM;
  1766. }
  1767. static inline int ipa_copy_hdr(struct ipa_ioc_copy_hdr *copy)
  1768. {
  1769. return -EPERM;
  1770. }
  1771. static inline int ipa_register_pull_msg(struct ipa_msg_meta *meta,
  1772. ipa_msg_pull_fn callback)
  1773. {
  1774. return -EPERM;
  1775. }
  1776. static inline int ipa_deregister_pull_msg(struct ipa_msg_meta *meta)
  1777. {
  1778. return -EPERM;
  1779. }
  1780. static inline int ipa_register_intf_ext(const char *name,
  1781. const struct ipa_tx_intf *tx,
  1782. const struct ipa_rx_intf *rx,
  1783. const struct ipa_ext_intf *ext)
  1784. {
  1785. return -EPERM;
  1786. }
  1787. static inline int ipa_tx_dp_mul(enum ipa_client_type src,
  1788. struct ipa_tx_data_desc *data_desc)
  1789. {
  1790. return -EPERM;
  1791. }
  1792. static inline u16 ipa_get_smem_restr_bytes(void)
  1793. {
  1794. return -EPERM;
  1795. }
  1796. static inline int ipa_create_wdi_mapping(u32 num_buffers,
  1797. struct ipa_wdi_buffer_info *info)
  1798. {
  1799. return -EPERM;
  1800. }
  1801. static inline int ipa_release_wdi_mapping(u32 num_buffers,
  1802. struct ipa_wdi_buffer_info *info)
  1803. {
  1804. return -EPERM;
  1805. }
  1806. static inline int ipa_rm_create_resource(
  1807. struct ipa_rm_create_params *create_params)
  1808. {
  1809. return -EPERM;
  1810. }
  1811. static inline int ipa_rm_delete_resource(
  1812. enum ipa_rm_resource_name resource_name)
  1813. {
  1814. return -EPERM;
  1815. }
  1816. static inline int ipa_rm_register(enum ipa_rm_resource_name resource_name,
  1817. struct ipa_rm_register_params *reg_params)
  1818. {
  1819. return -EPERM;
  1820. }
  1821. static inline int ipa_rm_deregister(
  1822. enum ipa_rm_resource_name resource_name,
  1823. struct ipa_rm_register_params *reg_params)
  1824. {
  1825. return -EPERM;
  1826. }
  1827. static inline int ipa_rm_set_perf_profile(
  1828. enum ipa_rm_resource_name resource_name,
  1829. struct ipa_rm_perf_profile *profile)
  1830. {
  1831. return -EPERM;
  1832. }
  1833. static inline int ipa_rm_add_dependency(
  1834. enum ipa_rm_resource_name resource_name,
  1835. enum ipa_rm_resource_name depends_on_name)
  1836. {
  1837. return -EPERM;
  1838. }
  1839. static inline int ipa_rm_add_dependency_sync(
  1840. enum ipa_rm_resource_name resource_name,
  1841. enum ipa_rm_resource_name depends_on_name)
  1842. {
  1843. return -EPERM;
  1844. }
  1845. static inline int ipa_rm_delete_dependency(
  1846. enum ipa_rm_resource_name resource_name,
  1847. enum ipa_rm_resource_name depends_on_name)
  1848. {
  1849. return -EPERM;
  1850. }
  1851. static inline int ipa_rm_request_resource(
  1852. enum ipa_rm_resource_name resource_name)
  1853. {
  1854. return -EPERM;
  1855. }
  1856. static inline int ipa_rm_inactivity_timer_init(
  1857. enum ipa_rm_resource_name resource_name,
  1858. unsigned long msecs)
  1859. {
  1860. return -EPERM;
  1861. }
  1862. static inline int ipa_rm_release_resource(
  1863. enum ipa_rm_resource_name resource_name)
  1864. {
  1865. return -EPERM;
  1866. }
  1867. static inline int ipa_rm_notify_completion(enum ipa_rm_event event,
  1868. enum ipa_rm_resource_name resource_name)
  1869. {
  1870. return -EPERM;
  1871. }
  1872. static inline int ipa_rm_inactivity_timer_destroy(
  1873. enum ipa_rm_resource_name resource_name)
  1874. {
  1875. return -EPERM;
  1876. }
  1877. static inline int ipa_rm_inactivity_timer_request_resource(
  1878. enum ipa_rm_resource_name resource_name)
  1879. {
  1880. return -EPERM;
  1881. }
  1882. static inline int ipa_rm_inactivity_timer_release_resource(
  1883. enum ipa_rm_resource_name resource_name)
  1884. {
  1885. return -EPERM;
  1886. }
  1887. static inline enum ipa_rm_resource_name ipa_get_rm_resource_from_ep(
  1888. int pipe_idx)
  1889. {
  1890. return -EPERM;
  1891. }
  1892. static inline void ipa_bam_reg_dump(void)
  1893. {
  1894. }
  1895. static inline void ipa_proxy_clk_vote(void)
  1896. {
  1897. }
  1898. static inline void ipa_proxy_clk_unvote(void)
  1899. {
  1900. }
  1901. static inline bool ipa_is_client_handle_valid(u32 clnt_hdl)
  1902. {
  1903. return false;
  1904. }
  1905. static inline enum ipa_client_type ipa_get_client_mapping(int pipe_idx)
  1906. {
  1907. return -EPERM;
  1908. }
  1909. static inline bool ipa_get_modem_cfg_emb_pipe_flt(void)
  1910. {
  1911. return false;
  1912. }
  1913. static inline enum ipa_transport_type ipa_get_transport_type(void)
  1914. {
  1915. return IPA_TRANSPORT_TYPE_GSI;
  1916. }
  1917. static inline struct device *ipa_get_dma_dev(void)
  1918. {
  1919. return NULL;
  1920. }
  1921. static inline struct iommu_domain *ipa_get_smmu_domain(void)
  1922. {
  1923. return NULL;
  1924. }
  1925. static inline int ipa_disable_apps_wan_cons_deaggr(
  1926. uint32_t agg_size, uint32_t agg_count)
  1927. {
  1928. return -EPERM;
  1929. }
  1930. static inline int ipa_add_hdr(struct ipa_ioc_add_hdr *hdrs)
  1931. {
  1932. return -EPERM;
  1933. }
  1934. static inline int ipa_del_hdr(struct ipa_ioc_del_hdr *hdls)
  1935. {
  1936. return -EPERM;
  1937. }
  1938. static inline int ipa_get_hdr(struct ipa_ioc_get_hdr *lookup)
  1939. {
  1940. return -EPERM;
  1941. }
  1942. static inline int ipa_deregister_intf(const char *name)
  1943. {
  1944. return -EPERM;
  1945. }
  1946. static inline int ipa_uc_dereg_rdyCB(void)
  1947. {
  1948. return -EPERM;
  1949. }
  1950. #endif /* _IPA_H_ */