aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOr Gerlitz <ogerlitz@mellanox.com>2011-06-15 10:49:57 -0400
committerRoland Dreier <roland@purestorage.com>2011-07-19 00:04:36 -0400
commitcfcde11c3d7ae175f49280bb6f913478c2f1bd8c (patch)
tree1d6bc41c59035f791bd27f8d34fb95eb667a691f
parent6aea213a62122701891fe55cc3405d31b927cfde (diff)
IB/mlx4: Use flow counters on IBoE ports
Allocate flow counter per Ethernet/IBoE port, and attach this counter to all the QPs created on that port. Based on patch by Eli Cohen <eli@mellanox.co.il>. Signed-off-by: Or Gerlitz <ogerlitz@mellanox.co.il> Signed-off-by: Roland Dreier <roland@purestorage.com>
-rw-r--r--drivers/infiniband/hw/mlx4/main.c19
-rw-r--r--drivers/infiniband/hw/mlx4/mlx4_ib.h1
-rw-r--r--drivers/infiniband/hw/mlx4/qp.c10
-rw-r--r--include/linux/mlx4/qp.h3
4 files changed, 29 insertions, 4 deletions
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 621c409433e2..fa643f4f4e28 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -1098,11 +1098,21 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
1098 if (init_node_data(ibdev)) 1098 if (init_node_data(ibdev))
1099 goto err_map; 1099 goto err_map;
1100 1100
1101 for (i = 0; i < ibdev->num_ports; ++i) {
1102 if (mlx4_ib_port_link_layer(&ibdev->ib_dev, i + 1) ==
1103 IB_LINK_LAYER_ETHERNET) {
1104 err = mlx4_counter_alloc(ibdev->dev, &ibdev->counters[i]);
1105 if (err)
1106 ibdev->counters[i] = -1;
1107 } else
1108 ibdev->counters[i] = -1;
1109 }
1110
1101 spin_lock_init(&ibdev->sm_lock); 1111 spin_lock_init(&ibdev->sm_lock);
1102 mutex_init(&ibdev->cap_mask_mutex); 1112 mutex_init(&ibdev->cap_mask_mutex);
1103 1113
1104 if (ib_register_device(&ibdev->ib_dev, NULL)) 1114 if (ib_register_device(&ibdev->ib_dev, NULL))
1105 goto err_map; 1115 goto err_counter;
1106 1116
1107 if (mlx4_ib_mad_init(ibdev)) 1117 if (mlx4_ib_mad_init(ibdev))
1108 goto err_reg; 1118 goto err_reg;
@@ -1132,6 +1142,10 @@ err_notif:
1132err_reg: 1142err_reg:
1133 ib_unregister_device(&ibdev->ib_dev); 1143 ib_unregister_device(&ibdev->ib_dev);
1134 1144
1145err_counter:
1146 for (; i; --i)
1147 mlx4_counter_free(ibdev->dev, ibdev->counters[i - 1]);
1148
1135err_map: 1149err_map:
1136 iounmap(ibdev->uar_map); 1150 iounmap(ibdev->uar_map);
1137 1151
@@ -1160,7 +1174,8 @@ static void mlx4_ib_remove(struct mlx4_dev *dev, void *ibdev_ptr)
1160 ibdev->iboe.nb.notifier_call = NULL; 1174 ibdev->iboe.nb.notifier_call = NULL;
1161 } 1175 }
1162 iounmap(ibdev->uar_map); 1176 iounmap(ibdev->uar_map);
1163 1177 for (p = 0; p < ibdev->num_ports; ++p)
1178 mlx4_counter_free(ibdev->dev, ibdev->counters[p]);
1164 mlx4_foreach_port(p, dev, MLX4_PORT_TYPE_IB) 1179 mlx4_foreach_port(p, dev, MLX4_PORT_TYPE_IB)
1165 mlx4_CLOSE_PORT(dev, p); 1180 mlx4_CLOSE_PORT(dev, p);
1166 1181
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 2a322f21049f..e4bf2cff8662 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -193,6 +193,7 @@ struct mlx4_ib_dev {
193 struct mutex cap_mask_mutex; 193 struct mutex cap_mask_mutex;
194 bool ib_active; 194 bool ib_active;
195 struct mlx4_ib_iboe iboe; 195 struct mlx4_ib_iboe iboe;
196 int counters[MLX4_MAX_PORTS];
196}; 197};
197 198
198static inline struct mlx4_ib_dev *to_mdev(struct ib_device *ibdev) 199static inline struct mlx4_ib_dev *to_mdev(struct ib_device *ibdev)
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 2001f20a4361..3a91d9d8dc51 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -893,7 +893,6 @@ static int mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
893 --path->static_rate; 893 --path->static_rate;
894 } else 894 } else
895 path->static_rate = 0; 895 path->static_rate = 0;
896 path->counter_index = 0xff;
897 896
898 if (ah->ah_flags & IB_AH_GRH) { 897 if (ah->ah_flags & IB_AH_GRH) {
899 if (ah->grh.sgid_index >= dev->dev->caps.gid_table_len[port]) { 898 if (ah->grh.sgid_index >= dev->dev->caps.gid_table_len[port]) {
@@ -1034,6 +1033,15 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
1034 } 1033 }
1035 } 1034 }
1036 1035
1036 if (cur_state == IB_QPS_INIT && new_state == IB_QPS_RTR) {
1037 if (dev->counters[qp->port - 1] != -1) {
1038 context->pri_path.counter_index =
1039 dev->counters[qp->port - 1];
1040 optpar |= MLX4_QP_OPTPAR_COUNTER_INDEX;
1041 } else
1042 context->pri_path.counter_index = 0xff;
1043 }
1044
1037 if (attr_mask & IB_QP_PKEY_INDEX) { 1045 if (attr_mask & IB_QP_PKEY_INDEX) {
1038 context->pri_path.pkey_index = attr->pkey_index; 1046 context->pri_path.pkey_index = attr->pkey_index;
1039 optpar |= MLX4_QP_OPTPAR_PKEY_INDEX; 1047 optpar |= MLX4_QP_OPTPAR_PKEY_INDEX;
diff --git a/include/linux/mlx4/qp.h b/include/linux/mlx4/qp.h
index 6486d880bdbf..4001c8249dbb 100644
--- a/include/linux/mlx4/qp.h
+++ b/include/linux/mlx4/qp.h
@@ -54,7 +54,8 @@ enum mlx4_qp_optpar {
54 MLX4_QP_OPTPAR_RETRY_COUNT = 1 << 12, 54 MLX4_QP_OPTPAR_RETRY_COUNT = 1 << 12,
55 MLX4_QP_OPTPAR_RNR_RETRY = 1 << 13, 55 MLX4_QP_OPTPAR_RNR_RETRY = 1 << 13,
56 MLX4_QP_OPTPAR_ACK_TIMEOUT = 1 << 14, 56 MLX4_QP_OPTPAR_ACK_TIMEOUT = 1 << 14,
57 MLX4_QP_OPTPAR_SCHED_QUEUE = 1 << 16 57 MLX4_QP_OPTPAR_SCHED_QUEUE = 1 << 16,
58 MLX4_QP_OPTPAR_COUNTER_INDEX = 1 << 20
58}; 59};
59 60
60enum mlx4_qp_state { 61enum mlx4_qp_state {