sfc: 10Xpress: Report support for pause frames
[linux-2.6.git] / drivers / net / gianfar_ethtool.c
index c111c53..6c144b5 100644 (file)
@@ -293,7 +293,7 @@ static int gfar_gcoalesce(struct net_device *dev, struct ethtool_coalesce *cvals
        rxtime  = get_ictt_value(priv->rxic);
        rxcount = get_icft_value(priv->rxic);
        txtime  = get_ictt_value(priv->txic);
-       txcount = get_icft_value(priv->txic);;
+       txcount = get_icft_value(priv->txic);
        cvals->rx_coalesce_usecs = gfar_ticks2usecs(priv, rxtime);
        cvals->rx_max_coalesced_frames = rxcount;
 
@@ -366,9 +366,8 @@ static int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals
                return -EINVAL;
        }
 
-       priv->rxic = mk_ic_value(
-               gfar_usecs2ticks(priv, cvals->rx_coalesce_usecs),
-               cvals->rx_max_coalesced_frames);
+       priv->rxic = mk_ic_value(cvals->rx_max_coalesced_frames,
+               gfar_usecs2ticks(priv, cvals->rx_coalesce_usecs));
 
        /* Set up tx coalescing */
        if ((cvals->tx_coalesce_usecs == 0) ||
@@ -390,9 +389,8 @@ static int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals
                return -EINVAL;
        }
 
-       priv->txic = mk_ic_value(
-               gfar_usecs2ticks(priv, cvals->tx_coalesce_usecs),
-               cvals->tx_max_coalesced_frames);
+       priv->txic = mk_ic_value(cvals->tx_max_coalesced_frames,
+               gfar_usecs2ticks(priv, cvals->tx_coalesce_usecs));
 
        gfar_write(&priv->regs->rxic, 0);
        if (priv->rxcoalescing)
@@ -462,11 +460,12 @@ static int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rva
                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);
 
+               gfar_clean_rx_ring(dev, priv->rx_ring_size);
+
                /* Now we take down the rings to rebuild them */
                stop_gfar(dev);
        }
@@ -474,11 +473,13 @@ static int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rva
        /* Change the size */
        priv->rx_ring_size = rvals->rx_pending;
        priv->tx_ring_size = rvals->tx_pending;
+       priv->num_txbdfree = priv->tx_ring_size;
 
        /* Rebuild the rings with the new size */
-       if (dev->flags & IFF_UP)
+       if (dev->flags & IFF_UP) {
                err = startup_gfar(dev);
-
+               netif_wake_queue(dev);
+       }
        return err;
 }
 
@@ -498,11 +499,12 @@ static int gfar_set_rx_csum(struct net_device *dev, uint32_t data)
                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);
 
+               gfar_clean_rx_ring(dev, priv->rx_ring_size);
+
                /* Now we take down the rings to rebuild them */
                stop_gfar(dev);
        }
@@ -511,9 +513,10 @@ static int gfar_set_rx_csum(struct net_device *dev, uint32_t data)
        priv->rx_csum_enable = data;
        spin_unlock_irqrestore(&priv->bflock, flags);
 
-       if (dev->flags & IFF_UP)
+       if (dev->flags & IFF_UP) {
                err = startup_gfar(dev);
-
+               netif_wake_queue(dev);
+       }
        return err;
 }
 
@@ -529,22 +532,19 @@ static uint32_t gfar_get_rx_csum(struct net_device *dev)
 
 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->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
                return -EOPNOTSUPP;
 
-       spin_lock_irqsave(&priv->txlock, flags);
-       gfar_halt(dev);
+       netif_tx_lock_bh(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);
+       netif_tx_unlock_bh(dev);
 
        return 0;
 }
@@ -598,6 +598,7 @@ static int gfar_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 
        spin_lock_irqsave(&priv->bflock, flags);
        priv->wol_en = wol->wolopts & WAKE_MAGIC ? 1 : 0;
+       device_set_wakeup_enable(&dev->dev, priv->wol_en);
        spin_unlock_irqrestore(&priv->bflock, flags);
 
        return 0;
@@ -622,6 +623,7 @@ const struct ethtool_ops gfar_ethtool_ops = {
        .get_tx_csum = gfar_get_tx_csum,
        .set_rx_csum = gfar_set_rx_csum,
        .set_tx_csum = gfar_set_tx_csum,
+       .set_sg = ethtool_op_set_sg,
        .get_msglevel = gfar_get_msglevel,
        .set_msglevel = gfar_set_msglevel,
 #ifdef CONFIG_PM