cxgb4_debugfs.c 101 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723
  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. #include "cudbg_if.h"
  47. #include "cudbg_lib_common.h"
  48. #include "cudbg_entity.h"
  49. #include "cudbg_lib.h"
  50. /* generic seq_file support for showing a table of size rows x width. */
  51. static void *seq_tab_get_idx(struct seq_tab *tb, loff_t pos)
  52. {
  53. pos -= tb->skip_first;
  54. return pos >= tb->rows ? NULL : &tb->data[pos * tb->width];
  55. }
  56. static void *seq_tab_start(struct seq_file *seq, loff_t *pos)
  57. {
  58. struct seq_tab *tb = seq->private;
  59. if (tb->skip_first && *pos == 0)
  60. return SEQ_START_TOKEN;
  61. return seq_tab_get_idx(tb, *pos);
  62. }
  63. static void *seq_tab_next(struct seq_file *seq, void *v, loff_t *pos)
  64. {
  65. v = seq_tab_get_idx(seq->private, *pos + 1);
  66. ++(*pos);
  67. return v;
  68. }
  69. static void seq_tab_stop(struct seq_file *seq, void *v)
  70. {
  71. }
  72. static int seq_tab_show(struct seq_file *seq, void *v)
  73. {
  74. const struct seq_tab *tb = seq->private;
  75. return tb->show(seq, v, ((char *)v - tb->data) / tb->width);
  76. }
  77. static const struct seq_operations seq_tab_ops = {
  78. .start = seq_tab_start,
  79. .next = seq_tab_next,
  80. .stop = seq_tab_stop,
  81. .show = seq_tab_show
  82. };
  83. struct seq_tab *seq_open_tab(struct file *f, unsigned int rows,
  84. unsigned int width, unsigned int have_header,
  85. int (*show)(struct seq_file *seq, void *v, int i))
  86. {
  87. struct seq_tab *p;
  88. p = __seq_open_private(f, &seq_tab_ops, sizeof(*p) + rows * width);
  89. if (p) {
  90. p->show = show;
  91. p->rows = rows;
  92. p->width = width;
  93. p->skip_first = have_header != 0;
  94. }
  95. return p;
  96. }
  97. /* Trim the size of a seq_tab to the supplied number of rows. The operation is
  98. * irreversible.
  99. */
  100. static int seq_tab_trim(struct seq_tab *p, unsigned int new_rows)
  101. {
  102. if (new_rows > p->rows)
  103. return -EINVAL;
  104. p->rows = new_rows;
  105. return 0;
  106. }
  107. static int cim_la_show(struct seq_file *seq, void *v, int idx)
  108. {
  109. if (v == SEQ_START_TOKEN)
  110. seq_puts(seq, "Status Data PC LS0Stat LS0Addr "
  111. " LS0Data\n");
  112. else {
  113. const u32 *p = v;
  114. seq_printf(seq,
  115. " %02x %x%07x %x%07x %08x %08x %08x%08x%08x%08x\n",
  116. (p[0] >> 4) & 0xff, p[0] & 0xf, p[1] >> 4,
  117. p[1] & 0xf, p[2] >> 4, p[2] & 0xf, p[3], p[4], p[5],
  118. p[6], p[7]);
  119. }
  120. return 0;
  121. }
  122. static int cim_la_show_3in1(struct seq_file *seq, void *v, int idx)
  123. {
  124. if (v == SEQ_START_TOKEN) {
  125. seq_puts(seq, "Status Data PC\n");
  126. } else {
  127. const u32 *p = v;
  128. seq_printf(seq, " %02x %08x %08x\n", p[5] & 0xff, p[6],
  129. p[7]);
  130. seq_printf(seq, " %02x %02x%06x %02x%06x\n",
  131. (p[3] >> 8) & 0xff, p[3] & 0xff, p[4] >> 8,
  132. p[4] & 0xff, p[5] >> 8);
  133. seq_printf(seq, " %02x %x%07x %x%07x\n", (p[0] >> 4) & 0xff,
  134. p[0] & 0xf, p[1] >> 4, p[1] & 0xf, p[2] >> 4);
  135. }
  136. return 0;
  137. }
  138. static int cim_la_show_t6(struct seq_file *seq, void *v, int idx)
  139. {
  140. if (v == SEQ_START_TOKEN) {
  141. seq_puts(seq, "Status Inst Data PC LS0Stat "
  142. "LS0Addr LS0Data LS1Stat LS1Addr LS1Data\n");
  143. } else {
  144. const u32 *p = v;
  145. seq_printf(seq, " %02x %04x%04x %04x%04x %04x%04x %08x %08x %08x %08x %08x %08x\n",
  146. (p[9] >> 16) & 0xff, /* Status */
  147. p[9] & 0xffff, p[8] >> 16, /* Inst */
  148. p[8] & 0xffff, p[7] >> 16, /* Data */
  149. p[7] & 0xffff, p[6] >> 16, /* PC */
  150. p[2], p[1], p[0], /* LS0 Stat, Addr and Data */
  151. p[5], p[4], p[3]); /* LS1 Stat, Addr and Data */
  152. }
  153. return 0;
  154. }
  155. static int cim_la_show_pc_t6(struct seq_file *seq, void *v, int idx)
  156. {
  157. if (v == SEQ_START_TOKEN) {
  158. seq_puts(seq, "Status Inst Data PC\n");
  159. } else {
  160. const u32 *p = v;
  161. seq_printf(seq, " %02x %08x %08x %08x\n",
  162. p[3] & 0xff, p[2], p[1], p[0]);
  163. seq_printf(seq, " %02x %02x%06x %02x%06x %02x%06x\n",
  164. (p[6] >> 8) & 0xff, p[6] & 0xff, p[5] >> 8,
  165. p[5] & 0xff, p[4] >> 8, p[4] & 0xff, p[3] >> 8);
  166. seq_printf(seq, " %02x %04x%04x %04x%04x %04x%04x\n",
  167. (p[9] >> 16) & 0xff, p[9] & 0xffff, p[8] >> 16,
  168. p[8] & 0xffff, p[7] >> 16, p[7] & 0xffff,
  169. p[6] >> 16);
  170. }
  171. return 0;
  172. }
  173. static int cim_la_open(struct inode *inode, struct file *file)
  174. {
  175. int ret;
  176. unsigned int cfg;
  177. struct seq_tab *p;
  178. struct adapter *adap = inode->i_private;
  179. ret = t4_cim_read(adap, UP_UP_DBG_LA_CFG_A, 1, &cfg);
  180. if (ret)
  181. return ret;
  182. if (is_t6(adap->params.chip)) {
  183. /* +1 to account for integer division of CIMLA_SIZE/10 */
  184. p = seq_open_tab(file, (adap->params.cim_la_size / 10) + 1,
  185. 10 * sizeof(u32), 1,
  186. cfg & UPDBGLACAPTPCONLY_F ?
  187. cim_la_show_pc_t6 : cim_la_show_t6);
  188. } else {
  189. p = seq_open_tab(file, adap->params.cim_la_size / 8,
  190. 8 * sizeof(u32), 1,
  191. cfg & UPDBGLACAPTPCONLY_F ? cim_la_show_3in1 :
  192. cim_la_show);
  193. }
  194. if (!p)
  195. return -ENOMEM;
  196. ret = t4_cim_read_la(adap, (u32 *)p->data, NULL);
  197. if (ret)
  198. seq_release_private(inode, file);
  199. return ret;
  200. }
  201. static const struct file_operations cim_la_fops = {
  202. .owner = THIS_MODULE,
  203. .open = cim_la_open,
  204. .read = seq_read,
  205. .llseek = seq_lseek,
  206. .release = seq_release_private
  207. };
  208. static int cim_pif_la_show(struct seq_file *seq, void *v, int idx)
  209. {
  210. const u32 *p = v;
  211. if (v == SEQ_START_TOKEN) {
  212. seq_puts(seq, "Cntl ID DataBE Addr Data\n");
  213. } else if (idx < CIM_PIFLA_SIZE) {
  214. seq_printf(seq, " %02x %02x %04x %08x %08x%08x%08x%08x\n",
  215. (p[5] >> 22) & 0xff, (p[5] >> 16) & 0x3f,
  216. p[5] & 0xffff, p[4], p[3], p[2], p[1], p[0]);
  217. } else {
  218. if (idx == CIM_PIFLA_SIZE)
  219. seq_puts(seq, "\nCntl ID Data\n");
  220. seq_printf(seq, " %02x %02x %08x%08x%08x%08x\n",
  221. (p[4] >> 6) & 0xff, p[4] & 0x3f,
  222. p[3], p[2], p[1], p[0]);
  223. }
  224. return 0;
  225. }
  226. static int cim_pif_la_open(struct inode *inode, struct file *file)
  227. {
  228. struct seq_tab *p;
  229. struct adapter *adap = inode->i_private;
  230. p = seq_open_tab(file, 2 * CIM_PIFLA_SIZE, 6 * sizeof(u32), 1,
  231. cim_pif_la_show);
  232. if (!p)
  233. return -ENOMEM;
  234. t4_cim_read_pif_la(adap, (u32 *)p->data,
  235. (u32 *)p->data + 6 * CIM_PIFLA_SIZE, NULL, NULL);
  236. return 0;
  237. }
  238. static const struct file_operations cim_pif_la_fops = {
  239. .owner = THIS_MODULE,
  240. .open = cim_pif_la_open,
  241. .read = seq_read,
  242. .llseek = seq_lseek,
  243. .release = seq_release_private
  244. };
  245. static int cim_ma_la_show(struct seq_file *seq, void *v, int idx)
  246. {
  247. const u32 *p = v;
  248. if (v == SEQ_START_TOKEN) {
  249. seq_puts(seq, "\n");
  250. } else if (idx < CIM_MALA_SIZE) {
  251. seq_printf(seq, "%02x%08x%08x%08x%08x\n",
  252. p[4], p[3], p[2], p[1], p[0]);
  253. } else {
  254. if (idx == CIM_MALA_SIZE)
  255. seq_puts(seq,
  256. "\nCnt ID Tag UE Data RDY VLD\n");
  257. seq_printf(seq, "%3u %2u %x %u %08x%08x %u %u\n",
  258. (p[2] >> 10) & 0xff, (p[2] >> 7) & 7,
  259. (p[2] >> 3) & 0xf, (p[2] >> 2) & 1,
  260. (p[1] >> 2) | ((p[2] & 3) << 30),
  261. (p[0] >> 2) | ((p[1] & 3) << 30), (p[0] >> 1) & 1,
  262. p[0] & 1);
  263. }
  264. return 0;
  265. }
  266. static int cim_ma_la_open(struct inode *inode, struct file *file)
  267. {
  268. struct seq_tab *p;
  269. struct adapter *adap = inode->i_private;
  270. p = seq_open_tab(file, 2 * CIM_MALA_SIZE, 5 * sizeof(u32), 1,
  271. cim_ma_la_show);
  272. if (!p)
  273. return -ENOMEM;
  274. t4_cim_read_ma_la(adap, (u32 *)p->data,
  275. (u32 *)p->data + 5 * CIM_MALA_SIZE);
  276. return 0;
  277. }
  278. static const struct file_operations cim_ma_la_fops = {
  279. .owner = THIS_MODULE,
  280. .open = cim_ma_la_open,
  281. .read = seq_read,
  282. .llseek = seq_lseek,
  283. .release = seq_release_private
  284. };
  285. static int cim_qcfg_show(struct seq_file *seq, void *v)
  286. {
  287. static const char * const qname[] = {
  288. "TP0", "TP1", "ULP", "SGE0", "SGE1", "NC-SI",
  289. "ULP0", "ULP1", "ULP2", "ULP3", "SGE", "NC-SI",
  290. "SGE0-RX", "SGE1-RX"
  291. };
  292. int i;
  293. struct adapter *adap = seq->private;
  294. u16 base[CIM_NUM_IBQ + CIM_NUM_OBQ_T5];
  295. u16 size[CIM_NUM_IBQ + CIM_NUM_OBQ_T5];
  296. u32 stat[(4 * (CIM_NUM_IBQ + CIM_NUM_OBQ_T5))];
  297. u16 thres[CIM_NUM_IBQ];
  298. u32 obq_wr_t4[2 * CIM_NUM_OBQ], *wr;
  299. u32 obq_wr_t5[2 * CIM_NUM_OBQ_T5];
  300. u32 *p = stat;
  301. int cim_num_obq = is_t4(adap->params.chip) ?
  302. CIM_NUM_OBQ : CIM_NUM_OBQ_T5;
  303. i = t4_cim_read(adap, is_t4(adap->params.chip) ? UP_IBQ_0_RDADDR_A :
  304. UP_IBQ_0_SHADOW_RDADDR_A,
  305. ARRAY_SIZE(stat), stat);
  306. if (!i) {
  307. if (is_t4(adap->params.chip)) {
  308. i = t4_cim_read(adap, UP_OBQ_0_REALADDR_A,
  309. ARRAY_SIZE(obq_wr_t4), obq_wr_t4);
  310. wr = obq_wr_t4;
  311. } else {
  312. i = t4_cim_read(adap, UP_OBQ_0_SHADOW_REALADDR_A,
  313. ARRAY_SIZE(obq_wr_t5), obq_wr_t5);
  314. wr = obq_wr_t5;
  315. }
  316. }
  317. if (i)
  318. return i;
  319. t4_read_cimq_cfg(adap, base, size, thres);
  320. seq_printf(seq,
  321. " Queue Base Size Thres RdPtr WrPtr SOP EOP Avail\n");
  322. for (i = 0; i < CIM_NUM_IBQ; i++, p += 4)
  323. seq_printf(seq, "%7s %5x %5u %5u %6x %4x %4u %4u %5u\n",
  324. qname[i], base[i], size[i], thres[i],
  325. IBQRDADDR_G(p[0]), IBQWRADDR_G(p[1]),
  326. QUESOPCNT_G(p[3]), QUEEOPCNT_G(p[3]),
  327. QUEREMFLITS_G(p[2]) * 16);
  328. for ( ; i < CIM_NUM_IBQ + cim_num_obq; i++, p += 4, wr += 2)
  329. seq_printf(seq, "%7s %5x %5u %12x %4x %4u %4u %5u\n",
  330. qname[i], base[i], size[i],
  331. QUERDADDR_G(p[0]) & 0x3fff, wr[0] - base[i],
  332. QUESOPCNT_G(p[3]), QUEEOPCNT_G(p[3]),
  333. QUEREMFLITS_G(p[2]) * 16);
  334. return 0;
  335. }
  336. static int cim_qcfg_open(struct inode *inode, struct file *file)
  337. {
  338. return single_open(file, cim_qcfg_show, inode->i_private);
  339. }
  340. static const struct file_operations cim_qcfg_fops = {
  341. .owner = THIS_MODULE,
  342. .open = cim_qcfg_open,
  343. .read = seq_read,
  344. .llseek = seq_lseek,
  345. .release = single_release,
  346. };
  347. static int cimq_show(struct seq_file *seq, void *v, int idx)
  348. {
  349. const u32 *p = v;
  350. seq_printf(seq, "%#06x: %08x %08x %08x %08x\n", idx * 16, p[0], p[1],
  351. p[2], p[3]);
  352. return 0;
  353. }
  354. static int cim_ibq_open(struct inode *inode, struct file *file)
  355. {
  356. int ret;
  357. struct seq_tab *p;
  358. unsigned int qid = (uintptr_t)inode->i_private & 7;
  359. struct adapter *adap = inode->i_private - qid;
  360. p = seq_open_tab(file, CIM_IBQ_SIZE, 4 * sizeof(u32), 0, cimq_show);
  361. if (!p)
  362. return -ENOMEM;
  363. ret = t4_read_cim_ibq(adap, qid, (u32 *)p->data, CIM_IBQ_SIZE * 4);
  364. if (ret < 0)
  365. seq_release_private(inode, file);
  366. else
  367. ret = 0;
  368. return ret;
  369. }
  370. static const struct file_operations cim_ibq_fops = {
  371. .owner = THIS_MODULE,
  372. .open = cim_ibq_open,
  373. .read = seq_read,
  374. .llseek = seq_lseek,
  375. .release = seq_release_private
  376. };
  377. static int cim_obq_open(struct inode *inode, struct file *file)
  378. {
  379. int ret;
  380. struct seq_tab *p;
  381. unsigned int qid = (uintptr_t)inode->i_private & 7;
  382. struct adapter *adap = inode->i_private - qid;
  383. p = seq_open_tab(file, 6 * CIM_OBQ_SIZE, 4 * sizeof(u32), 0, cimq_show);
  384. if (!p)
  385. return -ENOMEM;
  386. ret = t4_read_cim_obq(adap, qid, (u32 *)p->data, 6 * CIM_OBQ_SIZE * 4);
  387. if (ret < 0) {
  388. seq_release_private(inode, file);
  389. } else {
  390. seq_tab_trim(p, ret / 4);
  391. ret = 0;
  392. }
  393. return ret;
  394. }
  395. static const struct file_operations cim_obq_fops = {
  396. .owner = THIS_MODULE,
  397. .open = cim_obq_open,
  398. .read = seq_read,
  399. .llseek = seq_lseek,
  400. .release = seq_release_private
  401. };
  402. struct field_desc {
  403. const char *name;
  404. unsigned int start;
  405. unsigned int width;
  406. };
  407. static void field_desc_show(struct seq_file *seq, u64 v,
  408. const struct field_desc *p)
  409. {
  410. char buf[32];
  411. int line_size = 0;
  412. while (p->name) {
  413. u64 mask = (1ULL << p->width) - 1;
  414. int len = scnprintf(buf, sizeof(buf), "%s: %llu", p->name,
  415. ((unsigned long long)v >> p->start) & mask);
  416. if (line_size + len >= 79) {
  417. line_size = 8;
  418. seq_puts(seq, "\n ");
  419. }
  420. seq_printf(seq, "%s ", buf);
  421. line_size += len + 1;
  422. p++;
  423. }
  424. seq_putc(seq, '\n');
  425. }
  426. static struct field_desc tp_la0[] = {
  427. { "RcfOpCodeOut", 60, 4 },
  428. { "State", 56, 4 },
  429. { "WcfState", 52, 4 },
  430. { "RcfOpcSrcOut", 50, 2 },
  431. { "CRxError", 49, 1 },
  432. { "ERxError", 48, 1 },
  433. { "SanityFailed", 47, 1 },
  434. { "SpuriousMsg", 46, 1 },
  435. { "FlushInputMsg", 45, 1 },
  436. { "FlushInputCpl", 44, 1 },
  437. { "RssUpBit", 43, 1 },
  438. { "RssFilterHit", 42, 1 },
  439. { "Tid", 32, 10 },
  440. { "InitTcb", 31, 1 },
  441. { "LineNumber", 24, 7 },
  442. { "Emsg", 23, 1 },
  443. { "EdataOut", 22, 1 },
  444. { "Cmsg", 21, 1 },
  445. { "CdataOut", 20, 1 },
  446. { "EreadPdu", 19, 1 },
  447. { "CreadPdu", 18, 1 },
  448. { "TunnelPkt", 17, 1 },
  449. { "RcfPeerFin", 16, 1 },
  450. { "RcfReasonOut", 12, 4 },
  451. { "TxCchannel", 10, 2 },
  452. { "RcfTxChannel", 8, 2 },
  453. { "RxEchannel", 6, 2 },
  454. { "RcfRxChannel", 5, 1 },
  455. { "RcfDataOutSrdy", 4, 1 },
  456. { "RxDvld", 3, 1 },
  457. { "RxOoDvld", 2, 1 },
  458. { "RxCongestion", 1, 1 },
  459. { "TxCongestion", 0, 1 },
  460. { NULL }
  461. };
  462. static int tp_la_show(struct seq_file *seq, void *v, int idx)
  463. {
  464. const u64 *p = v;
  465. field_desc_show(seq, *p, tp_la0);
  466. return 0;
  467. }
  468. static int tp_la_show2(struct seq_file *seq, void *v, int idx)
  469. {
  470. const u64 *p = v;
  471. if (idx)
  472. seq_putc(seq, '\n');
  473. field_desc_show(seq, p[0], tp_la0);
  474. if (idx < (TPLA_SIZE / 2 - 1) || p[1] != ~0ULL)
  475. field_desc_show(seq, p[1], tp_la0);
  476. return 0;
  477. }
  478. static int tp_la_show3(struct seq_file *seq, void *v, int idx)
  479. {
  480. static struct field_desc tp_la1[] = {
  481. { "CplCmdIn", 56, 8 },
  482. { "CplCmdOut", 48, 8 },
  483. { "ESynOut", 47, 1 },
  484. { "EAckOut", 46, 1 },
  485. { "EFinOut", 45, 1 },
  486. { "ERstOut", 44, 1 },
  487. { "SynIn", 43, 1 },
  488. { "AckIn", 42, 1 },
  489. { "FinIn", 41, 1 },
  490. { "RstIn", 40, 1 },
  491. { "DataIn", 39, 1 },
  492. { "DataInVld", 38, 1 },
  493. { "PadIn", 37, 1 },
  494. { "RxBufEmpty", 36, 1 },
  495. { "RxDdp", 35, 1 },
  496. { "RxFbCongestion", 34, 1 },
  497. { "TxFbCongestion", 33, 1 },
  498. { "TxPktSumSrdy", 32, 1 },
  499. { "RcfUlpType", 28, 4 },
  500. { "Eread", 27, 1 },
  501. { "Ebypass", 26, 1 },
  502. { "Esave", 25, 1 },
  503. { "Static0", 24, 1 },
  504. { "Cread", 23, 1 },
  505. { "Cbypass", 22, 1 },
  506. { "Csave", 21, 1 },
  507. { "CPktOut", 20, 1 },
  508. { "RxPagePoolFull", 18, 2 },
  509. { "RxLpbkPkt", 17, 1 },
  510. { "TxLpbkPkt", 16, 1 },
  511. { "RxVfValid", 15, 1 },
  512. { "SynLearned", 14, 1 },
  513. { "SetDelEntry", 13, 1 },
  514. { "SetInvEntry", 12, 1 },
  515. { "CpcmdDvld", 11, 1 },
  516. { "CpcmdSave", 10, 1 },
  517. { "RxPstructsFull", 8, 2 },
  518. { "EpcmdDvld", 7, 1 },
  519. { "EpcmdFlush", 6, 1 },
  520. { "EpcmdTrimPrefix", 5, 1 },
  521. { "EpcmdTrimPostfix", 4, 1 },
  522. { "ERssIp4Pkt", 3, 1 },
  523. { "ERssIp6Pkt", 2, 1 },
  524. { "ERssTcpUdpPkt", 1, 1 },
  525. { "ERssFceFipPkt", 0, 1 },
  526. { NULL }
  527. };
  528. static struct field_desc tp_la2[] = {
  529. { "CplCmdIn", 56, 8 },
  530. { "MpsVfVld", 55, 1 },
  531. { "MpsPf", 52, 3 },
  532. { "MpsVf", 44, 8 },
  533. { "SynIn", 43, 1 },
  534. { "AckIn", 42, 1 },
  535. { "FinIn", 41, 1 },
  536. { "RstIn", 40, 1 },
  537. { "DataIn", 39, 1 },
  538. { "DataInVld", 38, 1 },
  539. { "PadIn", 37, 1 },
  540. { "RxBufEmpty", 36, 1 },
  541. { "RxDdp", 35, 1 },
  542. { "RxFbCongestion", 34, 1 },
  543. { "TxFbCongestion", 33, 1 },
  544. { "TxPktSumSrdy", 32, 1 },
  545. { "RcfUlpType", 28, 4 },
  546. { "Eread", 27, 1 },
  547. { "Ebypass", 26, 1 },
  548. { "Esave", 25, 1 },
  549. { "Static0", 24, 1 },
  550. { "Cread", 23, 1 },
  551. { "Cbypass", 22, 1 },
  552. { "Csave", 21, 1 },
  553. { "CPktOut", 20, 1 },
  554. { "RxPagePoolFull", 18, 2 },
  555. { "RxLpbkPkt", 17, 1 },
  556. { "TxLpbkPkt", 16, 1 },
  557. { "RxVfValid", 15, 1 },
  558. { "SynLearned", 14, 1 },
  559. { "SetDelEntry", 13, 1 },
  560. { "SetInvEntry", 12, 1 },
  561. { "CpcmdDvld", 11, 1 },
  562. { "CpcmdSave", 10, 1 },
  563. { "RxPstructsFull", 8, 2 },
  564. { "EpcmdDvld", 7, 1 },
  565. { "EpcmdFlush", 6, 1 },
  566. { "EpcmdTrimPrefix", 5, 1 },
  567. { "EpcmdTrimPostfix", 4, 1 },
  568. { "ERssIp4Pkt", 3, 1 },
  569. { "ERssIp6Pkt", 2, 1 },
  570. { "ERssTcpUdpPkt", 1, 1 },
  571. { "ERssFceFipPkt", 0, 1 },
  572. { NULL }
  573. };
  574. const u64 *p = v;
  575. if (idx)
  576. seq_putc(seq, '\n');
  577. field_desc_show(seq, p[0], tp_la0);
  578. if (idx < (TPLA_SIZE / 2 - 1) || p[1] != ~0ULL)
  579. field_desc_show(seq, p[1], (p[0] & BIT(17)) ? tp_la2 : tp_la1);
  580. return 0;
  581. }
  582. static int tp_la_open(struct inode *inode, struct file *file)
  583. {
  584. struct seq_tab *p;
  585. struct adapter *adap = inode->i_private;
  586. switch (DBGLAMODE_G(t4_read_reg(adap, TP_DBG_LA_CONFIG_A))) {
  587. case 2:
  588. p = seq_open_tab(file, TPLA_SIZE / 2, 2 * sizeof(u64), 0,
  589. tp_la_show2);
  590. break;
  591. case 3:
  592. p = seq_open_tab(file, TPLA_SIZE / 2, 2 * sizeof(u64), 0,
  593. tp_la_show3);
  594. break;
  595. default:
  596. p = seq_open_tab(file, TPLA_SIZE, sizeof(u64), 0, tp_la_show);
  597. }
  598. if (!p)
  599. return -ENOMEM;
  600. t4_tp_read_la(adap, (u64 *)p->data, NULL);
  601. return 0;
  602. }
  603. static ssize_t tp_la_write(struct file *file, const char __user *buf,
  604. size_t count, loff_t *pos)
  605. {
  606. int err;
  607. char s[32];
  608. unsigned long val;
  609. size_t size = min(sizeof(s) - 1, count);
  610. struct adapter *adap = file_inode(file)->i_private;
  611. if (copy_from_user(s, buf, size))
  612. return -EFAULT;
  613. s[size] = '\0';
  614. err = kstrtoul(s, 0, &val);
  615. if (err)
  616. return err;
  617. if (val > 0xffff)
  618. return -EINVAL;
  619. adap->params.tp.la_mask = val << 16;
  620. t4_set_reg_field(adap, TP_DBG_LA_CONFIG_A, 0xffff0000U,
  621. adap->params.tp.la_mask);
  622. return count;
  623. }
  624. static const struct file_operations tp_la_fops = {
  625. .owner = THIS_MODULE,
  626. .open = tp_la_open,
  627. .read = seq_read,
  628. .llseek = seq_lseek,
  629. .release = seq_release_private,
  630. .write = tp_la_write
  631. };
  632. static int ulprx_la_show(struct seq_file *seq, void *v, int idx)
  633. {
  634. const u32 *p = v;
  635. if (v == SEQ_START_TOKEN)
  636. seq_puts(seq, " Pcmd Type Message"
  637. " Data\n");
  638. else
  639. seq_printf(seq, "%08x%08x %4x %08x %08x%08x%08x%08x\n",
  640. p[1], p[0], p[2], p[3], p[7], p[6], p[5], p[4]);
  641. return 0;
  642. }
  643. static int ulprx_la_open(struct inode *inode, struct file *file)
  644. {
  645. struct seq_tab *p;
  646. struct adapter *adap = inode->i_private;
  647. p = seq_open_tab(file, ULPRX_LA_SIZE, 8 * sizeof(u32), 1,
  648. ulprx_la_show);
  649. if (!p)
  650. return -ENOMEM;
  651. t4_ulprx_read_la(adap, (u32 *)p->data);
  652. return 0;
  653. }
  654. static const struct file_operations ulprx_la_fops = {
  655. .owner = THIS_MODULE,
  656. .open = ulprx_la_open,
  657. .read = seq_read,
  658. .llseek = seq_lseek,
  659. .release = seq_release_private
  660. };
  661. /* Show the PM memory stats. These stats include:
  662. *
  663. * TX:
  664. * Read: memory read operation
  665. * Write Bypass: cut-through
  666. * Bypass + mem: cut-through and save copy
  667. *
  668. * RX:
  669. * Read: memory read
  670. * Write Bypass: cut-through
  671. * Flush: payload trim or drop
  672. */
  673. static int pm_stats_show(struct seq_file *seq, void *v)
  674. {
  675. static const char * const tx_pm_stats[] = {
  676. "Read:", "Write bypass:", "Write mem:", "Bypass + mem:"
  677. };
  678. static const char * const rx_pm_stats[] = {
  679. "Read:", "Write bypass:", "Write mem:", "Flush:"
  680. };
  681. int i;
  682. u32 tx_cnt[T6_PM_NSTATS], rx_cnt[T6_PM_NSTATS];
  683. u64 tx_cyc[T6_PM_NSTATS], rx_cyc[T6_PM_NSTATS];
  684. struct adapter *adap = seq->private;
  685. t4_pmtx_get_stats(adap, tx_cnt, tx_cyc);
  686. t4_pmrx_get_stats(adap, rx_cnt, rx_cyc);
  687. seq_printf(seq, "%13s %10s %20s\n", " ", "Tx pcmds", "Tx bytes");
  688. for (i = 0; i < PM_NSTATS - 1; i++)
  689. seq_printf(seq, "%-13s %10u %20llu\n",
  690. tx_pm_stats[i], tx_cnt[i], tx_cyc[i]);
  691. seq_printf(seq, "%13s %10s %20s\n", " ", "Rx pcmds", "Rx bytes");
  692. for (i = 0; i < PM_NSTATS - 1; i++)
  693. seq_printf(seq, "%-13s %10u %20llu\n",
  694. rx_pm_stats[i], rx_cnt[i], rx_cyc[i]);
  695. if (CHELSIO_CHIP_VERSION(adap->params.chip) > CHELSIO_T5) {
  696. /* In T5 the granularity of the total wait is too fine.
  697. * It is not useful as it reaches the max value too fast.
  698. * Hence display this Input FIFO wait for T6 onwards.
  699. */
  700. seq_printf(seq, "%13s %10s %20s\n",
  701. " ", "Total wait", "Total Occupancy");
  702. seq_printf(seq, "Tx FIFO wait %10u %20llu\n",
  703. tx_cnt[i], tx_cyc[i]);
  704. seq_printf(seq, "Rx FIFO wait %10u %20llu\n",
  705. rx_cnt[i], rx_cyc[i]);
  706. /* Skip index 6 as there is nothing useful ihere */
  707. i += 2;
  708. /* At index 7, a new stat for read latency (count, total wait)
  709. * is added.
  710. */
  711. seq_printf(seq, "%13s %10s %20s\n",
  712. " ", "Reads", "Total wait");
  713. seq_printf(seq, "Tx latency %10u %20llu\n",
  714. tx_cnt[i], tx_cyc[i]);
  715. seq_printf(seq, "Rx latency %10u %20llu\n",
  716. rx_cnt[i], rx_cyc[i]);
  717. }
  718. return 0;
  719. }
  720. static int pm_stats_open(struct inode *inode, struct file *file)
  721. {
  722. return single_open(file, pm_stats_show, inode->i_private);
  723. }
  724. static ssize_t pm_stats_clear(struct file *file, const char __user *buf,
  725. size_t count, loff_t *pos)
  726. {
  727. struct adapter *adap = file_inode(file)->i_private;
  728. t4_write_reg(adap, PM_RX_STAT_CONFIG_A, 0);
  729. t4_write_reg(adap, PM_TX_STAT_CONFIG_A, 0);
  730. return count;
  731. }
  732. static const struct file_operations pm_stats_debugfs_fops = {
  733. .owner = THIS_MODULE,
  734. .open = pm_stats_open,
  735. .read = seq_read,
  736. .llseek = seq_lseek,
  737. .release = single_release,
  738. .write = pm_stats_clear
  739. };
  740. static int tx_rate_show(struct seq_file *seq, void *v)
  741. {
  742. u64 nrate[NCHAN], orate[NCHAN];
  743. struct adapter *adap = seq->private;
  744. t4_get_chan_txrate(adap, nrate, orate);
  745. if (adap->params.arch.nchan == NCHAN) {
  746. seq_puts(seq, " channel 0 channel 1 "
  747. "channel 2 channel 3\n");
  748. seq_printf(seq, "NIC B/s: %10llu %10llu %10llu %10llu\n",
  749. (unsigned long long)nrate[0],
  750. (unsigned long long)nrate[1],
  751. (unsigned long long)nrate[2],
  752. (unsigned long long)nrate[3]);
  753. seq_printf(seq, "Offload B/s: %10llu %10llu %10llu %10llu\n",
  754. (unsigned long long)orate[0],
  755. (unsigned long long)orate[1],
  756. (unsigned long long)orate[2],
  757. (unsigned long long)orate[3]);
  758. } else {
  759. seq_puts(seq, " channel 0 channel 1\n");
  760. seq_printf(seq, "NIC B/s: %10llu %10llu\n",
  761. (unsigned long long)nrate[0],
  762. (unsigned long long)nrate[1]);
  763. seq_printf(seq, "Offload B/s: %10llu %10llu\n",
  764. (unsigned long long)orate[0],
  765. (unsigned long long)orate[1]);
  766. }
  767. return 0;
  768. }
  769. DEFINE_SIMPLE_DEBUGFS_FILE(tx_rate);
  770. static int cctrl_tbl_show(struct seq_file *seq, void *v)
  771. {
  772. static const char * const dec_fac[] = {
  773. "0.5", "0.5625", "0.625", "0.6875", "0.75", "0.8125", "0.875",
  774. "0.9375" };
  775. int i;
  776. u16 (*incr)[NCCTRL_WIN];
  777. struct adapter *adap = seq->private;
  778. incr = kmalloc_array(NMTUS, sizeof(*incr), GFP_KERNEL);
  779. if (!incr)
  780. return -ENOMEM;
  781. t4_read_cong_tbl(adap, incr);
  782. for (i = 0; i < NCCTRL_WIN; ++i) {
  783. seq_printf(seq, "%2d: %4u %4u %4u %4u %4u %4u %4u %4u\n", i,
  784. incr[0][i], incr[1][i], incr[2][i], incr[3][i],
  785. incr[4][i], incr[5][i], incr[6][i], incr[7][i]);
  786. seq_printf(seq, "%8u %4u %4u %4u %4u %4u %4u %4u %5u %s\n",
  787. incr[8][i], incr[9][i], incr[10][i], incr[11][i],
  788. incr[12][i], incr[13][i], incr[14][i], incr[15][i],
  789. adap->params.a_wnd[i],
  790. dec_fac[adap->params.b_wnd[i]]);
  791. }
  792. kfree(incr);
  793. return 0;
  794. }
  795. DEFINE_SIMPLE_DEBUGFS_FILE(cctrl_tbl);
  796. /* Format a value in a unit that differs from the value's native unit by the
  797. * given factor.
  798. */
  799. static char *unit_conv(char *buf, size_t len, unsigned int val,
  800. unsigned int factor)
  801. {
  802. unsigned int rem = val % factor;
  803. if (rem == 0) {
  804. snprintf(buf, len, "%u", val / factor);
  805. } else {
  806. while (rem % 10 == 0)
  807. rem /= 10;
  808. snprintf(buf, len, "%u.%u", val / factor, rem);
  809. }
  810. return buf;
  811. }
  812. static int clk_show(struct seq_file *seq, void *v)
  813. {
  814. char buf[32];
  815. struct adapter *adap = seq->private;
  816. unsigned int cclk_ps = 1000000000 / adap->params.vpd.cclk; /* in ps */
  817. u32 res = t4_read_reg(adap, TP_TIMER_RESOLUTION_A);
  818. unsigned int tre = TIMERRESOLUTION_G(res);
  819. unsigned int dack_re = DELAYEDACKRESOLUTION_G(res);
  820. unsigned long long tp_tick_us = (cclk_ps << tre) / 1000000; /* in us */
  821. seq_printf(seq, "Core clock period: %s ns\n",
  822. unit_conv(buf, sizeof(buf), cclk_ps, 1000));
  823. seq_printf(seq, "TP timer tick: %s us\n",
  824. unit_conv(buf, sizeof(buf), (cclk_ps << tre), 1000000));
  825. seq_printf(seq, "TCP timestamp tick: %s us\n",
  826. unit_conv(buf, sizeof(buf),
  827. (cclk_ps << TIMESTAMPRESOLUTION_G(res)), 1000000));
  828. seq_printf(seq, "DACK tick: %s us\n",
  829. unit_conv(buf, sizeof(buf), (cclk_ps << dack_re), 1000000));
  830. seq_printf(seq, "DACK timer: %u us\n",
  831. ((cclk_ps << dack_re) / 1000000) *
  832. t4_read_reg(adap, TP_DACK_TIMER_A));
  833. seq_printf(seq, "Retransmit min: %llu us\n",
  834. tp_tick_us * t4_read_reg(adap, TP_RXT_MIN_A));
  835. seq_printf(seq, "Retransmit max: %llu us\n",
  836. tp_tick_us * t4_read_reg(adap, TP_RXT_MAX_A));
  837. seq_printf(seq, "Persist timer min: %llu us\n",
  838. tp_tick_us * t4_read_reg(adap, TP_PERS_MIN_A));
  839. seq_printf(seq, "Persist timer max: %llu us\n",
  840. tp_tick_us * t4_read_reg(adap, TP_PERS_MAX_A));
  841. seq_printf(seq, "Keepalive idle timer: %llu us\n",
  842. tp_tick_us * t4_read_reg(adap, TP_KEEP_IDLE_A));
  843. seq_printf(seq, "Keepalive interval: %llu us\n",
  844. tp_tick_us * t4_read_reg(adap, TP_KEEP_INTVL_A));
  845. seq_printf(seq, "Initial SRTT: %llu us\n",
  846. tp_tick_us * INITSRTT_G(t4_read_reg(adap, TP_INIT_SRTT_A)));
  847. seq_printf(seq, "FINWAIT2 timer: %llu us\n",
  848. tp_tick_us * t4_read_reg(adap, TP_FINWAIT2_TIMER_A));
  849. return 0;
  850. }
  851. DEFINE_SIMPLE_DEBUGFS_FILE(clk);
  852. /* Firmware Device Log dump. */
  853. static const char * const devlog_level_strings[] = {
  854. [FW_DEVLOG_LEVEL_EMERG] = "EMERG",
  855. [FW_DEVLOG_LEVEL_CRIT] = "CRIT",
  856. [FW_DEVLOG_LEVEL_ERR] = "ERR",
  857. [FW_DEVLOG_LEVEL_NOTICE] = "NOTICE",
  858. [FW_DEVLOG_LEVEL_INFO] = "INFO",
  859. [FW_DEVLOG_LEVEL_DEBUG] = "DEBUG"
  860. };
  861. static const char * const devlog_facility_strings[] = {
  862. [FW_DEVLOG_FACILITY_CORE] = "CORE",
  863. [FW_DEVLOG_FACILITY_CF] = "CF",
  864. [FW_DEVLOG_FACILITY_SCHED] = "SCHED",
  865. [FW_DEVLOG_FACILITY_TIMER] = "TIMER",
  866. [FW_DEVLOG_FACILITY_RES] = "RES",
  867. [FW_DEVLOG_FACILITY_HW] = "HW",
  868. [FW_DEVLOG_FACILITY_FLR] = "FLR",
  869. [FW_DEVLOG_FACILITY_DMAQ] = "DMAQ",
  870. [FW_DEVLOG_FACILITY_PHY] = "PHY",
  871. [FW_DEVLOG_FACILITY_MAC] = "MAC",
  872. [FW_DEVLOG_FACILITY_PORT] = "PORT",
  873. [FW_DEVLOG_FACILITY_VI] = "VI",
  874. [FW_DEVLOG_FACILITY_FILTER] = "FILTER",
  875. [FW_DEVLOG_FACILITY_ACL] = "ACL",
  876. [FW_DEVLOG_FACILITY_TM] = "TM",
  877. [FW_DEVLOG_FACILITY_QFC] = "QFC",
  878. [FW_DEVLOG_FACILITY_DCB] = "DCB",
  879. [FW_DEVLOG_FACILITY_ETH] = "ETH",
  880. [FW_DEVLOG_FACILITY_OFLD] = "OFLD",
  881. [FW_DEVLOG_FACILITY_RI] = "RI",
  882. [FW_DEVLOG_FACILITY_ISCSI] = "ISCSI",
  883. [FW_DEVLOG_FACILITY_FCOE] = "FCOE",
  884. [FW_DEVLOG_FACILITY_FOISCSI] = "FOISCSI",
  885. [FW_DEVLOG_FACILITY_FOFCOE] = "FOFCOE"
  886. };
  887. /* Information gathered by Device Log Open routine for the display routine.
  888. */
  889. struct devlog_info {
  890. unsigned int nentries; /* number of entries in log[] */
  891. unsigned int first; /* first [temporal] entry in log[] */
  892. struct fw_devlog_e log[0]; /* Firmware Device Log */
  893. };
  894. /* Dump a Firmaware Device Log entry.
  895. */
  896. static int devlog_show(struct seq_file *seq, void *v)
  897. {
  898. if (v == SEQ_START_TOKEN)
  899. seq_printf(seq, "%10s %15s %8s %8s %s\n",
  900. "Seq#", "Tstamp", "Level", "Facility", "Message");
  901. else {
  902. struct devlog_info *dinfo = seq->private;
  903. int fidx = (uintptr_t)v - 2;
  904. unsigned long index;
  905. struct fw_devlog_e *e;
  906. /* Get a pointer to the log entry to display. Skip unused log
  907. * entries.
  908. */
  909. index = dinfo->first + fidx;
  910. if (index >= dinfo->nentries)
  911. index -= dinfo->nentries;
  912. e = &dinfo->log[index];
  913. if (e->timestamp == 0)
  914. return 0;
  915. /* Print the message. This depends on the firmware using
  916. * exactly the same formating strings as the kernel so we may
  917. * eventually have to put a format interpreter in here ...
  918. */
  919. seq_printf(seq, "%10d %15llu %8s %8s ",
  920. be32_to_cpu(e->seqno),
  921. be64_to_cpu(e->timestamp),
  922. (e->level < ARRAY_SIZE(devlog_level_strings)
  923. ? devlog_level_strings[e->level]
  924. : "UNKNOWN"),
  925. (e->facility < ARRAY_SIZE(devlog_facility_strings)
  926. ? devlog_facility_strings[e->facility]
  927. : "UNKNOWN"));
  928. seq_printf(seq, e->fmt,
  929. be32_to_cpu(e->params[0]),
  930. be32_to_cpu(e->params[1]),
  931. be32_to_cpu(e->params[2]),
  932. be32_to_cpu(e->params[3]),
  933. be32_to_cpu(e->params[4]),
  934. be32_to_cpu(e->params[5]),
  935. be32_to_cpu(e->params[6]),
  936. be32_to_cpu(e->params[7]));
  937. }
  938. return 0;
  939. }
  940. /* Sequential File Operations for Device Log.
  941. */
  942. static inline void *devlog_get_idx(struct devlog_info *dinfo, loff_t pos)
  943. {
  944. if (pos > dinfo->nentries)
  945. return NULL;
  946. return (void *)(uintptr_t)(pos + 1);
  947. }
  948. static void *devlog_start(struct seq_file *seq, loff_t *pos)
  949. {
  950. struct devlog_info *dinfo = seq->private;
  951. return (*pos
  952. ? devlog_get_idx(dinfo, *pos)
  953. : SEQ_START_TOKEN);
  954. }
  955. static void *devlog_next(struct seq_file *seq, void *v, loff_t *pos)
  956. {
  957. struct devlog_info *dinfo = seq->private;
  958. (*pos)++;
  959. return devlog_get_idx(dinfo, *pos);
  960. }
  961. static void devlog_stop(struct seq_file *seq, void *v)
  962. {
  963. }
  964. static const struct seq_operations devlog_seq_ops = {
  965. .start = devlog_start,
  966. .next = devlog_next,
  967. .stop = devlog_stop,
  968. .show = devlog_show
  969. };
  970. /* Set up for reading the firmware's device log. We read the entire log here
  971. * and then display it incrementally in devlog_show().
  972. */
  973. static int devlog_open(struct inode *inode, struct file *file)
  974. {
  975. struct adapter *adap = inode->i_private;
  976. struct devlog_params *dparams = &adap->params.devlog;
  977. struct devlog_info *dinfo;
  978. unsigned int index;
  979. u32 fseqno;
  980. int ret;
  981. /* If we don't know where the log is we can't do anything.
  982. */
  983. if (dparams->start == 0)
  984. return -ENXIO;
  985. /* Allocate the space to read in the firmware's device log and set up
  986. * for the iterated call to our display function.
  987. */
  988. dinfo = __seq_open_private(file, &devlog_seq_ops,
  989. sizeof(*dinfo) + dparams->size);
  990. if (!dinfo)
  991. return -ENOMEM;
  992. /* Record the basic log buffer information and read in the raw log.
  993. */
  994. dinfo->nentries = (dparams->size / sizeof(struct fw_devlog_e));
  995. dinfo->first = 0;
  996. spin_lock(&adap->win0_lock);
  997. ret = t4_memory_rw(adap, adap->params.drv_memwin, dparams->memtype,
  998. dparams->start, dparams->size, (__be32 *)dinfo->log,
  999. T4_MEMORY_READ);
  1000. spin_unlock(&adap->win0_lock);
  1001. if (ret) {
  1002. seq_release_private(inode, file);
  1003. return ret;
  1004. }
  1005. /* Find the earliest (lowest Sequence Number) log entry in the
  1006. * circular Device Log.
  1007. */
  1008. for (fseqno = ~((u32)0), index = 0; index < dinfo->nentries; index++) {
  1009. struct fw_devlog_e *e = &dinfo->log[index];
  1010. __u32 seqno;
  1011. if (e->timestamp == 0)
  1012. continue;
  1013. seqno = be32_to_cpu(e->seqno);
  1014. if (seqno < fseqno) {
  1015. fseqno = seqno;
  1016. dinfo->first = index;
  1017. }
  1018. }
  1019. return 0;
  1020. }
  1021. static const struct file_operations devlog_fops = {
  1022. .owner = THIS_MODULE,
  1023. .open = devlog_open,
  1024. .read = seq_read,
  1025. .llseek = seq_lseek,
  1026. .release = seq_release_private
  1027. };
  1028. /* Show Firmware Mailbox Command/Reply Log
  1029. *
  1030. * Note that we don't do any locking when dumping the Firmware Mailbox Log so
  1031. * it's possible that we can catch things during a log update and therefore
  1032. * see partially corrupted log entries. But it's probably Good Enough(tm).
  1033. * If we ever decide that we want to make sure that we're dumping a coherent
  1034. * log, we'd need to perform locking in the mailbox logging and in
  1035. * mboxlog_open() where we'd need to grab the entire mailbox log in one go
  1036. * like we do for the Firmware Device Log.
  1037. */
  1038. static int mboxlog_show(struct seq_file *seq, void *v)
  1039. {
  1040. struct adapter *adapter = seq->private;
  1041. struct mbox_cmd_log *log = adapter->mbox_log;
  1042. struct mbox_cmd *entry;
  1043. int entry_idx, i;
  1044. if (v == SEQ_START_TOKEN) {
  1045. seq_printf(seq,
  1046. "%10s %15s %5s %5s %s\n",
  1047. "Seq#", "Tstamp", "Atime", "Etime",
  1048. "Command/Reply");
  1049. return 0;
  1050. }
  1051. entry_idx = log->cursor + ((uintptr_t)v - 2);
  1052. if (entry_idx >= log->size)
  1053. entry_idx -= log->size;
  1054. entry = mbox_cmd_log_entry(log, entry_idx);
  1055. /* skip over unused entries */
  1056. if (entry->timestamp == 0)
  1057. return 0;
  1058. seq_printf(seq, "%10u %15llu %5d %5d",
  1059. entry->seqno, entry->timestamp,
  1060. entry->access, entry->execute);
  1061. for (i = 0; i < MBOX_LEN / 8; i++) {
  1062. u64 flit = entry->cmd[i];
  1063. u32 hi = (u32)(flit >> 32);
  1064. u32 lo = (u32)flit;
  1065. seq_printf(seq, " %08x %08x", hi, lo);
  1066. }
  1067. seq_puts(seq, "\n");
  1068. return 0;
  1069. }
  1070. static inline void *mboxlog_get_idx(struct seq_file *seq, loff_t pos)
  1071. {
  1072. struct adapter *adapter = seq->private;
  1073. struct mbox_cmd_log *log = adapter->mbox_log;
  1074. return ((pos <= log->size) ? (void *)(uintptr_t)(pos + 1) : NULL);
  1075. }
  1076. static void *mboxlog_start(struct seq_file *seq, loff_t *pos)
  1077. {
  1078. return *pos ? mboxlog_get_idx(seq, *pos) : SEQ_START_TOKEN;
  1079. }
  1080. static void *mboxlog_next(struct seq_file *seq, void *v, loff_t *pos)
  1081. {
  1082. ++*pos;
  1083. return mboxlog_get_idx(seq, *pos);
  1084. }
  1085. static void mboxlog_stop(struct seq_file *seq, void *v)
  1086. {
  1087. }
  1088. static const struct seq_operations mboxlog_seq_ops = {
  1089. .start = mboxlog_start,
  1090. .next = mboxlog_next,
  1091. .stop = mboxlog_stop,
  1092. .show = mboxlog_show
  1093. };
  1094. static int mboxlog_open(struct inode *inode, struct file *file)
  1095. {
  1096. int res = seq_open(file, &mboxlog_seq_ops);
  1097. if (!res) {
  1098. struct seq_file *seq = file->private_data;
  1099. seq->private = inode->i_private;
  1100. }
  1101. return res;
  1102. }
  1103. static const struct file_operations mboxlog_fops = {
  1104. .owner = THIS_MODULE,
  1105. .open = mboxlog_open,
  1106. .read = seq_read,
  1107. .llseek = seq_lseek,
  1108. .release = seq_release,
  1109. };
  1110. static int mbox_show(struct seq_file *seq, void *v)
  1111. {
  1112. static const char * const owner[] = { "none", "FW", "driver",
  1113. "unknown", "<unread>" };
  1114. int i;
  1115. unsigned int mbox = (uintptr_t)seq->private & 7;
  1116. struct adapter *adap = seq->private - mbox;
  1117. void __iomem *addr = adap->regs + PF_REG(mbox, CIM_PF_MAILBOX_DATA_A);
  1118. /* For T4 we don't have a shadow copy of the Mailbox Control register.
  1119. * And since reading that real register causes a side effect of
  1120. * granting ownership, we're best of simply not reading it at all.
  1121. */
  1122. if (is_t4(adap->params.chip)) {
  1123. i = 4; /* index of "<unread>" */
  1124. } else {
  1125. unsigned int ctrl_reg = CIM_PF_MAILBOX_CTRL_SHADOW_COPY_A;
  1126. void __iomem *ctrl = adap->regs + PF_REG(mbox, ctrl_reg);
  1127. i = MBOWNER_G(readl(ctrl));
  1128. }
  1129. seq_printf(seq, "mailbox owned by %s\n\n", owner[i]);
  1130. for (i = 0; i < MBOX_LEN; i += 8)
  1131. seq_printf(seq, "%016llx\n",
  1132. (unsigned long long)readq(addr + i));
  1133. return 0;
  1134. }
  1135. static int mbox_open(struct inode *inode, struct file *file)
  1136. {
  1137. return single_open(file, mbox_show, inode->i_private);
  1138. }
  1139. static ssize_t mbox_write(struct file *file, const char __user *buf,
  1140. size_t count, loff_t *pos)
  1141. {
  1142. int i;
  1143. char c = '\n', s[256];
  1144. unsigned long long data[8];
  1145. const struct inode *ino;
  1146. unsigned int mbox;
  1147. struct adapter *adap;
  1148. void __iomem *addr;
  1149. void __iomem *ctrl;
  1150. if (count > sizeof(s) - 1 || !count)
  1151. return -EINVAL;
  1152. if (copy_from_user(s, buf, count))
  1153. return -EFAULT;
  1154. s[count] = '\0';
  1155. if (sscanf(s, "%llx %llx %llx %llx %llx %llx %llx %llx%c", &data[0],
  1156. &data[1], &data[2], &data[3], &data[4], &data[5], &data[6],
  1157. &data[7], &c) < 8 || c != '\n')
  1158. return -EINVAL;
  1159. ino = file_inode(file);
  1160. mbox = (uintptr_t)ino->i_private & 7;
  1161. adap = ino->i_private - mbox;
  1162. addr = adap->regs + PF_REG(mbox, CIM_PF_MAILBOX_DATA_A);
  1163. ctrl = addr + MBOX_LEN;
  1164. if (MBOWNER_G(readl(ctrl)) != X_MBOWNER_PL)
  1165. return -EBUSY;
  1166. for (i = 0; i < 8; i++)
  1167. writeq(data[i], addr + 8 * i);
  1168. writel(MBMSGVALID_F | MBOWNER_V(X_MBOWNER_FW), ctrl);
  1169. return count;
  1170. }
  1171. static const struct file_operations mbox_debugfs_fops = {
  1172. .owner = THIS_MODULE,
  1173. .open = mbox_open,
  1174. .read = seq_read,
  1175. .llseek = seq_lseek,
  1176. .release = single_release,
  1177. .write = mbox_write
  1178. };
  1179. static int mps_trc_show(struct seq_file *seq, void *v)
  1180. {
  1181. int enabled, i;
  1182. struct trace_params tp;
  1183. unsigned int trcidx = (uintptr_t)seq->private & 3;
  1184. struct adapter *adap = seq->private - trcidx;
  1185. t4_get_trace_filter(adap, &tp, trcidx, &enabled);
  1186. if (!enabled) {
  1187. seq_puts(seq, "tracer is disabled\n");
  1188. return 0;
  1189. }
  1190. if (tp.skip_ofst * 8 >= TRACE_LEN) {
  1191. dev_err(adap->pdev_dev, "illegal trace pattern skip offset\n");
  1192. return -EINVAL;
  1193. }
  1194. if (tp.port < 8) {
  1195. i = adap->chan_map[tp.port & 3];
  1196. if (i >= MAX_NPORTS) {
  1197. dev_err(adap->pdev_dev, "tracer %u is assigned "
  1198. "to non-existing port\n", trcidx);
  1199. return -EINVAL;
  1200. }
  1201. seq_printf(seq, "tracer is capturing %s %s, ",
  1202. adap->port[i]->name, tp.port < 4 ? "Rx" : "Tx");
  1203. } else
  1204. seq_printf(seq, "tracer is capturing loopback %d, ",
  1205. tp.port - 8);
  1206. seq_printf(seq, "snap length: %u, min length: %u\n", tp.snap_len,
  1207. tp.min_len);
  1208. seq_printf(seq, "packets captured %smatch filter\n",
  1209. tp.invert ? "do not " : "");
  1210. if (tp.skip_ofst) {
  1211. seq_puts(seq, "filter pattern: ");
  1212. for (i = 0; i < tp.skip_ofst * 2; i += 2)
  1213. seq_printf(seq, "%08x%08x", tp.data[i], tp.data[i + 1]);
  1214. seq_putc(seq, '/');
  1215. for (i = 0; i < tp.skip_ofst * 2; i += 2)
  1216. seq_printf(seq, "%08x%08x", tp.mask[i], tp.mask[i + 1]);
  1217. seq_puts(seq, "@0\n");
  1218. }
  1219. seq_puts(seq, "filter pattern: ");
  1220. for (i = tp.skip_ofst * 2; i < TRACE_LEN / 4; i += 2)
  1221. seq_printf(seq, "%08x%08x", tp.data[i], tp.data[i + 1]);
  1222. seq_putc(seq, '/');
  1223. for (i = tp.skip_ofst * 2; i < TRACE_LEN / 4; i += 2)
  1224. seq_printf(seq, "%08x%08x", tp.mask[i], tp.mask[i + 1]);
  1225. seq_printf(seq, "@%u\n", (tp.skip_ofst + tp.skip_len) * 8);
  1226. return 0;
  1227. }
  1228. static int mps_trc_open(struct inode *inode, struct file *file)
  1229. {
  1230. return single_open(file, mps_trc_show, inode->i_private);
  1231. }
  1232. static unsigned int xdigit2int(unsigned char c)
  1233. {
  1234. return isdigit(c) ? c - '0' : tolower(c) - 'a' + 10;
  1235. }
  1236. #define TRC_PORT_NONE 0xff
  1237. #define TRC_RSS_ENABLE 0x33
  1238. #define TRC_RSS_DISABLE 0x13
  1239. /* Set an MPS trace filter. Syntax is:
  1240. *
  1241. * disable
  1242. *
  1243. * to disable tracing, or
  1244. *
  1245. * interface qid=<qid no> [snaplen=<val>] [minlen=<val>] [not] [<pattern>]...
  1246. *
  1247. * where interface is one of rxN, txN, or loopbackN, N = 0..3, qid can be one
  1248. * of the NIC's response qid obtained from sge_qinfo and pattern has the form
  1249. *
  1250. * <pattern data>[/<pattern mask>][@<anchor>]
  1251. *
  1252. * Up to 2 filter patterns can be specified. If 2 are supplied the first one
  1253. * must be anchored at 0. An omitted mask is taken as a mask of 1s, an omitted
  1254. * anchor is taken as 0.
  1255. */
  1256. static ssize_t mps_trc_write(struct file *file, const char __user *buf,
  1257. size_t count, loff_t *pos)
  1258. {
  1259. int i, enable, ret;
  1260. u32 *data, *mask;
  1261. struct trace_params tp;
  1262. const struct inode *ino;
  1263. unsigned int trcidx;
  1264. char *s, *p, *word, *end;
  1265. struct adapter *adap;
  1266. u32 j;
  1267. ino = file_inode(file);
  1268. trcidx = (uintptr_t)ino->i_private & 3;
  1269. adap = ino->i_private - trcidx;
  1270. /* Don't accept input more than 1K, can't be anything valid except lots
  1271. * of whitespace. Well, use less.
  1272. */
  1273. if (count > 1024)
  1274. return -EFBIG;
  1275. p = s = kzalloc(count + 1, GFP_USER);
  1276. if (!s)
  1277. return -ENOMEM;
  1278. if (copy_from_user(s, buf, count)) {
  1279. count = -EFAULT;
  1280. goto out;
  1281. }
  1282. if (s[count - 1] == '\n')
  1283. s[count - 1] = '\0';
  1284. enable = strcmp("disable", s) != 0;
  1285. if (!enable)
  1286. goto apply;
  1287. /* enable or disable trace multi rss filter */
  1288. if (adap->trace_rss)
  1289. t4_write_reg(adap, MPS_TRC_CFG_A, TRC_RSS_ENABLE);
  1290. else
  1291. t4_write_reg(adap, MPS_TRC_CFG_A, TRC_RSS_DISABLE);
  1292. memset(&tp, 0, sizeof(tp));
  1293. tp.port = TRC_PORT_NONE;
  1294. i = 0; /* counts pattern nibbles */
  1295. while (p) {
  1296. while (isspace(*p))
  1297. p++;
  1298. word = strsep(&p, " ");
  1299. if (!*word)
  1300. break;
  1301. if (!strncmp(word, "qid=", 4)) {
  1302. end = (char *)word + 4;
  1303. ret = kstrtouint(end, 10, &j);
  1304. if (ret)
  1305. goto out;
  1306. if (!adap->trace_rss) {
  1307. t4_write_reg(adap, MPS_T5_TRC_RSS_CONTROL_A, j);
  1308. continue;
  1309. }
  1310. switch (trcidx) {
  1311. case 0:
  1312. t4_write_reg(adap, MPS_TRC_RSS_CONTROL_A, j);
  1313. break;
  1314. case 1:
  1315. t4_write_reg(adap,
  1316. MPS_TRC_FILTER1_RSS_CONTROL_A, j);
  1317. break;
  1318. case 2:
  1319. t4_write_reg(adap,
  1320. MPS_TRC_FILTER2_RSS_CONTROL_A, j);
  1321. break;
  1322. case 3:
  1323. t4_write_reg(adap,
  1324. MPS_TRC_FILTER3_RSS_CONTROL_A, j);
  1325. break;
  1326. }
  1327. continue;
  1328. }
  1329. if (!strncmp(word, "snaplen=", 8)) {
  1330. end = (char *)word + 8;
  1331. ret = kstrtouint(end, 10, &j);
  1332. if (ret || j > 9600) {
  1333. inval: count = -EINVAL;
  1334. goto out;
  1335. }
  1336. tp.snap_len = j;
  1337. continue;
  1338. }
  1339. if (!strncmp(word, "minlen=", 7)) {
  1340. end = (char *)word + 7;
  1341. ret = kstrtouint(end, 10, &j);
  1342. if (ret || j > TFMINPKTSIZE_M)
  1343. goto inval;
  1344. tp.min_len = j;
  1345. continue;
  1346. }
  1347. if (!strcmp(word, "not")) {
  1348. tp.invert = !tp.invert;
  1349. continue;
  1350. }
  1351. if (!strncmp(word, "loopback", 8) && tp.port == TRC_PORT_NONE) {
  1352. if (word[8] < '0' || word[8] > '3' || word[9])
  1353. goto inval;
  1354. tp.port = word[8] - '0' + 8;
  1355. continue;
  1356. }
  1357. if (!strncmp(word, "tx", 2) && tp.port == TRC_PORT_NONE) {
  1358. if (word[2] < '0' || word[2] > '3' || word[3])
  1359. goto inval;
  1360. tp.port = word[2] - '0' + 4;
  1361. if (adap->chan_map[tp.port & 3] >= MAX_NPORTS)
  1362. goto inval;
  1363. continue;
  1364. }
  1365. if (!strncmp(word, "rx", 2) && tp.port == TRC_PORT_NONE) {
  1366. if (word[2] < '0' || word[2] > '3' || word[3])
  1367. goto inval;
  1368. tp.port = word[2] - '0';
  1369. if (adap->chan_map[tp.port] >= MAX_NPORTS)
  1370. goto inval;
  1371. continue;
  1372. }
  1373. if (!isxdigit(*word))
  1374. goto inval;
  1375. /* we have found a trace pattern */
  1376. if (i) { /* split pattern */
  1377. if (tp.skip_len) /* too many splits */
  1378. goto inval;
  1379. tp.skip_ofst = i / 16;
  1380. }
  1381. data = &tp.data[i / 8];
  1382. mask = &tp.mask[i / 8];
  1383. j = i;
  1384. while (isxdigit(*word)) {
  1385. if (i >= TRACE_LEN * 2) {
  1386. count = -EFBIG;
  1387. goto out;
  1388. }
  1389. *data = (*data << 4) + xdigit2int(*word++);
  1390. if (++i % 8 == 0)
  1391. data++;
  1392. }
  1393. if (*word == '/') {
  1394. word++;
  1395. while (isxdigit(*word)) {
  1396. if (j >= i) /* mask longer than data */
  1397. goto inval;
  1398. *mask = (*mask << 4) + xdigit2int(*word++);
  1399. if (++j % 8 == 0)
  1400. mask++;
  1401. }
  1402. if (i != j) /* mask shorter than data */
  1403. goto inval;
  1404. } else { /* no mask, use all 1s */
  1405. for ( ; i - j >= 8; j += 8)
  1406. *mask++ = 0xffffffff;
  1407. if (i % 8)
  1408. *mask = (1 << (i % 8) * 4) - 1;
  1409. }
  1410. if (*word == '@') {
  1411. end = (char *)word + 1;
  1412. ret = kstrtouint(end, 10, &j);
  1413. if (*end && *end != '\n')
  1414. goto inval;
  1415. if (j & 7) /* doesn't start at multiple of 8 */
  1416. goto inval;
  1417. j /= 8;
  1418. if (j < tp.skip_ofst) /* overlaps earlier pattern */
  1419. goto inval;
  1420. if (j - tp.skip_ofst > 31) /* skip too big */
  1421. goto inval;
  1422. tp.skip_len = j - tp.skip_ofst;
  1423. }
  1424. if (i % 8) {
  1425. *data <<= (8 - i % 8) * 4;
  1426. *mask <<= (8 - i % 8) * 4;
  1427. i = (i + 15) & ~15; /* 8-byte align */
  1428. }
  1429. }
  1430. if (tp.port == TRC_PORT_NONE)
  1431. goto inval;
  1432. apply:
  1433. i = t4_set_trace_filter(adap, &tp, trcidx, enable);
  1434. if (i)
  1435. count = i;
  1436. out:
  1437. kfree(s);
  1438. return count;
  1439. }
  1440. static const struct file_operations mps_trc_debugfs_fops = {
  1441. .owner = THIS_MODULE,
  1442. .open = mps_trc_open,
  1443. .read = seq_read,
  1444. .llseek = seq_lseek,
  1445. .release = single_release,
  1446. .write = mps_trc_write
  1447. };
  1448. static ssize_t flash_read(struct file *file, char __user *buf, size_t count,
  1449. loff_t *ppos)
  1450. {
  1451. loff_t pos = *ppos;
  1452. loff_t avail = file_inode(file)->i_size;
  1453. struct adapter *adap = file->private_data;
  1454. if (pos < 0)
  1455. return -EINVAL;
  1456. if (pos >= avail)
  1457. return 0;
  1458. if (count > avail - pos)
  1459. count = avail - pos;
  1460. while (count) {
  1461. size_t len;
  1462. int ret, ofst;
  1463. u8 data[256];
  1464. ofst = pos & 3;
  1465. len = min(count + ofst, sizeof(data));
  1466. ret = t4_read_flash(adap, pos - ofst, (len + 3) / 4,
  1467. (u32 *)data, 1);
  1468. if (ret)
  1469. return ret;
  1470. len -= ofst;
  1471. if (copy_to_user(buf, data + ofst, len))
  1472. return -EFAULT;
  1473. buf += len;
  1474. pos += len;
  1475. count -= len;
  1476. }
  1477. count = pos - *ppos;
  1478. *ppos = pos;
  1479. return count;
  1480. }
  1481. static const struct file_operations flash_debugfs_fops = {
  1482. .owner = THIS_MODULE,
  1483. .open = mem_open,
  1484. .read = flash_read,
  1485. .llseek = default_llseek,
  1486. };
  1487. static inline void tcamxy2valmask(u64 x, u64 y, u8 *addr, u64 *mask)
  1488. {
  1489. *mask = x | y;
  1490. y = (__force u64)cpu_to_be64(y);
  1491. memcpy(addr, (char *)&y + 2, ETH_ALEN);
  1492. }
  1493. static int mps_tcam_show(struct seq_file *seq, void *v)
  1494. {
  1495. struct adapter *adap = seq->private;
  1496. unsigned int chip_ver = CHELSIO_CHIP_VERSION(adap->params.chip);
  1497. if (v == SEQ_START_TOKEN) {
  1498. if (chip_ver > CHELSIO_T5) {
  1499. seq_puts(seq, "Idx Ethernet address Mask "
  1500. " VNI Mask IVLAN Vld "
  1501. "DIP_Hit Lookup Port "
  1502. "Vld Ports PF VF "
  1503. "Replication "
  1504. " P0 P1 P2 P3 ML\n");
  1505. } else {
  1506. if (adap->params.arch.mps_rplc_size > 128)
  1507. seq_puts(seq, "Idx Ethernet address Mask "
  1508. "Vld Ports PF VF "
  1509. "Replication "
  1510. " P0 P1 P2 P3 ML\n");
  1511. else
  1512. seq_puts(seq, "Idx Ethernet address Mask "
  1513. "Vld Ports PF VF Replication"
  1514. " P0 P1 P2 P3 ML\n");
  1515. }
  1516. } else {
  1517. u64 mask;
  1518. u8 addr[ETH_ALEN];
  1519. bool replicate, dip_hit = false, vlan_vld = false;
  1520. unsigned int idx = (uintptr_t)v - 2;
  1521. u64 tcamy, tcamx, val;
  1522. u32 cls_lo, cls_hi, ctl, data2, vnix = 0, vniy = 0;
  1523. u32 rplc[8] = {0};
  1524. u8 lookup_type = 0, port_num = 0;
  1525. u16 ivlan = 0;
  1526. if (chip_ver > CHELSIO_T5) {
  1527. /* CtlCmdType - 0: Read, 1: Write
  1528. * CtlTcamSel - 0: TCAM0, 1: TCAM1
  1529. * CtlXYBitSel- 0: Y bit, 1: X bit
  1530. */
  1531. /* Read tcamy */
  1532. ctl = CTLCMDTYPE_V(0) | CTLXYBITSEL_V(0);
  1533. if (idx < 256)
  1534. ctl |= CTLTCAMINDEX_V(idx) | CTLTCAMSEL_V(0);
  1535. else
  1536. ctl |= CTLTCAMINDEX_V(idx - 256) |
  1537. CTLTCAMSEL_V(1);
  1538. t4_write_reg(adap, MPS_CLS_TCAM_DATA2_CTL_A, ctl);
  1539. val = t4_read_reg(adap, MPS_CLS_TCAM_DATA1_A);
  1540. tcamy = DMACH_G(val) << 32;
  1541. tcamy |= t4_read_reg(adap, MPS_CLS_TCAM_DATA0_A);
  1542. data2 = t4_read_reg(adap, MPS_CLS_TCAM_DATA2_CTL_A);
  1543. lookup_type = DATALKPTYPE_G(data2);
  1544. /* 0 - Outer header, 1 - Inner header
  1545. * [71:48] bit locations are overloaded for
  1546. * outer vs. inner lookup types.
  1547. */
  1548. if (lookup_type && (lookup_type != DATALKPTYPE_M)) {
  1549. /* Inner header VNI */
  1550. vniy = (data2 & DATAVIDH2_F) |
  1551. (DATAVIDH1_G(data2) << 16) | VIDL_G(val);
  1552. dip_hit = data2 & DATADIPHIT_F;
  1553. } else {
  1554. vlan_vld = data2 & DATAVIDH2_F;
  1555. ivlan = VIDL_G(val);
  1556. }
  1557. port_num = DATAPORTNUM_G(data2);
  1558. /* Read tcamx. Change the control param */
  1559. vnix = 0;
  1560. ctl |= CTLXYBITSEL_V(1);
  1561. t4_write_reg(adap, MPS_CLS_TCAM_DATA2_CTL_A, ctl);
  1562. val = t4_read_reg(adap, MPS_CLS_TCAM_DATA1_A);
  1563. tcamx = DMACH_G(val) << 32;
  1564. tcamx |= t4_read_reg(adap, MPS_CLS_TCAM_DATA0_A);
  1565. data2 = t4_read_reg(adap, MPS_CLS_TCAM_DATA2_CTL_A);
  1566. if (lookup_type && (lookup_type != DATALKPTYPE_M)) {
  1567. /* Inner header VNI mask */
  1568. vnix = (data2 & DATAVIDH2_F) |
  1569. (DATAVIDH1_G(data2) << 16) | VIDL_G(val);
  1570. }
  1571. } else {
  1572. tcamy = t4_read_reg64(adap, MPS_CLS_TCAM_Y_L(idx));
  1573. tcamx = t4_read_reg64(adap, MPS_CLS_TCAM_X_L(idx));
  1574. }
  1575. cls_lo = t4_read_reg(adap, MPS_CLS_SRAM_L(idx));
  1576. cls_hi = t4_read_reg(adap, MPS_CLS_SRAM_H(idx));
  1577. if (tcamx & tcamy) {
  1578. seq_printf(seq, "%3u -\n", idx);
  1579. goto out;
  1580. }
  1581. rplc[0] = rplc[1] = rplc[2] = rplc[3] = 0;
  1582. if (chip_ver > CHELSIO_T5)
  1583. replicate = (cls_lo & T6_REPLICATE_F);
  1584. else
  1585. replicate = (cls_lo & REPLICATE_F);
  1586. if (replicate) {
  1587. struct fw_ldst_cmd ldst_cmd;
  1588. int ret;
  1589. struct fw_ldst_mps_rplc mps_rplc;
  1590. u32 ldst_addrspc;
  1591. memset(&ldst_cmd, 0, sizeof(ldst_cmd));
  1592. ldst_addrspc =
  1593. FW_LDST_CMD_ADDRSPACE_V(FW_LDST_ADDRSPC_MPS);
  1594. ldst_cmd.op_to_addrspace =
  1595. htonl(FW_CMD_OP_V(FW_LDST_CMD) |
  1596. FW_CMD_REQUEST_F |
  1597. FW_CMD_READ_F |
  1598. ldst_addrspc);
  1599. ldst_cmd.cycles_to_len16 = htonl(FW_LEN16(ldst_cmd));
  1600. ldst_cmd.u.mps.rplc.fid_idx =
  1601. htons(FW_LDST_CMD_FID_V(FW_LDST_MPS_RPLC) |
  1602. FW_LDST_CMD_IDX_V(idx));
  1603. ret = t4_wr_mbox(adap, adap->mbox, &ldst_cmd,
  1604. sizeof(ldst_cmd), &ldst_cmd);
  1605. if (ret)
  1606. dev_warn(adap->pdev_dev, "Can't read MPS "
  1607. "replication map for idx %d: %d\n",
  1608. idx, -ret);
  1609. else {
  1610. mps_rplc = ldst_cmd.u.mps.rplc;
  1611. rplc[0] = ntohl(mps_rplc.rplc31_0);
  1612. rplc[1] = ntohl(mps_rplc.rplc63_32);
  1613. rplc[2] = ntohl(mps_rplc.rplc95_64);
  1614. rplc[3] = ntohl(mps_rplc.rplc127_96);
  1615. if (adap->params.arch.mps_rplc_size > 128) {
  1616. rplc[4] = ntohl(mps_rplc.rplc159_128);
  1617. rplc[5] = ntohl(mps_rplc.rplc191_160);
  1618. rplc[6] = ntohl(mps_rplc.rplc223_192);
  1619. rplc[7] = ntohl(mps_rplc.rplc255_224);
  1620. }
  1621. }
  1622. }
  1623. tcamxy2valmask(tcamx, tcamy, addr, &mask);
  1624. if (chip_ver > CHELSIO_T5) {
  1625. /* Inner header lookup */
  1626. if (lookup_type && (lookup_type != DATALKPTYPE_M)) {
  1627. seq_printf(seq,
  1628. "%3u %02x:%02x:%02x:%02x:%02x:%02x "
  1629. "%012llx %06x %06x - - %3c"
  1630. " 'I' %4x "
  1631. "%3c %#x%4u%4d", idx, addr[0],
  1632. addr[1], addr[2], addr[3],
  1633. addr[4], addr[5],
  1634. (unsigned long long)mask,
  1635. vniy, (vnix | vniy),
  1636. dip_hit ? 'Y' : 'N',
  1637. port_num,
  1638. (cls_lo & T6_SRAM_VLD_F) ? 'Y' : 'N',
  1639. PORTMAP_G(cls_hi),
  1640. T6_PF_G(cls_lo),
  1641. (cls_lo & T6_VF_VALID_F) ?
  1642. T6_VF_G(cls_lo) : -1);
  1643. } else {
  1644. seq_printf(seq,
  1645. "%3u %02x:%02x:%02x:%02x:%02x:%02x "
  1646. "%012llx - - ",
  1647. idx, addr[0], addr[1], addr[2],
  1648. addr[3], addr[4], addr[5],
  1649. (unsigned long long)mask);
  1650. if (vlan_vld)
  1651. seq_printf(seq, "%4u Y ", ivlan);
  1652. else
  1653. seq_puts(seq, " - N ");
  1654. seq_printf(seq,
  1655. "- %3c %4x %3c %#x%4u%4d",
  1656. lookup_type ? 'I' : 'O', port_num,
  1657. (cls_lo & T6_SRAM_VLD_F) ? 'Y' : 'N',
  1658. PORTMAP_G(cls_hi),
  1659. T6_PF_G(cls_lo),
  1660. (cls_lo & T6_VF_VALID_F) ?
  1661. T6_VF_G(cls_lo) : -1);
  1662. }
  1663. } else
  1664. seq_printf(seq, "%3u %02x:%02x:%02x:%02x:%02x:%02x "
  1665. "%012llx%3c %#x%4u%4d",
  1666. idx, addr[0], addr[1], addr[2], addr[3],
  1667. addr[4], addr[5], (unsigned long long)mask,
  1668. (cls_lo & SRAM_VLD_F) ? 'Y' : 'N',
  1669. PORTMAP_G(cls_hi),
  1670. PF_G(cls_lo),
  1671. (cls_lo & VF_VALID_F) ? VF_G(cls_lo) : -1);
  1672. if (replicate) {
  1673. if (adap->params.arch.mps_rplc_size > 128)
  1674. seq_printf(seq, " %08x %08x %08x %08x "
  1675. "%08x %08x %08x %08x",
  1676. rplc[7], rplc[6], rplc[5], rplc[4],
  1677. rplc[3], rplc[2], rplc[1], rplc[0]);
  1678. else
  1679. seq_printf(seq, " %08x %08x %08x %08x",
  1680. rplc[3], rplc[2], rplc[1], rplc[0]);
  1681. } else {
  1682. if (adap->params.arch.mps_rplc_size > 128)
  1683. seq_printf(seq, "%72c", ' ');
  1684. else
  1685. seq_printf(seq, "%36c", ' ');
  1686. }
  1687. if (chip_ver > CHELSIO_T5)
  1688. seq_printf(seq, "%4u%3u%3u%3u %#x\n",
  1689. T6_SRAM_PRIO0_G(cls_lo),
  1690. T6_SRAM_PRIO1_G(cls_lo),
  1691. T6_SRAM_PRIO2_G(cls_lo),
  1692. T6_SRAM_PRIO3_G(cls_lo),
  1693. (cls_lo >> T6_MULTILISTEN0_S) & 0xf);
  1694. else
  1695. seq_printf(seq, "%4u%3u%3u%3u %#x\n",
  1696. SRAM_PRIO0_G(cls_lo), SRAM_PRIO1_G(cls_lo),
  1697. SRAM_PRIO2_G(cls_lo), SRAM_PRIO3_G(cls_lo),
  1698. (cls_lo >> MULTILISTEN0_S) & 0xf);
  1699. }
  1700. out: return 0;
  1701. }
  1702. static inline void *mps_tcam_get_idx(struct seq_file *seq, loff_t pos)
  1703. {
  1704. struct adapter *adap = seq->private;
  1705. int max_mac_addr = is_t4(adap->params.chip) ?
  1706. NUM_MPS_CLS_SRAM_L_INSTANCES :
  1707. NUM_MPS_T5_CLS_SRAM_L_INSTANCES;
  1708. return ((pos <= max_mac_addr) ? (void *)(uintptr_t)(pos + 1) : NULL);
  1709. }
  1710. static void *mps_tcam_start(struct seq_file *seq, loff_t *pos)
  1711. {
  1712. return *pos ? mps_tcam_get_idx(seq, *pos) : SEQ_START_TOKEN;
  1713. }
  1714. static void *mps_tcam_next(struct seq_file *seq, void *v, loff_t *pos)
  1715. {
  1716. ++*pos;
  1717. return mps_tcam_get_idx(seq, *pos);
  1718. }
  1719. static void mps_tcam_stop(struct seq_file *seq, void *v)
  1720. {
  1721. }
  1722. static const struct seq_operations mps_tcam_seq_ops = {
  1723. .start = mps_tcam_start,
  1724. .next = mps_tcam_next,
  1725. .stop = mps_tcam_stop,
  1726. .show = mps_tcam_show
  1727. };
  1728. static int mps_tcam_open(struct inode *inode, struct file *file)
  1729. {
  1730. int res = seq_open(file, &mps_tcam_seq_ops);
  1731. if (!res) {
  1732. struct seq_file *seq = file->private_data;
  1733. seq->private = inode->i_private;
  1734. }
  1735. return res;
  1736. }
  1737. static const struct file_operations mps_tcam_debugfs_fops = {
  1738. .owner = THIS_MODULE,
  1739. .open = mps_tcam_open,
  1740. .read = seq_read,
  1741. .llseek = seq_lseek,
  1742. .release = seq_release,
  1743. };
  1744. /* Display various sensor information.
  1745. */
  1746. static int sensors_show(struct seq_file *seq, void *v)
  1747. {
  1748. struct adapter *adap = seq->private;
  1749. u32 param[7], val[7];
  1750. int ret;
  1751. /* Note that if the sensors haven't been initialized and turned on
  1752. * we'll get values of 0, so treat those as "<unknown>" ...
  1753. */
  1754. param[0] = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
  1755. FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_DIAG) |
  1756. FW_PARAMS_PARAM_Y_V(FW_PARAM_DEV_DIAG_TMP));
  1757. param[1] = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
  1758. FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_DIAG) |
  1759. FW_PARAMS_PARAM_Y_V(FW_PARAM_DEV_DIAG_VDD));
  1760. ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 2,
  1761. param, val);
  1762. if (ret < 0 || val[0] == 0)
  1763. seq_puts(seq, "Temperature: <unknown>\n");
  1764. else
  1765. seq_printf(seq, "Temperature: %dC\n", val[0]);
  1766. if (ret < 0 || val[1] == 0)
  1767. seq_puts(seq, "Core VDD: <unknown>\n");
  1768. else
  1769. seq_printf(seq, "Core VDD: %dmV\n", val[1]);
  1770. return 0;
  1771. }
  1772. DEFINE_SIMPLE_DEBUGFS_FILE(sensors);
  1773. #if IS_ENABLED(CONFIG_IPV6)
  1774. static int clip_tbl_open(struct inode *inode, struct file *file)
  1775. {
  1776. return single_open(file, clip_tbl_show, inode->i_private);
  1777. }
  1778. static const struct file_operations clip_tbl_debugfs_fops = {
  1779. .owner = THIS_MODULE,
  1780. .open = clip_tbl_open,
  1781. .read = seq_read,
  1782. .llseek = seq_lseek,
  1783. .release = single_release
  1784. };
  1785. #endif
  1786. /*RSS Table.
  1787. */
  1788. static int rss_show(struct seq_file *seq, void *v, int idx)
  1789. {
  1790. u16 *entry = v;
  1791. seq_printf(seq, "%4d: %4u %4u %4u %4u %4u %4u %4u %4u\n",
  1792. idx * 8, entry[0], entry[1], entry[2], entry[3], entry[4],
  1793. entry[5], entry[6], entry[7]);
  1794. return 0;
  1795. }
  1796. static int rss_open(struct inode *inode, struct file *file)
  1797. {
  1798. struct adapter *adap = inode->i_private;
  1799. int ret, nentries;
  1800. struct seq_tab *p;
  1801. nentries = t4_chip_rss_size(adap);
  1802. p = seq_open_tab(file, nentries / 8, 8 * sizeof(u16), 0, rss_show);
  1803. if (!p)
  1804. return -ENOMEM;
  1805. ret = t4_read_rss(adap, (u16 *)p->data);
  1806. if (ret)
  1807. seq_release_private(inode, file);
  1808. return ret;
  1809. }
  1810. static const struct file_operations rss_debugfs_fops = {
  1811. .owner = THIS_MODULE,
  1812. .open = rss_open,
  1813. .read = seq_read,
  1814. .llseek = seq_lseek,
  1815. .release = seq_release_private
  1816. };
  1817. /* RSS Configuration.
  1818. */
  1819. /* Small utility function to return the strings "yes" or "no" if the supplied
  1820. * argument is non-zero.
  1821. */
  1822. static const char *yesno(int x)
  1823. {
  1824. static const char *yes = "yes";
  1825. static const char *no = "no";
  1826. return x ? yes : no;
  1827. }
  1828. static int rss_config_show(struct seq_file *seq, void *v)
  1829. {
  1830. struct adapter *adapter = seq->private;
  1831. static const char * const keymode[] = {
  1832. "global",
  1833. "global and per-VF scramble",
  1834. "per-PF and per-VF scramble",
  1835. "per-VF and per-VF scramble",
  1836. };
  1837. u32 rssconf;
  1838. rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_A);
  1839. seq_printf(seq, "TP_RSS_CONFIG: %#x\n", rssconf);
  1840. seq_printf(seq, " Tnl4TupEnIpv6: %3s\n", yesno(rssconf &
  1841. TNL4TUPENIPV6_F));
  1842. seq_printf(seq, " Tnl2TupEnIpv6: %3s\n", yesno(rssconf &
  1843. TNL2TUPENIPV6_F));
  1844. seq_printf(seq, " Tnl4TupEnIpv4: %3s\n", yesno(rssconf &
  1845. TNL4TUPENIPV4_F));
  1846. seq_printf(seq, " Tnl2TupEnIpv4: %3s\n", yesno(rssconf &
  1847. TNL2TUPENIPV4_F));
  1848. seq_printf(seq, " TnlTcpSel: %3s\n", yesno(rssconf & TNLTCPSEL_F));
  1849. seq_printf(seq, " TnlIp6Sel: %3s\n", yesno(rssconf & TNLIP6SEL_F));
  1850. seq_printf(seq, " TnlVrtSel: %3s\n", yesno(rssconf & TNLVRTSEL_F));
  1851. seq_printf(seq, " TnlMapEn: %3s\n", yesno(rssconf & TNLMAPEN_F));
  1852. seq_printf(seq, " OfdHashSave: %3s\n", yesno(rssconf &
  1853. OFDHASHSAVE_F));
  1854. seq_printf(seq, " OfdVrtSel: %3s\n", yesno(rssconf & OFDVRTSEL_F));
  1855. seq_printf(seq, " OfdMapEn: %3s\n", yesno(rssconf & OFDMAPEN_F));
  1856. seq_printf(seq, " OfdLkpEn: %3s\n", yesno(rssconf & OFDLKPEN_F));
  1857. seq_printf(seq, " Syn4TupEnIpv6: %3s\n", yesno(rssconf &
  1858. SYN4TUPENIPV6_F));
  1859. seq_printf(seq, " Syn2TupEnIpv6: %3s\n", yesno(rssconf &
  1860. SYN2TUPENIPV6_F));
  1861. seq_printf(seq, " Syn4TupEnIpv4: %3s\n", yesno(rssconf &
  1862. SYN4TUPENIPV4_F));
  1863. seq_printf(seq, " Syn2TupEnIpv4: %3s\n", yesno(rssconf &
  1864. SYN2TUPENIPV4_F));
  1865. seq_printf(seq, " Syn4TupEnIpv6: %3s\n", yesno(rssconf &
  1866. SYN4TUPENIPV6_F));
  1867. seq_printf(seq, " SynIp6Sel: %3s\n", yesno(rssconf & SYNIP6SEL_F));
  1868. seq_printf(seq, " SynVrt6Sel: %3s\n", yesno(rssconf & SYNVRTSEL_F));
  1869. seq_printf(seq, " SynMapEn: %3s\n", yesno(rssconf & SYNMAPEN_F));
  1870. seq_printf(seq, " SynLkpEn: %3s\n", yesno(rssconf & SYNLKPEN_F));
  1871. seq_printf(seq, " ChnEn: %3s\n", yesno(rssconf &
  1872. CHANNELENABLE_F));
  1873. seq_printf(seq, " PrtEn: %3s\n", yesno(rssconf &
  1874. PORTENABLE_F));
  1875. seq_printf(seq, " TnlAllLkp: %3s\n", yesno(rssconf &
  1876. TNLALLLOOKUP_F));
  1877. seq_printf(seq, " VrtEn: %3s\n", yesno(rssconf &
  1878. VIRTENABLE_F));
  1879. seq_printf(seq, " CngEn: %3s\n", yesno(rssconf &
  1880. CONGESTIONENABLE_F));
  1881. seq_printf(seq, " HashToeplitz: %3s\n", yesno(rssconf &
  1882. HASHTOEPLITZ_F));
  1883. seq_printf(seq, " Udp4En: %3s\n", yesno(rssconf & UDPENABLE_F));
  1884. seq_printf(seq, " Disable: %3s\n", yesno(rssconf & DISABLE_F));
  1885. seq_puts(seq, "\n");
  1886. rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_TNL_A);
  1887. seq_printf(seq, "TP_RSS_CONFIG_TNL: %#x\n", rssconf);
  1888. seq_printf(seq, " MaskSize: %3d\n", MASKSIZE_G(rssconf));
  1889. seq_printf(seq, " MaskFilter: %3d\n", MASKFILTER_G(rssconf));
  1890. if (CHELSIO_CHIP_VERSION(adapter->params.chip) > CHELSIO_T5) {
  1891. seq_printf(seq, " HashAll: %3s\n",
  1892. yesno(rssconf & HASHALL_F));
  1893. seq_printf(seq, " HashEth: %3s\n",
  1894. yesno(rssconf & HASHETH_F));
  1895. }
  1896. seq_printf(seq, " UseWireCh: %3s\n", yesno(rssconf & USEWIRECH_F));
  1897. seq_puts(seq, "\n");
  1898. rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_OFD_A);
  1899. seq_printf(seq, "TP_RSS_CONFIG_OFD: %#x\n", rssconf);
  1900. seq_printf(seq, " MaskSize: %3d\n", MASKSIZE_G(rssconf));
  1901. seq_printf(seq, " RRCplMapEn: %3s\n", yesno(rssconf &
  1902. RRCPLMAPEN_F));
  1903. seq_printf(seq, " RRCplQueWidth: %3d\n", RRCPLQUEWIDTH_G(rssconf));
  1904. seq_puts(seq, "\n");
  1905. rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_SYN_A);
  1906. seq_printf(seq, "TP_RSS_CONFIG_SYN: %#x\n", rssconf);
  1907. seq_printf(seq, " MaskSize: %3d\n", MASKSIZE_G(rssconf));
  1908. seq_printf(seq, " UseWireCh: %3s\n", yesno(rssconf & USEWIRECH_F));
  1909. seq_puts(seq, "\n");
  1910. rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_VRT_A);
  1911. seq_printf(seq, "TP_RSS_CONFIG_VRT: %#x\n", rssconf);
  1912. if (CHELSIO_CHIP_VERSION(adapter->params.chip) > CHELSIO_T5) {
  1913. seq_printf(seq, " KeyWrAddrX: %3d\n",
  1914. KEYWRADDRX_G(rssconf));
  1915. seq_printf(seq, " KeyExtend: %3s\n",
  1916. yesno(rssconf & KEYEXTEND_F));
  1917. }
  1918. seq_printf(seq, " VfRdRg: %3s\n", yesno(rssconf & VFRDRG_F));
  1919. seq_printf(seq, " VfRdEn: %3s\n", yesno(rssconf & VFRDEN_F));
  1920. seq_printf(seq, " VfPerrEn: %3s\n", yesno(rssconf & VFPERREN_F));
  1921. seq_printf(seq, " KeyPerrEn: %3s\n", yesno(rssconf & KEYPERREN_F));
  1922. seq_printf(seq, " DisVfVlan: %3s\n", yesno(rssconf &
  1923. DISABLEVLAN_F));
  1924. seq_printf(seq, " EnUpSwt: %3s\n", yesno(rssconf & ENABLEUP0_F));
  1925. seq_printf(seq, " HashDelay: %3d\n", HASHDELAY_G(rssconf));
  1926. if (CHELSIO_CHIP_VERSION(adapter->params.chip) <= CHELSIO_T5)
  1927. seq_printf(seq, " VfWrAddr: %3d\n", VFWRADDR_G(rssconf));
  1928. else
  1929. seq_printf(seq, " VfWrAddr: %3d\n",
  1930. T6_VFWRADDR_G(rssconf));
  1931. seq_printf(seq, " KeyMode: %s\n", keymode[KEYMODE_G(rssconf)]);
  1932. seq_printf(seq, " VfWrEn: %3s\n", yesno(rssconf & VFWREN_F));
  1933. seq_printf(seq, " KeyWrEn: %3s\n", yesno(rssconf & KEYWREN_F));
  1934. seq_printf(seq, " KeyWrAddr: %3d\n", KEYWRADDR_G(rssconf));
  1935. seq_puts(seq, "\n");
  1936. rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_CNG_A);
  1937. seq_printf(seq, "TP_RSS_CONFIG_CNG: %#x\n", rssconf);
  1938. seq_printf(seq, " ChnCount3: %3s\n", yesno(rssconf & CHNCOUNT3_F));
  1939. seq_printf(seq, " ChnCount2: %3s\n", yesno(rssconf & CHNCOUNT2_F));
  1940. seq_printf(seq, " ChnCount1: %3s\n", yesno(rssconf & CHNCOUNT1_F));
  1941. seq_printf(seq, " ChnCount0: %3s\n", yesno(rssconf & CHNCOUNT0_F));
  1942. seq_printf(seq, " ChnUndFlow3: %3s\n", yesno(rssconf &
  1943. CHNUNDFLOW3_F));
  1944. seq_printf(seq, " ChnUndFlow2: %3s\n", yesno(rssconf &
  1945. CHNUNDFLOW2_F));
  1946. seq_printf(seq, " ChnUndFlow1: %3s\n", yesno(rssconf &
  1947. CHNUNDFLOW1_F));
  1948. seq_printf(seq, " ChnUndFlow0: %3s\n", yesno(rssconf &
  1949. CHNUNDFLOW0_F));
  1950. seq_printf(seq, " RstChn3: %3s\n", yesno(rssconf & RSTCHN3_F));
  1951. seq_printf(seq, " RstChn2: %3s\n", yesno(rssconf & RSTCHN2_F));
  1952. seq_printf(seq, " RstChn1: %3s\n", yesno(rssconf & RSTCHN1_F));
  1953. seq_printf(seq, " RstChn0: %3s\n", yesno(rssconf & RSTCHN0_F));
  1954. seq_printf(seq, " UpdVld: %3s\n", yesno(rssconf & UPDVLD_F));
  1955. seq_printf(seq, " Xoff: %3s\n", yesno(rssconf & XOFF_F));
  1956. seq_printf(seq, " UpdChn3: %3s\n", yesno(rssconf & UPDCHN3_F));
  1957. seq_printf(seq, " UpdChn2: %3s\n", yesno(rssconf & UPDCHN2_F));
  1958. seq_printf(seq, " UpdChn1: %3s\n", yesno(rssconf & UPDCHN1_F));
  1959. seq_printf(seq, " UpdChn0: %3s\n", yesno(rssconf & UPDCHN0_F));
  1960. seq_printf(seq, " Queue: %3d\n", QUEUE_G(rssconf));
  1961. return 0;
  1962. }
  1963. DEFINE_SIMPLE_DEBUGFS_FILE(rss_config);
  1964. /* RSS Secret Key.
  1965. */
  1966. static int rss_key_show(struct seq_file *seq, void *v)
  1967. {
  1968. u32 key[10];
  1969. t4_read_rss_key(seq->private, key, true);
  1970. seq_printf(seq, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x\n",
  1971. key[9], key[8], key[7], key[6], key[5], key[4], key[3],
  1972. key[2], key[1], key[0]);
  1973. return 0;
  1974. }
  1975. static int rss_key_open(struct inode *inode, struct file *file)
  1976. {
  1977. return single_open(file, rss_key_show, inode->i_private);
  1978. }
  1979. static ssize_t rss_key_write(struct file *file, const char __user *buf,
  1980. size_t count, loff_t *pos)
  1981. {
  1982. int i, j;
  1983. u32 key[10];
  1984. char s[100], *p;
  1985. struct adapter *adap = file_inode(file)->i_private;
  1986. if (count > sizeof(s) - 1)
  1987. return -EINVAL;
  1988. if (copy_from_user(s, buf, count))
  1989. return -EFAULT;
  1990. for (i = count; i > 0 && isspace(s[i - 1]); i--)
  1991. ;
  1992. s[i] = '\0';
  1993. for (p = s, i = 9; i >= 0; i--) {
  1994. key[i] = 0;
  1995. for (j = 0; j < 8; j++, p++) {
  1996. if (!isxdigit(*p))
  1997. return -EINVAL;
  1998. key[i] = (key[i] << 4) | hex2val(*p);
  1999. }
  2000. }
  2001. t4_write_rss_key(adap, key, -1, true);
  2002. return count;
  2003. }
  2004. static const struct file_operations rss_key_debugfs_fops = {
  2005. .owner = THIS_MODULE,
  2006. .open = rss_key_open,
  2007. .read = seq_read,
  2008. .llseek = seq_lseek,
  2009. .release = single_release,
  2010. .write = rss_key_write
  2011. };
  2012. /* PF RSS Configuration.
  2013. */
  2014. struct rss_pf_conf {
  2015. u32 rss_pf_map;
  2016. u32 rss_pf_mask;
  2017. u32 rss_pf_config;
  2018. };
  2019. static int rss_pf_config_show(struct seq_file *seq, void *v, int idx)
  2020. {
  2021. struct rss_pf_conf *pfconf;
  2022. if (v == SEQ_START_TOKEN) {
  2023. /* use the 0th entry to dump the PF Map Index Size */
  2024. pfconf = seq->private + offsetof(struct seq_tab, data);
  2025. seq_printf(seq, "PF Map Index Size = %d\n\n",
  2026. LKPIDXSIZE_G(pfconf->rss_pf_map));
  2027. seq_puts(seq, " RSS PF VF Hash Tuple Enable Default\n");
  2028. seq_puts(seq, " Enable IPF Mask Mask IPv6 IPv4 UDP Queue\n");
  2029. seq_puts(seq, " PF Map Chn Prt Map Size Size Four Two Four Two Four Ch1 Ch0\n");
  2030. } else {
  2031. #define G_PFnLKPIDX(map, n) \
  2032. (((map) >> PF1LKPIDX_S*(n)) & PF0LKPIDX_M)
  2033. #define G_PFnMSKSIZE(mask, n) \
  2034. (((mask) >> PF1MSKSIZE_S*(n)) & PF1MSKSIZE_M)
  2035. pfconf = v;
  2036. seq_printf(seq, "%3d %3s %3s %3s %3d %3d %3d %3s %3s %3s %3s %3s %3d %3d\n",
  2037. idx,
  2038. yesno(pfconf->rss_pf_config & MAPENABLE_F),
  2039. yesno(pfconf->rss_pf_config & CHNENABLE_F),
  2040. yesno(pfconf->rss_pf_config & PRTENABLE_F),
  2041. G_PFnLKPIDX(pfconf->rss_pf_map, idx),
  2042. G_PFnMSKSIZE(pfconf->rss_pf_mask, idx),
  2043. IVFWIDTH_G(pfconf->rss_pf_config),
  2044. yesno(pfconf->rss_pf_config & IP6FOURTUPEN_F),
  2045. yesno(pfconf->rss_pf_config & IP6TWOTUPEN_F),
  2046. yesno(pfconf->rss_pf_config & IP4FOURTUPEN_F),
  2047. yesno(pfconf->rss_pf_config & IP4TWOTUPEN_F),
  2048. yesno(pfconf->rss_pf_config & UDPFOURTUPEN_F),
  2049. CH1DEFAULTQUEUE_G(pfconf->rss_pf_config),
  2050. CH0DEFAULTQUEUE_G(pfconf->rss_pf_config));
  2051. #undef G_PFnLKPIDX
  2052. #undef G_PFnMSKSIZE
  2053. }
  2054. return 0;
  2055. }
  2056. static int rss_pf_config_open(struct inode *inode, struct file *file)
  2057. {
  2058. struct adapter *adapter = inode->i_private;
  2059. struct seq_tab *p;
  2060. u32 rss_pf_map, rss_pf_mask;
  2061. struct rss_pf_conf *pfconf;
  2062. int pf;
  2063. p = seq_open_tab(file, 8, sizeof(*pfconf), 1, rss_pf_config_show);
  2064. if (!p)
  2065. return -ENOMEM;
  2066. pfconf = (struct rss_pf_conf *)p->data;
  2067. rss_pf_map = t4_read_rss_pf_map(adapter, true);
  2068. rss_pf_mask = t4_read_rss_pf_mask(adapter, true);
  2069. for (pf = 0; pf < 8; pf++) {
  2070. pfconf[pf].rss_pf_map = rss_pf_map;
  2071. pfconf[pf].rss_pf_mask = rss_pf_mask;
  2072. t4_read_rss_pf_config(adapter, pf, &pfconf[pf].rss_pf_config,
  2073. true);
  2074. }
  2075. return 0;
  2076. }
  2077. static const struct file_operations rss_pf_config_debugfs_fops = {
  2078. .owner = THIS_MODULE,
  2079. .open = rss_pf_config_open,
  2080. .read = seq_read,
  2081. .llseek = seq_lseek,
  2082. .release = seq_release_private
  2083. };
  2084. /* VF RSS Configuration.
  2085. */
  2086. struct rss_vf_conf {
  2087. u32 rss_vf_vfl;
  2088. u32 rss_vf_vfh;
  2089. };
  2090. static int rss_vf_config_show(struct seq_file *seq, void *v, int idx)
  2091. {
  2092. if (v == SEQ_START_TOKEN) {
  2093. seq_puts(seq, " RSS Hash Tuple Enable\n");
  2094. seq_puts(seq, " Enable IVF Dis Enb IPv6 IPv4 UDP Def Secret Key\n");
  2095. seq_puts(seq, " VF Chn Prt Map VLAN uP Four Two Four Two Four Que Idx Hash\n");
  2096. } else {
  2097. struct rss_vf_conf *vfconf = v;
  2098. seq_printf(seq, "%3d %3s %3s %3d %3s %3s %3s %3s %3s %3s %3s %4d %3d %#10x\n",
  2099. idx,
  2100. yesno(vfconf->rss_vf_vfh & VFCHNEN_F),
  2101. yesno(vfconf->rss_vf_vfh & VFPRTEN_F),
  2102. VFLKPIDX_G(vfconf->rss_vf_vfh),
  2103. yesno(vfconf->rss_vf_vfh & VFVLNEX_F),
  2104. yesno(vfconf->rss_vf_vfh & VFUPEN_F),
  2105. yesno(vfconf->rss_vf_vfh & VFIP4FOURTUPEN_F),
  2106. yesno(vfconf->rss_vf_vfh & VFIP6TWOTUPEN_F),
  2107. yesno(vfconf->rss_vf_vfh & VFIP4FOURTUPEN_F),
  2108. yesno(vfconf->rss_vf_vfh & VFIP4TWOTUPEN_F),
  2109. yesno(vfconf->rss_vf_vfh & ENABLEUDPHASH_F),
  2110. DEFAULTQUEUE_G(vfconf->rss_vf_vfh),
  2111. KEYINDEX_G(vfconf->rss_vf_vfh),
  2112. vfconf->rss_vf_vfl);
  2113. }
  2114. return 0;
  2115. }
  2116. static int rss_vf_config_open(struct inode *inode, struct file *file)
  2117. {
  2118. struct adapter *adapter = inode->i_private;
  2119. struct seq_tab *p;
  2120. struct rss_vf_conf *vfconf;
  2121. int vf, vfcount = adapter->params.arch.vfcount;
  2122. p = seq_open_tab(file, vfcount, sizeof(*vfconf), 1, rss_vf_config_show);
  2123. if (!p)
  2124. return -ENOMEM;
  2125. vfconf = (struct rss_vf_conf *)p->data;
  2126. for (vf = 0; vf < vfcount; vf++) {
  2127. t4_read_rss_vf_config(adapter, vf, &vfconf[vf].rss_vf_vfl,
  2128. &vfconf[vf].rss_vf_vfh, true);
  2129. }
  2130. return 0;
  2131. }
  2132. static const struct file_operations rss_vf_config_debugfs_fops = {
  2133. .owner = THIS_MODULE,
  2134. .open = rss_vf_config_open,
  2135. .read = seq_read,
  2136. .llseek = seq_lseek,
  2137. .release = seq_release_private
  2138. };
  2139. #ifdef CONFIG_CHELSIO_T4_DCB
  2140. extern char *dcb_ver_array[];
  2141. /* Data Center Briging information for each port.
  2142. */
  2143. static int dcb_info_show(struct seq_file *seq, void *v)
  2144. {
  2145. struct adapter *adap = seq->private;
  2146. if (v == SEQ_START_TOKEN) {
  2147. seq_puts(seq, "Data Center Bridging Information\n");
  2148. } else {
  2149. int port = (uintptr_t)v - 2;
  2150. struct net_device *dev = adap->port[port];
  2151. struct port_info *pi = netdev2pinfo(dev);
  2152. struct port_dcb_info *dcb = &pi->dcb;
  2153. seq_puts(seq, "\n");
  2154. seq_printf(seq, "Port: %d (DCB negotiated: %s)\n",
  2155. port,
  2156. cxgb4_dcb_enabled(dev) ? "yes" : "no");
  2157. if (cxgb4_dcb_enabled(dev))
  2158. seq_printf(seq, "[ DCBx Version %s ]\n",
  2159. dcb_ver_array[dcb->dcb_version]);
  2160. if (dcb->msgs) {
  2161. int i;
  2162. seq_puts(seq, "\n Index\t\t\t :\t");
  2163. for (i = 0; i < 8; i++)
  2164. seq_printf(seq, " %3d", i);
  2165. seq_puts(seq, "\n\n");
  2166. }
  2167. if (dcb->msgs & CXGB4_DCB_FW_PGID) {
  2168. int prio, pgid;
  2169. seq_puts(seq, " Priority Group IDs\t :\t");
  2170. for (prio = 0; prio < 8; prio++) {
  2171. pgid = (dcb->pgid >> 4 * (7 - prio)) & 0xf;
  2172. seq_printf(seq, " %3d", pgid);
  2173. }
  2174. seq_puts(seq, "\n");
  2175. }
  2176. if (dcb->msgs & CXGB4_DCB_FW_PGRATE) {
  2177. int pg;
  2178. seq_puts(seq, " Priority Group BW(%)\t :\t");
  2179. for (pg = 0; pg < 8; pg++)
  2180. seq_printf(seq, " %3d", dcb->pgrate[pg]);
  2181. seq_puts(seq, "\n");
  2182. if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) {
  2183. seq_puts(seq, " TSA Algorithm\t\t :\t");
  2184. for (pg = 0; pg < 8; pg++)
  2185. seq_printf(seq, " %3d", dcb->tsa[pg]);
  2186. seq_puts(seq, "\n");
  2187. }
  2188. seq_printf(seq, " Max PG Traffic Classes [%3d ]\n",
  2189. dcb->pg_num_tcs_supported);
  2190. seq_puts(seq, "\n");
  2191. }
  2192. if (dcb->msgs & CXGB4_DCB_FW_PRIORATE) {
  2193. int prio;
  2194. seq_puts(seq, " Priority Rate\t:\t");
  2195. for (prio = 0; prio < 8; prio++)
  2196. seq_printf(seq, " %3d", dcb->priorate[prio]);
  2197. seq_puts(seq, "\n");
  2198. }
  2199. if (dcb->msgs & CXGB4_DCB_FW_PFC) {
  2200. int prio;
  2201. seq_puts(seq, " Priority Flow Control :\t");
  2202. for (prio = 0; prio < 8; prio++) {
  2203. int pfcen = (dcb->pfcen >> 1 * (7 - prio))
  2204. & 0x1;
  2205. seq_printf(seq, " %3d", pfcen);
  2206. }
  2207. seq_puts(seq, "\n");
  2208. seq_printf(seq, " Max PFC Traffic Classes [%3d ]\n",
  2209. dcb->pfc_num_tcs_supported);
  2210. seq_puts(seq, "\n");
  2211. }
  2212. if (dcb->msgs & CXGB4_DCB_FW_APP_ID) {
  2213. int app, napps;
  2214. seq_puts(seq, " Application Information:\n");
  2215. seq_puts(seq, " App Priority Selection Protocol\n");
  2216. seq_puts(seq, " Index Map Field ID\n");
  2217. for (app = 0, napps = 0;
  2218. app < CXGB4_MAX_DCBX_APP_SUPPORTED; app++) {
  2219. struct app_priority *ap;
  2220. static const char * const sel_names[] = {
  2221. "Ethertype",
  2222. "Socket TCP",
  2223. "Socket UDP",
  2224. "Socket All",
  2225. };
  2226. const char *sel_name;
  2227. ap = &dcb->app_priority[app];
  2228. /* skip empty slots */
  2229. if (ap->protocolid == 0)
  2230. continue;
  2231. napps++;
  2232. if (ap->sel_field < ARRAY_SIZE(sel_names))
  2233. sel_name = sel_names[ap->sel_field];
  2234. else
  2235. sel_name = "UNKNOWN";
  2236. seq_printf(seq, " %3d %#04x %-10s (%d) %#06x (%d)\n",
  2237. app,
  2238. ap->user_prio_map,
  2239. sel_name, ap->sel_field,
  2240. ap->protocolid, ap->protocolid);
  2241. }
  2242. if (napps == 0)
  2243. seq_puts(seq, " --- None ---\n");
  2244. }
  2245. }
  2246. return 0;
  2247. }
  2248. static inline void *dcb_info_get_idx(struct adapter *adap, loff_t pos)
  2249. {
  2250. return (pos <= adap->params.nports
  2251. ? (void *)((uintptr_t)pos + 1)
  2252. : NULL);
  2253. }
  2254. static void *dcb_info_start(struct seq_file *seq, loff_t *pos)
  2255. {
  2256. struct adapter *adap = seq->private;
  2257. return (*pos
  2258. ? dcb_info_get_idx(adap, *pos)
  2259. : SEQ_START_TOKEN);
  2260. }
  2261. static void dcb_info_stop(struct seq_file *seq, void *v)
  2262. {
  2263. }
  2264. static void *dcb_info_next(struct seq_file *seq, void *v, loff_t *pos)
  2265. {
  2266. struct adapter *adap = seq->private;
  2267. (*pos)++;
  2268. return dcb_info_get_idx(adap, *pos);
  2269. }
  2270. static const struct seq_operations dcb_info_seq_ops = {
  2271. .start = dcb_info_start,
  2272. .next = dcb_info_next,
  2273. .stop = dcb_info_stop,
  2274. .show = dcb_info_show
  2275. };
  2276. static int dcb_info_open(struct inode *inode, struct file *file)
  2277. {
  2278. int res = seq_open(file, &dcb_info_seq_ops);
  2279. if (!res) {
  2280. struct seq_file *seq = file->private_data;
  2281. seq->private = inode->i_private;
  2282. }
  2283. return res;
  2284. }
  2285. static const struct file_operations dcb_info_debugfs_fops = {
  2286. .owner = THIS_MODULE,
  2287. .open = dcb_info_open,
  2288. .read = seq_read,
  2289. .llseek = seq_lseek,
  2290. .release = seq_release,
  2291. };
  2292. #endif /* CONFIG_CHELSIO_T4_DCB */
  2293. static int resources_show(struct seq_file *seq, void *v)
  2294. {
  2295. struct adapter *adapter = seq->private;
  2296. struct pf_resources *pfres = &adapter->params.pfres;
  2297. #define S(desc, fmt, var) \
  2298. seq_printf(seq, "%-60s " fmt "\n", \
  2299. desc " (" #var "):", pfres->var)
  2300. S("Virtual Interfaces", "%d", nvi);
  2301. S("Egress Queues", "%d", neq);
  2302. S("Ethernet Control", "%d", nethctrl);
  2303. S("Ingress Queues/w Free Lists/Interrupts", "%d", niqflint);
  2304. S("Ingress Queues", "%d", niq);
  2305. S("Traffic Class", "%d", tc);
  2306. S("Port Access Rights Mask", "%#x", pmask);
  2307. S("MAC Address Filters", "%d", nexactf);
  2308. S("Firmware Command Read Capabilities", "%#x", r_caps);
  2309. S("Firmware Command Write/Execute Capabilities", "%#x", wx_caps);
  2310. #undef S
  2311. return 0;
  2312. }
  2313. static int resources_open(struct inode *inode, struct file *file)
  2314. {
  2315. return single_open(file, resources_show, inode->i_private);
  2316. }
  2317. static const struct file_operations resources_debugfs_fops = {
  2318. .owner = THIS_MODULE,
  2319. .open = resources_open,
  2320. .read = seq_read,
  2321. .llseek = seq_lseek,
  2322. .release = seq_release,
  2323. };
  2324. /**
  2325. * ethqset2pinfo - return port_info of an Ethernet Queue Set
  2326. * @adap: the adapter
  2327. * @qset: Ethernet Queue Set
  2328. */
  2329. static inline struct port_info *ethqset2pinfo(struct adapter *adap, int qset)
  2330. {
  2331. int pidx;
  2332. for_each_port(adap, pidx) {
  2333. struct port_info *pi = adap2pinfo(adap, pidx);
  2334. if (qset >= pi->first_qset &&
  2335. qset < pi->first_qset + pi->nqsets)
  2336. return pi;
  2337. }
  2338. /* should never happen! */
  2339. BUG_ON(1);
  2340. return NULL;
  2341. }
  2342. static int sge_qinfo_uld_txq_entries(const struct adapter *adap, int uld)
  2343. {
  2344. const struct sge_uld_txq_info *utxq_info = adap->sge.uld_txq_info[uld];
  2345. if (!utxq_info)
  2346. return 0;
  2347. return DIV_ROUND_UP(utxq_info->ntxq, 4);
  2348. }
  2349. static int sge_qinfo_uld_rspq_entries(const struct adapter *adap, int uld,
  2350. bool ciq)
  2351. {
  2352. const struct sge_uld_rxq_info *urxq_info = adap->sge.uld_rxq_info[uld];
  2353. if (!urxq_info)
  2354. return 0;
  2355. return ciq ? DIV_ROUND_UP(urxq_info->nciq, 4) :
  2356. DIV_ROUND_UP(urxq_info->nrxq, 4);
  2357. }
  2358. static int sge_qinfo_uld_rxq_entries(const struct adapter *adap, int uld)
  2359. {
  2360. return sge_qinfo_uld_rspq_entries(adap, uld, false);
  2361. }
  2362. static int sge_qinfo_uld_ciq_entries(const struct adapter *adap, int uld)
  2363. {
  2364. return sge_qinfo_uld_rspq_entries(adap, uld, true);
  2365. }
  2366. static int sge_qinfo_show(struct seq_file *seq, void *v)
  2367. {
  2368. int uld_rxq_entries[CXGB4_ULD_MAX] = { 0 };
  2369. int uld_ciq_entries[CXGB4_ULD_MAX] = { 0 };
  2370. int uld_txq_entries[CXGB4_TX_MAX] = { 0 };
  2371. const struct sge_uld_txq_info *utxq_info;
  2372. const struct sge_uld_rxq_info *urxq_info;
  2373. struct adapter *adap = seq->private;
  2374. int i, n, r = (uintptr_t)v - 1;
  2375. int eth_entries, ctrl_entries;
  2376. struct sge *s = &adap->sge;
  2377. eth_entries = DIV_ROUND_UP(adap->sge.ethqsets, 4);
  2378. ctrl_entries = DIV_ROUND_UP(MAX_CTRL_QUEUES, 4);
  2379. mutex_lock(&uld_mutex);
  2380. if (s->uld_txq_info)
  2381. for (i = 0; i < ARRAY_SIZE(uld_txq_entries); i++)
  2382. uld_txq_entries[i] = sge_qinfo_uld_txq_entries(adap, i);
  2383. if (s->uld_rxq_info) {
  2384. for (i = 0; i < ARRAY_SIZE(uld_rxq_entries); i++) {
  2385. uld_rxq_entries[i] = sge_qinfo_uld_rxq_entries(adap, i);
  2386. uld_ciq_entries[i] = sge_qinfo_uld_ciq_entries(adap, i);
  2387. }
  2388. }
  2389. if (r)
  2390. seq_putc(seq, '\n');
  2391. #define S3(fmt_spec, s, v) \
  2392. do { \
  2393. seq_printf(seq, "%-12s", s); \
  2394. for (i = 0; i < n; ++i) \
  2395. seq_printf(seq, " %16" fmt_spec, v); \
  2396. seq_putc(seq, '\n'); \
  2397. } while (0)
  2398. #define S(s, v) S3("s", s, v)
  2399. #define T3(fmt_spec, s, v) S3(fmt_spec, s, tx[i].v)
  2400. #define T(s, v) S3("u", s, tx[i].v)
  2401. #define TL(s, v) T3("lu", s, v)
  2402. #define R3(fmt_spec, s, v) S3(fmt_spec, s, rx[i].v)
  2403. #define R(s, v) S3("u", s, rx[i].v)
  2404. #define RL(s, v) R3("lu", s, v)
  2405. if (r < eth_entries) {
  2406. int base_qset = r * 4;
  2407. const struct sge_eth_rxq *rx = &s->ethrxq[base_qset];
  2408. const struct sge_eth_txq *tx = &s->ethtxq[base_qset];
  2409. n = min(4, s->ethqsets - 4 * r);
  2410. S("QType:", "Ethernet");
  2411. S("Interface:",
  2412. rx[i].rspq.netdev ? rx[i].rspq.netdev->name : "N/A");
  2413. T("TxQ ID:", q.cntxt_id);
  2414. T("TxQ size:", q.size);
  2415. T("TxQ inuse:", q.in_use);
  2416. T("TxQ CIDX:", q.cidx);
  2417. T("TxQ PIDX:", q.pidx);
  2418. #ifdef CONFIG_CHELSIO_T4_DCB
  2419. T("DCB Prio:", dcb_prio);
  2420. S3("u", "DCB PGID:",
  2421. (ethqset2pinfo(adap, base_qset + i)->dcb.pgid >>
  2422. 4*(7-tx[i].dcb_prio)) & 0xf);
  2423. S3("u", "DCB PFC:",
  2424. (ethqset2pinfo(adap, base_qset + i)->dcb.pfcen >>
  2425. 1*(7-tx[i].dcb_prio)) & 0x1);
  2426. #endif
  2427. R("RspQ ID:", rspq.abs_id);
  2428. R("RspQ size:", rspq.size);
  2429. R("RspQE size:", rspq.iqe_len);
  2430. R("RspQ CIDX:", rspq.cidx);
  2431. R("RspQ Gen:", rspq.gen);
  2432. S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
  2433. S3("u", "Intr pktcnt:", s->counter_val[rx[i].rspq.pktcnt_idx]);
  2434. R("FL ID:", fl.cntxt_id);
  2435. R("FL size:", fl.size - 8);
  2436. R("FL pend:", fl.pend_cred);
  2437. R("FL avail:", fl.avail);
  2438. R("FL PIDX:", fl.pidx);
  2439. R("FL CIDX:", fl.cidx);
  2440. RL("RxPackets:", stats.pkts);
  2441. RL("RxCSO:", stats.rx_cso);
  2442. RL("VLANxtract:", stats.vlan_ex);
  2443. RL("LROmerged:", stats.lro_merged);
  2444. RL("LROpackets:", stats.lro_pkts);
  2445. RL("RxDrops:", stats.rx_drops);
  2446. TL("TSO:", tso);
  2447. TL("TxCSO:", tx_cso);
  2448. TL("VLANins:", vlan_ins);
  2449. TL("TxQFull:", q.stops);
  2450. TL("TxQRestarts:", q.restarts);
  2451. TL("TxMapErr:", mapping_err);
  2452. RL("FLAllocErr:", fl.alloc_failed);
  2453. RL("FLLrgAlcErr:", fl.large_alloc_failed);
  2454. RL("FLMapErr:", fl.mapping_err);
  2455. RL("FLLow:", fl.low);
  2456. RL("FLStarving:", fl.starving);
  2457. goto unlock;
  2458. }
  2459. r -= eth_entries;
  2460. if (r < uld_txq_entries[CXGB4_TX_OFLD]) {
  2461. const struct sge_uld_txq *tx;
  2462. utxq_info = s->uld_txq_info[CXGB4_TX_OFLD];
  2463. tx = &utxq_info->uldtxq[r * 4];
  2464. n = min(4, utxq_info->ntxq - 4 * r);
  2465. S("QType:", "OFLD-TXQ");
  2466. T("TxQ ID:", q.cntxt_id);
  2467. T("TxQ size:", q.size);
  2468. T("TxQ inuse:", q.in_use);
  2469. T("TxQ CIDX:", q.cidx);
  2470. T("TxQ PIDX:", q.pidx);
  2471. goto unlock;
  2472. }
  2473. r -= uld_txq_entries[CXGB4_TX_OFLD];
  2474. if (r < uld_rxq_entries[CXGB4_ULD_RDMA]) {
  2475. const struct sge_ofld_rxq *rx;
  2476. urxq_info = s->uld_rxq_info[CXGB4_ULD_RDMA];
  2477. rx = &urxq_info->uldrxq[r * 4];
  2478. n = min(4, urxq_info->nrxq - 4 * r);
  2479. S("QType:", "RDMA-CPL");
  2480. S("Interface:",
  2481. rx[i].rspq.netdev ? rx[i].rspq.netdev->name : "N/A");
  2482. R("RspQ ID:", rspq.abs_id);
  2483. R("RspQ size:", rspq.size);
  2484. R("RspQE size:", rspq.iqe_len);
  2485. R("RspQ CIDX:", rspq.cidx);
  2486. R("RspQ Gen:", rspq.gen);
  2487. S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
  2488. S3("u", "Intr pktcnt:", s->counter_val[rx[i].rspq.pktcnt_idx]);
  2489. R("FL ID:", fl.cntxt_id);
  2490. R("FL size:", fl.size - 8);
  2491. R("FL pend:", fl.pend_cred);
  2492. R("FL avail:", fl.avail);
  2493. R("FL PIDX:", fl.pidx);
  2494. R("FL CIDX:", fl.cidx);
  2495. goto unlock;
  2496. }
  2497. r -= uld_rxq_entries[CXGB4_ULD_RDMA];
  2498. if (r < uld_ciq_entries[CXGB4_ULD_RDMA]) {
  2499. const struct sge_ofld_rxq *rx;
  2500. int ciq_idx = 0;
  2501. urxq_info = s->uld_rxq_info[CXGB4_ULD_RDMA];
  2502. ciq_idx = urxq_info->nrxq + (r * 4);
  2503. rx = &urxq_info->uldrxq[ciq_idx];
  2504. n = min(4, urxq_info->nciq - 4 * r);
  2505. S("QType:", "RDMA-CIQ");
  2506. S("Interface:",
  2507. rx[i].rspq.netdev ? rx[i].rspq.netdev->name : "N/A");
  2508. R("RspQ ID:", rspq.abs_id);
  2509. R("RspQ size:", rspq.size);
  2510. R("RspQE size:", rspq.iqe_len);
  2511. R("RspQ CIDX:", rspq.cidx);
  2512. R("RspQ Gen:", rspq.gen);
  2513. S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
  2514. S3("u", "Intr pktcnt:", s->counter_val[rx[i].rspq.pktcnt_idx]);
  2515. goto unlock;
  2516. }
  2517. r -= uld_ciq_entries[CXGB4_ULD_RDMA];
  2518. if (r < uld_rxq_entries[CXGB4_ULD_ISCSI]) {
  2519. const struct sge_ofld_rxq *rx;
  2520. urxq_info = s->uld_rxq_info[CXGB4_ULD_ISCSI];
  2521. rx = &urxq_info->uldrxq[r * 4];
  2522. n = min(4, urxq_info->nrxq - 4 * r);
  2523. S("QType:", "iSCSI");
  2524. R("RspQ ID:", rspq.abs_id);
  2525. R("RspQ size:", rspq.size);
  2526. R("RspQE size:", rspq.iqe_len);
  2527. R("RspQ CIDX:", rspq.cidx);
  2528. R("RspQ Gen:", rspq.gen);
  2529. S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
  2530. S3("u", "Intr pktcnt:", s->counter_val[rx[i].rspq.pktcnt_idx]);
  2531. R("FL ID:", fl.cntxt_id);
  2532. R("FL size:", fl.size - 8);
  2533. R("FL pend:", fl.pend_cred);
  2534. R("FL avail:", fl.avail);
  2535. R("FL PIDX:", fl.pidx);
  2536. R("FL CIDX:", fl.cidx);
  2537. goto unlock;
  2538. }
  2539. r -= uld_rxq_entries[CXGB4_ULD_ISCSI];
  2540. if (r < uld_rxq_entries[CXGB4_ULD_ISCSIT]) {
  2541. const struct sge_ofld_rxq *rx;
  2542. urxq_info = s->uld_rxq_info[CXGB4_ULD_ISCSIT];
  2543. rx = &urxq_info->uldrxq[r * 4];
  2544. n = min(4, urxq_info->nrxq - 4 * r);
  2545. S("QType:", "iSCSIT");
  2546. R("RspQ ID:", rspq.abs_id);
  2547. R("RspQ size:", rspq.size);
  2548. R("RspQE size:", rspq.iqe_len);
  2549. R("RspQ CIDX:", rspq.cidx);
  2550. R("RspQ Gen:", rspq.gen);
  2551. S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
  2552. S3("u", "Intr pktcnt:", s->counter_val[rx[i].rspq.pktcnt_idx]);
  2553. R("FL ID:", fl.cntxt_id);
  2554. R("FL size:", fl.size - 8);
  2555. R("FL pend:", fl.pend_cred);
  2556. R("FL avail:", fl.avail);
  2557. R("FL PIDX:", fl.pidx);
  2558. R("FL CIDX:", fl.cidx);
  2559. goto unlock;
  2560. }
  2561. r -= uld_rxq_entries[CXGB4_ULD_ISCSIT];
  2562. if (r < uld_rxq_entries[CXGB4_ULD_TLS]) {
  2563. const struct sge_ofld_rxq *rx;
  2564. urxq_info = s->uld_rxq_info[CXGB4_ULD_TLS];
  2565. rx = &urxq_info->uldrxq[r * 4];
  2566. n = min(4, urxq_info->nrxq - 4 * r);
  2567. S("QType:", "TLS");
  2568. R("RspQ ID:", rspq.abs_id);
  2569. R("RspQ size:", rspq.size);
  2570. R("RspQE size:", rspq.iqe_len);
  2571. R("RspQ CIDX:", rspq.cidx);
  2572. R("RspQ Gen:", rspq.gen);
  2573. S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
  2574. S3("u", "Intr pktcnt:", s->counter_val[rx[i].rspq.pktcnt_idx]);
  2575. R("FL ID:", fl.cntxt_id);
  2576. R("FL size:", fl.size - 8);
  2577. R("FL pend:", fl.pend_cred);
  2578. R("FL avail:", fl.avail);
  2579. R("FL PIDX:", fl.pidx);
  2580. R("FL CIDX:", fl.cidx);
  2581. goto unlock;
  2582. }
  2583. r -= uld_rxq_entries[CXGB4_ULD_TLS];
  2584. if (r < uld_txq_entries[CXGB4_TX_CRYPTO]) {
  2585. const struct sge_ofld_rxq *rx;
  2586. const struct sge_uld_txq *tx;
  2587. utxq_info = s->uld_txq_info[CXGB4_TX_CRYPTO];
  2588. urxq_info = s->uld_rxq_info[CXGB4_ULD_CRYPTO];
  2589. tx = &utxq_info->uldtxq[r * 4];
  2590. rx = &urxq_info->uldrxq[r * 4];
  2591. n = min(4, utxq_info->ntxq - 4 * r);
  2592. S("QType:", "Crypto");
  2593. T("TxQ ID:", q.cntxt_id);
  2594. T("TxQ size:", q.size);
  2595. T("TxQ inuse:", q.in_use);
  2596. T("TxQ CIDX:", q.cidx);
  2597. T("TxQ PIDX:", q.pidx);
  2598. R("RspQ ID:", rspq.abs_id);
  2599. R("RspQ size:", rspq.size);
  2600. R("RspQE size:", rspq.iqe_len);
  2601. R("RspQ CIDX:", rspq.cidx);
  2602. R("RspQ Gen:", rspq.gen);
  2603. S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
  2604. S3("u", "Intr pktcnt:", s->counter_val[rx[i].rspq.pktcnt_idx]);
  2605. R("FL ID:", fl.cntxt_id);
  2606. R("FL size:", fl.size - 8);
  2607. R("FL pend:", fl.pend_cred);
  2608. R("FL avail:", fl.avail);
  2609. R("FL PIDX:", fl.pidx);
  2610. R("FL CIDX:", fl.cidx);
  2611. goto unlock;
  2612. }
  2613. r -= uld_txq_entries[CXGB4_TX_CRYPTO];
  2614. if (r < ctrl_entries) {
  2615. const struct sge_ctrl_txq *tx = &s->ctrlq[r * 4];
  2616. n = min(4, adap->params.nports - 4 * r);
  2617. S("QType:", "Control");
  2618. T("TxQ ID:", q.cntxt_id);
  2619. T("TxQ size:", q.size);
  2620. T("TxQ inuse:", q.in_use);
  2621. T("TxQ CIDX:", q.cidx);
  2622. T("TxQ PIDX:", q.pidx);
  2623. TL("TxQFull:", q.stops);
  2624. TL("TxQRestarts:", q.restarts);
  2625. goto unlock;
  2626. }
  2627. r -= ctrl_entries;
  2628. if (r < 1) {
  2629. const struct sge_rspq *evtq = &s->fw_evtq;
  2630. seq_printf(seq, "%-12s %16s\n", "QType:", "FW event queue");
  2631. seq_printf(seq, "%-12s %16u\n", "RspQ ID:", evtq->abs_id);
  2632. seq_printf(seq, "%-12s %16u\n", "RspQ size:", evtq->size);
  2633. seq_printf(seq, "%-12s %16u\n", "RspQE size:", evtq->iqe_len);
  2634. seq_printf(seq, "%-12s %16u\n", "RspQ CIDX:", evtq->cidx);
  2635. seq_printf(seq, "%-12s %16u\n", "RspQ Gen:", evtq->gen);
  2636. seq_printf(seq, "%-12s %16u\n", "Intr delay:",
  2637. qtimer_val(adap, evtq));
  2638. seq_printf(seq, "%-12s %16u\n", "Intr pktcnt:",
  2639. s->counter_val[evtq->pktcnt_idx]);
  2640. goto unlock;
  2641. }
  2642. unlock:
  2643. mutex_unlock(&uld_mutex);
  2644. #undef R
  2645. #undef RL
  2646. #undef T
  2647. #undef TL
  2648. #undef S
  2649. #undef R3
  2650. #undef T3
  2651. #undef S3
  2652. return 0;
  2653. }
  2654. static int sge_queue_entries(const struct adapter *adap)
  2655. {
  2656. int tot_uld_entries = 0;
  2657. int i;
  2658. if (!is_uld(adap))
  2659. goto lld_only;
  2660. mutex_lock(&uld_mutex);
  2661. for (i = 0; i < CXGB4_TX_MAX; i++)
  2662. tot_uld_entries += sge_qinfo_uld_txq_entries(adap, i);
  2663. for (i = 0; i < CXGB4_ULD_MAX; i++) {
  2664. tot_uld_entries += sge_qinfo_uld_rxq_entries(adap, i);
  2665. tot_uld_entries += sge_qinfo_uld_ciq_entries(adap, i);
  2666. }
  2667. mutex_unlock(&uld_mutex);
  2668. lld_only:
  2669. return DIV_ROUND_UP(adap->sge.ethqsets, 4) +
  2670. tot_uld_entries +
  2671. DIV_ROUND_UP(MAX_CTRL_QUEUES, 4) + 1;
  2672. }
  2673. static void *sge_queue_start(struct seq_file *seq, loff_t *pos)
  2674. {
  2675. int entries = sge_queue_entries(seq->private);
  2676. return *pos < entries ? (void *)((uintptr_t)*pos + 1) : NULL;
  2677. }
  2678. static void sge_queue_stop(struct seq_file *seq, void *v)
  2679. {
  2680. }
  2681. static void *sge_queue_next(struct seq_file *seq, void *v, loff_t *pos)
  2682. {
  2683. int entries = sge_queue_entries(seq->private);
  2684. ++*pos;
  2685. return *pos < entries ? (void *)((uintptr_t)*pos + 1) : NULL;
  2686. }
  2687. static const struct seq_operations sge_qinfo_seq_ops = {
  2688. .start = sge_queue_start,
  2689. .next = sge_queue_next,
  2690. .stop = sge_queue_stop,
  2691. .show = sge_qinfo_show
  2692. };
  2693. static int sge_qinfo_open(struct inode *inode, struct file *file)
  2694. {
  2695. int res = seq_open(file, &sge_qinfo_seq_ops);
  2696. if (!res) {
  2697. struct seq_file *seq = file->private_data;
  2698. seq->private = inode->i_private;
  2699. }
  2700. return res;
  2701. }
  2702. static const struct file_operations sge_qinfo_debugfs_fops = {
  2703. .owner = THIS_MODULE,
  2704. .open = sge_qinfo_open,
  2705. .read = seq_read,
  2706. .llseek = seq_lseek,
  2707. .release = seq_release,
  2708. };
  2709. int mem_open(struct inode *inode, struct file *file)
  2710. {
  2711. unsigned int mem;
  2712. struct adapter *adap;
  2713. file->private_data = inode->i_private;
  2714. mem = (uintptr_t)file->private_data & 0x7;
  2715. adap = file->private_data - mem;
  2716. (void)t4_fwcache(adap, FW_PARAM_DEV_FWCACHE_FLUSH);
  2717. return 0;
  2718. }
  2719. static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
  2720. loff_t *ppos)
  2721. {
  2722. loff_t pos = *ppos;
  2723. loff_t avail = file_inode(file)->i_size;
  2724. unsigned int mem = (uintptr_t)file->private_data & 0x7;
  2725. struct adapter *adap = file->private_data - mem;
  2726. __be32 *data;
  2727. int ret;
  2728. if (pos < 0)
  2729. return -EINVAL;
  2730. if (pos >= avail)
  2731. return 0;
  2732. if (count > avail - pos)
  2733. count = avail - pos;
  2734. data = kvzalloc(count, GFP_KERNEL);
  2735. if (!data)
  2736. return -ENOMEM;
  2737. spin_lock(&adap->win0_lock);
  2738. ret = t4_memory_rw(adap, 0, mem, pos, count, data, T4_MEMORY_READ);
  2739. spin_unlock(&adap->win0_lock);
  2740. if (ret) {
  2741. kvfree(data);
  2742. return ret;
  2743. }
  2744. ret = copy_to_user(buf, data, count);
  2745. kvfree(data);
  2746. if (ret)
  2747. return -EFAULT;
  2748. *ppos = pos + count;
  2749. return count;
  2750. }
  2751. static const struct file_operations mem_debugfs_fops = {
  2752. .owner = THIS_MODULE,
  2753. .open = simple_open,
  2754. .read = mem_read,
  2755. .llseek = default_llseek,
  2756. };
  2757. static int tid_info_show(struct seq_file *seq, void *v)
  2758. {
  2759. unsigned int tid_start = 0;
  2760. struct adapter *adap = seq->private;
  2761. const struct tid_info *t = &adap->tids;
  2762. enum chip_type chip = CHELSIO_CHIP_VERSION(adap->params.chip);
  2763. if (chip > CHELSIO_T5)
  2764. tid_start = t4_read_reg(adap, LE_DB_ACTIVE_TABLE_START_INDEX_A);
  2765. if (t4_read_reg(adap, LE_DB_CONFIG_A) & HASHEN_F) {
  2766. unsigned int sb;
  2767. seq_printf(seq, "Connections in use: %u\n",
  2768. atomic_read(&t->conns_in_use));
  2769. if (chip <= CHELSIO_T5)
  2770. sb = t4_read_reg(adap, LE_DB_SERVER_INDEX_A) / 4;
  2771. else
  2772. sb = t4_read_reg(adap, LE_DB_SRVR_START_INDEX_A);
  2773. if (sb) {
  2774. seq_printf(seq, "TID range: %u..%u/%u..%u", tid_start,
  2775. sb - 1, adap->tids.hash_base,
  2776. t->ntids - 1);
  2777. seq_printf(seq, ", in use: %u/%u\n",
  2778. atomic_read(&t->tids_in_use),
  2779. atomic_read(&t->hash_tids_in_use));
  2780. } else if (adap->flags & FW_OFLD_CONN) {
  2781. seq_printf(seq, "TID range: %u..%u/%u..%u",
  2782. t->aftid_base,
  2783. t->aftid_end,
  2784. adap->tids.hash_base,
  2785. t->ntids - 1);
  2786. seq_printf(seq, ", in use: %u/%u\n",
  2787. atomic_read(&t->tids_in_use),
  2788. atomic_read(&t->hash_tids_in_use));
  2789. } else {
  2790. seq_printf(seq, "TID range: %u..%u",
  2791. adap->tids.hash_base,
  2792. t->ntids - 1);
  2793. seq_printf(seq, ", in use: %u\n",
  2794. atomic_read(&t->hash_tids_in_use));
  2795. }
  2796. } else if (t->ntids) {
  2797. seq_printf(seq, "Connections in use: %u\n",
  2798. atomic_read(&t->conns_in_use));
  2799. seq_printf(seq, "TID range: %u..%u", tid_start,
  2800. tid_start + t->ntids - 1);
  2801. seq_printf(seq, ", in use: %u\n",
  2802. atomic_read(&t->tids_in_use));
  2803. }
  2804. if (t->nstids)
  2805. seq_printf(seq, "STID range: %u..%u, in use-IPv4/IPv6: %u/%u\n",
  2806. (!t->stid_base &&
  2807. (chip <= CHELSIO_T5)) ?
  2808. t->stid_base + 1 : t->stid_base,
  2809. t->stid_base + t->nstids - 1,
  2810. t->stids_in_use - t->v6_stids_in_use,
  2811. t->v6_stids_in_use);
  2812. if (t->natids)
  2813. seq_printf(seq, "ATID range: 0..%u, in use: %u\n",
  2814. t->natids - 1, t->atids_in_use);
  2815. seq_printf(seq, "FTID range: %u..%u\n", t->ftid_base,
  2816. t->ftid_base + t->nftids - 1);
  2817. if (t->nsftids)
  2818. seq_printf(seq, "SFTID range: %u..%u in use: %u\n",
  2819. t->sftid_base, t->sftid_base + t->nsftids - 2,
  2820. t->sftids_in_use);
  2821. if (t->ntids)
  2822. seq_printf(seq, "HW TID usage: %u IP users, %u IPv6 users\n",
  2823. t4_read_reg(adap, LE_DB_ACT_CNT_IPV4_A),
  2824. t4_read_reg(adap, LE_DB_ACT_CNT_IPV6_A));
  2825. return 0;
  2826. }
  2827. DEFINE_SIMPLE_DEBUGFS_FILE(tid_info);
  2828. static void add_debugfs_mem(struct adapter *adap, const char *name,
  2829. unsigned int idx, unsigned int size_mb)
  2830. {
  2831. debugfs_create_file_size(name, 0400, adap->debugfs_root,
  2832. (void *)adap + idx, &mem_debugfs_fops,
  2833. size_mb << 20);
  2834. }
  2835. static ssize_t blocked_fl_read(struct file *filp, char __user *ubuf,
  2836. size_t count, loff_t *ppos)
  2837. {
  2838. int len;
  2839. const struct adapter *adap = filp->private_data;
  2840. char *buf;
  2841. ssize_t size = (adap->sge.egr_sz + 3) / 4 +
  2842. adap->sge.egr_sz / 32 + 2; /* includes ,/\n/\0 */
  2843. buf = kzalloc(size, GFP_KERNEL);
  2844. if (!buf)
  2845. return -ENOMEM;
  2846. len = snprintf(buf, size - 1, "%*pb\n",
  2847. adap->sge.egr_sz, adap->sge.blocked_fl);
  2848. len += sprintf(buf + len, "\n");
  2849. size = simple_read_from_buffer(ubuf, count, ppos, buf, len);
  2850. kvfree(buf);
  2851. return size;
  2852. }
  2853. static ssize_t blocked_fl_write(struct file *filp, const char __user *ubuf,
  2854. size_t count, loff_t *ppos)
  2855. {
  2856. int err;
  2857. unsigned long *t;
  2858. struct adapter *adap = filp->private_data;
  2859. t = kcalloc(BITS_TO_LONGS(adap->sge.egr_sz), sizeof(long), GFP_KERNEL);
  2860. if (!t)
  2861. return -ENOMEM;
  2862. err = bitmap_parse_user(ubuf, count, t, adap->sge.egr_sz);
  2863. if (err) {
  2864. kvfree(t);
  2865. return err;
  2866. }
  2867. bitmap_copy(adap->sge.blocked_fl, t, adap->sge.egr_sz);
  2868. kvfree(t);
  2869. return count;
  2870. }
  2871. static const struct file_operations blocked_fl_fops = {
  2872. .owner = THIS_MODULE,
  2873. .open = simple_open,
  2874. .read = blocked_fl_read,
  2875. .write = blocked_fl_write,
  2876. .llseek = generic_file_llseek,
  2877. };
  2878. static void mem_region_show(struct seq_file *seq, const char *name,
  2879. unsigned int from, unsigned int to)
  2880. {
  2881. char buf[40];
  2882. string_get_size((u64)to - from + 1, 1, STRING_UNITS_2, buf,
  2883. sizeof(buf));
  2884. seq_printf(seq, "%-15s %#x-%#x [%s]\n", name, from, to, buf);
  2885. }
  2886. static int meminfo_show(struct seq_file *seq, void *v)
  2887. {
  2888. static const char * const memory[] = { "EDC0:", "EDC1:", "MC:",
  2889. "MC0:", "MC1:", "HMA:"};
  2890. struct adapter *adap = seq->private;
  2891. struct cudbg_meminfo meminfo;
  2892. int i, rc;
  2893. memset(&meminfo, 0, sizeof(struct cudbg_meminfo));
  2894. rc = cudbg_fill_meminfo(adap, &meminfo);
  2895. if (rc)
  2896. return -ENXIO;
  2897. for (i = 0; i < meminfo.avail_c; i++)
  2898. mem_region_show(seq, memory[meminfo.avail[i].idx],
  2899. meminfo.avail[i].base,
  2900. meminfo.avail[i].limit - 1);
  2901. seq_putc(seq, '\n');
  2902. for (i = 0; i < meminfo.mem_c; i++) {
  2903. if (meminfo.mem[i].idx >= ARRAY_SIZE(cudbg_region))
  2904. continue; /* skip holes */
  2905. if (!meminfo.mem[i].limit)
  2906. meminfo.mem[i].limit =
  2907. i < meminfo.mem_c - 1 ?
  2908. meminfo.mem[i + 1].base - 1 : ~0;
  2909. mem_region_show(seq, cudbg_region[meminfo.mem[i].idx],
  2910. meminfo.mem[i].base, meminfo.mem[i].limit);
  2911. }
  2912. seq_putc(seq, '\n');
  2913. mem_region_show(seq, "uP RAM:", meminfo.up_ram_lo, meminfo.up_ram_hi);
  2914. mem_region_show(seq, "uP Extmem2:", meminfo.up_extmem2_lo,
  2915. meminfo.up_extmem2_hi);
  2916. seq_printf(seq, "\n%u Rx pages (%u free) of size %uKiB for %u channels\n",
  2917. meminfo.rx_pages_data[0], meminfo.free_rx_cnt,
  2918. meminfo.rx_pages_data[1], meminfo.rx_pages_data[2]);
  2919. seq_printf(seq, "%u Tx pages (%u free) of size %u%ciB for %u channels\n",
  2920. meminfo.tx_pages_data[0], meminfo.free_tx_cnt,
  2921. meminfo.tx_pages_data[1], meminfo.tx_pages_data[2],
  2922. meminfo.tx_pages_data[3]);
  2923. seq_printf(seq, "%u p-structs (%u free)\n\n",
  2924. meminfo.p_structs, meminfo.p_structs_free_cnt);
  2925. for (i = 0; i < 4; i++)
  2926. /* For T6 these are MAC buffer groups */
  2927. seq_printf(seq, "Port %d using %u pages out of %u allocated\n",
  2928. i, meminfo.port_used[i], meminfo.port_alloc[i]);
  2929. for (i = 0; i < adap->params.arch.nchan; i++)
  2930. /* For T6 these are MAC buffer groups */
  2931. seq_printf(seq,
  2932. "Loopback %d using %u pages out of %u allocated\n",
  2933. i, meminfo.loopback_used[i],
  2934. meminfo.loopback_alloc[i]);
  2935. return 0;
  2936. }
  2937. static int meminfo_open(struct inode *inode, struct file *file)
  2938. {
  2939. return single_open(file, meminfo_show, inode->i_private);
  2940. }
  2941. static const struct file_operations meminfo_fops = {
  2942. .owner = THIS_MODULE,
  2943. .open = meminfo_open,
  2944. .read = seq_read,
  2945. .llseek = seq_lseek,
  2946. .release = single_release,
  2947. };
  2948. static int chcr_show(struct seq_file *seq, void *v)
  2949. {
  2950. struct adapter *adap = seq->private;
  2951. seq_puts(seq, "Chelsio Crypto Accelerator Stats \n");
  2952. seq_printf(seq, "Cipher Ops: %10u \n",
  2953. atomic_read(&adap->chcr_stats.cipher_rqst));
  2954. seq_printf(seq, "Digest Ops: %10u \n",
  2955. atomic_read(&adap->chcr_stats.digest_rqst));
  2956. seq_printf(seq, "Aead Ops: %10u \n",
  2957. atomic_read(&adap->chcr_stats.aead_rqst));
  2958. seq_printf(seq, "Completion: %10u \n",
  2959. atomic_read(&adap->chcr_stats.complete));
  2960. seq_printf(seq, "Error: %10u \n",
  2961. atomic_read(&adap->chcr_stats.error));
  2962. seq_printf(seq, "Fallback: %10u \n",
  2963. atomic_read(&adap->chcr_stats.fallback));
  2964. seq_printf(seq, "IPSec PDU: %10u\n",
  2965. atomic_read(&adap->chcr_stats.ipsec_cnt));
  2966. return 0;
  2967. }
  2968. static int chcr_stats_open(struct inode *inode, struct file *file)
  2969. {
  2970. return single_open(file, chcr_show, inode->i_private);
  2971. }
  2972. static const struct file_operations chcr_stats_debugfs_fops = {
  2973. .owner = THIS_MODULE,
  2974. .open = chcr_stats_open,
  2975. .read = seq_read,
  2976. .llseek = seq_lseek,
  2977. .release = single_release,
  2978. };
  2979. #define PRINT_ADAP_STATS(string, value) \
  2980. seq_printf(seq, "%-25s %-20llu\n", (string), \
  2981. (unsigned long long)(value))
  2982. #define PRINT_CH_STATS(string, value) \
  2983. do { \
  2984. seq_printf(seq, "%-25s ", (string)); \
  2985. for (i = 0; i < adap->params.arch.nchan; i++) \
  2986. seq_printf(seq, "%-20llu ", \
  2987. (unsigned long long)stats.value[i]); \
  2988. seq_printf(seq, "\n"); \
  2989. } while (0)
  2990. #define PRINT_CH_STATS2(string, value) \
  2991. do { \
  2992. seq_printf(seq, "%-25s ", (string)); \
  2993. for (i = 0; i < adap->params.arch.nchan; i++) \
  2994. seq_printf(seq, "%-20llu ", \
  2995. (unsigned long long)stats[i].value); \
  2996. seq_printf(seq, "\n"); \
  2997. } while (0)
  2998. static void show_tcp_stats(struct seq_file *seq)
  2999. {
  3000. struct adapter *adap = seq->private;
  3001. struct tp_tcp_stats v4, v6;
  3002. spin_lock(&adap->stats_lock);
  3003. t4_tp_get_tcp_stats(adap, &v4, &v6, false);
  3004. spin_unlock(&adap->stats_lock);
  3005. PRINT_ADAP_STATS("tcp_ipv4_out_rsts:", v4.tcp_out_rsts);
  3006. PRINT_ADAP_STATS("tcp_ipv4_in_segs:", v4.tcp_in_segs);
  3007. PRINT_ADAP_STATS("tcp_ipv4_out_segs:", v4.tcp_out_segs);
  3008. PRINT_ADAP_STATS("tcp_ipv4_retrans_segs:", v4.tcp_retrans_segs);
  3009. PRINT_ADAP_STATS("tcp_ipv6_out_rsts:", v6.tcp_out_rsts);
  3010. PRINT_ADAP_STATS("tcp_ipv6_in_segs:", v6.tcp_in_segs);
  3011. PRINT_ADAP_STATS("tcp_ipv6_out_segs:", v6.tcp_out_segs);
  3012. PRINT_ADAP_STATS("tcp_ipv6_retrans_segs:", v6.tcp_retrans_segs);
  3013. }
  3014. static void show_ddp_stats(struct seq_file *seq)
  3015. {
  3016. struct adapter *adap = seq->private;
  3017. struct tp_usm_stats stats;
  3018. spin_lock(&adap->stats_lock);
  3019. t4_get_usm_stats(adap, &stats, false);
  3020. spin_unlock(&adap->stats_lock);
  3021. PRINT_ADAP_STATS("usm_ddp_frames:", stats.frames);
  3022. PRINT_ADAP_STATS("usm_ddp_octets:", stats.octets);
  3023. PRINT_ADAP_STATS("usm_ddp_drops:", stats.drops);
  3024. }
  3025. static void show_rdma_stats(struct seq_file *seq)
  3026. {
  3027. struct adapter *adap = seq->private;
  3028. struct tp_rdma_stats stats;
  3029. spin_lock(&adap->stats_lock);
  3030. t4_tp_get_rdma_stats(adap, &stats, false);
  3031. spin_unlock(&adap->stats_lock);
  3032. PRINT_ADAP_STATS("rdma_no_rqe_mod_defer:", stats.rqe_dfr_mod);
  3033. PRINT_ADAP_STATS("rdma_no_rqe_pkt_defer:", stats.rqe_dfr_pkt);
  3034. }
  3035. static void show_tp_err_adapter_stats(struct seq_file *seq)
  3036. {
  3037. struct adapter *adap = seq->private;
  3038. struct tp_err_stats stats;
  3039. spin_lock(&adap->stats_lock);
  3040. t4_tp_get_err_stats(adap, &stats, false);
  3041. spin_unlock(&adap->stats_lock);
  3042. PRINT_ADAP_STATS("tp_err_ofld_no_neigh:", stats.ofld_no_neigh);
  3043. PRINT_ADAP_STATS("tp_err_ofld_cong_defer:", stats.ofld_cong_defer);
  3044. }
  3045. static void show_cpl_stats(struct seq_file *seq)
  3046. {
  3047. struct adapter *adap = seq->private;
  3048. struct tp_cpl_stats stats;
  3049. u8 i;
  3050. spin_lock(&adap->stats_lock);
  3051. t4_tp_get_cpl_stats(adap, &stats, false);
  3052. spin_unlock(&adap->stats_lock);
  3053. PRINT_CH_STATS("tp_cpl_requests:", req);
  3054. PRINT_CH_STATS("tp_cpl_responses:", rsp);
  3055. }
  3056. static void show_tp_err_channel_stats(struct seq_file *seq)
  3057. {
  3058. struct adapter *adap = seq->private;
  3059. struct tp_err_stats stats;
  3060. u8 i;
  3061. spin_lock(&adap->stats_lock);
  3062. t4_tp_get_err_stats(adap, &stats, false);
  3063. spin_unlock(&adap->stats_lock);
  3064. PRINT_CH_STATS("tp_mac_in_errs:", mac_in_errs);
  3065. PRINT_CH_STATS("tp_hdr_in_errs:", hdr_in_errs);
  3066. PRINT_CH_STATS("tp_tcp_in_errs:", tcp_in_errs);
  3067. PRINT_CH_STATS("tp_tcp6_in_errs:", tcp6_in_errs);
  3068. PRINT_CH_STATS("tp_tnl_cong_drops:", tnl_cong_drops);
  3069. PRINT_CH_STATS("tp_tnl_tx_drops:", tnl_tx_drops);
  3070. PRINT_CH_STATS("tp_ofld_vlan_drops:", ofld_vlan_drops);
  3071. PRINT_CH_STATS("tp_ofld_chan_drops:", ofld_chan_drops);
  3072. }
  3073. static void show_fcoe_stats(struct seq_file *seq)
  3074. {
  3075. struct adapter *adap = seq->private;
  3076. struct tp_fcoe_stats stats[NCHAN];
  3077. u8 i;
  3078. spin_lock(&adap->stats_lock);
  3079. for (i = 0; i < adap->params.arch.nchan; i++)
  3080. t4_get_fcoe_stats(adap, i, &stats[i], false);
  3081. spin_unlock(&adap->stats_lock);
  3082. PRINT_CH_STATS2("fcoe_octets_ddp", octets_ddp);
  3083. PRINT_CH_STATS2("fcoe_frames_ddp", frames_ddp);
  3084. PRINT_CH_STATS2("fcoe_frames_drop", frames_drop);
  3085. }
  3086. #undef PRINT_CH_STATS2
  3087. #undef PRINT_CH_STATS
  3088. #undef PRINT_ADAP_STATS
  3089. static int tp_stats_show(struct seq_file *seq, void *v)
  3090. {
  3091. struct adapter *adap = seq->private;
  3092. seq_puts(seq, "\n--------Adapter Stats--------\n");
  3093. show_tcp_stats(seq);
  3094. show_ddp_stats(seq);
  3095. show_rdma_stats(seq);
  3096. show_tp_err_adapter_stats(seq);
  3097. seq_puts(seq, "\n-------- Channel Stats --------\n");
  3098. if (adap->params.arch.nchan == NCHAN)
  3099. seq_printf(seq, "%-25s %-20s %-20s %-20s %-20s\n",
  3100. " ", "channel 0", "channel 1",
  3101. "channel 2", "channel 3");
  3102. else
  3103. seq_printf(seq, "%-25s %-20s %-20s\n",
  3104. " ", "channel 0", "channel 1");
  3105. show_cpl_stats(seq);
  3106. show_tp_err_channel_stats(seq);
  3107. show_fcoe_stats(seq);
  3108. return 0;
  3109. }
  3110. DEFINE_SIMPLE_DEBUGFS_FILE(tp_stats);
  3111. /* Add an array of Debug FS files.
  3112. */
  3113. void add_debugfs_files(struct adapter *adap,
  3114. struct t4_debugfs_entry *files,
  3115. unsigned int nfiles)
  3116. {
  3117. int i;
  3118. /* debugfs support is best effort */
  3119. for (i = 0; i < nfiles; i++)
  3120. debugfs_create_file(files[i].name, files[i].mode,
  3121. adap->debugfs_root,
  3122. (void *)adap + files[i].data,
  3123. files[i].ops);
  3124. }
  3125. int t4_setup_debugfs(struct adapter *adap)
  3126. {
  3127. int i;
  3128. u32 size = 0;
  3129. struct dentry *de;
  3130. static struct t4_debugfs_entry t4_debugfs_files[] = {
  3131. { "cim_la", &cim_la_fops, 0400, 0 },
  3132. { "cim_pif_la", &cim_pif_la_fops, 0400, 0 },
  3133. { "cim_ma_la", &cim_ma_la_fops, 0400, 0 },
  3134. { "cim_qcfg", &cim_qcfg_fops, 0400, 0 },
  3135. { "clk", &clk_debugfs_fops, 0400, 0 },
  3136. { "devlog", &devlog_fops, 0400, 0 },
  3137. { "mboxlog", &mboxlog_fops, 0400, 0 },
  3138. { "mbox0", &mbox_debugfs_fops, 0600, 0 },
  3139. { "mbox1", &mbox_debugfs_fops, 0600, 1 },
  3140. { "mbox2", &mbox_debugfs_fops, 0600, 2 },
  3141. { "mbox3", &mbox_debugfs_fops, 0600, 3 },
  3142. { "mbox4", &mbox_debugfs_fops, 0600, 4 },
  3143. { "mbox5", &mbox_debugfs_fops, 0600, 5 },
  3144. { "mbox6", &mbox_debugfs_fops, 0600, 6 },
  3145. { "mbox7", &mbox_debugfs_fops, 0600, 7 },
  3146. { "trace0", &mps_trc_debugfs_fops, 0600, 0 },
  3147. { "trace1", &mps_trc_debugfs_fops, 0600, 1 },
  3148. { "trace2", &mps_trc_debugfs_fops, 0600, 2 },
  3149. { "trace3", &mps_trc_debugfs_fops, 0600, 3 },
  3150. { "l2t", &t4_l2t_fops, 0400, 0},
  3151. { "mps_tcam", &mps_tcam_debugfs_fops, 0400, 0 },
  3152. { "rss", &rss_debugfs_fops, 0400, 0 },
  3153. { "rss_config", &rss_config_debugfs_fops, 0400, 0 },
  3154. { "rss_key", &rss_key_debugfs_fops, 0400, 0 },
  3155. { "rss_pf_config", &rss_pf_config_debugfs_fops, 0400, 0 },
  3156. { "rss_vf_config", &rss_vf_config_debugfs_fops, 0400, 0 },
  3157. { "resources", &resources_debugfs_fops, 0400, 0 },
  3158. #ifdef CONFIG_CHELSIO_T4_DCB
  3159. { "dcb_info", &dcb_info_debugfs_fops, 0400, 0 },
  3160. #endif
  3161. { "sge_qinfo", &sge_qinfo_debugfs_fops, 0400, 0 },
  3162. { "ibq_tp0", &cim_ibq_fops, 0400, 0 },
  3163. { "ibq_tp1", &cim_ibq_fops, 0400, 1 },
  3164. { "ibq_ulp", &cim_ibq_fops, 0400, 2 },
  3165. { "ibq_sge0", &cim_ibq_fops, 0400, 3 },
  3166. { "ibq_sge1", &cim_ibq_fops, 0400, 4 },
  3167. { "ibq_ncsi", &cim_ibq_fops, 0400, 5 },
  3168. { "obq_ulp0", &cim_obq_fops, 0400, 0 },
  3169. { "obq_ulp1", &cim_obq_fops, 0400, 1 },
  3170. { "obq_ulp2", &cim_obq_fops, 0400, 2 },
  3171. { "obq_ulp3", &cim_obq_fops, 0400, 3 },
  3172. { "obq_sge", &cim_obq_fops, 0400, 4 },
  3173. { "obq_ncsi", &cim_obq_fops, 0400, 5 },
  3174. { "tp_la", &tp_la_fops, 0400, 0 },
  3175. { "ulprx_la", &ulprx_la_fops, 0400, 0 },
  3176. { "sensors", &sensors_debugfs_fops, 0400, 0 },
  3177. { "pm_stats", &pm_stats_debugfs_fops, 0400, 0 },
  3178. { "tx_rate", &tx_rate_debugfs_fops, 0400, 0 },
  3179. { "cctrl", &cctrl_tbl_debugfs_fops, 0400, 0 },
  3180. #if IS_ENABLED(CONFIG_IPV6)
  3181. { "clip_tbl", &clip_tbl_debugfs_fops, 0400, 0 },
  3182. #endif
  3183. { "tids", &tid_info_debugfs_fops, 0400, 0},
  3184. { "blocked_fl", &blocked_fl_fops, 0600, 0 },
  3185. { "meminfo", &meminfo_fops, 0400, 0 },
  3186. { "crypto", &chcr_stats_debugfs_fops, 0400, 0 },
  3187. { "tp_stats", &tp_stats_debugfs_fops, 0400, 0 },
  3188. };
  3189. /* Debug FS nodes common to all T5 and later adapters.
  3190. */
  3191. static struct t4_debugfs_entry t5_debugfs_files[] = {
  3192. { "obq_sge_rx_q0", &cim_obq_fops, 0400, 6 },
  3193. { "obq_sge_rx_q1", &cim_obq_fops, 0400, 7 },
  3194. };
  3195. add_debugfs_files(adap,
  3196. t4_debugfs_files,
  3197. ARRAY_SIZE(t4_debugfs_files));
  3198. if (!is_t4(adap->params.chip))
  3199. add_debugfs_files(adap,
  3200. t5_debugfs_files,
  3201. ARRAY_SIZE(t5_debugfs_files));
  3202. i = t4_read_reg(adap, MA_TARGET_MEM_ENABLE_A);
  3203. if (i & EDRAM0_ENABLE_F) {
  3204. size = t4_read_reg(adap, MA_EDRAM0_BAR_A);
  3205. add_debugfs_mem(adap, "edc0", MEM_EDC0, EDRAM0_SIZE_G(size));
  3206. }
  3207. if (i & EDRAM1_ENABLE_F) {
  3208. size = t4_read_reg(adap, MA_EDRAM1_BAR_A);
  3209. add_debugfs_mem(adap, "edc1", MEM_EDC1, EDRAM1_SIZE_G(size));
  3210. }
  3211. if (is_t5(adap->params.chip)) {
  3212. if (i & EXT_MEM0_ENABLE_F) {
  3213. size = t4_read_reg(adap, MA_EXT_MEMORY0_BAR_A);
  3214. add_debugfs_mem(adap, "mc0", MEM_MC0,
  3215. EXT_MEM0_SIZE_G(size));
  3216. }
  3217. if (i & EXT_MEM1_ENABLE_F) {
  3218. size = t4_read_reg(adap, MA_EXT_MEMORY1_BAR_A);
  3219. add_debugfs_mem(adap, "mc1", MEM_MC1,
  3220. EXT_MEM1_SIZE_G(size));
  3221. }
  3222. } else {
  3223. if (i & EXT_MEM_ENABLE_F) {
  3224. size = t4_read_reg(adap, MA_EXT_MEMORY_BAR_A);
  3225. add_debugfs_mem(adap, "mc", MEM_MC,
  3226. EXT_MEM_SIZE_G(size));
  3227. }
  3228. if (i & HMA_MUX_F) {
  3229. size = t4_read_reg(adap, MA_EXT_MEMORY1_BAR_A);
  3230. add_debugfs_mem(adap, "hma", MEM_HMA,
  3231. EXT_MEM1_SIZE_G(size));
  3232. }
  3233. }
  3234. de = debugfs_create_file_size("flash", 0400, adap->debugfs_root, adap,
  3235. &flash_debugfs_fops, adap->params.sf_size);
  3236. debugfs_create_bool("use_backdoor", 0600,
  3237. adap->debugfs_root, &adap->use_bd);
  3238. debugfs_create_bool("trace_rss", 0600,
  3239. adap->debugfs_root, &adap->trace_rss);
  3240. return 0;
  3241. }