Commit 2632d18d authored by Eran Ben Elisha's avatar Eran Ben Elisha Committed by David S. Miller

net/mlx4_core: Remove counters table allocation from VF flow

Since virtual functions get their counters indices allocation from the PF,
allocate counters indices bitmap only in case the function isn't virtual.

Also, check that the device has counters to allocate before creating the
indices bitmap table.
Signed-off-by: default avatarEran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: default avatarHadar Hen Zion <hadarh@mellanox.com>
Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 47d8417f
...@@ -2198,6 +2198,9 @@ static int mlx4_init_counters_table(struct mlx4_dev *dev) ...@@ -2198,6 +2198,9 @@ static int mlx4_init_counters_table(struct mlx4_dev *dev)
if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS)) if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS))
return -ENOENT; return -ENOENT;
if (!dev->caps.max_counters)
return -ENOSPC;
nent_pow2 = roundup_pow_of_two(dev->caps.max_counters); nent_pow2 = roundup_pow_of_two(dev->caps.max_counters);
/* reserve last counter index for sink counter */ /* reserve last counter index for sink counter */
return mlx4_bitmap_init(&priv->counters_bitmap, nent_pow2, return mlx4_bitmap_init(&priv->counters_bitmap, nent_pow2,
...@@ -2210,6 +2213,9 @@ static void mlx4_cleanup_counters_table(struct mlx4_dev *dev) ...@@ -2210,6 +2213,9 @@ static void mlx4_cleanup_counters_table(struct mlx4_dev *dev)
if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS)) if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS))
return; return;
if (!dev->caps.max_counters)
return;
mlx4_bitmap_cleanup(&mlx4_priv(dev)->counters_bitmap); mlx4_bitmap_cleanup(&mlx4_priv(dev)->counters_bitmap);
} }
...@@ -2425,11 +2431,13 @@ static int mlx4_setup_hca(struct mlx4_dev *dev) ...@@ -2425,11 +2431,13 @@ static int mlx4_setup_hca(struct mlx4_dev *dev)
goto err_srq_table_free; goto err_srq_table_free;
} }
if (!mlx4_is_slave(dev)) {
err = mlx4_init_counters_table(dev); err = mlx4_init_counters_table(dev);
if (err && err != -ENOENT) { if (err && err != -ENOENT) {
mlx4_err(dev, "Failed to initialize counters table, aborting\n"); mlx4_err(dev, "Failed to initialize counters table, aborting\n");
goto err_qp_table_free; goto err_qp_table_free;
} }
}
if (!mlx4_is_slave(dev)) { if (!mlx4_is_slave(dev)) {
for (port = 1; port <= dev->caps.num_ports; port++) { for (port = 1; port <= dev->caps.num_ports; port++) {
...@@ -2470,6 +2478,7 @@ static int mlx4_setup_hca(struct mlx4_dev *dev) ...@@ -2470,6 +2478,7 @@ static int mlx4_setup_hca(struct mlx4_dev *dev)
return 0; return 0;
err_counters_table_free: err_counters_table_free:
if (!mlx4_is_slave(dev))
mlx4_cleanup_counters_table(dev); mlx4_cleanup_counters_table(dev);
err_qp_table_free: err_qp_table_free:
...@@ -3203,6 +3212,7 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data, ...@@ -3203,6 +3212,7 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data,
for (--port; port >= 1; --port) for (--port; port >= 1; --port)
mlx4_cleanup_port_info(&priv->port[port]); mlx4_cleanup_port_info(&priv->port[port]);
if (!mlx4_is_slave(dev))
mlx4_cleanup_counters_table(dev); mlx4_cleanup_counters_table(dev);
mlx4_cleanup_qp_table(dev); mlx4_cleanup_qp_table(dev);
mlx4_cleanup_srq_table(dev); mlx4_cleanup_srq_table(dev);
...@@ -3501,6 +3511,7 @@ static void mlx4_unload_one(struct pci_dev *pdev) ...@@ -3501,6 +3511,7 @@ static void mlx4_unload_one(struct pci_dev *pdev)
mlx4_free_resource_tracker(dev, mlx4_free_resource_tracker(dev,
RES_TR_FREE_SLAVES_ONLY); RES_TR_FREE_SLAVES_ONLY);
if (!mlx4_is_slave(dev))
mlx4_cleanup_counters_table(dev); mlx4_cleanup_counters_table(dev);
mlx4_cleanup_qp_table(dev); mlx4_cleanup_qp_table(dev);
mlx4_cleanup_srq_table(dev); mlx4_cleanup_srq_table(dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment