All of lore.kernel.org
 help / color / mirror / Atom feed
From: Erez Shitrit <erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
To: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	valex-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
	leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
	saedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
	erezsh-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org,
	Erez Shitrit <erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: [RFC v1 for accelerated IPoIB 13/25] net/mlx5e: Export resource creation function to be used in IB link
Date: Mon, 13 Mar 2017 20:31:24 +0200	[thread overview]
Message-ID: <1489429896-10781-14-git-send-email-erezsh@mellanox.com> (raw)
In-Reply-To: <1489429896-10781-1-git-send-email-erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>


mlx5i_attach that creates the resources of IB network device.
mlx5i_detach cleans resources for IB device.

Signed-off-by: Erez Shitrit <erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 122 +++++++++++++++-------
 1 file changed, 87 insertions(+), 35 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 87881f9ddf35..5b3c2e67607f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -3844,6 +3844,54 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)
 	mlx5_lag_remove(mdev);
 }
 
+static int mlx5n_attach_netdev_common(struct mlx5_core_dev *mdev,
+				      struct mlx5e_priv *priv)
+{
+	const struct mlx5e_profile *profile;
+	struct net_device *netdev;
+	int err;
+
+	netdev = priv->netdev;
+	profile = priv->profile;
+	clear_bit(MLX5E_STATE_DESTROYING, &priv->state);
+
+	err = profile->init_tx(priv);
+	if (err)
+		goto out;
+
+	err = mlx5e_open_drop_rq(priv);
+	if (err) {
+		mlx5_core_err(mdev, "open drop rq failed, %d\n", err);
+		goto err_cleanup_tx;
+	}
+
+	err = profile->init_rx(priv);
+	if (err)
+		goto err_close_drop_rq;
+
+	mlx5e_create_q_counter(priv);
+
+	if (profile->enable)
+		profile->enable(priv);
+
+	rtnl_lock();
+	if (netif_running(netdev))
+		mlx5e_open(netdev);
+	netif_device_attach(netdev);
+	rtnl_unlock();
+
+	return 0;
+
+err_close_drop_rq:
+	mlx5e_close_drop_rq(priv);
+
+err_cleanup_tx:
+	profile->cleanup_tx(priv);
+
+out:
+	return err;
+}
+
 static void mlx5i_nic_init(struct mlx5_core_dev *mdev,
 			   struct net_device *netdev,
 			   const struct mlx5e_profile *profile,
@@ -3942,6 +3990,42 @@ struct net_device *mlx5i_create_netdev(struct mlx5_core_dev *mdev,
 }
 EXPORT_SYMBOL(mlx5i_create_netdev);
 
+int mlx5i_attach(struct mlx5_core_dev *mdev, void *vpriv)
+{
+	struct mlx5e_priv *priv = vpriv;
+	struct net_device *netdev = priv->netdev;
+	int err;
+
+	if (netif_device_present(netdev))
+		return 0;
+
+	err = mlx5e_create_mdev_resources(mdev);
+	if (err)
+		return err;
+
+	err = mlx5n_attach_netdev_common(mdev, priv);
+	if (err) {
+		mlx5e_destroy_mdev_resources(mdev);
+		return err;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(mlx5i_attach);
+
+void mlx5i_detach(struct mlx5_core_dev *mdev, void *vpriv)
+{
+	struct mlx5e_priv *priv = vpriv;
+	struct net_device *netdev = priv->netdev;
+
+	if (!netif_device_present(netdev))
+		return;
+
+	mlx5e_detach_netdev(mdev, netdev);
+	mlx5e_destroy_mdev_resources(mdev);
+}
+EXPORT_SYMBOL(mlx5i_detach);
+
 static const struct mlx5e_profile mlx5e_nic_profile = {
 	.init		   = mlx5e_nic_init,
 	.cleanup	   = mlx5e_nic_cleanup,
@@ -3996,31 +4080,17 @@ struct net_device *mlx5e_create_netdev(struct mlx5_core_dev *mdev,
 
 int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, struct mlx5e_priv *priv)
 {
-	const struct mlx5e_profile *profile;
 	struct net_device *netdev;
 	u16 max_mtu;
 	int err;
 
 	netdev = priv->netdev;
-	profile = priv->profile;
-	clear_bit(MLX5E_STATE_DESTROYING, &priv->state);
-
-	err = profile->init_tx(priv);
-	if (err)
-		goto out;
 
-	err = mlx5e_open_drop_rq(priv);
+	err = mlx5n_attach_netdev_common(mdev, priv);
 	if (err) {
-		mlx5_core_err(mdev, "open drop rq failed, %d\n", err);
-		goto err_cleanup_tx;
+		mlx5_core_err(mdev, "failed attach netdev %d\n", err);
+		return err;
 	}
-
-	err = profile->init_rx(priv);
-	if (err)
-		goto err_close_drop_rq;
-
-	mlx5e_create_q_counter(priv);
-	//TBD do i need to change that?
 	mlx5e_init_l2_addr(priv);
 
 	/* MTU range: 68 - hw-specific max */
@@ -4030,25 +4100,7 @@ int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, struct mlx5e_priv *priv)
 
 	mlx5e_set_dev_port_mtu(netdev);
 
-	if (profile->enable)
-		profile->enable(priv);
-
-	rtnl_lock();
-	if (netif_running(netdev))
-		mlx5e_open(netdev);
-	netif_device_attach(netdev);
-	rtnl_unlock();
-
 	return 0;
-
-err_close_drop_rq:
-	mlx5e_close_drop_rq(priv);
-
-err_cleanup_tx:
-	profile->cleanup_tx(priv);
-
-out:
-	return err;
 }
 
 static void mlx5e_register_vport_rep(struct mlx5_core_dev *mdev)
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-03-13 18:31 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-13 18:31 [RFC v1 for accelerated IPoIB 00/25] Enhanced mode for IPoIB driver Erez Shitrit
2017-03-13 18:31 ` [RFC v1 for accelerated IPoIB 01/25] IB/ipoib: Separate control and data related initializations Erez Shitrit
2017-03-13 18:31 ` [RFC v1 for accelerated IPoIB 02/25] IB/ipoib: separate control from HW operation on ipoib_open/stop ndo Erez Shitrit
2017-03-13 18:31 ` [RFC v1 for accelerated IPoIB 03/25] IB/ipoib: Rename qpn to dqpn in ipoib_send and post_send functions Erez Shitrit
2017-03-13 18:31 ` [RFC v1 for accelerated IPoIB 04/25] IB/verb: Add ipoib_options struct and API Erez Shitrit
     [not found]   ` <1489429896-10781-5-git-send-email-erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-03-13 20:01     ` Jason Gunthorpe
2017-03-14  7:01       ` Vishwanathapura, Niranjana
2017-03-14 13:25         ` Erez Shitrit
2017-03-14 16:11         ` Jason Gunthorpe
     [not found]           ` <20170314161149.GA15752-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-03-15  6:30             ` Leon Romanovsky
2017-03-15  6:30               ` Leon Romanovsky
     [not found]               ` <20170315063043.GC2079-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-03-15 16:40                 ` Vishwanathapura, Niranjana
     [not found]                   ` <20170315164050.GA81782-wPcXA7LoDC+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-03-15 16:52                     ` Erez Shitrit
     [not found]       ` <20170313200136.GA2738-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-03-14 13:25         ` Erez Shitrit
     [not found]           ` <CAAk-MO8dZJKYgpWT8p1fz0O6y2wTx4jxoJhYf21ikMOef_xUMg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-14 19:03             ` Vishwanathapura, Niranjana
     [not found]               ` <20170314190300.GA80705-wPcXA7LoDC+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-03-15  6:27                 ` Leon Romanovsky
     [not found]                   ` <20170315062728.GB2079-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-03-15 16:42                     ` Vishwanathapura, Niranjana
2017-03-16 15:17       ` Erez Shitrit
2017-03-16 16:04         ` Jason Gunthorpe
2017-03-14  6:44     ` Vishwanathapura, Niranjana
2017-03-13 18:31 ` [RFC v1 for accelerated IPoIB 05/25] IB/ipoib: Support ipoib acceleration options callbacks Erez Shitrit
2017-03-13 20:10   ` Jason Gunthorpe
     [not found]     ` <20170313201049.GB2738-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-03-14 14:39       ` Erez Shitrit
     [not found]         ` <CAAk-MO8-bnWRu7BDtYDhNePj+76X4Vb7gFNhED8irLNtqR7tCw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-14 16:06           ` Jason Gunthorpe
     [not found]             ` <20170314160616.GE3244-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-03-15 16:27               ` Erez Shitrit
     [not found]                 ` <CAAk-MO96BbTnn=gzdZhRpQUENn=AVUJv1JhPbrSYrNHOrbFVeg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-15 16:46                   ` Jason Gunthorpe
     [not found]   ` <1489429896-10781-6-git-send-email-erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-03-14  6:35     ` Vishwanathapura, Niranjana
     [not found]       ` <20170314063538.GB79937-wPcXA7LoDC+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-03-14 14:42         ` Erez Shitrit
2017-03-14 16:00           ` Jason Gunthorpe
     [not found]             ` <20170314160021.GD3244-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-03-15  6:47               ` Leon Romanovsky
2017-03-15  6:47                 ` Leon Romanovsky
2017-03-15 15:58                 ` Jason Gunthorpe
     [not found]                   ` <20170315155802.GB29562-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-03-15 17:39                     ` Leon Romanovsky
2017-03-15 17:39                       ` Leon Romanovsky
2017-03-15 10:11               ` Erez Shitrit
2017-03-14 15:44       ` Jason Gunthorpe
2017-03-13 18:31 ` [RFC v1 for accelerated IPoIB 06/25] hw/mlx5: Add New bit to check over QP creation Erez Shitrit
2017-03-13 18:31 ` [RFC v1 for accelerated IPoIB 07/25] linux/mlx5/mlx5_ifc.h: Add underlay_qpn field to PRM objects Erez Shitrit
2017-03-13 18:31 ` [RFC v1 for accelerated IPoIB 08/25] net/mlx5e: Refactor EN code to support IB link Erez Shitrit
2017-03-13 18:31 ` [RFC v1 for accelerated IPoIB 10/25] net/mlx5e: Support netdevice creation for IB link type Erez Shitrit
2017-03-13 18:31 ` [RFC v1 for accelerated IPoIB 14/25] net/mlx5: Enable flow-steering for IB link Erez Shitrit
2017-03-15 18:56   ` Leon Romanovsky
2017-03-15 18:56     ` Leon Romanovsky
2017-03-13 18:31 ` [RFC v1 for accelerated IPoIB 15/25] net/mlx5e: Enhanced flow table creation to support ETH and IB links Erez Shitrit
2017-03-13 18:31 ` [RFC v1 for accelerated IPoIB 16/25] net/mlx5e: Change cleanup API in order to enable IB link Erez Shitrit
2017-03-13 18:31 ` [RFC v1 for accelerated IPoIB 21/25] net/mlx5e: Export send function for IB link type Erez Shitrit
     [not found] ` <1489429896-10781-1-git-send-email-erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-03-13 18:31   ` [RFC v1 for accelerated IPoIB 09/25] net/mlx5e: Creating and Destroying flow-steering tables for IB link Erez Shitrit
2017-03-13 18:31   ` [RFC v1 for accelerated IPoIB 11/25] net/mlx5e: Refactor attach_netdev API Erez Shitrit
2017-03-13 18:31   ` [RFC v1 for accelerated IPoIB 12/25] net/mlx5e: Use underlay_qpn in tis creation Erez Shitrit
2017-03-13 18:31   ` Erez Shitrit [this message]
2017-03-13 18:31   ` [RFC v1 for accelerated IPoIB 17/25] net/mlx5e: Change mlx5e_open_locked and mlx5e_close_locked api Erez Shitrit
2017-03-13 18:31   ` [RFC v1 for accelerated IPoIB 18/25] net/mlx5e: Export open/close api for IB link Erez Shitrit
2017-03-13 18:31   ` [RFC v1 for accelerated IPoIB 19/25] include/linux/mlx5: Add mlx5_wqe_eth_pad and enhanced-ipoib-qp-mode Erez Shitrit
2017-03-13 18:31   ` [RFC v1 for accelerated IPoIB 20/25] net/mlx5e: Refactor TX send flow Erez Shitrit
2017-03-13 18:31   ` [RFC v1 for accelerated IPoIB 22/25] net/mlx5e: New function pointer for build_rx_skb is Erez Shitrit
2017-03-13 18:31   ` [RFC v1 for accelerated IPoIB 23/25] net/mlx5e: Change the function that checks the packet type Erez Shitrit
2017-03-13 18:31 ` [RFC v1 for accelerated IPoIB 24/25] net/mlx5e: Add support for build_rx_skb for packet from IB type Erez Shitrit
2017-03-13 18:31 ` [RFC v1 for accelerated IPoIB 25/25] mlx5_ib: skeleton for mlx5_ib to support ipoib_ops Erez Shitrit
     [not found]   ` <1489429896-10781-26-git-send-email-erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-03-13 20:27     ` Jason Gunthorpe
     [not found]       ` <20170313202720.GC2738-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-03-14 14:53         ` Erez Shitrit
2017-03-14 16:10           ` Jason Gunthorpe
2017-03-14 16:37             ` Erez Shitrit
     [not found]             ` <20170314161013.GF3244-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-03-15  8:42               ` Erez Shitrit
2017-03-14  6:07   ` Vishwanathapura, Niranjana
     [not found]     ` <20170314060730.GA79937-wPcXA7LoDC+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-03-14 14:55       ` Erez Shitrit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1489429896-10781-14-git-send-email-erezsh@mellanox.com \
    --to=erezsh-vpraknaxozvwk0htik3j/w@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=erezsh-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org \
    --cc=leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=saedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=valex-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.