Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Sep 2016 11:51:31 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r305874 - head/sys/dev/mlx5/mlx5_en
Message-ID:  <201609161151.u8GBpV02099952@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Fri Sep 16 11:51:31 2016
New Revision: 305874
URL: https://svnweb.freebsd.org/changeset/base/305874

Log:
  mlx5en: Allow setting the software MTU size below 1500 bytes
  
  The hardware MTU size can't be set to a value less than 1500 bytes due
  to side-band management support. Allow setting the software MTU size
  below 1500 bytes, thus creating a mismatch between hardware and
  software MTU sizes.
  
  Sponsored by:	Mellanox Technologies
  MFC after:	1 week

Modified:
  head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c

Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==============================================================================
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c	Fri Sep 16 11:47:16 2016	(r305873)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c	Fri Sep 16 11:51:31 2016	(r305874)
@@ -2173,7 +2173,6 @@ mlx5e_set_dev_port_mtu(struct ifnet *ifp
 	int hw_mtu;
 	int err;
 
-
 	err = mlx5_set_port_mtu(mdev, MLX5E_SW2HW_MTU(sw_mtu));
 	if (err) {
 		if_printf(ifp, "%s: mlx5_set_port_mtu failed setting %d, err=%d\n",
@@ -2181,19 +2180,20 @@ mlx5e_set_dev_port_mtu(struct ifnet *ifp
 		return (err);
 	}
 	err = mlx5_query_port_oper_mtu(mdev, &hw_mtu);
-	if (!err) {
-		ifp->if_mtu = MLX5E_HW2SW_MTU(hw_mtu);
-
-		if (ifp->if_mtu != sw_mtu) {
-			if_printf(ifp, "Port MTU %d is different than "
-			    "ifp mtu %d\n", sw_mtu, (int)ifp->if_mtu);
-		}
-	} else {
+	if (err) {
 		if_printf(ifp, "Query port MTU, after setting new "
 		    "MTU value, failed\n");
-		ifp->if_mtu = sw_mtu;
+	} else if (MLX5E_HW2SW_MTU(hw_mtu) < sw_mtu) {
+		err = -E2BIG,
+		if_printf(ifp, "Port MTU %d is smaller than "
+                    "ifp mtu %d\n", hw_mtu, sw_mtu);
+	} else if (MLX5E_HW2SW_MTU(hw_mtu) > sw_mtu) {
+		err = -EINVAL;
+                if_printf(ifp, "Port MTU %d is bigger than "
+                    "ifp mtu %d\n", hw_mtu, sw_mtu);
 	}
-	return (0);
+	ifp->if_mtu = sw_mtu;
+	return (err);
 }
 
 int



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201609161151.u8GBpV02099952>