From patchwork Fri Aug 6 22:50:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vu Pham X-Patchwork-Id: 118082 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 o76MsNeq027290 for ; Fri, 6 Aug 2010 22:54:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762152Ab0HFWyz (ORCPT ); Fri, 6 Aug 2010 18:54:55 -0400 Received: from p02c11o148.mxlogic.net ([208.65.144.81]:54215 "EHLO p02c11o148.mxlogic.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761950Ab0HFWyy (ORCPT ); Fri, 6 Aug 2010 18:54:54 -0400 Received: from unknown [63.251.237.3] (EHLO p02c11o148.mxlogic.net) by p02c11o148.mxlogic.net(mxl_mta-6.7.0-0) with ESMTP id eb29c5c4.2aaac5401940.188379.00-554.438941.p02c11o148.mxlogic.net (envelope-from ); Fri, 06 Aug 2010 16:54:54 -0600 (MDT) X-MXL-Hash: 4c5c92be1b257b85-7aee6d6e2b223fe4979eed8516715fe03e239a76 Received: from unknown [63.251.237.3] (EHLO mtiexch01.mti.com) by p02c11o148.mxlogic.net(mxl_mta-6.7.0-0) with ESMTP id 2c19c5c4.0.187975.00-285.438064.p02c11o148.mxlogic.net (envelope-from ); Fri, 06 Aug 2010 16:50:43 -0600 (MDT) X-MXL-Hash: 4c5c91c3168ce3b2-c15fa6446b00fd1dfcdb75e406a9e28ea3a23059 Received: from vu-lt.mti.mtl.com ([10.2.1.17]) by mtiexch01.mti.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 6 Aug 2010 15:54:58 -0700 Message-ID: <4C5C91C2.5040803@mellanox.com> Date: Fri, 06 Aug 2010 15:50:42 -0700 From: Vu Pham User-Agent: Thunderbird 2.0.0.23 (X11/20090812) MIME-Version: 1.0 To: Roland Dreier CC: Oren Duer , Linux RDMA , OpenFabrics EWG Subject: [PATCH 05/10] query ib device from given mlx4 device X-OriginalArrivalTime: 06 Aug 2010 22:54:58.0500 (UTC) FILETIME=[6501D840:01CB35BA] 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=pH2YMzzKHgsA:10 a=VphdPIyG4kEA:10 a=xupnbh4h0Y] X-AnalysisOut: [LOHZnncC45HQ==:17 a=SeBm4QpjAAAA:8 a=YUSCQ_kKhnjW_Pft-uwA:] X-AnalysisOut: [9 a=yobmO9oa0DHVnoHcfNDeI1FU_H4A:4 a=wPNLvfGTeEIA:10 a=T2c] X-AnalysisOut: [JKXzbRCYA:10 a=adx-UyD0YttY-a0jPEEA:9 a=fA0mRhgjWz1dQ5_Vpx] X-AnalysisOut: [IA:7 a=RktchzGTqxBgRWvxUVGqzIW_Tk0A:4] 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]); Fri, 06 Aug 2010 22:54:56 +0000 (UTC) Adding API to query ib_device with mlx4_dev Signed-off-by: Oren Duer Signed-off-by: Vu Pham drivers/infiniband/hw/mlx4/main.c | 10 +++++++++- drivers/net/mlx4/intf.c | 20 ++++++++++++++++++++ drivers/net/mlx4/main.c | 10 +++++++--- drivers/net/mlx4/mlx4.h | 1 + include/linux/mlx4/driver.h | 10 ++++++++++ 7 files changed, 72 insertions(+), 15 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/intf.c b/drivers/net/mlx4/intf.c index beeed80..f8f97f9 100644 --- a/drivers/net/mlx4/intf.c +++ b/drivers/net/mlx4/intf.c @@ -191,3 +191,23 @@ void mlx4_unregister_device(struct mlx4_dev *dev) mutex_unlock(&intf_mutex); } + +void *mlx4_find_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; +} diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c index 38fbf01..f14f0d6 100644 --- a/drivers/net/mlx4/main.c +++ b/drivers/net/mlx4/main.c @@ -105,6 +105,12 @@ static int log_mtts_per_seg = ilog2(MLX4_MTT_ENTRY_PER_SEG); module_param_named(log_mtts_per_seg, log_mtts_per_seg, int, 0444); MODULE_PARM_DESC(log_mtts_per_seg, "Log2 number of MTT entries per segment (1-5)"); +void *mlx4_get_prot_dev(struct mlx4_dev *dev, enum mlx4_prot proto, int port) +{ + return mlx4_find_get_prot_dev(dev, proto, port); +} +EXPORT_SYMBOL(mlx4_get_prot_dev); + int mlx4_check_port_params(struct mlx4_dev *dev, enum mlx4_port_type *port_type) { diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index 416aeca..9c62019 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h @@ -364,6 +364,7 @@ int mlx4_restart_one(struct pci_dev *pdev); int mlx4_register_device(struct mlx4_dev *dev); void mlx4_unregister_device(struct mlx4_dev *dev); void mlx4_dispatch_event(struct mlx4_dev *dev, enum mlx4_dev_event type, int port); +void *mlx4_find_get_prot_dev(struct mlx4_dev *dev, enum mlx4_prot proto, int port); struct mlx4_dev_cap; struct mlx4_init_hca_param; diff --git a/include/linux/mlx4/driver.h b/include/linux/mlx4/driver.h index 55b45a6..94c9617 100644 --- a/include/linux/mlx4/driver.h +++ b/include/linux/mlx4/driver.h @@ -49,17 +49,27 @@ enum mlx4_query_reply { MLX4_QUERY_MINE_NOPORT = 0 }; +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; + enum mlx4_query_reply (*query) (void *context, void *); 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 proto, int port); + struct mlx4_dev *mlx4_query_interface(void *, int *port); #endif /* MLX4_DRIVER_H */