librdmacm: Add support for XRC QPs
cover librdmacm: Add support for XRC QPs
From: Sean Hefty <[email protected]>
Update the XRC support in the librdmacm to match the upstream libibverbs XRC support, plus verbs extensions.
This patch aligns the librdmacm with the latest libibverbs version, and removes compatibility with earlier version of libibverbs that do not support verbs extensions.
Sean Hefty (8):
librdmacm: Remove NULL checks after calling alloca
librdmacm: Use SRQ in rdma_create_qp
build: Add build support for XRC
rdmacm: Add functionality to allocate an XRCD
rdmacm: Add support for allocating XRC SRQs
rdmacm: Add support for XRC QPs
rdmacm: Update addrinfo with XRC support example/rdma_xclient/server: Update XRC support in sample programs
configure.ac | 8 +- examples/rdma_xclient.c | 195 ++++++------------------------- examples/rdma_xserver.c | 285 ++++++++------------------------------------- include/rdma/rdma_cma.h | 4 +- include/rdma/rdma_verbs.h | 3 +- src/addrinfo.c | 14 +-- src/cma.c | 166 ++++++++++++++++++++------- src/cma.h | 42 +------- src/librdmacm.map | 2 + 9 files changed, 223 insertions(+), 496 deletions(-)
Signature · 6 lines
1.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1404281479-6755-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
PATCH 1/8 librdmacm: Remove NULL checks after calling alloca
From: Sean Hefty <[email protected]>
alloca doesn't return a NULL pointer on failure.
--- src/cma.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
src/cma.c +0 -3
@@ -720,9 +720,6 @@ static int ucma_query_path(struct rdma_cm_id *id) size =sizeof (*resp) +sizeof (struct ibv_path_data ) *6 ; resp =alloca (size); -if (!resp) -return ERR (ENOMEM ); -CMA_INIT_CMD_RESP (&cmd,sizeof cmd,QUERY , resp, size); id_priv = container_of(id, struct cma_id_private, id); cmd.id = id_priv->handle;
Signature · 6 lines
1.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/8 librdmacm: Use SRQ in rdma_create_qp
In reply to a message not in the archiveFrom: Sean Hefty <[email protected]>
If an application has allocated an SRQ on an rdma_cm_id, use it when creating a QP.
--- src/cma.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
src/cma.c +2 -0
@@ -1303,6 +1303,8 @@ int rdma_create_qp(struct rdma_cm_id *id, struct ibv_pd *pd, qp_init_attr->send_cq = id->send_cq;if (!qp_init_attr->recv_cq) qp_init_attr->recv_cq = id->recv_cq; +if (id->srq && !qp_init_attr->srq) + qp_init_attr->srq = id->srq; qp =ibv_create_qp (pd, qp_init_attr);if (!qp) { ret =ERR (ENOMEM );
Signature · 6 lines
1.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/8 build: Add build support for XRC
In reply to a message not in the archiveFrom: Sean Hefty <[email protected]>
Modify autotools to check for and require a libibverbs version that includes XRC and extension support.
Remove any code used to support older versions of
libibverbs.
--- configure.ac | 8 ++------ src/cma.h | 42 +----------------------------------------- 2 files changed, 3 insertions(+), 47 deletions(-)
configure.ac +2 -6
@@ -40,14 +40,10 @@ dnl Checks for libraries AC_CHECK_LIB(pthread, pthread_mutex_init, [], AC_MSG_ERROR([pthread_mutex_init() not found. librdmacm requires libpthread.])) if test "$disable_libcheck" != "yes"; then -AC_CHECK_LIB(ibverbs, ibv_get_device_list, [], - AC_MSG_ERROR([ibv_get_device_list() not found. librdmacm requires libibverbs.])) +AC_CHECK_LIB(ibverbs, ibv_cmd_open_xrcd, [], + AC_MSG_ERROR([ibv_cmd_open_xrcd() not found. librdmacm requires libibverbs 1.1.8 or later.])) fi -AC_CHECK_MEMBER(struct ibv_path_record.service_id, [], - AC_DEFINE(DEFINE_PATH_RECORD, 1, [adding path record definition]), - [#include <infiniband/sa.h>]) - dnl Check for gcc atomic intrinsics AC_MSG_CHECKING(compiler support for atomics) AC_LINK_IFELSE([AC_LANG_PROGRAM([[int i = 0;]],
src/cma.h +1 -41
52 lines not on this page · raw message
Signature · 6 lines
1.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/8 rdmacm: Add functionality to allocate an XRCD
In reply to a message not in the archiveFrom: Sean Hefty <[email protected]>
XRC QPs and SRQs are associated by an XRC domain. Provide a call to allocate an XRCD, similar to how the rdmacm allocates a PD for the user.
--- src/cma.c | 22 +++++++++++++++++++++- 1 files changed, 21 insertions(+), 1 deletions(-)
src/cma.c +21 -1
@@ -76,6 +76,7 @@ do { \struct cma_device {struct ibv_context *verbs;struct ibv_pd *pd; +struct ibv_xrcd *xrcd;uint64_t guid;int port_cnt;int refcnt;
@@ -439,9 +440,28 @@ out:static void ucma_put_device (struct cma_device *cma_dev) {pthread_mutex_lock (&mut); -if (!--cma_dev->refcnt) +if (!--cma_dev->refcnt) {ibv_dealloc_pd (cma_dev->pd); +if (cma_dev->xrcd) +ibv_close_xrcd (cma_dev->xrcd); + } +pthread_mutex_unlock (&mut); +} + +static struct ibv_xrcd *ucma_get_xrcd (struct cma_device *cma_dev) +{ +struct ibv_xrcd_init_attr attr; + +pthread_mutex_lock (&mut); +if (!cma_dev->xrcd) { +memset (&attr,0 ,sizeof attr); + attr.comp_mask =IBV_XRCD_INIT_ATTR_FD |IBV_XRCD_INIT_ATTR_OFLAGS ; + attr.fd =-1 ; + attr.oflags =O_CREAT ; + cma_dev->xrcd =ibv_open_xrcd (cma_dev->verbs, &attr); + }pthread_mutex_unlock (&mut); +return cma_dev->xrcd; }static void ucma_insert_id (struct cma_id_private *id_priv)
Signature · 6 lines
1.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 5/8 rdmacm: Add support for allocating XRC SRQs
In reply to a message not in the archiveFrom: Sean Hefty <[email protected]>
Add extended SRQ creation call, to support allocating XRC SRQs. Use the rdma_cm_id qp type field to determine which type of SRQ should be allocated.
--- include/rdma/rdma_verbs.h | 3 +- src/cma.c | 85 +++++++++++++++++++++++++++++++------------- src/librdmacm.map | 1 + 3 files changed, 63 insertions(+), 26 deletions(-)
include/rdma/rdma_verbs.h +2 -1
@@ -1,5 +1,5 @@/* -* Copyright (c) 2010-2011 Intel Corporation. All rights reserved. +* Copyright (c) 2010-2014 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
@@ -56,6 +56,7 @@ static inline int rdma_seterrno(int ret)*/ int rdma_create_srq (struct rdma_cm_id *id,struct ibv_pd *pd,struct ibv_srq_init_attr *attr); +int rdma_create_srq_ex (struct rdma_cm_id *id,struct ibv_srq_init_attr_ex *attr);void rdma_destroy_srq (struct rdma_cm_id *id);
src/cma.c +60 -25
138 lines not on this page · raw message
src/librdmacm.map +1 -0
@@ -66,5 +66,6 @@ RDMACM_1.0 { riomap; riounmap; riowrite; + rdma_create_srq_ex; local: *; };
Signature · 6 lines
1.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 6/8 rdmacm: Add support for XRC QPs
In reply to a message not in the archiveFrom: Sean Hefty <[email protected]>
Export a new extended create QP call. Add support for XRC QPs.
--- include/rdma/rdma_cma.h | 4 ++- src/cma.c | 58 ++++++++++++++++++++++++++++++++++------------ src/librdmacm.map | 1 + 3 files changed, 47 insertions(+), 16 deletions(-)
include/rdma/rdma_cma.h +3 -1
@@ -1,6 +1,6 @@/* * Copyright (c) 2005 Voltaire Inc. All rights reserved. -* Copyright (c) 2005-2012 Intel Corporation. All rights reserved. +* Copyright (c) 2005-2014 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
@@ -384,6 +384,8 @@ int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms);*/ int rdma_create_qp (struct rdma_cm_id *id,struct ibv_pd *pd,struct ibv_qp_init_attr *qp_init_attr); +int rdma_create_qp_ex (struct rdma_cm_id *id, +struct ibv_qp_init_attr_ex *qp_init_attr);/** * rdma_destroy_qp - Deallocate a QP.
src/cma.c +43 -15
87 lines not on this page · raw message
src/librdmacm.map +1 -0
@@ -67,5 +67,6 @@ RDMACM_1.0 { riounmap; riowrite; rdma_create_srq_ex; + rdma_create_qp_ex; local: *; };
Signature · 6 lines
1.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 7/8 rdmacm: Update addrinfo with XRC support
In reply to a message not in the archiveFrom: Sean Hefty <[email protected]>
Remove internal defines, and use libibverbs exported values instead.
--- src/addrinfo.c | 14 +++----------- 1 files changed, 3 insertions(+), 11 deletions(-)
src/addrinfo.c +3 -11
@@ -1,5 +1,5 @@/* -* Copyright (c) 2010 Intel Corporation. All rights reserved. +* Copyright (c) 2010-2014 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
@@ -45,14 +45,6 @@#include <rdma/rdma_cma.h> #include <infiniband/ib.h> -#ifdef IBV_XRC_OPS -#define RDMA_QPT_XRC_SEND IBV_QPT_XRC_SEND -#define RDMA_QPT_XRC_RECV IBV_QPT_XRC_RECV -#else -#define RDMA_QPT_XRC_SEND 9 -#define RDMA_QPT_XRC_RECV 10 -#endif -struct rdma_addrinfo nohints;static void ucma_convert_to_ai (struct addrinfo *ai,struct rdma_addrinfo *rai)
@@ -68,8 +60,8 @@ static void ucma_convert_to_ai(struct addrinfo *ai, struct rdma_addrinfo *rai)switch (rai->ai_qp_type) {case IBV_QPT_RC :case IBV_QPT_UC : -case RDMA_QPT_XRC_SEND : -case RDMA_QPT_XRC_RECV : +case IBV_QPT_XRC_SEND : +case IBV_QPT_XRC_RECV : ai->ai_socktype =SOCK_STREAM ;break ;case IBV_QPT_UD :
Signature · 6 lines
1.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 8/8 example/rdma_xclient/server: Update XRC support in sample programs
In reply to a message not in the archiveFrom: Sean Hefty <[email protected]>
Update rdma_xclient and rdma_xserver sample programs to test XRC data transfers.
--- examples/rdma_xclient.c | 195 ++++++-------------------------- examples/rdma_xserver.c | 285 ++++++++--------------------------------------- 2 files changed, 86 insertions(+), 394 deletions(-)
examples/rdma_xclient.c +37 -158
@@ -1,5 +1,5 @@/* -* Copyright (c) 2010-2011 Intel Corporation. All rights reserved. +* Copyright (c) 2010-2014 Intel Corporation. All rights reserved. * * This software is available to you under the OpenIB.org BSD license * below:
@@ -39,111 +39,19 @@static char *server ="127.0.0.1" ;static char port[6 ] ="7471" ; -static int (*run_func)() =NULL ;struct rdma_cm_id *id;struct ibv_mr *mr; -enum ibv_qp_type qpt =IBV_QPT_RC ; +struct rdma_addrinfo hints; -#define MSG_SIZE 16 -uint8_t send_msg[MSG_SIZE ]; -uint8_t recv_msg[MSG_SIZE ]; - -#ifdef IBV_XRC_OPS -#define PRINT_XRC_OPT printf("\t x - XRC: extended-reliable-connected\n") +uint8_t send_msg[16 ];uint32_t srqn; -/* -* Connect XRC SEND QP. -*/ -static int xrc_connect_send (void ) -{ -struct rdma_addrinfo hints, *res; -struct ibv_qp_init_attr attr; -int ret; - -memset (&hints,0 ,sizeof hints); - hints.ai_port_space =RDMA_PS_IB ; - hints.ai_qp_type =IBV_QPT_XRC_SEND ; - ret =rdma_getaddrinfo (server, port, &hints, &res); -if (ret) { -printf ("rdma_getaddrinfo connect send %d\n" , errno); -return ret; - } - -memset (&attr,0 ,sizeof attr); - attr.cap.max_send_wr =1 ; - attr.cap.max_send_sge =1 ; - attr.cap.max_inline_data =sizeof send_msg; - attr.qp_context = id; - attr.sq_sig_all =1 ; - ret =rdma_create_ep (&id, res,NULL , &attr); -rdma_freeaddrinfo (res); -if (ret) { -printf ("rdma_create_ep send qp %d\n" , errno); -return ret; - } - - ret =rdma_connect (id,NULL ); -if (ret) { -printf ("rdma_connect send qp %d\n" , errno); -return ret; - } - -return 0 ; -} - -/* -* Resolve remote SRQ number -*/ -static int xrc_resolve_srqn (void ) -{ -struct rdma_addrinfo hints, *res; -struct rdma_cm_id *id; -int ret; - -memset (&hints,0 ,sizeof hints); - hints.ai_qp_type =IBV_QPT_UD ;/* for now */ - hints.ai_port_space =RDMA_PS_IB ; -sprintf (port,"%d" ,atoi (port) +1 ); - ret =rdma_getaddrinfo (server, port, &hints, &res); -if (ret) { -printf ("rdma_getaddrinfo resolve srqn %d\n" , errno); -return ret; - } - - ret =rdma_create_ep (&id, res,NULL ,NULL ); -rdma_freeaddrinfo (res); -if (ret) { -printf ("rdma_create_ep for srqn %d\n" , errno); -return ret; - } - - ret =rdma_connect (id,NULL ); -if (ret) { -printf ("rdma_connect for srqn %d\n" , errno); -return ret; - } - - srqn = id->event->param.ud.qp_num; -rdma_destroy_ep (id); -return 0 ; -} - -static int xrc_test (void ) +static int post_send (void ) {struct ibv_send_wr wr, *bad;struct ibv_sge sge; -struct ibv_wc wc;int ret; - ret =xrc_connect_send (); -if (ret) -return ret; - - ret =xrc_resolve_srqn (); -if (ret) -return ret; - sge.addr = (uint64_t ) (uintptr_t ) send_msg; sge.length = (uint32_t )sizeof send_msg; sge.lkey =0 ;
@@ -153,92 +61,64 @@ static int xrc_test(void) wr.num_sge =1 ; wr.opcode =IBV_WR_SEND ; wr.send_flags =IBV_SEND_INLINE ; - wr.wr.xrc.remote_srqn = srqn; +if (hints.ai_qp_type ==IBV_QPT_XRC_SEND ) + wr.qp_type.xrc.remote_srqn = srqn; ret =ibv_post_send (id->qp, &wr, &bad); -if (ret) { -printf ("rdma_post_send %d\n" , errno); -return ret; - } - - ret =rdma_get_send_comp (id, &wc); -if (ret <=0 ) { -printf ("rdma_get_recv_comp %d\n" , ret); -return ret; - } - -rdma_disconnect (id); -rdma_destroy_ep (id); -return 0 ; -} +if (ret) +perror ("rdma_post_send" ); -static inline int set_xrc_qpt (void ) -{ - qpt =IBV_QPT_XRC_SEND ; - run_func = xrc_test; -return 0 ; +return ret; } -#else -#define PRINT_XRC_OPT -#define set_xrc_qpt () -1 -#endif /* IBV_XRC_OPS */ - -static int rc_test (void ) +static int test (void ) { -struct rdma_addrinfo hints, *res; +struct rdma_addrinfo *res;struct ibv_qp_init_attr attr;struct ibv_wc wc;int ret; -memset (&hints,0 ,sizeof hints); - hints.ai_port_space =RDMA_PS_TCP ; ret =rdma_getaddrinfo (server, port, &hints, &res);if (ret) { -printf ("rdma_getaddrinfo %d\n" , errno); +perror ("rdma_getaddrinfo" );return ret; }memset (&attr,0 ,sizeof attr); attr.cap.max_send_wr = attr.cap.max_recv_wr =1 ; attr.cap.max_send_sge = attr.cap.max_recv_sge =1 ; - attr.cap.max_inline_data =sizeof send_msg; - attr.qp_context = id; attr.sq_sig_all =1 ; ret =rdma_create_ep (&id, res,NULL , &attr);rdma_freeaddrinfo (res);if (ret) { -printf ("rdma_create_ep %d\n" , errno); +perror ("rdma_create_ep" );return ret; } - mr =rdma_reg_msgs (id, recv_msg,sizeof recv_msg); + mr =rdma_reg_msgs (id, send_msg,sizeof send_msg);if (!mr) { -printf ("rdma_reg_msgs %d\n" , errno); -return ret; - } - - ret =rdma_post_recv (id,NULL , recv_msg,sizeof recv_msg, mr); -if (ret) { -printf ("rdma_post_recv %d\n" , errno); +perror ("rdma_reg_msgs" );return ret; } ret =rdma_connect (id,NULL );if (ret) { -printf ("rdma_connect %d\n" , errno); +perror ("rdma_connect" );return ret; } - ret =rdma_post_send (id,NULL , send_msg,sizeof send_msg,NULL ,IBV_SEND_INLINE ); +if (hints.ai_qp_type ==IBV_QPT_XRC_SEND ) + srqn =ntohl (*(uint32_t *) id->event->param.conn.private_data); + + ret =post_send ();if (ret) { -printf ("rdma_post_send %d\n" , errno); +perror ("post_send" );return ret; } - ret =rdma_get_recv_comp (id, &wc); + ret =rdma_get_send_comp (id, &wc);if (ret <=0 ) { -printf ("rdma_get_recv_comp %d\n" , ret); +perror ("rdma_get_recv_comp" );return ret; }
@@ -248,22 +128,13 @@ static int rc_test(void)return 0 ; } -static int set_qpt (char type) -{ -if (type =='r' ) { - qpt =IBV_QPT_RC ; -return 0 ; - }else if (type =='x' ) { -return set_xrc_qpt (); - } -return -1 ; -} -int main (int argc,char **argv) {int op, ret; - run_func = rc_test; + hints.ai_port_space =RDMA_PS_TCP ; + hints.ai_qp_type =IBV_QPT_RC ; +while ((op =getopt (argc, argv,"s:p:c:" )) !=-1 ) {switch (op) {case 's' :
@@ -273,8 +144,16 @@ int main(int argc, char **argv)strncpy (port, optarg,sizeof port -1 );break ;case 'c' : -if (set_qpt (tolower (optarg[0 ]))) +switch (tolower (optarg[0 ])) { +case 'r' : +break ; +case 'x' : + hints.ai_port_space =RDMA_PS_IB ; + hints.ai_qp_type =IBV_QPT_XRC_SEND ; +break ; +default : goto err; + }break ;default : goto err;
@@ -282,7 +161,7 @@ int main(int argc, char **argv) }printf ("%s: start\n" , argv[0 ]); - ret =run_func (); + ret =test ();printf ("%s: end %d\n" , argv[0 ], ret);return ret;
@@ -292,6 +171,6 @@ err:printf ("\t[-p port_number]\n" );printf ("\t[-c communication type]\n" );printf ("\t r - RC: reliable-connected (default)\n" ); -PRINT_XRC_OPT ; +printf ("\t x - XRC: extended-reliable-connected\n" );exit (1 ); }
examples/rdma_xserver.c +49 -236
384 lines not on this page · raw message
Signature · 6 lines
1.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html