diff options
author | Roland Dreier <rolandd@cisco.com> | 2006-01-30 17:29:21 -0500 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-03-20 13:08:07 -0500 |
commit | 33b9b3ee9709b19c4f02ab91571d53540d05c3d1 (patch) | |
tree | 2d1019e9b8bf63e4235d7c73fd78ab294b993de2 /drivers/infiniband/core/uverbs_cmd.c | |
parent | 399d7921299fc4f146bd62bfa6312382a5429bcc (diff) |
IB: Add userspace support for resizing CQs
Add support to uverbs to handle resizing userspace CQs (completion
queues), including adding an ABI for marshalling requests and
responses. The kernel midlayer already has ib_resize_cq().
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/core/uverbs_cmd.c')
-rw-r--r-- | drivers/infiniband/core/uverbs_cmd.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 407b6284d7d5..be1cef1b3116 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2005 Topspin Communications. All rights reserved. | 2 | * Copyright (c) 2005 Topspin Communications. All rights reserved. |
3 | * Copyright (c) 2005 Cisco Systems. All rights reserved. | 3 | * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved. |
4 | * Copyright (c) 2005 PathScale, Inc. All rights reserved. | 4 | * Copyright (c) 2005 PathScale, Inc. All rights reserved. |
5 | * | 5 | * |
6 | * This software is available to you under a choice of one of two | 6 | * This software is available to you under a choice of one of two |
@@ -675,6 +675,46 @@ err: | |||
675 | return ret; | 675 | return ret; |
676 | } | 676 | } |
677 | 677 | ||
678 | ssize_t ib_uverbs_resize_cq(struct ib_uverbs_file *file, | ||
679 | const char __user *buf, int in_len, | ||
680 | int out_len) | ||
681 | { | ||
682 | struct ib_uverbs_resize_cq cmd; | ||
683 | struct ib_uverbs_resize_cq_resp resp; | ||
684 | struct ib_udata udata; | ||
685 | struct ib_cq *cq; | ||
686 | int ret = -EINVAL; | ||
687 | |||
688 | if (copy_from_user(&cmd, buf, sizeof cmd)) | ||
689 | return -EFAULT; | ||
690 | |||
691 | INIT_UDATA(&udata, buf + sizeof cmd, | ||
692 | (unsigned long) cmd.response + sizeof resp, | ||
693 | in_len - sizeof cmd, out_len - sizeof resp); | ||
694 | |||
695 | mutex_lock(&ib_uverbs_idr_mutex); | ||
696 | |||
697 | cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); | ||
698 | if (!cq || cq->uobject->context != file->ucontext || !cq->device->resize_cq) | ||
699 | goto out; | ||
700 | |||
701 | ret = cq->device->resize_cq(cq, cmd.cqe, &udata); | ||
702 | if (ret) | ||
703 | goto out; | ||
704 | |||
705 | memset(&resp, 0, sizeof resp); | ||
706 | resp.cqe = cq->cqe; | ||
707 | |||
708 | if (copy_to_user((void __user *) (unsigned long) cmd.response, | ||
709 | &resp, sizeof resp)) | ||
710 | ret = -EFAULT; | ||
711 | |||
712 | out: | ||
713 | mutex_unlock(&ib_uverbs_idr_mutex); | ||
714 | |||
715 | return ret ? ret : in_len; | ||
716 | } | ||
717 | |||
678 | ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file, | 718 | ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file, |
679 | const char __user *buf, int in_len, | 719 | const char __user *buf, int in_len, |
680 | int out_len) | 720 | int out_len) |