40 #include <linux/pci.h>
42 #include <linux/module.h>
50 static void qib_7220_handle_hwerrors(
struct qib_devdata *,
char *,
size_t);
52 static u32 qib_7220_iblink_state(
u64);
53 static u8 qib_7220_phys_portstate(
u64);
64 #define KREG_IDX(regname) (QIB_7220_##regname##_OFFS / sizeof(u64))
67 #define kr_control KREG_IDX(Control)
68 #define kr_counterregbase KREG_IDX(CntrRegBase)
69 #define kr_errclear KREG_IDX(ErrClear)
70 #define kr_errmask KREG_IDX(ErrMask)
71 #define kr_errstatus KREG_IDX(ErrStatus)
72 #define kr_extctrl KREG_IDX(EXTCtrl)
73 #define kr_extstatus KREG_IDX(EXTStatus)
74 #define kr_gpio_clear KREG_IDX(GPIOClear)
75 #define kr_gpio_mask KREG_IDX(GPIOMask)
76 #define kr_gpio_out KREG_IDX(GPIOOut)
77 #define kr_gpio_status KREG_IDX(GPIOStatus)
78 #define kr_hrtbt_guid KREG_IDX(HRTBT_GUID)
79 #define kr_hwdiagctrl KREG_IDX(HwDiagCtrl)
80 #define kr_hwerrclear KREG_IDX(HwErrClear)
81 #define kr_hwerrmask KREG_IDX(HwErrMask)
82 #define kr_hwerrstatus KREG_IDX(HwErrStatus)
83 #define kr_ibcctrl KREG_IDX(IBCCtrl)
84 #define kr_ibcddrctrl KREG_IDX(IBCDDRCtrl)
85 #define kr_ibcddrstatus KREG_IDX(IBCDDRStatus)
86 #define kr_ibcstatus KREG_IDX(IBCStatus)
87 #define kr_ibserdesctrl KREG_IDX(IBSerDesCtrl)
88 #define kr_intclear KREG_IDX(IntClear)
89 #define kr_intmask KREG_IDX(IntMask)
90 #define kr_intstatus KREG_IDX(IntStatus)
91 #define kr_ncmodectrl KREG_IDX(IBNCModeCtrl)
92 #define kr_palign KREG_IDX(PageAlign)
93 #define kr_partitionkey KREG_IDX(RcvPartitionKey)
94 #define kr_portcnt KREG_IDX(PortCnt)
95 #define kr_rcvbthqp KREG_IDX(RcvBTHQP)
96 #define kr_rcvctrl KREG_IDX(RcvCtrl)
97 #define kr_rcvegrbase KREG_IDX(RcvEgrBase)
98 #define kr_rcvegrcnt KREG_IDX(RcvEgrCnt)
99 #define kr_rcvhdrcnt KREG_IDX(RcvHdrCnt)
100 #define kr_rcvhdrentsize KREG_IDX(RcvHdrEntSize)
101 #define kr_rcvhdrsize KREG_IDX(RcvHdrSize)
102 #define kr_rcvpktledcnt KREG_IDX(RcvPktLEDCnt)
103 #define kr_rcvtidbase KREG_IDX(RcvTIDBase)
104 #define kr_rcvtidcnt KREG_IDX(RcvTIDCnt)
105 #define kr_revision KREG_IDX(Revision)
106 #define kr_scratch KREG_IDX(Scratch)
107 #define kr_sendbuffererror KREG_IDX(SendBufErr0)
108 #define kr_sendctrl KREG_IDX(SendCtrl)
109 #define kr_senddmabase KREG_IDX(SendDmaBase)
110 #define kr_senddmabufmask0 KREG_IDX(SendDmaBufMask0)
111 #define kr_senddmabufmask1 (KREG_IDX(SendDmaBufMask0) + 1)
112 #define kr_senddmabufmask2 (KREG_IDX(SendDmaBufMask0) + 2)
113 #define kr_senddmahead KREG_IDX(SendDmaHead)
114 #define kr_senddmaheadaddr KREG_IDX(SendDmaHeadAddr)
115 #define kr_senddmalengen KREG_IDX(SendDmaLenGen)
116 #define kr_senddmastatus KREG_IDX(SendDmaStatus)
117 #define kr_senddmatail KREG_IDX(SendDmaTail)
118 #define kr_sendpioavailaddr KREG_IDX(SendBufAvailAddr)
119 #define kr_sendpiobufbase KREG_IDX(SendBufBase)
120 #define kr_sendpiobufcnt KREG_IDX(SendBufCnt)
121 #define kr_sendpiosize KREG_IDX(SendBufSize)
122 #define kr_sendregbase KREG_IDX(SendRegBase)
123 #define kr_userregbase KREG_IDX(UserRegBase)
124 #define kr_xgxs_cfg KREG_IDX(XGXSCfg)
127 #define kr_rcvhdraddr KREG_IDX(RcvHdrAddr0)
128 #define kr_rcvhdrtailaddr KREG_IDX(RcvHdrTailAddr0)
131 #define CREG_IDX(regname) ((QIB_7220_##regname##_OFFS - \
132 QIB_7220_LBIntCnt_OFFS) / sizeof(u64))
134 #define cr_badformat CREG_IDX(RxVersionErrCnt)
135 #define cr_erricrc CREG_IDX(RxICRCErrCnt)
136 #define cr_errlink CREG_IDX(RxLinkMalformCnt)
137 #define cr_errlpcrc CREG_IDX(RxLPCRCErrCnt)
138 #define cr_errpkey CREG_IDX(RxPKeyMismatchCnt)
139 #define cr_rcvflowctrl_err CREG_IDX(RxFlowCtrlViolCnt)
140 #define cr_err_rlen CREG_IDX(RxLenErrCnt)
141 #define cr_errslen CREG_IDX(TxLenErrCnt)
142 #define cr_errtidfull CREG_IDX(RxTIDFullErrCnt)
143 #define cr_errtidvalid CREG_IDX(RxTIDValidErrCnt)
144 #define cr_errvcrc CREG_IDX(RxVCRCErrCnt)
145 #define cr_ibstatuschange CREG_IDX(IBStatusChangeCnt)
146 #define cr_lbint CREG_IDX(LBIntCnt)
147 #define cr_invalidrlen CREG_IDX(RxMaxMinLenErrCnt)
148 #define cr_invalidslen CREG_IDX(TxMaxMinLenErrCnt)
149 #define cr_lbflowstall CREG_IDX(LBFlowStallCnt)
150 #define cr_pktrcv CREG_IDX(RxDataPktCnt)
151 #define cr_pktrcvflowctrl CREG_IDX(RxFlowPktCnt)
152 #define cr_pktsend CREG_IDX(TxDataPktCnt)
153 #define cr_pktsendflow CREG_IDX(TxFlowPktCnt)
154 #define cr_portovfl CREG_IDX(RxP0HdrEgrOvflCnt)
155 #define cr_rcvebp CREG_IDX(RxEBPCnt)
156 #define cr_rcvovfl CREG_IDX(RxBufOvflCnt)
157 #define cr_senddropped CREG_IDX(TxDroppedPktCnt)
158 #define cr_sendstall CREG_IDX(TxFlowStallCnt)
159 #define cr_sendunderrun CREG_IDX(TxUnderrunCnt)
160 #define cr_wordrcv CREG_IDX(RxDwordCnt)
161 #define cr_wordsend CREG_IDX(TxDwordCnt)
162 #define cr_txunsupvl CREG_IDX(TxUnsupVLErrCnt)
163 #define cr_rxdroppkt CREG_IDX(RxDroppedPktCnt)
164 #define cr_iblinkerrrecov CREG_IDX(IBLinkErrRecoveryCnt)
165 #define cr_iblinkdown CREG_IDX(IBLinkDownedCnt)
166 #define cr_ibsymbolerr CREG_IDX(IBSymbolErrCnt)
167 #define cr_vl15droppedpkt CREG_IDX(RxVL15DroppedPktCnt)
168 #define cr_rxotherlocalphyerr CREG_IDX(RxOtherLocalPhyErrCnt)
169 #define cr_excessbufferovfl CREG_IDX(ExcessBufferOvflCnt)
170 #define cr_locallinkintegrityerr CREG_IDX(LocalLinkIntegrityErrCnt)
171 #define cr_rxvlerr CREG_IDX(RxVlErrCnt)
172 #define cr_rxdlidfltr CREG_IDX(RxDlidFltrCnt)
173 #define cr_psstat CREG_IDX(PSStat)
174 #define cr_psstart CREG_IDX(PSStart)
175 #define cr_psinterval CREG_IDX(PSInterval)
176 #define cr_psrcvdatacount CREG_IDX(PSRcvDataCount)
177 #define cr_psrcvpktscount CREG_IDX(PSRcvPktsCount)
178 #define cr_psxmitdatacount CREG_IDX(PSXmitDataCount)
179 #define cr_psxmitpktscount CREG_IDX(PSXmitPktsCount)
180 #define cr_psxmitwaitcount CREG_IDX(PSXmitWaitCount)
181 #define cr_txsdmadesc CREG_IDX(TxSDmaDescCnt)
182 #define cr_pcieretrydiag CREG_IDX(PcieRetryBufDiagQwordCnt)
184 #define SYM_RMASK(regname, fldname) ((u64) \
185 QIB_7220_##regname##_##fldname##_RMASK)
186 #define SYM_MASK(regname, fldname) ((u64) \
187 QIB_7220_##regname##_##fldname##_RMASK << \
188 QIB_7220_##regname##_##fldname##_LSB)
189 #define SYM_LSB(regname, fldname) (QIB_7220_##regname##_##fldname##_LSB)
190 #define SYM_FIELD(value, regname, fldname) ((u64) \
191 (((value) >> SYM_LSB(regname, fldname)) & \
192 SYM_RMASK(regname, fldname)))
193 #define ERR_MASK(fldname) SYM_MASK(ErrMask, fldname##Mask)
194 #define HWE_MASK(fldname) SYM_MASK(HwErrMask, fldname##Mask)
197 #define QLOGIC_IB_IBCC_LINKINITCMD_DISABLE 1
199 #define QLOGIC_IB_IBCC_LINKINITCMD_POLL 2
201 #define QLOGIC_IB_IBCC_LINKINITCMD_SLEEP 3
202 #define QLOGIC_IB_IBCC_LINKINITCMD_SHIFT 16
204 #define QLOGIC_IB_IBCC_LINKCMD_DOWN 1
205 #define QLOGIC_IB_IBCC_LINKCMD_ARMED 2
206 #define QLOGIC_IB_IBCC_LINKCMD_ACTIVE 3
208 #define BLOB_7220_IBCHG 0x81
255 static inline void qib_write_ureg(
const struct qib_devdata *
dd,
271 writeq(value, &ubase[regno]);
281 static inline void qib_write_kreg_ctxt(
const struct qib_devdata *dd,
282 const u16 regno,
unsigned ctxt,
285 qib_write_kreg(dd, regno + ctxt, value);
288 static inline void write_7220_creg(
const struct qib_devdata *dd,
310 #define QLOGIC_IB_R_EMULATORREV_MASK ((1ULL << 22) - 1)
311 #define QLOGIC_IB_R_EMULATORREV_SHIFT 40
314 #define QLOGIC_IB_C_RESET (1U << 7)
317 #define QLOGIC_IB_I_RCVURG_MASK ((1ULL << 17) - 1)
318 #define QLOGIC_IB_I_RCVURG_SHIFT 32
319 #define QLOGIC_IB_I_RCVAVAIL_MASK ((1ULL << 17) - 1)
320 #define QLOGIC_IB_I_RCVAVAIL_SHIFT 0
321 #define QLOGIC_IB_I_SERDESTRIMDONE (1ULL << 27)
323 #define QLOGIC_IB_C_FREEZEMODE 0x00000002
324 #define QLOGIC_IB_C_LINKENABLE 0x00000004
326 #define QLOGIC_IB_I_SDMAINT 0x8000000000000000ULL
327 #define QLOGIC_IB_I_SDMADISABLED 0x4000000000000000ULL
328 #define QLOGIC_IB_I_ERROR 0x0000000080000000ULL
329 #define QLOGIC_IB_I_SPIOSENT 0x0000000040000000ULL
330 #define QLOGIC_IB_I_SPIOBUFAVAIL 0x0000000020000000ULL
331 #define QLOGIC_IB_I_GPIO 0x0000000010000000ULL
334 #define QLOGIC_IB_I_BITSEXTANT \
335 (QLOGIC_IB_I_SDMAINT | QLOGIC_IB_I_SDMADISABLED | \
336 (QLOGIC_IB_I_RCVURG_MASK << QLOGIC_IB_I_RCVURG_SHIFT) | \
337 (QLOGIC_IB_I_RCVAVAIL_MASK << \
338 QLOGIC_IB_I_RCVAVAIL_SHIFT) | \
339 QLOGIC_IB_I_ERROR | QLOGIC_IB_I_SPIOSENT | \
340 QLOGIC_IB_I_SPIOBUFAVAIL | QLOGIC_IB_I_GPIO | \
341 QLOGIC_IB_I_SERDESTRIMDONE)
343 #define IB_HWE_BITSEXTANT \
344 (HWE_MASK(RXEMemParityErr) | \
345 HWE_MASK(TXEMemParityErr) | \
346 (QLOGIC_IB_HWE_PCIEMEMPARITYERR_MASK << \
347 QLOGIC_IB_HWE_PCIEMEMPARITYERR_SHIFT) | \
348 QLOGIC_IB_HWE_PCIE1PLLFAILED | \
349 QLOGIC_IB_HWE_PCIE0PLLFAILED | \
350 QLOGIC_IB_HWE_PCIEPOISONEDTLP | \
351 QLOGIC_IB_HWE_PCIECPLTIMEOUT | \
352 QLOGIC_IB_HWE_PCIEBUSPARITYXTLH | \
353 QLOGIC_IB_HWE_PCIEBUSPARITYXADM | \
354 QLOGIC_IB_HWE_PCIEBUSPARITYRADM | \
355 HWE_MASK(PowerOnBISTFailed) | \
356 QLOGIC_IB_HWE_COREPLL_FBSLIP | \
357 QLOGIC_IB_HWE_COREPLL_RFSLIP | \
358 QLOGIC_IB_HWE_SERDESPLLFAILED | \
359 HWE_MASK(IBCBusToSPCParityErr) | \
360 HWE_MASK(IBCBusFromSPCParityErr) | \
361 QLOGIC_IB_HWE_PCIECPLDATAQUEUEERR | \
362 QLOGIC_IB_HWE_PCIECPLHDRQUEUEERR | \
363 QLOGIC_IB_HWE_SDMAMEMREADERR | \
364 QLOGIC_IB_HWE_CLK_UC_PLLNOTLOCKED | \
365 QLOGIC_IB_HWE_PCIESERDESQ0PCLKNOTDETECT | \
366 QLOGIC_IB_HWE_PCIESERDESQ1PCLKNOTDETECT | \
367 QLOGIC_IB_HWE_PCIESERDESQ2PCLKNOTDETECT | \
368 QLOGIC_IB_HWE_PCIESERDESQ3PCLKNOTDETECT | \
369 QLOGIC_IB_HWE_DDSRXEQMEMORYPARITYERR | \
370 QLOGIC_IB_HWE_IB_UC_MEMORYPARITYERR | \
371 QLOGIC_IB_HWE_PCIE_UC_OCT0MEMORYPARITYERR | \
372 QLOGIC_IB_HWE_PCIE_UC_OCT1MEMORYPARITYERR)
374 #define IB_E_BITSEXTANT \
375 (ERR_MASK(RcvFormatErr) | ERR_MASK(RcvVCRCErr) | \
376 ERR_MASK(RcvICRCErr) | ERR_MASK(RcvMinPktLenErr) | \
377 ERR_MASK(RcvMaxPktLenErr) | ERR_MASK(RcvLongPktLenErr) | \
378 ERR_MASK(RcvShortPktLenErr) | ERR_MASK(RcvUnexpectedCharErr) | \
379 ERR_MASK(RcvUnsupportedVLErr) | ERR_MASK(RcvEBPErr) | \
380 ERR_MASK(RcvIBFlowErr) | ERR_MASK(RcvBadVersionErr) | \
381 ERR_MASK(RcvEgrFullErr) | ERR_MASK(RcvHdrFullErr) | \
382 ERR_MASK(RcvBadTidErr) | ERR_MASK(RcvHdrLenErr) | \
383 ERR_MASK(RcvHdrErr) | ERR_MASK(RcvIBLostLinkErr) | \
384 ERR_MASK(SendSpecialTriggerErr) | \
385 ERR_MASK(SDmaDisabledErr) | ERR_MASK(SendMinPktLenErr) | \
386 ERR_MASK(SendMaxPktLenErr) | ERR_MASK(SendUnderRunErr) | \
387 ERR_MASK(SendPktLenErr) | ERR_MASK(SendDroppedSmpPktErr) | \
388 ERR_MASK(SendDroppedDataPktErr) | \
389 ERR_MASK(SendPioArmLaunchErr) | \
390 ERR_MASK(SendUnexpectedPktNumErr) | \
391 ERR_MASK(SendUnsupportedVLErr) | ERR_MASK(SendBufMisuseErr) | \
392 ERR_MASK(SDmaGenMismatchErr) | ERR_MASK(SDmaOutOfBoundErr) | \
393 ERR_MASK(SDmaTailOutOfBoundErr) | ERR_MASK(SDmaBaseErr) | \
394 ERR_MASK(SDma1stDescErr) | ERR_MASK(SDmaRpyTagErr) | \
395 ERR_MASK(SDmaDwEnErr) | ERR_MASK(SDmaMissingDwErr) | \
396 ERR_MASK(SDmaUnexpDataErr) | \
397 ERR_MASK(IBStatusChanged) | ERR_MASK(InvalidAddrErr) | \
398 ERR_MASK(ResetNegated) | ERR_MASK(HardwareErr) | \
399 ERR_MASK(SDmaDescAddrMisalignErr) | \
400 ERR_MASK(InvalidEEPCmd))
403 #define QLOGIC_IB_HWE_PCIEMEMPARITYERR_MASK 0x00000000000000ffULL
404 #define QLOGIC_IB_HWE_PCIEMEMPARITYERR_SHIFT 0
405 #define QLOGIC_IB_HWE_PCIEPOISONEDTLP 0x0000000010000000ULL
406 #define QLOGIC_IB_HWE_PCIECPLTIMEOUT 0x0000000020000000ULL
407 #define QLOGIC_IB_HWE_PCIEBUSPARITYXTLH 0x0000000040000000ULL
408 #define QLOGIC_IB_HWE_PCIEBUSPARITYXADM 0x0000000080000000ULL
409 #define QLOGIC_IB_HWE_PCIEBUSPARITYRADM 0x0000000100000000ULL
410 #define QLOGIC_IB_HWE_COREPLL_FBSLIP 0x0080000000000000ULL
411 #define QLOGIC_IB_HWE_COREPLL_RFSLIP 0x0100000000000000ULL
412 #define QLOGIC_IB_HWE_PCIE1PLLFAILED 0x0400000000000000ULL
413 #define QLOGIC_IB_HWE_PCIE0PLLFAILED 0x0800000000000000ULL
414 #define QLOGIC_IB_HWE_SERDESPLLFAILED 0x1000000000000000ULL
416 #define QLOGIC_IB_HWE_PCIECPLDATAQUEUEERR 0x0000000000000040ULL
417 #define QLOGIC_IB_HWE_PCIECPLHDRQUEUEERR 0x0000000000000080ULL
418 #define QLOGIC_IB_HWE_SDMAMEMREADERR 0x0000000010000000ULL
419 #define QLOGIC_IB_HWE_CLK_UC_PLLNOTLOCKED 0x2000000000000000ULL
420 #define QLOGIC_IB_HWE_PCIESERDESQ0PCLKNOTDETECT 0x0100000000000000ULL
421 #define QLOGIC_IB_HWE_PCIESERDESQ1PCLKNOTDETECT 0x0200000000000000ULL
422 #define QLOGIC_IB_HWE_PCIESERDESQ2PCLKNOTDETECT 0x0400000000000000ULL
423 #define QLOGIC_IB_HWE_PCIESERDESQ3PCLKNOTDETECT 0x0800000000000000ULL
424 #define QLOGIC_IB_HWE_DDSRXEQMEMORYPARITYERR 0x0000008000000000ULL
425 #define QLOGIC_IB_HWE_IB_UC_MEMORYPARITYERR 0x0000004000000000ULL
426 #define QLOGIC_IB_HWE_PCIE_UC_OCT0MEMORYPARITYERR 0x0000001000000000ULL
427 #define QLOGIC_IB_HWE_PCIE_UC_OCT1MEMORYPARITYERR 0x0000002000000000ULL
429 #define IBA7220_IBCC_LINKCMD_SHIFT 19
432 #define IBA7220_IBC_DLIDLMC_MASK 0xFFFFFFFFUL
433 #define IBA7220_IBC_DLIDLMC_SHIFT 32
435 #define IBA7220_IBC_HRTBT_MASK (SYM_RMASK(IBCDDRCtrl, HRTBT_AUTO) | \
436 SYM_RMASK(IBCDDRCtrl, HRTBT_ENB))
437 #define IBA7220_IBC_HRTBT_SHIFT SYM_LSB(IBCDDRCtrl, HRTBT_ENB)
439 #define IBA7220_IBC_LANE_REV_SUPPORTED (1<<8)
440 #define IBA7220_IBC_LREV_MASK 1
441 #define IBA7220_IBC_LREV_SHIFT 8
442 #define IBA7220_IBC_RXPOL_MASK 1
443 #define IBA7220_IBC_RXPOL_SHIFT 7
444 #define IBA7220_IBC_WIDTH_SHIFT 5
445 #define IBA7220_IBC_WIDTH_MASK 0x3
446 #define IBA7220_IBC_WIDTH_1X_ONLY (0 << IBA7220_IBC_WIDTH_SHIFT)
447 #define IBA7220_IBC_WIDTH_4X_ONLY (1 << IBA7220_IBC_WIDTH_SHIFT)
448 #define IBA7220_IBC_WIDTH_AUTONEG (2 << IBA7220_IBC_WIDTH_SHIFT)
449 #define IBA7220_IBC_SPEED_AUTONEG (1 << 1)
450 #define IBA7220_IBC_SPEED_SDR (1 << 2)
451 #define IBA7220_IBC_SPEED_DDR (1 << 3)
452 #define IBA7220_IBC_SPEED_AUTONEG_MASK (0x7 << 1)
453 #define IBA7220_IBC_IBTA_1_2_MASK (1)
457 #define IBA7220_DDRSTAT_LINKLAT_MASK 0x3ffffff
460 #define QLOGIC_IB_EXTS_FREQSEL 0x2
461 #define QLOGIC_IB_EXTS_SERDESSEL 0x4
462 #define QLOGIC_IB_EXTS_MEMBIST_ENDTEST 0x0000000000004000
463 #define QLOGIC_IB_EXTS_MEMBIST_DISABLED 0x0000000000008000
466 #define QLOGIC_IB_XGXS_RESET 0x5ULL
467 #define QLOGIC_IB_XGXS_FC_SAFE (1ULL << 63)
470 #define IBA7220_LEDBLINK_ON_SHIFT 32
471 #define IBA7220_LEDBLINK_OFF_SHIFT 0
473 #define _QIB_GPIO_SDA_NUM 1
474 #define _QIB_GPIO_SCL_NUM 0
475 #define QIB_TWSI_EEPROM_DEV 0xA2
476 #define QIB_TWSI_TEMP_DEV 0x98
479 #define QIB_7220_PSXMITWAIT_CHECK_RATE 4000
481 #define IBA7220_R_INTRAVAIL_SHIFT 17
482 #define IBA7220_R_PKEY_DIS_SHIFT 34
483 #define IBA7220_R_TAILUPD_SHIFT 35
484 #define IBA7220_R_CTXTCFG_SHIFT 36
486 #define IBA7220_HDRHEAD_PKTINT_SHIFT 32
492 #define IBA7220_TID_SZ_SHIFT 37
493 #define IBA7220_TID_SZ_2K (1UL << IBA7220_TID_SZ_SHIFT)
494 #define IBA7220_TID_SZ_4K (2UL << IBA7220_TID_SZ_SHIFT)
495 #define IBA7220_TID_PA_SHIFT 11U
496 #define PBC_7220_VL15_SEND (1ULL << 63)
497 #define PBC_7220_VL15_SEND_CTRL (1ULL << 31)
499 #define AUTONEG_TRIES 5
502 static u8 rate_to_delay[2][2] = {
515 #define IBA7220_LINKSPEED_SHIFT SYM_LSB(IBCStatus, LinkSpeedActive)
516 #define IBA7220_LINKWIDTH_SHIFT SYM_LSB(IBCStatus, LinkWidthActive)
519 #define IB_7220_LT_STATE_DISABLED 0x00
520 #define IB_7220_LT_STATE_LINKUP 0x01
521 #define IB_7220_LT_STATE_POLLACTIVE 0x02
522 #define IB_7220_LT_STATE_POLLQUIET 0x03
523 #define IB_7220_LT_STATE_SLEEPDELAY 0x04
524 #define IB_7220_LT_STATE_SLEEPQUIET 0x05
525 #define IB_7220_LT_STATE_CFGDEBOUNCE 0x08
526 #define IB_7220_LT_STATE_CFGRCVFCFG 0x09
527 #define IB_7220_LT_STATE_CFGWAITRMT 0x0a
528 #define IB_7220_LT_STATE_CFGIDLE 0x0b
529 #define IB_7220_LT_STATE_RECOVERRETRAIN 0x0c
530 #define IB_7220_LT_STATE_RECOVERWAITRMT 0x0e
531 #define IB_7220_LT_STATE_RECOVERIDLE 0x0f
534 #define IB_7220_L_STATE_DOWN 0x0
535 #define IB_7220_L_STATE_INIT 0x1
536 #define IB_7220_L_STATE_ARM 0x2
537 #define IB_7220_L_STATE_ACTIVE 0x3
538 #define IB_7220_L_STATE_ACT_DEFER 0x4
540 static const u8 qib_7220_physportstate[0x20] = {
574 #define IBCBUSFRSPCPARITYERR HWE_MASK(IBCBusFromSPCParityErr)
575 #define IBCBUSTOSPCPARITYERR HWE_MASK(IBCBusToSPCParityErr)
577 #define SYM_MASK_BIT(regname, fldname, bit) ((u64) \
578 (1ULL << (SYM_LSB(regname, fldname) + (bit))))
580 #define TXEMEMPARITYERR_PIOBUF \
581 SYM_MASK_BIT(HwErrMask, TXEMemParityErrMask, 0)
582 #define TXEMEMPARITYERR_PIOPBC \
583 SYM_MASK_BIT(HwErrMask, TXEMemParityErrMask, 1)
584 #define TXEMEMPARITYERR_PIOLAUNCHFIFO \
585 SYM_MASK_BIT(HwErrMask, TXEMemParityErrMask, 2)
587 #define RXEMEMPARITYERR_RCVBUF \
588 SYM_MASK_BIT(HwErrMask, RXEMemParityErrMask, 0)
589 #define RXEMEMPARITYERR_LOOKUPQ \
590 SYM_MASK_BIT(HwErrMask, RXEMemParityErrMask, 1)
591 #define RXEMEMPARITYERR_EXPTID \
592 SYM_MASK_BIT(HwErrMask, RXEMemParityErrMask, 2)
593 #define RXEMEMPARITYERR_EAGERTID \
594 SYM_MASK_BIT(HwErrMask, RXEMemParityErrMask, 3)
595 #define RXEMEMPARITYERR_FLAGBUF \
596 SYM_MASK_BIT(HwErrMask, RXEMemParityErrMask, 4)
597 #define RXEMEMPARITYERR_DATAINFO \
598 SYM_MASK_BIT(HwErrMask, RXEMemParityErrMask, 5)
599 #define RXEMEMPARITYERR_HDRINFO \
600 SYM_MASK_BIT(HwErrMask, RXEMemParityErrMask, 6)
609 "TXE PIOBUF Memory Parity"),
611 "TXE PIOPBC Memory Parity"),
613 "TXE PIOLAUNCHFIFO Memory Parity"),
616 "RXE RCVBUF Memory Parity"),
618 "RXE LOOKUPQ Memory Parity"),
620 "RXE EAGERTID Memory Parity"),
622 "RXE EXPTID Memory Parity"),
624 "RXE FLAGBUF Memory Parity"),
626 "RXE DATAINFO Memory Parity"),
628 "RXE HDRINFO Memory Parity"),
632 "PCIe Poisoned TLP"),
634 "PCIe completion timeout"),
647 "PCIe XTLH core parity"),
649 "PCIe ADM TX core parity"),
651 "PCIe ADM RX core parity"),
655 "PCIe cpl header queue"),
657 "PCIe cpl data queue"),
659 "Send DMA memory read"),
661 "uC PLL clock not locked"),
663 "PCIe serdes Q0 no clock"),
665 "PCIe serdes Q1 no clock"),
667 "PCIe serdes Q2 no clock"),
669 "PCIe serdes Q3 no clock"),
671 "DDS RXEQ memory parity"),
673 "IB uC memory parity"),
675 "PCIe uC oct0 memory parity"),
677 "PCIe uC oct1 memory parity"),
680 #define RXE_PARITY (RXEMEMPARITYERR_EAGERTID|RXEMEMPARITYERR_EXPTID)
682 #define QLOGIC_IB_E_PKTERRS (\
683 ERR_MASK(SendPktLenErr) | \
684 ERR_MASK(SendDroppedDataPktErr) | \
685 ERR_MASK(RcvVCRCErr) | \
686 ERR_MASK(RcvICRCErr) | \
687 ERR_MASK(RcvShortPktLenErr) | \
691 #define QLOGIC_IB_E_SDMAERRS ( \
692 ERR_MASK(SDmaGenMismatchErr) | \
693 ERR_MASK(SDmaOutOfBoundErr) | \
694 ERR_MASK(SDmaTailOutOfBoundErr) | ERR_MASK(SDmaBaseErr) | \
695 ERR_MASK(SDma1stDescErr) | ERR_MASK(SDmaRpyTagErr) | \
696 ERR_MASK(SDmaDwEnErr) | ERR_MASK(SDmaMissingDwErr) | \
697 ERR_MASK(SDmaUnexpDataErr) | \
698 ERR_MASK(SDmaDescAddrMisalignErr) | \
699 ERR_MASK(SDmaDisabledErr) | \
700 ERR_MASK(SendBufMisuseErr))
703 #define E_SUM_PKTERRS \
704 (ERR_MASK(RcvHdrLenErr) | ERR_MASK(RcvBadTidErr) | \
705 ERR_MASK(RcvBadVersionErr) | ERR_MASK(RcvHdrErr) | \
706 ERR_MASK(RcvLongPktLenErr) | ERR_MASK(RcvShortPktLenErr) | \
707 ERR_MASK(RcvMaxPktLenErr) | ERR_MASK(RcvMinPktLenErr) | \
708 ERR_MASK(RcvFormatErr) | ERR_MASK(RcvUnsupportedVLErr) | \
709 ERR_MASK(RcvUnexpectedCharErr) | ERR_MASK(RcvEBPErr))
713 (ERR_MASK(SendPioArmLaunchErr) | ERR_MASK(SendUnexpectedPktNumErr) | \
714 ERR_MASK(SendDroppedDataPktErr) | ERR_MASK(SendDroppedSmpPktErr) | \
715 ERR_MASK(SendMaxPktLenErr) | ERR_MASK(SendUnsupportedVLErr) | \
716 ERR_MASK(SendMinPktLenErr) | ERR_MASK(SendPktLenErr) | \
717 ERR_MASK(InvalidAddrErr))
725 #define E_SPKT_ERRS_IGNORE \
726 (ERR_MASK(SendDroppedDataPktErr) | ERR_MASK(SendDroppedSmpPktErr) | \
727 ERR_MASK(SendMaxPktLenErr) | ERR_MASK(SendMinPktLenErr) | \
728 ERR_MASK(SendPktLenErr))
736 #define E_SUM_LINK_PKTERRS \
737 (ERR_MASK(SendDroppedDataPktErr) | ERR_MASK(SendDroppedSmpPktErr) | \
738 ERR_MASK(SendMinPktLenErr) | ERR_MASK(SendPktLenErr) | \
739 ERR_MASK(RcvShortPktLenErr) | ERR_MASK(RcvMinPktLenErr) | \
740 ERR_MASK(RcvUnexpectedCharErr))
742 static void autoneg_7220_work(
struct work_struct *);
750 static void qib_disarm_7220_senderrbufs(
struct qib_pportdata *ppd)
752 unsigned long sbuf[3];
764 if (sbuf[0] || sbuf[1] || sbuf[2])
769 static void qib_7220_txe_recover(
struct qib_devdata *dd)
772 qib_disarm_7220_senderrbufs(dd->
pport);
778 static void qib_7220_sdma_sendctrl(
struct qib_pportdata *ppd,
unsigned op)
781 u64 set_sendctrl = 0;
782 u64 clr_sendctrl = 0;
785 set_sendctrl |=
SYM_MASK(SendCtrl, SDmaEnable);
787 clr_sendctrl |=
SYM_MASK(SendCtrl, SDmaEnable);
790 set_sendctrl |=
SYM_MASK(SendCtrl, SDmaIntEnable);
792 clr_sendctrl |=
SYM_MASK(SendCtrl, SDmaIntEnable);
795 set_sendctrl |=
SYM_MASK(SendCtrl, SDmaHalt);
797 clr_sendctrl |=
SYM_MASK(SendCtrl, SDmaHalt);
810 static void qib_decode_7220_sdma_errs(
struct qib_pportdata *ppd,
813 static const struct {
822 "SDmaTailOutOfBound" },
835 {
ERR_MASK(SDmaDescAddrMisalignErr),
836 "SDmaDescAddrMisalign" },
846 if (err & errs[i].err)
847 bidx +=
scnprintf(buf + bidx, blen - bidx,
856 static void qib_7220_sdma_hw_clean_up(
struct qib_pportdata *ppd)
861 ppd->
dd->upd_pio_shadow = 1;
864 static void qib_sdma_7220_setlengen(
struct qib_pportdata *ppd)
877 static void qib_7220_sdma_hw_start_up(
struct qib_pportdata *ppd)
879 qib_sdma_7220_setlengen(ppd);
880 qib_sdma_update_7220_tail(ppd, 0);
884 #define DISABLES_SDMA ( \
885 ERR_MASK(SDmaDisabledErr) | \
886 ERR_MASK(SDmaBaseErr) | \
887 ERR_MASK(SDmaTailOutOfBoundErr) | \
888 ERR_MASK(SDmaOutOfBoundErr) | \
889 ERR_MASK(SDma1stDescErr) | \
890 ERR_MASK(SDmaRpyTagErr) | \
891 ERR_MASK(SDmaGenMismatchErr) | \
892 ERR_MASK(SDmaDescAddrMisalignErr) | \
893 ERR_MASK(SDmaMissingDwErr) | \
894 ERR_MASK(SDmaDwEnErr))
904 msg = dd->
cspec->sdmamsgbuf;
905 qib_decode_7220_sdma_errs(ppd, errs, msg,
sizeof dd->
cspec->sdmamsgbuf);
908 if (errs &
ERR_MASK(SendBufMisuseErr)) {
909 unsigned long sbuf[3];
916 "IB%u:%u SendBufMisuse: %04lx %016lx %016lx\n",
917 ppd->
dd->unit, ppd->
port, sbuf[2], sbuf[1],
921 if (errs &
ERR_MASK(SDmaUnexpDataErr))
943 if (errs &
ERR_MASK(SDmaDisabledErr))
959 spin_unlock_irqrestore(&ppd->sdma_lock, flags);
968 static int qib_decode_7220_err(
struct qib_devdata *dd,
char *buf,
size_t blen,
975 if (!(err & ~QLOGIC_IB_E_PKTERRS))
984 strlcat(buf,
"rhdrlen ", blen);
986 strlcat(buf,
"rbadtid ", blen);
987 if (err &
ERR_MASK(RcvBadVersionErr))
988 strlcat(buf,
"rbadversion ", blen);
991 if (err &
ERR_MASK(SendSpecialTriggerErr))
992 strlcat(buf,
"sendspecialtrigger ", blen);
993 if (err &
ERR_MASK(RcvLongPktLenErr))
994 strlcat(buf,
"rlongpktlen ", blen);
995 if (err &
ERR_MASK(RcvMaxPktLenErr))
996 strlcat(buf,
"rmaxpktlen ", blen);
997 if (err &
ERR_MASK(RcvMinPktLenErr))
998 strlcat(buf,
"rminpktlen ", blen);
999 if (err &
ERR_MASK(SendMinPktLenErr))
1000 strlcat(buf,
"sminpktlen ", blen);
1002 strlcat(buf,
"rformaterr ", blen);
1003 if (err &
ERR_MASK(RcvUnsupportedVLErr))
1004 strlcat(buf,
"runsupvl ", blen);
1005 if (err &
ERR_MASK(RcvUnexpectedCharErr))
1006 strlcat(buf,
"runexpchar ", blen);
1008 strlcat(buf,
"ribflow ", blen);
1009 if (err &
ERR_MASK(SendUnderRunErr))
1010 strlcat(buf,
"sunderrun ", blen);
1011 if (err &
ERR_MASK(SendPioArmLaunchErr))
1012 strlcat(buf,
"spioarmlaunch ", blen);
1013 if (err &
ERR_MASK(SendUnexpectedPktNumErr))
1014 strlcat(buf,
"sunexperrpktnum ", blen);
1015 if (err &
ERR_MASK(SendDroppedSmpPktErr))
1016 strlcat(buf,
"sdroppedsmppkt ", blen);
1017 if (err &
ERR_MASK(SendMaxPktLenErr))
1018 strlcat(buf,
"smaxpktlen ", blen);
1019 if (err &
ERR_MASK(SendUnsupportedVLErr))
1020 strlcat(buf,
"sunsupVL ", blen);
1021 if (err &
ERR_MASK(InvalidAddrErr))
1022 strlcat(buf,
"invalidaddr ", blen);
1024 strlcat(buf,
"rcvegrfull ", blen);
1026 strlcat(buf,
"rcvhdrfull ", blen);
1027 if (err &
ERR_MASK(IBStatusChanged))
1028 strlcat(buf,
"ibcstatuschg ", blen);
1029 if (err &
ERR_MASK(RcvIBLostLinkErr))
1030 strlcat(buf,
"riblostlink ", blen);
1032 strlcat(buf,
"hardware ", blen);
1036 qib_decode_7220_sdma_errs(dd->
pport, err, buf, blen);
1038 strlcat(buf,
"invalideepromcmd ", blen);
1043 static void reenable_7220_chase(
unsigned long opaque)
1046 ppd->
cpspec->chase_timer.expires = 0;
1056 ibclt = (
u8)
SYM_FIELD(ibcst, IBCStatus, LinkTrainingState);
1070 if (ppd->
cpspec->chase_end &&
1072 ppd->
cpspec->chase_end = 0;
1073 qib_set_ib_7220_lstate(ppd,
1079 }
else if (!ppd->
cpspec->chase_end)
1084 ppd->
cpspec->chase_end = 0;
1092 u64 ignore_this_time = 0;
1099 errs &= dd->
cspec->errormask;
1100 msg = dd->
cspec->emsgbuf;
1104 qib_7220_handle_hwerrors(dd, msg,
sizeof dd->
cspec->emsgbuf);
1110 if (errs & QLOGIC_IB_E_SDMAERRS)
1111 sdma_7220_errors(ppd, errs);
1115 "error interrupt with unknown errors %llx set\n",
1119 qib_disarm_7220_senderrbufs(ppd);
1131 }
else if ((errs & E_SUM_LINK_PKTERRS) &&
1145 errs &= ~ignore_this_time;
1158 qib_decode_7220_err(dd, msg,
sizeof dd->
cspec->emsgbuf, errs & ~mask);
1162 if (errs & E_SUM_ERRS)
1164 iserr = errs & ~(E_SUM_PKTERRS | QLOGIC_IB_E_PKTERRS |
1167 if (errs &
ERR_MASK(IBStatusChanged)) {
1172 handle_7220_chase(ppd, ibcs);
1189 if (qib_7220_phys_portstate(ibcs) !=
1194 if (errs &
ERR_MASK(ResetNegated)) {
1196 "Got reset, requires re-init (unload and reload driver)\n");
1218 if (errs &
ERR_MASK(RcvEgrFullErr))
1255 static void qib_7220_clear_freeze(
struct qib_devdata *dd)
1261 qib_7220_set_intr_state(dd, 0);
1281 qib_7220_set_intr_state(dd, 1);
1295 static void qib_7220_handle_hwerrors(
struct qib_devdata *dd,
char *msg,
1307 if (hwerrs == ~0ULL) {
1309 "Read of hardware error status failed (all bits set); ignoring\n");
1322 hwerrs & ~
HWE_MASK(PowerOnBISTFailed));
1324 hwerrs &= dd->
cspec->hwerrmask;
1333 "Hardware error: hwerr=0x%llx (cleared)\n",
1334 (
unsigned long long) hwerrs);
1338 "hwerror interrupt with unknown errors %llx set\n",
1352 qib_7220_txe_recover(dd);
1359 qib_7220_clear_freeze(dd);
1364 if (hwerrs &
HWE_MASK(PowerOnBISTFailed)) {
1367 "[Memory BIST test failed, InfiniPath hardware unusable]",
1375 ARRAY_SIZE(qib_7220_hwerror_msgs), msg, msgl);
1377 bitsmsg = dd->
cspec->bitsmsgbuf;
1380 bits = (
u32) ((hwerrs >>
1384 "[PCIe Mem Parity Errs %x] ", bits);
1388 #define _QIB_PLL_FAIL (QLOGIC_IB_HWE_COREPLL_FBSLIP | \
1389 QLOGIC_IB_HWE_COREPLL_RFSLIP)
1391 if (hwerrs & _QIB_PLL_FAIL) {
1394 "[PLL failed (%llx), InfiniPath hardware unusable]",
1395 (
unsigned long long) hwerrs & _QIB_PLL_FAIL);
1398 dd->
cspec->hwerrmask &= ~(hwerrs & _QIB_PLL_FAIL);
1407 dd->
cspec->hwerrmask &= ~QLOGIC_IB_HWE_SERDESPLLFAILED;
1415 "Fatal Hardware Error, no longer usable, SN %.16s\n",
1439 static void qib_7220_init_hwerrors(
struct qib_devdata *dd)
1454 val &= ~QLOGIC_IB_HWE_IB_UC_MEMORYPARITYERR;
1475 static void qib_set_7220_armlaunch(
struct qib_devdata *dd,
u32 enable)
1495 unsigned long flags;
1535 static int qib_7220_bringup_serdes(
struct qib_pportdata *ppd)
1538 u64 val, prev_val, guid, ibc;
1546 ppd->
cpspec->ibdeltainprog = 1;
1548 ppd->
cpspec->iblnkerrsnap =
1553 ibc = 0x5ULL <<
SYM_LSB(IBCCtrl, FlowCtrlWaterMark);
1559 ibc |= 0x3ULL <<
SYM_LSB(IBCCtrl, FlowCtrlPeriod);
1561 ibc |= 0xfULL <<
SYM_LSB(IBCCtrl, PhyerrThreshold);
1563 ibc |= 4ULL <<
SYM_LSB(IBCCtrl, CreditScale);
1565 ibc |= 0xfULL <<
SYM_LSB(IBCCtrl, OverrunThreshold);
1571 ppd->
cpspec->ibcctrl = ibc;
1578 if (!ppd->
cpspec->ibcddrctrl) {
1583 ppd->
cpspec->ibcddrctrl |=
1587 ppd->
cpspec->ibcddrctrl |=
1594 ppd->
cpspec->ibcddrctrl |=
1600 ppd->
cpspec->ibcddrctrl |=
1602 ppd->
cpspec->ibcddrctrl |=
1622 if (val != prev_val) {
1627 val &= ~QLOGIC_IB_XGXS_RESET;
1628 if (val != prev_val)
1651 static void qib_7220_quiet_serdes(
struct qib_pportdata *ppd)
1655 unsigned long flags;
1660 dd->
control | QLOGIC_IB_C_FREEZEMODE);
1662 ppd->
cpspec->chase_end = 0;
1663 if (ppd->
cpspec->chase_timer.data)
1666 if (ppd->
cpspec->ibsymdelta || ppd->
cpspec->iblnkerrdelta ||
1667 ppd->
cpspec->ibdeltainprog) {
1673 diagc |
SYM_MASK(HwDiagCtrl, CounterWrEnable));
1675 if (ppd->
cpspec->ibsymdelta || ppd->
cpspec->ibdeltainprog) {
1677 if (ppd->
cpspec->ibdeltainprog)
1678 val -= val - ppd->
cpspec->ibsymsnap;
1679 val -= ppd->
cpspec->ibsymdelta;
1682 if (ppd->
cpspec->iblnkerrdelta || ppd->
cpspec->ibdeltainprog) {
1684 if (ppd->
cpspec->ibdeltainprog)
1685 val -= val - ppd->
cpspec->iblnkerrsnap;
1686 val -= ppd->
cpspec->iblnkerrdelta;
1733 u64 extctl, ledblink = 0,
val, lst, ltst;
1734 unsigned long flags;
1750 ltst = qib_7220_phys_portstate(val);
1751 lst = qib_7220_iblink_state(val);
1758 extctl = dd->
cspec->extctrl & ~(
SYM_MASK(EXTCtrl, LEDPriPortGreenOn) |
1759 SYM_MASK(EXTCtrl, LEDPriPortYellowOn));
1761 extctl |=
SYM_MASK(EXTCtrl, LEDPriPortGreenOn);
1771 extctl |=
SYM_MASK(EXTCtrl, LEDPriPortYellowOn);
1772 dd->
cspec->extctrl = extctl;
1774 spin_unlock_irqrestore(&dd->
cspec->gpio_lock, flags);
1780 static void qib_7220_free_irq(
struct qib_devdata *dd)
1782 if (dd->
cspec->irq) {
1796 static void qib_setup_7220_cleanup(
struct qib_devdata *dd)
1798 qib_7220_free_irq(dd);
1809 unsigned long flags;
1839 spin_unlock_irqrestore(&ppd->sdma_lock, flags);
1842 static void qib_wantpiobuf_7220_intr(
struct qib_devdata *dd,
u32 needint)
1844 unsigned long flags;
1856 ~
SYM_MASK(SendCtrl, SendBufAvailUpd));
1875 "interrupt with unknown interrupts %Lx set\n",
1900 u32 gpio_irq = mask & gpiostatus;
1913 dd->
cspec->gpio_mask &= ~gpio_irq;
1925 "error interrupt (%Lx), but no error bits set!\n",
1928 handle_7220_errors(dd, estat);
1970 QLOGIC_IB_I_GPIO | QLOGIC_IB_I_ERROR)))
1971 unlikely_7220_intr(dd, istat);
1993 if (ctxtrbits & rmask) {
1994 ctxtrbits &= ~rmask;
2009 sdma_7220_intr(dd->
pport, istat);
2027 static void qib_setup_7220_interrupt(
struct qib_devdata *dd)
2029 if (!dd->
cspec->irq)
2031 "irq is 0, BIOS error? Interrupts won't work\n");
2039 "Couldn't setup %s interrupt (irq=%d): %d\n",
2040 dd->
msi_lo ?
"MSI" :
"INTx",
2041 dd->
cspec->irq, ret);
2051 static void qib_7220_boardname(
struct qib_devdata *dd)
2061 n =
"InfiniPath_QLE7240";
2064 n =
"InfiniPath_QLE7280";
2067 qib_dev_err(dd,
"Unknown 7220 board with ID %u\n", boardid);
2068 n =
"Unknown_InfiniPath_7220";
2075 qib_dev_err(dd,
"Failed allocation for board name: %s\n", n);
2081 "Unsupported InfiniPath hardware revision %u.%u!\n",
2085 "ChipABI %u.%u, %s, InfiniPath%u %u.%u, SW Compat %u\n",
2096 static int qib_setup_7220_reset(
struct qib_devdata *dd)
2102 u8 int_line, clinesz;
2103 unsigned long flags;
2111 qib_7220_set_intr_state(dd, 0);
2113 dd->
pport->cpspec->ibdeltainprog = 0;
2114 dd->
pport->cpspec->ibsymdelta = 0;
2115 dd->
pport->cpspec->iblnkerrdelta = 0;
2128 for (i = 1; i <= 5; i++) {
2134 msleep(1000 + (1 + i) * 2000);
2155 "Reset failed to setup PCIe or interrupts; continuing anyway\n");
2161 qib_7220_init_hwerrors(dd);
2165 dd->
cspec->presets_needed = 1;
2169 spin_unlock_irqrestore(&dd->
pport->lflags_lock, flags);
2189 if (pa != (chippa << IBA7220_TID_PA_SHIFT)) {
2190 qib_dev_err(dd,
"Physaddr %lx not 2KB aligned!\n",
2196 "Physical page address 0x%lx larger than supported\n",
2221 static void qib_7220_clear_tids(
struct qib_devdata *dd,
2225 unsigned long tidinv;
2238 ctxt * dd->
rcvtidcnt *
sizeof(*tidbase));
2260 static void qib_7220_tidtemplate(
struct qib_devdata *dd)
2277 static int qib_7220_get_base_info(
struct qib_ctxtdata *rcd,
2292 u32 offset = qib_hdrget_offset(rhf_addr);
2298 static void qib_7220_config_ctxts(
struct qib_devdata *dd)
2300 unsigned long flags;
2303 nchipctxts = qib_read_kreg32(dd,
kr_portcnt);
2304 dd->
cspec->numctxts = nchipctxts;
2319 else if (nctxts <= 9)
2321 else if (nctxts <= nchipctxts)
2342 spin_unlock_irqrestore(&dd->
cspec->rcvmod_lock, flags);
2349 static int qib_7220_get_ib_cfg(
struct qib_pportdata *ppd,
int which)
2410 ret = (ppd->
cpspec->ibcctrl &
2411 SYM_MASK(IBCCtrl, LinkDownDefaultState)) ?
2432 ret = (
int)((ppd->
cpspec->ibcddrctrl >> lsb) & maskr);
2437 static int qib_7220_set_ib_cfg(
struct qib_pportdata *ppd,
int which,
u32 val)
2441 int lsb, ret = 0, setforce = 0;
2443 unsigned long flags;
2493 dd->
cspec->presets_needed = 1;
2517 lsb =
SYM_LSB(IBCDDRCtrl, IB_ENHANCED_MODE);
2536 ~
SYM_MASK(IBCCtrl, OverrunThreshold);
2538 SYM_LSB(IBCCtrl, OverrunThreshold);
2549 ~
SYM_MASK(IBCCtrl, PhyerrThreshold);
2551 SYM_LSB(IBCCtrl, PhyerrThreshold);
2568 ~
SYM_MASK(IBCCtrl, LinkDownDefaultState);
2571 SYM_MASK(IBCCtrl, LinkDownDefaultState);
2592 switch (val & 0xffff0000) {
2595 if (!ppd->
cpspec->ibdeltainprog &&
2597 ppd->
cpspec->ibdeltainprog = 1;
2600 ppd->
cpspec->iblnkerrsnap =
2615 qib_dev_err(dd,
"bad linkcmd req 0x%x\n", val >> 16);
2618 switch (val & 0xffff) {
2633 ppd->
cpspec->chase_end = 0;
2638 if (ppd->
cpspec->chase_timer.expires) {
2640 ppd->
cpspec->chase_timer.expires = 0;
2650 qib_set_ib_7220_lstate(ppd, lcmd, licmd);
2654 tmp = (ppd->
cpspec->ibcddrctrl >>
lsb) & maskr;
2662 ppd->
cpspec->ibcddrctrl &= ~(maskr <<
lsb);
2663 ppd->
cpspec->ibcddrctrl |=
2667 ppd->
cpspec->ibcddrctrl);
2688 ppd->
cpspec->ibcddrctrl &= ~(maskr <<
lsb);
2689 ppd->
cpspec->ibcddrctrl |= (((
u64) val & maskr) <<
lsb);
2706 if (!
strncmp(what,
"ibc", 3)) {
2709 qib_devinfo(ppd->
dd->pcidev,
"Enabling IB%u:%u IBC loopback\n",
2710 ppd->
dd->unit, ppd->
port);
2711 }
else if (!
strncmp(what,
"off", 3)) {
2716 "Disabling IB%u:%u IBC loopback (normal)\n",
2717 ppd->
dd->unit, ppd->
port);
2726 ppd->
cpspec->ibcddrctrl);
2748 tail = qib_get_rcvhdrtail(rcd);
2751 return head ==
tail;
2761 static void rcvctrl_7220_mod(
struct qib_pportdata *ppd,
unsigned int op,
2766 unsigned long flags;
2778 mask = (1ULL << dd->
ctxtcnt) - 1;
2780 mask = (1ULL << ctxt);
2788 dd->
rcd[ctxt]->rcvhdrqtailaddr_phys);
2790 dd->
rcd[ctxt]->rcvhdrq_phys);
2791 dd->
rcd[ctxt]->seq_cnt = 1;
2806 if (op & QIB_RCVCTRL_CTXT_ENB) {
2817 dd->
rcd[ctxt]->head =
val;
2823 if (op & QIB_RCVCTRL_CTXT_DIS) {
2830 for (i = 0; i < dd->
cfgctxts; i++) {
2837 spin_unlock_irqrestore(&dd->
cspec->rcvmod_lock, flags);
2851 u64 tmp_dd_sendctrl;
2852 unsigned long flags;
2883 SYM_MASK(SendCtrl, SendBufAvailUpd));
2884 for (i = 0; i < last; i++) {
2897 tmp_dd_sendctrl |=
SYM_MASK(SendCtrl, Disarm) |
2899 SYM_LSB(SendCtrl, DisarmPIOBuf));
2902 tmp_dd_sendctrl &= ~
SYM_MASK(SendCtrl, SendBufAvailUpd);
2907 if (op & QIB_SENDCTRL_AVAIL_BLIP) {
2914 if (op & QIB_SENDCTRL_FLUSH) {
2941 static const u16 xlator[] = {
2980 "Unimplemented portcounter %u\n", reg);
3001 ret = read_7220_creg(dd, creg);
3003 ret = read_7220_creg32(dd, creg);
3005 if (dd->
pport->cpspec->ibdeltainprog)
3006 ret -= ret - ppd->
cpspec->ibsymsnap;
3007 ret -= dd->
pport->cpspec->ibsymdelta;
3009 if (dd->
pport->cpspec->ibdeltainprog)
3010 ret -= ret - ppd->
cpspec->iblnkerrsnap;
3011 ret -= dd->
pport->cpspec->iblnkerrdelta;
3030 static const char cntr7220names[] =
3053 static const size_t cntr7220indices[] = {
3082 static const char portcntr7220names[] =
3120 #define _PORT_VIRT_FLAG 0x8000
3121 static const size_t portcntr7220indices[] = {
3160 static void init_7220_cntrnames(
struct qib_devdata *dd)
3165 for (i = 0, s = (
char *)cntr7220names; s && j <= dd->
cfgctxts;
3168 if (!j && !
strncmp(
"Ctxt0EgrOvfl", s + 1, 12))
3177 dd->
cspec->cntrnamelen =
sizeof(cntr7220names) - 1;
3179 dd->
cspec->cntrnamelen = 1 + s - cntr7220names;
3182 if (!dd->
cspec->cntrs)
3183 qib_dev_err(dd,
"Failed allocation for counters\n");
3185 for (i = 0, s = (
char *)portcntr7220names;
s; i++)
3187 dd->
cspec->nportcntrs = i - 1;
3188 dd->
cspec->portcntrnamelen =
sizeof(portcntr7220names) - 1;
3191 if (!dd->
cspec->portcntrs)
3192 qib_dev_err(dd,
"Failed allocation for portcounters\n");
3200 if (!dd->
cspec->cntrs) {
3206 *namep = (
char *)cntr7220names;
3207 ret = dd->
cspec->cntrnamelen;
3214 ret = dd->
cspec->ncntrs *
sizeof(
u64);
3215 if (!cntr || pos >= ret) {
3222 for (i = 0; i < dd->
cspec->ncntrs; i++)
3223 *cntr++ = read_7220_creg32(dd, cntr7220indices[i]);
3230 char **namep,
u64 **cntrp)
3234 if (!dd->
cspec->portcntrs) {
3239 *namep = (
char *)portcntr7220names;
3240 ret = dd->
cspec->portcntrnamelen;
3248 ret = dd->
cspec->nportcntrs *
sizeof(
u64);
3249 if (!cntr || pos >= ret) {
3255 for (i = 0; i < dd->
cspec->nportcntrs; i++) {
3257 *cntr++ = qib_portcntr_7220(ppd,
3258 portcntr7220indices[i] &
3261 *cntr++ = read_7220_creg32(dd,
3262 portcntr7220indices[i]);
3277 static void qib_get_7220_faststats(
unsigned long opaque)
3281 unsigned long flags;
3297 traffic_wds = qib_portcntr_7220(ppd,
cr_wordsend) +
3312 static int qib_7220_intr_fallback(
struct qib_devdata *dd)
3318 "MSI interrupt not detected, trying INTx interrupts\n");
3319 qib_7220_free_irq(dd);
3328 qib_setup_7220_interrupt(dd);
3345 prev_val &= ~QLOGIC_IB_XGXS_RESET;
3372 u32 lbuf = ppd->
dd->cspec->lastbuf_for_pio;
3374 unsigned long flags;
3380 sendctrl_7220_mod(ppd->
dd->pport, QIB_SENDCTRL_AVAIL_BLIP);
3393 qib_7220_sdma_hw_clean_up(ppd);
3395 spin_unlock_irqrestore(&ppd->sdma_lock, flags);
3425 while (!(piobuf = get_7220_link_buf(ppd, &pnum))) {
3448 static void autoneg_7220_send(
struct qib_pportdata *ppd,
int which)
3453 static u32 hdr[7] = { 0xf002ffff, 0x48ffff, 0x6400abba };
3454 static u32 madpayload_start[0x40] = {
3455 0x1810103, 0x1, 0x0, 0x0, 0x2c90000, 0x2c9, 0x0, 0x0,
3456 0xffffffff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
3457 0x1, 0x1388, 0x15e, 0x1,
3459 static u32 madpayload_done[0x40] = {
3460 0x1810103, 0x1, 0x0, 0x0, 0x2c90000, 0x2c9, 0x0, 0x0,
3461 0xffffffff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
3462 0x40000001, 0x1388, 0x15e,
3469 for (i = 0; i < hcnt; i++) {
3473 for (i = 0; i < dcnt; i++) {
3475 madpayload_start[
i] = dw;
3477 madpayload_done[
i] = dw;
3482 data = which ? madpayload_done : madpayload_start;
3484 autoneg_7220_sendpkt(ppd, hdr, dcnt, data);
3487 autoneg_7220_sendpkt(ppd, hdr, dcnt, data);
3530 unsigned long flags;
3542 autoneg_7220_send(ppd, 0);
3561 unsigned long flags;
3564 autoneg_work.work)->pportdata;
3573 for (i = 0; i < 25; i++) {
3615 dd->
cspec->autoneg_tries = 0;
3622 static u32 qib_7220_iblink_state(
u64 ibcs)
3647 static u8 qib_7220_phys_portstate(
u64 ibcs)
3649 u8 state = (
u8)
SYM_FIELD(ibcs, IBCStatus, LinkTrainingState);
3650 return qib_7220_physportstate[
state];
3653 static int qib_7220_ib_updown(
struct qib_pportdata *ppd,
int ibup,
u64 ibcs)
3655 int ret = 0, symadj = 0;
3657 unsigned long flags;
3676 if (__qib_sdma_running(ppd))
3679 spin_unlock_irqrestore(&ppd->sdma_lock, flags);
3692 ++dd->
cspec->autoneg_tries;
3693 if (!ppd->
cpspec->ibdeltainprog) {
3694 ppd->
cpspec->ibdeltainprog = 1;
3695 ppd->
cpspec->ibsymsnap = read_7220_creg32(dd,
3697 ppd->
cpspec->iblnkerrsnap = read_7220_creg32(dd,
3700 try_7220_autoneg(ppd);
3704 autoneg_7220_send(ppd, 1);
3717 dd->
cspec->autoneg_tries = 0;
3719 set_7220_ibspeed_fast(ppd,
3734 ppd->
cpspec->ibcddrctrl |=
3760 spin_unlock_irqrestore(&ppd->sdma_lock, flags);
3765 if (ppd->
cpspec->ibdeltainprog) {
3766 ppd->
cpspec->ibdeltainprog = 0;
3767 ppd->
cpspec->ibsymdelta += read_7220_creg32(ppd->
dd,
3769 ppd->
cpspec->iblnkerrdelta += read_7220_creg32(ppd->
dd,
3773 !ppd->
cpspec->ibdeltainprog &&
3775 ppd->
cpspec->ibdeltainprog = 1;
3776 ppd->
cpspec->ibsymsnap = read_7220_creg32(ppd->
dd,
3778 ppd->
cpspec->iblnkerrsnap = read_7220_creg32(ppd->
dd,
3783 qib_setup_7220_setextled(ppd, ibup);
3796 u64 read_val, new_out;
3797 unsigned long flags;
3806 new_out = (dd->
cspec->gpio_out & ~mask) | out;
3810 dd->
cspec->gpio_out = new_out;
3811 spin_unlock_irqrestore(&dd->
cspec->gpio_lock, flags);
3822 return SYM_FIELD(read_val, EXTStatus, GPIOIn);
3830 static void get_7220_chip_params(
struct qib_devdata *dd)
3883 static void set_7220_baseaddrs(
struct qib_devdata *dd)
3896 #define SENDCTRL_SHADOWED (SYM_MASK(SendCtrl, SendIntBufAvail) | \
3897 SYM_MASK(SendCtrl, SPioEnable) | \
3898 SYM_MASK(SendCtrl, SSpecialTriggerEn) | \
3899 SYM_MASK(SendCtrl, SendBufAvailUpd) | \
3900 SYM_MASK(SendCtrl, AvailUpdThld) | \
3901 SYM_MASK(SendCtrl, SDmaEnable) | \
3902 SYM_MASK(SendCtrl, SDmaIntEnable) | \
3903 SYM_MASK(SendCtrl, SDmaHalt) | \
3904 SYM_MASK(SendCtrl, SDmaSingleDescriptor))
3910 unsigned long flags;
3911 unsigned idx = offs /
sizeof(
u64);
3912 u64 local_data, all_bits;
3915 qib_dev_err(dd,
"SendCtrl Hook called with offs %X, %s-bit\n",
3916 offs, only_32 ?
"32" :
"64");
3924 if ((mask & all_bits) != all_bits) {
3933 local_data = (
u64)qib_read_kreg32(dd, idx);
3935 local_data = qib_read_kreg64(dd, idx);
3939 (dd->
sendctrl & SENDCTRL_SHADOWED))
3940 qib_dev_err(dd,
"Sendctrl read: %X shadow is %X\n",
3942 *data = (local_data & ~mask) | (*data & mask);
3966 return only_32 ? 4 : 8;
3979 static int qib_late_7220_initreg(
struct qib_devdata *dd)
3991 "Catastrophic software error, SendPIOAvailAddr written as %lx, read back as %llx\n",
3993 (
unsigned long long) val);
4000 static int qib_init_7220_variables(
struct qib_devdata *dd)
4005 u32 sbufs, updthresh;
4022 if ((dd->
revision & 0xffffffffU) == 0xffffffffU) {
4024 "Revision register read failure, giving up initialization\n");
4035 get_7220_chip_params(dd);
4036 qib_7220_boardname(dd);
4048 dd->
flags |= qib_special_trigger ?
4084 ppd->
cpspec->chase_timer.function = reenable_7220_chase;
4085 ppd->
cpspec->chase_timer.data = (
unsigned long)ppd;
4100 qib_7220_tidtemplate(dd);
4111 dd->
stats_timer.function = qib_get_7220_faststats;
4126 qib_7220_config_ctxts(dd);
4134 set_7220_baseaddrs(dd);
4141 init_7220_cntrnames(dd);
4156 sbufs = updthresh > 3 ? updthresh : 3;
4158 dd->
cspec->sdmabufcnt = 0;
4163 dd->
cspec->sdmabufcnt;
4165 dd->
cspec->lastbuf_for_pio--;
4179 dd->
cspec->updthresh_dflt = updthresh;
4180 dd->
cspec->updthresh = updthresh;
4184 <<
SYM_LSB(SendCtrl, AvailUpdThld);
4201 buf = get_7220_link_buf(ppd, pbufnum);
4208 last = dd->
cspec->lastbuf_for_pio;
4237 static void qib_sdma_set_7220_desc_cnt(
struct qib_pportdata *ppd,
unsigned cnt)
4246 .go_s99_running_tofalse = 1,
4277 .go_s99_running_totrue = 1,
4281 static void qib_7220_sdma_init_early(
struct qib_pportdata *ppd)
4283 ppd->
sdma_state.set_state_action = sdma_7220_action_table;
4290 u64 senddmabufmask[3] = { 0 };
4294 qib_sdma_7220_setlengen(ppd);
4295 qib_sdma_update_7220_tail(ppd, 0);
4304 i = n - dd->
cspec->sdmabufcnt;
4306 for (; i <
n; ++
i) {
4307 unsigned word = i / 64;
4308 unsigned bit = i & 63;
4311 senddmabufmask[
word] |= 1ULL <<
bit;
4334 use_dmahead = __qib_sdma_running(ppd) &&
4337 hwhead = use_dmahead ?
4345 if (swhead < swtail) {
4347 sane = (hwhead >= swhead) & (hwhead <= swtail);
4348 }
else if (swhead > swtail) {
4350 sane = ((hwhead >= swhead) && (hwhead < cnt)) ||
4354 sane = (hwhead == swhead);
4374 return (hwstatus &
SYM_MASK(SendDmaStatus, ScoreBoardDrainInProg)) ||
4375 (hwstatus &
SYM_MASK(SendDmaStatus, AbortInProg)) ||
4376 (hwstatus &
SYM_MASK(SendDmaStatus, InternalSDmaEnable)) ||
4377 !(hwstatus &
SYM_MASK(SendDmaStatus, ScbEmpty));
4392 u8 rcv_mult = ib_rate_to_delay[srate];
4395 ppd->
cpspec->last_delay_mult = (rcv_mult > snd_mult) ?
4396 (plen * (rcv_mult - snd_mult) + 1) >> 1 : 0;
4404 static void qib_7220_initvl15_bufs(
struct qib_devdata *dd)
4408 static void qib_7220_init_ctxt(
struct qib_ctxtdata *rcd)
4424 unsigned long flags;
4431 dd->
cspec->updthresh != dd->
cspec->updthresh_dflt
4433 if (dd->
rcd[i] && dd->
rcd[i]->subctxt_cnt &&
4434 ((dd->
rcd[i]->piocnt / dd->
rcd[i]->subctxt_cnt) - 1)
4435 < dd->
cspec->updthresh_dflt)
4437 spin_unlock_irqrestore(&dd->
uctxt_lock, flags);
4440 dd->
cspec->updthresh = dd->
cspec->updthresh_dflt;
4444 SYM_LSB(SendCtrl, AvailUpdThld);
4446 sendctrl_7220_mod(dd->
pport, QIB_SENDCTRL_AVAIL_BLIP);
4458 <<
SYM_LSB(SendCtrl, AvailUpdThld);
4460 sendctrl_7220_mod(dd->
pport, QIB_SENDCTRL_AVAIL_BLIP);
4472 #define VALID_TS_RD_REG_MASK 0xBF
4480 static int qib_7220_tempsense_rd(
struct qib_devdata *dd,
int regnum)
4517 static int qib_7220_eeprom_wen(
struct qib_devdata *dd,
int wen)
4535 u32 boardid, minwidth;
4564 dd->
f_reset = qib_setup_7220_reset;
4601 ret = qib_init_7220_variables(dd);
4623 "Failed to setup PCIe or interrupts; continuing anyway\n");
4629 QLOGIC_IB_HWE_SERDESPLLFAILED)
4631 QLOGIC_IB_HWE_SERDESPLLFAILED);
4634 qib_setup_7220_interrupt(dd);
4635 qib_7220_init_hwerrors(dd);