Skip to content

Commit a645a89

Browse files
Leon Romanovskyjgunthorpe
authored andcommitted
RDMA/mlx5: Return ECE DC support
The DC QPs are many-to-one QP types that means that first connection will establish ECE options that coming connections should follow. Due to this property, the ECE code was removed between first [1] and second [2] ECE submissions. This patch returns the dropped code, because ECE is a property of a connection and like any other connection users are needed to manage this data. Allow them to set ECE parameter for DC too and avoid need of having compatibility flag for the DC ECE. [1] https://lore.kernel.org/linux-rdma/[email protected]/ [2] https://lore.kernel.org/linux-rdma/[email protected]/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 92cd667 commit a645a89

File tree

2 files changed

+34
-16
lines changed

2 files changed

+34
-16
lines changed

drivers/infiniband/hw/mlx5/qp.c

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,7 +2404,8 @@ static void destroy_qp_common(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
24042404
destroy_qp(dev, qp, base, udata);
24052405
}
24062406

2407-
static int create_dct(struct ib_pd *pd, struct mlx5_ib_qp *qp,
2407+
static int create_dct(struct mlx5_ib_dev *dev, struct ib_pd *pd,
2408+
struct mlx5_ib_qp *qp,
24082409
struct mlx5_create_qp_params *params)
24092410
{
24102411
struct ib_qp_init_attr *attr = params->attr;
@@ -2423,6 +2424,8 @@ static int create_dct(struct ib_pd *pd, struct mlx5_ib_qp *qp,
24232424
MLX5_SET(dctc, dctc, cqn, to_mcq(attr->recv_cq)->mcq.cqn);
24242425
MLX5_SET64(dctc, dctc, dc_access_key, ucmd->access_key);
24252426
MLX5_SET(dctc, dctc, user_index, uidx);
2427+
if (MLX5_CAP_GEN(dev->mdev, ece_support))
2428+
MLX5_SET(dctc, dctc, ece, ucmd->ece_options);
24262429

24272430
if (qp->flags_en & MLX5_QP_FLAG_SCATTER_CQE) {
24282431
int rcqe_sz = mlx5_ib_get_cqe_size(attr->recv_cq);
@@ -2768,7 +2771,7 @@ static int create_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,
27682771
}
27692772

27702773
if (qp->type == MLX5_IB_QPT_DCT) {
2771-
err = create_dct(pd, qp, params);
2774+
err = create_dct(dev, pd, qp, params);
27722775
goto out;
27732776
}
27742777

@@ -2882,9 +2885,8 @@ static int check_ucmd_data(struct mlx5_ib_dev *dev,
28822885
*/
28832886
last = sizeof(struct mlx5_ib_create_qp_rss);
28842887
else
2885-
/* IB_QPT_RAW_PACKET and IB_QPT_DRIVER don't have ECE data */
2888+
/* IB_QPT_RAW_PACKET doesn't have ECE data */
28862889
switch (attr->qp_type) {
2887-
case IB_QPT_DRIVER:
28882890
case IB_QPT_RAW_PACKET:
28892891
last = offsetof(struct mlx5_ib_create_qp, ece_options);
28902892
break;
@@ -4095,7 +4097,8 @@ static bool modify_dci_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state new
40954097
* Other transitions and attributes are illegal
40964098
*/
40974099
static int mlx5_ib_modify_dct(struct ib_qp *ibqp, struct ib_qp_attr *attr,
4098-
int attr_mask, struct ib_udata *udata)
4100+
int attr_mask, struct mlx5_ib_modify_qp *ucmd,
4101+
struct ib_udata *udata)
40994102
{
41004103
struct mlx5_ib_qp *qp = to_mqp(ibqp);
41014104
struct mlx5_ib_dev *dev = to_mdev(ibqp->device);
@@ -4111,6 +4114,15 @@ static int mlx5_ib_modify_dct(struct ib_qp *ibqp, struct ib_qp_attr *attr,
41114114
new_state = attr->qp_state;
41124115

41134116
dctc = MLX5_ADDR_OF(create_dct_in, qp->dct.in, dct_context_entry);
4117+
if (MLX5_CAP_GEN(dev->mdev, ece_support) && ucmd->ece_options)
4118+
/*
4119+
* DCT doesn't initialize QP till modify command is executed,
4120+
* so we need to overwrite previously set ECE field if user
4121+
* provided any value except zero, which means not set/not
4122+
* valid.
4123+
*/
4124+
MLX5_SET(dctc, dctc, ece, ucmd->ece_options);
4125+
41144126
if (cur_state == IB_QPS_RESET && new_state == IB_QPS_INIT) {
41154127
u16 set_id;
41164128

@@ -4145,14 +4157,21 @@ static int mlx5_ib_modify_dct(struct ib_qp *ibqp, struct ib_qp_attr *attr,
41454157
MLX5_SET(dctc, dctc, counter_set_id, set_id);
41464158
} else if (cur_state == IB_QPS_INIT && new_state == IB_QPS_RTR) {
41474159
struct mlx5_ib_modify_qp_resp resp = {};
4148-
u32 out[MLX5_ST_SZ_DW(create_dct_out)] = {0};
4149-
u32 min_resp_len = offsetof(typeof(resp), dctn) +
4150-
sizeof(resp.dctn);
4160+
u32 out[MLX5_ST_SZ_DW(create_dct_out)] = {};
4161+
u32 min_resp_len = offsetofend(typeof(resp), dctn);
41514162

41524163
if (udata->outlen < min_resp_len)
41534164
return -EINVAL;
41544165
resp.response_length = min_resp_len;
41554166

4167+
/*
4168+
* If we don't have enough space for the ECE options,
4169+
* simply indicate it with resp.response_length.
4170+
*/
4171+
resp.response_length = (udata->outlen < sizeof(resp)) ?
4172+
min_resp_len :
4173+
sizeof(resp);
4174+
41564175
required |= IB_QP_MIN_RNR_TIMER | IB_QP_AV | IB_QP_PATH_MTU;
41574176
if (!is_valid_mask(attr_mask, required, 0))
41584177
return -EINVAL;
@@ -4169,6 +4188,8 @@ static int mlx5_ib_modify_dct(struct ib_qp *ibqp, struct ib_qp_attr *attr,
41694188
if (err)
41704189
return err;
41714190
resp.dctn = qp->dct.mdct.mqp.qpn;
4191+
if (MLX5_CAP_GEN(dev->mdev, ece_support))
4192+
resp.ece_options = MLX5_GET(create_dct_out, out, ece);
41724193
err = ib_copy_to_udata(udata, &resp, resp.response_length);
41734194
if (err) {
41744195
mlx5_core_destroy_dct(dev, &qp->dct.mdct);
@@ -4226,12 +4247,8 @@ int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
42264247
qp_type = (unlikely(ibqp->qp_type == MLX5_IB_QPT_HW_GSI)) ? IB_QPT_GSI :
42274248
qp->type;
42284249

4229-
if (qp_type == MLX5_IB_QPT_DCT) {
4230-
if (memchr_inv(&ucmd.ece_options, 0, sizeof(ucmd.ece_options)))
4231-
return -EOPNOTSUPP;
4232-
4233-
return mlx5_ib_modify_dct(ibqp, attr, attr_mask, udata);
4234-
}
4250+
if (qp_type == MLX5_IB_QPT_DCT)
4251+
return mlx5_ib_modify_dct(ibqp, attr, attr_mask, &ucmd, udata);
42354252

42364253
mutex_lock(&qp->mutex);
42374254

include/linux/mlx5/mlx5_ifc.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3690,7 +3690,8 @@ struct mlx5_ifc_dctc_bits {
36903690
u8 ecn[0x2];
36913691
u8 dscp[0x6];
36923692

3693-
u8 reserved_at_1c0[0x40];
3693+
u8 reserved_at_1c0[0x20];
3694+
u8 ece[0x20];
36943695
};
36953696

36963697
enum {
@@ -7940,7 +7941,7 @@ struct mlx5_ifc_create_dct_out_bits {
79407941
u8 reserved_at_40[0x8];
79417942
u8 dctn[0x18];
79427943

7943-
u8 reserved_at_60[0x20];
7944+
u8 ece[0x20];
79447945
};
79457946

79467947
struct mlx5_ifc_create_dct_in_bits {

0 commit comments

Comments
 (0)