cxgb4_debugfs.c 107 KB

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