Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Sep 2016 08:24:41 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r306240 - stable/11/sys/dev/mlx5/mlx5_en
Message-ID:  <201609230824.u8N8OfEJ050100@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Fri Sep 23 08:24:41 2016
New Revision: 306240
URL: https://svnweb.freebsd.org/changeset/base/306240

Log:
  MFC r305874:
  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

Modified:
  stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==============================================================================
--- stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c	Fri Sep 23 08:23:57 2016	(r306239)
+++ stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c	Fri Sep 23 08:24:41 2016	(r306240)
@@ -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?201609230824.u8N8OfEJ050100>