[openib-general] [RFC] [PATCH 3/3] RDMA CM: add rdma_get/set_option calls to userspace library

Sean Hefty sean.hefty at intel.com
Tue Apr 25 16:43:41 PDT 2006


Support rdma_get_option / rdma_set_option through the userspace
RDMA CM library.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
Index: include/rdma/rdma_cma_abi.h
===================================================================
--- include/rdma/rdma_cma_abi.h	(revision 6335)
+++ include/rdma/rdma_cma_abi.h	(working copy)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005 Intel Corporation.  All rights reserved.
+ * Copyright (c) 2005-2006 Intel Corporation.  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
@@ -57,7 +57,9 @@ enum {
 	UCMA_CMD_REJECT,
 	UCMA_CMD_DISCONNECT,
 	UCMA_CMD_INIT_QP_ATTR,
-	UCMA_CMD_GET_EVENT
+	UCMA_CMD_GET_EVENT,
+	UCMA_CMD_GET_OPTION,
+	UCMA_CMD_SET_OPTION,
 };
 
 struct ucma_abi_cmd_hdr {
@@ -182,4 +184,25 @@ struct ucma_abi_event_resp {
 	__u8  private_data[RDMA_MAX_PRIVATE_DATA];
 };
 
+struct ucma_abi_get_option {
+	__u64 response;
+	__u64 optval;
+	__u32 id;
+	__u32 level;
+	__u32 optname;
+	__u32 optlen;
+};
+
+struct ucma_abi_get_option_resp {
+	__u32 optlen;
+};
+
+struct ucma_abi_set_option {
+	__u64 optval;
+	__u32 id;
+	__u32 level;
+	__u32 optname;
+	__u32 optlen;
+};
+
 #endif /* RDMA_CMA_ABI_H */
Index: include/rdma/rdma_cma.h
===================================================================
--- include/rdma/rdma_cma.h	(revision 5693)
+++ include/rdma/rdma_cma.h	(working copy)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2005 Voltaire Inc.  All rights reserved.
- * Copyright (c) 2005 Intel Corporation.  All rights reserved.
+ * Copyright (c) 2005-2006 Intel Corporation.  All rights reserved.
  *
  * This Software is licensed under one of the following licenses:
  *
@@ -54,6 +54,17 @@ enum rdma_cm_event_type {
 	RDMA_CM_EVENT_DEVICE_REMOVAL,
 };
 
+/* Protocol levels for get/set options. */
+enum {
+	RDMA_PROTO_IP = 0,
+	RDMA_PROTO_IB = 1,
+};
+
+/* IB specific option names for get/set. */
+enum {
+	IB_PATH_OPTIONS = 1,
+};
+
 struct ib_addr {
 	union ibv_gid	sgid;
 	union ibv_gid	dgid;
@@ -219,4 +230,27 @@ int rdma_ack_cm_event(struct rdma_cm_eve
 
 int rdma_get_fd(void);
 
+/**
+ * rdma_get_option - Retrieve options for an rdma_cm_id.
+ * @id: Communication identifier to retrieve option for.
+ * @level: Protocol level of the option to retrieve.
+ * @optname: Name of the option to retrieve.
+ * @optval: Buffer to receive the returned options.
+ * @optlen: On input, the size of the %optval buffer.  On output, the
+ *   size of the returned data.
+ */
+int rdma_get_option(struct rdma_cm_id *id, int level, int optname,
+		    void *optval, size_t *optlen);
+
+/**
+ * rdma_set_option - Set options for an rdma_cm_id.
+ * @id: Communication identifier to set option for.
+ * @level: Protocol level of the option to set.
+ * @optname: Name of the option to set.
+ * @optval: Reference to the option data.
+ * @optlen: The size of the %optval buffer.
+ */
+int rdma_set_option(struct rdma_cm_id *id, int level, int optname,
+		    void *optval, size_t optlen);
+
 #endif /* RDMA_CMA_H */
Index: src/cma.c
===================================================================
--- src/cma.c	(revision 6628)
+++ src/cma.c	(working copy)
@@ -952,3 +952,51 @@ int rdma_get_fd(void)
 
 	return cma_fd;
 }
+
+int rdma_get_option(struct rdma_cm_id *id, int level, int optname,
+		    void *optval, size_t *optlen)
+{
+	struct ucma_abi_get_option_resp *resp;
+	struct ucma_abi_get_option *cmd;
+	struct cma_id_private *id_priv;
+	void *msg;
+	int ret, size;
+	
+	CMA_CREATE_MSG_CMD_RESP(msg, cmd, resp, UCMA_CMD_GET_OPTION, size);
+	id_priv = container_of(id, struct cma_id_private, id);
+	cmd->id = id_priv->handle;
+	cmd->optval = (uintptr_t) optval;
+	cmd->level = level;
+	cmd->optname = optname;
+	cmd->optlen = *optlen;
+
+	ret = write(cma_fd, msg, size);
+	if (ret != size)
+		return (ret > 0) ? -ENODATA : ret;
+
+	*optlen = resp->optlen;
+	return 0;
+}
+
+int rdma_set_option(struct rdma_cm_id *id, int level, int optname,
+		    void *optval, size_t optlen)
+{
+	struct ucma_abi_set_option *cmd;
+	struct cma_id_private *id_priv;
+	void *msg;
+	int ret, size;
+	
+	CMA_CREATE_MSG_CMD(msg, cmd, UCMA_CMD_SET_OPTION, size);
+	id_priv = container_of(id, struct cma_id_private, id);
+	cmd->id = id_priv->handle;
+	cmd->optval = (uintptr_t) optval;
+	cmd->level = level;
+	cmd->optname = optname;
+	cmd->optlen = optlen;
+
+	ret = write(cma_fd, msg, size);
+	if (ret != size)
+		return (ret > 0) ? -ENODATA : ret;
+
+	return 0;
+}
Index: src/librdmacm.map
===================================================================
--- src/librdmacm.map	(revision 5693)
+++ src/librdmacm.map	(working copy)
@@ -15,5 +15,7 @@ RDMACM_1.0 {
 		rdma_get_cm_event;
 		rdma_ack_cm_event;
 		rdma_get_fd;
+		rdma_get_option;
+		rdma_set_option;
 	local: *;
 };




More information about the general mailing list