From patchwork Mon Aug 16 22:16:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vu Pham X-Patchwork-Id: 119816 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7GMOoIP011875 for ; Mon, 16 Aug 2010 22:25:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756646Ab0HPWZp (ORCPT ); Mon, 16 Aug 2010 18:25:45 -0400 Received: from p02c12o145.mxlogic.net ([208.65.145.78]:36456 "EHLO p02c12o145.mxlogic.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756515Ab0HPWZo (ORCPT ); Mon, 16 Aug 2010 18:25:44 -0400 Received: from unknown [63.251.237.3] (EHLO p02c12o145.mxlogic.net) by p02c12o145.mxlogic.net(mxl_mta-6.7.0-0) with ESMTP id 8eab96c4.6fa46940.24795.00-587.55466.p02c12o145.mxlogic.net (envelope-from ); Mon, 16 Aug 2010 16:25:44 -0600 (MDT) X-MXL-Hash: 4c69bae873c9bdff-8c30ef5e868ee0deb354506f818250a6121f9943 Received: from unknown [63.251.237.3] by p02c12o145.mxlogic.net(mxl_mta-6.7.0-0) with SMTP id fc8b96c4.0.23128.00-368.51870.p02c12o145.mxlogic.net (envelope-from ); Mon, 16 Aug 2010 16:16:53 -0600 (MDT) X-MXL-Hash: 4c69b8d535ac57db-e628ed090e05634fa97b9f16052ac5725d372673 Received: from vu-lt.mti.mtl.com ([10.2.1.17]) by mtiexch01.mti.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 16 Aug 2010 15:21:11 -0700 Message-ID: <4C69B8D0.5060608@mellanox.com> Date: Mon, 16 Aug 2010 15:16:48 -0700 From: Vu Pham User-Agent: Thunderbird 2.0.0.23 (X11/20090812) MIME-Version: 1.0 To: Roland Dreier CC: OpenFabrics EWG , Linux RDMA , Oren Duer Subject: [PATCH v1 08/10] mlx4: Add API to query protocol device of specific port on mlx4_device X-OriginalArrivalTime: 16 Aug 2010 22:21:11.0906 (UTC) FILETIME=[5531A420:01CB3D91] X-Spam: [F=0.2000000000; CM=0.500; S=0.200(2010073001)] X-MAIL-FROM: X-SOURCE-IP: [63.251.237.3] X-AnalysisOut: [v=1.0 c=1 a=Yg6yRx_Qq6oA:10 a=VphdPIyG4kEA:10 a=xupnbh4h0Y] X-AnalysisOut: [LOHZnncC45HQ==:17 a=37r9H06TAAAA:8 a=SeBm4QpjAAAA:8 a=adx-] X-AnalysisOut: [UyD0YttY-a0jPEEA:9 a=1t6AiCV6OFbiVLPv-dwA:7 a=k9iHNFBqMCTb] X-AnalysisOut: [bJxglczvzVlu_ikA:4 a=T2cJKXzbRCYA:10] 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.3 (demeter.kernel.org [140.211.167.41]); Mon, 16 Aug 2010 22:25:45 +0000 (UTC) From f29fe7ee6b8563eb362e22b8276e817e0337f048 Mon Sep 17 00:00:00 2001 From: Vu Pham Date: Mon, 16 Aug 2010 10:16:42 -0700 Subject: [PATCH 08/10] mlx4: Add API to query protocol device of specific port on mlx4_device Adding new fields in mlx4_interface to set the type of protocol (IB, EN,...) and interface to query the underline protocol device of a specific port on the mlx4_device provided Signed-off-by: Oren Duer Signed-off-by: Vu Pham --- drivers/infiniband/hw/mlx4/main.c | 10 +++++++++- drivers/net/mlx4/en_main.c | 9 +++++++++ drivers/net/mlx4/intf.c | 19 +++++++++++++++++++ include/linux/mlx4/driver.h | 9 +++++++++ 4 files changed, 46 insertions(+), 1 deletions(-) diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index 4e94e36..e071229 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -58,6 +58,12 @@ static const char mlx4_ib_version[] = DRV_NAME ": Mellanox ConnectX InfiniBand driver v" DRV_VERSION " (" DRV_RELDATE ")\n"; +static void *get_ibdev(struct mlx4_dev *dev, void *ctx, u8 port) +{ + struct mlx4_ib_dev *mlxibdev = ctx; + return &mlxibdev->ib_dev; +} + static void init_query_mad(struct ib_smp *mad) { mad->base_version = 1; @@ -749,7 +755,9 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr, static struct mlx4_interface mlx4_ib_interface = { .add = mlx4_ib_add, .remove = mlx4_ib_remove, - .event = mlx4_ib_event + .event = mlx4_ib_event, + .get_prot_dev = get_ibdev, + .protocol = MLX4_PROT_IB }; static int __init mlx4_ib_init(void) diff --git a/drivers/net/mlx4/en_main.c b/drivers/net/mlx4/en_main.c index 97934f1..03a4c3e 100644 --- a/drivers/net/mlx4/en_main.c +++ b/drivers/net/mlx4/en_main.c @@ -281,10 +281,19 @@ err_free_res: return NULL; } +static void *get_netdev(struct mlx4_dev *dev, void *ctx, u8 port) +{ + struct mlx4_en_dev *mdev = ctx; + + return (port <= MLX4_MAX_PORTS) ? mdev->pndev[port] : NULL; +} + static struct mlx4_interface mlx4_en_interface = { .add = mlx4_en_add, .remove = mlx4_en_remove, .event = mlx4_en_event, + .get_prot_dev = get_netdev, + .protocol = MLX4_PROT_EN }; static int __init mlx4_en_init(void) diff --git a/drivers/net/mlx4/intf.c b/drivers/net/mlx4/intf.c index 5550678..10e18e4 100644 --- a/drivers/net/mlx4/intf.c +++ b/drivers/net/mlx4/intf.c @@ -80,6 +80,25 @@ static void mlx4_remove_device(struct mlx4_interface *intf, struct mlx4_priv *pr } } +void *mlx4_get_prot_dev(struct mlx4_dev *dev, enum mlx4_prot proto, int port) +{ + struct mlx4_priv *priv = mlx4_priv(dev); + struct mlx4_device_context *dev_ctx; + unsigned long flags; + void *result = NULL; + + spin_lock_irqsave(&priv->ctx_lock, flags); + list_for_each_entry(dev_ctx, &priv->ctx_list, list) + if (dev_ctx->intf->protocol == proto && dev_ctx->intf->get_prot_dev) { + result = dev_ctx->intf->get_prot_dev(dev, dev_ctx->context, port); + break; + } + spin_unlock_irqrestore(&priv->ctx_lock, flags); + + return result; +} +EXPORT_SYMBOL_GPL(mlx4_get_prot_dev); + int mlx4_register_interface(struct mlx4_interface *intf) { struct mlx4_priv *priv; diff --git a/include/linux/mlx4/driver.h b/include/linux/mlx4/driver.h index 53c5fdb..370e90a 100644 --- a/include/linux/mlx4/driver.h +++ b/include/linux/mlx4/driver.h @@ -44,15 +44,24 @@ enum mlx4_dev_event { MLX4_DEV_EVENT_PORT_REINIT, }; +enum mlx4_prot { + MLX4_PROT_IB, + MLX4_PROT_EN, +}; + struct mlx4_interface { void * (*add) (struct mlx4_dev *dev); void (*remove)(struct mlx4_dev *dev, void *context); void (*event) (struct mlx4_dev *dev, void *context, enum mlx4_dev_event event, int port); + void * (*get_prot_dev) (struct mlx4_dev *dev, + void *context, u8 port); + enum mlx4_prot protocol; struct list_head list; }; int mlx4_register_interface(struct mlx4_interface *intf); void mlx4_unregister_interface(struct mlx4_interface *intf); +void *mlx4_get_prot_dev(struct mlx4_dev *dev, enum mlx4_prot protocol, int port); #endif /* MLX4_DRIVER_H */ -- 1.6.3.3