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