Remove compatibility with libibverbs < 1.1.7

Since the changes to add verbs extensions / XRC support will break
compatibility with libibverbs < 1.1.8, take this chance to strip out all
the backwards compatibility code that won't make any sense once we do that.

Signed-off-by: Roland Dreier <roland@purestorage.com>
diff --git a/Makefile.am b/Makefile.am
index a7afb14..c398635 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,19 +5,12 @@
 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
diff --git a/configure.ac b/configure.ac
index e0169ea..d7cd4c2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,21 +45,20 @@
 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 <infiniband/verbs.h>],
                                                    [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 <<IBV_VERSION > $dummy.c
@@ -68,8 +67,9 @@
 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,
diff --git a/debian/control b/debian/control
index cf41750..75a3eef 100644
--- a/debian/control
+++ b/debian/control
@@ -1,7 +1,7 @@
 Source: libmlx4
 Priority: extra
 Maintainer: Roland Dreier <rbd@debian.org>
-Build-Depends: debhelper (>= 7.0.50~), dpkg-dev (>= 1.13.19), libibverbs-dev (>= 1.1.3)
+Build-Depends: debhelper (>= 7.0.50~), dpkg-dev (>= 1.13.19), libibverbs-dev (>= 1.1.7)
 Standards-Version: 3.9.2
 Section: libs
 Homepage: http://www.openfabrics.org/
@@ -9,7 +9,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)
 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 --git a/libmlx4.spec.in b/libmlx4.spec.in
index cb92ea1..22ecd8c 100644
--- a/libmlx4.spec.in
+++ b/libmlx4.spec.in
@@ -9,7 +9,7 @@
 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
diff --git a/src/buf.c b/src/buf.c
index a80bcb1..be4df3b 100644
--- a/src/buf.c
+++ b/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;
diff --git a/src/mlx4.c b/src/mlx4.c
index 4cef2b9..4120e5c 100644
--- a/src/mlx4.c
+++ b/src/mlx4.c
@@ -42,10 +42,6 @@
 #include <pthread.h>
 #include <string.h>
 
-#ifndef HAVE_IBV_REGISTER_DRIVER
-#include <sysfs/libsysfs.h>
-#endif
-
 #include "mlx4.h"
 #include "mlx4-abi.h"
 
@@ -268,25 +264,7 @@
 	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 */
diff --git a/src/mlx4.h b/src/mlx4.h
index be7a632..a4e9b32 100644
--- a/src/mlx4.h
+++ b/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
 };
diff --git a/src/verbs.c b/src/verbs.c
index 7c5ee53..0f52c61 100644
--- a/src/verbs.c
+++ b/src/verbs.c
@@ -112,24 +112,16 @@
 {
 	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 @@
 {
 	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 @@
 	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;