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

📄 skgeinit.c

📁 F:worksip2440a board可启动u-boot-like.tar.gz F:worksip2440a board可启动u-boot-like.tar.gz
💻 C
📖 第 1 页 / 共 5 页
字号:
	SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), (PollRxD) ?		CSR_ENA_POL : CSR_DIS_POL);}	/* SkGePollRxD *//****************************************************************************** * *	SkGePollTxD() - Enable / Disable Descriptor Polling of TxD Rings * * Description: *	Enable or disable the descriptor polling of the transmit descriptor *	ring(s) (TxD) for port 'Port'. *	The new configuration is *not* saved over any SkGeStopPort() and *	SkGeInitPort() calls. * * Returns: *	nothing */void SkGePollTxD(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC,		/* IO context */int		Port,		/* Port Index (MAC_1 + n) */SK_BOOL PollTxD)	/* SK_TRUE (enable pol.), SK_FALSE (disable pol.) */{	SK_GEPORT *pPrt;	SK_U32	DWord;	pPrt = &pAC->GIni.GP[Port];	DWord = (PollTxD) ? CSR_ENA_POL : CSR_DIS_POL;	if (pPrt->PXSQSize != 0) {		SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), DWord);	}	if (pPrt->PXAQSize != 0) {		SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), DWord);	}}	/* SkGePollTxD *//****************************************************************************** * *	SkGeYellowLED() - Switch the yellow LED on or off. * * Description: *	Switch the yellow LED on or off. * * Note: *	This function may be called any time after SkGeInit(Level 1). * * Returns: *	nothing */void SkGeYellowLED(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC,		/* IO context */int		State)		/* yellow LED state, 0 = OFF, 0 != ON */{	if (State == 0) {		/* Switch yellow LED OFF */		SK_OUT8(IoC, B0_LED, LED_STAT_OFF);	}	else {		/* Switch yellow LED ON */		SK_OUT8(IoC, B0_LED, LED_STAT_ON);	}}	/* SkGeYellowLED *//****************************************************************************** * *	SkGeXmitLED() - Modify the Operational Mode of a transmission LED. * * Description: *	The Rx or Tx LED which is specified by 'Led' will be *	enabled, disabled or switched on in test mode. * * Note: *	'Led' must contain the address offset of the LEDs INI register. * * Usage: *	SkGeXmitLED(pAC, IoC, MR_ADDR(Port, TX_LED_INI), SK_LED_ENA); * * Returns: *	nothing */void SkGeXmitLED(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC,		/* IO context */int		Led,		/* offset to the LED Init Value register */int		Mode)		/* Mode may be SK_LED_DIS, SK_LED_ENA, SK_LED_TST */{	SK_U32	LedIni;	switch (Mode) {	case SK_LED_ENA:		LedIni = SK_XMIT_DUR * (SK_U32)pAC->GIni.GIHstClkFact / 100;		SK_OUT32(IoC, Led + XMIT_LED_INI, LedIni);		SK_OUT8(IoC, Led + XMIT_LED_CTRL, LED_START);		break;	case SK_LED_TST:		SK_OUT8(IoC, Led + XMIT_LED_TST, LED_T_ON);		SK_OUT32(IoC, Led + XMIT_LED_CNT, 100);		SK_OUT8(IoC, Led + XMIT_LED_CTRL, LED_START);		break;	case SK_LED_DIS:	default:		/*		 * Do NOT stop the LED Timer here. The LED might be		 * in on state. But it needs to go off.		 */		SK_OUT32(IoC, Led + XMIT_LED_CNT, 0);		SK_OUT8(IoC, Led + XMIT_LED_TST, LED_T_OFF);		break;	}	/*	 * 1000BT: The Transmit LED is driven by the PHY.	 * But the default LED configuration is used for	 * Level One and Broadcom PHYs.	 * (Broadcom: It may be that PHY_B_PEC_EN_LTR has to be set.)	 * (In this case it has to be added here. But we will see. XXX)	 */}	/* SkGeXmitLED *//****************************************************************************** * *	DoCalcAddr() - Calculates the start and the end address of a queue. * * Description: *	This function calculates the start and the end address of a queue. *  Afterwards the 'StartVal' is incremented to the next start position. *	If the port is already initialized the calculated values *	will be checked against the configured values and an *	error will be returned, if they are not equal. *	If the port is not initialized the values will be written to *	*StartAdr and *EndAddr. * * Returns: *	0:	success *	1:	configuration error */static int DoCalcAddr(SK_AC		*pAC, 			/* adapter context */SK_GEPORT	*pPrt,			/* port index */int			QuSize,			/* size of the queue to configure in kB */SK_U32		*StartVal,		/* start value for address calculation */SK_U32		*QuStartAddr,	/* start addr to calculate */SK_U32		*QuEndAddr)		/* end address to calculate */{	SK_U32	EndVal;	SK_U32	NextStart;	int		Rtv;	Rtv = 0;	if (QuSize == 0) {		EndVal = *StartVal;		NextStart = EndVal;	}	else {		EndVal = *StartVal + ((SK_U32)QuSize * 1024) - 1;		NextStart = EndVal + 1;	}	if (pPrt->PState >= SK_PRT_INIT) {		if (*StartVal != *QuStartAddr || EndVal != *QuEndAddr) {			Rtv = 1;		}	}	else {		*QuStartAddr = *StartVal;		*QuEndAddr = EndVal;	}	*StartVal = NextStart;	return(Rtv);}	/* DoCalcAddr *//****************************************************************************** * *	SkGeInitAssignRamToQueues() - allocate default queue sizes * * Description: *	This function assigns the memory to the different queues and ports. *	When DualNet is set to SK_TRUE all ports get the same amount of memory. *  Otherwise the first port gets most of the memory and all the *	other ports just the required minimum. *	This function can only be called when pAC->GIni.GIRamSize and *	pAC->GIni.GIMacsFound have been initialized, usually this happens *	at init level 1 * * Returns: *	0 - ok *	1 - invalid input values *	2 - not enough memory */int SkGeInitAssignRamToQueues(SK_AC	*pAC,			/* Adapter context */int		ActivePort,		/* Active Port in RLMT mode */SK_BOOL	DualNet)		/* adapter context */{	int	i;	int	UsedKilobytes;			/* memory already assigned */	int	ActivePortKilobytes;	/* memory available for active port */	SK_GEPORT *pGePort;	UsedKilobytes = 0;	if (ActivePort >= pAC->GIni.GIMacsFound) {		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,			("SkGeInitAssignRamToQueues: ActivePort (%d) invalid\n",			ActivePort));		return(1);	}	if (((pAC->GIni.GIMacsFound * (SK_MIN_RXQ_SIZE + SK_MIN_TXQ_SIZE)) +		((RAM_QUOTA_SYNC == 0) ? 0 : SK_MIN_TXQ_SIZE)) > pAC->GIni.GIRamSize) {		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT,			("SkGeInitAssignRamToQueues: Not enough memory (%d)\n",			 pAC->GIni.GIRamSize));		return(2);	}	if (DualNet) {		/* every port gets the same amount of memory */		ActivePortKilobytes = pAC->GIni.GIRamSize / pAC->GIni.GIMacsFound;		for (i = 0; i < pAC->GIni.GIMacsFound; i++) {			pGePort = &pAC->GIni.GP[i];			/* take away the minimum memory for active queues */			ActivePortKilobytes -= (SK_MIN_RXQ_SIZE + SK_MIN_TXQ_SIZE);			/* receive queue gets the minimum + 80% of the rest */			pGePort->PRxQSize = (int) (ROUND_QUEUE_SIZE_KB((				ActivePortKilobytes * (unsigned long) RAM_QUOTA_RX) / 100))				+ SK_MIN_RXQ_SIZE;			ActivePortKilobytes -= (pGePort->PRxQSize - SK_MIN_RXQ_SIZE);			/* synchronous transmit queue */			pGePort->PXSQSize = 0;			/* asynchronous transmit queue */			pGePort->PXAQSize = (int) ROUND_QUEUE_SIZE_KB(ActivePortKilobytes +				SK_MIN_TXQ_SIZE);		}	}	else {		/* Rlmt Mode or single link adapter */		/* Set standby queue size defaults for all standby ports */		for (i = 0; i < pAC->GIni.GIMacsFound; i++) {			if (i != ActivePort) {				pGePort = &pAC->GIni.GP[i];				pGePort->PRxQSize = SK_MIN_RXQ_SIZE;				pGePort->PXAQSize = SK_MIN_TXQ_SIZE;				pGePort->PXSQSize = 0;				/* Count used RAM */				UsedKilobytes += pGePort->PRxQSize + pGePort->PXAQSize;			}		}		/* what's left? */		ActivePortKilobytes = pAC->GIni.GIRamSize - UsedKilobytes;		/* assign it to the active port */		/* first take away the minimum memory */		ActivePortKilobytes -= (SK_MIN_RXQ_SIZE + SK_MIN_TXQ_SIZE);		pGePort = &pAC->GIni.GP[ActivePort];		/* receive queue get's the minimum + 80% of the rest */		pGePort->PRxQSize = (int) (ROUND_QUEUE_SIZE_KB((ActivePortKilobytes *			(unsigned long) RAM_QUOTA_RX) / 100)) + SK_MIN_RXQ_SIZE;		ActivePortKilobytes -= (pGePort->PRxQSize - SK_MIN_RXQ_SIZE);		/* synchronous transmit queue */		pGePort->PXSQSize = 0;		/* asynchronous transmit queue */		pGePort->PXAQSize = (int) ROUND_QUEUE_SIZE_KB(ActivePortKilobytes) +			SK_MIN_TXQ_SIZE;	}#ifdef VCPU	VCPUprintf(0, "PRxQSize=%u, PXSQSize=%u, PXAQSize=%u\n",		pGePort->PRxQSize, pGePort->PXSQSize, pGePort->PXAQSize);#endif /* VCPU */	return(0);}	/* SkGeInitAssignRamToQueues *//****************************************************************************** * *	SkGeCheckQSize() - Checks the Adapters Queue Size Configuration * * Description: *	This function verifies the Queue Size Configuration specified *	in the variables PRxQSize, PXSQSize, and PXAQSize of all *	used ports. *	This requirements must be fullfilled to have a valid configuration: *		- The size of all queues must not exceed GIRamSize. *		- The queue sizes must be specified in units of 8 kB. *		- The size of Rx queues of available ports must not be *		  smaller than 16 kB. *		- The size of at least one Tx queue (synch. or asynch.) *        of available ports must not be smaller than 16 kB *        when Jumbo Frames are used. *		- The RAM start and end addresses must not be changed *		  for ports which are already initialized. *	Furthermore SkGeCheckQSize() defines the Start and End Addresses *  of all ports and stores them into the HWAC port	structure. * * Returns: *	0:	Queue Size Configuration valid *	1:	Queue Size Configuration invalid */static int SkGeCheckQSize(SK_AC	 *pAC,		/* adapter context */int		 Port)		/* port index */{	SK_GEPORT *pPrt;	int	UsedMem;	/* total memory used (max. found ports) */	int	i;	int	Rtv;	int	Rtv2;	SK_U32	StartAddr;	UsedMem = 0;	Rtv = 0;	for (i = 0; i < pAC->GIni.GIMacsFound; i++) {		pPrt = &pAC->GIni.GP[i];		if ((pPrt->PRxQSize & QZ_UNITS) != 0 ||			(pPrt->PXSQSize & QZ_UNITS) != 0 ||			(pPrt->PXAQSize & QZ_UNITS) != 0) {			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E012, SKERR_HWI_E012MSG);			return(1);		}		if (i == Port && pPrt->PRxQSize < SK_MIN_RXQ_SIZE) {			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E011, SKERR_HWI_E011MSG);			return(1);		}		/*		 * the size of at least one Tx queue (synch. or asynch.) has to be > 0.		 * if Jumbo Frames are used, this size has to be >= 16 kB.		 */		if ((i == Port && pPrt->PXSQSize == 0 && pPrt->PXAQSize == 0) ||			(pAC->GIni.GIPortUsage == SK_JUMBO_LINK &&	    ((pPrt->PXSQSize > 0 && pPrt->PXSQSize < SK_MIN_TXQ_SIZE) ||			 (pPrt->PXAQSize > 0 && pPrt->PXAQSize < SK_MIN_TXQ_SIZE)))) {				SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E023, SKERR_HWI_E023MSG);				return(1);		}		UsedMem += pPrt->PRxQSize + pPrt->PXSQSize + pPrt->PXAQSize;	}	if (UsedMem > pAC->GIni.GIRamSize) {		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E012, SKERR_HWI_E012MSG);		return(1);	}	/* Now start address calculation */	StartAddr = pAC->GIni.GIRamOffs;	for (i = 0; i < pAC->GIni.GIMacsFound; i++) {		pPrt = &pAC->GIni.GP[i];		/* Calculate/Check values for the receive queue */		Rtv2 = DoCalcAddr(pAC, pPrt, pPrt->PRxQSize, &StartAddr,			&pPrt->PRxQRamStart, &pPrt->PRxQRamEnd);		Rtv |= Rtv2;		/* Calculate/Check values for the synchronous Tx queue */		Rtv2 = DoCalcAddr(pAC, pPrt, pPrt->PXSQSize, &StartAddr,			&pPrt->PXsQRamStart, &pPrt->PXsQRamEnd);		Rtv |= Rtv2;		/* Calculate/Check values for the asynchronous Tx queue */		Rtv2 = DoCalcAddr(pAC, pPrt, pPrt->PXAQSize, &StartAddr,			&pPrt->PXaQRamStart, &pPrt->PXaQRamEnd);		Rtv |= Rtv2;		if (Rtv) {			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E013, SKERR_HWI_E013MSG);			return(1);		}	}	return(0);}	/* SkGeCheckQSize *//****************************************************************************** * *	SkGeInitMacArb() - Initialize the MAC Arbiter * * Description: *	This function initializes the MAC Arbiter. *	It must not be called if there is still an *	initialized or active port. * * Returns: *	nothing */static void SkGeInitMacArb(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC)		/* IO context */{	/* release local reset */	SK_OUT16(IoC, B3_MA_TO_CTRL, MA_RST_CLR);	/* configure timeout values */	SK_OUT8(IoC, B3_MA_TOINI_RX1, SK_MAC_TO_53);	SK_OUT8(IoC, B3_MA_TOINI_RX2, SK_MAC_TO_53);	SK_OUT8(IoC, B3_MA_TOINI_TX1, SK_MAC_TO_53);	SK_OUT8(IoC, B3_MA_TOINI_TX2, SK_MAC_TO_53);	SK_OUT8(IoC, B3_MA_RCINI_RX1, 0);	SK_OUT8(IoC, B3_MA_RCINI_RX2, 0);	SK_OUT8(IoC, B3_MA_RCINI_TX1, 0);	SK_OUT8(IoC, B3_MA_RCINI_TX2, 0);	/* recovery values are needed for XMAC II Rev. B2 only */	/* Fast Output Enable Mode was intended to use with Rev. B2, but now? */	/*	 * There is no start or enable button to push, therefore	 * the MAC arbiter is configured and enabled now.	 */}	/* SkGeInitMacArb *//****************************************************************************** *

⌨️ 快捷键说明

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