netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarod Wilson <jarod@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Jarod Wilson <jarod@redhat.com>,
	netdev@vger.kernel.org, Tariq Toukan <tariqt@mellanox.com>,
	Saeed Mahameed <saeedm@mellanox.com>
Subject: [PATCH net-next 05/15] ethernet/mellanox: use core min/max MTU checking
Date: Mon, 17 Oct 2016 15:54:07 -0400	[thread overview]
Message-ID: <20161017195417.48259-6-jarod@redhat.com> (raw)
In-Reply-To: <20161017195417.48259-1-jarod@redhat.com>

mlx4: min_mtu 46, max_mtu depends on hardware

mlx5: min_mtu 68, max_mtu depends on hardware

CC: netdev@vger.kernel.org
CC: Tariq Toukan <tariqt@mellanox.com>
CC: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c    |  8 ++++----
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 24 ++++++-----------------
 2 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 7e703be..bf35ac4 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -2205,10 +2205,6 @@ static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu)
 	en_dbg(DRV, priv, "Change MTU called - current:%d new:%d\n",
 		 dev->mtu, new_mtu);
 
-	if ((new_mtu < MLX4_EN_MIN_MTU) || (new_mtu > priv->max_mtu)) {
-		en_err(priv, "Bad MTU size:%d.\n", new_mtu);
-		return -EPERM;
-	}
 	if (priv->xdp_ring_num && MLX4_EN_EFF_MTU(new_mtu) > FRAG_SZ0) {
 		en_err(priv, "MTU size:%d requires frags but XDP running\n",
 		       new_mtu);
@@ -3288,6 +3284,10 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
 		dev->gso_partial_features = NETIF_F_GSO_UDP_TUNNEL_CSUM;
 	}
 
+	/* MTU range: 46 - hw-specific max */
+	dev->min_mtu = MLX4_EN_MIN_MTU;
+	dev->max_mtu = priv->max_mtu;
+
 	mdev->pndev[port] = dev;
 	mdev->upper[port] = NULL;
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 7eaf380..03183eb 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -2851,31 +2851,13 @@ static int mlx5e_set_features(struct net_device *netdev,
 	return err ? -EINVAL : 0;
 }
 
-#define MXL5_HW_MIN_MTU 64
-#define MXL5E_MIN_MTU (MXL5_HW_MIN_MTU + ETH_FCS_LEN)
-
 static int mlx5e_change_mtu(struct net_device *netdev, int new_mtu)
 {
 	struct mlx5e_priv *priv = netdev_priv(netdev);
-	struct mlx5_core_dev *mdev = priv->mdev;
 	bool was_opened;
-	u16 max_mtu;
-	u16 min_mtu;
 	int err = 0;
 	bool reset;
 
-	mlx5_query_port_max_mtu(mdev, &max_mtu, 1);
-
-	max_mtu = MLX5E_HW2SW_MTU(max_mtu);
-	min_mtu = MLX5E_HW2SW_MTU(MXL5E_MIN_MTU);
-
-	if (new_mtu > max_mtu || new_mtu < min_mtu) {
-		netdev_err(netdev,
-			   "%s: Bad MTU (%d), valid range is: [%d..%d]\n",
-			   __func__, new_mtu, min_mtu, max_mtu);
-		return -EINVAL;
-	}
-
 	mutex_lock(&priv->state_lock);
 
 	reset = !priv->params.lro_en &&
@@ -3835,6 +3817,7 @@ int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev)
 {
 	const struct mlx5e_profile *profile;
 	struct mlx5e_priv *priv;
+	u16 max_mtu;
 	int err;
 
 	priv = netdev_priv(netdev);
@@ -3865,6 +3848,11 @@ int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev)
 
 	mlx5e_init_l2_addr(priv);
 
+	/* MTU range: 68 - hw-specific max */
+	netdev->min_mtu = ETH_MIN_MTU;
+	mlx5_query_port_max_mtu(priv->mdev, &max_mtu, 1);
+	netdev->max_mtu = MLX5E_HW2SW_MTU(max_mtu);
+
 	mlx5e_set_dev_port_mtu(netdev);
 
 	if (profile->enable)
-- 
2.10.0

  parent reply	other threads:[~2016-10-17 19:54 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-17 19:54 [PATCH net-next 00/15] ethernet: use core min/max MTU checking Jarod Wilson
2016-10-17 19:54 ` [PATCH net-next 01/15] ethernet/atheros: " Jarod Wilson
2016-10-17 19:54 ` [PATCH net-next 02/15] ethernet/broadcom: " Jarod Wilson
2016-10-17 19:54 ` [PATCH net-next 03/15] ethernet/intel: " Jarod Wilson
2016-10-17 20:20   ` Jakub Kicinski
2016-10-17 19:54 ` [PATCH net-next 04/15] ethernet/marvell: " Jarod Wilson
2016-10-17 19:54 ` Jarod Wilson [this message]
2016-10-17 19:54 ` [PATCH net-next 06/15] ethernet/qlogic: " Jarod Wilson
2016-10-17 19:54 ` [PATCH net-next 07/15] ethernet/realtek: " Jarod Wilson
2016-10-17 19:54 ` [PATCH net-next 08/15] ethernet/sun: " Jarod Wilson
2016-10-17 19:54 ` [PATCH net-next 09/15] ethernet/dlink: " Jarod Wilson
2016-10-18 13:45   ` Denis Kirjanov
2016-10-18 15:04     ` Jarod Wilson
2016-10-22  9:54       ` Stefan Richter
2016-10-17 19:54 ` [PATCH net-next 10/15] ethernet/neterion: " Jarod Wilson
2016-10-17 19:54 ` [PATCH net-next 11/15] ethernet/cavium: " Jarod Wilson
2016-10-17 19:54 ` [PATCH net-next 12/15] ethernet/ibm: " Jarod Wilson
2016-10-17 19:54 ` [PATCH net-next 13/15] ethernet/tile: " Jarod Wilson
2016-10-17 19:54 ` [PATCH net-next 14/15] ethernet/toshiba: " Jarod Wilson
2016-10-17 19:54 ` [PATCH net-next 15/15] ethernet: " Jarod Wilson
2016-10-17 20:03 ` [PATCH net-next 00/15] " David Miller
2016-10-17 20:29   ` Jarod Wilson
2016-10-18 15:33     ` David Miller
2016-10-18 22:28       ` Jarod Wilson
2016-10-19  2:35         ` Jarod Wilson
2016-10-18 15:34 ` David Miller

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=20161017195417.48259-6-jarod@redhat.com \
    --to=jarod@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@mellanox.com \
    --cc=tariqt@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).