cxgb4_debugfs.c 89 KB

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