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 | |
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>
-rw-r--r-- | drivers/infiniband/core/uverbs.h | 3 | ||||
-rw-r--r-- | drivers/infiniband/core/uverbs_cmd.c | 42 | ||||
-rw-r--r-- | drivers/infiniband/core/uverbs_main.c | 3 | ||||
-rw-r--r-- | drivers/infiniband/core/verbs.c | 4 | ||||
-rw-r--r-- | include/rdma/ib_user_verbs.h | 13 | ||||
-rw-r--r-- | include/rdma/ib_verbs.h | 5 |
6 files changed, 62 insertions, 8 deletions
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index f7eecbc6af6c..3207239819ce 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h | |||
@@ -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 Mellanox Technologies. All rights reserved. | 4 | * Copyright (c) 2005 Mellanox Technologies. All rights reserved. |
5 | * Copyright (c) 2005 Voltaire, Inc. All rights reserved. | 5 | * Copyright (c) 2005 Voltaire, Inc. All rights reserved. |
6 | * Copyright (c) 2005 PathScale, Inc. All rights reserved. | 6 | * Copyright (c) 2005 PathScale, Inc. All rights reserved. |
@@ -178,6 +178,7 @@ IB_UVERBS_DECLARE_CMD(reg_mr); | |||
178 | IB_UVERBS_DECLARE_CMD(dereg_mr); | 178 | IB_UVERBS_DECLARE_CMD(dereg_mr); |
179 | IB_UVERBS_DECLARE_CMD(create_comp_channel); | 179 | IB_UVERBS_DECLARE_CMD(create_comp_channel); |
180 | IB_UVERBS_DECLARE_CMD(create_cq); | 180 | IB_UVERBS_DECLARE_CMD(create_cq); |
181 | IB_UVERBS_DECLARE_CMD(resize_cq); | ||
181 | IB_UVERBS_DECLARE_CMD(poll_cq); | 182 | IB_UVERBS_DECLARE_CMD(poll_cq); |
182 | IB_UVERBS_DECLARE_CMD(req_notify_cq); | 183 | IB_UVERBS_DECLARE_CMD(req_notify_cq); |
183 | IB_UVERBS_DECLARE_CMD(destroy_cq); | 184 | IB_UVERBS_DECLARE_CMD(destroy_cq); |
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) |
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 903f85a4bc0c..099fe6cde68c 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.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 Mellanox Technologies. All rights reserved. | 4 | * Copyright (c) 2005 Mellanox Technologies. All rights reserved. |
5 | * Copyright (c) 2005 Voltaire, Inc. All rights reserved. | 5 | * Copyright (c) 2005 Voltaire, Inc. All rights reserved. |
6 | * Copyright (c) 2005 PathScale, Inc. All rights reserved. | 6 | * Copyright (c) 2005 PathScale, Inc. All rights reserved. |
@@ -91,6 +91,7 @@ static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file, | |||
91 | [IB_USER_VERBS_CMD_DEREG_MR] = ib_uverbs_dereg_mr, | 91 | [IB_USER_VERBS_CMD_DEREG_MR] = ib_uverbs_dereg_mr, |
92 | [IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL] = ib_uverbs_create_comp_channel, | 92 | [IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL] = ib_uverbs_create_comp_channel, |
93 | [IB_USER_VERBS_CMD_CREATE_CQ] = ib_uverbs_create_cq, | 93 | [IB_USER_VERBS_CMD_CREATE_CQ] = ib_uverbs_create_cq, |
94 | [IB_USER_VERBS_CMD_RESIZE_CQ] = ib_uverbs_resize_cq, | ||
94 | [IB_USER_VERBS_CMD_POLL_CQ] = ib_uverbs_poll_cq, | 95 | [IB_USER_VERBS_CMD_POLL_CQ] = ib_uverbs_poll_cq, |
95 | [IB_USER_VERBS_CMD_REQ_NOTIFY_CQ] = ib_uverbs_req_notify_cq, | 96 | [IB_USER_VERBS_CMD_REQ_NOTIFY_CQ] = ib_uverbs_req_notify_cq, |
96 | [IB_USER_VERBS_CMD_DESTROY_CQ] = ib_uverbs_destroy_cq, | 97 | [IB_USER_VERBS_CMD_DESTROY_CQ] = ib_uverbs_destroy_cq, |
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index c857361be449..8e0ba16bcbdd 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * Copyright (c) 2004 Topspin Corporation. All rights reserved. | 5 | * Copyright (c) 2004 Topspin Corporation. All rights reserved. |
6 | * Copyright (c) 2004 Voltaire Corporation. All rights reserved. | 6 | * Copyright (c) 2004 Voltaire Corporation. All rights reserved. |
7 | * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. | 7 | * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. |
8 | * Copyright (c) 2005 Cisco Systems. All rights reserved. | 8 | * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved. |
9 | * | 9 | * |
10 | * This software is available to you under a choice of one of two | 10 | * This software is available to you under a choice of one of two |
11 | * licenses. You may choose to be licensed under the terms of the GNU | 11 | * licenses. You may choose to be licensed under the terms of the GNU |
@@ -326,7 +326,7 @@ int ib_resize_cq(struct ib_cq *cq, | |||
326 | int cqe) | 326 | int cqe) |
327 | { | 327 | { |
328 | return cq->device->resize_cq ? | 328 | return cq->device->resize_cq ? |
329 | cq->device->resize_cq(cq, cqe) : -ENOSYS; | 329 | cq->device->resize_cq(cq, cqe, NULL) : -ENOSYS; |
330 | } | 330 | } |
331 | EXPORT_SYMBOL(ib_resize_cq); | 331 | EXPORT_SYMBOL(ib_resize_cq); |
332 | 332 | ||
diff --git a/include/rdma/ib_user_verbs.h b/include/rdma/ib_user_verbs.h index 5ff1490c08db..6ad1207e4235 100644 --- a/include/rdma/ib_user_verbs.h +++ b/include/rdma/ib_user_verbs.h | |||
@@ -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 |
@@ -265,6 +265,17 @@ struct ib_uverbs_create_cq_resp { | |||
265 | __u32 cqe; | 265 | __u32 cqe; |
266 | }; | 266 | }; |
267 | 267 | ||
268 | struct ib_uverbs_resize_cq { | ||
269 | __u64 response; | ||
270 | __u32 cq_handle; | ||
271 | __u32 cqe; | ||
272 | __u64 driver_data[0]; | ||
273 | }; | ||
274 | |||
275 | struct ib_uverbs_resize_cq_resp { | ||
276 | __u32 cqe; | ||
277 | }; | ||
278 | |||
268 | struct ib_uverbs_poll_cq { | 279 | struct ib_uverbs_poll_cq { |
269 | __u64 response; | 280 | __u64 response; |
270 | __u32 cq_handle; | 281 | __u32 cq_handle; |
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 22fc886b9695..38fa6c082eae 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h | |||
@@ -5,7 +5,7 @@ | |||
5 | * Copyright (c) 2004 Topspin Corporation. All rights reserved. | 5 | * Copyright (c) 2004 Topspin Corporation. All rights reserved. |
6 | * Copyright (c) 2004 Voltaire Corporation. All rights reserved. | 6 | * Copyright (c) 2004 Voltaire Corporation. All rights reserved. |
7 | * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. | 7 | * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. |
8 | * Copyright (c) 2005 Cisco Systems. All rights reserved. | 8 | * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved. |
9 | * | 9 | * |
10 | * This software is available to you under a choice of one of two | 10 | * This software is available to you under a choice of one of two |
11 | * licenses. You may choose to be licensed under the terms of the GNU | 11 | * licenses. You may choose to be licensed under the terms of the GNU |
@@ -880,7 +880,8 @@ struct ib_device { | |||
880 | struct ib_ucontext *context, | 880 | struct ib_ucontext *context, |
881 | struct ib_udata *udata); | 881 | struct ib_udata *udata); |
882 | int (*destroy_cq)(struct ib_cq *cq); | 882 | int (*destroy_cq)(struct ib_cq *cq); |
883 | int (*resize_cq)(struct ib_cq *cq, int cqe); | 883 | int (*resize_cq)(struct ib_cq *cq, int cqe, |
884 | struct ib_udata *udata); | ||
884 | int (*poll_cq)(struct ib_cq *cq, int num_entries, | 885 | int (*poll_cq)(struct ib_cq *cq, int num_entries, |
885 | struct ib_wc *wc); | 886 | struct ib_wc *wc); |
886 | int (*peek_cq)(struct ib_cq *cq, int wc_cnt); | 887 | int (*peek_cq)(struct ib_cq *cq, int wc_cnt); |