From: Sean Hefty Date: Fri, 5 May 2006 18:05:03 +0000 (+0000) Subject: r6950: Add routines to the user RDMA CM library to get/set transport specific options. X-Git-Tag: v1.0-rc1~46 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=94cc609fa7b0d10a8d7ece3f93065d5c0b0a3cfc;p=~shefty%2Flibrdmacm.git r6950: Add routines to the user RDMA CM library to get/set transport specific options. 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 --- diff --git a/include/rdma/rdma_cma.h b/include/rdma/rdma_cma.h index 6d105a25..2ab0a854 100644 --- a/include/rdma/rdma_cma.h +++ b/include/rdma/rdma_cma.h @@ -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 */ diff --git a/include/rdma/rdma_cma_abi.h b/include/rdma/rdma_cma_abi.h index db96894d..ca5b173d 100644 --- a/include/rdma/rdma_cma_abi.h +++ b/include/rdma/rdma_cma_abi.h @@ -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 */ diff --git a/src/cma.c b/src/cma.c index 63b0af7f..b51b56a4 100644 --- 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; +} diff --git a/src/librdmacm.map b/src/librdmacm.map index bb70eb29..d14dd94f 100644 --- a/src/librdmacm.map +++ b/src/librdmacm.map @@ -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: *; };