aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorDotan Barak <dotanb@mellanox.co.il>2006-02-13 19:31:57 -0500
committerRoland Dreier <rolandd@cisco.com>2006-03-20 13:08:14 -0500
commit8bdb0e8632e0f5061bd18b6934346cb609490135 (patch)
treebaa94a9ad7c97f4c025452ffbba2b7f6d8cc0af2 /drivers/infiniband
parent7ccc9a24e01258a31ee2b964215e4ddddd2a02c4 (diff)
IB/uverbs: Support for query SRQ from userspace
Add support to uverbs to handle querying userspace SRQs (shared receive queues), including adding an ABI for marshalling requests and responses. The kernel midlayer already has the underlying ib_query_srq() function. Signed-off-by: Dotan Barak <dotanb@mellanox.co.il> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/core/uverbs.h1
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c44
-rw-r--r--drivers/infiniband/core/uverbs_main.c1
3 files changed, 46 insertions, 0 deletions
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
index 89c798eb5749..3372d67ff139 100644
--- a/drivers/infiniband/core/uverbs.h
+++ b/drivers/infiniband/core/uverbs.h
@@ -195,6 +195,7 @@ IB_UVERBS_DECLARE_CMD(attach_mcast);
195IB_UVERBS_DECLARE_CMD(detach_mcast); 195IB_UVERBS_DECLARE_CMD(detach_mcast);
196IB_UVERBS_DECLARE_CMD(create_srq); 196IB_UVERBS_DECLARE_CMD(create_srq);
197IB_UVERBS_DECLARE_CMD(modify_srq); 197IB_UVERBS_DECLARE_CMD(modify_srq);
198IB_UVERBS_DECLARE_CMD(query_srq);
198IB_UVERBS_DECLARE_CMD(destroy_srq); 199IB_UVERBS_DECLARE_CMD(destroy_srq);
199 200
200#endif /* UVERBS_H */ 201#endif /* UVERBS_H */
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 4cbef8c06634..38a66fbef36d 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -2,6 +2,7 @@
2 * Copyright (c) 2005 Topspin Communications. All rights reserved. 2 * Copyright (c) 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005, 2006 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 * Copyright (c) 2006 Mellanox Technologies. All rights reserved.
5 * 6 *
6 * This software is available to you under a choice of one of two 7 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU 8 * licenses. You may choose to be licensed under the terms of the GNU
@@ -1923,6 +1924,49 @@ out:
1923 return ret ? ret : in_len; 1924 return ret ? ret : in_len;
1924} 1925}
1925 1926
1927ssize_t ib_uverbs_query_srq(struct ib_uverbs_file *file,
1928 const char __user *buf,
1929 int in_len, int out_len)
1930{
1931 struct ib_uverbs_query_srq cmd;
1932 struct ib_uverbs_query_srq_resp resp;
1933 struct ib_srq_attr attr;
1934 struct ib_srq *srq;
1935 int ret;
1936
1937 if (out_len < sizeof resp)
1938 return -ENOSPC;
1939
1940 if (copy_from_user(&cmd, buf, sizeof cmd))
1941 return -EFAULT;
1942
1943 mutex_lock(&ib_uverbs_idr_mutex);
1944
1945 srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle);
1946 if (srq && srq->uobject->context == file->ucontext)
1947 ret = ib_query_srq(srq, &attr);
1948 else
1949 ret = -EINVAL;
1950
1951 mutex_unlock(&ib_uverbs_idr_mutex);
1952
1953 if (ret)
1954 goto out;
1955
1956 memset(&resp, 0, sizeof resp);
1957
1958 resp.max_wr = attr.max_wr;
1959 resp.max_sge = attr.max_sge;
1960 resp.srq_limit = attr.srq_limit;
1961
1962 if (copy_to_user((void __user *) (unsigned long) cmd.response,
1963 &resp, sizeof resp))
1964 ret = -EFAULT;
1965
1966out:
1967 return ret ? ret : in_len;
1968}
1969
1926ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, 1970ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
1927 const char __user *buf, int in_len, 1971 const char __user *buf, int in_len,
1928 int out_len) 1972 int out_len)
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 91e4750fa319..ff092a0a94da 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -108,6 +108,7 @@ static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file,
108 [IB_USER_VERBS_CMD_DETACH_MCAST] = ib_uverbs_detach_mcast, 108 [IB_USER_VERBS_CMD_DETACH_MCAST] = ib_uverbs_detach_mcast,
109 [IB_USER_VERBS_CMD_CREATE_SRQ] = ib_uverbs_create_srq, 109 [IB_USER_VERBS_CMD_CREATE_SRQ] = ib_uverbs_create_srq,
110 [IB_USER_VERBS_CMD_MODIFY_SRQ] = ib_uverbs_modify_srq, 110 [IB_USER_VERBS_CMD_MODIFY_SRQ] = ib_uverbs_modify_srq,
111 [IB_USER_VERBS_CMD_QUERY_SRQ] = ib_uverbs_query_srq,
111 [IB_USER_VERBS_CMD_DESTROY_SRQ] = ib_uverbs_destroy_srq, 112 [IB_USER_VERBS_CMD_DESTROY_SRQ] = ib_uverbs_destroy_srq,
112}; 113};
113 114