[openib-general] [PATCH 4/4] uCMA: export UD QP support to userspace

Sean Hefty sean.hefty at intel.com
Tue Jun 6 19:57:24 PDT 2006


Export the RDMA CM's support of UD QPs to the userspace library.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
My intent is to bump the ABI version only once.  The multicast patches
will not increment the ABI.

Index: core/ucma.c
===================================================================
--- core/ucma.c	(revision 7758)
+++ core/ucma.c	(working copy)
@@ -41,6 +41,7 @@
 #include <rdma/rdma_user_cm.h>
 #include <rdma/ib_marshall.h>
 #include <rdma/rdma_cm.h>
+#include <rdma/rdma_cm_ib.h>
 
 #include "ucma_ib.h"
 
@@ -291,7 +292,7 @@ static ssize_t ucma_create_id(struct ucm
 		return -ENOMEM;
 
 	ctx->uid = cmd.uid;
-	ctx->cm_id = rdma_create_id(ucma_event_handler, ctx, RDMA_PS_TCP);
+	ctx->cm_id = rdma_create_id(ucma_event_handler, ctx, cmd.ps);
 	if (IS_ERR(ctx->cm_id)) {
 		ret = PTR_ERR(ctx->cm_id);
 		goto err1;
@@ -736,6 +737,40 @@ static ssize_t ucma_set_option(struct uc
 	return ret;
 }
 
+static ssize_t ucma_get_dst_attr(struct ucma_file *file,
+				 const char __user *inbuf,
+				 int in_len, int out_len)
+{
+	struct rdma_ucm_get_dst_attr cmd;
+	struct rdma_ucm_dst_attr_resp resp;
+	struct ib_ah_attr ah_attr;
+	struct ucma_context *ctx;
+	int ret;
+
+	if (out_len < sizeof(resp))
+		return -ENOSPC;
+
+	if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+		return -EFAULT;
+
+	ctx = ucma_get_ctx(file, cmd.id);
+	if (IS_ERR(ctx))
+		return PTR_ERR(ctx);
+
+	ret = rdma_get_dst_attr(ctx->cm_id, (struct sockaddr *) &cmd.addr,
+				&ah_attr, &resp.remote_qpn, &resp.remote_qkey);
+	if (ret)
+		goto out;
+
+	ib_copy_ah_attr_to_user(&resp.ah_attr, &ah_attr);
+	if (copy_to_user((void __user *)(unsigned long)cmd.response,
+			 &resp, sizeof(resp)))
+		ret = -EFAULT;
+out:
+	ucma_put_ctx(ctx);
+	return ret;
+}
+
 static ssize_t (*ucma_cmd_table[])(struct ucma_file *file,
 				   const char __user *inbuf,
 				   int in_len, int out_len) = {
@@ -753,7 +788,8 @@ static ssize_t (*ucma_cmd_table[])(struc
 	[RDMA_USER_CM_CMD_INIT_QP_ATTR]	= ucma_init_qp_attr,
 	[RDMA_USER_CM_CMD_GET_EVENT]	= ucma_get_event,
 	[RDMA_USER_CM_CMD_GET_OPTION]	= ucma_get_option,
-	[RDMA_USER_CM_CMD_SET_OPTION]	= ucma_set_option
+	[RDMA_USER_CM_CMD_SET_OPTION]	= ucma_set_option,
+	[RDMA_USER_CM_CMD_GET_DST_ATTR] = ucma_get_dst_attr
 };
 
 static ssize_t ucma_write(struct file *filp, const char __user *buf,
Index: include/rdma/rdma_user_cm.h
===================================================================
--- include/rdma/rdma_user_cm.h	(revision 7758)
+++ include/rdma/rdma_user_cm.h	(working copy)
@@ -38,7 +38,7 @@
 #include <rdma/ib_user_verbs.h>
 #include <rdma/ib_user_sa.h>
 
-#define RDMA_USER_CM_ABI_VERSION	1
+#define RDMA_USER_CM_ABI_VERSION	2
 
 #define RDMA_MAX_PRIVATE_DATA		256
 
@@ -58,6 +58,7 @@ enum {
 	RDMA_USER_CM_CMD_GET_EVENT,
 	RDMA_USER_CM_CMD_GET_OPTION,
 	RDMA_USER_CM_CMD_SET_OPTION,
+	RDMA_USER_CM_CMD_GET_DST_ATTR
 };
 
 /*
@@ -72,6 +73,8 @@ struct rdma_ucm_cmd_hdr {
 struct rdma_ucm_create_id {
 	__u64 uid;
 	__u64 response;
+	__u16 ps;
+	__u8  reserved[6];
 };
 
 struct rdma_ucm_create_id_resp {
@@ -171,6 +174,18 @@ struct rdma_ucm_init_qp_attr {
 	__u32 qp_state;
 };
 
+struct rdma_ucm_dst_attr_resp {
+	__u32 remote_qpn;
+	__u32 remote_qkey;
+	struct ib_uverbs_ah_attr ah_attr;
+};
+
+struct rdma_ucm_get_dst_attr {
+	__u64 response;
+	struct sockaddr_in6 addr;
+	__u32 id;
+};
+
 struct rdma_ucm_get_event {
 	__u64 response;
 };





More information about the general mailing list