]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
r6950: Add routines to the user RDMA CM library to get/set transport specific options.
authorSean Hefty <sean.hefty@intel.com>
Fri, 5 May 2006 18:05:03 +0000 (18:05 +0000)
committerSean Hefty <sean.hefty@intel.com>
Fri, 5 May 2006 18:05:03 +0000 (18:05 +0000)
Add an option to retrieve possible path records for a connection, and set
which path a connection will be established on.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
include/rdma/rdma_cma.h
include/rdma/rdma_cma_abi.h
src/cma.c
src/librdmacm.map

index 6d105a25220aa457f452e7645cf920c77644b9e7..2ab0a854d63952eee8a3d967a3d54b29345023a9 100644 (file)
@@ -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_event *event);
 
 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 db96894d0c1391d13d6bdf24959ed8b862bab95d..ca5b173d97eaeeb65ee77b5f5aa70d980c3186f4 100644 (file)
@@ -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 63b0af7f325092c178a8e93fdda319a5e2bb567c..b51b56a40ff5dd2888d24846928b19e4c768cc2d 100644 (file)
--- a/src/cma.c
+++ b/src/cma.c
@@ -963,3 +963,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 bb70eb29c0e433b62f46f6ed38ab218b0b21664e..d14dd94ff4418bacf987c30bdd365550b86b7564 100644 (file)
@@ -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: *;
 };