📄 skgesirq.c
字号:
/****************************************************************************** * * Name: skgesirq.c * Project: GEnesis, PCI Gigabit Ethernet Adapter * Version: $Revision: 1.65 $ * Date: $Date: 2001/02/23 13:41:51 $ * Purpose: Special IRQ module * ******************************************************************************//****************************************************************************** * * (C)Copyright 1998-2000 SysKonnect GmbH. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * The information in this file is provided "AS IS" without warranty. * ******************************************************************************//****************************************************************************** * * History: * * $Log: skgesirq.c,v $ * Revision 1.65 2001/02/23 13:41:51 gklug * fix: PHYS2INST should be used correctly for Dual Net operation * chg: do no longer work with older PNMI * * Revision 1.64 2001/02/15 11:27:04 rassmann * Working with RLMT v1 if SK_MAX_NETS undefined. * * Revision 1.63 2001/02/06 10:44:23 mkunz * - NetIndex added to interface functions of pnmi V4 with dual net support * * Revision 1.62 2001/01/31 15:31:41 gklug * fix: problem with autosensing an SR8800 switch * * Revision 1.61 2000/11/09 11:30:09 rassmann * WA: Waiting after releasing reset until BCom chip is accessible. * * Revision 1.60 2000/10/18 12:37:48 cgoos * Reinserted the comment for version 1.56. * * Revision 1.59 2000/10/18 12:22:20 cgoos * Added workaround for half duplex hangup. * * Revision 1.58 2000/09/28 13:06:04 gklug * fix: BCOM may NOT be touched if XMAC is in RESET state * * Revision 1.57 2000/09/08 12:38:39 cgoos * Added forgotten variable declaration. * * Revision 1.56 2000/09/08 08:12:13 cgoos * Changed handling of parity errors in SkGeHwErr (correct reset of error). * * Revision 1.55 2000/06/19 08:36:25 cgoos * Changed comment. * * Revision 1.54 2000/05/22 08:45:57 malthoff * Fix: #10523 is valid for all BCom PHYs. * * Revision 1.53 2000/05/19 10:20:30 cgoos * Removed Solaris debug output code. * * Revision 1.52 2000/05/19 10:19:37 cgoos * Added PHY state check in HWLinkDown. * Move PHY interrupt code to IS_EXT_REG case in SkGeSirqIsr. * * Revision 1.51 2000/05/18 05:56:20 cgoos * Fixed typo. * * Revision 1.50 2000/05/17 12:49:49 malthoff * Fixes BCom link bugs (#10523). * * Revision 1.49 1999/12/17 11:02:50 gklug * fix: read PHY_STAT of Broadcom chip more often to assure good status * * Revision 1.48 1999/12/06 10:01:17 cgoos * Added SET function for Role. * * Revision 1.47 1999/11/22 13:34:24 cgoos * Changed license header to GPL. * * Revision 1.46 1999/09/16 10:30:07 cgoos * Removed debugging output statement from Linux. * * Revision 1.45 1999/09/16 07:32:55 cgoos * Fixed dual-port copperfield bug (PHY_READ from resetted port). * Removed some unused variables. * * Revision 1.44 1999/08/03 15:25:04 cgoos * Removed workaround for disabled interrupts in half duplex mode. * * Revision 1.43 1999/08/03 14:27:58 cgoos * Removed SENSE mode code from SkGePortCheckUpBcom. * * Revision 1.42 1999/07/26 09:16:54 cgoos * Added some typecasts to avoid compiler warnings. * * Revision 1.41 1999/05/19 07:28:59 cgoos * Changes for 1000Base-T. * * Revision 1.40 1999/04/08 13:59:39 gklug * fix: problem with 3Com switches endless RESTARTs * * Revision 1.39 1999/03/08 10:10:52 gklug * fix: AutoSensing did switch to next mode even if LiPa indicated offline * * Revision 1.38 1999/03/08 09:49:03 gklug * fix: Bug using pAC instead of IoC, causing AIX problems * fix: change compare for Linux compiler bug workaround * * Revision 1.37 1999/01/28 14:51:33 gklug * fix: monitor for autosensing and extra RESETS the RX on wire counters * * Revision 1.36 1999/01/22 09:19:55 gklug * fix: Init DupMode and InitPauseMd are now called in RxTxEnable * * Revision 1.35 1998/12/11 15:22:59 gklug * chg: autosensing: check for receive if manual mode was guessed * chg: simplified workaround for XMAC errata * chg: wait additional 100 ms before link goes up. * chg: autoneg timeout to 600 ms * chg: restart autoneg even if configured to autonegotiation * * Revision 1.34 1998/12/10 10:33:14 gklug * add: more debug messages * fix: do a new InitPhy if link went down (AutoSensing problem) * chg: Check for zero shorts if link is NOT up * chg: reset Port if link goes down * chg: wait additional 100 ms when link comes up to check shorts * fix: dummy read extended autoneg status to prevent link going down immediately * * Revision 1.33 1998/12/07 12:18:29 gklug * add: refinement of autosense mode: take into account the autoneg cap of LiPa * * Revision 1.32 1998/12/07 07:11:21 gklug * fix: compiler warning * * Revision 1.31 1998/12/02 09:29:05 gklug * fix: WA XMAC Errata: FCSCt check was not correct. * fix: WA XMAC Errata: Prec Counter were NOT updated in case of short checks. * fix: Clear Stat : now clears the Prev counters of all known Ports * * Revision 1.30 1998/12/01 10:54:15 gklug * dd: workaround for XMAC errata changed. Check RX count and CRC err Count, too. * * Revision 1.29 1998/12/01 10:01:53 gklug * fix: if MAC IRQ occurs during port down, this will be handled correctly * * Revision 1.28 1998/11/26 16:22:11 gklug * fix: bug in autosense if manual modes are used * * Revision 1.27 1998/11/26 15:50:06 gklug * fix: PNMI needs to set PLinkModeConf * * Revision 1.26 1998/11/26 14:51:58 gklug * add: AutoSensing functionalty * * Revision 1.25 1998/11/26 07:34:37 gklug * fix: Init PrevShorts when restarting port due to Link connection * * Revision 1.24 1998/11/25 10:57:32 gklug * fix: remove unreferenced local vars * * Revision 1.23 1998/11/25 08:26:40 gklug * fix: don't do a RESET on a starting or stopping port * * Revision 1.22 1998/11/24 13:29:44 gklug * add: Workaround for MAC parity errata * * Revision 1.21 1998/11/18 15:31:06 gklug * fix: lint bugs * * Revision 1.20 1998/11/18 12:58:54 gklug * fix: use PNMI query instead of hardware access * * Revision 1.19 1998/11/18 12:54:55 gklug * chg: add new workaround for XMAC Errata * add: short event counter monitoring on active link too * * Revision 1.18 1998/11/13 14:27:41 malthoff * Bug Fix: Packet Arbiter Timeout was not cleared correctly * for timeout on TX1 and TX2. * * Revision 1.17 1998/11/04 07:01:59 cgoos * Moved HW link poll sequence. * Added call to SkXmRxTxEnable. * * Revision 1.16 1998/11/03 13:46:03 gklug * add: functionality of SET_LMODE and SET_FLOW_MODE * fix: send RLMT LinkDown event when Port stop is given with LinkUp * * Revision 1.15 1998/11/03 12:56:47 gklug * fix: Needs more events * * Revision 1.14 1998/10/30 07:36:35 gklug * rmv: unnecessary code * * Revision 1.13 1998/10/29 15:21:57 gklug * add: Poll link feature for activating HW link * fix: Deactivate HWLink when Port STOP is given * * Revision 1.12 1998/10/28 07:38:57 cgoos * Checking link status at begin of SkHWLinkUp. * * Revision 1.11 1998/10/22 09:46:50 gklug * fix SysKonnectFileId typo * * Revision 1.10 1998/10/14 13:57:47 gklug * add: Port start/stop event * * Revision 1.9 1998/10/14 05:48:29 cgoos * Added definition for Para. * * Revision 1.8 1998/10/14 05:40:09 gklug * add: Hardware Linkup signal used * * Revision 1.7 1998/10/09 06:50:20 malthoff * Remove ID_sccs by SysKonnectFileId. * * Revision 1.6 1998/10/08 09:11:49 gklug * add: clear IRQ commands * * Revision 1.5 1998/10/02 14:27:35 cgoos * Fixed some typos and wrong event names. * * Revision 1.4 1998/10/02 06:24:17 gklug * add: HW error function * fix: OUT macros * * Revision 1.3 1998/10/01 07:03:00 gklug * add: ISR for the usual interrupt source register * * Revision 1.2 1998/09/03 13:50:33 gklug * add: function prototypes * * Revision 1.1 1998/08/27 11:50:21 gklug * initial revision * * * ******************************************************************************//* * Special Interrupt handler * * The following abstract should show how this module is included * in the driver path: * * In the ISR of the driver the bits for frame transmission complete and * for receive complete are checked and handled by the driver itself. * The bits of the slow path mask are checked after this and then the * entry into the so-called "slow path" is prepared. It is an implemetors * decision whether this is executed directly or just scheduled by * disabling the mask. In the interrupt service routine events may be * generated, so it would be a good idea to call the EventDispatcher * right after this ISR. * * The Interrupt service register of the adapter is NOT read by this * module. SO if the drivers implemetor needs a while loop around the * slow data paths Interrupt bits, he needs to call the SkGeIsr() for * each loop entered. * * However, the XMAC Interrupt status registers are read in a while loop. * */ static const char SysKonnectFileId[] = "$Id: skgesirq.c,v 1.65 2001/02/23 13:41:51 gklug Exp $" ;#include "h/skdrv1st.h" /* Driver Specific Definitions */#include "h/skgepnmi.h" /* PNMI Definitions */#include "h/skrlmt.h" /* RLMT Definitions */#include "h/skdrv2nd.h" /* Adapter Control- and Driver specific Def. *//* local function prototypes */static int SkGePortCheckUpXmac(SK_AC*, SK_IOC, int);static int SkGePortCheckUpBcom(SK_AC*, SK_IOC, int);static int SkGePortCheckUpLone(SK_AC*, SK_IOC, int);static int SkGePortCheckUpNat(SK_AC*, SK_IOC, int);static void SkPhyIsrBcom(SK_AC*, SK_IOC, int, SK_U16);static void SkPhyIsrLone(SK_AC*, SK_IOC, int, SK_U16);/* * Define an array of RX counter which are checked * in AutoSense mode to check whether a link is not able to autonegotiate. */static const SK_U32 SkGeRxOids[]= { OID_SKGE_STAT_RX_64, OID_SKGE_STAT_RX_127, OID_SKGE_STAT_RX_255, OID_SKGE_STAT_RX_511, OID_SKGE_STAT_RX_1023, OID_SKGE_STAT_RX_MAX,} ;#ifdef __C2MAN__/* * Special IRQ function * * General Description: * */intro(){}#endif/* Define return codes of SkGePortCheckUp and CheckShort. */#define SK_HW_PS_NONE 0 /* No action needed */#define SK_HW_PS_RESTART 1 /* Restart needed */#define SK_HW_PS_LINK 2 /* Link Up actions needed *//****************************************************************************** * * SkHWInitDefSense() - Default Autosensing mode initialization * * Description: * This function handles the Hardware link down signal * * Note: * */void SkHWInitDefSense(SK_AC *pAC, /* adapter context */SK_IOC IoC, /* IO context */int Port) /* Port Index (MAC_1 + n) */{ SK_GEPORT *pPrt; pPrt = &pAC->GIni.GP[Port]; pPrt->PAutoNegTimeOut = 0; if (pPrt->PLinkModeConf != SK_LMODE_AUTOSENSE) { pPrt->PLinkMode = pPrt->PLinkModeConf; return; } SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ, ("AutoSensing: First mode %d on Port %d\n", (int)SK_LMODE_AUTOFULL, Port)); pPrt->PLinkMode = SK_LMODE_AUTOFULL; return;} /* SkHWInitDefSense *//****************************************************************************** * * SkHWSenseGetNext() - GetNextAutosensing Mode * * Description: * This function handles the AutoSensing * * Note: * */SK_U8 SkHWSenseGetNext(SK_AC *pAC, /* adapter context */SK_IOC IoC, /* IO context */int Port) /* Port Index (MAC_1 + n) */{ SK_GEPORT *pPrt; pPrt = &pAC->GIni.GP[Port]; pPrt->PAutoNegTimeOut = 0; if (pPrt->PLinkModeConf != SK_LMODE_AUTOSENSE) { /* Leave all as configured */ return (pPrt->PLinkModeConf); } if (pPrt->PLinkMode == SK_LMODE_AUTOFULL) { /* Return next mode AUTOBOTH */ return (SK_LMODE_AUTOBOTH); } /* Return default autofull */ return (SK_LMODE_AUTOFULL);} /* SkHWSenseGetNext *//****************************************************************************** * * SkHWSenseSetNext() - Autosensing Set next mode * * Description: * This function sets the appropriate next mode. * * Note: * */void SkHWSenseSetNext(SK_AC *pAC, /* adapter context */SK_IOC IoC, /* IO context */int Port, /* Port Index (MAC_1 + n) */SK_U8 NewMode) /* New Mode to be written in sense mode */{ SK_GEPORT *pPrt; pPrt = &pAC->GIni.GP[Port]; pPrt->PAutoNegTimeOut = 0; if (pPrt->PLinkModeConf != SK_LMODE_AUTOSENSE) { return; } SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_IRQ, ("AutoSensing: next mode %d on Port %d\n", (int)NewMode, Port)); pPrt->PLinkMode = NewMode; return;} /* SkHWSenseSetNext *//****************************************************************************** * * SkHWLinkDown() - Link Down handling * * Description: * This function handles the Hardware link down signal * * Note: * */void SkHWLinkDown(SK_AC *pAC, /* adapter context */SK_IOC IoC, /* IO context */int Port) /* Port Index (MAC_1 + n) */{ SK_GEPORT *pPrt; SK_U16 Word; pPrt = &pAC->GIni.GP[Port]; /* Disable all XMAC interrupts. */ XM_OUT16(IoC, Port, XM_IMSK, 0xffff); /* Disable Receiver and Transmitter. */ XM_IN16(IoC, Port, XM_MMU_CMD, &Word); XM_OUT16(IoC, Port, XM_MMU_CMD, Word & ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX)); /* Disable all PHY interrupts. */ switch (pPrt->PhyType) { case SK_PHY_BCOM: /* Make sure that PHY is initialized. */ if (pAC->GIni.GP[Port].PState) { /* NOT allowed if BCOM is in RESET state */ /* Workaround BCOM Errata (#10523) all BCom. */ /* Disable Power Management if link is down. */ PHY_READ(IoC, pPrt, Port, PHY_BCOM_AUX_CTRL, &Word); PHY_WRITE(IoC, pPrt, Port, PHY_BCOM_AUX_CTRL, Word | PHY_B_AC_DIS_PM); PHY_WRITE(IoC, pPrt, Port, PHY_BCOM_INT_MASK, 0xffff); } break; case SK_PHY_LONE: PHY_WRITE(IoC, pPrt, Port, PHY_LONE_INT_ENAB, 0x0); break; case SK_PHY_NAT: /* todo: National PHY_WRITE(IoC, pPrt, Port, PHY_NAT_INT_MASK, 0xffff); */ break; } /* Init default sense mode. */ SkHWInitDefSense(pAC, IoC, Port); if (!pPrt->PHWLinkUp) { return; } SK_DBG_MSG(pAC,SK_DBGMOD_HWM,SK_DBGCAT_IRQ, ("Link down Port %d\n", Port)); /* Set Link to DOWN. */ pPrt->PHWLinkUp = SK_FALSE; /* Reset Port stati */ pPrt->PLinkModeStatus = SK_LMODE_STAT_UNKNOWN; pPrt->PFlowCtrlStatus = SK_FLOW_STAT_NONE; /* * Reinit Phy especially when the AutoSense default is set now. */ SkXmInitPhy(pAC, IoC, Port, SK_FALSE); /* GP0: used for workaround of Rev. C Errata 2. */ /* Do NOT signal to RLMT. */ /* Do NOT start the timer here. */} /* SkHWLinkDown *//****************************************************************************** * * SkHWLinkUp() - Link Up handling * * Description: * This function handles the Hardware link up signal * * Note: * */void SkHWLinkUp(SK_AC *pAC, /* adapter context */SK_IOC IoC, /* IO context */int Port) /* Port Index (MAC_1 + n) */{ SK_GEPORT *pPrt; pPrt = &pAC->GIni.GP[Port]; if (pPrt->PHWLinkUp) { /* We do NOT need to proceed on active link */ return; } pPrt->PHWLinkUp = SK_TRUE; pPrt->PAutoNegFail = SK_FALSE; pPrt->PLinkModeStatus = SK_LMODE_STAT_UNKNOWN; if (pPrt->PLinkMode != SK_LMODE_AUTOHALF && pPrt->PLinkMode != SK_LMODE_AUTOFULL && pPrt->PLinkMode != SK_LMODE_AUTOBOTH) { /* Link is up and no Autonegotiation should be done */ /* Configure Port */ /* Set Link Mode */ if (pPrt->PLinkMode == SK_LMODE_FULL) { pPrt->PLinkModeStatus = SK_LMODE_STAT_FULL; } else { pPrt->PLinkModeStatus = SK_LMODE_STAT_HALF; } /* No flow control without autonegotiation */ pPrt->PFlowCtrlStatus = SK_FLOW_STAT_NONE; /* RX/TX enable */ SkXmRxTxEnable(pAC, IoC, Port); }} /* SkHWLinkUp *//****************************************************************************** * * SkMacParity - does everything to handle MAC parity errors correctly * */static void SkMacParity(SK_AC *pAC, /* adapter context */SK_IOC IoC, /* IO context */int Port) /* Port Index of the port failed */{ SK_EVPARA Para; SK_GEPORT *pPrt; /* GIni Port struct pointer */ SK_U64 TxMax; /* TxMax Counter */ unsigned Len;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -