ipa_debugfs.c 79 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifdef CONFIG_DEBUG_FS
  6. #include <linux/debugfs.h>
  7. #include <linux/kernel.h>
  8. #include <linux/stringify.h>
  9. #include "ipa_i.h"
  10. #include "../ipa_rm_i.h"
  11. #include "ipahal/ipahal_nat.h"
  12. #include "ipa_odl.h"
  13. #include "ipa_qmi_service.h"
  14. #define IPA_MAX_ENTRY_STRING_LEN 500
  15. #define IPA_MAX_MSG_LEN 4096
  16. #define IPA_DBG_MAX_RULE_IN_TBL 128
  17. #define IPA_DBG_ACTIVE_CLIENT_BUF_SIZE ((IPA3_ACTIVE_CLIENTS_LOG_LINE_LEN \
  18. * IPA3_ACTIVE_CLIENTS_LOG_BUFFER_SIZE_LINES) + IPA_MAX_MSG_LEN)
  19. #define IPA_DUMP_STATUS_FIELD(f) \
  20. pr_err(#f "=0x%x\n", status->f)
  21. #define IPA_READ_ONLY_MODE 0444
  22. #define IPA_READ_WRITE_MODE 0664
  23. #define IPA_WRITE_ONLY_MODE 0220
  24. struct ipa3_debugfs_file {
  25. const char *name;
  26. umode_t mode;
  27. void *data;
  28. const struct file_operations fops;
  29. };
  30. const char *ipa3_event_name[IPA_EVENT_MAX_NUM] = {
  31. __stringify(WLAN_CLIENT_CONNECT),
  32. __stringify(WLAN_CLIENT_DISCONNECT),
  33. __stringify(WLAN_CLIENT_POWER_SAVE_MODE),
  34. __stringify(WLAN_CLIENT_NORMAL_MODE),
  35. __stringify(SW_ROUTING_ENABLE),
  36. __stringify(SW_ROUTING_DISABLE),
  37. __stringify(WLAN_AP_CONNECT),
  38. __stringify(WLAN_AP_DISCONNECT),
  39. __stringify(WLAN_STA_CONNECT),
  40. __stringify(WLAN_STA_DISCONNECT),
  41. __stringify(WLAN_CLIENT_CONNECT_EX),
  42. __stringify(WLAN_SWITCH_TO_SCC),
  43. __stringify(WLAN_SWITCH_TO_MCC),
  44. __stringify(WLAN_WDI_ENABLE),
  45. __stringify(WLAN_WDI_DISABLE),
  46. __stringify(WAN_UPSTREAM_ROUTE_ADD),
  47. __stringify(WAN_UPSTREAM_ROUTE_DEL),
  48. __stringify(WAN_EMBMS_CONNECT),
  49. __stringify(WAN_XLAT_CONNECT),
  50. __stringify(ECM_CONNECT),
  51. __stringify(ECM_DISCONNECT),
  52. __stringify(IPA_TETHERING_STATS_UPDATE_STATS),
  53. __stringify(IPA_TETHERING_STATS_UPDATE_NETWORK_STATS),
  54. __stringify(IPA_QUOTA_REACH),
  55. __stringify(IPA_SSR_BEFORE_SHUTDOWN),
  56. __stringify(IPA_SSR_AFTER_POWERUP),
  57. __stringify(ADD_VLAN_IFACE),
  58. __stringify(DEL_VLAN_IFACE),
  59. __stringify(ADD_L2TP_VLAN_MAPPING),
  60. __stringify(DEL_L2TP_VLAN_MAPPING),
  61. __stringify(IPA_PER_CLIENT_STATS_CONNECT_EVENT),
  62. __stringify(IPA_PER_CLIENT_STATS_DISCONNECT_EVENT),
  63. __stringify(ADD_BRIDGE_VLAN_MAPPING),
  64. __stringify(DEL_BRIDGE_VLAN_MAPPING),
  65. __stringify(WLAN_FWR_SSR_BEFORE_SHUTDOWN),
  66. __stringify(IPA_GSB_CONNECT),
  67. __stringify(IPA_GSB_DISCONNECT),
  68. __stringify(IPA_COALESCE_ENABLE),
  69. __stringify(IPA_COALESCE_DISABLE),
  70. __stringify_1(WIGIG_CLIENT_CONNECT),
  71. __stringify_1(WIGIG_FST_SWITCH),
  72. };
  73. const char *ipa3_hdr_l2_type_name[] = {
  74. __stringify(IPA_HDR_L2_NONE),
  75. __stringify(IPA_HDR_L2_ETHERNET_II),
  76. __stringify(IPA_HDR_L2_802_3),
  77. __stringify(IPA_HDR_L2_802_1Q),
  78. };
  79. const char *ipa3_hdr_proc_type_name[] = {
  80. __stringify(IPA_HDR_PROC_NONE),
  81. __stringify(IPA_HDR_PROC_ETHII_TO_ETHII),
  82. __stringify(IPA_HDR_PROC_ETHII_TO_802_3),
  83. __stringify(IPA_HDR_PROC_802_3_TO_ETHII),
  84. __stringify(IPA_HDR_PROC_802_3_TO_802_3),
  85. __stringify(IPA_HDR_PROC_L2TP_HEADER_ADD),
  86. __stringify(IPA_HDR_PROC_L2TP_HEADER_REMOVE),
  87. __stringify(IPA_HDR_PROC_ETHII_TO_ETHII_EX),
  88. };
  89. static struct dentry *dent;
  90. static char dbg_buff[IPA_MAX_MSG_LEN + 1];
  91. static char *active_clients_buf;
  92. static s8 ep_reg_idx;
  93. static void *ipa_ipc_low_buff;
  94. static ssize_t ipa3_read_gen_reg(struct file *file, char __user *ubuf,
  95. size_t count, loff_t *ppos)
  96. {
  97. int nbytes;
  98. struct ipahal_reg_shared_mem_size smem_sz;
  99. memset(&smem_sz, 0, sizeof(smem_sz));
  100. IPA_ACTIVE_CLIENTS_INC_SIMPLE();
  101. ipahal_read_reg_fields(IPA_SHARED_MEM_SIZE, &smem_sz);
  102. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  103. "IPA_VERSION=0x%x\n"
  104. "IPA_COMP_HW_VERSION=0x%x\n"
  105. "IPA_ROUTE=0x%x\n"
  106. "IPA_SHARED_MEM_RESTRICTED=0x%x\n"
  107. "IPA_SHARED_MEM_SIZE=0x%x\n"
  108. "IPA_QTIME_TIMESTAMP_CFG=0x%x\n"
  109. "IPA_TIMERS_PULSE_GRAN_CFG=0x%x\n"
  110. "IPA_TIMERS_XO_CLK_DIV_CFG=0x%x\n",
  111. ipahal_read_reg(IPA_VERSION),
  112. ipahal_read_reg(IPA_COMP_HW_VERSION),
  113. ipahal_read_reg(IPA_ROUTE),
  114. smem_sz.shared_mem_baddr,
  115. smem_sz.shared_mem_sz,
  116. ipahal_read_reg(IPA_QTIME_TIMESTAMP_CFG),
  117. ipahal_read_reg(IPA_TIMERS_PULSE_GRAN_CFG),
  118. ipahal_read_reg(IPA_TIMERS_XO_CLK_DIV_CFG));
  119. IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
  120. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, nbytes);
  121. }
  122. static ssize_t ipa3_write_ep_holb(struct file *file,
  123. const char __user *buf, size_t count, loff_t *ppos)
  124. {
  125. struct ipa_ep_cfg_holb holb;
  126. u32 en;
  127. u32 tmr_val;
  128. u32 ep_idx;
  129. unsigned long missing;
  130. char *sptr, *token;
  131. if (count >= sizeof(dbg_buff))
  132. return -EFAULT;
  133. missing = copy_from_user(dbg_buff, buf, count);
  134. if (missing)
  135. return -EFAULT;
  136. dbg_buff[count] = '\0';
  137. sptr = dbg_buff;
  138. token = strsep(&sptr, " ");
  139. if (!token)
  140. return -EINVAL;
  141. if (kstrtou32(token, 0, &ep_idx))
  142. return -EINVAL;
  143. token = strsep(&sptr, " ");
  144. if (!token)
  145. return -EINVAL;
  146. if (kstrtou32(token, 0, &en))
  147. return -EINVAL;
  148. token = strsep(&sptr, " ");
  149. if (!token)
  150. return -EINVAL;
  151. if (kstrtou32(token, 0, &tmr_val))
  152. return -EINVAL;
  153. holb.en = en;
  154. holb.tmr_val = tmr_val;
  155. ipa3_cfg_ep_holb(ep_idx, &holb);
  156. return count;
  157. }
  158. static ssize_t ipa3_write_ep_reg(struct file *file, const char __user *buf,
  159. size_t count, loff_t *ppos)
  160. {
  161. s8 option;
  162. int ret;
  163. ret = kstrtos8_from_user(buf, count, 0, &option);
  164. if (ret)
  165. return ret;
  166. if (option >= ipa3_ctx->ipa_num_pipes) {
  167. IPAERR("bad pipe specified %u\n", option);
  168. return count;
  169. }
  170. ep_reg_idx = option;
  171. return count;
  172. }
  173. /**
  174. * _ipa_read_ep_reg_v3_0() - Reads and prints endpoint configuration registers
  175. *
  176. * Returns the number of characters printed
  177. */
  178. int _ipa_read_ep_reg_v3_0(char *buf, int max_len, int pipe)
  179. {
  180. return scnprintf(
  181. dbg_buff, IPA_MAX_MSG_LEN,
  182. "IPA_ENDP_INIT_NAT_%u=0x%x\n"
  183. "IPA_ENDP_INIT_HDR_%u=0x%x\n"
  184. "IPA_ENDP_INIT_HDR_EXT_%u=0x%x\n"
  185. "IPA_ENDP_INIT_MODE_%u=0x%x\n"
  186. "IPA_ENDP_INIT_AGGR_%u=0x%x\n"
  187. "IPA_ENDP_INIT_ROUTE_%u=0x%x\n"
  188. "IPA_ENDP_INIT_CTRL_%u=0x%x\n"
  189. "IPA_ENDP_INIT_HOL_EN_%u=0x%x\n"
  190. "IPA_ENDP_INIT_HOL_TIMER_%u=0x%x\n"
  191. "IPA_ENDP_INIT_DEAGGR_%u=0x%x\n"
  192. "IPA_ENDP_INIT_CFG_%u=0x%x\n",
  193. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_NAT_n, pipe),
  194. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_HDR_n, pipe),
  195. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_HDR_EXT_n, pipe),
  196. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_MODE_n, pipe),
  197. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_AGGR_n, pipe),
  198. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_ROUTE_n, pipe),
  199. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_CTRL_n, pipe),
  200. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_HOL_BLOCK_EN_n, pipe),
  201. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_HOL_BLOCK_TIMER_n, pipe),
  202. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_DEAGGR_n, pipe),
  203. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_CFG_n, pipe));
  204. }
  205. /**
  206. * _ipa_read_ep_reg_v4_0() - Reads and prints endpoint configuration registers
  207. *
  208. * Returns the number of characters printed
  209. * Removed IPA_ENDP_INIT_ROUTE_n from v3
  210. */
  211. int _ipa_read_ep_reg_v4_0(char *buf, int max_len, int pipe)
  212. {
  213. return scnprintf(
  214. dbg_buff, IPA_MAX_MSG_LEN,
  215. "IPA_ENDP_INIT_NAT_%u=0x%x\n"
  216. "IPA_ENDP_INIT_CONN_TRACK_n%u=0x%x\n"
  217. "IPA_ENDP_INIT_HDR_%u=0x%x\n"
  218. "IPA_ENDP_INIT_HDR_EXT_%u=0x%x\n"
  219. "IPA_ENDP_INIT_MODE_%u=0x%x\n"
  220. "IPA_ENDP_INIT_AGGR_%u=0x%x\n"
  221. "IPA_ENDP_INIT_CTRL_%u=0x%x\n"
  222. "IPA_ENDP_INIT_HOL_EN_%u=0x%x\n"
  223. "IPA_ENDP_INIT_HOL_TIMER_%u=0x%x\n"
  224. "IPA_ENDP_INIT_DEAGGR_%u=0x%x\n"
  225. "IPA_ENDP_INIT_CFG_%u=0x%x\n",
  226. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_NAT_n, pipe),
  227. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_CONN_TRACK_n, pipe),
  228. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_HDR_n, pipe),
  229. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_HDR_EXT_n, pipe),
  230. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_MODE_n, pipe),
  231. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_AGGR_n, pipe),
  232. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_CTRL_n, pipe),
  233. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_HOL_BLOCK_EN_n, pipe),
  234. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_HOL_BLOCK_TIMER_n, pipe),
  235. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_DEAGGR_n, pipe),
  236. pipe, ipahal_read_reg_n(IPA_ENDP_INIT_CFG_n, pipe));
  237. }
  238. static ssize_t ipa3_read_ep_reg(struct file *file, char __user *ubuf,
  239. size_t count, loff_t *ppos)
  240. {
  241. int nbytes;
  242. int i;
  243. int start_idx;
  244. int end_idx;
  245. int size = 0;
  246. int ret;
  247. loff_t pos;
  248. /* negative ep_reg_idx means all registers */
  249. if (ep_reg_idx < 0) {
  250. start_idx = 0;
  251. end_idx = ipa3_ctx->ipa_num_pipes;
  252. } else {
  253. start_idx = ep_reg_idx;
  254. end_idx = start_idx + 1;
  255. }
  256. pos = *ppos;
  257. IPA_ACTIVE_CLIENTS_INC_SIMPLE();
  258. for (i = start_idx; i < end_idx; i++) {
  259. nbytes = ipa3_ctx->ctrl->ipa3_read_ep_reg(dbg_buff,
  260. IPA_MAX_MSG_LEN, i);
  261. *ppos = pos;
  262. ret = simple_read_from_buffer(ubuf, count, ppos, dbg_buff,
  263. nbytes);
  264. if (ret < 0) {
  265. IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
  266. return ret;
  267. }
  268. size += ret;
  269. ubuf += nbytes;
  270. count -= nbytes;
  271. }
  272. IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
  273. *ppos = pos + size;
  274. return size;
  275. }
  276. static ssize_t ipa3_write_keep_awake(struct file *file, const char __user *buf,
  277. size_t count, loff_t *ppos)
  278. {
  279. s8 option = 0;
  280. int ret;
  281. uint32_t bw_mbps = 0;
  282. ret = kstrtos8_from_user(buf, count, 0, &option);
  283. if (ret)
  284. return ret;
  285. switch (option) {
  286. case 0:
  287. IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
  288. bw_mbps = 0;
  289. break;
  290. case 1:
  291. IPA_ACTIVE_CLIENTS_INC_SIMPLE();
  292. bw_mbps = 0;
  293. break;
  294. case 2:
  295. IPA_ACTIVE_CLIENTS_INC_SIMPLE();
  296. bw_mbps = 700;
  297. break;
  298. case 3:
  299. IPA_ACTIVE_CLIENTS_INC_SIMPLE();
  300. bw_mbps = 3000;
  301. break;
  302. case 4:
  303. IPA_ACTIVE_CLIENTS_INC_SIMPLE();
  304. bw_mbps = 7000;
  305. break;
  306. default:
  307. pr_err("Not support this vote (%d)\n", option);
  308. return -EFAULT;
  309. }
  310. if (ipa3_vote_for_bus_bw(&bw_mbps)) {
  311. IPAERR("Failed to vote for bus BW (%u)\n", bw_mbps);
  312. return -EFAULT;
  313. }
  314. return count;
  315. }
  316. static ssize_t ipa3_read_keep_awake(struct file *file, char __user *ubuf,
  317. size_t count, loff_t *ppos)
  318. {
  319. int nbytes;
  320. mutex_lock(&ipa3_ctx->ipa3_active_clients.mutex);
  321. if (atomic_read(&ipa3_ctx->ipa3_active_clients.cnt))
  322. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  323. "IPA APPS power state is ON\n");
  324. else
  325. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  326. "IPA APPS power state is OFF\n");
  327. mutex_unlock(&ipa3_ctx->ipa3_active_clients.mutex);
  328. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, nbytes);
  329. }
  330. static ssize_t ipa3_read_hdr(struct file *file, char __user *ubuf, size_t count,
  331. loff_t *ppos)
  332. {
  333. int nbytes = 0;
  334. int i = 0;
  335. struct ipa3_hdr_entry *entry;
  336. mutex_lock(&ipa3_ctx->lock);
  337. if (ipa3_ctx->hdr_tbl_lcl)
  338. pr_err("Table resides on local memory\n");
  339. else
  340. pr_err("Table resides on system (ddr) memory\n");
  341. list_for_each_entry(entry, &ipa3_ctx->hdr_tbl.head_hdr_entry_list,
  342. link) {
  343. if (entry->cookie != IPA_HDR_COOKIE)
  344. continue;
  345. nbytes += scnprintf(
  346. dbg_buff + nbytes,
  347. IPA_MAX_MSG_LEN - nbytes,
  348. "name:%s len=%d ref=%d partial=%d type=%s ",
  349. entry->name,
  350. entry->hdr_len,
  351. entry->ref_cnt,
  352. entry->is_partial,
  353. ipa3_hdr_l2_type_name[entry->type]);
  354. if (entry->is_hdr_proc_ctx) {
  355. nbytes += scnprintf(
  356. dbg_buff + nbytes,
  357. IPA_MAX_MSG_LEN - nbytes,
  358. "phys_base=0x%pa ",
  359. &entry->phys_base);
  360. } else {
  361. nbytes += scnprintf(
  362. dbg_buff + nbytes,
  363. IPA_MAX_MSG_LEN - nbytes,
  364. "ofst=%u ",
  365. entry->offset_entry->offset >> 2);
  366. }
  367. for (i = 0; i < entry->hdr_len; i++) {
  368. nbytes += scnprintf(
  369. dbg_buff + nbytes,
  370. IPA_MAX_MSG_LEN - nbytes,
  371. "%02x", entry->hdr[i]);
  372. }
  373. nbytes += scnprintf(
  374. dbg_buff + nbytes,
  375. IPA_MAX_MSG_LEN - nbytes,
  376. "\n");
  377. }
  378. mutex_unlock(&ipa3_ctx->lock);
  379. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, nbytes);
  380. }
  381. static int ipa3_attrib_dump(struct ipa_rule_attrib *attrib,
  382. enum ipa_ip_type ip, int nbytes)
  383. {
  384. uint32_t addr[4];
  385. uint32_t mask[4];
  386. int i;
  387. if (attrib->attrib_mask & IPA_FLT_IS_PURE_ACK)
  388. nbytes += scnprintf(
  389. dbg_buff + nbytes,
  390. IPA_MAX_MSG_LEN - nbytes,
  391. "is_pure_ack ");
  392. if (attrib->attrib_mask & IPA_FLT_TOS)
  393. nbytes += scnprintf(
  394. dbg_buff + nbytes,
  395. IPA_MAX_MSG_LEN - nbytes,
  396. "tos:%d ", attrib->u.v4.tos);
  397. if (attrib->attrib_mask & IPA_FLT_TOS_MASKED) {
  398. nbytes += scnprintf(
  399. dbg_buff + nbytes,
  400. IPA_MAX_MSG_LEN - nbytes,
  401. "tos_value:%d ", attrib->tos_value);
  402. nbytes += scnprintf(
  403. dbg_buff + nbytes,
  404. IPA_MAX_MSG_LEN - nbytes,
  405. "tos_mask:%d ", attrib->tos_mask);
  406. }
  407. if (attrib->attrib_mask & IPA_FLT_PROTOCOL)
  408. nbytes += scnprintf(
  409. dbg_buff + nbytes,
  410. IPA_MAX_MSG_LEN - nbytes,
  411. "protocol:%d ", attrib->u.v4.protocol);
  412. if (attrib->attrib_mask & IPA_FLT_SRC_ADDR) {
  413. if (ip == IPA_IP_v4) {
  414. addr[0] = htonl(attrib->u.v4.src_addr);
  415. mask[0] = htonl(attrib->u.v4.src_addr_mask);
  416. nbytes += scnprintf(
  417. dbg_buff + nbytes,
  418. IPA_MAX_MSG_LEN - nbytes,
  419. "src_addr:%pI4 src_addr_mask:%pI4 ",
  420. addr + 0, mask + 0);
  421. } else if (ip == IPA_IP_v6) {
  422. for (i = 0; i < 4; i++) {
  423. addr[i] = htonl(attrib->u.v6.src_addr[i]);
  424. mask[i] = htonl(attrib->u.v6.src_addr_mask[i]);
  425. }
  426. nbytes += scnprintf(
  427. dbg_buff + nbytes,
  428. IPA_MAX_MSG_LEN - nbytes,
  429. "src_addr:%pI6 src_addr_mask:%pI6 ",
  430. addr + 0, mask + 0);
  431. }
  432. }
  433. if (attrib->attrib_mask & IPA_FLT_DST_ADDR) {
  434. if (ip == IPA_IP_v4) {
  435. addr[0] = htonl(attrib->u.v4.dst_addr);
  436. mask[0] = htonl(attrib->u.v4.dst_addr_mask);
  437. nbytes += scnprintf(
  438. dbg_buff + nbytes,
  439. IPA_MAX_MSG_LEN - nbytes,
  440. "dst_addr:%pI4 dst_addr_mask:%pI4 ",
  441. addr + 0, mask + 0);
  442. } else if (ip == IPA_IP_v6) {
  443. for (i = 0; i < 4; i++) {
  444. addr[i] = htonl(attrib->u.v6.dst_addr[i]);
  445. mask[i] = htonl(attrib->u.v6.dst_addr_mask[i]);
  446. }
  447. nbytes += scnprintf(
  448. dbg_buff + nbytes,
  449. IPA_MAX_MSG_LEN - nbytes,
  450. "dst_addr:%pI6 dst_addr_mask:%pI6 ",
  451. addr + 0, mask + 0);
  452. }
  453. }
  454. if (attrib->attrib_mask & IPA_FLT_SRC_PORT_RANGE)
  455. nbytes += scnprintf(
  456. dbg_buff + nbytes,
  457. IPA_MAX_MSG_LEN - nbytes,
  458. "src_port_range:%u %u ",
  459. attrib->src_port_lo,
  460. attrib->src_port_hi);
  461. if (attrib->attrib_mask & IPA_FLT_DST_PORT_RANGE)
  462. nbytes += scnprintf(
  463. dbg_buff + nbytes,
  464. IPA_MAX_MSG_LEN - nbytes,
  465. "dst_port_range:%u %u ",
  466. attrib->dst_port_lo,
  467. attrib->dst_port_hi);
  468. if (attrib->attrib_mask & IPA_FLT_TYPE)
  469. nbytes += scnprintf(
  470. dbg_buff + nbytes,
  471. IPA_MAX_MSG_LEN - nbytes,
  472. "type:%d ", attrib->type);
  473. if (attrib->attrib_mask & IPA_FLT_CODE)
  474. nbytes += scnprintf(
  475. dbg_buff + nbytes,
  476. IPA_MAX_MSG_LEN - nbytes,
  477. "code:%d ", attrib->code);
  478. if (attrib->attrib_mask & IPA_FLT_SPI)
  479. nbytes += scnprintf(
  480. dbg_buff + nbytes,
  481. IPA_MAX_MSG_LEN - nbytes,
  482. "spi:%x ", attrib->spi);
  483. if (attrib->attrib_mask & IPA_FLT_SRC_PORT)
  484. nbytes += scnprintf(
  485. dbg_buff + nbytes,
  486. IPA_MAX_MSG_LEN - nbytes,
  487. "src_port:%u ", attrib->src_port);
  488. if (attrib->attrib_mask & IPA_FLT_DST_PORT)
  489. nbytes += scnprintf(
  490. dbg_buff + nbytes,
  491. IPA_MAX_MSG_LEN - nbytes,
  492. "dst_port:%u ", attrib->dst_port);
  493. if (attrib->attrib_mask & IPA_FLT_TC)
  494. nbytes += scnprintf(
  495. dbg_buff + nbytes,
  496. IPA_MAX_MSG_LEN - nbytes,
  497. "tc:%d ", attrib->u.v6.tc);
  498. if (attrib->attrib_mask & IPA_FLT_FLOW_LABEL)
  499. nbytes += scnprintf(
  500. dbg_buff + nbytes,
  501. IPA_MAX_MSG_LEN - nbytes,
  502. "flow_label:%x ",
  503. attrib->u.v6.flow_label);
  504. if (attrib->attrib_mask & IPA_FLT_NEXT_HDR)
  505. nbytes += scnprintf(
  506. dbg_buff + nbytes,
  507. IPA_MAX_MSG_LEN - nbytes,
  508. "next_hdr:%d ",
  509. attrib->u.v6.next_hdr);
  510. if (attrib->attrib_mask & IPA_FLT_META_DATA)
  511. nbytes += scnprintf(
  512. dbg_buff + nbytes,
  513. IPA_MAX_MSG_LEN - nbytes,
  514. "metadata:%x metadata_mask:%x ",
  515. attrib->meta_data,
  516. attrib->meta_data_mask);
  517. if (attrib->attrib_mask & IPA_FLT_FRAGMENT)
  518. nbytes += scnprintf(
  519. dbg_buff + nbytes,
  520. IPA_MAX_MSG_LEN - nbytes,
  521. "frg ");
  522. if ((attrib->attrib_mask & IPA_FLT_MAC_SRC_ADDR_ETHER_II) ||
  523. (attrib->attrib_mask & IPA_FLT_MAC_SRC_ADDR_802_3) ||
  524. (attrib->attrib_mask & IPA_FLT_MAC_SRC_ADDR_802_1Q))
  525. nbytes += scnprintf(
  526. dbg_buff + nbytes,
  527. IPA_MAX_MSG_LEN - nbytes,
  528. "src_mac_addr:%pM ",
  529. attrib->src_mac_addr);
  530. if ((attrib->attrib_mask & IPA_FLT_MAC_DST_ADDR_ETHER_II) ||
  531. (attrib->attrib_mask & IPA_FLT_MAC_DST_ADDR_802_3) ||
  532. (attrib->attrib_mask & IPA_FLT_MAC_DST_ADDR_L2TP) ||
  533. (attrib->attrib_mask & IPA_FLT_MAC_DST_ADDR_802_1Q))
  534. nbytes += scnprintf(
  535. dbg_buff + nbytes,
  536. IPA_MAX_MSG_LEN - nbytes,
  537. "dst_mac_addr:%pM ",
  538. attrib->dst_mac_addr);
  539. if (attrib->attrib_mask & IPA_FLT_MAC_ETHER_TYPE)
  540. nbytes += scnprintf(
  541. dbg_buff + nbytes,
  542. IPA_MAX_MSG_LEN - nbytes,
  543. "ether_type:%x ",
  544. attrib->ether_type);
  545. if (attrib->attrib_mask & IPA_FLT_VLAN_ID)
  546. nbytes += scnprintf(
  547. dbg_buff + nbytes,
  548. IPA_MAX_MSG_LEN - nbytes,
  549. "vlan_id:%x ",
  550. attrib->vlan_id);
  551. if (attrib->attrib_mask & IPA_FLT_TCP_SYN)
  552. nbytes += scnprintf(
  553. dbg_buff + nbytes,
  554. IPA_MAX_MSG_LEN - nbytes,
  555. "tcp syn ");
  556. if (attrib->attrib_mask & IPA_FLT_TCP_SYN_L2TP)
  557. nbytes += scnprintf(
  558. dbg_buff + nbytes,
  559. IPA_MAX_MSG_LEN - nbytes,
  560. "tcp syn l2tp ");
  561. if (attrib->attrib_mask & IPA_FLT_L2TP_INNER_IP_TYPE)
  562. nbytes += scnprintf(
  563. dbg_buff + nbytes,
  564. IPA_MAX_MSG_LEN - nbytes,
  565. "l2tp inner ip type: %d ",
  566. attrib->type);
  567. if (attrib->attrib_mask & IPA_FLT_L2TP_INNER_IPV4_DST_ADDR) {
  568. addr[0] = htonl(attrib->u.v4.dst_addr);
  569. mask[0] = htonl(attrib->u.v4.dst_addr_mask);
  570. nbytes += scnprintf(
  571. dbg_buff + nbytes,
  572. IPA_MAX_MSG_LEN - nbytes,
  573. "dst_addr:%pI4 dst_addr_mask:%pI4 ",
  574. addr, mask);
  575. }
  576. nbytes += scnprintf(
  577. dbg_buff + nbytes,
  578. IPA_MAX_MSG_LEN - nbytes,
  579. "\n");
  580. return 0;
  581. }
  582. static int ipa3_attrib_dump_eq(struct ipa_ipfltri_rule_eq *attrib,
  583. int nbytes)
  584. {
  585. uint8_t addr[16];
  586. uint8_t mask[16];
  587. int i;
  588. int j;
  589. if (attrib->tos_eq_present) {
  590. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_5)
  591. nbytes += scnprintf(
  592. dbg_buff + nbytes,
  593. IPA_MAX_MSG_LEN - nbytes,
  594. "pure_ack ");
  595. else
  596. nbytes += scnprintf(
  597. dbg_buff + nbytes,
  598. IPA_MAX_MSG_LEN - nbytes,
  599. "tos:%d ",
  600. attrib->tos_eq);
  601. }
  602. if (attrib->protocol_eq_present)
  603. nbytes += scnprintf(
  604. dbg_buff + nbytes,
  605. IPA_MAX_MSG_LEN - nbytes,
  606. "protocol:%d ",
  607. attrib->protocol_eq);
  608. if (attrib->tc_eq_present)
  609. nbytes += scnprintf(
  610. dbg_buff + nbytes,
  611. IPA_MAX_MSG_LEN - nbytes,
  612. "tc:%d ", attrib->tc_eq);
  613. if (attrib->num_offset_meq_128 > IPA_IPFLTR_NUM_MEQ_128_EQNS) {
  614. IPAERR_RL("num_offset_meq_128 Max %d passed value %d\n",
  615. IPA_IPFLTR_NUM_MEQ_128_EQNS, attrib->num_offset_meq_128);
  616. return -EPERM;
  617. }
  618. for (i = 0; i < attrib->num_offset_meq_128; i++) {
  619. for (j = 0; j < 16; j++) {
  620. addr[j] = attrib->offset_meq_128[i].value[j];
  621. mask[j] = attrib->offset_meq_128[i].mask[j];
  622. }
  623. nbytes += scnprintf(
  624. dbg_buff + nbytes,
  625. IPA_MAX_MSG_LEN - nbytes,
  626. "(ofst_meq128: ofst:%d mask:%pI6 val:%pI6) ",
  627. attrib->offset_meq_128[i].offset,
  628. mask, addr);
  629. }
  630. if (attrib->num_offset_meq_32 > IPA_IPFLTR_NUM_MEQ_32_EQNS) {
  631. IPAERR_RL("num_offset_meq_32 Max %d passed value %d\n",
  632. IPA_IPFLTR_NUM_MEQ_32_EQNS, attrib->num_offset_meq_32);
  633. return -EPERM;
  634. }
  635. for (i = 0; i < attrib->num_offset_meq_32; i++)
  636. nbytes += scnprintf(
  637. dbg_buff + nbytes,
  638. IPA_MAX_MSG_LEN - nbytes,
  639. "(ofst_meq32: ofst:%u mask:0x%x val:0x%x) ",
  640. attrib->offset_meq_32[i].offset,
  641. attrib->offset_meq_32[i].mask,
  642. attrib->offset_meq_32[i].value);
  643. if (attrib->num_ihl_offset_meq_32 > IPA_IPFLTR_NUM_IHL_MEQ_32_EQNS) {
  644. IPAERR_RL("num_ihl_offset_meq_32 Max %d passed value %d\n",
  645. IPA_IPFLTR_NUM_IHL_MEQ_32_EQNS, attrib->num_ihl_offset_meq_32);
  646. return -EPERM;
  647. }
  648. for (i = 0; i < attrib->num_ihl_offset_meq_32; i++)
  649. nbytes += scnprintf(
  650. dbg_buff + nbytes,
  651. IPA_MAX_MSG_LEN - nbytes,
  652. "(ihl_ofst_meq32: ofts:%d mask:0x%x val:0x%x) ",
  653. attrib->ihl_offset_meq_32[i].offset,
  654. attrib->ihl_offset_meq_32[i].mask,
  655. attrib->ihl_offset_meq_32[i].value);
  656. if (attrib->metadata_meq32_present)
  657. nbytes += scnprintf(
  658. dbg_buff + nbytes,
  659. IPA_MAX_MSG_LEN - nbytes,
  660. "(metadata: ofst:%u mask:0x%x val:0x%x) ",
  661. attrib->metadata_meq32.offset,
  662. attrib->metadata_meq32.mask,
  663. attrib->metadata_meq32.value);
  664. if (attrib->num_ihl_offset_range_16 >
  665. IPA_IPFLTR_NUM_IHL_RANGE_16_EQNS) {
  666. IPAERR_RL("num_ihl_offset_range_16 Max %d passed value %d\n",
  667. IPA_IPFLTR_NUM_IHL_RANGE_16_EQNS,
  668. attrib->num_ihl_offset_range_16);
  669. return -EPERM;
  670. }
  671. for (i = 0; i < attrib->num_ihl_offset_range_16; i++)
  672. nbytes += scnprintf(
  673. dbg_buff + nbytes,
  674. IPA_MAX_MSG_LEN - nbytes,
  675. "(ihl_ofst_range16: ofst:%u lo:%u hi:%u) ",
  676. attrib->ihl_offset_range_16[i].offset,
  677. attrib->ihl_offset_range_16[i].range_low,
  678. attrib->ihl_offset_range_16[i].range_high);
  679. if (attrib->ihl_offset_eq_32_present)
  680. nbytes += scnprintf(
  681. dbg_buff + nbytes,
  682. IPA_MAX_MSG_LEN - nbytes,
  683. "(ihl_ofst_eq32:%d val:0x%x) ",
  684. attrib->ihl_offset_eq_32.offset,
  685. attrib->ihl_offset_eq_32.value);
  686. if (attrib->ihl_offset_eq_16_present)
  687. nbytes += scnprintf(
  688. dbg_buff + nbytes,
  689. IPA_MAX_MSG_LEN - nbytes,
  690. "(ihl_ofst_eq16:%d val:0x%x) ",
  691. attrib->ihl_offset_eq_16.offset,
  692. attrib->ihl_offset_eq_16.value);
  693. if (attrib->fl_eq_present)
  694. nbytes += scnprintf(
  695. dbg_buff + nbytes,
  696. IPA_MAX_MSG_LEN - nbytes,
  697. "flow_label:%d ", attrib->fl_eq);
  698. if (attrib->ipv4_frag_eq_present)
  699. nbytes += scnprintf(
  700. dbg_buff + nbytes,
  701. IPA_MAX_MSG_LEN - nbytes,
  702. "frag ");
  703. nbytes += scnprintf(
  704. dbg_buff + nbytes,
  705. IPA_MAX_MSG_LEN - nbytes,
  706. "\n");
  707. return 0;
  708. }
  709. static int ipa3_open_dbg(struct inode *inode, struct file *file)
  710. {
  711. file->private_data = inode->i_private;
  712. return 0;
  713. }
  714. static ssize_t ipa3_read_rt(struct file *file, char __user *ubuf, size_t count,
  715. loff_t *ppos)
  716. {
  717. int i = 0;
  718. struct ipa3_rt_tbl *tbl;
  719. struct ipa3_rt_entry *entry;
  720. struct ipa3_rt_tbl_set *set;
  721. enum ipa_ip_type ip = (enum ipa_ip_type)file->private_data;
  722. u32 ofst;
  723. u32 ofst_words;
  724. int nbytes = 0;
  725. set = &ipa3_ctx->rt_tbl_set[ip];
  726. mutex_lock(&ipa3_ctx->lock);
  727. if (ip == IPA_IP_v6) {
  728. if (ipa3_ctx->ip6_rt_tbl_hash_lcl)
  729. pr_err("Hashable table resides on local memory\n");
  730. else
  731. pr_err("Hashable table resides on system (ddr) memory\n");
  732. if (ipa3_ctx->ip6_rt_tbl_nhash_lcl)
  733. pr_err("Non-Hashable table resides on local memory\n");
  734. else
  735. pr_err("Non-Hashable table resides on system (ddr) memory\n");
  736. } else if (ip == IPA_IP_v4) {
  737. if (ipa3_ctx->ip4_rt_tbl_hash_lcl)
  738. pr_err("Hashable table resides on local memory\n");
  739. else
  740. pr_err("Hashable table resides on system (ddr) memory\n");
  741. if (ipa3_ctx->ip4_rt_tbl_nhash_lcl)
  742. pr_err("Non-Hashable table resides on local memory\n");
  743. else
  744. pr_err("Non-Hashable table resides on system (ddr) memory\n");
  745. }
  746. list_for_each_entry(tbl, &set->head_rt_tbl_list, link) {
  747. i = 0;
  748. list_for_each_entry(entry, &tbl->head_rt_rule_list, link) {
  749. if (entry->proc_ctx) {
  750. ofst = entry->proc_ctx->offset_entry->offset;
  751. ofst_words =
  752. (ofst +
  753. ipa3_ctx->hdr_proc_ctx_tbl.start_offset)
  754. >> 5;
  755. nbytes += scnprintf(
  756. dbg_buff + nbytes,
  757. IPA_MAX_MSG_LEN - nbytes,
  758. "tbl_idx:%d tbl_name:%s tbl_ref:%u ",
  759. entry->tbl->idx, entry->tbl->name,
  760. entry->tbl->ref_cnt);
  761. nbytes += scnprintf(
  762. dbg_buff + nbytes,
  763. IPA_MAX_MSG_LEN - nbytes,
  764. "rule_idx:%d dst:%d ep:%d S:%u ",
  765. i, entry->rule.dst,
  766. ipa3_get_ep_mapping(entry->rule.dst),
  767. !ipa3_ctx->hdr_proc_ctx_tbl_lcl);
  768. nbytes += scnprintf(
  769. dbg_buff + nbytes,
  770. IPA_MAX_MSG_LEN - nbytes,
  771. "proc_ctx[32B]:%u attrib_mask:%08x ",
  772. ofst_words,
  773. entry->rule.attrib.attrib_mask);
  774. nbytes += scnprintf(
  775. dbg_buff + nbytes,
  776. IPA_MAX_MSG_LEN - nbytes,
  777. "rule_id:%u max_prio:%u prio:%u ",
  778. entry->rule_id, entry->rule.max_prio,
  779. entry->prio);
  780. nbytes += scnprintf(
  781. dbg_buff + nbytes,
  782. IPA_MAX_MSG_LEN - nbytes,
  783. "enable_stats:%u counter_id:%u\n",
  784. entry->rule.enable_stats,
  785. entry->rule.cnt_idx);
  786. nbytes += scnprintf(
  787. dbg_buff + nbytes,
  788. IPA_MAX_MSG_LEN - nbytes,
  789. "hashable:%u retain_hdr:%u ",
  790. entry->rule.hashable,
  791. entry->rule.retain_hdr);
  792. } else {
  793. if (entry->hdr)
  794. ofst = entry->hdr->offset_entry->offset;
  795. else
  796. ofst = 0;
  797. nbytes += scnprintf(
  798. dbg_buff + nbytes,
  799. IPA_MAX_MSG_LEN - nbytes,
  800. "tbl_idx:%d tbl_name:%s tbl_ref:%u ",
  801. entry->tbl->idx, entry->tbl->name,
  802. entry->tbl->ref_cnt);
  803. nbytes += scnprintf(
  804. dbg_buff + nbytes,
  805. IPA_MAX_MSG_LEN - nbytes,
  806. "rule_idx:%d dst:%d ep:%d S:%u ",
  807. i, entry->rule.dst,
  808. ipa3_get_ep_mapping(entry->rule.dst),
  809. !ipa3_ctx->hdr_tbl_lcl);
  810. nbytes += scnprintf(
  811. dbg_buff + nbytes,
  812. IPA_MAX_MSG_LEN - nbytes,
  813. "hdr_ofst[words]:%u attrib_mask:%08x ",
  814. ofst >> 2,
  815. entry->rule.attrib.attrib_mask);
  816. nbytes += scnprintf(
  817. dbg_buff + nbytes,
  818. IPA_MAX_MSG_LEN - nbytes,
  819. "rule_id:%u max_prio:%u prio:%u ",
  820. entry->rule_id, entry->rule.max_prio,
  821. entry->prio);
  822. nbytes += scnprintf(
  823. dbg_buff + nbytes,
  824. IPA_MAX_MSG_LEN - nbytes,
  825. "enable_stats:%u counter_id:%u\n",
  826. entry->rule.enable_stats,
  827. entry->rule.cnt_idx);
  828. nbytes += scnprintf(
  829. dbg_buff + nbytes,
  830. IPA_MAX_MSG_LEN - nbytes,
  831. "hashable:%u retain_hdr:%u ",
  832. entry->rule.hashable,
  833. entry->rule.retain_hdr);
  834. }
  835. ipa3_attrib_dump(&entry->rule.attrib, ip, nbytes);
  836. i++;
  837. }
  838. }
  839. mutex_unlock(&ipa3_ctx->lock);
  840. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, nbytes);
  841. }
  842. static ssize_t ipa3_read_rt_hw(struct file *file, char __user *ubuf,
  843. size_t count, loff_t *ppos)
  844. {
  845. enum ipa_ip_type ip = (enum ipa_ip_type)file->private_data;
  846. int tbls_num;
  847. int rules_num;
  848. int tbl;
  849. int rl;
  850. int res = 0;
  851. struct ipahal_rt_rule_entry *rules = NULL;
  852. int nbytes = 0;
  853. switch (ip) {
  854. case IPA_IP_v4:
  855. tbls_num = IPA_MEM_PART(v4_rt_num_index);
  856. break;
  857. case IPA_IP_v6:
  858. tbls_num = IPA_MEM_PART(v6_rt_num_index);
  859. break;
  860. default:
  861. IPAERR("ip type error %d\n", ip);
  862. return -EINVAL;
  863. }
  864. IPADBG("Tring to parse %d H/W routing tables - IP=%d\n", tbls_num, ip);
  865. rules = kzalloc(sizeof(*rules) * IPA_DBG_MAX_RULE_IN_TBL, GFP_KERNEL);
  866. if (!rules) {
  867. IPAERR("failed to allocate mem for tbl rules\n");
  868. return -ENOMEM;
  869. }
  870. IPA_ACTIVE_CLIENTS_INC_SIMPLE();
  871. mutex_lock(&ipa3_ctx->lock);
  872. for (tbl = 0 ; tbl < tbls_num ; tbl++) {
  873. nbytes += scnprintf(
  874. dbg_buff + nbytes,
  875. IPA_MAX_MSG_LEN - nbytes,
  876. "=== Routing Table %d = Hashable Rules ===\n",
  877. tbl);
  878. rules_num = IPA_DBG_MAX_RULE_IN_TBL;
  879. res = ipa3_rt_read_tbl_from_hw(tbl, ip, true, rules,
  880. &rules_num);
  881. if (res) {
  882. nbytes += scnprintf(
  883. dbg_buff + nbytes,
  884. IPA_MAX_MSG_LEN - nbytes,
  885. "ERROR - Check the logs\n");
  886. IPAERR("failed reading tbl from hw\n");
  887. goto bail;
  888. }
  889. if (!rules_num)
  890. nbytes += scnprintf(
  891. dbg_buff + nbytes,
  892. IPA_MAX_MSG_LEN - nbytes,
  893. "-->No rules. Empty tbl or modem system table\n");
  894. for (rl = 0 ; rl < rules_num ; rl++) {
  895. nbytes += scnprintf(
  896. dbg_buff + nbytes,
  897. IPA_MAX_MSG_LEN - nbytes,
  898. "rule_idx:%d dst ep:%d L:%u ",
  899. rl, rules[rl].dst_pipe_idx, rules[rl].hdr_lcl);
  900. if (rules[rl].hdr_type == IPAHAL_RT_RULE_HDR_PROC_CTX)
  901. nbytes += scnprintf(
  902. dbg_buff + nbytes,
  903. IPA_MAX_MSG_LEN - nbytes,
  904. "proc_ctx:%u attrib_mask:%08x ",
  905. rules[rl].hdr_ofst,
  906. rules[rl].eq_attrib.rule_eq_bitmap);
  907. else
  908. nbytes += scnprintf(
  909. dbg_buff + nbytes,
  910. IPA_MAX_MSG_LEN - nbytes,
  911. "hdr_ofst:%u attrib_mask:%08x ",
  912. rules[rl].hdr_ofst,
  913. rules[rl].eq_attrib.rule_eq_bitmap);
  914. nbytes += scnprintf(
  915. dbg_buff + nbytes,
  916. IPA_MAX_MSG_LEN - nbytes,
  917. "rule_id:%u cnt_id:%hhu prio:%u retain_hdr:%u\n",
  918. rules[rl].id, rules[rl].cnt_idx,
  919. rules[rl].priority, rules[rl].retain_hdr);
  920. res = ipa3_attrib_dump_eq(&rules[rl].eq_attrib, nbytes);
  921. if (res) {
  922. IPAERR_RL("failed read attrib eq\n");
  923. goto bail;
  924. }
  925. }
  926. nbytes += scnprintf(
  927. dbg_buff + nbytes,
  928. IPA_MAX_MSG_LEN - nbytes,
  929. "=== Routing Table %d = Non-Hashable Rules ===\n",
  930. tbl);
  931. rules_num = IPA_DBG_MAX_RULE_IN_TBL;
  932. res = ipa3_rt_read_tbl_from_hw(tbl, ip, false, rules,
  933. &rules_num);
  934. if (res) {
  935. nbytes += scnprintf(
  936. dbg_buff + nbytes,
  937. IPA_MAX_MSG_LEN - nbytes,
  938. "ERROR - Check the logs\n");
  939. IPAERR("failed reading tbl from hw\n");
  940. goto bail;
  941. }
  942. if (!rules_num)
  943. nbytes += scnprintf(
  944. dbg_buff + nbytes,
  945. IPA_MAX_MSG_LEN - nbytes,
  946. "-->No rules. Empty tbl or modem system table\n");
  947. for (rl = 0 ; rl < rules_num ; rl++) {
  948. nbytes += scnprintf(
  949. dbg_buff + nbytes,
  950. IPA_MAX_MSG_LEN - nbytes,
  951. "rule_idx:%d dst ep:%d L:%u ",
  952. rl, rules[rl].dst_pipe_idx,
  953. rules[rl].hdr_lcl);
  954. if (rules[rl].hdr_type == IPAHAL_RT_RULE_HDR_PROC_CTX)
  955. nbytes += scnprintf(
  956. dbg_buff + nbytes,
  957. IPA_MAX_MSG_LEN - nbytes,
  958. "proc_ctx:%u attrib_mask:%08x ",
  959. rules[rl].hdr_ofst,
  960. rules[rl].eq_attrib.rule_eq_bitmap);
  961. else
  962. nbytes += scnprintf(
  963. dbg_buff + nbytes,
  964. IPA_MAX_MSG_LEN - nbytes,
  965. "hdr_ofst:%u attrib_mask:%08x ",
  966. rules[rl].hdr_ofst,
  967. rules[rl].eq_attrib.rule_eq_bitmap);
  968. nbytes += scnprintf(
  969. dbg_buff + nbytes,
  970. IPA_MAX_MSG_LEN - nbytes,
  971. "rule_id:%u cnt_id:%hhu prio:%u retain_hdr:%u\n",
  972. rules[rl].id, rules[rl].cnt_idx,
  973. rules[rl].priority, rules[rl].retain_hdr);
  974. res = ipa3_attrib_dump_eq(&rules[rl].eq_attrib, nbytes);
  975. if (res) {
  976. IPAERR_RL("failed read attrib eq\n");
  977. goto bail;
  978. }
  979. }
  980. nbytes += scnprintf(
  981. dbg_buff + nbytes,
  982. IPA_MAX_MSG_LEN - nbytes,
  983. "\n");
  984. }
  985. bail:
  986. mutex_unlock(&ipa3_ctx->lock);
  987. IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
  988. kfree(rules);
  989. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, nbytes);
  990. }
  991. static ssize_t ipa3_read_proc_ctx(struct file *file, char __user *ubuf,
  992. size_t count, loff_t *ppos)
  993. {
  994. int nbytes = 0;
  995. struct ipa3_hdr_proc_ctx_tbl *tbl;
  996. struct ipa3_hdr_proc_ctx_entry *entry;
  997. u32 ofst_words;
  998. tbl = &ipa3_ctx->hdr_proc_ctx_tbl;
  999. mutex_lock(&ipa3_ctx->lock);
  1000. if (ipa3_ctx->hdr_proc_ctx_tbl_lcl)
  1001. pr_info("Table resides on local memory\n");
  1002. else
  1003. pr_info("Table resides on system(ddr) memory\n");
  1004. list_for_each_entry(entry, &tbl->head_proc_ctx_entry_list, link) {
  1005. ofst_words = (entry->offset_entry->offset +
  1006. ipa3_ctx->hdr_proc_ctx_tbl.start_offset)
  1007. >> 5;
  1008. if (entry->hdr->is_hdr_proc_ctx) {
  1009. nbytes += scnprintf(
  1010. dbg_buff + nbytes,
  1011. IPA_MAX_MSG_LEN - nbytes,
  1012. "id:%u hdr_proc_type:%s proc_ctx[32B]:%u ",
  1013. entry->id,
  1014. ipa3_hdr_proc_type_name[entry->type],
  1015. ofst_words);
  1016. nbytes += scnprintf(
  1017. dbg_buff + nbytes,
  1018. IPA_MAX_MSG_LEN - nbytes,
  1019. "hdr_phys_base:0x%pa\n",
  1020. &entry->hdr->phys_base);
  1021. } else {
  1022. nbytes += scnprintf(
  1023. dbg_buff + nbytes,
  1024. IPA_MAX_MSG_LEN - nbytes,
  1025. "id:%u hdr_proc_type:%s proc_ctx[32B]:%u ",
  1026. entry->id,
  1027. ipa3_hdr_proc_type_name[entry->type],
  1028. ofst_words);
  1029. nbytes += scnprintf(
  1030. dbg_buff + nbytes,
  1031. IPA_MAX_MSG_LEN - nbytes,
  1032. "hdr[words]:%u\n",
  1033. entry->hdr->offset_entry->offset >> 2);
  1034. }
  1035. }
  1036. mutex_unlock(&ipa3_ctx->lock);
  1037. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, nbytes);
  1038. }
  1039. static ssize_t ipa3_read_flt(struct file *file, char __user *ubuf, size_t count,
  1040. loff_t *ppos)
  1041. {
  1042. int i;
  1043. int j;
  1044. struct ipa3_flt_tbl *tbl;
  1045. struct ipa3_flt_entry *entry;
  1046. enum ipa_ip_type ip = (enum ipa_ip_type)file->private_data;
  1047. struct ipa3_rt_tbl *rt_tbl;
  1048. u32 rt_tbl_idx;
  1049. u32 bitmap;
  1050. bool eq;
  1051. int res = 0;
  1052. int nbytes = 0;
  1053. mutex_lock(&ipa3_ctx->lock);
  1054. for (j = 0; j < ipa3_ctx->ipa_num_pipes; j++) {
  1055. if (!ipa_is_ep_support_flt(j))
  1056. continue;
  1057. tbl = &ipa3_ctx->flt_tbl[j][ip];
  1058. i = 0;
  1059. list_for_each_entry(entry, &tbl->head_flt_rule_list, link) {
  1060. if (entry->cookie != IPA_FLT_COOKIE)
  1061. continue;
  1062. if (entry->rule.eq_attrib_type) {
  1063. rt_tbl_idx = entry->rule.rt_tbl_idx;
  1064. bitmap = entry->rule.eq_attrib.rule_eq_bitmap;
  1065. eq = true;
  1066. } else {
  1067. rt_tbl = ipa3_id_find(entry->rule.rt_tbl_hdl);
  1068. if (rt_tbl == NULL ||
  1069. rt_tbl->cookie != IPA_RT_TBL_COOKIE)
  1070. rt_tbl_idx = ~0;
  1071. else
  1072. rt_tbl_idx = rt_tbl->idx;
  1073. bitmap = entry->rule.attrib.attrib_mask;
  1074. eq = false;
  1075. }
  1076. nbytes += scnprintf(
  1077. dbg_buff + nbytes,
  1078. IPA_MAX_MSG_LEN - nbytes,
  1079. "ep_idx:%d rule_idx:%d act:%d rt_tbl_idx:%d ",
  1080. j, i, entry->rule.action, rt_tbl_idx);
  1081. nbytes += scnprintf(
  1082. dbg_buff + nbytes,
  1083. IPA_MAX_MSG_LEN - nbytes,
  1084. "attrib_mask:%08x retain_hdr:%d eq:%d ",
  1085. bitmap, entry->rule.retain_hdr, eq);
  1086. nbytes += scnprintf(
  1087. dbg_buff + nbytes,
  1088. IPA_MAX_MSG_LEN - nbytes,
  1089. "hashable:%u rule_id:%u max_prio:%u prio:%u ",
  1090. entry->rule.hashable, entry->rule_id,
  1091. entry->rule.max_prio, entry->prio);
  1092. nbytes += scnprintf(
  1093. dbg_buff + nbytes,
  1094. IPA_MAX_MSG_LEN - nbytes,
  1095. "enable_stats:%u counter_id:%u\n",
  1096. entry->rule.enable_stats,
  1097. entry->rule.cnt_idx);
  1098. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0)
  1099. nbytes += scnprintf(
  1100. dbg_buff + nbytes,
  1101. IPA_MAX_MSG_LEN - nbytes,
  1102. "pdn index %d, set metadata %d ",
  1103. entry->rule.pdn_idx,
  1104. entry->rule.set_metadata);
  1105. if (eq) {
  1106. res = ipa3_attrib_dump_eq(
  1107. &entry->rule.eq_attrib, nbytes);
  1108. if (res) {
  1109. IPAERR_RL("failed read attrib eq\n");
  1110. goto bail;
  1111. }
  1112. } else
  1113. ipa3_attrib_dump(
  1114. &entry->rule.attrib, ip, nbytes);
  1115. i++;
  1116. nbytes += scnprintf(
  1117. dbg_buff + nbytes,
  1118. IPA_MAX_MSG_LEN - nbytes,
  1119. "\n");
  1120. }
  1121. }
  1122. bail:
  1123. mutex_unlock(&ipa3_ctx->lock);
  1124. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, nbytes);
  1125. }
  1126. static ssize_t ipa3_read_flt_hw(struct file *file, char __user *ubuf,
  1127. size_t count, loff_t *ppos)
  1128. {
  1129. int pipe;
  1130. int rl;
  1131. int rules_num;
  1132. struct ipahal_flt_rule_entry *rules;
  1133. enum ipa_ip_type ip = (enum ipa_ip_type)file->private_data;
  1134. u32 rt_tbl_idx;
  1135. u32 bitmap;
  1136. int res = 0;
  1137. int nbytes = 0;
  1138. IPADBG("Tring to parse %d H/W filtering tables - IP=%d\n",
  1139. ipa3_ctx->ep_flt_num, ip);
  1140. rules = kzalloc(sizeof(*rules) * IPA_DBG_MAX_RULE_IN_TBL, GFP_KERNEL);
  1141. if (!rules)
  1142. return -ENOMEM;
  1143. IPA_ACTIVE_CLIENTS_INC_SIMPLE();
  1144. mutex_lock(&ipa3_ctx->lock);
  1145. for (pipe = 0; pipe < ipa3_ctx->ipa_num_pipes; pipe++) {
  1146. if (!ipa_is_ep_support_flt(pipe))
  1147. continue;
  1148. nbytes += scnprintf(
  1149. dbg_buff + nbytes,
  1150. IPA_MAX_MSG_LEN - nbytes,
  1151. "=== Filtering Table ep:%d = Hashable Rules ===\n",
  1152. pipe);
  1153. rules_num = IPA_DBG_MAX_RULE_IN_TBL;
  1154. res = ipa3_flt_read_tbl_from_hw(pipe, ip, true, rules,
  1155. &rules_num);
  1156. if (res) {
  1157. nbytes += scnprintf(
  1158. dbg_buff + nbytes,
  1159. IPA_MAX_MSG_LEN - nbytes,
  1160. "ERROR - Check the logs\n");
  1161. IPAERR("failed reading tbl from hw\n");
  1162. goto bail;
  1163. }
  1164. if (!rules_num)
  1165. nbytes += scnprintf(
  1166. dbg_buff + nbytes,
  1167. IPA_MAX_MSG_LEN - nbytes,
  1168. "-->No rules. Empty tbl or modem sys table\n");
  1169. for (rl = 0; rl < rules_num; rl++) {
  1170. rt_tbl_idx = rules[rl].rule.rt_tbl_idx;
  1171. bitmap = rules[rl].rule.eq_attrib.rule_eq_bitmap;
  1172. nbytes += scnprintf(
  1173. dbg_buff + nbytes,
  1174. IPA_MAX_MSG_LEN - nbytes,
  1175. "ep_idx:%d rule_idx:%d act:%d rt_tbl_idx:%d ",
  1176. pipe, rl, rules[rl].rule.action, rt_tbl_idx);
  1177. nbytes += scnprintf(
  1178. dbg_buff + nbytes,
  1179. IPA_MAX_MSG_LEN - nbytes,
  1180. "attrib_mask:%08x retain_hdr:%d ",
  1181. bitmap, rules[rl].rule.retain_hdr);
  1182. nbytes += scnprintf(
  1183. dbg_buff + nbytes,
  1184. IPA_MAX_MSG_LEN - nbytes,
  1185. "rule_id:%u cnt_id:%hhu prio:%u\n",
  1186. rules[rl].id, rules[rl].cnt_idx,
  1187. rules[rl].priority);
  1188. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0)
  1189. nbytes += scnprintf(
  1190. dbg_buff + nbytes,
  1191. IPA_MAX_MSG_LEN - nbytes,
  1192. "pdn: %u, set_metadata: %u ",
  1193. rules[rl].rule.pdn_idx,
  1194. rules[rl].rule.set_metadata);
  1195. res = ipa3_attrib_dump_eq(&rules[rl].rule.eq_attrib,
  1196. nbytes);
  1197. if (res) {
  1198. IPAERR_RL("failed read attrib eq\n");
  1199. goto bail;
  1200. }
  1201. }
  1202. nbytes += scnprintf(
  1203. dbg_buff + nbytes,
  1204. IPA_MAX_MSG_LEN - nbytes,
  1205. "=== Filtering Table ep:%d = Non-Hashable Rules ===\n",
  1206. pipe);
  1207. rules_num = IPA_DBG_MAX_RULE_IN_TBL;
  1208. res = ipa3_flt_read_tbl_from_hw(pipe, ip, false, rules,
  1209. &rules_num);
  1210. if (res) {
  1211. IPAERR("failed reading tbl from hw\n");
  1212. goto bail;
  1213. }
  1214. if (!rules_num)
  1215. nbytes += scnprintf(
  1216. dbg_buff + nbytes,
  1217. IPA_MAX_MSG_LEN - nbytes,
  1218. "-->No rules. Empty tbl or modem sys table\n");
  1219. for (rl = 0; rl < rules_num; rl++) {
  1220. rt_tbl_idx = rules[rl].rule.rt_tbl_idx;
  1221. bitmap = rules[rl].rule.eq_attrib.rule_eq_bitmap;
  1222. nbytes += scnprintf(
  1223. dbg_buff + nbytes,
  1224. IPA_MAX_MSG_LEN - nbytes,
  1225. "ep_idx:%d rule_idx:%d act:%d rt_tbl_idx:%d ",
  1226. pipe, rl, rules[rl].rule.action, rt_tbl_idx);
  1227. nbytes += scnprintf(
  1228. dbg_buff + nbytes,
  1229. IPA_MAX_MSG_LEN - nbytes,
  1230. "attrib_mask:%08x retain_hdr:%d ",
  1231. bitmap, rules[rl].rule.retain_hdr);
  1232. nbytes += scnprintf(
  1233. dbg_buff + nbytes,
  1234. IPA_MAX_MSG_LEN - nbytes,
  1235. "rule_id:%u cnt_id:%hhu prio:%u\n",
  1236. rules[rl].id, rules[rl].cnt_idx,
  1237. rules[rl].priority);
  1238. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0)
  1239. nbytes += scnprintf(
  1240. dbg_buff + nbytes,
  1241. IPA_MAX_MSG_LEN - nbytes,
  1242. "pdn: %u, set_metadata: %u ",
  1243. rules[rl].rule.pdn_idx,
  1244. rules[rl].rule.set_metadata);
  1245. res = ipa3_attrib_dump_eq(&rules[rl].rule.eq_attrib,
  1246. nbytes);
  1247. if (res) {
  1248. IPAERR_RL("failed read attrib eq\n");
  1249. goto bail;
  1250. }
  1251. }
  1252. nbytes += scnprintf(
  1253. dbg_buff + nbytes,
  1254. IPA_MAX_MSG_LEN - nbytes,
  1255. "\n");
  1256. }
  1257. bail:
  1258. mutex_unlock(&ipa3_ctx->lock);
  1259. kfree(rules);
  1260. IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
  1261. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, nbytes);
  1262. }
  1263. static ssize_t ipa3_read_stats(struct file *file, char __user *ubuf,
  1264. size_t count, loff_t *ppos)
  1265. {
  1266. int nbytes;
  1267. int i;
  1268. int cnt = 0;
  1269. uint connect = 0;
  1270. for (i = 0; i < ipa3_ctx->ipa_num_pipes; i++)
  1271. connect |= (ipa3_ctx->ep[i].valid << i);
  1272. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  1273. "sw_tx=%u\n"
  1274. "hw_tx=%u\n"
  1275. "tx_non_linear=%u\n"
  1276. "tx_compl=%u\n"
  1277. "wan_rx=%u\n"
  1278. "stat_compl=%u\n"
  1279. "lan_aggr_close=%u\n"
  1280. "wan_aggr_close=%u\n"
  1281. "act_clnt=%u\n"
  1282. "con_clnt_bmap=0x%x\n"
  1283. "wan_rx_empty=%u\n"
  1284. "wan_repl_rx_empty=%u\n"
  1285. "lan_rx_empty=%u\n"
  1286. "lan_repl_rx_empty=%u\n"
  1287. "flow_enable=%u\n"
  1288. "flow_disable=%u\n",
  1289. ipa3_ctx->stats.tx_sw_pkts,
  1290. ipa3_ctx->stats.tx_hw_pkts,
  1291. ipa3_ctx->stats.tx_non_linear,
  1292. ipa3_ctx->stats.tx_pkts_compl,
  1293. ipa3_ctx->stats.rx_pkts,
  1294. ipa3_ctx->stats.stat_compl,
  1295. ipa3_ctx->stats.aggr_close,
  1296. ipa3_ctx->stats.wan_aggr_close,
  1297. atomic_read(&ipa3_ctx->ipa3_active_clients.cnt),
  1298. connect,
  1299. ipa3_ctx->stats.wan_rx_empty,
  1300. ipa3_ctx->stats.wan_repl_rx_empty,
  1301. ipa3_ctx->stats.lan_rx_empty,
  1302. ipa3_ctx->stats.lan_repl_rx_empty,
  1303. ipa3_ctx->stats.flow_enable,
  1304. ipa3_ctx->stats.flow_disable);
  1305. cnt += nbytes;
  1306. for (i = 0; i < IPAHAL_PKT_STATUS_EXCEPTION_MAX; i++) {
  1307. nbytes = scnprintf(dbg_buff + cnt,
  1308. IPA_MAX_MSG_LEN - cnt,
  1309. "lan_rx_excp[%u:%20s]=%u\n", i,
  1310. ipahal_pkt_status_exception_str(i),
  1311. ipa3_ctx->stats.rx_excp_pkts[i]);
  1312. cnt += nbytes;
  1313. }
  1314. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
  1315. }
  1316. static ssize_t ipa3_read_odlstats(struct file *file, char __user *ubuf,
  1317. size_t count, loff_t *ppos)
  1318. {
  1319. int nbytes;
  1320. int cnt = 0;
  1321. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  1322. "ODL received pkt =%u\n"
  1323. "ODL processed pkt to DIAG=%u\n"
  1324. "ODL dropped pkt =%u\n"
  1325. "ODL packet in queue =%u\n",
  1326. ipa3_odl_ctx->stats.odl_rx_pkt,
  1327. ipa3_odl_ctx->stats.odl_tx_diag_pkt,
  1328. ipa3_odl_ctx->stats.odl_drop_pkt,
  1329. atomic_read(&ipa3_odl_ctx->stats.numer_in_queue));
  1330. cnt += nbytes;
  1331. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
  1332. }
  1333. static ssize_t ipa3_read_page_recycle_stats(struct file *file,
  1334. char __user *ubuf, size_t count, loff_t *ppos)
  1335. {
  1336. int nbytes;
  1337. int cnt = 0;
  1338. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  1339. "COAL : Total number of packets replenished =%llu\n"
  1340. "COAL : Number of tmp alloc packets =%llu\n"
  1341. "DEF : Total number of packets replenished =%llu\n"
  1342. "DEF : Number of tmp alloc packets =%llu\n",
  1343. ipa3_ctx->stats.page_recycle_stats[0].total_replenished,
  1344. ipa3_ctx->stats.page_recycle_stats[0].tmp_alloc,
  1345. ipa3_ctx->stats.page_recycle_stats[1].total_replenished,
  1346. ipa3_ctx->stats.page_recycle_stats[1].tmp_alloc);
  1347. cnt += nbytes;
  1348. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
  1349. }
  1350. static ssize_t ipa3_read_wstats(struct file *file, char __user *ubuf,
  1351. size_t count, loff_t *ppos)
  1352. {
  1353. #define HEAD_FRMT_STR "%25s\n"
  1354. #define FRMT_STR "%25s %10u\n"
  1355. #define FRMT_STR1 "%25s %10u\n\n"
  1356. int cnt = 0;
  1357. int nbytes;
  1358. int ipa_ep_idx;
  1359. enum ipa_client_type client = IPA_CLIENT_WLAN1_PROD;
  1360. struct ipa3_ep_context *ep;
  1361. do {
  1362. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  1363. HEAD_FRMT_STR, "Client IPA_CLIENT_WLAN1_PROD Stats:");
  1364. cnt += nbytes;
  1365. ipa_ep_idx = ipa3_get_ep_mapping(client);
  1366. if (ipa_ep_idx == -1) {
  1367. nbytes = scnprintf(dbg_buff + cnt,
  1368. IPA_MAX_MSG_LEN - cnt, HEAD_FRMT_STR, "Not up");
  1369. cnt += nbytes;
  1370. break;
  1371. }
  1372. ep = &ipa3_ctx->ep[ipa_ep_idx];
  1373. if (ep->valid != 1) {
  1374. nbytes = scnprintf(dbg_buff + cnt,
  1375. IPA_MAX_MSG_LEN - cnt, HEAD_FRMT_STR, "Not up");
  1376. cnt += nbytes;
  1377. break;
  1378. }
  1379. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  1380. FRMT_STR, "Avail Fifo Desc:",
  1381. atomic_read(&ep->avail_fifo_desc));
  1382. cnt += nbytes;
  1383. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  1384. FRMT_STR, "Rx Pkts Rcvd:", ep->wstats.rx_pkts_rcvd);
  1385. cnt += nbytes;
  1386. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  1387. FRMT_STR, "Rx Pkts Status Rcvd:",
  1388. ep->wstats.rx_pkts_status_rcvd);
  1389. cnt += nbytes;
  1390. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  1391. FRMT_STR, "Rx DH Rcvd:", ep->wstats.rx_hd_rcvd);
  1392. cnt += nbytes;
  1393. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  1394. FRMT_STR, "Rx DH Processed:",
  1395. ep->wstats.rx_hd_processed);
  1396. cnt += nbytes;
  1397. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  1398. FRMT_STR, "Rx DH Sent Back:", ep->wstats.rx_hd_reply);
  1399. cnt += nbytes;
  1400. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  1401. FRMT_STR, "Rx Pkt Leak:", ep->wstats.rx_pkt_leak);
  1402. cnt += nbytes;
  1403. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  1404. FRMT_STR1, "Rx DP Fail:", ep->wstats.rx_dp_fail);
  1405. cnt += nbytes;
  1406. } while (0);
  1407. client = IPA_CLIENT_WLAN1_CONS;
  1408. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt, HEAD_FRMT_STR,
  1409. "Client IPA_CLIENT_WLAN1_CONS Stats:");
  1410. cnt += nbytes;
  1411. while (1) {
  1412. ipa_ep_idx = ipa3_get_ep_mapping(client);
  1413. if (ipa_ep_idx == -1) {
  1414. nbytes = scnprintf(dbg_buff + cnt,
  1415. IPA_MAX_MSG_LEN - cnt, HEAD_FRMT_STR, "Not up");
  1416. cnt += nbytes;
  1417. goto nxt_clnt_cons;
  1418. }
  1419. ep = &ipa3_ctx->ep[ipa_ep_idx];
  1420. if (ep->valid != 1) {
  1421. nbytes = scnprintf(dbg_buff + cnt,
  1422. IPA_MAX_MSG_LEN - cnt, HEAD_FRMT_STR, "Not up");
  1423. cnt += nbytes;
  1424. goto nxt_clnt_cons;
  1425. }
  1426. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  1427. FRMT_STR, "Tx Pkts Received:", ep->wstats.tx_pkts_rcvd);
  1428. cnt += nbytes;
  1429. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  1430. FRMT_STR, "Tx Pkts Sent:", ep->wstats.tx_pkts_sent);
  1431. cnt += nbytes;
  1432. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  1433. FRMT_STR1, "Tx Pkts Dropped:",
  1434. ep->wstats.tx_pkts_dropped);
  1435. cnt += nbytes;
  1436. nxt_clnt_cons:
  1437. switch (client) {
  1438. case IPA_CLIENT_WLAN1_CONS:
  1439. client = IPA_CLIENT_WLAN2_CONS;
  1440. nbytes = scnprintf(dbg_buff + cnt,
  1441. IPA_MAX_MSG_LEN - cnt, HEAD_FRMT_STR,
  1442. "Client IPA_CLIENT_WLAN2_CONS Stats:");
  1443. cnt += nbytes;
  1444. continue;
  1445. case IPA_CLIENT_WLAN2_CONS:
  1446. client = IPA_CLIENT_WLAN3_CONS;
  1447. nbytes = scnprintf(dbg_buff + cnt,
  1448. IPA_MAX_MSG_LEN - cnt, HEAD_FRMT_STR,
  1449. "Client IPA_CLIENT_WLAN3_CONS Stats:");
  1450. cnt += nbytes;
  1451. continue;
  1452. case IPA_CLIENT_WLAN3_CONS:
  1453. client = IPA_CLIENT_WLAN4_CONS;
  1454. nbytes = scnprintf(dbg_buff + cnt,
  1455. IPA_MAX_MSG_LEN - cnt, HEAD_FRMT_STR,
  1456. "Client IPA_CLIENT_WLAN4_CONS Stats:");
  1457. cnt += nbytes;
  1458. continue;
  1459. case IPA_CLIENT_WLAN4_CONS:
  1460. default:
  1461. break;
  1462. }
  1463. break;
  1464. }
  1465. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  1466. "\n"HEAD_FRMT_STR, "All Wlan Consumer pipes stats:");
  1467. cnt += nbytes;
  1468. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt, FRMT_STR,
  1469. "Tx Comm Buff Allocated:",
  1470. ipa3_ctx->wc_memb.wlan_comm_total_cnt);
  1471. cnt += nbytes;
  1472. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt, FRMT_STR,
  1473. "Tx Comm Buff Avail:", ipa3_ctx->wc_memb.wlan_comm_free_cnt);
  1474. cnt += nbytes;
  1475. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt, FRMT_STR1,
  1476. "Total Tx Pkts Freed:", ipa3_ctx->wc_memb.total_tx_pkts_freed);
  1477. cnt += nbytes;
  1478. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
  1479. }
  1480. static ssize_t ipa3_read_ntn(struct file *file, char __user *ubuf,
  1481. size_t count, loff_t *ppos)
  1482. {
  1483. #define TX_STATS(y) \
  1484. ipa3_ctx->uc_ntn_ctx.ntn_uc_stats_mmio->tx_ch_stats[0].y
  1485. #define RX_STATS(y) \
  1486. ipa3_ctx->uc_ntn_ctx.ntn_uc_stats_mmio->rx_ch_stats[0].y
  1487. struct Ipa3HwStatsNTNInfoData_t stats;
  1488. int nbytes;
  1489. int cnt = 0;
  1490. if (!ipa3_get_ntn_stats(&stats)) {
  1491. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  1492. "TX num_pkts_processed=%u\n"
  1493. "TX ringFull=%u\n"
  1494. "TX ringEmpty=%u\n"
  1495. "TX ringUsageHigh=%u\n"
  1496. "TX ringUsageLow=%u\n"
  1497. "TX RingUtilCount=%u\n"
  1498. "TX bamFifoFull=%u\n"
  1499. "TX bamFifoEmpty=%u\n"
  1500. "TX bamFifoUsageHigh=%u\n"
  1501. "TX bamFifoUsageLow=%u\n"
  1502. "TX bamUtilCount=%u\n"
  1503. "TX num_db=%u\n"
  1504. "TX num_qmb_int_handled=%u\n"
  1505. "TX ipa_pipe_number=%u\n",
  1506. TX_STATS(num_pkts_processed),
  1507. TX_STATS(ring_stats.ringFull),
  1508. TX_STATS(ring_stats.ringEmpty),
  1509. TX_STATS(ring_stats.ringUsageHigh),
  1510. TX_STATS(ring_stats.ringUsageLow),
  1511. TX_STATS(ring_stats.RingUtilCount),
  1512. TX_STATS(gsi_stats.bamFifoFull),
  1513. TX_STATS(gsi_stats.bamFifoEmpty),
  1514. TX_STATS(gsi_stats.bamFifoUsageHigh),
  1515. TX_STATS(gsi_stats.bamFifoUsageLow),
  1516. TX_STATS(gsi_stats.bamUtilCount),
  1517. TX_STATS(num_db),
  1518. TX_STATS(num_qmb_int_handled),
  1519. TX_STATS(ipa_pipe_number));
  1520. cnt += nbytes;
  1521. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  1522. "RX num_pkts_processed=%u\n"
  1523. "RX ringFull=%u\n"
  1524. "RX ringEmpty=%u\n"
  1525. "RX ringUsageHigh=%u\n"
  1526. "RX ringUsageLow=%u\n"
  1527. "RX RingUtilCount=%u\n"
  1528. "RX bamFifoFull=%u\n"
  1529. "RX bamFifoEmpty=%u\n"
  1530. "RX bamFifoUsageHigh=%u\n"
  1531. "RX bamFifoUsageLow=%u\n"
  1532. "RX bamUtilCount=%u\n"
  1533. "RX num_db=%u\n"
  1534. "RX num_qmb_int_handled=%u\n"
  1535. "RX ipa_pipe_number=%u\n",
  1536. RX_STATS(num_pkts_processed),
  1537. RX_STATS(ring_stats.ringFull),
  1538. RX_STATS(ring_stats.ringEmpty),
  1539. RX_STATS(ring_stats.ringUsageHigh),
  1540. RX_STATS(ring_stats.ringUsageLow),
  1541. RX_STATS(ring_stats.RingUtilCount),
  1542. RX_STATS(gsi_stats.bamFifoFull),
  1543. RX_STATS(gsi_stats.bamFifoEmpty),
  1544. RX_STATS(gsi_stats.bamFifoUsageHigh),
  1545. RX_STATS(gsi_stats.bamFifoUsageLow),
  1546. RX_STATS(gsi_stats.bamUtilCount),
  1547. RX_STATS(num_db),
  1548. RX_STATS(num_qmb_int_handled),
  1549. RX_STATS(ipa_pipe_number));
  1550. cnt += nbytes;
  1551. } else {
  1552. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  1553. "Fail to read NTN stats\n");
  1554. cnt += nbytes;
  1555. }
  1556. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
  1557. }
  1558. static ssize_t ipa3_read_wdi(struct file *file, char __user *ubuf,
  1559. size_t count, loff_t *ppos)
  1560. {
  1561. struct IpaHwStatsWDIInfoData_t stats;
  1562. int nbytes;
  1563. int cnt = 0;
  1564. struct IpaHwStatsWDITxInfoData_t *tx_ch_ptr;
  1565. if (!ipa3_get_wdi_stats(&stats)) {
  1566. tx_ch_ptr = &stats.tx_ch_stats;
  1567. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  1568. "TX num_pkts_processed=%u\n"
  1569. "TX copy_engine_doorbell_value=%u\n"
  1570. "TX num_db_fired=%u\n"
  1571. "TX ringFull=%u\n"
  1572. "TX ringEmpty=%u\n"
  1573. "TX ringUsageHigh=%u\n"
  1574. "TX ringUsageLow=%u\n"
  1575. "TX RingUtilCount=%u\n"
  1576. "TX bamFifoFull=%u\n"
  1577. "TX bamFifoEmpty=%u\n"
  1578. "TX bamFifoUsageHigh=%u\n"
  1579. "TX bamFifoUsageLow=%u\n"
  1580. "TX bamUtilCount=%u\n"
  1581. "TX num_db=%u\n"
  1582. "TX num_unexpected_db=%u\n"
  1583. "TX num_bam_int_handled=%u\n"
  1584. "TX num_bam_int_in_non_running_state=%u\n"
  1585. "TX num_qmb_int_handled=%u\n"
  1586. "TX num_bam_int_handled_while_wait_for_bam=%u\n",
  1587. tx_ch_ptr->num_pkts_processed,
  1588. tx_ch_ptr->copy_engine_doorbell_value,
  1589. tx_ch_ptr->num_db_fired,
  1590. tx_ch_ptr->tx_comp_ring_stats.ringFull,
  1591. tx_ch_ptr->tx_comp_ring_stats.ringEmpty,
  1592. tx_ch_ptr->tx_comp_ring_stats.ringUsageHigh,
  1593. tx_ch_ptr->tx_comp_ring_stats.ringUsageLow,
  1594. tx_ch_ptr->tx_comp_ring_stats.RingUtilCount,
  1595. tx_ch_ptr->bam_stats.bamFifoFull,
  1596. tx_ch_ptr->bam_stats.bamFifoEmpty,
  1597. tx_ch_ptr->bam_stats.bamFifoUsageHigh,
  1598. tx_ch_ptr->bam_stats.bamFifoUsageLow,
  1599. tx_ch_ptr->bam_stats.bamUtilCount,
  1600. tx_ch_ptr->num_db,
  1601. tx_ch_ptr->num_unexpected_db,
  1602. tx_ch_ptr->num_bam_int_handled,
  1603. tx_ch_ptr->num_bam_int_in_non_running_state,
  1604. tx_ch_ptr->num_qmb_int_handled,
  1605. tx_ch_ptr->num_bam_int_handled_while_wait_for_bam);
  1606. cnt += nbytes;
  1607. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  1608. "RX max_outstanding_pkts=%u\n"
  1609. "RX num_pkts_processed=%u\n"
  1610. "RX rx_ring_rp_value=%u\n"
  1611. "RX ringFull=%u\n"
  1612. "RX ringEmpty=%u\n"
  1613. "RX ringUsageHigh=%u\n"
  1614. "RX ringUsageLow=%u\n"
  1615. "RX RingUtilCount=%u\n"
  1616. "RX bamFifoFull=%u\n"
  1617. "RX bamFifoEmpty=%u\n"
  1618. "RX bamFifoUsageHigh=%u\n"
  1619. "RX bamFifoUsageLow=%u\n"
  1620. "RX bamUtilCount=%u\n"
  1621. "RX num_bam_int_handled=%u\n"
  1622. "RX num_db=%u\n"
  1623. "RX num_unexpected_db=%u\n"
  1624. "RX num_pkts_in_dis_uninit_state=%u\n"
  1625. "RX num_ic_inj_vdev_change=%u\n"
  1626. "RX num_ic_inj_fw_desc_change=%u\n"
  1627. "RX num_qmb_int_handled=%u\n"
  1628. "RX reserved1=%u\n"
  1629. "RX reserved2=%u\n",
  1630. stats.rx_ch_stats.max_outstanding_pkts,
  1631. stats.rx_ch_stats.num_pkts_processed,
  1632. stats.rx_ch_stats.rx_ring_rp_value,
  1633. stats.rx_ch_stats.rx_ind_ring_stats.ringFull,
  1634. stats.rx_ch_stats.rx_ind_ring_stats.ringEmpty,
  1635. stats.rx_ch_stats.rx_ind_ring_stats.ringUsageHigh,
  1636. stats.rx_ch_stats.rx_ind_ring_stats.ringUsageLow,
  1637. stats.rx_ch_stats.rx_ind_ring_stats.RingUtilCount,
  1638. stats.rx_ch_stats.bam_stats.bamFifoFull,
  1639. stats.rx_ch_stats.bam_stats.bamFifoEmpty,
  1640. stats.rx_ch_stats.bam_stats.bamFifoUsageHigh,
  1641. stats.rx_ch_stats.bam_stats.bamFifoUsageLow,
  1642. stats.rx_ch_stats.bam_stats.bamUtilCount,
  1643. stats.rx_ch_stats.num_bam_int_handled,
  1644. stats.rx_ch_stats.num_db,
  1645. stats.rx_ch_stats.num_unexpected_db,
  1646. stats.rx_ch_stats.num_pkts_in_dis_uninit_state,
  1647. stats.rx_ch_stats.num_ic_inj_vdev_change,
  1648. stats.rx_ch_stats.num_ic_inj_fw_desc_change,
  1649. stats.rx_ch_stats.num_qmb_int_handled,
  1650. stats.rx_ch_stats.reserved1,
  1651. stats.rx_ch_stats.reserved2);
  1652. cnt += nbytes;
  1653. } else {
  1654. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  1655. "Fail to read WDI stats\n");
  1656. cnt += nbytes;
  1657. }
  1658. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
  1659. }
  1660. static ssize_t ipa3_write_dbg_cnt(struct file *file, const char __user *buf,
  1661. size_t count, loff_t *ppos)
  1662. {
  1663. u32 option = 0;
  1664. struct ipahal_reg_debug_cnt_ctrl dbg_cnt_ctrl;
  1665. int ret;
  1666. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0) {
  1667. IPAERR("IPA_DEBUG_CNT_CTRL is not supported in IPA 4.0\n");
  1668. return -EPERM;
  1669. }
  1670. ret = kstrtou32_from_user(buf, count, 0, &option);
  1671. if (ret)
  1672. return ret;
  1673. memset(&dbg_cnt_ctrl, 0, sizeof(dbg_cnt_ctrl));
  1674. dbg_cnt_ctrl.type = DBG_CNT_TYPE_GENERAL;
  1675. dbg_cnt_ctrl.product = true;
  1676. dbg_cnt_ctrl.src_pipe = 0xff;
  1677. dbg_cnt_ctrl.rule_idx_pipe_rule = false;
  1678. dbg_cnt_ctrl.rule_idx = 0;
  1679. if (option == 1)
  1680. dbg_cnt_ctrl.en = true;
  1681. else
  1682. dbg_cnt_ctrl.en = false;
  1683. IPA_ACTIVE_CLIENTS_INC_SIMPLE();
  1684. ipahal_write_reg_n_fields(IPA_DEBUG_CNT_CTRL_n, 0, &dbg_cnt_ctrl);
  1685. IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
  1686. return count;
  1687. }
  1688. static ssize_t ipa3_read_dbg_cnt(struct file *file, char __user *ubuf,
  1689. size_t count, loff_t *ppos)
  1690. {
  1691. int nbytes;
  1692. u32 regval;
  1693. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0) {
  1694. IPAERR("IPA_DEBUG_CNT_REG is not supported in IPA 4.0\n");
  1695. return -EPERM;
  1696. }
  1697. IPA_ACTIVE_CLIENTS_INC_SIMPLE();
  1698. regval =
  1699. ipahal_read_reg_n(IPA_DEBUG_CNT_REG_n, 0);
  1700. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  1701. "IPA_DEBUG_CNT_REG_0=0x%x\n", regval);
  1702. IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
  1703. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, nbytes);
  1704. }
  1705. static ssize_t ipa3_read_msg(struct file *file, char __user *ubuf,
  1706. size_t count, loff_t *ppos)
  1707. {
  1708. int nbytes;
  1709. int cnt = 0;
  1710. int i;
  1711. for (i = 0; i < ARRAY_SIZE(ipa3_event_name); i++) {
  1712. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  1713. "msg[%u:%27s] W:%u R:%u\n", i,
  1714. ipa3_event_name[i],
  1715. ipa3_ctx->stats.msg_w[i],
  1716. ipa3_ctx->stats.msg_r[i]);
  1717. cnt += nbytes;
  1718. }
  1719. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
  1720. }
  1721. static void ipa3_read_table(
  1722. char *table_addr,
  1723. u32 table_size,
  1724. u32 *total_num_entries,
  1725. u32 *rule_id,
  1726. enum ipahal_nat_type nat_type)
  1727. {
  1728. int result;
  1729. char *entry;
  1730. size_t entry_size;
  1731. bool entry_zeroed;
  1732. bool entry_valid;
  1733. u32 i, num_entries = 0, id = *rule_id;
  1734. char *buff;
  1735. size_t buff_size = 2 * IPA_MAX_ENTRY_STRING_LEN;
  1736. IPADBG("In\n");
  1737. if (table_addr == NULL) {
  1738. pr_err("NULL NAT table\n");
  1739. goto bail;
  1740. }
  1741. result = ipahal_nat_entry_size(nat_type, &entry_size);
  1742. if (result) {
  1743. IPAERR("Failed to retrieve size of %s entry\n",
  1744. ipahal_nat_type_str(nat_type));
  1745. goto bail;
  1746. }
  1747. buff = kzalloc(buff_size, GFP_KERNEL);
  1748. if (!buff) {
  1749. IPAERR("Out of memory\n");
  1750. goto bail;
  1751. }
  1752. for (i = 0, entry = table_addr;
  1753. i < table_size;
  1754. ++i, ++id, entry += entry_size) {
  1755. result = ipahal_nat_is_entry_zeroed(nat_type, entry,
  1756. &entry_zeroed);
  1757. if (result) {
  1758. IPAERR("Undefined if %s entry is zero\n",
  1759. ipahal_nat_type_str(nat_type));
  1760. goto free_buf;
  1761. }
  1762. if (entry_zeroed)
  1763. continue;
  1764. result = ipahal_nat_is_entry_valid(nat_type, entry,
  1765. &entry_valid);
  1766. if (result) {
  1767. IPAERR("Undefined if %s entry is valid\n",
  1768. ipahal_nat_type_str(nat_type));
  1769. goto free_buf;
  1770. }
  1771. if (entry_valid) {
  1772. ++num_entries;
  1773. pr_err("\tEntry_Index=%d\n", id);
  1774. } else
  1775. pr_err("\tEntry_Index=%d - Invalid Entry\n", id);
  1776. ipahal_nat_stringify_entry(nat_type, entry,
  1777. buff, buff_size);
  1778. pr_err("%s\n", buff);
  1779. memset(buff, 0, buff_size);
  1780. }
  1781. if (num_entries)
  1782. pr_err("\n");
  1783. else
  1784. pr_err("\tEmpty\n\n");
  1785. free_buf:
  1786. kfree(buff);
  1787. *rule_id = id;
  1788. *total_num_entries += num_entries;
  1789. bail:
  1790. IPADBG("Out\n");
  1791. }
  1792. static void ipa3_start_read_memory_device(
  1793. struct ipa3_nat_ipv6ct_common_mem *dev,
  1794. enum ipahal_nat_type nat_type,
  1795. u32 *num_ddr_ent_ptr,
  1796. u32 *num_sram_ent_ptr)
  1797. {
  1798. u32 rule_id = 0;
  1799. if (dev->is_ipv6ct_mem) {
  1800. IPADBG("In: v6\n");
  1801. pr_err("%s_Table_Size=%d\n",
  1802. dev->name, dev->table_entries + 1);
  1803. pr_err("%s_Expansion_Table_Size=%d\n",
  1804. dev->name, dev->expn_table_entries);
  1805. pr_err("\n%s Base Table:\n", dev->name);
  1806. if (dev->base_table_addr)
  1807. ipa3_read_table(
  1808. dev->base_table_addr,
  1809. dev->table_entries + 1,
  1810. num_ddr_ent_ptr,
  1811. &rule_id,
  1812. nat_type);
  1813. pr_err("%s Expansion Table:\n", dev->name);
  1814. if (dev->expansion_table_addr)
  1815. ipa3_read_table(
  1816. dev->expansion_table_addr,
  1817. dev->expn_table_entries,
  1818. num_ddr_ent_ptr,
  1819. &rule_id,
  1820. nat_type);
  1821. }
  1822. if (dev->is_nat_mem) {
  1823. struct ipa3_nat_mem *nm_ptr = (struct ipa3_nat_mem *) dev;
  1824. struct ipa3_nat_mem_loc_data *mld_ptr = NULL;
  1825. u32 *num_ent_ptr;
  1826. const char *type_ptr;
  1827. IPADBG("In: v4\n");
  1828. if (nm_ptr->active_table == IPA_NAT_MEM_IN_DDR &&
  1829. nm_ptr->ddr_in_use) {
  1830. mld_ptr = &nm_ptr->mem_loc[IPA_NAT_MEM_IN_DDR];
  1831. num_ent_ptr = num_ddr_ent_ptr;
  1832. type_ptr = "DDR based table";
  1833. }
  1834. if (nm_ptr->active_table == IPA_NAT_MEM_IN_SRAM &&
  1835. nm_ptr->sram_in_use) {
  1836. mld_ptr = &nm_ptr->mem_loc[IPA_NAT_MEM_IN_SRAM];
  1837. num_ent_ptr = num_sram_ent_ptr;
  1838. type_ptr = "SRAM based table";
  1839. }
  1840. if (mld_ptr) {
  1841. pr_err("(%s) %s_Table_Size=%d\n",
  1842. type_ptr,
  1843. dev->name,
  1844. mld_ptr->table_entries + 1);
  1845. pr_err("(%s) %s_Expansion_Table_Size=%d\n",
  1846. type_ptr,
  1847. dev->name,
  1848. mld_ptr->expn_table_entries);
  1849. pr_err("\n(%s) %s_Base Table:\n",
  1850. type_ptr,
  1851. dev->name);
  1852. if (mld_ptr->base_table_addr)
  1853. ipa3_read_table(
  1854. mld_ptr->base_table_addr,
  1855. mld_ptr->table_entries + 1,
  1856. num_ent_ptr,
  1857. &rule_id,
  1858. nat_type);
  1859. pr_err("(%s) %s_Expansion Table:\n",
  1860. type_ptr,
  1861. dev->name);
  1862. if (mld_ptr->expansion_table_addr)
  1863. ipa3_read_table(
  1864. mld_ptr->expansion_table_addr,
  1865. mld_ptr->expn_table_entries,
  1866. num_ent_ptr,
  1867. &rule_id,
  1868. nat_type);
  1869. }
  1870. }
  1871. IPADBG("Out\n");
  1872. }
  1873. static void ipa3_finish_read_memory_device(
  1874. struct ipa3_nat_ipv6ct_common_mem *dev,
  1875. u32 num_ddr_entries,
  1876. u32 num_sram_entries)
  1877. {
  1878. IPADBG("In\n");
  1879. if (dev->is_ipv6ct_mem) {
  1880. pr_err("Overall number %s entries: %u\n\n",
  1881. dev->name,
  1882. num_ddr_entries);
  1883. } else {
  1884. struct ipa3_nat_mem *nm_ptr = (struct ipa3_nat_mem *) dev;
  1885. if (num_ddr_entries)
  1886. pr_err("%s: Overall number of DDR entries: %u\n\n",
  1887. dev->name,
  1888. num_ddr_entries);
  1889. if (num_sram_entries)
  1890. pr_err("%s: Overall number of SRAM entries: %u\n\n",
  1891. dev->name,
  1892. num_sram_entries);
  1893. pr_err("%s: Driver focus changes to DDR(%u) to SRAM(%u)\n",
  1894. dev->name,
  1895. nm_ptr->switch2ddr_cnt,
  1896. nm_ptr->switch2sram_cnt);
  1897. }
  1898. IPADBG("Out\n");
  1899. }
  1900. static void ipa3_read_pdn_table(void)
  1901. {
  1902. int i, result;
  1903. char *pdn_entry;
  1904. size_t pdn_entry_size;
  1905. bool entry_zeroed;
  1906. bool entry_valid;
  1907. char *buff;
  1908. size_t buff_size = 128;
  1909. IPADBG("In\n");
  1910. if (ipa3_ctx->nat_mem.pdn_mem.base) {
  1911. result = ipahal_nat_entry_size(
  1912. IPAHAL_NAT_IPV4_PDN, &pdn_entry_size);
  1913. if (result) {
  1914. IPAERR("Failed to retrieve size of PDN entry");
  1915. goto bail;
  1916. }
  1917. buff = kzalloc(buff_size, GFP_KERNEL);
  1918. if (!buff) {
  1919. IPAERR("Out of memory\n");
  1920. goto bail;
  1921. }
  1922. for (i = 0, pdn_entry = ipa3_ctx->nat_mem.pdn_mem.base;
  1923. i < IPA_MAX_PDN_NUM;
  1924. ++i, pdn_entry += pdn_entry_size) {
  1925. result = ipahal_nat_is_entry_zeroed(
  1926. IPAHAL_NAT_IPV4_PDN,
  1927. pdn_entry, &entry_zeroed);
  1928. if (result) {
  1929. IPAERR("ipahal_nat_is_entry_zeroed() fail\n");
  1930. goto free;
  1931. }
  1932. if (entry_zeroed)
  1933. continue;
  1934. result = ipahal_nat_is_entry_valid(
  1935. IPAHAL_NAT_IPV4_PDN,
  1936. pdn_entry, &entry_valid);
  1937. if (result) {
  1938. IPAERR(
  1939. "Failed to determine whether the PDN entry is valid\n");
  1940. goto free;
  1941. }
  1942. ipahal_nat_stringify_entry(
  1943. IPAHAL_NAT_IPV4_PDN,
  1944. pdn_entry, buff, buff_size);
  1945. if (entry_valid)
  1946. pr_err("PDN %d: %s\n", i, buff);
  1947. else
  1948. pr_err("PDN %d - Invalid: %s\n", i, buff);
  1949. memset(buff, 0, buff_size);
  1950. }
  1951. pr_err("\n");
  1952. free:
  1953. kfree(buff);
  1954. }
  1955. bail:
  1956. IPADBG("Out\n");
  1957. }
  1958. static ssize_t ipa3_read_nat4(
  1959. struct file *file,
  1960. char __user *ubuf,
  1961. size_t count,
  1962. loff_t *ppos)
  1963. {
  1964. struct ipa3_nat_ipv6ct_common_mem *dev = &ipa3_ctx->nat_mem.dev;
  1965. struct ipa3_nat_mem *nm_ptr = (struct ipa3_nat_mem *) dev;
  1966. struct ipa3_nat_mem_loc_data *mld_ptr = NULL;
  1967. u32 rule_id = 0;
  1968. u32 *num_ents_ptr;
  1969. u32 num_ddr_ents = 0;
  1970. u32 num_sram_ents = 0;
  1971. u32 *num_index_ents_ptr;
  1972. u32 num_ddr_index_ents = 0;
  1973. u32 num_sram_index_ents = 0;
  1974. const char *type_ptr;
  1975. bool any_table_active = (nm_ptr->ddr_in_use || nm_ptr->sram_in_use);
  1976. pr_err("IPA3 NAT stats\n");
  1977. if (!dev->is_dev_init) {
  1978. pr_err("NAT hasn't been initialized or not supported\n");
  1979. goto ret;
  1980. }
  1981. mutex_lock(&dev->lock);
  1982. if (!dev->is_hw_init || !any_table_active) {
  1983. pr_err("NAT H/W and/or S/W not initialized\n");
  1984. goto bail;
  1985. }
  1986. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0) {
  1987. ipa3_read_pdn_table();
  1988. } else {
  1989. pr_err("NAT Table IP Address=%pI4h\n\n",
  1990. &ipa3_ctx->nat_mem.public_ip_addr);
  1991. }
  1992. ipa3_start_read_memory_device(
  1993. dev,
  1994. IPAHAL_NAT_IPV4,
  1995. &num_ddr_ents,
  1996. &num_sram_ents);
  1997. if (nm_ptr->active_table == IPA_NAT_MEM_IN_DDR &&
  1998. nm_ptr->ddr_in_use) {
  1999. mld_ptr = &nm_ptr->mem_loc[IPA_NAT_MEM_IN_DDR];
  2000. num_ents_ptr = &num_ddr_ents;
  2001. num_index_ents_ptr = &num_ddr_index_ents;
  2002. type_ptr = "DDR based table";
  2003. }
  2004. if (nm_ptr->active_table == IPA_NAT_MEM_IN_SRAM &&
  2005. nm_ptr->sram_in_use) {
  2006. mld_ptr = &nm_ptr->mem_loc[IPA_NAT_MEM_IN_SRAM];
  2007. num_ents_ptr = &num_sram_ents;
  2008. num_index_ents_ptr = &num_sram_index_ents;
  2009. type_ptr = "SRAM based table";
  2010. }
  2011. if (mld_ptr) {
  2012. /* Print Index tables */
  2013. pr_err("(%s) ipaNatTable Index Table:\n", type_ptr);
  2014. ipa3_read_table(
  2015. mld_ptr->index_table_addr,
  2016. mld_ptr->table_entries + 1,
  2017. num_index_ents_ptr,
  2018. &rule_id,
  2019. IPAHAL_NAT_IPV4_INDEX);
  2020. pr_err("(%s) ipaNatTable Expansion Index Table:\n", type_ptr);
  2021. ipa3_read_table(
  2022. mld_ptr->index_table_expansion_addr,
  2023. mld_ptr->expn_table_entries,
  2024. num_index_ents_ptr,
  2025. &rule_id,
  2026. IPAHAL_NAT_IPV4_INDEX);
  2027. if (*num_ents_ptr != *num_index_ents_ptr)
  2028. IPAERR(
  2029. "(%s) Base Table vs Index Table entry count differs (%u vs %u)\n",
  2030. type_ptr, *num_ents_ptr, *num_index_ents_ptr);
  2031. }
  2032. ipa3_finish_read_memory_device(
  2033. dev,
  2034. num_ddr_ents,
  2035. num_sram_ents);
  2036. bail:
  2037. mutex_unlock(&dev->lock);
  2038. ret:
  2039. IPADBG("Out\n");
  2040. return 0;
  2041. }
  2042. static ssize_t ipa3_read_ipv6ct(
  2043. struct file *file,
  2044. char __user *ubuf,
  2045. size_t count,
  2046. loff_t *ppos)
  2047. {
  2048. struct ipa3_nat_ipv6ct_common_mem *dev = &ipa3_ctx->ipv6ct_mem.dev;
  2049. u32 num_ddr_ents, num_sram_ents;
  2050. num_ddr_ents = num_sram_ents = 0;
  2051. IPADBG("In\n");
  2052. pr_err("\n");
  2053. if (!dev->is_dev_init) {
  2054. pr_err("IPv6 Conntrack not initialized or not supported\n");
  2055. goto bail;
  2056. }
  2057. if (!dev->is_hw_init) {
  2058. pr_err("IPv6 connection tracking H/W hasn't been initialized\n");
  2059. goto bail;
  2060. }
  2061. mutex_lock(&dev->lock);
  2062. ipa3_start_read_memory_device(
  2063. dev,
  2064. IPAHAL_NAT_IPV6CT,
  2065. &num_ddr_ents,
  2066. &num_sram_ents);
  2067. ipa3_finish_read_memory_device(
  2068. dev,
  2069. num_ddr_ents,
  2070. num_sram_ents);
  2071. mutex_unlock(&dev->lock);
  2072. bail:
  2073. IPADBG("Out\n");
  2074. return 0;
  2075. }
  2076. static ssize_t ipa3_pm_read_stats(struct file *file, char __user *ubuf,
  2077. size_t count, loff_t *ppos)
  2078. {
  2079. int result, cnt = 0;
  2080. result = ipa_pm_stat(dbg_buff, IPA_MAX_MSG_LEN);
  2081. if (result < 0) {
  2082. cnt += scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  2083. "Error in printing PM stat %d\n", result);
  2084. goto ret;
  2085. }
  2086. cnt += result;
  2087. ret:
  2088. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
  2089. }
  2090. static ssize_t ipa3_pm_ex_read_stats(struct file *file, char __user *ubuf,
  2091. size_t count, loff_t *ppos)
  2092. {
  2093. int result, cnt = 0;
  2094. result = ipa_pm_exceptions_stat(dbg_buff, IPA_MAX_MSG_LEN);
  2095. if (result < 0) {
  2096. cnt += scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  2097. "Error in printing PM stat %d\n", result);
  2098. goto ret;
  2099. }
  2100. cnt += result;
  2101. ret:
  2102. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
  2103. }
  2104. static ssize_t ipa3_read_ipahal_regs(struct file *file, char __user *ubuf,
  2105. size_t count, loff_t *ppos)
  2106. {
  2107. IPA_ACTIVE_CLIENTS_INC_SIMPLE();
  2108. ipahal_print_all_regs(true);
  2109. IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
  2110. return 0;
  2111. }
  2112. static ssize_t ipa3_read_wdi_gsi_stats(struct file *file,
  2113. char __user *ubuf, size_t count, loff_t *ppos)
  2114. {
  2115. struct ipa_uc_dbg_ring_stats stats;
  2116. int nbytes;
  2117. int cnt = 0;
  2118. if (ipa3_ctx->ipa_hw_type < IPA_HW_v4_5) {
  2119. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  2120. "This feature only support on IPA4.5+\n");
  2121. cnt += nbytes;
  2122. goto done;
  2123. }
  2124. if (!ipa3_get_wdi_gsi_stats(&stats)) {
  2125. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  2126. "TX ringFull=%u\n"
  2127. "TX ringEmpty=%u\n"
  2128. "TX ringUsageHigh=%u\n"
  2129. "TX ringUsageLow=%u\n"
  2130. "TX RingUtilCount=%u\n",
  2131. stats.ring[1].ringFull,
  2132. stats.ring[1].ringEmpty,
  2133. stats.ring[1].ringUsageHigh,
  2134. stats.ring[1].ringUsageLow,
  2135. stats.ring[1].RingUtilCount);
  2136. cnt += nbytes;
  2137. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  2138. "RX ringFull=%u\n"
  2139. "RX ringEmpty=%u\n"
  2140. "RX ringUsageHigh=%u\n"
  2141. "RX ringUsageLow=%u\n"
  2142. "RX RingUtilCount=%u\n",
  2143. stats.ring[0].ringFull,
  2144. stats.ring[0].ringEmpty,
  2145. stats.ring[0].ringUsageHigh,
  2146. stats.ring[0].ringUsageLow,
  2147. stats.ring[0].RingUtilCount);
  2148. cnt += nbytes;
  2149. } else {
  2150. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  2151. "Fail to read WDI GSI stats\n");
  2152. cnt += nbytes;
  2153. }
  2154. done:
  2155. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
  2156. }
  2157. static ssize_t ipa3_read_wdi3_gsi_stats(struct file *file,
  2158. char __user *ubuf, size_t count, loff_t *ppos)
  2159. {
  2160. struct ipa_uc_dbg_ring_stats stats;
  2161. int nbytes;
  2162. int cnt = 0;
  2163. if (ipa3_ctx->ipa_hw_type < IPA_HW_v4_5) {
  2164. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  2165. "This feature only support on IPA4.5+\n");
  2166. cnt += nbytes;
  2167. goto done;
  2168. }
  2169. if (!ipa3_get_wdi3_gsi_stats(&stats)) {
  2170. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  2171. "TX ringFull=%u\n"
  2172. "TX ringEmpty=%u\n"
  2173. "TX ringUsageHigh=%u\n"
  2174. "TX ringUsageLow=%u\n"
  2175. "TX RingUtilCount=%u\n",
  2176. stats.ring[1].ringFull,
  2177. stats.ring[1].ringEmpty,
  2178. stats.ring[1].ringUsageHigh,
  2179. stats.ring[1].ringUsageLow,
  2180. stats.ring[1].RingUtilCount);
  2181. cnt += nbytes;
  2182. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  2183. "RX ringFull=%u\n"
  2184. "RX ringEmpty=%u\n"
  2185. "RX ringUsageHigh=%u\n"
  2186. "RX ringUsageLow=%u\n"
  2187. "RX RingUtilCount=%u\n",
  2188. stats.ring[0].ringFull,
  2189. stats.ring[0].ringEmpty,
  2190. stats.ring[0].ringUsageHigh,
  2191. stats.ring[0].ringUsageLow,
  2192. stats.ring[0].RingUtilCount);
  2193. cnt += nbytes;
  2194. } else {
  2195. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  2196. "Fail to read WDI GSI stats\n");
  2197. cnt += nbytes;
  2198. }
  2199. done:
  2200. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
  2201. }
  2202. static ssize_t ipa3_read_11ad_gsi_stats(struct file *file,
  2203. char __user *ubuf, size_t count, loff_t *ppos)
  2204. {
  2205. int nbytes;
  2206. int cnt = 0;
  2207. if (ipa3_ctx->ipa_hw_type < IPA_HW_v4_5) {
  2208. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  2209. "This feature only support on IPA4.5+\n");
  2210. cnt += nbytes;
  2211. goto done;
  2212. }
  2213. return 0;
  2214. done:
  2215. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
  2216. }
  2217. static ssize_t ipa3_read_aqc_gsi_stats(struct file *file,
  2218. char __user *ubuf, size_t count, loff_t *ppos)
  2219. {
  2220. struct ipa_uc_dbg_ring_stats stats;
  2221. int nbytes;
  2222. int cnt = 0;
  2223. if (ipa3_ctx->ipa_hw_type < IPA_HW_v4_5) {
  2224. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  2225. "This feature only support on IPA4.5+\n");
  2226. cnt += nbytes;
  2227. goto done;
  2228. }
  2229. if (!ipa3_get_aqc_gsi_stats(&stats)) {
  2230. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  2231. "TX ringFull=%u\n"
  2232. "TX ringEmpty=%u\n"
  2233. "TX ringUsageHigh=%u\n"
  2234. "TX ringUsageLow=%u\n"
  2235. "TX RingUtilCount=%u\n",
  2236. stats.ring[1].ringFull,
  2237. stats.ring[1].ringEmpty,
  2238. stats.ring[1].ringUsageHigh,
  2239. stats.ring[1].ringUsageLow,
  2240. stats.ring[1].RingUtilCount);
  2241. cnt += nbytes;
  2242. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  2243. "RX ringFull=%u\n"
  2244. "RX ringEmpty=%u\n"
  2245. "RX ringUsageHigh=%u\n"
  2246. "RX ringUsageLow=%u\n"
  2247. "RX RingUtilCount=%u\n",
  2248. stats.ring[0].ringFull,
  2249. stats.ring[0].ringEmpty,
  2250. stats.ring[0].ringUsageHigh,
  2251. stats.ring[0].ringUsageLow,
  2252. stats.ring[0].RingUtilCount);
  2253. cnt += nbytes;
  2254. } else {
  2255. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  2256. "Fail to read AQC GSI stats\n");
  2257. cnt += nbytes;
  2258. }
  2259. done:
  2260. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
  2261. }
  2262. static ssize_t ipa3_read_mhip_gsi_stats(struct file *file,
  2263. char __user *ubuf, size_t count, loff_t *ppos)
  2264. {
  2265. struct ipa_uc_dbg_ring_stats stats;
  2266. int nbytes;
  2267. int cnt = 0;
  2268. if (ipa3_ctx->ipa_hw_type < IPA_HW_v4_5) {
  2269. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  2270. "This feature only support on IPA4.5+\n");
  2271. cnt += nbytes;
  2272. goto done;
  2273. }
  2274. if (!ipa3_get_mhip_gsi_stats(&stats)) {
  2275. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  2276. "IPA_CLIENT_MHI_PRIME_TETH_CONS ringFull=%u\n"
  2277. "IPA_CLIENT_MHI_PRIME_TETH_CONS ringEmpty=%u\n"
  2278. "IPA_CLIENT_MHI_PRIME_TETH_CONS ringUsageHigh=%u\n"
  2279. "IPA_CLIENT_MHI_PRIME_TETH_CONS ringUsageLow=%u\n"
  2280. "IPA_CLIENT_MHI_PRIME_TETH_CONS RingUtilCount=%u\n",
  2281. stats.ring[1].ringFull,
  2282. stats.ring[1].ringEmpty,
  2283. stats.ring[1].ringUsageHigh,
  2284. stats.ring[1].ringUsageLow,
  2285. stats.ring[1].RingUtilCount);
  2286. cnt += nbytes;
  2287. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  2288. "IPA_CLIENT_MHI_PRIME_TETH_PROD ringFull=%u\n"
  2289. "IPA_CLIENT_MHI_PRIME_TETH_PROD ringEmpty=%u\n"
  2290. "IPA_CLIENT_MHI_PRIME_TETH_PROD ringUsageHigh=%u\n"
  2291. "IPA_CLIENT_MHI_PRIME_TETH_PROD ringUsageLow=%u\n"
  2292. "IPA_CLIENT_MHI_PRIME_TETH_PROD RingUtilCount=%u\n",
  2293. stats.ring[0].ringFull,
  2294. stats.ring[0].ringEmpty,
  2295. stats.ring[0].ringUsageHigh,
  2296. stats.ring[0].ringUsageLow,
  2297. stats.ring[0].RingUtilCount);
  2298. cnt += nbytes;
  2299. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  2300. "IPA_CLIENT_MHI_PRIME_RMNET_CONS ringFull=%u\n"
  2301. "IPA_CLIENT_MHI_PRIME_RMNET_CONS ringEmpty=%u\n"
  2302. "IPA_CLIENT_MHI_PRIME_RMNET_CONS ringUsageHigh=%u\n"
  2303. "IPA_CLIENT_MHI_PRIME_RMNET_CONS ringUsageLow=%u\n"
  2304. "IPA_CLIENT_MHI_PRIME_RMNET_CONS RingUtilCount=%u\n",
  2305. stats.ring[3].ringFull,
  2306. stats.ring[3].ringEmpty,
  2307. stats.ring[3].ringUsageHigh,
  2308. stats.ring[3].ringUsageLow,
  2309. stats.ring[3].RingUtilCount);
  2310. cnt += nbytes;
  2311. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  2312. "IPA_CLIENT_MHI_PRIME_RMNET_PROD ringFull=%u\n"
  2313. "IPA_CLIENT_MHI_PRIME_RMNET_PROD ringEmpty=%u\n"
  2314. "IPA_CLIENT_MHI_PRIME_RMNET_PROD ringUsageHigh=%u\n"
  2315. "IPA_CLIENT_MHI_PRIME_RMNET_PROD ringUsageLow=%u\n"
  2316. "IPA_CLIENT_MHI_PRIME_RMNET_PROD RingUtilCount=%u\n",
  2317. stats.ring[2].ringFull,
  2318. stats.ring[2].ringEmpty,
  2319. stats.ring[2].ringUsageHigh,
  2320. stats.ring[2].ringUsageLow,
  2321. stats.ring[2].RingUtilCount);
  2322. cnt += nbytes;
  2323. } else {
  2324. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  2325. "Fail to read WDI GSI stats\n");
  2326. cnt += nbytes;
  2327. }
  2328. done:
  2329. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
  2330. }
  2331. static ssize_t ipa3_read_usb_gsi_stats(struct file *file,
  2332. char __user *ubuf, size_t count, loff_t *ppos)
  2333. {
  2334. struct ipa_uc_dbg_ring_stats stats;
  2335. int nbytes;
  2336. int cnt = 0;
  2337. if (ipa3_ctx->ipa_hw_type < IPA_HW_v4_5) {
  2338. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  2339. "This feature only support on IPA4.5+\n");
  2340. cnt += nbytes;
  2341. goto done;
  2342. }
  2343. if (!ipa3_get_usb_gsi_stats(&stats)) {
  2344. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  2345. "TX ringFull=%u\n"
  2346. "TX ringEmpty=%u\n"
  2347. "TX ringUsageHigh=%u\n"
  2348. "TX ringUsageLow=%u\n"
  2349. "TX RingUtilCount=%u\n",
  2350. stats.ring[1].ringFull,
  2351. stats.ring[1].ringEmpty,
  2352. stats.ring[1].ringUsageHigh,
  2353. stats.ring[1].ringUsageLow,
  2354. stats.ring[1].RingUtilCount);
  2355. cnt += nbytes;
  2356. nbytes = scnprintf(dbg_buff + cnt, IPA_MAX_MSG_LEN - cnt,
  2357. "RX ringFull=%u\n"
  2358. "RX ringEmpty=%u\n"
  2359. "RX ringUsageHigh=%u\n"
  2360. "RX ringUsageLow=%u\n"
  2361. "RX RingUtilCount=%u\n",
  2362. stats.ring[0].ringFull,
  2363. stats.ring[0].ringEmpty,
  2364. stats.ring[0].ringUsageHigh,
  2365. stats.ring[0].ringUsageLow,
  2366. stats.ring[0].RingUtilCount);
  2367. cnt += nbytes;
  2368. } else {
  2369. nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN,
  2370. "Fail to read WDI GSI stats\n");
  2371. cnt += nbytes;
  2372. }
  2373. done:
  2374. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
  2375. }
  2376. static ssize_t ipa3_read_app_clk_vote(
  2377. struct file *file,
  2378. char __user *ubuf,
  2379. size_t count,
  2380. loff_t *ppos)
  2381. {
  2382. int cnt =
  2383. scnprintf(
  2384. dbg_buff,
  2385. IPA_MAX_MSG_LEN,
  2386. "%u\n",
  2387. ipa3_ctx->app_clock_vote.cnt);
  2388. return simple_read_from_buffer(ubuf, count, ppos, dbg_buff, cnt);
  2389. }
  2390. static void ipa_dump_status(struct ipahal_pkt_status *status)
  2391. {
  2392. IPA_DUMP_STATUS_FIELD(status_opcode);
  2393. IPA_DUMP_STATUS_FIELD(exception);
  2394. IPA_DUMP_STATUS_FIELD(status_mask);
  2395. IPA_DUMP_STATUS_FIELD(pkt_len);
  2396. IPA_DUMP_STATUS_FIELD(endp_src_idx);
  2397. IPA_DUMP_STATUS_FIELD(endp_dest_idx);
  2398. IPA_DUMP_STATUS_FIELD(metadata);
  2399. IPA_DUMP_STATUS_FIELD(flt_local);
  2400. IPA_DUMP_STATUS_FIELD(flt_hash);
  2401. IPA_DUMP_STATUS_FIELD(flt_global);
  2402. IPA_DUMP_STATUS_FIELD(flt_ret_hdr);
  2403. IPA_DUMP_STATUS_FIELD(flt_miss);
  2404. IPA_DUMP_STATUS_FIELD(flt_rule_id);
  2405. IPA_DUMP_STATUS_FIELD(rt_local);
  2406. IPA_DUMP_STATUS_FIELD(rt_hash);
  2407. IPA_DUMP_STATUS_FIELD(ucp);
  2408. IPA_DUMP_STATUS_FIELD(rt_tbl_idx);
  2409. IPA_DUMP_STATUS_FIELD(rt_miss);
  2410. IPA_DUMP_STATUS_FIELD(rt_rule_id);
  2411. IPA_DUMP_STATUS_FIELD(nat_hit);
  2412. IPA_DUMP_STATUS_FIELD(nat_entry_idx);
  2413. IPA_DUMP_STATUS_FIELD(nat_type);
  2414. pr_err("tag = 0x%llx\n", (u64)status->tag_info & 0xFFFFFFFFFFFF);
  2415. IPA_DUMP_STATUS_FIELD(seq_num);
  2416. IPA_DUMP_STATUS_FIELD(time_of_day_ctr);
  2417. IPA_DUMP_STATUS_FIELD(hdr_local);
  2418. IPA_DUMP_STATUS_FIELD(hdr_offset);
  2419. IPA_DUMP_STATUS_FIELD(frag_hit);
  2420. IPA_DUMP_STATUS_FIELD(frag_rule);
  2421. }
  2422. static ssize_t ipa_status_stats_read(struct file *file, char __user *ubuf,
  2423. size_t count, loff_t *ppos)
  2424. {
  2425. struct ipa3_status_stats *stats;
  2426. int i, j;
  2427. stats = kzalloc(sizeof(*stats), GFP_KERNEL);
  2428. if (!stats)
  2429. return -EFAULT;
  2430. for (i = 0; i < ipa3_ctx->ipa_num_pipes; i++) {
  2431. if (!ipa3_ctx->ep[i].sys || !ipa3_ctx->ep[i].sys->status_stat)
  2432. continue;
  2433. memcpy(stats, ipa3_ctx->ep[i].sys->status_stat, sizeof(*stats));
  2434. pr_err("Statuses for pipe %d\n", i);
  2435. for (j = 0; j < IPA_MAX_STATUS_STAT_NUM; j++) {
  2436. pr_err("curr=%d\n", stats->curr);
  2437. ipa_dump_status(&stats->status[stats->curr]);
  2438. pr_err("\n\n\n");
  2439. stats->curr = (stats->curr + 1) %
  2440. IPA_MAX_STATUS_STAT_NUM;
  2441. }
  2442. }
  2443. kfree(stats);
  2444. return 0;
  2445. }
  2446. static ssize_t ipa3_print_active_clients_log(struct file *file,
  2447. char __user *ubuf, size_t count, loff_t *ppos)
  2448. {
  2449. int cnt;
  2450. int table_size;
  2451. if (active_clients_buf == NULL) {
  2452. IPAERR("Active Clients buffer is not allocated");
  2453. return 0;
  2454. }
  2455. memset(active_clients_buf, 0, IPA_DBG_ACTIVE_CLIENT_BUF_SIZE);
  2456. mutex_lock(&ipa3_ctx->ipa3_active_clients.mutex);
  2457. cnt = ipa3_active_clients_log_print_buffer(active_clients_buf,
  2458. IPA_DBG_ACTIVE_CLIENT_BUF_SIZE - IPA_MAX_MSG_LEN);
  2459. table_size = ipa3_active_clients_log_print_table(active_clients_buf
  2460. + cnt, IPA_MAX_MSG_LEN);
  2461. mutex_unlock(&ipa3_ctx->ipa3_active_clients.mutex);
  2462. return simple_read_from_buffer(ubuf, count, ppos,
  2463. active_clients_buf, cnt + table_size);
  2464. }
  2465. static ssize_t ipa3_clear_active_clients_log(struct file *file,
  2466. const char __user *ubuf, size_t count, loff_t *ppos)
  2467. {
  2468. ipa3_active_clients_log_clear();
  2469. return count;
  2470. }
  2471. static ssize_t ipa3_enable_ipc_low(struct file *file,
  2472. const char __user *ubuf, size_t count, loff_t *ppos)
  2473. {
  2474. s8 option = 0;
  2475. int ret;
  2476. ret = kstrtos8_from_user(ubuf, count, 0, &option);
  2477. if (ret)
  2478. return ret;
  2479. mutex_lock(&ipa3_ctx->lock);
  2480. if (option) {
  2481. if (!ipa_ipc_low_buff) {
  2482. ipa_ipc_low_buff =
  2483. ipc_log_context_create(IPA_IPC_LOG_PAGES,
  2484. "ipa_low", 0);
  2485. }
  2486. if (ipa_ipc_low_buff == NULL)
  2487. IPADBG("failed to get logbuf_low\n");
  2488. ipa3_ctx->logbuf_low = ipa_ipc_low_buff;
  2489. } else {
  2490. ipa3_ctx->logbuf_low = NULL;
  2491. }
  2492. mutex_unlock(&ipa3_ctx->lock);
  2493. return count;
  2494. }
  2495. static const struct ipa3_debugfs_file debugfs_files[] = {
  2496. {
  2497. "gen_reg", IPA_READ_ONLY_MODE, NULL, {
  2498. .read = ipa3_read_gen_reg
  2499. }
  2500. }, {
  2501. "active_clients", IPA_READ_WRITE_MODE, NULL, {
  2502. .read = ipa3_print_active_clients_log,
  2503. .write = ipa3_clear_active_clients_log
  2504. }
  2505. }, {
  2506. "ep_reg", IPA_READ_WRITE_MODE, NULL, {
  2507. .read = ipa3_read_ep_reg,
  2508. .write = ipa3_write_ep_reg,
  2509. }
  2510. }, {
  2511. "keep_awake", IPA_READ_WRITE_MODE, NULL, {
  2512. .read = ipa3_read_keep_awake,
  2513. .write = ipa3_write_keep_awake,
  2514. }
  2515. }, {
  2516. "holb", IPA_WRITE_ONLY_MODE, NULL, {
  2517. .write = ipa3_write_ep_holb,
  2518. }
  2519. }, {
  2520. "hdr", IPA_READ_ONLY_MODE, NULL, {
  2521. .read = ipa3_read_hdr,
  2522. }
  2523. }, {
  2524. "proc_ctx", IPA_READ_ONLY_MODE, NULL, {
  2525. .read = ipa3_read_proc_ctx,
  2526. }
  2527. }, {
  2528. "ip4_rt", IPA_READ_ONLY_MODE, (void *)IPA_IP_v4, {
  2529. .read = ipa3_read_rt,
  2530. .open = ipa3_open_dbg,
  2531. }
  2532. }, {
  2533. "ip4_rt_hw", IPA_READ_ONLY_MODE, (void *)IPA_IP_v4, {
  2534. .read = ipa3_read_rt_hw,
  2535. .open = ipa3_open_dbg,
  2536. }
  2537. }, {
  2538. "ip6_rt", IPA_READ_ONLY_MODE, (void *)IPA_IP_v6, {
  2539. .read = ipa3_read_rt,
  2540. .open = ipa3_open_dbg,
  2541. }
  2542. }, {
  2543. "ip6_rt_hw", IPA_READ_ONLY_MODE, (void *)IPA_IP_v6, {
  2544. .read = ipa3_read_rt_hw,
  2545. .open = ipa3_open_dbg,
  2546. }
  2547. }, {
  2548. "ip4_flt", IPA_READ_ONLY_MODE, (void *)IPA_IP_v4, {
  2549. .read = ipa3_read_flt,
  2550. .open = ipa3_open_dbg,
  2551. }
  2552. }, {
  2553. "ip4_flt_hw", IPA_READ_ONLY_MODE, (void *)IPA_IP_v4, {
  2554. .read = ipa3_read_flt_hw,
  2555. .open = ipa3_open_dbg,
  2556. }
  2557. }, {
  2558. "ip6_flt", IPA_READ_ONLY_MODE, (void *)IPA_IP_v6, {
  2559. .read = ipa3_read_flt,
  2560. .open = ipa3_open_dbg,
  2561. }
  2562. }, {
  2563. "ip6_flt_hw", IPA_READ_ONLY_MODE, (void *)IPA_IP_v6, {
  2564. .read = ipa3_read_flt_hw,
  2565. .open = ipa3_open_dbg,
  2566. }
  2567. }, {
  2568. "stats", IPA_READ_ONLY_MODE, NULL, {
  2569. .read = ipa3_read_stats,
  2570. }
  2571. }, {
  2572. "wstats", IPA_READ_ONLY_MODE, NULL, {
  2573. .read = ipa3_read_wstats,
  2574. }
  2575. }, {
  2576. "odlstats", IPA_READ_ONLY_MODE, NULL, {
  2577. .read = ipa3_read_odlstats,
  2578. }
  2579. }, {
  2580. "page_recycle_stats", IPA_READ_ONLY_MODE, NULL, {
  2581. .read = ipa3_read_page_recycle_stats,
  2582. }
  2583. }, {
  2584. "wdi", IPA_READ_ONLY_MODE, NULL, {
  2585. .read = ipa3_read_wdi,
  2586. }
  2587. }, {
  2588. "ntn", IPA_READ_ONLY_MODE, NULL, {
  2589. .read = ipa3_read_ntn,
  2590. }
  2591. }, {
  2592. "dbg_cnt", IPA_READ_WRITE_MODE, NULL, {
  2593. .read = ipa3_read_dbg_cnt,
  2594. .write = ipa3_write_dbg_cnt,
  2595. }
  2596. }, {
  2597. "msg", IPA_READ_ONLY_MODE, NULL, {
  2598. .read = ipa3_read_msg,
  2599. }
  2600. }, {
  2601. "ip4_nat", IPA_READ_ONLY_MODE, NULL, {
  2602. .read = ipa3_read_nat4,
  2603. }
  2604. }, {
  2605. "ipv6ct", IPA_READ_ONLY_MODE, NULL, {
  2606. .read = ipa3_read_ipv6ct,
  2607. }
  2608. }, {
  2609. "pm_stats", IPA_READ_ONLY_MODE, NULL, {
  2610. .read = ipa3_pm_read_stats,
  2611. }
  2612. }, {
  2613. "pm_ex_stats", IPA_READ_ONLY_MODE, NULL, {
  2614. .read = ipa3_pm_ex_read_stats,
  2615. }
  2616. }, {
  2617. "status_stats", IPA_READ_ONLY_MODE, NULL, {
  2618. .read = ipa_status_stats_read,
  2619. }
  2620. }, {
  2621. "enable_low_prio_print", IPA_WRITE_ONLY_MODE, NULL, {
  2622. .write = ipa3_enable_ipc_low,
  2623. }
  2624. }, {
  2625. "ipa_dump_regs", IPA_READ_ONLY_MODE, NULL, {
  2626. .read = ipa3_read_ipahal_regs,
  2627. }
  2628. }, {
  2629. "wdi_gsi_stats", IPA_READ_ONLY_MODE, NULL, {
  2630. .read = ipa3_read_wdi_gsi_stats,
  2631. }
  2632. }, {
  2633. "wdi3_gsi_stats", IPA_READ_ONLY_MODE, NULL, {
  2634. .read = ipa3_read_wdi3_gsi_stats,
  2635. }
  2636. }, {
  2637. "11ad_gsi_stats", IPA_READ_ONLY_MODE, NULL, {
  2638. .read = ipa3_read_11ad_gsi_stats,
  2639. }
  2640. }, {
  2641. "aqc_gsi_stats", IPA_READ_ONLY_MODE, NULL, {
  2642. .read = ipa3_read_aqc_gsi_stats,
  2643. }
  2644. }, {
  2645. "mhip_gsi_stats", IPA_READ_ONLY_MODE, NULL, {
  2646. .read = ipa3_read_mhip_gsi_stats,
  2647. }
  2648. }, {
  2649. "usb_gsi_stats", IPA_READ_ONLY_MODE, NULL, {
  2650. .read = ipa3_read_usb_gsi_stats,
  2651. }
  2652. }, {
  2653. "app_clk_vote_cnt", IPA_READ_ONLY_MODE, NULL, {
  2654. .read = ipa3_read_app_clk_vote,
  2655. }
  2656. },
  2657. };
  2658. void ipa3_debugfs_init(void)
  2659. {
  2660. const size_t debugfs_files_num =
  2661. sizeof(debugfs_files) / sizeof(struct ipa3_debugfs_file);
  2662. size_t i;
  2663. struct dentry *file;
  2664. dent = debugfs_create_dir("ipa", 0);
  2665. if (IS_ERR(dent)) {
  2666. IPAERR("fail to create folder in debug_fs.\n");
  2667. return;
  2668. }
  2669. file = debugfs_create_u32("hw_type", IPA_READ_ONLY_MODE,
  2670. dent, &ipa3_ctx->ipa_hw_type);
  2671. if (!file) {
  2672. IPAERR("could not create hw_type file\n");
  2673. goto fail;
  2674. }
  2675. for (i = 0; i < debugfs_files_num; ++i) {
  2676. const struct ipa3_debugfs_file *curr = &debugfs_files[i];
  2677. file = debugfs_create_file(curr->name, curr->mode, dent,
  2678. curr->data, &curr->fops);
  2679. if (!file || IS_ERR(file)) {
  2680. IPAERR("fail to create file for debug_fs %s\n",
  2681. curr->name);
  2682. goto fail;
  2683. }
  2684. }
  2685. active_clients_buf = NULL;
  2686. active_clients_buf = kzalloc(IPA_DBG_ACTIVE_CLIENT_BUF_SIZE,
  2687. GFP_KERNEL);
  2688. if (active_clients_buf == NULL)
  2689. goto fail;
  2690. file = debugfs_create_u32("enable_clock_scaling", IPA_READ_WRITE_MODE,
  2691. dent, &ipa3_ctx->enable_clock_scaling);
  2692. if (!file) {
  2693. IPAERR("could not create enable_clock_scaling file\n");
  2694. goto fail;
  2695. }
  2696. file = debugfs_create_u32("enable_napi_chain", IPA_READ_WRITE_MODE,
  2697. dent, &ipa3_ctx->enable_napi_chain);
  2698. if (!file) {
  2699. IPAERR("could not create enable_napi_chain file\n");
  2700. goto fail;
  2701. }
  2702. file = debugfs_create_u32("clock_scaling_bw_threshold_nominal_mbps",
  2703. IPA_READ_WRITE_MODE, dent,
  2704. &ipa3_ctx->ctrl->clock_scaling_bw_threshold_nominal);
  2705. if (!file) {
  2706. IPAERR("could not create bw_threshold_nominal_mbps\n");
  2707. goto fail;
  2708. }
  2709. file = debugfs_create_u32("clock_scaling_bw_threshold_turbo_mbps",
  2710. IPA_READ_WRITE_MODE, dent,
  2711. &ipa3_ctx->ctrl->clock_scaling_bw_threshold_turbo);
  2712. if (!file) {
  2713. IPAERR("could not create bw_threshold_turbo_mbps\n");
  2714. goto fail;
  2715. }
  2716. file = debugfs_create_u32("clk_rate", IPA_READ_ONLY_MODE,
  2717. dent, &ipa3_ctx->curr_ipa_clk_rate);
  2718. if (!file) {
  2719. IPAERR("could not create clk_rate file\n");
  2720. goto fail;
  2721. }
  2722. ipa_debugfs_init_stats(dent);
  2723. ipa3_wigig_init_debugfs_i(dent);
  2724. return;
  2725. fail:
  2726. debugfs_remove_recursive(dent);
  2727. }
  2728. void ipa3_debugfs_remove(void)
  2729. {
  2730. if (IS_ERR(dent)) {
  2731. IPAERR("Debugfs:folder was not created.\n");
  2732. return;
  2733. }
  2734. if (active_clients_buf != NULL) {
  2735. kfree(active_clients_buf);
  2736. active_clients_buf = NULL;
  2737. }
  2738. debugfs_remove_recursive(dent);
  2739. }
  2740. struct dentry *ipa_debugfs_get_root(void)
  2741. {
  2742. return dent;
  2743. }
  2744. EXPORT_SYMBOL(ipa_debugfs_get_root);
  2745. #else /* !CONFIG_DEBUG_FS */
  2746. void ipa3_debugfs_init(void) {}
  2747. void ipa3_debugfs_remove(void) {}
  2748. #endif