Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rdma-core 18 build (#50) #51

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ config.h*
config.log
config.status
configure
include/kernel-abi
libtool
Makefile
/Makefile.in
Expand Down
12 changes: 10 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ AM_CFLAGS = $(EXTRA_CFLAGS) \
-fno-strict-aliasing \
-fvisibility=hidden

EXTRA_DIST = gpl-2.0.txt config/version.sh src/urdmad/urdmad.service.in
EXTRA_DIST = gpl-2.0.txt config/version.sh src/urdmad/urdmad.service.in \
config/make_abi_structs.py
include_HEADERS = include/urdma_kabi.h \
include/urdmad_private.h \
include/proto.h \
Expand All @@ -68,8 +69,14 @@ lib_LTLIBRARIES = src/liburdma/liburdma.la
EXTRA_src_liburdma_liburdma_la_SOURCES = \
rdma-core/17/infiniband/kern-abi.h \
rdma-core/17/infiniband/driver.h \
rdma-core/18/infiniband/cmd_ioctl.h \
rdma-core/18/infiniband/kern-abi.h \
rdma-core/18/infiniband/driver.h
rdma-core/18/infiniband/driver.h \
rdma-core/18/rdma/rdma_user_ioctl_cmds.h \
rdma-core/18/rdma/rdma_user_ioctl.h \
rdma-core/18/rdma/hfi/hfi1_ioctl.h \
rdma-core/18/rdma/ib_user_mad.h \
rdma-core/18/rdma/ib_user_verbs.h
src_liburdma_liburdma_la_SOURCES = \
src/liburdma/driver.c \
src/liburdma/interface.c \
Expand Down Expand Up @@ -191,6 +198,7 @@ src/urdmad/urdmad.service: src/urdmad/urdmad.service.in
all-local: src/urdmad/urdmad.service

MOSTLYCLEANFILES = src/urdmad/urdmad.service
DISTCLEANFILES = include/kernel-abi/ib_user_verbs.h

install-data-hook:
$(MKDIR_P) $(DESTDIR)$(prefix)/lib/systemd/user
Expand Down
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Requirements
- json-c
- uthash (included in Fedora, Ubuntu, openSUSE, and EPEL for RHEL
repositories)
- Python 2.7 (for build system)

Setup instructions
------------------
Expand Down
57 changes: 57 additions & 0 deletions config/make_abi_structs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env python
# Copied from rdma-core 18.2
"""This script transforms the structs inside the kernel ABI headers into a define
of an anonymous struct.

eg
struct abc {int foo;};
becomes
#define _STRUCT_abc struct {int foo;};

This allows the exact same struct to be included in the provider wrapper struct:

struct abc_resp {
struct ibv_abc ibv_resp;
_STRUCT_abc;
};

Which duplicates the struct layout and naming we have historically used, but
sources the data directly from the kernel headers instead of manually copying."""
import re;
import functools;
import sys;

def in_struct(ln,FO,nesting=0):
"""Copy a top level structure over to the #define output, keeping track of
nested structures."""
if nesting == 0:
if re.match(r"(}.*);",ln):
FO.write(ln[:-1] + "\n\n");
return find_struct;

FO.write(ln + " \\\n");

if ln == "struct {" or ln == "union {":
return functools.partial(in_struct,nesting=nesting+1);

if re.match(r"}.*;",ln):
return functools.partial(in_struct,nesting=nesting-1);
return functools.partial(in_struct,nesting=nesting);

def find_struct(ln,FO):
"""Look for the start of a top level structure"""
if ln.startswith("struct ") or ln.startswith("union "):
g = re.match(r"(struct|union)\s+(\S+)\s+{",ln);
FO.write("#define _STRUCT_%s %s { \\\n"%(g.group(2),g.group(1)));
return in_struct;
return find_struct;

with open(sys.argv[1]) as FI:
with open(sys.argv[2],"w") as FO:
state = find_struct;
for ln in FI:
# Drop obvious comments
ln = ln.strip();
ln = re.sub(r"/\*.*\*/","",ln);
ln = re.sub(r"//.*$","",ln);
state = state(ln,FO);
11 changes: 9 additions & 2 deletions config/rdma_core.m4
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ AC_DEFUN([_URDMA_FUNC_VERBS_INIT_AND_ALLOC_CONTEXT],
AC_CACHE_CHECK([number of arguments verbs_init_and_alloc_context takes],
[dpdk_cv_func_verbs_init_and_alloc_context],
[old_CPPFLAGS="${CPPFLAGS}"
CPPFLAGS="-I${srcdir} -I${srcdir}/rdma-core/${ibverbs_pabi_version} ${CPPFLAGS}"
CPPFLAGS="-I${srcdir} -I${srcdir}/rdma-core/${ibverbs_pabi_version} -Iinclude -I${srcdir}/rdma-core/${ibverbs_pabi_version}/rdma ${CPPFLAGS}"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <infiniband/driver.h>]],
[verbs_init_and_alloc_context@{:@@:}@;])],
[[# No-argument case is invalid and means we didn't find a prototype]]
[dpdk_cv_func_verbs_init_and_alloc_context=no],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <infiniband/driver.h>]],
[[struct foo { struct verbs_context bar; } *baz; verbs_init_and_alloc_context@{:@NULL, NULL, baz, bar, 0@:}@;]])],
[[struct foo { struct verbs_context bar; } *baz; verbs_init_and_alloc_context@{:@NULL, 0, baz, bar, 0@:}@;]])],
[dpdk_cv_func_verbs_init_and_alloc_context=5],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <infiniband/driver.h>]],
[[struct foo { struct verbs_context bar; } *baz; verbs_init_and_alloc_context@{:@NULL, NULL, baz, bar@:}@;]])],
Expand Down Expand Up @@ -94,6 +94,13 @@ AC_DEFINE_UNQUOTED([IBVERBS_PABI_VERSION], [${ibverbs_pabi_version}],
[Define to rdma-core private ABI version])
AC_SUBST([ibverbs_pabi_version])

if test $ibverbs_pabi_version -ge 18; then
mkdir -p include/kernel-abi
${srcdir}/config/make_abi_structs.py \
${srcdir}/rdma-core/${ibverbs_pabi_version}/rdma/ib_user_verbs.h \
include/kernel-abi/ib_user_verbs.h
CPPFLAGS="${CPPFLAGS} -Iinclude"
fi
if test $ibverbs_pabi_version -ge 17; then
_URDMA_FUNC_VERBS_INIT_AND_ALLOC_CONTEXT
fi
Expand Down
Loading