ipath_iba6120.c 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801
  1. /*
  2. * Copyright (c) 2006, 2007, 2008 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
  35. * InfiniPath PCIe chip.
  36. */
  37. #include <linux/interrupt.h>
  38. #include <linux/pci.h>
  39. #include <linux/delay.h>
  40. #include <rdma/ib_verbs.h>
  41. #include "ipath_kernel.h"
  42. #include "ipath_registers.h"
  43. static void ipath_setup_pe_setextled(struct ipath_devdata *, u64, u64);
  44. /*
  45. * This file contains all the chip-specific register information and
  46. * access functions for the QLogic InfiniPath PCI-Express chip.
  47. *
  48. * This lists the InfiniPath registers, in the actual chip layout.
  49. * This structure should never be directly accessed.
  50. */
  51. struct _infinipath_do_not_use_kernel_regs {
  52. unsigned long long Revision;
  53. unsigned long long Control;
  54. unsigned long long PageAlign;
  55. unsigned long long PortCnt;
  56. unsigned long long DebugPortSelect;
  57. unsigned long long Reserved0;
  58. unsigned long long SendRegBase;
  59. unsigned long long UserRegBase;
  60. unsigned long long CounterRegBase;
  61. unsigned long long Scratch;
  62. unsigned long long Reserved1;
  63. unsigned long long Reserved2;
  64. unsigned long long IntBlocked;
  65. unsigned long long IntMask;
  66. unsigned long long IntStatus;
  67. unsigned long long IntClear;
  68. unsigned long long ErrorMask;
  69. unsigned long long ErrorStatus;
  70. unsigned long long ErrorClear;
  71. unsigned long long HwErrMask;
  72. unsigned long long HwErrStatus;
  73. unsigned long long HwErrClear;
  74. unsigned long long HwDiagCtrl;
  75. unsigned long long MDIO;
  76. unsigned long long IBCStatus;
  77. unsigned long long IBCCtrl;
  78. unsigned long long ExtStatus;
  79. unsigned long long ExtCtrl;
  80. unsigned long long GPIOOut;
  81. unsigned long long GPIOMask;
  82. unsigned long long GPIOStatus;
  83. unsigned long long GPIOClear;
  84. unsigned long long RcvCtrl;
  85. unsigned long long RcvBTHQP;
  86. unsigned long long RcvHdrSize;
  87. unsigned long long RcvHdrCnt;
  88. unsigned long long RcvHdrEntSize;
  89. unsigned long long RcvTIDBase;
  90. unsigned long long RcvTIDCnt;
  91. unsigned long long RcvEgrBase;
  92. unsigned long long RcvEgrCnt;
  93. unsigned long long RcvBufBase;
  94. unsigned long long RcvBufSize;
  95. unsigned long long RxIntMemBase;
  96. unsigned long long RxIntMemSize;
  97. unsigned long long RcvPartitionKey;
  98. unsigned long long Reserved3;
  99. unsigned long long RcvPktLEDCnt;
  100. unsigned long long Reserved4[8];
  101. unsigned long long SendCtrl;
  102. unsigned long long SendPIOBufBase;
  103. unsigned long long SendPIOSize;
  104. unsigned long long SendPIOBufCnt;
  105. unsigned long long SendPIOAvailAddr;
  106. unsigned long long TxIntMemBase;
  107. unsigned long long TxIntMemSize;
  108. unsigned long long Reserved5;
  109. unsigned long long PCIeRBufTestReg0;
  110. unsigned long long PCIeRBufTestReg1;
  111. unsigned long long Reserved51[6];
  112. unsigned long long SendBufferError;
  113. unsigned long long SendBufferErrorCONT1;
  114. unsigned long long Reserved6SBE[6];
  115. unsigned long long RcvHdrAddr0;
  116. unsigned long long RcvHdrAddr1;
  117. unsigned long long RcvHdrAddr2;
  118. unsigned long long RcvHdrAddr3;
  119. unsigned long long RcvHdrAddr4;
  120. unsigned long long Reserved7RHA[11];
  121. unsigned long long RcvHdrTailAddr0;
  122. unsigned long long RcvHdrTailAddr1;
  123. unsigned long long RcvHdrTailAddr2;
  124. unsigned long long RcvHdrTailAddr3;
  125. unsigned long long RcvHdrTailAddr4;
  126. unsigned long long Reserved8RHTA[11];
  127. unsigned long long Reserved9SW[8];
  128. unsigned long long SerdesConfig0;
  129. unsigned long long SerdesConfig1;
  130. unsigned long long SerdesStatus;
  131. unsigned long long XGXSConfig;
  132. unsigned long long IBPLLCfg;
  133. unsigned long long Reserved10SW2[3];
  134. unsigned long long PCIEQ0SerdesConfig0;
  135. unsigned long long PCIEQ0SerdesConfig1;
  136. unsigned long long PCIEQ0SerdesStatus;
  137. unsigned long long Reserved11;
  138. unsigned long long PCIEQ1SerdesConfig0;
  139. unsigned long long PCIEQ1SerdesConfig1;
  140. unsigned long long PCIEQ1SerdesStatus;
  141. unsigned long long Reserved12;
  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_pe_kregs = {
  194. .kr_control = IPATH_KREG_OFFSET(Control),
  195. .kr_counterregbase = IPATH_KREG_OFFSET(CounterRegBase),
  196. .kr_debugportselect = IPATH_KREG_OFFSET(DebugPortSelect),
  197. .kr_errorclear = IPATH_KREG_OFFSET(ErrorClear),
  198. .kr_errormask = IPATH_KREG_OFFSET(ErrorMask),
  199. .kr_errorstatus = IPATH_KREG_OFFSET(ErrorStatus),
  200. .kr_extctrl = IPATH_KREG_OFFSET(ExtCtrl),
  201. .kr_extstatus = IPATH_KREG_OFFSET(ExtStatus),
  202. .kr_gpio_clear = IPATH_KREG_OFFSET(GPIOClear),
  203. .kr_gpio_mask = IPATH_KREG_OFFSET(GPIOMask),
  204. .kr_gpio_out = IPATH_KREG_OFFSET(GPIOOut),
  205. .kr_gpio_status = IPATH_KREG_OFFSET(GPIOStatus),
  206. .kr_hwdiagctrl = IPATH_KREG_OFFSET(HwDiagCtrl),
  207. .kr_hwerrclear = IPATH_KREG_OFFSET(HwErrClear),
  208. .kr_hwerrmask = IPATH_KREG_OFFSET(HwErrMask),
  209. .kr_hwerrstatus = IPATH_KREG_OFFSET(HwErrStatus),
  210. .kr_ibcctrl = IPATH_KREG_OFFSET(IBCCtrl),
  211. .kr_ibcstatus = IPATH_KREG_OFFSET(IBCStatus),
  212. .kr_intblocked = IPATH_KREG_OFFSET(IntBlocked),
  213. .kr_intclear = IPATH_KREG_OFFSET(IntClear),
  214. .kr_intmask = IPATH_KREG_OFFSET(IntMask),
  215. .kr_intstatus = IPATH_KREG_OFFSET(IntStatus),
  216. .kr_mdio = IPATH_KREG_OFFSET(MDIO),
  217. .kr_pagealign = IPATH_KREG_OFFSET(PageAlign),
  218. .kr_partitionkey = IPATH_KREG_OFFSET(RcvPartitionKey),
  219. .kr_portcnt = IPATH_KREG_OFFSET(PortCnt),
  220. .kr_rcvbthqp = IPATH_KREG_OFFSET(RcvBTHQP),
  221. .kr_rcvbufbase = IPATH_KREG_OFFSET(RcvBufBase),
  222. .kr_rcvbufsize = IPATH_KREG_OFFSET(RcvBufSize),
  223. .kr_rcvctrl = IPATH_KREG_OFFSET(RcvCtrl),
  224. .kr_rcvegrbase = IPATH_KREG_OFFSET(RcvEgrBase),
  225. .kr_rcvegrcnt = IPATH_KREG_OFFSET(RcvEgrCnt),
  226. .kr_rcvhdrcnt = IPATH_KREG_OFFSET(RcvHdrCnt),
  227. .kr_rcvhdrentsize = IPATH_KREG_OFFSET(RcvHdrEntSize),
  228. .kr_rcvhdrsize = IPATH_KREG_OFFSET(RcvHdrSize),
  229. .kr_rcvintmembase = IPATH_KREG_OFFSET(RxIntMemBase),
  230. .kr_rcvintmemsize = IPATH_KREG_OFFSET(RxIntMemSize),
  231. .kr_rcvtidbase = IPATH_KREG_OFFSET(RcvTIDBase),
  232. .kr_rcvtidcnt = IPATH_KREG_OFFSET(RcvTIDCnt),
  233. .kr_revision = IPATH_KREG_OFFSET(Revision),
  234. .kr_scratch = IPATH_KREG_OFFSET(Scratch),
  235. .kr_sendbuffererror = IPATH_KREG_OFFSET(SendBufferError),
  236. .kr_sendctrl = IPATH_KREG_OFFSET(SendCtrl),
  237. .kr_sendpioavailaddr = IPATH_KREG_OFFSET(SendPIOAvailAddr),
  238. .kr_sendpiobufbase = IPATH_KREG_OFFSET(SendPIOBufBase),
  239. .kr_sendpiobufcnt = IPATH_KREG_OFFSET(SendPIOBufCnt),
  240. .kr_sendpiosize = IPATH_KREG_OFFSET(SendPIOSize),
  241. .kr_sendregbase = IPATH_KREG_OFFSET(SendRegBase),
  242. .kr_txintmembase = IPATH_KREG_OFFSET(TxIntMemBase),
  243. .kr_txintmemsize = IPATH_KREG_OFFSET(TxIntMemSize),
  244. .kr_userregbase = IPATH_KREG_OFFSET(UserRegBase),
  245. .kr_serdesconfig0 = IPATH_KREG_OFFSET(SerdesConfig0),
  246. .kr_serdesconfig1 = IPATH_KREG_OFFSET(SerdesConfig1),
  247. .kr_serdesstatus = IPATH_KREG_OFFSET(SerdesStatus),
  248. .kr_xgxsconfig = IPATH_KREG_OFFSET(XGXSConfig),
  249. .kr_ibpllcfg = IPATH_KREG_OFFSET(IBPLLCfg),
  250. /*
  251. * These should not be used directly via ipath_write_kreg64(),
  252. * use them with ipath_write_kreg64_port(),
  253. */
  254. .kr_rcvhdraddr = IPATH_KREG_OFFSET(RcvHdrAddr0),
  255. .kr_rcvhdrtailaddr = IPATH_KREG_OFFSET(RcvHdrTailAddr0),
  256. /* The rcvpktled register controls one of the debug port signals, so
  257. * a packet activity LED can be connected to it. */
  258. .kr_rcvpktledcnt = IPATH_KREG_OFFSET(RcvPktLEDCnt),
  259. .kr_pcierbuftestreg0 = IPATH_KREG_OFFSET(PCIeRBufTestReg0),
  260. .kr_pcierbuftestreg1 = IPATH_KREG_OFFSET(PCIeRBufTestReg1),
  261. .kr_pcieq0serdesconfig0 = IPATH_KREG_OFFSET(PCIEQ0SerdesConfig0),
  262. .kr_pcieq0serdesconfig1 = IPATH_KREG_OFFSET(PCIEQ0SerdesConfig1),
  263. .kr_pcieq0serdesstatus = IPATH_KREG_OFFSET(PCIEQ0SerdesStatus),
  264. .kr_pcieq1serdesconfig0 = IPATH_KREG_OFFSET(PCIEQ1SerdesConfig0),
  265. .kr_pcieq1serdesconfig1 = IPATH_KREG_OFFSET(PCIEQ1SerdesConfig1),
  266. .kr_pcieq1serdesstatus = IPATH_KREG_OFFSET(PCIEQ1SerdesStatus)
  267. };
  268. static const struct ipath_cregs ipath_pe_cregs = {
  269. .cr_badformatcnt = IPATH_CREG_OFFSET(RxBadFormatCnt),
  270. .cr_erricrccnt = IPATH_CREG_OFFSET(RxICRCErrCnt),
  271. .cr_errlinkcnt = IPATH_CREG_OFFSET(RxLinkProblemCnt),
  272. .cr_errlpcrccnt = IPATH_CREG_OFFSET(RxLPCRCErrCnt),
  273. .cr_errpkey = IPATH_CREG_OFFSET(RxPKeyMismatchCnt),
  274. .cr_errrcvflowctrlcnt = IPATH_CREG_OFFSET(RxFlowCtrlErrCnt),
  275. .cr_err_rlencnt = IPATH_CREG_OFFSET(RxLenErrCnt),
  276. .cr_errslencnt = IPATH_CREG_OFFSET(TxLenErrCnt),
  277. .cr_errtidfull = IPATH_CREG_OFFSET(RxTIDFullErrCnt),
  278. .cr_errtidvalid = IPATH_CREG_OFFSET(RxTIDValidErrCnt),
  279. .cr_errvcrccnt = IPATH_CREG_OFFSET(RxVCRCErrCnt),
  280. .cr_ibstatuschange = IPATH_CREG_OFFSET(IBStatusChangeCnt),
  281. .cr_intcnt = IPATH_CREG_OFFSET(LBIntCnt),
  282. .cr_invalidrlencnt = IPATH_CREG_OFFSET(RxMaxMinLenErrCnt),
  283. .cr_invalidslencnt = IPATH_CREG_OFFSET(TxMaxMinLenErrCnt),
  284. .cr_lbflowstallcnt = IPATH_CREG_OFFSET(LBFlowStallCnt),
  285. .cr_pktrcvcnt = IPATH_CREG_OFFSET(RxDataPktCnt),
  286. .cr_pktrcvflowctrlcnt = IPATH_CREG_OFFSET(RxFlowPktCnt),
  287. .cr_pktsendcnt = IPATH_CREG_OFFSET(TxDataPktCnt),
  288. .cr_pktsendflowcnt = IPATH_CREG_OFFSET(TxFlowPktCnt),
  289. .cr_portovflcnt = IPATH_CREG_OFFSET(RxP0HdrEgrOvflCnt),
  290. .cr_rcvebpcnt = IPATH_CREG_OFFSET(RxEBPCnt),
  291. .cr_rcvovflcnt = IPATH_CREG_OFFSET(RxBufOvflCnt),
  292. .cr_senddropped = IPATH_CREG_OFFSET(TxDroppedPktCnt),
  293. .cr_sendstallcnt = IPATH_CREG_OFFSET(TxFlowStallCnt),
  294. .cr_sendunderruncnt = IPATH_CREG_OFFSET(TxUnderrunCnt),
  295. .cr_wordrcvcnt = IPATH_CREG_OFFSET(RxDwordCnt),
  296. .cr_wordsendcnt = IPATH_CREG_OFFSET(TxDwordCnt),
  297. .cr_unsupvlcnt = IPATH_CREG_OFFSET(TxUnsupVLErrCnt),
  298. .cr_rxdroppktcnt = IPATH_CREG_OFFSET(RxDroppedPktCnt),
  299. .cr_iblinkerrrecovcnt = IPATH_CREG_OFFSET(IBLinkErrRecoveryCnt),
  300. .cr_iblinkdowncnt = IPATH_CREG_OFFSET(IBLinkDownedCnt),
  301. .cr_ibsymbolerrcnt = IPATH_CREG_OFFSET(IBSymbolErrCnt)
  302. };
  303. /* kr_control bits */
  304. #define INFINIPATH_C_RESET 1U
  305. /* kr_intstatus, kr_intclear, kr_intmask bits */
  306. #define INFINIPATH_I_RCVURG_MASK ((1U<<5)-1)
  307. #define INFINIPATH_I_RCVURG_SHIFT 0
  308. #define INFINIPATH_I_RCVAVAIL_MASK ((1U<<5)-1)
  309. #define INFINIPATH_I_RCVAVAIL_SHIFT 12
  310. /* kr_hwerrclear, kr_hwerrmask, kr_hwerrstatus, bits */
  311. #define INFINIPATH_HWE_PCIEMEMPARITYERR_MASK 0x000000000000003fULL
  312. #define INFINIPATH_HWE_PCIEMEMPARITYERR_SHIFT 0
  313. #define INFINIPATH_HWE_PCIEPOISONEDTLP 0x0000000010000000ULL
  314. #define INFINIPATH_HWE_PCIECPLTIMEOUT 0x0000000020000000ULL
  315. #define INFINIPATH_HWE_PCIEBUSPARITYXTLH 0x0000000040000000ULL
  316. #define INFINIPATH_HWE_PCIEBUSPARITYXADM 0x0000000080000000ULL
  317. #define INFINIPATH_HWE_PCIEBUSPARITYRADM 0x0000000100000000ULL
  318. #define INFINIPATH_HWE_COREPLL_FBSLIP 0x0080000000000000ULL
  319. #define INFINIPATH_HWE_COREPLL_RFSLIP 0x0100000000000000ULL
  320. #define INFINIPATH_HWE_PCIE1PLLFAILED 0x0400000000000000ULL
  321. #define INFINIPATH_HWE_PCIE0PLLFAILED 0x0800000000000000ULL
  322. #define INFINIPATH_HWE_SERDESPLLFAILED 0x1000000000000000ULL
  323. #define IBA6120_IBCS_LINKTRAININGSTATE_MASK 0xf
  324. #define IBA6120_IBCS_LINKSTATE_SHIFT 4
  325. /* kr_extstatus bits */
  326. #define INFINIPATH_EXTS_FREQSEL 0x2
  327. #define INFINIPATH_EXTS_SERDESSEL 0x4
  328. #define INFINIPATH_EXTS_MEMBIST_ENDTEST 0x0000000000004000
  329. #define INFINIPATH_EXTS_MEMBIST_FOUND 0x0000000000008000
  330. /* kr_xgxsconfig bits */
  331. #define INFINIPATH_XGXS_RESET 0x5ULL
  332. #define _IPATH_GPIO_SDA_NUM 1
  333. #define _IPATH_GPIO_SCL_NUM 0
  334. #define IPATH_GPIO_SDA (1ULL << \
  335. (_IPATH_GPIO_SDA_NUM+INFINIPATH_EXTC_GPIOOE_SHIFT))
  336. #define IPATH_GPIO_SCL (1ULL << \
  337. (_IPATH_GPIO_SCL_NUM+INFINIPATH_EXTC_GPIOOE_SHIFT))
  338. #define INFINIPATH_RT_BUFSIZE_MASK 0xe0000000ULL
  339. #define INFINIPATH_RT_BUFSIZE_SHIFTVAL(tid) \
  340. ((((tid) & INFINIPATH_RT_BUFSIZE_MASK) >> 29) + 11 - 1)
  341. #define INFINIPATH_RT_BUFSIZE(tid) (1 << INFINIPATH_RT_BUFSIZE_SHIFTVAL(tid))
  342. #define INFINIPATH_RT_IS_VALID(tid) \
  343. (((tid) & INFINIPATH_RT_BUFSIZE_MASK) && \
  344. ((((tid) & INFINIPATH_RT_BUFSIZE_MASK) != INFINIPATH_RT_BUFSIZE_MASK)))
  345. #define INFINIPATH_RT_ADDR_MASK 0x1FFFFFFFULL /* 29 bits valid */
  346. #define INFINIPATH_RT_ADDR_SHIFT 10
  347. #define INFINIPATH_R_INTRAVAIL_SHIFT 16
  348. #define INFINIPATH_R_TAILUPD_SHIFT 31
  349. /* 6120 specific hardware errors... */
  350. static const struct ipath_hwerror_msgs ipath_6120_hwerror_msgs[] = {
  351. INFINIPATH_HWE_MSG(PCIEPOISONEDTLP, "PCIe Poisoned TLP"),
  352. INFINIPATH_HWE_MSG(PCIECPLTIMEOUT, "PCIe completion timeout"),
  353. /*
  354. * In practice, it's unlikely wthat we'll see PCIe PLL, or bus
  355. * parity or memory parity error failures, because most likely we
  356. * won't be able to talk to the core of the chip. Nonetheless, we
  357. * might see them, if they are in parts of the PCIe core that aren't
  358. * essential.
  359. */
  360. INFINIPATH_HWE_MSG(PCIE1PLLFAILED, "PCIePLL1"),
  361. INFINIPATH_HWE_MSG(PCIE0PLLFAILED, "PCIePLL0"),
  362. INFINIPATH_HWE_MSG(PCIEBUSPARITYXTLH, "PCIe XTLH core parity"),
  363. INFINIPATH_HWE_MSG(PCIEBUSPARITYXADM, "PCIe ADM TX core parity"),
  364. INFINIPATH_HWE_MSG(PCIEBUSPARITYRADM, "PCIe ADM RX core parity"),
  365. INFINIPATH_HWE_MSG(RXDSYNCMEMPARITYERR, "Rx Dsync"),
  366. INFINIPATH_HWE_MSG(SERDESPLLFAILED, "SerDes PLL"),
  367. };
  368. #define TXE_PIO_PARITY ((INFINIPATH_HWE_TXEMEMPARITYERR_PIOBUF | \
  369. INFINIPATH_HWE_TXEMEMPARITYERR_PIOPBC) \
  370. << INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT)
  371. #define RXE_EAGER_PARITY (INFINIPATH_HWE_RXEMEMPARITYERR_EAGERTID \
  372. << INFINIPATH_HWE_RXEMEMPARITYERR_SHIFT)
  373. static void ipath_pe_put_tid_2(struct ipath_devdata *, u64 __iomem *,
  374. u32, unsigned long);
  375. /*
  376. * On platforms using this chip, and not having ordered WC stores, we
  377. * can get TXE parity errors due to speculative reads to the PIO buffers,
  378. * and this, due to a chip bug can result in (many) false parity error
  379. * reports. So it's a debug print on those, and an info print on systems
  380. * where the speculative reads don't occur.
  381. */
  382. static void ipath_pe_txe_recover(struct ipath_devdata *dd)
  383. {
  384. if (ipath_unordered_wc())
  385. ipath_dbg("Recovering from TXE PIO parity error\n");
  386. else {
  387. ++ipath_stats.sps_txeparity;
  388. dev_info(&dd->pcidev->dev,
  389. "Recovering from TXE PIO parity error\n");
  390. }
  391. }
  392. /**
  393. * ipath_pe_handle_hwerrors - display hardware errors.
  394. * @dd: the infinipath device
  395. * @msg: the output buffer
  396. * @msgl: the size of the output buffer
  397. *
  398. * Use same msg buffer as regular errors to avoid excessive stack
  399. * use. Most hardware errors are catastrophic, but for right now,
  400. * we'll print them and continue. We reuse the same message buffer as
  401. * ipath_handle_errors() to avoid excessive stack usage.
  402. */
  403. static void ipath_pe_handle_hwerrors(struct ipath_devdata *dd, char *msg,
  404. size_t msgl)
  405. {
  406. ipath_err_t hwerrs;
  407. u32 bits, ctrl;
  408. int isfatal = 0;
  409. char bitsmsg[64];
  410. int log_idx;
  411. hwerrs = ipath_read_kreg64(dd, dd->ipath_kregs->kr_hwerrstatus);
  412. if (!hwerrs) {
  413. /*
  414. * better than printing cofusing messages
  415. * This seems to be related to clearing the crc error, or
  416. * the pll error during init.
  417. */
  418. ipath_cdbg(VERBOSE, "Called but no hardware errors set\n");
  419. return;
  420. } else if (hwerrs == ~0ULL) {
  421. ipath_dev_err(dd, "Read of hardware error status failed "
  422. "(all bits set); ignoring\n");
  423. return;
  424. }
  425. ipath_stats.sps_hwerrs++;
  426. /* Always clear the error status register, except MEMBISTFAIL,
  427. * regardless of whether we continue or stop using the chip.
  428. * We want that set so we know it failed, even across driver reload.
  429. * We'll still ignore it in the hwerrmask. We do this partly for
  430. * diagnostics, but also for support */
  431. ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrclear,
  432. hwerrs&~INFINIPATH_HWE_MEMBISTFAILED);
  433. hwerrs &= dd->ipath_hwerrmask;
  434. /* We log some errors to EEPROM, check if we have any of those. */
  435. for (log_idx = 0; log_idx < IPATH_EEP_LOG_CNT; ++log_idx)
  436. if (hwerrs & dd->ipath_eep_st_masks[log_idx].hwerrs_to_log)
  437. ipath_inc_eeprom_err(dd, log_idx, 1);
  438. /*
  439. * make sure we get this much out, unless told to be quiet,
  440. * or it's occurred within the last 5 seconds
  441. */
  442. if ((hwerrs & ~(dd->ipath_lasthwerror | TXE_PIO_PARITY |
  443. RXE_EAGER_PARITY)) ||
  444. (ipath_debug & __IPATH_VERBDBG))
  445. dev_info(&dd->pcidev->dev, "Hardware error: hwerr=0x%llx "
  446. "(cleared)\n", (unsigned long long) hwerrs);
  447. dd->ipath_lasthwerror |= hwerrs;
  448. if (hwerrs & ~dd->ipath_hwe_bitsextant)
  449. ipath_dev_err(dd, "hwerror interrupt with unknown errors "
  450. "%llx set\n", (unsigned long long)
  451. (hwerrs & ~dd->ipath_hwe_bitsextant));
  452. ctrl = ipath_read_kreg32(dd, dd->ipath_kregs->kr_control);
  453. if ((ctrl & INFINIPATH_C_FREEZEMODE) && !ipath_diag_inuse) {
  454. /*
  455. * parity errors in send memory are recoverable,
  456. * just cancel the send (if indicated in * sendbuffererror),
  457. * count the occurrence, unfreeze (if no other handled
  458. * hardware error bits are set), and continue. They can
  459. * occur if a processor speculative read is done to the PIO
  460. * buffer while we are sending a packet, for example.
  461. */
  462. if (hwerrs & TXE_PIO_PARITY) {
  463. ipath_pe_txe_recover(dd);
  464. hwerrs &= ~TXE_PIO_PARITY;
  465. }
  466. if (!hwerrs) {
  467. static u32 freeze_cnt;
  468. freeze_cnt++;
  469. ipath_dbg("Clearing freezemode on ignored or recovered "
  470. "hardware error (%u)\n", freeze_cnt);
  471. ipath_clear_freeze(dd);
  472. }
  473. }
  474. *msg = '\0';
  475. if (hwerrs & INFINIPATH_HWE_MEMBISTFAILED) {
  476. strlcat(msg, "[Memory BIST test failed, InfiniPath hardware unusable]",
  477. msgl);
  478. /* ignore from now on, so disable until driver reloaded */
  479. *dd->ipath_statusp |= IPATH_STATUS_HWERROR;
  480. dd->ipath_hwerrmask &= ~INFINIPATH_HWE_MEMBISTFAILED;
  481. ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrmask,
  482. dd->ipath_hwerrmask);
  483. }
  484. ipath_format_hwerrors(hwerrs,
  485. ipath_6120_hwerror_msgs,
  486. sizeof(ipath_6120_hwerror_msgs)/
  487. sizeof(ipath_6120_hwerror_msgs[0]),
  488. msg, msgl);
  489. if (hwerrs & (INFINIPATH_HWE_PCIEMEMPARITYERR_MASK
  490. << INFINIPATH_HWE_PCIEMEMPARITYERR_SHIFT)) {
  491. bits = (u32) ((hwerrs >>
  492. INFINIPATH_HWE_PCIEMEMPARITYERR_SHIFT) &
  493. INFINIPATH_HWE_PCIEMEMPARITYERR_MASK);
  494. snprintf(bitsmsg, sizeof bitsmsg,
  495. "[PCIe Mem Parity Errs %x] ", bits);
  496. strlcat(msg, bitsmsg, msgl);
  497. }
  498. #define _IPATH_PLL_FAIL (INFINIPATH_HWE_COREPLL_FBSLIP | \
  499. INFINIPATH_HWE_COREPLL_RFSLIP )
  500. if (hwerrs & _IPATH_PLL_FAIL) {
  501. snprintf(bitsmsg, sizeof bitsmsg,
  502. "[PLL failed (%llx), InfiniPath hardware unusable]",
  503. (unsigned long long) hwerrs & _IPATH_PLL_FAIL);
  504. strlcat(msg, bitsmsg, msgl);
  505. /* ignore from now on, so disable until driver reloaded */
  506. dd->ipath_hwerrmask &= ~(hwerrs & _IPATH_PLL_FAIL);
  507. ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrmask,
  508. dd->ipath_hwerrmask);
  509. }
  510. if (hwerrs & INFINIPATH_HWE_SERDESPLLFAILED) {
  511. /*
  512. * If it occurs, it is left masked since the external
  513. * interface is unused
  514. */
  515. dd->ipath_hwerrmask &= ~INFINIPATH_HWE_SERDESPLLFAILED;
  516. ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrmask,
  517. dd->ipath_hwerrmask);
  518. }
  519. if (hwerrs) {
  520. /*
  521. * if any set that we aren't ignoring; only
  522. * make the complaint once, in case it's stuck
  523. * or recurring, and we get here multiple
  524. * times.
  525. */
  526. ipath_dev_err(dd, "%s hardware error\n", msg);
  527. if (dd->ipath_flags & IPATH_INITTED) {
  528. ipath_set_linkstate(dd, IPATH_IB_LINKDOWN);
  529. ipath_setup_pe_setextled(dd,
  530. INFINIPATH_IBCS_L_STATE_DOWN,
  531. INFINIPATH_IBCS_LT_STATE_DISABLED);
  532. ipath_dev_err(dd, "Fatal Hardware Error (freeze "
  533. "mode), no longer usable, SN %.16s\n",
  534. dd->ipath_serial);
  535. isfatal = 1;
  536. }
  537. *dd->ipath_statusp &= ~IPATH_STATUS_IB_READY;
  538. /* mark as having had error */
  539. *dd->ipath_statusp |= IPATH_STATUS_HWERROR;
  540. /*
  541. * mark as not usable, at a minimum until driver
  542. * is reloaded, probably until reboot, since no
  543. * other reset is possible.
  544. */
  545. dd->ipath_flags &= ~IPATH_INITTED;
  546. } else
  547. *msg = 0; /* recovered from all of them */
  548. if (isfatal && !ipath_diag_inuse && dd->ipath_freezemsg && msg) {
  549. /*
  550. * for /sys status file ; if no trailing brace is copied,
  551. * we'll know it was truncated.
  552. */
  553. snprintf(dd->ipath_freezemsg, dd->ipath_freezelen,
  554. "{%s}", msg);
  555. }
  556. }
  557. /**
  558. * ipath_pe_boardname - fill in the board name
  559. * @dd: the infinipath device
  560. * @name: the output buffer
  561. * @namelen: the size of the output buffer
  562. *
  563. * info is based on the board revision register
  564. */
  565. static int ipath_pe_boardname(struct ipath_devdata *dd, char *name,
  566. size_t namelen)
  567. {
  568. char *n = NULL;
  569. u8 boardrev = dd->ipath_boardrev;
  570. int ret;
  571. switch (boardrev) {
  572. case 0:
  573. n = "InfiniPath_Emulation";
  574. break;
  575. case 1:
  576. n = "InfiniPath_QLE7140-Bringup";
  577. break;
  578. case 2:
  579. n = "InfiniPath_QLE7140";
  580. break;
  581. case 3:
  582. n = "InfiniPath_QMI7140";
  583. break;
  584. case 4:
  585. n = "InfiniPath_QEM7140";
  586. break;
  587. case 5:
  588. n = "InfiniPath_QMH7140";
  589. break;
  590. case 6:
  591. n = "InfiniPath_QLE7142";
  592. break;
  593. default:
  594. ipath_dev_err(dd,
  595. "Don't yet know about board with ID %u\n",
  596. boardrev);
  597. snprintf(name, namelen, "Unknown_InfiniPath_PCIe_%u",
  598. boardrev);
  599. break;
  600. }
  601. if (n)
  602. snprintf(name, namelen, "%s", n);
  603. if (dd->ipath_majrev != 4 || !dd->ipath_minrev || dd->ipath_minrev>2) {
  604. ipath_dev_err(dd, "Unsupported InfiniPath hardware revision %u.%u!\n",
  605. dd->ipath_majrev, dd->ipath_minrev);
  606. ret = 1;
  607. } else {
  608. ret = 0;
  609. if (dd->ipath_minrev >= 2)
  610. dd->ipath_f_put_tid = ipath_pe_put_tid_2;
  611. }
  612. /*
  613. * set here, not in ipath_init_*_funcs because we have to do
  614. * it after we can read chip registers.
  615. */
  616. dd->ipath_ureg_align =
  617. ipath_read_kreg32(dd, dd->ipath_kregs->kr_pagealign);
  618. return ret;
  619. }
  620. /**
  621. * ipath_pe_init_hwerrors - enable hardware errors
  622. * @dd: the infinipath device
  623. *
  624. * now that we have finished initializing everything that might reasonably
  625. * cause a hardware error, and cleared those errors bits as they occur,
  626. * we can enable hardware errors in the mask (potentially enabling
  627. * freeze mode), and enable hardware errors as errors (along with
  628. * everything else) in errormask
  629. */
  630. static void ipath_pe_init_hwerrors(struct ipath_devdata *dd)
  631. {
  632. ipath_err_t val;
  633. u64 extsval;
  634. extsval = ipath_read_kreg64(dd, dd->ipath_kregs->kr_extstatus);
  635. if (!(extsval & INFINIPATH_EXTS_MEMBIST_ENDTEST))
  636. ipath_dev_err(dd, "MemBIST did not complete!\n");
  637. if (extsval & INFINIPATH_EXTS_MEMBIST_FOUND)
  638. ipath_dbg("MemBIST corrected\n");
  639. val = ~0ULL; /* barring bugs, all hwerrors become interrupts, */
  640. if (!dd->ipath_boardrev) // no PLL for Emulator
  641. val &= ~INFINIPATH_HWE_SERDESPLLFAILED;
  642. if (dd->ipath_minrev < 2) {
  643. /* workaround bug 9460 in internal interface bus parity
  644. * checking. Fixed (HW bug 9490) in Rev2.
  645. */
  646. val &= ~INFINIPATH_HWE_PCIEBUSPARITYRADM;
  647. }
  648. dd->ipath_hwerrmask = val;
  649. }
  650. /**
  651. * ipath_pe_bringup_serdes - bring up the serdes
  652. * @dd: the infinipath device
  653. */
  654. static int ipath_pe_bringup_serdes(struct ipath_devdata *dd)
  655. {
  656. u64 val, config1, prev_val;
  657. int ret = 0;
  658. ipath_dbg("Trying to bringup serdes\n");
  659. if (ipath_read_kreg64(dd, dd->ipath_kregs->kr_hwerrstatus) &
  660. INFINIPATH_HWE_SERDESPLLFAILED) {
  661. ipath_dbg("At start, serdes PLL failed bit set "
  662. "in hwerrstatus, clearing and continuing\n");
  663. ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrclear,
  664. INFINIPATH_HWE_SERDESPLLFAILED);
  665. }
  666. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig0);
  667. config1 = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig1);
  668. ipath_cdbg(VERBOSE, "SerDes status config0=%llx config1=%llx, "
  669. "xgxsconfig %llx\n", (unsigned long long) val,
  670. (unsigned long long) config1, (unsigned long long)
  671. ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig));
  672. /*
  673. * Force reset on, also set rxdetect enable. Must do before reading
  674. * serdesstatus at least for simulation, or some of the bits in
  675. * serdes status will come back as undefined and cause simulation
  676. * failures
  677. */
  678. val |= INFINIPATH_SERDC0_RESET_PLL | INFINIPATH_SERDC0_RXDETECT_EN
  679. | INFINIPATH_SERDC0_L1PWR_DN;
  680. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);
  681. /* be sure chip saw it */
  682. ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
  683. udelay(5); /* need pll reset set at least for a bit */
  684. /*
  685. * after PLL is reset, set the per-lane Resets and TxIdle and
  686. * clear the PLL reset and rxdetect (to get falling edge).
  687. * Leave L1PWR bits set (permanently)
  688. */
  689. val &= ~(INFINIPATH_SERDC0_RXDETECT_EN | INFINIPATH_SERDC0_RESET_PLL
  690. | INFINIPATH_SERDC0_L1PWR_DN);
  691. val |= INFINIPATH_SERDC0_RESET_MASK | INFINIPATH_SERDC0_TXIDLE;
  692. ipath_cdbg(VERBOSE, "Clearing pll reset and setting lane resets "
  693. "and txidle (%llx)\n", (unsigned long long) val);
  694. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);
  695. /* be sure chip saw it */
  696. ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
  697. /* need PLL reset clear for at least 11 usec before lane
  698. * resets cleared; give it a few more to be sure */
  699. udelay(15);
  700. val &= ~(INFINIPATH_SERDC0_RESET_MASK | INFINIPATH_SERDC0_TXIDLE);
  701. ipath_cdbg(VERBOSE, "Clearing lane resets and txidle "
  702. "(writing %llx)\n", (unsigned long long) val);
  703. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);
  704. /* be sure chip saw it */
  705. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
  706. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig);
  707. prev_val = val;
  708. if (val & INFINIPATH_XGXS_RESET)
  709. val &= ~INFINIPATH_XGXS_RESET;
  710. if (((val >> INFINIPATH_XGXS_RX_POL_SHIFT) &
  711. INFINIPATH_XGXS_RX_POL_MASK) != dd->ipath_rx_pol_inv ) {
  712. /* need to compensate for Tx inversion in partner */
  713. val &= ~(INFINIPATH_XGXS_RX_POL_MASK <<
  714. INFINIPATH_XGXS_RX_POL_SHIFT);
  715. val |= dd->ipath_rx_pol_inv <<
  716. INFINIPATH_XGXS_RX_POL_SHIFT;
  717. }
  718. if (val != prev_val)
  719. ipath_write_kreg(dd, dd->ipath_kregs->kr_xgxsconfig, val);
  720. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig0);
  721. /* clear current and de-emphasis bits */
  722. config1 &= ~0x0ffffffff00ULL;
  723. /* set current to 20ma */
  724. config1 |= 0x00000000000ULL;
  725. /* set de-emphasis to -5.68dB */
  726. config1 |= 0x0cccc000000ULL;
  727. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig1, config1);
  728. ipath_cdbg(VERBOSE, "done: SerDes status config0=%llx "
  729. "config1=%llx, sstatus=%llx xgxs=%llx\n",
  730. (unsigned long long) val, (unsigned long long) config1,
  731. (unsigned long long)
  732. ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesstatus),
  733. (unsigned long long)
  734. ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig));
  735. return ret;
  736. }
  737. /**
  738. * ipath_pe_quiet_serdes - set serdes to txidle
  739. * @dd: the infinipath device
  740. * Called when driver is being unloaded
  741. */
  742. static void ipath_pe_quiet_serdes(struct ipath_devdata *dd)
  743. {
  744. u64 val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig0);
  745. val |= INFINIPATH_SERDC0_TXIDLE;
  746. ipath_dbg("Setting TxIdleEn on serdes (config0 = %llx)\n",
  747. (unsigned long long) val);
  748. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);
  749. }
  750. static int ipath_pe_intconfig(struct ipath_devdata *dd)
  751. {
  752. u32 chiprev;
  753. /*
  754. * If the chip supports added error indication via GPIO pins,
  755. * enable interrupts on those bits so the interrupt routine
  756. * can count the events. Also set flag so interrupt routine
  757. * can know they are expected.
  758. */
  759. chiprev = dd->ipath_revision >> INFINIPATH_R_CHIPREVMINOR_SHIFT;
  760. if ((chiprev & INFINIPATH_R_CHIPREVMINOR_MASK) > 1) {
  761. /* Rev2+ reports extra errors via internal GPIO pins */
  762. dd->ipath_flags |= IPATH_GPIO_ERRINTRS;
  763. dd->ipath_gpio_mask |= IPATH_GPIO_ERRINTR_MASK;
  764. ipath_write_kreg(dd, dd->ipath_kregs->kr_gpio_mask,
  765. dd->ipath_gpio_mask);
  766. }
  767. return 0;
  768. }
  769. /**
  770. * ipath_setup_pe_setextled - set the state of the two external LEDs
  771. * @dd: the infinipath device
  772. * @lst: the L state
  773. * @ltst: the LT state
  774. * These LEDs indicate the physical and logical state of IB link.
  775. * For this chip (at least with recommended board pinouts), LED1
  776. * is Yellow (logical state) and LED2 is Green (physical state),
  777. *
  778. * Note: We try to match the Mellanox HCA LED behavior as best
  779. * we can. Green indicates physical link state is OK (something is
  780. * plugged in, and we can train).
  781. * Amber indicates the link is logically up (ACTIVE).
  782. * Mellanox further blinks the amber LED to indicate data packet
  783. * activity, but we have no hardware support for that, so it would
  784. * require waking up every 10-20 msecs and checking the counters
  785. * on the chip, and then turning the LED off if appropriate. That's
  786. * visible overhead, so not something we will do.
  787. *
  788. */
  789. static void ipath_setup_pe_setextled(struct ipath_devdata *dd, u64 lst,
  790. u64 ltst)
  791. {
  792. u64 extctl;
  793. unsigned long flags = 0;
  794. /* the diags use the LED to indicate diag info, so we leave
  795. * the external LED alone when the diags are running */
  796. if (ipath_diag_inuse)
  797. return;
  798. /* Allow override of LED display for, e.g. Locating system in rack */
  799. if (dd->ipath_led_override) {
  800. ltst = (dd->ipath_led_override & IPATH_LED_PHYS)
  801. ? INFINIPATH_IBCS_LT_STATE_LINKUP
  802. : INFINIPATH_IBCS_LT_STATE_DISABLED;
  803. lst = (dd->ipath_led_override & IPATH_LED_LOG)
  804. ? INFINIPATH_IBCS_L_STATE_ACTIVE
  805. : INFINIPATH_IBCS_L_STATE_DOWN;
  806. }
  807. spin_lock_irqsave(&dd->ipath_gpio_lock, flags);
  808. extctl = dd->ipath_extctrl & ~(INFINIPATH_EXTC_LED1PRIPORT_ON |
  809. INFINIPATH_EXTC_LED2PRIPORT_ON);
  810. if (ltst == INFINIPATH_IBCS_LT_STATE_LINKUP)
  811. extctl |= INFINIPATH_EXTC_LED2PRIPORT_ON;
  812. if (lst == INFINIPATH_IBCS_L_STATE_ACTIVE)
  813. extctl |= INFINIPATH_EXTC_LED1PRIPORT_ON;
  814. dd->ipath_extctrl = extctl;
  815. ipath_write_kreg(dd, dd->ipath_kregs->kr_extctrl, extctl);
  816. spin_unlock_irqrestore(&dd->ipath_gpio_lock, flags);
  817. }
  818. /**
  819. * ipath_setup_pe_cleanup - clean up any per-chip chip-specific stuff
  820. * @dd: the infinipath device
  821. *
  822. * This is called during driver unload.
  823. * We do the pci_disable_msi here, not in generic code, because it
  824. * isn't used for the HT chips. If we do end up needing pci_enable_msi
  825. * at some point in the future for HT, we'll move the call back
  826. * into the main init_one code.
  827. */
  828. static void ipath_setup_pe_cleanup(struct ipath_devdata *dd)
  829. {
  830. dd->ipath_msi_lo = 0; /* just in case unload fails */
  831. pci_disable_msi(dd->pcidev);
  832. }
  833. static void ipath_6120_pcie_params(struct ipath_devdata *dd)
  834. {
  835. u16 linkstat, speed;
  836. int pos;
  837. pos = pci_find_capability(dd->pcidev, PCI_CAP_ID_EXP);
  838. if (!pos) {
  839. ipath_dev_err(dd, "Can't find PCI Express capability!\n");
  840. goto bail;
  841. }
  842. pci_read_config_word(dd->pcidev, pos + PCI_EXP_LNKSTA,
  843. &linkstat);
  844. /*
  845. * speed is bits 0-4, linkwidth is bits 4-8
  846. * no defines for them in headers
  847. */
  848. speed = linkstat & 0xf;
  849. linkstat >>= 4;
  850. linkstat &= 0x1f;
  851. dd->ipath_lbus_width = linkstat;
  852. switch (speed) {
  853. case 1:
  854. dd->ipath_lbus_speed = 2500; /* Gen1, 2.5GHz */
  855. break;
  856. case 2:
  857. dd->ipath_lbus_speed = 5000; /* Gen1, 5GHz */
  858. break;
  859. default: /* not defined, assume gen1 */
  860. dd->ipath_lbus_speed = 2500;
  861. break;
  862. }
  863. if (linkstat < 8)
  864. ipath_dev_err(dd,
  865. "PCIe width %u (x8 HCA), performance reduced\n",
  866. linkstat);
  867. else
  868. ipath_cdbg(VERBOSE, "PCIe speed %u width %u (x8 HCA)\n",
  869. dd->ipath_lbus_speed, linkstat);
  870. if (speed != 1)
  871. ipath_dev_err(dd,
  872. "PCIe linkspeed %u is incorrect; "
  873. "should be 1 (2500)!\n", speed);
  874. bail:
  875. /* fill in string, even on errors */
  876. snprintf(dd->ipath_lbus_info, sizeof(dd->ipath_lbus_info),
  877. "PCIe,%uMHz,x%u\n",
  878. dd->ipath_lbus_speed,
  879. dd->ipath_lbus_width);
  880. return;
  881. }
  882. /**
  883. * ipath_setup_pe_config - setup PCIe config related stuff
  884. * @dd: the infinipath device
  885. * @pdev: the PCI device
  886. *
  887. * The pci_enable_msi() call will fail on systems with MSI quirks
  888. * such as those with AMD8131, even if the device of interest is not
  889. * attached to that device, (in the 2.6.13 - 2.6.15 kernels, at least, fixed
  890. * late in 2.6.16).
  891. * All that can be done is to edit the kernel source to remove the quirk
  892. * check until that is fixed.
  893. * We do not need to call enable_msi() for our HyperTransport chip,
  894. * even though it uses MSI, and we want to avoid the quirk warning, so
  895. * So we call enable_msi only for PCIe. If we do end up needing
  896. * pci_enable_msi at some point in the future for HT, we'll move the
  897. * call back into the main init_one code.
  898. * We save the msi lo and hi values, so we can restore them after
  899. * chip reset (the kernel PCI infrastructure doesn't yet handle that
  900. * correctly).
  901. */
  902. static int ipath_setup_pe_config(struct ipath_devdata *dd,
  903. struct pci_dev *pdev)
  904. {
  905. int pos, ret;
  906. dd->ipath_msi_lo = 0; /* used as a flag during reset processing */
  907. ret = pci_enable_msi(dd->pcidev);
  908. if (ret)
  909. ipath_dev_err(dd, "pci_enable_msi failed: %d, "
  910. "interrupts may not work\n", ret);
  911. /* continue even if it fails, we may still be OK... */
  912. dd->ipath_irq = pdev->irq;
  913. if ((pos = pci_find_capability(dd->pcidev, PCI_CAP_ID_MSI))) {
  914. u16 control;
  915. pci_read_config_dword(dd->pcidev, pos + PCI_MSI_ADDRESS_LO,
  916. &dd->ipath_msi_lo);
  917. pci_read_config_dword(dd->pcidev, pos + PCI_MSI_ADDRESS_HI,
  918. &dd->ipath_msi_hi);
  919. pci_read_config_word(dd->pcidev, pos + PCI_MSI_FLAGS,
  920. &control);
  921. /* now save the data (vector) info */
  922. pci_read_config_word(dd->pcidev,
  923. pos + ((control & PCI_MSI_FLAGS_64BIT)
  924. ? 12 : 8),
  925. &dd->ipath_msi_data);
  926. ipath_cdbg(VERBOSE, "Read msi data 0x%x from config offset "
  927. "0x%x, control=0x%x\n", dd->ipath_msi_data,
  928. pos + ((control & PCI_MSI_FLAGS_64BIT) ? 12 : 8),
  929. control);
  930. /* we save the cachelinesize also, although it doesn't
  931. * really matter */
  932. pci_read_config_byte(dd->pcidev, PCI_CACHE_LINE_SIZE,
  933. &dd->ipath_pci_cacheline);
  934. } else
  935. ipath_dev_err(dd, "Can't find MSI capability, "
  936. "can't save MSI settings for reset\n");
  937. ipath_6120_pcie_params(dd);
  938. dd->ipath_link_width_supported = IB_WIDTH_1X | IB_WIDTH_4X;
  939. dd->ipath_link_speed_supported = IPATH_IB_SDR;
  940. dd->ipath_link_width_enabled = IB_WIDTH_4X;
  941. dd->ipath_link_speed_enabled = dd->ipath_link_speed_supported;
  942. /* these can't change for this chip, so set once */
  943. dd->ipath_link_width_active = dd->ipath_link_width_enabled;
  944. dd->ipath_link_speed_active = dd->ipath_link_speed_enabled;
  945. return 0;
  946. }
  947. static void ipath_init_pe_variables(struct ipath_devdata *dd)
  948. {
  949. /*
  950. * setup the register offsets, since they are different for each
  951. * chip
  952. */
  953. dd->ipath_kregs = &ipath_pe_kregs;
  954. dd->ipath_cregs = &ipath_pe_cregs;
  955. /*
  956. * bits for selecting i2c direction and values,
  957. * used for I2C serial flash
  958. */
  959. dd->ipath_gpio_sda_num = _IPATH_GPIO_SDA_NUM;
  960. dd->ipath_gpio_scl_num = _IPATH_GPIO_SCL_NUM;
  961. dd->ipath_gpio_sda = IPATH_GPIO_SDA;
  962. dd->ipath_gpio_scl = IPATH_GPIO_SCL;
  963. /*
  964. * Fill in data for field-values that change in newer chips.
  965. * We dynamically specify only the mask for LINKTRAININGSTATE
  966. * and only the shift for LINKSTATE, as they are the only ones
  967. * that change. Also precalculate the 3 link states of interest
  968. * and the combined mask.
  969. */
  970. dd->ibcs_ls_shift = IBA6120_IBCS_LINKSTATE_SHIFT;
  971. dd->ibcs_lts_mask = IBA6120_IBCS_LINKTRAININGSTATE_MASK;
  972. dd->ibcs_mask = (INFINIPATH_IBCS_LINKSTATE_MASK <<
  973. dd->ibcs_ls_shift) | dd->ibcs_lts_mask;
  974. dd->ib_init = (INFINIPATH_IBCS_LT_STATE_LINKUP <<
  975. INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) |
  976. (INFINIPATH_IBCS_L_STATE_INIT << dd->ibcs_ls_shift);
  977. dd->ib_arm = (INFINIPATH_IBCS_LT_STATE_LINKUP <<
  978. INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) |
  979. (INFINIPATH_IBCS_L_STATE_ARM << dd->ibcs_ls_shift);
  980. dd->ib_active = (INFINIPATH_IBCS_LT_STATE_LINKUP <<
  981. INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) |
  982. (INFINIPATH_IBCS_L_STATE_ACTIVE << dd->ibcs_ls_shift);
  983. /*
  984. * Fill in data for ibcc field-values that change in newer chips.
  985. * We dynamically specify only the mask for LINKINITCMD
  986. * and only the shift for LINKCMD and MAXPKTLEN, as they are
  987. * the only ones that change.
  988. */
  989. dd->ibcc_lic_mask = INFINIPATH_IBCC_LINKINITCMD_MASK;
  990. dd->ibcc_lc_shift = INFINIPATH_IBCC_LINKCMD_SHIFT;
  991. dd->ibcc_mpl_shift = INFINIPATH_IBCC_MAXPKTLEN_SHIFT;
  992. /* Fill in shifts for RcvCtrl. */
  993. dd->ipath_r_portenable_shift = INFINIPATH_R_PORTENABLE_SHIFT;
  994. dd->ipath_r_intravail_shift = INFINIPATH_R_INTRAVAIL_SHIFT;
  995. dd->ipath_r_tailupd_shift = INFINIPATH_R_TAILUPD_SHIFT;
  996. dd->ipath_r_portcfg_shift = 0; /* Not on IBA6120 */
  997. /* variables for sanity checking interrupt and errors */
  998. dd->ipath_hwe_bitsextant =
  999. (INFINIPATH_HWE_RXEMEMPARITYERR_MASK <<
  1000. INFINIPATH_HWE_RXEMEMPARITYERR_SHIFT) |
  1001. (INFINIPATH_HWE_TXEMEMPARITYERR_MASK <<
  1002. INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT) |
  1003. (INFINIPATH_HWE_PCIEMEMPARITYERR_MASK <<
  1004. INFINIPATH_HWE_PCIEMEMPARITYERR_SHIFT) |
  1005. INFINIPATH_HWE_PCIE1PLLFAILED |
  1006. INFINIPATH_HWE_PCIE0PLLFAILED |
  1007. INFINIPATH_HWE_PCIEPOISONEDTLP |
  1008. INFINIPATH_HWE_PCIECPLTIMEOUT |
  1009. INFINIPATH_HWE_PCIEBUSPARITYXTLH |
  1010. INFINIPATH_HWE_PCIEBUSPARITYXADM |
  1011. INFINIPATH_HWE_PCIEBUSPARITYRADM |
  1012. INFINIPATH_HWE_MEMBISTFAILED |
  1013. INFINIPATH_HWE_COREPLL_FBSLIP |
  1014. INFINIPATH_HWE_COREPLL_RFSLIP |
  1015. INFINIPATH_HWE_SERDESPLLFAILED |
  1016. INFINIPATH_HWE_IBCBUSTOSPCPARITYERR |
  1017. INFINIPATH_HWE_IBCBUSFRSPCPARITYERR;
  1018. dd->ipath_i_bitsextant =
  1019. (INFINIPATH_I_RCVURG_MASK << INFINIPATH_I_RCVURG_SHIFT) |
  1020. (INFINIPATH_I_RCVAVAIL_MASK <<
  1021. INFINIPATH_I_RCVAVAIL_SHIFT) |
  1022. INFINIPATH_I_ERROR | INFINIPATH_I_SPIOSENT |
  1023. INFINIPATH_I_SPIOBUFAVAIL | INFINIPATH_I_GPIO;
  1024. dd->ipath_e_bitsextant =
  1025. INFINIPATH_E_RFORMATERR | INFINIPATH_E_RVCRC |
  1026. INFINIPATH_E_RICRC | INFINIPATH_E_RMINPKTLEN |
  1027. INFINIPATH_E_RMAXPKTLEN | INFINIPATH_E_RLONGPKTLEN |
  1028. INFINIPATH_E_RSHORTPKTLEN | INFINIPATH_E_RUNEXPCHAR |
  1029. INFINIPATH_E_RUNSUPVL | INFINIPATH_E_REBP |
  1030. INFINIPATH_E_RIBFLOW | INFINIPATH_E_RBADVERSION |
  1031. INFINIPATH_E_RRCVEGRFULL | INFINIPATH_E_RRCVHDRFULL |
  1032. INFINIPATH_E_RBADTID | INFINIPATH_E_RHDRLEN |
  1033. INFINIPATH_E_RHDR | INFINIPATH_E_RIBLOSTLINK |
  1034. INFINIPATH_E_SMINPKTLEN | INFINIPATH_E_SMAXPKTLEN |
  1035. INFINIPATH_E_SUNDERRUN | INFINIPATH_E_SPKTLEN |
  1036. INFINIPATH_E_SDROPPEDSMPPKT | INFINIPATH_E_SDROPPEDDATAPKT |
  1037. INFINIPATH_E_SPIOARMLAUNCH | INFINIPATH_E_SUNEXPERRPKTNUM |
  1038. INFINIPATH_E_SUNSUPVL | INFINIPATH_E_IBSTATUSCHANGED |
  1039. INFINIPATH_E_INVALIDADDR | INFINIPATH_E_RESET |
  1040. INFINIPATH_E_HARDWARE;
  1041. dd->ipath_i_rcvavail_mask = INFINIPATH_I_RCVAVAIL_MASK;
  1042. dd->ipath_i_rcvurg_mask = INFINIPATH_I_RCVURG_MASK;
  1043. dd->ipath_i_rcvavail_shift = INFINIPATH_I_RCVAVAIL_SHIFT;
  1044. dd->ipath_i_rcvurg_shift = INFINIPATH_I_RCVURG_SHIFT;
  1045. /*
  1046. * EEPROM error log 0 is TXE Parity errors. 1 is RXE Parity.
  1047. * 2 is Some Misc, 3 is reserved for future.
  1048. */
  1049. dd->ipath_eep_st_masks[0].hwerrs_to_log =
  1050. INFINIPATH_HWE_TXEMEMPARITYERR_MASK <<
  1051. INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT;
  1052. /* Ignore errors in PIO/PBC on systems with unordered write-combining */
  1053. if (ipath_unordered_wc())
  1054. dd->ipath_eep_st_masks[0].hwerrs_to_log &= ~TXE_PIO_PARITY;
  1055. dd->ipath_eep_st_masks[1].hwerrs_to_log =
  1056. INFINIPATH_HWE_RXEMEMPARITYERR_MASK <<
  1057. INFINIPATH_HWE_RXEMEMPARITYERR_SHIFT;
  1058. dd->ipath_eep_st_masks[2].errs_to_log = INFINIPATH_E_RESET;
  1059. dd->delay_mult = 2; /* SDR, 4X, can't change */
  1060. }
  1061. /* setup the MSI stuff again after a reset. I'd like to just call
  1062. * pci_enable_msi() and request_irq() again, but when I do that,
  1063. * the MSI enable bit doesn't get set in the command word, and
  1064. * we switch to to a different interrupt vector, which is confusing,
  1065. * so I instead just do it all inline. Perhaps somehow can tie this
  1066. * into the PCIe hotplug support at some point
  1067. * Note, because I'm doing it all here, I don't call pci_disable_msi()
  1068. * or free_irq() at the start of ipath_setup_pe_reset().
  1069. */
  1070. static int ipath_reinit_msi(struct ipath_devdata *dd)
  1071. {
  1072. int pos;
  1073. u16 control;
  1074. int ret;
  1075. if (!dd->ipath_msi_lo) {
  1076. dev_info(&dd->pcidev->dev, "Can't restore MSI config, "
  1077. "initial setup failed?\n");
  1078. ret = 0;
  1079. goto bail;
  1080. }
  1081. if (!(pos = pci_find_capability(dd->pcidev, PCI_CAP_ID_MSI))) {
  1082. ipath_dev_err(dd, "Can't find MSI capability, "
  1083. "can't restore MSI settings\n");
  1084. ret = 0;
  1085. goto bail;
  1086. }
  1087. ipath_cdbg(VERBOSE, "Writing msi_lo 0x%x to config offset 0x%x\n",
  1088. dd->ipath_msi_lo, pos + PCI_MSI_ADDRESS_LO);
  1089. pci_write_config_dword(dd->pcidev, pos + PCI_MSI_ADDRESS_LO,
  1090. dd->ipath_msi_lo);
  1091. ipath_cdbg(VERBOSE, "Writing msi_lo 0x%x to config offset 0x%x\n",
  1092. dd->ipath_msi_hi, pos + PCI_MSI_ADDRESS_HI);
  1093. pci_write_config_dword(dd->pcidev, pos + PCI_MSI_ADDRESS_HI,
  1094. dd->ipath_msi_hi);
  1095. pci_read_config_word(dd->pcidev, pos + PCI_MSI_FLAGS, &control);
  1096. if (!(control & PCI_MSI_FLAGS_ENABLE)) {
  1097. ipath_cdbg(VERBOSE, "MSI control at off %x was %x, "
  1098. "setting MSI enable (%x)\n", pos + PCI_MSI_FLAGS,
  1099. control, control | PCI_MSI_FLAGS_ENABLE);
  1100. control |= PCI_MSI_FLAGS_ENABLE;
  1101. pci_write_config_word(dd->pcidev, pos + PCI_MSI_FLAGS,
  1102. control);
  1103. }
  1104. /* now rewrite the data (vector) info */
  1105. pci_write_config_word(dd->pcidev, pos +
  1106. ((control & PCI_MSI_FLAGS_64BIT) ? 12 : 8),
  1107. dd->ipath_msi_data);
  1108. /* we restore the cachelinesize also, although it doesn't really
  1109. * matter */
  1110. pci_write_config_byte(dd->pcidev, PCI_CACHE_LINE_SIZE,
  1111. dd->ipath_pci_cacheline);
  1112. /* and now set the pci master bit again */
  1113. pci_set_master(dd->pcidev);
  1114. ret = 1;
  1115. bail:
  1116. return ret;
  1117. }
  1118. /* This routine sleeps, so it can only be called from user context, not
  1119. * from interrupt context. If we need interrupt context, we can split
  1120. * it into two routines.
  1121. */
  1122. static int ipath_setup_pe_reset(struct ipath_devdata *dd)
  1123. {
  1124. u64 val;
  1125. int i;
  1126. int ret;
  1127. u16 cmdval;
  1128. pci_read_config_word(dd->pcidev, PCI_COMMAND, &cmdval);
  1129. /* Use ERROR so it shows up in logs, etc. */
  1130. ipath_dev_err(dd, "Resetting InfiniPath unit %u\n", dd->ipath_unit);
  1131. /* keep chip from being accessed in a few places */
  1132. dd->ipath_flags &= ~(IPATH_INITTED|IPATH_PRESENT);
  1133. val = dd->ipath_control | INFINIPATH_C_RESET;
  1134. ipath_write_kreg(dd, dd->ipath_kregs->kr_control, val);
  1135. mb();
  1136. for (i = 1; i <= 5; i++) {
  1137. int r;
  1138. /* allow MBIST, etc. to complete; longer on each retry.
  1139. * We sometimes get machine checks from bus timeout if no
  1140. * response, so for now, make it *really* long.
  1141. */
  1142. msleep(1000 + (1 + i) * 2000);
  1143. if ((r =
  1144. pci_write_config_dword(dd->pcidev, PCI_BASE_ADDRESS_0,
  1145. dd->ipath_pcibar0)))
  1146. ipath_dev_err(dd, "rewrite of BAR0 failed: %d\n",
  1147. r);
  1148. if ((r =
  1149. pci_write_config_dword(dd->pcidev, PCI_BASE_ADDRESS_1,
  1150. dd->ipath_pcibar1)))
  1151. ipath_dev_err(dd, "rewrite of BAR1 failed: %d\n",
  1152. r);
  1153. /* now re-enable memory access */
  1154. pci_write_config_word(dd->pcidev, PCI_COMMAND, cmdval);
  1155. if ((r = pci_enable_device(dd->pcidev)))
  1156. ipath_dev_err(dd, "pci_enable_device failed after "
  1157. "reset: %d\n", r);
  1158. /*
  1159. * whether it fully enabled or not, mark as present,
  1160. * again (but not INITTED)
  1161. */
  1162. dd->ipath_flags |= IPATH_PRESENT;
  1163. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_revision);
  1164. if (val == dd->ipath_revision) {
  1165. ipath_cdbg(VERBOSE, "Got matching revision "
  1166. "register %llx on try %d\n",
  1167. (unsigned long long) val, i);
  1168. ret = ipath_reinit_msi(dd);
  1169. goto bail;
  1170. }
  1171. /* Probably getting -1 back */
  1172. ipath_dbg("Didn't get expected revision register, "
  1173. "got %llx, try %d\n", (unsigned long long) val,
  1174. i + 1);
  1175. }
  1176. ret = 0; /* failed */
  1177. bail:
  1178. if (ret)
  1179. ipath_6120_pcie_params(dd);
  1180. return ret;
  1181. }
  1182. /**
  1183. * ipath_pe_put_tid - write a TID in chip
  1184. * @dd: the infinipath device
  1185. * @tidptr: pointer to the expected TID (in chip) to udpate
  1186. * @tidtype: RCVHQ_RCV_TYPE_EAGER (1) for eager, RCVHQ_RCV_TYPE_EXPECTED (0) for expected
  1187. * @pa: physical address of in memory buffer; ipath_tidinvalid if freeing
  1188. *
  1189. * This exists as a separate routine to allow for special locking etc.
  1190. * It's used for both the full cleanup on exit, as well as the normal
  1191. * setup and teardown.
  1192. */
  1193. static void ipath_pe_put_tid(struct ipath_devdata *dd, u64 __iomem *tidptr,
  1194. u32 type, unsigned long pa)
  1195. {
  1196. u32 __iomem *tidp32 = (u32 __iomem *)tidptr;
  1197. unsigned long flags = 0; /* keep gcc quiet */
  1198. int tidx;
  1199. spinlock_t *tidlockp;
  1200. if (!dd->ipath_kregbase)
  1201. return;
  1202. if (pa != dd->ipath_tidinvalid) {
  1203. if (pa & ((1U << 11) - 1)) {
  1204. dev_info(&dd->pcidev->dev, "BUG: physaddr %lx "
  1205. "not 2KB aligned!\n", pa);
  1206. return;
  1207. }
  1208. pa >>= 11;
  1209. /* paranoia check */
  1210. if (pa & ~INFINIPATH_RT_ADDR_MASK)
  1211. ipath_dev_err(dd,
  1212. "BUG: Physical page address 0x%lx "
  1213. "has bits set in 31-29\n", pa);
  1214. if (type == RCVHQ_RCV_TYPE_EAGER)
  1215. pa |= dd->ipath_tidtemplate;
  1216. else /* for now, always full 4KB page */
  1217. pa |= 2 << 29;
  1218. }
  1219. /*
  1220. * Workaround chip bug 9437 by writing the scratch register
  1221. * before and after the TID, and with an io write barrier.
  1222. * We use a spinlock around the writes, so they can't intermix
  1223. * with other TID (eager or expected) writes (the chip bug
  1224. * is triggered by back to back TID writes). Unfortunately, this
  1225. * call can be done from interrupt level for the port 0 eager TIDs,
  1226. * so we have to use irqsave locks.
  1227. */
  1228. /*
  1229. * Assumes tidptr always > ipath_egrtidbase
  1230. * if type == RCVHQ_RCV_TYPE_EAGER.
  1231. */
  1232. tidx = tidptr - dd->ipath_egrtidbase;
  1233. tidlockp = (type == RCVHQ_RCV_TYPE_EAGER && tidx < dd->ipath_rcvegrcnt)
  1234. ? &dd->ipath_kernel_tid_lock : &dd->ipath_user_tid_lock;
  1235. spin_lock_irqsave(tidlockp, flags);
  1236. ipath_write_kreg(dd, dd->ipath_kregs->kr_scratch, 0xfeeddeaf);
  1237. writel(pa, tidp32);
  1238. ipath_write_kreg(dd, dd->ipath_kregs->kr_scratch, 0xdeadbeef);
  1239. mmiowb();
  1240. spin_unlock_irqrestore(tidlockp, flags);
  1241. }
  1242. /**
  1243. * ipath_pe_put_tid_2 - write a TID in chip, Revision 2 or higher
  1244. * @dd: the infinipath device
  1245. * @tidptr: pointer to the expected TID (in chip) to udpate
  1246. * @tidtype: RCVHQ_RCV_TYPE_EAGER (1) for eager, RCVHQ_RCV_TYPE_EXPECTED (0) for expected
  1247. * @pa: physical address of in memory buffer; ipath_tidinvalid if freeing
  1248. *
  1249. * This exists as a separate routine to allow for selection of the
  1250. * appropriate "flavor". The static calls in cleanup just use the
  1251. * revision-agnostic form, as they are not performance critical.
  1252. */
  1253. static void ipath_pe_put_tid_2(struct ipath_devdata *dd, u64 __iomem *tidptr,
  1254. u32 type, unsigned long pa)
  1255. {
  1256. u32 __iomem *tidp32 = (u32 __iomem *)tidptr;
  1257. u32 tidx;
  1258. if (!dd->ipath_kregbase)
  1259. return;
  1260. if (pa != dd->ipath_tidinvalid) {
  1261. if (pa & ((1U << 11) - 1)) {
  1262. dev_info(&dd->pcidev->dev, "BUG: physaddr %lx "
  1263. "not 2KB aligned!\n", pa);
  1264. return;
  1265. }
  1266. pa >>= 11;
  1267. /* paranoia check */
  1268. if (pa & ~INFINIPATH_RT_ADDR_MASK)
  1269. ipath_dev_err(dd,
  1270. "BUG: Physical page address 0x%lx "
  1271. "has bits set in 31-29\n", pa);
  1272. if (type == RCVHQ_RCV_TYPE_EAGER)
  1273. pa |= dd->ipath_tidtemplate;
  1274. else /* for now, always full 4KB page */
  1275. pa |= 2 << 29;
  1276. }
  1277. tidx = tidptr - dd->ipath_egrtidbase;
  1278. writel(pa, tidp32);
  1279. mmiowb();
  1280. }
  1281. /**
  1282. * ipath_pe_clear_tid - clear all TID entries for a port, expected and eager
  1283. * @dd: the infinipath device
  1284. * @port: the port
  1285. *
  1286. * clear all TID entries for a port, expected and eager.
  1287. * Used from ipath_close(). On this chip, TIDs are only 32 bits,
  1288. * not 64, but they are still on 64 bit boundaries, so tidbase
  1289. * is declared as u64 * for the pointer math, even though we write 32 bits
  1290. */
  1291. static void ipath_pe_clear_tids(struct ipath_devdata *dd, unsigned port)
  1292. {
  1293. u64 __iomem *tidbase;
  1294. unsigned long tidinv;
  1295. int i;
  1296. if (!dd->ipath_kregbase)
  1297. return;
  1298. ipath_cdbg(VERBOSE, "Invalidate TIDs for port %u\n", port);
  1299. tidinv = dd->ipath_tidinvalid;
  1300. tidbase = (u64 __iomem *)
  1301. ((char __iomem *)(dd->ipath_kregbase) +
  1302. dd->ipath_rcvtidbase +
  1303. port * dd->ipath_rcvtidcnt * sizeof(*tidbase));
  1304. for (i = 0; i < dd->ipath_rcvtidcnt; i++)
  1305. dd->ipath_f_put_tid(dd, &tidbase[i], RCVHQ_RCV_TYPE_EXPECTED,
  1306. tidinv);
  1307. tidbase = (u64 __iomem *)
  1308. ((char __iomem *)(dd->ipath_kregbase) +
  1309. dd->ipath_rcvegrbase +
  1310. port * dd->ipath_rcvegrcnt * sizeof(*tidbase));
  1311. for (i = 0; i < dd->ipath_rcvegrcnt; i++)
  1312. dd->ipath_f_put_tid(dd, &tidbase[i], RCVHQ_RCV_TYPE_EAGER,
  1313. tidinv);
  1314. }
  1315. /**
  1316. * ipath_pe_tidtemplate - setup constants for TID updates
  1317. * @dd: the infinipath device
  1318. *
  1319. * We setup stuff that we use a lot, to avoid calculating each time
  1320. */
  1321. static void ipath_pe_tidtemplate(struct ipath_devdata *dd)
  1322. {
  1323. u32 egrsize = dd->ipath_rcvegrbufsize;
  1324. /* For now, we always allocate 4KB buffers (at init) so we can
  1325. * receive max size packets. We may want a module parameter to
  1326. * specify 2KB or 4KB and/or make be per port instead of per device
  1327. * for those who want to reduce memory footprint. Note that the
  1328. * ipath_rcvhdrentsize size must be large enough to hold the largest
  1329. * IB header (currently 96 bytes) that we expect to handle (plus of
  1330. * course the 2 dwords of RHF).
  1331. */
  1332. if (egrsize == 2048)
  1333. dd->ipath_tidtemplate = 1U << 29;
  1334. else if (egrsize == 4096)
  1335. dd->ipath_tidtemplate = 2U << 29;
  1336. else {
  1337. egrsize = 4096;
  1338. dev_info(&dd->pcidev->dev, "BUG: unsupported egrbufsize "
  1339. "%u, using %u\n", dd->ipath_rcvegrbufsize,
  1340. egrsize);
  1341. dd->ipath_tidtemplate = 2U << 29;
  1342. }
  1343. dd->ipath_tidinvalid = 0;
  1344. }
  1345. static int ipath_pe_early_init(struct ipath_devdata *dd)
  1346. {
  1347. dd->ipath_flags |= IPATH_4BYTE_TID;
  1348. if (ipath_unordered_wc())
  1349. dd->ipath_flags |= IPATH_PIO_FLUSH_WC;
  1350. /*
  1351. * For openfabrics, we need to be able to handle an IB header of
  1352. * 24 dwords. HT chip has arbitrary sized receive buffers, so we
  1353. * made them the same size as the PIO buffers. This chip does not
  1354. * handle arbitrary size buffers, so we need the header large enough
  1355. * to handle largest IB header, but still have room for a 2KB MTU
  1356. * standard IB packet.
  1357. */
  1358. dd->ipath_rcvhdrentsize = 24;
  1359. dd->ipath_rcvhdrsize = IPATH_DFLT_RCVHDRSIZE;
  1360. dd->ipath_rhf_offset = 0;
  1361. dd->ipath_egrtidbase = (u64 __iomem *)
  1362. ((char __iomem *) dd->ipath_kregbase + dd->ipath_rcvegrbase);
  1363. dd->ipath_rcvegrbufsize = ipath_mtu4096 ? 4096 : 2048;
  1364. /*
  1365. * the min() check here is currently a nop, but it may not always
  1366. * be, depending on just how we do ipath_rcvegrbufsize
  1367. */
  1368. dd->ipath_ibmaxlen = min(ipath_mtu4096 ? dd->ipath_piosize4k :
  1369. dd->ipath_piosize2k,
  1370. dd->ipath_rcvegrbufsize +
  1371. (dd->ipath_rcvhdrentsize << 2));
  1372. dd->ipath_init_ibmaxlen = dd->ipath_ibmaxlen;
  1373. /*
  1374. * We can request a receive interrupt for 1 or
  1375. * more packets from current offset. For now, we set this
  1376. * up for a single packet.
  1377. */
  1378. dd->ipath_rhdrhead_intr_off = 1ULL<<32;
  1379. ipath_get_eeprom_info(dd);
  1380. return 0;
  1381. }
  1382. int __attribute__((weak)) ipath_unordered_wc(void)
  1383. {
  1384. return 0;
  1385. }
  1386. /**
  1387. * ipath_init_pe_get_base_info - set chip-specific flags for user code
  1388. * @pd: the infinipath port
  1389. * @kbase: ipath_base_info pointer
  1390. *
  1391. * We set the PCIE flag because the lower bandwidth on PCIe vs
  1392. * HyperTransport can affect some user packet algorithms.
  1393. */
  1394. static int ipath_pe_get_base_info(struct ipath_portdata *pd, void *kbase)
  1395. {
  1396. struct ipath_base_info *kinfo = kbase;
  1397. struct ipath_devdata *dd;
  1398. if (ipath_unordered_wc()) {
  1399. kinfo->spi_runtime_flags |= IPATH_RUNTIME_FORCE_WC_ORDER;
  1400. ipath_cdbg(PROC, "Intel processor, forcing WC order\n");
  1401. }
  1402. else
  1403. ipath_cdbg(PROC, "Not Intel processor, WC ordered\n");
  1404. if (pd == NULL)
  1405. goto done;
  1406. dd = pd->port_dd;
  1407. done:
  1408. kinfo->spi_runtime_flags |= IPATH_RUNTIME_PCIE |
  1409. IPATH_RUNTIME_FORCE_PIOAVAIL | IPATH_RUNTIME_PIO_REGSWAPPED;
  1410. return 0;
  1411. }
  1412. static void ipath_pe_free_irq(struct ipath_devdata *dd)
  1413. {
  1414. free_irq(dd->ipath_irq, dd);
  1415. dd->ipath_irq = 0;
  1416. }
  1417. static struct ipath_message_header *
  1418. ipath_pe_get_msgheader(struct ipath_devdata *dd, __le32 *rhf_addr)
  1419. {
  1420. return (struct ipath_message_header *)
  1421. &rhf_addr[sizeof(u64) / sizeof(u32)];
  1422. }
  1423. static void ipath_pe_config_ports(struct ipath_devdata *dd, ushort cfgports)
  1424. {
  1425. dd->ipath_portcnt =
  1426. ipath_read_kreg32(dd, dd->ipath_kregs->kr_portcnt);
  1427. dd->ipath_p0_rcvegrcnt =
  1428. ipath_read_kreg32(dd, dd->ipath_kregs->kr_rcvegrcnt);
  1429. }
  1430. static void ipath_pe_read_counters(struct ipath_devdata *dd,
  1431. struct infinipath_counters *cntrs)
  1432. {
  1433. cntrs->LBIntCnt =
  1434. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(LBIntCnt));
  1435. cntrs->LBFlowStallCnt =
  1436. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(LBFlowStallCnt));
  1437. cntrs->TxSDmaDescCnt = 0;
  1438. cntrs->TxUnsupVLErrCnt =
  1439. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxUnsupVLErrCnt));
  1440. cntrs->TxDataPktCnt =
  1441. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxDataPktCnt));
  1442. cntrs->TxFlowPktCnt =
  1443. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxFlowPktCnt));
  1444. cntrs->TxDwordCnt =
  1445. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxDwordCnt));
  1446. cntrs->TxLenErrCnt =
  1447. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxLenErrCnt));
  1448. cntrs->TxMaxMinLenErrCnt =
  1449. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxMaxMinLenErrCnt));
  1450. cntrs->TxUnderrunCnt =
  1451. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxUnderrunCnt));
  1452. cntrs->TxFlowStallCnt =
  1453. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxFlowStallCnt));
  1454. cntrs->TxDroppedPktCnt =
  1455. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxDroppedPktCnt));
  1456. cntrs->RxDroppedPktCnt =
  1457. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxDroppedPktCnt));
  1458. cntrs->RxDataPktCnt =
  1459. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxDataPktCnt));
  1460. cntrs->RxFlowPktCnt =
  1461. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxFlowPktCnt));
  1462. cntrs->RxDwordCnt =
  1463. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxDwordCnt));
  1464. cntrs->RxLenErrCnt =
  1465. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxLenErrCnt));
  1466. cntrs->RxMaxMinLenErrCnt =
  1467. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxMaxMinLenErrCnt));
  1468. cntrs->RxICRCErrCnt =
  1469. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxICRCErrCnt));
  1470. cntrs->RxVCRCErrCnt =
  1471. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxVCRCErrCnt));
  1472. cntrs->RxFlowCtrlErrCnt =
  1473. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxFlowCtrlErrCnt));
  1474. cntrs->RxBadFormatCnt =
  1475. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxBadFormatCnt));
  1476. cntrs->RxLinkProblemCnt =
  1477. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxLinkProblemCnt));
  1478. cntrs->RxEBPCnt =
  1479. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxEBPCnt));
  1480. cntrs->RxLPCRCErrCnt =
  1481. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxLPCRCErrCnt));
  1482. cntrs->RxBufOvflCnt =
  1483. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxBufOvflCnt));
  1484. cntrs->RxTIDFullErrCnt =
  1485. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxTIDFullErrCnt));
  1486. cntrs->RxTIDValidErrCnt =
  1487. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxTIDValidErrCnt));
  1488. cntrs->RxPKeyMismatchCnt =
  1489. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxPKeyMismatchCnt));
  1490. cntrs->RxP0HdrEgrOvflCnt =
  1491. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP0HdrEgrOvflCnt));
  1492. cntrs->RxP1HdrEgrOvflCnt =
  1493. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP1HdrEgrOvflCnt));
  1494. cntrs->RxP2HdrEgrOvflCnt =
  1495. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP2HdrEgrOvflCnt));
  1496. cntrs->RxP3HdrEgrOvflCnt =
  1497. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP3HdrEgrOvflCnt));
  1498. cntrs->RxP4HdrEgrOvflCnt =
  1499. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP4HdrEgrOvflCnt));
  1500. cntrs->RxP5HdrEgrOvflCnt = 0;
  1501. cntrs->RxP6HdrEgrOvflCnt = 0;
  1502. cntrs->RxP7HdrEgrOvflCnt = 0;
  1503. cntrs->RxP8HdrEgrOvflCnt = 0;
  1504. cntrs->RxP9HdrEgrOvflCnt = 0;
  1505. cntrs->RxP10HdrEgrOvflCnt = 0;
  1506. cntrs->RxP11HdrEgrOvflCnt = 0;
  1507. cntrs->RxP12HdrEgrOvflCnt = 0;
  1508. cntrs->RxP13HdrEgrOvflCnt = 0;
  1509. cntrs->RxP14HdrEgrOvflCnt = 0;
  1510. cntrs->RxP15HdrEgrOvflCnt = 0;
  1511. cntrs->RxP16HdrEgrOvflCnt = 0;
  1512. cntrs->IBStatusChangeCnt =
  1513. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(IBStatusChangeCnt));
  1514. cntrs->IBLinkErrRecoveryCnt =
  1515. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(IBLinkErrRecoveryCnt));
  1516. cntrs->IBLinkDownedCnt =
  1517. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(IBLinkDownedCnt));
  1518. cntrs->IBSymbolErrCnt =
  1519. ipath_snap_cntr(dd, IPATH_CREG_OFFSET(IBSymbolErrCnt));
  1520. cntrs->RxVL15DroppedPktCnt = 0;
  1521. cntrs->RxOtherLocalPhyErrCnt = 0;
  1522. cntrs->PcieRetryBufDiagQwordCnt = 0;
  1523. cntrs->ExcessBufferOvflCnt = dd->ipath_overrun_thresh_errs;
  1524. cntrs->LocalLinkIntegrityErrCnt = dd->ipath_lli_errs;
  1525. cntrs->RxVlErrCnt = 0;
  1526. cntrs->RxDlidFltrCnt = 0;
  1527. }
  1528. /* no interrupt fallback for these chips */
  1529. static int ipath_pe_nointr_fallback(struct ipath_devdata *dd)
  1530. {
  1531. return 0;
  1532. }
  1533. /*
  1534. * reset the XGXS (between serdes and IBC). Slightly less intrusive
  1535. * than resetting the IBC or external link state, and useful in some
  1536. * cases to cause some retraining. To do this right, we reset IBC
  1537. * as well.
  1538. */
  1539. static void ipath_pe_xgxs_reset(struct ipath_devdata *dd)
  1540. {
  1541. u64 val, prev_val;
  1542. prev_val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig);
  1543. val = prev_val | INFINIPATH_XGXS_RESET;
  1544. prev_val &= ~INFINIPATH_XGXS_RESET; /* be sure */
  1545. ipath_write_kreg(dd, dd->ipath_kregs->kr_control,
  1546. dd->ipath_control & ~INFINIPATH_C_LINKENABLE);
  1547. ipath_write_kreg(dd, dd->ipath_kregs->kr_xgxsconfig, val);
  1548. ipath_read_kreg32(dd, dd->ipath_kregs->kr_scratch);
  1549. ipath_write_kreg(dd, dd->ipath_kregs->kr_xgxsconfig, prev_val);
  1550. ipath_write_kreg(dd, dd->ipath_kregs->kr_control,
  1551. dd->ipath_control);
  1552. }
  1553. static int ipath_pe_get_ib_cfg(struct ipath_devdata *dd, int which)
  1554. {
  1555. int ret;
  1556. switch (which) {
  1557. case IPATH_IB_CFG_LWID:
  1558. ret = dd->ipath_link_width_active;
  1559. break;
  1560. case IPATH_IB_CFG_SPD:
  1561. ret = dd->ipath_link_speed_active;
  1562. break;
  1563. case IPATH_IB_CFG_LWID_ENB:
  1564. ret = dd->ipath_link_width_enabled;
  1565. break;
  1566. case IPATH_IB_CFG_SPD_ENB:
  1567. ret = dd->ipath_link_speed_enabled;
  1568. break;
  1569. default:
  1570. ret = -ENOTSUPP;
  1571. break;
  1572. }
  1573. return ret;
  1574. }
  1575. /* we assume range checking is already done, if needed */
  1576. static int ipath_pe_set_ib_cfg(struct ipath_devdata *dd, int which, u32 val)
  1577. {
  1578. int ret = 0;
  1579. if (which == IPATH_IB_CFG_LWID_ENB)
  1580. dd->ipath_link_width_enabled = val;
  1581. else if (which == IPATH_IB_CFG_SPD_ENB)
  1582. dd->ipath_link_speed_enabled = val;
  1583. else
  1584. ret = -ENOTSUPP;
  1585. return ret;
  1586. }
  1587. static void ipath_pe_config_jint(struct ipath_devdata *dd, u16 a, u16 b)
  1588. {
  1589. }
  1590. static int ipath_pe_ib_updown(struct ipath_devdata *dd, int ibup, u64 ibcs)
  1591. {
  1592. ipath_setup_pe_setextled(dd, ipath_ib_linkstate(dd, ibcs),
  1593. ipath_ib_linktrstate(dd, ibcs));
  1594. return 0;
  1595. }
  1596. /**
  1597. * ipath_init_iba6120_funcs - set up the chip-specific function pointers
  1598. * @dd: the infinipath device
  1599. *
  1600. * This is global, and is called directly at init to set up the
  1601. * chip-specific function pointers for later use.
  1602. */
  1603. void ipath_init_iba6120_funcs(struct ipath_devdata *dd)
  1604. {
  1605. dd->ipath_f_intrsetup = ipath_pe_intconfig;
  1606. dd->ipath_f_bus = ipath_setup_pe_config;
  1607. dd->ipath_f_reset = ipath_setup_pe_reset;
  1608. dd->ipath_f_get_boardname = ipath_pe_boardname;
  1609. dd->ipath_f_init_hwerrors = ipath_pe_init_hwerrors;
  1610. dd->ipath_f_early_init = ipath_pe_early_init;
  1611. dd->ipath_f_handle_hwerrors = ipath_pe_handle_hwerrors;
  1612. dd->ipath_f_quiet_serdes = ipath_pe_quiet_serdes;
  1613. dd->ipath_f_bringup_serdes = ipath_pe_bringup_serdes;
  1614. dd->ipath_f_clear_tids = ipath_pe_clear_tids;
  1615. /*
  1616. * _f_put_tid may get changed after we read the chip revision,
  1617. * but we start with the safe version for all revs
  1618. */
  1619. dd->ipath_f_put_tid = ipath_pe_put_tid;
  1620. dd->ipath_f_cleanup = ipath_setup_pe_cleanup;
  1621. dd->ipath_f_setextled = ipath_setup_pe_setextled;
  1622. dd->ipath_f_get_base_info = ipath_pe_get_base_info;
  1623. dd->ipath_f_free_irq = ipath_pe_free_irq;
  1624. dd->ipath_f_tidtemplate = ipath_pe_tidtemplate;
  1625. dd->ipath_f_intr_fallback = ipath_pe_nointr_fallback;
  1626. dd->ipath_f_xgxs_reset = ipath_pe_xgxs_reset;
  1627. dd->ipath_f_get_msgheader = ipath_pe_get_msgheader;
  1628. dd->ipath_f_config_ports = ipath_pe_config_ports;
  1629. dd->ipath_f_read_counters = ipath_pe_read_counters;
  1630. dd->ipath_f_get_ib_cfg = ipath_pe_get_ib_cfg;
  1631. dd->ipath_f_set_ib_cfg = ipath_pe_set_ib_cfg;
  1632. dd->ipath_f_config_jint = ipath_pe_config_jint;
  1633. dd->ipath_f_ib_updown = ipath_pe_ib_updown;
  1634. /* initialize chip-specific variables */
  1635. ipath_init_pe_variables(dd);
  1636. }