ipath_iba6110.c 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813
  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. bail:
  691. return ret;
  692. }
  693. static void ipath_check_htlink(struct ipath_devdata *dd)
  694. {
  695. u8 linkerr, link_off, i;
  696. for (i = 0; i < 2; i++) {
  697. link_off = dd->ipath_ht_slave_off + i * 4 + 0xd;
  698. if (pci_read_config_byte(dd->pcidev, link_off, &linkerr))
  699. dev_info(&dd->pcidev->dev, "Couldn't read "
  700. "linkerror%d of HT slave/primary block\n",
  701. i);
  702. else if (linkerr & 0xf0) {
  703. ipath_cdbg(VERBOSE, "HT linkerr%d bits 0x%x set, "
  704. "clearing\n", linkerr >> 4, i);
  705. /*
  706. * writing the linkerr bits that are set should
  707. * clear them
  708. */
  709. if (pci_write_config_byte(dd->pcidev, link_off,
  710. linkerr))
  711. ipath_dbg("Failed write to clear HT "
  712. "linkerror%d\n", i);
  713. if (pci_read_config_byte(dd->pcidev, link_off,
  714. &linkerr))
  715. dev_info(&dd->pcidev->dev,
  716. "Couldn't reread linkerror%d of "
  717. "HT slave/primary block\n", i);
  718. else if (linkerr & 0xf0)
  719. dev_info(&dd->pcidev->dev,
  720. "HT linkerror%d bits 0x%x "
  721. "couldn't be cleared\n",
  722. i, linkerr >> 4);
  723. }
  724. }
  725. }
  726. static int ipath_setup_ht_reset(struct ipath_devdata *dd)
  727. {
  728. ipath_dbg("No reset possible for this InfiniPath hardware\n");
  729. return 0;
  730. }
  731. #define HT_INTR_DISC_CONFIG 0x80 /* HT interrupt and discovery cap */
  732. #define HT_INTR_REG_INDEX 2 /* intconfig requires indirect accesses */
  733. /*
  734. * Bits 13-15 of command==0 is slave/primary block. Clear any HT CRC
  735. * errors. We only bother to do this at load time, because it's OK if
  736. * it happened before we were loaded (first time after boot/reset),
  737. * but any time after that, it's fatal anyway. Also need to not check
  738. * for for upper byte errors if we are in 8 bit mode, so figure out
  739. * our width. For now, at least, also complain if it's 8 bit.
  740. */
  741. static void slave_or_pri_blk(struct ipath_devdata *dd, struct pci_dev *pdev,
  742. int pos, u8 cap_type)
  743. {
  744. u8 linkwidth = 0, linkerr, link_a_b_off, link_off;
  745. u16 linkctrl = 0;
  746. int i;
  747. dd->ipath_ht_slave_off = pos;
  748. /* command word, master_host bit */
  749. /* master host || slave */
  750. if ((cap_type >> 2) & 1)
  751. link_a_b_off = 4;
  752. else
  753. link_a_b_off = 0;
  754. ipath_cdbg(VERBOSE, "HT%u (Link %c) connected to processor\n",
  755. link_a_b_off ? 1 : 0,
  756. link_a_b_off ? 'B' : 'A');
  757. link_a_b_off += pos;
  758. /*
  759. * check both link control registers; clear both HT CRC sets if
  760. * necessary.
  761. */
  762. for (i = 0; i < 2; i++) {
  763. link_off = pos + i * 4 + 0x4;
  764. if (pci_read_config_word(pdev, link_off, &linkctrl))
  765. ipath_dev_err(dd, "Couldn't read HT link control%d "
  766. "register\n", i);
  767. else if (linkctrl & (0xf << 8)) {
  768. ipath_cdbg(VERBOSE, "Clear linkctrl%d CRC Error "
  769. "bits %x\n", i, linkctrl & (0xf << 8));
  770. /*
  771. * now write them back to clear the error.
  772. */
  773. pci_write_config_byte(pdev, link_off,
  774. linkctrl & (0xf << 8));
  775. }
  776. }
  777. /*
  778. * As with HT CRC bits, same for protocol errors that might occur
  779. * during boot.
  780. */
  781. for (i = 0; i < 2; i++) {
  782. link_off = pos + i * 4 + 0xd;
  783. if (pci_read_config_byte(pdev, link_off, &linkerr))
  784. dev_info(&pdev->dev, "Couldn't read linkerror%d "
  785. "of HT slave/primary block\n", i);
  786. else if (linkerr & 0xf0) {
  787. ipath_cdbg(VERBOSE, "HT linkerr%d bits 0x%x set, "
  788. "clearing\n", linkerr >> 4, i);
  789. /*
  790. * writing the linkerr bits that are set will clear
  791. * them
  792. */
  793. if (pci_write_config_byte
  794. (pdev, link_off, linkerr))
  795. ipath_dbg("Failed write to clear HT "
  796. "linkerror%d\n", i);
  797. if (pci_read_config_byte(pdev, link_off, &linkerr))
  798. dev_info(&pdev->dev, "Couldn't reread "
  799. "linkerror%d of HT slave/primary "
  800. "block\n", i);
  801. else if (linkerr & 0xf0)
  802. dev_info(&pdev->dev, "HT linkerror%d bits "
  803. "0x%x couldn't be cleared\n",
  804. i, linkerr >> 4);
  805. }
  806. }
  807. /*
  808. * this is just for our link to the host, not devices connected
  809. * through tunnel.
  810. */
  811. if (pci_read_config_byte(pdev, link_a_b_off + 7, &linkwidth))
  812. ipath_dev_err(dd, "Couldn't read HT link width "
  813. "config register\n");
  814. else {
  815. u32 width;
  816. switch (linkwidth & 7) {
  817. case 5:
  818. width = 4;
  819. break;
  820. case 4:
  821. width = 2;
  822. break;
  823. case 3:
  824. width = 32;
  825. break;
  826. case 1:
  827. width = 16;
  828. break;
  829. case 0:
  830. default: /* if wrong, assume 8 bit */
  831. width = 8;
  832. break;
  833. }
  834. dd->ipath_htwidth = width;
  835. if (linkwidth != 0x11) {
  836. ipath_dev_err(dd, "Not configured for 16 bit HT "
  837. "(%x)\n", linkwidth);
  838. if (!(linkwidth & 0xf)) {
  839. ipath_dbg("Will ignore HT lane1 errors\n");
  840. dd->ipath_flags |= IPATH_8BIT_IN_HT0;
  841. }
  842. }
  843. }
  844. /*
  845. * this is just for our link to the host, not devices connected
  846. * through tunnel.
  847. */
  848. if (pci_read_config_byte(pdev, link_a_b_off + 0xd, &linkwidth))
  849. ipath_dev_err(dd, "Couldn't read HT link frequency "
  850. "config register\n");
  851. else {
  852. u32 speed;
  853. switch (linkwidth & 0xf) {
  854. case 6:
  855. speed = 1000;
  856. break;
  857. case 5:
  858. speed = 800;
  859. break;
  860. case 4:
  861. speed = 600;
  862. break;
  863. case 3:
  864. speed = 500;
  865. break;
  866. case 2:
  867. speed = 400;
  868. break;
  869. case 1:
  870. speed = 300;
  871. break;
  872. default:
  873. /*
  874. * assume reserved and vendor-specific are 200...
  875. */
  876. case 0:
  877. speed = 200;
  878. break;
  879. }
  880. dd->ipath_htspeed = speed;
  881. }
  882. }
  883. static int ipath_ht_intconfig(struct ipath_devdata *dd)
  884. {
  885. int ret;
  886. if (dd->ipath_intconfig) {
  887. ipath_write_kreg(dd, dd->ipath_kregs->kr_interruptconfig,
  888. dd->ipath_intconfig); /* interrupt address */
  889. ret = 0;
  890. } else {
  891. ipath_dev_err(dd, "No interrupts enabled, couldn't setup "
  892. "interrupt address\n");
  893. ret = -EINVAL;
  894. }
  895. return ret;
  896. }
  897. static void ipath_ht_irq_update(struct pci_dev *dev, int irq,
  898. struct ht_irq_msg *msg)
  899. {
  900. struct ipath_devdata *dd = pci_get_drvdata(dev);
  901. u64 prev_intconfig = dd->ipath_intconfig;
  902. dd->ipath_intconfig = msg->address_lo;
  903. dd->ipath_intconfig |= ((u64) msg->address_hi) << 32;
  904. /*
  905. * If the previous value of dd->ipath_intconfig is zero, we're
  906. * getting configured for the first time, and must not program the
  907. * intconfig register here (it will be programmed later, when the
  908. * hardware is ready). Otherwise, we should.
  909. */
  910. if (prev_intconfig)
  911. ipath_ht_intconfig(dd);
  912. }
  913. /**
  914. * ipath_setup_ht_config - setup the interruptconfig register
  915. * @dd: the infinipath device
  916. * @pdev: the PCI device
  917. *
  918. * setup the interruptconfig register from the HT config info.
  919. * Also clear CRC errors in HT linkcontrol, if necessary.
  920. * This is done only for the real hardware. It is done before
  921. * chip address space is initted, so can't touch infinipath registers
  922. */
  923. static int ipath_setup_ht_config(struct ipath_devdata *dd,
  924. struct pci_dev *pdev)
  925. {
  926. int pos, ret;
  927. ret = __ht_create_irq(pdev, 0, ipath_ht_irq_update);
  928. if (ret < 0) {
  929. ipath_dev_err(dd, "Couldn't create interrupt handler: "
  930. "err %d\n", ret);
  931. goto bail;
  932. }
  933. dd->ipath_irq = ret;
  934. ret = 0;
  935. /*
  936. * Handle clearing CRC errors in linkctrl register if necessary. We
  937. * do this early, before we ever enable errors or hardware errors,
  938. * mostly to avoid causing the chip to enter freeze mode.
  939. */
  940. pos = pci_find_capability(pdev, PCI_CAP_ID_HT);
  941. if (!pos) {
  942. ipath_dev_err(dd, "Couldn't find HyperTransport "
  943. "capability; no interrupts\n");
  944. ret = -ENODEV;
  945. goto bail;
  946. }
  947. do {
  948. u8 cap_type;
  949. /*
  950. * The HT capability type byte is 3 bytes after the
  951. * capability byte.
  952. */
  953. if (pci_read_config_byte(pdev, pos + 3, &cap_type)) {
  954. dev_info(&pdev->dev, "Couldn't read config "
  955. "command @ %d\n", pos);
  956. continue;
  957. }
  958. if (!(cap_type & 0xE0))
  959. slave_or_pri_blk(dd, pdev, pos, cap_type);
  960. } while ((pos = pci_find_next_capability(pdev, pos,
  961. PCI_CAP_ID_HT)));
  962. bail:
  963. return ret;
  964. }
  965. /**
  966. * ipath_setup_ht_cleanup - clean up any per-chip chip-specific stuff
  967. * @dd: the infinipath device
  968. *
  969. * Called during driver unload.
  970. * This is currently a nop for the HT chip, not for all chips
  971. */
  972. static void ipath_setup_ht_cleanup(struct ipath_devdata *dd)
  973. {
  974. }
  975. /**
  976. * ipath_setup_ht_setextled - set the state of the two external LEDs
  977. * @dd: the infinipath device
  978. * @lst: the L state
  979. * @ltst: the LT state
  980. *
  981. * Set the state of the two external LEDs, to indicate physical and
  982. * logical state of IB link. For this chip (at least with recommended
  983. * board pinouts), LED1 is Green (physical state), and LED2 is Yellow
  984. * (logical state)
  985. *
  986. * Note: We try to match the Mellanox HCA LED behavior as best
  987. * we can. Green indicates physical link state is OK (something is
  988. * plugged in, and we can train).
  989. * Amber indicates the link is logically up (ACTIVE).
  990. * Mellanox further blinks the amber LED to indicate data packet
  991. * activity, but we have no hardware support for that, so it would
  992. * require waking up every 10-20 msecs and checking the counters
  993. * on the chip, and then turning the LED off if appropriate. That's
  994. * visible overhead, so not something we will do.
  995. *
  996. */
  997. static void ipath_setup_ht_setextled(struct ipath_devdata *dd,
  998. u64 lst, u64 ltst)
  999. {
  1000. u64 extctl;
  1001. unsigned long flags = 0;
  1002. /* the diags use the LED to indicate diag info, so we leave
  1003. * the external LED alone when the diags are running */
  1004. if (ipath_diag_inuse)
  1005. return;
  1006. /* Allow override of LED display for, e.g. Locating system in rack */
  1007. if (dd->ipath_led_override) {
  1008. ltst = (dd->ipath_led_override & IPATH_LED_PHYS)
  1009. ? INFINIPATH_IBCS_LT_STATE_LINKUP
  1010. : INFINIPATH_IBCS_LT_STATE_DISABLED;
  1011. lst = (dd->ipath_led_override & IPATH_LED_LOG)
  1012. ? INFINIPATH_IBCS_L_STATE_ACTIVE
  1013. : INFINIPATH_IBCS_L_STATE_DOWN;
  1014. }
  1015. spin_lock_irqsave(&dd->ipath_gpio_lock, flags);
  1016. /*
  1017. * start by setting both LED control bits to off, then turn
  1018. * on the appropriate bit(s).
  1019. */
  1020. if (dd->ipath_boardrev == 8) { /* LS/X-1 uses different pins */
  1021. /*
  1022. * major difference is that INFINIPATH_EXTC_LEDGBLERR_OFF
  1023. * is inverted, because it is normally used to indicate
  1024. * a hardware fault at reset, if there were errors
  1025. */
  1026. extctl = (dd->ipath_extctrl & ~INFINIPATH_EXTC_LEDGBLOK_ON)
  1027. | INFINIPATH_EXTC_LEDGBLERR_OFF;
  1028. if (ltst == INFINIPATH_IBCS_LT_STATE_LINKUP)
  1029. extctl &= ~INFINIPATH_EXTC_LEDGBLERR_OFF;
  1030. if (lst == INFINIPATH_IBCS_L_STATE_ACTIVE)
  1031. extctl |= INFINIPATH_EXTC_LEDGBLOK_ON;
  1032. }
  1033. else {
  1034. extctl = dd->ipath_extctrl &
  1035. ~(INFINIPATH_EXTC_LED1PRIPORT_ON |
  1036. INFINIPATH_EXTC_LED2PRIPORT_ON);
  1037. if (ltst == INFINIPATH_IBCS_LT_STATE_LINKUP)
  1038. extctl |= INFINIPATH_EXTC_LED1PRIPORT_ON;
  1039. if (lst == INFINIPATH_IBCS_L_STATE_ACTIVE)
  1040. extctl |= INFINIPATH_EXTC_LED2PRIPORT_ON;
  1041. }
  1042. dd->ipath_extctrl = extctl;
  1043. ipath_write_kreg(dd, dd->ipath_kregs->kr_extctrl, extctl);
  1044. spin_unlock_irqrestore(&dd->ipath_gpio_lock, flags);
  1045. }
  1046. static void ipath_init_ht_variables(struct ipath_devdata *dd)
  1047. {
  1048. dd->ipath_gpio_sda_num = _IPATH_GPIO_SDA_NUM;
  1049. dd->ipath_gpio_scl_num = _IPATH_GPIO_SCL_NUM;
  1050. dd->ipath_gpio_sda = IPATH_GPIO_SDA;
  1051. dd->ipath_gpio_scl = IPATH_GPIO_SCL;
  1052. /* Fill in shifts for RcvCtrl. */
  1053. dd->ipath_r_portenable_shift = INFINIPATH_R_PORTENABLE_SHIFT;
  1054. dd->ipath_r_intravail_shift = INFINIPATH_R_INTRAVAIL_SHIFT;
  1055. dd->ipath_r_tailupd_shift = INFINIPATH_R_TAILUPD_SHIFT;
  1056. dd->ipath_r_portcfg_shift = 0; /* Not on IBA6110 */
  1057. dd->ipath_i_bitsextant =
  1058. (INFINIPATH_I_RCVURG_MASK << INFINIPATH_I_RCVURG_SHIFT) |
  1059. (INFINIPATH_I_RCVAVAIL_MASK <<
  1060. INFINIPATH_I_RCVAVAIL_SHIFT) |
  1061. INFINIPATH_I_ERROR | INFINIPATH_I_SPIOSENT |
  1062. INFINIPATH_I_SPIOBUFAVAIL | INFINIPATH_I_GPIO;
  1063. dd->ipath_e_bitsextant =
  1064. INFINIPATH_E_RFORMATERR | INFINIPATH_E_RVCRC |
  1065. INFINIPATH_E_RICRC | INFINIPATH_E_RMINPKTLEN |
  1066. INFINIPATH_E_RMAXPKTLEN | INFINIPATH_E_RLONGPKTLEN |
  1067. INFINIPATH_E_RSHORTPKTLEN | INFINIPATH_E_RUNEXPCHAR |
  1068. INFINIPATH_E_RUNSUPVL | INFINIPATH_E_REBP |
  1069. INFINIPATH_E_RIBFLOW | INFINIPATH_E_RBADVERSION |
  1070. INFINIPATH_E_RRCVEGRFULL | INFINIPATH_E_RRCVHDRFULL |
  1071. INFINIPATH_E_RBADTID | INFINIPATH_E_RHDRLEN |
  1072. INFINIPATH_E_RHDR | INFINIPATH_E_RIBLOSTLINK |
  1073. INFINIPATH_E_SMINPKTLEN | INFINIPATH_E_SMAXPKTLEN |
  1074. INFINIPATH_E_SUNDERRUN | INFINIPATH_E_SPKTLEN |
  1075. INFINIPATH_E_SDROPPEDSMPPKT | INFINIPATH_E_SDROPPEDDATAPKT |
  1076. INFINIPATH_E_SPIOARMLAUNCH | INFINIPATH_E_SUNEXPERRPKTNUM |
  1077. INFINIPATH_E_SUNSUPVL | INFINIPATH_E_IBSTATUSCHANGED |
  1078. INFINIPATH_E_INVALIDADDR | INFINIPATH_E_RESET |
  1079. INFINIPATH_E_HARDWARE;
  1080. dd->ipath_hwe_bitsextant =
  1081. (INFINIPATH_HWE_HTCMEMPARITYERR_MASK <<
  1082. INFINIPATH_HWE_HTCMEMPARITYERR_SHIFT) |
  1083. (INFINIPATH_HWE_TXEMEMPARITYERR_MASK <<
  1084. INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT) |
  1085. (INFINIPATH_HWE_RXEMEMPARITYERR_MASK <<
  1086. INFINIPATH_HWE_RXEMEMPARITYERR_SHIFT) |
  1087. INFINIPATH_HWE_HTCLNKABYTE0CRCERR |
  1088. INFINIPATH_HWE_HTCLNKABYTE1CRCERR |
  1089. INFINIPATH_HWE_HTCLNKBBYTE0CRCERR |
  1090. INFINIPATH_HWE_HTCLNKBBYTE1CRCERR |
  1091. INFINIPATH_HWE_HTCMISCERR4 |
  1092. INFINIPATH_HWE_HTCMISCERR5 | INFINIPATH_HWE_HTCMISCERR6 |
  1093. INFINIPATH_HWE_HTCMISCERR7 |
  1094. INFINIPATH_HWE_HTCBUSTREQPARITYERR |
  1095. INFINIPATH_HWE_HTCBUSTRESPPARITYERR |
  1096. INFINIPATH_HWE_HTCBUSIREQPARITYERR |
  1097. INFINIPATH_HWE_RXDSYNCMEMPARITYERR |
  1098. INFINIPATH_HWE_MEMBISTFAILED |
  1099. INFINIPATH_HWE_COREPLL_FBSLIP |
  1100. INFINIPATH_HWE_COREPLL_RFSLIP |
  1101. INFINIPATH_HWE_HTBPLL_FBSLIP |
  1102. INFINIPATH_HWE_HTBPLL_RFSLIP |
  1103. INFINIPATH_HWE_HTAPLL_FBSLIP |
  1104. INFINIPATH_HWE_HTAPLL_RFSLIP |
  1105. INFINIPATH_HWE_SERDESPLLFAILED |
  1106. INFINIPATH_HWE_IBCBUSTOSPCPARITYERR |
  1107. INFINIPATH_HWE_IBCBUSFRSPCPARITYERR;
  1108. dd->ipath_i_rcvavail_mask = INFINIPATH_I_RCVAVAIL_MASK;
  1109. dd->ipath_i_rcvurg_mask = INFINIPATH_I_RCVURG_MASK;
  1110. /*
  1111. * EEPROM error log 0 is TXE Parity errors. 1 is RXE Parity.
  1112. * 2 is Some Misc, 3 is reserved for future.
  1113. */
  1114. dd->ipath_eep_st_masks[0].hwerrs_to_log =
  1115. INFINIPATH_HWE_TXEMEMPARITYERR_MASK <<
  1116. INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT;
  1117. dd->ipath_eep_st_masks[1].hwerrs_to_log =
  1118. INFINIPATH_HWE_RXEMEMPARITYERR_MASK <<
  1119. INFINIPATH_HWE_RXEMEMPARITYERR_SHIFT;
  1120. dd->ipath_eep_st_masks[2].errs_to_log =
  1121. INFINIPATH_E_INVALIDADDR | INFINIPATH_E_RESET;
  1122. }
  1123. /**
  1124. * ipath_ht_init_hwerrors - enable hardware errors
  1125. * @dd: the infinipath device
  1126. *
  1127. * now that we have finished initializing everything that might reasonably
  1128. * cause a hardware error, and cleared those errors bits as they occur,
  1129. * we can enable hardware errors in the mask (potentially enabling
  1130. * freeze mode), and enable hardware errors as errors (along with
  1131. * everything else) in errormask
  1132. */
  1133. static void ipath_ht_init_hwerrors(struct ipath_devdata *dd)
  1134. {
  1135. ipath_err_t val;
  1136. u64 extsval;
  1137. extsval = ipath_read_kreg64(dd, dd->ipath_kregs->kr_extstatus);
  1138. if (!(extsval & INFINIPATH_EXTS_MEMBIST_ENDTEST))
  1139. ipath_dev_err(dd, "MemBIST did not complete!\n");
  1140. if (extsval & INFINIPATH_EXTS_MEMBIST_CORRECT)
  1141. ipath_dbg("MemBIST corrected\n");
  1142. ipath_check_htlink(dd);
  1143. /* barring bugs, all hwerrors become interrupts, which can */
  1144. val = -1LL;
  1145. /* don't look at crc lane1 if 8 bit */
  1146. if (dd->ipath_flags & IPATH_8BIT_IN_HT0)
  1147. val &= ~infinipath_hwe_htclnkabyte1crcerr;
  1148. /* don't look at crc lane1 if 8 bit */
  1149. if (dd->ipath_flags & IPATH_8BIT_IN_HT1)
  1150. val &= ~infinipath_hwe_htclnkbbyte1crcerr;
  1151. /*
  1152. * disable RXDSYNCMEMPARITY because external serdes is unused,
  1153. * and therefore the logic will never be used or initialized,
  1154. * and uninitialized state will normally result in this error
  1155. * being asserted. Similarly for the external serdess pll
  1156. * lock signal.
  1157. */
  1158. val &= ~(INFINIPATH_HWE_SERDESPLLFAILED |
  1159. INFINIPATH_HWE_RXDSYNCMEMPARITYERR);
  1160. /*
  1161. * Disable MISCERR4 because of an inversion in the HT core
  1162. * logic checking for errors that cause this bit to be set.
  1163. * The errata can also cause the protocol error bit to be set
  1164. * in the HT config space linkerror register(s).
  1165. */
  1166. val &= ~INFINIPATH_HWE_HTCMISCERR4;
  1167. /*
  1168. * PLL ignored because MDIO interface has a logic problem
  1169. * for reads, on Comstock and Ponderosa. BRINGUP
  1170. */
  1171. if (dd->ipath_boardrev == 4 || dd->ipath_boardrev == 9)
  1172. val &= ~INFINIPATH_HWE_SERDESPLLFAILED;
  1173. dd->ipath_hwerrmask = val;
  1174. }
  1175. /**
  1176. * ipath_ht_bringup_serdes - bring up the serdes
  1177. * @dd: the infinipath device
  1178. */
  1179. static int ipath_ht_bringup_serdes(struct ipath_devdata *dd)
  1180. {
  1181. u64 val, config1;
  1182. int ret = 0, change = 0;
  1183. ipath_dbg("Trying to bringup serdes\n");
  1184. if (ipath_read_kreg64(dd, dd->ipath_kregs->kr_hwerrstatus) &
  1185. INFINIPATH_HWE_SERDESPLLFAILED)
  1186. {
  1187. ipath_dbg("At start, serdes PLL failed bit set in "
  1188. "hwerrstatus, clearing and continuing\n");
  1189. ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrclear,
  1190. INFINIPATH_HWE_SERDESPLLFAILED);
  1191. }
  1192. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig0);
  1193. config1 = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig1);
  1194. ipath_cdbg(VERBOSE, "Initial serdes status is config0=%llx "
  1195. "config1=%llx, sstatus=%llx xgxs %llx\n",
  1196. (unsigned long long) val, (unsigned long long) config1,
  1197. (unsigned long long)
  1198. ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesstatus),
  1199. (unsigned long long)
  1200. ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig));
  1201. /* force reset on */
  1202. val |= INFINIPATH_SERDC0_RESET_PLL
  1203. /* | INFINIPATH_SERDC0_RESET_MASK */
  1204. ;
  1205. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);
  1206. udelay(15); /* need pll reset set at least for a bit */
  1207. if (val & INFINIPATH_SERDC0_RESET_PLL) {
  1208. u64 val2 = val &= ~INFINIPATH_SERDC0_RESET_PLL;
  1209. /* set lane resets, and tx idle, during pll reset */
  1210. val2 |= INFINIPATH_SERDC0_RESET_MASK |
  1211. INFINIPATH_SERDC0_TXIDLE;
  1212. ipath_cdbg(VERBOSE, "Clearing serdes PLL reset (writing "
  1213. "%llx)\n", (unsigned long long) val2);
  1214. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0,
  1215. val2);
  1216. /*
  1217. * be sure chip saw it
  1218. */
  1219. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
  1220. /*
  1221. * need pll reset clear at least 11 usec before lane
  1222. * resets cleared; give it a few more
  1223. */
  1224. udelay(15);
  1225. val = val2; /* for check below */
  1226. }
  1227. if (val & (INFINIPATH_SERDC0_RESET_PLL |
  1228. INFINIPATH_SERDC0_RESET_MASK |
  1229. INFINIPATH_SERDC0_TXIDLE)) {
  1230. val &= ~(INFINIPATH_SERDC0_RESET_PLL |
  1231. INFINIPATH_SERDC0_RESET_MASK |
  1232. INFINIPATH_SERDC0_TXIDLE);
  1233. /* clear them */
  1234. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0,
  1235. val);
  1236. }
  1237. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig);
  1238. if (((val >> INFINIPATH_XGXS_MDIOADDR_SHIFT) &
  1239. INFINIPATH_XGXS_MDIOADDR_MASK) != 3) {
  1240. val &= ~(INFINIPATH_XGXS_MDIOADDR_MASK <<
  1241. INFINIPATH_XGXS_MDIOADDR_SHIFT);
  1242. /*
  1243. * we use address 3
  1244. */
  1245. val |= 3ULL << INFINIPATH_XGXS_MDIOADDR_SHIFT;
  1246. change = 1;
  1247. }
  1248. if (val & INFINIPATH_XGXS_RESET) {
  1249. /* normally true after boot */
  1250. val &= ~INFINIPATH_XGXS_RESET;
  1251. change = 1;
  1252. }
  1253. if (((val >> INFINIPATH_XGXS_RX_POL_SHIFT) &
  1254. INFINIPATH_XGXS_RX_POL_MASK) != dd->ipath_rx_pol_inv ) {
  1255. /* need to compensate for Tx inversion in partner */
  1256. val &= ~(INFINIPATH_XGXS_RX_POL_MASK <<
  1257. INFINIPATH_XGXS_RX_POL_SHIFT);
  1258. val |= dd->ipath_rx_pol_inv <<
  1259. INFINIPATH_XGXS_RX_POL_SHIFT;
  1260. change = 1;
  1261. }
  1262. if (change)
  1263. ipath_write_kreg(dd, dd->ipath_kregs->kr_xgxsconfig, val);
  1264. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig0);
  1265. /* clear current and de-emphasis bits */
  1266. config1 &= ~0x0ffffffff00ULL;
  1267. /* set current to 20ma */
  1268. config1 |= 0x00000000000ULL;
  1269. /* set de-emphasis to -5.68dB */
  1270. config1 |= 0x0cccc000000ULL;
  1271. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig1, config1);
  1272. ipath_cdbg(VERBOSE, "After setup: serdes status is config0=%llx "
  1273. "config1=%llx, sstatus=%llx xgxs %llx\n",
  1274. (unsigned long long) val, (unsigned long long) config1,
  1275. (unsigned long long)
  1276. ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesstatus),
  1277. (unsigned long long)
  1278. ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig));
  1279. if (!ipath_waitfor_mdio_cmdready(dd)) {
  1280. ipath_write_kreg(dd, dd->ipath_kregs->kr_mdio,
  1281. ipath_mdio_req(IPATH_MDIO_CMD_READ, 31,
  1282. IPATH_MDIO_CTRL_XGXS_REG_8,
  1283. 0));
  1284. if (ipath_waitfor_complete(dd, dd->ipath_kregs->kr_mdio,
  1285. IPATH_MDIO_DATAVALID, &val))
  1286. ipath_dbg("Never got MDIO data for XGXS status "
  1287. "read\n");
  1288. else
  1289. ipath_cdbg(VERBOSE, "MDIO Read reg8, "
  1290. "'bank' 31 %x\n", (u32) val);
  1291. } else
  1292. ipath_dbg("Never got MDIO cmdready for XGXS status read\n");
  1293. return ret; /* for now, say we always succeeded */
  1294. }
  1295. /**
  1296. * ipath_ht_quiet_serdes - set serdes to txidle
  1297. * @dd: the infinipath device
  1298. * driver is being unloaded
  1299. */
  1300. static void ipath_ht_quiet_serdes(struct ipath_devdata *dd)
  1301. {
  1302. u64 val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig0);
  1303. val |= INFINIPATH_SERDC0_TXIDLE;
  1304. ipath_dbg("Setting TxIdleEn on serdes (config0 = %llx)\n",
  1305. (unsigned long long) val);
  1306. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);
  1307. }
  1308. /**
  1309. * ipath_pe_put_tid - write a TID in chip
  1310. * @dd: the infinipath device
  1311. * @tidptr: pointer to the expected TID (in chip) to udpate
  1312. * @tidtype: RCVHQ_RCV_TYPE_EAGER (1) for eager, RCVHQ_RCV_TYPE_EXPECTED (0) for expected
  1313. * @pa: physical address of in memory buffer; ipath_tidinvalid if freeing
  1314. *
  1315. * This exists as a separate routine to allow for special locking etc.
  1316. * It's used for both the full cleanup on exit, as well as the normal
  1317. * setup and teardown.
  1318. */
  1319. static void ipath_ht_put_tid(struct ipath_devdata *dd,
  1320. u64 __iomem *tidptr, u32 type,
  1321. unsigned long pa)
  1322. {
  1323. if (!dd->ipath_kregbase)
  1324. return;
  1325. if (pa != dd->ipath_tidinvalid) {
  1326. if (unlikely((pa & ~INFINIPATH_RT_ADDR_MASK))) {
  1327. dev_info(&dd->pcidev->dev,
  1328. "physaddr %lx has more than "
  1329. "40 bits, using only 40!!!\n", pa);
  1330. pa &= INFINIPATH_RT_ADDR_MASK;
  1331. }
  1332. if (type == RCVHQ_RCV_TYPE_EAGER)
  1333. pa |= dd->ipath_tidtemplate;
  1334. else {
  1335. /* in words (fixed, full page). */
  1336. u64 lenvalid = PAGE_SIZE >> 2;
  1337. lenvalid <<= INFINIPATH_RT_BUFSIZE_SHIFT;
  1338. pa |= lenvalid | INFINIPATH_RT_VALID;
  1339. }
  1340. }
  1341. writeq(pa, tidptr);
  1342. }
  1343. /**
  1344. * ipath_ht_clear_tid - clear all TID entries for a port, expected and eager
  1345. * @dd: the infinipath device
  1346. * @port: the port
  1347. *
  1348. * Used from ipath_close(), and at chip initialization.
  1349. */
  1350. static void ipath_ht_clear_tids(struct ipath_devdata *dd, unsigned port)
  1351. {
  1352. u64 __iomem *tidbase;
  1353. int i;
  1354. if (!dd->ipath_kregbase)
  1355. return;
  1356. ipath_cdbg(VERBOSE, "Invalidate TIDs for port %u\n", port);
  1357. /*
  1358. * need to invalidate all of the expected TID entries for this
  1359. * port, so we don't have valid entries that might somehow get
  1360. * used (early in next use of this port, or through some bug)
  1361. */
  1362. tidbase = (u64 __iomem *) ((char __iomem *)(dd->ipath_kregbase) +
  1363. dd->ipath_rcvtidbase +
  1364. port * dd->ipath_rcvtidcnt *
  1365. sizeof(*tidbase));
  1366. for (i = 0; i < dd->ipath_rcvtidcnt; i++)
  1367. ipath_ht_put_tid(dd, &tidbase[i], RCVHQ_RCV_TYPE_EXPECTED,
  1368. dd->ipath_tidinvalid);
  1369. tidbase = (u64 __iomem *) ((char __iomem *)(dd->ipath_kregbase) +
  1370. dd->ipath_rcvegrbase +
  1371. port * dd->ipath_rcvegrcnt *
  1372. sizeof(*tidbase));
  1373. for (i = 0; i < dd->ipath_rcvegrcnt; i++)
  1374. ipath_ht_put_tid(dd, &tidbase[i], RCVHQ_RCV_TYPE_EAGER,
  1375. dd->ipath_tidinvalid);
  1376. }
  1377. /**
  1378. * ipath_ht_tidtemplate - setup constants for TID updates
  1379. * @dd: the infinipath device
  1380. *
  1381. * We setup stuff that we use a lot, to avoid calculating each time
  1382. */
  1383. static void ipath_ht_tidtemplate(struct ipath_devdata *dd)
  1384. {
  1385. dd->ipath_tidtemplate = dd->ipath_ibmaxlen >> 2;
  1386. dd->ipath_tidtemplate <<= INFINIPATH_RT_BUFSIZE_SHIFT;
  1387. dd->ipath_tidtemplate |= INFINIPATH_RT_VALID;
  1388. /*
  1389. * work around chip errata bug 7358, by marking invalid tids
  1390. * as having max length
  1391. */
  1392. dd->ipath_tidinvalid = (-1LL & INFINIPATH_RT_BUFSIZE_MASK) <<
  1393. INFINIPATH_RT_BUFSIZE_SHIFT;
  1394. }
  1395. static int ipath_ht_early_init(struct ipath_devdata *dd)
  1396. {
  1397. u32 __iomem *piobuf;
  1398. u32 pioincr, val32;
  1399. int i;
  1400. /*
  1401. * one cache line; long IB headers will spill over into received
  1402. * buffer
  1403. */
  1404. dd->ipath_rcvhdrentsize = 16;
  1405. dd->ipath_rcvhdrsize = IPATH_DFLT_RCVHDRSIZE;
  1406. /*
  1407. * For HT, we allocate a somewhat overly large eager buffer,
  1408. * such that we can guarantee that we can receive the largest
  1409. * packet that we can send out. To truly support a 4KB MTU,
  1410. * we need to bump this to a large value. To date, other than
  1411. * testing, we have never encountered an HCA that can really
  1412. * send 4KB MTU packets, so we do not handle that (we'll get
  1413. * errors interrupts if we ever see one).
  1414. */
  1415. dd->ipath_rcvegrbufsize = dd->ipath_piosize2k;
  1416. /*
  1417. * the min() check here is currently a nop, but it may not
  1418. * always be, depending on just how we do ipath_rcvegrbufsize
  1419. */
  1420. dd->ipath_ibmaxlen = min(dd->ipath_piosize2k,
  1421. dd->ipath_rcvegrbufsize);
  1422. dd->ipath_init_ibmaxlen = dd->ipath_ibmaxlen;
  1423. ipath_ht_tidtemplate(dd);
  1424. /*
  1425. * zero all the TID entries at startup. We do this for sanity,
  1426. * in case of a previous driver crash of some kind, and also
  1427. * because the chip powers up with these memories in an unknown
  1428. * state. Use portcnt, not cfgports, since this is for the
  1429. * full chip, not for current (possibly different) configuration
  1430. * value.
  1431. * Chip Errata bug 6447
  1432. */
  1433. for (val32 = 0; val32 < dd->ipath_portcnt; val32++)
  1434. ipath_ht_clear_tids(dd, val32);
  1435. /*
  1436. * write the pbc of each buffer, to be sure it's initialized, then
  1437. * cancel all the buffers, and also abort any packets that might
  1438. * have been in flight for some reason (the latter is for driver
  1439. * unload/reload, but isn't a bad idea at first init). PIO send
  1440. * isn't enabled at this point, so there is no danger of sending
  1441. * these out on the wire.
  1442. * Chip Errata bug 6610
  1443. */
  1444. piobuf = (u32 __iomem *) (((char __iomem *)(dd->ipath_kregbase)) +
  1445. dd->ipath_piobufbase);
  1446. pioincr = dd->ipath_palign / sizeof(*piobuf);
  1447. for (i = 0; i < dd->ipath_piobcnt2k; i++) {
  1448. /*
  1449. * reasonable word count, just to init pbc
  1450. */
  1451. writel(16, piobuf);
  1452. piobuf += pioincr;
  1453. }
  1454. ipath_get_eeprom_info(dd);
  1455. if (dd->ipath_boardrev == 5 && dd->ipath_serial[0] == '1' &&
  1456. dd->ipath_serial[1] == '2' && dd->ipath_serial[2] == '8') {
  1457. /*
  1458. * Later production QHT7040 has same changes as QHT7140, so
  1459. * can use GPIO interrupts. They have serial #'s starting
  1460. * with 128, rather than 112.
  1461. */
  1462. if (dd->ipath_serial[0] == '1' &&
  1463. dd->ipath_serial[1] == '2' &&
  1464. dd->ipath_serial[2] == '8')
  1465. dd->ipath_flags |= IPATH_GPIO_INTR;
  1466. else {
  1467. ipath_dev_err(dd, "Unsupported InfiniPath board "
  1468. "(serial number %.16s)!\n",
  1469. dd->ipath_serial);
  1470. return 1;
  1471. }
  1472. }
  1473. if (dd->ipath_minrev >= 4) {
  1474. /* Rev4+ reports extra errors via internal GPIO pins */
  1475. dd->ipath_flags |= IPATH_GPIO_ERRINTRS;
  1476. dd->ipath_gpio_mask |= IPATH_GPIO_ERRINTR_MASK;
  1477. ipath_write_kreg(dd, dd->ipath_kregs->kr_gpio_mask,
  1478. dd->ipath_gpio_mask);
  1479. }
  1480. return 0;
  1481. }
  1482. static int ipath_ht_txe_recover(struct ipath_devdata *dd)
  1483. {
  1484. int cnt = ++ipath_stats.sps_txeparity;
  1485. if (cnt >= IPATH_MAX_PARITY_ATTEMPTS) {
  1486. if (cnt == IPATH_MAX_PARITY_ATTEMPTS)
  1487. ipath_dev_err(dd,
  1488. "Too many attempts to recover from "
  1489. "TXE parity, giving up\n");
  1490. return 0;
  1491. }
  1492. dev_info(&dd->pcidev->dev,
  1493. "Recovering from TXE PIO parity error\n");
  1494. return 1;
  1495. }
  1496. /**
  1497. * ipath_init_ht_get_base_info - set chip-specific flags for user code
  1498. * @dd: the infinipath device
  1499. * @kbase: ipath_base_info pointer
  1500. *
  1501. * We set the PCIE flag because the lower bandwidth on PCIe vs
  1502. * HyperTransport can affect some user packet algorithms.
  1503. */
  1504. static int ipath_ht_get_base_info(struct ipath_portdata *pd, void *kbase)
  1505. {
  1506. struct ipath_base_info *kinfo = kbase;
  1507. kinfo->spi_runtime_flags |= IPATH_RUNTIME_HT |
  1508. IPATH_RUNTIME_PIO_REGSWAPPED;
  1509. if (pd->port_dd->ipath_minrev < 4)
  1510. kinfo->spi_runtime_flags |= IPATH_RUNTIME_RCVHDR_COPY;
  1511. return 0;
  1512. }
  1513. static void ipath_ht_free_irq(struct ipath_devdata *dd)
  1514. {
  1515. free_irq(dd->ipath_irq, dd);
  1516. ht_destroy_irq(dd->ipath_irq);
  1517. dd->ipath_irq = 0;
  1518. dd->ipath_intconfig = 0;
  1519. }
  1520. static void ipath_ht_read_counters(struct ipath_devdata *dd,
  1521. struct infinipath_counters *cntrs)
  1522. {
  1523. cntrs->LBIntCnt =
  1524. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(LBIntCnt));
  1525. cntrs->LBFlowStallCnt =
  1526. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(LBFlowStallCnt));
  1527. cntrs->TxSDmaDescCnt = 0;
  1528. cntrs->TxUnsupVLErrCnt =
  1529. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxUnsupVLErrCnt));
  1530. cntrs->TxDataPktCnt =
  1531. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxDataPktCnt));
  1532. cntrs->TxFlowPktCnt =
  1533. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxFlowPktCnt));
  1534. cntrs->TxDwordCnt =
  1535. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxDwordCnt));
  1536. cntrs->TxLenErrCnt =
  1537. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxLenErrCnt));
  1538. cntrs->TxMaxMinLenErrCnt =
  1539. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxMaxMinLenErrCnt));
  1540. cntrs->TxUnderrunCnt =
  1541. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxUnderrunCnt));
  1542. cntrs->TxFlowStallCnt =
  1543. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxFlowStallCnt));
  1544. cntrs->TxDroppedPktCnt =
  1545. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxDroppedPktCnt));
  1546. cntrs->RxDroppedPktCnt =
  1547. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxDroppedPktCnt));
  1548. cntrs->RxDataPktCnt =
  1549. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxDataPktCnt));
  1550. cntrs->RxFlowPktCnt =
  1551. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxFlowPktCnt));
  1552. cntrs->RxDwordCnt =
  1553. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxDwordCnt));
  1554. cntrs->RxLenErrCnt =
  1555. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxLenErrCnt));
  1556. cntrs->RxMaxMinLenErrCnt =
  1557. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxMaxMinLenErrCnt));
  1558. cntrs->RxICRCErrCnt =
  1559. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxICRCErrCnt));
  1560. cntrs->RxVCRCErrCnt =
  1561. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxVCRCErrCnt));
  1562. cntrs->RxFlowCtrlErrCnt =
  1563. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxFlowCtrlErrCnt));
  1564. cntrs->RxBadFormatCnt =
  1565. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxBadFormatCnt));
  1566. cntrs->RxLinkProblemCnt =
  1567. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxLinkProblemCnt));
  1568. cntrs->RxEBPCnt =
  1569. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxEBPCnt));
  1570. cntrs->RxLPCRCErrCnt =
  1571. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxLPCRCErrCnt));
  1572. cntrs->RxBufOvflCnt =
  1573. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxBufOvflCnt));
  1574. cntrs->RxTIDFullErrCnt =
  1575. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxTIDFullErrCnt));
  1576. cntrs->RxTIDValidErrCnt =
  1577. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxTIDValidErrCnt));
  1578. cntrs->RxPKeyMismatchCnt =
  1579. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxPKeyMismatchCnt));
  1580. cntrs->RxP0HdrEgrOvflCnt =
  1581. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP0HdrEgrOvflCnt));
  1582. cntrs->RxP1HdrEgrOvflCnt =
  1583. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP1HdrEgrOvflCnt));
  1584. cntrs->RxP2HdrEgrOvflCnt =
  1585. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP2HdrEgrOvflCnt));
  1586. cntrs->RxP3HdrEgrOvflCnt =
  1587. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP3HdrEgrOvflCnt));
  1588. cntrs->RxP4HdrEgrOvflCnt =
  1589. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP4HdrEgrOvflCnt));
  1590. cntrs->RxP5HdrEgrOvflCnt =
  1591. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP5HdrEgrOvflCnt));
  1592. cntrs->RxP6HdrEgrOvflCnt =
  1593. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP6HdrEgrOvflCnt));
  1594. cntrs->RxP7HdrEgrOvflCnt =
  1595. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP7HdrEgrOvflCnt));
  1596. cntrs->RxP8HdrEgrOvflCnt =
  1597. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP8HdrEgrOvflCnt));
  1598. cntrs->RxP9HdrEgrOvflCnt = 0;
  1599. cntrs->RxP10HdrEgrOvflCnt = 0;
  1600. cntrs->RxP11HdrEgrOvflCnt = 0;
  1601. cntrs->RxP12HdrEgrOvflCnt = 0;
  1602. cntrs->RxP13HdrEgrOvflCnt = 0;
  1603. cntrs->RxP14HdrEgrOvflCnt = 0;
  1604. cntrs->RxP15HdrEgrOvflCnt = 0;
  1605. cntrs->RxP16HdrEgrOvflCnt = 0;
  1606. cntrs->IBStatusChangeCnt =
  1607. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(IBStatusChangeCnt));
  1608. cntrs->IBLinkErrRecoveryCnt =
  1609. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(IBLinkErrRecoveryCnt));
  1610. cntrs->IBLinkDownedCnt =
  1611. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(IBLinkDownedCnt));
  1612. cntrs->IBSymbolErrCnt =
  1613. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(IBSymbolErrCnt));
  1614. cntrs->RxVL15DroppedPktCnt = 0;
  1615. cntrs->RxOtherLocalPhyErrCnt = 0;
  1616. cntrs->PcieRetryBufDiagQwordCnt = 0;
  1617. cntrs->ExcessBufferOvflCnt = dd->ipath_overrun_thresh_errs;
  1618. cntrs->LocalLinkIntegrityErrCnt =
  1619. (dd->ipath_flags & IPATH_GPIO_ERRINTRS) ?
  1620. dd->ipath_lli_errs : dd->ipath_lli_errors;
  1621. cntrs->RxVlErrCnt = 0;
  1622. cntrs->RxDlidFltrCnt = 0;
  1623. }
  1624. /**
  1625. * ipath_init_iba6110_funcs - set up the chip-specific function pointers
  1626. * @dd: the infinipath device
  1627. *
  1628. * This is global, and is called directly at init to set up the
  1629. * chip-specific function pointers for later use.
  1630. */
  1631. void ipath_init_iba6110_funcs(struct ipath_devdata *dd)
  1632. {
  1633. dd->ipath_f_intrsetup = ipath_ht_intconfig;
  1634. dd->ipath_f_bus = ipath_setup_ht_config;
  1635. dd->ipath_f_reset = ipath_setup_ht_reset;
  1636. dd->ipath_f_get_boardname = ipath_ht_boardname;
  1637. dd->ipath_f_init_hwerrors = ipath_ht_init_hwerrors;
  1638. dd->ipath_f_early_init = ipath_ht_early_init;
  1639. dd->ipath_f_handle_hwerrors = ipath_ht_handle_hwerrors;
  1640. dd->ipath_f_quiet_serdes = ipath_ht_quiet_serdes;
  1641. dd->ipath_f_bringup_serdes = ipath_ht_bringup_serdes;
  1642. dd->ipath_f_clear_tids = ipath_ht_clear_tids;
  1643. dd->ipath_f_put_tid = ipath_ht_put_tid;
  1644. dd->ipath_f_cleanup = ipath_setup_ht_cleanup;
  1645. dd->ipath_f_setextled = ipath_setup_ht_setextled;
  1646. dd->ipath_f_get_base_info = ipath_ht_get_base_info;
  1647. dd->ipath_f_free_irq = ipath_ht_free_irq;
  1648. dd->ipath_f_read_counters = ipath_ht_read_counters;
  1649. /*
  1650. * initialize chip-specific variables
  1651. */
  1652. dd->ipath_f_tidtemplate = ipath_ht_tidtemplate;
  1653. /*
  1654. * setup the register offsets, since they are different for each
  1655. * chip
  1656. */
  1657. dd->ipath_kregs = &ipath_ht_kregs;
  1658. dd->ipath_cregs = &ipath_ht_cregs;
  1659. /*
  1660. * do very early init that is needed before ipath_f_bus is
  1661. * called
  1662. */
  1663. ipath_init_ht_variables(dd);
  1664. }