All of lore.kernel.org
 help / color / mirror / Atom feed
From: Erez Shitrit <erezsh@mellanox.com>
To: dledford@redhat.com
Cc: linux-rdma@vger.kernel.org, netdev@vger.kernel.org,
	valex@mellanox.com, leonro@mellanox.com, saedm@mellanox.com,
	erezsh@dev.mellanox.co.il, Erez Shitrit <erezsh@mellanox.com>
Subject: [RFC v1 for accelerated IPoIB 08/25] net/mlx5e: Refactor EN code to support IB link
Date: Mon, 13 Mar 2017 20:31:19 +0200	[thread overview]
Message-ID: <1489429896-10781-9-git-send-email-erezsh@mellanox.com> (raw)
In-Reply-To: <1489429896-10781-1-git-send-email-erezsh@mellanox.com>


The idea is to use the same infrastructures for both ETH and IB link
types, so the first step is to refactor the ETH handling to be able to
use IB link as well.

1. Check requirments for ETH and for IB
2. Move code to common functions, where it will be used for both link
types.
3. Change init and cleanup flows not to be specific for ETH link.

Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 120 ++++++++++++++--------
 1 file changed, 80 insertions(+), 40 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 041e0ac16096..88541f99d37b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -3323,29 +3323,39 @@ static void mlx5e_netpoll(struct net_device *dev)
 	.ndo_get_offload_stats	 = mlx5e_get_offload_stats,
 };
 
-static int mlx5e_check_required_hca_cap(struct mlx5_core_dev *mdev)
-{
-	if (MLX5_CAP_GEN(mdev, port_type) != MLX5_CAP_PORT_TYPE_ETH)
-		return -EOPNOTSUPP;
-	if (!MLX5_CAP_GEN(mdev, eth_net_offloads) ||
-	    !MLX5_CAP_GEN(mdev, nic_flow_table) ||
-	    !MLX5_CAP_ETH(mdev, csum_cap) ||
-	    !MLX5_CAP_ETH(mdev, max_lso_cap) ||
-	    !MLX5_CAP_ETH(mdev, vlan_cap) ||
-	    !MLX5_CAP_ETH(mdev, rss_ind_tbl_cap) ||
-	    MLX5_CAP_FLOWTABLE(mdev,
-			       flow_table_properties_nic_receive.max_ft_level)
-			       < 3) {
-		mlx5_core_warn(mdev,
-			       "Not creating net device, some required device capabilities are missing\n");
-		return -EOPNOTSUPP;
+static int mlx5e_check_required_hca_cap(struct mlx5_core_dev *mdev,
+					int link_type)
+{
+	if (link_type == MLX5_INTERFACE_PROTOCOL_ETH) {
+		if (!MLX5_CAP_GEN(mdev, eth_net_offloads) ||
+		    !MLX5_CAP_GEN(mdev, nic_flow_table) ||
+		    !MLX5_CAP_ETH(mdev, csum_cap) ||
+		    !MLX5_CAP_ETH(mdev, max_lso_cap) ||
+		    !MLX5_CAP_ETH(mdev, vlan_cap) ||
+		    !MLX5_CAP_ETH(mdev, rss_ind_tbl_cap) ||
+		    MLX5_CAP_FLOWTABLE(mdev,
+				       flow_table_properties_nic_receive.max_ft_level)
+				       < 3) {
+			mlx5_core_warn(mdev,
+				       "Not creating net device, some required device capabilities are missing\n");
+			return -ENOTSUPP;
+		}
+		if (!MLX5_CAP_ETH(mdev, self_lb_en_modifiable))
+			mlx5_core_warn(mdev, "Self loop back prevention is not supported\n");
+		if (!MLX5_CAP_GEN(mdev, cq_moderation))
+			mlx5_core_warn(mdev, "CQ modiration is not supported\n");
+
+		return 0;
+	} else if (link_type == MLX5_INTERFACE_PROTOCOL_IB) {
+		if (!MLX5_CAP_GEN(mdev, ipoib_enhanced_offloads)) {
+			pr_warn("Not creating net device (IB), some required device capabilities are missing\n");
+			return -ENOTSUPP;
+		}
+		return 0;
 	}
-	if (!MLX5_CAP_ETH(mdev, self_lb_en_modifiable))
-		mlx5_core_warn(mdev, "Self loop back prevention is not supported\n");
-	if (!MLX5_CAP_GEN(mdev, cq_moderation))
-		mlx5_core_warn(mdev, "CQ modiration is not supported\n");
 
-	return 0;
+	return -ENOTSUPP;
+
 }
 
 u16 mlx5e_get_max_inline_cap(struct mlx5_core_dev *mdev)
@@ -3455,12 +3465,12 @@ u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout)
 	return MLX5_CAP_ETH(mdev, lro_timer_supported_periods[i]);
 }
 
-static void mlx5e_build_nic_netdev_priv(struct mlx5_core_dev *mdev,
+void mlx5n_build_nic_netdev_priv_common(struct mlx5_core_dev *mdev,
 					struct net_device *netdev,
+					struct mlx5e_priv *priv,
 					const struct mlx5e_profile *profile,
 					void *ppriv)
 {
-	struct mlx5e_priv *priv = netdev_priv(netdev);
 	u32 link_speed = 0;
 	u32 pci_bw = 0;
 	u8 cq_period_mode = MLX5_CAP_GEN(mdev, cq_period_start_from_cqe) ?
@@ -3524,6 +3534,15 @@ static void mlx5e_build_nic_netdev_priv(struct mlx5_core_dev *mdev,
 	MLX5E_SET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS, priv->params.rx_cqe_compress_def);
 
 	mutex_init(&priv->state_lock);
+}
+
+static void mlx5e_build_nic_netdev_priv(struct mlx5_core_dev *mdev,
+					struct net_device *netdev,
+					struct mlx5e_priv *priv,
+					const struct mlx5e_profile *profile,
+					void *ppriv)
+{
+	mlx5n_build_nic_netdev_priv_common(mdev, netdev, priv, profile, ppriv);
 
 	INIT_WORK(&priv->update_carrier_work, mlx5e_update_carrier_work);
 	INIT_WORK(&priv->set_rx_mode_work, mlx5e_set_rx_mode_work);
@@ -3663,7 +3682,7 @@ static void mlx5e_nic_init(struct mlx5_core_dev *mdev,
 {
 	struct mlx5e_priv *priv = netdev_priv(netdev);
 
-	mlx5e_build_nic_netdev_priv(mdev, netdev, profile, ppriv);
+	mlx5e_build_nic_netdev_priv(mdev, netdev, priv, profile, ppriv);
 	mlx5e_build_nic_netdev(netdev);
 	mlx5e_vxlan_init(priv);
 }
@@ -3676,7 +3695,8 @@ static void mlx5e_nic_cleanup(struct mlx5e_priv *priv)
 		bpf_prog_put(priv->xdp_prog);
 }
 
-static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)
+/* used for ETH && IB link layer */
+static int mlx5n_init_nic_rx_common(struct mlx5e_priv *priv)
 {
 	struct mlx5_core_dev *mdev = priv->mdev;
 	int err;
@@ -3706,20 +3726,12 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)
 		goto err_destroy_indirect_tirs;
 	}
 
-	err = mlx5e_create_flow_steering(priv);
-	if (err) {
-		mlx5_core_warn(mdev, "create flow steering failed, %d\n", err);
-		goto err_destroy_direct_tirs;
-	}
-
 	err = mlx5e_tc_init(priv);
 	if (err)
-		goto err_destroy_flow_steering;
+		goto err_destroy_direct_tirs;
 
 	return 0;
 
-err_destroy_flow_steering:
-	mlx5e_destroy_flow_steering(priv);
 err_destroy_direct_tirs:
 	mlx5e_destroy_direct_tirs(priv);
 err_destroy_indirect_tirs:
@@ -3732,12 +3744,31 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)
 	return err;
 }
 
-static void mlx5e_cleanup_nic_rx(struct mlx5e_priv *priv)
+static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)
+{
+	struct mlx5_core_dev *mdev = priv->mdev;
+	int err;
+
+	err = mlx5n_init_nic_rx_common(priv);
+	if (err) {
+		mlx5_core_warn(mdev, "failed create nic rx res, %d\n", err);
+		return err;
+	}
+
+	err = mlx5e_create_flow_steering(priv);
+	if (err) {
+		mlx5_core_warn(mdev, "create flow steering failed, %d\n", err);
+		return err;
+	}
+
+	return 0;
+}
+
+static void mlx5n_cleanup_nic_rx_common(struct mlx5e_priv *priv)
 {
 	int i;
 
 	mlx5e_tc_cleanup(priv);
-	mlx5e_destroy_flow_steering(priv);
 	mlx5e_destroy_direct_tirs(priv);
 	mlx5e_destroy_indirect_tirs(priv);
 	for (i = 0; i < priv->profile->max_nch(priv->mdev); i++)
@@ -3745,6 +3776,12 @@ static void mlx5e_cleanup_nic_rx(struct mlx5e_priv *priv)
 	mlx5e_destroy_rqt(priv, &priv->indir_rqt);
 }
 
+static void mlx5e_cleanup_nic_rx(struct mlx5e_priv *priv)
+{
+	mlx5e_destroy_flow_steering(priv);
+	mlx5n_cleanup_nic_rx_common(priv);
+}
+
 static int mlx5e_init_nic_tx(struct mlx5e_priv *priv)
 {
 	int err;
@@ -3836,7 +3873,8 @@ struct net_device *mlx5e_create_netdev(struct mlx5_core_dev *mdev,
 		return NULL;
 	}
 
-	profile->init(mdev, netdev, profile, ppriv);
+	if (profile->init)
+		profile->init(mdev, netdev, profile, ppriv);
 
 	netif_carrier_off(netdev);
 
@@ -3849,7 +3887,9 @@ struct net_device *mlx5e_create_netdev(struct mlx5_core_dev *mdev,
 	return netdev;
 
 err_cleanup_nic:
-	profile->cleanup(priv);
+	if (profile->cleanup)
+		profile->cleanup(priv);
+
 	free_netdev(netdev);
 
 	return NULL;
@@ -3881,7 +3921,7 @@ int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev)
 		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 */
@@ -4006,7 +4046,7 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)
 	int err;
 	struct net_device *netdev;
 
-	err = mlx5e_check_required_hca_cap(mdev);
+	err = mlx5e_check_required_hca_cap(mdev, MLX5_INTERFACE_PROTOCOL_ETH);
 	if (err)
 		return NULL;
 
-- 
1.8.3.1

  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 ` Erez Shitrit [this message]
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   ` [RFC v1 for accelerated IPoIB 13/25] net/mlx5e: Export resource creation function to be used in IB link Erez Shitrit
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-9-git-send-email-erezsh@mellanox.com \
    --to=erezsh@mellanox.com \
    --cc=dledford@redhat.com \
    --cc=erezsh@dev.mellanox.co.il \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=saedm@mellanox.com \
    --cc=valex@mellanox.com \
    /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.