cxgb4_debugfs.c 86 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102
  1. /*
  2. * This file is part of the Chelsio T4 Ethernet driver for Linux.
  3. *
  4. * Copyright (c) 2003-2014 Chelsio Communications, Inc. All rights reserved.
  5. *
  6. * This software is available to you under a choice of one of two
  7. * licenses. You may choose to be licensed under the terms of the GNU
  8. * General Public License (GPL) Version 2, available from the file
  9. * COPYING in the main directory of this source tree, or the
  10. * OpenIB.org BSD license below:
  11. *
  12. * Redistribution and use in source and binary forms, with or
  13. * without modification, are permitted provided that the following
  14. * conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above
  17. * copyright notice, this list of conditions and the following
  18. * disclaimer.
  19. *
  20. * - Redistributions in binary form must reproduce the above
  21. * copyright notice, this list of conditions and the following
  22. * disclaimer in the documentation and/or other materials
  23. * provided with the distribution.
  24. *
  25. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  28. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  29. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  30. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  31. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32. * SOFTWARE.
  33. */
  34. #include <linux/seq_file.h>
  35. #include <linux/debugfs.h>
  36. #include <linux/string_helpers.h>
  37. #include <linux/sort.h>
  38. #include <linux/ctype.h>
  39. #include "cxgb4.h"
  40. #include "t4_regs.h"
  41. #include "t4_values.h"
  42. #include "t4fw_api.h"
  43. #include "cxgb4_debugfs.h"
  44. #include "clip_tbl.h"
  45. #include "l2t.h"
  46. /* generic seq_file support for showing a table of size rows x width. */
  47. static void *seq_tab_get_idx(struct seq_tab *tb, loff_t pos)
  48. {
  49. pos -= tb->skip_first;
  50. return pos >= tb->rows ? NULL : &tb->data[pos * tb->width];
  51. }
  52. static void *seq_tab_start(struct seq_file *seq, loff_t *pos)
  53. {
  54. struct seq_tab *tb = seq->private;
  55. if (tb->skip_first && *pos == 0)
  56. return SEQ_START_TOKEN;
  57. return seq_tab_get_idx(tb, *pos);
  58. }
  59. static void *seq_tab_next(struct seq_file *seq, void *v, loff_t *pos)
  60. {
  61. v = seq_tab_get_idx(seq->private, *pos + 1);
  62. if (v)
  63. ++*pos;
  64. return v;
  65. }
  66. static void seq_tab_stop(struct seq_file *seq, void *v)
  67. {
  68. }
  69. static int seq_tab_show(struct seq_file *seq, void *v)
  70. {
  71. const struct seq_tab *tb = seq->private;
  72. return tb->show(seq, v, ((char *)v - tb->data) / tb->width);
  73. }
  74. static const struct seq_operations seq_tab_ops = {
  75. .start = seq_tab_start,
  76. .next = seq_tab_next,
  77. .stop = seq_tab_stop,
  78. .show = seq_tab_show
  79. };
  80. struct seq_tab *seq_open_tab(struct file *f, unsigned int rows,
  81. unsigned int width, unsigned int have_header,
  82. int (*show)(struct seq_file *seq, void *v, int i))
  83. {
  84. struct seq_tab *p;
  85. p = __seq_open_private(f, &seq_tab_ops, sizeof(*p) + rows * width);
  86. if (p) {
  87. p->show = show;
  88. p->rows = rows;
  89. p->width = width;
  90. p->skip_first = have_header != 0;
  91. }
  92. return p;
  93. }
  94. /* Trim the size of a seq_tab to the supplied number of rows. The operation is
  95. * irreversible.
  96. */
  97. static int seq_tab_trim(struct seq_tab *p, unsigned int new_rows)
  98. {
  99. if (new_rows > p->rows)
  100. return -EINVAL;
  101. p->rows = new_rows;
  102. return 0;
  103. }
  104. static int cim_la_show(struct seq_file *seq, void *v, int idx)
  105. {
  106. if (v == SEQ_START_TOKEN)
  107. seq_puts(seq, "Status Data PC LS0Stat LS0Addr "
  108. " LS0Data\n");
  109. else {
  110. const u32 *p = v;
  111. seq_printf(seq,
  112. " %02x %x%07x %x%07x %08x %08x %08x%08x%08x%08x\n",
  113. (p[0] >> 4) & 0xff, p[0] & 0xf, p[1] >> 4,
  114. p[1] & 0xf, p[2] >> 4, p[2] & 0xf, p[3], p[4], p[5],
  115. p[6], p[7]);
  116. }
  117. return 0;
  118. }
  119. static int cim_la_show_3in1(struct seq_file *seq, void *v, int idx)
  120. {
  121. if (v == SEQ_START_TOKEN) {
  122. seq_puts(seq, "Status Data PC\n");
  123. } else {
  124. const u32 *p = v;
  125. seq_printf(seq, " %02x %08x %08x\n", p[5] & 0xff, p[6],
  126. p[7]);
  127. seq_printf(seq, " %02x %02x%06x %02x%06x\n",
  128. (p[3] >> 8) & 0xff, p[3] & 0xff, p[4] >> 8,
  129. p[4] & 0xff, p[5] >> 8);
  130. seq_printf(seq, " %02x %x%07x %x%07x\n", (p[0] >> 4) & 0xff,
  131. p[0] & 0xf, p[1] >> 4, p[1] & 0xf, p[2] >> 4);
  132. }
  133. return 0;
  134. }
  135. static int cim_la_show_t6(struct seq_file *seq, void *v, int idx)
  136. {
  137. if (v == SEQ_START_TOKEN) {
  138. seq_puts(seq, "Status Inst Data PC LS0Stat "
  139. "LS0Addr LS0Data LS1Stat LS1Addr LS1Data\n");
  140. } else {
  141. const u32 *p = v;
  142. seq_printf(seq, " %02x %04x%04x %04x%04x %04x%04x %08x %08x %08x %08x %08x %08x\n",
  143. (p[9] >> 16) & 0xff, /* Status */
  144. p[9] & 0xffff, p[8] >> 16, /* Inst */
  145. p[8] & 0xffff, p[7] >> 16, /* Data */
  146. p[7] & 0xffff, p[6] >> 16, /* PC */
  147. p[2], p[1], p[0], /* LS0 Stat, Addr and Data */
  148. p[5], p[4], p[3]); /* LS1 Stat, Addr and Data */
  149. }
  150. return 0;
  151. }
  152. static int cim_la_show_pc_t6(struct seq_file *seq, void *v, int idx)
  153. {
  154. if (v == SEQ_START_TOKEN) {
  155. seq_puts(seq, "Status Inst Data PC\n");
  156. } else {
  157. const u32 *p = v;
  158. seq_printf(seq, " %02x %08x %08x %08x\n",
  159. p[3] & 0xff, p[2], p[1], p[0]);
  160. seq_printf(seq, " %02x %02x%06x %02x%06x %02x%06x\n",
  161. (p[6] >> 8) & 0xff, p[6] & 0xff, p[5] >> 8,
  162. p[5] & 0xff, p[4] >> 8, p[4] & 0xff, p[3] >> 8);
  163. seq_printf(seq, " %02x %04x%04x %04x%04x %04x%04x\n",
  164. (p[9] >> 16) & 0xff, p[9] & 0xffff, p[8] >> 16,
  165. p[8] & 0xffff, p[7] >> 16, p[7] & 0xffff,
  166. p[6] >> 16);
  167. }
  168. return 0;
  169. }
  170. static int cim_la_open(struct inode *inode, struct file *file)
  171. {
  172. int ret;
  173. unsigned int cfg;
  174. struct seq_tab *p;
  175. struct adapter *adap = inode->i_private;
  176. ret = t4_cim_read(adap, UP_UP_DBG_LA_CFG_A, 1, &cfg);
  177. if (ret)
  178. return ret;
  179. if (is_t6(adap->params.chip)) {
  180. /* +1 to account for integer division of CIMLA_SIZE/10 */
  181. p = seq_open_tab(file, (adap->params.cim_la_size / 10) + 1,
  182. 10 * sizeof(u32), 1,
  183. cfg & UPDBGLACAPTPCONLY_F ?
  184. cim_la_show_pc_t6 : cim_la_show_t6);
  185. } else {
  186. p = seq_open_tab(file, adap->params.cim_la_size / 8,
  187. 8 * sizeof(u32), 1,
  188. cfg & UPDBGLACAPTPCONLY_F ? cim_la_show_3in1 :
  189. cim_la_show);
  190. }
  191. if (!p)
  192. return -ENOMEM;
  193. ret = t4_cim_read_la(adap, (u32 *)p->data, NULL);
  194. if (ret)
  195. seq_release_private(inode, file);
  196. return ret;
  197. }
  198. static const struct file_operations cim_la_fops = {
  199. .owner = THIS_MODULE,
  200. .open = cim_la_open,
  201. .read = seq_read,
  202. .llseek = seq_lseek,
  203. .release = seq_release_private
  204. };
  205. static int cim_pif_la_show(struct seq_file *seq, void *v, int idx)
  206. {
  207. const u32 *p = v;
  208. if (v == SEQ_START_TOKEN) {
  209. seq_puts(seq, "Cntl ID DataBE Addr Data\n");
  210. } else if (idx < CIM_PIFLA_SIZE) {
  211. seq_printf(seq, " %02x %02x %04x %08x %08x%08x%08x%08x\n",
  212. (p[5] >> 22) & 0xff, (p[5] >> 16) & 0x3f,
  213. p[5] & 0xffff, p[4], p[3], p[2], p[1], p[0]);
  214. } else {
  215. if (idx == CIM_PIFLA_SIZE)
  216. seq_puts(seq, "\nCntl ID Data\n");
  217. seq_printf(seq, " %02x %02x %08x%08x%08x%08x\n",
  218. (p[4] >> 6) & 0xff, p[4] & 0x3f,
  219. p[3], p[2], p[1], p[0]);
  220. }
  221. return 0;
  222. }
  223. static int cim_pif_la_open(struct inode *inode, struct file *file)
  224. {
  225. struct seq_tab *p;
  226. struct adapter *adap = inode->i_private;
  227. p = seq_open_tab(file, 2 * CIM_PIFLA_SIZE, 6 * sizeof(u32), 1,
  228. cim_pif_la_show);
  229. if (!p)
  230. return -ENOMEM;
  231. t4_cim_read_pif_la(adap, (u32 *)p->data,
  232. (u32 *)p->data + 6 * CIM_PIFLA_SIZE, NULL, NULL);
  233. return 0;
  234. }
  235. static const struct file_operations cim_pif_la_fops = {
  236. .owner = THIS_MODULE,
  237. .open = cim_pif_la_open,
  238. .read = seq_read,
  239. .llseek = seq_lseek,
  240. .release = seq_release_private
  241. };
  242. static int cim_ma_la_show(struct seq_file *seq, void *v, int idx)
  243. {
  244. const u32 *p = v;
  245. if (v == SEQ_START_TOKEN) {
  246. seq_puts(seq, "\n");
  247. } else if (idx < CIM_MALA_SIZE) {
  248. seq_printf(seq, "%02x%08x%08x%08x%08x\n",
  249. p[4], p[3], p[2], p[1], p[0]);
  250. } else {
  251. if (idx == CIM_MALA_SIZE)
  252. seq_puts(seq,
  253. "\nCnt ID Tag UE Data RDY VLD\n");
  254. seq_printf(seq, "%3u %2u %x %u %08x%08x %u %u\n",
  255. (p[2] >> 10) & 0xff, (p[2] >> 7) & 7,
  256. (p[2] >> 3) & 0xf, (p[2] >> 2) & 1,
  257. (p[1] >> 2) | ((p[2] & 3) << 30),
  258. (p[0] >> 2) | ((p[1] & 3) << 30), (p[0] >> 1) & 1,
  259. p[0] & 1);
  260. }
  261. return 0;
  262. }
  263. static int cim_ma_la_open(struct inode *inode, struct file *file)
  264. {
  265. struct seq_tab *p;
  266. struct adapter *adap = inode->i_private;
  267. p = seq_open_tab(file, 2 * CIM_MALA_SIZE, 5 * sizeof(u32), 1,
  268. cim_ma_la_show);
  269. if (!p)
  270. return -ENOMEM;
  271. t4_cim_read_ma_la(adap, (u32 *)p->data,
  272. (u32 *)p->data + 5 * CIM_MALA_SIZE);
  273. return 0;
  274. }
  275. static const struct file_operations cim_ma_la_fops = {
  276. .owner = THIS_MODULE,
  277. .open = cim_ma_la_open,
  278. .read = seq_read,
  279. .llseek = seq_lseek,
  280. .release = seq_release_private
  281. };
  282. static int cim_qcfg_show(struct seq_file *seq, void *v)
  283. {
  284. static const char * const qname[] = {
  285. "TP0", "TP1", "ULP", "SGE0", "SGE1", "NC-SI",
  286. "ULP0", "ULP1", "ULP2", "ULP3", "SGE", "NC-SI",
  287. "SGE0-RX", "SGE1-RX"
  288. };
  289. int i;
  290. struct adapter *adap = seq->private;
  291. u16 base[CIM_NUM_IBQ + CIM_NUM_OBQ_T5];
  292. u16 size[CIM_NUM_IBQ + CIM_NUM_OBQ_T5];
  293. u32 stat[(4 * (CIM_NUM_IBQ + CIM_NUM_OBQ_T5))];
  294. u16 thres[CIM_NUM_IBQ];
  295. u32 obq_wr_t4[2 * CIM_NUM_OBQ], *wr;
  296. u32 obq_wr_t5[2 * CIM_NUM_OBQ_T5];
  297. u32 *p = stat;
  298. int cim_num_obq = is_t4(adap->params.chip) ?
  299. CIM_NUM_OBQ : CIM_NUM_OBQ_T5;
  300. i = t4_cim_read(adap, is_t4(adap->params.chip) ? UP_IBQ_0_RDADDR_A :
  301. UP_IBQ_0_SHADOW_RDADDR_A,
  302. ARRAY_SIZE(stat), stat);
  303. if (!i) {
  304. if (is_t4(adap->params.chip)) {
  305. i = t4_cim_read(adap, UP_OBQ_0_REALADDR_A,
  306. ARRAY_SIZE(obq_wr_t4), obq_wr_t4);
  307. wr = obq_wr_t4;
  308. } else {
  309. i = t4_cim_read(adap, UP_OBQ_0_SHADOW_REALADDR_A,
  310. ARRAY_SIZE(obq_wr_t5), obq_wr_t5);
  311. wr = obq_wr_t5;
  312. }
  313. }
  314. if (i)
  315. return i;
  316. t4_read_cimq_cfg(adap, base, size, thres);
  317. seq_printf(seq,
  318. " Queue Base Size Thres RdPtr WrPtr SOP EOP Avail\n");
  319. for (i = 0; i < CIM_NUM_IBQ; i++, p += 4)
  320. seq_printf(seq, "%7s %5x %5u %5u %6x %4x %4u %4u %5u\n",
  321. qname[i], base[i], size[i], thres[i],
  322. IBQRDADDR_G(p[0]), IBQWRADDR_G(p[1]),
  323. QUESOPCNT_G(p[3]), QUEEOPCNT_G(p[3]),
  324. QUEREMFLITS_G(p[2]) * 16);
  325. for ( ; i < CIM_NUM_IBQ + cim_num_obq; i++, p += 4, wr += 2)
  326. seq_printf(seq, "%7s %5x %5u %12x %4x %4u %4u %5u\n",
  327. qname[i], base[i], size[i],
  328. QUERDADDR_G(p[0]) & 0x3fff, wr[0] - base[i],
  329. QUESOPCNT_G(p[3]), QUEEOPCNT_G(p[3]),
  330. QUEREMFLITS_G(p[2]) * 16);
  331. return 0;
  332. }
  333. static int cim_qcfg_open(struct inode *inode, struct file *file)
  334. {
  335. return single_open(file, cim_qcfg_show, inode->i_private);
  336. }
  337. static const struct file_operations cim_qcfg_fops = {
  338. .owner = THIS_MODULE,
  339. .open = cim_qcfg_open,
  340. .read = seq_read,
  341. .llseek = seq_lseek,
  342. .release = single_release,
  343. };
  344. static int cimq_show(struct seq_file *seq, void *v, int idx)
  345. {
  346. const u32 *p = v;
  347. seq_printf(seq, "%#06x: %08x %08x %08x %08x\n", idx * 16, p[0], p[1],
  348. p[2], p[3]);
  349. return 0;
  350. }
  351. static int cim_ibq_open(struct inode *inode, struct file *file)
  352. {
  353. int ret;
  354. struct seq_tab *p;
  355. unsigned int qid = (uintptr_t)inode->i_private & 7;
  356. struct adapter *adap = inode->i_private - qid;
  357. p = seq_open_tab(file, CIM_IBQ_SIZE, 4 * sizeof(u32), 0, cimq_show);
  358. if (!p)
  359. return -ENOMEM;
  360. ret = t4_read_cim_ibq(adap, qid, (u32 *)p->data, CIM_IBQ_SIZE * 4);
  361. if (ret < 0)
  362. seq_release_private(inode, file);
  363. else
  364. ret = 0;
  365. return ret;
  366. }
  367. static const struct file_operations cim_ibq_fops = {
  368. .owner = THIS_MODULE,
  369. .open = cim_ibq_open,
  370. .read = seq_read,
  371. .llseek = seq_lseek,
  372. .release = seq_release_private
  373. };
  374. static int cim_obq_open(struct inode *inode, struct file *file)
  375. {
  376. int ret;
  377. struct seq_tab *p;
  378. unsigned int qid = (uintptr_t)inode->i_private & 7;
  379. struct adapter *adap = inode->i_private - qid;
  380. p = seq_open_tab(file, 6 * CIM_OBQ_SIZE, 4 * sizeof(u32), 0, cimq_show);
  381. if (!p)
  382. return -ENOMEM;
  383. ret = t4_read_cim_obq(adap, qid, (u32 *)p->data, 6 * CIM_OBQ_SIZE * 4);
  384. if (ret < 0) {
  385. seq_release_private(inode, file);
  386. } else {
  387. seq_tab_trim(p, ret / 4);
  388. ret = 0;
  389. }
  390. return ret;
  391. }
  392. static const struct file_operations cim_obq_fops = {
  393. .owner = THIS_MODULE,
  394. .open = cim_obq_open,
  395. .read = seq_read,
  396. .llseek = seq_lseek,
  397. .release = seq_release_private
  398. };
  399. struct field_desc {
  400. const char *name;
  401. unsigned int start;
  402. unsigned int width;
  403. };
  404. static void field_desc_show(struct seq_file *seq, u64 v,
  405. const struct field_desc *p)
  406. {
  407. char buf[32];
  408. int line_size = 0;
  409. while (p->name) {
  410. u64 mask = (1ULL << p->width) - 1;
  411. int len = scnprintf(buf, sizeof(buf), "%s: %llu", p->name,
  412. ((unsigned long long)v >> p->start) & mask);
  413. if (line_size + len >= 79) {
  414. line_size = 8;
  415. seq_puts(seq, "\n ");
  416. }
  417. seq_printf(seq, "%s ", buf);
  418. line_size += len + 1;
  419. p++;
  420. }
  421. seq_putc(seq, '\n');
  422. }
  423. static struct field_desc tp_la0[] = {
  424. { "RcfOpCodeOut", 60, 4 },
  425. { "State", 56, 4 },
  426. { "WcfState", 52, 4 },
  427. { "RcfOpcSrcOut", 50, 2 },
  428. { "CRxError", 49, 1 },
  429. { "ERxError", 48, 1 },
  430. { "SanityFailed", 47, 1 },
  431. { "SpuriousMsg", 46, 1 },
  432. { "FlushInputMsg", 45, 1 },
  433. { "FlushInputCpl", 44, 1 },
  434. { "RssUpBit", 43, 1 },
  435. { "RssFilterHit", 42, 1 },
  436. { "Tid", 32, 10 },
  437. { "InitTcb", 31, 1 },
  438. { "LineNumber", 24, 7 },
  439. { "Emsg", 23, 1 },
  440. { "EdataOut", 22, 1 },
  441. { "Cmsg", 21, 1 },
  442. { "CdataOut", 20, 1 },
  443. { "EreadPdu", 19, 1 },
  444. { "CreadPdu", 18, 1 },
  445. { "TunnelPkt", 17, 1 },
  446. { "RcfPeerFin", 16, 1 },
  447. { "RcfReasonOut", 12, 4 },
  448. { "TxCchannel", 10, 2 },
  449. { "RcfTxChannel", 8, 2 },
  450. { "RxEchannel", 6, 2 },
  451. { "RcfRxChannel", 5, 1 },
  452. { "RcfDataOutSrdy", 4, 1 },
  453. { "RxDvld", 3, 1 },
  454. { "RxOoDvld", 2, 1 },
  455. { "RxCongestion", 1, 1 },
  456. { "TxCongestion", 0, 1 },
  457. { NULL }
  458. };
  459. static int tp_la_show(struct seq_file *seq, void *v, int idx)
  460. {
  461. const u64 *p = v;
  462. field_desc_show(seq, *p, tp_la0);
  463. return 0;
  464. }
  465. static int tp_la_show2(struct seq_file *seq, void *v, int idx)
  466. {
  467. const u64 *p = v;
  468. if (idx)
  469. seq_putc(seq, '\n');
  470. field_desc_show(seq, p[0], tp_la0);
  471. if (idx < (TPLA_SIZE / 2 - 1) || p[1] != ~0ULL)
  472. field_desc_show(seq, p[1], tp_la0);
  473. return 0;
  474. }
  475. static int tp_la_show3(struct seq_file *seq, void *v, int idx)
  476. {
  477. static struct field_desc tp_la1[] = {
  478. { "CplCmdIn", 56, 8 },
  479. { "CplCmdOut", 48, 8 },
  480. { "ESynOut", 47, 1 },
  481. { "EAckOut", 46, 1 },
  482. { "EFinOut", 45, 1 },
  483. { "ERstOut", 44, 1 },
  484. { "SynIn", 43, 1 },
  485. { "AckIn", 42, 1 },
  486. { "FinIn", 41, 1 },
  487. { "RstIn", 40, 1 },
  488. { "DataIn", 39, 1 },
  489. { "DataInVld", 38, 1 },
  490. { "PadIn", 37, 1 },
  491. { "RxBufEmpty", 36, 1 },
  492. { "RxDdp", 35, 1 },
  493. { "RxFbCongestion", 34, 1 },
  494. { "TxFbCongestion", 33, 1 },
  495. { "TxPktSumSrdy", 32, 1 },
  496. { "RcfUlpType", 28, 4 },
  497. { "Eread", 27, 1 },
  498. { "Ebypass", 26, 1 },
  499. { "Esave", 25, 1 },
  500. { "Static0", 24, 1 },
  501. { "Cread", 23, 1 },
  502. { "Cbypass", 22, 1 },
  503. { "Csave", 21, 1 },
  504. { "CPktOut", 20, 1 },
  505. { "RxPagePoolFull", 18, 2 },
  506. { "RxLpbkPkt", 17, 1 },
  507. { "TxLpbkPkt", 16, 1 },
  508. { "RxVfValid", 15, 1 },
  509. { "SynLearned", 14, 1 },
  510. { "SetDelEntry", 13, 1 },
  511. { "SetInvEntry", 12, 1 },
  512. { "CpcmdDvld", 11, 1 },
  513. { "CpcmdSave", 10, 1 },
  514. { "RxPstructsFull", 8, 2 },
  515. { "EpcmdDvld", 7, 1 },
  516. { "EpcmdFlush", 6, 1 },
  517. { "EpcmdTrimPrefix", 5, 1 },
  518. { "EpcmdTrimPostfix", 4, 1 },
  519. { "ERssIp4Pkt", 3, 1 },
  520. { "ERssIp6Pkt", 2, 1 },
  521. { "ERssTcpUdpPkt", 1, 1 },
  522. { "ERssFceFipPkt", 0, 1 },
  523. { NULL }
  524. };
  525. static struct field_desc tp_la2[] = {
  526. { "CplCmdIn", 56, 8 },
  527. { "MpsVfVld", 55, 1 },
  528. { "MpsPf", 52, 3 },
  529. { "MpsVf", 44, 8 },
  530. { "SynIn", 43, 1 },
  531. { "AckIn", 42, 1 },
  532. { "FinIn", 41, 1 },
  533. { "RstIn", 40, 1 },
  534. { "DataIn", 39, 1 },
  535. { "DataInVld", 38, 1 },
  536. { "PadIn", 37, 1 },
  537. { "RxBufEmpty", 36, 1 },
  538. { "RxDdp", 35, 1 },
  539. { "RxFbCongestion", 34, 1 },
  540. { "TxFbCongestion", 33, 1 },
  541. { "TxPktSumSrdy", 32, 1 },
  542. { "RcfUlpType", 28, 4 },
  543. { "Eread", 27, 1 },
  544. { "Ebypass", 26, 1 },
  545. { "Esave", 25, 1 },
  546. { "Static0", 24, 1 },
  547. { "Cread", 23, 1 },
  548. { "Cbypass", 22, 1 },
  549. { "Csave", 21, 1 },
  550. { "CPktOut", 20, 1 },
  551. { "RxPagePoolFull", 18, 2 },
  552. { "RxLpbkPkt", 17, 1 },
  553. { "TxLpbkPkt", 16, 1 },
  554. { "RxVfValid", 15, 1 },
  555. { "SynLearned", 14, 1 },
  556. { "SetDelEntry", 13, 1 },
  557. { "SetInvEntry", 12, 1 },
  558. { "CpcmdDvld", 11, 1 },
  559. { "CpcmdSave", 10, 1 },
  560. { "RxPstructsFull", 8, 2 },
  561. { "EpcmdDvld", 7, 1 },
  562. { "EpcmdFlush", 6, 1 },
  563. { "EpcmdTrimPrefix", 5, 1 },
  564. { "EpcmdTrimPostfix", 4, 1 },
  565. { "ERssIp4Pkt", 3, 1 },
  566. { "ERssIp6Pkt", 2, 1 },
  567. { "ERssTcpUdpPkt", 1, 1 },
  568. { "ERssFceFipPkt", 0, 1 },
  569. { NULL }
  570. };
  571. const u64 *p = v;
  572. if (idx)
  573. seq_putc(seq, '\n');
  574. field_desc_show(seq, p[0], tp_la0);
  575. if (idx < (TPLA_SIZE / 2 - 1) || p[1] != ~0ULL)
  576. field_desc_show(seq, p[1], (p[0] & BIT(17)) ? tp_la2 : tp_la1);
  577. return 0;
  578. }
  579. static int tp_la_open(struct inode *inode, struct file *file)
  580. {
  581. struct seq_tab *p;
  582. struct adapter *adap = inode->i_private;
  583. switch (DBGLAMODE_G(t4_read_reg(adap, TP_DBG_LA_CONFIG_A))) {
  584. case 2:
  585. p = seq_open_tab(file, TPLA_SIZE / 2, 2 * sizeof(u64), 0,
  586. tp_la_show2);
  587. break;
  588. case 3:
  589. p = seq_open_tab(file, TPLA_SIZE / 2, 2 * sizeof(u64), 0,
  590. tp_la_show3);
  591. break;
  592. default:
  593. p = seq_open_tab(file, TPLA_SIZE, sizeof(u64), 0, tp_la_show);
  594. }
  595. if (!p)
  596. return -ENOMEM;
  597. t4_tp_read_la(adap, (u64 *)p->data, NULL);
  598. return 0;
  599. }
  600. static ssize_t tp_la_write(struct file *file, const char __user *buf,
  601. size_t count, loff_t *pos)
  602. {
  603. int err;
  604. char s[32];
  605. unsigned long val;
  606. size_t size = min(sizeof(s) - 1, count);
  607. struct adapter *adap = file_inode(file)->i_private;
  608. if (copy_from_user(s, buf, size))
  609. return -EFAULT;
  610. s[size] = '\0';
  611. err = kstrtoul(s, 0, &val);
  612. if (err)
  613. return err;
  614. if (val > 0xffff)
  615. return -EINVAL;
  616. adap->params.tp.la_mask = val << 16;
  617. t4_set_reg_field(adap, TP_DBG_LA_CONFIG_A, 0xffff0000U,
  618. adap->params.tp.la_mask);
  619. return count;
  620. }
  621. static const struct file_operations tp_la_fops = {
  622. .owner = THIS_MODULE,
  623. .open = tp_la_open,
  624. .read = seq_read,
  625. .llseek = seq_lseek,
  626. .release = seq_release_private,
  627. .write = tp_la_write
  628. };
  629. static int ulprx_la_show(struct seq_file *seq, void *v, int idx)
  630. {
  631. const u32 *p = v;
  632. if (v == SEQ_START_TOKEN)
  633. seq_puts(seq, " Pcmd Type Message"
  634. " Data\n");
  635. else
  636. seq_printf(seq, "%08x%08x %4x %08x %08x%08x%08x%08x\n",
  637. p[1], p[0], p[2], p[3], p[7], p[6], p[5], p[4]);
  638. return 0;
  639. }
  640. static int ulprx_la_open(struct inode *inode, struct file *file)
  641. {
  642. struct seq_tab *p;
  643. struct adapter *adap = inode->i_private;
  644. p = seq_open_tab(file, ULPRX_LA_SIZE, 8 * sizeof(u32), 1,
  645. ulprx_la_show);
  646. if (!p)
  647. return -ENOMEM;
  648. t4_ulprx_read_la(adap, (u32 *)p->data);
  649. return 0;
  650. }
  651. static const struct file_operations ulprx_la_fops = {
  652. .owner = THIS_MODULE,
  653. .open = ulprx_la_open,
  654. .read = seq_read,
  655. .llseek = seq_lseek,
  656. .release = seq_release_private
  657. };
  658. /* Show the PM memory stats. These stats include:
  659. *
  660. * TX:
  661. * Read: memory read operation
  662. * Write Bypass: cut-through
  663. * Bypass + mem: cut-through and save copy
  664. *
  665. * RX:
  666. * Read: memory read
  667. * Write Bypass: cut-through
  668. * Flush: payload trim or drop
  669. */
  670. static int pm_stats_show(struct seq_file *seq, void *v)
  671. {
  672. static const char * const tx_pm_stats[] = {
  673. "Read:", "Write bypass:", "Write mem:", "Bypass + mem:"
  674. };
  675. static const char * const rx_pm_stats[] = {
  676. "Read:", "Write bypass:", "Write mem:", "Flush:"
  677. };
  678. int i;
  679. u32 tx_cnt[PM_NSTATS], rx_cnt[PM_NSTATS];
  680. u64 tx_cyc[PM_NSTATS], rx_cyc[PM_NSTATS];
  681. struct adapter *adap = seq->private;
  682. t4_pmtx_get_stats(adap, tx_cnt, tx_cyc);
  683. t4_pmrx_get_stats(adap, rx_cnt, rx_cyc);
  684. seq_printf(seq, "%13s %10s %20s\n", " ", "Tx pcmds", "Tx bytes");
  685. for (i = 0; i < PM_NSTATS - 1; i++)
  686. seq_printf(seq, "%-13s %10u %20llu\n",
  687. tx_pm_stats[i], tx_cnt[i], tx_cyc[i]);
  688. seq_printf(seq, "%13s %10s %20s\n", " ", "Rx pcmds", "Rx bytes");
  689. for (i = 0; i < PM_NSTATS - 1; i++)
  690. seq_printf(seq, "%-13s %10u %20llu\n",
  691. rx_pm_stats[i], rx_cnt[i], rx_cyc[i]);
  692. return 0;
  693. }
  694. static int pm_stats_open(struct inode *inode, struct file *file)
  695. {
  696. return single_open(file, pm_stats_show, inode->i_private);
  697. }
  698. static ssize_t pm_stats_clear(struct file *file, const char __user *buf,
  699. size_t count, loff_t *pos)
  700. {
  701. struct adapter *adap = file_inode(file)->i_private;
  702. t4_write_reg(adap, PM_RX_STAT_CONFIG_A, 0);
  703. t4_write_reg(adap, PM_TX_STAT_CONFIG_A, 0);
  704. return count;
  705. }
  706. static const struct file_operations pm_stats_debugfs_fops = {
  707. .owner = THIS_MODULE,
  708. .open = pm_stats_open,
  709. .read = seq_read,
  710. .llseek = seq_lseek,
  711. .release = single_release,
  712. .write = pm_stats_clear
  713. };
  714. static int tx_rate_show(struct seq_file *seq, void *v)
  715. {
  716. u64 nrate[NCHAN], orate[NCHAN];
  717. struct adapter *adap = seq->private;
  718. t4_get_chan_txrate(adap, nrate, orate);
  719. if (adap->params.arch.nchan == NCHAN) {
  720. seq_puts(seq, " channel 0 channel 1 "
  721. "channel 2 channel 3\n");
  722. seq_printf(seq, "NIC B/s: %10llu %10llu %10llu %10llu\n",
  723. (unsigned long long)nrate[0],
  724. (unsigned long long)nrate[1],
  725. (unsigned long long)nrate[2],
  726. (unsigned long long)nrate[3]);
  727. seq_printf(seq, "Offload B/s: %10llu %10llu %10llu %10llu\n",
  728. (unsigned long long)orate[0],
  729. (unsigned long long)orate[1],
  730. (unsigned long long)orate[2],
  731. (unsigned long long)orate[3]);
  732. } else {
  733. seq_puts(seq, " channel 0 channel 1\n");
  734. seq_printf(seq, "NIC B/s: %10llu %10llu\n",
  735. (unsigned long long)nrate[0],
  736. (unsigned long long)nrate[1]);
  737. seq_printf(seq, "Offload B/s: %10llu %10llu\n",
  738. (unsigned long long)orate[0],
  739. (unsigned long long)orate[1]);
  740. }
  741. return 0;
  742. }
  743. DEFINE_SIMPLE_DEBUGFS_FILE(tx_rate);
  744. static int cctrl_tbl_show(struct seq_file *seq, void *v)
  745. {
  746. static const char * const dec_fac[] = {
  747. "0.5", "0.5625", "0.625", "0.6875", "0.75", "0.8125", "0.875",
  748. "0.9375" };
  749. int i;
  750. u16 (*incr)[NCCTRL_WIN];
  751. struct adapter *adap = seq->private;
  752. incr = kmalloc(sizeof(*incr) * NMTUS, GFP_KERNEL);
  753. if (!incr)
  754. return -ENOMEM;
  755. t4_read_cong_tbl(adap, incr);
  756. for (i = 0; i < NCCTRL_WIN; ++i) {
  757. seq_printf(seq, "%2d: %4u %4u %4u %4u %4u %4u %4u %4u\n", i,
  758. incr[0][i], incr[1][i], incr[2][i], incr[3][i],
  759. incr[4][i], incr[5][i], incr[6][i], incr[7][i]);
  760. seq_printf(seq, "%8u %4u %4u %4u %4u %4u %4u %4u %5u %s\n",
  761. incr[8][i], incr[9][i], incr[10][i], incr[11][i],
  762. incr[12][i], incr[13][i], incr[14][i], incr[15][i],
  763. adap->params.a_wnd[i],
  764. dec_fac[adap->params.b_wnd[i]]);
  765. }
  766. kfree(incr);
  767. return 0;
  768. }
  769. DEFINE_SIMPLE_DEBUGFS_FILE(cctrl_tbl);
  770. /* Format a value in a unit that differs from the value's native unit by the
  771. * given factor.
  772. */
  773. static char *unit_conv(char *buf, size_t len, unsigned int val,
  774. unsigned int factor)
  775. {
  776. unsigned int rem = val % factor;
  777. if (rem == 0) {
  778. snprintf(buf, len, "%u", val / factor);
  779. } else {
  780. while (rem % 10 == 0)
  781. rem /= 10;
  782. snprintf(buf, len, "%u.%u", val / factor, rem);
  783. }
  784. return buf;
  785. }
  786. static int clk_show(struct seq_file *seq, void *v)
  787. {
  788. char buf[32];
  789. struct adapter *adap = seq->private;
  790. unsigned int cclk_ps = 1000000000 / adap->params.vpd.cclk; /* in ps */
  791. u32 res = t4_read_reg(adap, TP_TIMER_RESOLUTION_A);
  792. unsigned int tre = TIMERRESOLUTION_G(res);
  793. unsigned int dack_re = DELAYEDACKRESOLUTION_G(res);
  794. unsigned long long tp_tick_us = (cclk_ps << tre) / 1000000; /* in us */
  795. seq_printf(seq, "Core clock period: %s ns\n",
  796. unit_conv(buf, sizeof(buf), cclk_ps, 1000));
  797. seq_printf(seq, "TP timer tick: %s us\n",
  798. unit_conv(buf, sizeof(buf), (cclk_ps << tre), 1000000));
  799. seq_printf(seq, "TCP timestamp tick: %s us\n",
  800. unit_conv(buf, sizeof(buf),
  801. (cclk_ps << TIMESTAMPRESOLUTION_G(res)), 1000000));
  802. seq_printf(seq, "DACK tick: %s us\n",
  803. unit_conv(buf, sizeof(buf), (cclk_ps << dack_re), 1000000));
  804. seq_printf(seq, "DACK timer: %u us\n",
  805. ((cclk_ps << dack_re) / 1000000) *
  806. t4_read_reg(adap, TP_DACK_TIMER_A));
  807. seq_printf(seq, "Retransmit min: %llu us\n",
  808. tp_tick_us * t4_read_reg(adap, TP_RXT_MIN_A));
  809. seq_printf(seq, "Retransmit max: %llu us\n",
  810. tp_tick_us * t4_read_reg(adap, TP_RXT_MAX_A));
  811. seq_printf(seq, "Persist timer min: %llu us\n",
  812. tp_tick_us * t4_read_reg(adap, TP_PERS_MIN_A));
  813. seq_printf(seq, "Persist timer max: %llu us\n",
  814. tp_tick_us * t4_read_reg(adap, TP_PERS_MAX_A));
  815. seq_printf(seq, "Keepalive idle timer: %llu us\n",
  816. tp_tick_us * t4_read_reg(adap, TP_KEEP_IDLE_A));
  817. seq_printf(seq, "Keepalive interval: %llu us\n",
  818. tp_tick_us * t4_read_reg(adap, TP_KEEP_INTVL_A));
  819. seq_printf(seq, "Initial SRTT: %llu us\n",
  820. tp_tick_us * INITSRTT_G(t4_read_reg(adap, TP_INIT_SRTT_A)));
  821. seq_printf(seq, "FINWAIT2 timer: %llu us\n",
  822. tp_tick_us * t4_read_reg(adap, TP_FINWAIT2_TIMER_A));
  823. return 0;
  824. }
  825. DEFINE_SIMPLE_DEBUGFS_FILE(clk);
  826. /* Firmware Device Log dump. */
  827. static const char * const devlog_level_strings[] = {
  828. [FW_DEVLOG_LEVEL_EMERG] = "EMERG",
  829. [FW_DEVLOG_LEVEL_CRIT] = "CRIT",
  830. [FW_DEVLOG_LEVEL_ERR] = "ERR",
  831. [FW_DEVLOG_LEVEL_NOTICE] = "NOTICE",
  832. [FW_DEVLOG_LEVEL_INFO] = "INFO",
  833. [FW_DEVLOG_LEVEL_DEBUG] = "DEBUG"
  834. };
  835. static const char * const devlog_facility_strings[] = {
  836. [FW_DEVLOG_FACILITY_CORE] = "CORE",
  837. [FW_DEVLOG_FACILITY_CF] = "CF",
  838. [FW_DEVLOG_FACILITY_SCHED] = "SCHED",
  839. [FW_DEVLOG_FACILITY_TIMER] = "TIMER",
  840. [FW_DEVLOG_FACILITY_RES] = "RES",
  841. [FW_DEVLOG_FACILITY_HW] = "HW",
  842. [FW_DEVLOG_FACILITY_FLR] = "FLR",
  843. [FW_DEVLOG_FACILITY_DMAQ] = "DMAQ",
  844. [FW_DEVLOG_FACILITY_PHY] = "PHY",
  845. [FW_DEVLOG_FACILITY_MAC] = "MAC",
  846. [FW_DEVLOG_FACILITY_PORT] = "PORT",
  847. [FW_DEVLOG_FACILITY_VI] = "VI",
  848. [FW_DEVLOG_FACILITY_FILTER] = "FILTER",
  849. [FW_DEVLOG_FACILITY_ACL] = "ACL",
  850. [FW_DEVLOG_FACILITY_TM] = "TM",
  851. [FW_DEVLOG_FACILITY_QFC] = "QFC",
  852. [FW_DEVLOG_FACILITY_DCB] = "DCB",
  853. [FW_DEVLOG_FACILITY_ETH] = "ETH",
  854. [FW_DEVLOG_FACILITY_OFLD] = "OFLD",
  855. [FW_DEVLOG_FACILITY_RI] = "RI",
  856. [FW_DEVLOG_FACILITY_ISCSI] = "ISCSI",
  857. [FW_DEVLOG_FACILITY_FCOE] = "FCOE",
  858. [FW_DEVLOG_FACILITY_FOISCSI] = "FOISCSI",
  859. [FW_DEVLOG_FACILITY_FOFCOE] = "FOFCOE"
  860. };
  861. /* Information gathered by Device Log Open routine for the display routine.
  862. */
  863. struct devlog_info {
  864. unsigned int nentries; /* number of entries in log[] */
  865. unsigned int first; /* first [temporal] entry in log[] */
  866. struct fw_devlog_e log[0]; /* Firmware Device Log */
  867. };
  868. /* Dump a Firmaware Device Log entry.
  869. */
  870. static int devlog_show(struct seq_file *seq, void *v)
  871. {
  872. if (v == SEQ_START_TOKEN)
  873. seq_printf(seq, "%10s %15s %8s %8s %s\n",
  874. "Seq#", "Tstamp", "Level", "Facility", "Message");
  875. else {
  876. struct devlog_info *dinfo = seq->private;
  877. int fidx = (uintptr_t)v - 2;
  878. unsigned long index;
  879. struct fw_devlog_e *e;
  880. /* Get a pointer to the log entry to display. Skip unused log
  881. * entries.
  882. */
  883. index = dinfo->first + fidx;
  884. if (index >= dinfo->nentries)
  885. index -= dinfo->nentries;
  886. e = &dinfo->log[index];
  887. if (e->timestamp == 0)
  888. return 0;
  889. /* Print the message. This depends on the firmware using
  890. * exactly the same formating strings as the kernel so we may
  891. * eventually have to put a format interpreter in here ...
  892. */
  893. seq_printf(seq, "%10d %15llu %8s %8s ",
  894. be32_to_cpu(e->seqno),
  895. be64_to_cpu(e->timestamp),
  896. (e->level < ARRAY_SIZE(devlog_level_strings)
  897. ? devlog_level_strings[e->level]
  898. : "UNKNOWN"),
  899. (e->facility < ARRAY_SIZE(devlog_facility_strings)
  900. ? devlog_facility_strings[e->facility]
  901. : "UNKNOWN"));
  902. seq_printf(seq, e->fmt,
  903. be32_to_cpu(e->params[0]),
  904. be32_to_cpu(e->params[1]),
  905. be32_to_cpu(e->params[2]),
  906. be32_to_cpu(e->params[3]),
  907. be32_to_cpu(e->params[4]),
  908. be32_to_cpu(e->params[5]),
  909. be32_to_cpu(e->params[6]),
  910. be32_to_cpu(e->params[7]));
  911. }
  912. return 0;
  913. }
  914. /* Sequential File Operations for Device Log.
  915. */
  916. static inline void *devlog_get_idx(struct devlog_info *dinfo, loff_t pos)
  917. {
  918. if (pos > dinfo->nentries)
  919. return NULL;
  920. return (void *)(uintptr_t)(pos + 1);
  921. }
  922. static void *devlog_start(struct seq_file *seq, loff_t *pos)
  923. {
  924. struct devlog_info *dinfo = seq->private;
  925. return (*pos
  926. ? devlog_get_idx(dinfo, *pos)
  927. : SEQ_START_TOKEN);
  928. }
  929. static void *devlog_next(struct seq_file *seq, void *v, loff_t *pos)
  930. {
  931. struct devlog_info *dinfo = seq->private;
  932. (*pos)++;
  933. return devlog_get_idx(dinfo, *pos);
  934. }
  935. static void devlog_stop(struct seq_file *seq, void *v)
  936. {
  937. }
  938. static const struct seq_operations devlog_seq_ops = {
  939. .start = devlog_start,
  940. .next = devlog_next,
  941. .stop = devlog_stop,
  942. .show = devlog_show
  943. };
  944. /* Set up for reading the firmware's device log. We read the entire log here
  945. * and then display it incrementally in devlog_show().
  946. */
  947. static int devlog_open(struct inode *inode, struct file *file)
  948. {
  949. struct adapter *adap = inode->i_private;
  950. struct devlog_params *dparams = &adap->params.devlog;
  951. struct devlog_info *dinfo;
  952. unsigned int index;
  953. u32 fseqno;
  954. int ret;
  955. /* If we don't know where the log is we can't do anything.
  956. */
  957. if (dparams->start == 0)
  958. return -ENXIO;
  959. /* Allocate the space to read in the firmware's device log and set up
  960. * for the iterated call to our display function.
  961. */
  962. dinfo = __seq_open_private(file, &devlog_seq_ops,
  963. sizeof(*dinfo) + dparams->size);
  964. if (!dinfo)
  965. return -ENOMEM;
  966. /* Record the basic log buffer information and read in the raw log.
  967. */
  968. dinfo->nentries = (dparams->size / sizeof(struct fw_devlog_e));
  969. dinfo->first = 0;
  970. spin_lock(&adap->win0_lock);
  971. ret = t4_memory_rw(adap, adap->params.drv_memwin, dparams->memtype,
  972. dparams->start, dparams->size, (__be32 *)dinfo->log,
  973. T4_MEMORY_READ);
  974. spin_unlock(&adap->win0_lock);
  975. if (ret) {
  976. seq_release_private(inode, file);
  977. return ret;
  978. }
  979. /* Find the earliest (lowest Sequence Number) log entry in the
  980. * circular Device Log.
  981. */
  982. for (fseqno = ~((u32)0), index = 0; index < dinfo->nentries; index++) {
  983. struct fw_devlog_e *e = &dinfo->log[index];
  984. __u32 seqno;
  985. if (e->timestamp == 0)
  986. continue;
  987. seqno = be32_to_cpu(e->seqno);
  988. if (seqno < fseqno) {
  989. fseqno = seqno;
  990. dinfo->first = index;
  991. }
  992. }
  993. return 0;
  994. }
  995. static const struct file_operations devlog_fops = {
  996. .owner = THIS_MODULE,
  997. .open = devlog_open,
  998. .read = seq_read,
  999. .llseek = seq_lseek,
  1000. .release = seq_release_private
  1001. };
  1002. static int mbox_show(struct seq_file *seq, void *v)
  1003. {
  1004. static const char * const owner[] = { "none", "FW", "driver",
  1005. "unknown", "<unread>" };
  1006. int i;
  1007. unsigned int mbox = (uintptr_t)seq->private & 7;
  1008. struct adapter *adap = seq->private - mbox;
  1009. void __iomem *addr = adap->regs + PF_REG(mbox, CIM_PF_MAILBOX_DATA_A);
  1010. /* For T4 we don't have a shadow copy of the Mailbox Control register.
  1011. * And since reading that real register causes a side effect of
  1012. * granting ownership, we're best of simply not reading it at all.
  1013. */
  1014. if (is_t4(adap->params.chip)) {
  1015. i = 4; /* index of "<unread>" */
  1016. } else {
  1017. unsigned int ctrl_reg = CIM_PF_MAILBOX_CTRL_SHADOW_COPY_A;
  1018. void __iomem *ctrl = adap->regs + PF_REG(mbox, ctrl_reg);
  1019. i = MBOWNER_G(readl(ctrl));
  1020. }
  1021. seq_printf(seq, "mailbox owned by %s\n\n", owner[i]);
  1022. for (i = 0; i < MBOX_LEN; i += 8)
  1023. seq_printf(seq, "%016llx\n",
  1024. (unsigned long long)readq(addr + i));
  1025. return 0;
  1026. }
  1027. static int mbox_open(struct inode *inode, struct file *file)
  1028. {
  1029. return single_open(file, mbox_show, inode->i_private);
  1030. }
  1031. static ssize_t mbox_write(struct file *file, const char __user *buf,
  1032. size_t count, loff_t *pos)
  1033. {
  1034. int i;
  1035. char c = '\n', s[256];
  1036. unsigned long long data[8];
  1037. const struct inode *ino;
  1038. unsigned int mbox;
  1039. struct adapter *adap;
  1040. void __iomem *addr;
  1041. void __iomem *ctrl;
  1042. if (count > sizeof(s) - 1 || !count)
  1043. return -EINVAL;
  1044. if (copy_from_user(s, buf, count))
  1045. return -EFAULT;
  1046. s[count] = '\0';
  1047. if (sscanf(s, "%llx %llx %llx %llx %llx %llx %llx %llx%c", &data[0],
  1048. &data[1], &data[2], &data[3], &data[4], &data[5], &data[6],
  1049. &data[7], &c) < 8 || c != '\n')
  1050. return -EINVAL;
  1051. ino = file_inode(file);
  1052. mbox = (uintptr_t)ino->i_private & 7;
  1053. adap = ino->i_private - mbox;
  1054. addr = adap->regs + PF_REG(mbox, CIM_PF_MAILBOX_DATA_A);
  1055. ctrl = addr + MBOX_LEN;
  1056. if (MBOWNER_G(readl(ctrl)) != X_MBOWNER_PL)
  1057. return -EBUSY;
  1058. for (i = 0; i < 8; i++)
  1059. writeq(data[i], addr + 8 * i);
  1060. writel(MBMSGVALID_F | MBOWNER_V(X_MBOWNER_FW), ctrl);
  1061. return count;
  1062. }
  1063. static const struct file_operations mbox_debugfs_fops = {
  1064. .owner = THIS_MODULE,
  1065. .open = mbox_open,
  1066. .read = seq_read,
  1067. .llseek = seq_lseek,
  1068. .release = single_release,
  1069. .write = mbox_write
  1070. };
  1071. static int mps_trc_show(struct seq_file *seq, void *v)
  1072. {
  1073. int enabled, i;
  1074. struct trace_params tp;
  1075. unsigned int trcidx = (uintptr_t)seq->private & 3;
  1076. struct adapter *adap = seq->private - trcidx;
  1077. t4_get_trace_filter(adap, &tp, trcidx, &enabled);
  1078. if (!enabled) {
  1079. seq_puts(seq, "tracer is disabled\n");
  1080. return 0;
  1081. }
  1082. if (tp.skip_ofst * 8 >= TRACE_LEN) {
  1083. dev_err(adap->pdev_dev, "illegal trace pattern skip offset\n");
  1084. return -EINVAL;
  1085. }
  1086. if (tp.port < 8) {
  1087. i = adap->chan_map[tp.port & 3];
  1088. if (i >= MAX_NPORTS) {
  1089. dev_err(adap->pdev_dev, "tracer %u is assigned "
  1090. "to non-existing port\n", trcidx);
  1091. return -EINVAL;
  1092. }
  1093. seq_printf(seq, "tracer is capturing %s %s, ",
  1094. adap->port[i]->name, tp.port < 4 ? "Rx" : "Tx");
  1095. } else
  1096. seq_printf(seq, "tracer is capturing loopback %d, ",
  1097. tp.port - 8);
  1098. seq_printf(seq, "snap length: %u, min length: %u\n", tp.snap_len,
  1099. tp.min_len);
  1100. seq_printf(seq, "packets captured %smatch filter\n",
  1101. tp.invert ? "do not " : "");
  1102. if (tp.skip_ofst) {
  1103. seq_puts(seq, "filter pattern: ");
  1104. for (i = 0; i < tp.skip_ofst * 2; i += 2)
  1105. seq_printf(seq, "%08x%08x", tp.data[i], tp.data[i + 1]);
  1106. seq_putc(seq, '/');
  1107. for (i = 0; i < tp.skip_ofst * 2; i += 2)
  1108. seq_printf(seq, "%08x%08x", tp.mask[i], tp.mask[i + 1]);
  1109. seq_puts(seq, "@0\n");
  1110. }
  1111. seq_puts(seq, "filter pattern: ");
  1112. for (i = tp.skip_ofst * 2; i < TRACE_LEN / 4; i += 2)
  1113. seq_printf(seq, "%08x%08x", tp.data[i], tp.data[i + 1]);
  1114. seq_putc(seq, '/');
  1115. for (i = tp.skip_ofst * 2; i < TRACE_LEN / 4; i += 2)
  1116. seq_printf(seq, "%08x%08x", tp.mask[i], tp.mask[i + 1]);
  1117. seq_printf(seq, "@%u\n", (tp.skip_ofst + tp.skip_len) * 8);
  1118. return 0;
  1119. }
  1120. static int mps_trc_open(struct inode *inode, struct file *file)
  1121. {
  1122. return single_open(file, mps_trc_show, inode->i_private);
  1123. }
  1124. static unsigned int xdigit2int(unsigned char c)
  1125. {
  1126. return isdigit(c) ? c - '0' : tolower(c) - 'a' + 10;
  1127. }
  1128. #define TRC_PORT_NONE 0xff
  1129. #define TRC_RSS_ENABLE 0x33
  1130. #define TRC_RSS_DISABLE 0x13
  1131. /* Set an MPS trace filter. Syntax is:
  1132. *
  1133. * disable
  1134. *
  1135. * to disable tracing, or
  1136. *
  1137. * interface qid=<qid no> [snaplen=<val>] [minlen=<val>] [not] [<pattern>]...
  1138. *
  1139. * where interface is one of rxN, txN, or loopbackN, N = 0..3, qid can be one
  1140. * of the NIC's response qid obtained from sge_qinfo and pattern has the form
  1141. *
  1142. * <pattern data>[/<pattern mask>][@<anchor>]
  1143. *
  1144. * Up to 2 filter patterns can be specified. If 2 are supplied the first one
  1145. * must be anchored at 0. An omited mask is taken as a mask of 1s, an omitted
  1146. * anchor is taken as 0.
  1147. */
  1148. static ssize_t mps_trc_write(struct file *file, const char __user *buf,
  1149. size_t count, loff_t *pos)
  1150. {
  1151. int i, enable, ret;
  1152. u32 *data, *mask;
  1153. struct trace_params tp;
  1154. const struct inode *ino;
  1155. unsigned int trcidx;
  1156. char *s, *p, *word, *end;
  1157. struct adapter *adap;
  1158. u32 j;
  1159. ino = file_inode(file);
  1160. trcidx = (uintptr_t)ino->i_private & 3;
  1161. adap = ino->i_private - trcidx;
  1162. /* Don't accept input more than 1K, can't be anything valid except lots
  1163. * of whitespace. Well, use less.
  1164. */
  1165. if (count > 1024)
  1166. return -EFBIG;
  1167. p = s = kzalloc(count + 1, GFP_USER);
  1168. if (!s)
  1169. return -ENOMEM;
  1170. if (copy_from_user(s, buf, count)) {
  1171. count = -EFAULT;
  1172. goto out;
  1173. }
  1174. if (s[count - 1] == '\n')
  1175. s[count - 1] = '\0';
  1176. enable = strcmp("disable", s) != 0;
  1177. if (!enable)
  1178. goto apply;
  1179. /* enable or disable trace multi rss filter */
  1180. if (adap->trace_rss)
  1181. t4_write_reg(adap, MPS_TRC_CFG_A, TRC_RSS_ENABLE);
  1182. else
  1183. t4_write_reg(adap, MPS_TRC_CFG_A, TRC_RSS_DISABLE);
  1184. memset(&tp, 0, sizeof(tp));
  1185. tp.port = TRC_PORT_NONE;
  1186. i = 0; /* counts pattern nibbles */
  1187. while (p) {
  1188. while (isspace(*p))
  1189. p++;
  1190. word = strsep(&p, " ");
  1191. if (!*word)
  1192. break;
  1193. if (!strncmp(word, "qid=", 4)) {
  1194. end = (char *)word + 4;
  1195. ret = kstrtouint(end, 10, &j);
  1196. if (ret)
  1197. goto out;
  1198. if (!adap->trace_rss) {
  1199. t4_write_reg(adap, MPS_T5_TRC_RSS_CONTROL_A, j);
  1200. continue;
  1201. }
  1202. switch (trcidx) {
  1203. case 0:
  1204. t4_write_reg(adap, MPS_TRC_RSS_CONTROL_A, j);
  1205. break;
  1206. case 1:
  1207. t4_write_reg(adap,
  1208. MPS_TRC_FILTER1_RSS_CONTROL_A, j);
  1209. break;
  1210. case 2:
  1211. t4_write_reg(adap,
  1212. MPS_TRC_FILTER2_RSS_CONTROL_A, j);
  1213. break;
  1214. case 3:
  1215. t4_write_reg(adap,
  1216. MPS_TRC_FILTER3_RSS_CONTROL_A, j);
  1217. break;
  1218. }
  1219. continue;
  1220. }
  1221. if (!strncmp(word, "snaplen=", 8)) {
  1222. end = (char *)word + 8;
  1223. ret = kstrtouint(end, 10, &j);
  1224. if (ret || j > 9600) {
  1225. inval: count = -EINVAL;
  1226. goto out;
  1227. }
  1228. tp.snap_len = j;
  1229. continue;
  1230. }
  1231. if (!strncmp(word, "minlen=", 7)) {
  1232. end = (char *)word + 7;
  1233. ret = kstrtouint(end, 10, &j);
  1234. if (ret || j > TFMINPKTSIZE_M)
  1235. goto inval;
  1236. tp.min_len = j;
  1237. continue;
  1238. }
  1239. if (!strcmp(word, "not")) {
  1240. tp.invert = !tp.invert;
  1241. continue;
  1242. }
  1243. if (!strncmp(word, "loopback", 8) && tp.port == TRC_PORT_NONE) {
  1244. if (word[8] < '0' || word[8] > '3' || word[9])
  1245. goto inval;
  1246. tp.port = word[8] - '0' + 8;
  1247. continue;
  1248. }
  1249. if (!strncmp(word, "tx", 2) && tp.port == TRC_PORT_NONE) {
  1250. if (word[2] < '0' || word[2] > '3' || word[3])
  1251. goto inval;
  1252. tp.port = word[2] - '0' + 4;
  1253. if (adap->chan_map[tp.port & 3] >= MAX_NPORTS)
  1254. goto inval;
  1255. continue;
  1256. }
  1257. if (!strncmp(word, "rx", 2) && tp.port == TRC_PORT_NONE) {
  1258. if (word[2] < '0' || word[2] > '3' || word[3])
  1259. goto inval;
  1260. tp.port = word[2] - '0';
  1261. if (adap->chan_map[tp.port] >= MAX_NPORTS)
  1262. goto inval;
  1263. continue;
  1264. }
  1265. if (!isxdigit(*word))
  1266. goto inval;
  1267. /* we have found a trace pattern */
  1268. if (i) { /* split pattern */
  1269. if (tp.skip_len) /* too many splits */
  1270. goto inval;
  1271. tp.skip_ofst = i / 16;
  1272. }
  1273. data = &tp.data[i / 8];
  1274. mask = &tp.mask[i / 8];
  1275. j = i;
  1276. while (isxdigit(*word)) {
  1277. if (i >= TRACE_LEN * 2) {
  1278. count = -EFBIG;
  1279. goto out;
  1280. }
  1281. *data = (*data << 4) + xdigit2int(*word++);
  1282. if (++i % 8 == 0)
  1283. data++;
  1284. }
  1285. if (*word == '/') {
  1286. word++;
  1287. while (isxdigit(*word)) {
  1288. if (j >= i) /* mask longer than data */
  1289. goto inval;
  1290. *mask = (*mask << 4) + xdigit2int(*word++);
  1291. if (++j % 8 == 0)
  1292. mask++;
  1293. }
  1294. if (i != j) /* mask shorter than data */
  1295. goto inval;
  1296. } else { /* no mask, use all 1s */
  1297. for ( ; i - j >= 8; j += 8)
  1298. *mask++ = 0xffffffff;
  1299. if (i % 8)
  1300. *mask = (1 << (i % 8) * 4) - 1;
  1301. }
  1302. if (*word == '@') {
  1303. end = (char *)word + 1;
  1304. ret = kstrtouint(end, 10, &j);
  1305. if (*end && *end != '\n')
  1306. goto inval;
  1307. if (j & 7) /* doesn't start at multiple of 8 */
  1308. goto inval;
  1309. j /= 8;
  1310. if (j < tp.skip_ofst) /* overlaps earlier pattern */
  1311. goto inval;
  1312. if (j - tp.skip_ofst > 31) /* skip too big */
  1313. goto inval;
  1314. tp.skip_len = j - tp.skip_ofst;
  1315. }
  1316. if (i % 8) {
  1317. *data <<= (8 - i % 8) * 4;
  1318. *mask <<= (8 - i % 8) * 4;
  1319. i = (i + 15) & ~15; /* 8-byte align */
  1320. }
  1321. }
  1322. if (tp.port == TRC_PORT_NONE)
  1323. goto inval;
  1324. apply:
  1325. i = t4_set_trace_filter(adap, &tp, trcidx, enable);
  1326. if (i)
  1327. count = i;
  1328. out:
  1329. kfree(s);
  1330. return count;
  1331. }
  1332. static const struct file_operations mps_trc_debugfs_fops = {
  1333. .owner = THIS_MODULE,
  1334. .open = mps_trc_open,
  1335. .read = seq_read,
  1336. .llseek = seq_lseek,
  1337. .release = single_release,
  1338. .write = mps_trc_write
  1339. };
  1340. static ssize_t flash_read(struct file *file, char __user *buf, size_t count,
  1341. loff_t *ppos)
  1342. {
  1343. loff_t pos = *ppos;
  1344. loff_t avail = file_inode(file)->i_size;
  1345. struct adapter *adap = file->private_data;
  1346. if (pos < 0)
  1347. return -EINVAL;
  1348. if (pos >= avail)
  1349. return 0;
  1350. if (count > avail - pos)
  1351. count = avail - pos;
  1352. while (count) {
  1353. size_t len;
  1354. int ret, ofst;
  1355. u8 data[256];
  1356. ofst = pos & 3;
  1357. len = min(count + ofst, sizeof(data));
  1358. ret = t4_read_flash(adap, pos - ofst, (len + 3) / 4,
  1359. (u32 *)data, 1);
  1360. if (ret)
  1361. return ret;
  1362. len -= ofst;
  1363. if (copy_to_user(buf, data + ofst, len))
  1364. return -EFAULT;
  1365. buf += len;
  1366. pos += len;
  1367. count -= len;
  1368. }
  1369. count = pos - *ppos;
  1370. *ppos = pos;
  1371. return count;
  1372. }
  1373. static const struct file_operations flash_debugfs_fops = {
  1374. .owner = THIS_MODULE,
  1375. .open = mem_open,
  1376. .read = flash_read,
  1377. };
  1378. static inline void tcamxy2valmask(u64 x, u64 y, u8 *addr, u64 *mask)
  1379. {
  1380. *mask = x | y;
  1381. y = (__force u64)cpu_to_be64(y);
  1382. memcpy(addr, (char *)&y + 2, ETH_ALEN);
  1383. }
  1384. static int mps_tcam_show(struct seq_file *seq, void *v)
  1385. {
  1386. struct adapter *adap = seq->private;
  1387. unsigned int chip_ver = CHELSIO_CHIP_VERSION(adap->params.chip);
  1388. if (v == SEQ_START_TOKEN) {
  1389. if (adap->params.arch.mps_rplc_size > 128)
  1390. seq_puts(seq, "Idx Ethernet address Mask "
  1391. "Vld Ports PF VF "
  1392. "Replication "
  1393. " P0 P1 P2 P3 ML\n");
  1394. else
  1395. seq_puts(seq, "Idx Ethernet address Mask "
  1396. "Vld Ports PF VF Replication"
  1397. " P0 P1 P2 P3 ML\n");
  1398. } else {
  1399. u64 mask;
  1400. u8 addr[ETH_ALEN];
  1401. bool replicate;
  1402. unsigned int idx = (uintptr_t)v - 2;
  1403. u64 tcamy, tcamx, val;
  1404. u32 cls_lo, cls_hi, ctl;
  1405. u32 rplc[8] = {0};
  1406. if (chip_ver > CHELSIO_T5) {
  1407. /* CtlCmdType - 0: Read, 1: Write
  1408. * CtlTcamSel - 0: TCAM0, 1: TCAM1
  1409. * CtlXYBitSel- 0: Y bit, 1: X bit
  1410. */
  1411. /* Read tcamy */
  1412. ctl = CTLCMDTYPE_V(0) | CTLXYBITSEL_V(0);
  1413. if (idx < 256)
  1414. ctl |= CTLTCAMINDEX_V(idx) | CTLTCAMSEL_V(0);
  1415. else
  1416. ctl |= CTLTCAMINDEX_V(idx - 256) |
  1417. CTLTCAMSEL_V(1);
  1418. t4_write_reg(adap, MPS_CLS_TCAM_DATA2_CTL_A, ctl);
  1419. val = t4_read_reg(adap, MPS_CLS_TCAM_DATA1_A);
  1420. tcamy = DMACH_G(val) << 32;
  1421. tcamy |= t4_read_reg(adap, MPS_CLS_TCAM_DATA0_A);
  1422. /* Read tcamx. Change the control param */
  1423. ctl |= CTLXYBITSEL_V(1);
  1424. t4_write_reg(adap, MPS_CLS_TCAM_DATA2_CTL_A, ctl);
  1425. val = t4_read_reg(adap, MPS_CLS_TCAM_DATA1_A);
  1426. tcamx = DMACH_G(val) << 32;
  1427. tcamx |= t4_read_reg(adap, MPS_CLS_TCAM_DATA0_A);
  1428. } else {
  1429. tcamy = t4_read_reg64(adap, MPS_CLS_TCAM_Y_L(idx));
  1430. tcamx = t4_read_reg64(adap, MPS_CLS_TCAM_X_L(idx));
  1431. }
  1432. cls_lo = t4_read_reg(adap, MPS_CLS_SRAM_L(idx));
  1433. cls_hi = t4_read_reg(adap, MPS_CLS_SRAM_H(idx));
  1434. if (tcamx & tcamy) {
  1435. seq_printf(seq, "%3u -\n", idx);
  1436. goto out;
  1437. }
  1438. rplc[0] = rplc[1] = rplc[2] = rplc[3] = 0;
  1439. if (chip_ver > CHELSIO_T5)
  1440. replicate = (cls_lo & T6_REPLICATE_F);
  1441. else
  1442. replicate = (cls_lo & REPLICATE_F);
  1443. if (replicate) {
  1444. struct fw_ldst_cmd ldst_cmd;
  1445. int ret;
  1446. struct fw_ldst_mps_rplc mps_rplc;
  1447. u32 ldst_addrspc;
  1448. memset(&ldst_cmd, 0, sizeof(ldst_cmd));
  1449. ldst_addrspc =
  1450. FW_LDST_CMD_ADDRSPACE_V(FW_LDST_ADDRSPC_MPS);
  1451. ldst_cmd.op_to_addrspace =
  1452. htonl(FW_CMD_OP_V(FW_LDST_CMD) |
  1453. FW_CMD_REQUEST_F |
  1454. FW_CMD_READ_F |
  1455. ldst_addrspc);
  1456. ldst_cmd.cycles_to_len16 = htonl(FW_LEN16(ldst_cmd));
  1457. ldst_cmd.u.mps.rplc.fid_idx =
  1458. htons(FW_LDST_CMD_FID_V(FW_LDST_MPS_RPLC) |
  1459. FW_LDST_CMD_IDX_V(idx));
  1460. ret = t4_wr_mbox(adap, adap->mbox, &ldst_cmd,
  1461. sizeof(ldst_cmd), &ldst_cmd);
  1462. if (ret)
  1463. dev_warn(adap->pdev_dev, "Can't read MPS "
  1464. "replication map for idx %d: %d\n",
  1465. idx, -ret);
  1466. else {
  1467. mps_rplc = ldst_cmd.u.mps.rplc;
  1468. rplc[0] = ntohl(mps_rplc.rplc31_0);
  1469. rplc[1] = ntohl(mps_rplc.rplc63_32);
  1470. rplc[2] = ntohl(mps_rplc.rplc95_64);
  1471. rplc[3] = ntohl(mps_rplc.rplc127_96);
  1472. if (adap->params.arch.mps_rplc_size > 128) {
  1473. rplc[4] = ntohl(mps_rplc.rplc159_128);
  1474. rplc[5] = ntohl(mps_rplc.rplc191_160);
  1475. rplc[6] = ntohl(mps_rplc.rplc223_192);
  1476. rplc[7] = ntohl(mps_rplc.rplc255_224);
  1477. }
  1478. }
  1479. }
  1480. tcamxy2valmask(tcamx, tcamy, addr, &mask);
  1481. if (chip_ver > CHELSIO_T5)
  1482. seq_printf(seq, "%3u %02x:%02x:%02x:%02x:%02x:%02x "
  1483. "%012llx%3c %#x%4u%4d",
  1484. idx, addr[0], addr[1], addr[2], addr[3],
  1485. addr[4], addr[5], (unsigned long long)mask,
  1486. (cls_lo & T6_SRAM_VLD_F) ? 'Y' : 'N',
  1487. PORTMAP_G(cls_hi),
  1488. T6_PF_G(cls_lo),
  1489. (cls_lo & T6_VF_VALID_F) ?
  1490. T6_VF_G(cls_lo) : -1);
  1491. else
  1492. seq_printf(seq, "%3u %02x:%02x:%02x:%02x:%02x:%02x "
  1493. "%012llx%3c %#x%4u%4d",
  1494. idx, addr[0], addr[1], addr[2], addr[3],
  1495. addr[4], addr[5], (unsigned long long)mask,
  1496. (cls_lo & SRAM_VLD_F) ? 'Y' : 'N',
  1497. PORTMAP_G(cls_hi),
  1498. PF_G(cls_lo),
  1499. (cls_lo & VF_VALID_F) ? VF_G(cls_lo) : -1);
  1500. if (replicate) {
  1501. if (adap->params.arch.mps_rplc_size > 128)
  1502. seq_printf(seq, " %08x %08x %08x %08x "
  1503. "%08x %08x %08x %08x",
  1504. rplc[7], rplc[6], rplc[5], rplc[4],
  1505. rplc[3], rplc[2], rplc[1], rplc[0]);
  1506. else
  1507. seq_printf(seq, " %08x %08x %08x %08x",
  1508. rplc[3], rplc[2], rplc[1], rplc[0]);
  1509. } else {
  1510. if (adap->params.arch.mps_rplc_size > 128)
  1511. seq_printf(seq, "%72c", ' ');
  1512. else
  1513. seq_printf(seq, "%36c", ' ');
  1514. }
  1515. if (chip_ver > CHELSIO_T5)
  1516. seq_printf(seq, "%4u%3u%3u%3u %#x\n",
  1517. T6_SRAM_PRIO0_G(cls_lo),
  1518. T6_SRAM_PRIO1_G(cls_lo),
  1519. T6_SRAM_PRIO2_G(cls_lo),
  1520. T6_SRAM_PRIO3_G(cls_lo),
  1521. (cls_lo >> T6_MULTILISTEN0_S) & 0xf);
  1522. else
  1523. seq_printf(seq, "%4u%3u%3u%3u %#x\n",
  1524. SRAM_PRIO0_G(cls_lo), SRAM_PRIO1_G(cls_lo),
  1525. SRAM_PRIO2_G(cls_lo), SRAM_PRIO3_G(cls_lo),
  1526. (cls_lo >> MULTILISTEN0_S) & 0xf);
  1527. }
  1528. out: return 0;
  1529. }
  1530. static inline void *mps_tcam_get_idx(struct seq_file *seq, loff_t pos)
  1531. {
  1532. struct adapter *adap = seq->private;
  1533. int max_mac_addr = is_t4(adap->params.chip) ?
  1534. NUM_MPS_CLS_SRAM_L_INSTANCES :
  1535. NUM_MPS_T5_CLS_SRAM_L_INSTANCES;
  1536. return ((pos <= max_mac_addr) ? (void *)(uintptr_t)(pos + 1) : NULL);
  1537. }
  1538. static void *mps_tcam_start(struct seq_file *seq, loff_t *pos)
  1539. {
  1540. return *pos ? mps_tcam_get_idx(seq, *pos) : SEQ_START_TOKEN;
  1541. }
  1542. static void *mps_tcam_next(struct seq_file *seq, void *v, loff_t *pos)
  1543. {
  1544. ++*pos;
  1545. return mps_tcam_get_idx(seq, *pos);
  1546. }
  1547. static void mps_tcam_stop(struct seq_file *seq, void *v)
  1548. {
  1549. }
  1550. static const struct seq_operations mps_tcam_seq_ops = {
  1551. .start = mps_tcam_start,
  1552. .next = mps_tcam_next,
  1553. .stop = mps_tcam_stop,
  1554. .show = mps_tcam_show
  1555. };
  1556. static int mps_tcam_open(struct inode *inode, struct file *file)
  1557. {
  1558. int res = seq_open(file, &mps_tcam_seq_ops);
  1559. if (!res) {
  1560. struct seq_file *seq = file->private_data;
  1561. seq->private = inode->i_private;
  1562. }
  1563. return res;
  1564. }
  1565. static const struct file_operations mps_tcam_debugfs_fops = {
  1566. .owner = THIS_MODULE,
  1567. .open = mps_tcam_open,
  1568. .read = seq_read,
  1569. .llseek = seq_lseek,
  1570. .release = seq_release,
  1571. };
  1572. /* Display various sensor information.
  1573. */
  1574. static int sensors_show(struct seq_file *seq, void *v)
  1575. {
  1576. struct adapter *adap = seq->private;
  1577. u32 param[7], val[7];
  1578. int ret;
  1579. /* Note that if the sensors haven't been initialized and turned on
  1580. * we'll get values of 0, so treat those as "<unknown>" ...
  1581. */
  1582. param[0] = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
  1583. FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_DIAG) |
  1584. FW_PARAMS_PARAM_Y_V(FW_PARAM_DEV_DIAG_TMP));
  1585. param[1] = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
  1586. FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_DIAG) |
  1587. FW_PARAMS_PARAM_Y_V(FW_PARAM_DEV_DIAG_VDD));
  1588. ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 2,
  1589. param, val);
  1590. if (ret < 0 || val[0] == 0)
  1591. seq_puts(seq, "Temperature: <unknown>\n");
  1592. else
  1593. seq_printf(seq, "Temperature: %dC\n", val[0]);
  1594. if (ret < 0 || val[1] == 0)
  1595. seq_puts(seq, "Core VDD: <unknown>\n");
  1596. else
  1597. seq_printf(seq, "Core VDD: %dmV\n", val[1]);
  1598. return 0;
  1599. }
  1600. DEFINE_SIMPLE_DEBUGFS_FILE(sensors);
  1601. #if IS_ENABLED(CONFIG_IPV6)
  1602. static int clip_tbl_open(struct inode *inode, struct file *file)
  1603. {
  1604. return single_open(file, clip_tbl_show, inode->i_private);
  1605. }
  1606. static const struct file_operations clip_tbl_debugfs_fops = {
  1607. .owner = THIS_MODULE,
  1608. .open = clip_tbl_open,
  1609. .read = seq_read,
  1610. .llseek = seq_lseek,
  1611. .release = single_release
  1612. };
  1613. #endif
  1614. /*RSS Table.
  1615. */
  1616. static int rss_show(struct seq_file *seq, void *v, int idx)
  1617. {
  1618. u16 *entry = v;
  1619. seq_printf(seq, "%4d: %4u %4u %4u %4u %4u %4u %4u %4u\n",
  1620. idx * 8, entry[0], entry[1], entry[2], entry[3], entry[4],
  1621. entry[5], entry[6], entry[7]);
  1622. return 0;
  1623. }
  1624. static int rss_open(struct inode *inode, struct file *file)
  1625. {
  1626. int ret;
  1627. struct seq_tab *p;
  1628. struct adapter *adap = inode->i_private;
  1629. p = seq_open_tab(file, RSS_NENTRIES / 8, 8 * sizeof(u16), 0, rss_show);
  1630. if (!p)
  1631. return -ENOMEM;
  1632. ret = t4_read_rss(adap, (u16 *)p->data);
  1633. if (ret)
  1634. seq_release_private(inode, file);
  1635. return ret;
  1636. }
  1637. static const struct file_operations rss_debugfs_fops = {
  1638. .owner = THIS_MODULE,
  1639. .open = rss_open,
  1640. .read = seq_read,
  1641. .llseek = seq_lseek,
  1642. .release = seq_release_private
  1643. };
  1644. /* RSS Configuration.
  1645. */
  1646. /* Small utility function to return the strings "yes" or "no" if the supplied
  1647. * argument is non-zero.
  1648. */
  1649. static const char *yesno(int x)
  1650. {
  1651. static const char *yes = "yes";
  1652. static const char *no = "no";
  1653. return x ? yes : no;
  1654. }
  1655. static int rss_config_show(struct seq_file *seq, void *v)
  1656. {
  1657. struct adapter *adapter = seq->private;
  1658. static const char * const keymode[] = {
  1659. "global",
  1660. "global and per-VF scramble",
  1661. "per-PF and per-VF scramble",
  1662. "per-VF and per-VF scramble",
  1663. };
  1664. u32 rssconf;
  1665. rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_A);
  1666. seq_printf(seq, "TP_RSS_CONFIG: %#x\n", rssconf);
  1667. seq_printf(seq, " Tnl4TupEnIpv6: %3s\n", yesno(rssconf &
  1668. TNL4TUPENIPV6_F));
  1669. seq_printf(seq, " Tnl2TupEnIpv6: %3s\n", yesno(rssconf &
  1670. TNL2TUPENIPV6_F));
  1671. seq_printf(seq, " Tnl4TupEnIpv4: %3s\n", yesno(rssconf &
  1672. TNL4TUPENIPV4_F));
  1673. seq_printf(seq, " Tnl2TupEnIpv4: %3s\n", yesno(rssconf &
  1674. TNL2TUPENIPV4_F));
  1675. seq_printf(seq, " TnlTcpSel: %3s\n", yesno(rssconf & TNLTCPSEL_F));
  1676. seq_printf(seq, " TnlIp6Sel: %3s\n", yesno(rssconf & TNLIP6SEL_F));
  1677. seq_printf(seq, " TnlVrtSel: %3s\n", yesno(rssconf & TNLVRTSEL_F));
  1678. seq_printf(seq, " TnlMapEn: %3s\n", yesno(rssconf & TNLMAPEN_F));
  1679. seq_printf(seq, " OfdHashSave: %3s\n", yesno(rssconf &
  1680. OFDHASHSAVE_F));
  1681. seq_printf(seq, " OfdVrtSel: %3s\n", yesno(rssconf & OFDVRTSEL_F));
  1682. seq_printf(seq, " OfdMapEn: %3s\n", yesno(rssconf & OFDMAPEN_F));
  1683. seq_printf(seq, " OfdLkpEn: %3s\n", yesno(rssconf & OFDLKPEN_F));
  1684. seq_printf(seq, " Syn4TupEnIpv6: %3s\n", yesno(rssconf &
  1685. SYN4TUPENIPV6_F));
  1686. seq_printf(seq, " Syn2TupEnIpv6: %3s\n", yesno(rssconf &
  1687. SYN2TUPENIPV6_F));
  1688. seq_printf(seq, " Syn4TupEnIpv4: %3s\n", yesno(rssconf &
  1689. SYN4TUPENIPV4_F));
  1690. seq_printf(seq, " Syn2TupEnIpv4: %3s\n", yesno(rssconf &
  1691. SYN2TUPENIPV4_F));
  1692. seq_printf(seq, " Syn4TupEnIpv6: %3s\n", yesno(rssconf &
  1693. SYN4TUPENIPV6_F));
  1694. seq_printf(seq, " SynIp6Sel: %3s\n", yesno(rssconf & SYNIP6SEL_F));
  1695. seq_printf(seq, " SynVrt6Sel: %3s\n", yesno(rssconf & SYNVRTSEL_F));
  1696. seq_printf(seq, " SynMapEn: %3s\n", yesno(rssconf & SYNMAPEN_F));
  1697. seq_printf(seq, " SynLkpEn: %3s\n", yesno(rssconf & SYNLKPEN_F));
  1698. seq_printf(seq, " ChnEn: %3s\n", yesno(rssconf &
  1699. CHANNELENABLE_F));
  1700. seq_printf(seq, " PrtEn: %3s\n", yesno(rssconf &
  1701. PORTENABLE_F));
  1702. seq_printf(seq, " TnlAllLkp: %3s\n", yesno(rssconf &
  1703. TNLALLLOOKUP_F));
  1704. seq_printf(seq, " VrtEn: %3s\n", yesno(rssconf &
  1705. VIRTENABLE_F));
  1706. seq_printf(seq, " CngEn: %3s\n", yesno(rssconf &
  1707. CONGESTIONENABLE_F));
  1708. seq_printf(seq, " HashToeplitz: %3s\n", yesno(rssconf &
  1709. HASHTOEPLITZ_F));
  1710. seq_printf(seq, " Udp4En: %3s\n", yesno(rssconf & UDPENABLE_F));
  1711. seq_printf(seq, " Disable: %3s\n", yesno(rssconf & DISABLE_F));
  1712. seq_puts(seq, "\n");
  1713. rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_TNL_A);
  1714. seq_printf(seq, "TP_RSS_CONFIG_TNL: %#x\n", rssconf);
  1715. seq_printf(seq, " MaskSize: %3d\n", MASKSIZE_G(rssconf));
  1716. seq_printf(seq, " MaskFilter: %3d\n", MASKFILTER_G(rssconf));
  1717. if (CHELSIO_CHIP_VERSION(adapter->params.chip) > CHELSIO_T5) {
  1718. seq_printf(seq, " HashAll: %3s\n",
  1719. yesno(rssconf & HASHALL_F));
  1720. seq_printf(seq, " HashEth: %3s\n",
  1721. yesno(rssconf & HASHETH_F));
  1722. }
  1723. seq_printf(seq, " UseWireCh: %3s\n", yesno(rssconf & USEWIRECH_F));
  1724. seq_puts(seq, "\n");
  1725. rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_OFD_A);
  1726. seq_printf(seq, "TP_RSS_CONFIG_OFD: %#x\n", rssconf);
  1727. seq_printf(seq, " MaskSize: %3d\n", MASKSIZE_G(rssconf));
  1728. seq_printf(seq, " RRCplMapEn: %3s\n", yesno(rssconf &
  1729. RRCPLMAPEN_F));
  1730. seq_printf(seq, " RRCplQueWidth: %3d\n", RRCPLQUEWIDTH_G(rssconf));
  1731. seq_puts(seq, "\n");
  1732. rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_SYN_A);
  1733. seq_printf(seq, "TP_RSS_CONFIG_SYN: %#x\n", rssconf);
  1734. seq_printf(seq, " MaskSize: %3d\n", MASKSIZE_G(rssconf));
  1735. seq_printf(seq, " UseWireCh: %3s\n", yesno(rssconf & USEWIRECH_F));
  1736. seq_puts(seq, "\n");
  1737. rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_VRT_A);
  1738. seq_printf(seq, "TP_RSS_CONFIG_VRT: %#x\n", rssconf);
  1739. if (CHELSIO_CHIP_VERSION(adapter->params.chip) > CHELSIO_T5) {
  1740. seq_printf(seq, " KeyWrAddrX: %3d\n",
  1741. KEYWRADDRX_G(rssconf));
  1742. seq_printf(seq, " KeyExtend: %3s\n",
  1743. yesno(rssconf & KEYEXTEND_F));
  1744. }
  1745. seq_printf(seq, " VfRdRg: %3s\n", yesno(rssconf & VFRDRG_F));
  1746. seq_printf(seq, " VfRdEn: %3s\n", yesno(rssconf & VFRDEN_F));
  1747. seq_printf(seq, " VfPerrEn: %3s\n", yesno(rssconf & VFPERREN_F));
  1748. seq_printf(seq, " KeyPerrEn: %3s\n", yesno(rssconf & KEYPERREN_F));
  1749. seq_printf(seq, " DisVfVlan: %3s\n", yesno(rssconf &
  1750. DISABLEVLAN_F));
  1751. seq_printf(seq, " EnUpSwt: %3s\n", yesno(rssconf & ENABLEUP0_F));
  1752. seq_printf(seq, " HashDelay: %3d\n", HASHDELAY_G(rssconf));
  1753. if (CHELSIO_CHIP_VERSION(adapter->params.chip) <= CHELSIO_T5)
  1754. seq_printf(seq, " VfWrAddr: %3d\n", VFWRADDR_G(rssconf));
  1755. else
  1756. seq_printf(seq, " VfWrAddr: %3d\n",
  1757. T6_VFWRADDR_G(rssconf));
  1758. seq_printf(seq, " KeyMode: %s\n", keymode[KEYMODE_G(rssconf)]);
  1759. seq_printf(seq, " VfWrEn: %3s\n", yesno(rssconf & VFWREN_F));
  1760. seq_printf(seq, " KeyWrEn: %3s\n", yesno(rssconf & KEYWREN_F));
  1761. seq_printf(seq, " KeyWrAddr: %3d\n", KEYWRADDR_G(rssconf));
  1762. seq_puts(seq, "\n");
  1763. rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_CNG_A);
  1764. seq_printf(seq, "TP_RSS_CONFIG_CNG: %#x\n", rssconf);
  1765. seq_printf(seq, " ChnCount3: %3s\n", yesno(rssconf & CHNCOUNT3_F));
  1766. seq_printf(seq, " ChnCount2: %3s\n", yesno(rssconf & CHNCOUNT2_F));
  1767. seq_printf(seq, " ChnCount1: %3s\n", yesno(rssconf & CHNCOUNT1_F));
  1768. seq_printf(seq, " ChnCount0: %3s\n", yesno(rssconf & CHNCOUNT0_F));
  1769. seq_printf(seq, " ChnUndFlow3: %3s\n", yesno(rssconf &
  1770. CHNUNDFLOW3_F));
  1771. seq_printf(seq, " ChnUndFlow2: %3s\n", yesno(rssconf &
  1772. CHNUNDFLOW2_F));
  1773. seq_printf(seq, " ChnUndFlow1: %3s\n", yesno(rssconf &
  1774. CHNUNDFLOW1_F));
  1775. seq_printf(seq, " ChnUndFlow0: %3s\n", yesno(rssconf &
  1776. CHNUNDFLOW0_F));
  1777. seq_printf(seq, " RstChn3: %3s\n", yesno(rssconf & RSTCHN3_F));
  1778. seq_printf(seq, " RstChn2: %3s\n", yesno(rssconf & RSTCHN2_F));
  1779. seq_printf(seq, " RstChn1: %3s\n", yesno(rssconf & RSTCHN1_F));
  1780. seq_printf(seq, " RstChn0: %3s\n", yesno(rssconf & RSTCHN0_F));
  1781. seq_printf(seq, " UpdVld: %3s\n", yesno(rssconf & UPDVLD_F));
  1782. seq_printf(seq, " Xoff: %3s\n", yesno(rssconf & XOFF_F));
  1783. seq_printf(seq, " UpdChn3: %3s\n", yesno(rssconf & UPDCHN3_F));
  1784. seq_printf(seq, " UpdChn2: %3s\n", yesno(rssconf & UPDCHN2_F));
  1785. seq_printf(seq, " UpdChn1: %3s\n", yesno(rssconf & UPDCHN1_F));
  1786. seq_printf(seq, " UpdChn0: %3s\n", yesno(rssconf & UPDCHN0_F));
  1787. seq_printf(seq, " Queue: %3d\n", QUEUE_G(rssconf));
  1788. return 0;
  1789. }
  1790. DEFINE_SIMPLE_DEBUGFS_FILE(rss_config);
  1791. /* RSS Secret Key.
  1792. */
  1793. static int rss_key_show(struct seq_file *seq, void *v)
  1794. {
  1795. u32 key[10];
  1796. t4_read_rss_key(seq->private, key);
  1797. seq_printf(seq, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x\n",
  1798. key[9], key[8], key[7], key[6], key[5], key[4], key[3],
  1799. key[2], key[1], key[0]);
  1800. return 0;
  1801. }
  1802. static int rss_key_open(struct inode *inode, struct file *file)
  1803. {
  1804. return single_open(file, rss_key_show, inode->i_private);
  1805. }
  1806. static ssize_t rss_key_write(struct file *file, const char __user *buf,
  1807. size_t count, loff_t *pos)
  1808. {
  1809. int i, j;
  1810. u32 key[10];
  1811. char s[100], *p;
  1812. struct adapter *adap = file_inode(file)->i_private;
  1813. if (count > sizeof(s) - 1)
  1814. return -EINVAL;
  1815. if (copy_from_user(s, buf, count))
  1816. return -EFAULT;
  1817. for (i = count; i > 0 && isspace(s[i - 1]); i--)
  1818. ;
  1819. s[i] = '\0';
  1820. for (p = s, i = 9; i >= 0; i--) {
  1821. key[i] = 0;
  1822. for (j = 0; j < 8; j++, p++) {
  1823. if (!isxdigit(*p))
  1824. return -EINVAL;
  1825. key[i] = (key[i] << 4) | hex2val(*p);
  1826. }
  1827. }
  1828. t4_write_rss_key(adap, key, -1);
  1829. return count;
  1830. }
  1831. static const struct file_operations rss_key_debugfs_fops = {
  1832. .owner = THIS_MODULE,
  1833. .open = rss_key_open,
  1834. .read = seq_read,
  1835. .llseek = seq_lseek,
  1836. .release = single_release,
  1837. .write = rss_key_write
  1838. };
  1839. /* PF RSS Configuration.
  1840. */
  1841. struct rss_pf_conf {
  1842. u32 rss_pf_map;
  1843. u32 rss_pf_mask;
  1844. u32 rss_pf_config;
  1845. };
  1846. static int rss_pf_config_show(struct seq_file *seq, void *v, int idx)
  1847. {
  1848. struct rss_pf_conf *pfconf;
  1849. if (v == SEQ_START_TOKEN) {
  1850. /* use the 0th entry to dump the PF Map Index Size */
  1851. pfconf = seq->private + offsetof(struct seq_tab, data);
  1852. seq_printf(seq, "PF Map Index Size = %d\n\n",
  1853. LKPIDXSIZE_G(pfconf->rss_pf_map));
  1854. seq_puts(seq, " RSS PF VF Hash Tuple Enable Default\n");
  1855. seq_puts(seq, " Enable IPF Mask Mask IPv6 IPv4 UDP Queue\n");
  1856. seq_puts(seq, " PF Map Chn Prt Map Size Size Four Two Four Two Four Ch1 Ch0\n");
  1857. } else {
  1858. #define G_PFnLKPIDX(map, n) \
  1859. (((map) >> PF1LKPIDX_S*(n)) & PF0LKPIDX_M)
  1860. #define G_PFnMSKSIZE(mask, n) \
  1861. (((mask) >> PF1MSKSIZE_S*(n)) & PF1MSKSIZE_M)
  1862. pfconf = v;
  1863. seq_printf(seq, "%3d %3s %3s %3s %3d %3d %3d %3s %3s %3s %3s %3s %3d %3d\n",
  1864. idx,
  1865. yesno(pfconf->rss_pf_config & MAPENABLE_F),
  1866. yesno(pfconf->rss_pf_config & CHNENABLE_F),
  1867. yesno(pfconf->rss_pf_config & PRTENABLE_F),
  1868. G_PFnLKPIDX(pfconf->rss_pf_map, idx),
  1869. G_PFnMSKSIZE(pfconf->rss_pf_mask, idx),
  1870. IVFWIDTH_G(pfconf->rss_pf_config),
  1871. yesno(pfconf->rss_pf_config & IP6FOURTUPEN_F),
  1872. yesno(pfconf->rss_pf_config & IP6TWOTUPEN_F),
  1873. yesno(pfconf->rss_pf_config & IP4FOURTUPEN_F),
  1874. yesno(pfconf->rss_pf_config & IP4TWOTUPEN_F),
  1875. yesno(pfconf->rss_pf_config & UDPFOURTUPEN_F),
  1876. CH1DEFAULTQUEUE_G(pfconf->rss_pf_config),
  1877. CH0DEFAULTQUEUE_G(pfconf->rss_pf_config));
  1878. #undef G_PFnLKPIDX
  1879. #undef G_PFnMSKSIZE
  1880. }
  1881. return 0;
  1882. }
  1883. static int rss_pf_config_open(struct inode *inode, struct file *file)
  1884. {
  1885. struct adapter *adapter = inode->i_private;
  1886. struct seq_tab *p;
  1887. u32 rss_pf_map, rss_pf_mask;
  1888. struct rss_pf_conf *pfconf;
  1889. int pf;
  1890. p = seq_open_tab(file, 8, sizeof(*pfconf), 1, rss_pf_config_show);
  1891. if (!p)
  1892. return -ENOMEM;
  1893. pfconf = (struct rss_pf_conf *)p->data;
  1894. rss_pf_map = t4_read_rss_pf_map(adapter);
  1895. rss_pf_mask = t4_read_rss_pf_mask(adapter);
  1896. for (pf = 0; pf < 8; pf++) {
  1897. pfconf[pf].rss_pf_map = rss_pf_map;
  1898. pfconf[pf].rss_pf_mask = rss_pf_mask;
  1899. t4_read_rss_pf_config(adapter, pf, &pfconf[pf].rss_pf_config);
  1900. }
  1901. return 0;
  1902. }
  1903. static const struct file_operations rss_pf_config_debugfs_fops = {
  1904. .owner = THIS_MODULE,
  1905. .open = rss_pf_config_open,
  1906. .read = seq_read,
  1907. .llseek = seq_lseek,
  1908. .release = seq_release_private
  1909. };
  1910. /* VF RSS Configuration.
  1911. */
  1912. struct rss_vf_conf {
  1913. u32 rss_vf_vfl;
  1914. u32 rss_vf_vfh;
  1915. };
  1916. static int rss_vf_config_show(struct seq_file *seq, void *v, int idx)
  1917. {
  1918. if (v == SEQ_START_TOKEN) {
  1919. seq_puts(seq, " RSS Hash Tuple Enable\n");
  1920. seq_puts(seq, " Enable IVF Dis Enb IPv6 IPv4 UDP Def Secret Key\n");
  1921. seq_puts(seq, " VF Chn Prt Map VLAN uP Four Two Four Two Four Que Idx Hash\n");
  1922. } else {
  1923. struct rss_vf_conf *vfconf = v;
  1924. seq_printf(seq, "%3d %3s %3s %3d %3s %3s %3s %3s %3s %3s %3s %4d %3d %#10x\n",
  1925. idx,
  1926. yesno(vfconf->rss_vf_vfh & VFCHNEN_F),
  1927. yesno(vfconf->rss_vf_vfh & VFPRTEN_F),
  1928. VFLKPIDX_G(vfconf->rss_vf_vfh),
  1929. yesno(vfconf->rss_vf_vfh & VFVLNEX_F),
  1930. yesno(vfconf->rss_vf_vfh & VFUPEN_F),
  1931. yesno(vfconf->rss_vf_vfh & VFIP4FOURTUPEN_F),
  1932. yesno(vfconf->rss_vf_vfh & VFIP6TWOTUPEN_F),
  1933. yesno(vfconf->rss_vf_vfh & VFIP4FOURTUPEN_F),
  1934. yesno(vfconf->rss_vf_vfh & VFIP4TWOTUPEN_F),
  1935. yesno(vfconf->rss_vf_vfh & ENABLEUDPHASH_F),
  1936. DEFAULTQUEUE_G(vfconf->rss_vf_vfh),
  1937. KEYINDEX_G(vfconf->rss_vf_vfh),
  1938. vfconf->rss_vf_vfl);
  1939. }
  1940. return 0;
  1941. }
  1942. static int rss_vf_config_open(struct inode *inode, struct file *file)
  1943. {
  1944. struct adapter *adapter = inode->i_private;
  1945. struct seq_tab *p;
  1946. struct rss_vf_conf *vfconf;
  1947. int vf, vfcount = adapter->params.arch.vfcount;
  1948. p = seq_open_tab(file, vfcount, sizeof(*vfconf), 1, rss_vf_config_show);
  1949. if (!p)
  1950. return -ENOMEM;
  1951. vfconf = (struct rss_vf_conf *)p->data;
  1952. for (vf = 0; vf < vfcount; vf++) {
  1953. t4_read_rss_vf_config(adapter, vf, &vfconf[vf].rss_vf_vfl,
  1954. &vfconf[vf].rss_vf_vfh);
  1955. }
  1956. return 0;
  1957. }
  1958. static const struct file_operations rss_vf_config_debugfs_fops = {
  1959. .owner = THIS_MODULE,
  1960. .open = rss_vf_config_open,
  1961. .read = seq_read,
  1962. .llseek = seq_lseek,
  1963. .release = seq_release_private
  1964. };
  1965. /**
  1966. * ethqset2pinfo - return port_info of an Ethernet Queue Set
  1967. * @adap: the adapter
  1968. * @qset: Ethernet Queue Set
  1969. */
  1970. static inline struct port_info *ethqset2pinfo(struct adapter *adap, int qset)
  1971. {
  1972. int pidx;
  1973. for_each_port(adap, pidx) {
  1974. struct port_info *pi = adap2pinfo(adap, pidx);
  1975. if (qset >= pi->first_qset &&
  1976. qset < pi->first_qset + pi->nqsets)
  1977. return pi;
  1978. }
  1979. /* should never happen! */
  1980. BUG_ON(1);
  1981. return NULL;
  1982. }
  1983. static int sge_qinfo_show(struct seq_file *seq, void *v)
  1984. {
  1985. struct adapter *adap = seq->private;
  1986. int eth_entries = DIV_ROUND_UP(adap->sge.ethqsets, 4);
  1987. int iscsi_entries = DIV_ROUND_UP(adap->sge.ofldqsets, 4);
  1988. int rdma_entries = DIV_ROUND_UP(adap->sge.rdmaqs, 4);
  1989. int ciq_entries = DIV_ROUND_UP(adap->sge.rdmaciqs, 4);
  1990. int ctrl_entries = DIV_ROUND_UP(MAX_CTRL_QUEUES, 4);
  1991. int i, r = (uintptr_t)v - 1;
  1992. int iscsi_idx = r - eth_entries;
  1993. int rdma_idx = iscsi_idx - iscsi_entries;
  1994. int ciq_idx = rdma_idx - rdma_entries;
  1995. int ctrl_idx = ciq_idx - ciq_entries;
  1996. int fq_idx = ctrl_idx - ctrl_entries;
  1997. if (r)
  1998. seq_putc(seq, '\n');
  1999. #define S3(fmt_spec, s, v) \
  2000. do { \
  2001. seq_printf(seq, "%-12s", s); \
  2002. for (i = 0; i < n; ++i) \
  2003. seq_printf(seq, " %16" fmt_spec, v); \
  2004. seq_putc(seq, '\n'); \
  2005. } while (0)
  2006. #define S(s, v) S3("s", s, v)
  2007. #define T3(fmt_spec, s, v) S3(fmt_spec, s, tx[i].v)
  2008. #define T(s, v) S3("u", s, tx[i].v)
  2009. #define TL(s, v) T3("lu", s, v)
  2010. #define R3(fmt_spec, s, v) S3(fmt_spec, s, rx[i].v)
  2011. #define R(s, v) S3("u", s, rx[i].v)
  2012. #define RL(s, v) R3("lu", s, v)
  2013. if (r < eth_entries) {
  2014. int base_qset = r * 4;
  2015. const struct sge_eth_rxq *rx = &adap->sge.ethrxq[base_qset];
  2016. const struct sge_eth_txq *tx = &adap->sge.ethtxq[base_qset];
  2017. int n = min(4, adap->sge.ethqsets - 4 * r);
  2018. S("QType:", "Ethernet");
  2019. S("Interface:",
  2020. rx[i].rspq.netdev ? rx[i].rspq.netdev->name : "N/A");
  2021. T("TxQ ID:", q.cntxt_id);
  2022. T("TxQ size:", q.size);
  2023. T("TxQ inuse:", q.in_use);
  2024. T("TxQ CIDX:", q.cidx);
  2025. T("TxQ PIDX:", q.pidx);
  2026. #ifdef CONFIG_CHELSIO_T4_DCB
  2027. T("DCB Prio:", dcb_prio);
  2028. S3("u", "DCB PGID:",
  2029. (ethqset2pinfo(adap, base_qset + i)->dcb.pgid >>
  2030. 4*(7-tx[i].dcb_prio)) & 0xf);
  2031. S3("u", "DCB PFC:",
  2032. (ethqset2pinfo(adap, base_qset + i)->dcb.pfcen >>
  2033. 1*(7-tx[i].dcb_prio)) & 0x1);
  2034. #endif
  2035. R("RspQ ID:", rspq.abs_id);
  2036. R("RspQ size:", rspq.size);
  2037. R("RspQE size:", rspq.iqe_len);
  2038. R("RspQ CIDX:", rspq.cidx);
  2039. R("RspQ Gen:", rspq.gen);
  2040. S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
  2041. S3("u", "Intr pktcnt:",
  2042. adap->sge.counter_val[rx[i].rspq.pktcnt_idx]);
  2043. R("FL ID:", fl.cntxt_id);
  2044. R("FL size:", fl.size - 8);
  2045. R("FL pend:", fl.pend_cred);
  2046. R("FL avail:", fl.avail);
  2047. R("FL PIDX:", fl.pidx);
  2048. R("FL CIDX:", fl.cidx);
  2049. RL("RxPackets:", stats.pkts);
  2050. RL("RxCSO:", stats.rx_cso);
  2051. RL("VLANxtract:", stats.vlan_ex);
  2052. RL("LROmerged:", stats.lro_merged);
  2053. RL("LROpackets:", stats.lro_pkts);
  2054. RL("RxDrops:", stats.rx_drops);
  2055. TL("TSO:", tso);
  2056. TL("TxCSO:", tx_cso);
  2057. TL("VLANins:", vlan_ins);
  2058. TL("TxQFull:", q.stops);
  2059. TL("TxQRestarts:", q.restarts);
  2060. TL("TxMapErr:", mapping_err);
  2061. RL("FLAllocErr:", fl.alloc_failed);
  2062. RL("FLLrgAlcErr:", fl.large_alloc_failed);
  2063. RL("FLStarving:", fl.starving);
  2064. } else if (iscsi_idx < iscsi_entries) {
  2065. const struct sge_ofld_rxq *rx =
  2066. &adap->sge.ofldrxq[iscsi_idx * 4];
  2067. const struct sge_ofld_txq *tx =
  2068. &adap->sge.ofldtxq[iscsi_idx * 4];
  2069. int n = min(4, adap->sge.ofldqsets - 4 * iscsi_idx);
  2070. S("QType:", "iSCSI");
  2071. T("TxQ ID:", q.cntxt_id);
  2072. T("TxQ size:", q.size);
  2073. T("TxQ inuse:", q.in_use);
  2074. T("TxQ CIDX:", q.cidx);
  2075. T("TxQ PIDX:", q.pidx);
  2076. R("RspQ ID:", rspq.abs_id);
  2077. R("RspQ size:", rspq.size);
  2078. R("RspQE size:", rspq.iqe_len);
  2079. R("RspQ CIDX:", rspq.cidx);
  2080. R("RspQ Gen:", rspq.gen);
  2081. S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
  2082. S3("u", "Intr pktcnt:",
  2083. adap->sge.counter_val[rx[i].rspq.pktcnt_idx]);
  2084. R("FL ID:", fl.cntxt_id);
  2085. R("FL size:", fl.size - 8);
  2086. R("FL pend:", fl.pend_cred);
  2087. R("FL avail:", fl.avail);
  2088. R("FL PIDX:", fl.pidx);
  2089. R("FL CIDX:", fl.cidx);
  2090. RL("RxPackets:", stats.pkts);
  2091. RL("RxImmPkts:", stats.imm);
  2092. RL("RxNoMem:", stats.nomem);
  2093. RL("FLAllocErr:", fl.alloc_failed);
  2094. RL("FLLrgAlcErr:", fl.large_alloc_failed);
  2095. RL("FLStarving:", fl.starving);
  2096. } else if (rdma_idx < rdma_entries) {
  2097. const struct sge_ofld_rxq *rx =
  2098. &adap->sge.rdmarxq[rdma_idx * 4];
  2099. int n = min(4, adap->sge.rdmaqs - 4 * rdma_idx);
  2100. S("QType:", "RDMA-CPL");
  2101. S("Interface:",
  2102. rx[i].rspq.netdev ? rx[i].rspq.netdev->name : "N/A");
  2103. R("RspQ ID:", rspq.abs_id);
  2104. R("RspQ size:", rspq.size);
  2105. R("RspQE size:", rspq.iqe_len);
  2106. R("RspQ CIDX:", rspq.cidx);
  2107. R("RspQ Gen:", rspq.gen);
  2108. S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
  2109. S3("u", "Intr pktcnt:",
  2110. adap->sge.counter_val[rx[i].rspq.pktcnt_idx]);
  2111. R("FL ID:", fl.cntxt_id);
  2112. R("FL size:", fl.size - 8);
  2113. R("FL pend:", fl.pend_cred);
  2114. R("FL avail:", fl.avail);
  2115. R("FL PIDX:", fl.pidx);
  2116. R("FL CIDX:", fl.cidx);
  2117. RL("RxPackets:", stats.pkts);
  2118. RL("RxImmPkts:", stats.imm);
  2119. RL("RxNoMem:", stats.nomem);
  2120. RL("FLAllocErr:", fl.alloc_failed);
  2121. RL("FLLrgAlcErr:", fl.large_alloc_failed);
  2122. RL("FLStarving:", fl.starving);
  2123. } else if (ciq_idx < ciq_entries) {
  2124. const struct sge_ofld_rxq *rx = &adap->sge.rdmaciq[ciq_idx * 4];
  2125. int n = min(4, adap->sge.rdmaciqs - 4 * ciq_idx);
  2126. S("QType:", "RDMA-CIQ");
  2127. S("Interface:",
  2128. rx[i].rspq.netdev ? rx[i].rspq.netdev->name : "N/A");
  2129. R("RspQ ID:", rspq.abs_id);
  2130. R("RspQ size:", rspq.size);
  2131. R("RspQE size:", rspq.iqe_len);
  2132. R("RspQ CIDX:", rspq.cidx);
  2133. R("RspQ Gen:", rspq.gen);
  2134. S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
  2135. S3("u", "Intr pktcnt:",
  2136. adap->sge.counter_val[rx[i].rspq.pktcnt_idx]);
  2137. RL("RxAN:", stats.an);
  2138. RL("RxNoMem:", stats.nomem);
  2139. } else if (ctrl_idx < ctrl_entries) {
  2140. const struct sge_ctrl_txq *tx = &adap->sge.ctrlq[ctrl_idx * 4];
  2141. int n = min(4, adap->params.nports - 4 * ctrl_idx);
  2142. S("QType:", "Control");
  2143. T("TxQ ID:", q.cntxt_id);
  2144. T("TxQ size:", q.size);
  2145. T("TxQ inuse:", q.in_use);
  2146. T("TxQ CIDX:", q.cidx);
  2147. T("TxQ PIDX:", q.pidx);
  2148. TL("TxQFull:", q.stops);
  2149. TL("TxQRestarts:", q.restarts);
  2150. } else if (fq_idx == 0) {
  2151. const struct sge_rspq *evtq = &adap->sge.fw_evtq;
  2152. seq_printf(seq, "%-12s %16s\n", "QType:", "FW event queue");
  2153. seq_printf(seq, "%-12s %16u\n", "RspQ ID:", evtq->abs_id);
  2154. seq_printf(seq, "%-12s %16u\n", "RspQ size:", evtq->size);
  2155. seq_printf(seq, "%-12s %16u\n", "RspQE size:", evtq->iqe_len);
  2156. seq_printf(seq, "%-12s %16u\n", "RspQ CIDX:", evtq->cidx);
  2157. seq_printf(seq, "%-12s %16u\n", "RspQ Gen:", evtq->gen);
  2158. seq_printf(seq, "%-12s %16u\n", "Intr delay:",
  2159. qtimer_val(adap, evtq));
  2160. seq_printf(seq, "%-12s %16u\n", "Intr pktcnt:",
  2161. adap->sge.counter_val[evtq->pktcnt_idx]);
  2162. }
  2163. #undef R
  2164. #undef RL
  2165. #undef T
  2166. #undef TL
  2167. #undef S
  2168. #undef R3
  2169. #undef T3
  2170. #undef S3
  2171. return 0;
  2172. }
  2173. static int sge_queue_entries(const struct adapter *adap)
  2174. {
  2175. return DIV_ROUND_UP(adap->sge.ethqsets, 4) +
  2176. DIV_ROUND_UP(adap->sge.ofldqsets, 4) +
  2177. DIV_ROUND_UP(adap->sge.rdmaqs, 4) +
  2178. DIV_ROUND_UP(adap->sge.rdmaciqs, 4) +
  2179. DIV_ROUND_UP(MAX_CTRL_QUEUES, 4) + 1;
  2180. }
  2181. static void *sge_queue_start(struct seq_file *seq, loff_t *pos)
  2182. {
  2183. int entries = sge_queue_entries(seq->private);
  2184. return *pos < entries ? (void *)((uintptr_t)*pos + 1) : NULL;
  2185. }
  2186. static void sge_queue_stop(struct seq_file *seq, void *v)
  2187. {
  2188. }
  2189. static void *sge_queue_next(struct seq_file *seq, void *v, loff_t *pos)
  2190. {
  2191. int entries = sge_queue_entries(seq->private);
  2192. ++*pos;
  2193. return *pos < entries ? (void *)((uintptr_t)*pos + 1) : NULL;
  2194. }
  2195. static const struct seq_operations sge_qinfo_seq_ops = {
  2196. .start = sge_queue_start,
  2197. .next = sge_queue_next,
  2198. .stop = sge_queue_stop,
  2199. .show = sge_qinfo_show
  2200. };
  2201. static int sge_qinfo_open(struct inode *inode, struct file *file)
  2202. {
  2203. int res = seq_open(file, &sge_qinfo_seq_ops);
  2204. if (!res) {
  2205. struct seq_file *seq = file->private_data;
  2206. seq->private = inode->i_private;
  2207. }
  2208. return res;
  2209. }
  2210. static const struct file_operations sge_qinfo_debugfs_fops = {
  2211. .owner = THIS_MODULE,
  2212. .open = sge_qinfo_open,
  2213. .read = seq_read,
  2214. .llseek = seq_lseek,
  2215. .release = seq_release,
  2216. };
  2217. int mem_open(struct inode *inode, struct file *file)
  2218. {
  2219. unsigned int mem;
  2220. struct adapter *adap;
  2221. file->private_data = inode->i_private;
  2222. mem = (uintptr_t)file->private_data & 0x3;
  2223. adap = file->private_data - mem;
  2224. (void)t4_fwcache(adap, FW_PARAM_DEV_FWCACHE_FLUSH);
  2225. return 0;
  2226. }
  2227. static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
  2228. loff_t *ppos)
  2229. {
  2230. loff_t pos = *ppos;
  2231. loff_t avail = file_inode(file)->i_size;
  2232. unsigned int mem = (uintptr_t)file->private_data & 3;
  2233. struct adapter *adap = file->private_data - mem;
  2234. __be32 *data;
  2235. int ret;
  2236. if (pos < 0)
  2237. return -EINVAL;
  2238. if (pos >= avail)
  2239. return 0;
  2240. if (count > avail - pos)
  2241. count = avail - pos;
  2242. data = t4_alloc_mem(count);
  2243. if (!data)
  2244. return -ENOMEM;
  2245. spin_lock(&adap->win0_lock);
  2246. ret = t4_memory_rw(adap, 0, mem, pos, count, data, T4_MEMORY_READ);
  2247. spin_unlock(&adap->win0_lock);
  2248. if (ret) {
  2249. t4_free_mem(data);
  2250. return ret;
  2251. }
  2252. ret = copy_to_user(buf, data, count);
  2253. t4_free_mem(data);
  2254. if (ret)
  2255. return -EFAULT;
  2256. *ppos = pos + count;
  2257. return count;
  2258. }
  2259. static const struct file_operations mem_debugfs_fops = {
  2260. .owner = THIS_MODULE,
  2261. .open = simple_open,
  2262. .read = mem_read,
  2263. .llseek = default_llseek,
  2264. };
  2265. static int tid_info_show(struct seq_file *seq, void *v)
  2266. {
  2267. struct adapter *adap = seq->private;
  2268. const struct tid_info *t = &adap->tids;
  2269. enum chip_type chip = CHELSIO_CHIP_VERSION(adap->params.chip);
  2270. if (t4_read_reg(adap, LE_DB_CONFIG_A) & HASHEN_F) {
  2271. unsigned int sb;
  2272. if (chip <= CHELSIO_T5)
  2273. sb = t4_read_reg(adap, LE_DB_SERVER_INDEX_A) / 4;
  2274. else
  2275. sb = t4_read_reg(adap, LE_DB_SRVR_START_INDEX_A);
  2276. if (sb) {
  2277. seq_printf(seq, "TID range: 0..%u/%u..%u", sb - 1,
  2278. adap->tids.hash_base,
  2279. t->ntids - 1);
  2280. seq_printf(seq, ", in use: %u/%u\n",
  2281. atomic_read(&t->tids_in_use),
  2282. atomic_read(&t->hash_tids_in_use));
  2283. } else if (adap->flags & FW_OFLD_CONN) {
  2284. seq_printf(seq, "TID range: %u..%u/%u..%u",
  2285. t->aftid_base,
  2286. t->aftid_end,
  2287. adap->tids.hash_base,
  2288. t->ntids - 1);
  2289. seq_printf(seq, ", in use: %u/%u\n",
  2290. atomic_read(&t->tids_in_use),
  2291. atomic_read(&t->hash_tids_in_use));
  2292. } else {
  2293. seq_printf(seq, "TID range: %u..%u",
  2294. adap->tids.hash_base,
  2295. t->ntids - 1);
  2296. seq_printf(seq, ", in use: %u\n",
  2297. atomic_read(&t->hash_tids_in_use));
  2298. }
  2299. } else if (t->ntids) {
  2300. seq_printf(seq, "TID range: 0..%u", t->ntids - 1);
  2301. seq_printf(seq, ", in use: %u\n",
  2302. atomic_read(&t->tids_in_use));
  2303. }
  2304. if (t->nstids)
  2305. seq_printf(seq, "STID range: %u..%u, in use: %u\n",
  2306. (!t->stid_base &&
  2307. (chip <= CHELSIO_T5)) ?
  2308. t->stid_base + 1 : t->stid_base,
  2309. t->stid_base + t->nstids - 1, t->stids_in_use);
  2310. if (t->natids)
  2311. seq_printf(seq, "ATID range: 0..%u, in use: %u\n",
  2312. t->natids - 1, t->atids_in_use);
  2313. seq_printf(seq, "FTID range: %u..%u\n", t->ftid_base,
  2314. t->ftid_base + t->nftids - 1);
  2315. if (t->nsftids)
  2316. seq_printf(seq, "SFTID range: %u..%u in use: %u\n",
  2317. t->sftid_base, t->sftid_base + t->nsftids - 2,
  2318. t->sftids_in_use);
  2319. if (t->ntids)
  2320. seq_printf(seq, "HW TID usage: %u IP users, %u IPv6 users\n",
  2321. t4_read_reg(adap, LE_DB_ACT_CNT_IPV4_A),
  2322. t4_read_reg(adap, LE_DB_ACT_CNT_IPV6_A));
  2323. return 0;
  2324. }
  2325. DEFINE_SIMPLE_DEBUGFS_FILE(tid_info);
  2326. static void add_debugfs_mem(struct adapter *adap, const char *name,
  2327. unsigned int idx, unsigned int size_mb)
  2328. {
  2329. debugfs_create_file_size(name, S_IRUSR, adap->debugfs_root,
  2330. (void *)adap + idx, &mem_debugfs_fops,
  2331. size_mb << 20);
  2332. }
  2333. static int blocked_fl_open(struct inode *inode, struct file *file)
  2334. {
  2335. file->private_data = inode->i_private;
  2336. return 0;
  2337. }
  2338. static ssize_t blocked_fl_read(struct file *filp, char __user *ubuf,
  2339. size_t count, loff_t *ppos)
  2340. {
  2341. int len;
  2342. const struct adapter *adap = filp->private_data;
  2343. char *buf;
  2344. ssize_t size = (adap->sge.egr_sz + 3) / 4 +
  2345. adap->sge.egr_sz / 32 + 2; /* includes ,/\n/\0 */
  2346. buf = kzalloc(size, GFP_KERNEL);
  2347. if (!buf)
  2348. return -ENOMEM;
  2349. len = snprintf(buf, size - 1, "%*pb\n",
  2350. adap->sge.egr_sz, adap->sge.blocked_fl);
  2351. len += sprintf(buf + len, "\n");
  2352. size = simple_read_from_buffer(ubuf, count, ppos, buf, len);
  2353. t4_free_mem(buf);
  2354. return size;
  2355. }
  2356. static ssize_t blocked_fl_write(struct file *filp, const char __user *ubuf,
  2357. size_t count, loff_t *ppos)
  2358. {
  2359. int err;
  2360. unsigned long *t;
  2361. struct adapter *adap = filp->private_data;
  2362. t = kcalloc(BITS_TO_LONGS(adap->sge.egr_sz), sizeof(long), GFP_KERNEL);
  2363. if (!t)
  2364. return -ENOMEM;
  2365. err = bitmap_parse_user(ubuf, count, t, adap->sge.egr_sz);
  2366. if (err)
  2367. return err;
  2368. bitmap_copy(adap->sge.blocked_fl, t, adap->sge.egr_sz);
  2369. t4_free_mem(t);
  2370. return count;
  2371. }
  2372. static const struct file_operations blocked_fl_fops = {
  2373. .owner = THIS_MODULE,
  2374. .open = blocked_fl_open,
  2375. .read = blocked_fl_read,
  2376. .write = blocked_fl_write,
  2377. .llseek = generic_file_llseek,
  2378. };
  2379. struct mem_desc {
  2380. unsigned int base;
  2381. unsigned int limit;
  2382. unsigned int idx;
  2383. };
  2384. static int mem_desc_cmp(const void *a, const void *b)
  2385. {
  2386. return ((const struct mem_desc *)a)->base -
  2387. ((const struct mem_desc *)b)->base;
  2388. }
  2389. static void mem_region_show(struct seq_file *seq, const char *name,
  2390. unsigned int from, unsigned int to)
  2391. {
  2392. char buf[40];
  2393. string_get_size((u64)to - from + 1, 1, STRING_UNITS_2, buf,
  2394. sizeof(buf));
  2395. seq_printf(seq, "%-15s %#x-%#x [%s]\n", name, from, to, buf);
  2396. }
  2397. static int meminfo_show(struct seq_file *seq, void *v)
  2398. {
  2399. static const char * const memory[] = { "EDC0:", "EDC1:", "MC:",
  2400. "MC0:", "MC1:"};
  2401. static const char * const region[] = {
  2402. "DBQ contexts:", "IMSG contexts:", "FLM cache:", "TCBs:",
  2403. "Pstructs:", "Timers:", "Rx FL:", "Tx FL:", "Pstruct FL:",
  2404. "Tx payload:", "Rx payload:", "LE hash:", "iSCSI region:",
  2405. "TDDP region:", "TPT region:", "STAG region:", "RQ region:",
  2406. "RQUDP region:", "PBL region:", "TXPBL region:",
  2407. "DBVFIFO region:", "ULPRX state:", "ULPTX state:",
  2408. "On-chip queues:"
  2409. };
  2410. int i, n;
  2411. u32 lo, hi, used, alloc;
  2412. struct mem_desc avail[4];
  2413. struct mem_desc mem[ARRAY_SIZE(region) + 3]; /* up to 3 holes */
  2414. struct mem_desc *md = mem;
  2415. struct adapter *adap = seq->private;
  2416. for (i = 0; i < ARRAY_SIZE(mem); i++) {
  2417. mem[i].limit = 0;
  2418. mem[i].idx = i;
  2419. }
  2420. /* Find and sort the populated memory ranges */
  2421. i = 0;
  2422. lo = t4_read_reg(adap, MA_TARGET_MEM_ENABLE_A);
  2423. if (lo & EDRAM0_ENABLE_F) {
  2424. hi = t4_read_reg(adap, MA_EDRAM0_BAR_A);
  2425. avail[i].base = EDRAM0_BASE_G(hi) << 20;
  2426. avail[i].limit = avail[i].base + (EDRAM0_SIZE_G(hi) << 20);
  2427. avail[i].idx = 0;
  2428. i++;
  2429. }
  2430. if (lo & EDRAM1_ENABLE_F) {
  2431. hi = t4_read_reg(adap, MA_EDRAM1_BAR_A);
  2432. avail[i].base = EDRAM1_BASE_G(hi) << 20;
  2433. avail[i].limit = avail[i].base + (EDRAM1_SIZE_G(hi) << 20);
  2434. avail[i].idx = 1;
  2435. i++;
  2436. }
  2437. if (is_t5(adap->params.chip)) {
  2438. if (lo & EXT_MEM0_ENABLE_F) {
  2439. hi = t4_read_reg(adap, MA_EXT_MEMORY0_BAR_A);
  2440. avail[i].base = EXT_MEM0_BASE_G(hi) << 20;
  2441. avail[i].limit =
  2442. avail[i].base + (EXT_MEM0_SIZE_G(hi) << 20);
  2443. avail[i].idx = 3;
  2444. i++;
  2445. }
  2446. if (lo & EXT_MEM1_ENABLE_F) {
  2447. hi = t4_read_reg(adap, MA_EXT_MEMORY1_BAR_A);
  2448. avail[i].base = EXT_MEM1_BASE_G(hi) << 20;
  2449. avail[i].limit =
  2450. avail[i].base + (EXT_MEM1_SIZE_G(hi) << 20);
  2451. avail[i].idx = 4;
  2452. i++;
  2453. }
  2454. } else {
  2455. if (lo & EXT_MEM_ENABLE_F) {
  2456. hi = t4_read_reg(adap, MA_EXT_MEMORY_BAR_A);
  2457. avail[i].base = EXT_MEM_BASE_G(hi) << 20;
  2458. avail[i].limit =
  2459. avail[i].base + (EXT_MEM_SIZE_G(hi) << 20);
  2460. avail[i].idx = 2;
  2461. i++;
  2462. }
  2463. }
  2464. if (!i) /* no memory available */
  2465. return 0;
  2466. sort(avail, i, sizeof(struct mem_desc), mem_desc_cmp, NULL);
  2467. (md++)->base = t4_read_reg(adap, SGE_DBQ_CTXT_BADDR_A);
  2468. (md++)->base = t4_read_reg(adap, SGE_IMSG_CTXT_BADDR_A);
  2469. (md++)->base = t4_read_reg(adap, SGE_FLM_CACHE_BADDR_A);
  2470. (md++)->base = t4_read_reg(adap, TP_CMM_TCB_BASE_A);
  2471. (md++)->base = t4_read_reg(adap, TP_CMM_MM_BASE_A);
  2472. (md++)->base = t4_read_reg(adap, TP_CMM_TIMER_BASE_A);
  2473. (md++)->base = t4_read_reg(adap, TP_CMM_MM_RX_FLST_BASE_A);
  2474. (md++)->base = t4_read_reg(adap, TP_CMM_MM_TX_FLST_BASE_A);
  2475. (md++)->base = t4_read_reg(adap, TP_CMM_MM_PS_FLST_BASE_A);
  2476. /* the next few have explicit upper bounds */
  2477. md->base = t4_read_reg(adap, TP_PMM_TX_BASE_A);
  2478. md->limit = md->base - 1 +
  2479. t4_read_reg(adap, TP_PMM_TX_PAGE_SIZE_A) *
  2480. PMTXMAXPAGE_G(t4_read_reg(adap, TP_PMM_TX_MAX_PAGE_A));
  2481. md++;
  2482. md->base = t4_read_reg(adap, TP_PMM_RX_BASE_A);
  2483. md->limit = md->base - 1 +
  2484. t4_read_reg(adap, TP_PMM_RX_PAGE_SIZE_A) *
  2485. PMRXMAXPAGE_G(t4_read_reg(adap, TP_PMM_RX_MAX_PAGE_A));
  2486. md++;
  2487. if (t4_read_reg(adap, LE_DB_CONFIG_A) & HASHEN_F) {
  2488. if (CHELSIO_CHIP_VERSION(adap->params.chip) <= CHELSIO_T5) {
  2489. hi = t4_read_reg(adap, LE_DB_TID_HASHBASE_A) / 4;
  2490. md->base = t4_read_reg(adap, LE_DB_HASH_TID_BASE_A);
  2491. } else {
  2492. hi = t4_read_reg(adap, LE_DB_HASH_TID_BASE_A);
  2493. md->base = t4_read_reg(adap,
  2494. LE_DB_HASH_TBL_BASE_ADDR_A);
  2495. }
  2496. md->limit = 0;
  2497. } else {
  2498. md->base = 0;
  2499. md->idx = ARRAY_SIZE(region); /* hide it */
  2500. }
  2501. md++;
  2502. #define ulp_region(reg) do { \
  2503. md->base = t4_read_reg(adap, ULP_ ## reg ## _LLIMIT_A);\
  2504. (md++)->limit = t4_read_reg(adap, ULP_ ## reg ## _ULIMIT_A); \
  2505. } while (0)
  2506. ulp_region(RX_ISCSI);
  2507. ulp_region(RX_TDDP);
  2508. ulp_region(TX_TPT);
  2509. ulp_region(RX_STAG);
  2510. ulp_region(RX_RQ);
  2511. ulp_region(RX_RQUDP);
  2512. ulp_region(RX_PBL);
  2513. ulp_region(TX_PBL);
  2514. #undef ulp_region
  2515. md->base = 0;
  2516. md->idx = ARRAY_SIZE(region);
  2517. if (!is_t4(adap->params.chip)) {
  2518. u32 size = 0;
  2519. u32 sge_ctrl = t4_read_reg(adap, SGE_CONTROL2_A);
  2520. u32 fifo_size = t4_read_reg(adap, SGE_DBVFIFO_SIZE_A);
  2521. if (is_t5(adap->params.chip)) {
  2522. if (sge_ctrl & VFIFO_ENABLE_F)
  2523. size = DBVFIFO_SIZE_G(fifo_size);
  2524. } else {
  2525. size = T6_DBVFIFO_SIZE_G(fifo_size);
  2526. }
  2527. if (size) {
  2528. md->base = BASEADDR_G(t4_read_reg(adap,
  2529. SGE_DBVFIFO_BADDR_A));
  2530. md->limit = md->base + (size << 2) - 1;
  2531. }
  2532. }
  2533. md++;
  2534. md->base = t4_read_reg(adap, ULP_RX_CTX_BASE_A);
  2535. md->limit = 0;
  2536. md++;
  2537. md->base = t4_read_reg(adap, ULP_TX_ERR_TABLE_BASE_A);
  2538. md->limit = 0;
  2539. md++;
  2540. md->base = adap->vres.ocq.start;
  2541. if (adap->vres.ocq.size)
  2542. md->limit = md->base + adap->vres.ocq.size - 1;
  2543. else
  2544. md->idx = ARRAY_SIZE(region); /* hide it */
  2545. md++;
  2546. /* add any address-space holes, there can be up to 3 */
  2547. for (n = 0; n < i - 1; n++)
  2548. if (avail[n].limit < avail[n + 1].base)
  2549. (md++)->base = avail[n].limit;
  2550. if (avail[n].limit)
  2551. (md++)->base = avail[n].limit;
  2552. n = md - mem;
  2553. sort(mem, n, sizeof(struct mem_desc), mem_desc_cmp, NULL);
  2554. for (lo = 0; lo < i; lo++)
  2555. mem_region_show(seq, memory[avail[lo].idx], avail[lo].base,
  2556. avail[lo].limit - 1);
  2557. seq_putc(seq, '\n');
  2558. for (i = 0; i < n; i++) {
  2559. if (mem[i].idx >= ARRAY_SIZE(region))
  2560. continue; /* skip holes */
  2561. if (!mem[i].limit)
  2562. mem[i].limit = i < n - 1 ? mem[i + 1].base - 1 : ~0;
  2563. mem_region_show(seq, region[mem[i].idx], mem[i].base,
  2564. mem[i].limit);
  2565. }
  2566. seq_putc(seq, '\n');
  2567. lo = t4_read_reg(adap, CIM_SDRAM_BASE_ADDR_A);
  2568. hi = t4_read_reg(adap, CIM_SDRAM_ADDR_SIZE_A) + lo - 1;
  2569. mem_region_show(seq, "uP RAM:", lo, hi);
  2570. lo = t4_read_reg(adap, CIM_EXTMEM2_BASE_ADDR_A);
  2571. hi = t4_read_reg(adap, CIM_EXTMEM2_ADDR_SIZE_A) + lo - 1;
  2572. mem_region_show(seq, "uP Extmem2:", lo, hi);
  2573. lo = t4_read_reg(adap, TP_PMM_RX_MAX_PAGE_A);
  2574. seq_printf(seq, "\n%u Rx pages of size %uKiB for %u channels\n",
  2575. PMRXMAXPAGE_G(lo),
  2576. t4_read_reg(adap, TP_PMM_RX_PAGE_SIZE_A) >> 10,
  2577. (lo & PMRXNUMCHN_F) ? 2 : 1);
  2578. lo = t4_read_reg(adap, TP_PMM_TX_MAX_PAGE_A);
  2579. hi = t4_read_reg(adap, TP_PMM_TX_PAGE_SIZE_A);
  2580. seq_printf(seq, "%u Tx pages of size %u%ciB for %u channels\n",
  2581. PMTXMAXPAGE_G(lo),
  2582. hi >= (1 << 20) ? (hi >> 20) : (hi >> 10),
  2583. hi >= (1 << 20) ? 'M' : 'K', 1 << PMTXNUMCHN_G(lo));
  2584. seq_printf(seq, "%u p-structs\n\n",
  2585. t4_read_reg(adap, TP_CMM_MM_MAX_PSTRUCT_A));
  2586. for (i = 0; i < 4; i++) {
  2587. if (CHELSIO_CHIP_VERSION(adap->params.chip) > CHELSIO_T5)
  2588. lo = t4_read_reg(adap, MPS_RX_MAC_BG_PG_CNT0_A + i * 4);
  2589. else
  2590. lo = t4_read_reg(adap, MPS_RX_PG_RSV0_A + i * 4);
  2591. if (is_t5(adap->params.chip)) {
  2592. used = T5_USED_G(lo);
  2593. alloc = T5_ALLOC_G(lo);
  2594. } else {
  2595. used = USED_G(lo);
  2596. alloc = ALLOC_G(lo);
  2597. }
  2598. /* For T6 these are MAC buffer groups */
  2599. seq_printf(seq, "Port %d using %u pages out of %u allocated\n",
  2600. i, used, alloc);
  2601. }
  2602. for (i = 0; i < adap->params.arch.nchan; i++) {
  2603. if (CHELSIO_CHIP_VERSION(adap->params.chip) > CHELSIO_T5)
  2604. lo = t4_read_reg(adap,
  2605. MPS_RX_LPBK_BG_PG_CNT0_A + i * 4);
  2606. else
  2607. lo = t4_read_reg(adap, MPS_RX_PG_RSV4_A + i * 4);
  2608. if (is_t5(adap->params.chip)) {
  2609. used = T5_USED_G(lo);
  2610. alloc = T5_ALLOC_G(lo);
  2611. } else {
  2612. used = USED_G(lo);
  2613. alloc = ALLOC_G(lo);
  2614. }
  2615. /* For T6 these are MAC buffer groups */
  2616. seq_printf(seq,
  2617. "Loopback %d using %u pages out of %u allocated\n",
  2618. i, used, alloc);
  2619. }
  2620. return 0;
  2621. }
  2622. static int meminfo_open(struct inode *inode, struct file *file)
  2623. {
  2624. return single_open(file, meminfo_show, inode->i_private);
  2625. }
  2626. static const struct file_operations meminfo_fops = {
  2627. .owner = THIS_MODULE,
  2628. .open = meminfo_open,
  2629. .read = seq_read,
  2630. .llseek = seq_lseek,
  2631. .release = single_release,
  2632. };
  2633. /* Add an array of Debug FS files.
  2634. */
  2635. void add_debugfs_files(struct adapter *adap,
  2636. struct t4_debugfs_entry *files,
  2637. unsigned int nfiles)
  2638. {
  2639. int i;
  2640. /* debugfs support is best effort */
  2641. for (i = 0; i < nfiles; i++)
  2642. debugfs_create_file(files[i].name, files[i].mode,
  2643. adap->debugfs_root,
  2644. (void *)adap + files[i].data,
  2645. files[i].ops);
  2646. }
  2647. int t4_setup_debugfs(struct adapter *adap)
  2648. {
  2649. int i;
  2650. u32 size = 0;
  2651. struct dentry *de;
  2652. static struct t4_debugfs_entry t4_debugfs_files[] = {
  2653. { "cim_la", &cim_la_fops, S_IRUSR, 0 },
  2654. { "cim_pif_la", &cim_pif_la_fops, S_IRUSR, 0 },
  2655. { "cim_ma_la", &cim_ma_la_fops, S_IRUSR, 0 },
  2656. { "cim_qcfg", &cim_qcfg_fops, S_IRUSR, 0 },
  2657. { "clk", &clk_debugfs_fops, S_IRUSR, 0 },
  2658. { "devlog", &devlog_fops, S_IRUSR, 0 },
  2659. { "mbox0", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 0 },
  2660. { "mbox1", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 1 },
  2661. { "mbox2", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 2 },
  2662. { "mbox3", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 3 },
  2663. { "mbox4", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 4 },
  2664. { "mbox5", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 5 },
  2665. { "mbox6", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 6 },
  2666. { "mbox7", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 7 },
  2667. { "trace0", &mps_trc_debugfs_fops, S_IRUSR | S_IWUSR, 0 },
  2668. { "trace1", &mps_trc_debugfs_fops, S_IRUSR | S_IWUSR, 1 },
  2669. { "trace2", &mps_trc_debugfs_fops, S_IRUSR | S_IWUSR, 2 },
  2670. { "trace3", &mps_trc_debugfs_fops, S_IRUSR | S_IWUSR, 3 },
  2671. { "l2t", &t4_l2t_fops, S_IRUSR, 0},
  2672. { "mps_tcam", &mps_tcam_debugfs_fops, S_IRUSR, 0 },
  2673. { "rss", &rss_debugfs_fops, S_IRUSR, 0 },
  2674. { "rss_config", &rss_config_debugfs_fops, S_IRUSR, 0 },
  2675. { "rss_key", &rss_key_debugfs_fops, S_IRUSR, 0 },
  2676. { "rss_pf_config", &rss_pf_config_debugfs_fops, S_IRUSR, 0 },
  2677. { "rss_vf_config", &rss_vf_config_debugfs_fops, S_IRUSR, 0 },
  2678. { "sge_qinfo", &sge_qinfo_debugfs_fops, S_IRUSR, 0 },
  2679. { "ibq_tp0", &cim_ibq_fops, S_IRUSR, 0 },
  2680. { "ibq_tp1", &cim_ibq_fops, S_IRUSR, 1 },
  2681. { "ibq_ulp", &cim_ibq_fops, S_IRUSR, 2 },
  2682. { "ibq_sge0", &cim_ibq_fops, S_IRUSR, 3 },
  2683. { "ibq_sge1", &cim_ibq_fops, S_IRUSR, 4 },
  2684. { "ibq_ncsi", &cim_ibq_fops, S_IRUSR, 5 },
  2685. { "obq_ulp0", &cim_obq_fops, S_IRUSR, 0 },
  2686. { "obq_ulp1", &cim_obq_fops, S_IRUSR, 1 },
  2687. { "obq_ulp2", &cim_obq_fops, S_IRUSR, 2 },
  2688. { "obq_ulp3", &cim_obq_fops, S_IRUSR, 3 },
  2689. { "obq_sge", &cim_obq_fops, S_IRUSR, 4 },
  2690. { "obq_ncsi", &cim_obq_fops, S_IRUSR, 5 },
  2691. { "tp_la", &tp_la_fops, S_IRUSR, 0 },
  2692. { "ulprx_la", &ulprx_la_fops, S_IRUSR, 0 },
  2693. { "sensors", &sensors_debugfs_fops, S_IRUSR, 0 },
  2694. { "pm_stats", &pm_stats_debugfs_fops, S_IRUSR, 0 },
  2695. { "tx_rate", &tx_rate_debugfs_fops, S_IRUSR, 0 },
  2696. { "cctrl", &cctrl_tbl_debugfs_fops, S_IRUSR, 0 },
  2697. #if IS_ENABLED(CONFIG_IPV6)
  2698. { "clip_tbl", &clip_tbl_debugfs_fops, S_IRUSR, 0 },
  2699. #endif
  2700. { "tids", &tid_info_debugfs_fops, S_IRUSR, 0},
  2701. { "blocked_fl", &blocked_fl_fops, S_IRUSR | S_IWUSR, 0 },
  2702. { "meminfo", &meminfo_fops, S_IRUSR, 0 },
  2703. };
  2704. /* Debug FS nodes common to all T5 and later adapters.
  2705. */
  2706. static struct t4_debugfs_entry t5_debugfs_files[] = {
  2707. { "obq_sge_rx_q0", &cim_obq_fops, S_IRUSR, 6 },
  2708. { "obq_sge_rx_q1", &cim_obq_fops, S_IRUSR, 7 },
  2709. };
  2710. add_debugfs_files(adap,
  2711. t4_debugfs_files,
  2712. ARRAY_SIZE(t4_debugfs_files));
  2713. if (!is_t4(adap->params.chip))
  2714. add_debugfs_files(adap,
  2715. t5_debugfs_files,
  2716. ARRAY_SIZE(t5_debugfs_files));
  2717. i = t4_read_reg(adap, MA_TARGET_MEM_ENABLE_A);
  2718. if (i & EDRAM0_ENABLE_F) {
  2719. size = t4_read_reg(adap, MA_EDRAM0_BAR_A);
  2720. add_debugfs_mem(adap, "edc0", MEM_EDC0, EDRAM0_SIZE_G(size));
  2721. }
  2722. if (i & EDRAM1_ENABLE_F) {
  2723. size = t4_read_reg(adap, MA_EDRAM1_BAR_A);
  2724. add_debugfs_mem(adap, "edc1", MEM_EDC1, EDRAM1_SIZE_G(size));
  2725. }
  2726. if (is_t5(adap->params.chip)) {
  2727. if (i & EXT_MEM0_ENABLE_F) {
  2728. size = t4_read_reg(adap, MA_EXT_MEMORY0_BAR_A);
  2729. add_debugfs_mem(adap, "mc0", MEM_MC0,
  2730. EXT_MEM0_SIZE_G(size));
  2731. }
  2732. if (i & EXT_MEM1_ENABLE_F) {
  2733. size = t4_read_reg(adap, MA_EXT_MEMORY1_BAR_A);
  2734. add_debugfs_mem(adap, "mc1", MEM_MC1,
  2735. EXT_MEM1_SIZE_G(size));
  2736. }
  2737. } else {
  2738. if (i & EXT_MEM_ENABLE_F) {
  2739. size = t4_read_reg(adap, MA_EXT_MEMORY_BAR_A);
  2740. add_debugfs_mem(adap, "mc", MEM_MC,
  2741. EXT_MEM_SIZE_G(size));
  2742. }
  2743. }
  2744. de = debugfs_create_file_size("flash", S_IRUSR, adap->debugfs_root, adap,
  2745. &flash_debugfs_fops, adap->params.sf_size);
  2746. debugfs_create_bool("use_backdoor", S_IWUSR | S_IRUSR,
  2747. adap->debugfs_root, &adap->use_bd);
  2748. debugfs_create_bool("trace_rss", S_IWUSR | S_IRUSR,
  2749. adap->debugfs_root, &adap->trace_rss);
  2750. return 0;
  2751. }