From owner-svn-src-all@freebsd.org  Thu Oct 13 22:43:51 2016
Return-Path: <owner-svn-src-all@freebsd.org>
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 3CED5C10B07;
 Thu, 13 Oct 2016 22:43:51 +0000 (UTC)
 (envelope-from bapt@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 17039EB5;
 Thu, 13 Oct 2016 22:43:51 +0000 (UTC)
 (envelope-from bapt@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DMhoXE064830;
 Thu, 13 Oct 2016 22:43:50 GMT (envelope-from bapt@FreeBSD.org)
Received: (from bapt@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DMhnVH064823;
 Thu, 13 Oct 2016 22:43:49 GMT (envelope-from bapt@FreeBSD.org)
Message-Id: <201610132243.u9DMhnVH064823@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: bapt set sender to
 bapt@FreeBSD.org using -f
From: Baptiste Daroussin <bapt@FreeBSD.org>
Date: Thu, 13 Oct 2016 22:43:49 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r307238 - in head/sys/boot: arm/uboot common mips/uboot
 powerpc/kboot powerpc/ofw powerpc/ps3 sparc64/loader
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 &quot;
 user&quot; and &quot; projects&quot; \)" <svn-src-all.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-all>,
 <mailto:svn-src-all-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-all/>
List-Post: <mailto:svn-src-all@freebsd.org>
List-Help: <mailto:svn-src-all-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-all>,
 <mailto:svn-src-all-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Thu, 13 Oct 2016 22:43:51 -0000

Author: bapt
Date: Thu Oct 13 22:43:49 2016
New Revision: 307238
URL: https://svnweb.freebsd.org/changeset/base/307238

Log:
  Stop closing the network device when netbooting for loaders using the common
  dev_net.c code.
  
  The NETIF_OPEN_CLOSE_ONCE flag was added in r201932 to prevent that behaviour
  on some architectures (sparc64 and powerpc64) the default was left to always
  open and close the device for each open and close of a file by the loader
  because it was necessary for u-boot on arm.
  
  Since it has been added, the flag was turned on for every arches including the
  u-boot loader for arm.
  
  This also fixes netbooting on RPi3 (tested by gonzo@)
  
  For the loader.efi it greatly speeds up netbooting
  
  Reviewed by:	emaste, gonzo, tsoome
  Approved by:	gonzo
  MFC after:	1 month
  Sponsored by:	Gandi.net
  Differential Revision:	https://reviews.freebsd.org/D8230

Modified:
  head/sys/boot/arm/uboot/Makefile
  head/sys/boot/common/dev_net.c
  head/sys/boot/mips/uboot/Makefile
  head/sys/boot/powerpc/kboot/Makefile
  head/sys/boot/powerpc/ofw/Makefile
  head/sys/boot/powerpc/ps3/Makefile
  head/sys/boot/sparc64/loader/Makefile

Modified: head/sys/boot/arm/uboot/Makefile
==============================================================================
--- head/sys/boot/arm/uboot/Makefile	Thu Oct 13 21:35:48 2016	(r307237)
+++ head/sys/boot/arm/uboot/Makefile	Thu Oct 13 22:43:49 2016	(r307238)
@@ -77,8 +77,6 @@ LIBUBOOT_FDT=	${.OBJDIR}/../../uboot/fdt
 LIBFDT=		${.OBJDIR}/../../fdt/libfdt.a
 .endif
 
-CFLAGS+=	-DNETIF_OPEN_CLOSE_ONCE
-
 .if ${MK_FORTH} != "no"
 # Enable BootForth
 BOOT_FORTH=	yes

Modified: head/sys/boot/common/dev_net.c
==============================================================================
--- head/sys/boot/common/dev_net.c	Thu Oct 13 21:35:48 2016	(r307237)
+++ head/sys/boot/common/dev_net.c	Thu Oct 13 22:43:49 2016	(r307238)
@@ -120,11 +120,9 @@ net_open(struct open_file *f, ...)
 	devname = va_arg(args, char*);
 	va_end(args);
 
-#ifdef	NETIF_OPEN_CLOSE_ONCE
 	/* Before opening another interface, close the previous one first. */
 	if (netdev_sock >= 0 && strcmp(devname, netdev_name) != 0)
 		net_cleanup();
-#endif
 
 	/* On first open, do netif open, mount, etc. */
 	if (netdev_opens == 0) {
@@ -198,21 +196,6 @@ net_close(struct open_file *f)
 
 	f->f_devdata = NULL;
 
-#ifndef	NETIF_OPEN_CLOSE_ONCE
-	/* Extra close call? */
-	if (netdev_opens <= 0)
-		return (0);
-	netdev_opens--;
-	/* Not last close? */
-	if (netdev_opens > 0)
-		return (0);
-	/* On last close, do netif close, etc. */
-#ifdef	NETIF_DEBUG
-	if (debug)
-		printf("net_close: calling net_cleanup()\n");
-#endif
-	net_cleanup();
-#endif
 	return (0);
 }
 

Modified: head/sys/boot/mips/uboot/Makefile
==============================================================================
--- head/sys/boot/mips/uboot/Makefile	Thu Oct 13 21:35:48 2016	(r307237)
+++ head/sys/boot/mips/uboot/Makefile	Thu Oct 13 22:43:49 2016	(r307238)
@@ -81,8 +81,6 @@ LIBUBOOT_FDT=	${.OBJDIR}/../../uboot/fdt
 LIBFDT=		${.OBJDIR}/../../fdt/libfdt.a
 .endif
 
-CFLAGS+=	-DNETIF_OPEN_CLOSE_ONCE
-
 .if ${MK_FORTH} != "no"
 # Enable BootForth
 BOOT_FORTH=	yes

Modified: head/sys/boot/powerpc/kboot/Makefile
==============================================================================
--- head/sys/boot/powerpc/kboot/Makefile	Thu Oct 13 21:35:48 2016	(r307237)
+++ head/sys/boot/powerpc/kboot/Makefile	Thu Oct 13 22:43:49 2016	(r307238)
@@ -68,10 +68,7 @@ CFLAGS+=	-DBOOT_FORTH -I${.CURDIR}/../..
 LIBFICL=	${.OBJDIR}/../../ficl/libficl.a
 .endif
 
-# Avoid the open-close-dance for every file access as some firmwares perform
-# an auto-negotiation on every open of the network interface and thus causes
-# netbooting to take horribly long.
-CFLAGS+=	-DNETIF_OPEN_CLOSE_ONCE -mcpu=powerpc64
+CFLAGS+=	-mcpu=powerpc64
 
 # Always add MI sources
 .PATH:		${.CURDIR}/../../common ${.CURDIR}/../../../libkern

Modified: head/sys/boot/powerpc/ofw/Makefile
==============================================================================
--- head/sys/boot/powerpc/ofw/Makefile	Thu Oct 13 21:35:48 2016	(r307237)
+++ head/sys/boot/powerpc/ofw/Makefile	Thu Oct 13 22:43:49 2016	(r307238)
@@ -67,11 +67,6 @@ CFLAGS+=	-DBOOT_FORTH -I${.CURDIR}/../..
 LIBFICL=	${.OBJDIR}/../../ficl/libficl.a
 .endif
 
-# Avoid the open-close-dance for every file access as some firmwares perform
-# an auto-negotiation on every open of the network interface and thus causes
-# netbooting to take horribly long.
-CFLAGS+=	-DNETIF_OPEN_CLOSE_ONCE
-
 # Always add MI sources
 .PATH:		${.CURDIR}/../../common ${.CURDIR}/../../../libkern
 .include	"${.CURDIR}/../../common/Makefile.inc"

Modified: head/sys/boot/powerpc/ps3/Makefile
==============================================================================
--- head/sys/boot/powerpc/ps3/Makefile	Thu Oct 13 21:35:48 2016	(r307237)
+++ head/sys/boot/powerpc/ps3/Makefile	Thu Oct 13 22:43:49 2016	(r307238)
@@ -68,10 +68,7 @@ CFLAGS+=	-DBOOT_FORTH -I${.CURDIR}/../..
 LIBFICL=	${.OBJDIR}/../../ficl/libficl.a
 .endif
 
-# Avoid the open-close-dance for every file access as some firmwares perform
-# an auto-negotiation on every open of the network interface and thus causes
-# netbooting to take horribly long.
-CFLAGS+=	-DNETIF_OPEN_CLOSE_ONCE -mcpu=powerpc64
+CFLAGS+=	-mcpu=powerpc64
 
 # Always add MI sources
 .PATH:		${.CURDIR}/../../common ${.CURDIR}/../../../libkern

Modified: head/sys/boot/sparc64/loader/Makefile
==============================================================================
--- head/sys/boot/sparc64/loader/Makefile	Thu Oct 13 21:35:48 2016	(r307237)
+++ head/sys/boot/sparc64/loader/Makefile	Thu Oct 13 22:43:49 2016	(r307238)
@@ -69,10 +69,6 @@ LIBFICL=	${.OBJDIR}/../../ficl/libficl.a
 .include	"${.CURDIR}/../../common/Makefile.inc"
 CFLAGS+=	-I${.CURDIR}/../../common
 CFLAGS+=	-I.
-# Avoid the open-close-dance for every file access as some firmwares perform
-# an auto-negotiation on every open of the network interface and thus causes
-# netbooting to take horribly long.
-CFLAGS+=	-DNETIF_OPEN_CLOSE_ONCE
 
 CLEANFILES+=	vers.c loader.help