Author: hselasky
Date: Fri Sep 23 08:33:47 2016
New Revision: 306251
URL: https://svnweb.freebsd.org/changeset/base/306251

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/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==============================================================================
--- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c       Fri Sep 23 08:33:03 
2016        (r306250)
+++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c       Fri Sep 23 08:33:47 
2016        (r306251)
@@ -2179,7 +2179,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",
@@ -2187,19 +2186,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
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to