Skip to content

Commit 50aec2c

Browse files
Leon Romanovskyjgunthorpe
authored andcommitted
RDMA/mlx5: Return ECE data after modify QP
After users sets the ECE option, FW will return the agreed/supported bits through an output structures of modify QP stages for regular QPs or through create QP for the DCT. Link: https://lore.kernel.org/r/20200526115440.205922-9-leon@kernel.org Reviewed-by: Mark Zhang <markz@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent 5f62a52 commit 50aec2c

3 files changed

Lines changed: 48 additions & 4 deletions

File tree

‎drivers/infiniband/hw/mlx5/qp.c‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3708,6 +3708,7 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
37083708
enum ib_qp_state cur_state,
37093709
enum ib_qp_state new_state,
37103710
const struct mlx5_ib_modify_qp *ucmd,
3711+
struct mlx5_ib_modify_qp_resp *resp,
37113712
struct ib_udata *udata)
37123713
{
37133714
static const u16 optab[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE] = {
@@ -3978,10 +3979,15 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
39783979

39793980
err = modify_raw_packet_qp(dev, qp, &raw_qp_param, tx_affinity);
39803981
} else {
3981-
u32 ece = MLX5_CAP_GEN(dev->mdev, ece_support) ?
3982-
ucmd->ece_options : 0;
3982+
if (udata) {
3983+
/* For the kernel flows, the resp will stay zero */
3984+
resp->ece_options =
3985+
MLX5_CAP_GEN(dev->mdev, ece_support) ?
3986+
ucmd->ece_options : 0;
3987+
resp->response_length = sizeof(*resp);
3988+
}
39833989
err = mlx5_core_qp_modify(dev, op, optpar, qpc, &base->mqp,
3984-
&ece);
3990+
&resp->ece_options);
39853991
}
39863992

39873993
if (err)
@@ -4180,6 +4186,7 @@ int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
41804186
int attr_mask, struct ib_udata *udata)
41814187
{
41824188
struct mlx5_ib_dev *dev = to_mdev(ibqp->device);
4189+
struct mlx5_ib_modify_qp_resp resp = {};
41834190
struct mlx5_ib_qp *qp = to_mqp(ibqp);
41844191
struct mlx5_ib_modify_qp ucmd = {};
41854192
enum ib_qp_type qp_type;
@@ -4292,7 +4299,17 @@ int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
42924299
}
42934300

42944301
err = __mlx5_ib_modify_qp(ibqp, attr, attr_mask, cur_state,
4295-
new_state, &ucmd, udata);
4302+
new_state, &ucmd, &resp, udata);
4303+
4304+
/* resp.response_length is set in ECE supported flows only */
4305+
if (!err && resp.response_length &&
4306+
udata->outlen >= resp.response_length)
4307+
/*
4308+
* We don't check return value of the function below
4309+
* on purpose, because it is unclear how to unwind the
4310+
* error flow after QP was modified to the new state.
4311+
*/
4312+
ib_copy_to_udata(udata, &resp, resp.response_length);
42964313

42974314
out:
42984315
mutex_unlock(&qp->mutex);

‎drivers/infiniband/hw/mlx5/qpc.c‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,27 @@ static void mbox_free(struct mbox_info *mbox)
341341
kfree(mbox->out);
342342
}
343343

344+
static int get_ece_from_mbox(void *out, u16 opcode)
345+
{
346+
int ece = 0;
347+
348+
switch (opcode) {
349+
case MLX5_CMD_OP_INIT2RTR_QP:
350+
ece = MLX5_GET(init2rtr_qp_out, out, ece);
351+
break;
352+
case MLX5_CMD_OP_RTR2RTS_QP:
353+
ece = MLX5_GET(rtr2rts_qp_out, out, ece);
354+
break;
355+
case MLX5_CMD_OP_RTS2RTS_QP:
356+
ece = MLX5_GET(rts2rts_qp_out, out, ece);
357+
break;
358+
default:
359+
break;
360+
}
361+
362+
return ece;
363+
}
364+
344365
static int modify_qp_mbox_alloc(struct mlx5_core_dev *dev, u16 opcode, int qpn,
345366
u32 opt_param_mask, void *qpc,
346367
struct mbox_info *mbox, u16 uid, u32 ece)
@@ -438,6 +459,10 @@ int mlx5_core_qp_modify(struct mlx5_ib_dev *dev, u16 opcode, u32 opt_param_mask,
438459

439460
err = mlx5_cmd_exec(dev->mdev, mbox.in, mbox.inlen, mbox.out,
440461
mbox.outlen);
462+
463+
if (ece)
464+
*ece = get_ece_from_mbox(mbox.out, opcode);
465+
441466
mbox_free(&mbox);
442467
return err;
443468
}

‎include/uapi/rdma/mlx5-abi.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ struct mlx5_ib_modify_qp {
429429
struct mlx5_ib_modify_qp_resp {
430430
__u32 response_length;
431431
__u32 dctn;
432+
__u32 ece_options;
433+
__u32 reserved;
432434
};
433435

434436
struct mlx5_ib_create_wq_resp {

0 commit comments

Comments
 (0)