]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
net/mlx4_core: Add sink counter
authorEran Ben Elisha <eranbe@mellanox.com>
Mon, 15 Jun 2015 14:58:58 +0000 (17:58 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 16 Jun 2015 00:23:01 +0000 (17:23 -0700)
Reserve the last valid counter index for "sink" counter, when a
new counter cannot be allocated, the driver will use this counter.

In order to avoid allocating this counter on any other flow, fix the
indices bitmap allocation range, and reserve the sink counter index.

Add macro for the sink counter index and replace all appearences of the
index with the macro.

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/infiniband/hw/mlx4/qp.c
drivers/net/ethernet/mellanox/mlx4/en_resources.c
drivers/net/ethernet/mellanox/mlx4/main.c
include/linux/mlx4/device.h

index 02fc91c6802787e0f8f723417d9c7655b6123d3a..c7d916fab68a520341825105e047e511827104da 100644 (file)
@@ -1544,7 +1544,8 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
                                                dev->counters[qp->port - 1];
                        optpar |= MLX4_QP_OPTPAR_COUNTER_INDEX;
                } else
-                       context->pri_path.counter_index = 0xff;
+                       context->pri_path.counter_index =
+                               MLX4_SINK_COUNTER_INDEX(dev->dev);
 
                if (qp->flags & MLX4_IB_QP_NETIF) {
                        mlx4_ib_steer_qp_reg(dev, qp, 1);
index 34f2fdf4fe5d214154714d3e9a672e47e23afdae..97bcb9135f8db0792a9f203750a62f2f71b6a600 100644 (file)
@@ -66,7 +66,7 @@ void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int size, int stride,
                context->pri_path.sched_queue |= user_prio << 3;
                context->pri_path.feup = MLX4_FEUP_FORCE_ETH_UP;
        }
-       context->pri_path.counter_index = 0xff;
+       context->pri_path.counter_index = MLX4_SINK_COUNTER_INDEX(mdev->dev);
        context->cqn_send = cpu_to_be32(cqn);
        context->cqn_recv = cpu_to_be32(cqn);
        context->db_rec_addr = cpu_to_be64(priv->res.db.dma << 2);
index 1072dc1054dd0867258e14c9064f5f52d04627ee..2bf54687f9fb03c37ebb7520cd73428422eb0d9f 100644 (file)
@@ -479,7 +479,7 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
                }
        }
 
-       dev->caps.max_counters = 1 << ilog2(dev_cap->max_counters);
+       dev->caps.max_counters = dev_cap->max_counters;
 
        dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW] = dev_cap->reserved_qps;
        dev->caps.reserved_qps_cnt[MLX4_QP_REGION_ETH_ADDR] =
@@ -2193,13 +2193,16 @@ err_free_icm:
 static int mlx4_init_counters_table(struct mlx4_dev *dev)
 {
        struct mlx4_priv *priv = mlx4_priv(dev);
-       int nent;
+       int nent_pow2;
 
        if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS))
                return -ENOENT;
 
-       nent = dev->caps.max_counters;
-       return mlx4_bitmap_init(&priv->counters_bitmap, nent, nent - 1, 0, 0);
+       nent_pow2 = roundup_pow_of_two(dev->caps.max_counters);
+       /* reserve last counter index for sink counter */
+       return mlx4_bitmap_init(&priv->counters_bitmap, nent_pow2,
+                               nent_pow2 - 1, 0,
+                               nent_pow2 - dev->caps.max_counters + 1);
 }
 
 static void mlx4_cleanup_counters_table(struct mlx4_dev *dev)
index ad31e476873f8b8f9a5a8fd0f04fb70075a4df7c..312c50420dde08de308bfed6e666fe15f5c54dfd 100644 (file)
@@ -957,6 +957,7 @@ struct mlx4_mad_ifc {
                        ((dev)->caps.flags & MLX4_DEV_CAP_FLAG_IBOE))
 
 #define MLX4_INVALID_SLAVE_ID  0xFF
+#define MLX4_SINK_COUNTER_INDEX(dev)   (dev->caps.max_counters - 1)
 
 void handle_port_mgmt_change_event(struct work_struct *work);