From patchwork Wed Mar 1 14:02:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erez Shitrit X-Patchwork-Id: 9598429 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7181260453 for ; Wed, 1 Mar 2017 14:04:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EF852855D for ; Wed, 1 Mar 2017 14:04:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50D1628563; Wed, 1 Mar 2017 14:04:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6D202855D for ; Wed, 1 Mar 2017 14:04:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751527AbdCAOEx (ORCPT ); Wed, 1 Mar 2017 09:04:53 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:33508 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751474AbdCAOEf (ORCPT ); Wed, 1 Mar 2017 09:04:35 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from erezsh@mellanox.com) with ESMTPS (AES256-SHA encrypted); 1 Mar 2017 16:02:51 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v21E2kkP028329; Wed, 1 Mar 2017 16:02:51 +0200 From: Erez Shitrit To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, valex@mellanox.com, leonro@mellanox.com, Erez Shitrit Subject: [RFC for accelerated IPoIB 19/26] net/mlx5e: Export open/close api for IB link Date: Wed, 1 Mar 2017 16:02:27 +0200 Message-Id: <1488376954-8346-20-git-send-email-erezsh@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1488376954-8346-1-git-send-email-erezsh@mellanox.com> References: <1488376954-8346-1-git-send-email-erezsh@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now IB device is able to call open or close for its net device. TBD: There is one change that is waiting for the new channels api, till then used an "if" in the code. Signed-off-by: Erez Shitrit --- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 23 +++++++++++++++++++++-- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 13 ++++++++++++- include/linux/mlx5/driver.h | 3 +++ 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index 2f9242ae06f3..154cab2a301b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h @@ -934,4 +934,5 @@ int mlx5e_get_offload_stats(int attr_id, const struct net_device *dev, bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv); bool mlx5e_is_vf_vport_rep(struct mlx5e_priv *priv); +bool mlx5e_is_eswitch_vport_mngr(struct mlx5_core_dev *mdev); #endif /* __MLX5_EN_H__ */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 8e6d0b3cd835..2ca2de9d2578 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -2269,7 +2269,9 @@ int mlx5e_open_locked(struct mlx5e_priv *priv) } mlx5e_redirect_rqts(priv); - mlx5e_update_carrier(priv); + /* only for the RFC, will use channels api when available */ + if (MLX5_CAP_GEN(mdev, port_type) == MLX5_CAP_PORT_TYPE_ETH) + mlx5e_update_carrier(priv); mlx5e_timestamp_init(priv); #ifdef CONFIG_RFS_ACCEL priv->netdev->rx_cpu_rmap = priv->mdev->rmap; @@ -2277,7 +2279,7 @@ int mlx5e_open_locked(struct mlx5e_priv *priv) if (priv->profile->update_stats) queue_delayed_work(priv->wq, &priv->update_stats_work, 0); - if (MLX5_CAP_GEN(mdev, vport_group_manager)) { + if (mlx5e_is_eswitch_vport_mngr(mdev)) { err = mlx5e_add_sqs_fwd_rules(priv); if (err) goto err_close_channels; @@ -3900,6 +3902,7 @@ static void mlx5i_nic_init(struct mlx5_core_dev *mdev, struct mlx5e_priv *priv = netdev_priv(netdev) + base_size; mlx5n_build_nic_netdev_priv_common(mdev, netdev, priv, profile, ppriv); + priv->ppriv = NULL; } static int mlx5i_init_nic_rx(struct mlx5e_priv *priv) @@ -4026,6 +4029,22 @@ void mlx5i_detach(struct mlx5_core_dev *mdev, void *vpriv) } EXPORT_SYMBOL(mlx5i_detach); +int mlx5i_open(void *vpriv) +{ + struct mlx5e_priv *priv = vpriv; + + return mlx5e_open_locked(priv); +} +EXPORT_SYMBOL(mlx5i_open); + +int mlx5i_close(void *vpriv) +{ + struct mlx5e_priv *priv = vpriv; + + return mlx5e_close_locked(priv); +} +EXPORT_SYMBOL(mlx5i_close); + static const struct mlx5e_profile mlx5e_nic_profile = { .init = mlx5e_nic_init, .cleanup = mlx5e_nic_cleanup, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c index 21d3d8e0bab7..cbb1092dddd4 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c @@ -219,7 +219,12 @@ int mlx5e_nic_rep_load(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep) void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv) { struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; - struct mlx5_eswitch_rep *rep = priv->ppriv; + struct mlx5_eswitch_rep *rep; + + if (!priv->ppriv) + return; + + rep = priv->ppriv; mlx5_eswitch_sqs2vport_stop(esw, rep); } @@ -323,6 +328,12 @@ bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv) return false; } +bool mlx5e_is_eswitch_vport_mngr(struct mlx5_core_dev *mdev) +{ + return (MLX5_CAP_GEN(mdev, vport_group_manager) && + MLX5_CAP_GEN(mdev, port_type) == MLX5_CAP_PORT_TYPE_ETH); +} + bool mlx5e_is_vf_vport_rep(struct mlx5e_priv *priv) { struct mlx5_eswitch_rep *rep = (struct mlx5_eswitch_rep *)priv->ppriv; diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h index 0acf099e9d06..f7f4e301fbd2 100644 --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h @@ -1138,4 +1138,7 @@ struct net_device *mlx5i_create_netdev(struct mlx5_core_dev *mdev, struct mlx5i_create_ext_param *param); int mlx5i_attach(struct mlx5_core_dev *mdev, void *vpriv); void mlx5i_detach(struct mlx5_core_dev *mdev, void *vpriv); +int mlx5i_close(void *vpriv); +int mlx5i_open(void *vpriv); + #endif /* MLX5_DRIVER_H */