ipath_iba6110.c 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939
  1. /*
  2. * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved.
  3. * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.
  4. *
  5. * This software is available to you under a choice of one of two
  6. * licenses. You may choose to be licensed under the terms of the GNU
  7. * General Public License (GPL) Version 2, available from the file
  8. * COPYING in the main directory of this source tree, or the
  9. * OpenIB.org BSD license below:
  10. *
  11. * Redistribution and use in source and binary forms, with or
  12. * without modification, are permitted provided that the following
  13. * conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials
  22. * provided with the distribution.
  23. *
  24. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31. * SOFTWARE.
  32. */
  33. /*
  34. * This file contains all of the code that is specific to the InfiniPath
  35. * HT chip.
  36. */
  37. #include <linux/vmalloc.h>
  38. #include <linux/pci.h>
  39. #include <linux/delay.h>
  40. #include <linux/htirq.h>
  41. #include <rdma/ib_verbs.h>
  42. #include "ipath_kernel.h"
  43. #include "ipath_registers.h"
  44. static void ipath_setup_ht_setextled(struct ipath_devdata *, u64, u64);
  45. /*
  46. * This lists the InfiniPath registers, in the actual chip layout.
  47. * This structure should never be directly accessed.
  48. *
  49. * The names are in InterCap form because they're taken straight from
  50. * the chip specification. Since they're only used in this file, they
  51. * don't pollute the rest of the source.
  52. */
  53. struct _infinipath_do_not_use_kernel_regs {
  54. unsigned long long Revision;
  55. unsigned long long Control;
  56. unsigned long long PageAlign;
  57. unsigned long long PortCnt;
  58. unsigned long long DebugPortSelect;
  59. unsigned long long DebugPort;
  60. unsigned long long SendRegBase;
  61. unsigned long long UserRegBase;
  62. unsigned long long CounterRegBase;
  63. unsigned long long Scratch;
  64. unsigned long long ReservedMisc1;
  65. unsigned long long InterruptConfig;
  66. unsigned long long IntBlocked;
  67. unsigned long long IntMask;
  68. unsigned long long IntStatus;
  69. unsigned long long IntClear;
  70. unsigned long long ErrorMask;
  71. unsigned long long ErrorStatus;
  72. unsigned long long ErrorClear;
  73. unsigned long long HwErrMask;
  74. unsigned long long HwErrStatus;
  75. unsigned long long HwErrClear;
  76. unsigned long long HwDiagCtrl;
  77. unsigned long long MDIO;
  78. unsigned long long IBCStatus;
  79. unsigned long long IBCCtrl;
  80. unsigned long long ExtStatus;
  81. unsigned long long ExtCtrl;
  82. unsigned long long GPIOOut;
  83. unsigned long long GPIOMask;
  84. unsigned long long GPIOStatus;
  85. unsigned long long GPIOClear;
  86. unsigned long long RcvCtrl;
  87. unsigned long long RcvBTHQP;
  88. unsigned long long RcvHdrSize;
  89. unsigned long long RcvHdrCnt;
  90. unsigned long long RcvHdrEntSize;
  91. unsigned long long RcvTIDBase;
  92. unsigned long long RcvTIDCnt;
  93. unsigned long long RcvEgrBase;
  94. unsigned long long RcvEgrCnt;
  95. unsigned long long RcvBufBase;
  96. unsigned long long RcvBufSize;
  97. unsigned long long RxIntMemBase;
  98. unsigned long long RxIntMemSize;
  99. unsigned long long RcvPartitionKey;
  100. unsigned long long ReservedRcv[10];
  101. unsigned long long SendCtrl;
  102. unsigned long long SendPIOBufBase;
  103. unsigned long long SendPIOSize;
  104. unsigned long long SendPIOBufCnt;
  105. unsigned long long SendPIOAvailAddr;
  106. unsigned long long TxIntMemBase;
  107. unsigned long long TxIntMemSize;
  108. unsigned long long ReservedSend[9];
  109. unsigned long long SendBufferError;
  110. unsigned long long SendBufferErrorCONT1;
  111. unsigned long long SendBufferErrorCONT2;
  112. unsigned long long SendBufferErrorCONT3;
  113. unsigned long long ReservedSBE[4];
  114. unsigned long long RcvHdrAddr0;
  115. unsigned long long RcvHdrAddr1;
  116. unsigned long long RcvHdrAddr2;
  117. unsigned long long RcvHdrAddr3;
  118. unsigned long long RcvHdrAddr4;
  119. unsigned long long RcvHdrAddr5;
  120. unsigned long long RcvHdrAddr6;
  121. unsigned long long RcvHdrAddr7;
  122. unsigned long long RcvHdrAddr8;
  123. unsigned long long ReservedRHA[7];
  124. unsigned long long RcvHdrTailAddr0;
  125. unsigned long long RcvHdrTailAddr1;
  126. unsigned long long RcvHdrTailAddr2;
  127. unsigned long long RcvHdrTailAddr3;
  128. unsigned long long RcvHdrTailAddr4;
  129. unsigned long long RcvHdrTailAddr5;
  130. unsigned long long RcvHdrTailAddr6;
  131. unsigned long long RcvHdrTailAddr7;
  132. unsigned long long RcvHdrTailAddr8;
  133. unsigned long long ReservedRHTA[7];
  134. unsigned long long Sync; /* Software only */
  135. unsigned long long Dump; /* Software only */
  136. unsigned long long SimVer; /* Software only */
  137. unsigned long long ReservedSW[5];
  138. unsigned long long SerdesConfig0;
  139. unsigned long long SerdesConfig1;
  140. unsigned long long SerdesStatus;
  141. unsigned long long XGXSConfig;
  142. unsigned long long ReservedSW2[4];
  143. };
  144. struct _infinipath_do_not_use_counters {
  145. __u64 LBIntCnt;
  146. __u64 LBFlowStallCnt;
  147. __u64 Reserved1;
  148. __u64 TxUnsupVLErrCnt;
  149. __u64 TxDataPktCnt;
  150. __u64 TxFlowPktCnt;
  151. __u64 TxDwordCnt;
  152. __u64 TxLenErrCnt;
  153. __u64 TxMaxMinLenErrCnt;
  154. __u64 TxUnderrunCnt;
  155. __u64 TxFlowStallCnt;
  156. __u64 TxDroppedPktCnt;
  157. __u64 RxDroppedPktCnt;
  158. __u64 RxDataPktCnt;
  159. __u64 RxFlowPktCnt;
  160. __u64 RxDwordCnt;
  161. __u64 RxLenErrCnt;
  162. __u64 RxMaxMinLenErrCnt;
  163. __u64 RxICRCErrCnt;
  164. __u64 RxVCRCErrCnt;
  165. __u64 RxFlowCtrlErrCnt;
  166. __u64 RxBadFormatCnt;
  167. __u64 RxLinkProblemCnt;
  168. __u64 RxEBPCnt;
  169. __u64 RxLPCRCErrCnt;
  170. __u64 RxBufOvflCnt;
  171. __u64 RxTIDFullErrCnt;
  172. __u64 RxTIDValidErrCnt;
  173. __u64 RxPKeyMismatchCnt;
  174. __u64 RxP0HdrEgrOvflCnt;
  175. __u64 RxP1HdrEgrOvflCnt;
  176. __u64 RxP2HdrEgrOvflCnt;
  177. __u64 RxP3HdrEgrOvflCnt;
  178. __u64 RxP4HdrEgrOvflCnt;
  179. __u64 RxP5HdrEgrOvflCnt;
  180. __u64 RxP6HdrEgrOvflCnt;
  181. __u64 RxP7HdrEgrOvflCnt;
  182. __u64 RxP8HdrEgrOvflCnt;
  183. __u64 Reserved6;
  184. __u64 Reserved7;
  185. __u64 IBStatusChangeCnt;
  186. __u64 IBLinkErrRecoveryCnt;
  187. __u64 IBLinkDownedCnt;
  188. __u64 IBSymbolErrCnt;
  189. };
  190. #define IPATH_KREG_OFFSET(field) (offsetof( \
  191. struct _infinipath_do_not_use_kernel_regs, field) / sizeof(u64))
  192. #define IPATH_CREG_OFFSET(field) (offsetof( \
  193. struct _infinipath_do_not_use_counters, field) / sizeof(u64))
  194. static const struct ipath_kregs ipath_ht_kregs = {
  195. .kr_control = IPATH_KREG_OFFSET(Control),
  196. .kr_counterregbase = IPATH_KREG_OFFSET(CounterRegBase),
  197. .kr_debugport = IPATH_KREG_OFFSET(DebugPort),
  198. .kr_debugportselect = IPATH_KREG_OFFSET(DebugPortSelect),
  199. .kr_errorclear = IPATH_KREG_OFFSET(ErrorClear),
  200. .kr_errormask = IPATH_KREG_OFFSET(ErrorMask),
  201. .kr_errorstatus = IPATH_KREG_OFFSET(ErrorStatus),
  202. .kr_extctrl = IPATH_KREG_OFFSET(ExtCtrl),
  203. .kr_extstatus = IPATH_KREG_OFFSET(ExtStatus),
  204. .kr_gpio_clear = IPATH_KREG_OFFSET(GPIOClear),
  205. .kr_gpio_mask = IPATH_KREG_OFFSET(GPIOMask),
  206. .kr_gpio_out = IPATH_KREG_OFFSET(GPIOOut),
  207. .kr_gpio_status = IPATH_KREG_OFFSET(GPIOStatus),
  208. .kr_hwdiagctrl = IPATH_KREG_OFFSET(HwDiagCtrl),
  209. .kr_hwerrclear = IPATH_KREG_OFFSET(HwErrClear),
  210. .kr_hwerrmask = IPATH_KREG_OFFSET(HwErrMask),
  211. .kr_hwerrstatus = IPATH_KREG_OFFSET(HwErrStatus),
  212. .kr_ibcctrl = IPATH_KREG_OFFSET(IBCCtrl),
  213. .kr_ibcstatus = IPATH_KREG_OFFSET(IBCStatus),
  214. .kr_intblocked = IPATH_KREG_OFFSET(IntBlocked),
  215. .kr_intclear = IPATH_KREG_OFFSET(IntClear),
  216. .kr_interruptconfig = IPATH_KREG_OFFSET(InterruptConfig),
  217. .kr_intmask = IPATH_KREG_OFFSET(IntMask),
  218. .kr_intstatus = IPATH_KREG_OFFSET(IntStatus),
  219. .kr_mdio = IPATH_KREG_OFFSET(MDIO),
  220. .kr_pagealign = IPATH_KREG_OFFSET(PageAlign),
  221. .kr_partitionkey = IPATH_KREG_OFFSET(RcvPartitionKey),
  222. .kr_portcnt = IPATH_KREG_OFFSET(PortCnt),
  223. .kr_rcvbthqp = IPATH_KREG_OFFSET(RcvBTHQP),
  224. .kr_rcvbufbase = IPATH_KREG_OFFSET(RcvBufBase),
  225. .kr_rcvbufsize = IPATH_KREG_OFFSET(RcvBufSize),
  226. .kr_rcvctrl = IPATH_KREG_OFFSET(RcvCtrl),
  227. .kr_rcvegrbase = IPATH_KREG_OFFSET(RcvEgrBase),
  228. .kr_rcvegrcnt = IPATH_KREG_OFFSET(RcvEgrCnt),
  229. .kr_rcvhdrcnt = IPATH_KREG_OFFSET(RcvHdrCnt),
  230. .kr_rcvhdrentsize = IPATH_KREG_OFFSET(RcvHdrEntSize),
  231. .kr_rcvhdrsize = IPATH_KREG_OFFSET(RcvHdrSize),
  232. .kr_rcvintmembase = IPATH_KREG_OFFSET(RxIntMemBase),
  233. .kr_rcvintmemsize = IPATH_KREG_OFFSET(RxIntMemSize),
  234. .kr_rcvtidbase = IPATH_KREG_OFFSET(RcvTIDBase),
  235. .kr_rcvtidcnt = IPATH_KREG_OFFSET(RcvTIDCnt),
  236. .kr_revision = IPATH_KREG_OFFSET(Revision),
  237. .kr_scratch = IPATH_KREG_OFFSET(Scratch),
  238. .kr_sendbuffererror = IPATH_KREG_OFFSET(SendBufferError),
  239. .kr_sendctrl = IPATH_KREG_OFFSET(SendCtrl),
  240. .kr_sendpioavailaddr = IPATH_KREG_OFFSET(SendPIOAvailAddr),
  241. .kr_sendpiobufbase = IPATH_KREG_OFFSET(SendPIOBufBase),
  242. .kr_sendpiobufcnt = IPATH_KREG_OFFSET(SendPIOBufCnt),
  243. .kr_sendpiosize = IPATH_KREG_OFFSET(SendPIOSize),
  244. .kr_sendregbase = IPATH_KREG_OFFSET(SendRegBase),
  245. .kr_txintmembase = IPATH_KREG_OFFSET(TxIntMemBase),
  246. .kr_txintmemsize = IPATH_KREG_OFFSET(TxIntMemSize),
  247. .kr_userregbase = IPATH_KREG_OFFSET(UserRegBase),
  248. .kr_serdesconfig0 = IPATH_KREG_OFFSET(SerdesConfig0),
  249. .kr_serdesconfig1 = IPATH_KREG_OFFSET(SerdesConfig1),
  250. .kr_serdesstatus = IPATH_KREG_OFFSET(SerdesStatus),
  251. .kr_xgxsconfig = IPATH_KREG_OFFSET(XGXSConfig),
  252. /*
  253. * These should not be used directly via ipath_write_kreg64(),
  254. * use them with ipath_write_kreg64_port(),
  255. */
  256. .kr_rcvhdraddr = IPATH_KREG_OFFSET(RcvHdrAddr0),
  257. .kr_rcvhdrtailaddr = IPATH_KREG_OFFSET(RcvHdrTailAddr0)
  258. };
  259. static const struct ipath_cregs ipath_ht_cregs = {
  260. .cr_badformatcnt = IPATH_CREG_OFFSET(RxBadFormatCnt),
  261. .cr_erricrccnt = IPATH_CREG_OFFSET(RxICRCErrCnt),
  262. .cr_errlinkcnt = IPATH_CREG_OFFSET(RxLinkProblemCnt),
  263. .cr_errlpcrccnt = IPATH_CREG_OFFSET(RxLPCRCErrCnt),
  264. .cr_errpkey = IPATH_CREG_OFFSET(RxPKeyMismatchCnt),
  265. .cr_errrcvflowctrlcnt = IPATH_CREG_OFFSET(RxFlowCtrlErrCnt),
  266. .cr_err_rlencnt = IPATH_CREG_OFFSET(RxLenErrCnt),
  267. .cr_errslencnt = IPATH_CREG_OFFSET(TxLenErrCnt),
  268. .cr_errtidfull = IPATH_CREG_OFFSET(RxTIDFullErrCnt),
  269. .cr_errtidvalid = IPATH_CREG_OFFSET(RxTIDValidErrCnt),
  270. .cr_errvcrccnt = IPATH_CREG_OFFSET(RxVCRCErrCnt),
  271. .cr_ibstatuschange = IPATH_CREG_OFFSET(IBStatusChangeCnt),
  272. /* calc from Reg_CounterRegBase + offset */
  273. .cr_intcnt = IPATH_CREG_OFFSET(LBIntCnt),
  274. .cr_invalidrlencnt = IPATH_CREG_OFFSET(RxMaxMinLenErrCnt),
  275. .cr_invalidslencnt = IPATH_CREG_OFFSET(TxMaxMinLenErrCnt),
  276. .cr_lbflowstallcnt = IPATH_CREG_OFFSET(LBFlowStallCnt),
  277. .cr_pktrcvcnt = IPATH_CREG_OFFSET(RxDataPktCnt),
  278. .cr_pktrcvflowctrlcnt = IPATH_CREG_OFFSET(RxFlowPktCnt),
  279. .cr_pktsendcnt = IPATH_CREG_OFFSET(TxDataPktCnt),
  280. .cr_pktsendflowcnt = IPATH_CREG_OFFSET(TxFlowPktCnt),
  281. .cr_portovflcnt = IPATH_CREG_OFFSET(RxP0HdrEgrOvflCnt),
  282. .cr_rcvebpcnt = IPATH_CREG_OFFSET(RxEBPCnt),
  283. .cr_rcvovflcnt = IPATH_CREG_OFFSET(RxBufOvflCnt),
  284. .cr_senddropped = IPATH_CREG_OFFSET(TxDroppedPktCnt),
  285. .cr_sendstallcnt = IPATH_CREG_OFFSET(TxFlowStallCnt),
  286. .cr_sendunderruncnt = IPATH_CREG_OFFSET(TxUnderrunCnt),
  287. .cr_wordrcvcnt = IPATH_CREG_OFFSET(RxDwordCnt),
  288. .cr_wordsendcnt = IPATH_CREG_OFFSET(TxDwordCnt),
  289. .cr_unsupvlcnt = IPATH_CREG_OFFSET(TxUnsupVLErrCnt),
  290. .cr_rxdroppktcnt = IPATH_CREG_OFFSET(RxDroppedPktCnt),
  291. .cr_iblinkerrrecovcnt = IPATH_CREG_OFFSET(IBLinkErrRecoveryCnt),
  292. .cr_iblinkdowncnt = IPATH_CREG_OFFSET(IBLinkDownedCnt),
  293. .cr_ibsymbolerrcnt = IPATH_CREG_OFFSET(IBSymbolErrCnt)
  294. };
  295. /* kr_intstatus, kr_intclear, kr_intmask bits */
  296. #define INFINIPATH_I_RCVURG_MASK ((1U<<9)-1)
  297. #define INFINIPATH_I_RCVAVAIL_MASK ((1U<<9)-1)
  298. /* kr_hwerrclear, kr_hwerrmask, kr_hwerrstatus, bits */
  299. #define INFINIPATH_HWE_HTCMEMPARITYERR_SHIFT 0
  300. #define INFINIPATH_HWE_HTCMEMPARITYERR_MASK 0x3FFFFFULL
  301. #define INFINIPATH_HWE_HTCLNKABYTE0CRCERR 0x0000000000800000ULL
  302. #define INFINIPATH_HWE_HTCLNKABYTE1CRCERR 0x0000000001000000ULL
  303. #define INFINIPATH_HWE_HTCLNKBBYTE0CRCERR 0x0000000002000000ULL
  304. #define INFINIPATH_HWE_HTCLNKBBYTE1CRCERR 0x0000000004000000ULL
  305. #define INFINIPATH_HWE_HTCMISCERR4 0x0000000008000000ULL
  306. #define INFINIPATH_HWE_HTCMISCERR5 0x0000000010000000ULL
  307. #define INFINIPATH_HWE_HTCMISCERR6 0x0000000020000000ULL
  308. #define INFINIPATH_HWE_HTCMISCERR7 0x0000000040000000ULL
  309. #define INFINIPATH_HWE_HTCBUSTREQPARITYERR 0x0000000080000000ULL
  310. #define INFINIPATH_HWE_HTCBUSTRESPPARITYERR 0x0000000100000000ULL
  311. #define INFINIPATH_HWE_HTCBUSIREQPARITYERR 0x0000000200000000ULL
  312. #define INFINIPATH_HWE_COREPLL_FBSLIP 0x0080000000000000ULL
  313. #define INFINIPATH_HWE_COREPLL_RFSLIP 0x0100000000000000ULL
  314. #define INFINIPATH_HWE_HTBPLL_FBSLIP 0x0200000000000000ULL
  315. #define INFINIPATH_HWE_HTBPLL_RFSLIP 0x0400000000000000ULL
  316. #define INFINIPATH_HWE_HTAPLL_FBSLIP 0x0800000000000000ULL
  317. #define INFINIPATH_HWE_HTAPLL_RFSLIP 0x1000000000000000ULL
  318. #define INFINIPATH_HWE_SERDESPLLFAILED 0x2000000000000000ULL
  319. #define IBA6110_IBCS_LINKTRAININGSTATE_MASK 0xf
  320. #define IBA6110_IBCS_LINKSTATE_SHIFT 4
  321. /* kr_extstatus bits */
  322. #define INFINIPATH_EXTS_FREQSEL 0x2
  323. #define INFINIPATH_EXTS_SERDESSEL 0x4
  324. #define INFINIPATH_EXTS_MEMBIST_ENDTEST 0x0000000000004000
  325. #define INFINIPATH_EXTS_MEMBIST_CORRECT 0x0000000000008000
  326. /* TID entries (memory), HT-only */
  327. #define INFINIPATH_RT_ADDR_MASK 0xFFFFFFFFFFULL /* 40 bits valid */
  328. #define INFINIPATH_RT_VALID 0x8000000000000000ULL
  329. #define INFINIPATH_RT_ADDR_SHIFT 0
  330. #define INFINIPATH_RT_BUFSIZE_MASK 0x3FFFULL
  331. #define INFINIPATH_RT_BUFSIZE_SHIFT 48
  332. #define INFINIPATH_R_INTRAVAIL_SHIFT 16
  333. #define INFINIPATH_R_TAILUPD_SHIFT 31
  334. /* kr_xgxsconfig bits */
  335. #define INFINIPATH_XGXS_RESET 0x7ULL
  336. /*
  337. * masks and bits that are different in different chips, or present only
  338. * in one
  339. */
  340. static const ipath_err_t infinipath_hwe_htcmemparityerr_mask =
  341. INFINIPATH_HWE_HTCMEMPARITYERR_MASK;
  342. static const ipath_err_t infinipath_hwe_htcmemparityerr_shift =
  343. INFINIPATH_HWE_HTCMEMPARITYERR_SHIFT;
  344. static const ipath_err_t infinipath_hwe_htclnkabyte0crcerr =
  345. INFINIPATH_HWE_HTCLNKABYTE0CRCERR;
  346. static const ipath_err_t infinipath_hwe_htclnkabyte1crcerr =
  347. INFINIPATH_HWE_HTCLNKABYTE1CRCERR;
  348. static const ipath_err_t infinipath_hwe_htclnkbbyte0crcerr =
  349. INFINIPATH_HWE_HTCLNKBBYTE0CRCERR;
  350. static const ipath_err_t infinipath_hwe_htclnkbbyte1crcerr =
  351. INFINIPATH_HWE_HTCLNKBBYTE1CRCERR;
  352. #define _IPATH_GPIO_SDA_NUM 1
  353. #define _IPATH_GPIO_SCL_NUM 0
  354. #define IPATH_GPIO_SDA \
  355. (1ULL << (_IPATH_GPIO_SDA_NUM+INFINIPATH_EXTC_GPIOOE_SHIFT))
  356. #define IPATH_GPIO_SCL \
  357. (1ULL << (_IPATH_GPIO_SCL_NUM+INFINIPATH_EXTC_GPIOOE_SHIFT))
  358. /* keep the code below somewhat more readonable; not used elsewhere */
  359. #define _IPATH_HTLINK0_CRCBITS (infinipath_hwe_htclnkabyte0crcerr | \
  360. infinipath_hwe_htclnkabyte1crcerr)
  361. #define _IPATH_HTLINK1_CRCBITS (infinipath_hwe_htclnkbbyte0crcerr | \
  362. infinipath_hwe_htclnkbbyte1crcerr)
  363. #define _IPATH_HTLANE0_CRCBITS (infinipath_hwe_htclnkabyte0crcerr | \
  364. infinipath_hwe_htclnkbbyte0crcerr)
  365. #define _IPATH_HTLANE1_CRCBITS (infinipath_hwe_htclnkabyte1crcerr | \
  366. infinipath_hwe_htclnkbbyte1crcerr)
  367. static void hwerr_crcbits(struct ipath_devdata *dd, ipath_err_t hwerrs,
  368. char *msg, size_t msgl)
  369. {
  370. char bitsmsg[64];
  371. ipath_err_t crcbits = hwerrs &
  372. (_IPATH_HTLINK0_CRCBITS | _IPATH_HTLINK1_CRCBITS);
  373. /* don't check if 8bit HT */
  374. if (dd->ipath_flags & IPATH_8BIT_IN_HT0)
  375. crcbits &= ~infinipath_hwe_htclnkabyte1crcerr;
  376. /* don't check if 8bit HT */
  377. if (dd->ipath_flags & IPATH_8BIT_IN_HT1)
  378. crcbits &= ~infinipath_hwe_htclnkbbyte1crcerr;
  379. /*
  380. * we'll want to ignore link errors on link that is
  381. * not in use, if any. For now, complain about both
  382. */
  383. if (crcbits) {
  384. u16 ctrl0, ctrl1;
  385. snprintf(bitsmsg, sizeof bitsmsg,
  386. "[HT%s lane %s CRC (%llx); powercycle to completely clear]",
  387. !(crcbits & _IPATH_HTLINK1_CRCBITS) ?
  388. "0 (A)" : (!(crcbits & _IPATH_HTLINK0_CRCBITS)
  389. ? "1 (B)" : "0+1 (A+B)"),
  390. !(crcbits & _IPATH_HTLANE1_CRCBITS) ? "0"
  391. : (!(crcbits & _IPATH_HTLANE0_CRCBITS) ? "1" :
  392. "0+1"), (unsigned long long) crcbits);
  393. strlcat(msg, bitsmsg, msgl);
  394. /*
  395. * print extra info for debugging. slave/primary
  396. * config word 4, 8 (link control 0, 1)
  397. */
  398. if (pci_read_config_word(dd->pcidev,
  399. dd->ipath_ht_slave_off + 0x4,
  400. &ctrl0))
  401. dev_info(&dd->pcidev->dev, "Couldn't read "
  402. "linkctrl0 of slave/primary "
  403. "config block\n");
  404. else if (!(ctrl0 & 1 << 6))
  405. /* not if EOC bit set */
  406. ipath_dbg("HT linkctrl0 0x%x%s%s\n", ctrl0,
  407. ((ctrl0 >> 8) & 7) ? " CRC" : "",
  408. ((ctrl0 >> 4) & 1) ? "linkfail" :
  409. "");
  410. if (pci_read_config_word(dd->pcidev,
  411. dd->ipath_ht_slave_off + 0x8,
  412. &ctrl1))
  413. dev_info(&dd->pcidev->dev, "Couldn't read "
  414. "linkctrl1 of slave/primary "
  415. "config block\n");
  416. else if (!(ctrl1 & 1 << 6))
  417. /* not if EOC bit set */
  418. ipath_dbg("HT linkctrl1 0x%x%s%s\n", ctrl1,
  419. ((ctrl1 >> 8) & 7) ? " CRC" : "",
  420. ((ctrl1 >> 4) & 1) ? "linkfail" :
  421. "");
  422. /* disable until driver reloaded */
  423. dd->ipath_hwerrmask &= ~crcbits;
  424. ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrmask,
  425. dd->ipath_hwerrmask);
  426. ipath_dbg("HT crc errs: %s\n", msg);
  427. } else
  428. ipath_dbg("ignoring HT crc errors 0x%llx, "
  429. "not in use\n", (unsigned long long)
  430. (hwerrs & (_IPATH_HTLINK0_CRCBITS |
  431. _IPATH_HTLINK1_CRCBITS)));
  432. }
  433. /* 6110 specific hardware errors... */
  434. static const struct ipath_hwerror_msgs ipath_6110_hwerror_msgs[] = {
  435. INFINIPATH_HWE_MSG(HTCBUSIREQPARITYERR, "HTC Ireq Parity"),
  436. INFINIPATH_HWE_MSG(HTCBUSTREQPARITYERR, "HTC Treq Parity"),
  437. INFINIPATH_HWE_MSG(HTCBUSTRESPPARITYERR, "HTC Tresp Parity"),
  438. INFINIPATH_HWE_MSG(HTCMISCERR5, "HT core Misc5"),
  439. INFINIPATH_HWE_MSG(HTCMISCERR6, "HT core Misc6"),
  440. INFINIPATH_HWE_MSG(HTCMISCERR7, "HT core Misc7"),
  441. INFINIPATH_HWE_MSG(RXDSYNCMEMPARITYERR, "Rx Dsync"),
  442. INFINIPATH_HWE_MSG(SERDESPLLFAILED, "SerDes PLL"),
  443. };
  444. #define TXE_PIO_PARITY ((INFINIPATH_HWE_TXEMEMPARITYERR_PIOBUF | \
  445. INFINIPATH_HWE_TXEMEMPARITYERR_PIOPBC) \
  446. << INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT)
  447. #define RXE_EAGER_PARITY (INFINIPATH_HWE_RXEMEMPARITYERR_EAGERTID \
  448. << INFINIPATH_HWE_RXEMEMPARITYERR_SHIFT)
  449. static void ipath_ht_txe_recover(struct ipath_devdata *dd)
  450. {
  451. ++ipath_stats.sps_txeparity;
  452. dev_info(&dd->pcidev->dev,
  453. "Recovering from TXE PIO parity error\n");
  454. }
  455. /**
  456. * ipath_ht_handle_hwerrors - display hardware errors.
  457. * @dd: the infinipath device
  458. * @msg: the output buffer
  459. * @msgl: the size of the output buffer
  460. *
  461. * Use same msg buffer as regular errors to avoid excessive stack
  462. * use. Most hardware errors are catastrophic, but for right now,
  463. * we'll print them and continue. We reuse the same message buffer as
  464. * ipath_handle_errors() to avoid excessive stack usage.
  465. */
  466. static void ipath_ht_handle_hwerrors(struct ipath_devdata *dd, char *msg,
  467. size_t msgl)
  468. {
  469. ipath_err_t hwerrs;
  470. u32 bits, ctrl;
  471. int isfatal = 0;
  472. char bitsmsg[64];
  473. int log_idx;
  474. hwerrs = ipath_read_kreg64(dd, dd->ipath_kregs->kr_hwerrstatus);
  475. if (!hwerrs) {
  476. ipath_cdbg(VERBOSE, "Called but no hardware errors set\n");
  477. /*
  478. * better than printing cofusing messages
  479. * This seems to be related to clearing the crc error, or
  480. * the pll error during init.
  481. */
  482. goto bail;
  483. } else if (hwerrs == -1LL) {
  484. ipath_dev_err(dd, "Read of hardware error status failed "
  485. "(all bits set); ignoring\n");
  486. goto bail;
  487. }
  488. ipath_stats.sps_hwerrs++;
  489. /* Always clear the error status register, except MEMBISTFAIL,
  490. * regardless of whether we continue or stop using the chip.
  491. * We want that set so we know it failed, even across driver reload.
  492. * We'll still ignore it in the hwerrmask. We do this partly for
  493. * diagnostics, but also for support */
  494. ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrclear,
  495. hwerrs&~INFINIPATH_HWE_MEMBISTFAILED);
  496. hwerrs &= dd->ipath_hwerrmask;
  497. /* We log some errors to EEPROM, check if we have any of those. */
  498. for (log_idx = 0; log_idx < IPATH_EEP_LOG_CNT; ++log_idx)
  499. if (hwerrs & dd->ipath_eep_st_masks[log_idx].hwerrs_to_log)
  500. ipath_inc_eeprom_err(dd, log_idx, 1);
  501. /*
  502. * make sure we get this much out, unless told to be quiet,
  503. * it's a parity error we may recover from,
  504. * or it's occurred within the last 5 seconds
  505. */
  506. if ((hwerrs & ~(dd->ipath_lasthwerror | TXE_PIO_PARITY |
  507. RXE_EAGER_PARITY)) ||
  508. (ipath_debug & __IPATH_VERBDBG))
  509. dev_info(&dd->pcidev->dev, "Hardware error: hwerr=0x%llx "
  510. "(cleared)\n", (unsigned long long) hwerrs);
  511. dd->ipath_lasthwerror |= hwerrs;
  512. if (hwerrs & ~dd->ipath_hwe_bitsextant)
  513. ipath_dev_err(dd, "hwerror interrupt with unknown errors "
  514. "%llx set\n", (unsigned long long)
  515. (hwerrs & ~dd->ipath_hwe_bitsextant));
  516. ctrl = ipath_read_kreg32(dd, dd->ipath_kregs->kr_control);
  517. if ((ctrl & INFINIPATH_C_FREEZEMODE) && !ipath_diag_inuse) {
  518. /*
  519. * parity errors in send memory are recoverable,
  520. * just cancel the send (if indicated in * sendbuffererror),
  521. * count the occurrence, unfreeze (if no other handled
  522. * hardware error bits are set), and continue. They can
  523. * occur if a processor speculative read is done to the PIO
  524. * buffer while we are sending a packet, for example.
  525. */
  526. if (hwerrs & TXE_PIO_PARITY) {
  527. ipath_ht_txe_recover(dd);
  528. hwerrs &= ~TXE_PIO_PARITY;
  529. }
  530. if (!hwerrs) {
  531. ipath_dbg("Clearing freezemode on ignored or "
  532. "recovered hardware error\n");
  533. ipath_clear_freeze(dd);
  534. }
  535. }
  536. *msg = '\0';
  537. /*
  538. * may someday want to decode into which bits are which
  539. * functional area for parity errors, etc.
  540. */
  541. if (hwerrs & (infinipath_hwe_htcmemparityerr_mask
  542. << INFINIPATH_HWE_HTCMEMPARITYERR_SHIFT)) {
  543. bits = (u32) ((hwerrs >>
  544. INFINIPATH_HWE_HTCMEMPARITYERR_SHIFT) &
  545. INFINIPATH_HWE_HTCMEMPARITYERR_MASK);
  546. snprintf(bitsmsg, sizeof bitsmsg, "[HTC Parity Errs %x] ",
  547. bits);
  548. strlcat(msg, bitsmsg, msgl);
  549. }
  550. ipath_format_hwerrors(hwerrs,
  551. ipath_6110_hwerror_msgs,
  552. sizeof(ipath_6110_hwerror_msgs) /
  553. sizeof(ipath_6110_hwerror_msgs[0]),
  554. msg, msgl);
  555. if (hwerrs & (_IPATH_HTLINK0_CRCBITS | _IPATH_HTLINK1_CRCBITS))
  556. hwerr_crcbits(dd, hwerrs, msg, msgl);
  557. if (hwerrs & INFINIPATH_HWE_MEMBISTFAILED) {
  558. strlcat(msg, "[Memory BIST test failed, InfiniPath hardware unusable]",
  559. msgl);
  560. /* ignore from now on, so disable until driver reloaded */
  561. dd->ipath_hwerrmask &= ~INFINIPATH_HWE_MEMBISTFAILED;
  562. ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrmask,
  563. dd->ipath_hwerrmask);
  564. }
  565. #define _IPATH_PLL_FAIL (INFINIPATH_HWE_COREPLL_FBSLIP | \
  566. INFINIPATH_HWE_COREPLL_RFSLIP | \
  567. INFINIPATH_HWE_HTBPLL_FBSLIP | \
  568. INFINIPATH_HWE_HTBPLL_RFSLIP | \
  569. INFINIPATH_HWE_HTAPLL_FBSLIP | \
  570. INFINIPATH_HWE_HTAPLL_RFSLIP)
  571. if (hwerrs & _IPATH_PLL_FAIL) {
  572. snprintf(bitsmsg, sizeof bitsmsg,
  573. "[PLL failed (%llx), InfiniPath hardware unusable]",
  574. (unsigned long long) (hwerrs & _IPATH_PLL_FAIL));
  575. strlcat(msg, bitsmsg, msgl);
  576. /* ignore from now on, so disable until driver reloaded */
  577. dd->ipath_hwerrmask &= ~(hwerrs & _IPATH_PLL_FAIL);
  578. ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrmask,
  579. dd->ipath_hwerrmask);
  580. }
  581. if (hwerrs & INFINIPATH_HWE_SERDESPLLFAILED) {
  582. /*
  583. * If it occurs, it is left masked since the eternal
  584. * interface is unused
  585. */
  586. dd->ipath_hwerrmask &= ~INFINIPATH_HWE_SERDESPLLFAILED;
  587. ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrmask,
  588. dd->ipath_hwerrmask);
  589. }
  590. if (hwerrs) {
  591. /*
  592. * if any set that we aren't ignoring; only
  593. * make the complaint once, in case it's stuck
  594. * or recurring, and we get here multiple
  595. * times.
  596. * force link down, so switch knows, and
  597. * LEDs are turned off
  598. */
  599. if (dd->ipath_flags & IPATH_INITTED) {
  600. ipath_set_linkstate(dd, IPATH_IB_LINKDOWN);
  601. ipath_setup_ht_setextled(dd,
  602. INFINIPATH_IBCS_L_STATE_DOWN,
  603. INFINIPATH_IBCS_LT_STATE_DISABLED);
  604. ipath_dev_err(dd, "Fatal Hardware Error (freeze "
  605. "mode), no longer usable, SN %.16s\n",
  606. dd->ipath_serial);
  607. isfatal = 1;
  608. }
  609. *dd->ipath_statusp &= ~IPATH_STATUS_IB_READY;
  610. /* mark as having had error */
  611. *dd->ipath_statusp |= IPATH_STATUS_HWERROR;
  612. /*
  613. * mark as not usable, at a minimum until driver
  614. * is reloaded, probably until reboot, since no
  615. * other reset is possible.
  616. */
  617. dd->ipath_flags &= ~IPATH_INITTED;
  618. }
  619. else
  620. *msg = 0; /* recovered from all of them */
  621. if (*msg)
  622. ipath_dev_err(dd, "%s hardware error\n", msg);
  623. if (isfatal && !ipath_diag_inuse && dd->ipath_freezemsg)
  624. /*
  625. * for status file; if no trailing brace is copied,
  626. * we'll know it was truncated.
  627. */
  628. snprintf(dd->ipath_freezemsg,
  629. dd->ipath_freezelen, "{%s}", msg);
  630. bail:;
  631. }
  632. /**
  633. * ipath_ht_boardname - fill in the board name
  634. * @dd: the infinipath device
  635. * @name: the output buffer
  636. * @namelen: the size of the output buffer
  637. *
  638. * fill in the board name, based on the board revision register
  639. */
  640. static int ipath_ht_boardname(struct ipath_devdata *dd, char *name,
  641. size_t namelen)
  642. {
  643. char *n = NULL;
  644. u8 boardrev = dd->ipath_boardrev;
  645. int ret = 0;
  646. switch (boardrev) {
  647. case 5:
  648. /*
  649. * original production board; two production levels, with
  650. * different serial number ranges. See ipath_ht_early_init() for
  651. * case where we enable IPATH_GPIO_INTR for later serial # range.
  652. * Original 112* serial number is no longer supported.
  653. */
  654. n = "InfiniPath_QHT7040";
  655. break;
  656. case 7:
  657. /* small form factor production board */
  658. n = "InfiniPath_QHT7140";
  659. break;
  660. default: /* don't know, just print the number */
  661. ipath_dev_err(dd, "Don't yet know about board "
  662. "with ID %u\n", boardrev);
  663. snprintf(name, namelen, "Unknown_InfiniPath_QHT7xxx_%u",
  664. boardrev);
  665. break;
  666. }
  667. if (n)
  668. snprintf(name, namelen, "%s", n);
  669. if (ret) {
  670. ipath_dev_err(dd, "Unsupported InfiniPath board %s!\n", name);
  671. goto bail;
  672. }
  673. if (dd->ipath_majrev != 3 || (dd->ipath_minrev < 2 ||
  674. dd->ipath_minrev > 4)) {
  675. /*
  676. * This version of the driver only supports Rev 3.2 - 3.4
  677. */
  678. ipath_dev_err(dd,
  679. "Unsupported InfiniPath hardware revision %u.%u!\n",
  680. dd->ipath_majrev, dd->ipath_minrev);
  681. ret = 1;
  682. goto bail;
  683. }
  684. /*
  685. * pkt/word counters are 32 bit, and therefore wrap fast enough
  686. * that we snapshot them from a timer, and maintain 64 bit shadow
  687. * copies
  688. */
  689. dd->ipath_flags |= IPATH_32BITCOUNTERS;
  690. dd->ipath_flags |= IPATH_GPIO_INTR;
  691. if (dd->ipath_lbus_speed != 800)
  692. ipath_dev_err(dd,
  693. "Incorrectly configured for HT @ %uMHz\n",
  694. dd->ipath_lbus_speed);
  695. /*
  696. * set here, not in ipath_init_*_funcs because we have to do
  697. * it after we can read chip registers.
  698. */
  699. dd->ipath_ureg_align =
  700. ipath_read_kreg32(dd, dd->ipath_kregs->kr_pagealign);
  701. bail:
  702. return ret;
  703. }
  704. static void ipath_check_htlink(struct ipath_devdata *dd)
  705. {
  706. u8 linkerr, link_off, i;
  707. for (i = 0; i < 2; i++) {
  708. link_off = dd->ipath_ht_slave_off + i * 4 + 0xd;
  709. if (pci_read_config_byte(dd->pcidev, link_off, &linkerr))
  710. dev_info(&dd->pcidev->dev, "Couldn't read "
  711. "linkerror%d of HT slave/primary block\n",
  712. i);
  713. else if (linkerr & 0xf0) {
  714. ipath_cdbg(VERBOSE, "HT linkerr%d bits 0x%x set, "
  715. "clearing\n", linkerr >> 4, i);
  716. /*
  717. * writing the linkerr bits that are set should
  718. * clear them
  719. */
  720. if (pci_write_config_byte(dd->pcidev, link_off,
  721. linkerr))
  722. ipath_dbg("Failed write to clear HT "
  723. "linkerror%d\n", i);
  724. if (pci_read_config_byte(dd->pcidev, link_off,
  725. &linkerr))
  726. dev_info(&dd->pcidev->dev,
  727. "Couldn't reread linkerror%d of "
  728. "HT slave/primary block\n", i);
  729. else if (linkerr & 0xf0)
  730. dev_info(&dd->pcidev->dev,
  731. "HT linkerror%d bits 0x%x "
  732. "couldn't be cleared\n",
  733. i, linkerr >> 4);
  734. }
  735. }
  736. }
  737. static int ipath_setup_ht_reset(struct ipath_devdata *dd)
  738. {
  739. ipath_dbg("No reset possible for this InfiniPath hardware\n");
  740. return 0;
  741. }
  742. #define HT_INTR_DISC_CONFIG 0x80 /* HT interrupt and discovery cap */
  743. #define HT_INTR_REG_INDEX 2 /* intconfig requires indirect accesses */
  744. /*
  745. * Bits 13-15 of command==0 is slave/primary block. Clear any HT CRC
  746. * errors. We only bother to do this at load time, because it's OK if
  747. * it happened before we were loaded (first time after boot/reset),
  748. * but any time after that, it's fatal anyway. Also need to not check
  749. * for for upper byte errors if we are in 8 bit mode, so figure out
  750. * our width. For now, at least, also complain if it's 8 bit.
  751. */
  752. static void slave_or_pri_blk(struct ipath_devdata *dd, struct pci_dev *pdev,
  753. int pos, u8 cap_type)
  754. {
  755. u8 linkwidth = 0, linkerr, link_a_b_off, link_off;
  756. u16 linkctrl = 0;
  757. int i;
  758. dd->ipath_ht_slave_off = pos;
  759. /* command word, master_host bit */
  760. /* master host || slave */
  761. if ((cap_type >> 2) & 1)
  762. link_a_b_off = 4;
  763. else
  764. link_a_b_off = 0;
  765. ipath_cdbg(VERBOSE, "HT%u (Link %c) connected to processor\n",
  766. link_a_b_off ? 1 : 0,
  767. link_a_b_off ? 'B' : 'A');
  768. link_a_b_off += pos;
  769. /*
  770. * check both link control registers; clear both HT CRC sets if
  771. * necessary.
  772. */
  773. for (i = 0; i < 2; i++) {
  774. link_off = pos + i * 4 + 0x4;
  775. if (pci_read_config_word(pdev, link_off, &linkctrl))
  776. ipath_dev_err(dd, "Couldn't read HT link control%d "
  777. "register\n", i);
  778. else if (linkctrl & (0xf << 8)) {
  779. ipath_cdbg(VERBOSE, "Clear linkctrl%d CRC Error "
  780. "bits %x\n", i, linkctrl & (0xf << 8));
  781. /*
  782. * now write them back to clear the error.
  783. */
  784. pci_write_config_word(pdev, link_off,
  785. linkctrl & (0xf << 8));
  786. }
  787. }
  788. /*
  789. * As with HT CRC bits, same for protocol errors that might occur
  790. * during boot.
  791. */
  792. for (i = 0; i < 2; i++) {
  793. link_off = pos + i * 4 + 0xd;
  794. if (pci_read_config_byte(pdev, link_off, &linkerr))
  795. dev_info(&pdev->dev, "Couldn't read linkerror%d "
  796. "of HT slave/primary block\n", i);
  797. else if (linkerr & 0xf0) {
  798. ipath_cdbg(VERBOSE, "HT linkerr%d bits 0x%x set, "
  799. "clearing\n", linkerr >> 4, i);
  800. /*
  801. * writing the linkerr bits that are set will clear
  802. * them
  803. */
  804. if (pci_write_config_byte
  805. (pdev, link_off, linkerr))
  806. ipath_dbg("Failed write to clear HT "
  807. "linkerror%d\n", i);
  808. if (pci_read_config_byte(pdev, link_off, &linkerr))
  809. dev_info(&pdev->dev, "Couldn't reread "
  810. "linkerror%d of HT slave/primary "
  811. "block\n", i);
  812. else if (linkerr & 0xf0)
  813. dev_info(&pdev->dev, "HT linkerror%d bits "
  814. "0x%x couldn't be cleared\n",
  815. i, linkerr >> 4);
  816. }
  817. }
  818. /*
  819. * this is just for our link to the host, not devices connected
  820. * through tunnel.
  821. */
  822. if (pci_read_config_byte(pdev, link_a_b_off + 7, &linkwidth))
  823. ipath_dev_err(dd, "Couldn't read HT link width "
  824. "config register\n");
  825. else {
  826. u32 width;
  827. switch (linkwidth & 7) {
  828. case 5:
  829. width = 4;
  830. break;
  831. case 4:
  832. width = 2;
  833. break;
  834. case 3:
  835. width = 32;
  836. break;
  837. case 1:
  838. width = 16;
  839. break;
  840. case 0:
  841. default: /* if wrong, assume 8 bit */
  842. width = 8;
  843. break;
  844. }
  845. dd->ipath_lbus_width = width;
  846. if (linkwidth != 0x11) {
  847. ipath_dev_err(dd, "Not configured for 16 bit HT "
  848. "(%x)\n", linkwidth);
  849. if (!(linkwidth & 0xf)) {
  850. ipath_dbg("Will ignore HT lane1 errors\n");
  851. dd->ipath_flags |= IPATH_8BIT_IN_HT0;
  852. }
  853. }
  854. }
  855. /*
  856. * this is just for our link to the host, not devices connected
  857. * through tunnel.
  858. */
  859. if (pci_read_config_byte(pdev, link_a_b_off + 0xd, &linkwidth))
  860. ipath_dev_err(dd, "Couldn't read HT link frequency "
  861. "config register\n");
  862. else {
  863. u32 speed;
  864. switch (linkwidth & 0xf) {
  865. case 6:
  866. speed = 1000;
  867. break;
  868. case 5:
  869. speed = 800;
  870. break;
  871. case 4:
  872. speed = 600;
  873. break;
  874. case 3:
  875. speed = 500;
  876. break;
  877. case 2:
  878. speed = 400;
  879. break;
  880. case 1:
  881. speed = 300;
  882. break;
  883. default:
  884. /*
  885. * assume reserved and vendor-specific are 200...
  886. */
  887. case 0:
  888. speed = 200;
  889. break;
  890. }
  891. dd->ipath_lbus_speed = speed;
  892. }
  893. snprintf(dd->ipath_lbus_info, sizeof(dd->ipath_lbus_info),
  894. "HyperTransport,%uMHz,x%u\n",
  895. dd->ipath_lbus_speed,
  896. dd->ipath_lbus_width);
  897. }
  898. static int ipath_ht_intconfig(struct ipath_devdata *dd)
  899. {
  900. int ret;
  901. if (dd->ipath_intconfig) {
  902. ipath_write_kreg(dd, dd->ipath_kregs->kr_interruptconfig,
  903. dd->ipath_intconfig); /* interrupt address */
  904. ret = 0;
  905. } else {
  906. ipath_dev_err(dd, "No interrupts enabled, couldn't setup "
  907. "interrupt address\n");
  908. ret = -EINVAL;
  909. }
  910. return ret;
  911. }
  912. static void ipath_ht_irq_update(struct pci_dev *dev, int irq,
  913. struct ht_irq_msg *msg)
  914. {
  915. struct ipath_devdata *dd = pci_get_drvdata(dev);
  916. u64 prev_intconfig = dd->ipath_intconfig;
  917. dd->ipath_intconfig = msg->address_lo;
  918. dd->ipath_intconfig |= ((u64) msg->address_hi) << 32;
  919. /*
  920. * If the previous value of dd->ipath_intconfig is zero, we're
  921. * getting configured for the first time, and must not program the
  922. * intconfig register here (it will be programmed later, when the
  923. * hardware is ready). Otherwise, we should.
  924. */
  925. if (prev_intconfig)
  926. ipath_ht_intconfig(dd);
  927. }
  928. /**
  929. * ipath_setup_ht_config - setup the interruptconfig register
  930. * @dd: the infinipath device
  931. * @pdev: the PCI device
  932. *
  933. * setup the interruptconfig register from the HT config info.
  934. * Also clear CRC errors in HT linkcontrol, if necessary.
  935. * This is done only for the real hardware. It is done before
  936. * chip address space is initted, so can't touch infinipath registers
  937. */
  938. static int ipath_setup_ht_config(struct ipath_devdata *dd,
  939. struct pci_dev *pdev)
  940. {
  941. int pos, ret;
  942. ret = __ht_create_irq(pdev, 0, ipath_ht_irq_update);
  943. if (ret < 0) {
  944. ipath_dev_err(dd, "Couldn't create interrupt handler: "
  945. "err %d\n", ret);
  946. goto bail;
  947. }
  948. dd->ipath_irq = ret;
  949. ret = 0;
  950. /*
  951. * Handle clearing CRC errors in linkctrl register if necessary. We
  952. * do this early, before we ever enable errors or hardware errors,
  953. * mostly to avoid causing the chip to enter freeze mode.
  954. */
  955. pos = pci_find_capability(pdev, PCI_CAP_ID_HT);
  956. if (!pos) {
  957. ipath_dev_err(dd, "Couldn't find HyperTransport "
  958. "capability; no interrupts\n");
  959. ret = -ENODEV;
  960. goto bail;
  961. }
  962. do {
  963. u8 cap_type;
  964. /*
  965. * The HT capability type byte is 3 bytes after the
  966. * capability byte.
  967. */
  968. if (pci_read_config_byte(pdev, pos + 3, &cap_type)) {
  969. dev_info(&pdev->dev, "Couldn't read config "
  970. "command @ %d\n", pos);
  971. continue;
  972. }
  973. if (!(cap_type & 0xE0))
  974. slave_or_pri_blk(dd, pdev, pos, cap_type);
  975. } while ((pos = pci_find_next_capability(pdev, pos,
  976. PCI_CAP_ID_HT)));
  977. dd->ipath_flags |= IPATH_SWAP_PIOBUFS;
  978. bail:
  979. return ret;
  980. }
  981. /**
  982. * ipath_setup_ht_cleanup - clean up any per-chip chip-specific stuff
  983. * @dd: the infinipath device
  984. *
  985. * Called during driver unload.
  986. * This is currently a nop for the HT chip, not for all chips
  987. */
  988. static void ipath_setup_ht_cleanup(struct ipath_devdata *dd)
  989. {
  990. }
  991. /**
  992. * ipath_setup_ht_setextled - set the state of the two external LEDs
  993. * @dd: the infinipath device
  994. * @lst: the L state
  995. * @ltst: the LT state
  996. *
  997. * Set the state of the two external LEDs, to indicate physical and
  998. * logical state of IB link. For this chip (at least with recommended
  999. * board pinouts), LED1 is Green (physical state), and LED2 is Yellow
  1000. * (logical state)
  1001. *
  1002. * Note: We try to match the Mellanox HCA LED behavior as best
  1003. * we can. Green indicates physical link state is OK (something is
  1004. * plugged in, and we can train).
  1005. * Amber indicates the link is logically up (ACTIVE).
  1006. * Mellanox further blinks the amber LED to indicate data packet
  1007. * activity, but we have no hardware support for that, so it would
  1008. * require waking up every 10-20 msecs and checking the counters
  1009. * on the chip, and then turning the LED off if appropriate. That's
  1010. * visible overhead, so not something we will do.
  1011. *
  1012. */
  1013. static void ipath_setup_ht_setextled(struct ipath_devdata *dd,
  1014. u64 lst, u64 ltst)
  1015. {
  1016. u64 extctl;
  1017. unsigned long flags = 0;
  1018. /* the diags use the LED to indicate diag info, so we leave
  1019. * the external LED alone when the diags are running */
  1020. if (ipath_diag_inuse)
  1021. return;
  1022. /* Allow override of LED display for, e.g. Locating system in rack */
  1023. if (dd->ipath_led_override) {
  1024. ltst = (dd->ipath_led_override & IPATH_LED_PHYS)
  1025. ? INFINIPATH_IBCS_LT_STATE_LINKUP
  1026. : INFINIPATH_IBCS_LT_STATE_DISABLED;
  1027. lst = (dd->ipath_led_override & IPATH_LED_LOG)
  1028. ? INFINIPATH_IBCS_L_STATE_ACTIVE
  1029. : INFINIPATH_IBCS_L_STATE_DOWN;
  1030. }
  1031. spin_lock_irqsave(&dd->ipath_gpio_lock, flags);
  1032. /*
  1033. * start by setting both LED control bits to off, then turn
  1034. * on the appropriate bit(s).
  1035. */
  1036. if (dd->ipath_boardrev == 8) { /* LS/X-1 uses different pins */
  1037. /*
  1038. * major difference is that INFINIPATH_EXTC_LEDGBLERR_OFF
  1039. * is inverted, because it is normally used to indicate
  1040. * a hardware fault at reset, if there were errors
  1041. */
  1042. extctl = (dd->ipath_extctrl & ~INFINIPATH_EXTC_LEDGBLOK_ON)
  1043. | INFINIPATH_EXTC_LEDGBLERR_OFF;
  1044. if (ltst == INFINIPATH_IBCS_LT_STATE_LINKUP)
  1045. extctl &= ~INFINIPATH_EXTC_LEDGBLERR_OFF;
  1046. if (lst == INFINIPATH_IBCS_L_STATE_ACTIVE)
  1047. extctl |= INFINIPATH_EXTC_LEDGBLOK_ON;
  1048. }
  1049. else {
  1050. extctl = dd->ipath_extctrl &
  1051. ~(INFINIPATH_EXTC_LED1PRIPORT_ON |
  1052. INFINIPATH_EXTC_LED2PRIPORT_ON);
  1053. if (ltst == INFINIPATH_IBCS_LT_STATE_LINKUP)
  1054. extctl |= INFINIPATH_EXTC_LED1PRIPORT_ON;
  1055. if (lst == INFINIPATH_IBCS_L_STATE_ACTIVE)
  1056. extctl |= INFINIPATH_EXTC_LED2PRIPORT_ON;
  1057. }
  1058. dd->ipath_extctrl = extctl;
  1059. ipath_write_kreg(dd, dd->ipath_kregs->kr_extctrl, extctl);
  1060. spin_unlock_irqrestore(&dd->ipath_gpio_lock, flags);
  1061. }
  1062. static void ipath_init_ht_variables(struct ipath_devdata *dd)
  1063. {
  1064. /*
  1065. * setup the register offsets, since they are different for each
  1066. * chip
  1067. */
  1068. dd->ipath_kregs = &ipath_ht_kregs;
  1069. dd->ipath_cregs = &ipath_ht_cregs;
  1070. dd->ipath_gpio_sda_num = _IPATH_GPIO_SDA_NUM;
  1071. dd->ipath_gpio_scl_num = _IPATH_GPIO_SCL_NUM;
  1072. dd->ipath_gpio_sda = IPATH_GPIO_SDA;
  1073. dd->ipath_gpio_scl = IPATH_GPIO_SCL;
  1074. /*
  1075. * Fill in data for field-values that change in newer chips.
  1076. * We dynamically specify only the mask for LINKTRAININGSTATE
  1077. * and only the shift for LINKSTATE, as they are the only ones
  1078. * that change. Also precalculate the 3 link states of interest
  1079. * and the combined mask.
  1080. */
  1081. dd->ibcs_ls_shift = IBA6110_IBCS_LINKSTATE_SHIFT;
  1082. dd->ibcs_lts_mask = IBA6110_IBCS_LINKTRAININGSTATE_MASK;
  1083. dd->ibcs_mask = (INFINIPATH_IBCS_LINKSTATE_MASK <<
  1084. dd->ibcs_ls_shift) | dd->ibcs_lts_mask;
  1085. dd->ib_init = (INFINIPATH_IBCS_LT_STATE_LINKUP <<
  1086. INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) |
  1087. (INFINIPATH_IBCS_L_STATE_INIT << dd->ibcs_ls_shift);
  1088. dd->ib_arm = (INFINIPATH_IBCS_LT_STATE_LINKUP <<
  1089. INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) |
  1090. (INFINIPATH_IBCS_L_STATE_ARM << dd->ibcs_ls_shift);
  1091. dd->ib_active = (INFINIPATH_IBCS_LT_STATE_LINKUP <<
  1092. INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) |
  1093. (INFINIPATH_IBCS_L_STATE_ACTIVE << dd->ibcs_ls_shift);
  1094. /*
  1095. * Fill in data for ibcc field-values that change in newer chips.
  1096. * We dynamically specify only the mask for LINKINITCMD
  1097. * and only the shift for LINKCMD and MAXPKTLEN, as they are
  1098. * the only ones that change.
  1099. */
  1100. dd->ibcc_lic_mask = INFINIPATH_IBCC_LINKINITCMD_MASK;
  1101. dd->ibcc_lc_shift = INFINIPATH_IBCC_LINKCMD_SHIFT;
  1102. dd->ibcc_mpl_shift = INFINIPATH_IBCC_MAXPKTLEN_SHIFT;
  1103. /* Fill in shifts for RcvCtrl. */
  1104. dd->ipath_r_portenable_shift = INFINIPATH_R_PORTENABLE_SHIFT;
  1105. dd->ipath_r_intravail_shift = INFINIPATH_R_INTRAVAIL_SHIFT;
  1106. dd->ipath_r_tailupd_shift = INFINIPATH_R_TAILUPD_SHIFT;
  1107. dd->ipath_r_portcfg_shift = 0; /* Not on IBA6110 */
  1108. dd->ipath_i_bitsextant =
  1109. (INFINIPATH_I_RCVURG_MASK << INFINIPATH_I_RCVURG_SHIFT) |
  1110. (INFINIPATH_I_RCVAVAIL_MASK <<
  1111. INFINIPATH_I_RCVAVAIL_SHIFT) |
  1112. INFINIPATH_I_ERROR | INFINIPATH_I_SPIOSENT |
  1113. INFINIPATH_I_SPIOBUFAVAIL | INFINIPATH_I_GPIO;
  1114. dd->ipath_e_bitsextant =
  1115. INFINIPATH_E_RFORMATERR | INFINIPATH_E_RVCRC |
  1116. INFINIPATH_E_RICRC | INFINIPATH_E_RMINPKTLEN |
  1117. INFINIPATH_E_RMAXPKTLEN | INFINIPATH_E_RLONGPKTLEN |
  1118. INFINIPATH_E_RSHORTPKTLEN | INFINIPATH_E_RUNEXPCHAR |
  1119. INFINIPATH_E_RUNSUPVL | INFINIPATH_E_REBP |
  1120. INFINIPATH_E_RIBFLOW | INFINIPATH_E_RBADVERSION |
  1121. INFINIPATH_E_RRCVEGRFULL | INFINIPATH_E_RRCVHDRFULL |
  1122. INFINIPATH_E_RBADTID | INFINIPATH_E_RHDRLEN |
  1123. INFINIPATH_E_RHDR | INFINIPATH_E_RIBLOSTLINK |
  1124. INFINIPATH_E_SMINPKTLEN | INFINIPATH_E_SMAXPKTLEN |
  1125. INFINIPATH_E_SUNDERRUN | INFINIPATH_E_SPKTLEN |
  1126. INFINIPATH_E_SDROPPEDSMPPKT | INFINIPATH_E_SDROPPEDDATAPKT |
  1127. INFINIPATH_E_SPIOARMLAUNCH | INFINIPATH_E_SUNEXPERRPKTNUM |
  1128. INFINIPATH_E_SUNSUPVL | INFINIPATH_E_IBSTATUSCHANGED |
  1129. INFINIPATH_E_INVALIDADDR | INFINIPATH_E_RESET |
  1130. INFINIPATH_E_HARDWARE;
  1131. dd->ipath_hwe_bitsextant =
  1132. (INFINIPATH_HWE_HTCMEMPARITYERR_MASK <<
  1133. INFINIPATH_HWE_HTCMEMPARITYERR_SHIFT) |
  1134. (INFINIPATH_HWE_TXEMEMPARITYERR_MASK <<
  1135. INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT) |
  1136. (INFINIPATH_HWE_RXEMEMPARITYERR_MASK <<
  1137. INFINIPATH_HWE_RXEMEMPARITYERR_SHIFT) |
  1138. INFINIPATH_HWE_HTCLNKABYTE0CRCERR |
  1139. INFINIPATH_HWE_HTCLNKABYTE1CRCERR |
  1140. INFINIPATH_HWE_HTCLNKBBYTE0CRCERR |
  1141. INFINIPATH_HWE_HTCLNKBBYTE1CRCERR |
  1142. INFINIPATH_HWE_HTCMISCERR4 |
  1143. INFINIPATH_HWE_HTCMISCERR5 | INFINIPATH_HWE_HTCMISCERR6 |
  1144. INFINIPATH_HWE_HTCMISCERR7 |
  1145. INFINIPATH_HWE_HTCBUSTREQPARITYERR |
  1146. INFINIPATH_HWE_HTCBUSTRESPPARITYERR |
  1147. INFINIPATH_HWE_HTCBUSIREQPARITYERR |
  1148. INFINIPATH_HWE_RXDSYNCMEMPARITYERR |
  1149. INFINIPATH_HWE_MEMBISTFAILED |
  1150. INFINIPATH_HWE_COREPLL_FBSLIP |
  1151. INFINIPATH_HWE_COREPLL_RFSLIP |
  1152. INFINIPATH_HWE_HTBPLL_FBSLIP |
  1153. INFINIPATH_HWE_HTBPLL_RFSLIP |
  1154. INFINIPATH_HWE_HTAPLL_FBSLIP |
  1155. INFINIPATH_HWE_HTAPLL_RFSLIP |
  1156. INFINIPATH_HWE_SERDESPLLFAILED |
  1157. INFINIPATH_HWE_IBCBUSTOSPCPARITYERR |
  1158. INFINIPATH_HWE_IBCBUSFRSPCPARITYERR;
  1159. dd->ipath_i_rcvavail_mask = INFINIPATH_I_RCVAVAIL_MASK;
  1160. dd->ipath_i_rcvurg_mask = INFINIPATH_I_RCVURG_MASK;
  1161. dd->ipath_i_rcvavail_shift = INFINIPATH_I_RCVAVAIL_SHIFT;
  1162. dd->ipath_i_rcvurg_shift = INFINIPATH_I_RCVURG_SHIFT;
  1163. /*
  1164. * EEPROM error log 0 is TXE Parity errors. 1 is RXE Parity.
  1165. * 2 is Some Misc, 3 is reserved for future.
  1166. */
  1167. dd->ipath_eep_st_masks[0].hwerrs_to_log =
  1168. INFINIPATH_HWE_TXEMEMPARITYERR_MASK <<
  1169. INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT;
  1170. dd->ipath_eep_st_masks[1].hwerrs_to_log =
  1171. INFINIPATH_HWE_RXEMEMPARITYERR_MASK <<
  1172. INFINIPATH_HWE_RXEMEMPARITYERR_SHIFT;
  1173. dd->ipath_eep_st_masks[2].errs_to_log = INFINIPATH_E_RESET;
  1174. dd->delay_mult = 2; /* SDR, 4X, can't change */
  1175. dd->ipath_link_width_supported = IB_WIDTH_1X | IB_WIDTH_4X;
  1176. dd->ipath_link_speed_supported = IPATH_IB_SDR;
  1177. dd->ipath_link_width_enabled = IB_WIDTH_4X;
  1178. dd->ipath_link_speed_enabled = dd->ipath_link_speed_supported;
  1179. /* these can't change for this chip, so set once */
  1180. dd->ipath_link_width_active = dd->ipath_link_width_enabled;
  1181. dd->ipath_link_speed_active = dd->ipath_link_speed_enabled;
  1182. }
  1183. /**
  1184. * ipath_ht_init_hwerrors - enable hardware errors
  1185. * @dd: the infinipath device
  1186. *
  1187. * now that we have finished initializing everything that might reasonably
  1188. * cause a hardware error, and cleared those errors bits as they occur,
  1189. * we can enable hardware errors in the mask (potentially enabling
  1190. * freeze mode), and enable hardware errors as errors (along with
  1191. * everything else) in errormask
  1192. */
  1193. static void ipath_ht_init_hwerrors(struct ipath_devdata *dd)
  1194. {
  1195. ipath_err_t val;
  1196. u64 extsval;
  1197. extsval = ipath_read_kreg64(dd, dd->ipath_kregs->kr_extstatus);
  1198. if (!(extsval & INFINIPATH_EXTS_MEMBIST_ENDTEST))
  1199. ipath_dev_err(dd, "MemBIST did not complete!\n");
  1200. if (extsval & INFINIPATH_EXTS_MEMBIST_CORRECT)
  1201. ipath_dbg("MemBIST corrected\n");
  1202. ipath_check_htlink(dd);
  1203. /* barring bugs, all hwerrors become interrupts, which can */
  1204. val = -1LL;
  1205. /* don't look at crc lane1 if 8 bit */
  1206. if (dd->ipath_flags & IPATH_8BIT_IN_HT0)
  1207. val &= ~infinipath_hwe_htclnkabyte1crcerr;
  1208. /* don't look at crc lane1 if 8 bit */
  1209. if (dd->ipath_flags & IPATH_8BIT_IN_HT1)
  1210. val &= ~infinipath_hwe_htclnkbbyte1crcerr;
  1211. /*
  1212. * disable RXDSYNCMEMPARITY because external serdes is unused,
  1213. * and therefore the logic will never be used or initialized,
  1214. * and uninitialized state will normally result in this error
  1215. * being asserted. Similarly for the external serdess pll
  1216. * lock signal.
  1217. */
  1218. val &= ~(INFINIPATH_HWE_SERDESPLLFAILED |
  1219. INFINIPATH_HWE_RXDSYNCMEMPARITYERR);
  1220. /*
  1221. * Disable MISCERR4 because of an inversion in the HT core
  1222. * logic checking for errors that cause this bit to be set.
  1223. * The errata can also cause the protocol error bit to be set
  1224. * in the HT config space linkerror register(s).
  1225. */
  1226. val &= ~INFINIPATH_HWE_HTCMISCERR4;
  1227. /*
  1228. * PLL ignored because unused MDIO interface has a logic problem
  1229. */
  1230. if (dd->ipath_boardrev == 4 || dd->ipath_boardrev == 9)
  1231. val &= ~INFINIPATH_HWE_SERDESPLLFAILED;
  1232. dd->ipath_hwerrmask = val;
  1233. }
  1234. /**
  1235. * ipath_ht_bringup_serdes - bring up the serdes
  1236. * @dd: the infinipath device
  1237. */
  1238. static int ipath_ht_bringup_serdes(struct ipath_devdata *dd)
  1239. {
  1240. u64 val, config1;
  1241. int ret = 0, change = 0;
  1242. ipath_dbg("Trying to bringup serdes\n");
  1243. if (ipath_read_kreg64(dd, dd->ipath_kregs->kr_hwerrstatus) &
  1244. INFINIPATH_HWE_SERDESPLLFAILED)
  1245. {
  1246. ipath_dbg("At start, serdes PLL failed bit set in "
  1247. "hwerrstatus, clearing and continuing\n");
  1248. ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrclear,
  1249. INFINIPATH_HWE_SERDESPLLFAILED);
  1250. }
  1251. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig0);
  1252. config1 = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig1);
  1253. ipath_cdbg(VERBOSE, "Initial serdes status is config0=%llx "
  1254. "config1=%llx, sstatus=%llx xgxs %llx\n",
  1255. (unsigned long long) val, (unsigned long long) config1,
  1256. (unsigned long long)
  1257. ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesstatus),
  1258. (unsigned long long)
  1259. ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig));
  1260. /* force reset on */
  1261. val |= INFINIPATH_SERDC0_RESET_PLL
  1262. /* | INFINIPATH_SERDC0_RESET_MASK */
  1263. ;
  1264. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);
  1265. udelay(15); /* need pll reset set at least for a bit */
  1266. if (val & INFINIPATH_SERDC0_RESET_PLL) {
  1267. u64 val2 = val &= ~INFINIPATH_SERDC0_RESET_PLL;
  1268. /* set lane resets, and tx idle, during pll reset */
  1269. val2 |= INFINIPATH_SERDC0_RESET_MASK |
  1270. INFINIPATH_SERDC0_TXIDLE;
  1271. ipath_cdbg(VERBOSE, "Clearing serdes PLL reset (writing "
  1272. "%llx)\n", (unsigned long long) val2);
  1273. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0,
  1274. val2);
  1275. /*
  1276. * be sure chip saw it
  1277. */
  1278. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
  1279. /*
  1280. * need pll reset clear at least 11 usec before lane
  1281. * resets cleared; give it a few more
  1282. */
  1283. udelay(15);
  1284. val = val2; /* for check below */
  1285. }
  1286. if (val & (INFINIPATH_SERDC0_RESET_PLL |
  1287. INFINIPATH_SERDC0_RESET_MASK |
  1288. INFINIPATH_SERDC0_TXIDLE)) {
  1289. val &= ~(INFINIPATH_SERDC0_RESET_PLL |
  1290. INFINIPATH_SERDC0_RESET_MASK |
  1291. INFINIPATH_SERDC0_TXIDLE);
  1292. /* clear them */
  1293. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0,
  1294. val);
  1295. }
  1296. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig);
  1297. if (val & INFINIPATH_XGXS_RESET) {
  1298. /* normally true after boot */
  1299. val &= ~INFINIPATH_XGXS_RESET;
  1300. change = 1;
  1301. }
  1302. if (((val >> INFINIPATH_XGXS_RX_POL_SHIFT) &
  1303. INFINIPATH_XGXS_RX_POL_MASK) != dd->ipath_rx_pol_inv ) {
  1304. /* need to compensate for Tx inversion in partner */
  1305. val &= ~(INFINIPATH_XGXS_RX_POL_MASK <<
  1306. INFINIPATH_XGXS_RX_POL_SHIFT);
  1307. val |= dd->ipath_rx_pol_inv <<
  1308. INFINIPATH_XGXS_RX_POL_SHIFT;
  1309. change = 1;
  1310. }
  1311. if (change)
  1312. ipath_write_kreg(dd, dd->ipath_kregs->kr_xgxsconfig, val);
  1313. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig0);
  1314. /* clear current and de-emphasis bits */
  1315. config1 &= ~0x0ffffffff00ULL;
  1316. /* set current to 20ma */
  1317. config1 |= 0x00000000000ULL;
  1318. /* set de-emphasis to -5.68dB */
  1319. config1 |= 0x0cccc000000ULL;
  1320. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig1, config1);
  1321. ipath_cdbg(VERBOSE, "After setup: serdes status is config0=%llx "
  1322. "config1=%llx, sstatus=%llx xgxs %llx\n",
  1323. (unsigned long long) val, (unsigned long long) config1,
  1324. (unsigned long long)
  1325. ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesstatus),
  1326. (unsigned long long)
  1327. ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig));
  1328. return ret; /* for now, say we always succeeded */
  1329. }
  1330. /**
  1331. * ipath_ht_quiet_serdes - set serdes to txidle
  1332. * @dd: the infinipath device
  1333. * driver is being unloaded
  1334. */
  1335. static void ipath_ht_quiet_serdes(struct ipath_devdata *dd)
  1336. {
  1337. u64 val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig0);
  1338. val |= INFINIPATH_SERDC0_TXIDLE;
  1339. ipath_dbg("Setting TxIdleEn on serdes (config0 = %llx)\n",
  1340. (unsigned long long) val);
  1341. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);
  1342. }
  1343. /**
  1344. * ipath_pe_put_tid - write a TID in chip
  1345. * @dd: the infinipath device
  1346. * @tidptr: pointer to the expected TID (in chip) to udpate
  1347. * @tidtype: RCVHQ_RCV_TYPE_EAGER (1) for eager, RCVHQ_RCV_TYPE_EXPECTED (0) for expected
  1348. * @pa: physical address of in memory buffer; ipath_tidinvalid if freeing
  1349. *
  1350. * This exists as a separate routine to allow for special locking etc.
  1351. * It's used for both the full cleanup on exit, as well as the normal
  1352. * setup and teardown.
  1353. */
  1354. static void ipath_ht_put_tid(struct ipath_devdata *dd,
  1355. u64 __iomem *tidptr, u32 type,
  1356. unsigned long pa)
  1357. {
  1358. if (!dd->ipath_kregbase)
  1359. return;
  1360. if (pa != dd->ipath_tidinvalid) {
  1361. if (unlikely((pa & ~INFINIPATH_RT_ADDR_MASK))) {
  1362. dev_info(&dd->pcidev->dev,
  1363. "physaddr %lx has more than "
  1364. "40 bits, using only 40!!!\n", pa);
  1365. pa &= INFINIPATH_RT_ADDR_MASK;
  1366. }
  1367. if (type == RCVHQ_RCV_TYPE_EAGER)
  1368. pa |= dd->ipath_tidtemplate;
  1369. else {
  1370. /* in words (fixed, full page). */
  1371. u64 lenvalid = PAGE_SIZE >> 2;
  1372. lenvalid <<= INFINIPATH_RT_BUFSIZE_SHIFT;
  1373. pa |= lenvalid | INFINIPATH_RT_VALID;
  1374. }
  1375. }
  1376. writeq(pa, tidptr);
  1377. }
  1378. /**
  1379. * ipath_ht_clear_tid - clear all TID entries for a port, expected and eager
  1380. * @dd: the infinipath device
  1381. * @port: the port
  1382. *
  1383. * Used from ipath_close(), and at chip initialization.
  1384. */
  1385. static void ipath_ht_clear_tids(struct ipath_devdata *dd, unsigned port)
  1386. {
  1387. u64 __iomem *tidbase;
  1388. int i;
  1389. if (!dd->ipath_kregbase)
  1390. return;
  1391. ipath_cdbg(VERBOSE, "Invalidate TIDs for port %u\n", port);
  1392. /*
  1393. * need to invalidate all of the expected TID entries for this
  1394. * port, so we don't have valid entries that might somehow get
  1395. * used (early in next use of this port, or through some bug)
  1396. */
  1397. tidbase = (u64 __iomem *) ((char __iomem *)(dd->ipath_kregbase) +
  1398. dd->ipath_rcvtidbase +
  1399. port * dd->ipath_rcvtidcnt *
  1400. sizeof(*tidbase));
  1401. for (i = 0; i < dd->ipath_rcvtidcnt; i++)
  1402. ipath_ht_put_tid(dd, &tidbase[i], RCVHQ_RCV_TYPE_EXPECTED,
  1403. dd->ipath_tidinvalid);
  1404. tidbase = (u64 __iomem *) ((char __iomem *)(dd->ipath_kregbase) +
  1405. dd->ipath_rcvegrbase +
  1406. port * dd->ipath_rcvegrcnt *
  1407. sizeof(*tidbase));
  1408. for (i = 0; i < dd->ipath_rcvegrcnt; i++)
  1409. ipath_ht_put_tid(dd, &tidbase[i], RCVHQ_RCV_TYPE_EAGER,
  1410. dd->ipath_tidinvalid);
  1411. }
  1412. /**
  1413. * ipath_ht_tidtemplate - setup constants for TID updates
  1414. * @dd: the infinipath device
  1415. *
  1416. * We setup stuff that we use a lot, to avoid calculating each time
  1417. */
  1418. static void ipath_ht_tidtemplate(struct ipath_devdata *dd)
  1419. {
  1420. dd->ipath_tidtemplate = dd->ipath_ibmaxlen >> 2;
  1421. dd->ipath_tidtemplate <<= INFINIPATH_RT_BUFSIZE_SHIFT;
  1422. dd->ipath_tidtemplate |= INFINIPATH_RT_VALID;
  1423. /*
  1424. * work around chip errata bug 7358, by marking invalid tids
  1425. * as having max length
  1426. */
  1427. dd->ipath_tidinvalid = (-1LL & INFINIPATH_RT_BUFSIZE_MASK) <<
  1428. INFINIPATH_RT_BUFSIZE_SHIFT;
  1429. }
  1430. static int ipath_ht_early_init(struct ipath_devdata *dd)
  1431. {
  1432. u32 __iomem *piobuf;
  1433. u32 pioincr, val32;
  1434. int i;
  1435. /*
  1436. * one cache line; long IB headers will spill over into received
  1437. * buffer
  1438. */
  1439. dd->ipath_rcvhdrentsize = 16;
  1440. dd->ipath_rcvhdrsize = IPATH_DFLT_RCVHDRSIZE;
  1441. /*
  1442. * For HT, we allocate a somewhat overly large eager buffer,
  1443. * such that we can guarantee that we can receive the largest
  1444. * packet that we can send out. To truly support a 4KB MTU,
  1445. * we need to bump this to a large value. To date, other than
  1446. * testing, we have never encountered an HCA that can really
  1447. * send 4KB MTU packets, so we do not handle that (we'll get
  1448. * errors interrupts if we ever see one).
  1449. */
  1450. dd->ipath_rcvegrbufsize = dd->ipath_piosize2k;
  1451. /*
  1452. * the min() check here is currently a nop, but it may not
  1453. * always be, depending on just how we do ipath_rcvegrbufsize
  1454. */
  1455. dd->ipath_ibmaxlen = min(dd->ipath_piosize2k,
  1456. dd->ipath_rcvegrbufsize);
  1457. dd->ipath_init_ibmaxlen = dd->ipath_ibmaxlen;
  1458. ipath_ht_tidtemplate(dd);
  1459. /*
  1460. * zero all the TID entries at startup. We do this for sanity,
  1461. * in case of a previous driver crash of some kind, and also
  1462. * because the chip powers up with these memories in an unknown
  1463. * state. Use portcnt, not cfgports, since this is for the
  1464. * full chip, not for current (possibly different) configuration
  1465. * value.
  1466. * Chip Errata bug 6447
  1467. */
  1468. for (val32 = 0; val32 < dd->ipath_portcnt; val32++)
  1469. ipath_ht_clear_tids(dd, val32);
  1470. /*
  1471. * write the pbc of each buffer, to be sure it's initialized, then
  1472. * cancel all the buffers, and also abort any packets that might
  1473. * have been in flight for some reason (the latter is for driver
  1474. * unload/reload, but isn't a bad idea at first init). PIO send
  1475. * isn't enabled at this point, so there is no danger of sending
  1476. * these out on the wire.
  1477. * Chip Errata bug 6610
  1478. */
  1479. piobuf = (u32 __iomem *) (((char __iomem *)(dd->ipath_kregbase)) +
  1480. dd->ipath_piobufbase);
  1481. pioincr = dd->ipath_palign / sizeof(*piobuf);
  1482. for (i = 0; i < dd->ipath_piobcnt2k; i++) {
  1483. /*
  1484. * reasonable word count, just to init pbc
  1485. */
  1486. writel(16, piobuf);
  1487. piobuf += pioincr;
  1488. }
  1489. ipath_get_eeprom_info(dd);
  1490. if (dd->ipath_boardrev == 5) {
  1491. /*
  1492. * Later production QHT7040 has same changes as QHT7140, so
  1493. * can use GPIO interrupts. They have serial #'s starting
  1494. * with 128, rather than 112.
  1495. */
  1496. if (dd->ipath_serial[0] == '1' &&
  1497. dd->ipath_serial[1] == '2' &&
  1498. dd->ipath_serial[2] == '8')
  1499. dd->ipath_flags |= IPATH_GPIO_INTR;
  1500. else {
  1501. ipath_dev_err(dd, "Unsupported InfiniPath board "
  1502. "(serial number %.16s)!\n",
  1503. dd->ipath_serial);
  1504. return 1;
  1505. }
  1506. }
  1507. if (dd->ipath_minrev >= 4) {
  1508. /* Rev4+ reports extra errors via internal GPIO pins */
  1509. dd->ipath_flags |= IPATH_GPIO_ERRINTRS;
  1510. dd->ipath_gpio_mask |= IPATH_GPIO_ERRINTR_MASK;
  1511. ipath_write_kreg(dd, dd->ipath_kregs->kr_gpio_mask,
  1512. dd->ipath_gpio_mask);
  1513. }
  1514. return 0;
  1515. }
  1516. /**
  1517. * ipath_init_ht_get_base_info - set chip-specific flags for user code
  1518. * @dd: the infinipath device
  1519. * @kbase: ipath_base_info pointer
  1520. *
  1521. * We set the PCIE flag because the lower bandwidth on PCIe vs
  1522. * HyperTransport can affect some user packet algorithms.
  1523. */
  1524. static int ipath_ht_get_base_info(struct ipath_portdata *pd, void *kbase)
  1525. {
  1526. struct ipath_base_info *kinfo = kbase;
  1527. kinfo->spi_runtime_flags |= IPATH_RUNTIME_HT |
  1528. IPATH_RUNTIME_PIO_REGSWAPPED;
  1529. if (pd->port_dd->ipath_minrev < 4)
  1530. kinfo->spi_runtime_flags |= IPATH_RUNTIME_RCVHDR_COPY;
  1531. return 0;
  1532. }
  1533. static void ipath_ht_free_irq(struct ipath_devdata *dd)
  1534. {
  1535. free_irq(dd->ipath_irq, dd);
  1536. ht_destroy_irq(dd->ipath_irq);
  1537. dd->ipath_irq = 0;
  1538. dd->ipath_intconfig = 0;
  1539. }
  1540. static struct ipath_message_header *
  1541. ipath_ht_get_msgheader(struct ipath_devdata *dd, __le32 *rhf_addr)
  1542. {
  1543. return (struct ipath_message_header *)
  1544. &rhf_addr[sizeof(u64) / sizeof(u32)];
  1545. }
  1546. static void ipath_ht_config_ports(struct ipath_devdata *dd, ushort cfgports)
  1547. {
  1548. dd->ipath_portcnt =
  1549. ipath_read_kreg32(dd, dd->ipath_kregs->kr_portcnt);
  1550. dd->ipath_p0_rcvegrcnt =
  1551. ipath_read_kreg32(dd, dd->ipath_kregs->kr_rcvegrcnt);
  1552. }
  1553. static void ipath_ht_read_counters(struct ipath_devdata *dd,
  1554. struct infinipath_counters *cntrs)
  1555. {
  1556. cntrs->LBIntCnt =
  1557. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(LBIntCnt));
  1558. cntrs->LBFlowStallCnt =
  1559. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(LBFlowStallCnt));
  1560. cntrs->TxSDmaDescCnt = 0;
  1561. cntrs->TxUnsupVLErrCnt =
  1562. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxUnsupVLErrCnt));
  1563. cntrs->TxDataPktCnt =
  1564. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxDataPktCnt));
  1565. cntrs->TxFlowPktCnt =
  1566. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxFlowPktCnt));
  1567. cntrs->TxDwordCnt =
  1568. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxDwordCnt));
  1569. cntrs->TxLenErrCnt =
  1570. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxLenErrCnt));
  1571. cntrs->TxMaxMinLenErrCnt =
  1572. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxMaxMinLenErrCnt));
  1573. cntrs->TxUnderrunCnt =
  1574. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxUnderrunCnt));
  1575. cntrs->TxFlowStallCnt =
  1576. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxFlowStallCnt));
  1577. cntrs->TxDroppedPktCnt =
  1578. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxDroppedPktCnt));
  1579. cntrs->RxDroppedPktCnt =
  1580. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxDroppedPktCnt));
  1581. cntrs->RxDataPktCnt =
  1582. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxDataPktCnt));
  1583. cntrs->RxFlowPktCnt =
  1584. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxFlowPktCnt));
  1585. cntrs->RxDwordCnt =
  1586. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxDwordCnt));
  1587. cntrs->RxLenErrCnt =
  1588. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxLenErrCnt));
  1589. cntrs->RxMaxMinLenErrCnt =
  1590. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxMaxMinLenErrCnt));
  1591. cntrs->RxICRCErrCnt =
  1592. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxICRCErrCnt));
  1593. cntrs->RxVCRCErrCnt =
  1594. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxVCRCErrCnt));
  1595. cntrs->RxFlowCtrlErrCnt =
  1596. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxFlowCtrlErrCnt));
  1597. cntrs->RxBadFormatCnt =
  1598. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxBadFormatCnt));
  1599. cntrs->RxLinkProblemCnt =
  1600. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxLinkProblemCnt));
  1601. cntrs->RxEBPCnt =
  1602. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxEBPCnt));
  1603. cntrs->RxLPCRCErrCnt =
  1604. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxLPCRCErrCnt));
  1605. cntrs->RxBufOvflCnt =
  1606. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxBufOvflCnt));
  1607. cntrs->RxTIDFullErrCnt =
  1608. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxTIDFullErrCnt));
  1609. cntrs->RxTIDValidErrCnt =
  1610. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxTIDValidErrCnt));
  1611. cntrs->RxPKeyMismatchCnt =
  1612. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxPKeyMismatchCnt));
  1613. cntrs->RxP0HdrEgrOvflCnt =
  1614. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP0HdrEgrOvflCnt));
  1615. cntrs->RxP1HdrEgrOvflCnt =
  1616. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP1HdrEgrOvflCnt));
  1617. cntrs->RxP2HdrEgrOvflCnt =
  1618. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP2HdrEgrOvflCnt));
  1619. cntrs->RxP3HdrEgrOvflCnt =
  1620. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP3HdrEgrOvflCnt));
  1621. cntrs->RxP4HdrEgrOvflCnt =
  1622. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP4HdrEgrOvflCnt));
  1623. cntrs->RxP5HdrEgrOvflCnt =
  1624. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP5HdrEgrOvflCnt));
  1625. cntrs->RxP6HdrEgrOvflCnt =
  1626. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP6HdrEgrOvflCnt));
  1627. cntrs->RxP7HdrEgrOvflCnt =
  1628. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP7HdrEgrOvflCnt));
  1629. cntrs->RxP8HdrEgrOvflCnt =
  1630. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP8HdrEgrOvflCnt));
  1631. cntrs->RxP9HdrEgrOvflCnt = 0;
  1632. cntrs->RxP10HdrEgrOvflCnt = 0;
  1633. cntrs->RxP11HdrEgrOvflCnt = 0;
  1634. cntrs->RxP12HdrEgrOvflCnt = 0;
  1635. cntrs->RxP13HdrEgrOvflCnt = 0;
  1636. cntrs->RxP14HdrEgrOvflCnt = 0;
  1637. cntrs->RxP15HdrEgrOvflCnt = 0;
  1638. cntrs->RxP16HdrEgrOvflCnt = 0;
  1639. cntrs->IBStatusChangeCnt =
  1640. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(IBStatusChangeCnt));
  1641. cntrs->IBLinkErrRecoveryCnt =
  1642. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(IBLinkErrRecoveryCnt));
  1643. cntrs->IBLinkDownedCnt =
  1644. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(IBLinkDownedCnt));
  1645. cntrs->IBSymbolErrCnt =
  1646. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(IBSymbolErrCnt));
  1647. cntrs->RxVL15DroppedPktCnt = 0;
  1648. cntrs->RxOtherLocalPhyErrCnt = 0;
  1649. cntrs->PcieRetryBufDiagQwordCnt = 0;
  1650. cntrs->ExcessBufferOvflCnt = dd->ipath_overrun_thresh_errs;
  1651. cntrs->LocalLinkIntegrityErrCnt =
  1652. (dd->ipath_flags & IPATH_GPIO_ERRINTRS) ?
  1653. dd->ipath_lli_errs : dd->ipath_lli_errors;
  1654. cntrs->RxVlErrCnt = 0;
  1655. cntrs->RxDlidFltrCnt = 0;
  1656. }
  1657. /* no interrupt fallback for these chips */
  1658. static int ipath_ht_nointr_fallback(struct ipath_devdata *dd)
  1659. {
  1660. return 0;
  1661. }
  1662. /*
  1663. * reset the XGXS (between serdes and IBC). Slightly less intrusive
  1664. * than resetting the IBC or external link state, and useful in some
  1665. * cases to cause some retraining. To do this right, we reset IBC
  1666. * as well.
  1667. */
  1668. static void ipath_ht_xgxs_reset(struct ipath_devdata *dd)
  1669. {
  1670. u64 val, prev_val;
  1671. prev_val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig);
  1672. val = prev_val | INFINIPATH_XGXS_RESET;
  1673. prev_val &= ~INFINIPATH_XGXS_RESET; /* be sure */
  1674. ipath_write_kreg(dd, dd->ipath_kregs->kr_control,
  1675. dd->ipath_control & ~INFINIPATH_C_LINKENABLE);
  1676. ipath_write_kreg(dd, dd->ipath_kregs->kr_xgxsconfig, val);
  1677. ipath_read_kreg32(dd, dd->ipath_kregs->kr_scratch);
  1678. ipath_write_kreg(dd, dd->ipath_kregs->kr_xgxsconfig, prev_val);
  1679. ipath_write_kreg(dd, dd->ipath_kregs->kr_control,
  1680. dd->ipath_control);
  1681. }
  1682. static int ipath_ht_get_ib_cfg(struct ipath_devdata *dd, int which)
  1683. {
  1684. int ret;
  1685. switch (which) {
  1686. case IPATH_IB_CFG_LWID:
  1687. ret = dd->ipath_link_width_active;
  1688. break;
  1689. case IPATH_IB_CFG_SPD:
  1690. ret = dd->ipath_link_speed_active;
  1691. break;
  1692. case IPATH_IB_CFG_LWID_ENB:
  1693. ret = dd->ipath_link_width_enabled;
  1694. break;
  1695. case IPATH_IB_CFG_SPD_ENB:
  1696. ret = dd->ipath_link_speed_enabled;
  1697. break;
  1698. default:
  1699. ret = -ENOTSUPP;
  1700. break;
  1701. }
  1702. return ret;
  1703. }
  1704. /* we assume range checking is already done, if needed */
  1705. static int ipath_ht_set_ib_cfg(struct ipath_devdata *dd, int which, u32 val)
  1706. {
  1707. int ret = 0;
  1708. if (which == IPATH_IB_CFG_LWID_ENB)
  1709. dd->ipath_link_width_enabled = val;
  1710. else if (which == IPATH_IB_CFG_SPD_ENB)
  1711. dd->ipath_link_speed_enabled = val;
  1712. else
  1713. ret = -ENOTSUPP;
  1714. return ret;
  1715. }
  1716. static void ipath_ht_config_jint(struct ipath_devdata *dd, u16 a, u16 b)
  1717. {
  1718. }
  1719. static int ipath_ht_ib_updown(struct ipath_devdata *dd, int ibup, u64 ibcs)
  1720. {
  1721. ipath_setup_ht_setextled(dd, ipath_ib_linkstate(dd, ibcs),
  1722. ipath_ib_linktrstate(dd, ibcs));
  1723. return 0;
  1724. }
  1725. /**
  1726. * ipath_init_iba6110_funcs - set up the chip-specific function pointers
  1727. * @dd: the infinipath device
  1728. *
  1729. * This is global, and is called directly at init to set up the
  1730. * chip-specific function pointers for later use.
  1731. */
  1732. void ipath_init_iba6110_funcs(struct ipath_devdata *dd)
  1733. {
  1734. dd->ipath_f_intrsetup = ipath_ht_intconfig;
  1735. dd->ipath_f_bus = ipath_setup_ht_config;
  1736. dd->ipath_f_reset = ipath_setup_ht_reset;
  1737. dd->ipath_f_get_boardname = ipath_ht_boardname;
  1738. dd->ipath_f_init_hwerrors = ipath_ht_init_hwerrors;
  1739. dd->ipath_f_early_init = ipath_ht_early_init;
  1740. dd->ipath_f_handle_hwerrors = ipath_ht_handle_hwerrors;
  1741. dd->ipath_f_quiet_serdes = ipath_ht_quiet_serdes;
  1742. dd->ipath_f_bringup_serdes = ipath_ht_bringup_serdes;
  1743. dd->ipath_f_clear_tids = ipath_ht_clear_tids;
  1744. dd->ipath_f_put_tid = ipath_ht_put_tid;
  1745. dd->ipath_f_cleanup = ipath_setup_ht_cleanup;
  1746. dd->ipath_f_setextled = ipath_setup_ht_setextled;
  1747. dd->ipath_f_get_base_info = ipath_ht_get_base_info;
  1748. dd->ipath_f_free_irq = ipath_ht_free_irq;
  1749. dd->ipath_f_tidtemplate = ipath_ht_tidtemplate;
  1750. dd->ipath_f_intr_fallback = ipath_ht_nointr_fallback;
  1751. dd->ipath_f_get_msgheader = ipath_ht_get_msgheader;
  1752. dd->ipath_f_config_ports = ipath_ht_config_ports;
  1753. dd->ipath_f_read_counters = ipath_ht_read_counters;
  1754. dd->ipath_f_xgxs_reset = ipath_ht_xgxs_reset;
  1755. dd->ipath_f_get_ib_cfg = ipath_ht_get_ib_cfg;
  1756. dd->ipath_f_set_ib_cfg = ipath_ht_set_ib_cfg;
  1757. dd->ipath_f_config_jint = ipath_ht_config_jint;
  1758. dd->ipath_f_ib_updown = ipath_ht_ib_updown;
  1759. /*
  1760. * initialize chip-specific variables
  1761. */
  1762. ipath_init_ht_variables(dd);
  1763. }