mlx4: add dynamic LRO disable support
authorAmerigo Wang <amwang@redhat.com>
Mon, 21 Jun 2010 22:50:17 +0000 (22:50 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 29 Jun 2010 06:04:10 +0000 (23:04 -0700)
This patch adds dynamic LRO diable support for mlx4 net driver.
It also fixes a bug of mlx4, which checks NETIF_F_LRO flag in rx
path without rtnl lock.

(I don't have mlx4 card, so only did compiling test. Anyone who wants
to test this is more than welcome.)

This is based on Neil's initial work too, and heavily modified based
on Stanislaw's suggestions.

Signed-off-by: WANG Cong <amwang@redhat.com>
Signed-off-by: Neil Horman <nhorman@redhat.com>
Acked-by: Neil Horman <nhorman@redhat.com>
Reviewed-by: Stanislaw Gruszka <sgruszka@redhat.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/mlx4/en_ethtool.c

index d5afd037cd7d1ceec5e274318f78195a2eb3a7b3..b275238fe70d347dd89fa59b3152f1fc1fdc162d 100644 (file)
@@ -387,6 +387,42 @@ static void mlx4_en_get_ringparam(struct net_device *dev,
        param->tx_pending = mdev->profile.prof[priv->port].tx_ring_size;
 }
 
+static int mlx4_ethtool_op_set_flags(struct net_device *dev, u32 data)
+{
+       struct mlx4_en_priv *priv = netdev_priv(dev);
+       struct mlx4_en_dev *mdev = priv->mdev;
+       int rc = 0;
+       int changed = 0;
+
+       if (data & ~ETH_FLAG_LRO)
+               return -EOPNOTSUPP;
+
+       if (data & ETH_FLAG_LRO) {
+               if (mdev->profile.num_lro == 0)
+                       return -EOPNOTSUPP;
+               if (!(dev->features & NETIF_F_LRO))
+                       changed = 1;
+       } else if (dev->features & NETIF_F_LRO) {
+               changed = 1;
+       }
+
+       if (changed) {
+               if (netif_running(dev)) {
+                       mutex_lock(&mdev->state_lock);
+                       mlx4_en_stop_port(dev);
+               }
+               dev->features ^= NETIF_F_LRO;
+               if (netif_running(dev)) {
+                       rc = mlx4_en_start_port(dev);
+                       if (rc)
+                               en_err(priv, "Failed to restart port\n");
+                       mutex_unlock(&mdev->state_lock);
+               }
+       }
+
+       return rc;
+}
+
 const struct ethtool_ops mlx4_en_ethtool_ops = {
        .get_drvinfo = mlx4_en_get_drvinfo,
        .get_settings = mlx4_en_get_settings,
@@ -415,7 +451,7 @@ const struct ethtool_ops mlx4_en_ethtool_ops = {
        .get_ringparam = mlx4_en_get_ringparam,
        .set_ringparam = mlx4_en_set_ringparam,
        .get_flags = ethtool_op_get_flags,
-       .set_flags = ethtool_op_set_flags,
+       .set_flags = mlx4_ethtool_op_set_flags,
 };