@@ -3,7 +3,7 @@ AM_CFLAGS = -g -Wall -D_GNU_SOURCE
mlx4_version_script = @MLX4_VERSION_SCRIPT@
MLX4_SOURCES = src/buf.c src/cq.c src/dbrec.c src/mlx4.c src/qp.c \
- src/srq.c src/verbs.c
+ src/srq.c src/verbs.c src/mlx4-ext.c
if HAVE_IBV_DEVICE_LIBRARY_EXTENSION
lib_LTLIBRARIES = src/libmlx4.la
@@ -28,6 +28,9 @@ dnl Checks for libraries
AC_CHECK_LIB(ibverbs, ibv_get_device_list, [],
AC_MSG_ERROR([ibv_get_device_list() not found. libmlx4 requires libibverbs.]))
+AC_CHECK_LIB(ibverbs, ibv_register_driver_ext,
+ AC_DEFINE(HAVE_IBV_EXT, 1, [adding verbs extension support]))
+
dnl Checks for header files.
AC_CHECK_HEADER(infiniband/driver.h, [],
AC_MSG_ERROR([<infiniband/driver.h> not found. libmlx4 requires libibverbs.]))
new file mode 100644
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2011 Intel Corp., Inc. 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
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <pthread.h>
+#include <string.h>
+
+#include "mlx4.h"
+#include "mlx4-abi.h"
+#include "mlx4-ext.h"
+
+#ifdef HAVE_IBV_EXT
+
+int mlx4_have_ext_ops(struct ibv_device *device, const char *ext_name)
+{
+ if (!stricmp(ext_name, "ibv_xrc"))
+ return 0;
+
+ return ENOSYS;
+}
+
+void mlx4_device_config_ext(struct ibv_device *device)
+{
+ device->have_ext_ops = mlx4_have_ext_ops;
+ device->get_device_ext_ops = NULL;
+}
+
+static void *mlx4_get_ext_ops(struct ibv_context *context, const char *ext_name)
+{
+ return NULL;
+}
+
+void mlx4_context_config_ext(struct ibv_context *ibv_ctx)
+{
+ ibv_ctx->get_ext_ops = mlx4_get_ext_ops;
+}
+
+#endif /* HAVE_IBV_EXT */
new file mode 100644
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011 Intel Corp., Inc. 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
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef MLX4_EXT_H
+#define MLX4_EXT_H
+
+#include <infiniband/driver.h>
+#include <infiniband/verbs.h>
+
+#ifdef HAVE_IBV_EXT
+#define IBV_REGISTER_DRIVER_EXT ibv_register_driver_ext
+
+int mlx4_have_ext_ops(struct ibv_device *device, const char *ext_name);
+void mlx4_device_config_ext(struct ibv_device *device);
+void mlx4_context_config_ext(struct ibv_context *context);
+
+#else /* HAVE_IBV_EXT */
+#define IBV_REGISTER_DRIVER_EXT ibv_register_driver
+#define mlx4_device_config_ext(x)
+#define mlx4_context_config_ext(x)
+#endif
+
+#endif /* MLX4_EXT_H */
@@ -48,6 +48,7 @@
#include "mlx4.h"
#include "mlx4-abi.h"
+#include "mlx4-ext.h"
#ifndef PCI_VENDOR_ID_MELLANOX
#define PCI_VENDOR_ID_MELLANOX 0x15b3
@@ -155,6 +156,7 @@ static struct ibv_context *mlx4_alloc_context(struct ibv_device *ibdev, int cmd_
pthread_spin_init(&context->uar_lock, PTHREAD_PROCESS_PRIVATE);
context->ibv_ctx.ops = mlx4_ctx_ops;
+ mlx4_context_config_ext(&context->ibv_ctx);
return &context->ibv_ctx;
@@ -222,6 +224,7 @@ found:
}
dev->ibv_dev.ops = mlx4_dev_ops;
+ mlx4_device_config_ext(&dev->ibv_dev);
dev->page_size = sysconf(_SC_PAGESIZE);
return &dev->ibv_dev;
@@ -230,8 +233,9 @@ found:
#ifdef HAVE_IBV_REGISTER_DRIVER
static __attribute__((constructor)) void mlx4_register_driver(void)
{
- ibv_register_driver("mlx4", mlx4_driver_init);
+ IBV_REGISTER_DRIVER_EXT("mlx4", mlx4_driver_init);
}
+
#else
/*
* Export the old libsysfs sysfs_class_device-based driver entry point
Update the libmlx4 library to register extensions with libibverbs, if it supports extensions. By registering extension support, this indicates to ibverbs that extended data structures are available. Signed-off-by: Sean Hefty <sean.hefty@intel.com> --- Makefile.am | 2 +- configure.in | 3 ++ src/mlx4-ext.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/mlx4-ext.h | 52 +++++++++++++++++++++++++++++++++++++++ src/mlx4.c | 6 ++++- 5 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 src/mlx4-ext.c create mode 100644 src/mlx4-ext.h -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html