Skip to content

Commit 8094ba0

Browse files
Leon Romanovskyjgunthorpe
authored andcommitted
RDMA/cma: Provide ECE reject reason
IBTA declares "vendor option not supported" reject reason in REJ messages if passive side doesn't want to accept proposed ECE options. Due to the fact that ECE is managed by userspace, there is a need to let users to provide such rejected reason. Link: https://lore.kernel.org/r/20200526103304.196371-7-leon@kernel.org Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent 0cb1537 commit 8094ba0

9 files changed

Lines changed: 34 additions & 14 deletions

File tree

‎drivers/infiniband/core/cma.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4196,7 +4196,7 @@ int __rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param,
41964196
return 0;
41974197
reject:
41984198
cma_modify_qp_err(id_priv);
4199-
rdma_reject(id, NULL, 0);
4199+
rdma_reject(id, NULL, 0, IB_CM_REJ_CONSUMER_DEFINED);
42004200
return ret;
42014201
}
42024202
EXPORT_SYMBOL(__rdma_accept);
@@ -4236,7 +4236,7 @@ int rdma_notify(struct rdma_cm_id *id, enum ib_event_type event)
42364236
EXPORT_SYMBOL(rdma_notify);
42374237

42384238
int rdma_reject(struct rdma_cm_id *id, const void *private_data,
4239-
u8 private_data_len)
4239+
u8 private_data_len, u8 reason)
42404240
{
42414241
struct rdma_id_private *id_priv;
42424242
int ret;
@@ -4251,9 +4251,8 @@ int rdma_reject(struct rdma_cm_id *id, const void *private_data,
42514251
private_data, private_data_len);
42524252
} else {
42534253
trace_cm_send_rej(id_priv);
4254-
ret = ib_send_cm_rej(id_priv->cm_id.ib,
4255-
IB_CM_REJ_CONSUMER_DEFINED, NULL,
4256-
0, private_data, private_data_len);
4254+
ret = ib_send_cm_rej(id_priv->cm_id.ib, reason, NULL, 0,
4255+
private_data, private_data_len);
42574256
}
42584257
} else if (rdma_cap_iw_cm(id->device, id->port_num)) {
42594258
ret = iw_cm_reject(id_priv->cm_id.iw,

‎drivers/infiniband/core/ucma.c‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include <rdma/rdma_cm_ib.h>
5353
#include <rdma/ib_addr.h>
5454
#include <rdma/ib.h>
55+
#include <rdma/ib_cm.h>
5556
#include <rdma/rdma_netlink.h>
5657
#include "core_priv.h"
5758

@@ -1181,12 +1182,24 @@ static ssize_t ucma_reject(struct ucma_file *file, const char __user *inbuf,
11811182
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
11821183
return -EFAULT;
11831184

1185+
if (!cmd.reason)
1186+
cmd.reason = IB_CM_REJ_CONSUMER_DEFINED;
1187+
1188+
switch (cmd.reason) {
1189+
case IB_CM_REJ_CONSUMER_DEFINED:
1190+
case IB_CM_REJ_VENDOR_OPTION_NOT_SUPPORTED:
1191+
break;
1192+
default:
1193+
return -EINVAL;
1194+
}
1195+
11841196
ctx = ucma_get_ctx_dev(file, cmd.id);
11851197
if (IS_ERR(ctx))
11861198
return PTR_ERR(ctx);
11871199

11881200
mutex_lock(&ctx->mutex);
1189-
ret = rdma_reject(ctx->cm_id, cmd.private_data, cmd.private_data_len);
1201+
ret = rdma_reject(ctx->cm_id, cmd.private_data, cmd.private_data_len,
1202+
cmd.reason);
11901203
mutex_unlock(&ctx->mutex);
11911204
ucma_put_ctx(ctx);
11921205
return ret;

‎drivers/infiniband/ulp/isert/ib_isert.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/in.h>
1616
#include <linux/in6.h>
1717
#include <rdma/ib_verbs.h>
18+
#include <rdma/ib_cm.h>
1819
#include <rdma/rdma_cm.h>
1920
#include <target/target_core_base.h>
2021
#include <target/target_core_fabric.h>
@@ -502,7 +503,7 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
502503
if (!np->enabled) {
503504
spin_unlock_bh(&np->np_thread_lock);
504505
isert_dbg("iscsi_np is not enabled, reject connect request\n");
505-
return rdma_reject(cma_id, NULL, 0);
506+
return rdma_reject(cma_id, NULL, 0, IB_CM_REJ_CONSUMER_DEFINED);
506507
}
507508
spin_unlock_bh(&np->np_thread_lock);
508509

@@ -553,7 +554,7 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
553554
isert_free_login_buf(isert_conn);
554555
out:
555556
kfree(isert_conn);
556-
rdma_reject(cma_id, NULL, 0);
557+
rdma_reject(cma_id, NULL, 0, IB_CM_REJ_CONSUMER_DEFINED);
557558
return ret;
558559
}
559560

‎drivers/infiniband/ulp/rtrs/rtrs-srv.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "rtrs-srv.h"
1717
#include "rtrs-log.h"
18+
#include <rdma/ib_cm.h>
1819

1920
MODULE_DESCRIPTION("RDMA Transport Server");
2021
MODULE_LICENSE("GPL");
@@ -1576,7 +1577,7 @@ static int rtrs_rdma_do_reject(struct rdma_cm_id *cm_id, int errno)
15761577
.errno = cpu_to_le16(errno),
15771578
};
15781579

1579-
err = rdma_reject(cm_id, &msg, sizeof(msg));
1580+
err = rdma_reject(cm_id, &msg, sizeof(msg), IB_CM_REJ_CONSUMER_DEFINED);
15801581
if (err)
15811582
pr_err("rdma_reject(), err: %d\n", err);
15821583

‎drivers/infiniband/ulp/srpt/ib_srpt.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2497,7 +2497,8 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev,
24972497
SRP_BUF_FORMAT_INDIRECT);
24982498

24992499
if (rdma_cm_id)
2500-
rdma_reject(rdma_cm_id, rej, sizeof(*rej));
2500+
rdma_reject(rdma_cm_id, rej, sizeof(*rej),
2501+
IB_CM_REJ_CONSUMER_DEFINED);
25012502
else
25022503
ib_send_cm_rej(ib_cm_id, IB_CM_REJ_CONSUMER_DEFINED, NULL, 0,
25032504
rej, sizeof(*rej));

‎drivers/nvme/target/rdma.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <rdma/ib_verbs.h>
2121
#include <rdma/rdma_cm.h>
2222
#include <rdma/rw.h>
23+
#include <rdma/ib_cm.h>
2324

2425
#include <linux/nvme-rdma.h>
2526
#include "nvmet.h"
@@ -1138,7 +1139,8 @@ static int nvmet_rdma_cm_reject(struct rdma_cm_id *cm_id,
11381139
rej.recfmt = cpu_to_le16(NVME_RDMA_CM_FMT_1_0);
11391140
rej.sts = cpu_to_le16(status);
11401141

1141-
return rdma_reject(cm_id, (void *)&rej, sizeof(rej));
1142+
return rdma_reject(cm_id, (void *)&rej, sizeof(rej),
1143+
IB_CM_REJ_CONSUMER_DEFINED);
11421144
}
11431145

11441146
static struct nvmet_rdma_queue *

‎include/rdma/rdma_cm.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ int rdma_notify(struct rdma_cm_id *id, enum ib_event_type event);
320320
* rdma_reject - Called to reject a connection request or response.
321321
*/
322322
int rdma_reject(struct rdma_cm_id *id, const void *private_data,
323-
u8 private_data_len);
323+
u8 private_data_len, u8 reason);
324324

325325
/**
326326
* rdma_disconnect - This function disconnects the associated QP and

‎include/uapi/rdma/rdma_user_cm.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ struct rdma_ucm_accept {
238238
struct rdma_ucm_reject {
239239
__u32 id;
240240
__u8 private_data_len;
241-
__u8 reserved[3];
241+
__u8 reason;
242+
__u8 reserved[2];
242243
__u8 private_data[RDMA_MAX_PRIVATE_DATA];
243244
};
244245

‎net/rds/ib_cm.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <linux/vmalloc.h>
3838
#include <linux/ratelimit.h>
3939
#include <net/addrconf.h>
40+
#include <rdma/ib_cm.h>
4041

4142
#include "rds_single_path.h"
4243
#include "rds.h"
@@ -927,7 +928,8 @@ int rds_ib_cm_handle_connect(struct rdma_cm_id *cm_id,
927928
if (conn)
928929
mutex_unlock(&conn->c_cm_lock);
929930
if (err)
930-
rdma_reject(cm_id, &err, sizeof(int));
931+
rdma_reject(cm_id, &err, sizeof(int),
932+
IB_CM_REJ_CONSUMER_DEFINED);
931933
return destroy;
932934
}
933935

0 commit comments

Comments
 (0)