@@ -2404,7 +2404,8 @@ static void destroy_qp_common(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
2404
2404
destroy_qp (dev , qp , base , udata );
2405
2405
}
2406
2406
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 ,
2408
2409
struct mlx5_create_qp_params * params )
2409
2410
{
2410
2411
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,
2423
2424
MLX5_SET (dctc , dctc , cqn , to_mcq (attr -> recv_cq )-> mcq .cqn );
2424
2425
MLX5_SET64 (dctc , dctc , dc_access_key , ucmd -> access_key );
2425
2426
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 );
2426
2429
2427
2430
if (qp -> flags_en & MLX5_QP_FLAG_SCATTER_CQE ) {
2428
2431
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,
2768
2771
}
2769
2772
2770
2773
if (qp -> type == MLX5_IB_QPT_DCT ) {
2771
- err = create_dct (pd , qp , params );
2774
+ err = create_dct (dev , pd , qp , params );
2772
2775
goto out ;
2773
2776
}
2774
2777
@@ -2882,9 +2885,8 @@ static int check_ucmd_data(struct mlx5_ib_dev *dev,
2882
2885
*/
2883
2886
last = sizeof (struct mlx5_ib_create_qp_rss );
2884
2887
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 */
2886
2889
switch (attr -> qp_type ) {
2887
- case IB_QPT_DRIVER :
2888
2890
case IB_QPT_RAW_PACKET :
2889
2891
last = offsetof(struct mlx5_ib_create_qp , ece_options );
2890
2892
break ;
@@ -4095,7 +4097,8 @@ static bool modify_dci_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state new
4095
4097
* Other transitions and attributes are illegal
4096
4098
*/
4097
4099
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 )
4099
4102
{
4100
4103
struct mlx5_ib_qp * qp = to_mqp (ibqp );
4101
4104
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,
4111
4114
new_state = attr -> qp_state ;
4112
4115
4113
4116
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
+
4114
4126
if (cur_state == IB_QPS_RESET && new_state == IB_QPS_INIT ) {
4115
4127
u16 set_id ;
4116
4128
@@ -4145,14 +4157,21 @@ static int mlx5_ib_modify_dct(struct ib_qp *ibqp, struct ib_qp_attr *attr,
4145
4157
MLX5_SET (dctc , dctc , counter_set_id , set_id );
4146
4158
} else if (cur_state == IB_QPS_INIT && new_state == IB_QPS_RTR ) {
4147
4159
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 );
4151
4162
4152
4163
if (udata -> outlen < min_resp_len )
4153
4164
return - EINVAL ;
4154
4165
resp .response_length = min_resp_len ;
4155
4166
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
+
4156
4175
required |= IB_QP_MIN_RNR_TIMER | IB_QP_AV | IB_QP_PATH_MTU ;
4157
4176
if (!is_valid_mask (attr_mask , required , 0 ))
4158
4177
return - EINVAL ;
@@ -4169,6 +4188,8 @@ static int mlx5_ib_modify_dct(struct ib_qp *ibqp, struct ib_qp_attr *attr,
4169
4188
if (err )
4170
4189
return err ;
4171
4190
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 );
4172
4193
err = ib_copy_to_udata (udata , & resp , resp .response_length );
4173
4194
if (err ) {
4174
4195
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,
4226
4247
qp_type = (unlikely (ibqp -> qp_type == MLX5_IB_QPT_HW_GSI )) ? IB_QPT_GSI :
4227
4248
qp -> type ;
4228
4249
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 );
4235
4252
4236
4253
mutex_lock (& qp -> mutex );
4237
4254
0 commit comments