Merge pull request #13391 from Adirl/ibv_exp

msg/async/rdma: check if exp verbs avail

Reviewed-by: Haomai Wang <haomai@xsky.com>
This commit is contained in:
Sage Weil 2017-02-13 18:54:10 -06:00 committed by GitHub
commit a2fb70ddca
3 changed files with 30 additions and 0 deletions

View File

@ -20,6 +20,17 @@ endif ()
if (RDMA_FOUND)
message(STATUS "Found libibverbs: ${RDMA_LIBRARY}")
include(CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES("
#include <infiniband/verbs.h>
int main() {
struct ibv_context* ctxt;
struct ibv_exp_gid_attr gid_attr;
ibv_exp_query_gid_attr(ctxt, 1, 0, &gid_attr);
return 0;
} " HAVE_IBV_EXP)
else ()
message(STATUS "Not Found libibverbs: ${RDMA_LIBRARY}")
if (RDMA_FIND_REQUIRED)

View File

@ -130,6 +130,9 @@
/* AsyncMessenger RDMA conditional compilation */
#cmakedefine HAVE_RDMA
/* ibverbs experimental conditional compilation */
#cmakedefine HAVE_IBV_EXP
/* define if embedded enabled */
#cmakedefine WITH_EMBEDDED

View File

@ -29,10 +29,12 @@ static const uint32_t CQ_DEPTH = 30000;
Port::Port(CephContext *cct, struct ibv_context* ictxt, uint8_t ipn): ctxt(ictxt), port_num(ipn), port_attr(new ibv_port_attr)
{
#ifdef HAVE_IBV_EXP
union ibv_gid cgid;
struct ibv_exp_gid_attr gid_attr;
bool malformed = false;
ldout(cct,1) << __func__ << " using experimental verbs for gid" << dendl;
int r = ibv_query_port(ctxt, port_num, port_attr);
if (r == -1) {
lderr(cct) << __func__ << " query port failed " << cpp_strerror(errno) << dendl;
@ -87,6 +89,20 @@ Port::Port(CephContext *cct, struct ibv_context* ictxt, uint8_t ipn): ctxt(ictxt
lderr(cct) << __func__ << " Requested local GID was not found in GID table" << dendl;
ceph_abort();
}
#else
int r = ibv_query_port(ctxt, port_num, port_attr);
if (r == -1) {
lderr(cct) << __func__ << " query port failed " << cpp_strerror(errno) << dendl;
ceph_abort();
}
lid = port_attr->lid;
r = ibv_query_gid(ctxt, port_num, 0, &gid);
if (r) {
lderr(cct) << __func__ << " query gid failed " << cpp_strerror(errno) << dendl;
ceph_abort();
}
#endif
}