From bc8a6811199602d48db59e56d8c6b76656ab2642 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Fri, 7 Sep 2007 11:20:50 -0700 Subject: [PATCH] rdma/cm: Add ability to specify the type of service Add rdma_set_option, similar to setsockopt, to allow the user to specify the quality of service provided by a connection. Signed-off-by: Sean Hefty --- Makefile.am | 1 + include/rdma/rdma_cma.h | 21 +++++++++++++++++++++ include/rdma/rdma_cma_abi.h | 8 ++++++++ man/rdma_cm.7 | 4 ++-- man/rdma_create_id.3 | 3 ++- man/rdma_set_option.3 | 30 ++++++++++++++++++++++++++++++ src/cma.c | 23 +++++++++++++++++++++++ src/librdmacm.map | 1 + 8 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 man/rdma_set_option.3 diff --git a/Makefile.am b/Makefile.am index d0115943..1195bd97 100644 --- a/Makefile.am +++ b/Makefile.am @@ -57,6 +57,7 @@ man_MANS = \ man/rdma_resolve_addr.3 \ man/rdma_resolve_route.3 \ man/rdma_event_str.3 \ + man/rdma_set_option.3 \ man/ucmatose.1 \ man/udaddy.1 \ man/mckey.1 \ diff --git a/include/rdma/rdma_cma.h b/include/rdma/rdma_cma.h index 43c71d5f..b0848d52 100644 --- a/include/rdma/rdma_cma.h +++ b/include/rdma/rdma_cma.h @@ -529,6 +529,27 @@ void rdma_free_devices(struct ibv_context **list); */ const char *rdma_event_str(enum rdma_cm_event_type event); +/* Option levels */ +enum { + RDMA_OPTION_ID = 0 +}; + +/* Option details */ +enum { + RDMA_OPTION_ID_TOS = 0 /* uint8_t: RFC 2474 */ +}; + +/** + * 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); + #ifdef __cplusplus } #endif diff --git a/include/rdma/rdma_cma_abi.h b/include/rdma/rdma_cma_abi.h index 8f3e42d5..ba0e7b9f 100644 --- a/include/rdma/rdma_cma_abi.h +++ b/include/rdma/rdma_cma_abi.h @@ -213,4 +213,12 @@ struct ucma_abi_event_resp { } param; }; +struct ucma_abi_set_option { + __u64 optval; + __u32 id; + __u32 level; + __u32 optname; + __u32 optlen; +}; + #endif /* RDMA_CMA_ABI_H */ diff --git a/man/rdma_cm.7 b/man/rdma_cm.7 index 25b65f3a..bfb3493f 100644 --- a/man/rdma_cm.7 +++ b/man/rdma_cm.7 @@ -1,4 +1,4 @@ -.TH "RDMA_CM" 7 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm +.TH "RDMA_CM" 7 "2007-08-06" "librdmacm" "Librdmacm Programmer's Manual" librdmacm .SH NAME rdma_cm \- RDMA communication manager. .SH SYNOPSIS @@ -110,5 +110,5 @@ rdma_resolve_route(3), rdma_connect(3), rdma_listen(3), rdma_accept(3), rdma_reject(3), rdma_join_multicast(3), rdma_leave_multicast(3), rdma_notify(3), rdma_ack_cm_event(3), rdma_disconnect(3), rdma_destroy_qp(3), rdma_destroy_id(3), rdma_destroy_event_channel(3), rdma_get_devices(3), rdma_free_devices(3), -rdma_get_dst_port(3), rdma_get_src_port(3), +rdma_get_dst_port(3), rdma_get_src_port(3), rdma_set_option(3) ucmatose(1), udaddy(1), mckey(1), rping(1) diff --git a/man/rdma_create_id.3 b/man/rdma_create_id.3 index 90fa4c7f..eb29f3c7 100644 --- a/man/rdma_create_id.3 +++ b/man/rdma_create_id.3 @@ -1,4 +1,4 @@ -.TH "RDMA_CREATE_ID" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm +.TH "RDMA_CREATE_ID" 3 "2007-08-06" "librdmacm" "Librdmacm Programmer's Manual" librdmacm .SH NAME rdma_create_id \- Allocate a communication identifier. .SH SYNOPSIS @@ -41,3 +41,4 @@ and multicast communication. .SH "SEE ALSO" rdma_cm(7), rdma_create_event_channel(3), rdma_destroy_id(3), rdma_get_devices(3), rdma_bind_addr(3), rdma_resolve_addr(3), rdma_connect(3), rdma_listen(3), +rdma_set_option(3) diff --git a/man/rdma_set_option.3 b/man/rdma_set_option.3 new file mode 100644 index 00000000..ffa516cc --- /dev/null +++ b/man/rdma_set_option.3 @@ -0,0 +1,30 @@ +.TH "RDMA_SET_OPTION" 3 "2007-08-06" "librdmacm" "Librdmacm Programmer's Manual" librdmacm +.SH NAME +rdma_set_option \- Set communication options for an rdma_cm_id. +.SH SYNOPSIS +.B "#include " +.P +.B "int" rdma_set_option +.BI "(struct rdma_cm_id *" id "," +.BI "int " level "," +.BI "int " optname "," +.BI "void *" optval "," +.BI "size_t " optlen ");" +.SH ARGUMENTS +.IP "id" 12 +RDMA identifier. +.IP "level" 12 +Protocol level of the option to set. +.IP "optname" 12 +Name of the option, relative to the level, to set. +.IP "optval" 12 +Reference to the option data. The data is dependent on the level and optname. +.IP "optlen" 12 +The size of the %optval buffer. +.SH "DESCRIPTION" +Sets communication options for an rdma_cm_id. This call is used to override +the default system settings. +.SH "NOTES" +Option details may be found in the relevent header files. +.SH "SEE ALSO" +rdma_create_id(3) diff --git a/src/cma.c b/src/cma.c index 94c8cf3d..c0ae114e 100644 --- a/src/cma.c +++ b/src/cma.c @@ -1421,3 +1421,26 @@ const char *rdma_event_str(enum rdma_cm_event_type event) return "UNKNOWN EVENT"; } } + +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(id->channel->fd, msg, size); + if (ret != size) + return (ret > 0) ? -ENODATA : ret; + + return 0; +} diff --git a/src/librdmacm.map b/src/librdmacm.map index eafeae46..0f042fa1 100644 --- a/src/librdmacm.map +++ b/src/librdmacm.map @@ -24,5 +24,6 @@ RDMACM_1.0 { rdma_get_devices; rdma_free_devices; rdma_event_str; + rdma_set_option; local: *; }; -- 2.41.0