Skip to content

Commit cfcde11

Browse files
ogerlitzrolandd
authored andcommitted
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 <[email protected]>. Signed-off-by: Or Gerlitz <[email protected]> Signed-off-by: Roland Dreier <[email protected]>
1 parent 6aea213 commit cfcde11

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

drivers/infiniband/hw/mlx4/main.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,11 +1098,21 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
10981098
if (init_node_data(ibdev))
10991099
goto err_map;
11001100

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+
11011111
spin_lock_init(&ibdev->sm_lock);
11021112
mutex_init(&ibdev->cap_mask_mutex);
11031113

11041114
if (ib_register_device(&ibdev->ib_dev, NULL))
1105-
goto err_map;
1115+
goto err_counter;
11061116

11071117
if (mlx4_ib_mad_init(ibdev))
11081118
goto err_reg;
@@ -1132,6 +1142,10 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
11321142
err_reg:
11331143
ib_unregister_device(&ibdev->ib_dev);
11341144

1145+
err_counter:
1146+
for (; i; --i)
1147+
mlx4_counter_free(ibdev->dev, ibdev->counters[i - 1]);
1148+
11351149
err_map:
11361150
iounmap(ibdev->uar_map);
11371151

@@ -1160,7 +1174,8 @@ static void mlx4_ib_remove(struct mlx4_dev *dev, void *ibdev_ptr)
11601174
ibdev->iboe.nb.notifier_call = NULL;
11611175
}
11621176
iounmap(ibdev->uar_map);
1163-
1177+
for (p = 0; p < ibdev->num_ports; ++p)
1178+
mlx4_counter_free(ibdev->dev, ibdev->counters[p]);
11641179
mlx4_foreach_port(p, dev, MLX4_PORT_TYPE_IB)
11651180
mlx4_CLOSE_PORT(dev, p);
11661181

drivers/infiniband/hw/mlx4/mlx4_ib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ struct mlx4_ib_dev {
193193
struct mutex cap_mask_mutex;
194194
bool ib_active;
195195
struct mlx4_ib_iboe iboe;
196+
int counters[MLX4_MAX_PORTS];
196197
};
197198

198199
static inline struct mlx4_ib_dev *to_mdev(struct ib_device *ibdev)

drivers/infiniband/hw/mlx4/qp.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,6 @@ static int mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
893893
--path->static_rate;
894894
} else
895895
path->static_rate = 0;
896-
path->counter_index = 0xff;
897896

898897
if (ah->ah_flags & IB_AH_GRH) {
899898
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,
10341033
}
10351034
}
10361035

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+
10371045
if (attr_mask & IB_QP_PKEY_INDEX) {
10381046
context->pri_path.pkey_index = attr->pkey_index;
10391047
optpar |= MLX4_QP_OPTPAR_PKEY_INDEX;

include/linux/mlx4/qp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ enum mlx4_qp_optpar {
5454
MLX4_QP_OPTPAR_RETRY_COUNT = 1 << 12,
5555
MLX4_QP_OPTPAR_RNR_RETRY = 1 << 13,
5656
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
5859
};
5960

6061
enum mlx4_qp_state {

0 commit comments

Comments
 (0)