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

📄 skgeinit.c

📁 内核linux2.4.20,可跟rtlinux3.2打补丁 组成实时linux系统,编译内核
💻 C
📖 第 1 页 / 共 4 页
字号:
 * Returns: *	nothing */static void SkGeInitRamBufs(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC,		/* IO context */int		Port)		/* Port Index (MAC_1 + n) */{	SK_GEPORT *pPrt;	int RxQType;	pPrt = &pAC->GIni.GP[Port];	if (pPrt->PRxQSize == SK_MIN_RXQ_SIZE) {		RxQType = SK_RX_SRAM_Q; 	/* small Rx Queue */	}	else {		RxQType = SK_RX_BRAM_Q;		/* big Rx Queue */	}	DoInitRamQueue(pAC, IoC, pPrt->PRxQOff, pPrt->PRxQRamStart,		pPrt->PRxQRamEnd, RxQType);	DoInitRamQueue(pAC, IoC, pPrt->PXsQOff, pPrt->PXsQRamStart,		pPrt->PXsQRamEnd, SK_TX_RAM_Q);	DoInitRamQueue(pAC, IoC, pPrt->PXaQOff, pPrt->PXaQRamStart,		pPrt->PXaQRamEnd, SK_TX_RAM_Q);}	/* SkGeInitRamBufs *//****************************************************************************** * *	SkGeInitRamIface() - Initialize the RAM Interface * * Description: *	This function initializes the Adapbers RAM Interface. * * Note: *	This function is used in the diagnostics. * * Returns: *	nothing */void SkGeInitRamIface(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC)		/* IO context */{	/* release local reset */	SK_OUT16(IoC, B3_RI_CTRL, RI_RST_CLR);	/* configure timeout values */	SK_OUT8(IoC, B3_RI_WTO_R1, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_WTO_XA1, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_WTO_XS1, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_RTO_R1, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_RTO_XA1, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_RTO_XS1, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_WTO_R2, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_WTO_XA2, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_WTO_XS2, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_RTO_R2, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_RTO_XA2, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_RTO_XS2, SK_RI_TO_53);}	/* SkGeInitRamIface *//****************************************************************************** * *	SkGeInitBmu() - Initialize the BMU state machines * * Description: *	Initialize all BMU state machines of the specified port * * Returns: *	nothing */static void SkGeInitBmu(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];	/* Rx Queue: Release all local resets and set the watermark */	SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_CLR_RESET);	SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_F), SK_BMU_RX_WM);	/*	 * Tx Queue: Release all local resets if the queue is used!	 * 		set watermark	 */	if (pPrt->PXSQSize != 0) {		SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_CLR_RESET);		SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_F), SK_BMU_TX_WM);	}	if (pPrt->PXAQSize != 0) {		SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_CLR_RESET);		SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_F), SK_BMU_TX_WM);	}	/*	 * Do NOT enable the descriptor poll timers here, because	 * the descriptor addresses are not specified yet.	 */}	/* SkGeInitBmu *//****************************************************************************** * *	TestStopBit() -	Test the stop bit of the queue * * Description: *	Stopping a queue is not as simple as it seems to be. *	If descriptor polling is enabled, it may happen *	that RX/TX stop is done and SV idle is NOT set. *	In this case we have to issue another stop command. * * Retruns: *	The queues control status register */static SK_U32 TestStopBit(SK_AC	*pAC,		/* Adapter Context */SK_IOC	IoC,		/* IO Context */int		QuIoOffs)	/* Queue IO Address Offset */{	SK_U32	QuCsr;	/* CSR contents */	SK_IN32(IoC, Q_ADDR(QuIoOffs, Q_CSR), &QuCsr);	if ((QuCsr & (CSR_STOP|CSR_SV_IDLE)) == 0) {		SK_OUT32(IoC, Q_ADDR(QuIoOffs, Q_CSR), CSR_STOP);		SK_IN32(IoC, Q_ADDR(QuIoOffs, Q_CSR), &QuCsr);	}	return (QuCsr);}	/* TestStopBit*//****************************************************************************** * *	SkGeStopPort() - Stop the Rx/Tx activity of the port 'Port'. * * Description: *	After calling this function the descriptor rings and rx and tx *	queues of this port may be reconfigured. * *	It is possible to stop the receive and transmit path seperate or *	both together. * *	Dir =	SK_STOP_TX 	Stops the transmit path only and resets *				the XMAC. The receive queue is still and *				the pending rx frames may still transfered *				into the RxD. *		SK_STOP_RX	Stop the receive path. The tansmit path *				has to be stoped once before. *		SK_STOP_ALL	SK_STOP_TX + SK_STOP_RX * *	RstMode=SK_SOFT_RST	Resets the XMAC. The PHY is still alive. *		SK_HARD_RST	Resets the XMAC and the PHY. * * Example: *	1) A Link Down event was signaled for a port. Therefore the activity *	of this port should be stoped and a hardware reset should be issued *	to enable the workaround of XMAC errata #2. But the received frames *	should not be discarded. *		... *		SkGeStopPort(pAC, IoC, Port, SK_STOP_TX, SK_HARD_RST); *		(transfer all pending rx frames) *		SkGeStopPort(pAC, IoC, Port, SK_STOP_RX, SK_HARD_RST); *		... * *	2) An event was issued which request the driver to switch *	the 'virtual active' link to an other already active port *	as soon as possible. The frames in the receive queue of this *	port may be lost. But the PHY must not be reset during this *	event. *		... *		SkGeStopPort(pAC, IoC, Port, SK_STOP_ALL, SK_SOFT_RST); *		... * * Extended Description: *	If SK_STOP_TX is set, *		o disable the XMACs receive and transmiter to prevent *		  from sending incomplete frames *		o stop the port's transmit queues before terminating the *		  BMUs to prevent from performing incomplete PCI cycles *		  on the PCI bus *		- The network rx and tx activity and PCI tx transfer is *		  disabled now. *		o reset the XMAC depending on the RstMode *		o Stop Interval Timer and Limit Counter of Tx Arbiter, *		  also disable Force Sync bit and Enable Alloc bit. *		o perform a local reset of the port's tx path *			- reset the PCI FIFO of the async tx queue *			- reset the PCI FIFO of the sync tx queue *			- reset the RAM Buffer async tx queue *			- reset the RAM Butter sync tx queue *			- reset the MAC Tx FIFO *		o switch Link and Tx LED off, stop the LED counters * *	If SK_STOP_RX is set, *		o stop the port's receive queue *		- The path data transfer activity is fully stopped now. *		o perform a local reset of the port's rx path *			- reset the PCI FIFO of the rx queue *			- reset the RAM Buffer receive queue *			- reset the MAC Rx FIFO *		o switch Rx LED off, stop the LED counter * *	If all ports are stopped, *		o reset the RAM Interface. * * Notes: *	o This function may be called during the driver states RESET_PORT and *	  SWITCH_PORT. */void	SkGeStopPort(SK_AC	*pAC,	/* adapter context */SK_IOC	IoC,	/* I/O context */int		Port,	/* port to stop (MAC_1 + n) */int		Dir,	/* Direction to Stop (SK_STOP_RX, SK_STOP_TX, SK_STOP_ALL) */int		RstMode)/* Reset Mode (SK_SOFT_RST, SK_HARD_RST) */{#ifndef	SK_DIAG	SK_EVPARA Para;#endif	/* !SK_DIAG */	SK_GEPORT *pPrt;	SK_U32	DWord;	SK_U16	Word;	SK_U32	XsCsr;	SK_U32	XaCsr;	int		i;	SK_BOOL	AllPortsDis;	SK_U64	ToutStart;	int		ToutCnt;	pPrt = &pAC->GIni.GP[Port];	if (Dir & SK_STOP_TX) {		/* disable the XMACs 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));		/* dummy read to ensure writing */		XM_IN16(IoC, Port, XM_MMU_CMD, &Word);		/* stop both transmit queues */		/*		 * If the BMU is in the reset state CSR_STOP will terminate		 * immediately.		 */		SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_STOP);		SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_STOP);		ToutStart = SkOsGetTime(pAC);		ToutCnt = 0;		do {			/*			 * Clear packet arbiter timeout to make sure			 * this loop will terminate.			 */			if (Port == MAC_1) {				Word = PA_CLR_TO_TX1;			}			else {				Word = PA_CLR_TO_TX2;			}			SK_OUT16(IoC, B3_PA_CTRL, Word);			/*			 * If the transfer stucks at the XMAC the STOP command will not			 * terminate if we don't flush the XMAC's transmit FIFO!			 */			XM_IN32(IoC, Port, XM_MODE, &DWord);			DWord |= XM_MD_FTF;			XM_OUT32(IoC, Port, XM_MODE, DWord);			XsCsr = TestStopBit(pAC, IoC, pPrt->PXsQOff);			XaCsr = TestStopBit(pAC, IoC, pPrt->PXaQOff);			if (SkOsGetTime(pAC) - ToutStart > (SK_TICKS_PER_SEC / 18)) {				/*				 * Timeout of 1/18 second reached.				 * This needs to be checked at 1/18 sec only.				 */				ToutCnt++;				switch (ToutCnt) {				case 1:					/*					 * Cache Incoherency workaround: Assume a start command					 * has been lost while sending the frame. 					 */					ToutStart = SkOsGetTime(pAC);					if (XsCsr & CSR_STOP) {						SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_START);					}					if (XaCsr & CSR_STOP) {						SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_START);					}					break;				case 2:				default:					/* Might be a problem when the driver event handler					 * calls StopPort again.					 * XXX.					 */					/* Fatal Error, Loop aborted */					/* Create an Error Log Entry */					SK_ERR_LOG(						pAC,						SK_ERRCL_HW,						SKERR_HWI_E018,						SKERR_HWI_E018MSG);#ifndef SK_DIAG					Para.Para64 = Port;					SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_FAIL, Para);#endif	/* !SK_DIAG */					return;				}			}			/*			 * Because of the ASIC problem report entry from 21.08.1998 it is			 * required to wait until CSR_STOP is reset and CSR_SV_IDLE is set.			 */		} while ((XsCsr & (CSR_STOP | CSR_SV_IDLE)) != CSR_SV_IDLE ||			 (XaCsr & (CSR_STOP | CSR_SV_IDLE)) != CSR_SV_IDLE);		/* reset the XMAC depending on the RstMode */		if (RstMode == SK_SOFT_RST) {			SkXmSoftRst(pAC, IoC, Port);		}		else {			SkXmHardRst(pAC, IoC, Port);		} 		/*		 * Stop Interval Timer and Limit Counter of Tx Arbiter, 		 * also disable Force Sync bit and Enable Alloc bit.		 */		SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL),			TXA_DIS_FSYNC | TXA_DIS_ALLOC | TXA_STOP_RC);		SK_OUT32(IoC, MR_ADDR(Port, TXA_ITI_INI), 0x00000000L);		SK_OUT32(IoC, MR_ADDR(Port, TXA_LIM_INI), 0x00000000L);		/*		 * perform a local reset of the port's tx path		 *	- reset the PCI FIFO of the async tx queue		 *	- reset the PCI FIFO of the sync tx queue		 *	- reset the RAM Buffer async tx queue		 *	- reset the RAM Butter sync tx queue		 *	- reset the MAC Tx FIFO		 */		SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_SET_RESET);		SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_SET_RESET);		SK_OUT8(IoC, RB_ADDR(pPrt->PXaQOff, RB_CTRL), RB_RST_SET);		SK_OUT8(IoC, RB_ADDR(pPrt->PXsQOff, RB_CTRL), RB_RST_SET);		/* Note: MFF_RST_SET does NOT reset the XMAC! */		SK_OUT8(IoC, MR_ADDR(Port, TX_MFF_CTRL2), MFF_RST_SET);		/* switch Link and Tx LED off, stop the LED counters */		/* Link LED is switched off by the RLMT and the Diag itself */		SkGeXmitLED(pAC, IoC, MR_ADDR(Port, TX_LED_INI), SK_LED_DIS);	}	if (Dir & SK_STOP_RX) {		/*		 * The RX Stop Command will not terminate if no buffers		 * are queued in the RxD ring. But it will always reach		 * the Idle state. Therefore we can use this feature to		 * stop the transfer of received packets.		 */		/* stop the port's receive queue */		SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_STOP);		i = 100;		do {			/*			 * Clear packet arbiter timeout to make sure			 * this loop will terminate			 */			if (Port == MAC_1) {				Word = PA_CLR_TO_RX1;			}			else {				Word = PA_CLR_TO_RX2;			}			SK_OUT16(IoC, B3_PA_CTRL, Word);			DWord = TestStopBit(pAC, IoC, pPrt->PRxQOff);			if (i != 0) {				i--;			}			/* finish if CSR_STOP is done or CSR_SV_IDLE is true and i==0 */			/*			 * because of the ASIC problem report entry from 21.08.98			 * it is required to wait until CSR_STOP is reset and			 * CSR_SV_IDLE is set.			 */		} while ((DWord & (CSR_STOP | CSR_SV_IDLE)) != CSR_SV_IDLE &&			((DWord & CSR_SV_IDLE) == 0 || i != 0));		/* The path data transfer activity is fully stopped now. */		/*		 * perform a local reset of the port's rx path		 *	- reset the PCI FIFO of the rx queue		 *	- reset the RAM Buffer receive queue		 *	- reset the MAC Rx FIFO		 */		SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_SET_RESET);		SK_OUT8(IoC, RB_ADDR(pPrt->PRxQOff, RB_CTRL), RB_RST_SET);		SK_OUT8(IoC, MR_ADDR(Port, RX_MFF_CTRL2), MFF_RST_SET);		/* switch Rx LED off, stop the LED counter */		SkGeXmitLED(pAC, IoC, MR_ADDR(Port, RX_LED_INI), SK_LED_DIS);	} 	/*	 * If all ports are stopped reset the RAM Interface.	 */	for (i = 0, AllPortsDis = SK_TRUE; i < pAC->GIni.GIMacsFound; i++) {		if (pAC->GIni.GP[i].PState != SK_PRT_RESET &&			pAC->GIni.GP[i].PState != SK_PRT_STOP) {			AllPortsDis = SK_FALSE;			break;		}	}	if (AllPortsDis) {		pAC->GIni.GIAnyPortAct = SK_FALSE;	}}	/* SkGeStopPort *//****************************************************************************** * *	SkGeInit0() - Level 0 Initialization * * Description: *	- Initialize the BMU address offsets * * Returns: *	nothing */static void SkGeInit0(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC)		/* IO context */{	int i;	SK_GEPORT *pPrt;	for (i = 0; i < SK_MAX_MACS; i++) {		pPrt = &pAC->GIni.GP[i];		pPrt->PState = SK_PRT_RESET;		pPrt->PRxQOff = QOffTab[i].RxQOff;		pPrt->PXsQOff = QOffTab[i].XsQOff;		pPrt->PXaQOff = QOffTab[i].XaQOff;		pPrt->PCheckPar = SK_FALSE;		pPrt->PRxCmd = XM_RX_STRIP_FCS | XM_RX_LENERR_OK;		pPrt->PIsave = 0;		pPrt->PPrevShorts = 0;		pPrt->PLinkResCt = 0;		pPrt->PAutoNegTOCt = 0;		pPrt->PPrevRx = 0;		pPrt->PPrevFcs = 0;		pPrt->PRxLim = SK_DEF_RX_WA_LIM;		pPrt->PLinkMode = SK_LMODE_AUTOFULL;		pPrt->PLinkModeConf = SK_LMODE_AUTOSENSE;		pPrt->PFlowCtrlMode = SK_FLOW_MODE_SYM_OR_REM;		pPrt->PLinkBroken = SK_TRUE; /* See WA code */		pPrt->PLinkCap = (SK_LMODE_CAP_HALF | SK_LMODE_CAP_FULL |				SK_LMODE_CAP_AUTOHALF | SK_LMODE_CAP_AUTOFULL);		pPrt->PLinkModeStatus = SK_LMODE_STAT_UNKNOWN;		pPrt->PFlowCtrlCap = SK_FLOW_MODE_SYM_OR_REM;		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_NONE;		pPrt->PMSCap = (SK_MS_CAP_AUTO | SK_MS_CAP_MASTER | 				SK_MS_CAP_SLAVE);		pPrt->PMSMode = SK_MS_MODE_AUTO;		pPrt->PMSStatus = SK_MS_STAT_UNSET;		pPrt->PAutoNegFail = SK_FALSE;		pPrt->PLipaAutoNeg = SK_LIPA_UNKNOWN;		pPrt->PHWLinkUp = SK_FALSE;	}	pAC->GIni.GIPortUsage = SK_RED_LINK;	pAC->GIni.GIAnyPortAct = SK_FALSE;}	/* SkGeInit0*/#ifdef SK_PCI_RESET/****************************************************************************** * *	SkGePciReset() - Reset PCI interface * * Description:

⌨️ 快捷键说明

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