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

📄 gianfar_ethtool.c

📁 Powerpc网络处理器MPC85xx增强型三速以太控制器驱动程序
💻 C
📖 第 1 页 / 共 2 页
字号:
	cvals->pkt_rate_high = 0;	cvals->rx_coalesce_usecs_high = 0;	cvals->rx_max_coalesced_frames_high = 0;	cvals->tx_coalesce_usecs_high = 0;	cvals->tx_max_coalesced_frames_high = 0;	/* How often to do adaptive coalescing packet rate sampling,	 * measured in seconds.  Must not be zero.	 */	cvals->rate_sample_interval = 0;	return 0;}/* Change the coalescing values. * Both cvals->*_usecs and cvals->*_frames have to be > 0 * in order for coalescing to be active */static int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals){	struct gfar_private *priv = netdev_priv(dev);	if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_COALESCE))		return -EOPNOTSUPP;	/* Set up rx coalescing */	if ((cvals->rx_coalesce_usecs == 0) ||	    (cvals->rx_max_coalesced_frames == 0))		priv->rxcoalescing = 0;	else		priv->rxcoalescing = 1;	if (NULL == priv->phydev)		return -ENODEV;	/* Check the bounds of the values */	if (cvals->rx_coalesce_usecs > GFAR_MAX_COAL_USECS) {		pr_info("Coalescing is limited to %d microseconds\n",				GFAR_MAX_COAL_USECS);		return -EINVAL;	}	if (cvals->rx_max_coalesced_frames > GFAR_MAX_COAL_FRAMES) {		pr_info("Coalescing is limited to %d frames\n",				GFAR_MAX_COAL_FRAMES);		return -EINVAL;	}	priv->rxtime = gfar_usecs2ticks(priv, cvals->rx_coalesce_usecs);	priv->rxcount = cvals->rx_max_coalesced_frames;	/* Set up tx coalescing */	if ((cvals->tx_coalesce_usecs == 0) ||	    (cvals->tx_max_coalesced_frames == 0))		priv->txcoalescing = 0;	else		priv->txcoalescing = 1;	/* Check the bounds of the values */	if (cvals->tx_coalesce_usecs > GFAR_MAX_COAL_USECS) {		pr_info("Coalescing is limited to %d microseconds\n",				GFAR_MAX_COAL_USECS);		return -EINVAL;	}	if (cvals->tx_max_coalesced_frames > GFAR_MAX_COAL_FRAMES) {		pr_info("Coalescing is limited to %d frames\n",				GFAR_MAX_COAL_FRAMES);		return -EINVAL;	}	priv->txtime = gfar_usecs2ticks(priv, cvals->tx_coalesce_usecs);	priv->txcount = cvals->tx_max_coalesced_frames;	if (priv->rxcoalescing)		gfar_write(&priv->regs->rxic,			   mk_ic_value(priv->rxcount, priv->rxtime));	else		gfar_write(&priv->regs->rxic, 0);	if (priv->txcoalescing)		gfar_write(&priv->regs->txic,			   mk_ic_value(priv->txcount, priv->txtime));	else		gfar_write(&priv->regs->txic, 0);	return 0;}/* Fills in rvals with the current ring parameters.  Currently, * rx, rx_mini, and rx_jumbo rings are the same size, as mini and * jumbo are ignored by the driver */static void gfar_gringparam(struct net_device *dev, struct ethtool_ringparam *rvals){	struct gfar_private *priv = netdev_priv(dev);	rvals->rx_max_pending = GFAR_RX_MAX_RING_SIZE;	rvals->rx_mini_max_pending = GFAR_RX_MAX_RING_SIZE;	rvals->rx_jumbo_max_pending = GFAR_RX_MAX_RING_SIZE;	rvals->tx_max_pending = GFAR_TX_MAX_RING_SIZE;	/* Values changeable by the user.  The valid values are	 * in the range 1 to the "*_max_pending" counterpart above.	 */	rvals->rx_pending = priv->rx_ring_size;	rvals->rx_mini_pending = priv->rx_ring_size;	rvals->rx_jumbo_pending = priv->rx_ring_size;	rvals->tx_pending = priv->tx_ring_size;}/* Change the current ring parameters, stopping the controller if * necessary so that we don't mess things up while we're in * motion.  We wait for the ring to be clean before reallocating * the rings. */static int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rvals){	struct gfar_private *priv = netdev_priv(dev);	int err = 0;	if (rvals->rx_pending > GFAR_RX_MAX_RING_SIZE)		return -EINVAL;	if (!is_power_of_2(rvals->rx_pending)) {		printk("%s: Ring sizes must be a power of 2\n",				dev->name);		return -EINVAL;	}	if (rvals->tx_pending > GFAR_TX_MAX_RING_SIZE)		return -EINVAL;	if (!is_power_of_2(rvals->tx_pending)) {		printk("%s: Ring sizes must be a power of 2\n",				dev->name);		return -EINVAL;	}	if (dev->flags & IFF_UP) {		unsigned long flags;		/* Halt TX and RX, and process the frames which		 * have already been received */		spin_lock_irqsave(&priv->txlock, flags);		spin_lock(&priv->rxlock);		gfar_halt(dev);		gfar_clean_rx_ring(dev, priv->rx_ring_size);		spin_unlock(&priv->rxlock);		spin_unlock_irqrestore(&priv->txlock, flags);		/* Now we take down the rings to rebuild them */		stop_gfar(dev);	}	/* Change the size */	priv->rx_ring_size = rvals->rx_pending;	priv->tx_ring_size = rvals->tx_pending;	/* Rebuild the rings with the new size */	if (dev->flags & IFF_UP)		err = startup_gfar(dev);	return err;}static int gfar_set_rx_csum(struct net_device *dev, uint32_t data){	struct gfar_private *priv = netdev_priv(dev);	unsigned long flags;	int err = 0;	if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))		return -EOPNOTSUPP;	if (dev->flags & IFF_UP) {		/* Halt TX and RX, and process the frames which		 * have already been received */		spin_lock_irqsave(&priv->txlock, flags);		spin_lock(&priv->rxlock);		gfar_halt(dev);		gfar_clean_rx_ring(dev, priv->rx_ring_size);		spin_unlock(&priv->rxlock);		spin_unlock_irqrestore(&priv->txlock, flags);		/* Now we take down the rings to rebuild them */		stop_gfar(dev);	}	spin_lock_irqsave(&priv->bflock, flags);	priv->rx_csum_enable = data;	spin_unlock_irqrestore(&priv->bflock, flags);	if (dev->flags & IFF_UP)		err = startup_gfar(dev);	return err;}static uint32_t gfar_get_rx_csum(struct net_device *dev){	struct gfar_private *priv = netdev_priv(dev);	if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))		return 0;	return priv->rx_csum_enable;}static int gfar_set_tx_csum(struct net_device *dev, uint32_t data){	unsigned long flags;	struct gfar_private *priv = netdev_priv(dev);	if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))		return -EOPNOTSUPP;	spin_lock_irqsave(&priv->txlock, flags);	gfar_halt(dev);	if (data)		dev->features |= NETIF_F_IP_CSUM;	else		dev->features &= ~NETIF_F_IP_CSUM;	gfar_start(dev);	spin_unlock_irqrestore(&priv->txlock, flags);	return 0;}static uint32_t gfar_get_tx_csum(struct net_device *dev){	struct gfar_private *priv = netdev_priv(dev);	if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))		return 0;	return (dev->features & NETIF_F_IP_CSUM) != 0;}static uint32_t gfar_get_msglevel(struct net_device *dev){	struct gfar_private *priv = netdev_priv(dev);	return priv->msg_enable;}static void gfar_set_msglevel(struct net_device *dev, uint32_t data){	struct gfar_private *priv = netdev_priv(dev);	priv->msg_enable = data;}#ifdef CONFIG_PMstatic void gfar_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol){	struct gfar_private *priv = netdev_priv(dev);	if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET) {		wol->supported |= WAKE_MAGIC;		wol->wolopts |= priv->wol_magic_packet ? WAKE_MAGIC : 0;	}	if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_WAKE_PHY) {		wol->supported |= WAKE_PHY;		wol->wolopts |= priv->wol_wake_phy ? WAKE_PHY : 0;	} else {		wol->supported = 0;		wol->wolopts = 0;	}}static int gfar_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol){	struct gfar_private *priv = netdev_priv(dev);	unsigned long flags;	if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET) &&	    !(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_WAKE_PHY) &&	    wol->wolopts != 0)		return -EINVAL;	if (wol->wolopts & ~(WAKE_MAGIC | WAKE_PHY))		return -EINVAL;	spin_lock_irqsave(&priv->bflock, flags);	priv->wol_magic_packet = wol->wolopts & WAKE_MAGIC ? 1 : 0;	priv->wol_wake_phy = wol->wolopts & WAKE_PHY ? 1 : 0;	spin_unlock_irqrestore(&priv->bflock, flags);	return 0;}#endifconst struct ethtool_ops gfar_ethtool_ops = {	.get_settings = gfar_gsettings,	.set_settings = gfar_ssettings,	.get_drvinfo = gfar_gdrvinfo,	.get_regs_len = gfar_reglen,	.get_regs = gfar_get_regs,	.get_link = ethtool_op_get_link,	.get_coalesce = gfar_gcoalesce,	.set_coalesce = gfar_scoalesce,	.get_ringparam = gfar_gringparam,	.set_ringparam = gfar_sringparam,	.get_strings = gfar_gstrings,	.get_stats_count = gfar_stats_count,	.get_ethtool_stats = gfar_fill_stats,	.get_rx_csum = gfar_get_rx_csum,	.get_tx_csum = gfar_get_tx_csum,	.set_rx_csum = gfar_set_rx_csum,	.set_tx_csum = gfar_set_tx_csum,	.get_msglevel = gfar_get_msglevel,	.set_msglevel = gfar_set_msglevel,#ifdef CONFIG_PM	.get_wol = gfar_get_wol,	.set_wol = gfar_set_wol,#endif};

⌨️ 快捷键说明

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