From owner-svn-src-all@freebsd.org Fri Sep 16 11:51:32 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DC17ABDDCB9; Fri, 16 Sep 2016 11:51:32 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 88E4AC9F; Fri, 16 Sep 2016 11:51:32 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u8GBpVL0099953; Fri, 16 Sep 2016 11:51:31 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u8GBpV02099952; Fri, 16 Sep 2016 11:51:31 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201609161151.u8GBpV02099952@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Fri, 16 Sep 2016 11:51:31 +0000 (UTC) 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 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Sep 2016 11:51:33 -0000 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