📄 skgeinit.c
字号:
* Revision 1.8 1998/09/11 05:29:14 gklug * add: init state of a port * * Revision 1.7 1998/09/04 09:26:25 malthoff * Short temporary modification. * * Revision 1.6 1998/09/04 08:27:59 malthoff * Remark the do-while in StopPort() because it never ends * without a GE adapter. * * Revision 1.5 1998/09/03 14:05:45 malthoff * Change comment for SkGeInitPort(). Do not * repair the queue sizes if invalid. * * Revision 1.4 1998/09/03 10:03:19 malthoff * Implement the new interface according to the * reviewed interface specification. * * Revision 1.3 1998/08/19 09:11:25 gklug * fix: struct are removed from c-source (see CCC) * * Revision 1.2 1998/07/28 12:33:58 malthoff * Add 'IoC' parameter in function declaration and SK IO macros. * * Revision 1.1 1998/07/23 09:48:57 malthoff * Creation. First dummy 'C' file. * SkGeInit(Level 0) is card_start for GE. * SkGeDeInit() is card_stop for GE. * * ******************************************************************************/#include "h/skdrv1st.h"#include "h/skdrv2nd.h"/* global variables ***********************************************************//* local variables ************************************************************/#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))static const char SysKonnectFileId[] = "@(#) $Id: skgeinit.c,v 1.93 2003/05/28 15:44:43 rschmidt Exp $ (C) Marvell.";#endifstruct s_QOffTab { int RxQOff; /* Receive Queue Address Offset */ int XsQOff; /* Sync Tx Queue Address Offset */ int XaQOff; /* Async Tx Queue Address Offset */};static struct s_QOffTab QOffTab[] = { {Q_R1, Q_XS1, Q_XA1}, {Q_R2, Q_XS2, Q_XA2}};struct s_Config { char ScanString[8]; SK_U32 Value;};static struct s_Config OemConfig = { {'O','E','M','_','C','o','n','f'},#ifdef SK_OEM_CONFIG OEM_CONFIG_VALUE,#else 0,#endif};/****************************************************************************** * * SkGePollRxD() - Enable / Disable Descriptor Polling of RxD Ring * * Description: * Enable or disable the descriptor polling of the receive descriptor * ring (RxD) for port 'Port'. * The new configuration is *not* saved over any SkGeStopPort() and * SkGeInitPort() calls. * * Returns: * nothing */void SkGePollRxD(SK_AC *pAC, /* adapter context */SK_IOC IoC, /* IO context */int Port, /* Port Index (MAC_1 + n) */SK_BOOL PollRxD) /* SK_TRUE (enable pol.), SK_FALSE (disable pol.) */{ SK_GEPORT *pPrt; pPrt = &pAC->GIni.GP[Port]; 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 = (SK_U32)(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 */#if (!defined(SK_SLIM) || defined(GENESIS))/****************************************************************************** * * 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 */#endif /* !SK_SLIM || GENESIS *//****************************************************************************** * * 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 SK_FAR *pPrt, /* port index */int QuSize, /* size of the queue to configure in kB */SK_U32 SK_FAR *StartVal, /* start value for address calculation */SK_U32 SK_FAR *QuStartAddr,/* start addr to calculate */SK_U32 SK_FAR *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 i; int Rtv; int Rtv2; SK_U32 StartAddr;#ifndef SK_SLIM int UsedMem; /* total memory used (max. found ports) */#endif Rtv = 0; #ifndef SK_SLIM
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -