aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/ucma.c
diff options
context:
space:
mode:
authorSean Hefty <sean.hefty@intel.com>2010-04-01 13:08:41 -0400
committerRoland Dreier <roland@purestorage.com>2011-05-25 16:46:23 -0400
commitb26f9b9949013fec31b23c426fc463164ae08891 (patch)
tree072bbf5abb93baea33a4aebaad2381ff69563a0b /drivers/infiniband/core/ucma.c
parent9a7147b506ccae8552b0cf218b3c02982012eb4d (diff)
RDMA/cma: Pass QP type into rdma_create_id()
The RDMA CM currently infers the QP type from the port space selected by the user. In the future (eg with RDMA_PS_IB or XRC), there may not be a 1-1 correspondence between port space and QP type. For netlink export of RDMA CM state, we want to export the QP type to userspace, so it is cleaner to explicitly associate a QP type to an ID. Modify rdma_create_id() to allow the user to specify the QP type, and use it to make our selections of datagram versus connected mode. Signed-off-by: Sean Hefty <sean.hefty@intel.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband/core/ucma.c')
-rw-r--r--drivers/infiniband/core/ucma.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index b3fa798525b..7109d5d23ba 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -367,13 +367,28 @@ done:
367 return ret; 367 return ret;
368} 368}
369 369
370static ssize_t ucma_create_id(struct ucma_file *file, 370static int ucma_get_qp_type(struct rdma_ucm_create_id *cmd, enum ib_qp_type *qp_type)
371 const char __user *inbuf, 371{
372 int in_len, int out_len) 372 switch (cmd->ps) {
373 case RDMA_PS_TCP:
374 *qp_type = IB_QPT_RC;
375 return 0;
376 case RDMA_PS_UDP:
377 case RDMA_PS_IPOIB:
378 *qp_type = IB_QPT_UD;
379 return 0;
380 default:
381 return -EINVAL;
382 }
383}
384
385static ssize_t ucma_create_id(struct ucma_file *file, const char __user *inbuf,
386 int in_len, int out_len)
373{ 387{
374 struct rdma_ucm_create_id cmd; 388 struct rdma_ucm_create_id cmd;
375 struct rdma_ucm_create_id_resp resp; 389 struct rdma_ucm_create_id_resp resp;
376 struct ucma_context *ctx; 390 struct ucma_context *ctx;
391 enum ib_qp_type qp_type;
377 int ret; 392 int ret;
378 393
379 if (out_len < sizeof(resp)) 394 if (out_len < sizeof(resp))
@@ -382,6 +397,10 @@ static ssize_t ucma_create_id(struct ucma_file *file,
382 if (copy_from_user(&cmd, inbuf, sizeof(cmd))) 397 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
383 return -EFAULT; 398 return -EFAULT;
384 399
400 ret = ucma_get_qp_type(&cmd, &qp_type);
401 if (ret)
402 return ret;
403
385 mutex_lock(&file->mut); 404 mutex_lock(&file->mut);
386 ctx = ucma_alloc_ctx(file); 405 ctx = ucma_alloc_ctx(file);
387 mutex_unlock(&file->mut); 406 mutex_unlock(&file->mut);
@@ -389,7 +408,7 @@ static ssize_t ucma_create_id(struct ucma_file *file,
389 return -ENOMEM; 408 return -ENOMEM;
390 409
391 ctx->uid = cmd.uid; 410 ctx->uid = cmd.uid;
392 ctx->cm_id = rdma_create_id(ucma_event_handler, ctx, cmd.ps); 411 ctx->cm_id = rdma_create_id(ucma_event_handler, ctx, cmd.ps, qp_type);
393 if (IS_ERR(ctx->cm_id)) { 412 if (IS_ERR(ctx->cm_id)) {
394 ret = PTR_ERR(ctx->cm_id); 413 ret = PTR_ERR(ctx->cm_id);
395 goto err1; 414 goto err1;