⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 skxmac2.c

📁 广州斯道2410普及版II的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/****************************************************************************** * * Name:	skxmac2.c * Project:	GEnesis, PCI Gigabit Ethernet Adapter * Version:	$Revision: 1.61 $ * Date:	$Date: 2001/02/09 15:40:59 $ * Purpose:	Contains functions to initialize the XMAC II * ******************************************************************************//****************************************************************************** * *	(C)Copyright 1998-2001 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: skxmac2.c,v $ *	Revision 1.61  2001/02/09 15:40:59  rassmann *	Editorial changes. *	 *	Revision 1.60  2001/02/07 15:02:01  cgoos *	Added workaround for Fujitsu switch link down. *	 *	Revision 1.59  2001/01/10 09:38:06  cgoos *	Fixed Broadcom C0/A1 Id check for workaround. *	 *	Revision 1.58  2000/11/29 11:30:38  cgoos *	Changed DEBUG sections with NW output to xDEBUG *	 *	Revision 1.57  2000/11/27 12:40:40  rassmann *	Suppressing preamble after first access to BCom, not before (#10556). *	 *	Revision 1.56  2000/11/09 12:32:48  rassmann *	Renamed variables. *	 *	Revision 1.55  2000/11/09 11:30:10  rassmann *	WA: Waiting after releasing reset until BCom chip is accessible. *	 *	Revision 1.54  2000/10/02 14:10:27  rassmann *	Reading BCOM PHY after releasing reset until it returns a valid value. *	 *	Revision 1.53  2000/07/27 12:22:11  gklug *	fix: possible endless loop in XmHardRst. *	 *	Revision 1.52  2000/05/22 08:48:31  malthoff *	Fix: #10523 errata valid for all BCOM PHYs. *	 *	Revision 1.51  2000/05/17 12:52:18  malthoff *	Fixes BCom link errata (#10523). *	 *	Revision 1.50  1999/11/22 13:40:14  cgoos *	Changed license header to GPL. *	 *	Revision 1.49  1999/11/22 08:12:13  malthoff *	Add workaround for power consumption feature of BCom C0 chip. *	 *	Revision 1.48  1999/11/16 08:39:01  malthoff *	Fix: MDIO preamble suppression is port dependent. *	 *	Revision 1.47  1999/08/27 08:55:35  malthoff *	1000BT: Optimizing MDIO transfer by oppressing MDIO preamble. *	 *	Revision 1.46  1999/08/13 11:01:12  malthoff *	Fix for 1000BT: pFlowCtrlMode was not set correctly. *	 *	Revision 1.45  1999/08/12 19:18:28  malthoff *	1000BT Fixes: Do not owerwrite XM_MMU_CMD. *	Do not execute BCOM A1 workaround for B1 chips. *	Fix pause frame setting. *	Always set PHY_B_AC_TX_TST in PHY_BCOM_AUX_CTRL. *	 *	Revision 1.44  1999/08/03 15:23:48  cgoos *	Fixed setting of PHY interrupt mask in half duplex mode. *	 *	Revision 1.43  1999/08/03 15:22:17  cgoos *	Added some debug output. *	Disabled XMac GP0 interrupt for external PHYs. *	 *	Revision 1.42  1999/08/02 08:39:23  malthoff *	BCOM PHY: TX LED: To get the mono flop behaviour it is required *	to set the LED Traffic Mode bit in PHY_BCOM_P_EXT_CTRL. *	 *	Revision 1.41  1999/07/30 06:54:31  malthoff *	Add temp. workarounds for the BCOM Phy revision A1. *	 *	Revision 1.40  1999/06/01 07:43:26  cgoos *	Changed Link Mode Status in SkXmAutoNegDone... from FULL/HALF to *	AUTOFULL/AUTOHALF. *	 *	Revision 1.39  1999/05/19 07:29:51  cgoos *	Changes for 1000Base-T. *	 *	Revision 1.38  1999/04/08 14:35:10  malthoff *	Add code for enabling signal detect. Enabling signal detect is disabled. *	 *	Revision 1.37  1999/03/12 13:42:54  malthoff *	Add: Jumbo Frame Support. *	Add: Receive modes SK_LENERR_OK_ON/OFF and *	SK_BIG_PK_OK_ON/OFF in SkXmSetRxCmd(). *	 *	Revision 1.36  1999/03/08 10:10:55  gklug *	fix: AutoSensing did switch to next mode even if LiPa indicated offline * *	Revision 1.35  1999/02/22 15:16:41  malthoff *	Remove some compiler warnings. * *	Revision 1.34  1999/01/22 09:19:59  gklug *	fix: Init DupMode and InitPauseMd are now called in RxTxEnable * *	Revision 1.33  1998/12/11 15:19:11  gklug *	chg: lipa autoneg stati *	chg: debug messages *	chg: do NOT use spurious XmIrq * *	Revision 1.32  1998/12/10 11:08:44  malthoff *	bug fix: pAC has been used for IOs in SkXmHardRst(). *	SkXmInitPhy() is also called for the Diag in SkXmInitMac(). * *	Revision 1.31  1998/12/10 10:39:11  gklug *	fix: do 4 RESETS of the XMAC at the beginning *	fix: dummy read interrupt source register BEFORE initializing the Phy *	add: debug messages *	fix: Linkpartners autoneg capability cannot be shown by TX_PAGE interrupt * *	Revision 1.30  1998/12/07 12:18:32  gklug *	add: refinement of autosense mode: take into account the autoneg cap of LiPa * *	Revision 1.29  1998/12/07 07:12:29  gklug *	fix: if page is received the link is  down. * *	Revision 1.28  1998/12/01 10:12:47  gklug *	chg: if spurious IRQ from XMAC encountered, save it * *	Revision 1.27  1998/11/26 07:33:38  gklug *	add: InitPhy call is now in XmInit function * *	Revision 1.26  1998/11/18 13:38:24  malthoff *	'Imsk' is also unused in SkXmAutoNegDone. * *	Revision 1.25  1998/11/18 13:28:01  malthoff *	Remove unused variable 'Reg' in SkXmAutoNegDone(). * *	Revision 1.24  1998/11/18 13:18:45  gklug *	add: workaround for xmac errata #1 *	add: detect Link Down also when Link partner requested config *	chg: XMIrq is only used when link is up * *	Revision 1.23  1998/11/04 07:07:04  cgoos *	Added function SkXmRxTxEnable. * *	Revision 1.22  1998/10/30 07:35:54  gklug *	fix: serve LinkDown interrupt when link is already down * *	Revision 1.21  1998/10/29 15:32:03  gklug *	fix: Link Down signaling * *	Revision 1.20  1998/10/29 11:17:27  gklug *	fix: AutoNegDone bug * *	Revision 1.19  1998/10/29 10:14:43  malthoff *	Add endainesss comment for reading/writing MAC addresses. * *	Revision 1.18  1998/10/28 07:48:55  cgoos *	Fix: ASS somtimes signaled although link is up. * *	Revision 1.17  1998/10/26 07:55:39  malthoff *	Fix in SkXmInitPauseMd(): Pause Mode *	was disabled and not enabled. *	Fix in SkXmAutoNegDone(): Checking Mode bits *	always failed, becaues of some missing braces. * *	Revision 1.16  1998/10/22 09:46:52  gklug *	fix SysKonnectFileId typo * *	Revision 1.15  1998/10/21 05:51:37  gklug *	add: para DoLoop to InitPhy function for loopback set-up * *	Revision 1.14  1998/10/16 10:59:23  malthoff *	Remove Lint warning for dummy reads. * *	Revision 1.13  1998/10/15 14:01:20  malthoff *	Fix: SkXmAutoNegDone() is (int) but does not return a value. * *	Revision 1.12  1998/10/14 14:45:04  malthoff *	Remove SKERR_SIRQ_E0xx and SKERR_SIRQ_E0xxMSG by *	SKERR_HWI_Exx and SKERR_HWI_E0xxMSG to be independant *	from the Sirq module. * *	Revision 1.11  1998/10/14 13:59:01  gklug *	add: InitPhy function * *	Revision 1.10  1998/10/14 11:20:57  malthoff *	Make SkXmAutoNegDone() public, because it's *	used in diagnostics, too. *	The Link Up event to the RLMT is issued in *	SkXmIrq(). SkXmIrq() is not available in *	diagnostics. Use PHY_READ when reading *	PHY registers. * *	Revision 1.9  1998/10/14 05:50:10  cgoos *	Added definition for Para. * *	Revision 1.8  1998/10/14 05:41:28  gklug *	add: Xmac IRQ *	add: auto negotiation done function * *	Revision 1.7  1998/10/09 06:55:20  malthoff *	The configuration of the XMACs Tx Request Threshold *	depends from the drivers port usage now. The port *	usage is configured in GIPortUsage. * *	Revision 1.6  1998/10/05 07:48:00  malthoff *	minor changes * *	Revision 1.5  1998/10/01 07:03:54  gklug *	add: dummy function for XMAC ISR * *	Revision 1.4  1998/09/30 12:37:44  malthoff *	Add SkXmSetRxCmd() and related code. * *	Revision 1.3  1998/09/28 13:26:40  malthoff *	Add SkXmInitMac(), SkXmInitDupMd(), and SkXmInitPauseMd() * *	Revision 1.2  1998/09/16 14:34:21  malthoff *	Add SkXmClrExactAddr(), SkXmClrSrcCheck(), *	SkXmClrHashAddr(), SkXmFlushTxFifo(), *	SkXmFlushRxFifo(), and SkXmHardRst(). *	Finish Coding of SkXmSoftRst(). *	The sources may be compiled now. * *	Revision 1.1  1998/09/04 10:05:56  malthoff *	Created. * * ******************************************************************************/#include "h/skdrv1st.h"#include "h/xmac_ii.h"#include "h/skdrv2nd.h"/* defines ********************************************************************//* typedefs *******************************************************************//* global variables ***********************************************************//* local variables ************************************************************/static const char SysKonnectFileId[] =	"@(#)$Id: skxmac2.c,v 1.61 2001/02/09 15:40:59 rassmann Exp $ (C) SK ";/* BCOM PHY magic pattern list */typedef struct s_PhyHack {	int		PhyReg;		/* Phy register */	SK_U16	PhyVal;		/* Value to write */} BCOM_HACK;BCOM_HACK BcomRegA1Hack[] = { { 0x18, 0x0c20 }, { 0x17, 0x0012 }, { 0x15, 0x1104 }, { 0x17, 0x0013 }, { 0x15, 0x0404 }, { 0x17, 0x8006 }, { 0x15, 0x0132 }, { 0x17, 0x8006 }, { 0x15, 0x0232 }, { 0x17, 0x800D }, { 0x15, 0x000F }, { 0x18, 0x0420 }, { 0, 0 }};BCOM_HACK BcomRegC0Hack[] = { { 0x18, 0x0c20 }, { 0x17, 0x0012 }, { 0x15, 0x1204 }, { 0x17, 0x0013 }, { 0x15, 0x0A04 }, { 0x18, 0x0420 }, { 0, 0 }};/* function prototypes ********************************************************/static void	SkXmInitPhyXmac(SK_AC*, SK_IOC, int, SK_BOOL);static void	SkXmInitPhyBcom(SK_AC*, SK_IOC, int, SK_BOOL);static void	SkXmInitPhyLone(SK_AC*, SK_IOC, int, SK_BOOL);static void	SkXmInitPhyNat (SK_AC*, SK_IOC, int, SK_BOOL);static int	SkXmAutoNegDoneXmac(SK_AC*, SK_IOC, int);static int	SkXmAutoNegDoneBcom(SK_AC*, SK_IOC, int);static int	SkXmAutoNegDoneLone(SK_AC*, SK_IOC, int);static int	SkXmAutoNegDoneNat (SK_AC*, SK_IOC, int);/****************************************************************************** * *	SkXmSetRxCmd() - Modify the value of the XMACs Rx Command Register * * Description: *	The features *	 o FCS stripping,			SK_STRIP_FCS_ON/OFF *	 o pad byte stripping,			SK_STRIP_PAD_ON/OFF *	 o don't set XMR_FS_ERR in frame	SK_LENERR_OK_ON/OFF *	   status for inrange length error *	   frames, and *	 o don't set XMR_FS_ERR in frame	SK_BIG_PK_OK_ON/OFF *	   status for frames > 1514 bytes * *	for incomming packets may be enabled/disabled by this function. *	Additional modes may be added later. *	Multiple modes can be enabled/disabled at the same time. *	The new configuration is stored into the HWAC port configuration *	and is written to the Receive Command register immediatlely. *	The new configuration is saved over any SkGePortStop() and *	SkGeInitPort() calls. The configured value will be overwritten *	when SkGeInit(Level 0) is executed. * * Returns: *	nothing */void SkXmSetRxCmd(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC,		/* IO context */int		Port,		/* The XMAC to handle with belongs to this Port */int		Mode)		/* Mode is SK_STRIP_FCS_ON/OFF, SK_STRIP_PAD_ON/OFF,					   SK_LENERR_OK_ON/OFF, or SK_BIG_PK_OK_ON/OFF */{	SK_GEPORT	*pPrt;	SK_U16		OldRxMode;	pPrt = &pAC->GIni.GP[Port];	OldRxMode = pPrt->PRxCmd;	switch(Mode & (SK_STRIP_FCS_ON | SK_STRIP_FCS_OFF)) {	case SK_STRIP_FCS_ON:		pPrt->PRxCmd |= XM_RX_STRIP_FCS;		break;	case SK_STRIP_FCS_OFF:		pPrt->PRxCmd &= ~XM_RX_STRIP_FCS;		break;	}	switch(Mode & (SK_STRIP_PAD_ON | SK_STRIP_PAD_OFF)) {	case SK_STRIP_PAD_ON:		pPrt->PRxCmd |= XM_RX_STRIP_PAD;		break;	case SK_STRIP_PAD_OFF:		pPrt->PRxCmd &= ~XM_RX_STRIP_PAD;		break;	}	switch(Mode & (SK_LENERR_OK_ON | SK_LENERR_OK_OFF)) {	case SK_LENERR_OK_ON:		pPrt->PRxCmd |= XM_RX_LENERR_OK;		break;	case SK_LENERR_OK_OFF:		pPrt->PRxCmd &= ~XM_RX_LENERR_OK;		break;	}	switch(Mode & (SK_BIG_PK_OK_ON | SK_BIG_PK_OK_OFF)) {	case SK_BIG_PK_OK_ON:		pPrt->PRxCmd |= XM_RX_BIG_PK_OK;		break;	case SK_BIG_PK_OK_OFF:		pPrt->PRxCmd &= ~XM_RX_BIG_PK_OK;		break;	}	/* Write the new mode to the receive command register if required */	if (OldRxMode != pPrt->PRxCmd) {		XM_OUT16(IoC, Port, XM_RX_CMD, pPrt->PRxCmd);	}}	/* SkXmSetRxCmd*//****************************************************************************** * *	SkXmClrExactAddr() - Clear Exact Match Address Registers * * Description: *	All Exact Match Address registers of the XMAC 'Port' will be *	cleared starting with 'StartNum' up to (and including) the *	Exact Match address number of 'StopNum'. * * Returns: *	nothing */void SkXmClrExactAddr(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC,		/* IO context */int		Port,		/* The XMAC to handle with belongs to this Port */int		StartNum,	/* Begin with this Address Register Index (0..15) */int		StopNum)	/* Stop after finished with this Register Idx (0..15) */{	int		i;	SK_U16	ZeroAddr[3] = {0x0000, 0x0000, 0x0000};	if ((unsigned)StartNum > 15 || (unsigned)StopNum > 15 ||		StartNum > StopNum) {		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E001, SKERR_HWI_E001MSG);		return;	}	for (i = StartNum; i <= StopNum; i++) {		XM_OUTADDR(IoC, Port, XM_EXM(i), &ZeroAddr[0]);	}}	/* SkXmClrExactAddr *//****************************************************************************** * *	SkXmClrSrcCheck() - Clear Source Check Address Register * * Description: *	The Source Check Address Register of the XMAC 'Port' number *	will be cleared. * * Returns: *	nothing */static void SkXmClrSrcCheck(SK_AC	*pAC,	/* adapter context */SK_IOC	IoC,	/* IO context */int		Port)	/* The XMAC to handle with belongs to this Port (MAC_1 + n) */{	SK_U16	ZeroAddr[3] = {0x0000, 0x0000, 0x0000};	XM_OUTHASH(IoC, Port, XM_SRC_CHK, &ZeroAddr);}	/* SkXmClrSrcCheck *//****************************************************************************** * *	SkXmClrHashAddr() - Clear Hash Address Registers * * Description: *	The Hash Address Register of the XMAC 'Port' will be cleared. * * Returns: *	nothing */static void SkXmClrHashAddr(SK_AC	*pAC,	/* adapter context */SK_IOC	IoC,	/* IO context */int		Port)	/* The XMAC to handle with belongs to this Port (MAC_1 + n) */{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -