Path: blob/master/drivers/infiniband/hw/ipath/ipath_iba6110.c
15112 views
/*1* Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved.2* Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.3*4* This software is available to you under a choice of one of two5* licenses. You may choose to be licensed under the terms of the GNU6* General Public License (GPL) Version 2, available from the file7* COPYING in the main directory of this source tree, or the8* OpenIB.org BSD license below:9*10* Redistribution and use in source and binary forms, with or11* without modification, are permitted provided that the following12* conditions are met:13*14* - Redistributions of source code must retain the above15* copyright notice, this list of conditions and the following16* disclaimer.17*18* - Redistributions in binary form must reproduce the above19* copyright notice, this list of conditions and the following20* disclaimer in the documentation and/or other materials21* provided with the distribution.22*23* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,24* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF25* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND26* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS27* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN28* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN29* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE30* SOFTWARE.31*/3233/*34* This file contains all of the code that is specific to the InfiniPath35* HT chip.36*/3738#include <linux/vmalloc.h>39#include <linux/pci.h>40#include <linux/delay.h>41#include <linux/htirq.h>42#include <rdma/ib_verbs.h>4344#include "ipath_kernel.h"45#include "ipath_registers.h"4647static void ipath_setup_ht_setextled(struct ipath_devdata *, u64, u64);484950/*51* This lists the InfiniPath registers, in the actual chip layout.52* This structure should never be directly accessed.53*54* The names are in InterCap form because they're taken straight from55* the chip specification. Since they're only used in this file, they56* don't pollute the rest of the source.57*/5859struct _infinipath_do_not_use_kernel_regs {60unsigned long long Revision;61unsigned long long Control;62unsigned long long PageAlign;63unsigned long long PortCnt;64unsigned long long DebugPortSelect;65unsigned long long DebugPort;66unsigned long long SendRegBase;67unsigned long long UserRegBase;68unsigned long long CounterRegBase;69unsigned long long Scratch;70unsigned long long ReservedMisc1;71unsigned long long InterruptConfig;72unsigned long long IntBlocked;73unsigned long long IntMask;74unsigned long long IntStatus;75unsigned long long IntClear;76unsigned long long ErrorMask;77unsigned long long ErrorStatus;78unsigned long long ErrorClear;79unsigned long long HwErrMask;80unsigned long long HwErrStatus;81unsigned long long HwErrClear;82unsigned long long HwDiagCtrl;83unsigned long long MDIO;84unsigned long long IBCStatus;85unsigned long long IBCCtrl;86unsigned long long ExtStatus;87unsigned long long ExtCtrl;88unsigned long long GPIOOut;89unsigned long long GPIOMask;90unsigned long long GPIOStatus;91unsigned long long GPIOClear;92unsigned long long RcvCtrl;93unsigned long long RcvBTHQP;94unsigned long long RcvHdrSize;95unsigned long long RcvHdrCnt;96unsigned long long RcvHdrEntSize;97unsigned long long RcvTIDBase;98unsigned long long RcvTIDCnt;99unsigned long long RcvEgrBase;100unsigned long long RcvEgrCnt;101unsigned long long RcvBufBase;102unsigned long long RcvBufSize;103unsigned long long RxIntMemBase;104unsigned long long RxIntMemSize;105unsigned long long RcvPartitionKey;106unsigned long long ReservedRcv[10];107unsigned long long SendCtrl;108unsigned long long SendPIOBufBase;109unsigned long long SendPIOSize;110unsigned long long SendPIOBufCnt;111unsigned long long SendPIOAvailAddr;112unsigned long long TxIntMemBase;113unsigned long long TxIntMemSize;114unsigned long long ReservedSend[9];115unsigned long long SendBufferError;116unsigned long long SendBufferErrorCONT1;117unsigned long long SendBufferErrorCONT2;118unsigned long long SendBufferErrorCONT3;119unsigned long long ReservedSBE[4];120unsigned long long RcvHdrAddr0;121unsigned long long RcvHdrAddr1;122unsigned long long RcvHdrAddr2;123unsigned long long RcvHdrAddr3;124unsigned long long RcvHdrAddr4;125unsigned long long RcvHdrAddr5;126unsigned long long RcvHdrAddr6;127unsigned long long RcvHdrAddr7;128unsigned long long RcvHdrAddr8;129unsigned long long ReservedRHA[7];130unsigned long long RcvHdrTailAddr0;131unsigned long long RcvHdrTailAddr1;132unsigned long long RcvHdrTailAddr2;133unsigned long long RcvHdrTailAddr3;134unsigned long long RcvHdrTailAddr4;135unsigned long long RcvHdrTailAddr5;136unsigned long long RcvHdrTailAddr6;137unsigned long long RcvHdrTailAddr7;138unsigned long long RcvHdrTailAddr8;139unsigned long long ReservedRHTA[7];140unsigned long long Sync; /* Software only */141unsigned long long Dump; /* Software only */142unsigned long long SimVer; /* Software only */143unsigned long long ReservedSW[5];144unsigned long long SerdesConfig0;145unsigned long long SerdesConfig1;146unsigned long long SerdesStatus;147unsigned long long XGXSConfig;148unsigned long long ReservedSW2[4];149};150151struct _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};197198#define IPATH_KREG_OFFSET(field) (offsetof( \199struct _infinipath_do_not_use_kernel_regs, field) / sizeof(u64))200#define IPATH_CREG_OFFSET(field) (offsetof( \201struct _infinipath_do_not_use_counters, field) / sizeof(u64))202203static 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/*262* These should not be used directly via ipath_write_kreg64(),263* use them with ipath_write_kreg64_port(),264*/265.kr_rcvhdraddr = IPATH_KREG_OFFSET(RcvHdrAddr0),266.kr_rcvhdrtailaddr = IPATH_KREG_OFFSET(RcvHdrTailAddr0)267};268269static 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};305306/* kr_intstatus, kr_intclear, kr_intmask bits */307#define INFINIPATH_I_RCVURG_MASK ((1U<<9)-1)308#define INFINIPATH_I_RCVURG_SHIFT 0309#define INFINIPATH_I_RCVAVAIL_MASK ((1U<<9)-1)310#define INFINIPATH_I_RCVAVAIL_SHIFT 12311312/* kr_hwerrclear, kr_hwerrmask, kr_hwerrstatus, bits */313#define INFINIPATH_HWE_HTCMEMPARITYERR_SHIFT 0314#define INFINIPATH_HWE_HTCMEMPARITYERR_MASK 0x3FFFFFULL315#define INFINIPATH_HWE_HTCLNKABYTE0CRCERR 0x0000000000800000ULL316#define INFINIPATH_HWE_HTCLNKABYTE1CRCERR 0x0000000001000000ULL317#define INFINIPATH_HWE_HTCLNKBBYTE0CRCERR 0x0000000002000000ULL318#define INFINIPATH_HWE_HTCLNKBBYTE1CRCERR 0x0000000004000000ULL319#define INFINIPATH_HWE_HTCMISCERR4 0x0000000008000000ULL320#define INFINIPATH_HWE_HTCMISCERR5 0x0000000010000000ULL321#define INFINIPATH_HWE_HTCMISCERR6 0x0000000020000000ULL322#define INFINIPATH_HWE_HTCMISCERR7 0x0000000040000000ULL323#define INFINIPATH_HWE_HTCBUSTREQPARITYERR 0x0000000080000000ULL324#define INFINIPATH_HWE_HTCBUSTRESPPARITYERR 0x0000000100000000ULL325#define INFINIPATH_HWE_HTCBUSIREQPARITYERR 0x0000000200000000ULL326#define INFINIPATH_HWE_COREPLL_FBSLIP 0x0080000000000000ULL327#define INFINIPATH_HWE_COREPLL_RFSLIP 0x0100000000000000ULL328#define INFINIPATH_HWE_HTBPLL_FBSLIP 0x0200000000000000ULL329#define INFINIPATH_HWE_HTBPLL_RFSLIP 0x0400000000000000ULL330#define INFINIPATH_HWE_HTAPLL_FBSLIP 0x0800000000000000ULL331#define INFINIPATH_HWE_HTAPLL_RFSLIP 0x1000000000000000ULL332#define INFINIPATH_HWE_SERDESPLLFAILED 0x2000000000000000ULL333334#define IBA6110_IBCS_LINKTRAININGSTATE_MASK 0xf335#define IBA6110_IBCS_LINKSTATE_SHIFT 4336337/* kr_extstatus bits */338#define INFINIPATH_EXTS_FREQSEL 0x2339#define INFINIPATH_EXTS_SERDESSEL 0x4340#define INFINIPATH_EXTS_MEMBIST_ENDTEST 0x0000000000004000341#define INFINIPATH_EXTS_MEMBIST_CORRECT 0x0000000000008000342343344/* TID entries (memory), HT-only */345#define INFINIPATH_RT_ADDR_MASK 0xFFFFFFFFFFULL /* 40 bits valid */346#define INFINIPATH_RT_VALID 0x8000000000000000ULL347#define INFINIPATH_RT_ADDR_SHIFT 0348#define INFINIPATH_RT_BUFSIZE_MASK 0x3FFFULL349#define INFINIPATH_RT_BUFSIZE_SHIFT 48350351#define INFINIPATH_R_INTRAVAIL_SHIFT 16352#define INFINIPATH_R_TAILUPD_SHIFT 31353354/* kr_xgxsconfig bits */355#define INFINIPATH_XGXS_RESET 0x7ULL356357/*358* masks and bits that are different in different chips, or present only359* in one360*/361static const ipath_err_t infinipath_hwe_htcmemparityerr_mask =362INFINIPATH_HWE_HTCMEMPARITYERR_MASK;363static const ipath_err_t infinipath_hwe_htcmemparityerr_shift =364INFINIPATH_HWE_HTCMEMPARITYERR_SHIFT;365366static const ipath_err_t infinipath_hwe_htclnkabyte0crcerr =367INFINIPATH_HWE_HTCLNKABYTE0CRCERR;368static const ipath_err_t infinipath_hwe_htclnkabyte1crcerr =369INFINIPATH_HWE_HTCLNKABYTE1CRCERR;370static const ipath_err_t infinipath_hwe_htclnkbbyte0crcerr =371INFINIPATH_HWE_HTCLNKBBYTE0CRCERR;372static const ipath_err_t infinipath_hwe_htclnkbbyte1crcerr =373INFINIPATH_HWE_HTCLNKBBYTE1CRCERR;374375#define _IPATH_GPIO_SDA_NUM 1376#define _IPATH_GPIO_SCL_NUM 0377378#define IPATH_GPIO_SDA \379(1ULL << (_IPATH_GPIO_SDA_NUM+INFINIPATH_EXTC_GPIOOE_SHIFT))380#define IPATH_GPIO_SCL \381(1ULL << (_IPATH_GPIO_SCL_NUM+INFINIPATH_EXTC_GPIOOE_SHIFT))382383/* keep the code below somewhat more readable; not used elsewhere */384#define _IPATH_HTLINK0_CRCBITS (infinipath_hwe_htclnkabyte0crcerr | \385infinipath_hwe_htclnkabyte1crcerr)386#define _IPATH_HTLINK1_CRCBITS (infinipath_hwe_htclnkbbyte0crcerr | \387infinipath_hwe_htclnkbbyte1crcerr)388#define _IPATH_HTLANE0_CRCBITS (infinipath_hwe_htclnkabyte0crcerr | \389infinipath_hwe_htclnkbbyte0crcerr)390#define _IPATH_HTLANE1_CRCBITS (infinipath_hwe_htclnkabyte1crcerr | \391infinipath_hwe_htclnkbbyte1crcerr)392393static void hwerr_crcbits(struct ipath_devdata *dd, ipath_err_t hwerrs,394char *msg, size_t msgl)395{396char bitsmsg[64];397ipath_err_t crcbits = hwerrs &398(_IPATH_HTLINK0_CRCBITS | _IPATH_HTLINK1_CRCBITS);399/* don't check if 8bit HT */400if (dd->ipath_flags & IPATH_8BIT_IN_HT0)401crcbits &= ~infinipath_hwe_htclnkabyte1crcerr;402/* don't check if 8bit HT */403if (dd->ipath_flags & IPATH_8BIT_IN_HT1)404crcbits &= ~infinipath_hwe_htclnkbbyte1crcerr;405/*406* we'll want to ignore link errors on link that is407* not in use, if any. For now, complain about both408*/409if (crcbits) {410u16 ctrl0, ctrl1;411snprintf(bitsmsg, sizeof bitsmsg,412"[HT%s lane %s CRC (%llx); powercycle to completely clear]",413!(crcbits & _IPATH_HTLINK1_CRCBITS) ?414"0 (A)" : (!(crcbits & _IPATH_HTLINK0_CRCBITS)415? "1 (B)" : "0+1 (A+B)"),416!(crcbits & _IPATH_HTLANE1_CRCBITS) ? "0"417: (!(crcbits & _IPATH_HTLANE0_CRCBITS) ? "1" :418"0+1"), (unsigned long long) crcbits);419strlcat(msg, bitsmsg, msgl);420421/*422* print extra info for debugging. slave/primary423* config word 4, 8 (link control 0, 1)424*/425426if (pci_read_config_word(dd->pcidev,427dd->ipath_ht_slave_off + 0x4,428&ctrl0))429dev_info(&dd->pcidev->dev, "Couldn't read "430"linkctrl0 of slave/primary "431"config block\n");432else if (!(ctrl0 & 1 << 6))433/* not if EOC bit set */434ipath_dbg("HT linkctrl0 0x%x%s%s\n", ctrl0,435((ctrl0 >> 8) & 7) ? " CRC" : "",436((ctrl0 >> 4) & 1) ? "linkfail" :437"");438if (pci_read_config_word(dd->pcidev,439dd->ipath_ht_slave_off + 0x8,440&ctrl1))441dev_info(&dd->pcidev->dev, "Couldn't read "442"linkctrl1 of slave/primary "443"config block\n");444else if (!(ctrl1 & 1 << 6))445/* not if EOC bit set */446ipath_dbg("HT linkctrl1 0x%x%s%s\n", ctrl1,447((ctrl1 >> 8) & 7) ? " CRC" : "",448((ctrl1 >> 4) & 1) ? "linkfail" :449"");450451/* disable until driver reloaded */452dd->ipath_hwerrmask &= ~crcbits;453ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrmask,454dd->ipath_hwerrmask);455ipath_dbg("HT crc errs: %s\n", msg);456} else457ipath_dbg("ignoring HT crc errors 0x%llx, "458"not in use\n", (unsigned long long)459(hwerrs & (_IPATH_HTLINK0_CRCBITS |460_IPATH_HTLINK1_CRCBITS)));461}462463/* 6110 specific hardware errors... */464static const struct ipath_hwerror_msgs ipath_6110_hwerror_msgs[] = {465INFINIPATH_HWE_MSG(HTCBUSIREQPARITYERR, "HTC Ireq Parity"),466INFINIPATH_HWE_MSG(HTCBUSTREQPARITYERR, "HTC Treq Parity"),467INFINIPATH_HWE_MSG(HTCBUSTRESPPARITYERR, "HTC Tresp Parity"),468INFINIPATH_HWE_MSG(HTCMISCERR5, "HT core Misc5"),469INFINIPATH_HWE_MSG(HTCMISCERR6, "HT core Misc6"),470INFINIPATH_HWE_MSG(HTCMISCERR7, "HT core Misc7"),471INFINIPATH_HWE_MSG(RXDSYNCMEMPARITYERR, "Rx Dsync"),472INFINIPATH_HWE_MSG(SERDESPLLFAILED, "SerDes PLL"),473};474475#define TXE_PIO_PARITY ((INFINIPATH_HWE_TXEMEMPARITYERR_PIOBUF | \476INFINIPATH_HWE_TXEMEMPARITYERR_PIOPBC) \477<< INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT)478#define RXE_EAGER_PARITY (INFINIPATH_HWE_RXEMEMPARITYERR_EAGERTID \479<< INFINIPATH_HWE_RXEMEMPARITYERR_SHIFT)480481static void ipath_ht_txe_recover(struct ipath_devdata *dd)482{483++ipath_stats.sps_txeparity;484dev_info(&dd->pcidev->dev,485"Recovering from TXE PIO parity error\n");486}487488489/**490* ipath_ht_handle_hwerrors - display hardware errors.491* @dd: the infinipath device492* @msg: the output buffer493* @msgl: the size of the output buffer494*495* Use same msg buffer as regular errors to avoid excessive stack496* use. Most hardware errors are catastrophic, but for right now,497* we'll print them and continue. We reuse the same message buffer as498* ipath_handle_errors() to avoid excessive stack usage.499*/500static void ipath_ht_handle_hwerrors(struct ipath_devdata *dd, char *msg,501size_t msgl)502{503ipath_err_t hwerrs;504u32 bits, ctrl;505int isfatal = 0;506char bitsmsg[64];507int log_idx;508509hwerrs = ipath_read_kreg64(dd, dd->ipath_kregs->kr_hwerrstatus);510511if (!hwerrs) {512ipath_cdbg(VERBOSE, "Called but no hardware errors set\n");513/*514* better than printing cofusing messages515* This seems to be related to clearing the crc error, or516* the pll error during init.517*/518goto bail;519} else if (hwerrs == -1LL) {520ipath_dev_err(dd, "Read of hardware error status failed "521"(all bits set); ignoring\n");522goto bail;523}524ipath_stats.sps_hwerrs++;525526/* Always clear the error status register, except MEMBISTFAIL,527* regardless of whether we continue or stop using the chip.528* We want that set so we know it failed, even across driver reload.529* We'll still ignore it in the hwerrmask. We do this partly for530* diagnostics, but also for support */531ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrclear,532hwerrs&~INFINIPATH_HWE_MEMBISTFAILED);533534hwerrs &= dd->ipath_hwerrmask;535536/* We log some errors to EEPROM, check if we have any of those. */537for (log_idx = 0; log_idx < IPATH_EEP_LOG_CNT; ++log_idx)538if (hwerrs & dd->ipath_eep_st_masks[log_idx].hwerrs_to_log)539ipath_inc_eeprom_err(dd, log_idx, 1);540541/*542* make sure we get this much out, unless told to be quiet,543* it's a parity error we may recover from,544* or it's occurred within the last 5 seconds545*/546if ((hwerrs & ~(dd->ipath_lasthwerror | TXE_PIO_PARITY |547RXE_EAGER_PARITY)) ||548(ipath_debug & __IPATH_VERBDBG))549dev_info(&dd->pcidev->dev, "Hardware error: hwerr=0x%llx "550"(cleared)\n", (unsigned long long) hwerrs);551dd->ipath_lasthwerror |= hwerrs;552553if (hwerrs & ~dd->ipath_hwe_bitsextant)554ipath_dev_err(dd, "hwerror interrupt with unknown errors "555"%llx set\n", (unsigned long long)556(hwerrs & ~dd->ipath_hwe_bitsextant));557558ctrl = ipath_read_kreg32(dd, dd->ipath_kregs->kr_control);559if ((ctrl & INFINIPATH_C_FREEZEMODE) && !ipath_diag_inuse) {560/*561* parity errors in send memory are recoverable,562* just cancel the send (if indicated in * sendbuffererror),563* count the occurrence, unfreeze (if no other handled564* hardware error bits are set), and continue. They can565* occur if a processor speculative read is done to the PIO566* buffer while we are sending a packet, for example.567*/568if (hwerrs & TXE_PIO_PARITY) {569ipath_ht_txe_recover(dd);570hwerrs &= ~TXE_PIO_PARITY;571}572573if (!hwerrs) {574ipath_dbg("Clearing freezemode on ignored or "575"recovered hardware error\n");576ipath_clear_freeze(dd);577}578}579580*msg = '\0';581582/*583* may someday want to decode into which bits are which584* functional area for parity errors, etc.585*/586if (hwerrs & (infinipath_hwe_htcmemparityerr_mask587<< INFINIPATH_HWE_HTCMEMPARITYERR_SHIFT)) {588bits = (u32) ((hwerrs >>589INFINIPATH_HWE_HTCMEMPARITYERR_SHIFT) &590INFINIPATH_HWE_HTCMEMPARITYERR_MASK);591snprintf(bitsmsg, sizeof bitsmsg, "[HTC Parity Errs %x] ",592bits);593strlcat(msg, bitsmsg, msgl);594}595596ipath_format_hwerrors(hwerrs,597ipath_6110_hwerror_msgs,598sizeof(ipath_6110_hwerror_msgs) /599sizeof(ipath_6110_hwerror_msgs[0]),600msg, msgl);601602if (hwerrs & (_IPATH_HTLINK0_CRCBITS | _IPATH_HTLINK1_CRCBITS))603hwerr_crcbits(dd, hwerrs, msg, msgl);604605if (hwerrs & INFINIPATH_HWE_MEMBISTFAILED) {606strlcat(msg, "[Memory BIST test failed, InfiniPath hardware unusable]",607msgl);608/* ignore from now on, so disable until driver reloaded */609dd->ipath_hwerrmask &= ~INFINIPATH_HWE_MEMBISTFAILED;610ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrmask,611dd->ipath_hwerrmask);612}613#define _IPATH_PLL_FAIL (INFINIPATH_HWE_COREPLL_FBSLIP | \614INFINIPATH_HWE_COREPLL_RFSLIP | \615INFINIPATH_HWE_HTBPLL_FBSLIP | \616INFINIPATH_HWE_HTBPLL_RFSLIP | \617INFINIPATH_HWE_HTAPLL_FBSLIP | \618INFINIPATH_HWE_HTAPLL_RFSLIP)619620if (hwerrs & _IPATH_PLL_FAIL) {621snprintf(bitsmsg, sizeof bitsmsg,622"[PLL failed (%llx), InfiniPath hardware unusable]",623(unsigned long long) (hwerrs & _IPATH_PLL_FAIL));624strlcat(msg, bitsmsg, msgl);625/* ignore from now on, so disable until driver reloaded */626dd->ipath_hwerrmask &= ~(hwerrs & _IPATH_PLL_FAIL);627ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrmask,628dd->ipath_hwerrmask);629}630631if (hwerrs & INFINIPATH_HWE_SERDESPLLFAILED) {632/*633* If it occurs, it is left masked since the eternal634* interface is unused635*/636dd->ipath_hwerrmask &= ~INFINIPATH_HWE_SERDESPLLFAILED;637ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrmask,638dd->ipath_hwerrmask);639}640641if (hwerrs) {642/*643* if any set that we aren't ignoring; only644* make the complaint once, in case it's stuck645* or recurring, and we get here multiple646* times.647* force link down, so switch knows, and648* LEDs are turned off649*/650if (dd->ipath_flags & IPATH_INITTED) {651ipath_set_linkstate(dd, IPATH_IB_LINKDOWN);652ipath_setup_ht_setextled(dd,653INFINIPATH_IBCS_L_STATE_DOWN,654INFINIPATH_IBCS_LT_STATE_DISABLED);655ipath_dev_err(dd, "Fatal Hardware Error (freeze "656"mode), no longer usable, SN %.16s\n",657dd->ipath_serial);658isfatal = 1;659}660*dd->ipath_statusp &= ~IPATH_STATUS_IB_READY;661/* mark as having had error */662*dd->ipath_statusp |= IPATH_STATUS_HWERROR;663/*664* mark as not usable, at a minimum until driver665* is reloaded, probably until reboot, since no666* other reset is possible.667*/668dd->ipath_flags &= ~IPATH_INITTED;669}670else671*msg = 0; /* recovered from all of them */672if (*msg)673ipath_dev_err(dd, "%s hardware error\n", msg);674if (isfatal && !ipath_diag_inuse && dd->ipath_freezemsg)675/*676* for status file; if no trailing brace is copied,677* we'll know it was truncated.678*/679snprintf(dd->ipath_freezemsg,680dd->ipath_freezelen, "{%s}", msg);681682bail:;683}684685/**686* ipath_ht_boardname - fill in the board name687* @dd: the infinipath device688* @name: the output buffer689* @namelen: the size of the output buffer690*691* fill in the board name, based on the board revision register692*/693static int ipath_ht_boardname(struct ipath_devdata *dd, char *name,694size_t namelen)695{696char *n = NULL;697u8 boardrev = dd->ipath_boardrev;698int ret = 0;699700switch (boardrev) {701case 5:702/*703* original production board; two production levels, with704* different serial number ranges. See ipath_ht_early_init() for705* case where we enable IPATH_GPIO_INTR for later serial # range.706* Original 112* serial number is no longer supported.707*/708n = "InfiniPath_QHT7040";709break;710case 7:711/* small form factor production board */712n = "InfiniPath_QHT7140";713break;714default: /* don't know, just print the number */715ipath_dev_err(dd, "Don't yet know about board "716"with ID %u\n", boardrev);717snprintf(name, namelen, "Unknown_InfiniPath_QHT7xxx_%u",718boardrev);719break;720}721if (n)722snprintf(name, namelen, "%s", n);723724if (ret) {725ipath_dev_err(dd, "Unsupported InfiniPath board %s!\n", name);726goto bail;727}728if (dd->ipath_majrev != 3 || (dd->ipath_minrev < 2 ||729dd->ipath_minrev > 4)) {730/*731* This version of the driver only supports Rev 3.2 - 3.4732*/733ipath_dev_err(dd,734"Unsupported InfiniPath hardware revision %u.%u!\n",735dd->ipath_majrev, dd->ipath_minrev);736ret = 1;737goto bail;738}739/*740* pkt/word counters are 32 bit, and therefore wrap fast enough741* that we snapshot them from a timer, and maintain 64 bit shadow742* copies743*/744dd->ipath_flags |= IPATH_32BITCOUNTERS;745dd->ipath_flags |= IPATH_GPIO_INTR;746if (dd->ipath_lbus_speed != 800)747ipath_dev_err(dd,748"Incorrectly configured for HT @ %uMHz\n",749dd->ipath_lbus_speed);750751/*752* set here, not in ipath_init_*_funcs because we have to do753* it after we can read chip registers.754*/755dd->ipath_ureg_align =756ipath_read_kreg32(dd, dd->ipath_kregs->kr_pagealign);757758bail:759return ret;760}761762static void ipath_check_htlink(struct ipath_devdata *dd)763{764u8 linkerr, link_off, i;765766for (i = 0; i < 2; i++) {767link_off = dd->ipath_ht_slave_off + i * 4 + 0xd;768if (pci_read_config_byte(dd->pcidev, link_off, &linkerr))769dev_info(&dd->pcidev->dev, "Couldn't read "770"linkerror%d of HT slave/primary block\n",771i);772else if (linkerr & 0xf0) {773ipath_cdbg(VERBOSE, "HT linkerr%d bits 0x%x set, "774"clearing\n", linkerr >> 4, i);775/*776* writing the linkerr bits that are set should777* clear them778*/779if (pci_write_config_byte(dd->pcidev, link_off,780linkerr))781ipath_dbg("Failed write to clear HT "782"linkerror%d\n", i);783if (pci_read_config_byte(dd->pcidev, link_off,784&linkerr))785dev_info(&dd->pcidev->dev,786"Couldn't reread linkerror%d of "787"HT slave/primary block\n", i);788else if (linkerr & 0xf0)789dev_info(&dd->pcidev->dev,790"HT linkerror%d bits 0x%x "791"couldn't be cleared\n",792i, linkerr >> 4);793}794}795}796797static int ipath_setup_ht_reset(struct ipath_devdata *dd)798{799ipath_dbg("No reset possible for this InfiniPath hardware\n");800return 0;801}802803#define HT_INTR_DISC_CONFIG 0x80 /* HT interrupt and discovery cap */804#define HT_INTR_REG_INDEX 2 /* intconfig requires indirect accesses */805806/*807* Bits 13-15 of command==0 is slave/primary block. Clear any HT CRC808* errors. We only bother to do this at load time, because it's OK if809* it happened before we were loaded (first time after boot/reset),810* but any time after that, it's fatal anyway. Also need to not check811* for upper byte errors if we are in 8 bit mode, so figure out812* our width. For now, at least, also complain if it's 8 bit.813*/814static void slave_or_pri_blk(struct ipath_devdata *dd, struct pci_dev *pdev,815int pos, u8 cap_type)816{817u8 linkwidth = 0, linkerr, link_a_b_off, link_off;818u16 linkctrl = 0;819int i;820821dd->ipath_ht_slave_off = pos;822/* command word, master_host bit */823/* master host || slave */824if ((cap_type >> 2) & 1)825link_a_b_off = 4;826else827link_a_b_off = 0;828ipath_cdbg(VERBOSE, "HT%u (Link %c) connected to processor\n",829link_a_b_off ? 1 : 0,830link_a_b_off ? 'B' : 'A');831832link_a_b_off += pos;833834/*835* check both link control registers; clear both HT CRC sets if836* necessary.837*/838for (i = 0; i < 2; i++) {839link_off = pos + i * 4 + 0x4;840if (pci_read_config_word(pdev, link_off, &linkctrl))841ipath_dev_err(dd, "Couldn't read HT link control%d "842"register\n", i);843else if (linkctrl & (0xf << 8)) {844ipath_cdbg(VERBOSE, "Clear linkctrl%d CRC Error "845"bits %x\n", i, linkctrl & (0xf << 8));846/*847* now write them back to clear the error.848*/849pci_write_config_word(pdev, link_off,850linkctrl & (0xf << 8));851}852}853854/*855* As with HT CRC bits, same for protocol errors that might occur856* during boot.857*/858for (i = 0; i < 2; i++) {859link_off = pos + i * 4 + 0xd;860if (pci_read_config_byte(pdev, link_off, &linkerr))861dev_info(&pdev->dev, "Couldn't read linkerror%d "862"of HT slave/primary block\n", i);863else if (linkerr & 0xf0) {864ipath_cdbg(VERBOSE, "HT linkerr%d bits 0x%x set, "865"clearing\n", linkerr >> 4, i);866/*867* writing the linkerr bits that are set will clear868* them869*/870if (pci_write_config_byte871(pdev, link_off, linkerr))872ipath_dbg("Failed write to clear HT "873"linkerror%d\n", i);874if (pci_read_config_byte(pdev, link_off, &linkerr))875dev_info(&pdev->dev, "Couldn't reread "876"linkerror%d of HT slave/primary "877"block\n", i);878else if (linkerr & 0xf0)879dev_info(&pdev->dev, "HT linkerror%d bits "880"0x%x couldn't be cleared\n",881i, linkerr >> 4);882}883}884885/*886* this is just for our link to the host, not devices connected887* through tunnel.888*/889890if (pci_read_config_byte(pdev, link_a_b_off + 7, &linkwidth))891ipath_dev_err(dd, "Couldn't read HT link width "892"config register\n");893else {894u32 width;895switch (linkwidth & 7) {896case 5:897width = 4;898break;899case 4:900width = 2;901break;902case 3:903width = 32;904break;905case 1:906width = 16;907break;908case 0:909default: /* if wrong, assume 8 bit */910width = 8;911break;912}913914dd->ipath_lbus_width = width;915916if (linkwidth != 0x11) {917ipath_dev_err(dd, "Not configured for 16 bit HT "918"(%x)\n", linkwidth);919if (!(linkwidth & 0xf)) {920ipath_dbg("Will ignore HT lane1 errors\n");921dd->ipath_flags |= IPATH_8BIT_IN_HT0;922}923}924}925926/*927* this is just for our link to the host, not devices connected928* through tunnel.929*/930if (pci_read_config_byte(pdev, link_a_b_off + 0xd, &linkwidth))931ipath_dev_err(dd, "Couldn't read HT link frequency "932"config register\n");933else {934u32 speed;935switch (linkwidth & 0xf) {936case 6:937speed = 1000;938break;939case 5:940speed = 800;941break;942case 4:943speed = 600;944break;945case 3:946speed = 500;947break;948case 2:949speed = 400;950break;951case 1:952speed = 300;953break;954default:955/*956* assume reserved and vendor-specific are 200...957*/958case 0:959speed = 200;960break;961}962dd->ipath_lbus_speed = speed;963}964965snprintf(dd->ipath_lbus_info, sizeof(dd->ipath_lbus_info),966"HyperTransport,%uMHz,x%u\n",967dd->ipath_lbus_speed,968dd->ipath_lbus_width);969}970971static int ipath_ht_intconfig(struct ipath_devdata *dd)972{973int ret;974975if (dd->ipath_intconfig) {976ipath_write_kreg(dd, dd->ipath_kregs->kr_interruptconfig,977dd->ipath_intconfig); /* interrupt address */978ret = 0;979} else {980ipath_dev_err(dd, "No interrupts enabled, couldn't setup "981"interrupt address\n");982ret = -EINVAL;983}984985return ret;986}987988static void ipath_ht_irq_update(struct pci_dev *dev, int irq,989struct ht_irq_msg *msg)990{991struct ipath_devdata *dd = pci_get_drvdata(dev);992u64 prev_intconfig = dd->ipath_intconfig;993994dd->ipath_intconfig = msg->address_lo;995dd->ipath_intconfig |= ((u64) msg->address_hi) << 32;996997/*998* If the previous value of dd->ipath_intconfig is zero, we're999* getting configured for the first time, and must not program the1000* intconfig register here (it will be programmed later, when the1001* hardware is ready). Otherwise, we should.1002*/1003if (prev_intconfig)1004ipath_ht_intconfig(dd);1005}10061007/**1008* ipath_setup_ht_config - setup the interruptconfig register1009* @dd: the infinipath device1010* @pdev: the PCI device1011*1012* setup the interruptconfig register from the HT config info.1013* Also clear CRC errors in HT linkcontrol, if necessary.1014* This is done only for the real hardware. It is done before1015* chip address space is initted, so can't touch infinipath registers1016*/1017static int ipath_setup_ht_config(struct ipath_devdata *dd,1018struct pci_dev *pdev)1019{1020int pos, ret;10211022ret = __ht_create_irq(pdev, 0, ipath_ht_irq_update);1023if (ret < 0) {1024ipath_dev_err(dd, "Couldn't create interrupt handler: "1025"err %d\n", ret);1026goto bail;1027}1028dd->ipath_irq = ret;1029ret = 0;10301031/*1032* Handle clearing CRC errors in linkctrl register if necessary. We1033* do this early, before we ever enable errors or hardware errors,1034* mostly to avoid causing the chip to enter freeze mode.1035*/1036pos = pci_find_capability(pdev, PCI_CAP_ID_HT);1037if (!pos) {1038ipath_dev_err(dd, "Couldn't find HyperTransport "1039"capability; no interrupts\n");1040ret = -ENODEV;1041goto bail;1042}1043do {1044u8 cap_type;10451046/*1047* The HT capability type byte is 3 bytes after the1048* capability byte.1049*/1050if (pci_read_config_byte(pdev, pos + 3, &cap_type)) {1051dev_info(&pdev->dev, "Couldn't read config "1052"command @ %d\n", pos);1053continue;1054}1055if (!(cap_type & 0xE0))1056slave_or_pri_blk(dd, pdev, pos, cap_type);1057} while ((pos = pci_find_next_capability(pdev, pos,1058PCI_CAP_ID_HT)));10591060dd->ipath_flags |= IPATH_SWAP_PIOBUFS;10611062bail:1063return ret;1064}10651066/**1067* ipath_setup_ht_cleanup - clean up any per-chip chip-specific stuff1068* @dd: the infinipath device1069*1070* Called during driver unload.1071* This is currently a nop for the HT chip, not for all chips1072*/1073static void ipath_setup_ht_cleanup(struct ipath_devdata *dd)1074{1075}10761077/**1078* ipath_setup_ht_setextled - set the state of the two external LEDs1079* @dd: the infinipath device1080* @lst: the L state1081* @ltst: the LT state1082*1083* Set the state of the two external LEDs, to indicate physical and1084* logical state of IB link. For this chip (at least with recommended1085* board pinouts), LED1 is Green (physical state), and LED2 is Yellow1086* (logical state)1087*1088* Note: We try to match the Mellanox HCA LED behavior as best1089* we can. Green indicates physical link state is OK (something is1090* plugged in, and we can train).1091* Amber indicates the link is logically up (ACTIVE).1092* Mellanox further blinks the amber LED to indicate data packet1093* activity, but we have no hardware support for that, so it would1094* require waking up every 10-20 msecs and checking the counters1095* on the chip, and then turning the LED off if appropriate. That's1096* visible overhead, so not something we will do.1097*1098*/1099static void ipath_setup_ht_setextled(struct ipath_devdata *dd,1100u64 lst, u64 ltst)1101{1102u64 extctl;1103unsigned long flags = 0;11041105/* the diags use the LED to indicate diag info, so we leave1106* the external LED alone when the diags are running */1107if (ipath_diag_inuse)1108return;11091110/* Allow override of LED display for, e.g. Locating system in rack */1111if (dd->ipath_led_override) {1112ltst = (dd->ipath_led_override & IPATH_LED_PHYS)1113? INFINIPATH_IBCS_LT_STATE_LINKUP1114: INFINIPATH_IBCS_LT_STATE_DISABLED;1115lst = (dd->ipath_led_override & IPATH_LED_LOG)1116? INFINIPATH_IBCS_L_STATE_ACTIVE1117: INFINIPATH_IBCS_L_STATE_DOWN;1118}11191120spin_lock_irqsave(&dd->ipath_gpio_lock, flags);1121/*1122* start by setting both LED control bits to off, then turn1123* on the appropriate bit(s).1124*/1125if (dd->ipath_boardrev == 8) { /* LS/X-1 uses different pins */1126/*1127* major difference is that INFINIPATH_EXTC_LEDGBLERR_OFF1128* is inverted, because it is normally used to indicate1129* a hardware fault at reset, if there were errors1130*/1131extctl = (dd->ipath_extctrl & ~INFINIPATH_EXTC_LEDGBLOK_ON)1132| INFINIPATH_EXTC_LEDGBLERR_OFF;1133if (ltst == INFINIPATH_IBCS_LT_STATE_LINKUP)1134extctl &= ~INFINIPATH_EXTC_LEDGBLERR_OFF;1135if (lst == INFINIPATH_IBCS_L_STATE_ACTIVE)1136extctl |= INFINIPATH_EXTC_LEDGBLOK_ON;1137}1138else {1139extctl = dd->ipath_extctrl &1140~(INFINIPATH_EXTC_LED1PRIPORT_ON |1141INFINIPATH_EXTC_LED2PRIPORT_ON);1142if (ltst == INFINIPATH_IBCS_LT_STATE_LINKUP)1143extctl |= INFINIPATH_EXTC_LED1PRIPORT_ON;1144if (lst == INFINIPATH_IBCS_L_STATE_ACTIVE)1145extctl |= INFINIPATH_EXTC_LED2PRIPORT_ON;1146}1147dd->ipath_extctrl = extctl;1148ipath_write_kreg(dd, dd->ipath_kregs->kr_extctrl, extctl);1149spin_unlock_irqrestore(&dd->ipath_gpio_lock, flags);1150}11511152static void ipath_init_ht_variables(struct ipath_devdata *dd)1153{1154/*1155* setup the register offsets, since they are different for each1156* chip1157*/1158dd->ipath_kregs = &ipath_ht_kregs;1159dd->ipath_cregs = &ipath_ht_cregs;11601161dd->ipath_gpio_sda_num = _IPATH_GPIO_SDA_NUM;1162dd->ipath_gpio_scl_num = _IPATH_GPIO_SCL_NUM;1163dd->ipath_gpio_sda = IPATH_GPIO_SDA;1164dd->ipath_gpio_scl = IPATH_GPIO_SCL;11651166/*1167* Fill in data for field-values that change in newer chips.1168* We dynamically specify only the mask for LINKTRAININGSTATE1169* and only the shift for LINKSTATE, as they are the only ones1170* that change. Also precalculate the 3 link states of interest1171* and the combined mask.1172*/1173dd->ibcs_ls_shift = IBA6110_IBCS_LINKSTATE_SHIFT;1174dd->ibcs_lts_mask = IBA6110_IBCS_LINKTRAININGSTATE_MASK;1175dd->ibcs_mask = (INFINIPATH_IBCS_LINKSTATE_MASK <<1176dd->ibcs_ls_shift) | dd->ibcs_lts_mask;1177dd->ib_init = (INFINIPATH_IBCS_LT_STATE_LINKUP <<1178INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) |1179(INFINIPATH_IBCS_L_STATE_INIT << dd->ibcs_ls_shift);1180dd->ib_arm = (INFINIPATH_IBCS_LT_STATE_LINKUP <<1181INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) |1182(INFINIPATH_IBCS_L_STATE_ARM << dd->ibcs_ls_shift);1183dd->ib_active = (INFINIPATH_IBCS_LT_STATE_LINKUP <<1184INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) |1185(INFINIPATH_IBCS_L_STATE_ACTIVE << dd->ibcs_ls_shift);11861187/*1188* Fill in data for ibcc field-values that change in newer chips.1189* We dynamically specify only the mask for LINKINITCMD1190* and only the shift for LINKCMD and MAXPKTLEN, as they are1191* the only ones that change.1192*/1193dd->ibcc_lic_mask = INFINIPATH_IBCC_LINKINITCMD_MASK;1194dd->ibcc_lc_shift = INFINIPATH_IBCC_LINKCMD_SHIFT;1195dd->ibcc_mpl_shift = INFINIPATH_IBCC_MAXPKTLEN_SHIFT;11961197/* Fill in shifts for RcvCtrl. */1198dd->ipath_r_portenable_shift = INFINIPATH_R_PORTENABLE_SHIFT;1199dd->ipath_r_intravail_shift = INFINIPATH_R_INTRAVAIL_SHIFT;1200dd->ipath_r_tailupd_shift = INFINIPATH_R_TAILUPD_SHIFT;1201dd->ipath_r_portcfg_shift = 0; /* Not on IBA6110 */12021203dd->ipath_i_bitsextant =1204(INFINIPATH_I_RCVURG_MASK << INFINIPATH_I_RCVURG_SHIFT) |1205(INFINIPATH_I_RCVAVAIL_MASK <<1206INFINIPATH_I_RCVAVAIL_SHIFT) |1207INFINIPATH_I_ERROR | INFINIPATH_I_SPIOSENT |1208INFINIPATH_I_SPIOBUFAVAIL | INFINIPATH_I_GPIO;12091210dd->ipath_e_bitsextant =1211INFINIPATH_E_RFORMATERR | INFINIPATH_E_RVCRC |1212INFINIPATH_E_RICRC | INFINIPATH_E_RMINPKTLEN |1213INFINIPATH_E_RMAXPKTLEN | INFINIPATH_E_RLONGPKTLEN |1214INFINIPATH_E_RSHORTPKTLEN | INFINIPATH_E_RUNEXPCHAR |1215INFINIPATH_E_RUNSUPVL | INFINIPATH_E_REBP |1216INFINIPATH_E_RIBFLOW | INFINIPATH_E_RBADVERSION |1217INFINIPATH_E_RRCVEGRFULL | INFINIPATH_E_RRCVHDRFULL |1218INFINIPATH_E_RBADTID | INFINIPATH_E_RHDRLEN |1219INFINIPATH_E_RHDR | INFINIPATH_E_RIBLOSTLINK |1220INFINIPATH_E_SMINPKTLEN | INFINIPATH_E_SMAXPKTLEN |1221INFINIPATH_E_SUNDERRUN | INFINIPATH_E_SPKTLEN |1222INFINIPATH_E_SDROPPEDSMPPKT | INFINIPATH_E_SDROPPEDDATAPKT |1223INFINIPATH_E_SPIOARMLAUNCH | INFINIPATH_E_SUNEXPERRPKTNUM |1224INFINIPATH_E_SUNSUPVL | INFINIPATH_E_IBSTATUSCHANGED |1225INFINIPATH_E_INVALIDADDR | INFINIPATH_E_RESET |1226INFINIPATH_E_HARDWARE;12271228dd->ipath_hwe_bitsextant =1229(INFINIPATH_HWE_HTCMEMPARITYERR_MASK <<1230INFINIPATH_HWE_HTCMEMPARITYERR_SHIFT) |1231(INFINIPATH_HWE_TXEMEMPARITYERR_MASK <<1232INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT) |1233(INFINIPATH_HWE_RXEMEMPARITYERR_MASK <<1234INFINIPATH_HWE_RXEMEMPARITYERR_SHIFT) |1235INFINIPATH_HWE_HTCLNKABYTE0CRCERR |1236INFINIPATH_HWE_HTCLNKABYTE1CRCERR |1237INFINIPATH_HWE_HTCLNKBBYTE0CRCERR |1238INFINIPATH_HWE_HTCLNKBBYTE1CRCERR |1239INFINIPATH_HWE_HTCMISCERR4 |1240INFINIPATH_HWE_HTCMISCERR5 | INFINIPATH_HWE_HTCMISCERR6 |1241INFINIPATH_HWE_HTCMISCERR7 |1242INFINIPATH_HWE_HTCBUSTREQPARITYERR |1243INFINIPATH_HWE_HTCBUSTRESPPARITYERR |1244INFINIPATH_HWE_HTCBUSIREQPARITYERR |1245INFINIPATH_HWE_RXDSYNCMEMPARITYERR |1246INFINIPATH_HWE_MEMBISTFAILED |1247INFINIPATH_HWE_COREPLL_FBSLIP |1248INFINIPATH_HWE_COREPLL_RFSLIP |1249INFINIPATH_HWE_HTBPLL_FBSLIP |1250INFINIPATH_HWE_HTBPLL_RFSLIP |1251INFINIPATH_HWE_HTAPLL_FBSLIP |1252INFINIPATH_HWE_HTAPLL_RFSLIP |1253INFINIPATH_HWE_SERDESPLLFAILED |1254INFINIPATH_HWE_IBCBUSTOSPCPARITYERR |1255INFINIPATH_HWE_IBCBUSFRSPCPARITYERR;12561257dd->ipath_i_rcvavail_mask = INFINIPATH_I_RCVAVAIL_MASK;1258dd->ipath_i_rcvurg_mask = INFINIPATH_I_RCVURG_MASK;1259dd->ipath_i_rcvavail_shift = INFINIPATH_I_RCVAVAIL_SHIFT;1260dd->ipath_i_rcvurg_shift = INFINIPATH_I_RCVURG_SHIFT;12611262/*1263* EEPROM error log 0 is TXE Parity errors. 1 is RXE Parity.1264* 2 is Some Misc, 3 is reserved for future.1265*/1266dd->ipath_eep_st_masks[0].hwerrs_to_log =1267INFINIPATH_HWE_TXEMEMPARITYERR_MASK <<1268INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT;12691270dd->ipath_eep_st_masks[1].hwerrs_to_log =1271INFINIPATH_HWE_RXEMEMPARITYERR_MASK <<1272INFINIPATH_HWE_RXEMEMPARITYERR_SHIFT;12731274dd->ipath_eep_st_masks[2].errs_to_log = INFINIPATH_E_RESET;12751276dd->delay_mult = 2; /* SDR, 4X, can't change */12771278dd->ipath_link_width_supported = IB_WIDTH_1X | IB_WIDTH_4X;1279dd->ipath_link_speed_supported = IPATH_IB_SDR;1280dd->ipath_link_width_enabled = IB_WIDTH_4X;1281dd->ipath_link_speed_enabled = dd->ipath_link_speed_supported;1282/* these can't change for this chip, so set once */1283dd->ipath_link_width_active = dd->ipath_link_width_enabled;1284dd->ipath_link_speed_active = dd->ipath_link_speed_enabled;1285}12861287/**1288* ipath_ht_init_hwerrors - enable hardware errors1289* @dd: the infinipath device1290*1291* now that we have finished initializing everything that might reasonably1292* cause a hardware error, and cleared those errors bits as they occur,1293* we can enable hardware errors in the mask (potentially enabling1294* freeze mode), and enable hardware errors as errors (along with1295* everything else) in errormask1296*/1297static void ipath_ht_init_hwerrors(struct ipath_devdata *dd)1298{1299ipath_err_t val;1300u64 extsval;13011302extsval = ipath_read_kreg64(dd, dd->ipath_kregs->kr_extstatus);13031304if (!(extsval & INFINIPATH_EXTS_MEMBIST_ENDTEST))1305ipath_dev_err(dd, "MemBIST did not complete!\n");1306if (extsval & INFINIPATH_EXTS_MEMBIST_CORRECT)1307ipath_dbg("MemBIST corrected\n");13081309ipath_check_htlink(dd);13101311/* barring bugs, all hwerrors become interrupts, which can */1312val = -1LL;1313/* don't look at crc lane1 if 8 bit */1314if (dd->ipath_flags & IPATH_8BIT_IN_HT0)1315val &= ~infinipath_hwe_htclnkabyte1crcerr;1316/* don't look at crc lane1 if 8 bit */1317if (dd->ipath_flags & IPATH_8BIT_IN_HT1)1318val &= ~infinipath_hwe_htclnkbbyte1crcerr;13191320/*1321* disable RXDSYNCMEMPARITY because external serdes is unused,1322* and therefore the logic will never be used or initialized,1323* and uninitialized state will normally result in this error1324* being asserted. Similarly for the external serdess pll1325* lock signal.1326*/1327val &= ~(INFINIPATH_HWE_SERDESPLLFAILED |1328INFINIPATH_HWE_RXDSYNCMEMPARITYERR);13291330/*1331* Disable MISCERR4 because of an inversion in the HT core1332* logic checking for errors that cause this bit to be set.1333* The errata can also cause the protocol error bit to be set1334* in the HT config space linkerror register(s).1335*/1336val &= ~INFINIPATH_HWE_HTCMISCERR4;13371338/*1339* PLL ignored because unused MDIO interface has a logic problem1340*/1341if (dd->ipath_boardrev == 4 || dd->ipath_boardrev == 9)1342val &= ~INFINIPATH_HWE_SERDESPLLFAILED;1343dd->ipath_hwerrmask = val;1344}13451346134713481349/**1350* ipath_ht_bringup_serdes - bring up the serdes1351* @dd: the infinipath device1352*/1353static int ipath_ht_bringup_serdes(struct ipath_devdata *dd)1354{1355u64 val, config1;1356int ret = 0, change = 0;13571358ipath_dbg("Trying to bringup serdes\n");13591360if (ipath_read_kreg64(dd, dd->ipath_kregs->kr_hwerrstatus) &1361INFINIPATH_HWE_SERDESPLLFAILED)1362{1363ipath_dbg("At start, serdes PLL failed bit set in "1364"hwerrstatus, clearing and continuing\n");1365ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrclear,1366INFINIPATH_HWE_SERDESPLLFAILED);1367}13681369val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig0);1370config1 = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig1);13711372ipath_cdbg(VERBOSE, "Initial serdes status is config0=%llx "1373"config1=%llx, sstatus=%llx xgxs %llx\n",1374(unsigned long long) val, (unsigned long long) config1,1375(unsigned long long)1376ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesstatus),1377(unsigned long long)1378ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig));13791380/* force reset on */1381val |= INFINIPATH_SERDC0_RESET_PLL1382/* | INFINIPATH_SERDC0_RESET_MASK */1383;1384ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);1385udelay(15); /* need pll reset set at least for a bit */13861387if (val & INFINIPATH_SERDC0_RESET_PLL) {1388u64 val2 = val &= ~INFINIPATH_SERDC0_RESET_PLL;1389/* set lane resets, and tx idle, during pll reset */1390val2 |= INFINIPATH_SERDC0_RESET_MASK |1391INFINIPATH_SERDC0_TXIDLE;1392ipath_cdbg(VERBOSE, "Clearing serdes PLL reset (writing "1393"%llx)\n", (unsigned long long) val2);1394ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0,1395val2);1396/*1397* be sure chip saw it1398*/1399val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);1400/*1401* need pll reset clear at least 11 usec before lane1402* resets cleared; give it a few more1403*/1404udelay(15);1405val = val2; /* for check below */1406}14071408if (val & (INFINIPATH_SERDC0_RESET_PLL |1409INFINIPATH_SERDC0_RESET_MASK |1410INFINIPATH_SERDC0_TXIDLE)) {1411val &= ~(INFINIPATH_SERDC0_RESET_PLL |1412INFINIPATH_SERDC0_RESET_MASK |1413INFINIPATH_SERDC0_TXIDLE);1414/* clear them */1415ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0,1416val);1417}14181419val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig);1420if (val & INFINIPATH_XGXS_RESET) {1421/* normally true after boot */1422val &= ~INFINIPATH_XGXS_RESET;1423change = 1;1424}1425if (((val >> INFINIPATH_XGXS_RX_POL_SHIFT) &1426INFINIPATH_XGXS_RX_POL_MASK) != dd->ipath_rx_pol_inv ) {1427/* need to compensate for Tx inversion in partner */1428val &= ~(INFINIPATH_XGXS_RX_POL_MASK <<1429INFINIPATH_XGXS_RX_POL_SHIFT);1430val |= dd->ipath_rx_pol_inv <<1431INFINIPATH_XGXS_RX_POL_SHIFT;1432change = 1;1433}1434if (change)1435ipath_write_kreg(dd, dd->ipath_kregs->kr_xgxsconfig, val);14361437val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig0);14381439/* clear current and de-emphasis bits */1440config1 &= ~0x0ffffffff00ULL;1441/* set current to 20ma */1442config1 |= 0x00000000000ULL;1443/* set de-emphasis to -5.68dB */1444config1 |= 0x0cccc000000ULL;1445ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig1, config1);14461447ipath_cdbg(VERBOSE, "After setup: serdes status is config0=%llx "1448"config1=%llx, sstatus=%llx xgxs %llx\n",1449(unsigned long long) val, (unsigned long long) config1,1450(unsigned long long)1451ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesstatus),1452(unsigned long long)1453ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig));14541455return ret; /* for now, say we always succeeded */1456}14571458/**1459* ipath_ht_quiet_serdes - set serdes to txidle1460* @dd: the infinipath device1461* driver is being unloaded1462*/1463static void ipath_ht_quiet_serdes(struct ipath_devdata *dd)1464{1465u64 val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig0);14661467val |= INFINIPATH_SERDC0_TXIDLE;1468ipath_dbg("Setting TxIdleEn on serdes (config0 = %llx)\n",1469(unsigned long long) val);1470ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);1471}14721473/**1474* ipath_pe_put_tid - write a TID in chip1475* @dd: the infinipath device1476* @tidptr: pointer to the expected TID (in chip) to update1477* @tidtype: RCVHQ_RCV_TYPE_EAGER (1) for eager, RCVHQ_RCV_TYPE_EXPECTED (0) for expected1478* @pa: physical address of in memory buffer; ipath_tidinvalid if freeing1479*1480* This exists as a separate routine to allow for special locking etc.1481* It's used for both the full cleanup on exit, as well as the normal1482* setup and teardown.1483*/1484static void ipath_ht_put_tid(struct ipath_devdata *dd,1485u64 __iomem *tidptr, u32 type,1486unsigned long pa)1487{1488if (!dd->ipath_kregbase)1489return;14901491if (pa != dd->ipath_tidinvalid) {1492if (unlikely((pa & ~INFINIPATH_RT_ADDR_MASK))) {1493dev_info(&dd->pcidev->dev,1494"physaddr %lx has more than "1495"40 bits, using only 40!!!\n", pa);1496pa &= INFINIPATH_RT_ADDR_MASK;1497}1498if (type == RCVHQ_RCV_TYPE_EAGER)1499pa |= dd->ipath_tidtemplate;1500else {1501/* in words (fixed, full page). */1502u64 lenvalid = PAGE_SIZE >> 2;1503lenvalid <<= INFINIPATH_RT_BUFSIZE_SHIFT;1504pa |= lenvalid | INFINIPATH_RT_VALID;1505}1506}15071508writeq(pa, tidptr);1509}151015111512/**1513* ipath_ht_clear_tid - clear all TID entries for a port, expected and eager1514* @dd: the infinipath device1515* @port: the port1516*1517* Used from ipath_close(), and at chip initialization.1518*/1519static void ipath_ht_clear_tids(struct ipath_devdata *dd, unsigned port)1520{1521u64 __iomem *tidbase;1522int i;15231524if (!dd->ipath_kregbase)1525return;15261527ipath_cdbg(VERBOSE, "Invalidate TIDs for port %u\n", port);15281529/*1530* need to invalidate all of the expected TID entries for this1531* port, so we don't have valid entries that might somehow get1532* used (early in next use of this port, or through some bug)1533*/1534tidbase = (u64 __iomem *) ((char __iomem *)(dd->ipath_kregbase) +1535dd->ipath_rcvtidbase +1536port * dd->ipath_rcvtidcnt *1537sizeof(*tidbase));1538for (i = 0; i < dd->ipath_rcvtidcnt; i++)1539ipath_ht_put_tid(dd, &tidbase[i], RCVHQ_RCV_TYPE_EXPECTED,1540dd->ipath_tidinvalid);15411542tidbase = (u64 __iomem *) ((char __iomem *)(dd->ipath_kregbase) +1543dd->ipath_rcvegrbase +1544port * dd->ipath_rcvegrcnt *1545sizeof(*tidbase));15461547for (i = 0; i < dd->ipath_rcvegrcnt; i++)1548ipath_ht_put_tid(dd, &tidbase[i], RCVHQ_RCV_TYPE_EAGER,1549dd->ipath_tidinvalid);1550}15511552/**1553* ipath_ht_tidtemplate - setup constants for TID updates1554* @dd: the infinipath device1555*1556* We setup stuff that we use a lot, to avoid calculating each time1557*/1558static void ipath_ht_tidtemplate(struct ipath_devdata *dd)1559{1560dd->ipath_tidtemplate = dd->ipath_ibmaxlen >> 2;1561dd->ipath_tidtemplate <<= INFINIPATH_RT_BUFSIZE_SHIFT;1562dd->ipath_tidtemplate |= INFINIPATH_RT_VALID;15631564/*1565* work around chip errata bug 7358, by marking invalid tids1566* as having max length1567*/1568dd->ipath_tidinvalid = (-1LL & INFINIPATH_RT_BUFSIZE_MASK) <<1569INFINIPATH_RT_BUFSIZE_SHIFT;1570}15711572static int ipath_ht_early_init(struct ipath_devdata *dd)1573{1574u32 __iomem *piobuf;1575u32 pioincr, val32;1576int i;15771578/*1579* one cache line; long IB headers will spill over into received1580* buffer1581*/1582dd->ipath_rcvhdrentsize = 16;1583dd->ipath_rcvhdrsize = IPATH_DFLT_RCVHDRSIZE;15841585/*1586* For HT, we allocate a somewhat overly large eager buffer,1587* such that we can guarantee that we can receive the largest1588* packet that we can send out. To truly support a 4KB MTU,1589* we need to bump this to a large value. To date, other than1590* testing, we have never encountered an HCA that can really1591* send 4KB MTU packets, so we do not handle that (we'll get1592* errors interrupts if we ever see one).1593*/1594dd->ipath_rcvegrbufsize = dd->ipath_piosize2k;15951596/*1597* the min() check here is currently a nop, but it may not1598* always be, depending on just how we do ipath_rcvegrbufsize1599*/1600dd->ipath_ibmaxlen = min(dd->ipath_piosize2k,1601dd->ipath_rcvegrbufsize);1602dd->ipath_init_ibmaxlen = dd->ipath_ibmaxlen;1603ipath_ht_tidtemplate(dd);16041605/*1606* zero all the TID entries at startup. We do this for sanity,1607* in case of a previous driver crash of some kind, and also1608* because the chip powers up with these memories in an unknown1609* state. Use portcnt, not cfgports, since this is for the1610* full chip, not for current (possibly different) configuration1611* value.1612* Chip Errata bug 64471613*/1614for (val32 = 0; val32 < dd->ipath_portcnt; val32++)1615ipath_ht_clear_tids(dd, val32);16161617/*1618* write the pbc of each buffer, to be sure it's initialized, then1619* cancel all the buffers, and also abort any packets that might1620* have been in flight for some reason (the latter is for driver1621* unload/reload, but isn't a bad idea at first init). PIO send1622* isn't enabled at this point, so there is no danger of sending1623* these out on the wire.1624* Chip Errata bug 66101625*/1626piobuf = (u32 __iomem *) (((char __iomem *)(dd->ipath_kregbase)) +1627dd->ipath_piobufbase);1628pioincr = dd->ipath_palign / sizeof(*piobuf);1629for (i = 0; i < dd->ipath_piobcnt2k; i++) {1630/*1631* reasonable word count, just to init pbc1632*/1633writel(16, piobuf);1634piobuf += pioincr;1635}16361637ipath_get_eeprom_info(dd);1638if (dd->ipath_boardrev == 5) {1639/*1640* Later production QHT7040 has same changes as QHT7140, so1641* can use GPIO interrupts. They have serial #'s starting1642* with 128, rather than 112.1643*/1644if (dd->ipath_serial[0] == '1' &&1645dd->ipath_serial[1] == '2' &&1646dd->ipath_serial[2] == '8')1647dd->ipath_flags |= IPATH_GPIO_INTR;1648else {1649ipath_dev_err(dd, "Unsupported InfiniPath board "1650"(serial number %.16s)!\n",1651dd->ipath_serial);1652return 1;1653}1654}16551656if (dd->ipath_minrev >= 4) {1657/* Rev4+ reports extra errors via internal GPIO pins */1658dd->ipath_flags |= IPATH_GPIO_ERRINTRS;1659dd->ipath_gpio_mask |= IPATH_GPIO_ERRINTR_MASK;1660ipath_write_kreg(dd, dd->ipath_kregs->kr_gpio_mask,1661dd->ipath_gpio_mask);1662}16631664return 0;1665}166616671668/**1669* ipath_init_ht_get_base_info - set chip-specific flags for user code1670* @dd: the infinipath device1671* @kbase: ipath_base_info pointer1672*1673* We set the PCIE flag because the lower bandwidth on PCIe vs1674* HyperTransport can affect some user packet algorithms.1675*/1676static int ipath_ht_get_base_info(struct ipath_portdata *pd, void *kbase)1677{1678struct ipath_base_info *kinfo = kbase;16791680kinfo->spi_runtime_flags |= IPATH_RUNTIME_HT |1681IPATH_RUNTIME_PIO_REGSWAPPED;16821683if (pd->port_dd->ipath_minrev < 4)1684kinfo->spi_runtime_flags |= IPATH_RUNTIME_RCVHDR_COPY;16851686return 0;1687}16881689static void ipath_ht_free_irq(struct ipath_devdata *dd)1690{1691free_irq(dd->ipath_irq, dd);1692ht_destroy_irq(dd->ipath_irq);1693dd->ipath_irq = 0;1694dd->ipath_intconfig = 0;1695}16961697static struct ipath_message_header *1698ipath_ht_get_msgheader(struct ipath_devdata *dd, __le32 *rhf_addr)1699{1700return (struct ipath_message_header *)1701&rhf_addr[sizeof(u64) / sizeof(u32)];1702}17031704static void ipath_ht_config_ports(struct ipath_devdata *dd, ushort cfgports)1705{1706dd->ipath_portcnt =1707ipath_read_kreg32(dd, dd->ipath_kregs->kr_portcnt);1708dd->ipath_p0_rcvegrcnt =1709ipath_read_kreg32(dd, dd->ipath_kregs->kr_rcvegrcnt);1710}17111712static void ipath_ht_read_counters(struct ipath_devdata *dd,1713struct infinipath_counters *cntrs)1714{1715cntrs->LBIntCnt =1716ipath_snap_cntr(dd, IPATH_CREG_OFFSET(LBIntCnt));1717cntrs->LBFlowStallCnt =1718ipath_snap_cntr(dd, IPATH_CREG_OFFSET(LBFlowStallCnt));1719cntrs->TxSDmaDescCnt = 0;1720cntrs->TxUnsupVLErrCnt =1721ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxUnsupVLErrCnt));1722cntrs->TxDataPktCnt =1723ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxDataPktCnt));1724cntrs->TxFlowPktCnt =1725ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxFlowPktCnt));1726cntrs->TxDwordCnt =1727ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxDwordCnt));1728cntrs->TxLenErrCnt =1729ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxLenErrCnt));1730cntrs->TxMaxMinLenErrCnt =1731ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxMaxMinLenErrCnt));1732cntrs->TxUnderrunCnt =1733ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxUnderrunCnt));1734cntrs->TxFlowStallCnt =1735ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxFlowStallCnt));1736cntrs->TxDroppedPktCnt =1737ipath_snap_cntr(dd, IPATH_CREG_OFFSET(TxDroppedPktCnt));1738cntrs->RxDroppedPktCnt =1739ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxDroppedPktCnt));1740cntrs->RxDataPktCnt =1741ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxDataPktCnt));1742cntrs->RxFlowPktCnt =1743ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxFlowPktCnt));1744cntrs->RxDwordCnt =1745ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxDwordCnt));1746cntrs->RxLenErrCnt =1747ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxLenErrCnt));1748cntrs->RxMaxMinLenErrCnt =1749ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxMaxMinLenErrCnt));1750cntrs->RxICRCErrCnt =1751ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxICRCErrCnt));1752cntrs->RxVCRCErrCnt =1753ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxVCRCErrCnt));1754cntrs->RxFlowCtrlErrCnt =1755ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxFlowCtrlErrCnt));1756cntrs->RxBadFormatCnt =1757ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxBadFormatCnt));1758cntrs->RxLinkProblemCnt =1759ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxLinkProblemCnt));1760cntrs->RxEBPCnt =1761ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxEBPCnt));1762cntrs->RxLPCRCErrCnt =1763ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxLPCRCErrCnt));1764cntrs->RxBufOvflCnt =1765ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxBufOvflCnt));1766cntrs->RxTIDFullErrCnt =1767ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxTIDFullErrCnt));1768cntrs->RxTIDValidErrCnt =1769ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxTIDValidErrCnt));1770cntrs->RxPKeyMismatchCnt =1771ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxPKeyMismatchCnt));1772cntrs->RxP0HdrEgrOvflCnt =1773ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP0HdrEgrOvflCnt));1774cntrs->RxP1HdrEgrOvflCnt =1775ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP1HdrEgrOvflCnt));1776cntrs->RxP2HdrEgrOvflCnt =1777ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP2HdrEgrOvflCnt));1778cntrs->RxP3HdrEgrOvflCnt =1779ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP3HdrEgrOvflCnt));1780cntrs->RxP4HdrEgrOvflCnt =1781ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP4HdrEgrOvflCnt));1782cntrs->RxP5HdrEgrOvflCnt =1783ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP5HdrEgrOvflCnt));1784cntrs->RxP6HdrEgrOvflCnt =1785ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP6HdrEgrOvflCnt));1786cntrs->RxP7HdrEgrOvflCnt =1787ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP7HdrEgrOvflCnt));1788cntrs->RxP8HdrEgrOvflCnt =1789ipath_snap_cntr(dd, IPATH_CREG_OFFSET(RxP8HdrEgrOvflCnt));1790cntrs->RxP9HdrEgrOvflCnt = 0;1791cntrs->RxP10HdrEgrOvflCnt = 0;1792cntrs->RxP11HdrEgrOvflCnt = 0;1793cntrs->RxP12HdrEgrOvflCnt = 0;1794cntrs->RxP13HdrEgrOvflCnt = 0;1795cntrs->RxP14HdrEgrOvflCnt = 0;1796cntrs->RxP15HdrEgrOvflCnt = 0;1797cntrs->RxP16HdrEgrOvflCnt = 0;1798cntrs->IBStatusChangeCnt =1799ipath_snap_cntr(dd, IPATH_CREG_OFFSET(IBStatusChangeCnt));1800cntrs->IBLinkErrRecoveryCnt =1801ipath_snap_cntr(dd, IPATH_CREG_OFFSET(IBLinkErrRecoveryCnt));1802cntrs->IBLinkDownedCnt =1803ipath_snap_cntr(dd, IPATH_CREG_OFFSET(IBLinkDownedCnt));1804cntrs->IBSymbolErrCnt =1805ipath_snap_cntr(dd, IPATH_CREG_OFFSET(IBSymbolErrCnt));1806cntrs->RxVL15DroppedPktCnt = 0;1807cntrs->RxOtherLocalPhyErrCnt = 0;1808cntrs->PcieRetryBufDiagQwordCnt = 0;1809cntrs->ExcessBufferOvflCnt = dd->ipath_overrun_thresh_errs;1810cntrs->LocalLinkIntegrityErrCnt =1811(dd->ipath_flags & IPATH_GPIO_ERRINTRS) ?1812dd->ipath_lli_errs : dd->ipath_lli_errors;1813cntrs->RxVlErrCnt = 0;1814cntrs->RxDlidFltrCnt = 0;1815}181618171818/* no interrupt fallback for these chips */1819static int ipath_ht_nointr_fallback(struct ipath_devdata *dd)1820{1821return 0;1822}182318241825/*1826* reset the XGXS (between serdes and IBC). Slightly less intrusive1827* than resetting the IBC or external link state, and useful in some1828* cases to cause some retraining. To do this right, we reset IBC1829* as well.1830*/1831static void ipath_ht_xgxs_reset(struct ipath_devdata *dd)1832{1833u64 val, prev_val;18341835prev_val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig);1836val = prev_val | INFINIPATH_XGXS_RESET;1837prev_val &= ~INFINIPATH_XGXS_RESET; /* be sure */1838ipath_write_kreg(dd, dd->ipath_kregs->kr_control,1839dd->ipath_control & ~INFINIPATH_C_LINKENABLE);1840ipath_write_kreg(dd, dd->ipath_kregs->kr_xgxsconfig, val);1841ipath_read_kreg32(dd, dd->ipath_kregs->kr_scratch);1842ipath_write_kreg(dd, dd->ipath_kregs->kr_xgxsconfig, prev_val);1843ipath_write_kreg(dd, dd->ipath_kregs->kr_control,1844dd->ipath_control);1845}184618471848static int ipath_ht_get_ib_cfg(struct ipath_devdata *dd, int which)1849{1850int ret;18511852switch (which) {1853case IPATH_IB_CFG_LWID:1854ret = dd->ipath_link_width_active;1855break;1856case IPATH_IB_CFG_SPD:1857ret = dd->ipath_link_speed_active;1858break;1859case IPATH_IB_CFG_LWID_ENB:1860ret = dd->ipath_link_width_enabled;1861break;1862case IPATH_IB_CFG_SPD_ENB:1863ret = dd->ipath_link_speed_enabled;1864break;1865default:1866ret = -ENOTSUPP;1867break;1868}1869return ret;1870}187118721873/* we assume range checking is already done, if needed */1874static int ipath_ht_set_ib_cfg(struct ipath_devdata *dd, int which, u32 val)1875{1876int ret = 0;18771878if (which == IPATH_IB_CFG_LWID_ENB)1879dd->ipath_link_width_enabled = val;1880else if (which == IPATH_IB_CFG_SPD_ENB)1881dd->ipath_link_speed_enabled = val;1882else1883ret = -ENOTSUPP;1884return ret;1885}188618871888static void ipath_ht_config_jint(struct ipath_devdata *dd, u16 a, u16 b)1889{1890}189118921893static int ipath_ht_ib_updown(struct ipath_devdata *dd, int ibup, u64 ibcs)1894{1895ipath_setup_ht_setextled(dd, ipath_ib_linkstate(dd, ibcs),1896ipath_ib_linktrstate(dd, ibcs));1897return 0;1898}189919001901/**1902* ipath_init_iba6110_funcs - set up the chip-specific function pointers1903* @dd: the infinipath device1904*1905* This is global, and is called directly at init to set up the1906* chip-specific function pointers for later use.1907*/1908void ipath_init_iba6110_funcs(struct ipath_devdata *dd)1909{1910dd->ipath_f_intrsetup = ipath_ht_intconfig;1911dd->ipath_f_bus = ipath_setup_ht_config;1912dd->ipath_f_reset = ipath_setup_ht_reset;1913dd->ipath_f_get_boardname = ipath_ht_boardname;1914dd->ipath_f_init_hwerrors = ipath_ht_init_hwerrors;1915dd->ipath_f_early_init = ipath_ht_early_init;1916dd->ipath_f_handle_hwerrors = ipath_ht_handle_hwerrors;1917dd->ipath_f_quiet_serdes = ipath_ht_quiet_serdes;1918dd->ipath_f_bringup_serdes = ipath_ht_bringup_serdes;1919dd->ipath_f_clear_tids = ipath_ht_clear_tids;1920dd->ipath_f_put_tid = ipath_ht_put_tid;1921dd->ipath_f_cleanup = ipath_setup_ht_cleanup;1922dd->ipath_f_setextled = ipath_setup_ht_setextled;1923dd->ipath_f_get_base_info = ipath_ht_get_base_info;1924dd->ipath_f_free_irq = ipath_ht_free_irq;1925dd->ipath_f_tidtemplate = ipath_ht_tidtemplate;1926dd->ipath_f_intr_fallback = ipath_ht_nointr_fallback;1927dd->ipath_f_get_msgheader = ipath_ht_get_msgheader;1928dd->ipath_f_config_ports = ipath_ht_config_ports;1929dd->ipath_f_read_counters = ipath_ht_read_counters;1930dd->ipath_f_xgxs_reset = ipath_ht_xgxs_reset;1931dd->ipath_f_get_ib_cfg = ipath_ht_get_ib_cfg;1932dd->ipath_f_set_ib_cfg = ipath_ht_set_ib_cfg;1933dd->ipath_f_config_jint = ipath_ht_config_jint;1934dd->ipath_f_ib_updown = ipath_ht_ib_updown;19351936/*1937* initialize chip-specific variables1938*/1939ipath_init_ht_variables(dd);1940}194119421943