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

📄 skethtool.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 2 页
字号:
	"tx_buffer_underrun_errors",	"tx_heartbeat_errors",	"tx_window_errors",};static int getStatsCount(struct net_device *dev){	return ARRAY_SIZE(StringsStats);}static void getStrings(struct net_device *dev, u32 stringset, u8 *data){	switch(stringset) {	case ETH_SS_STATS:		memcpy(data, *StringsStats, sizeof(StringsStats));		break;	}}static void getEthtoolStats(struct net_device *dev,			    struct ethtool_stats *stats, u64 *data){	const DEV_NET	*pNet = netdev_priv(dev);	const SK_AC *pAC = pNet->pAC;	const SK_PNMI_STRUCT_DATA *pPnmiStruct = &pAC->PnmiStruct;	*data++ = pPnmiStruct->Stat[0].StatRxOkCts;	*data++ = pPnmiStruct->Stat[0].StatTxOkCts;	*data++ = pPnmiStruct->Stat[0].StatRxOctetsOkCts;	*data++ = pPnmiStruct->Stat[0].StatTxOctetsOkCts;	*data++ = pPnmiStruct->InErrorsCts;	*data++ = pPnmiStruct->Stat[0].StatTxSingleCollisionCts;	*data++ = pPnmiStruct->RxNoBufCts;	*data++ = pPnmiStruct->TxNoBufCts;	*data++ = pPnmiStruct->Stat[0].StatRxMulticastOkCts;	*data++ = pPnmiStruct->Stat[0].StatTxSingleCollisionCts;	*data++ = pPnmiStruct->Stat[0].StatRxRuntCts;	*data++ = pPnmiStruct->Stat[0].StatRxFifoOverflowCts;	*data++ = pPnmiStruct->Stat[0].StatRxFcsCts;	*data++ = pPnmiStruct->Stat[0].StatRxFramingCts;	*data++ = pPnmiStruct->Stat[0].StatRxShortsCts;	*data++ = pPnmiStruct->Stat[0].StatRxTooLongCts;	*data++ = pPnmiStruct->Stat[0].StatRxCextCts;	*data++ = pPnmiStruct->Stat[0].StatRxSymbolCts;	*data++ = pPnmiStruct->Stat[0].StatRxIRLengthCts;	*data++ = pPnmiStruct->Stat[0].StatRxCarrierCts;	*data++ = pPnmiStruct->Stat[0].StatRxJabberCts;	*data++ = pPnmiStruct->Stat[0].StatRxMissedCts;	*data++ = pAC->stats.tx_aborted_errors;	*data++ = pPnmiStruct->Stat[0].StatTxCarrierCts;	*data++ = pPnmiStruct->Stat[0].StatTxFifoUnderrunCts;	*data++ = pPnmiStruct->Stat[0].StatTxCarrierCts;	*data++ = pAC->stats.tx_window_errors;}/***************************************************************************** * * 	toggleLeds - Changes the LED state of an adapter * * Description: *	This function changes the current state of all LEDs of an adapter so *	that it can be located by a user.  * * Returns:	N/A * */static void toggleLeds(DEV_NET *pNet, int on){	SK_AC *pAC = pNet->pAC;	int port = pNet->PortNr;	void __iomem *io = pAC->IoBase;	if (pAC->GIni.GIGenesis) {		SK_OUT8(io, MR_ADDR(port,LNK_LED_REG), 			on ? SK_LNK_ON : SK_LNK_OFF);		SkGeYellowLED(pAC, io, 			      on ? (LED_ON >> 1) : (LED_OFF >> 1));		SkGeXmitLED(pAC, io, MR_ADDR(port,RX_LED_INI),			    on ? SK_LED_TST : SK_LED_DIS);		if (pAC->GIni.GP[port].PhyType == SK_PHY_BCOM)			SkXmPhyWrite(pAC, io, port, PHY_BCOM_P_EXT_CTRL, 				     on ? PHY_B_PEC_LED_ON : PHY_B_PEC_LED_OFF);		else if (pAC->GIni.GP[port].PhyType == SK_PHY_LONE)			SkXmPhyWrite(pAC, io, port, PHY_LONE_LED_CFG,				     on ? 0x0800 : PHY_L_LC_LEDT);		else			SkGeXmitLED(pAC, io, MR_ADDR(port,TX_LED_INI),				    on ? SK_LED_TST : SK_LED_DIS);	} else {		const u16 YukLedOn = (PHY_M_LED_MO_DUP(MO_LED_ON)  |				      PHY_M_LED_MO_10(MO_LED_ON)   |				      PHY_M_LED_MO_100(MO_LED_ON)  |				      PHY_M_LED_MO_1000(MO_LED_ON) | 				      PHY_M_LED_MO_RX(MO_LED_ON));		const u16  YukLedOff = (PHY_M_LED_MO_DUP(MO_LED_OFF)  |					PHY_M_LED_MO_10(MO_LED_OFF)   |					PHY_M_LED_MO_100(MO_LED_OFF)  |					PHY_M_LED_MO_1000(MO_LED_OFF) | 					PHY_M_LED_MO_RX(MO_LED_OFF));			SkGmPhyWrite(pAC,io,port,PHY_MARV_LED_CTRL,0);		SkGmPhyWrite(pAC,io,port,PHY_MARV_LED_OVER, 			     on ? YukLedOn : YukLedOff);	}}/***************************************************************************** * * 	skGeBlinkTimer - Changes the LED state of an adapter * * Description: *	This function changes the current state of all LEDs of an adapter so *	that it can be located by a user. If the requested time interval for *	this test has elapsed, this function cleans up everything that was  *	temporarily setup during the locate NIC test. This involves of course *	also closing or opening any adapter so that the initial board state  *	is recovered. * * Returns:	N/A * */void SkGeBlinkTimer(unsigned long data){	struct net_device *dev = (struct net_device *) data;	DEV_NET *pNet = netdev_priv(dev);	SK_AC *pAC = pNet->pAC;	toggleLeds(pNet, pAC->LedsOn);	pAC->LedsOn = !pAC->LedsOn;	mod_timer(&pAC->BlinkTimer, jiffies + HZ/4);}/***************************************************************************** * * 	locateDevice - start the locate NIC feature of the elected adapter  * * Description: *	This function is used if the user want to locate a particular NIC. *	All LEDs are regularly switched on and off, so the NIC can easily *	be identified. * * Returns:	 *	==0:	everything fine, no error, locateNIC test was started *	!=0:	one locateNIC test runs already * */static int locateDevice(struct net_device *dev, u32 data){	DEV_NET *pNet = netdev_priv(dev);	SK_AC *pAC = pNet->pAC;	if(!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ))		data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ);	/* start blinking */	pAC->LedsOn = 0;	mod_timer(&pAC->BlinkTimer, jiffies);	msleep_interruptible(data * 1000);	del_timer_sync(&pAC->BlinkTimer);	toggleLeds(pNet, 0);	return 0;}/***************************************************************************** * * 	getPauseParams - retrieves the pause parameters * * Description: *	All current pause parameters of a selected adapter are placed  *	in the passed ethtool_pauseparam structure and are returned. * * Returns:	N/A * */static void getPauseParams(struct net_device *dev, struct ethtool_pauseparam *epause) {	DEV_NET	*pNet = netdev_priv(dev);	SK_AC *pAC = pNet->pAC;	SK_GEPORT *pPort = &pAC->GIni.GP[pNet->PortNr];	epause->rx_pause = (pPort->PFlowCtrlMode == SK_FLOW_MODE_SYMMETRIC) ||		  (pPort->PFlowCtrlMode == SK_FLOW_MODE_SYM_OR_REM);	epause->tx_pause = epause->rx_pause || (pPort->PFlowCtrlMode == SK_FLOW_MODE_LOC_SEND);	epause->autoneg = epause->rx_pause || epause->tx_pause;}/***************************************************************************** * *	setPauseParams - configures the pause parameters of an adapter * * Description: *	This function sets the Rx or Tx pause parameters  * * Returns: *	==0:	everything fine, no error *	!=0:	the return value is the error code of the failure  */static int setPauseParams(struct net_device *dev , struct ethtool_pauseparam *epause){	DEV_NET	*pNet = netdev_priv(dev);	SK_AC *pAC = pNet->pAC;	SK_GEPORT *pPort = &pAC->GIni.GP[pNet->PortNr];	u32	instance = pnmiInstance(pNet);	struct ethtool_pauseparam old;	u8	oldspeed = pPort->PLinkSpeedUsed;	char	buf[4];	int	len = 1;	int ret;	/*	** we have to determine the current settings to see if 	** the operator requested any modification of the flow 	** control parameters...	*/	getPauseParams(dev, &old);	/*	** perform modifications regarding the changes 	** requested by the operator	*/	if (epause->autoneg != old.autoneg) 		*buf = epause->autoneg ? SK_FLOW_MODE_NONE : SK_FLOW_MODE_SYMMETRIC;	else {		if (epause->rx_pause && epause->tx_pause) 			*buf = SK_FLOW_MODE_SYMMETRIC;		else if (epause->rx_pause && !epause->tx_pause)			*buf =  SK_FLOW_MODE_SYM_OR_REM;		else if (!epause->rx_pause && epause->tx_pause)			*buf =  SK_FLOW_MODE_LOC_SEND;		else			*buf = SK_FLOW_MODE_NONE;	}	ret = SkPnmiSetVar(pAC, pAC->IoBase, OID_SKGE_FLOWCTRL_MODE,			 &buf, &len, instance, pNet->NetNr);	if (ret != SK_PNMI_ERR_OK) {		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_CTRL,			   ("ethtool (sk98lin): error changing rx/tx pause (%i)\n", ret));		goto err;	}	/*	** It may be that autoneg has been disabled! Therefore	** set the speed to the previously used value...	*/	if (!epause->autoneg) {		len = 1;		ret = SkPnmiSetVar(pAC, pAC->IoBase, OID_SKGE_SPEED_MODE, 				   &oldspeed, &len, instance, pNet->NetNr);		if (ret != SK_PNMI_ERR_OK) 			SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_CTRL,				   ("ethtool (sk98lin): error setting speed (%i)\n", ret));	} err:        return ret ? -EIO : 0;}struct ethtool_ops SkGeEthtoolOps = {	.get_settings		= getSettings,	.set_settings		= setSettings,	.get_drvinfo		= getDriverInfo,	.get_strings		= getStrings,	.get_stats_count	= getStatsCount,	.get_ethtool_stats	= getEthtoolStats,	.phys_id		= locateDevice,	.get_pauseparam		= getPauseParams,	.set_pauseparam		= setPauseParams,	.get_link		= ethtool_op_get_link,	.get_perm_addr		= ethtool_op_get_perm_addr,};

⌨️ 快捷键说明

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