ipath_iba6110.c 59 KB

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