[openib-general] core kernel changes for query SRQ

Dotan Barak dotanb at mellanox.co.il
Thu Feb 9 07:00:48 PST 2006


Add support to uverbs to handle querying userspace SRQs (Shared
Receive Queue), including adding an ABI for marshalling requests and
responses.  The kernel midlayer already has ib_query_srq().

Signed-off-by: Dotan Barak <dotanb at mellanox.co.il>

Index: last_stable/drivers/infiniband/core/uverbs.h
===================================================================
--- last_stable.orig/drivers/infiniband/core/uverbs.h	2006-02-07 17:04:05.000000000 +0200
+++ last_stable/drivers/infiniband/core/uverbs.h	2006-02-08 09:51:59.000000000 +0200
@@ -201,6 +201,7 @@ IB_UVERBS_DECLARE_CMD(attach_mcast);
 IB_UVERBS_DECLARE_CMD(detach_mcast);
 IB_UVERBS_DECLARE_CMD(create_srq);
 IB_UVERBS_DECLARE_CMD(modify_srq);
+IB_UVERBS_DECLARE_CMD(query_srq);
 IB_UVERBS_DECLARE_CMD(destroy_srq);
 
 #endif /* UVERBS_H */
Index: last_stable/drivers/infiniband/core/uverbs_cmd.c
===================================================================
--- last_stable.orig/drivers/infiniband/core/uverbs_cmd.c	2006-02-07 17:04:05.000000000 +0200
+++ last_stable/drivers/infiniband/core/uverbs_cmd.c	2006-02-08 09:56:04.000000000 +0200
@@ -2,6 +2,7 @@
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005, 2006 Cisco Systems.  All rights reserved.
  * Copyright (c) 2005 PathScale, Inc.  All rights reserved.
+ * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -1823,6 +1824,49 @@ out:
 	return ret ? ret : in_len;
 }
 
+ssize_t ib_uverbs_query_srq(struct ib_uverbs_file *file,
+			    const char __user *buf,
+			    int in_len, int out_len)
+{
+	struct ib_uverbs_query_srq      cmd;
+	struct ib_uverbs_query_srq_resp resp;
+	struct ib_srq_attr              attr;
+	struct ib_srq                   *srq;
+	int                             ret;
+
+	if (out_len < sizeof resp)
+		return -ENOSPC;
+
+	if (copy_from_user(&cmd, buf, sizeof cmd))
+		return -EFAULT;
+
+	mutex_lock(&ib_uverbs_idr_mutex);
+
+	srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle);
+	if (!srq || srq->uobject->context != file->ucontext) {
+		ret = -EINVAL;
+		goto out;
+	}
+
+	ret = ib_query_srq(srq, &attr);
+
+out:
+	mutex_unlock(&ib_uverbs_idr_mutex);
+	if (!ret) {
+		memset(&resp, 0, sizeof resp);
+
+		resp.max_wr    = attr.max_wr;
+		resp.max_sge   = attr.max_sge;
+		resp.srq_limit = attr.srq_limit;
+
+		if (copy_to_user((void __user *) (unsigned long) cmd.response,
+				 &resp, sizeof resp))
+			ret = -EFAULT;
+	}
+
+	return ret ? ret : in_len;
+}
+
 ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
 			      const char __user *buf, int in_len,
 			      int out_len)
Index: last_stable/drivers/infiniband/core/uverbs_main.c
===================================================================
--- last_stable.orig/drivers/infiniband/core/uverbs_main.c	2006-02-07 21:13:38.000000000 +0200
+++ last_stable/drivers/infiniband/core/uverbs_main.c	2006-02-08 09:56:39.000000000 +0200
@@ -107,6 +107,7 @@ static ssize_t (*uverbs_cmd_table[])(str
 	[IB_USER_VERBS_CMD_DETACH_MCAST]	= ib_uverbs_detach_mcast,
 	[IB_USER_VERBS_CMD_CREATE_SRQ]		= ib_uverbs_create_srq,
 	[IB_USER_VERBS_CMD_MODIFY_SRQ]		= ib_uverbs_modify_srq,
+	[IB_USER_VERBS_CMD_QUERY_SRQ]		= ib_uverbs_query_srq,
 	[IB_USER_VERBS_CMD_DESTROY_SRQ]   	= ib_uverbs_destroy_srq,
 };
 
Index: last_stable/drivers/infiniband/include/rdma/ib_user_verbs.h
===================================================================
--- last_stable.orig/drivers/infiniband/include/rdma/ib_user_verbs.h	2006-02-07 17:04:01.000000000 +0200
+++ last_stable/drivers/infiniband/include/rdma/ib_user_verbs.h	2006-02-08 09:58:01.000000000 +0200
@@ -2,6 +2,7 @@
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005, 2006 Cisco Systems.  All rights reserved.
  * Copyright (c) 2005 PathScale, Inc.  All rights reserved.
+ * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -610,6 +611,20 @@ struct ib_uverbs_modify_srq {
 	__u64 driver_data[0];
 };
 
+struct ib_uverbs_query_srq {
+	__u64 response;
+	__u32 srq_handle;
+	__u32 reserved;
+	__u64 driver_data[0];
+};
+
+struct ib_uverbs_query_srq_resp {
+	__u32 max_wr;
+	__u32 max_sge;
+	__u32 srq_limit;
+	__u32 reserved;
+};
+
 struct ib_uverbs_destroy_srq {
 	__u64 response;
 	__u32 srq_handle;



Dotan Barak
Software Verification Engineer
Mellanox Technologies
Tel: +972-4-9097200 Ext: 231 Fax: +972-4-9593245
P.O. Box 86 Yokneam 20692 ISRAEL.
Home: +972-77-8841095  Cell: 052-4222383

[ May the fork be with you ]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20060209/659dc0e2/attachment.html>


More information about the general mailing list