Skip to content

Commit 0cb1537

Browse files
Leon Romanovskyjgunthorpe
authored andcommitted
RDMA/cma: Connect ECE to rdma_accept
The rdma_accept() is called by both passive and active sides of CMID connection to mark readiness to start data transfer. For passive side, this is called explicitly, for active side, it is called implicitly while receiving REP message. Provide ECE data to rdma_accept function needed for passive side to send that REP message. Link: https://lore.kernel.org/r/20200526103304.196371-6-leon@kernel.org Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent a20652e commit 0cb1537

4 files changed

Lines changed: 34 additions & 3 deletions

File tree

‎drivers/infiniband/core/cma.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4090,6 +4090,8 @@ static int cma_accept_ib(struct rdma_id_private *id_priv,
40904090
rep.flow_control = conn_param->flow_control;
40914091
rep.rnr_retry_count = min_t(u8, 7, conn_param->rnr_retry_count);
40924092
rep.srq = id_priv->srq ? 1 : 0;
4093+
rep.ece.vendor_id = id_priv->ece.vendor_id;
4094+
rep.ece.attr_mod = id_priv->ece.attr_mod;
40934095

40944096
trace_cm_send_rep(id_priv);
40954097
ret = ib_send_cm_rep(id_priv->cm_id.ib, &rep);
@@ -4137,7 +4139,11 @@ static int cma_send_sidr_rep(struct rdma_id_private *id_priv,
41374139
return ret;
41384140
rep.qp_num = id_priv->qp_num;
41394141
rep.qkey = id_priv->qkey;
4142+
4143+
rep.ece.vendor_id = id_priv->ece.vendor_id;
4144+
rep.ece.attr_mod = id_priv->ece.attr_mod;
41404145
}
4146+
41414147
rep.private_data = private_data;
41424148
rep.private_data_len = private_data_len;
41434149

@@ -4195,6 +4201,19 @@ int __rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param,
41954201
}
41964202
EXPORT_SYMBOL(__rdma_accept);
41974203

4204+
int __rdma_accept_ece(struct rdma_cm_id *id, struct rdma_conn_param *conn_param,
4205+
const char *caller, struct rdma_ucm_ece *ece)
4206+
{
4207+
struct rdma_id_private *id_priv =
4208+
container_of(id, struct rdma_id_private, id);
4209+
4210+
id_priv->ece.vendor_id = ece->vendor_id;
4211+
id_priv->ece.attr_mod = ece->attr_mod;
4212+
4213+
return __rdma_accept(id, conn_param, caller);
4214+
}
4215+
EXPORT_SYMBOL(__rdma_accept_ece);
4216+
41984217
int rdma_notify(struct rdma_cm_id *id, enum ib_event_type event)
41994218
{
42004219
struct rdma_id_private *id_priv;

‎drivers/infiniband/core/ucma.c‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,28 +1135,36 @@ static ssize_t ucma_accept(struct ucma_file *file, const char __user *inbuf,
11351135
{
11361136
struct rdma_ucm_accept cmd;
11371137
struct rdma_conn_param conn_param;
1138+
struct rdma_ucm_ece ece = {};
11381139
struct ucma_context *ctx;
1140+
size_t in_size;
11391141
int ret;
11401142

1141-
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
1143+
in_size = min_t(size_t, in_len, sizeof(cmd));
1144+
if (copy_from_user(&cmd, inbuf, in_size))
11421145
return -EFAULT;
11431146

11441147
ctx = ucma_get_ctx_dev(file, cmd.id);
11451148
if (IS_ERR(ctx))
11461149
return PTR_ERR(ctx);
11471150

1151+
if (offsetofend(typeof(cmd), ece) <= in_size) {
1152+
ece.vendor_id = cmd.ece.vendor_id;
1153+
ece.attr_mod = cmd.ece.attr_mod;
1154+
}
1155+
11481156
if (cmd.conn_param.valid) {
11491157
ucma_copy_conn_param(ctx->cm_id, &conn_param, &cmd.conn_param);
11501158
mutex_lock(&file->mut);
11511159
mutex_lock(&ctx->mutex);
1152-
ret = __rdma_accept(ctx->cm_id, &conn_param, NULL);
1160+
ret = __rdma_accept_ece(ctx->cm_id, &conn_param, NULL, &ece);
11531161
mutex_unlock(&ctx->mutex);
11541162
if (!ret)
11551163
ctx->uid = cmd.uid;
11561164
mutex_unlock(&file->mut);
11571165
} else {
11581166
mutex_lock(&ctx->mutex);
1159-
ret = __rdma_accept(ctx->cm_id, NULL, NULL);
1167+
ret = __rdma_accept_ece(ctx->cm_id, NULL, NULL, &ece);
11601168
mutex_unlock(&ctx->mutex);
11611169
}
11621170
ucma_put_ctx(ctx);

‎include/rdma/rdma_cm.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ int rdma_listen(struct rdma_cm_id *id, int backlog);
280280
int __rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param,
281281
const char *caller);
282282

283+
int __rdma_accept_ece(struct rdma_cm_id *id, struct rdma_conn_param *conn_param,
284+
const char *caller, struct rdma_ucm_ece *ece);
285+
283286
/**
284287
* rdma_accept - Called to accept a connection request or response.
285288
* @id: Connection identifier associated with the request.

‎include/uapi/rdma/rdma_user_cm.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ struct rdma_ucm_accept {
232232
struct rdma_ucm_conn_param conn_param;
233233
__u32 id;
234234
__u32 reserved;
235+
struct rdma_ucm_ece ece;
235236
};
236237

237238
struct rdma_ucm_reject {

0 commit comments

Comments
 (0)