From patchwork Fri Aug 19 03:34:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hefty, Sean" X-Patchwork-Id: 1078682 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7J3R3Kh013083 for ; Fri, 19 Aug 2011 03:34:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751509Ab1HSDeU (ORCPT ); Thu, 18 Aug 2011 23:34:20 -0400 Received: from mga14.intel.com ([143.182.124.37]:12586 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751148Ab1HSDeT convert rfc822-to-8bit (ORCPT ); Thu, 18 Aug 2011 23:34:19 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 18 Aug 2011 20:34:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.68,249,1312182000"; d="scan'208";a="40098141" Received: from azsmsx603.amr.corp.intel.com ([10.2.161.23]) by azsmga001.ch.intel.com with ESMTP; 18 Aug 2011 20:34:18 -0700 Received: from azsmsx604.amr.corp.intel.com (10.2.161.34) by azsmsx603.amr.corp.intel.com (10.2.161.23) with Microsoft SMTP Server (TLS) id 8.2.255.0; Thu, 18 Aug 2011 20:34:18 -0700 Received: from fmsmsx105.amr.corp.intel.com (10.19.9.36) by azsmsx604.amr.corp.intel.com (10.2.161.34) with Microsoft SMTP Server (TLS) id 8.2.255.0; Thu, 18 Aug 2011 20:34:18 -0700 Received: from fmsmsx151.amr.corp.intel.com ([169.254.6.155]) by FMSMSX105.amr.corp.intel.com ([169.254.5.97]) with mapi id 14.01.0323.003; Thu, 18 Aug 2011 20:34:17 -0700 From: "Hefty, Sean" To: "linux-rdma (linux-rdma@vger.kernel.org)" Subject: [PATCH 1/2] libmlx4: Add support for verbs extensions Thread-Topic: [PATCH 1/2] libmlx4: Add support for verbs extensions Thread-Index: AcxeINpB1JYT8Z/GQB6nMxk+LIsm7g== Date: Fri, 19 Aug 2011 03:34:16 +0000 Message-ID: <1828884A29C6694DAF28B7E6B8A8237316E41C01@FMSMSX151.amr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.22.254.140] MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 19 Aug 2011 03:34:21 +0000 (UTC) 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 --- 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 diff --git a/Makefile.am b/Makefile.am index a7afb14..0d1087c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/configure.in b/configure.in index d7fb436..2ed1cfa 100644 --- a/configure.in +++ b/configure.in @@ -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([ not found. libmlx4 requires libibverbs.])) diff --git a/src/mlx4-ext.c b/src/mlx4-ext.c new file mode 100644 index 0000000..cfa7586 --- /dev/null +++ b/src/mlx4-ext.c @@ -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 +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +#include +#include +#include + +#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 */ diff --git a/src/mlx4-ext.h b/src/mlx4-ext.h new file mode 100644 index 0000000..a91d6ba --- /dev/null +++ b/src/mlx4-ext.h @@ -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 +#include + +#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 */ diff --git a/src/mlx4.c b/src/mlx4.c index 1295c53..2a091a1 100644 --- a/src/mlx4.c +++ b/src/mlx4.c @@ -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