diff -Nru libmlx4-1.0.5/debian/changelog libmlx4-1.0.5/debian/changelog --- libmlx4-1.0.5/debian/changelog 2014-01-01 01:45:20.000000000 -0200 +++ libmlx4-1.0.5/debian/changelog 2015-08-05 16:27:59.000000000 -0300 @@ -1,3 +1,12 @@ +libmlx4 (1.0.5-1ubuntu2) trusty; urgency=medium + + * Remove compatibility with older libibverbs (LP: #1409904) + * Update to use libibverbs extensions support (LP: #1409904) + * Add receive flow steering support (LP: #1409904) + * Add checksum offload support capability (LP: #1409904) + + -- Rafael David Tinoco Wed, 05 Aug 2015 16:27:04 -0300 + libmlx4 (1.0.5-1ubuntu1) trusty; urgency=medium * Use dh-autoreconf to get libtool macros for ppc64el. diff -Nru libmlx4-1.0.5/debian/control libmlx4-1.0.5/debian/control --- libmlx4-1.0.5/debian/control 2014-01-01 01:45:22.000000000 -0200 +++ libmlx4-1.0.5/debian/control 2015-08-05 16:31:34.000000000 -0300 @@ -2,7 +2,7 @@ Priority: extra Maintainer: Ubuntu Developers XSBC-Original-Maintainer: Roland Dreier -Build-Depends: debhelper (>= 7.0.50~), dpkg-dev (>= 1.13.19), libibverbs-dev (>= 1.1.3), dh-autoreconf +Build-Depends: debhelper (>= 7.0.50~), dpkg-dev (>= 1.13.19), libibverbs-dev (>= 1.1.7-1ubuntu2), dh-autoreconf Standards-Version: 3.9.2 Section: libs Homepage: http://www.openfabrics.org/ @@ -10,7 +10,7 @@ Package: libmlx4-1 Section: libs Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, libibverbs1 (>= 1.1.3) +Depends: ${shlibs:Depends}, ${misc:Depends}, libibverbs1 (>= 1.1.7-1ubuntu2) Description: Userspace driver for Mellanox ConnectX InfiniBand HCAs libmlx4 is a device-specific driver for Mellanox ConnectX InfiniBand host channel adapters (HCAs) for the libibverbs library. This allows diff -Nru libmlx4-1.0.5/debian/patches/Add-checksum-offload-support-capability.patch libmlx4-1.0.5/debian/patches/Add-checksum-offload-support-capability.patch --- libmlx4-1.0.5/debian/patches/Add-checksum-offload-support-capability.patch 1969-12-31 21:00:00.000000000 -0300 +++ libmlx4-1.0.5/debian/patches/Add-checksum-offload-support-capability.patch 2015-08-05 16:22:44.000000000 -0300 @@ -0,0 +1,52 @@ +Description: Add support for IBV_SEND_IP_CSUM for posted send work-requests. + +When this flag is set, enable the HW checksum calculation by setting +MLX4_WQE_CTRL_IP_CSUM and MLX4_WQE_CTRL_TCP_UDP_CSUM flags in the WQE +control segment. + +Signed-off-by: Eyal Perry +Signed-off-by: Moshe Lazer +Signed-off-by: Or Gerlitz + +Origin: https://patchwork.kernel.org/patch/5572111/ +Bug-Ubuntu: https://launchpad.net/bugs/1409904 +Last-Update: 2015-02-09 + +--- libmlx4-1.0.5.orig/src/qp.c ++++ libmlx4-1.0.5/src/qp.c +@@ -283,6 +283,10 @@ int mlx4_post_send(struct ibv_qp *ibqp, + break; + + case IBV_QPT_UD: ++ ctrl->srcrb_flags |= ++ wr->send_flags & IBV_SEND_IP_CSUM ? ++ htonl(MLX4_WQE_CTRL_IP_CSUM | ++ MLX4_WQE_CTRL_TCP_UDP_CSUM) : 0; + set_datagram_seg(wqe, wr); + wqe += sizeof (struct mlx4_wqe_datagram_seg); + size += sizeof (struct mlx4_wqe_datagram_seg) / 16; +@@ -291,7 +295,12 @@ int mlx4_post_send(struct ibv_qp *ibqp, + case IBV_QPT_RAW_PACKET: + /* For raw eth, the MLX4_WQE_CTRL_SOLICIT flag is used + * to indicate that no icrc should be calculated */ +- ctrl->srcrb_flags |= htonl(MLX4_WQE_CTRL_SOLICIT); ++ ctrl->srcrb_flags |= ++ wr->send_flags & IBV_SEND_IP_CSUM ? ++ htonl(MLX4_WQE_CTRL_IP_CSUM | ++ MLX4_WQE_CTRL_TCP_UDP_CSUM | ++ MLX4_WQE_CTRL_SOLICIT) : ++ htonl(MLX4_WQE_CTRL_SOLICIT); + break; + + default: +--- libmlx4-1.0.5.orig/src/wqe.h ++++ libmlx4-1.0.5/src/wqe.h +@@ -41,6 +41,8 @@ enum { + MLX4_WQE_CTRL_FENCE = 1 << 6, + MLX4_WQE_CTRL_CQ_UPDATE = 3 << 2, + MLX4_WQE_CTRL_SOLICIT = 1 << 1, ++ MLX4_WQE_CTRL_IP_CSUM = 1 << 4, ++ MLX4_WQE_CTRL_TCP_UDP_CSUM = 1 << 5 + }; + + enum { diff -Nru libmlx4-1.0.5/debian/patches/Add-receive-flow-steering-support.patch libmlx4-1.0.5/debian/patches/Add-receive-flow-steering-support.patch --- libmlx4-1.0.5/debian/patches/Add-receive-flow-steering-support.patch 1969-12-31 21:00:00.000000000 -0300 +++ libmlx4-1.0.5/debian/patches/Add-receive-flow-steering-support.patch 2015-08-05 16:22:44.000000000 -0300 @@ -0,0 +1,25 @@ +Description: Add receive flow steering support + +The implementation uses the default commands from libibverbs. + +Author: Matan Barak +Signed-off-by: Matan Barak +Signed-off-by: Or Gerlitz +Signed-off-by: Roland Dreier + +Origin: upstream, commit: 1b6875d4c2cba3b751ad0b4286cf52b6a22bff97 +Bug-Ubuntu: https://launchpad.net/bugs/1409904 +Last-Update: 2015-02-09 + +--- libmlx4-1.0.5.orig/src/mlx4.c ++++ libmlx4-1.0.5/src/mlx4.c +@@ -198,6 +198,9 @@ static int mlx4_init_context(struct verb + ibv_ctx->ops = mlx4_ctx_ops; + /* New verbs should be added by using verbs_set_ctx_op */ + ++ verbs_set_ctx_op(verbs_ctx, drv_ibv_create_flow, ibv_cmd_create_flow); ++ verbs_set_ctx_op(verbs_ctx, drv_ibv_destroy_flow, ibv_cmd_destroy_flow); ++ + return 0; + + } diff -Nru libmlx4-1.0.5/debian/patches/Remove-compatibility-with-older-libibverbs.patch libmlx4-1.0.5/debian/patches/Remove-compatibility-with-older-libibverbs.patch --- libmlx4-1.0.5/debian/patches/Remove-compatibility-with-older-libibverbs.patch 1969-12-31 21:00:00.000000000 -0300 +++ libmlx4-1.0.5/debian/patches/Remove-compatibility-with-older-libibverbs.patch 2015-08-05 16:22:44.000000000 -0300 @@ -0,0 +1,234 @@ +Description: Remove compatibility with libibverbs < 1.1.7-1ubuntu1 + +Since the changes to add verbs extensions / XRC support will break +compatibility with libibverbs < 1.1.7-1ubuntu1, take this chance to +strip out all the backwards compatibility code that won't make any +sense once we do that. + +Author: Roland Dreier +Signed-off-by: Roland Dreier +Signed-off-by: Rafael David Tinoco + +Origin: upstream, commit: bcc5d064268073cb996bdbac1ae36728db3b2c96 +Bug-Ubuntu: https://launchpad.net/bugs/1409904 +Last-Update: 2015-02-09 + +--- libmlx4-1.0.5.orig/Makefile.am ++++ libmlx4-1.0.5/Makefile.am +@@ -5,19 +5,12 @@ mlx4_version_script = @MLX4_VERSION_SCRI + MLX4_SOURCES = src/buf.c src/cq.c src/dbrec.c src/mlx4.c src/qp.c \ + src/srq.c src/verbs.c + +-if HAVE_IBV_DEVICE_LIBRARY_EXTENSION +- lib_LTLIBRARIES = src/libmlx4.la +- src_libmlx4_la_SOURCES = $(MLX4_SOURCES) +- src_libmlx4_la_LDFLAGS = -avoid-version -release @IBV_DEVICE_LIBRARY_EXTENSION@ \ +- $(mlx4_version_script) +- mlx4confdir = $(sysconfdir)/libibverbs.d +- mlx4conf_DATA = mlx4.driver +-else +- mlx4libdir = $(libdir)/infiniband +- mlx4lib_LTLIBRARIES = src/mlx4.la +- src_mlx4_la_SOURCES = $(MLX4_SOURCES) +- src_mlx4_la_LDFLAGS = -avoid-version -module $(mlx4_version_script) +-endif ++lib_LTLIBRARIES = src/libmlx4.la ++src_libmlx4_la_SOURCES = $(MLX4_SOURCES) ++src_libmlx4_la_LDFLAGS = -avoid-version -release @IBV_DEVICE_LIBRARY_EXTENSION@ \ ++ $(mlx4_version_script) ++mlx4confdir = $(sysconfdir)/libibverbs.d ++mlx4conf_DATA = mlx4.driver + + EXTRA_DIST = src/doorbell.h src/mlx4.h src/mlx4-abi.h src/wqe.h \ + src/mlx4.map libmlx4.spec.in mlx4.driver +--- libmlx4-1.0.5.orig/configure.ac ++++ libmlx4-1.0.5/configure.ac +@@ -45,21 +45,20 @@ dnl Checks for typedefs, structures, and + AC_C_CONST + AC_CHECK_SIZEOF(long) + ++dnl Checks for library functions ++AC_CHECK_FUNC(ibv_register_driver, [], ++ AC_MSG_ERROR([ibv_register_driver() not found. libmlx4 requires libibverbs >= 1.1.7.])) ++ + AC_CACHE_CHECK([for IBV_QPT_RAW_PACKET], + [ac_cv_ibv_qpt_raw_packet], +- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], ++ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ], + [enum ibv_qp_type qpt = IBV_QPT_RAW_PACKET;])], + [ac_cv_ibv_qpt_raw_packet=yes], + [ac_cv_ibv_qpt_raw_packet=no])]) +-if test $ac_cv_ibv_qpt_raw_packet = yes; then +- AC_DEFINE([HAVE_IBV_QPT_RAW_PACKET], 1, [libibverbs has raw packet QP support]) ++if test $ac_cv_ibv_qpt_raw_packet = no; then ++ AC_MSG_ERROR([IBV_QPT_RAW_PACKET not found. libmlx4 requires libibverbs >= 1.1.7.]) + fi + +-dnl Checks for library functions +-AC_CHECK_FUNC(ibv_read_sysfs_file, [], +- AC_MSG_ERROR([ibv_read_sysfs_file() not found. libmlx4 requires libibverbs >= 1.0.3.])) +-AC_CHECK_FUNCS(ibv_dontfork_range ibv_dofork_range ibv_register_driver) +- + dnl Now check if for libibverbs 1.0 vs 1.1 + dummy=if$$ + cat < $dummy.c +@@ -68,8 +67,9 @@ IBV_DEVICE_LIBRARY_EXTENSION + IBV_VERSION + IBV_DEVICE_LIBRARY_EXTENSION=`$CC $CPPFLAGS -E $dummy.c 2> /dev/null | tail -1` + rm -f $dummy.c +-AM_CONDITIONAL(HAVE_IBV_DEVICE_LIBRARY_EXTENSION, +- test $IBV_DEVICE_LIBRARY_EXTENSION != IBV_DEVICE_LIBRARY_EXTENSION) ++if test $IBV_DEVICE_LIBRARY_EXTENSION = IBV_DEVICE_LIBRARY_EXTENSION; then ++ AC_MSG_ERROR([libibverbs does not define IBV_DEVICE_LIBRARY_EXTENSION.]) ++fi + AC_SUBST(IBV_DEVICE_LIBRARY_EXTENSION) + + AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script, +--- libmlx4-1.0.5.orig/libmlx4.spec.in ++++ libmlx4-1.0.5/libmlx4.spec.in +@@ -9,7 +9,7 @@ Url: http://openfabrics.org/ + Source: http://openfabrics.org/downloads/mlx4/libmlx4-1.0.5.tar.gz + BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) + +-BuildRequires: libibverbs-devel >= 1.1-0.1.rc2 ++BuildRequires: libibverbs-devel >= 1.1.7 + + %description + libmlx4 provides a device-specific userspace driver for Mellanox +--- libmlx4-1.0.5.orig/src/buf.c ++++ libmlx4-1.0.5/src/buf.c +@@ -40,25 +40,6 @@ + + #include "mlx4.h" + +-#if !(defined(HAVE_IBV_DONTFORK_RANGE) && defined(HAVE_IBV_DOFORK_RANGE)) +- +-/* +- * If libibverbs isn't exporting these functions, then there's no +- * point in doing it here, because the rest of libibverbs isn't going +- * to be fork-safe anyway. +- */ +-static int ibv_dontfork_range(void *base, size_t size) +-{ +- return 0; +-} +- +-static int ibv_dofork_range(void *base, size_t size) +-{ +- return 0; +-} +- +-#endif /* HAVE_IBV_DONTFORK_RANGE && HAVE_IBV_DOFORK_RANGE */ +- + int mlx4_alloc_buf(struct mlx4_buf *buf, size_t size, int page_size) + { + int ret; +--- libmlx4-1.0.5.orig/src/mlx4.c ++++ libmlx4-1.0.5/src/mlx4.c +@@ -42,10 +42,6 @@ + #include + #include + +-#ifndef HAVE_IBV_REGISTER_DRIVER +-#include +-#endif +- + #include "mlx4.h" + #include "mlx4-abi.h" + +@@ -268,25 +264,7 @@ found: + return &dev->ibv_dev; + } + +-#ifdef HAVE_IBV_REGISTER_DRIVER + static __attribute__((constructor)) void mlx4_register_driver(void) + { + ibv_register_driver("mlx4", mlx4_driver_init); + } +-#else +-/* +- * Export the old libsysfs sysfs_class_device-based driver entry point +- * if libibverbs does not export an ibv_register_driver() function. +- */ +-struct ibv_device *openib_driver_init(struct sysfs_class_device *sysdev) +-{ +- int abi_version = 0; +- char value[8]; +- +- if (ibv_read_sysfs_file(sysdev->path, "abi_version", +- value, sizeof value) > 0) +- abi_ver = strtol(value, NULL, 10); +- +- return mlx4_driver_init(sysdev->path, abi_version); +-} +-#endif /* HAVE_IBV_REGISTER_DRIVER */ +--- libmlx4-1.0.5.orig/src/mlx4.h ++++ libmlx4-1.0.5/src/mlx4.h +@@ -83,10 +83,6 @@ + + #define PFX "mlx4: " + +-#ifndef HAVE_IBV_QPT_RAW_PACKET +-#define IBV_QPT_RAW_PACKET 8 +-#endif +- + enum { + MLX4_STAT_RATE_OFFSET = 5 + }; +--- libmlx4-1.0.5.orig/src/verbs.c ++++ libmlx4-1.0.5/src/verbs.c +@@ -112,24 +112,16 @@ struct ibv_mr *mlx4_reg_mr(struct ibv_pd + { + struct ibv_mr *mr; + struct ibv_reg_mr cmd; ++ struct ibv_reg_mr_resp resp; + int ret; + + mr = malloc(sizeof *mr); + if (!mr) + return NULL; + +-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS +- { +- struct ibv_reg_mr_resp resp; +- +- ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr, +- access, mr, &cmd, sizeof cmd, +- &resp, sizeof resp); +- } +-#else +- ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr, access, mr, +- &cmd, sizeof cmd); +-#endif ++ ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr, ++ access, mr, &cmd, sizeof cmd, ++ &resp, sizeof resp); + if (ret) { + free(mr); + return NULL; +@@ -227,6 +219,7 @@ int mlx4_resize_cq(struct ibv_cq *ibcq, + { + struct mlx4_cq *cq = to_mcq(ibcq); + struct mlx4_resize_cq cmd; ++ struct ibv_resize_cq_resp resp; + struct mlx4_buf buf; + int old_cqe, outst_cqe, ret; + +@@ -256,15 +249,8 @@ int mlx4_resize_cq(struct ibv_cq *ibcq, + old_cqe = ibcq->cqe; + cmd.buf_addr = (uintptr_t) buf.buf; + +-#ifdef IBV_CMD_RESIZE_CQ_HAS_RESP_PARAMS +- { +- struct ibv_resize_cq_resp resp; +- ret = ibv_cmd_resize_cq(ibcq, cqe - 1, &cmd.ibv_cmd, sizeof cmd, +- &resp, sizeof resp); +- } +-#else +- ret = ibv_cmd_resize_cq(ibcq, cqe - 1, &cmd.ibv_cmd, sizeof cmd); +-#endif ++ ret = ibv_cmd_resize_cq(ibcq, cqe - 1, &cmd.ibv_cmd, sizeof cmd, ++ &resp, sizeof resp); + if (ret) { + mlx4_free_buf(&buf); + goto out; diff -Nru libmlx4-1.0.5/debian/patches/series libmlx4-1.0.5/debian/patches/series --- libmlx4-1.0.5/debian/patches/series 2013-05-30 15:26:38.000000000 -0300 +++ libmlx4-1.0.5/debian/patches/series 2015-08-05 16:22:44.000000000 -0300 @@ -1 +1,5 @@ driver-plugin-directory.patch +Remove-compatibility-with-older-libibverbs.patch +Update-to-use-libibverbs-extension-support.patch +Add-receive-flow-steering-support.patch +Add-checksum-offload-support-capability.patch diff -Nru libmlx4-1.0.5/debian/patches/Update-to-use-libibverbs-extension-support.patch libmlx4-1.0.5/debian/patches/Update-to-use-libibverbs-extension-support.patch --- libmlx4-1.0.5/debian/patches/Update-to-use-libibverbs-extension-support.patch 1969-12-31 21:00:00.000000000 -0300 +++ libmlx4-1.0.5/debian/patches/Update-to-use-libibverbs-extension-support.patch 2015-08-05 16:22:44.000000000 -0300 @@ -0,0 +1,219 @@ +Description: Update to use libiverbs extension support + +Have libmlx4 register with libibverbs with verbs_register_driver() to +indicate that libmlx4 supports verbs extensions, supplying its +verbs_init_func() for further initialization. This will be used to +add XRC support. + +Author: Yishai Hadas +Acked-by: Jason Gunthorpe +Signed-off-by: Yishai Hadas +Signed-off-by: Tzahi Oved + +Origin: upstream, commit: d00cfeb15ef4516539725b2f6c7d992e7201e13d +Bug-Ubuntu: https://launchpad.net/bugs/1409904 +Last-Update: 2015-02-09 + +--- libmlx4-1.0.5.orig/configure.ac ++++ libmlx4-1.0.5/configure.ac +@@ -46,8 +46,8 @@ AC_C_CONST + AC_CHECK_SIZEOF(long) + + dnl Checks for library functions +-AC_CHECK_FUNC(ibv_register_driver, [], +- AC_MSG_ERROR([ibv_register_driver() not found. libmlx4 requires libibverbs >= 1.1.7.])) ++AC_CHECK_FUNC(verbs_register_driver, [], ++ AC_MSG_ERROR([verbs_register_driver() not found. libmlx4 requires libibverbs >= 1.1.8.])) + + AC_CACHE_CHECK([for IBV_QPT_RAW_PACKET], + [ac_cv_ibv_qpt_raw_packet], +@@ -56,7 +56,7 @@ AC_CACHE_CHECK([for IBV_QPT_RAW_PACKET], + [ac_cv_ibv_qpt_raw_packet=yes], + [ac_cv_ibv_qpt_raw_packet=no])]) + if test $ac_cv_ibv_qpt_raw_packet = no; then +- AC_MSG_ERROR([IBV_QPT_RAW_PACKET not found. libmlx4 requires libibverbs >= 1.1.7.]) ++ AC_MSG_ERROR([IBV_QPT_RAW_PACKET not found. libmlx4 requires libibverbs >= 1.1.8.]) + fi + + dnl Now check if for libibverbs 1.0 vs 1.1 +--- libmlx4-1.0.5.orig/libmlx4.spec.in ++++ libmlx4-1.0.5/libmlx4.spec.in +@@ -9,7 +9,7 @@ Url: http://openfabrics.org/ + Source: http://openfabrics.org/downloads/mlx4/libmlx4-1.0.5.tar.gz + BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) + +-BuildRequires: libibverbs-devel >= 1.1.7 ++BuildRequires: libibverbs-devel >= 1.1.8 + + %description + libmlx4 provides a device-specific userspace driver for Mellanox +--- libmlx4-1.0.5.orig/src/mlx4.c ++++ libmlx4-1.0.5/src/mlx4.c +@@ -116,7 +116,8 @@ static struct ibv_context_ops mlx4_ctx_o + .detach_mcast = ibv_cmd_detach_mcast + }; + +-static struct ibv_context *mlx4_alloc_context(struct ibv_device *ibdev, int cmd_fd) ++static int mlx4_init_context(struct verbs_device *v_device, ++ struct ibv_context *ibv_ctx, int cmd_fd) + { + struct mlx4_context *context; + struct ibv_get_context cmd; +@@ -124,26 +125,28 @@ static struct ibv_context *mlx4_alloc_co + int i; + struct mlx4_alloc_ucontext_resp_v3 resp_v3; + __u16 bf_reg_size; +- struct mlx4_device *dev = to_mdev(ibdev); +- +- context = calloc(1, sizeof *context); +- if (!context) +- return NULL; +- +- context->ibv_ctx.cmd_fd = cmd_fd; ++ struct mlx4_device *dev = to_mdev(&v_device->device); ++ ++ struct verbs_context *verbs_ctx = verbs_get_ctx(ibv_ctx); ++ ++ /* memory footprint of mlx4_context and verbs_context share ++ * struct ibv_context. ++ */ ++ context = to_mctx(ibv_ctx); ++ ibv_ctx->cmd_fd = cmd_fd; + + if (dev->abi_version <= MLX4_UVERBS_NO_DEV_CAPS_ABI_VERSION) { +- if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof cmd, ++ if (ibv_cmd_get_context(ibv_ctx, &cmd, sizeof cmd, + &resp_v3.ibv_resp, sizeof resp_v3)) +- goto err_free; ++ return errno; + + context->num_qps = resp_v3.qp_tab_size; + bf_reg_size = resp_v3.bf_reg_size; + context->cqe_size = sizeof (struct mlx4_cqe); + } else { +- if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof cmd, ++ if (ibv_cmd_get_context(ibv_ctx, &cmd, sizeof cmd, + &resp.ibv_resp, sizeof resp)) +- goto err_free; ++ return errno; + + context->num_qps = resp.qp_tab_size; + bf_reg_size = resp.bf_reg_size; +@@ -165,15 +168,15 @@ static struct ibv_context *mlx4_alloc_co + + pthread_mutex_init(&context->db_list_mutex, NULL); + +- context->uar = mmap(NULL, to_mdev(ibdev)->page_size, PROT_WRITE, ++ context->uar = mmap(NULL, dev->page_size, PROT_WRITE, + MAP_SHARED, cmd_fd, 0); + if (context->uar == MAP_FAILED) +- goto err_free; ++ return errno; + + if (bf_reg_size) { +- context->bf_page = mmap(NULL, to_mdev(ibdev)->page_size, ++ context->bf_page = mmap(NULL, dev->page_size, + PROT_WRITE, MAP_SHARED, cmd_fd, +- to_mdev(ibdev)->page_size); ++ dev->page_size); + if (context->bf_page == MAP_FAILED) { + fprintf(stderr, PFX "Warning: BlueFlame available, " + "but failed to mmap() BlueFlame page.\n"); +@@ -190,32 +193,25 @@ static struct ibv_context *mlx4_alloc_co + } + + pthread_spin_init(&context->uar_lock, PTHREAD_PROCESS_PRIVATE); ++ ibv_ctx->ops = mlx4_ctx_ops; ++ /* New verbs should be added by using verbs_set_ctx_op */ + +- context->ibv_ctx.ops = mlx4_ctx_ops; ++ return 0; + +- return &context->ibv_ctx; +- +-err_free: +- free(context); +- return NULL; + } + +-static void mlx4_free_context(struct ibv_context *ibctx) ++static void mlx4_uninit_context(struct verbs_device *v_device, ++ struct ibv_context *ibv_ctx) + { +- struct mlx4_context *context = to_mctx(ibctx); ++ struct mlx4_context *context = to_mctx(ibv_ctx); + +- munmap(context->uar, to_mdev(ibctx->device)->page_size); ++ munmap(context->uar, to_mdev(&v_device->device)->page_size); + if (context->bf_page) +- munmap(context->bf_page, to_mdev(ibctx->device)->page_size); +- free(context); +-} ++ munmap(context->bf_page, to_mdev(&v_device->device)->page_size); + +-static struct ibv_device_ops mlx4_dev_ops = { +- .alloc_context = mlx4_alloc_context, +- .free_context = mlx4_free_context +-}; ++} + +-static struct ibv_device *mlx4_driver_init(const char *uverbs_sys_path, int abi_version) ++static struct verbs_device *mlx4_driver_init(const char *uverbs_sys_path, int abi_version) + { + char value[8]; + struct mlx4_device *dev; +@@ -250,21 +246,27 @@ found: + return NULL; + } + +- dev = malloc(sizeof *dev); ++ dev = calloc(1, sizeof *dev); + if (!dev) { + fprintf(stderr, PFX "Fatal: couldn't allocate device for %s\n", + uverbs_sys_path); + return NULL; + } + +- dev->ibv_dev.ops = mlx4_dev_ops; + dev->page_size = sysconf(_SC_PAGESIZE); + dev->abi_version = abi_version; + +- return &dev->ibv_dev; ++ dev->verbs_dev.sz = sizeof(*dev); ++ dev->verbs_dev.size_of_context = ++ sizeof(struct mlx4_context) - sizeof(struct ibv_context); ++ /* mlx4_init_context will initialize provider calls */ ++ dev->verbs_dev.init_context = mlx4_init_context; ++ dev->verbs_dev.uninit_context = mlx4_uninit_context; ++ ++ return &dev->verbs_dev; + } + + static __attribute__((constructor)) void mlx4_register_driver(void) + { +- ibv_register_driver("mlx4", mlx4_driver_init); ++ verbs_register_driver("mlx4", mlx4_driver_init); + } +--- libmlx4-1.0.5.orig/src/mlx4.h ++++ libmlx4-1.0.5/src/mlx4.h +@@ -127,7 +127,7 @@ enum { + }; + + struct mlx4_device { +- struct ibv_device ibv_dev; ++ struct verbs_device verbs_dev; + int page_size; + int abi_version; + }; +@@ -272,7 +272,10 @@ static inline unsigned long align(unsign + + static inline struct mlx4_device *to_mdev(struct ibv_device *ibdev) + { +- return to_mxxx(dev, device); ++ /* ibv_device is first field of verbs_device ++ * see try_driver() in libibverbs. ++ */ ++ return container_of(ibdev, struct mlx4_device, verbs_dev); + } + + static inline struct mlx4_context *to_mctx(struct ibv_context *ibctx)