net/mlx4_en: Do not query stats when device port is down
authorJack Morgenstein <jackm@dev.mellanox.com>
Tue, 25 Jun 2013 09:09:30 +0000 (12:09 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 25 Jun 2013 23:29:38 +0000 (16:29 -0700)
There are no counters allocated to the eth device when the port is down, so
this query is meaningless at that time.

It also leads to querying incorrect counters (since the counter_index is not
valid when the device port is down).

Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/en_netdev.c

index 7299ada876c2b4ae3b4e0e5f2e4ba6bbf2af5d5f..c0b02d7bcc2fe98cb2cfca2968b9ef435d22eac3 100644 (file)
@@ -1375,12 +1375,13 @@ static void mlx4_en_do_get_stats(struct work_struct *work)
 
        mutex_lock(&mdev->state_lock);
        if (mdev->device_up) {
-               err = mlx4_en_DUMP_ETH_STATS(mdev, priv->port, 0);
-               if (err)
-                       en_dbg(HW, priv, "Could not update stats\n");
+               if (priv->port_up) {
+                       err = mlx4_en_DUMP_ETH_STATS(mdev, priv->port, 0);
+                       if (err)
+                               en_dbg(HW, priv, "Could not update stats\n");
 
-               if (priv->port_up)
                        mlx4_en_auto_moderation(priv);
+               }
 
                queue_delayed_work(mdev->workqueue, &priv->stats_task, STATS_DELAY);
        }