]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
net/mlx4_core: Reset counters data when freed
authorEran Ben Elisha <eranbe@mellanox.com>
Mon, 15 Jun 2015 14:58:57 +0000 (17:58 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 16 Jun 2015 00:23:01 +0000 (17:23 -0700)
Add resetting the counter data to the free counter flow, so the counter's
data won't be accessible anymore if querying the counter. Also, on next
counter allocation (to another VM for example), it will be fresh and clear.

Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: Hadar Hen Zion <hadarh@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/main.c
drivers/net/ethernet/mellanox/mlx4/mlx4.h

index ad81364272e45fe69c86b3126b34f69ce1590b1d..1072dc1054dd0867258e14c9064f5f52d04627ee 100644 (file)
@@ -2242,11 +2242,32 @@ int mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx)
 }
 EXPORT_SYMBOL_GPL(mlx4_counter_alloc);
 
+static int __mlx4_clear_if_stat(struct mlx4_dev *dev,
+                               u8 counter_index)
+{
+       struct mlx4_cmd_mailbox *if_stat_mailbox;
+       int err;
+       u32 if_stat_in_mod = (counter_index & 0xff) | MLX4_QUERY_IF_STAT_RESET;
+
+       if_stat_mailbox = mlx4_alloc_cmd_mailbox(dev);
+       if (IS_ERR(if_stat_mailbox))
+               return PTR_ERR(if_stat_mailbox);
+
+       err = mlx4_cmd_box(dev, 0, if_stat_mailbox->dma, if_stat_in_mod, 0,
+                          MLX4_CMD_QUERY_IF_STAT, MLX4_CMD_TIME_CLASS_C,
+                          MLX4_CMD_NATIVE);
+
+       mlx4_free_cmd_mailbox(dev, if_stat_mailbox);
+       return err;
+}
+
 void __mlx4_counter_free(struct mlx4_dev *dev, u32 idx)
 {
        if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS))
                return;
 
+       __mlx4_clear_if_stat(dev, idx);
+
        mlx4_bitmap_free(&mlx4_priv(dev)->counters_bitmap, idx, MLX4_USE_RR);
        return;
 }
index f424900d23a65d8ad549927ae52bc6d262f9d37c..8d2d3594bf8f30094d5d982b34834543c6256c7f 100644 (file)
@@ -65,6 +65,8 @@
 
 #define INIT_HCA_TPT_MW_ENABLE          (1 << 7)
 
+#define MLX4_QUERY_IF_STAT_RESET       BIT(31)
+
 enum {
        MLX4_HCR_BASE           = 0x80680,
        MLX4_HCR_SIZE           = 0x0001c,