From patchwork Wed Mar 25 21:20:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Somnath Kotur X-Patchwork-Id: 6087981 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C071B9F820 for ; Wed, 25 Mar 2015 04:55:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C79B12017E for ; Wed, 25 Mar 2015 04:55:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B996C2035C for ; Wed, 25 Mar 2015 04:55:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752192AbbCYEzu (ORCPT ); Wed, 25 Mar 2015 00:55:50 -0400 Received: from cmexedge1.emulex.com ([138.239.224.99]:21271 "EHLO CMEXEDGE1.ext.emulex.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752135AbbCYEzu (ORCPT ); Wed, 25 Mar 2015 00:55:50 -0400 Received: from CMEXHTCAS2.ad.emulex.com (138.239.115.218) by CMEXEDGE1.ext.emulex.com (138.239.224.99) with Microsoft SMTP Server (TLS) id 14.3.210.2; Tue, 24 Mar 2015 21:55:57 -0700 Received: from codebrowse.emulex.com (10.192.207.129) by smtp.emulex.com (138.239.115.208) with Microsoft SMTP Server id 14.3.210.2; Tue, 24 Mar 2015 21:55:47 -0700 From: Somnath Kotur To: CC: , Moni Shoua , "Somnath Kotur" Subject: [PATCH v3 for-next 25/33] IB/mlx4: Implement ib_device callback - get_netdev Date: Thu, 26 Mar 2015 02:50:14 +0530 X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1427318422-12004-1-git-send-email-somnath.kotur@emulex.com> References: <1427318422-12004-1-git-send-email-somnath.kotur@emulex.com> MIME-Version: 1.0 Message-ID: <87913518-05db-4c2b-9cf9-587d5dae1517@CMEXHTCAS2.ad.emulex.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DATE_IN_FUTURE_12_24, RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Moni Shoua This is a new callback that is required for RoCEv2 support. In port aggregation mode it is required to return the netdev of the active port so support in mlx4 core driver to figure out that port identity is required. Signed-off-by: Moni Shoua Signed-off-by: Somnath Kotur --- drivers/infiniband/hw/mlx4/main.c | 29 +++++++++++++++++++++++++++++ drivers/net/ethernet/mellanox/mlx4/main.c | 18 ++++++++++++++++++ include/linux/mlx4/driver.h | 1 + 3 files changed, 48 insertions(+) diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index bf87a95..04e6603 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -47,6 +47,8 @@ #include #include +#include + #include #include #include @@ -1527,6 +1529,32 @@ unlock: mutex_unlock(&ibdev->qp1_proxy_lock[port - 1]); } +static struct net_device *mlx4_ib_get_netdev(struct ib_device *device, u8 port_num) +{ + struct mlx4_ib_dev *ibdev = to_mdev(device); + + if (mlx4_is_bonded(ibdev->dev)) { + struct net_device *dev; + struct net_device *upper = NULL; + + rcu_read_lock(); + + dev = mlx4_get_protocol_dev(ibdev->dev, MLX4_PROT_ETH, port_num); + if (dev) + upper = netdev_master_upper_dev_get_rcu(dev); + else + goto unlock; + if (upper) + dev = bond_option_active_slave_get_rcu(netdev_priv(upper)); +unlock: + rcu_read_unlock(); + + return dev; + } + + return mlx4_get_protocol_dev(ibdev->dev, MLX4_PROT_ETH, port_num); +} + static void mlx4_ib_scan_netdevs(struct mlx4_ib_dev *ibdev, struct net_device *dev, unsigned long event) @@ -1806,6 +1834,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev) ibdev->ib_dev.attach_mcast = mlx4_ib_mcg_attach; ibdev->ib_dev.detach_mcast = mlx4_ib_mcg_detach; ibdev->ib_dev.process_mad = mlx4_ib_process_mad; + ibdev->ib_dev.get_netdev = mlx4_ib_get_netdev; if (!mlx4_is_slave(ibdev->dev)) { ibdev->ib_dev.alloc_fmr = mlx4_ib_fmr_alloc; diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c index 29c60fd..3f469d3 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c @@ -1241,6 +1241,24 @@ int mlx4_port_map_set(struct mlx4_dev *dev, struct mlx4_port_map *v2p) } EXPORT_SYMBOL_GPL(mlx4_port_map_set); +int mlx4_port_map_get(struct mlx4_dev *dev, u8 vport, u8 *pport) +{ + struct mlx4_priv *priv = mlx4_priv(dev); + + if (!pport) + return -EINVAL; + *pport = 0; + + if (vport == 1) + *pport = priv->v2p.port1; + else if (vport == 2) + *pport = priv->v2p.port2; + if (!*pport) + return -EINVAL; + return 0; +} +EXPORT_SYMBOL_GPL(mlx4_port_map_get); + static int mlx4_load_fw(struct mlx4_dev *dev) { struct mlx4_priv *priv = mlx4_priv(dev); diff --git a/include/linux/mlx4/driver.h b/include/linux/mlx4/driver.h index 5a06d96..a992971 100644 --- a/include/linux/mlx4/driver.h +++ b/include/linux/mlx4/driver.h @@ -81,6 +81,7 @@ struct mlx4_port_map { }; int mlx4_port_map_set(struct mlx4_dev *dev, struct mlx4_port_map *v2p); +int mlx4_port_map_get(struct mlx4_dev *dev, u8 vport, u8 *pport); void *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum mlx4_protocol proto, int port);