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

📄 skgeinit.c

📁 该软件根据网络数据生成NetFlow记录。NetFlow可用于网络规划、负载均衡、安全监控等
💻 C
📖 第 1 页 / 共 5 页
字号:
	if ((Dir & SK_STOP_RX) != 0) {		/*		 * 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			 */			SK_OUT16(IoC, B3_PA_CTRL, (SK_U16)((Port == MAC_1) ?				PA_CLR_TO_RX1 : PA_CLR_TO_RX2));			DWord = TestStopBit(pAC, IoC, pPrt->PRxQOff);			/* timeout if i==0 (bug fix for #10748) */			if (--i == 0) {				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_HWI_E024,					SKERR_HWI_E024MSG);				break;			}			/*			 * 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);		/* 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 */		SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_SET_RESET);		/* Reset the RAM Buffer receive queue */		SK_OUT8(IoC, RB_ADDR(pPrt->PRxQOff, RB_CTRL), RB_RST_SET);		/* Reset Rx MAC FIFO */#ifdef GENESIS		if (pAC->GIni.GIGenesis) {						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);		}#endif /* GENESIS */	#ifdef YUKON		if (pAC->GIni.GIYukon) {			/* Reset Rx MAC FIFO */			SK_OUT8(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), (SK_U8)GMF_RST_SET);		}#endif /* YUKON */	}}	/* 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->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_U8)SK_LMODE_AUTOFULL;		pPrt->PLinkSpeedCap = (SK_U8)SK_LSPEED_CAP_1000MBPS;		pPrt->PLinkSpeed = (SK_U8)SK_LSPEED_1000MBPS;		pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_UNKNOWN;		pPrt->PLinkModeConf = (SK_U8)SK_LMODE_AUTOSENSE;		pPrt->PFlowCtrlMode = (SK_U8)SK_FLOW_MODE_SYM_OR_REM;		pPrt->PLinkCap = (SK_U8)(SK_LMODE_CAP_HALF | SK_LMODE_CAP_FULL |			SK_LMODE_CAP_AUTOHALF | SK_LMODE_CAP_AUTOFULL);		pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_UNKNOWN;		pPrt->PFlowCtrlCap = (SK_U8)SK_FLOW_MODE_SYM_OR_REM;		pPrt->PFlowCtrlStatus = (SK_U8)SK_FLOW_STAT_NONE;		pPrt->PMSCap = 0;		pPrt->PMSMode = (SK_U8)SK_MS_MODE_AUTO;		pPrt->PMSStatus = (SK_U8)SK_MS_STAT_UNSET;		pPrt->PLipaAutoNeg = (SK_U8)SK_LIPA_UNKNOWN;		pPrt->PAutoNegFail = SK_FALSE;		pPrt->PHWLinkUp = SK_FALSE;		pPrt->PLinkBroken = SK_TRUE; /* See WA code */	}	pAC->GIni.GIPortUsage = SK_RED_LINK;	pAC->GIni.GILedBlinkCtrl = (SK_U16)OemConfig.Value;	pAC->GIni.GIValIrqMask = IS_ALL_MSK;}	/* SkGeInit0*/#ifdef SK_PCI_RESET/****************************************************************************** * *	SkGePciReset() - Reset PCI interface * * Description: *	o Read PCI configuration. *	o Change power state to 3. *	o Change power state to 0. *	o Restore PCI configuration. * * Returns: *	0:	Success. *	1:	Power state could not be changed to 3. */static int SkGePciReset(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC)		/* IO context */{	int		i;	SK_U16	PmCtlSts;	SK_U32	Bp1;	SK_U32	Bp2;	SK_U16	PciCmd;	SK_U8	Cls;	SK_U8	Lat;	SK_U8	ConfigSpace[PCI_CFG_SIZE];	/*	 * Note: Switching to D3 state is like a software reset.	 *		 Switching from D3 to D0 is a hardware reset.	 *		 We have to save and restore the configuration space.	 */	for (i = 0; i < PCI_CFG_SIZE; i++) {		SkPciReadCfgDWord(pAC, i*4, &ConfigSpace[i]);	}	/* We know the RAM Interface Arbiter is enabled. */	SkPciWriteCfgWord(pAC, PCI_PM_CTL_STS, PCI_PM_STATE_D3);	SkPciReadCfgWord(pAC, PCI_PM_CTL_STS, &PmCtlSts);		if ((PmCtlSts & PCI_PM_STATE_MSK) != PCI_PM_STATE_D3) {		return(1);	}	/* Return to D0 state. */	SkPciWriteCfgWord(pAC, PCI_PM_CTL_STS, PCI_PM_STATE_D0);	/* Check for D0 state. */	SkPciReadCfgWord(pAC, PCI_PM_CTL_STS, &PmCtlSts);		if ((PmCtlSts & PCI_PM_STATE_MSK) != PCI_PM_STATE_D0) {		return(1);	}	/* Check PCI Config Registers. */	SkPciReadCfgWord(pAC, PCI_COMMAND, &PciCmd);	SkPciReadCfgByte(pAC, PCI_CACHE_LSZ, &Cls);	SkPciReadCfgDWord(pAC, PCI_BASE_1ST, &Bp1);	SkPciReadCfgDWord(pAC, PCI_BASE_2ND, &Bp2);	SkPciReadCfgByte(pAC, PCI_LAT_TIM, &Lat);		if (PciCmd != 0 || Cls != (SK_U8)0 || Lat != (SK_U8)0 ||		(Bp1 & 0xfffffff0L) != 0 || Bp2 != 1) {		return(1);	}	/* Restore PCI Config Space. */	for (i = 0; i < PCI_CFG_SIZE; i++) {		SkPciWriteCfgDWord(pAC, i*4, ConfigSpace[i]);	}	return(0);}	/* SkGePciReset */#endif /* SK_PCI_RESET *//****************************************************************************** * *	SkGeInit1() - Level 1 Initialization * * Description: *	o Do a software reset. *	o Clear all reset bits. *	o Verify that the detected hardware is present. *	  Return an error if not. *	o Get the hardware configuration *		+ Read the number of MACs/Ports. *		+ Read the RAM size. *		+ Read the PCI Revision Id. *		+ Find out the adapters host clock speed *		+ Read and check the PHY type * * Returns: *	0:	success *	5:	Unexpected PHY type detected *	6:	HW self test failed */static int SkGeInit1(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC)		/* IO context */{	SK_U8	Byte;	SK_U16	Word;	SK_U16	CtrlStat;	SK_U32	DWord;	int	RetVal;	int	i;	RetVal = 0;	/* save CLK_RUN bits (YUKON-Lite) */	SK_IN16(IoC, B0_CTST, &CtrlStat);#ifdef SK_PCI_RESET	(void)SkGePciReset(pAC, IoC);#endif /* SK_PCI_RESET */	/* do the SW-reset */	SK_OUT8(IoC, B0_CTST, CS_RST_SET);	/* release the SW-reset */	SK_OUT8(IoC, B0_CTST, CS_RST_CLR);	/* reset all error bits in the PCI STATUS register */	/*	 * Note: PCI Cfg cycles cannot be used, because they are not	 *		 available on some platforms after 'boot time'.	 */	SK_IN16(IoC, PCI_C(PCI_STATUS), &Word);		SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);	SK_OUT16(IoC, PCI_C(PCI_STATUS), (SK_U16)(Word | PCI_ERRBITS));	SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);	/* release Master Reset */	SK_OUT8(IoC, B0_CTST, CS_MRST_CLR);#ifdef CLK_RUN	CtrlStat |= CS_CLK_RUN_ENA;#endif /* CLK_RUN */	/* restore CLK_RUN bits */	SK_OUT16(IoC, B0_CTST, (SK_U16)(CtrlStat &		(CS_CLK_RUN_HOT | CS_CLK_RUN_RST | CS_CLK_RUN_ENA)));		/* read Chip Identification Number */	SK_IN8(IoC, B2_CHIP_ID, &Byte);	pAC->GIni.GIChipId = Byte;		/* read number of MACs */	SK_IN8(IoC, B2_MAC_CFG, &Byte);	pAC->GIni.GIMacsFound = (Byte & CFG_SNG_MAC) ? 1 : 2;		/* get Chip Revision Number */	pAC->GIni.GIChipRev = (SK_U8)((Byte & CFG_CHIP_R_MSK) >> 4);	/* get diff. PCI parameters */	SK_IN16(IoC, B0_CTST, &CtrlStat);		/* read the adapters RAM size */	SK_IN8(IoC, B2_E_0, &Byte);		pAC->GIni.GIGenesis = SK_FALSE;	pAC->GIni.GIYukon = SK_FALSE;	pAC->GIni.GIYukonLite = SK_FALSE;#ifdef GENESIS	if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) {		pAC->GIni.GIGenesis = SK_TRUE;		if (Byte == (SK_U8)3) {									/* special case: 4 x 64k x 36, offset = 0x80000 */			pAC->GIni.GIRamSize = 1024;			pAC->GIni.GIRamOffs = (SK_U32)512 * 1024;		}		else {			pAC->GIni.GIRamSize = (int)Byte * 512;			pAC->GIni.GIRamOffs = 0;		}		/* all GE adapters work with 53.125 MHz host clock */		pAC->GIni.GIHstClkFact = SK_FACT_53;				/* set Descr. Poll Timer Init Value to 250 ms */		pAC->GIni.GIPollTimerVal =			SK_DPOLL_DEF * (SK_U32)pAC->GIni.GIHstClkFact / 100;	}#endif /* GENESIS */	#ifdef YUKON	if (pAC->GIni.GIChipId != CHIP_ID_GENESIS) {				pAC->GIni.GIYukon = SK_TRUE;				pAC->GIni.GIRamSize = (Byte == (SK_U8)0) ? 128 : (int)Byte * 4;				pAC->GIni.GIRamOffs = 0;				/* WA for chip Rev. A */		pAC->GIni.GIWolOffs = (pAC->GIni.GIChipId == CHIP_ID_YUKON &&			pAC->GIni.GIChipRev == 0) ? WOL_REG_OFFS : 0;				/* get PM Capabilities of PCI config space */		SK_IN16(IoC, PCI_C(PCI_PM_CAP_REG), &Word);		/* check if VAUX is available */		if (((CtrlStat & CS_VAUX_AVAIL) != 0) &&			/* check also if PME from D3cold is set */			((Word & PCI_PME_D3C_SUP) != 0)) {			/* set entry in GE init struct */			pAC->GIni.GIVauxAvail = SK_TRUE;		}				if (pAC->GIni.GIChipId == CHIP_ID_YUKON_LITE) {			/* this is Rev. A1 */			pAC->GIni.GIYukonLite = SK_TRUE;		}		else {			/* save Flash-Address Register */			SK_IN32(IoC, B2_FAR, &DWord);			/* test Flash-Address Register */			SK_OUT8(IoC, B2_FAR + 3, 0xff);			SK_IN8(IoC, B2_FAR + 3, &Byte);			if (Byte != 0) {				/* this is Rev. A0 */				pAC->GIni.GIYukonLite = SK_TRUE;				/* restore Flash-Address Register */				SK_OUT32(IoC, B2_FAR, DWord);			}		}		/* switch power to VCC (WA for VAUX problem) */		SK_OUT8(IoC, B0_POWER_CTRL, (SK_U8)(PC_VAUX_ENA | PC_VCC_ENA |						    PC_VAUX_OFF | PC_VCC_ON));		/* read the Interrupt source */		SK_IN32(IoC, B0_ISRC, &DWord);				if ((DWord & IS_HW_ERR) != 0) {			/* read the HW Error Interrupt source */			SK_IN32(IoC, B0_HWE_ISRC, &DWord);						if ((DWord & IS_IRQ_SENSOR) != 0) {				/* disable HW Error IRQ */				pAC->GIni.GIValIrqMask &= ~IS_HW_ERR;			}		}				for (i = 0; i < pAC->GIni.GIMacsFound; i++) {			/* set GMAC Link Control reset */			SK_OUT16(IoC, MR_ADDR(i, GMAC_LINK_CTRL), GMLC_RST_SET);			/* clear GMAC Link Control reset */			SK_OUT16(IoC, MR_ADDR(i, GMAC_LINK_CTRL), GMLC_RST_CLR);		}		/* all YU chips work with 78.125 MHz host clock */		pAC->GIni.GIHstClkFact = SK_FACT_78;				pAC->GIni.GIPollTimerVal = SK_DPOLL_MAX;	/* 215 ms */	}#endif /* YUKON */	/* check if 64-bit PCI Slot is present */	pAC->GIni.GIPciSlot64 = (SK_BOOL)((CtrlStat & CS_BUS_SLOT_SZ) != 0);		/* check if 66 MHz PCI Clock is active */	pAC->GIni.GIPciClock66 = (SK_BOOL)((CtrlStat & CS_BUS_CLOCK) != 0);	/* read PCI HW Revision Id. */	SK_IN8(IoC, PCI_C(PCI_REV_ID), &Byte);	pAC->GIni.GIPciHwRev = Byte;	/* read the PMD type */	SK_IN8(IoC, B2_PMD_TYP, &Byte);	pAC->GIni.GICopperType = (SK_U8)(Byte == 'T');	/* read the PHY type */	SK_IN8(IoC, B2_E_1, &Byte);	Byte &= 0x0f;	/* the PHY type is stored in the lower nibble */	for (i = 0; i < pAC->GIni.GIMacsFound; i++) {		#ifdef GENESIS		if (pAC->GIni.GIGenesis) {			switch (Byte) {			case SK_PHY_XMAC:				pAC->GIni.GP[i].PhyAddr = PHY_ADDR_XMAC;				break;			case SK_PHY_BCOM:				pAC->GIni.GP[i].PhyAddr = PHY_ADDR_BCOM;				pAC->GIni.GP[i].PMSCap = (SK_U8)(SK_MS_CAP_AUTO |					SK_MS_CAP_MASTER | SK_MS_CAP_SLAVE);				break;#ifdef OTHER_PHY			case SK_PHY_LONE:				pAC->GIni.GP[i].PhyAddr = PHY_ADDR_LONE;				break;			case SK_PHY_NAT:				pAC->GIni.GP[i].PhyAddr = PHY_ADDR_NAT;				

⌨️ 快捷键说明

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