ipa_debugfs.c 67 KB

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