From patchwork Wed Jun 15 17:06:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hefty, Sean" X-Patchwork-Id: 882732 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5FH6oKC007593 for ; Wed, 15 Jun 2011 17:06:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751893Ab1FORGt (ORCPT ); Wed, 15 Jun 2011 13:06:49 -0400 Received: from mga11.intel.com ([192.55.52.93]:5158 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751555Ab1FORGt convert rfc822-to-8bit (ORCPT ); Wed, 15 Jun 2011 13:06:49 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 15 Jun 2011 10:06:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.65,370,1304319600"; d="scan'208";a="16619017" Received: from orsmsx602.amr.corp.intel.com ([10.22.226.211]) by fmsmga002.fm.intel.com with ESMTP; 15 Jun 2011 10:06:48 -0700 Received: from orsmsx104.amr.corp.intel.com (10.22.225.131) by orsmsx602.amr.corp.intel.com (10.22.226.211) with Microsoft SMTP Server (TLS) id 8.2.255.0; Wed, 15 Jun 2011 10:06:48 -0700 Received: from orsmsx101.amr.corp.intel.com ([169.254.8.26]) by ORSMSX104.amr.corp.intel.com ([169.254.3.236]) with mapi id 14.01.0289.001; Wed, 15 Jun 2011 10:06:48 -0700 From: "Hefty, Sean" To: "linux-rdma (linux-rdma@vger.kernel.org)" CC: "Hefty, Sean" Subject: [PATCH 1/2] libmlx4: Add support for verbs extensions Thread-Topic: [PATCH 1/2] libmlx4: Add support for verbs extensions Thread-Index: AcwrfposMIm7a826TduK3AUdUovo8A== Date: Wed, 15 Jun 2011 17:06:47 +0000 Message-ID: <1828884A29C6694DAF28B7E6B8A82373021260@ORSMSX101.amr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.9.131.214] 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 (demeter1.kernel.org [140.211.167.41]); Wed, 15 Jun 2011 17:06:50 +0000 (UTC) Update the libmlx4 library to register extensions with libibverbs, if it supports extensions. Signed-off-by: Sean Hefty --- configure.in | 3 ++ src/mlx4-ext.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/mlx4-ext.h | 52 ++++++++++++++++++++++++++++++++++++++++++ src/mlx4.c | 6 ++++- 4 files changed, 130 insertions(+), 1 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/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..7734720 --- /dev/null +++ b/src/mlx4-ext.c @@ -0,0 +1,70 @@ +/* + * 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" + +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; +} 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